Skip to main content

CreditLine

CreditLine

Deployment on Ethereum mainnet:

https://etherscan.io/address/0x4Df1e7fFB382F79736CA565F378F783678d995D8

A contract that represents the agreement between Backers and a Borrower. Includes the terms of the loan, as well as the current accounting state, such as interest owed. A CreditLine belongs to a TranchedPool, and is fully controlled by that TranchedPool. It does not operate in any standalone capacity. It should generally be considered internal to the TranchedPool.

SECONDS_PER_DAY

uint256 SECONDS_PER_DAY

GoldfinchConfigUpdated

event GoldfinchConfigUpdated(address who, address configAddress)

borrower

address borrower

currentLimit

uint256 currentLimit

maxLimit

uint256 maxLimit

interestApr

uint256 interestApr

paymentPeriodInDays

uint256 paymentPeriodInDays

termInDays

uint256 termInDays

principalGracePeriodInDays

uint256 principalGracePeriodInDays

lateFeeApr

uint256 lateFeeApr

balance

uint256 balance

interestOwed

uint256 interestOwed

principalOwed

uint256 principalOwed

termEndTime

uint256 termEndTime

nextDueTime

uint256 nextDueTime

interestAccruedAsOf

uint256 interestAccruedAsOf

lastFullPaymentTime

uint256 lastFullPaymentTime

totalInterestAccrued

uint256 totalInterestAccrued

config

contract GoldfinchConfig config

initialize

function initialize(address _config, address owner, address _borrower, uint256 _maxLimit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays) public

limit

function limit() external view returns (uint256)

drawdown

function drawdown(uint256 amount) external

Updates the internal accounting to track a drawdown as of current block timestamp. Does not move any money

NameTypeDescription
amountuint256The amount in USDC that has been drawndown

setLateFeeApr

function setLateFeeApr(uint256 newLateFeeApr) external

setLimit

function setLimit(uint256 newAmount) external

setMaxLimit

function setMaxLimit(uint256 newAmount) external

termStartTime

function termStartTime() external view returns (uint256)

isLate

function isLate() external view returns (bool)

withinPrincipalGracePeriod

function withinPrincipalGracePeriod() external view returns (bool)

setTermEndTime

function setTermEndTime(uint256 newTermEndTime) public

setNextDueTime

function setNextDueTime(uint256 newNextDueTime) public

setBalance

function setBalance(uint256 newBalance) public

setTotalInterestAccrued

function setTotalInterestAccrued(uint256 _totalInterestAccrued) public

setInterestOwed

function setInterestOwed(uint256 newInterestOwed) public

setPrincipalOwed

function setPrincipalOwed(uint256 newPrincipalOwed) public

setInterestAccruedAsOf

function setInterestAccruedAsOf(uint256 newInterestAccruedAsOf) public

setLastFullPaymentTime

function setLastFullPaymentTime(uint256 newLastFullPaymentTime) public

assess

function assess() public returns (uint256, uint256, uint256)

Triggers an assessment of the creditline. Any USDC balance available in the creditline is applied towards the interest and principal.

NameTypeDescription
[0]uint256Any amount remaining after applying payments towards the interest and principal
[1]uint256Amount applied towards interest
[2]uint256Amount applied towards principal

calculateNextDueTime

function calculateNextDueTime() internal view returns (uint256)

currentTime

function currentTime() internal view virtual returns (uint256)

_isLate

function _isLate(uint256 timestamp) internal view returns (bool)

_termStartTime

function _termStartTime() internal view returns (uint256)

handlePayment

function handlePayment(uint256 paymentAmount, uint256 timestamp) internal returns (uint256, uint256, uint256)

Applies `amount` of payment for a given credit line. This moves already collected money into the Pool. It also updates all the accounting variables. Note that interest is always paid back first, then principal. Any extra after paying the minimum will go towards existing principal (reducing the effective interest rate). Any extra after the full loan has been paid off will remain in the USDC Balance of the creditLine, where it will be automatically used for the next drawdown.

NameTypeDescription
paymentAmountuint256The amount, in USDC atomic units, to be applied
timestampuint256The timestamp on which accrual calculations should be based. This allows us to be precise when we assess a Credit Line

_updateAndGetInterestAndPrincipalOwedAsOf

function _updateAndGetInterestAndPrincipalOwedAsOf(uint256 timestamp) internal returns (uint256, uint256)

updateCreditLineAccounting

function updateCreditLineAccounting(uint256 newBalance, uint256 newInterestOwed, uint256 newPrincipalOwed) internal

_getUSDCBalance

function _getUSDCBalance(address _address) internal view returns (uint256)