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.
getSpotPricein terms of other tokens. However, disabling
isSwapPublicwill 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
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.
balancemust be a valid balance and
denormmust be a valid denormalized weight.
bindcreates the token record and then calls
rebindfor updating pool weights and token transfers.
ERR_NOT_CONTROLLER-- caller is not the controller
Tis already bound
ERC20token 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.
_publicSwapRequires 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.
setPublicSwapwill all throw
ERR_IS_FINALIZEDafter pool is finalized. This also switches
This syncs the internal
tokenwithin a pool with the actual
balanceregistered on the ERC20 contract. This is useful to account for airdropped tokens or any tokens sent to the pool without using the
Caller must be controller. Pool must NOT be finalized.
isFinalized() -> (bool)
finalizedstate lets users know that the weights, balances, and fees of this pool are immutable. In the
CONTROLcapabilities are disabled.
returns (uint tokenAmountOut, uint spotPriceAfter)
Trades an exact
tokenIntaken from the caller by the pool, in exchange for at least
tokenOutgiven to the caller from the pool, with a maximum marginal price of
(tokenAmountOut, spotPriceAfter), where
tokenAmountOutis the amount of token that came out of the pool, and
spotPriceAfteris the new marginal spot price, ie, the result of
getSpotPriceafter the call. (These values are what are limited by the arguments; you are guaranteed
tokenAmountOut >= minAmountOutand
spotPriceAfter <= maxPrice).
returns (uint tokenAmountIn, uint spotPriceAfter)
joinPool(uint poolAmountOut, uint calldata maxAmountsIn)
Join the pool, getting
poolAmountOutpool tokens. This will pull some of each of the currently trading tokens in the pool, meaning you must have called
approvefor each token for this pool. These values are limited by the array of
maxAmountsInin the order of the pool tokens.
If the balances you are adding are 10% of the current pool balances, then you should set
poolAmountOutas 10% of the current
poolSupply. Bear in mind that the proportions of the different underlying token balances might change until your transaction gets mined: therefore you should have a buffer to avoid the transaction being reverted. We usually suggest 1% if you use high gas prices for fast confirmation. So calculate
poolAmountOutas described above with 99% of the
exitPool(uint poolAmountIn, uint calldata minAmountsOut)
Exit the pool, paying
poolAmountInpool tokens and getting some of each of the currently trading tokens in return. These values are limited by the array of
minAmountsOutin the order of the pool tokens.
minAmountsOut, consider the percentage of the pool liquidity you are withdrawing, which is
poolAmountIn/poolSupplyand multiply that percentage by each of the underlying pool token balances. If you expect to receive say 10 units of each of the underlying tokens in the pool, consider setting
minAmountsOutas 9.9 to allow for variations in the balances proportions that may happen before your transaction gets mined.
joinswapExternAmountIn(address tokenIn, uint tokenAmountIn, uint minPoolAmountOut) -> (uint poolAmountOut)
tokenInto join the pool, getting
poolAmountOutof the pool shares.
exitswapExternAmountOut(address tokenOut, uint tokenAmountOut, uint maxPoolAmountIn) -> (uint poolAmountIn)
tokenOutthat you want to get out of the pool. This costs
poolAmountInpool shares (these went into the pool).
joinswapPoolAmountOut(address tokenIn, uint poolAmountOut, uint maxAmountIn) -> (uint tokenAmountIn)
poolAmountOutpool shares that you want to get, and a token
tokenInto pay with. This costs
tokenAmountIntokens (these went into the pool).
exitswapPoolAmountIn(address tokenOut, uint poolAmountIn, uint minAmountOut) -> (uint tokenAmountOut)
poolAmountInpool shares into the pool, getting
tokenAmountOutof the given token
tokenOutout of the pool.