Skip to main content

TranchedPool

TranchedPool

Deployment on Ethereum mainnet:

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

Borrower Pool deployments on Ethereum mainnet:

config

contract GoldfinchConfig config

LOCKER_ROLE

bytes32 LOCKER_ROLE

SENIOR_ROLE

bytes32 SENIOR_ROLE

MAJOR_VERSION

uint8 MAJOR_VERSION

MINOR_VERSION

uint8 MINOR_VERSION

PATCH_VERSION

uint8 PATCH_VERSION

creditLine

contract ICreditLine creditLine

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

createdAt

uint256 createdAt

Time when the pool was initialized. Zero if uninitialized

juniorFeePercent

uint256 juniorFeePercent

drawdownsPaused

bool drawdownsPaused

allowedUIDTypes

uint256[] allowedUIDTypes

totalDeployed

uint256 totalDeployed

fundableAt

uint256 fundableAt

_poolSlices

mapping(uint256 => struct ITranchedPool.PoolSlice) _poolSlices

numSlices

uint256 numSlices

Get the current number of slices for this pool

Return Values

NameTypeDescription

initialize

function initialize(address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, contract ISchedule _schedule, uint256 _lateFeeApr, uint256 _fundableAt, uint256[] _allowedUIDTypes) public

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
_configaddressaddress of GoldfinchConfig
_borroweraddressaddress of borrower, a non-transferrable role for performing privileged actions like drawdown
_juniorFeePercentuint256percent (whole number) of senior interest that gets re-allocated to the junior tranche. valid range is [0, 100]
_limituint256the max USDC amount that can be drawn down across all pool slices
_interestApruint256interest rate for the loan
_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[]

setAllowedUIDTypes

function setAllowedUIDTypes(uint256[] ids) external

getAllowedUIDTypes

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

assess

function assess() external

Intentionable no-op. Included to be compatible with the v1 pool interface

deposit

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

Supply capital to this pool. Caller can't deposit to the junior tranche if the junior pool is locked. Caller can't deposit to a senior tranche if the pool is locked. Caller can't deposit if they are missing the required UID NFT.

TL: tranche locked IA: invalid amount NA: not authorized. Must have correct UID or be go listed

Parameters

NameTypeDescription
trancheuint256id of tranche to supply capital to. Id must correspond to a tranche in the current slice.
amountuint256amount of capital to supply

Return Values

NameTypeDescription
[0]uint256

depositWithPermit

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

withdraw

function withdraw(uint256 tokenId, uint256 amount) public 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) public

Withdraw from multiple tokens

LEN: argument length mismatch

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.

DP: drawdowns paused IF: insufficient funds

Parameters

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

NUM_TRANCHES_PER_SLICE

function NUM_TRANCHES_PER_SLICE() external pure returns (uint256)

lockJuniorCapital

function lockJuniorCapital() external

Lock the junior capital in the junior tranche of the current slice. The capital is locked for DrawdownPeriodInSeconds seconds and gives the senior pool time to decide how much to invest (ensure leverage ratio cannot change for the period). During this period the borrower has the option to lock the senior capital by calling lockPool(). Backers may withdraw their junior capital if the the senior tranche has not been locked and the drawdown period has ended. Only the borrower can call this function.

lockPool

function lockPool() external

Lock the senior capital in the senior tranche of the current slice and reset the lock period of the junior capital to match the senior capital lock period. During this period the borrower has the option to draw down the pool. Beyond the drawdown period any unused capital is available to withdraw by all depositors.

setFundableAt

function setFundableAt(uint256 newFundableAt) external

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

initializeNextSlice

function initializeNextSlice(uint256 _fundableAt) external

Initialize the next slice for the pool. Enables backers and the senior pool to provide additional capital to the borrower.

NL: not locked LP: late payment GP: beyond principal grace period

Parameters

NameTypeDescription
_fundableAtuint256time at which the new slice (now the current slice) becomes fundable

getAmountsOwed

function getAmountsOwed(uint256 timestamp) external view returns (uint256 interestOwed, uint256 interestAccrued, uint256 principalOwed)

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

IT: invalid timestamp LI: loan inactive

Parameters

NameTypeDescription
timestampuint256time to calculate up to

Return Values

NameTypeDescription
interestOweduint256amount of obligated interest owed at timestamp
interestAccrueduint256amount of accrued interest (not yet owed) that can be paid at timestamp
principalOweduint256amount of principal owed at timestamp

pay

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

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

ZA: zero amount

Parameters

NameTypeDescription
amountuint256USDC amount to pay

Return Values

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

pay

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

Pay down the credit line, separating the principal and interest payments. You must pay back all interest before paying back principal. Excess payments are refunded to the caller

ZA: zero amount

Parameters

NameTypeDescription
principalAmountuint256
interestAmountuint256

Return Values

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

emergencyShutdown

function emergencyShutdown() public

Pauses the pool and sweeps any remaining funds to the treasury reserve.

pauseDrawdowns

function pauseDrawdowns() public

Pauses all drawdowns (but not deposits/withdraws)

unpauseDrawdowns

function unpauseDrawdowns() public

Unpause drawdowns

setLimit

function setLimit(uint256 newAmount) external

setMaxLimit

function setMaxLimit(uint256 newAmount) external

getTranche

function getTranche(uint256 tranche) public view returns (struct ITranchedPool.TrancheInfo)

TrancheInfo for tranche with id trancheId. The senior tranche of slice i has id 2(i-1)+1. The junior tranche of slice i has id 2i. Slice indices start at 1.

Parameters

NameTypeDescription
trancheuint256

poolSlices

function poolSlices(uint256 index) external view returns (struct ITranchedPool.PoolSlice)

Get a slice by index

Parameters

NameTypeDescription
indexuint256of slice. Valid indices are on the interval [0, numSlices - 1]

totalJuniorDeposits

function totalJuniorDeposits() external view returns (uint256)

Query the total capital supplied to the pool's junior tranches

getLoanType

function getLoanType() external view 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)

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 principalPayment, uint256 interestPayment) internal returns (struct ILoan.PaymentAllocation)

NL: not locked

_pay

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

distributeToSlicesAndAllocateBackerRewards

function distributeToSlicesAndAllocateBackerRewards(uint256 interestAccrued, struct ILoan.PaymentAllocation pa) internal

_collectInterestAndPrincipal

function _collectInterestAndPrincipal(uint256 interest, uint256 principal) internal returns (uint256)

_createAndSetCreditLine

function _createAndSetCreditLine(address _borrower, uint256 _maxLimit, uint256 _interestApr, contract ISchedule _schedule, uint256 _lateFeeApr) internal

_withdraw

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

ZA: Zero amount IA: Invalid amount - amount too large TL: Tranched Locked

_lockJuniorCapital

function _lockJuniorCapital(uint256 sliceId) internal

TL: tranch locked or has been locked before

_lockPool

function _lockPool() internal

NL: Not locked TL: tranche locked. The senior pool has already been locked.

_initializeNextSlice

function _initializeNextSlice(uint256 newFundableAt) internal

SL: slice limit

_locked

function _locked() internal view returns (bool)

_getTrancheInfo

function _getTrancheInfo(uint256 trancheId) internal view returns (struct ITranchedPool.TrancheInfo)

getVersion

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

Returns the version triplet [major, minor, patch]

onlyLocker

modifier onlyLocker()

NA: not authorized. not locker