Zap
Inherits: IZap, Ownable, 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 wLP addresses are passed as parameters to each function
Functions
constructor
constructor() Ownable(msg.sender);
zapIn
Add liquidity to SPA and automatically wrap LP tokens
function zapIn(
address spa,
address wlp,
address receiver,
uint256 minMintAmount,
uint256[] calldata amounts
)
external
nonReentrant
returns (uint256 wlpAmount);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wlp | address | Address of the wrapped LP token contract |
receiver | address | Address to receive the wrapped LP tokens |
minMintAmount | uint256 | Minimum amount of LP tokens to receive |
amounts | uint256[] | Array of token amounts to add |
Returns
Name | Type | Description |
---|---|---|
wlpAmount | uint256 | Amount of wrapped LP tokens minted |
zapOut
Remove liquidity from SPA by unwrapping LP tokens first
function zapOut(
address spa,
address wlp,
address receiver,
uint256 wlpAmount,
uint256[] calldata minAmountsOut,
bool proportional
)
external
nonReentrant
returns (uint256[] memory amounts);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wlp | address | Address of the wrapped LP token contract |
receiver | address | Address to receive the tokens |
wlpAmount | uint256 | Amount of wrapped LP 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 wLP tokens and redeem a single asset
function zapOutSingle(
address spa,
address wlp,
address receiver,
uint256 wlpAmount,
uint256 tokenIndex,
uint256 minAmountOut
)
external
nonReentrant
returns (uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
spa | address | Address of the SPA contract |
wlp | address | Address of the wrapped LP token contract |
receiver | address | Address to receive the tokens |
wlpAmount | uint256 | Amount of wrapped LP 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 |
recoverERC20
Recover tokens accidentally sent to this contract
function recoverERC20(address token, uint256 amount, address to) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of the token to recover |
amount | uint256 | Amount to recover |
to | address | Address to send the tokens to |
_mint
Call SPA's mint function
function _mint(address spa, uint256[] calldata amounts, uint256 minMintAmount) internal returns (uint256);
_deposit
Call WLPToken's deposit function
function _deposit(address wlp, uint256 assets, address receiver) internal returns (uint256);
_redeem
Call WLPToken's redeem function
function _redeem(address wlp, 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 LP 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();