Zap
Inherits: IZap, ReentrancyGuard
A helper contract to simplify liquidity provision and removal in Tapio
Allows users to add/remove liquidity with automatic wrapping/unwrapping in 1 tx
SPA and wSPA addresses are passed as parameters to each function
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
nonReentrant
returns (uint256 wspaAmount);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wspa | address | Address of the wrapped SPA token contract |
receiver | address | Address to receive the wrapped SPA tokens |
minMintAmount | uint256 | Minimum amount of SPA tokens to receive |
amounts | uint256[] | Array of token amounts to add |
Returns
Name | Type | Description |
---|---|---|
wspaAmount | uint256 | Amount 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
nonReentrant
returns (uint256[] memory amounts);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wspa | address | Address of the wrapped SPA token contract |
receiver | address | Address to receive the tokens |
wspaAmount | uint256 | Amount of wrapped SPA tokens to redeem |
minAmountsOut | uint256[] | Minimum amounts of tokens to receive |
proportional | bool | If true, withdraws proportionally; if false, uses minAmountsOut |
Returns
Name | Type | Description |
---|---|---|
amounts | uint256[] | 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
nonReentrant
returns (uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wspa | address | Address of the wrapped SPA token contract |
receiver | address | Address to receive the tokens |
wspaAmount | uint256 | Amount of wrapped SPA tokens to redeem |
tokenIndex | uint256 | Index of the token to receive |
minAmountOut | uint256 | Minimum amount of token to receive |
Returns
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of token received |
_mint
Call SPA's mint function
function _mint(address spa, uint256[] calldata amounts, uint256 minMintAmount) internal returns (uint256);
_deposit
Call WSPAToken's deposit function
function _deposit(address wspa, uint256 assets, address receiver) internal returns (uint256);
_redeem
Call WSPAToken's redeem function
function _redeem(address wspa, uint256 shares, address receiver) internal returns (uint256);
_redeemProportion
Call SPA's redeemProportion function
function _redeemProportion(
address spa,
uint256 amount,
uint256[] calldata minAmountsOut
)
internal
returns (uint256[] memory);
_redeemSingle
Call SPA's redeemSingle function
function _redeemSingle(
address spa,
uint256 amount,
uint256 tokenIndex,
uint256 minAmountOut
)
internal
returns (uint256);
_redeemMulti
Call SPA's redeemMulti function
function _redeemMulti(
address spa,
uint256[] calldata amounts,
uint256 maxRedeemAmount
)
internal
returns (uint256[] memory);
_getTokens
Get the tokens from SPA
function _getTokens(address spa) internal view returns (address[] memory);
_getPoolToken
Get the pool token from SPA
function _getPoolToken(address spa) internal view returns (address);
_revertBytes
Helper function to revert with the same error message as the original call
function _revertBytes(bytes memory data) internal pure;
Errors
ZeroAmount
error ZeroAmount();
InvalidParameters
error InvalidParameters();
CallFailed
error CallFailed();