Skip to main content

IVaultFormulas

IVaultFormulas

Addresses

ChainAddress

Functions

totalSupply

function totalSupply() external view returns (uint256)
Dev note

See {IERC20-totalSupply}.

activeWithdrawRequest

Whether owner has an active withdraw request

function activeWithdrawRequest(address owner) external view returns (bool status)

Parameters

NameTypeDescription
owneraddressAddress for which to check request

Return Values

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

NameTypeDescription
owneraddressAddress for which to check request

Return Values

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

NameTypeDescription
sharesSharesShares that would be requested
accountaddressAccount for which to preview the request

Return Values

NameTypeDescription
durationuint64Duration of the resulting WithdrawRequest
offsetint64Time 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

NameTypeDescription
sharesSharesRequest quantity
penaltyRatePerShareRate to apply
maxPenaltySecondsuint64Maximum penalty returned

Return Values

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

NameTypeDescription
receiveraddressaddress that will be receiving the deposit

Return Values

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

NameTypeDescription
receiveraddressaddress that will be receiving the minted shares

Return Values

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

NameTypeDescription
owneraddressOwner of the withdraw request.

Return Values

NameTypeDescription
redeemFractionFPUnsignedAvailable 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
)
Dev note

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

NameTypeDescription
assetsAuint256Assets of rate A
sharesASharesShares of rate A
assetsBuint256Assets of rate B
sharesBSharesShares of rate B

Return Values

NameTypeDescription
assetsuint256Assets of lesser rate
sharesSharesShares 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)
Dev note

DomFiPerp.getTotalPnL() is extremely expensive, call _computeUtilizationRatio() and save results if reuse is necessary.

Return Values

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

NameTypeDescription
utilizationRatioFPSignedCurrent utilization ratio of the vault