Interactions
The SelfPeggingAsset contract exposes the primary trading and liquidity management functions for interacting with Tapio pools. This section details the available functions for minting SPAs, executing swaps, and redeeming assets, along with their parameters and return values for integration into trading interfaces and DeFi applications.
User Operations
mint
Adds liquidity to the pool by depositing tokens in the amounts specified in _amounts
. Returns the amount of SPA tokens minted, which must be at least _minMintAmount
.
function mint(uint256[] calldata _amounts, uint256 _minMintAmount) external returns (uint256);
Parameters
_amounts
uint256[]
Unconverted token balances used to mint pool token
_minMintAmount
uint256
Minimum amount of pool token to mint
Returns
<none>
uint256
The amount of pool tokens minted
swap
Exchange between two underlying tokens.
function swap(uint256 _i, uint256 _j, uint256 _dx, uint256 _minDy) external returns (uint256);
Parameters
_i
uint256
Token index to swap in
_j
uint256
Token index to swap out
_dx
uint256
Unconverted amount of token _i
to swap in
_minDy
uint256
Minimum token _j
to swap out in converted balance
Returns
<none>
uint256
Amount of swap out
redeemProportion
Redeems pool token to underlying tokens proportionally.
function redeemProportion(uint256 _amount, uint256[] calldata _minRedeemAmounts) external returns (uint256[] memory);
Parameters
_amount
uint256
Amount of pool token to redeem
_minRedeemAmounts
uint256[]
Minimum amount of underlying tokens to get
Returns
<none>
uint256[]
An array of the amounts of each token to redeem
redeemSingle
Redeem pool token to one specific underlying token.
function redeemSingle(uint256 _amount, uint256 _i, uint256 _minRedeemAmount) external returns (uint256);
Parameters
_amount
uint256
Amount of pool token to redeem
_i
uint256
Index of the token to redeem to
_minRedeemAmount
uint256
Minimum amount of the underlying token to redeem to
Returns
<none>
uint256
Amount received
redeemMulti
Redeems underlying tokens.
function redeemMulti(uint256[] calldata _amounts, uint256 _maxRedeemAmount) external returns (uint256[] memory);
Parameters
_amounts
uint256[]
Amounts of underlying tokens to redeem to
_maxRedeemAmount
uint256
Maximum of pool token to redeem
Returns
<none>
uint256[]
Amounts received
Governance Functions
pause
Pause mint/swap/redeem actions.
function pause() external;
Access: only Owner (via Keeper)
unpause
Unpause mint/swap/redeem actions.
function unpause() external;
Access: only Owner (via Keeper)
setMintFee
Updates the mint fee on pool.
function setMintFee(uint256 _mintFee) external;
Parameters
_mintFee
uint256
The new mint fee value. Uses 10 decimal precision (denominator = 10^10). Examples: 1e6 = 0.01%, 1e7 = 0.1%, 1e8 = 1%
Access: only Owner (via Keeper)
setSwapFee
Updates the swap fee on pool.
function setSwapFee(uint256 _swapFee) external;
Parameters
_swapFee
uint256
The new swap fee value. Uses 10 decimal precision (denominator = 10^10). Examples: 1e6 = 0.01%, 1e7 = 0.1%, 1e8 = 1%
Access: only Owner (via Keeper)
setRedeemFee
Updates the redeem fee on pool.
function setRedeemFee(uint256 _redeemFee) external;
Parameters
_redeemFee
uint256
The new redeem fee value. Uses 10 decimal precision (denominator = 10^10). Examples: 1e6 = 0.01%, 1e7 = 0.1%, 1e8 = 1%
Access: only Owner (via Keeper)
setOffPegFeeMultiplier
Updates the off peg fee multiplier of pool.
function setOffPegFeeMultiplier(uint256 _offPegFeeMultiplier) external;
Parameters
_offPegFeeMultiplier
uint256
The new off peg fee multiplier value
Access: only Owner (via Keeper)
setExchangeRateFeeFactor
Updates the exchange rate fee factor of pool.
function setExchangeRateFeeFactor(uint256 _exchangeRateFeeFactor) external;
Parameters
_exchangeRateFeeFactor
uint256
The new exchange rate fee factor value
Access: only Owner (via Keeper)
setDecayPeriod
Updates the decay period
function setDecayPeriod(uint256 _decayPeriod) external;
Parameters
_decayPeriod
uint256
The new decay period value
Access: only Owner (via Keeper)
setRateChangeSkipPeriod
Updates the rate change skip period of pool.
function setRateChangeSkipPeriod(uint256 _rateChangeSkipPeriod) external;
Parameters
_rateChangeSkipPeriod
uint256
The new rate change skip period value
Access: only Owner (via Keeper)
updateFeeErrorMargin
Updates the fee error margin of pool.
function updateFeeErrorMargin(uint256 newValue) external;
Parameters
newValue
uint256
The new fee error margin value
Access: only Owner (via Keeper)
updateYieldErrorMargin
Updates yield error margin of pool.
function updateYieldErrorMargin(uint256 newValue) external;
Parameters
newValue
uint256
The new yield error margin value
Access: only Owner (via Keeper)
distributeLoss
Distribute losses by rebasing negatively
function distributeLoss() external;
Access: only Owner (via Keeper)
View Functions
getSwapAmount
Computes the output amount after the swap.
function getSwapAmount(uint256 _i, uint256 _j, uint256 _dx) external view returns (uint256, uint256);
Parameters
_i
uint256
Token index to swap in
_j
uint256
Token index to swap out
_dx
uint256
Unconverted amount of token _i
to swap in
Returns
<none>
uint256
Unconverted amount of token _j
to swap out
<none>
uint256
The amount of fees charged
getMintAmount
Compute the amount of pool token that can be minted.
function getMintAmount(uint256[] calldata _amounts) external view returns (uint256, uint256);
Parameters
_amounts
uint256[]
Unconverted token balances
Returns
<none>
uint256
The amount of pool tokens to be minted
<none>
uint256
The amount of fees charged
getCurrentA
Get the current A value from the controller if set, or use the local value.
function getCurrentA() external view returns (uint256);
Returns
<none>
uint256
The current A value
getTokens
Returns the array of token addresses in the pool.
function getTokens() external view returns (address[] memory);
Returns
<none>
address[]
Array of token addresses in the pool
getRedeemProportionAmount
Computes the amounts of underlying tokens when redeeming pool token.
function getRedeemProportionAmount(uint256 _amount) external view returns (uint256[] memory, uint256);
Parameters
_amount
uint256
Amount of pool tokens to redeem
Returns
<none>
uint256[]
An array of the amounts of each token to redeem
<none>
uint256
The amount of fee charged
getRedeemSingleAmount
Computes the amount when redeeming pool token to one specific underlying token.
function getRedeemSingleAmount(uint256 _amount, uint256 _i) external view returns (uint256, uint256);
Parameters
_amount
uint256
Amount of pool token to redeem
_i
uint256
Index of the underlying token to redeem to
Returns
<none>
uint256
The amount of single token that will be redeemed
<none>
uint256
The amount of pool token charged for redemption fee
getRedeemMultiAmount
Compute the amount of pool token that needs to be redeemed.
function getRedeemMultiAmount(uint256[] calldata _amounts) external view returns (uint256, uint256);
Parameters
_amounts
uint256[]
Unconverted token balances
Returns
<none>
uint256
The amount of pool token that needs to be redeemed
<none>
uint256
The amount of pool token charged for redemption fee
Last updated