Skip to main content

CallableLoan

CallableLoan

Deployment on Ethereum mainnet:

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

A loan that allows the lenders to call back capital from the borrower.

LOCKER_ROLE

bytes32 LOCKER_ROLE

SPLIT_TOKEN_DUST_THRESHOLD

uint256 SPLIT_TOKEN_DUST_THRESHOLD

MAJOR_VERSION

uint8 MAJOR_VERSION

MINOR_VERSION

uint8 MINOR_VERSION

PATCH_VERSION

uint8 PATCH_VERSION

_staleCreditLine

struct StaleCallableCreditLine _staleCreditLine

drawdownsPaused

bool drawdownsPaused

allowedUIDTypes

uint256[] allowedUIDTypes

config

contract IGoldfinchConfig config

createdAt

uint256 createdAt

Time when the pool was initialized. Zero if uninitialized

borrower

address borrower

initialize

function initialize(contract IGoldfinchConfig _config, address _borrower, uint256 _limit, uint256 _interestApr, uint256 _numLockupPeriods, contract ISchedule _schedule, uint256 _lateFeeApr, uint256 _fundableAt, uint256[] _allowedUIDTypes) external

Initialize the pool. Can only be called once, and should be called in the same transaction as contract creation to avoid initialization front-running

Parameters

NameTypeDescription
_configcontract IGoldfinchConfigaddress of GoldfinchConfig
_borroweraddressaddress of borrower, a non-transferrable role for performing privileged actions like drawdown
_limituint256
_interestApruint256interest rate for the loan
_numLockupPeriodsuint256the number of periods at the tail end of a principal period during which call requests are not allowed
_schedulecontract ISchedule
_lateFeeApruint256late fee interest rate for the loan, which kicks in LatenessGracePeriodInDays days after a payment becomes late
_fundableAtuint256earliest time at which the first slice can be funded
_allowedUIDTypesuint256[]

submitCall

function submitCall(uint256 callAmount, uint256 poolTokenId) external returns (uint256 callRequestedTokenId, uint256 remainingTokenId)

Submit a call request for the given amount of capital. The borrower is obligated to pay the call request back at the end of the corresponding call request period.

Parameters

NameTypeDescription
callAmountuint256Amount of capital to call back
poolTokenIduint256Pool token id to be called back.

Return Values

NameTypeDescription
callRequestedTokenIduint256callRequestedTokenId Token id of the call requested token.
remainingTokenIduint256remainingTokenId Token id of the remaining token.

deposit

function deposit(uint256 tranche, uint256 amount) external returns (uint256)

Supply capital to the loan.

Parameters

NameTypeDescription
trancheuint256Should always be uncalled capital tranche index.
amountuint256amount of capital to supply

Return Values

NameTypeDescription
[0]uint256tokenId NFT representing your position in this pool

depositWithPermit

