Price Oracle
Throughout the Aave Protocol, we require reliable, up to date, and secure price feeds. Our proxy price provider contract provides this capability and works by:
Aave Market
Uniswap Market
    1.
    First checking for a price from a Chainlink aggregator.
    2.
    If the price is below or equal to zero, we call our fallback price oracle.
      1.
      The fallback price oracle is currently maintained by the Aave team.
    3.
    In the future, Aave governance mechanisms will manage the selection of sources and the fallback price oracle.
The source code of the proxy price provider contract is available on Github.
    1.
    Checking for a price from our Uniswap price aggregator.
    2.
    In the future, Aave governance mechanisms will manage the selection of sources and the fallback price oracle.
The source code of the Uniswap price aggregator contract is available on Github.
Web3 code samples exclude the imports and transaction related parts to focus on methods interactions.
If you need development support, join the #developers channel on our Aave community Discord server.
Always get the latest price oracle address by calling getPriceOracle() on the LendingPoolAddressProvider contract.

View Methods

getAssetPrice()

function getAssetPrice(address _asset) public view returns(uint256)
Returns the price of the supported _asset in ETH wei units.
Parameter Name
Type
Description
_asset
address
address of the underlying asset
Solidity
JavaScript
IPriceOracleGetter.sol
1
pragma solidity ^0.5.0;
2
3
/************
4
@title IPriceOracleGetter interface
5
@notice Interface for the Aave price oracle.*/
6
interface IPriceOracleGetter {
7
function getAssetPrice(address _asset) external view returns (uint256);
8
function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory);
9
function getSourceOfAsset(address _asset) external view returns(address);
10
function getFallbackOracle() external view returns(address);
11
}
Copied!
YourContract.sol
1
pragma solidity ^0.5.0;
2
3
import "./IPriceOracleGetter.sol";
4
5
// ... rest of your contract ...
6
7
// Retrieve PriceOracle address
8
LendingPoolAddressesProvider provider = LendingPoolAddressesProvider(address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8)); // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
address priceOracleAddress = provider.getPriceOracle();
10
IPriceOracleGetter priceOracle = IPriceOracleGetter(priceOracleAddress);
11
12
address daiAddress = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); // mainnet DAI
13
uint256 price = priceOracle.getAssetPrice(daiAddress);
14
Copied!
1
import IPriceOracleABI from "./IPriceOracleGetter.json"
2
3
// From https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
4
import LendingPoolAddressesProviderABI from "./LendingPoolAddressesProvider.json"
5
6
// ... The rest of your code ...
7
8
const lpAddressProviderAddress = '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8' // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
const lpAddressProviderContract = new web3.eth.Contract(LendingPoolAddressesProviderABI, lpAddressProviderAddress)
10
11
// Get the latest PriceOracle address
12
const priceOracleAddress = await lpAddressProviderContract.methods
13
.getPriceOracle()
14
.call()
15
.catch((e) => {
16
throw Error(`Error getting priceOracle address: ${e.message}`)
17
})
18
19
const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // mainnet DAI
20
21
// Get the asset price
22
const priceOracleContract = new web3.eth.Contract(IPriceOracleABI, priceOracleAddress)
23
const price = await priceOracleContract.methods
24
.getAssetPrice(daiAddress)
25
.call()
26
.catch((e) => {
27
throw Error(`Error getting priceOracle price: ${e.message}`)
28
})
Copied!

getAssetsPrices()

