RedemptionPoolV0
Inherits: IRedemptionPool, AccessManaged, Pausable, ReentrancyGuardTransient
Title: RedemptionPoolV0
Redeems asset tokens for reserve assets at a configurable exchange rate
Non-upgradeable. Uses AccessManager for role-based access; ROLE_REDEEMER for redeem(), ADMIN for deposit/withdraw/setExchangeRate/pause/unpause. Exchange rate is reserve asset per asset (1e18 = 1:1) in the precision of the asset token.
The asset MUST support burnFrom(address,uint256) as defined in ERC20Burnable.
State Variables
asset
Asset token to be redeemed (burned); e.g. apxUSD
ERC20Burnable public immutable asset
reserveAsset
Reserve asset paid out on redemption; e.g. USDC
IERC20 public immutable reserveAsset
assetHasMoreDecimals
True if asset has more decimals than reserve, false otherwise
bool private immutable assetHasMoreDecimals
decimalScalingFactor
Scaling factor for decimal conversion: 10^abs(assetDecimals - reserveDecimals)
uint256 private immutable decimalScalingFactor
exchangeRate
Exchange rate: reserve asset per asset, 1e18 = 1:1 (reserveAmount = assetsAmount * exchangeRate / 1e18)
uint256 public exchangeRate
Functions
constructor
Initializes the redemption pool
constructor(address initialAuthority, ERC20Burnable asset_, IERC20 reserveAsset_) AccessManaged(initialAuthority);
Parameters
| Name | Type | Description |
|---|---|---|
initialAuthority | address | Address of the AccessManager contract |
asset_ | ERC20Burnable | Asset token (e.g. apxUSD) |
reserveAsset_ | IERC20 | Reserve asset token (e.g. USDC) |
previewRedeem
Preview how much reserve assets would be received for a given assets amount
Does not consider pause state or reserve balance; callers should check paused() and reserveBalance() Rounding is downward in favor of the pool. Formula: reserveAmount = (assetsAmount * exchangeRate) / (1e18 * 10^(assetDecimals - reserveDecimals))
function previewRedeem(uint256 assetsAmount) public view override 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 |
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
override
restricted
whenNotPaused
nonReentrant
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 |
deposit
Deposit reserve assets into the contract to fund redemptions
function deposit(uint256 reserveAmount) external override restricted nonReentrant;
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 amount, address receiver) external override restricted;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | |
receiver | address | Address to receive the reserve assets |
withdrawTokens
Withdraw excess assets from the contract
Use to recover tokens erroneously sent to the pool (e.g. asset or any other ERC20). Can also withdraw reserve asset; equivalent to withdraw() for that case.
function withdrawTokens(address withdrawAsset, uint256 amount, address receiver)
public
override
restricted
nonReentrant;
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 override restricted;
Parameters
| Name | Type | Description |
|---|---|---|
newRate | uint256 | Reserve asset per asset, 1e18 = 1:1 |
pause
Pause redemptions
Restricted to admin role
function pause() external restricted;
unpause
Unpause redemptions
Restricted to admin role
function unpause() external restricted;
reserveBalance
Get the current reserve asset balance
function reserveBalance() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Reserve asset balance available for redemptions |