Feeder Pools

Feeder Pools are 50/50 AMMs, usually consisting of one mAsset and another mAsset-like asset. Feeder Pools are an extension of the mStable ecosystem and allow for more assets to swap and mint.

Main Contracts

Peripheral Contracts

Feeder Pool tokens follow the ERC20 standard. The non-standard decreaseAllowance and increaseAllowance functions have been added to mitigate the well-known issues around setting allowances. These are based on the OpenZeppelin ERC20 implementation.

ERC-20 Functions

totalSupply()

function totalSupply () external returns (uint256)

Returns the amount of tokens in existence.

balanceOf()

function balanceOf () external returns (uint256)

Returns the amount of tokens owned by account.

transfer()

function transfer () external returns (bool)

Moves amount tokens from the caller's account to recipient.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.

allowance()

function allowance () external returns (uint256)

Returns the remaining number of tokens thatspenderwill be allowed to spend on behalf ofownerthrough {transferFrom}. This is zero by default.

This value changes when {approve} or {transferFrom} are called.

approve()

function approve () external returns (bool)

Sets amount as the allowance of spender over the caller's tokens.

Returns a boolean value indicating whether the operation succeeded.

IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

Emits an {Approval} event.

transferFrom()

function transferFrom () external returns (bool)

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.

increaseAllowance()

function increaseAllowance () public returns (bool)

Atomically increases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

decreaseAllowance()

function decreaseAllowance () public returns (bool)

Atomically decreases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

  • spender must have allowance for the caller of at least

    subtractedValue.

Feeder Pool Functions

mint()

function mint (address _input, uint256 _inputQuantity, uint256 _minOutputQuantity, address _recipient) external returns (uint256 mintOutput)

Mint fpTokens with a single bAsset. This contract must have approval to spend the senders bAsset. Supports either fAsset, mAsset or mpAsset as input - with mpAssets used to mint mAsset before depositing.

mintMulti()

function mintMulti (address[] _inputs, uint256[] _inputQuantities, uint256 _minOutputQuantity, address _recipient) external returns (uint256 mintOutput)

Mint fpTokens with multiple bAssets. This contract must have approval to spend the senders bAssets. Supports only fAsset or mAsset as inputs.

getMintOutput()

function getMintOutput (address _input, uint256 _inputQuantity) external returns (uint256 mintOutput)

Get the projected output of a given mint.

getMintMultiOutput()

function getMintMultiOutput (address[] _inputs, uint256[] _inputQuantities) external returns (uint256 mintOutput)

Get the projected output of a given mint

swap()

function swap (address _input, address _output, uint256 _inputQuantity, uint256 _minOutputQuantity, address _recipient) external returns (uint256 swapOutput)

Swaps two assets - either internally between fAsset<>mAsset, or between fAsset<>mpAsset by first routing through the mAsset pool.

getSwapOutput()

function getSwapOutput (address _input, address _output, uint256 _inputQuantity) external returns (uint256 swapOutput)

Determines both if a trade is valid, and the expected fee or output. Swap is valid if it does not result in the input asset exceeding its maximum weight.

redeem()

function redeem (address _output, uint256 _fpTokenQuantity, uint256 _minOutputQuantity, address _recipient) external returns (uint256 outputQuantity)

Burns a specified quantity of the senders fpToken in return for a bAsset. The output amount is derived from the invariant. Supports redemption into either the fAsset, mAsset or assets in the mAsset basket.

redeemProportionately()

function redeemProportionately (uint256 _inputQuantity, uint256[] _minOutputQuantities, address _recipient) external returns (uint256[] outputQuantities)

Credits a recipient with a proportionate amount of bAssets, relative to current vault balance levels and desired fpToken quantity. Burns the fpToken as payment. Only fAsset & mAsset are supported in this path.

redeemExactBassets()

function redeemExactBassets (address[] _outputs, uint256[] _outputQuantities, uint256 _maxInputQuantity, address _recipient) external returns (uint256 fpTokenQuantity)

Credits a recipient with a certain quantity of selected bAssets, in exchange for burning the relative fpToken quantity from the sender. Only fAsset & mAsset (0,1) are supported in this path.

getRedeemOutput()

function getRedeemOutput (address _output, uint256 _fpTokenQuantity) external returns (uint256 bAssetOutput)

Gets the estimated output from a given redeem

getRedeemExactBassetsOutput()

function getRedeemExactBassetsOutput (address[] _outputs, uint256[] _outputQuantities) external returns (uint256 fpTokenQuantity)

Gets the estimated output from a given redeem

getPrice()

function getPrice () public returns (uint256 price, uint256 k)

Gets the price of the fpToken, and invariant value k

getConfig()

function getConfig () external returns (struct FeederConfig config)

Gets all config needed for general InvariantValidator calls

getBasset()

function getBasset (address _bAsset) external returns (struct BassetPersonal personal, struct BassetData vaultData)

Get data for a specific bAsset, if it exists

getBassets()

function getBassets () external returns (struct BassetPersonal[], struct BassetData[] vaultData)

Get data for a all bAssets in basket

Last updated