BondToken
This contract implements a bond token with upgradeable capabilities, access control, and pausability. It includes functionality for managing indexed user assets and global asset pools.
State Variables
globalPool
The global asset pool
userAssets
Mapping of user addresses to their indexed assets
MINTER_ROLE
Role identifier for accounts with minting privileges
GOV_ROLE
Role identifier for accounts with governance privileges
DISTRIBUTOR_ROLE
Role identifier for the distributor
SHARES_DECIMALS
The number of decimals for shares
Functions
constructor
Note: constructor
initialize
Initializes the contract with a name, symbol, minter, governance address, distributor, and initial shares per token.
Parameters
mint
Can only be called by addresses with the MINTER_ROLE.
Mints new tokens to the specified address.
Parameters
burn
Can only be called by addresses with the MINTER_ROLE.
Burns tokens from the specified account.
Parameters
getPreviousPoolAmounts
Returns the previous pool amounts from the global pool.
Returns
_update
This function is called during token transfer and is paused when the contract is paused.
Internal function to update user assets after a transfer.
Parameters
updateIndexedUserAssets
This function updates the number of shares held by the user based on the current period.
Updates the indexed user assets for a specific user.
Parameters
getIndexedUserAmount
This function calculates the number of shares based on the current period and the previous pool amounts.
Returns the indexed amount of shares for a specific user.
Parameters
Returns
resetIndexedUserAssets
This function resets the last updated period and indexed amount of shares to zero. Can only be called by addresses with the DISTRIBUTOR_ROLE and when the contract is not paused.
Resets the indexed user assets for a specific user.
Parameters
increaseIndexedAssetPeriod
Can only be called by addresses with the GOV_ROLE and when the contract is not paused.
Increases the current period and updates the shares per token.
Parameters
grantRole
Can only be called by addresses with the GOV_ROLE.
Grants a role to an account.
Parameters
revokeRole
Can only be called by addresses with the GOV_ROLE.
Revokes a role from an account.
Parameters
pause
Can only be called by addresses with the GOV_ROLE.
Pauses all contract functions except for upgrades.
unpause
Can only be called by addresses with the GOV_ROLE.
Unpauses all contract functions.
_authorizeUpgrade
Can only be called by addresses with the GOV_ROLE.
Function that should revert when msg.sender
is not authorized to upgrade the contract. Called by {upgradeTo} and {upgradeToAndCall}.
Parameters
Events
IncreasedAssetPeriod
Emitted when the asset period is increased
UpdatedUserAssets
Emitted when a user's assets are updated
Structs
PoolAmount
Struct to represent a pool's outstanding shares and shares per bond at a specific period
Properties
IndexedGlobalAssetPool
Struct to represent the global asset pool, including the current period, shares per token, and previous pool amounts.
Properties
IndexedUserAssets
Struct to represent a user's indexed assets, which are the user's shares
Properties
Last updated