Inherits: ContextUpgradeable, AccessControlDefaultAdminRulesUpgradeable, IERC20Errors, IERC20Metadata
The supply-side reward accounting portion of the protocol. A lender's balance is measured in two parts: a static balance and a dynamic "supply factor". Their true balance is the product of the two values. The dynamic portion is then able to be used to distribute interest accrued to the lender.
State Variables
ION
Copy bytes32 public constant ION = keccak256("ION");
RewardTokenStorageLocation
Copy bytes32 private constant RewardTokenStorageLocation = 0xdb3a0d63a7808d7d0422c40bb62354f42bff7602a547c329c1453dbcbeef4900;
EIP712_REVISION
Copy bytes private constant EIP712_REVISION = bytes("1");
EIP712_DOMAIN
Copy bytes32 private constant EIP712_DOMAIN =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
PERMIT_TYPEHASH
Copy bytes32 public constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
Functions
_getRewardTokenStorage
Copy function _getRewardTokenStorage() private pure returns (RewardTokenStorage storage $);
_initialize
Copy function _initialize(
address _underlying,
address _treasury,
uint8 decimals_,
string memory name_,
string memory symbol_
)
internal
onlyInitializing;
_burn
Copy function _burn(address user, address receiverOfUnderlying, uint256 amount) internal returns (uint256);
Parameters
to send underlying tokens to
_burnNormalized
Copy function _burnNormalized(address account, uint256 amount) private;
Parameters
of normalized tokens to burn
_mint
Copy function _mint(address user, address senderOfUnderlying, uint256 amount) internal returns (uint256);
Parameters
address to transfer underlying tokens from
_mintNormalized
Copy function _mintNormalized(address account, uint256 amount) private;
Parameters
of normalized tokens to mint
_mintToTreasury
This function does not perform any rounding checks.
Copy function _mintToTreasury(uint256 amount) internal;
Parameters
of tokens to mint to treasury
approve
Copy function approve(address spender, uint256 amount) external returns (bool);
Parameters
_approve
Copy function _approve(address owner, address spender, uint256 amount) internal;
Parameters
_spendAllowance
Spends allowance
Copy function _spendAllowance(address owner, address spender, uint256 amount) private;
transfer
Can only be called by owner of the tokens
Copy function transfer(address to, uint256 amount) public returns (bool);
Parameters
transferFrom
For use with approve()
Copy function transferFrom(address from, address to, uint256 amount) public returns (bool);
Parameters
_transfer
Copy function _transfer(address from, address to, uint256 amount) private;
permit
implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
Copy function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
)
public
virtual;
Parameters
The deadline timestamp, type(uint256).max for max deadline
allowance
Returns current allowance
Copy function allowance(address owner, address spender) public view returns (uint256);
Parameters
nonces
Copy function nonces(address owner) public view returns (uint256);
_useNonce
Consumes a nonce. Returns the current value and increments nonce.
Copy function _useNonce(address owner) internal virtual returns (uint256);
_setSupplyFactor
Copy function _setSupplyFactor(uint256 newSupplyFactor) internal;
updateTreasury
Updates the treasury address
Copy function updateTreasury(address newTreasury) external onlyRole(ION);
Parameters
underlying
Address of underlying asset
Copy function underlying() public view returns (IERC20);
decimals
Decimals of the position asset
Copy function decimals() public view returns (uint8);
balanceOf
Current claim of the underlying token inclusive of interest to be accrued.
Copy function balanceOf(address user) public view returns (uint256);
Parameters
balanceOfUnaccrued
Current claim of the underlying token without accounting for interest to be accrued.
Copy function balanceOfUnaccrued(address user) public view returns (uint256);
normalizedBalanceOf
Accounting is done in normalized balances
Copy function normalizedBalanceOf(address user) external view returns (uint256);
Parameters
to get normalized balance of
name
Name of the position asset
Copy function name() public view returns (string memory);
symbol
Symbol of the position asset
Copy function symbol() public view returns (string memory);
treasury
Current treasury address
Copy function treasury() public view returns (address);
totalSupplyUnaccrued
Total claim of the underlying asset belonging to lenders not inclusive of the new interest to be accrued.
Copy function totalSupplyUnaccrued() public view returns (uint256);
totalSupply
Total claim of the underlying asset belonging to lender inclusive of the new interest to be accrued.
Copy function totalSupply() public view returns (uint256);
normalizedTotalSupplyUnaccrued
Copy function normalizedTotalSupplyUnaccrued() public view returns (uint256);
normalizedTotalSupply
Normalized total supply.
Copy function normalizedTotalSupply() public view returns (uint256);
supplyFactorUnaccrued
Copy function supplyFactorUnaccrued() public view returns (uint256);
supplyFactor
Current supply factor
Copy function supplyFactor() public view returns (uint256);
calculateRewardAndDebtDistribution
Copy function calculateRewardAndDebtDistribution()
public
view
virtual
returns (
uint256 totalSupplyFactorIncrease,
uint256 totalTreasuryMintAmount,
uint104[] memory rateIncreases,
uint256 totalDebtIncrease,
uint48[] memory timestampIncreases
);
Events
MintToTreasury
Copy event MintToTreasury(address indexed treasury, uint256 amount, uint256 supplyFactor);
TreasuryUpdate
Copy event TreasuryUpdate(address treasury);
Errors
InvalidBurnAmount
Cannot burn amount whose normalized value is less than zero.
Copy error InvalidBurnAmount();
InvalidMintAmount
Cannot mint amount whose normalized value is less than zero.
Copy error InvalidMintAmount();
InvalidUnderlyingAddress
Copy error InvalidUnderlyingAddress();
InvalidTreasuryAddress
Copy error InvalidTreasuryAddress();
InvalidSender
Indicates a failure with the token sender
. Used in transfers.
Copy error InvalidSender(address sender);
Parameters
Address whose tokens are being transferred.
InvalidReceiver
Indicates a failure with the token receiver
. Used in transfers.
Copy error InvalidReceiver(address receiver);
Parameters
Address to which tokens are being transferred.
SelfTransfer
Cannot transfer the token to address self
Copy error SelfTransfer(address self);
ERC2612ExpiredSignature
Signature cannot be submitted after deadline
has passed. Designed to mitigate replay attacks.
Copy error ERC2612ExpiredSignature(uint256 deadline);
ERC2612InvalidSigner
signer
does not match the owner
of the tokens. owner
did not approve.
Copy error ERC2612InvalidSigner(address signer, address owner);
InsufficientBalance
Indicates an error related to the current balance
of a sender
. Used in transfers.
Copy error InsufficientBalance(address account, uint256 balance, uint256 needed);
Parameters
Address whose token balance is insufficient.
Current balance for the interacting account.
Minimum amount required to perform a transfer.
Structs
RewardTokenStorage
Copy struct RewardTokenStorage {
IERC20 underlying;
uint8 decimals;
string name;
string symbol;
address treasury;
uint256 normalizedTotalSupply;
uint256 supplyFactor;
mapping(address account => uint256) _normalizedBalances;
mapping(address account => mapping(address spender => uint256)) _allowances;
mapping(address account => uint256) nonces;
}