SynapseIntentPreviewer

Git Source

Inherits: ISynapseIntentPreviewer

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

previewIntent

Preview the completion of a user intent.

Will not revert if the intent cannot be completed, returns empty values instead.

function previewIntent(
    address swapQuoter,
    address forwardTo,
    address tokenIn,
    address tokenOut,
    uint256 amountIn
)
    external
    view
    returns (uint256 amountOut, ISynapseIntentRouter.StepParams[] memory steps);

Parameters

NameTypeDescription
swapQuoteraddressPeripheral contract to use for swap quoting
forwardToaddressThe address to which the proceeds of the intent should be forwarded to. Note: if no forwarding is required (or done within the intent), use address(0).
tokenInaddressInitial token for the intent
tokenOutaddressFinal token for the intent
amountInuint256Initial amount of tokens to use for the intent

Returns

NameTypeDescription
amountOutuint256Final amount of tokens to receive. Zero if the intent cannot be completed.
stepsISynapseIntentRouter.StepParams[]Steps to use in SynapseIntentRouter in order to complete the intent. Empty if the intent cannot be completed, or if intent is a no-op (tokenIn == tokenOut).

_createSwapSteps

Helper function to create steps for a swap.

function _createSwapSteps(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    DefaultParams memory params,
    address forwardTo
)
    internal
    view
    returns (ISynapseIntentRouter.StepParams[] memory steps);

_createAddLiquiditySteps

Helper function to create steps for adding liquidity.

function _createAddLiquiditySteps(
    address tokenIn,
    address tokenOut,
    DefaultParams memory params,
    address forwardTo
)
    internal
    view
    returns (ISynapseIntentRouter.StepParams[] memory steps);

_createRemoveLiquiditySteps

Helper function to create steps for removing liquidity.

function _createRemoveLiquiditySteps(
    address tokenIn,
    address tokenOut,
    DefaultParams memory params,
    address forwardTo
)
    internal
    view
    returns (ISynapseIntentRouter.StepParams[] memory steps);

_verifyLpToken

function _verifyLpToken(address pool, address token) internal view;

_createHandleHativeSteps

Helper function to create steps for wrapping or unwrapping native gas tokens.

function _createHandleHativeSteps(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    address forwardTo
)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams[] memory steps);

_createSwapStep

Helper function to create a single step for a swap.

function _createSwapStep(
    address tokenIn,
    address tokenOut,
    DefaultParams memory params,
    address forwardTo
)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams memory);

_createWrapNativeStep

Helper function to create a single step for wrapping native gas tokens.

function _createWrapNativeStep(
    address wrappedNative,
    uint256 msgValue,
    address forwardTo
)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams memory);

_createUnwrapNativeStep

Helper function to create a single step for unwrapping native gas tokens.

function _createUnwrapNativeStep(
    address wrappedNative,
    address forwardTo
)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams memory);

_toStepsArray

Helper function to construct an array of steps having a single step.

function _toStepsArray(ISynapseIntentRouter.StepParams memory step0)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams[] memory);

_toStepsArray

Helper function to construct an array of steps having two steps.

function _toStepsArray(
    ISynapseIntentRouter.StepParams memory step0,
    ISynapseIntentRouter.StepParams memory step1
)
    internal
    pure
    returns (ISynapseIntentRouter.StepParams[] memory);

Errors

SIP__NoOpForwardNotSupported

error SIP__NoOpForwardNotSupported();

SIP__PoolTokenMismatch

error SIP__PoolTokenMismatch();

SIP__PoolZeroAddress

error SIP__PoolZeroAddress();

SIP__RawParamsEmpty

error SIP__RawParamsEmpty();

SIP__TokenNotNative

error SIP__TokenNotNative();