VaultFormulas
VaultFormulas
Addresses
Chain | Address |
---|---|
Arbitrum Sepolia | 0x9454d1dfCDf41A32Ea25a05B70ebC54B05ACCfC1 |
Base Sepolia | 0x4F29Ae8f4F363B2ca5fb6ec10bA20705158E4A76 |
Base Mainnet | 0x5E31ee796Ff17c3BC5994A524F3969809Dd0cE8D |
Functions
constructor
constructor(struct StorageInstance app_) public
This contract is not designed to be upgradable and is strictly a logic contract. Hance, we are directly initializing the contract from the constructor.
balanceOf
function balanceOf(address account) public view returns (uint256)
See {IERC20-balanceOf}.
totalSupply
function totalSupply() public view returns (uint256)
See {IERC20-totalSupply}.
activeWithdrawRequest
Whether owner
has an active withdraw request
function activeWithdrawRequest(address owner) public 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) public 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 |
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() public 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 |
_computeUtilizationRatio
function _computeUtilizationRatio() public 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) public view returns (PerShare nextRate, uint64 remainingSeconds)
computePenalty
Apply a given penalty rate to a shares
quantity
function computePenalty(
Shares shares,
PerShare penaltyRate,
uint64 maxPenaltySeconds
) public 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 |