An vToken is issued whenever assets are supplied into a Vaultera market and is burnt again when those assets are withdrawn. Each vToken records how much of a crypto asset a user has placed with the protocol together with the yield that position has accrued. Because an vToken stays pegged to its matching supplied asset at a 1:1 ratio, it can be held, moved, or traded with confidence. Every bit of yield gathered by the vTokens' reserves flows straight to vToken holders, whose wallet balances rise continuously over time.
This contract is the implementation of the interest bearing token for the Vaultera Protocol. It inherits the ScaledBalanceTokenBase and EIP712Base token contracts.
Every standard EIP20 method is available on vTokens, including balanceOf , transfer , transferFrom , approve , totalSupply and so on.
balanceOf always reports the freshest balance held by a user, folding together both their principal balance and the yield that principal balance has produced.
The complete source code lives on the repo.
Write Methods
initialize
function initialize( IPool initializingPool, address treasury, address underlyingAsset, IVaulteraIncentivesController incentivesController, uint8 aTokenDecimals, string calldata aTokenName, string calldata aTokenSymbol, bytes calldata params) public virtualRuns when a new vToken instance is initialized.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| initializingPool | IPool | The address of the pool it is linked to | |
| treasury | address | The treasury's onchain address | |
| underlyingAsset | address | Onchain address of the underlying asset | |
| incentivesController | IVaulteraIncentivesController | The incentives controller attached to this vToken | |
| aTokenDecimals | uint8 | Decimal count for the underlying asset | |
| aTokenName | string | The label of the vToken | |
| aTokenSymbol | string | The ticker of the vToken | |
| params | bytes | Encoded parameters used for any extra initialization |
mint
function mint( address caller, address onBehalfOf, uint256 amount, uint256 index) external virtual override onlyPool returns (bool)Issues amount vTokens to user .
Method Parameters:
| Name | Type | Description | |
|---|---|---|---|
| caller | address | The address that triggers the mint | |
| onBehalfOf | address | The account that will receive the newly minted vTokens | |
| amount | uint256 | The quantity of tokens being minted | |
| index | uint256 | The upcoming liquidity index of the reserve |
Output Values:
| Type | Description | |
|---|---|---|
| bool | true if the user's previous balance was equal to 0 |
burn
function burn( address from, address receiverOfUnderlying, uint256 amount, uint256 index) external virtual override onlyPoolBurns vTokens from user and transfers the matching amount of underlying to receiverOfUnderlying .
In certain cases, the mint event may fire during a burn transaction when the amount to burn is smaller than the interest the user has accrued.
Method Parameters:
| Name | Type | Description | |
|---|---|---|---|
| from | address | The wallet whose vTokens are scheduled to be burned | |
| receiverOfUnderlying | address | The account set to receive the underlying asset back | |
| amount | uint256 | The quantity of tokens slated for burning | |
| index | uint256 | The upcoming liquidity index for the reserve |
mintToTreasury
function mintToTreasury(uint256 amount, uint256 index) external override onlyPoolIssues vTokens into the reserve treasury.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| amount | uint256 | The quantity of tokens being minted | |
| index | uint256 | The account set to receive the underlying asset back |
transferOnLiquidation
function transferOnLiquidation( address from, address to, uint256 value) virtual override onlyPoolMoves vTokens whenever a borrow position is liquidated, provided the liquidator opts to claim the vToken.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| from | address | The account being liquidated, the present holder of the vTokens | |
| to | address | The party receiving vTokens | |
| value | uint256 | The quantity of tokens being transferred out |
transferUnderlyingTo
function transferUnderlyingTo(address target, uint256 amount) external virtual override onlyPoolSends the underlying asset across to target .
Run by the Pool to shift funds through borrow(), withdraw() and flashLoan().
Call Parameters:
| Name | Type | Description | |
|---|---|---|---|
| user | address | The party receiving the underlying | |
| amount | uint256 | The quantity being transferred |
handleRepayment
function handleRepayment(address user, address onBehalfOf, uint256 amount) external virtual override onlyPoolDeals with the underlying that lands in the vToken once the transfer step has fully settled.
By default this hook does nothing, since for ordinary ERC20 tokens no follow-up work is required once the transfer wraps up. Down the line, though, certain vTokens might let holders stake the underlying to collect LM rewards. In a design like that, handleRepayment() would carry out the staking of the underlying asset on the holder's behalf.
Call Parameters:
| Name | Type | Description | |
|---|---|---|---|
| user | address | The caller performing the repayment | |
| onBehalfOf | address` | The address whose borrow position is being repaid | |
| amount | uint256 | The quantity being repaid |
permit
function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external overrideLets a holder authorize another account (or contract) to spend their funds by handing over a signed message. This unlocks gas-less flows and folds approval and transfer into a single call. Pass along a signed message to grant spending rights.
Implements permit in accordance with EIP-2612.
Call Parameters:
| Name | Type | Description | |
|---|---|---|---|
| owner | address | The holder of the funds | |
| spender | address | The spender of those funds | |
| value | uint256 | How many tokens the approved spender may move | |
| deadline | uint256 | The expiry timestamp for the signature; pass type(uint256).max for no | |
| v | uint8 | The signature's V value | |
| r | bytes32 | The signature's R value | |
| s | bytes32 | The signature's S value |
A sample flow for signing and calling permit:
import { signTypedData_v4 } from "eth-sig-util";import { fromRpcSig } from "ethereumjs-util";// ... other importsimport aTokenAbi from "./aTokenAbi.json";// ... setup your web3 providerconst aTokenAddress = "ATOKEN_ADDRESS";const aTokenContract = new web3.eth.Contract(aTokenAbi, aTokenAddress);const privateKey = "YOUR_PRIVATE_KEY_WITHOUT_0x";const chainId = 1;const owner = "OWNER_ADDRESS";const spender = "SPENDER_ADDRESS";const value = 100; // Amount the spender is permittedconst nonce = 1; // The next valid nonce, use `_nonces()`const deadline = 1600093162;const permitParams = { types: { EIP712Domain: [ { name: "name", type: "string" }, { name: "version", type: "string" }, { name: "chainId", type: "uint256" }, { name: "verifyingContract", type: "address" }, ], Permit: [ { name: "owner", type: "address" }, { name: "spender", type: "address" }, { name: "value", type: "uint256" }, { name: "nonce", type: "uint256" }, { name: "deadline", type: "uint256" }, ], }, primaryType: "Permit", domain: { name: "aTOKEN_NAME", version: "1", chainId: chainId, verifyingContract: aTokenAddress, }, message: { owner, spender, value, nonce, deadline, },};const signature = signTypedData_v4(Buffer.from(privateKey, "hex"), { data: permitParams,});// The signature can now be used to execute the transactionconst { v, r, s } = fromRpcSig(signature);await aTokenContract.methods .permit({ owner, spender, value, deadline, v, r, s, }) .send() .catch((e) => { throw Error(`Error permitting: ${e.message}`); });rescueTokens
function rescueTokens( address token, address to, uint256 amount) external override onlyPoolAdminRecover and send out tokens that are stuck inside this contract. Only POOL_ADMIN.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| token | address | The address for the token | |
| to | address | The wallet receiving the tokens | |
| amount | uint256 | How much of the token to send |
View Methods
balanceOf
function balanceOf(address user) public view virtual override(IncentivizedERC20, IERC20) returns (uint256)Gives the token balance held by user .
Overrides the parent method.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| user | address | The address for the user |
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The token balance held by a given user |
totalSupply
function totalSupply() public view virtual override(IncentivizedERC20, IERC20 returns (uint256)Yields the current number of tokens minted.
Supersedes the base method.
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The total number of minted tokens |
RESERVE_TREASURY_ADDRESS
function RESERVE_TREASURY_ADDRESS() external view override returns (address)Provides the address of the Vaultera treasury, governed onchain, which collects the fees accrued by this vToken.
Return Values:
| Type | Description | |
|---|---|---|
| address | The address of the Vaultera treasury |
UNDERLYING_ASSET_ADDRESS
function UNDERLYING_ASSET_ADDRESS() external view override returns (address)Provides the address of the underlying reserve asset backing this vToken (E.g. WETH for vWETH).
Return Values:
| Type | Description | |
|---|---|---|
| address | Address of the underlying reserve asset |
DOMAIN_SEPARATOR
function DOMAIN_SEPARATOR() public view override(IAToken, EIP712Base) returns (bytes32)Fetch the domain separator for this token on the active chain.
Returns the cached copy when chainId matches, otherwise recomputes the separator.
Supersedes the base method to fully satisfy IAToken.
Return Values:
| Type | Description | |
|---|---|---|
| bytes32 | The token's domain separator on the current chain |
nonces
function nonces(address owner) public view override(IAToken, EIP712Base) returns (uint256)Provides the nonce value for the address passed as a parameter; this is the nonce consumed when calling permit() .
Supersedes the base method to completely implement IAToken.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| owner | address | The owner's onchain address |
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The owner's nonce value |
Example:
const token = new Contract(aTokenAddress, vToken.abi, provider);await token.nonces(user);Pure Methods
getRevision
function getRevision() internal pure virtual override returns (uint256)Provides the revision number of the contract. Must be declared in the inheriting class as a constant.
Returns 0x1 .
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The current revision |
RwaAToken is a purpose-built extension of the AToken contract tailored for Real-World Assets (RWAs). It tracks a user's supplied collateral within the Vaultera Horizon market. To satisfy regulatory obligations, RwaAToken instances remain non-transferable by default for end-users.
Core operations such as transfer , approve , and permit are switched off to block peer-to-peer movement of these tokens. The Vaultera Horizon market defines an ATOKEN_ADMIN_ROLE, which may be assigned to RWA issuers or their appointed managers to handle tasks such as wallet recovery or position migration. Any address holding this role can carry out authorized transfers on behalf of users, as described below.
Write Methods
authorizedTransfer
function authorizedTransfer(address from, address to, uint256 amount) external returns (bool)Moves a quantity of vTokens from one user to another. This function may only be invoked by the RWAaTokenManager address that holds the ATOKEN_ADMIN_ROLE to precisely oversee vToken-specific transfers. It is meant for administrative operations, such as relocating a user's position to a fresh wallet. Every transfer remains bound by the protocol's health factor checks.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| from | address | The address funds move out of | |
| to | address | The address funds move in to | |
| amount | uint256 | The quantity of tokens to move |
Return Values:
| Type | Description | |
|---|---|---|
| bool | true when the transfer has succeeded |
mint
function mint( address caller, address onBehalfOf, uint256 amount, uint256 index) public virtual returns (bool)Mints amount vTokens to a user. This function overrides the standard mint so that the caller of the transaction must match the onBehalfOf address. In practice, this turns off the supplyOnBehalfOf functionality for RWAs.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| caller | address | The address that performs the mint | |
| onBehalfOf | address | The wallet address set to receive the newly minted vTokens | |
| amount | uint256 | The number of tokens that will be minted | |
| index | uint256 | The upcoming liquidity index for the reserve |
Return Values:
| Type | Description | |
|---|---|---|
| bool | true when the account's prior balance was equal to 0 |
Pure Functions
ATOKEN_ADMIN_ROLE
function ATOKEN_ADMIN_ROLE() external pure returns (bytes32)Provides the bytes32 identifier assigned to the ATOKEN_ADMIN_ROLE . This role lets an account call authorizedTransfer .
Return Values:
| Type | Description | |
|---|---|---|
| bytes32 | The identifier tied to the ATokenAdmin role |
Unsupported Operations
To preserve the non-transferable and compliant design of RWA collateral, the majority of standard ERC20 interactions are turned off for RwaAToken . Invoking any of the functions listed below will revert with an OPERATION_NOT_SUPPORTED error:
permit
approve
increaseAllowance
decreaseAllowance
transfer
transferFrom
mintToTreasury
transferOnLiquidation
transferUnderlyingTo
The StataTokenFactory serves as both a factory and a registry contract that oversees every deployed StataToken instance for a given Vaultera pool. It supports deploying fresh StataToken instances on demand and enforces that only a single StataToken instance exists per underlying asset. The contract keeps a mapping that links each underlying asset to its matching StataToken address.
StataTokens are ERC-4626 compliant wrappers around Vaultera's vTokens that deliver a non-rebasing mechanism for yield accrual.
You can access the source code on RepoHub.
Write Actions
initialize
function initialize() external initializerSets up the StataTokenFactory contract for use. This method follows the Initializable pattern and must be invoked to prepare the contract once it has been deployed onchain. In the present build, it intentionally executes no operations.
createStataTokens
function createStataTokens(address[] memory underlyings) external returns (address[] memory)Deploys fresh StataToken instances for the supplied underlying assets whenever they are not yet present. For every underlying asset passed in, the routine checks whether a matching StataToken already exists. When one is found, its existing StataToken address is returned. Otherwise, it deploys a new StataToken for that underlying asset, registers it, and returns the freshly created address.
Method Arguments:
| Name | Type | Description | |
|---|---|---|---|
| underlyings | address[] | A list of underlying asset addresses |
Output Values:
| Type | Description | |
|---|---|---|
| address[] | A list of StataToken addresses matching each of the supplied underlying assets |
Emits:
A StataTokenCreated(address indexed stataToken, address indexed underlying) event is fired for every newly created StataToken.
Reverts:
NotListedUnderlying(address underlying) is raised when the underlying asset has not been listed in the
Read Methods
getStataTokens
function getStataTokens() external view returns (address[] memory)Yields every StataToken instance deployed by this factory.
Output Values:
| Type | Description | |
|---|---|---|
| address[] | A list of all StataToken contract addresses |
getStataToken
function getStataToken(address underlying) external view returns (address)Provides the StataToken address for a specified underlying asset.
Method Arguments:
| Name | Type | Description | |
|---|---|---|---|
| underlying | address | The underlying asset's onchain address |
Output Values:
| Type | Description | |
|---|---|---|
| address | The onchain address of the matching StataToken ; returns address(0) if absent |
POOL
function POOL() external view returns (IPool)Provides the onchain address of the Vaultera pool tied to this factory.
Return Values:
| Type | Description | |
|---|---|---|
| IPool | The address of the linked Vaultera pool |
PROXY_ADMIN
function PROXY_ADMIN() external view returns (address)Provides the proxy admin address that governs the StataToken proxies.
Return Values:
| Type | Description | |
|---|---|---|
| address | The proxy admin's onchain address |
TRANSPARENT_PROXY_FACTORY
function TRANSPARENT_PROXY_FACTORY() external view returns (ITransparentProxyFactory)Exposes the transparent proxy factory address used to spin up new StataToken proxies.
Return Values:
| Type | Description | |
|---|---|---|
| ITransparentProxyFactory | The transparent proxy factory's address |
STATA_TOKEN_IMPL
function STATA_TOKEN_IMPL() external view returns (address)Exposes the StataToken implementation address referenced whenever fresh StataToken instances are deployed.
Return Values:
| Type | Description | |
|---|---|---|
| address | The StataToken implementation's onchain address |
Provides a variable debt token that records the borrowing positions held by users in variable rate mode.
Because variable debt tokens are non-transferable, the transfer and approve functionalities remain disabled.
Each vToken holds a 1:1 peg to the underlying borrowed asset and reflects the full amount currently owed to the protocol, namely principal debt + interest accrued.
The VariableDebtToken contract extends both the DebtTokenBase and ScaledBalanceTokenBase token contracts.
You can read the full source code our repo.
Write Methods
initialize
function initialize( IPool initializingPool, address underlyingAsset, IVaulteraIncentivesController incentivesController, uint8 debtTokenDecimals, string memory debtTokenName, string memory debtTokenSymbol, bytes calldata params) external virtualRuns when a variableDebtToken instance is initialised.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| initializingPool | IPool | The pool contract carrying out initialization here | |
| underlyingAsset | address | The address of the reserve asset backing this vToken (E.g. WETH for vWETH) | |
| incentivesController | IVaulteraIncentivesController | The contract that oversees any potential incentive distributions | |
| debtTokenDecimals | uint8 | The decimal precision of the variableDebtToken, equal to the underlying's | |
| debtTokenName | string | The label of the variable debt token | |
| debtTokenSymbol | string | The ticker of the variable debt token | |
| params | bytes | A bundle of encoded parameters for extra initialization steps |
mint
function mint( address user, address onBehalfOf, uint256 amount, uint256 index) external virtual override onlyPool returns (bool, uint256)Issues the variable debt token to the onBehalfOf address.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| user | address | The address that receives the borrowed underlying, acting as the delegatee under credit delegation, or matching onBehalfOf otherwise | |
| onBehalfOf | address | The address credited with the variable debt tokens | |
| amount | uint256 | The quantity of variable debt tokens to mint | |
| index | uint256 | The reserve's current variable debt index |
Return Values:
| Type | Description | |
|---|---|---|
| bool | true when the user's prior balance equals 0, false otherwise | |
| uint256 | The scaled aggregate debt of the reserve |
burn
function burn( address from, uint256 amount, uint256 index) external virtual override onlyPool returns (uint256)Removes user variable debt.
Occasionally a burn transaction emits a mint event whenever the amount to burn is smaller than the interest the user has accrued.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| from | address | The address that will have its debt burned | |
| amount | uint256 | The quantity of debt tokens to be burned | |
| index | uint256 | The reserve's current variable debt index |
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The scaled aggregate debt of the reserve |
View Methods
UNDERLYING_ASSET_ADDRESS
function UNDERLYING_ASSET_ADDRESS() external view override returns (address)Provides the address of the underlying asset backing this variableDebtToken (e.g. WETH for variableDebtWETH)
Return Values:
| Type | Description | |
|---|---|---|
| address | The underlying asset's onchain address |
balanceOf
function balanceOf(address account) public view virtual override returns (uint256)Provides the number of tokens held by account - the fully up to date accrued debt (principal + interest) belonging to the user.
A standard ERC20 method.
Input Parameters:
| Name | Type | Description | |
|---|---|---|---|
| account | address | This address's token balance |
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The number of tokens held by account |
totalSupply
function totalSupply() public view virtual override returns (uint256)Reports how many tokens are currently outstanding — the freshest aggregate debt owed across every account in the protocol for that particular variable rate of debt token.
A standard ERC20 method.
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The count of tokens currently issued |
Pure Methods
getRevision
function getRevision() internal pure virtual override returns (uint256)Provides the revision identifier for this contract, which must be declared as a constant within the inheriting class.
Yields 0x1 .
Return Values:
| Type | Description | |
|---|---|---|
| uint256 | The contract revision |
NOT SUPPORTED OPERATIONS
Since it is not transferable by design, the variable debt token exposes none of the standard ERC20 functions for transfer and allowance .
Each of the methods listed here will revert with the error code 80, OPERATION_NOT_SUPPORTED : transfer , allowance , approve , transferFrom , increaseAllowance , decreaseAllowance .