Pool
Pool
Deployment on Ethereum mainnet:
https://etherscan.io/address/0xB01b315e32D1D9B5CE93e296D483e1f0aAD39E75
Deployment on Ethereum mainnet:
https://etherscan.io/address/0xB01b315e32D1D9B5CE93e296D483e1f0aAD39E75
Deployment on Ethereum mainnet:
https://etherscan.io/address/0xB01b315e32D1D9B5CE93e296D483e1f0aAD39E75
Deployment on Ethereum mainnet:
https://etherscan.io/address/0xB01b315e32D1D9B5CE93e296D483e1f0aAD39E75
Main entry point for LP's (a.k.a. capital providers) Handles key logic for depositing and withdrawing funds from the Pool
config
contract GoldfinchConfig config
compoundBalance
uint256 compoundBalance
DepositMade
event DepositMade(address capitalProvider, uint256 amount, uint256 shares)
WithdrawalMade
event WithdrawalMade(address capitalProvider, uint256 userAmount, uint256 reserveAmount)
TransferMade
event TransferMade(address from, address to, uint256 amount)
InterestCollected
event InterestCollected(address payer, uint256 poolAmount, uint256 reserveAmount)
PrincipalCollected
event PrincipalCollected(address payer, uint256 amount)
ReserveFundsCollected
event ReserveFundsCollected(address user, uint256 amount)
PrincipalWrittendown
event PrincipalWrittendown(address creditline, int256 amount)
GoldfinchConfigUpdated
event GoldfinchConfigUpdated(address who, address configAddress)
initialize
function initialize(address owner, contract GoldfinchConfig _config) public
Run only once, on initialization
Name | Type | Description |
---|---|---|
owner | address | The address of who should have the "OWNER_ROLE" of this contract |
_config | contract GoldfinchConfig | The address of the GoldfinchConfig contract |
deposit
function deposit(uint256 amount) external
Deposits `amount` USDC from msg.sender into the Pool, and returns you the equivalent value of FIDU tokens
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of USDC to deposit |
withdraw
function withdraw(uint256 usdcAmount) external
Withdraws USDC from the Pool to msg.sender, and burns the equivalent value of FIDU tokens
Name | Type | Description |
---|---|---|
usdcAmount | uint256 | The amount of USDC to withdraw |
withdrawInFidu
function withdrawInFidu(uint256 fiduAmount) external
Withdraws USDC (denominated in FIDU terms) from the Pool to msg.sender
Name | Type | Description |
---|---|---|
fiduAmount | uint256 | The amount of USDC to withdraw in terms of fidu shares |
collectInterestAndPrincipal
function collectInterestAndPrincipal(address from, uint256 interest, uint256 principal) public
Collects `interest` USDC in interest and `principal` in principal from `from` and sends it to the Pool. This also increases the share price accordingly. A portion is sent to the Goldfinch Reserve address
Name | Type | Description |
---|---|---|
from | address | The address to take the USDC from. Implicitly, the Pool must be authorized to move USDC on behalf of `from`. |
interest | uint256 | the interest amount of USDC to move to the Pool |
principal | uint256 | the principal amount of USDC to move to the Pool Requirements: - The caller must be the Credit Desk. Not even the owner can call this function. |
distributeLosses
function distributeLosses(address creditlineAddress, int256 writedownDelta) external
transferFrom
function transferFrom(address from, address to, uint256 amount) public returns (bool)
Moves `amount` USDC from `from`, to `to`.
Name | Type | Description |
---|---|---|
from | address | The address to take the USDC from. Implicitly, the Pool must be authorized to move USDC on behalf of `from`. |
to | address | The address that the USDC should be moved to |
amount | uint256 | the amount of USDC to move to the Pool Requirements: - The caller must be the Credit Desk. Not even the owner can call this function. |
drawdown
function drawdown(address to, uint256 amount) public returns (bool)
Moves `amount` USDC from the pool, to `to`. This is similar to transferFrom except we sweep any balance we have from compound first and recognize interest. Meant to be called only by the credit desk on drawdown
Name | Type | Description |
---|---|---|
to | address | The address that the USDC should be moved to |
amount | uint256 | the amount of USDC to move to the Pool Requirements: - The caller must be the Credit Desk. Not even the owner can call this function. |
assets
function assets() public view returns (uint256)
migrateToSeniorPool
function migrateToSeniorPool() external
toUint256
function toUint256(bytes _bytes) internal pure returns (uint256 value)
sweepToCompound
function sweepToCompound() public
Moves any USDC still in the Pool 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 Pool, 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.
_withdraw
function _withdraw(uint256 usdcAmount, uint256 withdrawShares) internal
sweepToCompound
function sweepToCompound(contract ICUSDCContract cUSDC, uint256 usdcAmount) internal
sweepFromCompound
function sweepFromCompound(contract ICUSDCContract cUSDC, uint256 cUSDCAmount) internal
_collectInterestAndPrincipal
function _collectInterestAndPrincipal(address from, uint256 interest, uint256 principal) internal
_sweepFromCompound
function _sweepFromCompound() internal
fiduMantissa
function fiduMantissa() internal pure returns (uint256)
usdcMantissa
function usdcMantissa() internal pure returns (uint256)
usdcToFidu
function usdcToFidu(uint256 amount) internal pure returns (uint256)
cUSDCToUSDC
function cUSDCToUSDC(uint256 exchangeRate, uint256 amount) internal pure returns (uint256)
totalShares
function totalShares() internal view returns (uint256)
usdcToSharePrice
function usdcToSharePrice(uint256 usdcAmount) internal view returns (uint256)
poolWithinLimit
function poolWithinLimit(uint256 _totalShares) internal view returns (bool)
transactionWithinLimit
function transactionWithinLimit(uint256 amount) internal view returns (bool)
getNumShares
function getNumShares(uint256 amount) internal view returns (uint256)
getUSDCAmountFromShares
function getUSDCAmountFromShares(uint256 fiduAmount) internal view returns (uint256)
fiduToUSDC
function fiduToUSDC(uint256 amount) internal pure returns (uint256)
sendToReserve
function sendToReserve(address from, uint256 amount, address userForEvent) internal
doUSDCTransfer
function doUSDCTransfer(address from, address to, uint256 amount) internal returns (bool)
withinTransactionLimit
modifier withinTransactionLimit(uint256 amount)
onlyCreditDesk
modifier onlyCreditDesk()