⚖️Multipool
This section describes the Multipool core contract.
Visit GitHub to see full implementation
Multipool
State Variables
assets
prices
deviationParam
deviationLimit
depegBaseFee
baseFee
totalTargetShares
totalCollectedCashbacks
collectedFees
initialSharePrice
sharePriceValidityDuration
isPriceSetter
isTargetShareSetter
developerAddress
developerBaseFee
collectedDeveloperFees
isPaused
signatureThershold
Functions
constructor
initialize
_authorizeUpgrade
notPaused
getSharePriceParams
Gets several share prive params
Fetches data by reading a single slot
Returns
Name | Type | Description |
---|---|---|
|
| Time in seconds for signed share price to be valid |
|
| Price that is used when contract's total supply is zero |
|
| _signatureThreshold Minimal signature number required for force push price verification |
getPriceFeed
Gets price feed data
Parameters
Name | Type | Description |
---|---|---|
|
| Asset for wich to get price feed |
Returns
Name | Type | Description |
---|---|---|
|
| Returns price feed data |
getPrice
Gets current asset price
Parameters
Name | Type | Description |
---|---|---|
|
| Asset for wich to get price |
Returns
Name | Type | Description |
---|---|---|
|
| Returns price data in a format of Q96 decimal value |
getFeeParams
getAsset
Gets asset related info
Reads exacly two storage slots
Parameters
Name | Type | Description |
---|---|---|
|
| address of asset wich data to provide |
Returns
Name | Type | Description |
---|---|---|
|
| asset related data structure |
getContext
Assembles context for swappping
tries to apply force pushed share price if provided address matches otherwhise ignores struct
Parameters
Name | Type | Description |
---|---|---|
|
| price force push related data |
Returns
Name | Type | Description |
---|---|---|
|
| state memory context used across swapping |
getPricesAndSumQuotes
Assembles context for swappping
Also checks that assets are unique via asserting that they are sorted and each element address is stricly bigger
Parameters
Name | Type | Description |
---|---|---|
|
| Multipool calculation context |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| Array of prices per each supplied asset |
transferAsset
Proceeses asset transfer
Handles multipool share with no contract calls
Parameters
Name | Type | Description |
---|---|---|
|
| Address of asset to send |
|
| Address value to send |
|
| Recepient address |
receiveAsset
Asserts there is enough token balance and makes left value refund
Handles multipool share with no contract calls
Parameters
Name | Type | Description |
---|---|---|
|
| Asset data structure storing asset relative data |
|
| Address of asset to check and refund |
|
| Value that is checked to present unused on contract |
|
| Address to receive asset refund |
swap
Method that executes every trading in multipool
This is a low level method that works via direct token transfer on contract and method execution. Should be used in other contracts only Fees are charged in native token equivalend via transferring them before invocation or in msg.value
Parameters
Name | Type | Description |
---|---|---|
|
| Arguments for share price force push |
|
| Assets that will be used as input or output and their amounts. Assets should be provided ascendingly sorted by addresses. Can't accept duplicates of assets |
|
| Shows sleepage direction. If is true input amouns (that are greater than zero) will be used exactly and output amounts (less than zero) will be used as slippage checks. If false it is reversed |
|
| Address that will receive output amounts |
|
| If this value is true, left ether will be sent to |
|
| Address that will be used to receive left input token and native token balances |
checkSwap
Method that dry runs swap execution and provides estimated fees and amounts
To avoid calculation errors don't provide small values to amount
Parameters
Name | Type | Description |
---|---|---|
|
| Arguments for share price force push |
|
| Assets that will be used as input or output and their amounts. Assets should be provided ascendingly sorted by addresses. Can't accept duplicates of assets |
|
| Shows sleepage direction. If is true input amouns (that are greater than zero) will be used and the output amounts will be estmated proportionally. If false it behaves reversed |
Returns
Name | Type | Description |
---|---|---|
|
| Native token amount to cover swap fees |
|
|
increaseCashback
Method that dry runs swap execution and provides estimated fees and amounts
Method is permissionless so anyone can boos incentives. Native token value can be transferred directly if used iva contract or via msg.value with any method
Parameters
Name | Type | Description |
---|---|---|
|
| Address of asset selected to increase its cashback |
Returns
Name | Type | Description |
---|---|---|
|
| Native token amount that was put into cashback |
updatePrices
Updates price feeds for multiple tokens.
Values in each of these arrays should match with indexes (e.g. index 1 contains all data for asset 1)
Parameters
Name | Type | Description |
---|---|---|
|
| Addresses of assets for wich to update feeds |
|
| Price feed extraction strategy type |
|
| Data with encoded payload for price extraction |
updateTargetShares
Updates target shares for multiple tokens.
Values in each of these arrays should match with indexes (e.g. index 1 contains all data for asset 1)
Parameters
Name | Type | Description |
---|---|---|
|
| Addresses of assets for wich to update target shares |
|
| Share values to update to |
withdrawFees
Method that allows to withdraw collected to owner fees. May be only called by owner
Sends all collected values at once
Parameters
Name | Type | Description |
---|---|---|
|
| Address to wich to transfer collected fees |
Returns
Name | Type | Description |
---|---|---|
|
| withdrawn native token value |
withdrawDeveloperFees
Method that allows to withdraw developer fees from contract
Can be invoked by anyone but is still safe as recepient is always developer address
Returns
Name | Type | Description |
---|---|---|
|
| withdrawn native token value |
togglePause
Method that stops or launches contract. Used in case of freezing (e.g hacks or temprorary stopping contract)
setFeeParams
Method to change fee charging rules. All ratios are Q32 values.
Remember to always update every value as this function overrides all variables
Parameters
Name | Type | Description |
---|---|---|
|
| curve parameter that shows maximum deviation changes that may be made by callers |
|
| curve parameter that is a fee ratio at the half of the curve |
|
| parameter that shows ratio of value taken from deviation fee as base fee |
|
| parameter that shows ratio of value taken from each operation quote value |
|
| parameter that shows ratio of value that is taken from base fee share for arcanum protocol developers and maintainers |
|
| address to send arcanum protocol development and maintaince fees |
setSharePriceParams
This method allows to chenge time for wich force pushed share price is valid and minimal number of unique signatures required for price force push
Called only by owner. This mechanism allow you to manage price volatility by changing valid price timeframes
Parameters
Name | Type | Description |
---|---|---|
|
| New interval in seconds |
|
| New number of signatures that substracted by 1 (if 0 is passed 1 signature is required) |
setAuthorityRights
Method that changes permissions of accounts
Remember to always update every value as this function overrides all variables
Parameters
Name | Type | Description |
---|---|---|
|
| address whos permissions change |
|
| allows to sign force push data if true |
|
| allows to change target share if true |
Last updated