function depositWithPermit(uint256 tranche, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external returns (uint256 tokenId)

Supply capital to the loan.

Parameters

NameTypeDescription
trancheuint256Should always be uncalled capital tranche index.
amountuint256amount of capital to supply
deadlineuint256deadline of permit operation
vuint8v portion of signature
rbytes32r portion of signature
sbytes32s portion of signature

Return Values

NameTypeDescription
tokenIduint256NFT representing your position in this pool

withdraw

function withdraw(uint256 tokenId, uint256 amount) external returns (uint256, uint256)

Withdraw an already deposited amount if the funds are available. Caller must be the owner or approved by the owner on tokenId. Amount withdrawn is sent to the caller.

Parameters

NameTypeDescription
tokenIduint256the NFT representing the position
amountuint256amount to withdraw (must be <= interest+principal available to withdraw)

Return Values

NameTypeDescription
[0]uint256
[1]uint256

withdrawMultiple

function withdrawMultiple(uint256[] tokenIds, uint256[] amounts) external

Withdraw from multiple tokens

Parameters

NameTypeDescription
tokenIdsuint256[]NFT positions to withdraw. Caller must be an owner or approved on all tokens in the array
amountsuint256[]amounts to withdraw from positions such that amounts[i] is withdrawn from position tokenIds[i]

withdrawMax

function withdrawMax(uint256 tokenId) external returns (uint256 interestWithdrawn, uint256 principalWithdrawn)

Similar to withdraw but withdraw the max interest and principal available for tokenId

drawdown

function drawdown(uint256 amount) external

Drawdown the loan. The credit line's balance should increase by the amount drawn down. Junior capital must be locked before this function can be called. If senior capital isn't locked then this function will lock it for you (convenience to avoid calling lockPool() separately). This function should revert if the amount requested exceeds the the current slice's currentLimit This function should revert if the caller is not the borrower.

Parameters

NameTypeDescription
amountuint256USDC to drawdown. This amount is transferred to the caller

pay

function pay(uint256 amount) external returns (struct ILoan.PaymentAllocation)

Pay down interest + principal. Excess payments are refunded to the caller

{this} must be approved by msg.sender to transfer {amount} of USDC

Parameters

NameTypeDescription
amountuint256USDC amount to pay

Return Values

NameTypeDescription
[0]struct ILoan.PaymentAllocationPaymentAllocation info on how the payment was allocated

pauseDrawdowns

function pauseDrawdowns() external

Pauses all drawdowns (but not deposits/withdraws)

unpauseDrawdowns

function unpauseDrawdowns() external

Unpause drawdowns

setAllowedUIDTypes

function setAllowedUIDTypes(uint256[] ids) external

Set accepted UID types for the loan. Requires that users have not already begun to deposit.

setFundableAt

function setFundableAt(uint256 newFundableAt) external

Update fundableAt to a new timestamp. Only the borrower can call this.

getLoanType

function getLoanType() external pure returns (enum LoanType)

getLoanType was added to support the new callable loan type. It is not supported in older versions of ILoan (e.g. legacy TranchedPools)

getFundableAt

function getFundableAt() external view returns (uint256)

getAllowedUIDTypes

function getAllowedUIDTypes() external view returns (uint256[])

inLockupPeriod

function inLockupPeriod() public view returns (bool)

numLockupPeriods

function numLockupPeriods() public view returns (uint256)

estimateOwedInterestAt

function estimateOwedInterestAt(uint256 assumedBalance, uint256 timestamp) public view returns (uint256)

Returns a naive estimate of the interest owed at the timestamp. Omits any late fees, and assumes no future payments.

estimateOwedInterestAt

function estimateOwedInterestAt(uint256 timestamp) external view returns (uint256)

Returns a naive estimate of the interest owed at the timestamp. Omits any late fees, and assumes no future payments.

loanPhase

function loanPhase() public view returns (enum LoanPhase)

Returns the current phase of the loan. See documentation on LoanPhase enum.

interestBearingBalance

function interestBearingBalance() public view returns (uint256)

TODO: Low priority tests - currently only used for tests and frontend

getAmountsOwed

function getAmountsOwed(uint256 timestamp) external view returns (uint256 returnedInterestOwed, uint256 returnedInterestAccrued, uint256 returnedPrincipalOwed)

Compute interest and principal owed on the current balance at a future timestamp

Parameters

NameTypeDescription
timestampuint256time to calculate up to

Return Values

NameTypeDescription
returnedInterestOweduint256
returnedInterestAccrueduint256
returnedPrincipalOweduint256

uncalledCapitalTrancheIndex

function uncalledCapitalTrancheIndex() public view returns (uint256)

getUncalledCapitalInfo

function getUncalledCapitalInfo() external view returns (struct ICallableLoan.UncalledCapitalInfo)

getCallRequestPeriod

function getCallRequestPeriod(uint256 callRequestPeriodIndex) external view returns (struct ICallableLoan.CallRequestPeriod)

availableToCall

function availableToCall(uint256 tokenId) public view returns (uint256)

availableToWithdraw

function availableToWithdraw(uint256 tokenId) public view returns (uint256, uint256)

Query the max amount available to withdraw for tokenId's position

Parameters

NameTypeDescription
tokenIduint256position to query max amount withdrawable for

Return Values

NameTypeDescription
[0]uint256
[1]uint256

hasAllowedUID

function hasAllowedUID(address sender) public view returns (bool)

_pay

function _pay(uint256 amount) internal returns (struct ILoan.PaymentAllocation)

_deposit

function _deposit(uint256 tranche, uint256 amount) internal returns (uint256)

Supply capital to the loan.

Parameters

NameTypeDescription
trancheuint256Should always be uncalled capital tranche index.
amountuint256amount of capital to supply

Return Values

NameTypeDescription
[0]uint256tokenId NFT representing your position in this pool

_withdraw

function _withdraw(struct IPoolTokens.TokenInfo tokenInfo, uint256 tokenId, uint256 amount) internal returns (uint256, uint256)

_withdraw

function _withdraw(struct IPoolTokens.TokenInfo tokenInfo, uint256 tokenId, uint256 amount, struct CallableCreditLine cl) internal returns (uint256, uint256)

_withdrawMax

function _withdrawMax(uint256 tokenId) internal returns (uint256, uint256)

nextPrincipalDueTime

function nextPrincipalDueTime() public view returns (uint256)

nextDueTimeAt

function nextDueTimeAt(uint256 timestamp) public view returns (uint256)

nextInterestDueTimeAt

function nextInterestDueTimeAt(uint256 timestamp) public view returns (uint256)

schedule

function schedule() public view returns (contract ISchedule)

_reserveFundsFeePercent

function _reserveFundsFeePercent() public view returns (uint256)

_availableToWithdraw

function _availableToWithdraw(struct IPoolTokens.TokenInfo tokenInfo) internal view returns (uint256 interestAvailable, uint256 principalAvailable)

_availableToWithdraw

function _availableToWithdraw(struct IPoolTokens.TokenInfo tokenInfo, struct CallableCreditLine cl) internal view returns (uint256 interestAvailable, uint256 principalAvailable)

_availableToWithdrawGivenProportions

function _availableToWithdrawGivenProportions(struct IPoolTokens.TokenInfo tokenInfo, uint256 totalInterestWithdrawable, uint256 totalPrincipalWithdrawable) internal view returns (uint256 interestAvailable, uint256 principalAvailable)

creditLine

function creditLine() external view returns (contract ICreditLine)

Pool's credit line, responsible for managing the loan's accounting variables

balance

function balance() public view returns (uint256)

interestOwed

function interestOwed() public view returns (uint256)

principalOwed

function principalOwed() public view returns (uint256)

termEndTime

function termEndTime() public view returns (uint256)

nextDueTime

function nextDueTime() public view returns (uint256)

interestAccruedAsOf

function interestAccruedAsOf() public view returns (uint256)

We keep this to conform to the ICreditLine interface, but it's redundant information now that we have checkpointedAsOf

currentLimit

function currentLimit() public view returns (uint256)

limit

function limit() public view returns (uint256)

interestApr

function interestApr() public view returns (uint256)

lateFeeApr

function lateFeeApr() public view returns (uint256)

isLate

function isLate() public view returns (bool)

totalInterestAccrued

function totalInterestAccrued() public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

totalInterestAccruedAt

function totalInterestAccruedAt(uint256 timestamp) public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

totalInterestPaid

function totalInterestPaid() public view returns (uint256)

Cumulative interest paid back up to now

totalInterestOwed

function totalInterestOwed() public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

totalInterestOwedAt

function totalInterestOwedAt(uint256 timestamp) public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

interestOwedAt

function interestOwedAt(uint256 timestamp) public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

interestAccrued

function interestAccrued() public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

interestAccruedAt

function interestAccruedAt(uint256 timestamp) public view returns (uint256)

If a checkpoint has not occurred, late fees may be overestimated beyond the next due time.

principalOwedAt

function principalOwedAt(uint256 timestamp) public view returns (uint256)

Principal owed up to timestamp

totalPrincipalPaid

function totalPrincipalPaid() public view returns (uint256)

Returns the total amount of principal thats been paid

totalPrincipalOwedAt

function totalPrincipalOwedAt(uint256 timestamp) public view returns (uint256)

Cumulative principal owed at timestamp

totalPrincipalOwed

function totalPrincipalOwed() public view returns (uint256)

Cumulative principal owed at current timestamp

termStartTime

function termStartTime() public view returns (uint256)

Time of first drawdown

withinPrincipalGracePeriod

function withinPrincipalGracePeriod() public view returns (bool)

lastFullPaymentTime

function lastFullPaymentTime() public view returns (uint256)

pay

function pay(uint256, uint256) external pure returns (struct ILoan.PaymentAllocation)

Unsupported in callable loans.

maxLimit

function maxLimit() external pure returns (uint256)

Unsupported in callable loans.

setMaxLimit

function setMaxLimit(uint256) external pure

Unsupported in callable loans.

setLimit

function setLimit(uint256) external pure

Unsupported ICreditLine method kept for ICreditLine conformance

getVersion

function getVersion() external pure returns (uint8[3] version)

Returns the version triplet [major, minor, patch]

onlyLocker

modifier onlyLocker()