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

IRedemptionPool

Git Source

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

NameTypeDescription
assetsAmountuint256Amount of assets to redeem
receiveraddressAddress to receive the reserve assets
minReserveAssetOutuint256Minimum reserve assets to receive (slippage protection)

Returns

NameTypeDescription
reserveAmountuint256Amount 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

NameTypeDescription
assetsAmountuint256Amount of assets to preview

Returns

NameTypeDescription
reserveAmountuint256Amount of reserve assets that would be received

deposit

Deposit reserve assets into the contract to fund redemptions

function deposit(uint256 reserveAmount) external;

Parameters

NameTypeDescription
reserveAmountuint256Amount 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

NameTypeDescription
reserveAmountuint256Amount of reserve assets to withdraw
receiveraddressAddress 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

NameTypeDescription
withdrawAssetaddressAddress of the asset to withdraw
amountuint256Amount of the asset to withdraw
receiveraddressAddress to receive the asset

setExchangeRate

Update the exchange rate (assets to reserve assets)

Restricted to admin role

function setExchangeRate(uint256 newRate) external;

Parameters

NameTypeDescription
newRateuint256New 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

NameTypeDescription
<none>uint256Exchange 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

NameTypeDescription
<none>ERC20BurnableAddress of the asset token

reserveAsset

Get the reserve asset token address

function reserveAsset() external view returns (IERC20);

Returns

NameTypeDescription
<none>IERC20Address of the reserve asset token

reserveBalance

Get the current reserve asset balance

function reserveBalance() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Reserve 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

NameTypeDescription
redeemeraddressAddress that performed the redemption
assetsAmountuint256Amount of assets burned/transferred
reserveAmountuint256Amount of reserve assets received

ExchangeRateUpdated

Emitted when the exchange rate is updated

event ExchangeRateUpdated(uint256 oldRate, uint256 newRate);

Parameters

NameTypeDescription
oldRateuint256Previous exchange rate
newRateuint256New exchange rate

Withdraw

Emitted when tokens are withdrawn via withdrawTokens

event Withdraw(address indexed caller, address indexed withdrawAsset, uint256 amount, address indexed receiver);

Parameters

NameTypeDescription
calleraddressAddress that initiated the withdrawal (admin)
withdrawAssetaddressAddress of the token withdrawn
amountuint256Amount withdrawn
receiveraddressAddress that received the tokens

ReservesDeposited

Emitted when reserve assets are deposited into the pool

event ReservesDeposited(address indexed depositor, uint256 amount);

Parameters

NameTypeDescription
depositoraddressAddress that deposited the reserve assets
amountuint256Amount of reserve assets deposited