isBound(address T) -> (bool)
A bound token has a valid balance and weight. A token cannot be bound without valid parameters which will enable e.g.
getSpotPrice in terms of other tokens. However, disabling
isSwapPublic will disable any interaction with this token in practice (assuming there are no existing tokens in the pool, which can always
getNumTokens() -> (uint)
How many tokens are bound to this pool.
getNormalizedWeight(address token) -> (uint)
The normalized weight of a token. The combined normalized weights of all tokens will sum up to 1. (Note: the actual sum may be 1 plus or minus a few wei due to division precision loss)
getController() -> (address)
Get the "controller" address, which can call
CONTROL functions like
bind(address token, uint balance, uint denorm)
Binds the token with address
token. Tokens will be pushed/pulled from caller to adjust match new balance. Token must not already be bound.
balance must be a valid balance and
denorm must be a valid denormalized weight.
bind creates the token record and then calls
rebind for updating pool weights and token transfers.
ERR_NOT_CONTROLLER -- caller is not the controller
T is already bound
isFinalized() is true
ERC20 token returned false
ERR_MAX_TOKENS -- Only 8 tokens are allowed per pool
unspecified error thrown by token
rebind(address token, uint balance, uint denorm)
Changes the parameters of an already-bound token. Performs the same validation on the parameters.
Unbinds a token, clearing all of its parameters. Exit fee is charged and the remaining balance is sent to caller.
_publicSwap Requires caller to be controller and pool not to be finalized. Finalized pools always have public swap.
This makes the pool finalized. This is a one-way transition.
setPublicSwap will all throw
ERR_IS_FINALIZED after pool is finalized. This also switches
isSwapPublic to true.
Caller must be controller. Pool must NOT be finalized.
isFinalized() -> (bool)
finalized state lets users know that the weights, balances, and fees of this pool are immutable. In the
EXIT are public.
CONTROL capabilities are disabled.
swapExactAmountIn(address tokenIn,uint tokenAmountIn,address tokenOut,uint minAmountOut,uint maxPrice)returns (uint tokenAmountOut, uint spotPriceAfter)
Trades an exact
tokenIn taken from the caller by the pool, in exchange for at least
tokenOut given to the caller from the pool, with a maximum marginal price of
(tokenAmountOut, spotPriceAfter), where
tokenAmountOut is the amount of token that came out of the pool, and
spotPriceAfter is the new marginal spot price, ie, the result of
getSpotPrice after the call. (These values are what are limited by the arguments; you are guaranteed
tokenAmountOut >= minAmountOut and
spotPriceAfter <= maxPrice).
swapExactAmountOut(address tokenIn,uint maxAmountIn,address tokenOut,uint minAmountOut,uint maxPrice)returns (uint tokenAmountIn, uint spotPriceAfter)
joinPool(uint poolAmountOut, uint calldata maxAmountsIn)
Join the pool, getting
poolAmountOut pool tokens. This will pull some of each of the currently trading tokens in the pool, meaning you must have called
approve for each token for this pool. These values are limited by the array of
maxAmountsIn in the order of the pool tokens.
exitPool(uint poolAmountIn, uint calldata minAmountsOut)
Exit the pool, paying
poolAmountIn pool tokens and getting some of each of the currently trading tokens in return. These values are limited by the array of
minAmountsOut in the order of the pool tokens.
joinswapExternAmountIn(address tokenIn, uint tokenAmountIn, uint minPoolAmountOut) -> (uint poolAmountOut)
tokenAmountIn of token
tokenIn to join the pool, getting
poolAmountOut of the pool shares.
exitswapExternAmountOut(address tokenOut, uint tokenAmountOut, uint maxPoolAmountIn) -> (uint poolAmountIn)
tokenAmountOut of token
tokenOut that you want to get out of the pool. This costs
poolAmountIn pool shares (these went into the pool).
joinswapPoolAmountOut(address tokenIn, uint poolAmountOut, uint maxAmountIn) -> (uint tokenAmountIn)
poolAmountOut pool shares that you want to get, and a token
tokenIn to pay with. This costs
tokenAmountIn tokens (these went into the pool).
exitswapPoolAmountIn(address tokenOut, uint poolAmountIn, uint minAmountOut) -> (uint tokenAmountOut)
poolAmountIn pool shares into the pool, getting
tokenAmountOut of the given token
tokenOut out of the pool.