MagpieRouterV2

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

FieldTypeDescription

commandType

uint16

The different commands like approval, transfer, transferFrom etc.

selector

bytes4

The function selector for each of these commands.

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

FieldTypeDescription

deadline

uint256

The timestamp in epochs beyond which the transaction will get expired.

fallback():

Handle uniswapV3SwapCallback requests from any protocol that is based on UniswapV3.

Input

FieldTypeDescription

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.

isTokenMovement():

This function is useful for determining whether a specific command action within a swap sequence involves moving tokens.

Input

FieldTypeDescription

commandAction

CommandAction

enum CommandAction {
    Call,
    Approval,
    TransferFrom,
    Transfer,
    Wrap,
    Unwrap,
    Balance,
    UniswapV2,
    UniswapV3,
    TraderJoeV2_1,
    Solidly,
    KyberSwapClassic,
    Ambient
}

Output

FieldTypeDescription

bool

It will return true if there is a movement in tokens like approval, transfer, transferFrom, wrap and unwrap.

estimateSwapGas():

the estimateSwapGas function provides an external interface for estimating the gas cost of a token swap operation without actually executing the swap.

Input

FieldTypeDescription

bytes calldata

A bytes array containing input parameters for swapping.

Output

FieldTypeDescription

amountOut

uint256

The amount received after swapping.

gasUsed

uint256

The cost of gas while performing the swap.

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

FieldTypeDescription

bytes calldata

A bytes array containing input parameters for swapping.

Output

FieldTypeDescription

amountOut

uint256

The amount received after swapping.

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

FieldTypeDescription

bytes calldata

A bytes array containing input parameters for swapping.

Output

FieldTypeDescription

amountOut

uint256

The amount received after swapping.

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

FieldTypeDescription

triggerEvent

bool

An indicator if the function needs to trigger the swap event.

Output

FieldTypeDescription

amountOut

uint256

The amount received after swapping.

gasUsed

uint256

The gas utilised during swapping.

Last updated