Skip to main content

Interest Payment

Overview​

The Interest Payment contract provides interest-based payment schedules for loans backed by RestrictedLockupTokens.

The dividend functions (IDividends) are in the separate Dividends contract. They moved from InterestPayment to Dividends to make the InterestPayment contract smaller. Both contracts read the same SnapshotPeriods contract of the token.

Key Features​

Interest Payment Features​

  • Configurable interest accrual start and end timestamps
  • Ability to create multiple payment periods with different interest rates
  • Admin can fund interest payments and force claim interest on behalf of token holders
  • Token holders can claim interest based on their ownership during specific periods
  • Support for principal amount funding and claiming at maturity
  • Comprehensive admin controls for managing interest distributions

Usage​

How It Works​

Interest payments are distributed to recipients based on their proportional ownership of the RestrictedLockupToken at specific time periods and the configured interest rates for each period. The contract keeps track of token ownership through the SnapshotPeriods contract, which records token balances at different timestamps. Interest rates can be set differently for each payment period, allowing for flexible interest payment schedules. Role checks (e.g., Transfer Admin, Contract Admin) are routed to the external AccessControl contract.

  1. Anyone funds the interest payment contract with a payment token (e.g., USDC) through fundInterest(). The call fills the period that contains the block time and the later periods. See "Paid periods".
  2. Transfer Admin creates payment periods using createPaymentPeriod(), defining the start and end timestamps, interest rate, and interest rate period duration for the period.
  3. After a period finishes, the Transfer Admin sets its paid flag with fundInterestForPeriod(amount, periodIdx). See "Paid periods".
  4. Token holders can claim their interest by calling claimInterest(amount) or claimInterestForPeriod(periodIdx, amount) with an optional amount cap.
  5. The contract calculates the amount of interest due based on the token holder's time-weighted ownership and the configured interest rate for each period.
  6. Interest is transferred to the token holder from the contract.

Each period has its own funds and a paid flag. A period pays its holders only from its own funds. The Transfer Admin sets the flag with fundInterestForPeriod when the funds cover the period. The flag is the trigger for a missed payment.

These terms apply:

  • Payment clock: nearestInterestPaymentTimestampAt(block.timestamp). The payment clock does not move back.
  • Finished period: a period with the payment clock at or after its end. A period that contains the accrual end is also finished when the payment clock is at the accrual end. A period that is not finished is an open period.
  • Ongoing period: the first period with an end after the payment clock. Before the accrual start, it is period 0. When the payment clock is at the accrual end, no period is ongoing. The periods after the ongoing period are the later periods. fundInterest starts at the first period with an end after the block time instead (see "fundInterest fills the ongoing period and the later periods").
  • Started period: a period with the payment clock after its start. A holder accrues in a period only after it starts. When the payment clock is at the start of the ongoing period, that period did not start. reclaimTotalInterest uses the block time instead of the payment clock (see "Reclaims and the funds of a period").
  • Funds of a period: all money that went into the period, less the money that reclaimTotalInterest took from it. periodFundedInterest(periodIdx) returns this value. A claim or a reclaim of a holder does not lower it.
  • Money outside all periods: the money that no period holds. unassignedInterest() returns this value.
  • Projected total: the total of the period at its end. For a finished period, it is the period total. For an open period, see "The projected total".
  • Need: the projected total less the funds of the period, or 0. For a period that is not finished, the need can also include a margin of 1 wei (see "The margin of 1 wei"). requiredInterestFunding(periodIdx) returns the need.
  • Surplus: the funds of the period less the projected total and the margin, or 0.

The flags are in period order. paidPeriodsCount() is the count of flags, and the next period to flag has this index.

The projected total​

For an open period, the projected total is the total to date plus the interest of the rest of the period. The total to date stops at the payment clock. The rest has two parts:

  • From the payment clock (or the start of the period, if later) to the block time: the recorded supply of each second, from the supply ledger (SnapshotPeriods).
  • From the block time to the end of the period: the current supply.

The interest of the rest rounds up. These rules apply:

  • The accrual end stops the projection. A period that starts at or after the accrual end has a projected total of 0.
  • Before the accrual end, a pause-after time does not stop the projection. The projected total of a period with a stopped clock still counts the time to its end. The paused time before the block time counts at the recorded supply. From the accrual end (block.timestamp >= interestAccrualEndTimestamp), the projected total stops at the stopped clock (see "A pause-after time at maturity").
  • An end off the payment grid is not rounded down.
  • A transfer does not change the supply, so it does not change the projected total.
  • A mint raises the projected total of the ongoing period and the later periods from the mint time. A burn lowers it from the burn time.
  • Inside the accrual window and without a pause-after time, the payment clock and the block time are in the same payment tick. With a tick of 1 second, they are equal, and the projection does not read the ledger.

The projected total is the total of the period at its end, or 1 wei above it. This rule applies if the supply does not change after the block time. The projected total is never below the total to date.

The margin of 1 wei​

The projected total is the total to date, rounded down, plus the interest of the rest, rounded up. At the same supply, this sum can grow by 1 wei when the payment clock moves. Thus the need of an open period includes a margin of 1 wei. A period with a need of 0 pays the full share to each holder. These rules apply:

  • The margin applies only when the interest of the rest of the period is above 0. A finished period has no margin, so its need is exact.
  • At a later payment tick, requiredInterestFunding of a filled period that is not finished can return 1 wei. The period still pays the full share.
  • The claims use the projected total without the margin (see "The pro-rata part").
  • reclaimTotalInterest does not take the funds of a started period below its projected total and the margin.
fundInterest fills the ongoing period and the later periods​

Any account can call fundInterest(amount). A prefund through PurchaseContract also calls it. The call divides amount in this order:

  1. The period that contains the block time gets its need.
  2. Each later period gets its need, in period order.
  3. The rest goes to the money outside all periods.

The block time decides the first period, not the payment clock. The prefund of a purchase pays the minted tokens, and they accrue from the mint time. Without a pause-after time, the block time and the payment clock are in the same period, with one exception: a period with an end off the grid, from its end to the next grid point. These rules apply:

  • A period that ended by the block time gets nothing from fundInterest, also when it has no flag.
  • While a pause-after time stops the clock in an earlier period, that period gets nothing. fundInterestForPeriod can fill its need, but it sets no flag. See "Funds for the period with a stopped clock".
  • A period that starts at or after the accrual end gets nothing, because its projected total is 0.
  • If no period ends after the block time, or the payment clock is at the accrual end, all of amount goes to the money outside all periods. For example, no period exists, or the last period ended.
  • A paused period (pausePaymentPeriod) gets its need. The pause blocks only the claims of the holders.
  • fundInterest does not move the money outside all periods into a period.
createPaymentPeriod moves the money outside all periods​

createPaymentPeriod moves the money outside all periods into the new period, up to the need of the new period. The need uses the current supply. The rest stays outside all periods. This rule also applies to a new period that is already finished. reclaimTotalInterest can also take the money outside all periods (see "Reclaims and the funds of a period").

fundInterestForPeriod pays a finished period​

Only the Transfer Admin can call fundInterestForPeriod(amount, periodIdx). The checks run in this order, before the transfer:

  1. periodIdx must be paidPeriodsCount(). Otherwise the call reverts with InterestPayment_PeriodNotNextToPay(nextIdx).
  2. The period must be finished, or a passed pause-after time must stop the clock inside it. Otherwise the call reverts with InterestPayment_PeriodNotFinished(periodIdx).
  3. amount must not be more than the need of the period. Otherwise the call reverts with InterestPayment_AmountAboveNeed(need).

Then amount goes into the funds of the period:

  • If the funds then cover the period total, the call sets the flag and emits PeriodPaid(periodIdx, funds).
  • If not, the money stays in the period without the flag. Each holder can claim a pro-rata part at once (see "The pro-rata part"). A later call with the rest of the need sets the flag.
  • An amount of 0 sets the flag when the funds already cover the period, for example after prefunds filled it.
  • For a period that the funds do not cover, an amount of 0 reverts with InterestPayment_PeriodInterestNotFullyFunded(funds, required). required is the period total.

Funds for the period with a stopped clock. While a passed pause-after time stops the clock inside a period, fundInterestForPeriod accepts that period. The amount goes into its funds, up to its need, but the call sets no flag. Only a full period can be paid, and the paused time is not paid. These rules apply:

  • Before the accrual end, the need counts the paused time, because the pause-after time can still move. After the accrual end, the need stops at the clock, and reclaimTotalInterest can take the funds of the paused time.
  • When the funds cover the projected total, each holder gets the full share up to the clock.
  • A call that adds nothing reverts with InterestPayment_PeriodNotFinished(periodIdx).
  • isPaidThrough stays false for each time at or after the end of this period. An off-chain reader must also read paymentPausedAfterTimestamp.
  • When the clock passes the end of the period, the usual checks apply. An amount of 0 then sets the flag if the funds cover the total.
  • The periods between this period and the period of the block time get no funds: fundInterest starts at the block time, and check 1 rejects them. First move the pause-after time or unpause, then fund each finished period in period order.

Check 1 keeps the flags in period order. Thus fundInterestForPeriod can send money only to the next period to pay. fundInterest gives money only to open periods. While an older period has no flag, a later period pays only from the money that it got while it was open. The exception is a new period that is already finished: createPaymentPeriod can move money into it.

Flag a period​

Do these steps after the end of each period:

  1. Make sure that the period is finished: nearestInterestPaymentTimestampAt(now) is at or after periodEndTimestamp(periodIdx).
  2. Make sure that periodIdx is equal to paidPeriodsCount(). If an earlier period has no flag, flag it first.
  3. Read requiredInterestFunding(periodIdx).
  4. Approve the payment token for the amount of step 3.
  5. Call fundInterestForPeriod(amount, periodIdx) with the amount of step 3. Do not add a margin, because a larger amount reverts.
  6. Make sure that isPeriodPaid(periodIdx) returns true.

If step 3 returns 0, the prefunds filled the period. Then do step 5 with an amount of 0. The total of a finished period does not change, so the value of step 3 stays correct. A second call with the same index reverts with InterestPayment_PeriodNotNextToPay(nextIdx), so a retry does not send money to the next period.

To pay more than one period, call fundInterestForPeriods(amount, periodIdxs). The call makes one transfer. These rules apply:

  • The list starts at paidPeriodsCount() and goes up by 1. An empty list reverts with InterestPayment_InvalidPeriod.
  • The amount fills each listed period to its need, in list order, with the rules of fundInterestForPeriod.
  • Send the sum of requiredInterestFunding of the listed periods. An amount above this sum reverts with InterestPayment_AmountAboveNeed(sum).
  • A short amount is permitted only when the shortage is in the last listed period, and that period gets more than 0. That period keeps the money without the flag. If an earlier listed period does not get its full need, the next index reverts with InterestPayment_PeriodNotNextToPay.
  • If one check fails, the whole call reverts.

Fund the figures that the contract reports. Do not fund the sum of the holder views. Each holder amount rounds down, so the sum can be less than the period total.

Reclaim the surplus of a finished period​

A finished period can keep a surplus. Examples: the margin of 1 wei, or the funds above its total after a burn or a rate cut. The surplus of a finished period is periodFundedInterest(periodIdx) less periodTotalInterest(periodIdx), or 0. After the end of each period, select one of these two choices:

  • Reclaim the surplus with reclaimTotalInterest(amount). The call sends the money to the reclaimer address. The parts of the holders do not change.
  • Keep the surplus. The money stays in the period. No holder can claim it, and no other period can use it. A later reclaimTotalInterest can take it.

To reclaim the surplus, do these steps:

  1. Make sure that the period is finished (see "Flag a period").
  2. Read periodFundedInterest(periodIdx) and periodTotalInterest(periodIdx). The surplus is the difference, or 0.
  3. If the surplus is more than 0, call reclaimTotalInterest(surplus).

reclaimTotalInterest takes the money outside all periods first, and then the surplus of each earlier period. If one of these is more than 0, step 3 takes it first, and a part of the surplus stays in the period. reclaimInterestForAllRecipients does not take a surplus. It takes only the period total less the claimed and the reclaimed interest of the period.

The pro-rata part​

Each period pays only from its own funds. If the funds of a period are at or above its projected total, each holder can claim the full share to date. If not, the part of a holder is accrued * funds / total. The amount that the holder already took from the period is subtracted from this value. These values apply:

  • accrued is the accrual of the holder in the period, up to the payment clock.
  • funds is the funds of the period.
  • total is the projected total of the period, without the margin of 1 wei.

A late claimant gets the same ratio as an early claimant. The sum of the accruals of all holders is not more than the projected total. Thus the sum of the parts is not more than the funds of the period. A period never pays from the funds of a different period.

A period with no funds pays nothing. A claim of that period alone reverts with InterestPayment_NoFundsToClaim. claimInterest and the other loops skip it. Thus a holder can claim a later period in full while an older period without funds pays nothing.

These events inside the ongoing period raise the projected total and lower the ratio:

  • a mint without a prefund;
  • shiftInterestAccrualEnd when the accrual end is inside the period.

Then an earlier claimant keeps a larger part. The funds of the period cap the sum of the payments. Money that comes later pays the rest: fundInterest for an open period, or fundInterestForPeriod for a finished period.

Limits of the projection​

The projection counts the recorded supply up to the block time, and the current supply after it. A supply change after the block time changes the projection:

  • A mint raises the projected total of the period that contains the mint time and of the later periods. These periods have a need again until fundInterest fills them. Until then, the holders of a short period claim a pro-rata part.
  • A burn lowers the projected total. The funds above it are surplus, and reclaimTotalInterest can take them.

While a pause-after time is set, calculateInterestFor stops at that time, but the projected total does not (see "The prefund of a purchase").

No holder gets more than the share, and the contract keeps all of the money.

The ongoing period​

To let the holders claim the full share to date, fund the period that contains the block time in advance with fundInterest. A purchase through PurchaseContract does this with its prefund. If the funds of that period are short, the holders claim a pro-rata part. After the end of the period, fundInterestForPeriod adds the rest of the need. The holders who claimed a part before then get the difference, and no holder gets a part two times.

PurchaseContract.executePurchaseWithInterest mints the tokens before it calls fundInterest. Thus the need of the period that contains the block time includes the new tokens, and the prefund fills that period first. For example, the ongoing period is full at 1,000 USDC for 1,000 tokens. At the start of the payment tick of day 15 of 30, a buyer gets 1,000 tokens with a prefund of 500 USDC. Then the period gets the 500 USDC and pays 100 %. With the prefund before the mint, the 500 USDC goes to the next period, and the ongoing period pays 66.7 %.

The prefund of a purchase​

The projection counts a mint from the mint time. Thus count the prefund of a purchase from the mint time. Do these steps for each purchase:

  1. Read end: periodEndTimestamp(lastIdx). lastIdx is the last period that the prefund must cover.
  2. Set the prefund to calculateInterestFor(mintAmount, now, end). now is the block time at the computation.

These rules apply:

  • The purchase executes after the computation. Thus the prefund is more than the need by the interest of the minted tokens for the time between them. The extra money goes to a later period or to the money outside all periods. A prefund from an earlier time, for example from the payment clock, puts more money outside all periods.
  • calculateInterestFor rounds down in each period, but the projected total rounds up, and the need adds the margin of 1 wei. Thus each filled period can need a few wei. fundInterest or fundInterestForPeriod pays them.
  • While a pause-after time is set, calculateInterestFor stops at that time, but the projected total does not. Then the prefund of step 2 is less than the need.
A period with a stopped payment clock​

After an early repayment, or while a pause-after time is set, the payment clock stops in a period. While a pause-after time before the accrual end stops the clock, these calls move the clock again:

  • unpausePaymentAfter;
  • earlyRepayment;
  • pausePaymentAfter with a later time.

