0.9.14 • Published 5 years ago

@dydxprotocol/dydx.js v0.9.14

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

A TypeScript library for interacting with the dYdX protocol.

Usage

Install

npm install --save @dydxprotocol/dydx.js

Initialize

import { DYDX } from '@dydxprotocol/dydx.js';

const dydx = new DYDX();
await dydx.initialize(provider, networkId);

Short & Leveraged Tokens

Mint

await dydx.shortToken.mint(
  positionId,
  trader,
  tokensToMint,
  payInHeldToken,
  exchangeWrapper,
  orderData,
  options,
);

Or mint with ETH:

await dydx.shortToken.mintWithETH(
  positionId,
  trader,
  tokensToMint,
  ethToSend,
  ethIsHeldToken,
  exchangeWrapper,
  orderData,
  options,
);

Or mint directly (you will put up all held token DAI for sETH and will receive owed token WETH for sETH):

// Set your allowance on our proxy contract - you only need to do this once
await dydx.token.setMaximumProxyAllowance(
  heldTokenAddress, // DAI address for sETH
  traderAddress, // your address
);

await dydx.shortToken.mintDirectly(
  positionId, // Can get from expo API
  trader, // your address
  tokensToMint, // BigNumber - Number of tokens to mint in base units (10^18 is 1 sETH)
);

Close

Close directly (you will pay all owed token owed to lenders WETH for sETH and will receive all held token collateral DAI for sETH)

// Set your allowance on our proxy contract - you only need to do this once
await dydx.token.setMaximumProxyAllowance(
  owedTokenAddress, // WETH address for sETH
  traderAddress, // your address
);

await dydx.shortToken.closeDirectly(
  positionId, // Can get from expo API
  closer, // your address
  tokensToClose, // BigNumber - Number of tokens to close in base units (10^18 is 1 sETH)
);

Development

Install

npm install

Compile

npm run build
0.9.14

5 years ago

0.9.13

5 years ago

0.9.12

5 years ago

0.9.11

5 years ago

0.9.10

5 years ago

0.9.9

5 years ago

0.9.8

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.11

5 years ago

0.8.10

6 years ago

0.8.9

6 years ago

0.8.8

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.4

6 years ago

0.8.3

6 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.9

6 years ago

0.4.8

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.18

6 years ago

0.3.17

6 years ago

0.3.16

6 years ago

0.3.15

6 years ago

0.3.14

6 years ago

0.3.13

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.14

6 years ago

0.2.13

6 years ago

0.2.12

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.25

6 years ago

0.1.24

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago