Skip to main content

AccruedInterest.sol

AccruedInterest

struct AccruedInterest {
uint256 accumulatedAt;
uint256 accumulatedAmount;
}

Structure for tracking accumulated interest

NameTypeDescription
accumulatedAtuint256The timestamp at which the interest was last accumulated.
accumulatedAmountuint256The total amount of interest accumulated.

AccruedInterestLib

Tracks the accumulated interest for a given token amount and period of time

accumulate

function accumulate(struct AccruedInterest self, struct LpContext ctx, uint256 tokenAmount, uint256 until) internal

Accumulates interest for a given token amount and period of time

  • Parameters:

    NameTypeDescription
    selfstruct AccruedInterestThe AccruedInterest storage
    ctxstruct LpContextThe LpContext instance for interest calculation
    tokenAmountuint256The amount of tokens to calculate interest for
    untiluint256The timestamp until which interest should be accumulated

deduct

function deduct(struct AccruedInterest self, uint256 amount) internal

Deducts interest from the accumulated interest.

  • Parameters:

    NameTypeDescription
    selfstruct AccruedInterestThe AccruedInterest storage.
    amountuint256The amount of interest to deduct.

calculateInterest

function calculateInterest(struct AccruedInterest self, struct LpContext ctx, uint256 tokenAmount, uint256 until) internal view returns (uint256)

Calculates the accumulated interest for a given token amount and period of time

  • Parameters:

    NameTypeDescription
    selfstruct AccruedInterestThe AccruedInterest storage
    ctxstruct LpContextThe LpContext instance for interest calculation
    tokenAmountuint256The amount of tokens to calculate interest for
    untiluint256The timestamp until which interest should be accumulated
  • Return Values:

    NameTypeDescription
    [0]uint256The accumulated interest amount