maTokens
Aave's aTokens on Matic Network
Information generally about how maTokens work is given in the article here: Aave's Interest-Bearing aTokens on Matic Network.

Conversion between aTokens and maTokens

The aToken bridging contract leverages the Aave protocol to convert aToken values to maToken values and back. Exactly how this is done is given in the two functions below.
To convert an aToken value to a maToken value or vise versa call the following functions on Ethereum on the aToken bridge contract which is at this address: 0x0D29aDA4c818A9f089107201eaCc6300e56E0d5c
1
/**
2
* @dev Converts aToken value to maToken value
3
* @param _aTokenAddress aToken contract address
4
* @param _aTokenValue aToken value to convert
5
* @return maTokenValue_ The converted maToken value
6
**/
7
function getMATokenValue(address _aTokenAddress, uint256 _aTokenValue)
8
public
9
view
10
returns
11
(uint256 maTokenValue_)
12
{
13
ILendingPool pool = IAToken(_aTokenAddress).POOL();
14
uint256 liquidityIndex = pool.getReserveNormalizedIncome(
15
IAToken(_aTokenAddress).UNDERLYING_ASSET_ADDRESS()
16
);
17
maTokenValue_ = p27Div(_aTokenValue, liquidityIndex);
18
}
19
20
/**
21
* @dev Converts maToken value to aToken value
22
* @param _aTokenAddress aToken contract address
23
* @param _maTokenValue maToken value to convert
24
* @return aTokenValue_ The converted aToken value
25
**/
26
function getATokenValue(address _aTokenAddress, uint256 _maTokenValue)
27
public
28
view
29
returns (uint256 aTokenValue_)
30
{
31
ILendingPool pool = IAToken(_aTokenAddress).POOL();
32
uint256 liquidityIndex = pool.getReserveNormalizedIncome(
33
IAToken(_aTokenAddress).UNDERLYING_ASSET_ADDRESS()
34
);
35
aTokenValue_ = p27Mul(_maTokenValue, liquidityIndex);
36
}
Copied!
Don't use the ABI on Etherscan to call these functions. Instead use the ABI at this link: https://gist.github.com/mudgen/5da65e965e05ba08354f003aa86e6587

Getting aToken and maToken contract addresses

Use the functions below to get aTokens and maToken addresses.
1
/**
2
* @dev Gets the maTokens contract address on Matic that is associate with
3
* the aTokens contract on Ethereum.
4
* @param _rootToken The aToken contract address on Ethereum
5
* @return The maToken contract address on Matic.
6
**/
7
function rootToChildToken(address _rootToken) external view returns (address)
8
9
/**
10
* @dev Gets the aTokens contract address on Ethereum that is associate with
11
* the maTokens contract on Matic.
12
* @param _childToken The maToken contract address on Matic
13
* @return The aToken contract address on Ethereum.
14
**/
15
function childToRootToken(address _childToken) external view returns (address)
Copied!
The aToken addresses can be found on Etherscan or in Aave documentation.
The aToken bridge to Matic only works with version 2 aToken contracts.
Last modified 9mo ago