Skip to main content

BackerRewards

BackerRewards

Deployment on Ethereum mainnet:

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

config

contract GoldfinchConfig config

GFI_MANTISSA

uint256 GFI_MANTISSA

FIDU_MANTISSA

uint256 FIDU_MANTISSA

USDC_MANTISSA

uint256 USDC_MANTISSA

NUM_TRANCHES_PER_SLICE

uint256 NUM_TRANCHES_PER_SLICE

totalRewards

uint256 totalRewards

total amount of GFI rewards available, times 1e18

maxInterestDollarsEligible

uint256 maxInterestDollarsEligible

interest $ eligible for gfi rewards, times 1e18

totalInterestReceived

uint256 totalInterestReceived

counter of total interest repayments, times 1e6

totalRewardPercentOfTotalGFI

uint256 totalRewardPercentOfTotalGFI

totalRewards/totalGFISupply * 100, times 1e18

tokens

mapping(uint256 => struct IBackerRewards.BackerRewardsTokenInfo) tokens

pools

mapping(address => struct IBackerRewards.BackerRewardsInfo) pools

poolStakingRewards

mapping(contract ITranchedPool => struct IBackerRewards.StakingRewardsPoolInfo) poolStakingRewards

tokenStakingRewards

mapping(uint256 => struct IBackerRewards.StakingRewardsTokenInfo) tokenStakingRewards

Staking rewards info for each pool token

initialize

function __initialize__(address owner, contract GoldfinchConfig _config) public

allocateRewards

function allocateRewards(uint256 _interestPaymentAmount) external

Calculates the accRewardsPerPrincipalDollar for a given pool, when a interest payment is received by the protocol

Parameters

NameTypeDescription
_interestPaymentAmountuint256Atomic usdc amount of the interest payment

setTotalRewards

function setTotalRewards(uint256 _totalRewards) public

Set the total gfi rewards and the % of total GFI

Parameters

NameTypeDescription
_totalRewardsuint256The amount of GFI rewards available, expects 10^18 value

setTotalInterestReceived

function setTotalInterestReceived(uint256 _totalInterestReceived) public

Set the total interest received to date. This should only be called once on contract deploy.

Parameters

NameTypeDescription
_totalInterestReceiveduint256The amount of interest the protocol has received to date, expects 10^6 value

setMaxInterestDollarsEligible

function setMaxInterestDollarsEligible(uint256 _maxInterestDollarsEligible) public

Set the max dollars across the entire protocol that are eligible for GFI rewards

Parameters

NameTypeDescription
_maxInterestDollarsEligibleuint256The amount of interest dollars eligible for GFI rewards, expects 10^18 value

setPoolTokenAccRewardsPerPrincipalDollarAtMint

function setPoolTokenAccRewardsPerPrincipalDollarAtMint(address poolAddress, uint256 tokenId) external

When a pool token is minted for multiple drawdowns, set accRewardsPerPrincipalDollarAtMint to the current accRewardsPerPrincipalDollar price

Parameters

NameTypeDescription
poolAddressaddressAddress of the pool associated with the pool token
tokenIduint256Pool token id

onTranchedPoolDrawdown

function onTranchedPoolDrawdown(uint256 _sliceIndex) external

callback for TranchedPools when they drawdown

initializes rewards info for the calling TranchedPool if it's the first drawdown for the given slice

Parameters

NameTypeDescription
_sliceIndexuint256

setBackerAndStakingRewardsTokenInfoOnSplit

function setBackerAndStakingRewardsTokenInfoOnSplit(struct IBackerRewards.BackerRewardsTokenInfo originalBackerRewardsTokenInfo, struct IBackerRewards.StakingRewardsTokenInfo originalStakingRewardsTokenInfo, uint256 newTokenId, uint256 newRewardsClaimed) external

Set BackerRewards and BackerStakingRewards metadata for tokens created by a pool token split.

The sum of newRewardsClaimed across the split tokens MUST be equal to (or be very slightly smaller than, in the case of rounding due to integer division) the original token's rewardsClaimed. Furthermore, they must be split proportional to the original and new token's principalAmounts. This impl validates neither of those things because only the pool tokens contract can call it, and it trusts that the PoolTokens contract doesn't call maliciously.

Parameters

NameTypeDescription
originalBackerRewardsTokenInfostruct IBackerRewards.BackerRewardsTokenInfobacker rewards info for the pool token that was split
originalStakingRewardsTokenInfostruct IBackerRewards.StakingRewardsTokenInfobacker staking rewards info for the pool token that was split
newTokenIduint256id of one of the tokens in the split
newRewardsClaimeduint256rewardsClaimed value for the new token.

clearTokenInfo

function clearTokenInfo(uint256 tokenId) external

Clear all BackerRewards and StakingRewards associated data for tokenId

getTokenInfo

function getTokenInfo(uint256 poolTokenId) external view returns (struct IBackerRewards.BackerRewardsTokenInfo)

Get backer rewards metadata for a pool token

getStakingRewardsTokenInfo

function getStakingRewardsTokenInfo(uint256 poolTokenId) external view returns (struct IBackerRewards.StakingRewardsTokenInfo)

Get backer staking rewards metadata for a pool token

getBackerStakingRewardsPoolInfo

function getBackerStakingRewardsPoolInfo(contract ITranchedPool pool) external view returns (struct IBackerRewards.StakingRewardsPoolInfo)

Get backer staking rewards for a pool

poolTokenClaimableRewards

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

Calculate the gross available gfi rewards for a PoolToken

Parameters

