IRedemptionPool
Inherits: IAccessManaged, EInvalidAddress, EInvalidAmount, EInsufficientBalance, ESlippageExceeded
Functions
redeem
Redeem assets for reserve assets at the current exchange rate
Requires ROLE_REDEEMER. Burns/transfers assets and sends reserve assets
function redeem(uint256 assetsAmount, address receiver, uint256 minReserveAssetOut)
external
returns (uint256 reserveAmount);
Parameters
| Name | Type | Description |
|---|---|---|
assetsAmount | uint256 | Amount of assets to redeem |
receiver | address | Address to receive the reserve assets |
minReserveAssetOut | uint256 | Minimum reserve assets to receive (slippage protection) |
Returns
| Name | Type | Description |
|---|---|---|
reserveAmount | uint256 | Amount of reserve assets received |
previewRedeem
Preview how much reserve assets would be received for a given assets amount
function previewRedeem(uint256 assetsAmount) external view returns (uint256 reserveAmount);
Parameters
| Name | Type | Description |
|---|---|---|
assetsAmount | uint256 | Amount of assets to preview |
Returns
| Name | Type | Description |
|---|---|---|
reserveAmount | uint256 | Amount of reserve assets that would be received |
deposit
Deposit reserve assets into the contract to fund redemptions
function deposit(uint256 reserveAmount) external;
Parameters
| Name | Type | Description |
|---|---|---|
reserveAmount | uint256 | Amount of reserve assets to deposit |
withdraw
Withdraw excess reserve assets from the contract
Restricted to admin role
function withdraw(uint256 reserveAmount, address receiver) external;
Parameters
| Name | Type | Description |
|---|---|---|
reserveAmount | uint256 | Amount of reserve assets to withdraw |
receiver | address | Address to receive the reserve assets |
withdrawTokens
Withdraw excess assets from the contract
Restricted to admin role
This function is used to support withdrawing tokens that are erroneously deposited to the redemption pool.
function withdrawTokens(address withdrawAsset, uint256 amount, address receiver) external;
Parameters
| Name | Type | Description |
|---|---|---|
withdrawAsset | address | Address of the asset to withdraw |
amount | uint256 | Amount of the asset to withdraw |
receiver | address | Address to receive the asset |
setExchangeRate
Update the exchange rate (assets to reserve assets)
Restricted to admin role
function setExchangeRate(uint256 newRate) external;
Parameters
| Name | Type | Description |
|---|---|---|
newRate | uint256 | New exchange rate in assets per reserve asset (1e18 = 1 asset per reserve asset) |
exchangeRate
Get the current exchange rate
function exchangeRate() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Exchange rate in assets per reserve asset (1e18 = 1 asset per reserve asset) |
asset
Get the asset token address
function asset() external view returns (ERC20Burnable);
Returns
| Name | Type | Description |
|---|---|---|
<none> | ERC20Burnable | Address of the asset token |
reserveAsset
Get the reserve asset token address
function reserveAsset() external view returns (IERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IERC20 | Address of the reserve asset token |
reserveBalance
Get the current reserve asset balance
function reserveBalance() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Reserve asset balance available for redemptions |
Events
Redeemed
Emitted when assets are redeemed for reserve assets
event Redeemed(address indexed redeemer, uint256 assetsAmount, uint256 reserveAmount);
Parameters
| Name | Type | Description |
|---|---|---|
redeemer | address | Address that performed the redemption |
assetsAmount | uint256 | Amount of assets burned/transferred |
reserveAmount | uint256 | Amount of reserve assets received |
ExchangeRateUpdated
Emitted when the exchange rate is updated
event ExchangeRateUpdated(uint256 oldRate, uint256 newRate);
Parameters
| Name | Type | Description |
|---|---|---|
oldRate | uint256 | Previous exchange rate |
newRate | uint256 | New exchange rate |
Withdraw
Emitted when tokens are withdrawn via withdrawTokens
event Withdraw(address indexed caller, address indexed withdrawAsset, uint256 amount, address indexed receiver);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Address that initiated the withdrawal (admin) |
withdrawAsset | address | Address of the token withdrawn |
amount | uint256 | Amount withdrawn |
receiver | address | Address that received the tokens |
ReservesDeposited
Emitted when reserve assets are deposited into the pool
event ReservesDeposited(address indexed depositor, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
depositor | address | Address that deposited the reserve assets |
amount | uint256 | Amount of reserve assets deposited |