Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IZap

Git Source

Interface for Zap contract

Defines functions to add and remove liquidity with wrapping/unwrapping in one transaction

Functions

zapIn

Add liquidity to SPA and automatically wrap SPA tokens

function zapIn(
    address spa,
    address wspa,
    address receiver,
    uint256 minMintAmount,
    uint256[] calldata amounts
)
    external
    returns (uint256 wspaAmount);

Parameters

NameTypeDescription
spaaddressAddress of the SPA contract
wspaaddressAddress of the wrapped SPA token contract
receiveraddressAddress to receive the wrapped SPA tokens
minMintAmountuint256Minimum amount of SPA tokens to receive
amountsuint256[]Array of token amounts to add

Returns

NameTypeDescription
wspaAmountuint256Amount of wrapped SPA tokens minted

zapOut

Remove liquidity from SPA by unwrapping SPA tokens first

function zapOut(
    address spa,
    address wspa,
    address receiver,
    uint256 wspaAmount,
    uint256[] calldata minAmountsOut,
    bool proportional
)
    external
    returns (uint256[] memory amounts);

Parameters

NameTypeDescription
spaaddressAddress of the SPA contract
wspaaddressAddress of the wrapped SPA token contract
receiveraddressAddress to receive the tokens
wspaAmountuint256Amount of wrapped SPA tokens to redeem
minAmountsOutuint256[]Minimum amounts of tokens to receive
proportionalboolIf true, withdraws proportionally; if false, uses minAmountsOut

Returns

NameTypeDescription
amountsuint256[]Array of token amounts received

zapOutSingle

Unwrap wSPA tokens and redeem a single asset

function zapOutSingle(
    address spa,
    address wspa,
    address receiver,
    uint256 wspaAmount,
    uint256 tokenIndex,
    uint256 minAmountOut
)
    external
    returns (uint256 amount);

Parameters

NameTypeDescription
spaaddressAddress of the SPA contract
wspaaddressAddress of the wrapped SPA token contract
receiveraddressAddress to receive the tokens
wspaAmountuint256Amount of wrapped SPA tokens to redeem
tokenIndexuint256Index of the token to receive
minAmountOutuint256Minimum amount of token to receive

Returns

NameTypeDescription
amountuint256Amount of token received

Events

ZapIn

event ZapIn(
    address indexed spa, address indexed user, address indexed receiver, uint256 wspaAmount, uint256[] inputAmounts
);

ZapOut

event ZapOut(
    address indexed spa,
    address indexed user,
    address indexed receiver,
    uint256 wspaAmount,
    uint256[] outputAmounts,
    bool proportional
);