Each of these calls restores the paused time. When the clock is at the accrual end, these calls move it only after shiftInterestAccrualEnd. These rules apply:

  • Before the accrual end, a pause-after time does not stop the projected total (see "The projected total"). While a pause-after time before the accrual end stops the clock, the period with the stopped clock is not finished, and it gets no flag. It pays from its funds as the ongoing period. fundInterestForPeriod can fill it (see "Funds for the period with a stopped clock").
  • After the accrual end, a passed pause-after time keeps the clock below the accrual end. Then the projected total of each period stops at the clock. The holders get the full share up to the clock, requiredInterestFunding shows no need for the paused time, and reclaimTotalInterest can take the funds of the paused time. After such a reclaim, a clock move restores the paused time, and the periods have a need again. Until fundInterestForPeriod fills them, the holders get a pro-rata part. See "A pause-after time at maturity".
  • A period that contains the accrual end can get the flag when the payment clock is at the accrual end. A pause-after time before the accrual end keeps the clock below it, so that period gets no flag.
  • A period that starts at or after the accrual end never accrues. It never gets a flag. All of its funds are surplus.
  • shiftInterestAccrualEnd and earlyRepayment remove the flag of the last flagged period if that period ends after the old accrual end. Both functions move the accrual end. The funds stay in the period, and the contract emits PeriodUnpaid(periodIdx, funds). A flag of an earlier period stays. earlyRepayment at the current accrual end does not move the end, so the flag stays.
  • While a pause-after time before the accrual end stops the clock, reclaimInterestForAllRecipients reverts for the period with the stopped clock and for each later period. The error is InterestPayment_CannotReclaimAllForOngoingPeriod. When the clock moves again, the usual checks apply again.
  • A period with a flag, such as the period that contains the accrual end, can be reclaimed before its end time.

Warning: Do not call reclaimInterestForAllRecipients for a period whose accrual can start again. Use the reclaims for one holder. They record the amount of each holder. reclaimInterestForAllRecipients adds to totalReclaimedInterest only. If the accrual starts again, the first claimant can take the new growth of all holders.

The accrual of a period starts again when all of these conditions are true:

  • The period contains the accrual end, and reclaimInterestForAllRecipients ran for it.
  • After the reclaim, shiftInterestAccrualEnd moves the accrual end.
  • Then unpausePaymentAfter, earlyRepayment or pausePaymentAfter with a later time moves the clock.

When the clock moves again, more than one period can be finished at one time. Flag them in period order.

A period with an end off the payment grid​

A period can end at an accrual end that is off the payment grid, for example a final stub period. If shiftInterestAccrualEnd then moves the accrual end, that period keeps its end. Each later period starts at an end off the grid, so its end is also off the grid. The payment clock passes such an end only at the next grid point. These rules apply:

  • The period is finished only when the payment clock is at or after its end. Before that time, fundInterestForPeriod reverts with InterestPayment_PeriodNotFinished.
  • After the end time, the total of the period grows until the payment clock passes the end. Before that time, reclaimInterestForAllRecipients reverts with InterestPayment_CannotReclaimAllForOngoingPeriod for a period without a flag.
  • The projected total of the ongoing period goes to the end of the period, not to the last grid point before the end.
  • isPaidThrough examines the end time, not the payment clock. From the end time to the next grid point, it returns false, but the period cannot get the flag. This time is shorter than one payment tick.
isPaidThrough and the lending pool​

isPaidThrough(timestamp) returns true when each period that ends at or before timestamp has a flag. It also returns true when the first period without a flag starts at or after the accrual end. Those periods never accrue, so after an early repayment the trigger does not see a false default.

isPaidThrough does not examine whether a period covers the time. If no period exists, or each created period has a flag, it returns true for any time.

During a pause-after time, the period with the stopped clock has no flag. For a time after the end of that period, the view returns false. Thus a pause-after can open a notice in the lending pool. The client can postpone the notice in the pool.

The lending pool trigger must read isPaidThrough or isPeriodPaid. It must not compare the funded total with the accrued total.

The sweep of the pool moves its cursor past each ended period, also when the claim reverts (then the pool emits IPPeriodClaimSkipped(idx)). It does not revert when the claim pays only a part. This is the pool runbook rule. A part payment of fundInterestForPeriod is an example: the sweep can pass the period before the flag. After each flag or top-up that raises the part of a period that the sweep already passed, run claimIPPeriod(idx) on the pool.

Gas​
  • A claim of one period reads only that period. Its cost does not grow with the count of older periods without a flag.
  • fundInterest finds the ongoing period with a binary search. Then it examines the ongoing period and the later periods until the money ends. Thus the gas of a purchase does not grow with the count of finished periods.
  • reclaimTotalInterest examines the started periods from period 0, then the periods that did not start from the last period, until it has the amount. Only the Transfer Admin can call it.
  • The projection of an open period reads the supply ledger once when the payment clock is below the block time. This occurs with a tick above 1 second, or while a pause-after time stops the clock.
Reclaims and the funds of a period​
  • reclaimInterestForPeriod, reclaimInterest, batchReclaimInterest and batchForceClaimInterest use the same part as a claim. The force claims also use that part.

  • reclaimInterestForAllRecipients(periodIdx) works only when the funds of the period cover its projected total. It takes the available interest of the period. A reclaim of a part for all holders is not permitted, because it can pay a holder two times.

  • reclaimTotalInterest can send only the money outside all periods, the surplus of the started periods and the funds of the periods that did not start. For this call, a period started when the block time is after its start. It takes the money in this order, and it lowers the funds of each period that gives money:

    1. The money outside all periods.
    2. The surplus of each started period, in period order.
    3. All funds of each period that did not start, from the last period. Thus the next period to start keeps its funds longest.

    An amount above this limit reverts with InterestPayment_ReclaimAboveSurplus(surplus). surplus is the limit.

  • A reclaim does not take the funds of a started period below its projected total and the margin. Thus a reclaim does not lower the part that a holder can claim at the time of the reclaim.

  • A period that did not start has no accrual, so a reclaim of its funds lowers no part. When the period starts, it pays nobody until a later funding fills it. Thus the prefund of a purchase for a later period can leave the contract.

  • While a pause-after time stops the clock, the block time still decides if a period started. Before the accrual end, the projected total of a started period counts the paused time at the recorded supply. Thus the period keeps the funds for that time. After the accrual end, the projected total stops at the clock, so the reclaim can take the funds of the paused time. A period that starts at or after the block time can lose all of its funds.

  • A mint after a reclaim gives the period that contains the mint time and the later periods a need again. The prefund of the purchase fills them.

  • Each holder amount rounds down. Thus a period can keep a small part of its total after all holders claim. This amount is not surplus. reclaimInterestForAllRecipients(periodIdx) moves it to the reclaimer address. No other function can move it.

Warning: Do not call reclaimInterestForAllRecipients for a period whose accrual can start again. Use the reclaims for one holder. They record the amount of each holder. See "A period with a stopped payment clock".

Runbook: changes of the accrual end​

Warning: Do not do these steps after reclaimInterestForAllRecipients of the period that contains the accrual end. The first claimant can then take the new growth of all holders. See "A period with a stopped payment clock".

A shift after an early repayment and a reclaim. After earlyRepayment, the projected totals of the periods after the new accrual end become smaller. reclaimTotalInterest can then take their surplus. A period that starts at or after the new accrual end did not start, so the call can take all of its funds. If shiftInterestAccrualEnd later moves the accrual end forward again, these periods have a need again. The pause-after time of the early repayment still stops the clock. Do these steps:

  1. Call shiftInterestAccrualEnd(newEnd). If no period covers newEnd, also create the periods (see "Extending Maturity").
  2. Call unpausePaymentAfter().
  3. Read requiredInterestFunding of each period that the clock passed, from the period with the old stopped clock.
  4. Pay each of these periods with fundInterestForPeriod, in period order. fundInterestForPeriods does this in one call.
  5. Call fundInterest with the need of the ongoing period and of the later periods.

fundInterest starts at the period that contains the block time. Before step 2, it gives nothing to the period with the stopped clock. fundInterestForPeriod can fill that period, but it sets no flag. Between step 2 and step 4, the holders of a finished period with a need claim a pro-rata part. The flag path then pays the rest of each share.

Keep a paused time out of the accrual. earlyRepayment replaces a pause-after time with its timestamp, and timestamp must not be before the block time. Thus an early repayment during a passed pause-after time restores the paused time up to timestamp. To keep the paused time out of the accrual, keep the pause-after time to the accrual end. After the accrual end, the projected total stops at the clock, and reclaimTotalInterest can take the funds of the paused time.

The accrual end never moves before the block time. The lending pool reads it as its maturity, and the maturity round of the principal reads the balances at it.

A pause-after time at maturity. After the accrual end, a passed pause-after time before the accrual end keeps the clock at the last grid point at or before the pause-after time. These rules apply:

  • The projected total of each period stops at the clock. The holders get the full share up to the clock. reclaimTotalInterest can take the funds of the paused time, also after the first principal claim.
  • The period with the stopped clock and each later period cannot get a flag. fundInterestForPeriod can fill the period with the stopped clock up to its total at the clock.
  • reclaimInterestForAllRecipients reverts for these periods, because a clock move can make their totals grow again. Use the reclaims for one holder, reclaimInterestForPeriod and reclaimInterest. They record the amount of each holder, so a later clock move pays each holder only the rest.
  • earlyRepayment reverts, because its time must be from the block time to the accrual end.
  • unpausePaymentAfter, pausePaymentAfter with a later time, or shiftInterestAccrualEnd with an exit call move the clock. These calls restore the paused time. The holders accrue it up to the end of the last period, or up to the new accrual end.

After a reclaim of the paused time, a clock move gives the periods a need again. At the accrual end, fundInterest assigns nothing to the periods. Read requiredInterestFunding and pay each period with fundInterestForPeriod, in period order. Until then, the holders get a pro-rata part of the restored time.

To restore the paused time and extend the loan, do these steps:

  1. Call shiftInterestAccrualEnd(newEnd) with a newEnd after the block time.
  2. Call earlyRepayment(timestamp) with a timestamp from the block time to newEnd.
  3. Flag the finished periods in period order (see "Flag a period").

Send the calls of steps 1 and 2 in one transaction. Between the two calls, claimPrincipal reverts with InterestPayment_MaturityNotReached, because the accrual end is in the future.

As an alternative in step 2, call unpausePaymentAfter(), or call pausePaymentAfter with a time at or after newEnd. With a time before newEnd, the clock stops again at that time. These calls have a similar effect on the clock, with these differences:

  • earlyRepayment with a timestamp equal to the block time sets the clock to the block time. The other two calls set the clock to the last grid point at or before the block time.
  • After the other two calls, claimPrincipal waits for newEnd.

Before maturity, earlyRepayment during a pause-after time also restores the paused time. It replaces the pause-after time with timestamp. Thus the holders accrue the time from the old pause-after time to timestamp.

Examples​

In these examples, the interest is 1 USDC for each token for each 30-day period. The periods are P1, P2 and so on. The examples do not show the margin of 1 wei.

A prefund in P3 while P1 and P2 have no funds.

  1. 1,000 tokens exist. P1 and P2 have 0 USDC. P3 and P4 exist.
  2. On day 0 of P3, fundInterest(1,500) runs. P3 gets 1,000 USDC, and P4 gets 500 USDC. P1 and P2 get 0.
  3. The holders claim P3 in full. P1 and P2 pay 0 until the admin pays them with fundInterestForPeriod.

A part payment.

  1. P1 is finished and has a total of 1,000 USDC. Holder A accrued 500 USDC, B accrued 300 USDC and C accrued 200 USDC.
  2. fundInterestForPeriod(800, P1) sets the funds of P1 to 800 USDC. The call sets no flag.
  3. A, B and C can claim 400, 240 and 160 USDC.
  4. fundInterestForPeriod(200, P1) sets the flag. Then A, B and C can claim 100, 60 and 40 USDC more.

After step 2, fundInterestForPeriod(300, P1) reverts with InterestPayment_AmountAboveNeed(200).

A surplus after a burn.

  1. 2,000 tokens exist. P3 is the ongoing period and has 2,000 USDC. P4 has 2,000 USDC.
  2. On day 15 of P3, a holder burns 1,000 tokens.
  3. The projected total of P3 becomes 1,500 USDC.
  4. reclaimTotalInterest can take the money outside all periods, 500 USDC of P3 and all 2,000 USDC of P4. P4 did not start, so no holder accrued in it.

A prepay, then a reclaim.

  1. 1,000 tokens exist. P1 is paid. P2 and P3 have 0 USDC. On day 5 of P2, fundInterest(2,000) fills P2 with 1,000 USDC and P3 with 1,000 USDC.
  2. On day 6 of P2, reclaimTotalInterest can take the 1,000 USDC of P3, because P3 did not start. It cannot take the funds of P2, because P2 started.
  3. If the borrower does not pay again, P3 pays nothing after it starts. The holders can still claim P2 in full.

Money after the last period.

  1. Only P3 and P4 exist, and their funds cover them.
  2. fundInterest(700) puts 700 USDC outside all periods. reclaimTotalInterest can take this money now.
  3. The admin creates P5 with a need of 1,000 USDC. createPaymentPeriod moves the 700 USDC into P5.
Events for an indexer​

An indexer can rebuild the funds of each period from PeriodFundsChanged(periodIdx, funds). It can rebuild the money outside all periods from UnassignedInterestChanged(amount). Each event gives the new value, not the change. The calls emit the events in this order:

  • fundInterest: PeriodFundsChanged for each period that gets money, then UnassignedInterestChanged if money goes outside all periods. Funded comes last.
  • fundInterestForPeriod and fundInterestForPeriods: for each listed period, PeriodFundsChanged if the period gets money, and PeriodPaid if the call sets the flag. Funded comes last, if amount is more than 0.
  • createPaymentPeriod: PaymentPeriodCreated and InterestRatePeriodDurationSet, then PeriodFundsChanged and UnassignedInterestChanged if money moves into the new period.
  • reclaimTotalInterest: UnassignedInterestChanged if it takes money outside all periods, then PeriodFundsChanged for each period that gives money, then ReclaimedAll. The started periods come in period order, then the periods that did not start, from the last period.
  • PurchaseContract.executePurchaseWithInterest: the mint events of the token, then the events of fundInterest, then PurchaseExecuted.

Note for an indexer: these orders changed:

  • In the admin calls fundInterestForPeriod and fundInterestForPeriods, Funded was the first event. Now it is the last event.
  • In fundInterest, Funded was the only event. Now PeriodFundsChanged and UnassignedInterestChanged come before it.
  • In a purchase, the mint events came after Funded. Now they come before the events of fundInterest.
Views and integrators​

unclaimedAmountForPeriod and unclaimedAmountAt do not examine the funds or the flags. periodPayableInterest and payableInterestOf return the amounts that the contract can pay now. If the funds of a period do not cover it, periodPayableInterest returns the pro-rata part that is left. For a period with no funds, it returns 0.

An integrator that skipped a period with no funds must claim it again after a funding. The lending pool does not return to a skipped period. A pool admin calls claimIPPeriod(periodIdx) on the pool to claim it.

Principal Amount Management​

The contract also supports principal amount management with partial operations:

  1. Transfer Admin can fund principal amounts using fundPrincipal(). After the funding, the unused principal must not be more than requiredPrincipalFunding().
  2. Token holders can claim their principal at maturity by calling claimPrincipal(amount). While the principal is not fully funded, a holder can claim only a pro-rata share (see "Pro-rata redemption"):
    • amount = 0: Claims all that is due to the token holder now, in whole tokens
    • amount > 0: Claims exactly the specified amount (must be divisible by principalAmountPerToken, and must not be more than the due amount)
  3. Transfer Admin can reclaim unused principal using reclaimPrincipal(amount):
    • amount = 0: Reclaims all unused principal
    • amount > 0: Reclaims exactly the specified amount
  4. The principal amount per token is set during contract deployment.

Pro-rata redemption​

The unused principal is the value that totalAvailablePrincipalAmount() returns. The view requiredPrincipalFunding() returns the face value of all circulating tokens:

requiredPrincipalFunding = (totalSupply - token balance of the Interest Payment contract) × principalAmountPerToken

Each claim burns one token for each principalAmountPerToken that it pays. The amount that a holder can claim depends on the funding:

  • Full funding (the unused principal is equal to or more than the required amount): each holder can redeem the full balance at face value, in any order.
  • Partial funding (the unused principal is less than the required amount): each holder can claim a pro-rata share of each principal round.
Principal rounds​

Each fundPrincipal call adds its amount to a principal round:

  • A funding before maturity, or at the maturity second, goes into the maturity round. The snapshot of this round is interestAccrualEndTimestamp - 1, the last second of accrual.
  • A funding after maturity goes into a new round. The snapshot of this round is block.timestamp - 1 of the funding. Thus a holder can claim in the funding block, and a transfer in that block does not change the shares.
  • The fundings of one second go into one round.

The amount of a round is the funded principal of the round minus reclaims. principalRoundCount() and principalRound(index) return the rounds, oldest first.

for each round k:
supplyAtSnapshot_k = circulating supply at the snapshot of round k
shareTokens_k = min(amount_k / principalAmountPerToken, supplyAtSnapshot_k)
× balance of the holder at the snapshot of round k / supplyAtSnapshot_k
due = min(sum of shareTokens_k − tokens that the holder claimed before,
balance of the holder now,
unused principal / principalAmountPerToken) × principalAmountPerToken

The circulating supply does not include the tokens of the Interest Payment contract. Each division rounds down to whole tokens, so the sum of the shares of a round is never more than the amount of the round. Thus each round can pay a holder up to one token less than the exact share, and a small share of a small round can be 0. Full funding removes this loss. The cap at supplyAtSnapshot_k limits the payout of a round to face value after a burn or a mint.

Example: principalAmountPerToken is 1. At maturity, holder A has 400,000 tokens and holder B has 100,000 tokens. Before maturity, the Transfer Admin funds 100,000 of the required 500,000 (20%).

StepHolder AHolder B
Each holder calls claimPrincipal(0)Receives 80,000 (80% of the maturity round). Burns 80,000 tokens and keeps 320,000.Receives 20,000 (20%). Burns 20,000 tokens and keeps 80,000.
After maturity, the Transfer Admin funds 100,000 more. At this funding, A has 320,000 tokens and B has 80,000 tokens.Can claim 80,000 more (80% of the new round).Can claim 20,000 more (20%).
The Transfer Admin funds the restRedeems the remaining tokens at face value.Redeems the remaining tokens at face value.

In one round, the result is the same in each order of the claims. A second claim in the same round reverts with InterestPayment_NoFundsToClaim.

A transfer after maturity​

A transfer does not move the share of an earlier round. The new holder gets a share of each later round. Example with principalAmountPerToken of 1:

  1. At maturity, user 1 has 1,000 tokens. The maturity round is 500.
  2. User 1 claims 500, burns 500 tokens, and transfers the other 500 tokens to user 2.
  3. After maturity, the Transfer Admin funds 250. At this funding, user 2 has all 500 circulating tokens.
  4. User 2 can claim 250. User 1 can claim nothing, because user 1 already claimed the share of the maturity round.

A claim burns tokens, so a holder must have tokens to claim a share. If user 1 transfers all tokens before the claim of the maturity share, user 1 cannot claim that share. If user 1 gets tokens again, user 1 can claim it. When the principal is fully funded, the holder of the tokens redeems them at face value.

Order of claims and fundings​

A claim before a later funding decreases the share of the holder in that funding. The claim burns tokens, and the later round divides by the supply at its snapshot. Thus a holder who waits gets more of a later partial funding than a holder who claimed before it.

Example with principalAmountPerToken of 1: A and B have 50 tokens each, and the maturity round is 50. A claims 25 and keeps 25 tokens. After maturity, the Transfer Admin funds 25, and that round divides by 75 tokens. A gets 8 and B gets 16, rounded down. In total, A gets 33 and B gets 41, not 37.5 each.

At full funding, each holder redeems the remaining tokens at face value. Thus the difference stops at full funding. It stays only if the principal is never fully funded.

Rules:

  • The Transfer Admin can fund in more than one tranche. If a tranche makes the unused principal more than the required amount, fundPrincipal reverts with InterestPayment_PrincipalFundingExceedsRequired(unusedPrincipal, required).
  • When the unused principal becomes equal to the required amount, the contract emits PrincipalFullyFunded(amount).
  • If nothing is due to the holder, or the unused principal is 0, claimPrincipal and forceClaimPrincipal revert with InterestPayment_NoFundsToClaim. If an explicit amount is more than the due amount, they revert with InterestPayment_NotEnoughFundedPrincipal.
  • availablePrincipalAmount(account) returns the due amount. With partial funding, it returns 0 before maturity, because the snapshot of the maturity round does not exist yet.
  • claimedPrincipalOf(account) returns the principal that the account claimed.
  • After the first principal claim, shiftInterestAccrualEnd reverts with InterestPayment_PrincipalRedemptionStarted. A shift would move the snapshot of the maturity round. While a round of a funding after maturity holds money, the shift also reverts with this error. The new maturity would be after the snapshot of that round. If a reclaim removes these rounds before the first claim, the shift is possible again.
  • The circulating supply includes the tokens of the issuer. Before the funding, burn the tokens that the issuer keeps, or fund their face value too.
  • A claim reads 3 snapshots for each round. In the tests, a claim over 20 rounds used approximately 950,000 gas, or approximately 45,000 gas for each round. After maturity, fund in few tranches.

Limits:

  • A wallet that gets tokens after a funding gets no share of that round. If the principal is never fully funded, those tokens get no payout from that round. The wallet at the funding has no tokens to burn, and the new wallet has no share. A lending pool that defaults with the tokens as collateral is an example.
  • A mint after a funding increases the required amount, and the new tokens get no share of that round. They get a share of each later round. The cap at the supply of a round stops a payout of more than face value.
  • If the token links this contract with setInterestPayment, the token rejects a mint at and after interestAccrualEndTimestamp. See Mint stop at the accrual end of an InterestPayment. The Contract Admin of the token can remove the link, so the cap above stays.
  • A reclaim takes from the newest round first, also if holders already claimed that round. See "Reclaim and the principal rounds".
  • If a holder transfers tokens after maturity and the new holder claims at full funding, the rounds do not record the claim for the first holder. If a later reclaim or mint ends full funding, the first holder keeps its share of the maturity round. Then the shares of a round can be more than the unused principal, and the first claims get it. The reclaim rule below and the mint stop keep the contract in full funding.
  • A forced transfer with forceTransferBetween moves the tokens, not the share of an earlier round. The share of the maturity round stays with the old wallet, also with a frozen wallet. At full funding, the new wallet redeems the tokens at face value.
Reclaim and the principal rounds​

reclaimPrincipal makes the newest round smaller first. If the reclaim is more than that round, it removes the round and continues with the round before it.

Do not reclaim more than the amount above requiredPrincipalFunding(). A larger reclaim decreases the shares of a round. A holder that claimed from that round before can then have more than the new share. Then the last claims can get less than their share.

Example with principalAmountPerToken of 1:

  1. At maturity, A and B have 500 tokens each. The maturity round is 500.
  2. A and B transfer all tokens to user 2. After maturity, the Transfer Admin funds 250, and user 2 claims all of that round.
  3. User 2 transfers 250 tokens to A and 250 tokens to B. The unused principal is 500, the money of the maturity round.
  4. The Transfer Admin reclaims 100. The reclaim takes it from the newest round, which becomes 150. User 2 keeps the 250.
  5. A and B have shares of 250 each, but the unused principal is 400. The first of them to claim gets 250, and the other gets 150.

Timelocked tokens at maturity​

claimPrincipal(0) and availablePrincipalAmount(account) count the full balance of the holder. This balance includes the tokens in timelocks. The claim burns the tokens with softBurn, which burns only the balance outside timelocks (superBalanceOf).

  • If the claim must burn more than the balance outside timelocks, claimPrincipal(0) reverts with RestrictedLockupToken_InsufficientBurnableBalance.
  • The holder can claim an explicit amount up to the due amount and up to superBalanceOf(holder) × principalAmountPerToken. The holder claims the rest after the timelocks release the tokens.
  • requiredPrincipalFunding() includes the timelocked tokens, so the unused principal keeps their face value until the holder claims it.

This diagram illustrates the principal funding and claiming process:

  1. Approve Funding: The Transfer Admin first approves the Interest Payment contract to spend payment tokens (like USDC) from their account.

  2. Fund Principal: The Transfer Admin calls fundPrincipal() with the amount to fund. The Transfer Admin can fund in tranches. After the funding, the unused principal must not be more than requiredPrincipalFunding(). Until the unused principal is equal to it, holders can claim only a pro-rata share.

  3. Wait for Maturity: Principal can only be claimed after reaching the maturity date (defined by interestAccrualEndTimestamp).

  4. Token Holder Approval: To claim principal, the token holder must first approve (or permit) the Interest Payment contract for the security tokens to burn. The claim burns the tokens with softBurn, so the Interest Payment contract must also have SOFT_BURN_ADMIN_ROLE in the access control contract of the token. The claim checks both before the burn. If the allowance is less than the tokens to burn, the claim reverts with InterestPayment_InsufficientBurnAllowance(allowance, required). If the role is missing, it reverts with InterestPayment_MissingSoftBurnRole.

  5. Claim Principal: The token holder calls claimPrincipal(amount), where:

    • amount = 0: Claims all that is due to the token holder now, in whole tokens
    • amount > 0: Claims the specific amount (must be divisible by principalAmountPerToken, and must not be more than the due amount)
  6. Token Burn: The corresponding security tokens are burned from the token holder, effectively redeeming them.

  7. Principal Payment: The requested principal amount in payment tokens is transferred to the token holder.

This process allows token holders to redeem their security tokens for the principal amount at maturity, similar to how a bond works in traditional finance.

Frozen wallets​

A freeze in the token stops every payout of this contract to the wallet. The claims of interest and principal revert with InterestPayment_WalletFrozen(wallet). The force claims of an admin (forceClaim, forceClaimForPeriod, batchForceClaimInterest and forceClaimPrincipal) also revert, because they pay the same wallet. softBurn in the token also reverts for a frozen holder. The dividend claims of the Dividends contract revert with Dividends_WalletFrozen(wallet).

The admin routes for a frozen position:

  1. The Transfer Admin reclaims the unclaimed interest of the wallet to the reclaimer address (reclaimInterest, reclaimInterestForPeriod, batchReclaimInterest). For the dividends, the Transfer Admin uses reclaimDividend of the Dividends contract.
  2. The Reserve Admin burns the tokens of the wallet with burn() and mints them to the rightful owner. The rightful owner then claims the principal. If the wallet has too many holdings for one burn() call, use burnHolding(). See Recovering a Wallet With Very Many Holdings.

A freeze does not remove the entitlement. If the freeze is removed before an admin reclaims, the wallet can claim again.

Administrative Functions​

The Interest Payment contract provides several advanced administrative functions to adjust the terms of the interest and principal payments after deployment:

Extending Maturity (shiftInterestAccrualEnd)​

The shiftInterestAccrualEnd(timestamp) function allows the Contract Admin or Transfer Admin to extend the maturity date by updating the interestAccrualEndTimestamp. This is particularly useful when:

  • The original maturity date needs to be extended due to business requirements
  • The loan or bond term is being renegotiated
  • Regulatory requirements necessitate a modification to the maturity date

The new timestamp must be greater than the current interestAccrualEndTimestamp, ensuring that maturity can only be extended, not reduced.

After the first principal claim, the shift reverts with InterestPayment_PrincipalRedemptionStarted. The pro-rata shares of the maturity round come from the snapshot at maturity. A shift would move that snapshot after a part of the shares was paid. While a round of a principal funding after maturity holds money, the shift also reverts with this error. The new maturity would be after the snapshot of that round (see "Principal rounds").

If the token links this contract with setInterestPayment, the token reads the accrual end at each mint. Thus after a shift, the token accepts a mint again until the new end.

A shift alone does not fund the extension. Every accrual reader stops at the end of the last payment period, while claimPrincipal waits for the new maturity. To extend maturity and fund the extension:

  1. Call shiftInterestAccrualEnd(newEnd).
  2. Before the old accrual end, call createPaymentPeriod(lastPeriodEnd, newEnd, interestRate, interestRatePeriodDuration).

The shift must come first, because createPaymentPeriod rejects a period that ends after the accrual end. A multisig can send the two calls in one transaction. If the old accrual end already passed, send them in one transaction. After an early repayment, the last period can already end at or after the new end. Then do only step 1.

createPaymentPeriod does not check the block time. Thus a period that starts in the past pays interest from its start, and holders can claim it. But an integrator that settled interest for a time with no period does not settle that time again. For example, a lending pool moves its accrual cursor and gives the borrower no credit for that time.

Do not let interest settle for a time with no period. Create the period before the old accrual end, or in the same transaction as the shift. Otherwise a lending pool gives the borrower no credit for that time.

An extension does not move the payment clock back. The old maturity can be off the payment grid, because of a final stub period or an early repayment. After the clock gets to the old maturity, holders can claim interest up to that time. With a later maturity, the grid rounds that time down to the start of the stub.

For this reason, shiftInterestAccrualEnd stores the current clock value in paymentClockFloorTimestamp. From that time on, nearestInterestPaymentTimestampAt does not return a smaller value. If the extension occurs before maturity, the stored value is already on the grid, and nothing changes.

The extension does not clear paymentPausedAfterTimestamp. After an early repayment, interest after the repayment time accrues again only after one of these calls:

  • unpausePaymentAfter();
  • a later earlyRepayment(timestamp);
  • pausePaymentAfter(timestamp) with a later time.

Each call removes the pause-after time or moves it to a later time. After unpausePaymentAfter(), the clock stays at the repayment time until the next period boundary. Then the clock follows the grid.

If the old accrual end is inside a period, a shift raises the projected total of that period. A period that exists after the old accrual end gets a projected total above 0. Thus these periods can have a need. To fund them, do these steps:

  1. Read requiredInterestFunding of these periods.
  2. Fund the open periods with fundInterest.
  3. Pay the finished periods with fundInterestForPeriod, in period order.

See "Runbook: changes of the accrual end".

Managing Interest for Payment Periods​

Creating Payment Periods​

When creating payment periods with createPaymentPeriod(startTimestamp, endTimestamp, interestRate, interestRatePeriodDuration), the following requirements must be met:

  • Periods must be created sequentially, with no gaps between them
  • The end timestamp of one period must be the start timestamp of the next period
  • The first period must start at interestAccrualStartTimestamp
  • Each period's end timestamp must be a multiple of interestRatePeriodSeconds from the start timestamp, except for the final period which may end at interestAccrualEndTimestamp
  • Periods cannot be created for timestamps before interestAccrualStartTimestamp or after interestAccrualEndTimestamp
  • Interest rates cannot exceed maxInterestRate. The cap is always in effect; the constructor and setMaxInterestRate reject a value of 0
  • interestRatePeriodDuration must be exactly 360, 365, or 366 days (in seconds) to prevent manipulation of interest rate calculations

This sequential creation ensures continuous tracking of token ownership across the entire interest accrual timeframe. Interest is calculated dynamically based on the rate and time-weighted token ownership rather than fixed amounts.

Updating Interest Rate for a Period​

The updateInterestRateForPeriod(periodIdx, interestRate, interestRatePeriodDuration) function allows the Transfer Admin to modify the interest rate for a specific payment period before it starts. This enables:

  • Correcting interest rate configurations
  • Adjusting rates due to changing market conditions
  • Setting interest rate to zero for periods where no interest should accrue

Important: Interest rates can only be updated before the period starts (i.e., before block.timestamp > period.startTimestamp). The new rate cannot exceed maxInterestRate. The interestRatePeriodDuration must be exactly 360, 365, or 366 days (in seconds) to prevent manipulation of interest rate calculations.

The contract records the day-count duration of each period in interestRatePeriodDurationOf(periodIdx). It emits InterestRatePeriodDurationSet(periodIdx, interestRatePeriodDuration) on creation and on each update. The "not changed" check compares the nominal rate and the day-count duration with the stored values. An update that changes one of the two values is accepted, also when the rate per second stays the same. An update with the same two values reverts with InterestPayment_InterestRateNotChanged.

An update for a period that starts at or after the current interestAccrualEndTimestamp reverts with InterestPayment_PeriodStartsAfterAccrualEnd. Such a period does not accrue under the current accrual end, for example after an early repayment. If an admin later moves the accrual end after the start of the period, the admin can update the rate before the period starts.

An update changes the projected total of the period, not its funds. After a rate increase, the period has a need again. requiredInterestFunding(periodIdx) shows the need, and fundInterest fills it in period order. After a rate cut, the funds above the new projected total are surplus. reclaimTotalInterest can take the surplus. See "Reclaims and the funds of a period".

Setting a period's interest rate to zero effectively means that no token holder will accrue interest during that period, regardless of their token ownership. This can be useful for:

  • Implementing grace periods
  • Reflecting periods of non-performance
  • Handling special situations where interest payments should be suspended

Managing Maximum Interest Rate​

The setMaxInterestRate(maxInterestRate) function allows the Contract Admin to set a maximum interest rate cap. The cap is always in effect. The value must be from 1 to MAX_ABSOLUTE_INTEREST_RATE (10^11 basis points); a value of 0 is rejected with InterestPayment_InvalidMaxInterestRate. To remove the effective cap, set MAX_ABSOLUTE_INTEREST_RATE. This provides:

  • Protection against accidentally setting excessively high interest rates
  • Governance control over maximum borrowing costs
  • Flexibility to adjust rate caps as market conditions change

