MagpieRouterV2
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.
pause():
this function is used to pause the contract incase of any emergency.
unpause():
this function is used to unpause the contract after the crisis has been resolved the the contract is redy to be used again.
getSelector():
this function is used to retrieve the selector for the given command type from the Magpie Storage.
Input:
Output:
updateSelector():
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
getSelector():
Gets the selector at the specific commandType.
Input:
Output:
enforceDeadline():
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
fallback():
Handle uniswapV3SwapCallback requests from any protocol that is based on UniswapV3.
Input
isTokenMovement():
This function is useful for determining whether a specific command action within a swap sequence involves moving tokens.
Input
Output
estimateSwapGas():
the estimateSwapGas function provides an external interface for estimating the gas cost of a token swap operation without actually executing the swap.
Input
Output
swap():
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
silentSwap():
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
execute():
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
Last updated