-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add frxETH price feed to OETH Oracle Router (#1779)
* Add frxETH price feed to OETH Oracle Router * Changed asset order in OETHOracleRouter for better gas * Added OETH Oracle contracts diagram * Updated OETH Oracle contract diagram Co-authored-by: Nicholas Addison <nick@addisonbrown.com.au>
- Loading branch information
1 parent
4647604
commit 4c80f7f
Showing
6 changed files
with
220 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const addresses = require("../utils/addresses"); | ||
const { | ||
deploymentWithGovernanceProposal, | ||
deployWithConfirmation, | ||
withConfirmation, | ||
} = require("../utils/deploy"); | ||
|
||
module.exports = deploymentWithGovernanceProposal( | ||
{ | ||
deployName: "074_upgrade_oeth_oracle_router", | ||
forceDeploy: false, | ||
// forceSkip: true, | ||
reduceQueueTime: true, | ||
deployerIsProposer: true, | ||
}, | ||
async () => { | ||
// Current OETH Vault contracts | ||
const cVaultProxy = await ethers.getContract("OETHVaultProxy"); | ||
const cVaultAdmin = await ethers.getContractAt( | ||
"VaultAdmin", | ||
cVaultProxy.address | ||
); | ||
|
||
// Deploy the new Router | ||
await deployWithConfirmation("OETHOracleRouter"); | ||
const cOETHOracleRouter = await ethers.getContract("OETHOracleRouter"); | ||
|
||
// Cache decimals of all known tokens | ||
await withConfirmation( | ||
// CRV/ETH | ||
cOETHOracleRouter.cacheDecimals(addresses.mainnet.CRV) | ||
); | ||
|
||
await withConfirmation( | ||
// CVX/ETH | ||
cOETHOracleRouter.cacheDecimals(addresses.mainnet.CVX) | ||
); | ||
|
||
await withConfirmation( | ||
// rETH/ETH | ||
cOETHOracleRouter.cacheDecimals(addresses.mainnet.rETH) | ||
); | ||
|
||
await withConfirmation( | ||
// stETH/ETH | ||
cOETHOracleRouter.cacheDecimals(addresses.mainnet.stETH) | ||
); | ||
|
||
await withConfirmation( | ||
// frxETH/ETH | ||
cOETHOracleRouter.cacheDecimals(addresses.mainnet.frxETH) | ||
); | ||
|
||
// ---------------- | ||
// Governance Actions | ||
// ---------------- | ||
return { | ||
name: "Add frxETH price feed to OETH Oracle Router", | ||
actions: [ | ||
{ | ||
contract: cVaultAdmin, | ||
signature: "setPriceProvider(address)", | ||
args: [cOETHOracleRouter.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@startuml | ||
|
||
skinparam tabSize 2 | ||
|
||
title "OETH Oracle Contract Dependencies" | ||
|
||
object "OETHVault" as vault <<Origin>> #DeepSkyBlue { | ||
assets: | ||
\tWETH | ||
\tfrxETH | ||
\trETH | ||
\tstETH | ||
} | ||
|
||
object "OETHOracleRouter" as router <<Origin>> #DeepSkyBlue { | ||
pairs: | ||
\tWETH/ETH | ||
\tfrxETH/ETH | ||
\tstETH/ETH | ||
\trETH/ETH | ||
} | ||
|
||
object "FrxEthFraxOracle" as fo <<Frax>> { | ||
pair: frxETH/ETH | ||
} | ||
|
||
object "FrxEthEthDualOracle" as fdo <<Frax>> { | ||
pair: frxETH/ETH | ||
} | ||
|
||
object "External\nAccess\nControlled\nAggregator" as clrETH <<Chainlink>> { | ||
pair: rETH/ETH | ||
} | ||
|
||
object "External\nAccess\nControlled\nAggregator" as clstETH <<Chainlink>> { | ||
pair: stETH/ETH | ||
} | ||
|
||
object "External\nAccess\nControlled\nAggregator" as cleth <<Chainlink>> { | ||
pair: ETH/USD | ||
} | ||
|
||
object "External\nAccess\nControlled\nAggregator" as clfrax <<Chainlink>> { | ||
pair: FRAX/USD | ||
} | ||
|
||
object "frxETH/ETH Pool" as cp <<Curve>> { | ||
assets: frxETH, ETH | ||
} | ||
|
||
object "StaticOracle" as uso <<Uniswap>> { | ||
} | ||
|
||
object "frxETH/FRAX Pool" as up <<Uniswap>> { | ||
assets: frxETH, FRAX | ||
} | ||
|
||
|
||
vault ..> router : price(asset) | ||
router ...> clrETH : latestRoundData() | ||
router ...> clstETH : latestRoundData() | ||
router ..> fo : latestRoundData() | ||
fdo .> fo : addRoundData() | ||
fdo ....> cp : price_oracle() | ||
fdo ....> uso : quoteSpecificPoolsWithTimePeriod() | ||
uso .> up : observe() | ||
fdo ..> cleth : latestRoundData() | ||
fdo ..> clfrax : latestRoundData() | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const { expect } = require("chai"); | ||
const { parseUnits } = require("ethers/lib/utils"); | ||
|
||
const { loadDefaultFixture } = require("../_fixture"); | ||
const { forkOnlyDescribe, isCI } = require("../helpers"); | ||
|
||
forkOnlyDescribe("ForkTest: Oracle Routers", function () { | ||
this.timeout(0); | ||
|
||
// Retry up to 3 times on CI | ||
this.retries(isCI ? 3 : 0); | ||
|
||
let fixture; | ||
|
||
describe("OETH Oracle Router", () => { | ||
let oethOracleRouter; | ||
beforeEach(async () => { | ||
fixture = await loadDefaultFixture(); | ||
oethOracleRouter = await ethers.getContract("OETHOracleRouter"); | ||
}); | ||
it("should get rETH price", async () => { | ||
const { reth } = fixture; | ||
|
||
const price = await oethOracleRouter.price(reth.address); | ||
expect(price).to.gte(parseUnits("1083", 15)); | ||
expect(price).to.lt(parseUnits("109", 16)); | ||
}); | ||
it("should get frxETH price", async () => { | ||
const { frxETH } = fixture; | ||
|
||
const price = await oethOracleRouter.price(frxETH.address); | ||
expect(price).to.lt(parseUnits("1", 18)); | ||
}); | ||
it("should get WETH price", async () => { | ||
const { weth } = fixture; | ||
|
||
const price = await oethOracleRouter.price(weth.address); | ||
expect(price).to.eq(parseUnits("1", 18)); | ||
}); | ||
it("should get stETH price", async () => { | ||
const { stETH } = fixture; | ||
|
||
const price = await oethOracleRouter.price(stETH.address); | ||
expect(price).to.approxEqualTolerance(parseUnits("1", 18), 1); | ||
expect(price).to.not.eq(parseUnits("1", 18)); | ||
}); | ||
it("should get gas costs of assets", async () => { | ||
const { reth, frxETH, stETH, weth, josh } = fixture; | ||
|
||
for (const asset of [frxETH, reth, stETH, weth]) { | ||
const tx = await oethOracleRouter | ||
.connect(josh) | ||
.populateTransaction.price(asset.address); | ||
await josh.sendTransaction(tx); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters