Skip to main content

TranchedPool

TranchedPool

Deployment on Ethereum mainnet:

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

Borrower Pool deployments on Ethereum mainnet:

config

contract GoldfinchConfig config

LOCKER_ROLE

bytes32 LOCKER_ROLE

SENIOR_ROLE

bytes32 SENIOR_ROLE

FP_SCALING_FACTOR

uint256 FP_SCALING_FACTOR

SECONDS_PER_DAY

uint256 SECONDS_PER_DAY

ONE_HUNDRED

uint256 ONE_HUNDRED

NUM_TRANCHES_PER_SLICE

uint256 NUM_TRANCHES_PER_SLICE

juniorFeePercent

uint256 juniorFeePercent

drawdownsPaused

bool drawdownsPaused

allowedUIDTypes

uint256[] allowedUIDTypes

totalDeployed

uint256 totalDeployed

fundableAt

uint256 fundableAt

poolSlices

struct ITranchedPool.PoolSlice[] poolSlices

DepositMade

event DepositMade(address owner, uint256 tranche, uint256 tokenId, uint256 amount)

WithdrawalMade

event WithdrawalMade(address owner, uint256 tranche, uint256 tokenId, uint256 interestWithdrawn, uint256 principalWithdrawn)

TranchedPoolAssessed

event TranchedPoolAssessed(address pool)

PaymentApplied

event PaymentApplied(address payer, address pool, uint256 interestAmount, uint256 principalAmount, uint256 remainingAmount, uint256 reserveAmount)

SharePriceUpdated

event SharePriceUpdated(address pool, uint256 tranche, uint256 principalSharePrice, int256 principalDelta, uint256 interestSharePrice, int256 interestDelta)

ReserveFundsCollected

event ReserveFundsCollected(address from, uint256 amount)

CreditLineMigrated

event CreditLineMigrated(address oldCreditLine, address newCreditLine)

DrawdownMade

event DrawdownMade(address borrower, uint256 amount)

DrawdownsPaused

event DrawdownsPaused(address pool)

DrawdownsUnpaused

event DrawdownsUnpaused(address pool)

EmergencyShutdown

event EmergencyShutdown(address pool)

TrancheLocked

event TrancheLocked(address pool, uint256 trancheId, uint256 lockedUntil)

SliceCreated

event SliceCreated(address pool, uint256 sliceId)

initialize

function initialize(address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays, uint256 _fundableAt, uint256[] _allowedUIDTypes) public

setAllowedUIDTypes

function setAllowedUIDTypes(uint256[] ids) public

getAllowedUIDTypes

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

deposit

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

Deposit a USDC amount into the pool for a tranche. Mints an NFT to the caller representing the position

NameTypeDescription
trancheuint256The number representing the tranche to deposit into
amountuint256The USDC amount to tranfer from the caller to the pool
NameTypeDescription
tokenIduint256The tokenId of the NFT

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 interestWithdrawn, uint256 principalWithdrawn)

Withdraw an already deposited amount if the funds are available

NameTypeDescription
tokenIduint256The NFT representing the position
amountuint256The amount to withdraw (must be <= interest+principal currently available to withdraw)
NameTypeDescription
interestWithdrawnuint256The interest amount that was withdrawn
principalWithdrawnuint256The principal amount that was withdrawn

withdrawMultiple

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

Withdraw from many tokens (that the sender owns) in a single transaction

NameTypeDescription
tokenIdsuint256[]An array of tokens ids representing the position
amountsuint256[]An array of amounts to withdraw from the corresponding tokenIds

withdrawMax

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

Similar to withdraw but will withdraw all available funds

NameTypeDescription
tokenIduint256The NFT representing the position
NameTypeDescription
interestWithdrawnuint256The interest amount that was withdrawn
principalWithdrawnuint256The principal amount that was withdrawn

drawdown

function drawdown(uint256 amount) external

Draws down the funds (and locks the pool) to the borrower address. Can only be called by the borrower

NameTypeDescription
amountuint256The amount to drawdown from the creditline (must be < limit)

