Skip to content

Exchange

Mike edited this page Jan 9, 2019 · 3 revisions

DEX methods

deposit ETH

deposit ETH to the exchange.

Sending funds to the contract, funds are recorded for the sender of the transaction

 function() public payable

withdraw

withdrawal ETH from the exchange

withdraw(
    uint amount)                // amount for withdrawal

depositToken

deposit tokens to the exchange (for ERC20)

depositToken(
    address token,              // address of the token to enter the exchange 
    uint amount)                // amount of tokens to enter the exchange          

tokenFallback

deposit tokens to the exchange (for ERC223)

tokenFallback(
    address owner,              // owner token 
    uint256 amount,             // amount of tokens to enter the exchange 
    bytes data)                 // payload          

withdrawToken

withdrawal tokens from the exchange

withdrawToken(
    address token,              // address of tokens for withdrawal from the exchange 
    uint amount)                // amount of tokens for withdrawal from the exchange          

balanceOf

current balance of tokens on the exchange(address for ETH 0x0000000000000000000000000000000000000000)

balanceOf(
    address token,              // address of tokens
    address user)               // address user

trade

the function allows you to make an exchange, checking all balances and additional parameters

trade(
    address tokenBuy,              // address of the token you want to buy
    uint amountBuy,                // amount of the token you want to buy
    address tokenSell,             // address of the token you want to sell
    uint amountSell,               // amount of the token you want to sell
    uint expires,                  // the lifetime of the order to which the order is considered valid
    uint nonce,                    // a number that you can include in your order to make it relatively unique
    address user,                  // address of the user who made the order
    uint8 v,                       // recovery
    bytes32 r,                     // the normal output of an ECDSA signature
    bytes32 s,                     // the normal output of an ECDSA signature
    uint amount                    // amount is in tokenBuy terms
)

order

placing an order using a smart contract

order(
    address tokenBuy,              // address of the token you want to buy
    uint amountBuy,                // amount of the token you want to buy
    address tokenSell,             // address of the token you want to sell
    uint amountSell,               // amount of the token you want to sell
    uint expires,                  // the lifetime of the order to which the order is considered valid
    uint nonce                     // a number that you can include in your order to make it relatively unique
)

cancelOrder

cancel an order using a smart contract

cancelOrder(
    address tokenBuy,              // address of the token you want to buy
    uint amountBuy,                // amount of the token you want to buy
    address tokenSell,             // address of the token you want to sell
    uint amountSell,               // amount of the token you want to sell
    uint expires,                  // the lifetime of the order to which the order is considered valid
    uint nonce                     // a number that you can include in your order to make it relatively unique
    uint8 v,                       // recovery
    bytes32 r,                     // the normal output of an ECDSA signature
    bytes32 s,                     // the normal output of an ECDSA signature
)
Clone this wiki locally