MagpieStargateBridgeV2

Similar to MagpieStargateBridge but the router address of the bridge has changed.

struct Settings {
        address aggregatorAddress;
        address routerAddress;
    }
FieldTypeDescription
aggregatorAddress
address

Magpie Aggregator Address

routerAddress
address

Stargate Router Address

struct WithdrawArgs {
        uint16 srcChainId;
        uint256 nonce;
        address assetAddress;
        bytes srcAddress;
        TransferKey transferKey;
    }
FieldTypeDescription
srcChainId
uint16

A uint16 value representing the source chain ID from which the withdrawal is initiated.

nonce
uint256

A uint256 value representing a unique identifier for the withdrawal transaction.

assetAddress
address

An address representing the asset address that is being withdrawn.

srcAddress
bytes

A bytes array representing the source address on the source chain.

transferKey
TransferKey

An instance of the TransferKey struct from the LibTransferKey library, which contains the network ID, sender address, and swap sequence associated with the withdrawal.

updateSettings():

to update the bridge settings. Only the contract owner can call this function.

Input:

FieldTypeDescription

_settings

Settings

struct Settings {
        address aggregatorAddress;
        address routerAddress;
    }

withdraw():

to withdraw deposited funds. It checks the deposited amount based on the transfer key and asset address, clears the cached swap if the amount is zero, and transfers the amount to the aggregator address. Only the Magpie aggregator can call this function.

Input:

FieldTypeDescription

withdrawArgs

WithdrawArgs

struct WithdrawArgs {
        uint16 srcChainId;
        uint256 nonce;
        address assetAddress;
        bytes srcAddress;
        TransferKey transferKey;
    }

Output:

FieldTypeDescription

amountOut

uint256

The amount that is withdrawn.

sgReceive():

sgReceive is called by the Stargate router when assets are received from another chain. It increments the deposited amount based on the transfer key, asset address, and amount.

Input:

FieldTypeDescription

transferKey.networkId

uint16

Network Id extracted from the TransferKey struct

transferKey.senderAddress

bytes

Sender Address extracted from the TransferKey struct

transferKey.swapSequence

uint256

Swap Sequence extracted from the TransferKey struct

assetAddress

address

An address parameter representing the address of the received asset.

amount

uint256

A uint256 parameter representing the amount of the received asset.

payload

bytes

A bytes calldata parameter containing encoded information about the transfer, including the TransferKey.

Last updated