Credit Coop
  • About Us
    • Introduction
    • Get in Touch
  • ⚙️About Our Products
    • Secured Line of Credit
      • Line of Credit Features (v1)
        • Cash Flow Financing
        • Deploying a Secured Line of Credit
        • Core Lending Functionality
        • Revenue-Based Lending Operations
        • Collateral Operations
        • Credit Events
    • The Spigot
      • Key features of the Spigot
      • Spigot Roles
        • Owner
        • Operator
  • ⚙️User Documentation
    • User Documentation (v1)
    • User Documentation (v2)
  • ⚙️DEVELOPER MATERIAL
    • Introduction
    • Deployed Contracts
    • V1 Developer Material
      • Architecture (v1)
      • Functions and Methods
        • LineOfCredit.sol
        • Oracle.sol
        • Spigot.sol
        • SpigotedLine.sol
        • Escrow.sol
        • EscrowedLine.sol
        • SecuredLine.sol
        • LineFactory.sol
        • Libraries
        • InterestRateCredit.sol
          • Accrued Interest Calculation
          • 'Interest Accrued' contract flow
        • Advanced Jargon
      • Repaying Debt - Function View
      • Valuation Oracle
      • Arbiter Role (v1)
        • liquidate() and declareInsolvent()
        • Spigot related functions
        • enableCollateral()
      • Edge Cases and Risk Situations
      • Security Audits
  • 💼Legal
    • Important Legal Notice
    • Terms of Use
    • Privacy Policy
Powered by GitBook
On this page
  • Formulae
  • Parameters
  • Contract workflow

Was this helpful?

  1. DEVELOPER MATERIAL
  2. V1 Developer Material
  3. Functions and Methods
  4. InterestRateCredit.sol

Accrued Interest Calculation

Describes how accrued interest is calculated and where and when this happens

Formulae

Interest = (r * x * t) / 1yr / 10000

r = APR in basis points (e.g. 5% = 500bp)

x = amount of tokens

t = time (in seconds)

1 year = 365.25 days (in seconds)

Full Accrued Interest formula

InterestAccrued =

(rate.dRate * drawnBalance * timespan) / INTEREST_DENOMINATOR

+

(rate.fRate * (facilityBalance - drawnBalance) * timespan) / INTEREST_DENOMINATOR

Parameters

interestAccrued

Interest owed by a Borrower but not yet repaid to the Line of Credit contract

Interest denominator = 365.25 days * Base denominator

Base denominator

10000 (adjustment factor since rates are expressed in basis points (bps) --> e.g. 5% rate is expressed as 500bp so we need to divide by 100 to get a % and then by another 100 to arrive at the decimal (500/100/100 = 0.05)

One year

One Julian astronomical year, has 365.25 days: 1 year = 365.25 days = (365.25 days) × (24 hours/day) × (3600 seconds/hour) = 31557600 seconds

dRate

The annual interest rate charged to a Borrower on borrowed / drawn down funds (in basis points to 4 decimals, e.g. 1000bp = 10% and 1234bp = 12.34% and 1234.56bp = 12.3456%)

drawnBalance

The balance of funds that a Borrower has drawn down on the Line of Credit

fRate

The annual interest rate charged to a Borrower on the remaining funds available, but not yet drawn down aka rate charged on the available facility headroom(in basis points to 4 decimals).

facilityBalance

The remaining balance of funds that a Borrower can still drawn down on the Line of Credit (aka headroom)

timespan= block.timestamp - rate.lastAccrued

The number of seconds for which interest will be accrued

block.timestamp

The block timestamp for the block during which interest is calculated, in seconds

Contract workflow

The definitions below are useful for that.

Principal

The amount of a Lender's Deposit that has actually been drawn down by the Borrower (USD)

Deposit

The sum of the total liquidity provided by a Lender in a given token on a Line of Credit

id

Reference id for the Credit Position made available to a Borrower by a single Lender for a given token on a Line

PreviousInterestRateCredit.solNext'Interest Accrued' contract flow

Last updated 2 years ago

Was this helpful?

Please see for an overview of the contract and function workflow.

⚙️
here