lockJuniorCapital

function lockJuniorCapital() external

Locks the junior tranche, preventing more junior deposits. Gives time for the senior to determine how much to invest (ensure leverage ratio cannot change for the period)

lockPool

function lockPool() external

Locks the pool (locks both senior and junior tranches and starts the drawdown period). Beyond the drawdown period, any unused capital is available to withdraw by all depositors

setFundableAt

function setFundableAt(uint256 newFundableAt) external

initializeNextSlice

function initializeNextSlice(uint256 _fundableAt) external

assess

function assess() external

Triggers an assessment of the creditline and the applies the payments according the tranche waterfall

pay

function pay(uint256 amount) external

Allows repaying the creditline. Collects the USDC amount from the sender and triggers an assess

NameTypeDescription
amountuint256The amount to repay

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

migrateCreditLine

function migrateCreditLine(address _borrower, uint256 _maxLimit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays) public

Migrates the accounting variables from the current creditline to a brand new one

NameTypeDescription
_borroweraddressThe borrower address
_maxLimituint256The new max limit
_interestApruint256The new interest APR
_paymentPeriodInDaysuint256The new payment period in days
_termInDaysuint256The new term in days
_lateFeeApruint256The new late fee APR
_principalGracePeriodInDaysuint256

migrateAndSetNewCreditLine

function migrateAndSetNewCreditLine(address newCl) public

Migrates to a new creditline without copying the accounting variables

setLimit

function setLimit(uint256 newAmount) external

setMaxLimit

function setMaxLimit(uint256 newAmount) external

getTranche

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

numSlices

function numSlices() public view returns (uint256)

usdcToSharePrice

function usdcToSharePrice(uint256 amount, uint256 totalShares) public pure returns (uint256)

Converts USDC amounts to share price

NameTypeDescription
amountuint256The USDC amount to convert
totalSharesuint256The total shares outstanding
NameTypeDescription
[0]uint256The share price of the input amount

sharePriceToUsdc

function sharePriceToUsdc(uint256 sharePrice, uint256 totalShares) public pure returns (uint256)

Converts share price to USDC amounts

NameTypeDescription
sharePriceuint256The share price to convert
totalSharesuint256The total shares outstanding
NameTypeDescription
[0]uint256The USDC amount of the input share price

totalJuniorDeposits

function totalJuniorDeposits() external view returns (uint256)

Returns the total junior capital deposited

NameTypeDescription
[0]uint256The total USDC amount deposited into all junior tranches

availableToWithdraw

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

Determines the amount of interest and principal redeemable by a particular tokenId

NameTypeDescription
tokenIduint256The token representing the position
NameTypeDescription
interestRedeemableuint256The interest available to redeem
principalRedeemableuint256The principal available to redeem

_withdraw

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

_isSeniorTrancheId

function _isSeniorTrancheId(uint256 trancheId) internal pure returns (bool)

redeemableInterestAndPrincipal

function redeemableInterestAndPrincipal(struct ITranchedPool.TrancheInfo trancheInfo, struct IPoolTokens.TokenInfo tokenInfo) internal view returns (uint256 interestRedeemable, uint256 principalRedeemable)

_lockJuniorCapital

function _lockJuniorCapital(uint256 sliceId) internal

_lockPool

function _lockPool() internal

_initializeNextSlice

function _initializeNextSlice(uint256 newFundableAt) internal

collectInterestAndPrincipal

function collectInterestAndPrincipal(address from, uint256 interest, uint256 principal) internal returns (uint256 totalReserveAmount)

locked

function locked() internal view returns (bool)

createAndSetCreditLine

function createAndSetCreditLine(address _borrower, uint256 _maxLimit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays) internal

_getTrancheInfo

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

currentTime

function currentTime() internal view virtual returns (uint256)

_sendToReserve

function _sendToReserve(uint256 amount) internal

_collectPayment

function _collectPayment(uint256 amount) internal

_assess

function _assess() internal

hasAllowedUID

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

onlyLocker

modifier onlyLocker()