Deployments before this change: an InterestPayment contract deployed from an earlier version accepts 0, and a stored maxInterestRate of 0 means no cap there. The contract is not upgradeable, so both generations can exist. A reader can apply one rule to both: a maxInterestRate of 0 or of MAX_ABSOLUTE_INTEREST_RATE is no effective cap.

Absolute Maximum Interest Rate​

In addition to the configurable maxInterestRate, the contract enforces an absolute maximum interest rate of 1,000,000% (10^11 in basis points) via the MAX_ABSOLUTE_INTEREST_RATE constant. This hard limit:

If an interest rate exceeding MAX_ABSOLUTE_INTEREST_RATE is provided to createPaymentPeriod() or updateInterestRateForPeriod(), the transaction will revert with InterestPayment_InterestRateExceedsAbsoluteMax(provided, maximum).

These administrative functions provide considerable flexibility in managing the lifecycle of interest-bearing security tokens, allowing adjustments to both principal and interest terms while maintaining the integrity of the payment system.

Reclaiming Interest and Principal​

In cases where interest or principal funds need to be reclaimed, administrators can use several functions to reclaim unused funds. This is often necessary in scenarios such as contract migration, correction of funding errors, or legal compliance requirements.

Reclaiming Interest​

The Interest Payment contract provides multiple ways to reclaim interest:

  1. Setup: Contract Admin sets the reclaimer address that will receive all reclaimed funds
  2. Pause: Transfer Admin pauses payment for the specific period being reclaimed
  3. Reclaim Options:
    • reclaimInterestForPeriod(wallet, paymentPeriodIdx, amount): Reclaims unclaimed interest from a specific wallet for a period
    • reclaimInterest(wallet, amount): Reclaims unclaimed interest from a specific wallet across all accrued periods
    • batchReclaimInterest(wallet, periodIdxs[], amount): Reclaims unclaimed interest from a specific wallet for the listed periods
    • reclaimInterestForAllRecipients(paymentPeriodIdx): Reclaims all unclaimed interest for an entire period
    • reclaimTotalInterest(amount): Reclaims an amount of the money outside all periods, of the surplus of the started periods and of the funds of the periods that did not start
  4. Unpause: Transfer Admin unpauses payment for the period after reclaiming is complete

A period pause blocks the claims of the holder: claimInterestForPeriod and batchClaimInterestForPeriods revert for a paused period, and claimInterest skips it. The pause does not block a reclaim. Each reclaim function above works on a paused period, so steps 1 to 3 move the funds in each option. The force claims also work on a paused period; see "Force Claiming Interest".

A reclaim that names a period obeys the rules of the claims (see "Paid periods"). A period with no funds has no part to reclaim. reclaimInterestForPeriod and reclaimInterestForAllRecipients revert for it with InterestPayment_NoFundsToClaim. reclaimInterest and batchReclaimInterest skip it.

reclaimTotalInterest names no period. It can send only the money outside all periods, the surplus of the started periods and the funds of the periods that did not start to the reclaimer address. An amount above this limit reverts with InterestPayment_ReclaimAboveSurplus. See reclaimTotalInterest.

Reclaiming Principal​

The principal amount can also be reclaimed if needed:

  1. Setup: Contract Admin sets the reclaimer address that will receive reclaimed funds
  2. Pause: Transfer Admin pauses the entire contract
  3. Reclaim: Transfer Admin reclaims all unused principal funds
  4. Unpause: Transfer Admin unpauses the contract after reclaiming is complete

Do not reclaim more than the amount above requiredPrincipalFunding(). A larger reclaim decreases the pro-rata shares of the newest principal round first (see "Reclaim and the principal rounds").

Important Considerations​

  • A valid reclaimer address must be set before any reclaiming can occur
  • setReclaimerAddress rejects the zero address and the InterestPayment contract. A reclaim records the funds as paid and then transfers them to the reclaimer. If the reclaimer is the contract, the funds stay in the contract, and the contract has no function to move them out
  • setReclaimerAddress takes effect immediately. If the token specification requires a delay before a reclaimer change, give CONTRACT_ADMIN_ROLE only to an OpenZeppelin TimelockController. Each change then has 2 steps, schedule and execute, with the minimum delay between them. See Delay on contract admin actions
  • Pausing before reclaiming prevents users from claiming during the reclaim process
  • Unpausing after reclaiming allows normal operations to resume
  • Only Transfer Admin can reclaim funds, while Contract Admin can set the reclaimer address
  • Reclaimed funds are transferred directly to the reclaimer address
  • A reclaim takes effect immediately, with no notice period. This is intended: an issuer can need to reclaim at any time, for example when a regulation requires it. Only reclaimTotalInterest has a cap: the money outside all periods, the surplus of the started periods and the funds of the periods that did not start (see reclaimTotalInterest). After a reclaim, use periodPayableInterest and payableInterestOf to see what holders can still claim

Early Repayment​

The Interest Payment contract supports early repayment functionality, allowing Contract Admin or Transfer Admin to trigger an early maturity event. This feature is useful in scenarios such as:

  • Refinancing debt at a lower interest rate
  • Restructuring financial obligations
  • Implementing callable bonds that can be paid off before maturity
  • Responding to changes in market conditions

The earlyRepayment(timestamp) function performs two key actions:

  1. Sets the interest accrual end timestamp to the specified timestamp, effectively stopping any further interest accrual
  2. Pauses payment after the specified timestamp to provide administrative control over final payments

When early repayment is triggered:

  • Interest stops accruing at the specified timestamp, freezing the total interest amount
  • Token holders can still claim their accrued interest up to the repayment timestamp
  • Principal becomes available for claiming immediately (assuming it has been funded)
  • The EarlyRepayment event is emitted, recording the admin address and timestamp
  • The projected totals of the period with the repayment time and of the later periods become smaller. The funds above them become surplus, and reclaimTotalInterest can take them. It can also take all funds of each period that starts at or after the repayment time (see "Reclaims and the funds of a period")
  • If a pause-after time stops the clock, earlyRepayment replaces it with the repayment time. The holders then accrue the time from the old pause-after time to the repayment time
  • If an admin extends the loan later with shiftInterestAccrualEnd, the clock stays at the repayment time. The interest for the stub period then does not decrease below the claimed amount. Accrual after the repayment time starts again only after unpausePaymentAfter(), a later earlyRepayment or pausePaymentAfter with a later time (see Extending Maturity)
  • After a reclaim of the surplus, a later shiftInterestAccrualEnd gives the later periods a need again. Fund them before the clock moves again (see "Runbook: changes of the accrual end")

This feature provides important flexibility in managing debt instruments represented by the token, allowing administrators to respond to changing financial conditions while preserving token holders' rights to receive their accrued interest and principal.

Force Claiming Interest​

The Interest Payment contract provides administrative functions to force claim interest on behalf of wallet addresses. This is particularly useful in scenarios such as:

  • Processing interest distributions for wallets that may not have the means to claim independently
  • Managing automated distributions for institutional or managed accounts
  • Handling special settlement cases requiring administrative intervention
  • Distributing interest from paused payment periods for specific wallets

Two administrative force claim functions are available:

Force Claim for Specific Period (forceClaimForPeriod)​

The forceClaimForPeriod(wallet, periodIdx, amount) function allows the Transfer Admin to force claim interest for a specific wallet from a specific payment period:

  • If the amount parameter is set to 0, all available interest for that wallet and period will be claimed
  • If the amount parameter is greater than 0, only that amount will be claimed (up to the available claimable amount)
  • This function works even for paused payment periods, providing administrative override capability
  • The ForceClaimed event is emitted with details of the transfer admin, recipient wallet, amount, and period index

Force Claim Across All Periods (forceClaim)​

The forceClaim(wallet, amount) function allows the Transfer Admin to force claim interest for a specific wallet across all eligible payment periods:

  • Similar to forceClaimForPeriod, if amount is 0, all available interest is claimed
  • If amount is greater than 0, the function will claim up to that amount, potentially across multiple periods
  • The function processes periods sequentially, and will stop once the specified amount is reached
  • This function also works for paused payment periods
  • The ForceClaimed event is emitted for each period from which interest is claimed

Admin Functions​

The Interest Payment contract has several admin functions for managing interest payments:

  • createPaymentPeriod(startTimestamp, endTimestamp, interestRate, interestRatePeriodDuration): Creates a new payment period with specified interest rate. It moves the money outside all periods into the new period, up to the need of the period.
  • updateInterestRateForPeriod(periodIdx, interestRate, interestRatePeriodDuration): Updates the interest rate for a specific period before it starts.
  • setMaxInterestRate(maxInterestRate): Sets the maximum allowed interest rate (Contract Admin only).
  • fundInterest(amount): Funds the contract with interest payment tokens. The amount fills the period that contains the block time and the later periods to their needs. The rest goes outside all periods.
  • fundInterestForPeriod(amount, periodIdx): Funds the next finished period to pay, up to its need. It sets the paid flag when the funds of the period cover it (Transfer Admin only).
  • fundInterestForPeriods(amount, periodIdxs): Makes one transfer and funds each listed period, in period order, with the rules of fundInterestForPeriod (Transfer Admin only).
  • claimInterest(amount): Allows token holders to claim interest across all payment periods, with optional amount cap (0 for all available).
  • claimInterestForPeriod(periodIdx, amount): Enables token holders to claim interest for a specific payment period, with optional amount cap.
  • batchClaimInterestForPeriods(periodIdxs[], amount): Allows token holders to claim interest for multiple payment periods in a single transaction, with optional amount cap. A listed period with nothing to claim is skipped.
  • reclaimInterest(wallet, amount): Reclaims unclaimed interest from a wallet across all periods. A positive amount is exact; 0 reclaims all available.
  • reclaimInterestForPeriod(wallet, paymentPeriodIdx, amount): Reclaims unclaimed interest from a wallet for a specific period, with optional amount cap.
  • batchReclaimInterest(wallet, periodIdxs[], amount): Reclaims unclaimed interest from a wallet for multiple periods, with optional amount cap.
  • reclaimInterestForAllRecipients(paymentPeriodIdx): Reclaims all unclaimed interest for a period.
  • reclaimTotalInterest(amount): Reclaims an amount of the money outside all periods, of the surplus of the started periods and of the funds of the periods that did not start.
  • pausePaymentPeriod(periodIdx) and unpausePaymentPeriod(periodIdx): Pauses or unpauses claiming for a specific period.
  • pausePaymentAfter(timestamp): Pauses claiming after the given timestamp.
  • unpausePaymentAfter(): Unpause claiming.
  • pause(isPaused): Pauses or unpauses the entire contract.
  • shiftInterestAccrualEnd(timestamp): Updates the end timestamp for interest accrual for all payment periods. This allows the Transfer Admin to extend the maturity day.
  • setReclaimerAddress(reclaimerAddress): Sets the address that is authorized to receive reclaimed interest. This address must be set before any reclaim operations can be performed.
  • fundPrincipal(amount): Transfers principal payment tokens to the contract for distribution to token holders at maturity. After the funding, the unused principal must not be more than requiredPrincipalFunding().
  • claimPrincipal(amount): Allows token holders to claim their principal amount at maturity based on their token holdings. While the principal is not fully funded, a holder can claim only a pro-rata share. Amount parameter: 0 = all that is due now, >0 = claim specific amount.
  • reclaimPrincipal(amount): Enables the Transfer Admin to reclaim unclaimed principal amounts from the contract. Amount parameter: 0 = reclaim all available, >0 = reclaim specific amount.
  • earlyRepayment(timestamp): Allows the Contract Admin or Transfer Admin to trigger early repayment of the loan at a specific timestamp.
  • forceClaim(wallet, amount): Allows Transfer Admin to force claim interest for a specific wallet across all payment periods, with optional amount cap (0 for all available).
  • forceClaimForPeriod(wallet, periodIdx, amount): Enables Transfer Admin to force claim interest for a specific wallet and payment period, with optional amount cap (0 for all available).

Interest Accrual and Calculation​

The contract provides several view functions to check accrued interest:

  • totalAccruedInterest(): Returns the total accrued interest at the current time.
  • totalAccruedInterestAt(timestamp): Returns the total accrued interest at a specific timestamp.
  • accruedInterest(account): Returns the accrued interest for a specific account.
  • accruedInterestAt(account, timestamp): Returns the accrued interest for a specific account at a specific timestamp.
  • accruedInterestForPeriod(account, periodIdx): Returns the accrued interest for a specific account in a specific payment period.
  • paymentPeriodsCount(): Returns the total number of payment periods that have been created.
  • periodTotalInterest(periodIdx): Returns the total interest amount that was accrued during a specific payment period.
  • periodTotalClaimedInterest(periodIdx): Returns the total amount of interest that has been claimed by token holders for a specific payment period.
  • periodTotalReclaimedInterest(periodIdx): Returns the total amount of interest that has been reclaimed by the admin for a specific payment period.
  • periodAvailableInterest(periodIdx): Returns the amount of interest that is still available to be claimed for a specific payment period.
  • periodPayableInterest(periodIdx): Returns the interest that the contract can still pay for a period. The result is 0 for a period with no funds.
  • payableInterestOf(account): Returns the most interest that claimInterest can pay to an account now. Each period pays only from its own funds.
  • isPeriodPaid(periodIdx) and paidPeriodsCount(): Return the paid flags.
  • isPaidThrough(timestamp): Returns true when each period that ends at or before the time has a flag, or does not accrue.
  • requiredInterestFunding(periodIdx): Returns the need of the period: its projected total less its funds, or 0. For a period that is not finished, the need can include a margin of 1 wei.
  • periodFundedInterest(periodIdx): Returns the funds of the period.
  • unassignedInterest(): Returns the money outside all periods.
  • periodDuration(periodIdx): Returns the duration (in seconds) of a specific payment period.
  • periodStartTimestamp(periodIdx): Returns the start timestamp of a specific payment period.
  • periodEndTimestamp(periodIdx): Returns the end timestamp of a specific payment period.
  • unclaimedAmountAt(receiver, timestamp): Returns the amount of unclaimed interest for a specific receiver at a given timestamp. The result does not examine the funds or the paid flags.
  • unclaimedAmountForPeriod(receiver, periodIdx): Returns the amount of unclaimed interest for a specific receiver in a specific payment period. The result does not examine the funds or the paid flags.
  • claimedAmountForPeriod(receiver, periodIdx): Returns the amount of interest that has been claimed by a specific receiver in a specific payment period.
  • reclaimedAmountForPeriod(receiver, periodIdx): Returns the amount of interest that has been reclaimed from a specific receiver in a specific payment period.
  • usedAmountForPeriod(receiver, periodIdx): Returns the total amount of interest that has been either claimed or reclaimed for a specific receiver in a specific payment period.
  • accountTotalClaimedAmount(receiver): Returns the total amount of interest that has been claimed by a specific receiver across all payment periods.
  • accountTotalReclaimedAmount(receiver): Returns the total amount of interest that has been reclaimed from a specific receiver across all payment periods.
  • totalInterestAmountFunded(): Returns the total amount of interest that has been funded to the contract.
  • totalInterestAmountClaimed(): Returns the total amount of interest that has been claimed by all token holders.
  • totalInterestAmountReclaimed(): Returns the total amount of interest that has been reclaimed by admins.
  • totalInterestAmountUnused(): Returns the total amount of interest that remains unused in the contract.
  • nearestInterestPaymentTimestampAt(timestamp): Returns the nearest interest payment timestamp at a given timestamp (rounded to period boundaries). At or after paymentClockFloorTimestamp, the result is never less than that floor.
  • paymentClockFloorTimestamp(): Returns the payment clock value stored at the last shiftInterestAccrualEnd call, or 0 if the accrual end was never extended.
  • findPaymentPeriodIndex(startTimestamp, endTimestamp): Finds the index of a payment period that covers the specified time range.
  • paymentPeriodPaused(periodIdx): Returns whether a specific payment period is paused.
  • fundedPrincipalAmount(): Returns the total amount of principal that has been funded to the contract.
  • reclaimPrincipalAmount(): Returns the total amount of principal that has been reclaimed by the admin.
  • claimedPrincipalAmount(): Returns the total amount of principal that has been claimed by token holders.
  • totalAvailablePrincipalAmount(): Returns the total amount of principal that is still available to be claimed.
  • availablePrincipalAmount(account): Returns the amount of principal that is available to be claimed by a specific account: the face value of the balance with full funding, or the pro-rata share with partial funding. With partial funding, it returns 0 before maturity. It returns 0 while the contract does not have the soft burn role. The view does not read the allowance that the claim needs.
  • claimedPrincipalOf(account): Returns the principal that a specific account claimed.
  • principalRoundCount(): Returns the number of principal rounds.
  • principalRound(index): Returns the snapshot time and the amount of a principal round, oldest first (see "Principal rounds").
  • requiredPrincipalFunding(): Returns the unused principal that the contract must hold before every holder can redeem the full balance: the circulating supply × principalAmountPerToken.

