IPaymentHelper

Git Source

Author: ZeroPoint Labs

helps decoding the bytes payload and returns meaningful information

Functions

addChain

admin config destination chain config for estimation

function addChain(uint64 chainId_, PaymentHelperConfig calldata config_) external;

Parameters

NameTypeDescription
chainId_uint64is the identifier of new chain id
config_PaymentHelperConfigis the chain config

updateChainConfig

admin update remote chain config for estimation

function updateChainConfig(uint64 chainId_, uint256 configType_, bytes memory config_) external;

Parameters

NameTypeDescription
chainId_uint64is the remote chain's identifier
configType_uint256is the type of config from 1 -> 6
config_bytesis the encoded new configuration

calculateAMBData

returns the amb overrides & gas to be used

function calculateAMBData(
    uint64 dstChainId_,
    uint8[] calldata ambIds_,
    bytes memory message_
)
    external
    view
    returns (uint256 totalFees, bytes memory extraData);

Parameters

NameTypeDescription
dstChainId_uint64is the unique dst chain identifier
ambIds_uint8[]is the identifiers of arbitrary message bridges to be used
message_bytesis the encoded cross-chain payload

estimateAMBFees

returns the gas fees estimation in native tokens if we send message through a combination of AMBs

function estimateAMBFees(
    uint8[] memory ambIds_,
    uint64 dstChainId_,
    bytes memory message_,
    bytes[] memory extraData_
)
    external
    view
    returns (uint256 ambFees, uint256[] memory);

Parameters

NameTypeDescription
ambIds_uint8[]is the identifier of different AMBs
dstChainId_uint64is the identifier of the destination chain
message_bytesis the cross-chain message
extraData_bytes[]is any amb-specific information

Returns

NameTypeDescription
ambFeesuint256is the native_tokens to be sent along the transaction for all the ambIds_ included
<none>uint256[]

estimateMultiDstMultiVault

estimates the gas fees for multiple destination and multi vault operation

function estimateMultiDstMultiVault(
    MultiDstMultiVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_MultiDstMultiVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

estimateMultiDstSingleVault

estimates the gas fees for multiple destination and single vault operation

function estimateMultiDstSingleVault(
    MultiDstSingleVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_MultiDstSingleVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

estimateSingleXChainMultiVault

estimates the gas fees for single destination and multi vault operation

function estimateSingleXChainMultiVault(
    SingleXChainMultiVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_SingleXChainMultiVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter ///
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

estimateSingleXChainSingleVault

estimates the gas fees for single destination and single vault operation

function estimateSingleXChainSingleVault(
    SingleXChainSingleVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_SingleXChainSingleVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

estimateSingleDirectSingleVault

estimates the gas fees for same chain operation

function estimateSingleDirectSingleVault(
    SingleDirectSingleVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_SingleDirectSingleVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

estimateSingleDirectMultiVault

estimates the gas fees for multiple same chain operation

function estimateSingleDirectMultiVault(
    SingleDirectMultiVaultStateReq calldata req_,
    bool isDeposit
)
    external
    view
    returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);

Parameters

NameTypeDescription
req_SingleDirectMultiVaultStateReqis the request object containing all necessary data for the actual operation on SuperRouter
isDepositbool

Returns

NameTypeDescription
liqAmountuint256is the amount of liquidity to be provided in native tokens
srcAmountuint256is the gas expense on source chain in native tokens
dstAmountuint256is the gas expense on dst chain in terms of src chain's native tokens
totalAmountuint256is the native_tokens to be sent along the transaction

Events

ChainConfigUpdated

event ChainConfigUpdated(uint64 chainId_, uint256 configType_, bytes config_);

Structs

PaymentHelperConfig

struct PaymentHelperConfig {
    address nativeFeedOracle;
    address gasPriceOracle;
    uint256 updateGasUsed;
    uint256 depositGasUsed;
    uint256 withdrawGasUsed;
    uint256 defaultNativePrice;
    uint256 defaultGasPrice;
    uint256 dstGasPerKB;
    uint256 ackGasCost;
    uint256 twoStepCost;
    uint256 swapGasUsed;
}

Properties

NameTypeDescription
nativeFeedOracleaddress
gasPriceOracleaddress
updateGasUseduint256
depositGasUseduint256
withdrawGasUseduint256
defaultNativePriceuint256
defaultGasPriceuint256
dstGasPerKBuint256
ackGasCostuint256
twoStepCostuint256
swapGasUseduint256