function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory)
Returns any array of prices in ETH wei units.
Parameter Name
Type
Description
_assets
address[ ]
an array of addresses of the underlying assets
Solidity
JavaScript
IPriceOracleGetter.sol
1
pragma solidity ^0.5.0;
2
3
/************
4
@title IPriceOracleGetter interface
5
@notice Interface for the Aave price oracle.*/
6
interface IPriceOracleGetter {
7
function getAssetPrice(address _asset) external view returns (uint256);
8
function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory);
9
function getSourceOfAsset(address _asset) external view returns(address);
10
function getFallbackOracle() external view returns(address);
11
}
Copied!
YourContract.sol
1
pragma solidity ^0.5.0;
2
3
import "./IPriceOracleGetter.sol";
4
5
// ... rest of your contract ...
6
7
// Retrieve PriceOracle address
8
LendingPoolAddressesProvider provider = LendingPoolAddressesProvider(address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8)); // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
address priceOracleAddress = provider.getPriceOracle();
10
IPriceOracleGetter priceOracle = IPriceOracleGetter(priceOracleAddress);
11
12
// Add assets in question to addresses array
13
address[] memory addresses;
14
addresses[0] = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); // mainnet DAI;
15
addresses[1] = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // mainnet USDC;
16
uint256[] memory prices = priceOracle.getAssetsPrices(addresses);
17
Copied!
1
import IPriceOracleABI from "./IPriceOracleGetter.json"
2
3
// From https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
4
import LendingPoolAddressesProviderABI from "./LendingPoolAddressesProvider.json"
5
6
// ... The rest of your code ...
7
8
const lpAddressProviderAddress = '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8' // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
const lpAddressProviderContract = new web3.eth.Contract(LendingPoolAddressesProviderABI, lpAddressProviderAddress)
10
11
// Get the latest PriceOracle address
12
const priceOracleAddress = await lpAddressProviderContract.methods
13
.getPriceOracle()
14
.call()
15
.catch((e) => {
16
throw Error(`Error getting priceOracle address: ${e.message}`)
17
})
18
19
const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // mainnet DAI
20
const usdcAddress = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' // mainnet USDC
21
22
// Get the asset prices
23
const priceOracleContract = new web3.eth.Contract(IPriceOracleABI, priceOracleAddress)
24
const prices = await priceOracleContract.methods
25
.getAssetsPrices([daiAddress, usdcAddress])
26
.call()
27
.catch((e) => {
28
throw Error(`Error getting priceOracle prices: ${e.message}`)
29
})
Copied!

getSourceOfAsset()

function getSourceOfAsset(address _asset) external view returns(uint256)
Returns the address of the price source for _asset.
Parameter Name
Type
Description
_asset
address
address of the underlying asset
Solidity
JavaScript
IPriceOracleGetter.sol
1
pragma solidity ^0.5.0;
2
3
/************
4
@title IPriceOracleGetter interface
5
@notice Interface for the Aave price oracle.*/
6
interface IPriceOracleGetter {
7
function getAssetPrice(address _asset) external view returns (uint256);
8
function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory);
9
function getSourceOfAsset(address _asset) external view returns(address);
10
function getFallbackOracle() external view returns(address);
11
}
Copied!
YourContract.sol
1
import "./IPriceOracleGetter.sol";
2
3
// ... rest of your contract ...
4
5
// Retrieve PriceOracle address
6
LendingPoolAddressesProvider provider = LendingPoolAddressesProvider(address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8)); // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
7
address priceOracleAddress = provider.getPriceOracle();
8
IPriceOracleGetter priceOracle = IPriceOracleGetter(priceOracleAddress);
9
10
address daiAddress = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); // mainnet DAI
11
address source = priceOracle.getSourceOfAsset(daiAddress);
Copied!
1
import IPriceOracleABI from "./IPriceOracleGetter.json"
2
3
// From https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
4
import LendingPoolAddressesProviderABI from "./LendingPoolAddressesProvider.json"
5
6
// ... The rest of your code ...
7
8
const lpAddressProviderAddress = '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8' // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
const lpAddressProviderContract = new web3.eth.Contract(LendingPoolAddressesProviderABI, lpAddressProviderAddress)
10
11
// Get the latest PriceOracle address
12
const priceOracleAddress = await lpAddressProviderContract.methods
13
.getPriceOracle()
14
.call()
15
.catch((e) => {
16
throw Error(`Error getting priceOracle address: ${e.message}`)
17
})
18
19
const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // mainnet DAI
20
21
// Get source for asset
22
const priceOracleContract = new web3.eth.Contract(IPriceOracleABI, priceOracleAddress)
23
const source = await priceOracleContract.methods
24
.getSourceOfAsset(daiAddress)
25
.call()
26
.catch((e) => {
27
throw Error(`Error getting priceOracle source for asset: ${e.message}`)
28
})
Copied!