Interest is accrued based on configurable interest rates and calculated using the formula:

interest = (interestRatePerSecond × principalAmountPerToken × ownershipForPeriod) / (INTEREST_RATE_PRECISION_FACTOR × BIPS_PRECISION)

Where:

  • ownershipForPeriod = time-weighted ownership = token balance × time period duration (in seconds)
  • interestRatePerSecond = (interestRate × INTEREST_RATE_PRECISION_FACTOR) / interestRatePeriodDuration
  • INTEREST_RATE_PRECISION_FACTOR = 10^24 (constant) for interest rate calculations
  • BIPS_PRECISION = 10,000,000 for basis points calculations

The interest rate is specified in basis points (bips) where 10,000,000 bips = 100%. For example, a 5% annual interest rate would be specified as 500,000 bips.

Precision and Overflow Protection​

The contract uses OpenZeppelin's Math.mulDiv function for all interest calculations, which provides:

  1. 512-bit intermediate arithmetic: Prevents overflow in multiplication before division
  2. Maximum precision: Single division operation minimizes rounding errors
  3. Simplified architecture: Fixed precision factor (10^24) works for all deployment scenarios

Purpose of INTEREST_RATE_PRECISION_FACTOR:

The precision factor prevents precision loss when dividing by interestRatePeriodDuration. Without it, small rates would lose precision immediately.

Example:

  • Interest rate: 5% = 500,000 (in BIPS, where 10,000,000 = 100%)
  • Period duration: 365 days = 31,536,000 seconds

Without precision factor:

500,000 / 31,536,000 = 0 (loses everything!)

With precision factor (10^24):

(500,000 × 10^24) / 31,536,000 = 15,854,895,991,882,091,391 (preserves precision)

How Math.mulDiv Prevents Overflow:

The Math.mulDiv(a, b, c) function computes (a × b) / c using 512-bit intermediate precision. This allows safe computation even when a × b would overflow a 256-bit integer.

// Interest calculation uses single mulDiv for maximum precision
return Math.mulDiv(
interestRatePerSecond * principalAmountPerToken,
ownershipForPeriod,
INTEREST_RATE_PRECISION_FACTOR * BIPS_PRECISION
);

Best Practices:

  • Set principalAmountPerToken to represent USD/stablecoin face value (e.g., 1,000,000 for $1.00 USDC with 6 decimals)
  • The principalAmountPerToken is validated at deployment to not exceed MAX_PRINCIPAL_AMOUNT_PER_TOKEN (10^47), ensuring safe multiplication with interestRatePerSecond without overflow

Interest Rate Period Duration Validation​

The interestRatePeriodDuration parameter used in createPaymentPeriod() and updateInterestRateForPeriod() functions is strictly validated to prevent manipulation of interest rate calculations. This parameter must be exactly one of the following values:

  • 360 days (31,104,000 seconds) - Standard banking year
  • 365 days (31,536,000 seconds) - Calendar year
  • 366 days (31,622,400 seconds) - Leap year

This validation prevents administrators from bypassing interest rate limits by manipulating the duration parameter. For example, setting an extremely small duration (like 1 second) would artificially inflate the calculated interestRatePerSecond, effectively bypassing the maxInterestRate validation.

Security Impact:

  • Ensures consistent and predictable interest rate calculations
  • Prevents manipulation of the interest rate calculation formula
  • Maintains the integrity of governance-set interest rate limits
  • Protects against economic parameter violations

If an invalid duration is provided, the transaction will revert with InterestPayment_InvalidInterestRatePeriodDuration().

Amount Parameter Behavior​

All claiming and reclaiming functions support an amount parameter that allows users to specify how much they want to claim or reclaim:

  • amount = 0: Claims/reclaims all available funds
  • amount > 0: Claims/reclaims up to the specified amount, capped at available funds
  • If the specified amount exceeds available funds, the transaction will revert with InterestPayment_NotEnoughFundsToClaim

This provides fine-grained control over fund movements and enables partial claiming/reclaiming scenarios.

Principal Amount Parameter Behavior​

Principal claiming and reclaiming functions also support an amount parameter for precise control:

For claimPrincipal(amount):

While the principal is not fully funded, a holder can claim only a pro-rata share (see "Pro-rata redemption").

  • amount = 0: Claims all that is due to the token holder now, in whole tokens
  • amount > 0: Claims exactly the specified amount, with requirements:
    • Amount must not exceed the holder's available principal (availablePrincipalAmount(holder))
    • Amount must be divisible by principalAmountPerToken to ensure exact token-to-principal conversion
    • Corresponding tokens are transferred: tokensToTransfer = amount / principalAmountPerToken

For reclaimPrincipal(amount):

  • amount = 0: Reclaims all unused principal from the contract
  • amount > 0: Reclaims exactly the specified amount, capped at available unused principal

This enables use cases such as:

  • Partial redemption of token positions
  • Staged principal withdrawals
  • Precise fund management for complex financial instruments

Error Handling​

Administrative Errors​

  • InterestPayment_InvalidRestrictedLockupTokenAddress: Thrown when attempting to deploy with an invalid token address
  • InterestPayment_InvalidPaymentPeriodSeconds: Thrown when payment period is set to zero
  • InterestPayment_InvalidReclaimerAddress: Thrown when the new reclaimer is the zero address or the InterestPayment contract. Also thrown when a reclaim function is called while no reclaimer is set
  • InterestPayment_InvalidTimestamp: Thrown when providing an invalid timestamp for payment pausing
  • InterestPayment_InvalidPaymentToken: Thrown when payment token address is invalid
  • InterestPayment_InterestRateGreaterThanMaxInterestRate: Thrown when trying to set interest rate above max rate
  • InterestPayment_PeriodAlreadyStarted: Thrown when trying to update interest rate after period has started
  • InterestPayment_InterestRateNotChanged: Thrown when trying to update interest rate to the same value
  • InterestPayment_MaxInterestRateNotChanged: Thrown when trying to set max interest rate to the same value

Configuration Errors​

  • InterestPayment_InvalidInterestAccrualStartTimestamp: Thrown when start timestamp is set to zero
  • InterestPayment_InvalidInterestAccrualEndTimestamp: Thrown when end timestamp is set to zero
  • InterestPayment_InvalidInterestAccrualPeriod: Thrown when start timestamp is greater than or equal to end timestamp
  • InterestPayment_PaymentNotPausedAfter: Thrown when trying to unpause when not paused

Period Management Errors​

  • InterestPayment_InvalidPeriod: Thrown when referencing a non-existent period
  • InterestPayment_StartTimestampGreaterThanEndTimestamp: Thrown when creating a period with start after end
  • InterestPayment_StartTimestampBeforeAccrualStartTimestamp: Thrown when period starts before overall interest accrual start
  • InterestPayment_EndTimestampGreaterThanAccrualEndTimestamp: Thrown when period ends after overall interest accrual end
  • InterestPayment_NoPaymentPeriods: Thrown when attempting to claim interest when no payment periods have been created
  • InterestPayment_PeriodDurationNotMultipleOfInterestRatePeriod: Thrown when a payment period's duration does not align with the configured interest rate period. For example, if the interest rate period is set to 1 day (86400 seconds), then all payment periods must start and end at the same time of day. If interest accrual begins at 2025-01-01 12:00:00, then valid period boundaries would be 2025-01-01 12:00:00 to 2025-01-02 12:00:00, 2025-01-02 12:00:00 to 2025-01-03 12:00:00, etc. This ensures consistent interest accrual calculations across all periods.
  • InterestPayment_PeriodAlreadyExists: Thrown when attempting to create a duplicate period
  • InterestPayment_PeriodNotNext: Thrown when attempting to create a payment period that does not immediately follow the previous period. For example, if the last payment period ends at 2025-02-14 12:00:00, the next period must start at exactly that timestamp. Creating a period starting at 2025-02-24 12:00:00 would fail because it creates a gap in the payment schedule. This ensures continuous, sequential payment periods without any gaps in the interest accrual timeline.
  • InterestPayment_InvalidTotalAccruedInterest: Thrown when setting accrued interest below already claimed/reclaimed amount
  • InterestPayment_PaymentPeriodPaused: Thrown when attempting to claim from a paused period

Funding and Claiming Errors​

  • InterestPayment_InvalidAmount: Thrown when attempting to fund with zero amount
  • InterestPayment_TokenSupplyIsZero: Thrown when the circulating supply is zero during principal funding
  • InterestPayment_PrincipalFundingExceedsRequired(unusedPrincipal, required): Thrown when a funding makes the unused principal more than requiredPrincipalFunding()
  • InterestPayment_PrincipalRedemptionStarted: Thrown when shiftInterestAccrualEnd is called after the first principal claim or after a principal funding after maturity, because the shift would move the snapshot of a principal round
  • InterestPayment_PrincipalAmountNotDivisibleByTokenSupply: Thrown when a principal claim amount does not divide by principalAmountPerToken
  • InterestPayment_MissingSoftBurnRole: Thrown when a principal claim is made while the contract does not have SOFT_BURN_ADMIN_ROLE in the access control contract of the token
  • InterestPayment_InsufficientBurnAllowance(allowance, required): Thrown when the allowance of the holder to the contract is less than the tokens that a principal claim burns
  • InterestPayment_WalletFrozen(wallet): Thrown when a claim of interest or principal pays a wallet that the token reports as frozen. The force claims of an admin also revert
  • InterestPayment_InvalidToken: Thrown when using an invalid token for payment
  • InterestPayment_InvalidFeeApplied: Thrown when token transfer results in unexpected balance
  • InterestPayment_NoFundsToClaim: Thrown when attempting to claim with no available funds, or when no principal is due to the holder
  • InterestPayment_NotEnoughFundsToClaim: Thrown when attempting to force claim more than available
  • InterestPayment_PeriodNotNextToPay(nextIdx): Thrown when fundInterestForPeriod names a period that is not the next period to pay
  • InterestPayment_PeriodNotFinished(periodIdx): Thrown when fundInterestForPeriod names a period that is not finished
  • InterestPayment_PeriodInterestNotFullyFunded(funds, required): Thrown when fundInterestForPeriod gives a period no money and the funds of the period do not cover its total. required is the period total
  • InterestPayment_AmountAboveNeed(need): Thrown when the amount of fundInterestForPeriod or fundInterestForPeriods is more than the need of the listed periods
  • InterestPayment_ReclaimAboveSurplus(surplus): Thrown when reclaimTotalInterest asks for more than the money outside all periods, plus the surplus of the started periods, plus the funds of the periods that did not start
  • InterestPayment_NotEnoughFundedPrincipal: Thrown when attempting to claim more principal than available, for example more than the pro-rata share
  • InterestPayment_MaturityNotReached: Thrown when attempting to claim principal before maturity

API Reference​

Constructor​

constructor(ConstructorParams params)​

Initializes the InterestPayment contract with configuration parameters.

Parameters:

  • params (ConstructorParams): Struct containing initialization parameters

ConstructorParams Structure:

struct ConstructorParams {
address accessControl; // External access control contract address
address restrictedLockupTokenAddress; // RestrictedLockupToken contract address
address trustedForwarder; // ERC-2771 trusted forwarder address
address paymentToken; // ERC-20 token used for payments
uint256 paymentPeriodSeconds; // Interest rate period duration in seconds
uint256 principalAmountPerToken; // Principal amount per token for maturity claims
uint256 interestAccrualStartTimestamp; // When interest accrual begins
uint256 interestAccrualEndTimestamp; // When interest accrual ends (maturity)
uint256 maxInterestRate; // Maximum allowed interest rate in basis points
}

Requirements:

  • All addresses must be non-zero
  • Payment period seconds must be greater than zero
  • Interest accrual start must be before end timestamp
  • Interest accrual end must fit uint48 (InterestPayment_FieldOverflow)
  • maxInterestRate must be from 1 to MAX_ABSOLUTE_INTEREST_RATE (InterestPayment_InvalidMaxInterestRate, InterestPayment_InterestRateExceedsAbsoluteMax)
  • The token must have a snapshot periods contract: snapshotPeriodsAddress() must not be zero (InterestPayment_InvalidSnapshotPeriodsAddress)
  • The accrual window does not have to be a whole number of paymentPeriodSeconds; the last payment period ends at interestAccrualEndTimestamp and can be shorter
  • Principal amount per token must be greater than zero

Constants​

CONTRACT_ADMIN_ROLE() → uint8​

Returns the contract admin role constant (1).

Returns:

  • uint8: The contract admin role value

RESERVE_ADMIN_ROLE() → uint8​

Returns the reserve admin role constant (2).

Returns:

  • uint8: The reserve admin role value

WALLETS_ADMIN_ROLE() → uint8​

Returns the wallets admin role constant (4).

Returns:

  • uint8: The wallets admin role value

TRANSFER_ADMIN_ROLE() → uint8​

Returns the transfer admin role constant (8).

Returns:

  • uint8: The transfer admin role value

INTEREST_RATE_PRECISION_FACTOR() → uint256​

Returns the precision factor used for interest rate calculations (10^24 = 1,000,000,000,000,000,000,000,000).

Returns:

  • uint256: The constant precision factor (10^24) for interest calculations

MAX_PRINCIPAL_AMOUNT_PER_TOKEN() → uint256​

Returns the maximum allowed principal amount per token (10^47 = 100,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000).

Returns:

  • uint256: The maximum allowed value for principalAmountPerToken to prevent overflow in interest calculations

MAX_ABSOLUTE_INTEREST_RATE() → uint256​

Returns the absolute maximum allowed interest rate (10^11 = 100,000,000,000), representing 1,000,000% APR.

Returns:

  • uint256: The absolute maximum interest rate that can be set, regardless of maxInterestRate configuration

Note: This constant prevents overflow in interest calculations by ensuring interestRatePerSecond * principalAmountPerToken cannot exceed uint256 bounds. Any attempt to set an interest rate above this value will revert with InterestPayment_InterestRateExceedsAbsoluteMax.


Administrative Functions (API)​

pause(bool isPaused_)​

Pauses or unpauses the contract.

Parameters:

  • isPaused_ (bool): True to pause, false to unpause

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE

Emits: Paused or Unpaused events


pausePaymentPeriod(uint256 periodIdx)​

Pauses a specific payment period.

Parameters:

  • periodIdx (uint256): Index of the payment period to pause

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • Period index must be valid

Emits: PeriodPaused(authority, periodIdx)


unpausePaymentPeriod(uint256 periodIdx)​

Unpauses a specific payment period.

Parameters:

  • periodIdx (uint256): Index of the payment period to unpause

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • Period index must be valid

Emits: PeriodUnpaused(authority, periodIdx)


pausePaymentAfter(uint256 timestamp)​

Pauses all payments after a specific timestamp.

Parameters:

  • timestamp (uint256): Timestamp after which payments are paused

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • Timestamp must be in the future

Emits: PaymentPausedAfter(timestamp)


unpausePaymentAfter()​

Removes the payment pause timestamp.

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • Payments must currently be paused after a timestamp

After the accrual end, the call moves the clock to the accrual end. The holders then accrue the paused time. See "A pause-after time at maturity".

Emits: PaymentUnpausedAfter()


setReclaimerAddress(address newReclaimerAddress)​

Sets the address that receives reclaimed funds.

Parameters:

  • newReclaimerAddress (address): New reclaimer address

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE
  • newReclaimerAddress must not be the zero address or the InterestPayment contract. If it is, the function reverts with InterestPayment_InvalidReclaimerAddress

Emits: ReclaimerAddressChanged(authority, newReclaimerAddress)

Delay: The change takes effect immediately. To add a delay, put CONTRACT_ADMIN_ROLE under an OpenZeppelin TimelockController (see Delay on contract admin actions).


shiftInterestAccrualEnd(uint256 newInterestAccrualEndTimestamp)​

Extends the interest accrual end timestamp (maturity date).

