File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { task } from "hardhat/config" ;
2
+ import { ethers } from "hardhat" ;
3
+ import dotenv from "dotenv" ;
4
+ dotenv . config ( ) ;
5
+
6
+ // Usage:
7
+ // npx hardhat update-AaveOracle --network <network> --asset <asset-address> --oracle <oracle-address>
8
+
9
+ task ( "update-AaveOracle" , "Update the price oracle address for an asset in the Aave V3 protocol" )
10
+ . addParam ( "asset" , "The address of the asset to update the oracle for" )
11
+ . addParam ( "oracle" , "The new oracle address for the asset" )
12
+ . setAction ( async ( { asset, oracle } , hre ) => {
13
+ if ( ! ethers . utils . isAddress ( asset ) ) {
14
+ throw new Error ( "Invalid asset address provided." ) ;
15
+ }
16
+ if ( ! ethers . utils . isAddress ( oracle ) ) {
17
+ throw new Error ( "Invalid oracle address provided." ) ;
18
+ }
19
+ const [ signer ] = await hre . ethers . getSigners ( ) ;
20
+ const AAVE_ORACLE_ADDRESS = process . env . AAVE_ORACLE_ADDRESS || "<AAVE_ORACLE_ADDRESS_HERE>" ;
21
+ if ( ! ethers . utils . isAddress ( AAVE_ORACLE_ADDRESS ) ) {
22
+ throw new Error ( "Invalid AaveOracle address. Set AAVE_ORACLE_ADDRESS in your .env file." ) ;
23
+ }
24
+ const aaveOracle = await ethers . getContractAt ( "AaveOracle" , AAVE_ORACLE_ADDRESS , signer ) ;
25
+ console . log ( `Updating oracle for asset: ${ asset } to new oracle: ${ oracle } ` ) ;
26
+ const tx = await aaveOracle . setAssetSources ( [ asset ] , [ oracle ] ) ;
27
+ await tx . wait ( ) ;
28
+ console . log ( `Oracle for asset ${ asset } successfully updated to ${ oracle } .` ) ;
29
+ } ) ;
You can’t perform that action at this time.
0 commit comments