getFallbackOracle()

function getFallbackOracle() external view returns(uint256)
Returns the address of the fallback oracle.
Solidity
JavaScript
IPriceOracleGetter.sol
1
pragma solidity ^0.5.0;
2
3
/************
4
@title IPriceOracleGetter interface
5
@notice Interface for the Aave price oracle.*/
6
interface IPriceOracleGetter {
7
function getAssetPrice(address _asset) external view returns (uint256);
8
function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory);
9
function getSourceOfAsset(address _asset) external view returns(address);
10
function getFallbackOracle() external view returns(address);
11
}
Copied!
YourContract.sol
1
import "./IPriceOracleGetter.sol";
2
3
// ... rest of your contract ...
4
5
// Retrieve PriceOracle address
6
LendingPoolAddressesProvider provider = LendingPoolAddressesProvider(address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8)); // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
7
address priceOracleAddress = provider.getPriceOracle();
8
IPriceOracleGetter priceOracle = IPriceOracleGetter(priceOracleAddress);
9
10
address fallback = priceOracle.getFallbackOracle();
11
Copied!
1
import IPriceOracleABI from "./IPriceOracleGetter.json"
2
3
// From https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
4
import LendingPoolAddressesProviderABI from "./LendingPoolAddressesProvider.json"
5
6
// ... The rest of your code ...
7
8
const lpAddressProviderAddress = '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8' // mainnet address, for other addresses: https://docs.aave.com/developers/developing-on-aave/deployed-contract-instances
9
const lpAddressProviderContract = new web3.eth.Contract(LendingPoolAddressesProviderABI, lpAddressProviderAddress)
10
11
// Get the latest PriceOracle address
12
const priceOracleAddress = await lpAddressProviderContract.methods
13
.getPriceOracle()
14
.call()
15
.catch((e) => {
16
throw Error(`Error getting priceOracle address: ${e.message}`)
17
})
18
19
// Get fallback oracle address
20
const priceOracleContract = new web3.eth.Contract(IPriceOracleABI, priceOracleAddress)
21
const fallbackOracle = await priceOracleContract.methods
22
.getFallbackOracle()
23
.call()
24
.catch((e) => {
25
throw Error(`Error getting priceOracle fallback: ${e.message}`)
26
})
Copied!

IPriceOracleGetter ABI

