Skip to content

Commit

Permalink
feat: add tests for price feed
Browse files Browse the repository at this point in the history
  • Loading branch information
PraneshASP committed May 2, 2024
1 parent 819ac07 commit 205a80c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
41 changes: 41 additions & 0 deletions contracts/test/oracle/aero-weth-oracle.base.fork-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { expect } = require("chai");
const { parseUnits } = require("ethers/lib/utils");

const { isCI } = require("../helpers");
const addresses = require("../../utils/addresses");

describe("ForkTest: Aero WETH Oracle", function () {
this.timeout(0);

// Retry up to 3 times on CI
this.retries(isCI ? 3 : 0);

let aeroWethOracle;

beforeEach(async () => {
const AeroWethOracle = await ethers.getContractFactory("AeroWEthPriceFeed");
aeroWethOracle = await AeroWethOracle.deploy(
addresses.base.ethUsdPriceFeed,
addresses.base.aeroUsdPriceFeed
);
await aeroWethOracle.deployed();
});

it("should get WETH price", async () => {
const price = await aeroWethOracle.price(addresses.base.wethTokenAddress);
expect(price).to.eq(parseUnits("1", 18));
});

it("should get AERO price", async () => {
const price = await aeroWethOracle.price(addresses.base.aeroTokenAddress);
const poolInstance = await ethers.getContractAt(
"IPool",
addresses.base.wethAeroPoolAddress
);
const ammPrice = await poolInstance.getAmountOut(
parseUnits("1"),
addresses.base.aeroTokenAddress
);
expect(price).to.approxEqualTolerance(ammPrice, 1);
});
});
6 changes: 6 additions & 0 deletions contracts/utils/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,10 @@ addresses.base.aeroFactoryAddress =
addresses.base.aeroGaugeGovernorAddress =
"0xE6A41fE61E7a1996B59d508661e3f524d6A32075";

addresses.base.ethUsdPriceFeed = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70";

addresses.base.aeroUsdPriceFeed = "0x4EC5970fC728C5f65ba413992CD5fF6FD70fcfF0";
addresses.base.wethTokenAddress = "0x4200000000000000000000000000000000000006";
addresses.base.wethAeroPoolAddress =
"0x80aBe24A3ef1fc593aC5Da960F232ca23B2069d0";
module.exports = addresses;

0 comments on commit 205a80c

Please sign in to comment.