uTokens
uToken.sol
The uTokens are the implementation of the interest-bearing token for the Unlockd protocol. They are the reserves, where all the underlying tokens will be stored.
View Methods
balanceOf
function balanceOf(address user) public view returns (uint256)
Calculates the balance of the user: principal balance + interest generated by the principal
Call Params
user
address
The user whose balance is calculated
Return Values
uint256
The balance of the user
scaledBalanceOf
function scaledBalanceOf(address user) external view returns (uint256)
Returns the scaled balance of the user. The scaled balance is the sum of all the updated stored balances divided by the reserve's liquidity index at the moment of the update.
Call Params
user
address
The user whose balance is calculated
Return Values
uint256
The scaled balance of the user
getScaledUserBalanceAndSupply
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256)
Returns the scaled balance of the user and the scaled total supply.
Call Params
user
address
The address of the user
Return Values
uint256
The scaled balance of the user
uint256
The scaled balance and the scaled total supply
UNDERLYING_ASSET_ADDRESS
function UNDERLYING_ASSET_ADDRESS() public view returns (address)
Returns the address of the underlying asset of this uToken.
Return Values
address
the underlying address of this uToken
RESERVE_TREASURY_ADDRESS
function RESERVE_TREASURY_ADDRESS() public view returns (address)
Returns the address of the Unlockd treasury, receiving the fees on this uToken
Return Values
address
the addres of the treasury wallet or contract
scaledTotalSupply
function scaledTotalSupply() public view virtual returns (uint256)
Returns the scaled total supply of the variable debt token. Represents sum(debt/index).
Return Values
uint256
the scaled total supply
totalSupply
function totalSupply() public view returns (uint256)
Calculates the total supply of the specific uToken since the balance of every single user increases over time. The total supply does that too.
Return Values
uint256
the current total supply
Write Methods
burn
function burn(address user, address receiverOfUnderlying, uint256 amount, uint256 index) external
Burns uTokens from user
and sends the equivalent amount of underlying to receiverOfUnderlying. This happens after a withdrawal.
Only callable by the LendPool
Call Params
user
address
The owner of the uTokens, getting them burned
receiverOfUnderlying
address
The address that will receive the underlying
amount
uint256
The amount being burned
index
uint256
The new liquidity index of the reserve
mint
function mint(address user, uint256 amount, uint256 index) external returns (bool)
Mints amount
uTokens to the user. This happens after a deposit.
Only callable by the LendPool.
Call Params
user
address
The address receiving the minted tokens
amount
uint256
The amount of tokens getting minted
index
uint256
The new liquidity index of the reserve
Return Values
bool
true
if the the previous balance of the user was 0
mintToTreasury
function mintToTreasury(uint256 amount, uint256 index) external
Mints uTokens to the treasury wallet or contract address.
Only callable by the LendPool
Call Params
amount
uint256
The amount of tokens getting minted
index
uint256
The new liquidity index of the reserve
transferUnderlyingTo
function transferUnderlyingTo(address target, uint256 amount) external returns (uint256)
Transfers the underlying asset to target
. Used by the LendPool to transfer assets in borrow(), withdraw() and flashLoan()
Call Params
target
address
The recipient of the uTokens
amount
uint256
The amount getting transferred
Return Values
uint256
The amount transferred
Last updated