Socket
Book a DemoInstallSign in
Socket

dai-plugin-maker-otc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dai-plugin-maker-otc

A dai.js plugin for interacting with the maker OTC contract

0.1.1
latest
npmnpm
Version published
Maintainers
1
Created
Source

dai-plugin-maker-otc

A dai.js plugin for interacting with the maker OTC contract

First, install:

$ yarn add @makerdao/dai-plugin-maker-otc

Then add it to your configuration:

import Maker from '@makerdao/dai';
import MakerOtc from '@makerdao/dai-plugin-eth2dai-direct';

async function createMakerInstance(amount) {
  const maker = await Maker.create('browser', {
    plugins: [MakerOtc]
  });
  await maker.authenticate();
  await maker.service('exchange').sell('ETH', 'DAI', amount);
}

Usage

const exchange = maker.service('exchange');
  • sellDai

Sell a set amount of DAI and receive another token in return.

Parameters

  • daiAmount - Amount of DAI to sell.
  • tokenSymbol - Token to receive in return.
  • minFillAmount - Minimum amount to receive in return.

Returns: promise (resolves to OasisOrder once mined)

// Sell 100.00 DAI for 0.30 WETH or more.
const sellOrder = await exchange.sellDai('100.0', 'WETH', '0.30');
  • buyDai

Buy a set amount of DAI and give another token in return.

  • Parameters

    • daiAmount - Amount of DAI to buy.
    • tokenSymbol - Token to give in return.
    • minFillAmount - Maximum amount to give in return.
  • Returns: promise (resolves to OasisOrder once mined)

// Buy 100.00 DAI for 0.30 WETH or less.
const buyOrder = await exchange.buyDai('100.0', 'WETH', '0.35');
  • OasisOrder

OasisOrders have a few methods: fillAmount: amount of token received in exchange fees(): amount of ether spent on gas created(): timestamp of when transaction was mined

const buyOrder = await exchange.buyDai('100.0', 'WETH', '0.35');
const fillAmount = buyOrder.fillAmount();
const gasPaid = buyOrder.fees();
const created = buyOrder.created();

FAQs

Package last updated on 27 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.