Source code for Ethereum Smart Contracts used by the dYdX Margin Trading Protocol
Short & Leveraged Long Tokens Whitepaper
npm install
npm run compile
npm test
Lint the javascript files (tests, deploy scripts)
npm run lint
Lint the solidity files (all smart contracts)
npm run solint
Lint the solidity files (custom dYdX linter)
npm run dydxlint
Contains business logic for margin trading. All external functions for margin trading are in this contract.
Used to transfer user funds. Users set token allowance for the proxy authorizing it to transfer their funds. Only allows authorized contracts to transfer funds.
Holds all token funds. Is authorized to transfer user funds via the Proxy. Allows authorized contracts to withdraw funds.
Allows positions to be opened or closed using 0x orders. Wraps the 0x Exchange Contract in a standard interface usable by Margin.
Allows short positions to be tokenized as ERC20 tokens. Ownership of a short token grants ownership of a proportional piece of the backing position.
Allows leveraged long positions to be tokenized as ERC20 tokens. Ownership of a leveraged long token grants ownership of a proportional piece of the backing position.
Allows margin positions to be represented as ERC721 tokens.
Allows loans to be represented as ERC721 tokens.
Allows margin positions to be automatically close via a dutch auction.
Allows multiple lenders to share in a loan position together.
Read more about our smart contract architecture here