SynapseIntentRouter

Git Source

Inherits: ISynapseIntentRouter, ISynapseIntentRouterErrors

State Variables

NATIVE_GAS_TOKEN

The address reserved for the native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc.).

address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

FULL_BALANCE

Amount value that signals that the Zap step should be performed using the full ZapRecipient balance.

uint256 internal constant FULL_BALANCE = type(uint256).max;

Functions

completeIntentWithBalanceChecks

Kindly ask SIR to complete the provided intent by completing a series of Zap steps using the provided ZapRecipient contract.

  • Each step is verified to be a correct Zap as per IZapRecipient specification.
  • The amounts used for each step can be predetermined or based on the proceeds from the previous steps.
  • SIR does not perform any checks on the Zap Data; the user is responsible for ensuring correct encoding.
  • The user is responsible for selecting the correct ZapRecipient for their intent: ZapRecipient must be able to modify the Zap Data to adjust to possible changes in the passed amount value.
  • SIR checks that the ZapRecipient balance for every token in steps has not increased after the last step.

Typical workflow involves a series of preparation steps followed by the last step representing the user intent such as bridging, depositing, or a simple transfer to the final recipient. The ZapRecipient must be the funds recipient for the preparation steps, while the final recipient must be used for the last step.

function completeIntentWithBalanceChecks(
    address zapRecipient,
    uint256 amountIn,
    uint256 minLastStepAmountIn,
    uint256 deadline,
    StepParams[] calldata steps
)
    external
    payable;

Parameters

NameTypeDescription
zapRecipientaddressAddress of the IZapRecipient contract to use for the Zap steps
amountInuint256Initial amount of tokens (steps[0].token) to transfer into ZapRecipient
minLastStepAmountInuint256Minimum amount of tokens (steps[N-1].token) to use for the last step
deadlineuint256Deadline for the intent to be completed
stepsStepParams[]Parameters for each step. Use amount = type(uint256).max for steps that should use the full ZapRecipient balance.

completeIntent

Kindly ask SIR to complete the provided intent by completing a series of Zap steps using the provided ZapRecipient contract.

This function is identical to completeIntentWithBalanceChecks except that it does not verify that the ZapRecipient balance for every token in steps has not increased after the last Zap. Anyone using this function must validate that the funds are fully spent by ZapRecipient using other means like separate on-chain checks or off-chain simulation.

function completeIntent(
    address zapRecipient,
    uint256 amountIn,
    uint256 minLastStepAmountIn,
    uint256 deadline,
    StepParams[] calldata steps
)
    public
    payable;

_transferInputAsset

Transfers the input asset from the user into ZapRecipient custody. This asset will later be used to perform the zap steps.

function _transferInputAsset(address zapRecipient, address token, uint256 amount) internal;

_performZap

Performs a Zap step, using the provided msg.value and calldata. Validates the return data from ZapRecipient as per IZapRecipient specification.

function _performZap(address zapRecipient, uint256 msgValue, bytes memory zapRecipientCallData) internal;