Skip to main content

SeniorPool

SeniorPool

Deployment on Ethereum mainnet:

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

Main entry point for senior LPs (a.k.a. capital providers) Automatically invests across borrower pools using an adjustable strategy.

config

contract GoldfinchConfig config

ZAPPER_ROLE

bytes32 ZAPPER_ROLE

compoundBalance

uint256 compoundBalance

writedowns

mapping(contract ITranchedPool => uint256) writedowns

DepositMade

event DepositMade(address capitalProvider, uint256 amount, uint256 shares)

WithdrawalMade

event WithdrawalMade(address capitalProvider, uint256 userAmount, uint256 reserveAmount)

InterestCollected

event InterestCollected(address payer, uint256 amount)

PrincipalCollected

event PrincipalCollected(address payer, uint256 amount)

ReserveFundsCollected

event ReserveFundsCollected(address user, uint256 amount)

PrincipalWrittenDown

event PrincipalWrittenDown(address tranchedPool, int256 amount)

InvestmentMadeInSenior

event InvestmentMadeInSenior(address tranchedPool, uint256 amount)

InvestmentMadeInJunior

event InvestmentMadeInJunior(address tranchedPool, uint256 amount)

GoldfinchConfigUpdated

event GoldfinchConfigUpdated(address who, address configAddress)

initialize

function initialize(address owner, contract GoldfinchConfig _config) public

deposit

function deposit(uint256 amount) public returns (uint256 depositShares)

Deposits `amount` USDC from msg.sender into the SeniorPool, and grants you the equivalent value of FIDU tokens

NameTypeDescription
amountuint256The amount of USDC to deposit

depositWithPermit

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

Identical to deposit, except it allows for a passed up signature to permit the Senior Pool to move funds on behalf of the user, all within one transaction.

NameTypeDescription
amountuint256The amount of USDC to deposit
deadlineuint256
vuint8secp256k1 signature component
rbytes32secp256k1 signature component
sbytes32secp256k1 signature component

withdraw

function withdraw(uint256 usdcAmount) external returns (uint256 amount)

Withdraws USDC from the SeniorPool to msg.sender, and burns the equivalent value of FIDU tokens

NameTypeDescription
usdcAmountuint256The amount of USDC to withdraw

withdrawInFidu

function withdrawInFidu(uint256 fiduAmount) external returns (uint256 amount)

Withdraws USDC (denominated in FIDU terms) from the SeniorPool to msg.sender

NameTypeDescription
fiduAmountuint256The amount of USDC to withdraw in terms of FIDU shares

sweepToCompound

function sweepToCompound() public

Moves any USDC still in the SeniorPool to Compound, and tracks the amount internally. This is done to earn interest on latent funds until we have other borrowers who can use it.

Requirements:

  • The caller must be an admin.

sweepFromCompound

function sweepFromCompound() public

Moves any USDC from Compound back to the SeniorPool, and recognizes interest earned. This is done automatically on drawdown or withdraw, but can be called manually if necessary.

Requirements:

  • The caller must be an admin.

invest

function invest(contract ITranchedPool pool) public

Invest in an ITranchedPool's senior tranche using the senior pool's strategy

NameTypeDescription
poolcontract ITranchedPoolAn ITranchedPool whose senior tranche should be considered for investment

estimateInvestment

function estimateInvestment(contract ITranchedPool pool) public view returns (uint256)

redeem

function redeem(uint256 tokenId) public

Redeem interest and/or principal from an ITranchedPool investment

NameTypeDescription
tokenIduint256the ID of an IPoolTokens token to be redeemed

writedown

function writedown(uint256 tokenId) public

Write down an ITranchedPool investment. This will adjust the senior pool's share price down if we're considering the investment a loss, or up if the borrower has subsequently made repayments that restore confidence that the full loan will be repaid.

NameTypeDescription
tokenIduint256the ID of an IPoolTokens token to be considered for writedown

calculateWritedown

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

Calculates the writedown amount for a particular pool position

NameTypeDescription
tokenIduint256The token reprsenting the position
NameTypeDescription
[0]uint256The amount in dollars the principal should be written down by

assets

function assets() public view returns (uint256)

Returns the net assests controlled by and owed to the pool

getNumShares

function getNumShares(uint256 amount) public view returns (uint256)

Converts and USDC amount to FIDU amount

NameTypeDescription
amountuint256USDC amount to convert to FIDU

_calculateWritedown

function _calculateWritedown(contract ITranchedPool pool, uint256 principal) internal view returns (uint256 writedownPercent, uint256 writedownAmount)

currentTime

function currentTime() internal view virtual returns (uint256)

_distributeLosses

function _distributeLosses(int256 writedownDelta) internal

_fiduMantissa

function _fiduMantissa() internal pure returns (uint256)

_usdcMantissa

function _usdcMantissa() internal pure returns (uint256)

_usdcToFidu

function _usdcToFidu(uint256 amount) internal pure returns (uint256)

_fiduToUSDC

function _fiduToUSDC(uint256 amount) internal pure returns (uint256)

_getUSDCAmountFromShares

function _getUSDCAmountFromShares(uint256 fiduAmount) internal view returns (uint256)

doUSDCTransfer

function doUSDCTransfer(address from, address to, uint256 amount) internal returns (bool)

_withdraw

function _withdraw(uint256 usdcAmount, uint256 withdrawShares) internal returns (uint256 userAmount)

_sweepToCompound

function _sweepToCompound(contract ICUSDCContract cUSDC, uint256 usdcAmount) internal

_sweepFromCompound

function _sweepFromCompound() internal

_sweepFromCompound

function _sweepFromCompound(contract ICUSDCContract cUSDC, uint256 cUSDCAmount) internal

_cUSDCToUSDC

function _cUSDCToUSDC(uint256 exchangeRate, uint256 amount) internal pure returns (uint256)

_collectInterestAndPrincipal

function _collectInterestAndPrincipal(address from, uint256 interest, uint256 principal) internal

_sendToReserve

function _sendToReserve(uint256 amount, address userForEvent) internal

_usdcToSharePrice

function _usdcToSharePrice(uint256 usdcAmount) internal view returns (uint256)

totalShares

function totalShares() internal view returns (uint256)

_isValidPool

function _isValidPool(contract ITranchedPool pool) internal view returns (bool)

_approvePool

function _approvePool(contract ITranchedPool pool, uint256 allowance) internal

isZapper

function isZapper() public view returns (bool)

initZapperRole

function initZapperRole() external

_sliceIndexToSeniorTrancheId

function _sliceIndexToSeniorTrancheId(uint256 index) internal pure returns (uint256)

Returns the senion tranche id for the given slice index

NameTypeDescription
indexuint256slice index
NameTypeDescription
[0]uint256senior tranche id of given slice index