MagpieRouterV2
Last updated
Last updated
The MagpieRouterV2 contract serves as the implementation of the IMagpieRouterV2 interface. It provides functions for executing token swaps, managing operational states, and dynamically updating function selectors for handling commands. The functions enforce necessary checks and interact with underlying libraries like LibSwap, LibCommand, and LibUniswapV3 to execute operations. Key functionalities include pausing and unpausing the contract, handling swaps and silent swaps, and estimating gas usage for swaps. Access control is strictly enforced using OpenZeppelin's Ownable2Step, ensuring that only the contract owner can perform critical updates and operations.
this function is used to pause the contract incase of any emergency.
this function is used to unpause the contract after the crisis has been resolved the the contract is redy to be used again.
this function is used to retrieve the selector for the given command type from the Magpie Storage.
Input:
Field | Type | Description |
---|---|---|
Output:
Field | Type | Description |
---|---|---|
the updateSelector function is an administrative tool within a smart contract that allows the owner to update the mapping of command types to function selectors.
Input
Gets the selector at the specific commandType.
Input:
Output:
the enforceDeadline function is used to enforce time constraints on certain operations within a smart contract. By checking if the current time has exceeded a specified deadline and reverting if it has, the function ensures that operations are only executed within their valid time windows.
Input
Handle uniswapV3SwapCallback requests from any protocol that is based on UniswapV3.
Input
This function is useful for determining whether a specific command action within a swap sequence involves moving tokens.
Input
Output
the estimateSwapGas function provides an external interface for estimating the gas cost of a token swap operation without actually executing the swap.
Input
Output
the swap function provides an external interface for performing token swaps, with the additional feature of triggering events. It simplifies the swap process for external callers by handling the complexities internally through the execute function. The inclusion of event triggering makes this function suitable for scenarios where tracking swap operations is necessary
Input
Output
the silentSwap function provides an external interface for performing token swaps. It simplifies the swap process for external callers by handling the complexities internally through the execute function. The function's design allows for straightforward token swaps without additional overhead like event logging or gas estimation, making it suitable for users or contracts seeking to perform swaps with minimal extra features.
Input
Output
the execute function is a comprehensive and versatile function that handles the execution of a sequence of commands, typically for the swap operation. It includes advanced features like gas estimation and event triggering.
Input
Output
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
The different commands like approval, transfer, transferFrom etc.
The function selector for each of the commands.
commandType
uint16
The different commands like approval, transfer, transferFrom etc.
selector
bytes4
The function selector for each of these commands.
Identifier for each command. We have one selector / command.
The function selector for the specified command.
deadline
uint256
The timestamp in epochs beyond which the transaction will get expired.
amount0Delta
int256
the changes in the amount of the first token involved in the swap
amount1Delta
int256
the changes in the amount of the second token involved in the swap
data
bytes calldata
a byte array containing additional information needed for the callback.
commandAction
CommandAction
bool
It will return true if there is a movement in tokens like approval, transfer, transferFrom, wrap and unwrap.
bytes calldata
A bytes array containing input parameters for swapping.
amountOut
uint256
The amount received after swapping.
gasUsed
uint256
The cost of gas while performing the swap.
bytes calldata
A bytes array containing input parameters for swapping.
amountOut
uint256
The amount received after swapping.
bytes calldata
A bytes array containing input parameters for swapping.
amountOut
uint256
The amount received after swapping.
triggerEvent
bool
An indicator if the function needs to trigger the swap event.
amountOut
uint256
The amount received after swapping.
gasUsed
uint256
The gas utilised during swapping.