ScaledBalanceTokenBaseERC20
Basic ERC20 implementation of scaled balance token
constructor
Constructor.
Parameters
Name | Type | Description |
---|---|---|
pool | contract IPool | The reference to the main Pool contract |
name | string | The name of the token |
symbol | string | The symbol of the token |
decimals | uint8 | The number of decimals of the token |
scaledBalanceOf
Returns the scaled balance of the user.
The scaled balance is the sum of all the updated stored balance divided by the reserve's liquidity index at the moment of the update
Parameters
Name | Type | Description |
---|---|---|
user | address | The user whose balance is calculated |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The scaled balance of the user |
getScaledUserBalanceAndSupply
Returns the scaled balance of the user and the scaled total supply.
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The scaled balance of the user |
[1] | uint256 | The scaled total supply |
scaledTotalSupply
Returns the scaled total supply of the scaled balance token. Represents sum(debt/index)
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The scaled total supply |
getPreviousIndex
Returns last index interest was accrued to the user's balance
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The last index interest was accrued to the user's balance, expressed in ray |
_mintScaled
Implements the basic logic to mint a scaled balance token.
Parameters
Name | Type | Description |
---|---|---|
caller | address | The address performing the mint |
onBehalfOf | address | The address of the user that will receive the scaled tokens |
amount | uint256 | The amount of tokens getting minted |
index | uint256 | The next liquidity index of the reserve |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool |
|
_burnScaled
Implements the basic logic to burn a scaled balance token.
In some instances, a burn transaction will emit a mint event if the amount to burn is less than the interest that the user accrued
Parameters
Name | Type | Description |
---|---|---|
user | address | The user which debt is burnt |
target | address | The address that will receive the underlying, if any |
amount | uint256 | The amount getting burned |
index | uint256 | The variable debt index of the reserve |