Skip to main content

PoolTokens

PoolTokens

Deployment on Ethereum mainnet:

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

PoolTokens is an ERC721 compliant contract, which can represent junior tranche or senior tranche shares of any of the borrower pools.

_INTERFACE_ID_ERC721

bytes4 _INTERFACE_ID_ERC721

_INTERFACE_ID_ERC721_METADATA

bytes4 _INTERFACE_ID_ERC721_METADATA

_INTERFACE_ID_ERC721_ENUMERABLE

bytes4 _INTERFACE_ID_ERC721_ENUMERABLE

_INTERFACE_ID_ERC165

bytes4 _INTERFACE_ID_ERC165

config

contract GoldfinchConfig config

PoolInfo

struct PoolInfo {
uint256 totalMinted;
uint256 totalPrincipalRedeemed;
bool created;
}

tokens

mapping(uint256 => struct IPoolTokens.TokenInfo) tokens

pools

mapping(address => struct PoolTokens.PoolInfo) pools

royaltyParams

struct ConfigurableRoyaltyStandard.RoyaltyParams royaltyParams

TokenMinted

event TokenMinted(address owner, address pool, uint256 tokenId, uint256 amount, uint256 tranche)

TokenRedeemed

event TokenRedeemed(address owner, address pool, uint256 tokenId, uint256 principalRedeemed, uint256 interestRedeemed, uint256 tranche)

TokenPrincipalWithdrawn

event TokenPrincipalWithdrawn(address owner, address pool, uint256 tokenId, uint256 principalWithdrawn, uint256 tranche)

TokenBurned

event TokenBurned(address owner, address pool, uint256 tokenId)

GoldfinchConfigUpdated

event GoldfinchConfigUpdated(address who, address configAddress)

RoyaltyParamsSet

event RoyaltyParamsSet(address sender, address newReceiver, uint256 newRoyaltyPercent)

initialize

function __initialize__(address owner, contract GoldfinchConfig _config) external

mint

function mint(struct IPoolTokens.MintParams params, address to) external virtual returns (uint256 tokenId)

Called by pool to create a debt position in a particular tranche and amount

NameTypeDescription
paramsstruct IPoolTokens.MintParamsStruct containing the tranche and the amount
toaddressThe address that should own the position
NameTypeDescription
tokenIduint256The token ID (auto-incrementing integer across all pools)

redeem

function redeem(uint256 tokenId, uint256 principalRedeemed, uint256 interestRedeemed) external virtual

Updates a token to reflect the principal and interest amounts that have been redeemed.

NameTypeDescription
tokenIduint256The token id to update (must be owned by the pool calling this function)
principalRedeemeduint256The incremental amount of principal redeemed (cannot be more than principal deposited)
interestRedeemeduint256The incremental amount of interest redeemed

reducePrincipalAmount

function reducePrincipalAmount(uint256 tokenId, uint256 amount) external

reduce a given pool token's principalAmount and principalRedeemed by a specified amount @dev uses safemath to prevent underflow @dev this function is only intended for use as part of the v2.6.0 upgrade to rectify a bug that allowed users to create a PoolToken that had a larger amount of principal than they actually made available to the borrower. This bug is fixed in v2.6.0 but still requires past pool tokens to have their principal redeemed and deposited to be rectified. @param tokenId id of token to decrease @param amount amount to decrease by

withdrawPrincipal

function withdrawPrincipal(uint256 tokenId, uint256 principalAmount) external virtual

Decrement a token's principal amount. This is different from `redeem`, which captures changes to principal and/or interest that occur when a loan is in progress.

NameTypeDescription
tokenIduint256The token id to update (must be owned by the pool calling this function)
principalAmountuint256The incremental amount of principal redeemed (cannot be more than principal deposited)

burn

function burn(uint256 tokenId) external virtual

Burns a specific ERC721 token, and removes the data from our mappings

NameTypeDescription
tokenIduint256uint256 id of the ERC721 token to be burned.

getTokenInfo

function getTokenInfo(uint256 tokenId) external view virtual returns (struct IPoolTokens.TokenInfo)

onPoolCreated

function onPoolCreated(address newPool) external

Called by the GoldfinchFactory to register the pool as a valid pool. Only valid pools can mint/redeem tokens

NameTypeDescription
newPooladdressThe address of the newly created pool

isApprovedOrOwner

function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool)

Returns a boolean representing whether the spender is the owner or the approved spender of the token

NameTypeDescription
spenderaddressThe address to check
tokenIduint256The token id to check for
NameTypeDescription
[0]boolTrue if approved to redeem/transfer/burn the token, false if not

validPool

function validPool(address sender) public view virtual returns (bool)

_createToken

function _createToken(struct IPoolTokens.MintParams params, address poolAddress) internal returns (uint256 tokenId)

_destroyAndBurn

function _destroyAndBurn(uint256 tokenId) internal

_validPool

function _validPool(address poolAddress) internal view virtual returns (bool)

_getTokenInfo

function _getTokenInfo(uint256 tokenId) internal view returns (struct IPoolTokens.TokenInfo)

royaltyInfo

function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address, uint256)
NameTypeDescription
_tokenIduint256The NFT asset queried for royalty information
_salePriceuint256The sale price of the NFT asset specified by _tokenId
NameTypeDescription
[0]addressreceiver Address that should receive royalties
[1]uint256royaltyAmount The royalty payment amount for _salePrice

setRoyaltyParams

function setRoyaltyParams(address newReceiver, uint256 newRoyaltyPercent) external

Set royalty params used in `royaltyInfo`. This function is only callable by an address with `OWNER_ROLE`.

NameTypeDescription
newReceiveraddressThe new address which should receive royalties. See `receiver`.
newRoyaltyPercentuint256The new percent of `salePrice` that should be taken for royalties. See `royaltyPercent`.

setBaseURI

function setBaseURI(string baseURI_) external

supportsInterface

function supportsInterface(bytes4 id) public view returns (bool)

onlyGoldfinchFactory

modifier onlyGoldfinchFactory()

onlyPool

modifier onlyPool()