Lending Market Contract
AppNFT FinanceGithubDocument Hub
  • Introduction
  • Core Contracts
    • LendingPool
      • ILendingPool
    • Addresses Provider
      • ILendingPoolAddressesProvider
    • Addresses Provider Registry
      • ILendingPoolAddressesProviderRegistry
    • vTokens
      • IVToekn
    • Debt Tokens
      • IVariableDebtToken
    • WETH Gateway
  • Deployment
    • Set the environment variables
    • Set the market parameters
    • Deploy to the blockchain
  • Security
    • Audits
Powered by GitBook
On this page
  • EIP20 Methods
  • EIP2612 Methods
  • permit()
  • _nonces()
  • Methods
  • UNDERLYING_ASSET_ADDRESS()
  • RESERVE_TREASURY_ADDRESS()
  • POOL()
  • scaledBalanceOf**()**
  • getScaledUserBalanceAndSupply**()**
  • scaledTotalSupply**()**
  1. Core Contracts

vTokens

PreviousILendingPoolAddressesProviderRegistryNextIVToekn

Last updated 2 years ago

vTokens are yield-generating tokens that are minted and burned upon and . The vTokens' value is pegged to the value of the corresponding deposited asset at a 1:1 ratio, and can be safely stored, transferred or traded. All interest collected by the vTokens reserves are distributed to vTokens holders directly by continuously increasing their wallet balance.

The source code can be found .

For all minting and burning actions, see and methods in the LendingPool contract.

EIP20 Methods

All standard EIP20 methods are implemented, such as balanceOf(), transfer(), transferFrom(), approve(), totalSupply(), etc.

balanceOf() will always return the most up to date balance of the user, which includes their principal balance + the interest generated by the principal balance.

EIP2612 Methods

permit()

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

Allows a user to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions.

Parameter
Type
Description

owner

address

The owner of the funds

spender

address

The spender for the funds

value

uint256

The amount the spender is permitted to use

deadline

uint256

The deadline timestamp that the permit is valid. Use type(uint).max for no deadline.

v

uint8

Signature parameter

r

bytes32

Signature parameter

s

bytes32

Signature parameter

_nonces()

function _nonces(address owner) public

Returns the next valid nonce to submit when calling permit()

Methods

UNDERLYING_ASSET_ADDRESS()

function UNDERLYING_ASSET_ADDRESS()

Returns the underlying asset of the vToken.

RESERVE_TREASURY_ADDRESS()

function RESERVE_TREASURY_ADDRESS()

Returns the address of the vTokens reserve treasury.

POOL()

function POOL()

scaledBalanceOf**()**

function scaledBalanceOf(address user)

Returns the scaled balance of user as a uint256.

The scaled balance is the balance of the underlying asset of the user (amount deposited), divided by the current liquidity index at the moment of the update.

I.e. scaledBalance=amountDeposited/currentLiquidityIndexscaledBalance = amount Deposited / currentLiquidityIndexscaledBalance=amountDeposited/currentLiquidityIndex

This essentially 'marks' when a user has deposited in the reserve pool, and can be used to calculate the users current compounded vToken balance.

Example:

  • User A deposits 1000 DAI at the liquidity index of 1.1

  • User B deposits another amount into the same pool

  • The liquidity index is now 1.2.

  • Therefore to calculate User A's current compounded vToken balance, the reverse operation should be performed: vTokenBalance=scaledBalance∗currentLiquidityIndexvTokenBalance = scaledBalance * currentLiquidityIndexvTokenBalance=scaledBalance∗currentLiquidityIndex

getScaledUserBalanceAndSupply**()**

function getScaledUserBalanceAndSupply(address user)

Returns the scaled balance of userand the principal total supply.

Return values

Type
Description

uint256

scaled balance of user

uint256

principal total supply

scaledTotalSupply**()**

function scaledTotalSupply()

Returns the scaled total supply of the vToken as uint256.

The scaled total supply is the sum of all the updated stored balances, divided by the reserve index at the moment of the update.

function isTransferAllowed(address user, uint256 amount)

Returns true if a transfer is allowed.

Returns the address of the associated for the vToken.

LendingPool
on Github here
deposit
withdraw
Deposit()
Withdraw()