Parameters:

  • newInterestAccrualEndTimestamp (uint256): New end timestamp

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • New timestamp must be after current end timestamp
  • New timestamp must fit uint48 (InterestPayment_FieldOverflow)
  • No principal claim occurred, and no principal funding occurred after maturity (InterestPayment_PrincipalRedemptionStarted). A shift would move the snapshot of a principal round

Effects:

  • Stores the current nearestInterestPaymentTimestampAt(block.timestamp) in paymentClockFloorTimestamp, so that the extension does not move the payment clock back
  • Does not create a payment period. Until a period covers the new end, no interest accrues after the last period. See Extending Maturity
  • Does not change paymentPausedAfterTimestamp
  • Can give the period with the old accrual end and the later periods a need. See "Runbook: changes of the accrual end"

Emits: PeriodUnpaid(periodIdx, funds) if the shift removes a flag, and InterestAccrualEndShifted(authority, newInterestAccrualEndTimestamp)


setMaxInterestRate(uint256 maxInterestRate_)​

Sets the maximum allowed interest rate.

Parameters:

  • maxInterestRate_ (uint256): New maximum interest rate in basis points

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE
  • Rate must be from 1 to MAX_ABSOLUTE_INTEREST_RATE (InterestPayment_InvalidMaxInterestRate, InterestPayment_InterestRateExceedsAbsoluteMax)
  • Rate must be different from current rate

Emits: SetMaxInterestRate(authority, maxInterestRate_)


earlyRepayment(uint256 timestamp)​

Triggers early repayment by pausing payments and updating maturity.

Parameters:

  • timestamp (uint256): New maturity timestamp

Requirements:

  • Caller must have CONTRACT_ADMIN_ROLE or TRANSFER_ADMIN_ROLE
  • Timestamp must not be before the block time (InterestPayment_InvalidTimestamp)
  • Timestamp must not be after the current interestAccrualEndTimestamp (InterestPayment_InvalidInterestAccrualEndTimestamp). Thus the call reverts after maturity. See "Runbook: changes of the accrual end"

Effects:

  • Sets paymentPausedAfterTimestamp and interestAccrualEndTimestamp to timestamp. A pause-after time that stopped the clock is replaced, so the holders accrue the time up to timestamp
  • The period that contains timestamp and the later periods get smaller projected totals. reclaimTotalInterest can take their surplus, and all funds of each period that starts at or after timestamp

Emits: PaymentPausedAfter(timestamp), PeriodUnpaid(periodIdx, funds) if the move removes a flag, InterestAccrualEndShifted(authority, timestamp) and EarlyRepayment(authority, timestamp)


Payment Period Management​

createPaymentPeriod(uint256 startTimestamp, uint256 endTimestamp, uint256 interestRate_, uint256 interestRatePeriodDuration)​

Creates a new payment period with specified interest rate.

The function does not check the block time. A period can start in the past, and it pays interest from its start.

Parameters:

  • startTimestamp (uint256): Period start timestamp
  • endTimestamp (uint256): Period end timestamp
  • interestRate_ (uint256): Interest rate in basis points
  • interestRatePeriodDuration (uint256): Duration for interest rate calculation (must be 360, 365, or 366 days)

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Start must be before end timestamp
  • Period must be sequential (no gaps)
  • End must not be after interestAccrualEndTimestamp
  • Interest rate must not exceed maximum
  • interestRatePeriodDuration must be exactly 360, 365, or 366 days (in seconds)

Effects:

  • Moves the money outside all periods into the new period, up to the need of the new period at the current supply. The rest stays outside all periods. See "createPaymentPeriod moves the money outside all periods"

Emits: PaymentPeriodCreated(authority, periodIdx, startTimestamp, endTimestamp, interestRate_) and InterestRatePeriodDurationSet(periodIdx, interestRatePeriodDuration). If money moves into the new period, then also PeriodFundsChanged(periodIdx, funds) and UnassignedInterestChanged(amount)


updateInterestRateForPeriod(uint256 periodIdx, uint256 interestRate_, uint256 interestRatePeriodDuration)​

Updates the interest rate for an existing period before it starts. The update changes the projected total of the period, not its funds. After a rate increase, fundInterest fills the need. After a rate cut, reclaimTotalInterest can take the surplus.

Parameters:

  • periodIdx (uint256): Index of the period to update
  • interestRate_ (uint256): New interest rate in basis points
  • interestRatePeriodDuration (uint256): Duration for interest rate calculation (must be 360, 365, or 366 days)

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Period must not have started yet
  • Period must start before the current interestAccrualEndTimestamp (InterestPayment_PeriodStartsAfterAccrualEnd)
  • The nominal rate or the day-count duration must be different from the stored values (InterestPayment_InterestRateNotChanged)
  • Rate must not exceed maximum
  • interestRatePeriodDuration must be exactly 360, 365, or 366 days (in seconds)

Emits: InterestRateUpdated(authority, periodIdx, interestRate_) and InterestRatePeriodDurationSet(periodIdx, interestRatePeriodDuration)


Interest Funding and Management​

fundInterest(uint256 amount)​

Funds the contract with payment tokens for interest distributions.

The amount fills the period that contains the block time to its need, then each later period in period order. The rest goes to the money outside all periods. A period that ended by the block time gets nothing, also without the flag. A period with a stopped clock before the block time also gets nothing; fundInterestForPeriod can fill it without the flag. The call does not move the money that is already outside all periods. See "fundInterest fills the ongoing period and the later periods". Use this function for a prefund or a top-up. For the amount of a prefund, see "The prefund of a purchase".

Parameters:

  • amount (uint256): Amount of payment tokens to fund

Requirements:

  • Contract must not be paused
  • Amount must be greater than zero
  • Caller must have approved tokens to contract

Emits: PeriodFundsChanged(periodIdx, funds) for each period that gets money, then UnassignedInterestChanged(amount) if money goes outside all periods, then Funded(funder, amount)


fundInterestForPeriod(uint256 amount, uint256 periodIdx)​

Funds a finished period up to its need. If the funds of the period then cover its total, the call sets the paid flag. If not, the money stays in the period without the flag, and holders claim a pro-rata part. The call also fills the period with a clock that a passed pause-after time stopped, without the flag. See "fundInterestForPeriod pays a finished period".

Parameters:

  • amount (uint256): Amount of payment tokens to fund, or 0. It must not be more than requiredInterestFunding(periodIdx)
  • periodIdx (uint256): Index of the period to fund

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Period must exist (InterestPayment_InvalidPeriodIndex)
  • periodIdx must be paidPeriodsCount(); otherwise the call reverts with InterestPayment_PeriodNotNextToPay(nextIdx)
  • The payment clock must be at or after the end of the period; otherwise the call reverts with InterestPayment_PeriodNotFinished(periodIdx). A period that contains the accrual end is also permitted when the payment clock is at the accrual end. A period with a clock that a passed pause-after time stopped inside it is permitted too, but it gets no flag. A call that adds nothing to that period reverts with InterestPayment_PeriodNotFinished(periodIdx)
  • amount must not be more than the need of the period; otherwise the call reverts with InterestPayment_AmountAboveNeed(need)
  • If amount is 0, the funds of the period must cover its total; otherwise the call reverts with InterestPayment_PeriodInterestNotFullyFunded(funds, required)
  • If amount is more than 0, the caller must have approved tokens to contract

The checks run before the transfer, in the order of this list.

Emits: PeriodFundsChanged(periodIdx, funds) if amount is more than 0, then PeriodPaid(periodIdx, funds) if the call sets the flag, then Funded(funder, amount) if amount is more than 0


fundInterestForPeriods(uint256 amount, uint256[] periodIdxs)​

Makes one transfer of amount and funds each listed period, in list order, with the rules of fundInterestForPeriod. See "Flag a period".

Parameters:

  • amount (uint256): Amount of payment tokens to fund, or 0. It must not be more than the sum of requiredInterestFunding of the listed periods
  • periodIdxs (uint256[]): The periods to fund. The list starts at paidPeriodsCount() and goes up by 1

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • The list must not be empty; otherwise the call reverts with InterestPayment_InvalidPeriod
  • Each period must pass the checks of fundInterestForPeriod. If one check fails, the whole call reverts and no flag is set
  • Each listed period except the last must get its full need. Otherwise the next index reverts with InterestPayment_PeriodNotNextToPay(nextIdx)
  • An amount above the sum of the needs reverts with InterestPayment_AmountAboveNeed(sum)

Emits: for each listed period, PeriodFundsChanged(periodIdx, funds) if the period gets money and PeriodPaid(periodIdx, funds) if the call sets the flag. Then Funded(funder, amount) if amount is more than 0


claimInterest(uint256 amount)​

Claims available interest for the caller across all periods.

Each period pays only from its own funds: the full share if its funds cover it, or a pro-rata part. The call skips a period with no funds. See "The pro-rata part". If a positive amount is more than the claimable share, the call reverts with InterestPayment_NotEnoughFundsToClaim. The same rule applies to forceClaim, reclaimInterest, batchReclaimInterest and batchForceClaimInterest.

Parameters:

  • amount (uint256): Maximum amount to claim (0 = claim all available)

Requirements:

  • Contract must not be paused
  • Must have available interest to claim
  • The caller must not be frozen in the token (InterestPayment_WalletFrozen(wallet))

The function skips a paused period and pays the other periods.

Emits: Claimed(claimer, amount, periodIdx) for each period


claimInterestForPeriod(uint256 paymentPeriodIdx, uint256 amount)​

Claims interest for a specific payment period.

Parameters:

  • paymentPeriodIdx (uint256): Index of the payment period
  • amount (uint256): Amount to claim (0 = claim all available for period)

Requirements:

  • Contract must not be paused
  • Period must exist and not be paused
  • Must have available interest for the period; otherwise the call reverts with InterestPayment_NoFundsToClaim
  • The period pays only from its own funds. A period with no funds reverts with InterestPayment_NoFundsToClaim. If the funds of the period do not cover it, the call pays the pro-rata part (see "The pro-rata part")
  • The caller must not be frozen in the token (InterestPayment_WalletFrozen(wallet))

Emits: Claimed(claimer, amount, paymentPeriodIdx)


batchClaimInterestForPeriods(uint256[] paymentPeriodIdxs, uint256 amount)​

Claims interest across multiple specified periods.

Parameters:

  • paymentPeriodIdxs (uint256[]): Array of payment period indices
  • amount (uint256): Maximum total amount to claim across periods

Requirements:

  • Contract must not be paused
  • All periods must exist and not be paused
  • At least one listed period must have interest to claim, else InterestPayment_NoFundsToClaim. A listed period with nothing to claim (claimed before, a duplicate index, reclaimed, or a period that cannot pay now) is skipped. Each period that pays has its own transfer
  • The function is protected against reentrancy
  • The caller must not be frozen in the token (InterestPayment_WalletFrozen(wallet))

Emits: Claimed(claimer, amount, periodIdx) for each period that pays


forceClaim(address wallet, uint256 amount)​

Force claims interest on behalf of a wallet (admin function).

Parameters:

  • wallet (address): Address to claim interest for
  • amount (uint256): Maximum amount to claim (0 = claim all available)

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • The wallet must not be frozen in the token (InterestPayment_WalletFrozen(wallet))
  • Contract must not be paused
  • Works on a paused period (administrative override)

Emits: ForceClaimed(authority, wallet, amount, periodIdx) for each period


forceClaimForPeriod(address wallet, uint256 paymentPeriodIdx, uint256 amount)​

Force claims interest for a specific period on behalf of a wallet.

Parameters:

  • wallet (address): Address to claim interest for
  • paymentPeriodIdx (uint256): Index of the payment period
  • amount (uint256): Amount to claim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • The wallet must not be frozen in the token (InterestPayment_WalletFrozen(wallet))
  • Contract must not be paused
  • Period must exist
  • Works on a paused period (administrative override)

Emits: ForceClaimed(authority, wallet, amount, paymentPeriodIdx)


batchForceClaimInterest(address wallet, uint256[] paymentPeriodIdxs, uint256 amount)​

Force claims interest across multiple periods on behalf of a wallet.

Parameters:

  • wallet (address): Address to claim interest for
  • paymentPeriodIdxs (uint256[]): Array of payment period indices
  • amount (uint256): Maximum total amount to claim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • The wallet must not be frozen in the token (InterestPayment_WalletFrozen(wallet))
  • Contract must not be paused
  • Works on a paused period (administrative override)

Emits: ForceClaimed(authority, wallet, amount, periodIdx) for each period


Interest Reclaiming Functions​

reclaimInterest(address wallet, uint256 amount)​

Reclaims unclaimed interest from a wallet to the reclaimer address.

Parameters:

  • wallet (address): Address to reclaim interest from
  • amount (uint256): Exact amount to reclaim (0 = reclaim all available). If a positive amount is more than the unclaimed interest of the holder, the call reverts with InterestPayment_NotEnoughFundsToClaim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Reclaimer address must be set
  • Works on a paused period

Emits: Reclaimed(reclaimerAddress, wallet, amount, periodIdx) for each period


reclaimInterestForPeriod(address wallet, uint256 paymentPeriodIdx, uint256 amount)​

Reclaims interest from a specific period.

Parameters:

  • wallet (address): Address to reclaim interest from
  • paymentPeriodIdx (uint256): Index of the payment period
  • amount (uint256): Amount to reclaim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Period must exist
  • Reclaimer address must be set
  • Works on a paused period

Emits: Reclaimed(reclaimerAddress, wallet, amount, paymentPeriodIdx)


batchReclaimInterest(address wallet, uint256[] paymentPeriodIdxs, uint256 amount)​

Reclaims interest across multiple periods.

Parameters:

  • wallet (address): Address to reclaim interest from
  • paymentPeriodIdxs (uint256[]): Array of payment period indices
  • amount (uint256): Maximum total amount to reclaim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Reclaimer address must be set
  • Works on a paused period

Emits: Reclaimed(reclaimerAddress, wallet, amount, periodIdx) for each period


reclaimInterestForAllRecipients(uint256 paymentPeriodIdx)​

Reclaims all remaining interest from a completed period.

Parameters:

  • paymentPeriodIdx (uint256): Index of the payment period

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • A period without a flag must be past its end timestamp on the block time. A period with a flag can be reclaimed before its end time, for example the period that contains the accrual end
  • For a period without a flag and with an end off the payment grid, the payment clock must also pass the end. Otherwise the call reverts with InterestPayment_CannotReclaimAllForOngoingPeriod. See "A period with an end off the payment grid"
  • The period must have available interest; otherwise the call reverts with InterestPayment_NoFundsToClaim
  • The funds of the period must cover its projected total; otherwise the call reverts with InterestPayment_NoFundsToClaim. The call does not reclaim a part of a period (see "Reclaims and the funds of a period")
  • After an early repayment, the period with the stopped clock has no flag. After its end time, the call reclaims it if its funds cover it
  • While a pause-after time before the accrual end stops the clock, the call reverts for the period with the stopped clock and each later period. The error is InterestPayment_CannotReclaimAllForOngoingPeriod
  • Reclaimer address must be set
  • Works on a paused period

Warning: Do not call this function for a period whose accrual can start again. Use the reclaims for one holder. They record the amount of each holder. See "A period with a stopped payment clock".

Emits: ReclaimedAll(reclaimerAddress, amount, paymentPeriodIdx)


reclaimTotalInterest(uint256 amount)​

Reclaims an amount of the money outside all periods, of the surplus of the started periods and of the funds of the periods that did not start, without regard to wallets.

The limit is the money outside all periods plus the surplus of each started period. It also includes all funds of each period that did not start. For this call, a period started when the block time is after its start (see "Started period" in "Paid periods"). The surplus of a period is its funds less its projected total and the margin of 1 wei, or 0. The call takes the money outside all periods first. Then it takes the surplus of each started period, in period order. Then it takes the funds of each period that did not start, from the last period. It lowers the funds of each period that gives money. See "Reclaims and the funds of a period".

These limits apply:

  • The call does not take the funds of a started period below its projected total and the margin. Thus a reclaim does not lower the part that a holder can claim at the time of the reclaim.
  • A period that did not start can lose all of its funds. When it starts, it pays nobody until a later funding fills it.
  • The projected total counts the recorded supply up to the block time and the current supply after it. After a later mint, the open periods have a need again until fundInterest fills them.
  • While a pause-after time stops the clock, the block time still decides if a period started. Before the accrual end, the projected total of a started period counts the paused time at the recorded supply. Thus the period keeps the funds for that time. After the accrual end, the projected total stops at the clock, so the call can take the funds of the paused time. A later clock move gives the periods a need again. See "A pause-after time at maturity".

