Magpie Protocol
  • Magpie Protocol
    • What is Magpie solving?
      • What is DeFi?
    • Magpies Key Features
      • Use Cases
    • FLY
      • xFLY & FLY33
  • 📶Supported Networks
  • Guides
    • 📖Glossary of DeFi Terms
    • 👜Connect Wallet
    • 🔄On-Chain Swap
    • 🔀Cross-Chain Swap
    • 🔂Swap configuration
    • 🥚Magpie Boosts
    • 📒Transaction History
    • 💲Portfolio
  • Media Kit
  • 👩‍💻Developers
    • Magpie Contracts
      • MagpieCCTPBridge
      • MagpieCelerBridgeV2
      • MagpieRouterV3
      • MagpieStargateBridgeV3
      • LibAsset
      • LibBridge
      • LibRouter
    • Smart Contracts Audit
    • Deployments
    • API Reference
      • On chain swap
      • Cross chain swap
      • Requesting and Using API Key
Powered by GitBook
On this page
  • updateSettings():
  • withdraw():
  • sgReceive():
  1. Developers
  2. Deprecated Magpie Contracts

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;
    }
Field
Type
Description

Magpie Aggregator Address

Stargate Router Address

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

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

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

An address representing the asset address that is being withdrawn.

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

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:

Field
Type
Description

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:

Field
Type
Description

Output:

Field
Type
Description

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:

Field
Type
Description

Network Id extracted from the TransferKey struct

Sender Address extracted from the TransferKey struct

Swap Sequence extracted from the TransferKey struct

An address parameter representing the address of the received asset.

A uint256 parameter representing the amount of the received asset.

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

Last updated 1 year ago

👩‍💻
aggregatorAddress
address
routerAddress
address
srcChainId
uint16
nonce
uint256
assetAddress
address
srcAddress
bytes
transferKey
TransferKey
_settings
Settings
struct Settings {
        address aggregatorAddress;
        address routerAddress;
    }
withdrawArgs
WithdrawArgs
struct WithdrawArgs {
        uint16 srcChainId;
        uint256 nonce;
        address assetAddress;
        bytes srcAddress;
        TransferKey transferKey;
    }
amountOut
uint256
transferKey.networkId
uint16
transferKey.senderAddress
bytes
transferKey.swapSequence
uint256
assetAddress
address
amount
uint256
payload
bytes