Swapping is fairly straight-forward. Pass in the first token, amount to trade, and second token.
// swap tokens and send outbound token to sender
function swap( address firstToken, uint amount, address secondToken ) external;
LP
There are two options for adding liquidity. You can add with a single token or all tokens.
// add token to pool as liquidity. returns number of pool tokens minted.
function add( address token, uint amount ) external returns ( uint amount_ );
// add liquidity evenly across all tokens. returns number of pool tokens minted.
function addAll( uint amount ) external returns ( uint amount_ );
Removing liquidity is the opposite.
// remove token from liquidity, burning pool token
// pass in amount token to remove, returns amount_ pool tokens burned
function remove( address token, uint amount ) external returns (uint amount_);
// remove liquidity evenly across all tokens
// pass in amount tokens to remove, returns amount_ pool tokens burned
function removeAll( uint amount ) public returns (uint amount_);
View Functions
Fees accrue to LPs with a rising redemption value per pool token.
// fee on trading volume (9 decimals)
function fee() public view returns (uint);
// number of tokens 1 pool token can be redeemed for
function redemptionValue() public view returns (uint value_);
// token value => pool token value
function value( uint amount ) public view returns ( uint );
Maximum amount of token that can be added, removed, or swapped (from one to another).
// maximum number of token that can be added to pool
function maxCanAdd( address token ) public view returns ( uint );
// maximum number of token that can be removed from pool
function maxCanRemove( address token ) public view returns ( uint );
The amount the can be swapped, and the returned amount from a swap.
// maximum size of trade from first token to second token
function maxCanSwap( address firstToken, address secondToken ) public view returns ( uint );
// amount of secondToken returned by swap
function amountOut( address firstToken, uint amount, address secondToken ) external view returns ( uint );
Ownable Functions
The owner can add tokens, change bounds, change the pool fee, and pause deposits of an asset.
// add new token to pool
// must call toggleAccept to activate token
function addToken( address token, uint lowAP, uint highAP ) external onlyOwner();
// change bounds of tokens in pool
function changeBound( address token, uint newLow, uint newHigh ) external onlyOwner();
// toggle whether to accept incoming token
// setting token to false will not allow swaps as incoming token or adds
function toggleAccept( address token ) external onlyOwner();
// set fee taken on trades and fee collector
function setFee( uint newFee, address collector, address collectToken ) external onlyOwner();