Parameters:

  • amount (uint256): Amount to reclaim

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • Amount must be available in unused funds; otherwise the call reverts with InterestPayment_NoFundsToClaim
  • Amount must not be more than the limit; otherwise the call reverts with InterestPayment_ReclaimAboveSurplus(surplus). surplus is the limit

Emits: UnassignedInterestChanged(amount) if the call takes money outside all periods, PeriodFundsChanged(periodIdx, funds) for each period that gives money, then ReclaimedAll(reclaimerAddress, amount, type(uint256).max)


Principal Management Functions​

fundPrincipal(uint256 amount)​

Funds principal amount for maturity claims.

Parameters:

  • amount (uint256): Amount of payment tokens to fund as principal

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Contract must not be paused
  • The circulating supply must not be zero
  • After the funding, the unused principal must not be more than requiredPrincipalFunding()

Effects:

  • A funding up to maturity goes into the maturity round. A funding after maturity goes into a new round with the snapshot at block.timestamp - 1. The fundings of one second go into one round (see "Principal rounds")

Emits: PrincipalFunded(funder, amount), and PrincipalFullyFunded(amount) when the unused principal becomes equal to requiredPrincipalFunding()


claimPrincipal(uint256 amount)​

Claims principal at maturity by burning tokens.

Parameters:

  • amount (uint256): Amount to claim (0 = all that is due now)

Requirements:

  • Contract must not be paused
  • Maturity must be reached
  • Caller must have tokens to burn
  • The amount must not be more than the due amount: the face value of the balance with full funding, or the pro-rata share with partial funding (see "Pro-rata redemption")
  • The caller must approve (or permit) the contract for the tokens to burn
  • The contract must have SOFT_BURN_ADMIN_ROLE in the access control contract of the token
  • The caller must not be frozen in the token (InterestPayment_WalletFrozen(wallet))

Emits: PrincipalClaimed(claimer, amount)


forceClaimPrincipal(address wallet, uint256 amount)​

Force claims principal on behalf of a wallet.

Parameters:

  • wallet (address): Address to claim principal for
  • amount (uint256): Amount to claim (0 = all that is due now)

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • The wallet must not be frozen in the token (InterestPayment_WalletFrozen(wallet))
  • Contract must not be paused
  • Maturity must be reached
  • The amount must not be more than the due amount of the wallet (see "Pro-rata redemption")
  • The wallet must approve (or permit) the contract for the tokens to burn
  • The contract must have SOFT_BURN_ADMIN_ROLE in the access control contract of the token

Emits: PrincipalClaimed(wallet, amount)


reclaimPrincipal(uint256 amount)​

Reclaims unused principal funds.

Parameters:

  • amount (uint256): Amount to reclaim (0 = reclaim all available)

Requirements:

  • Caller must have TRANSFER_ADMIN_ROLE
  • Reclaimer address must be set

Effects:

  • The reclaim takes from the newest principal round first, also if holders already claimed that round (see "Reclaim and the principal rounds")

Emits: PrincipalReclaimed(authority, amount)


Query Functions​

Interest Calculation Functions​

accruedInterest(address account) → uint256​

Returns total accrued interest for an account up to current time.

Parameters:

  • account (address): Address to query interest for

Returns:

  • uint256: Total accrued interest amount

accruedInterestAt(address account, uint256 timestamp) → uint256​

Returns accrued interest for an account up to a specific timestamp.

Parameters:

  • account (address): Address to query interest for
  • timestamp (uint256): Timestamp to calculate interest up to

Returns:

  • uint256: Accrued interest amount at timestamp

accruedInterestForPeriod(address account, uint256 periodIdx) → uint256​

Returns accrued interest for a specific period.

Parameters:

  • account (address): Address to query interest for
  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Accrued interest for the period

totalAccruedInterest() → uint256​

Returns total accrued interest across all accounts and periods.

Returns:

  • uint256: Total accrued interest amount

totalAccruedInterestAt(uint256 timestamp) → uint256​

Returns total accrued interest up to a specific timestamp.

Parameters:

  • timestamp (uint256): Timestamp to calculate interest up to

Returns:

  • uint256: Total accrued interest at timestamp

Period Information Functions​

paymentPeriodsCount() → uint256​

Returns the number of created payment periods.

Returns:

  • uint256: Count of payment periods

paymentPeriods(uint256 periodIdx) → (uint48, uint48, uint112, uint40, bool, uint128, uint128)​

Returns the fields of a payment period in the order of the packed struct. A consumer must decode this order. The lending pool decodes this order. Each value is one 32-byte word, so a consumer can declare the integer fields as uint256.

If periodIdx is paymentPeriodsCount() or more, the call reverts without error data. The lending pool depends on this revert. For the time after the last period, it calls the getter with paymentPeriodsCount() as the index, catches the revert and uses a rate of 0.

Release v5 of 2026-05-14 returned the fields in a different order: startTimestamp, endTimestamp, interestRatePerSecond, totalClaimedInterest, totalReclaimedInterest, interestRate, paused. A decoder for one order fails on the other order. In each direction, the bool position of the decoder holds totalReclaimedInterest of the other order. The decode reverts when that value is above 1, and a try/catch does not catch this revert.

Parameters:

  • periodIdx (uint256): Payment period index

Returns, in this order:

  1. startTimestamp (uint48)
  2. endTimestamp (uint48)
  3. interestRatePerSecond (uint112)
  4. interestRate (uint40)
  5. paused (bool)
  6. totalClaimedInterest (uint128)
  7. totalReclaimedInterest (uint128)

calculateInterestFor(uint256 amount, uint256 startTimestamp, uint256 endTimestamp) → uint256​

Calculates the interest for amount over the range, from the payment periods that overlap the range, at the present rate table. The result is a projection, not a claimable figure:

  • The function does not stop at the current block. A range that has not elapsed gives the interest that the range will earn if the rates do not change.
  • The function does not round the end down to a payment boundary. The claim paths do, so for a range that ends inside a period the result is larger than the claim paths pay at that time. For a claimable figure, round the end with nearestInterestPaymentTimestampAt() first. The result then equals accruedInterestAt() for a holder with that amount from the start.
  • The range is limited to the accrual window and to paymentPausedAfterTimestamp.
  • The result does not round. The lending pool depends on this, and it calls the function with ranges that end at or before the current block.

Parameters:

  • amount (uint256): Token amount
  • startTimestamp (uint256): Start of the range
  • endTimestamp (uint256): End of the range

Returns:

  • uint256: Interest in payment token units

paymentPeriodPaused(uint256 periodIdx) → bool​

Checks if a payment period is paused.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • bool: True if period is paused

periodTotalInterest(uint256 periodIdx) → uint256​

Returns total interest for a period based on current accrual.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Total interest amount for the period

periodAvailableInterest(uint256 periodIdx) → uint256​

Returns available (unclaimed/unreclaimed) interest for a period.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Available interest amount

periodPayableInterest(uint256 periodIdx) → uint256​

Returns the interest that the contract can still pay for a period. The result is 0 for a period with no funds. If the funds of the period cover it to its end, the result is periodAvailableInterest(periodIdx). If not, the result is the pro-rata part of the total to date, less the claimed and the reclaimed interest (see "The pro-rata part"). The funds of the period are always enough for the result. If periodIdx does not exist, the call reverts with InterestPayment_InvalidPeriodIndex.

periodAvailableInterest does not examine the funds. It can stay positive while the contract cannot pay it. periodPayableInterest then returns the amount that the contract can pay.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: The interest that the contract can pay for the period

payableInterestOf(address account) → uint256​

Returns the most interest that claimInterest can pay to account now. The function applies these rules:

  1. Add the part of the account in each period that started before the current payment timestamp, as claimInterest does. Each period pays only from its own funds (see "The pro-rata part").
  2. Skip each paused period, as claimInterest does. A force claim by an admin also includes the paused periods.

The contract always holds the total, because the funds of each period cover its parts. unclaimedAmountAt does not apply rule 1, and it does not apply rule 2. Its total can be more than claimInterest pays. Call claimInterest(payableInterestOf(account)) to claim the amount that claimInterest pays.

The function does not examine the global pause. If paused() is true, no claim occurs.

Parameters:

  • account (address): The account to check

Returns:

  • uint256: The most interest that claimInterest(amount) can pay to the account now

periodStartTimestamp(uint256 periodIdx) → uint256​

Returns the start timestamp of a payment period.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Period start timestamp

periodEndTimestamp(uint256 periodIdx) → uint256​

Returns the end timestamp of a payment period.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Period end timestamp

periodDuration(uint256 periodIdx) → uint256​

Returns the duration of a payment period in seconds.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: Period duration in seconds

Account Balance Functions​

unclaimedAmountForPeriod(address receiver_, uint256 paymentPeriodIdx_) → uint256​

Returns the unclaimed amount of an account for a specific period. The result does not examine the funds or the paid flags. It is the full share of the account, also when the funds of the period cover only a part. See "Paid periods". Use periodPayableInterest and payableInterestOf for the amounts that the contract can pay now.

Parameters:

  • receiver_ (address): Address to query
  • paymentPeriodIdx_ (uint256): Payment period index

Returns:

  • uint256: The unclaimed amount. If the claimed and reclaimed amounts are equal to or more than the accrued interest, the result is 0. The function does not revert in this case.

claimedAmountForPeriod(address receiver_, uint256 periodIdx_) → uint256​

Returns claimed interest amount for an account in a specific period.

Parameters:

  • receiver_ (address): Address to query
  • periodIdx_ (uint256): Payment period index

Returns:

  • uint256: Claimed interest amount

reclaimedAmountForPeriod(address receiver_, uint256 periodIdx_) → uint256​

Returns reclaimed interest amount for an account in a specific period.

Parameters:

  • receiver_ (address): Address to query
  • periodIdx_ (uint256): Payment period index

Returns:

  • uint256: Reclaimed interest amount

accountTotalClaimedAmount(address receiver_) → uint256​

Returns total claimed interest across all periods for an account.

Parameters:

  • receiver_ (address): Address to query

Returns:

  • uint256: Total claimed amount

accountTotalReclaimedAmount(address receiver_) → uint256​

Returns total reclaimed interest across all periods for an account.

Parameters:

  • receiver_ (address): Address to query

Returns:

  • uint256: Total reclaimed amount

Contract State Functions​

totalInterestAmountFunded() → uint256​

Returns total amount of interest funds deposited.

Returns:

  • uint256: Total funded interest amount

totalInterestAmountUnused() → uint256​

Returns total unused (available for claims) interest amount.

Returns:

  • uint256: Total unused interest amount

totalInterestAmountClaimed() → uint256​

Returns total amount of interest claimed by users.

Returns:

  • uint256: Total claimed interest amount

totalInterestAmountReclaimed() → uint256​

Returns total amount of interest reclaimed by admin.

Returns:

  • uint256: Total reclaimed interest amount

periodFundedInterest(uint256 periodIdx) → uint256​

Returns the funds of a period. fundInterest, createPaymentPeriod, fundInterestForPeriod and fundInterestForPeriods add to them. A claim or a reclaim of a holder does not lower them. reclaimTotalInterest lowers them by the amount that it takes from the period. If periodIdx does not exist, the call reverts with InterestPayment_InvalidPeriodIndex. See "Paid periods".

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: The funds of the period

unassignedInterest() → uint256​

Returns the money outside all periods. fundInterest puts here the part of its amount that the ongoing period and the later periods do not need. createPaymentPeriod moves this money into the new period. reclaimTotalInterest takes this money first. See "Paid periods".

Returns:

  • uint256: The money outside all periods

paidPeriodsCount() → uint256​

Returns the count of paid periods, from index 0. The next period to pay has this index. See "Paid periods".

Returns:

  • uint256: The count of paid periods

isPeriodPaid(uint256 periodIdx) → bool​

Returns true when fundInterestForPeriod set the flag of the period. The ongoing period is never paid, except a period that contains the accrual end when the payment clock is at that end. While a pause-after time stops the payment clock, the period with the stopped clock does not get the flag. See "A period with a stopped payment clock".

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • bool: True if the period is paid

isPaidThrough(uint256 timestamp) → bool​

Returns true when each period that ends at or before timestamp has the flag. It also returns true when the first period without a flag starts at or after the accrual end, because such a period never accrues. During a pause-after time, the period with the stopped clock has no flag. For a time after the end of that period, the result is false. See "isPaidThrough and the lending pool".

Parameters:

  • timestamp (uint256): The time to check

Returns:

  • bool: True if the first period without a flag ends after the time, or does not accrue

requiredInterestFunding(uint256 periodIdx) → uint256​

Returns the need of the period: its projected total less its funds, or 0. See "Paid periods".

  • For a finished period, the projected total is the period total. The need is the exact amount that fundInterestForPeriod must send to set the flag.
  • For the ongoing period and a later period, the projected total also counts the interest of the rest of the period. The rest counts the recorded supply up to the block time, and the current supply after it. This interest stops at an earlier accrual end, and it rounds up. A mint or a burn changes the value from its time.
  • If this interest is above 0, the need includes a margin of 1 wei (see "The margin of 1 wei"). At a later payment tick, a filled period that is not finished can show a need of 1 wei. It still pays the full share.

If periodIdx does not exist, the call reverts with InterestPayment_InvalidPeriodIndex.

Parameters:

  • periodIdx (uint256): Payment period index

Returns:

  • uint256: The amount to fund

Principal Functions​

fundedPrincipalAmount() → uint256​

Returns total principal amount funded.

Returns:

  • uint256: Total funded principal amount

claimedPrincipalAmount() → uint256​

Returns total principal amount claimed.

Returns:

  • uint256: Total claimed principal amount

reclaimedPrincipalAmount() → uint256​

Returns total principal amount reclaimed.

Returns:

  • uint256: Total reclaimed principal amount

totalAvailablePrincipalAmount() → uint256​

Returns total available principal amount for claims.

Returns:

  • uint256: Total available principal amount

availablePrincipalAmount(address account) → uint256​

Returns the available principal amount for a specific account: the amount that claimPrincipal(0) pays now. With full funding, it is the face value of the balance. With partial funding, it is the pro-rata share (see "Pro-rata redemption"), and it is 0 before maturity. It also returns 0 while the contract does not have SOFT_BURN_ADMIN_ROLE in the access control contract of the token. The view does not read the allowance that the claim needs.

Parameters:

  • account (address): Address to query

Returns:

  • uint256: Available principal amount for the account

requiredPrincipalFunding() → uint256​

Returns the unused principal that the contract must hold before every holder can redeem the full balance. A mint increases it, and a burn decreases it. While the unused principal is less, holders can claim only a pro-rata share.

Returns:

  • uint256: (total supply - token balance of the Interest Payment contract) × principalAmountPerToken

claimedPrincipalOf(address account) → uint256​

Returns the principal that a specific account claimed. A pro-rata claim subtracts it from the share of the account.

Parameters:

  • account (address): Address to query

Returns:

  • uint256: Principal that the account claimed, in payment token units

principalRoundCount() → uint256​

Returns the number of principal rounds. A reclaim that empties a round removes it.

Returns:

  • uint256: Number of principal rounds

principalRound(uint256 index) → (uint256 snapshotTimestamp, uint256 amount)​

Returns a principal round, oldest first (see "Principal rounds"). The maturity round, if it exists, is at index 0. Its snapshot is interestAccrualEndTimestamp - 1, and it moves with the accrual end until maturity. For an index that is not less than principalRoundCount(), it returns (0, 0).

Parameters:

  • index (uint256): Index of the round

Returns:

  • snapshotTimestamp (uint256): Time of the balances that set the shares of the round
  • amount (uint256): Funded principal of the round minus reclaims, in payment token units

Contract Configuration Functions​

restrictedLockupToken() → address​

Returns the RestrictedLockupToken contract address.

Returns:

  • address: Token contract address

paymentToken() → address​

Returns the payment token contract address.

Returns:

  • address: Payment token contract address

principalAmountPerToken() → uint256​

Returns the principal amount per token for maturity claims.

Returns:

  • uint256: Principal amount per token

Utility Functions​

nearestInterestPaymentTimestampAt(uint256 timestamp) → uint256​

Returns the nearest valid interest payment timestamp. The function applies these rules in this order:

  1. Before interestAccrualStartTimestamp, returns interestAccrualStartTimestamp
  2. If paymentPausedAfterTimestamp is set, limits the input to that value
  3. At or after interestAccrualEndTimestamp, returns interestAccrualEndTimestamp
  4. In other cases, rounds down to the last period boundary. At or after paymentClockFloorTimestamp, the result is never less than that floor

