PayloadHelper

Git Source

Inherits: IPayloadHelper

Author: ZeroPoint Labs

helps decode payload data more easily. Used for off-chain purposes

State Variables

superRegistry

ISuperRegistry public immutable superRegistry;

Functions

constructor

constructor(address superRegistry_);

decodeCoreStateRegistryPayload

reads the payload from the core state registry and decodes it in a more detailed manner.

function decodeCoreStateRegistryPayload(uint256 dstPayloadId_)
    external
    view
    override
    returns (
        uint8 txType,
        uint8 callbackType,
        address srcSender,
        uint64 srcChainId,
        uint256[] memory amounts,
        uint256[] memory slippage,
        uint256[] memory superformIds,
        uint256 srcPayloadId,
        uint8 superformRouterId
    );

Parameters

NameTypeDescription
dstPayloadId_uint256is the unique identifier of the payload received in dst core state registry

Returns

NameTypeDescription
txTypeuint8is the type of transaction. check {TransactionType} enum in DataTypes.sol
callbackTypeuint8is the type of payload. check {CallbackType} enum in DataTypes.sol
srcSenderaddressis the user who initiated the transaction on the srcChain
srcChainIduint64is the unique identifier of the srcChain
amountsuint256[]is the amount to deposit/withdraw
slippageuint256[]is the max slippage configured by the user (only for deposits)
superformIdsuint256[]is the unique identifiers of the superforms
srcPayloadIduint256is the identifier of the corresponding payload on srcChain
superformRouterIduint8is the identifier of the superform router

decodeCoreStateRegistryPayloadLiqData

reads the payload from the core state registry and decodes liqData for it (to be used in withdraw cases)

function decodeCoreStateRegistryPayloadLiqData(uint256 dstPayloadId_)
    external
    view
    override
    returns (
        uint8[] memory bridgeIds,
        bytes[] memory txDatas,
        address[] memory tokens,
        uint64[] memory liqDstChainIds,
        uint256[] memory amountsIn,
        uint256[] memory amountsOut,
        uint256[] memory nativeAmounts,
        bool[] memory hasDstSwaps,
        address dstRefundAddress
    );

Parameters

NameTypeDescription
dstPayloadId_uint256is the unique identifier of the payload received in dst core state registry

Returns

NameTypeDescription
bridgeIdsuint8[]is the ids of the bridges to be used
txDatasbytes[]is the array of txData to be sent to the bridges
tokensaddress[]is the tokens to be used in the liqData
liqDstChainIdsuint64[]are the final destination chain id for the underlying token (can be arbitrary on withdraws)
amountsInuint256[]are the from amounts to the liquidity bridge
amountsOutuint256[]are the minimum amounts to be bridged through the liquidity bridge
nativeAmountsuint256[]is the native amounts to be used in the liqData
hasDstSwapsbool[]is the array of flags indicating if the original liqData has a dstSwaps
dstRefundAddressaddressis the address to be used for refunds

decodeStateSyncerPayloadHistory

reads the payload header from a state syncer and decodes it.

function decodeStateSyncerPayloadHistory(
    uint256 srcPayloadId_,
    uint8 superformRouterId_
)
    external
    view
    override
    returns (uint8 txType, uint8 callbackType, uint8 multi, address srcSender, uint64 srcChainId);

Parameters

NameTypeDescription
srcPayloadId_uint256is the unique identifier of the payload allocated by super router
superformRouterId_uint8is the unique identifier of the superform router

Returns

NameTypeDescription
txTypeuint8is the type of transaction. check {TransactionType} enum in DataTypes.sol
callbackTypeuint8is the type of payload. check {CallbackType} enum in DataTypes.sol
multiuint8isMulti indicates if the transaction involves operations to multiple vaults
srcSenderaddressis the user who initiated the transaction on the srcChain
srcChainIduint64is the unique identifier of the srcChain

decodeTimeLockPayload

returns decoded two step form payloads

function decodeTimeLockPayload(uint256 timelockPayloadId_)
    external
    view
    override
    returns (address srcSender, uint64 srcChainId, uint256 srcPayloadId, uint256 superformId, uint256 amount);

Parameters

NameTypeDescription
timelockPayloadId_uint256is the unique identifier of payload in two step registry

decodeTimeLockFailedPayload

function decodeTimeLockFailedPayload(uint256 timelockPayloadId_)
    external
    view
    override
    returns (address srcSender, uint64 srcChainId, uint256 srcPayloadId, uint256 superformId, uint256 amount);

Structs

DecodeDstPayloadInternalVars

struct DecodeDstPayloadInternalVars {
    uint8 txType;
    uint8 callbackType;
    address srcSender;
    uint64 srcChainId;
    uint256[] amounts;
    uint256[] slippage;
    uint256[] superformIds;
    uint256 srcPayloadId;
    uint8 superformRouterId;
    uint8 multi;
    ReturnMultiData rd;
    ReturnSingleData rsd;
    InitMultiVaultData imvd;
    InitSingleVaultData isvd;
}

DecodeDstPayloadLiqDataInternalVars

struct DecodeDstPayloadLiqDataInternalVars {
    uint8 callbackType;
    uint8 multi;
    uint8[] bridgeIds;
    bytes[] txDatas;
    address[] liqDataTokens;
    uint64[] liqDataChainIds;
    uint256[] liqDataAmountsIn;
    uint256[] liqDataAmountsOut;
    uint256[] liqDataNativeAmounts;
    bool[] hasDstSwaps;
    address dstRefundAddress;
    InitMultiVaultData imvd;
    InitSingleVaultData isvd;
    uint256 i;
}