# fly.trade contracts

<table data-full-width="true"><thead><tr><th width="209">Contract</th><th>Description</th></tr></thead><tbody><tr><td>IAxelarGasService</td><td><p>The IAxelarGasService interface manages gas payments and refunds for cross-chain communication on the Axelar network. It has one function: </p><p>• <mark style="color:red;"><strong>payNativeGasForContractCall</strong></mark>: pays for gas using native currency for a contract call on a destination chain.</p></td></tr><tr><td>IAxelarGateway</td><td><p>The IAxelarGateway interface enables cross-chain communication on the Axelar network. It has two functions: </p><p>• <mark style="color:red;"><strong>callContract</strong></mark>: executes a remote contract call on a destination chain. </p><p>• <mark style="color:red;"><strong>validateContractCall</strong></mark>: verifies the authenticity of a contract call and returns a boolean result.</p></td></tr><tr><td>IReceiver</td><td><p>The IReceiver interface receives messages on the destination chain and forwards them to the IMessageDestinationHandler. It has one function: </p><p>• <mark style="color:red;"><strong>receiveMessage</strong></mark>: receives an incoming message, validates the header, and passes the body to the application-specific handler.</p></td></tr><tr><td>ILiquidityBridge</td><td>The <mark style="color:red;"><strong>ILiquidityBridge</strong></mark> contract defines an interface for a cross-chain liquidity bridge. It specifies several core functions for sending and relaying assets across different blockchain networks, managing transfer status, and handling withdrawals.</td></tr><tr><td>IMessageBus</td><td>The <mark style="color:red;"><strong>IMessageBus</strong></mark> interface facilitates cross-chain message passing and token transfers. It defines structures like <mark style="color:red;"><strong>SwapInfo</strong></mark> (swap details) and <mark style="color:red;"><strong>SwapRequest</strong></mark> (swap operation), and enums such as <mark style="color:red;"><strong>BridgeSendType</strong></mark> (bridge operation types) and <mark style="color:red;"><strong>TransferType</strong></mark> (transfer actions). Core functions include sending and executing messages with transfers, handling refunds, and calculating fees. It supports multiple transfer mechanisms and integrates with a liquidity bridge for cross-chain operations.</td></tr><tr><td>IOFT</td><td>The <mark style="color:red;"><strong>IOFT</strong></mark> interface manages cross-chain token transfers using Omnichain Fungible Tokens (OFT). It defines structures like <mark style="color:red;"><strong>SendParam</strong></mark> for transfer details and <mark style="color:red;"><strong>MessagingReceipt</strong></mark> for transaction receipts. The contract includes functionality for sending tokens across chains, quoting transfer limits and fees, and handling messaging and fee structures. It ensures security through slippage checks and transfer validation.</td></tr><tr><td>IStargate</td><td>The <mark style="color:red;"><strong>IStargate</strong></mark> interface extends the <mark style="color:red;"><strong>IOFT</strong></mark> contract for cross-chain token transfers. It introduces a <mark style="color:red;"><strong>StargateType</strong></mark> enum to define implementation types and a <mark style="color:red;"><strong>Ticket</strong></mark> struct for bus ride operations. Key functionality includes sending tokens across chains via <mark style="color:red;"><strong>sendToken</strong></mark>, which also returns a ticket if bus ride mode is enabled, and retrieving the Stargate type via <mark style="color:red;"><strong>stargateType()</strong></mark>. The interface builds on OFT operations, adding unique Stargate-related logic.</td></tr><tr><td>IBridge</td><td>The <mark style="color:red;"><strong>IBridge</strong></mark> interface defines the core functionality for a token bridge that supports swapping assets across chains. It emits events for swap operations (<mark style="color:red;"><strong>SwapIn</strong></mark>, <mark style="color:red;"><strong>SwapOut</strong></mark>) and allows the contract owner to update internal parameters such as whitelisted callers, WETH address, and network/router details. The <mark style="color:red;"><strong>multicall</strong></mark> function enables executing multiple operations in a single transaction, enhancing operational efficiency.</td></tr><tr><td>IMagpieCCTPBridge</td><td>The <mark style="color:red;"><strong>IMagpieCCTPBridge</strong></mark> interface extends the <mark style="color:red;"><strong>IBridge</strong></mark> contract and adds functionality for cross-chain token and message handling. It allows the owner to update critical addresses such as the CCTP token messenger, Axelar gateway, and gas receiver. Additionally, the interface includes an <mark style="color:red;"><strong>execute</strong></mark> function to handle commands from a source chain, processing them based on the provided command ID, source chain, source address, and encoded payload. This enables seamless communication and execution of cross-chain operations.</td></tr><tr><td>IMagpieCelerBridgeV2</td><td>The <mark style="color:red;"><strong>IMagpieCelerBridgeV2</strong></mark> interface extends the <mark style="color:red;"><strong>IBridge</strong></mark> contract, facilitating interactions with the Celer Network. It allows the owner to update the Celer address and includes functions for executing messages with fund transfers and managing refunds. This ensures efficient cross-chain communication and transaction handling.</td></tr><tr><td>IMagpieRouterV3</td><td>The <mark style="color:red;"><strong>IMagpieRouterV3</strong></mark> interface provides a framework for managing internal callers and bridges, enabling the owner to update their whitelisted statuses. It includes a <mark style="color:red;"><strong>multicall</strong></mark> function for executing multiple actions in a single transaction, and several token swap methods: <mark style="color:red;"><strong>swapWithMagpieSignature</strong></mark>, <mark style="color:red;"><strong>swapWithUserSignature</strong></mark>, and <mark style="color:red;"><strong>swapWithoutSignature</strong></mark>, each facilitating asset exchanges while returning the amount received. Additionally, it features an <mark style="color:red;"><strong>estimateSwapGas</strong></mark> function to assess gas costs for swaps, enhancing transaction efficiency and cost management.</td></tr><tr><td>IMagpieStargateBridgeV3</td><td>The <mark style="color:red;"><strong>IMagpieStargateBridgeV3</strong></mark> interface extends the <mark style="color:red;"><strong>IBridge</strong></mark> contract, enabling management of asset mappings to Stargate pools. It allows the owner to update the asset-to-Stargate and Stargate-to-asset mappings through dedicated functions. Additionally, it includes an <mark style="color:red;"><strong>updateLzAddress</strong></mark> function for modifying the LayerZero address. The interface also features the <mark style="color:red;"><strong>lzCompose</strong></mark> function, enabling Stargate to handle transfers and update deposit amounts, facilitating seamless asset management across the bridge.</td></tr><tr><td>IMagpieSymbiosisBridge</td><td>The <mark style="color:red;"><strong>IMagpieSymbiosisBridge</strong></mark> interface extends the <mark style="color:red;"><strong>IBridge</strong></mark> contract, providing functionalities to manage critical addresses for the Portal, Axelar gateway, and gas receiver, allowing the owner to update these addresses as needed. Additionally, it features an <mark style="color:red;"><strong>execute</strong></mark> function that facilitates the execution of Axelar commands from a source chain, using parameters like command ID, source chain name, source address, and payload. This ensures effective cross-chain communication and command execution.</td></tr><tr><td>IWETH</td><td>The <mark style="color:red;"><strong>IWETH</strong></mark> interface defines essential functions for interacting with Wrapped Ether (WETH). It includes a <mark style="color:red;"><strong>deposit</strong></mark> function to convert Ether to WETH, a <mark style="color:red;"><strong>transfer</strong></mark> function for transferring WETH to a specified address, and a <mark style="color:red;"><strong>withdraw</strong></mark> function for converting WETH back to Ether. This interface facilitates seamless handling of WETH within smart contracts.</td></tr><tr><td>MagpieCCTPBridge</td><td>The <mark style="color:red;"><strong>MagpieCCTPBridge</strong></mark> contract facilitates cross-chain asset swaps and deposits through Circle CCTP bridge. It includes functions for updating router addresses, processing inbound and outbound swaps, and managing deposits. The contract verifies signatures for secure transactions and emits events for asset bridging and deposits.</td></tr><tr><td>MagpieCelerBridgeV2</td><td>The <mark style="color:red;"><strong>MagpieCelerBridgeV2</strong></mark> contract enables cross-chain asset swaps and deposits, incorporating security measures like ownership control and pausable functions. It verifies swap signatures, manages deposit data, and facilitates asset bridging through the Celer Network, ensuring efficient transaction handling and refund management.</td></tr><tr><td>MagpieRouterV3</td><td>The contract is designed to facilitate token swaps. It includes a range of functions for executing commands, handling swaps, and managing gas usage. The contract uses a combination of libraries and interfaces to provide its functionality, including the <mark style="color:red;"><strong>IOFT</strong></mark> interface, <mark style="color:red;"><strong>LibAsset</strong></mark>, <mark style="color:red;"><strong>LibRouter</strong></mark>, and <mark style="color:red;"><strong>Ownable2Step</strong></mark> and <mark style="color:red;"><strong>Pausable</strong></mark> from OpenZeppelin.</td></tr><tr><td>MagpieStargateBridgeV3</td><td>The <mark style="color:red;"><strong>MagpieStargateBridgeV3</strong></mark> contract facilitates cross-chain asset swaps and deposits, ensuring security through ownership control and pausable functions. It verifies swap signatures, manages deposit data, and handles asset bridging via the Stargate network. Key functionalities include updating internal callers, executing swaps, and processing deposits while preventing reentrancy and validating addresses.</td></tr><tr><td>MagpieSymbiosisBridge</td><td>The <mark style="color:red;"><strong>IMagpieSymbiosisBridge</strong></mark> interface extends the IBridge contract and introduces functionalities for cross-chain asset transfers and swaps. It enables the owner to update key addresses, including the <mark style="color:red;"><strong>WETH</strong></mark> token, portal, Axelar gateway, and gas receiver, ensuring flexible asset management. The interface features several swap functions, allowing for inbound and outbound asset operations, supported by rigorous signature verification to enhance security. Furthermore, the <mark style="color:red;"><strong>execute</strong></mark> function processes incoming commands from a source chain, validating them through the Axelar gateway before executing the associated payload. This design facilitates efficient cross-chain communication and execution of transactions.</td></tr><tr><td>LibAsset</td><td>The LibAsset library offers utility functions for handling asset transfers, approvals, and balance checks within Ethereum smart contracts. It identifies native assets (Ether) and provides functions to wrap and unwrap assets securely. The library facilitates balance retrieval for both the contract and specific addresses. Additionally, it ensures safe transfer and approval operations for ERC20 tokens using low-level calls with detailed error handling. Key functions include <mark style="color:red;"><strong>wrap</strong></mark>, <mark style="color:red;"><strong>unwrap</strong></mark>, <mark style="color:red;"><strong>transfer</strong></mark>, <mark style="color:red;"><strong>approve</strong></mark>, and <mark style="color:red;"><strong>permit</strong></mark>, enhancing asset management capabilities in cross-chain contexts.</td></tr><tr><td>LibBridge</td><td>The <mark style="color:red;"><strong>LibBridge</strong></mark> library provides essential functions for managing cross-chain swap operations within smart contracts. It computes bridge fees based on the asset type, ensuring accurate financial handling during swaps. The library enables the encoding and decoding of deposit data hashes, facilitating secure data management across different networks. It also incorporates robust error handling for invalid swap conditions and provides methods for both inbound and outbound swap operations. Key functionalities include fee calculation, deposit data encoding, and executing swaps with native and ERC20 assets, optimizing cross-chain transaction processes.</td></tr><tr><td>LibRouter</td><td>The LibRouter library provides functionalities for handling swap operations in smart contracts. It processes incoming data to create a structured <mark style="color:red;"><strong>SwapData</strong></mark> object while validating transaction deadlines. The library facilitates fee transfers, including gas fees and affiliate fees, while managing permissions through an approval mechanism. It verifies signatures to ensure transaction authenticity, utilizing EIP-712 standards for structured data hashing. Key features include <mark style="color:red;"><strong>getData</strong></mark>, <mark style="color:red;"><strong>transferFees</strong></mark>, <mark style="color:red;"><strong>permit</strong></mark>, and <mark style="color:red;"><strong>verifySignature</strong></mark>, enabling robust and secure cross-chain swap functionality.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fly.trade/developers/fly.trade-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
