MagpieStargateBridge

The contract serves as a bridge between Magpie and the Stargate network, allowing deposits and withdrawals of assets between the two networks. It has a modifier onlyMagpieAggregator that restricts access to functions only to the Magpie aggregator address specified in the settings struct. It has a modifier onlyStargate that restricts access to functions only to the Stargate router address specified in the settings struct.

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

updateSettings():

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

Input:

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:

Output:

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:

Last updated