CronV1Actions
ASSET_IN
ASSET_OUT
FIVE_MIN_IN_SEC
ZERO_PCT_BP
TEN_PCT_BP
MAX_BP
Cron-Fi specific periphery relayer functionality for performing Time Weighted Average Market Maker (TWAMM) pool actions on a pool with some safety and convenience checks.
The periphery relayer is composed of two contracts: - CronV1Relayer contract, which acts as the point of entry into the system through convenience functions and a multicall function. - This library contract that defines the behaviors and checks allowed by the periphery relayer.
There are unchecked operations (this code targets Solidity 0.7.x which didn't yet feature implicit arithmetic checks or have the 'unchecked' block feature) herein for reasons of efficiency or desired overflow. Wherever they appear they will be documented and accompanied with one of the following tags: - #unchecked - #overUnderFlowIntended
NOTE: Only the entrypoint contract should be allowlisted by Balancer governance as a relayer, so that the Vault will reject calls from outside the entrypoint context.
WARNING: This contract should neither be allowlisted as a relayer, nor called directly by the user. No guarantees can be made about fund safety when calling this contract in an improper manner._
constructor
Creates an instance of the library contract and periphery relayer contract for convenient interactions with Cron-Fi TWAMM pools. The periphery relayer contract is created by this constructor and should not be separately be created.
Parameters
swap
see swap documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
join
see join documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
exit
see exit documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
longTermSwap
see longTermSwap documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
withdraw
see withdraw documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
cancel
cancel see documentation in ICronV1Relayer.sol, except noted differences below:
Parameters
getVault
Gets the Balancer Vault instance this periphery relayer library is servicing.
Return Values
getEntrypoint
Gets the periphery relayer contract instantiated by this library, that serves as the user relayer entrypoint to Cron-Fi Time-Weighted Average Market Maker (TWAMM) pools.
Return Values
getFactory
Gets the Cron-Fi Time-Weighted Average Market Maker (TWAMM) factory contract instance used by this periphery relayer library to select Cron-Fi TWAMM pools.
Return Values
_getPoolInfoAndCheckValid
Gets the Balancer pool address and pool id for the provided token addresses and pool type, if available. Reverts if the pool is not available with the reason why if possible.
Parameters
Return Values
_checkAmountIn
Checks the amount of token being sold by the user to the pool is within acceptable bounds, reverts otherwise. Also confirms that the user has sufficient amount of that token available in their account, reverts otherwise.
Parameters
_getPoolAssetsAndCheckBalances
Gets the tokens and balances for the pool specified by the pool id. Checks to ensure the balances are greater than the MINIMUM_LIQUIDITY constraint (reverts otherwise). Converts the token instances fetched from the pool into a sorted array of Asset instances; the sort order is that Asset instance 0 (the first instance) corresponds to the address specified for token in. Asset instance 1 (the second instance) corresponds to the address specified for token out (there's only two assets in all these pools).
Parameters
Return Values
_getEffectiveAmountInAndCheckIntervals
This method computes the effective amount of an order that the pool can process for a long-term swap verses a user specified amount. The difference between the two values results from a truncation error due to division of the user specified amount by the trade length. Losses due to this truncation are multiplied by the trade length.
Parameters
Return Values
_getDeadline
Gets a deadline timestamp--a timestamp in the future used to cue the Balancer Vault to ignore a transaction that has sat in the mempool for an excessive amount of time.
Return Values
_getPoolAssets
Gets the pool's Asset instances in Balancer token sort order given the Balancer pool id.
Parameters
Return Values
_convertERC20sToAssets
Converts an array of ERC20 instances to Asset instances.
Parameters
Return Values
Last updated