Skip to content

AToken Contract Interface ​

aTokens are tokens minted and burnt upon supply and withdraw of assets to Bend, which denote the amount of crypto assets supplied and the yield earned on those assets. aTokens’ value is pegged to the value of the corresponding supplied asset at a 1:1 ratio and can be safely stored, transferred or traded. All yield collected by the aTokens' reserves are distributed to aToken holders directly by continuously increasing their wallet balance (i.e. rebasing).

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

mint ​

solidity
function mint(address caller, address onBehalfOf, uint256 amount, uint256 index) external virtual returns (bool)

Mints amount aTokens to user

Parameters ​

NameTypeDescription
calleraddressThe address performing the mint
onBehalfOfaddressThe address of the user that will receive the minted aTokens
amountuint256The amount of tokens getting minted
indexuint256The next liquidity index of the reserve

Return Values ​

NameTypeDescription
[0]booltrue if the previous balance of the user was 0

burn ​

solidity
function burn(address from, address receiverOfUnderlying, uint256 amount, uint256 index) external virtual

Burns aTokens from user and sends the equivalent amount of underlying to receiverOfUnderlying

In some instances, the mint event could be emitted from a burn transaction if the amount to burn is less than the interest that the user accrued

Parameters ​

NameTypeDescription
fromaddressThe address from which the aTokens will be burned
receiverOfUnderlyingaddressThe address that will receive the underlying
amountuint256The amount being burned
indexuint256The next liquidity index of the reserve

mintToPOLFeeCollector ​

solidity
function mintToPOLFeeCollector(uint256 amount, uint256 index) external virtual

Mints aTokens to the reserve POL fee collector

Parameters ​

NameTypeDescription
amountuint256The amount of tokens getting minted
indexuint256The next liquidity index of the reserve

transferOnLiquidation ​

solidity
function transferOnLiquidation(address from, address to, uint256 value) external virtual

Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken

Parameters ​

NameTypeDescription
fromaddressThe address getting liquidated, current owner of the aTokens
toaddressThe recipient
valueuint256The amount of tokens getting transferred

balanceOf ​

solidity
function balanceOf(address user) public view virtual returns (uint256)

Returns the amount of tokens owned by account.

totalSupply ​

solidity
function totalSupply() public view virtual returns (uint256)

Returns the amount of tokens in existence.

RESERVE_POL_FEE_COLLECTOR ​

solidity
function RESERVE_POL_FEE_COLLECTOR() external view returns (address)

Returns the address of the POL fee collector, receiving the fees on this aToken.

The Fee is used to distribute among the BGT delegator.

Return Values ​

NameTypeDescription
[0]addressAddress of the Berachain fee collector contract.

UNDERLYING_ASSET_ADDRESS ​

solidity
function UNDERLYING_ASSET_ADDRESS() external view returns (address)

Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)

Return Values ​

NameTypeDescription
[0]addressThe address of the underlying asset

transferUnderlyingTo ​

solidity
function transferUnderlyingTo(address target, uint256 amount) external virtual

Transfers the underlying asset to target.

Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()

Parameters ​

NameTypeDescription
targetaddressThe recipient of the underlying
amountuint256The amount getting transferred

handleRepayment ​

solidity
function handleRepayment(address user, address onBehalfOf, uint256 amount) external virtual

Handles the underlying received by the aToken after the transfer has been completed.

The default implementation is empty as with standard ERC20 tokens, nothing needs to be done after the transfer is concluded. However in the future there may be aTokens that allow for example to stake the underlying to receive LM rewards. In that case, handleRepayment() would perform the staking of the underlying asset.

Parameters ​

NameTypeDescription
useraddressThe user executing the repayment
onBehalfOfaddressThe address of the user who will get his debt reduced/removed
amountuint256The amount getting repaid

permit ​

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

Allow passing a signed message to approve spending

_implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md_

Parameters ​

NameTypeDescription
owneraddressThe owner of the funds
spenderaddressThe spender
valueuint256The amount
deadlineuint256The deadline timestamp, type(uint256).max for max deadline
vuint8Signature param
rbytes32Signature param
sbytes32Signature param

_transfer ​

solidity
function _transfer(address from, address to, uint256 amount, bool validate) internal virtual

Transfers the aTokens between two users. Validates the transfer (ie checks for valid HF after the transfer) if required

Parameters ​

NameTypeDescription
fromaddressThe source address
toaddressThe destination address
amountuint256The amount getting transferred
validateboolTrue if the transfer needs to be validated, false otherwise

_transfer ​

solidity
function _transfer(address from, address to, uint128 amount) internal virtual

Overrides the parent _transfer to force validated transfer() and transferFrom()

Parameters ​

NameTypeDescription
fromaddressThe source address
toaddressThe destination address
amountuint128The amount getting transferred

DOMAIN_SEPARATOR ​

solidity
function DOMAIN_SEPARATOR() public view returns (bytes32)

Overrides the base function to fully implement IAToken see EIP712Base.DOMAIN_SEPARATOR() for more detailed documentation

nonces ​

solidity
function nonces(address owner) public view returns (uint256)

Overrides the base function to fully implement IAToken see EIP712Base.nonces() for more detailed documentation

_EIP712BaseId ​

solidity
function _EIP712BaseId() internal view returns (string)

Returns the user readable name of signing domain (e.g. token name)

Return Values ​

NameTypeDescription
[0]stringThe name of the signing domain

rescueTokens ​

solidity
function rescueTokens(address token, address to, uint256 amount) external

Rescue and transfer tokens locked in this contract

Parameters ​

NameTypeDescription
tokenaddressThe address of the token
toaddressThe address of the recipient
amountuint256The amount of token to transfer

scaledBalanceOf ​

solidity
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 balance divided by the reserve's liquidity index at the moment of the update

Parameters ​

NameTypeDescription
useraddressThe user whose balance is calculated

Return Values ​

NameTypeDescription
[0]uint256The scaled balance of the user

getScaledUserBalanceAndSupply ​

solidity
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256)

Returns the scaled balance of the user and the scaled total supply.

Parameters ​

NameTypeDescription
useraddressThe address of the user

Return Values ​

NameTypeDescription
[0]uint256The scaled balance of the user
[1]uint256The scaled total supply

scaledTotalSupply ​

solidity
function scaledTotalSupply() public view virtual returns (uint256)

Returns the scaled total supply of the scaled balance token. Represents sum(debt/index)

Return Values ​

NameTypeDescription
[0]uint256The scaled total supply

getPreviousIndex ​

solidity
function getPreviousIndex(address user) external view virtual returns (uint256)

Returns last index interest was accrued to the user's balance

Parameters ​

NameTypeDescription
useraddressThe address of the user

Return Values ​

NameTypeDescription
[0]uint256The last index interest was accrued to the user's balance, expressed in ray