DInterestLens

withdrawableAmountOfDeposit(contract DInterest pool, uint64 depositID, uint256 virtualTokenAmount) → uint256 withdrawableAmount, uint256 feeAmount (external)

Computes the amount of stablecoins that can be withdrawn by burning virtualTokenAmount virtual tokens from the deposit with ID depositID at time timestamp.

@dev The queried timestamp should >= the deposit's lastTopupTimestamp, since the information before this time is forgotten.

@param pool The DInterest pool

@param depositID The ID of the deposit

@param virtualTokenAmount The amount of virtual tokens to burn

@return withdrawableAmount The amount of stablecoins (after fee) that can be withdrawn @return feeAmount The amount of fees that will be given to the beneficiary

accruedInterestOfFunding(contract DInterest pool, uint64 fundingID) → uint256 fundingInterestAmount (external)

Computes the floating-rate interest accrued in the floating-rate bond with ID fundingID. @param pool The DInterest pool

@param fundingID The ID of the floating-rate bond

@return fundingInterestAmount The interest accrued, in stablecoins

fundingIsActive(contract DInterest pool, uint64 fundingID) → bool (external)

A floating-rate bond is no longer active if its principalPerToken becomes 0, which occurs when the corresponding deposit is completely withdrawn. When such a deposit is topped up, a new Funding struct and floating-rate bond will be created.

@param pool The DInterest pool

@param fundingID The ID of the floating-rate bond

@return True if the funding is active, false otherwise

totalInterestOwedToFunders(contract DInterest pool) → uint256 interestOwed (public)

Computes the floating interest amount owed to deficit funders, which will be paid out when a funded deposit is withdrawn.

Formula:∑irecordedFundedPrincipalAmounti(incomeIndexrecordedMoneyMarketIncomeIndexi−1)=incomeIndex(∑irecordedFundedPrincipalAmountirecordedMoneyMarketIncomeIndexi)−∑irecordedFundedPrincipalAmounti\sum_i recordedFundedPrincipalAmount_i (\frac{incomeIndex}{recordedMoneyMarketIncomeIndex_i} - 1) = incomeIndex (\sum_i \frac{recordedFundedPrincipalAmount_i}{recordedMoneyMarketIncomeIndex_i}) - \sum_i recordedFundedPrincipalAmount_i∑i​recordedFundedPrincipalAmounti​(recordedMoneyMarketIncomeIndexi​incomeIndex​−1)=incomeIndex(∑i​recordedMoneyMarketIncomeIndexi​recordedFundedPrincipalAmounti​​)−∑i​recordedFundedPrincipalAmounti​​

where i refers to a funding

@param pool The DInterest pool

@return interestOwed The floating-rate interest accrued to all floating-rate bond holders

surplusOfDeposit(contract DInterest pool, uint64 depositID) → bool isNegative, uint256 surplusAmount (public)

Computes the surplus of a deposit, which is the raw surplus of the unfunded part of the deposit. If the deposit is not funded, this will return the same value as {rawSurplusOfDeposit}. @param depositID The ID of the deposit

@return isNegative True if the surplus is negative, false otherwise

@return surplusAmount The absolute value of the surplus, in stablecoins

_depositVirtualTokenToPrincipal(struct DInterest.Deposit depositEntry, uint256 virtualTokenAmount) → uint256 (internal)

Converts a virtual token value into the corresponding principal value. Principal refers to deposit + full interest + fee.

@param depositEntry The deposit struct

@param virtualTokenAmount The virtual token value

@return The corresponding principal value

rawSurplusOfDeposit(uint64 depositID) → bool isNegative, uint256 surplusAmount (public)

Computes the raw surplus of a deposit, which is the current value of the deposit in the money market minus the amount owed (deposit + interest + fee). The deposit's funding status is not considered here, meaning even if a deposit's fixed-rate interest is fully funded, it likely will still have a non-zero surplus.

@param depositID The ID of the deposit

@return isNegative True if the surplus is negative, false otherwise

@return surplusAmount The absolute value of the surplus, in stablecoins

Last updated