DInterest

deposit(uint256 depositAmount, uint64 maturationTimestamp) → uint64 depositID, uint256 interestAmount (external)

Create a deposit using depositAmount stablecoin that matures at timestamp maturationTimestamp.

@dev The ERC-721 NFT representing deposit ownership is given to msg.sender

@param depositAmount The amount of deposit, in stablecoin

@param maturationTimestamp The Unix timestamp of maturation, in seconds

@return depositID The ID of the created deposit

@return interestAmount The amount of fixed-rate interest

topupDeposit(uint64 depositID, uint256 depositAmount) → uint256 interestAmount (external)

Add depositAmount stablecoin to the existing deposit with ID depositID.

@dev The interest rate for the topped up funds will be the current oracle rate.

@param depositID The deposit to top up

@param depositAmount The amount to top up, in stablecoin

@return interestAmount The amount of interest that will be earned by the topped up funds at maturation

rolloverDeposit(uint64 depositID, uint64 maturationTimestamp) → uint256 newDepositID, uint256 interestAmount (external)

Withdraw all funds from deposit with ID depositID and use them to create a new deposit that matures at time maturationTimestamp

@param depositID The deposit to roll over

@param maturationTimestamp The Unix timestamp of the new deposit, in seconds

@return newDepositID The ID of the new deposit

withdraw(uint64 depositID, uint256 virtualTokenAmount, bool early) → uint256 withdrawnStablecoinAmount (external)

Withdraws funds from the deposit with ID depositID.

@dev Virtual tokens behave like zero coupon bonds, after maturation withdrawing 1 virtual token yields 1 stablecoin. The total supply is given by deposit.virtualTokenTotalSupply

@param depositID the deposit to withdraw from

@param virtualTokenAmount the amount of virtual tokens to withdraw

@param early True if intend to withdraw before maturation, false otherwise

@return withdrawnStablecoinAmount the amount of stablecoins withdrawn

fund(uint64 depositID, uint256 fundAmount) → uint64 fundingID (external)

Funds the fixed-rate interest of the deposit with ID depositID. In exchange, the funder receives the future floating-rate interest generated by the portion of the deposit whose interest was funded.

@dev The sender receives ERC-1155 multitokens (fundingMultitoken) representing their floating-rate bonds.

@param depositID The deposit whose fixed-rate interest will be funded

@param fundAmount The amount of fixed-rate interest to fund. If it exceeds surplusOfDeposit(depositID), it will be set to the surplus value instead.

@param fundingID The ID of the fundingMultitoken the sender received

payInterestToFunders(uint64 fundingID) → uint256 interestAmount (external)

Distributes the floating-rate interest accrued by a deposit to the floating-rate bond holders.

@param fundingID The ID of the floating-rate bond

@return interestAmount The amount of interest distributed, in stablecoins

calculateInterestAmount(uint256 depositAmount, uint256 depositPeriodInSeconds) → uint256 interestAmount (public)

Computes the amount of fixed-rate interest (before fees) that will be given to a deposit of depositAmount stablecoins that matures in depositPeriodInSeconds seconds.

@param depositAmount The deposit amount, in stablecoins

@param depositPeriodInSeconds The deposit period, in seconds

@return interestAmount The amount of fixed-rate interest (before fees)

surplus() → bool isNegative, uint256 surplusAmount (public)

Computes the pool's overall surplus, which is the value of its holdings in the moneyMarket minus the amount owed to depositors, funders, and the fee beneficiary.

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

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

depositsLength() → uint256 (external)

Returns the total number of deposits.

@return deposits.length

fundingListLength() → uint256 (external)

Returns the total number of floating-rate bonds.

@return fundingList.length

getDeposit(uint64 depositID) → struct DInterest.Deposit (external)

Returns the Deposit struct associated with the deposit with ID depositID.

@param depositID The ID of the deposit

@return The deposit struct

// User deposit data
// Each deposit has an ID used in the depositNFT, which is equal to its index in `deposits` plus 1
struct Deposit {
    uint256 virtualTokenTotalSupply; // depositAmount + interestAmount, behaves like a zero coupon bond
    uint256 interestRate; // interestAmount = interestRate * depositAmount
    uint256 feeRate; // feeAmount = feeRate * depositAmount
    uint256 averageRecordedIncomeIndex; // Average income index at time of deposit, used for computing deposit surplus
    uint64 maturationTimestamp; // Unix timestamp after which the deposit may be withdrawn, in seconds
    uint64 fundingID; // The ID of the associated Funding struct. 0 if not funded.
}

getFunding(uint64 fundingID) → struct DInterest.Funding (external)

Returns the Funding struct associated with the floating-rate bond with ID fundingID.

@param fundingID The ID of the floating-rate bond

@return The Funding struct

// Funding data
// Each funding has an ID used in the fundingMultitoken, which is equal to its index in `fundingList` plus 1
struct Funding {
    uint64 depositID; // The ID of the associated Deposit struct.
    uint64 lastInterestPayoutTimestamp; // Unix timestamp of the most recent interest payout, in seconds
    uint256 recordedMoneyMarketIncomeIndex; // the income index at the last update (creation or withdrawal)
    uint256 principalPerToken; // The amount of stablecoins that's earning interest for you per funding token you own. Scaled to 18 decimals regardless of stablecoin decimals.
}

Last updated