IPriceOracleGetter.json
1
[
2
{
3
"inputs": [
4
{
5
"internalType": "address[]",
6
"name": "_assets",
7
"type": "address[]"
8
},
9
{
10
"internalType": "address[]",
11
"name": "_sources",
12
"type": "address[]"
13
},
14
{
15
"internalType": "address",
16
"name": "_fallbackOracle",
17
"type": "address"
18
}
19
],
20
"payable": false,
21
"stateMutability": "nonpayable",
22
"type": "constructor"
23
},
24
{
25
"anonymous": false,
26
"inputs": [
27
{
28
"indexed": true,
29
"internalType": "address",
30
"name": "asset",
31
"type": "address"
32
},
33
{
34
"indexed": true,
35
"internalType": "address",
36
"name": "source",
37
"type": "address"
38
}
39
],
40
"name": "AssetSourceUpdated",
41
"type": "event"
42
},
43
{
44
"anonymous": false,
45
"inputs": [
46
{
47
"indexed": true,
48
"internalType": "address",
49
"name": "fallbackOracle",
50
"type": "address"
51
}
52
],
53
"name": "FallbackOracleUpdated",
54
"type": "event"
55
},
56
{
57
"anonymous": false,
58
"inputs": [
59
{
60
"indexed": true,
61
"internalType": "address",
62
"name": "previousOwner",
63
"type": "address"
64
},
65
{
66
"indexed": true,
67
"internalType": "address",
68
"name": "newOwner",
69
"type": "address"
70
}
71
],
72
"name": "OwnershipTransferred",
73
"type": "event"
74
},
75
{
76
"constant": true,
77
"inputs": [],
78
"name": "isOwner",
79
"outputs": [
80
{
81
"internalType": "bool",
82
"name": "",
83
"type": "bool"
84
}
85
],
86
"payable": false,
87
"stateMutability": "view",
88
"type": "function"
89
},
90
{
91
"constant": true,
92
"inputs": [],
93
"name": "owner",
94
"outputs": [
95
{
96
"internalType": "address",
97
"name": "",
98
"type": "address"
99
}
100
],
101
"payable": false,
102
"stateMutability": "view",
103
"type": "function"
104
},
105
{
106
"constant": false,
107
"inputs": [],
108
"name": "renounceOwnership",
109
"outputs": [],
110
"payable": false,
111
"stateMutability": "nonpayable",
112
"type": "function"
113
},
114
{
115
"constant": false,
116
"inputs": [
117
{
118
"internalType": "address",
119
"name": "newOwner",
120
"type": "address"
121
}
122
],
123
"name": "transferOwnership",
124
"outputs": [],
125
"payable": false,
126
"stateMutability": "nonpayable",
127
"type": "function"
128
},
129
{
130
"constant": false,
131
"inputs": [
132
{
133
"internalType": "address[]",
134
"name": "_assets",
135
"type": "address[]"
136
},
137
{
138
"internalType": "address[]",
139
"name": "_sources",
140
"type": "address[]"
141
}
142
],
143
"name": "setAssetSources",
144
"outputs": [],
145
"payable": false,
146
"stateMutability": "nonpayable",
147
"type": "function"
148
},
149
{
150
"constant": false,
151
"inputs": [
152
{
153
"internalType": "address",
154
"name": "_fallbackOracle",
155
"type": "address"
156
}
157
],
158
"name": "setFallbackOracle",
159
"outputs": [],
160
"payable": false,
161
"stateMutability": "nonpayable",
162
"type": "function"
163
},
164
{
165
"constant": true,
166
"inputs": [
167
{
168
"internalType": "address",
169
"name": "_asset",
170
"type": "address"
171
}
172
],
173
"name": "getAssetPrice",
174
"outputs": [
175
{
176
"internalType": "uint256",
177
"name": "",
178
"type": "uint256"
179
}
180
],
181
"payable": false,
182
"stateMutability": "view",
183
"type": "function"
184
},
185
{
186
"constant": true,
187
"inputs": [
188
{
189
"internalType": "address[]",
190
"name": "_assets",
191
"type": "address[]"
192
}
193
],
194
"name": "getAssetsPrices",
195
"outputs": [
196
{
197
"internalType": "uint256[]",
198
"name": "",
199
"type": "uint256[]"
200
}
201
],
202
"payable": false,
203
"stateMutability": "view",
204
"type": "function"
205
},
206
{
207
"constant": true,
208
"inputs": [
209
{
210
"internalType": "address",
211
"name": "_asset",
212
"type": "address"
213
}
214
],
215
"name": "getSourceOfAsset",
216
"outputs": [
217
{
218
"internalType": "address",
219
"name": "",
220
"type": "address"
221
}
222
],
223
"payable": false,
224
"stateMutability": "view",
225
"type": "function"
226
},
227
{
228
"constant": true,
229
"inputs": [],
230
"name": "getFallbackOracle",
231
"outputs": [
232
{
233
"internalType": "address",
234
"name": "",
235
"type": "address"
236
}
237
],
238
"payable": false,
239
"stateMutability": "view",
240
"type": "function"
241
}
242
]
Copied!
Last modified 11mo ago