Parameters:

  • timestamp (uint256): Input timestamp

Returns:

  • uint256: Nearest payment timestamp

paymentClockFloorTimestamp() → uint256​

Returns the payment clock value stored at the last shiftInterestAccrualEnd call, or 0 if the accrual end was never extended.

Returns:

  • uint256: The floor that nearestInterestPaymentTimestampAt applies

findPaymentPeriodIndex(uint256 startTimestamp, uint256 endTimestamp) → uint256​

Finds the index of a payment period with specific start/end timestamps.

Parameters:

  • startTimestamp (uint256): Period start timestamp
  • endTimestamp (uint256): Period end timestamp

Returns:

  • uint256: Period index or type(uint256).max if not found

Events​

Interest Payment Events​

Funded(address indexed funder, uint256 amount)​

Emitted when interest funds are deposited.

Parameters:

  • funder (address, indexed): Address that funded the contract
  • amount (uint256): Amount of tokens funded

PeriodPaid(uint256 indexed periodIdx, uint256 funds)​

Emitted when fundInterestForPeriod or fundInterestForPeriods sets the flag of a period. The event comes before Funded. See "Paid periods".

Parameters:

  • periodIdx (uint256, indexed): The index of the paid period
  • funds (uint256): The funds of the period (periodFundedInterest). They cover the period total

PeriodUnpaid(uint256 indexed periodIdx, uint256 funds)​

Emitted when a move of the accrual end removes the flag of the last flagged period, because that period ends after the old accrual end. shiftInterestAccrualEnd and earlyRepayment both move the accrual end. The funds stay in the period. An early repayment at the current accrual end does not move the end and emits no event. See "A period with a stopped payment clock".

Parameters:

  • periodIdx (uint256, indexed): The index of the period that lost its flag
  • funds (uint256): The funds of the period (periodFundedInterest)

PeriodFundsChanged(uint256 indexed periodIdx, uint256 funds)​

Emitted on each change of the funds of a period. fundInterest, createPaymentPeriod, fundInterestForPeriod, fundInterestForPeriods and reclaimTotalInterest emit it. An indexer can rebuild the funds of each period from this event. See "Events for an indexer".

Parameters:

  • periodIdx (uint256, indexed): The index of the period
  • funds (uint256): The new value of periodFundedInterest(periodIdx)

UnassignedInterestChanged(uint256 amount)​

Emitted on each change of the money outside all periods. fundInterest, createPaymentPeriod and reclaimTotalInterest emit it. See "Events for an indexer".

Parameters:

  • amount (uint256): The new value of unassignedInterest()

Claimed(address indexed claimer, uint256 amount, uint256 indexed periodIdx)​

Emitted when interest is claimed by a user.

Parameters:

  • claimer (address, indexed): Address that claimed interest
  • amount (uint256): Amount of interest claimed
  • periodIdx (uint256, indexed): Payment period index

ForceClaimed(address indexed authority, address indexed wallet, uint256 amount, uint256 indexed periodIdx)​

Emitted when interest is force claimed by admin.

Parameters:

  • authority (address, indexed): Admin address that performed force claim
  • wallet (address, indexed): Wallet address that received the claim
  • amount (uint256): Amount of interest claimed
  • periodIdx (uint256, indexed): Payment period index

Reclaimed(address indexed reclaimerAddress, address indexed wallet, uint256 amount, uint256 indexed periodIdx)​

Emitted when interest is reclaimed from a wallet.

Parameters:

  • reclaimerAddress (address, indexed): Address that received reclaimed funds
  • wallet (address, indexed): Wallet address funds were reclaimed from
  • amount (uint256): Amount of interest reclaimed
  • periodIdx (uint256, indexed): Payment period index

ReclaimedAll(address indexed reclaimerAddress, uint256 amount, uint256 indexed periodIdx)​

Emitted when all remaining interest is reclaimed from a period.

Parameters:

  • reclaimerAddress (address, indexed): Address that received reclaimed funds
  • amount (uint256): Amount of interest reclaimed
  • periodIdx (uint256, indexed): Payment period index (type(uint256).max for total reclaim)

Payment Period Events​

PaymentPeriodCreated(address indexed authority, uint256 indexed periodIdx, uint256 startTimestamp, uint256 endTimestamp, uint256 interestRate)​

Emitted when a new payment period is created.

Parameters:

  • authority (address, indexed): Address that created the period
  • periodIdx (uint256, indexed): Index of the created period
  • startTimestamp (uint256): Period start timestamp
  • endTimestamp (uint256): Period end timestamp
  • interestRate (uint256): Interest rate in basis points

InterestRateUpdated(address indexed authority, uint256 indexed periodIdx, uint256 interestRate)​

Emitted when interest rate is updated for a period.

Parameters:

  • authority (address, indexed): Address that updated the rate
  • periodIdx (uint256, indexed): Payment period index
  • interestRate (uint256): New interest rate in basis points

InterestRatePeriodDurationSet(uint256 indexed periodIdx, uint256 interestRatePeriodDuration)​

Emitted when the day-count duration of a period is recorded: on createPaymentPeriod and on updateInterestRateForPeriod. The view interestRatePeriodDurationOf(periodIdx) returns the stored value.

Parameters:

  • periodIdx (uint256, indexed): Payment period index
  • interestRatePeriodDuration (uint256): The day-count duration in seconds (360, 365 or 366 days)

PeriodPaused(address indexed authority, uint256 indexed periodIdx)​

Emitted when a payment period is paused.

Parameters:

  • authority (address, indexed): Address that paused the period
  • periodIdx (uint256, indexed): Payment period index

PeriodUnpaused(address indexed authority, uint256 indexed periodIdx)​

Emitted when a payment period is unpaused.

Parameters:

  • authority (address, indexed): Address that unpaused the period
  • periodIdx (uint256, indexed): Payment period index

Administrative Events​

PaymentPausedAfter(uint256 timestamp)​

Emitted when payments are paused after a timestamp.

Parameters:

  • timestamp (uint256): Timestamp after which payments are paused

PaymentUnpausedAfter()​

Emitted when payment pause timestamp is removed.


ReclaimerAddressChanged(address indexed authority, address indexed newReclaimerAddress)​

Emitted when reclaimer address is changed.

Parameters:

  • authority (address, indexed): Address that changed the reclaimer
  • newReclaimerAddress (address, indexed): New reclaimer address

InterestAccrualEndShifted(address indexed authority, uint256 newInterestAccrualEndTimestamp)​

Emitted when interest accrual end timestamp is extended.

Parameters:

  • authority (address, indexed): Address that shifted the end timestamp
  • newInterestAccrualEndTimestamp (uint256): New end timestamp

SetMaxInterestRate(address indexed authority, uint256 maxInterestRate)​

Emitted when maximum interest rate is changed.

Parameters:

  • authority (address, indexed): Address that set the max rate
  • maxInterestRate (uint256): New maximum interest rate

EarlyRepayment(address indexed authority, uint256 timestamp)​

Emitted when early repayment is triggered.

Parameters:

  • authority (address, indexed): Address that triggered early repayment
  • timestamp (uint256): New maturity timestamp

Principal Events​

PrincipalFunded(address indexed funder, uint256 amount)​

Emitted when principal is funded.

Parameters:

  • funder (address, indexed): Address that funded principal
  • amount (uint256): Amount of principal funded

PrincipalFullyFunded(uint256 amount)​

Emitted when a funding makes the unused principal equal to requiredPrincipalFunding(). From this point, every holder can redeem the full balance at maturity.

Parameters:

  • amount (uint256): The required amount

PrincipalClaimed(address indexed claimer, uint256 amount)​

Emitted when principal is claimed.

Parameters:

  • claimer (address, indexed): Address that claimed principal
  • amount (uint256): Amount of principal claimed

PrincipalReclaimed(address indexed authority, uint256 amount)​

Emitted when principal is reclaimed.

Parameters:

  • authority (address, indexed): Address that reclaimed principal
  • amount (uint256): Amount of principal reclaimed

Pausable Events​

Paused(address account)​

Emitted when contract is paused.

Parameters:

  • account (address): Address that paused the contract

Unpaused(address account)​

Emitted when contract is unpaused.

Parameters:

  • account (address): Address that unpaused the contract

Custom Errors​

Access Control Errors​

EasyAccessControl_DoesNotHaveContractAdminRole(address addr)​

Thrown when address lacks CONTRACT_ADMIN_ROLE.

Parameters:

  • addr (address): Address that lacks the role

EasyAccessControl_DoesNotHaveTransferAdminRole(address addr)​

Thrown when address lacks TRANSFER_ADMIN_ROLE.

Parameters:

  • addr (address): Address that lacks the role

EasyAccessControl_DoesNotHaveContractOrTransferAdminRole(address addr)​

Thrown when address lacks both CONTRACT_ADMIN_ROLE and TRANSFER_ADMIN_ROLE.

Parameters:

  • addr (address): Address that lacks the roles

EasyAccessControl_InvalidZeroAddress()​

Thrown when zero address is provided where valid address required.


Configuration Errors (API)​

InterestPayment_InvalidRestrictedLockupTokenAddress()​

Thrown when invalid token address provided in constructor.


InterestPayment_InvalidPaymentPeriodSeconds()​

Thrown when payment period seconds is zero.


InterestPayment_InvalidInterestAccrualStartTimestamp()​

Thrown when interest accrual start timestamp is zero.


InterestPayment_InvalidInterestAccrualEndTimestamp()​

Thrown when interest accrual end timestamp is zero or invalid.


InterestPayment_InvalidInterestAccrualPeriod()​

Thrown when start timestamp >= end timestamp.


InterestPayment_InvalidPrincipalAmountPerToken()​

Thrown when principal amount per token is zero.


InterestPayment_PrincipalAmountPerTokenTooLarge(uint256 provided, uint256 maximum)​

Thrown when principal amount per token exceeds the maximum allowed value (10^47).

Parameters:

  • provided (uint256): The principal amount per token value that was provided
  • maximum (uint256): The maximum allowed value (MAX_PRINCIPAL_AMOUNT_PER_TOKEN)

InterestPayment_InvalidPaymentToken()​

Thrown when payment token address is zero.


InterestPayment_InvalidReclaimerAddress()​

Thrown when reclaimer address is zero.


InterestPayment_InvalidTimestamp()​

Thrown when invalid timestamp provided.


Payment Period Errors​

InterestPayment_InvalidPeriod()​

Thrown when referencing invalid period.


InterestPayment_InvalidPeriodIndex()​

Thrown when period index is out of bounds.


InterestPayment_StartTimestampGreaterThanEndTimestamp()​

Thrown when period start > end timestamp.


InterestPayment_StartTimestampBeforeAccrualStartTimestamp()​

Thrown when period starts before overall accrual start.


InterestPayment_EndTimestampGreaterThanAccrualEndTimestamp()​

Thrown when period ends after overall accrual end.


InterestPayment_PeriodDurationNotMultipleOfInterestRatePeriod()​

Thrown when period duration doesn't align with interest rate period.


InterestPayment_PeriodAlreadyExists()​

Thrown when attempting to create duplicate period.


InterestPayment_PeriodNotNext()​

Thrown when period doesn't follow sequentially.


InterestPayment_NoPaymentPeriods()​

Thrown when no payment periods exist.


InterestPayment_PaymentPeriodPaused(uint256 periodIdx)​

Thrown when attempting operation on paused period.

Parameters:

  • periodIdx (uint256): Index of paused period

InterestPayment_PeriodAlreadyStarted()​

Thrown when trying to modify started period.


InterestPayment_PeriodStartsAfterAccrualEnd()​

Thrown when updateInterestRateForPeriod is called for a period that starts at or after the current interestAccrualEndTimestamp. Such a period does not accrue under the current accrual end. If an admin moves the accrual end after the start of the period, the update is possible again.


Interest Rate Errors​

InterestPayment_InterestRateGreaterThanMaxInterestRate()​

Thrown when interest rate exceeds the configured maxInterestRate.


InterestPayment_InterestRateExceedsAbsoluteMax(uint256 provided, uint256 maximum)​

Thrown when interest rate exceeds the absolute maximum (MAX_ABSOLUTE_INTEREST_RATE = 10^11), regardless of maxInterestRate setting. This prevents overflow in interest calculations.

Parameters:

  • provided (uint256): The interest rate value that was provided
  • maximum (uint256): The maximum allowed value (MAX_ABSOLUTE_INTEREST_RATE)

InterestPayment_InterestRateNotChanged()​

Thrown when trying to set same interest rate.


InterestPayment_MaxInterestRateNotChanged()​

Thrown when trying to set same max interest rate.


InterestPayment_InvalidMaxInterestRate()​

Thrown when the constructor or setMaxInterestRate receives a maxInterestRate of 0. The cap is always in effect; set MAX_ABSOLUTE_INTEREST_RATE to remove the effective cap.


InterestPayment_InvalidSnapshotPeriodsAddress()​

Thrown by the constructor when the token's snapshotPeriodsAddress() is the zero address. The token was deployed without snapshots, so no accrual or claim could work.


InterestPayment_InvalidInterestRatePeriodDuration()​

Thrown when interestRatePeriodDuration is not one of the allowed values (360, 365, or 366 days).

Security Note: This validation prevents manipulation of interest rate calculations by restricting the duration parameter to standard year lengths.


Funding and Claiming Errors (API)​

InterestPayment_InvalidAmount()​

Thrown when amount is zero or invalid.


InterestPayment_TokenSupplyIsZero()​

Thrown when token supply is zero during operations.


InterestPayment_PrincipalFundingExceedsRequired(uint256 unusedPrincipal, uint256 required)​

Thrown when a funding makes the unused principal more than requiredPrincipalFunding().

Parameters:

  • unusedPrincipal (uint256): The unused principal after the funding
  • required (uint256): The value of requiredPrincipalFunding()

InterestPayment_PrincipalRedemptionStarted()​

Thrown when shiftInterestAccrualEnd is called after the first principal claim, or after a principal funding after maturity. The shift would move the snapshot of the maturity round, or put maturity after the snapshot of a later round (see "Principal rounds").


InterestPayment_PrincipalAmountNotDivisibleByTokenSupply()​

Thrown when a principal claim amount does not divide by principalAmountPerToken.


InterestPayment_InvalidFeeApplied()​

Thrown when unexpected fee applied during transfer.


InterestPayment_NoFundsToClaim()​

Thrown when no funds available for claiming.


InterestPayment_NotEnoughFundsToClaim()​

Thrown when insufficient funds for requested claim.


InterestPayment_PeriodNotNextToPay(uint256 nextIdx)​

Thrown when fundInterestForPeriod names a period that is not the next period to pay. The error gives the index of the next period to pay.


InterestPayment_PeriodNotFinished(uint256 periodIdx)​

Thrown when fundInterestForPeriod names a period that is not finished on the payment clock. The ongoing period and a period with a stopped payment clock are not finished. The exception is a period that contains the accrual end when the payment clock is at the accrual end.


InterestPayment_PeriodInterestNotFullyFunded(uint256 funds, uint256 required)​

Thrown when fundInterestForPeriod or fundInterestForPeriods gives a period no money and the funds of the period do not cover its total. An amount of 0 for a period that is not full is an example. funds is the funds of the period. required is the period total.


InterestPayment_AmountAboveNeed(uint256 need)​

Thrown when the amount of fundInterestForPeriod is more than the need of the period. For fundInterestForPeriods, the error gives the sum of the needs of the listed periods. See requiredInterestFunding.


InterestPayment_ReclaimAboveSurplus(uint256 surplus)​

Thrown when reclaimTotalInterest asks for more than the money outside all periods, plus the surplus of the started periods, plus the funds of the periods that did not start. The error gives this limit. See reclaimTotalInterest.


InterestPayment_NotEnoughFundedPrincipal()​

Thrown when insufficient principal funded.


InterestPayment_MaturityNotReached()​

Thrown when trying to claim principal before maturity.


Pause/Unpause Errors​

InterestPayment_PaymentNotPausedAfter()​

Thrown when trying to unpause when not paused.


InterestPayment_CannotReclaimAllForOngoingPeriod()​

Thrown when reclaimInterestForAllRecipients names a period without a flag before its end time. It is also thrown after the end time while the total of that period still grows, for an end off the payment grid.


Pausable Errors​

EnforcedPause()​

Thrown when operation attempted while contract paused.


ExpectedPause()​

Thrown when pause expected but contract not paused.