⚖️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
_sharePriceValidityDuration
uint128
Time in seconds for signed share price to be valid
_initialSharePrice
uint128
Price that is used when contract's total supply is zero
_signatureThershold
uint256
_signatureThreshold Minimal signature number required for force push price verification
getPriceFeed
Gets price feed data
Parameters
asset
address
Asset for wich to get price feed
Returns
priceFeed
FeedInfo
Returns price feed data
getPrice
Gets current asset price
Parameters
asset
address
Asset for wich to get price
Returns
price
uint256
Returns price data in a format of Q96 decimal value
getFeeParams
getAsset
Gets asset related info
Reads exacly two storage slots
Parameters
assetAddress
address
address of asset wich data to provide
Returns
asset
MpAsset
asset related data structure
getContext
Assembles context for swappping
tries to apply force pushed share price if provided address matches otherwhise ignores struct
Parameters
forcePushArgs
ForcePushArgs
price force push related data
Returns
ctx
MpContext
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
ctx
MpContext
Multipool calculation context
selectedAssets
AssetArgs[]
Returns
fetchedPrices
uint256[]
Array of prices per each supplied asset
transferAsset
Proceeses asset transfer
Handles multipool share with no contract calls
Parameters
asset
address
Address of asset to send
quantity
uint256
Address value to send
to
address
Recepient address
receiveAsset
Asserts there is enough token balance and makes left value refund
Handles multipool share with no contract calls
Parameters
asset
MpAsset
Asset data structure storing asset relative data
assetAddress
address
Address of asset to check and refund
requiredAmount
uint256
Value that is checked to present unused on contract
refundAddress
address
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
forcePushArgs
ForcePushArgs
Arguments for share price force push
assetsToSwap
AssetArgs[]
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
isExactInput
bool
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
receiverAddress
address
Address that will receive output amounts
refundEthToReceiver
bool
If this value is true, left ether will be sent to receiverAddress
, else, refundAddress
will be used
refundAddress
address
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
forcePushArgs
ForcePushArgs
Arguments for share price force push
assetsToSwap
AssetArgs[]
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
isExactInput
bool
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
fee
int256
Native token amount to cover swap fees
amounts
int256[]
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
assetAddress
address
Address of asset selected to increase its cashback
Returns
amount
uint128
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
assetAddresses
address[]
Addresses of assets for wich to update feeds
kinds
FeedType[]
Price feed extraction strategy type
feedData
bytes[]
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
assetAddresses
address[]
Addresses of assets for wich to update target shares
targetShares
uint256[]
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
to
address
Address to wich to transfer collected fees
Returns
fees
uint256
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
fees
uint256
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
newDeviationLimit
uint64
curve parameter that shows maximum deviation changes that may be made by callers
newHalfDeviationFee
uint64
curve parameter that is a fee ratio at the half of the curve
newDepegBaseFee
uint64
parameter that shows ratio of value taken from deviation fee as base fee
newBaseFee
uint64
parameter that shows ratio of value taken from each operation quote value
newDeveloperBaseFee
uint64
parameter that shows ratio of value that is taken from base fee share for arcanum protocol developers and maintainers
newDeveloperAddress
address
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
newValidityDuration
uint128
New interval in seconds
newSignatureThershold
uint256
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
authority
address
address whos permissions change
forcePushSettlement
bool
allows to sign force push data if true
targetShareSettlement
bool
allows to change target share if true
Last updated