Fly
  • Fly
    • What is Fly solving?
      • What is DeFi?
    • Fly key features
      • Use Cases
    • $FLY
      • xFLY & FLY33
  • 📶Supported Networks
  • Guides
    • 📖Glossary of DeFi Terms
    • 👜Connect Wallet
    • 🔄On-Chain Swap
    • 🔀Cross-Chain Swap
    • 🔂Swap configuration
    • 🥚fly boosts
    • 📒Transaction History
    • 💲Portfolio
  • 👩‍💻Developers
    • fly.trade 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
  • encode():
  • decode():
  • validate():
  1. Developers
  2. Deprecated Magpie Contracts
  3. MagpieAggregator Diamond Proxy
  4. Libraries

LibTransferKey

The LibTransferKey library provides functionality for encoding, decoding, and validating TransferKey structs, which are used to represent transfer keys in the application.

struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}
Field
Type
Description

networkId of the current chain in Magpie protocol, it is different from the actual networkId ethereum: 1 polygon: 2 bsc: 3 avalanche: 4 arbitrum: 5 optimism: 6

The address who initiated the transfer.

The magpie sequence for the current swap.

encode():

In the encode function, a new bytes array (payload) of size 42 is created to store the encoded transfer key.

Input:

Field
Type
Description

Output:

Field
Type
Description

The transferKey concatenated and converted to bytes

decode():

In the decode function, the assembly block is used to extract the values of each field from the payload array and store them in the transferKey struct.

Input:

Field
Type
Description

The data which contains the transferKey.

Output:

Field
Type
Description

validate():

The validate function checks if the networkId, senderAddress, and swapSequence fields of both TransferKey structs are equal. If any of the fields differ, indicating an invalid transfer key, the function reverts with an InvalidTransferKey error.

Input:

Field
Type
Description

Last updated 1 year ago

👩‍💻
networkId
uint16
senderAddress
bytes32
swapSequence
uint64
transferKey
TransferKey
struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}
payload
bytes
payload
bytes
transferKey
TransferKey
struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}
self
TransferKey
struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}
transferKey
TransferKey
struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}