NameTypeDescription
tokenIduint256Pool token id

Return Values

NameTypeDescription
[0]uint256The amount of GFI claimable

stakingRewardsClaimed

function stakingRewardsClaimed(uint256 tokenId) external view returns (uint256)

Calculates the amount of staking rewards already claimed for a PoolToken. This function is provided for the sake of external (e.g. frontend client) consumption; it is not necessary as an input to the mutative calculations in this contract.

Parameters

NameTypeDescription
tokenIduint256Pool token id

Return Values

NameTypeDescription
[0]uint256The amount of GFI claimed

withdrawMultiple

function withdrawMultiple(uint256[] tokenIds) public

PoolToken request to withdraw multiple PoolTokens allocated rewards

Parameters

NameTypeDescription
tokenIdsuint256[]Array of pool token id

withdraw

function withdraw(uint256 tokenId) public returns (uint256)

PoolToken request to withdraw all allocated rewards

Parameters

NameTypeDescription
tokenIduint256Pool token id

Return Values

NameTypeDescription
[0]uint256amount of rewards withdrawn

stakingRewardsEarnedSinceLastWithdraw

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

Returns the amount of staking rewards earned by a given token since the last time its staking rewards were withdrawn.

Parameters

NameTypeDescription
tokenIduint256token id to get rewards

Return Values

NameTypeDescription
[0]uint256amount of rewards

_allocateRewards

function _allocateRewards(uint256 _interestPaymentAmount) internal

_checkpointTokenStakingRewards

function _checkpointTokenStakingRewards(uint256 tokenId) internal

Updates the staking rewards accounting for for a given tokenId

Parameters

NameTypeDescription
tokenIduint256token id to checkpoint

_calculateNewGrossGFIRewardsForInterestAmount

function _calculateNewGrossGFIRewardsForInterestAmount(uint256 _interestPaymentAmount) internal view returns (uint256)

Calculate the rewards earned for a given interest payment

Parameters

NameTypeDescription
_interestPaymentAmountuint256interest payment amount times 1e6

_isSeniorTrancheToken

function _isSeniorTrancheToken(struct IPoolTokens.TokenInfo tokenInfo) internal pure returns (bool)

Return Values

NameTypeDescription
[0]boolWhether the provided tokenInfo is a token corresponding to a senior tranche.

_usdcToAtomic

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

Returns an amount with the base of usdc (1e6) as an 1e18 number

_atomicToUsdc

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

Returns an amount with the base 1e18 as a usdc amount (1e6)

_fiduToUsdc

function _fiduToUsdc(uint256 amount, uint256 sharePrice) internal pure returns (uint256)

Returns the equivalent amount of USDC given an amount of fidu and a share price

Parameters

NameTypeDescription
amountuint256amount of FIDU
sharePriceuint256share price of FIDU

Return Values

NameTypeDescription
[0]uint256equivalent amount of USDC

_juniorTrancheIdToSliceIndex

function _juniorTrancheIdToSliceIndex(uint256 trancheId) internal pure returns (uint256)

Returns the slice index for the given junior tranche id

Parameters

NameTypeDescription
trancheIduint256tranche id

Return Values

NameTypeDescription
[0]uint256slice index that the given tranche id belongs to

_poolRewardsHaveBeenInitialized

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

Returns true if a TranchedPool's rewards parameters have been initialized, otherwise false

Parameters

NameTypeDescription
poolcontract ITranchedPoolpool to check rewards info

_poolStakingRewardsInfoHaveBeenInitialized

function _poolStakingRewardsInfoHaveBeenInitialized(struct IBackerRewards.StakingRewardsPoolInfo poolInfo) internal pure returns (bool)

Returns true if a given pool's staking rewards parameters have been initialized

_sliceRewardsHaveBeenInitialized

function _sliceRewardsHaveBeenInitialized(contract ITranchedPool pool, uint256 sliceIndex) internal view returns (bool)

Returns true if a TranchedPool's slice's rewards parameters have been initialized, otherwise false

_getSliceAccumulatorAtLastCheckpoint

function _getSliceAccumulatorAtLastCheckpoint(struct IBackerRewards.StakingRewardsSliceInfo sliceInfo, struct IBackerRewards.StakingRewardsPoolInfo poolInfo) internal pure returns (uint256)

Return a slice's rewards accumulator if it has been intialized, otherwise return the TranchedPool's accumulator

_getTokenAccumulatorAtLastWithdraw

function _getTokenAccumulatorAtLastWithdraw(struct IBackerRewards.StakingRewardsTokenInfo tokenInfo, struct IBackerRewards.StakingRewardsSliceInfo sliceInfo) internal pure returns (uint256)

Return a tokenss rewards accumulator if its been initialized, otherwise return the slice's accumulator

onlyPoolTokens

modifier onlyPoolTokens()

onlyPool

modifier onlyPool()

BackerRewardsClaimed

event BackerRewardsClaimed(address owner, uint256 tokenId, uint256 amountOfTranchedPoolRewards, uint256 amountOfSeniorPoolRewards)

BackerRewardsSetTotalRewards

event BackerRewardsSetTotalRewards(address owner, uint256 totalRewards, uint256 totalRewardPercentOfTotalGFI)

BackerRewardsSetTotalInterestReceived

event BackerRewardsSetTotalInterestReceived(address owner, uint256 totalInterestReceived)

BackerRewardsSetMaxInterestDollarsEligible

event BackerRewardsSetMaxInterestDollarsEligible(address owner, uint256 maxInterestDollarsEligible)