Addresses
Functions
totalSupply
function totalSupply() external view returns (uint256)
See {IERC20-totalSupply}.
activeWithdrawRequest
Whether owner has an active withdraw request
function activeWithdrawRequest(address owner) external view returns (bool status)
Parameters
| Name | Type | Description |
|---|
owner | address | Address for which to check request |
Return Values
| Name | Type | Description |
|---|
status | bool | false if request is nonexistent, complete, or expired, true otherwise |
expiredWithdrawRequest
Whether owner has an expired withdraw request
function expiredWithdrawRequest(address owner) external view returns (bool status)
Parameters
| Name | Type | Description |
|---|
owner | address | Address for which to check request |
Return Values
| Name | Type | Description |
|---|
status | bool | true if request expired, false if it's active, nonexistent, or completed |
_computeUtilizationRatio
function _computeUtilizationRatio() external returns (bool instantRedeemAvailable, FPSigned utilizationRatio)
previewRedeemRequest
Preview a withdraw request
function previewRedeemRequest(Shares shares, address account) external returns (uint64 duration, int64 offset)
Parameters
| Name | Type | Description |
|---|
shares | Shares | Shares that would be requested |
account | address | Account for which to preview the request |
Return Values
| Name | Type | Description |
|---|
duration | uint64 | Duration of the resulting WithdrawRequest |
offset | int64 | Time until the resulting request begins. |
previewPenalty
Get the next penalty rate/max for a user, based on an existing
expired request. User MUST have an expired request.
function previewPenalty(address user) external view returns (PerShare nextRate, uint64 remainingSeconds)
computePenalty
Apply a given penalty rate to a shares quantity
function computePenalty(
Shares shares,
PerShare penaltyRate,
uint64 maxPenaltySeconds
) external pure returns (
uint64 penalty
)
Parameters
| Name | Type | Description |
|---|
shares | Shares | Request quantity |
penaltyRate | PerShare | Rate to apply |
maxPenaltySeconds | uint64 | Maximum penalty returned |
Return Values
| Name | Type | Description |
|---|
penalty | uint64 | Seconds that must be waited before request begins |
getPendingWithdraw
Get the amount of collateral tied up in redeem requests. This is
the lesser of pendingWithdraw and the current value of pendingRedeem.
function getPendingWithdraw() external view returns (uint256)
maxDeposit
Max deposit that receiver can receive. See EIP-4626.
function maxDeposit(address receiver) external view returns (uint256 maxAssets)
Parameters
| Name | Type | Description |
|---|
receiver | address | address that will be receiving the deposit |
Return Values
| Name | Type | Description |
|---|
maxAssets | uint256 | Maximum collateral that can be deposited for receiver |
maxMint
Max shares that can be minted to receiver. See EIP-4626.
function maxMint(address receiver) external view returns (Shares maxShares)
Parameters
| Name | Type | Description |
|---|
receiver | address | address that will be receiving the minted shares |
Return Values
| Name | Type | Description |
|---|
maxShares | Shares | Maximum collateral that can be minted for receiver |
availableFraction
Compute the fraction of a request currently available to redeem
or withdraw. Executing requests reduces the available fraction.
function availableFraction(address owner) external view returns (FPUnsigned redeemFraction)
Parameters
| Name | Type | Description |
|---|
owner | address | Owner of the withdraw request. |
Return Values
| Name | Type | Description |
|---|
redeemFraction | FPUnsigned | Available fraction of request, from 0 to 1. |
maxWithdraw
function maxWithdraw(
address owner
) external returns (
uint256 maxAssets,
bool instantRedeemAvailable,
FPSigned utilizationRatio
)
maxRedeem
function maxRedeem(
address owner
) external returns (
Shares maxShares,
bool instantRedeemAvailable,
FPSigned utilizationRatio
)
getLesserRate
Given two rates, where each rate expressed in collateral units
per share (for instance, $/share), return the lesser rate.
function getLesserRate(
uint256 assetsA,
Shares sharesA,
uint256 assetsB,
Shares sharesB
) external pure returns (
uint256 assets,
Shares shares
)
When a user is withdrawing a certain amount of collateral, we want
to use the rate that would have them burn the greater amount of shares.
When they're redeeming shares, we want them to get the lesser amount of
collateral.
Parameters
| Name | Type | Description |
|---|
assetsA | uint256 | Assets of rate A |
sharesA | Shares | Shares of rate A |
assetsB | uint256 | Assets of rate B |
sharesB | Shares | Shares of rate B |
Return Values
| Name | Type | Description |
|---|
assets | uint256 | Assets of lesser rate |
shares | Shares | Shares of lesser rate |
getInstantRedeemAvailable
Whether instant redeems are available. When true, ERC4626 methods
will work without a pre-existing request, and attempting to increase a
request will instantly execute it.
function getInstantRedeemAvailable() external returns (bool available)
DomFiPerp.getTotalPnL() is extremely expensive, call
_computeUtilizationRatio() and save results if reuse is necessary.
Return Values
| Name | Type | Description |
|---|
available | bool | Whether instant redeems and withdraws are available |
getUtilizationRatio
Compute current utilization ratio of the vault. Utilization ratio
is the total size of all positions divided by the effective vault
balance: the vault balance minus pending trader PnL, minus pending
withdrawals.
function getUtilizationRatio() external returns (FPSigned utilizationRatio)
Return Values
| Name | Type | Description |
|---|
utilizationRatio | FPSigned | Current utilization ratio of the vault |