π§βπ»Contracts
Overviews
A cross-chain swap is executed by sending a quoted swap request from the DApp to the PheasantNetworkSwap contract.
Technical Details
TransactionRequest
A structured format for sending a quoted swap request.
/// @param data Data of the quoted request.
/// @param toChainId Chain ID of the Swap destination.
/// @param swapToolIndex DEX Protocol index (for administrative use).
/// @param toolContract To address of the quoted request (DEX Protocol contract address).
/// @param fromToken Token address of the Swap source.
/// @param toToken Token address of the Swap destination.
/// @param amount Amount of the Swap source.
/// @param value Value of the quoted request.
/// @param gas Gas of the quoted request.
/// @param quoteTimestamp Timestamp of quote execution for RelayerFee determination.
struct TransactionRequest {
bytes data;
string toChainId;
uint16 swapToolIndex;
address toolContract;
address fromToken;
address toToken;
uint256 amount;
uint256 value;
uint256 gas;
uint256 quoteTimestamp;
}execute()
A function that executes the swap by calling the DEX protocol.
Low-Level Call Execution
The PheasantNetworkSwap contract initiates the swap by making a low-level call to the specified DEX protocol contract. It passes the quoted request parameters (data, gas and value), forwarding the transaction to the DEX protocol for execution.
RelayerFee
The RelayerFee is temporarily stored in the contract using a 32-byte key until the swapβs success is confirmed. Success is determined off-chain by querying the DEX protocol through the relayer.
The following code stores the RelayerFee along with a 32-byte key:
refund()
If the swap fails, the RelayerFee is refunded to the user.
withdraw()
If the swap succeeds, the Relayer can withdraw the earned RelayerFee.
Last updated