PaymentHelper
Introduction
This contract helps estimate various payments in the Superform Protocol.
Core Concepts
Chains are initiated with multiple variables to help with the estimation process by the PROTOCOL_ADMIN_ROLE
. There are all updatable by the EMERGENCY_ADMIN_ROLE
.
Config Data Type
nativeFeedOracle
address of the Chainlink native token / USD price feed (i.e. AVAX/USD)
gasPriceOracle
address of the Chainlink gas price feed
swapGasUsed
uint256 estimated gas consumed to make a swap on the specified chain
updateGasUsed
uint256 estimated gas consumed in updating a payload on the chain
depositGasUsed
uint256 estimated gas consumed in calling vault.deposit()
on that chain via Superform
withdrawGasUsed
uint256 estimated gas consumed in calling vault.redeem()
on that chain via Superform
defaultNativePrice
uint256 price of the native token to use as fallback if Chainlink price feed not available
defaultGasPrice
uint256 average gas price to use as fallback if Chainlink gas feed not available
dstGasPerByte
uint256 gas per size of data
ackGasCost
uint256 gas cost for processing ack on the source chain
timelockCost
unit256 cost for processing time-locked payloads
emergencyCost
uint256 cost for processing withdrawals sent to the emergency queue if Forms are paused
addRemoteChain
This function allows for the addition of new chains, including setting same chain parameters, for use in estimation.
chainId_
uint64 of the EVM chain id
config_
updateRemoteChain
This function allows the EmergencyAdmin
to update any of the above parameters at any given time for more accurate estimations. An event is emitted when any of these variables are updated.
chainId
uint64 EVM chain id to update
configType_
uint256 from 1-11 for the config type 1 = native token price feed oracle 2 = gas price feed oracle 3 = cost to swap 4 = cost to update payloads 5 = cost to deposit into vaults 6 = cost to withdraw from vaults 7 = default native token price 8 = default, average gas price 9 = gas price per byte 10 = acknowledgment gas cost 11 = timelocked gas cost 12 = emergency queue gas cost
config_
aERC20 Payments
updateRegisterAERC20Params
This function allows the EmergencyAdmin
to adjust the cost required to create an an aERC20
position from a SuperPosition id.
totalTransmuterFees_
unit256 fees to charge
extraDataForTransmuter_
bytes extraData
required to broadcast the information needed to create aERC20
across chains
calculateRegisterTransmuterAMBData
This function allows anyone to see the fees and data required to create a ERC20 position from a SuperPosition id.
AMB Fees
calculateAMBData
Function to return the cost and extraData
needed for a given message sent through various AMBs supported on Superform.
dstChainId_
uint64 EVM chain ID of where to send the message
ambIds_
uint8 array of AMB ids to send the message through, can also send in just one AMB
message_
bytes encoded message to send
estimateAMBFees
Function to return the native tokens to be sent alongside the transaction in order for the transaction to be properly processed on destination.
ambIds_
uint8 array of AMB ids to send the message through, can also send in just one AMB
dstChainId_
uint64 EVM chain id of where to send the message
message_
bytes encoded message to send
extraData_
bytes AMB-specific data
Estimating Native Token Payments
For each type of SuperformRouter transaction (6 total combinations of cross-chain/same chain, single and multi-vault, and single and multi-destination) as found in Datatypes -> Functions, there is a specific estimation function.
These functions all return the following:
liqAmount
: amount of native tokens contained in the liquidity requestsrcAmount
: total estimated gas expenditure on the source chaindstAmount
: total estimated gas expenditure on the destination chaintotalAmount
: total amount of native tokens to be sent alongside transaction
estimateMultiDstMultiVault
This function returns the native token breakdown assuming a multiple destination, multiple vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdrawal
estimateMultiDstSingleVault
This function returns the native token breakdown assuming a multiple destination, single vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdrawal
estimateSingleXChainMultiVault
This function returns the native token breakdown assuming a single cross-chain transaction for a multiple vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdrawal
estimateSingleXChainSingleVault
This function returns the native token breakdown assuming a single cross-chain transaction for a single vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdrawal
estimateSingleDirectSingleVault
This function returns the native token breakdown assuming a same-chain, single vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdrawal
estimateSingleDirectMultiVault
This function returns the native token breakdown assuming a same-chain, multiple vault deposit or withdrawal.
isDeposit_
boolean of True if deposit, False if withdraw
Last updated