DataLib

Git Source

rationale for "memory-safe" assembly: https://docs.soliditylang.org/en/v0.8.20/assembly.html#memory-safety

Functions

packTxInfo

function packTxInfo(
    uint8 txType_,
    uint8 callbackType_,
    uint8 multi_,
    uint8 registryId_,
    address srcSender_,
    uint64 srcChainId_
)
    internal
    pure
    returns (uint256 txInfo);

decodeTxInfo

function decodeTxInfo(uint256 txInfo_)
    internal
    pure
    returns (uint8 txType, uint8 callbackType, uint8 multi, uint8 registryId, address srcSender, uint64 srcChainId);

getSuperform

returns the vault-form-chain pair of a superform

function getSuperform(uint256 superformId_)
    internal
    pure
    returns (address superform_, uint32 formImplementationId_, uint64 chainId_);

Parameters

NameTypeDescription
superformId_uint256is the id of the superform

Returns

NameTypeDescription
superform_addressis the address of the superform
formImplementationId_uint32is the form id
chainId_uint64is the chain id

getSuperforms

returns the vault-form-chain pair of an array of superforms

function getSuperforms(uint256[] memory superformIds_)
    internal
    pure
    returns (address[] memory superforms_, uint32[] memory formIds_, uint64[] memory chainIds_);

Parameters

NameTypeDescription
superformIds_uint256[]array of superforms

Returns

NameTypeDescription
superforms_address[]are the address of the vaults
formIds_uint32[]are the form ids
chainIds_uint64[]are the chain ids

validateSuperformChainId

pointer to the end of the superformIds_ array (shl(5, mload(superformIds_)) == mul(32, mload(superformIds_))

initialize pointers for all the 4 arrays

execute what getSuperform() does on a single superformId and store the results in the respective arrays

increment pointers

check if we've reached the end of the array

validates if the superformId_ belongs to the chainId_

function validateSuperformChainId(uint256 superformId_, uint64 chainId_) internal pure;

Parameters

NameTypeDescription
superformId_uint256to validate
chainId_uint64is the chainId to check if the superform id belongs to

getDestinationChain

validates if superformId exists on factory

returns the destination chain of a given superform

function getDestinationChain(uint256 superformId_) internal pure returns (uint64 chainId_);

Parameters

NameTypeDescription
superformId_uint256is the id of the superform

Returns

NameTypeDescription
chainId_uint64is the chain id

packSuperform

generates the superformId

function packSuperform(
    address superform_,
    uint32 formImplementationId_,
    uint64 chainId_
)
    internal
    pure
    returns (uint256 superformId_);

Parameters

NameTypeDescription
superform_addressis the address of the superform
formImplementationId_uint32is the type of the form
chainId_uint64is the chain id on which the superform is deployed