From bd6b77ba41e4c21a63fce6bdd7e87da34a041379 Mon Sep 17 00:00:00 2001 From: Pablo Maldonado Date: Wed, 6 Dec 2023 15:24:00 +0000 Subject: [PATCH] feat: rename oev share to oval (#96) * feat: rename oev share to oval Signed-off-by: Pablo Maldonado * feat: ovaling Signed-off-by: Pablo Maldonado * feat: format Signed-off-by: Pablo Maldonado * fix: names Signed-off-by: Pablo Maldonado * refactor: format Signed-off-by: Pablo Maldonado * fix: test Signed-off-by: Pablo Maldonado * feat: try fix Signed-off-by: Pablo Maldonado * feat: try fix Signed-off-by: Pablo Maldonado * feat: test change Signed-off-by: Pablo Maldonado * revert changes Signed-off-by: Pablo Maldonado * fix: ci Signed-off-by: Pablo Maldonado * feat: format Signed-off-by: Pablo Maldonado * feat: remove logo Signed-off-by: Pablo Maldonado --------- Signed-off-by: Pablo Maldonado --- README.md | 10 +- logo.jpg | Bin 39114 -> 0 bytes scripts/README.md | 4 +- scripts/package.json | 4 +- scripts/src/gasProfiling/aaveV2Borrow.ts | 42 ++++---- scripts/src/gasProfiling/aaveV2Liquidation.ts | 42 ++++---- scripts/src/gasProfiling/aaveV3Borrow.ts | 42 ++++---- scripts/src/gasProfiling/aaveV3Liquidation.ts | 42 ++++---- scripts/src/gasProfiling/compoundBorrow.ts | 56 +++++----- .../src/gasProfiling/compoundLiquidation.ts | 56 +++++----- ...ndRootOevShare.sol => DiamondRootOval.sol} | 12 +-- src/{OevShare.sol => Oval.sol} | 10 +- .../BaseDestinationAdapter.sol | 6 +- .../ChainlinkDestinationAdapter.sol | 6 +- .../ChronicleMedianDestinationAdapter.sol | 6 +- .../OSMDestinationAdapter.sol | 6 +- .../PythDestinationAdapter.sol | 30 +++--- .../UniswapAnchoredViewDestinationAdapter.sol | 28 ++--- .../ChainlinkSourceAdapter.sol | 6 +- .../ChronicleMedianSourceAdapter.sol | 2 +- .../source-adapters/OSMSourceAdapter.sol | 2 +- .../source-adapters/PythSourceAdapter.sol | 2 +- .../source-adapters/SnapshotSource.sol | 4 +- .../UniswapAnchoredViewSourceAdapter.sol | 2 +- src/controllers/BaseController.sol | 20 ++-- src/controllers/ImmutableController.sol | 10 +- src/interfaces/{IOevShare.sol => IOval.sol} | 2 +- test/fork/aave/AaveV2.Liquidation.sol | 76 ++++++------- test/fork/aave/AaveV3.Liquidation.sol | 78 +++++++------- test/fork/adapters/PythSourceAdapter.sol | 4 +- test/fork/adapters/UnionSourceAdapter.sol | 16 ++- test/fork/compound/CompoundV2.Liquidation.sol | 80 +++++++------- test/mocks/MockSourceAdapter.sol | 4 +- test/unit/BaseController.sol | 2 +- test/unit/ImmutableController.sol | 2 +- ...l => Oval.ChainlinkDestinationAdapter.sol} | 46 ++++---- ...val.ChronicleMedianDestinationAdapter.sol} | 50 ++++----- ...ter.sol => Oval.OSMDestinationAdapter.sol} | 42 ++++---- ...er.sol => Oval.PythDestinationAdapter.sol} | 44 ++++---- ...UniswapAnchoredViewDestinationAdapter.sol} | 26 ++--- ...stValue.sol => Oval.UnlockLatestValue.sol} | 100 +++++++++--------- test/unit/SnapshotSource.SnapshotData.sol | 4 +- 42 files changed, 511 insertions(+), 515 deletions(-) delete mode 100644 logo.jpg rename src/{DiamondRootOevShare.sol => DiamondRootOval.sol} (88%) rename src/{OevShare.sol => Oval.sol} (87%) rename src/interfaces/{IOevShare.sol => IOval.sol} (90%) rename test/unit/{OevShare.ChainlinkDestinationAdapter.sol => Oval.ChainlinkDestinationAdapter.sol} (59%) rename test/unit/{OevShare.ChronicleMedianDestinationAdapter.sol => Oval.ChronicleMedianDestinationAdapter.sol} (58%) rename test/unit/{OevShare.OSMDestinationAdapter.sol => Oval.OSMDestinationAdapter.sol} (52%) rename test/unit/{OevShare.PythDestinationAdapter.sol => Oval.PythDestinationAdapter.sol} (64%) rename test/unit/{OevShare.UniswapAnchoredViewDestinationAdapter.sol => Oval.UniswapAnchoredViewDestinationAdapter.sol} (79%) rename test/unit/{OevShare.UnlockLatestValue.sol => Oval.UnlockLatestValue.sol} (57%) diff --git a/README.md b/README.md index 6c658e6..a3de6f4 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@


- OevShare +

OVAL


-

OEVShare enables the redirection and capture of Oracle Extractable Value.

+

OVAL enables the redirection and capture of Oracle Extractable Value.


-OEVShare enabled projects to do two main things: +OVAL enabled projects to do two main things: 1. capture MEV created as a result of oracle updates in their project, known as _Oracle Extractable Value_(OEV). This works by disrupting the MEV supply chain. For example a money market could get paid every time there are liquidations within their protocol. 2. aggregate multiple source oracles to provide increased security and fault tolerance. For example the [BoundedUnionAdapter]() returns the newest of Chainlink, Chronicle and Pyth, contingient on the value being within a tollerance percentage of at least one of the other feeds. -For more information on how OEVShare works and how to integrate with it see [oev.docs.uma.xyz](). +For more information on how OVAL works and how to integrate with it see [oev.docs.uma.xyz](). # Repo contents -This repository contains the main smart contracts for the OEVOracle. It uses [foundry](https://github.com/foundry-rs/foundry). +This repository contains the main smart contracts for the OVAL Oracle. It uses [foundry](https://github.com/foundry-rs/foundry). ### Building Contracts diff --git a/logo.jpg b/logo.jpg deleted file mode 100644 index dbc2516e01bf0b87194585be4177cc8f2347d86e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39114 zcmeFZ2|Sc<+c12Mv2SA+VuUC{*;*`e5aQGeLwf}|GxKrzwde8-}`&NE?sjSb6)3m9OrSK$2zh5*c3=) zyM>hnguy`2CGZEahoEfpNMA1qvax~GAqe7yxG-W67C;#A2VrC(t{*T2ZO6#{1>0d( z{i?$OL2KAK$sh{kXsTMh_)|iK0>DrpSQc z0M9U2#mIoefuWlsjg@|Mz6rof#o9`WKdOZJ8!PRz*`;U}6ym99ptV+OtrBP*;^DQ) zZmY$ww&0tw(yvKIL_}ys=xPOpcx$iQxN)QQS{-d29ZgU}GxS(sm}{hFV5su%9=3Xh zx`+4%hxrBtDlYZt>J}6pW~`*74Mx!ZHN+D5*IZ2$|6G44@P`6_DDZ~@e<<*W0{{P` zz(2Gd&p@E!L;zg|VoyUGb^%o>2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N|=bDCEDU3gpNK9?dtEk4#0- zAznHvrDCywXRMY&OmwYfAP^%#elQTCjPIQap9w(fwT0y@xjxMp5xHkWDqnzGoKnyj zhbz#>v#|9fg8ra{TyodL&r&3+$z#z#ZqMbjP%;!Q_%|TRu;T8d&e+#F&MG}fq2Mba zr)>8|3L7y`GsSA8N4q6OxXLqN$`@1n=e>T`j%PYR+dK0{sKEx2-c}N?OGuYchX1jt zh5_`&tA*q#kJUYm^8x-WoD7#ag-;xl>A@8!5?3xB^OA*rNs-!V1;M|${1uEf9@(~rZ` zXbTY$Lx=%gsUye=VKLK%puMpy>I z?hry*)H$6woCYlBO{uK4?F^kR! zZ2X$C{DXM=3(J%hk=CqIG5bAm_FtImKNd=35;<@Q&%x4FYEMc3%G`!_L3>{sYk;Ob zBG~(tch#Hc)4?@|f?DjGw6t1{MgDGCIV&!>4d_iwV_qzX(>{ajTLox;qOG%lM1K@M zeq@m{dKFUjA&AR>el~n`n2Q=9K$i?b>Q_O9*PA+H;p%{^2_X;JrD%zElUg}6HZ6{mhN9F0 z`W!hc$&kK61WaE0rlOb&udN#AJP(+BsCPa3Ky`%KsZA3{?7DCK+(McB&*ig => { return simulation.gasUsed; }; -const oevShareAaveV2Borrow = async (): Promise => { +const OVALAaveV2Borrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare AAVE V2 Borrow"; + const alias = "OVAL AAVE V2 Borrow"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -98,37 +98,37 @@ const oevShareAaveV2Borrow = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( "0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46", 18 ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); - await setForkSimulationDescription(fork.id, fork.headId, "Deploy OevShare"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy OVAL"); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // setOevShareAsAaveSource + // setOVALAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOevShare.address]] + [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOVAL.address]] ); simulation = await simulateTenderlyTx({ @@ -138,20 +138,20 @@ const oevShareAaveV2Borrow = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OEVShare as Aave source", + description: "Change OVAL as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -168,8 +168,8 @@ export const aaveV2Borrow = async () => { console.log("AAVE V2 Borrow gas comparison with unlock:\n"); const regularAaveV2BorrowGas = await regularAaveV2Borrow(); - const oevShareAaveV2BorrowGas = await oevShareAaveV2Borrow(); - const gasDiff = oevShareAaveV2BorrowGas - regularAaveV2BorrowGas; + const OVALAaveV2BorrowGas = await OVALAaveV2Borrow(); + const gasDiff = OVALAaveV2BorrowGas - regularAaveV2BorrowGas; console.log("Gas difference: " + gasDiff); }; diff --git a/scripts/src/gasProfiling/aaveV2Liquidation.ts b/scripts/src/gasProfiling/aaveV2Liquidation.ts index b8c6e25..3f680f0 100644 --- a/scripts/src/gasProfiling/aaveV2Liquidation.ts +++ b/scripts/src/gasProfiling/aaveV2Liquidation.ts @@ -12,8 +12,8 @@ import { TenderlySimulationResult, } from "../TenderlyHelpers/TenderlySimulation"; import { UniswapAnchoredViewDestinationAdapter__factory } from "../../contract-types"; -// Have to import TestedOevShare manually since it is not unique. -import { TestedOevShare__factory } from "../../contract-types/factories/AaveV2.Liquidation.sol/TestedOevShare__factory"; +// Have to import TestedOVAL manually since it is not unique. +import { TestedOVAL__factory } from "../../contract-types/factories/AaveV2.Liquidation.sol/TestedOVAL__factory"; // Common constants. const blockNumber = 17937311; @@ -91,9 +91,9 @@ const regularAaveV2Liquidation = async (): Promise => { return simulation.gasUsed; }; -const oevShareAaveV2Liquidation = async (): Promise => { +const OVALAaveV2Liquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare AAVE V2 Liquidation"; + const alias = "OVAL AAVE V2 Liquidation"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -114,37 +114,37 @@ const oevShareAaveV2Liquidation = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( "0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757", 18 ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); - await setForkSimulationDescription(fork.id, fork.headId, "Deploy OevShare"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy OVAL"); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // setOevShareAsAaveSource + // setOVALAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"], [testedOevShare.address]] + [["0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"], [testedOVAL.address]] ); simulation = await simulateTenderlyTx({ @@ -154,20 +154,20 @@ const oevShareAaveV2Liquidation = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OEVShare as Aave source", + description: "Change OVAL as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -184,8 +184,8 @@ export const aaveV2Liquidation = async () => { console.log("AAVE V2 Liquidation gas comparison with unlock:\n"); const regularAaveV2LiquidationGas = await regularAaveV2Liquidation(); - const oevShareAaveV2LiquidationGas = await oevShareAaveV2Liquidation(); - const gasDiff = oevShareAaveV2LiquidationGas - regularAaveV2LiquidationGas; + const OVALAaveV2LiquidationGas = await OVALAaveV2Liquidation(); + const gasDiff = OVALAaveV2LiquidationGas - regularAaveV2LiquidationGas; console.log("Gas difference: " + gasDiff); }; diff --git a/scripts/src/gasProfiling/aaveV3Borrow.ts b/scripts/src/gasProfiling/aaveV3Borrow.ts index c570585..d691014 100644 --- a/scripts/src/gasProfiling/aaveV3Borrow.ts +++ b/scripts/src/gasProfiling/aaveV3Borrow.ts @@ -11,8 +11,8 @@ import { TenderlySimulationResult, simulateTenderlyTx, } from "../TenderlyHelpers/TenderlySimulation"; -// Have to import TestedOevShare manually since it is not unique. -import { TestedOevShare__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOevShare__factory"; +// Have to import TestedOVAL manually since it is not unique. +import { TestedOVAL__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOVAL__factory"; // Common constants. const blockNumber = 18427678; @@ -74,9 +74,9 @@ const regularAaveV3Borrow = async (): Promise => { return simulation.gasUsed; }; -const oevShareAaveV3Borrow = async (): Promise => { +const OVALAaveV3Borrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare AAVE V3 Borrow"; + const alias = "OVAL AAVE V3 Borrow"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -97,37 +97,37 @@ const oevShareAaveV3Borrow = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( "0x3E7d1eAB13ad0104d2750B8863b489D65364e32D", 8 ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); - await setForkSimulationDescription(fork.id, fork.headId, "Deploy OevShare"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy OVAL"); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // setOevShareAsAaveSource + // setOVALAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOevShare.address]] + [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOVAL.address]] ); simulation = await simulateTenderlyTx({ @@ -137,20 +137,20 @@ const oevShareAaveV3Borrow = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OEVShare as Aave source", + description: "Change OVAL as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -167,8 +167,8 @@ export const aaveV3Borrow = async () => { console.log("AAVE V3 Borrow gas comparison with unlock:\n"); const regularAaveV3BorrowGas = await regularAaveV3Borrow(); - const oevShareAaveV3BorrowGas = await oevShareAaveV3Borrow(); - const gasDiff = oevShareAaveV3BorrowGas - regularAaveV3BorrowGas; + const OVALAaveV3BorrowGas = await OVALAaveV3Borrow(); + const gasDiff = OVALAaveV3BorrowGas - regularAaveV3BorrowGas; console.log("Gas difference: " + gasDiff); }; diff --git a/scripts/src/gasProfiling/aaveV3Liquidation.ts b/scripts/src/gasProfiling/aaveV3Liquidation.ts index aec8560..298f151 100644 --- a/scripts/src/gasProfiling/aaveV3Liquidation.ts +++ b/scripts/src/gasProfiling/aaveV3Liquidation.ts @@ -12,8 +12,8 @@ import { TenderlySimulationResult, } from "../TenderlyHelpers/TenderlySimulation"; import { UniswapAnchoredViewDestinationAdapter__factory } from "../../contract-types"; -// Have to import TestedOevShare manually since it is not unique. -import { TestedOevShare__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOevShare__factory"; +// Have to import TestedOVAL manually since it is not unique. +import { TestedOVAL__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOVAL__factory"; // Common constants. const blockNumber = 18018927; @@ -75,9 +75,9 @@ const regularAaveV3Liquidation = async (): Promise => { return simulation.gasUsed; }; -const oevShareAaveV3Liquidation = async (): Promise => { +const OVALAaveV3Liquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare AAVE V3 Liquidation"; + const alias = "OVAL AAVE V3 Liquidation"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -98,37 +98,37 @@ const oevShareAaveV3Liquidation = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419", 8 ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); - await setForkSimulationDescription(fork.id, fork.headId, "Deploy OevShare"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy OVAL"); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // setOevShareAsAaveSource + // setOVALAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], [testedOevShare.address]] + [["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], [testedOVAL.address]] ); simulation = await simulateTenderlyTx({ @@ -138,20 +138,20 @@ const oevShareAaveV3Liquidation = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OEVShare as Aave source", + description: "Change OVAL as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -168,8 +168,8 @@ export const aaveV3Liquidation = async () => { console.log("AAVE V3 Liquidation gas comparison with unlock:\n"); const regularAaveV3LiquidationGas = await regularAaveV3Liquidation(); - const oevShareAaveV3LiquidationGas = await oevShareAaveV3Liquidation(); - const gasDiff = oevShareAaveV3LiquidationGas - regularAaveV3LiquidationGas; + const OVALAaveV3LiquidationGas = await OVALAaveV3Liquidation(); + const gasDiff = OVALAaveV3LiquidationGas - regularAaveV3LiquidationGas; console.log("Gas difference: " + gasDiff); }; diff --git a/scripts/src/gasProfiling/compoundBorrow.ts b/scripts/src/gasProfiling/compoundBorrow.ts index 6b4313e..af1984a 100644 --- a/scripts/src/gasProfiling/compoundBorrow.ts +++ b/scripts/src/gasProfiling/compoundBorrow.ts @@ -12,8 +12,8 @@ import { TenderlySimulationResult, } from "../TenderlyHelpers/TenderlySimulation"; import { UniswapAnchoredViewDestinationAdapter__factory } from "../../contract-types"; -// Have to import TestedOevShare manually since it is not unique. -import { TestedOevShare__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOevShare__factory"; +// Have to import TestedOVAL manually since it is not unique. +import { TestedOVAL__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOVAL__factory"; // Common constants. const blockNumber = 18390940; // Latest as of writing this script. @@ -125,9 +125,9 @@ const regularCompoundBorrow = async (): Promise => { return simulation.gasUsed; }; -const oevShareCompoundBorrow = async (): Promise => { +const OVALCompoundBorrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare Compound Borrow"; + const alias = "OVAL Compound Borrow"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -162,55 +162,55 @@ const oevShareCompoundBorrow = async (): Promise => { "Deploy UniswapAnchoredViewDestinationAdapter" ); - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( uniswapAnchoredViewSourceAddress, cETHAddress ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); await setForkSimulationDescription( fork.id, fork.headId, - "Deploy OevShare" + "Deploy OVAL" ); - // Set TestedOevShare on UniswapAnchoredViewDestinationAdapter. - const setOevShareInput = - uavDestinationAdapterFactory.interface.encodeFunctionData("setOevShare", [ + // Set TestedOVAL on UniswapAnchoredViewDestinationAdapter. + const setOVALInput = + uavDestinationAdapterFactory.interface.encodeFunctionData("setOVAL", [ cETHAddress, - testedOevShare.address, + testedOVAL.address, ]); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, to: uavDestinationAdapter.address, - input: setOevShareInput, + input: setOVALInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Set OEVShare", + description: "Set OVAL", }); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // Whitelist TestedOevShare on chainlink + // Whitelist TestedOVAL on chainlink const sourceChainlinkOracleAddress = - await testedOevShare.callStatic.aggregator(); + await testedOVAL.callStatic.aggregator(); const sourceChainlinkOracle = new Contract( sourceChainlinkOracleAddress, accessControlledOffchainAggregatorAbi, @@ -220,7 +220,7 @@ const oevShareCompoundBorrow = async (): Promise => { await sourceChainlinkOracle.callStatic.owner(); const addAccessInput = sourceChainlinkOracle.interface.encodeFunctionData( "addAccess", - [testedOevShare.address] + [testedOVAL.address] ); simulation = await simulateTenderlyTx({ chainId, @@ -229,7 +229,7 @@ const oevShareCompoundBorrow = async (): Promise => { input: addAccessInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Whitelist OEVShare on Chainlink", + description: "Whitelist OVAL on Chainlink", }); // Point Comptroller to UniswapAnchoredViewDestinationAdapter. @@ -255,15 +255,15 @@ const oevShareCompoundBorrow = async (): Promise => { // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -285,8 +285,8 @@ export const compoundBorrow = async () => { console.log("Compound Borrow gas comparison with unlock:\n"); const regularCompoundBorrowGas = await regularCompoundBorrow(); - const oevShareCompoundBorrowGas = await oevShareCompoundBorrow(); - const gasDiff = oevShareCompoundBorrowGas - regularCompoundBorrowGas; + const OVALCompoundBorrowGas = await OVALCompoundBorrow(); + const gasDiff = OVALCompoundBorrowGas - regularCompoundBorrowGas; console.log("Gas difference: " + gasDiff); }; diff --git a/scripts/src/gasProfiling/compoundLiquidation.ts b/scripts/src/gasProfiling/compoundLiquidation.ts index de39f06..1ef7078 100644 --- a/scripts/src/gasProfiling/compoundLiquidation.ts +++ b/scripts/src/gasProfiling/compoundLiquidation.ts @@ -12,8 +12,8 @@ import { TenderlySimulationResult, } from "../TenderlyHelpers/TenderlySimulation"; import { UniswapAnchoredViewDestinationAdapter__factory } from "../../contract-types"; -// Have to import TestedOevShare manually since it is not unique. -import { TestedOevShare__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOevShare__factory"; +// Have to import TestedOVAL manually since it is not unique. +import { TestedOVAL__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOVAL__factory"; // Common constants. // Compound liquidation https://etherscan.io/tx/0xb955a078b9b2a73e111033a3e77142b5768f5729285279d56eff641e43060555 @@ -95,9 +95,9 @@ const regularCompoundLiquidation = async (): Promise => { return simulation.gasUsed; }; -const oevShareCompoundLiquidation = async (): Promise => { +const OVALCompoundLiquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OEVShare Compound Liquidation"; + const alias = "OVAL Compound Liquidation"; const description = "Genereated: " + utils.keccak256(utils.toUtf8Bytes(alias)); const existingFork = await findForkByDescription(description); @@ -132,51 +132,51 @@ const oevShareCompoundLiquidation = async (): Promise => { "Deploy UniswapAnchoredViewDestinationAdapter" ); - // Deploy OevShare. - const testedOevShareFactory = new TestedOevShare__factory(ownerSigner); - const testedOevShare = await testedOevShareFactory.deploy( + // Deploy OVAL. + const testedOVALFactory = new TestedOVAL__factory(ownerSigner); + const testedOVAL = await testedOVALFactory.deploy( uniswapAnchoredViewSourceAddress, cETHAddress ); - await testedOevShare.deployTransaction.wait(); + await testedOVAL.deployTransaction.wait(); fork = await getTenderlyFork(fork.id); // Refresh to get head id since we submitted tx through RPC. if (!fork.headId) throw new Error("Fork head id not found."); - await setForkSimulationDescription(fork.id, fork.headId, "Deploy OevShare"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy OVAL"); - // Set TestedOevShare on UniswapAnchoredViewDestinationAdapter. - const setOevShareInput = - uavDestinationAdapterFactory.interface.encodeFunctionData("setOevShare", [ + // Set TestedOVAL on UniswapAnchoredViewDestinationAdapter. + const setOVALInput = + uavDestinationAdapterFactory.interface.encodeFunctionData("setOVAL", [ cETHAddress, - testedOevShare.address, + testedOVAL.address, ]); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, to: uavDestinationAdapter.address, - input: setOevShareInput, + input: setOVALInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Set OEVShare", + description: "Set OVAL", }); - // Enable unlocker on TestedOevShare. - const setUnlockerInput = testedOevShareFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOVAL. + const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Enable unlocker on OEVShare", + description: "Enable unlocker on OVAL", }); - // Whitelist TestedOevShare on chainlink + // Whitelist TestedOVAL on chainlink const sourceChainlinkOracleAddress = - await testedOevShare.callStatic.aggregator(); + await testedOVAL.callStatic.aggregator(); const sourceChainlinkOracle = new Contract( sourceChainlinkOracleAddress, accessControlledOffchainAggregatorAbi, @@ -186,7 +186,7 @@ const oevShareCompoundLiquidation = async (): Promise => { await sourceChainlinkOracle.callStatic.owner(); const addAccessInput = sourceChainlinkOracle.interface.encodeFunctionData( "addAccess", - [testedOevShare.address] + [testedOVAL.address] ); simulation = await simulateTenderlyTx({ chainId, @@ -195,7 +195,7 @@ const oevShareCompoundLiquidation = async (): Promise => { input: addAccessInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Whitelist OEVShare on Chainlink", + description: "Whitelist OVAL on Chainlink", }); // Point Comptroller to UniswapAnchoredViewDestinationAdapter. @@ -221,15 +221,15 @@ const oevShareCompoundLiquidation = async (): Promise => { // Unlock latest value. const unlockLatestValueInput = - testedOevShareFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOevShare.address, + to: testedOVAL.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OEVShare", + description: "Unlock latest value on OVAL", }); // Open user position. @@ -246,8 +246,8 @@ export const compoundLiquidation = async () => { console.log("Compound Liquidation gas comparison with unlock:\n"); const regularCompoundBorrowGas = await regularCompoundLiquidation(); - const oevShareCompoundBorrowGas = await oevShareCompoundLiquidation(); - const gasDiff = oevShareCompoundBorrowGas - regularCompoundBorrowGas; + const OVALCompoundBorrowGas = await OVALCompoundLiquidation(); + const gasDiff = OVALCompoundBorrowGas - regularCompoundBorrowGas; console.log("Gas difference: " + gasDiff); }; diff --git a/src/DiamondRootOevShare.sol b/src/DiamondRootOval.sol similarity index 88% rename from src/DiamondRootOevShare.sol rename to src/DiamondRootOval.sol index 3be759f..77e9ccb 100644 --- a/src/DiamondRootOevShare.sol +++ b/src/DiamondRootOval.sol @@ -3,15 +3,15 @@ pragma solidity 0.8.17; import {IBaseOracleAdapter} from "./interfaces/IBaseOracleAdapter.sol"; import {IBaseController} from "./interfaces/IBaseController.sol"; -import {IOevShare} from "./interfaces/IOevShare.sol"; +import {IOVAL} from "./interfaces/IOval.sol"; /** - * @title DiamondRootOevShare contract to provide base functions that the three components of the OEV contract system - * need. They are exposed here to simplify the inheritance structure of the OEV contract system and to enable easier + * @title DiamondRootOVAL contract to provide base functions that the three components of the OVAL contract system + * need. They are exposed here to simplify the inheritance structure of the OVAL contract system and to enable easier * composability and extensibility at the integration layer, enabling arbitrary combinations of sources and destinations. */ -abstract contract DiamondRootOevShare is IBaseController, IOevShare, IBaseOracleAdapter { +abstract contract DiamondRootOVAL is IBaseController, IOVAL, IBaseOracleAdapter { /** * @notice Returns the latest data from the source. * @return answer The latest answer in 18 decimals. @@ -30,7 +30,7 @@ abstract contract DiamondRootOevShare is IBaseController, IOevShare, IBaseOracle function tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) public view virtual returns (int256, uint256); /** - * @notice Returns the latest data from the source. Depending on when the OEVShare was last unlocked this might + * @notice Returns the latest data from the source. Depending on when the OVAL was last unlocked this might * return an slightly stale value to protect the OEV from being stolen by a front runner. * @return answer The latest answer in 18 decimals. * @return updatedAt The timestamp of the answer. @@ -43,7 +43,7 @@ abstract contract DiamondRootOevShare is IBaseController, IOevShare, IBaseOracle function snapshotData() public virtual; /** - * @notice Permissioning function to control who can unlock the OEVShare. + * @notice Permissioning function to control who can unlock the OVAL. */ function canUnlock(address caller, uint256 cachedLatestTimestamp) public view virtual returns (bool); diff --git a/src/OevShare.sol b/src/Oval.sol similarity index 87% rename from src/OevShare.sol rename to src/Oval.sol index 1fe77a9..08a0801 100644 --- a/src/OevShare.sol +++ b/src/Oval.sol @@ -2,10 +2,10 @@ pragma solidity 0.8.17; import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol"; -import {DiamondRootOevShare} from "./DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "./DiamondRootOval.sol"; /** - * @title OEVShare contract to provide permissioned updating at the execution of an MEV-share auction. + * @title OVAL contract to provide permissioned updating at the execution of an MEV-share auction. * @dev This contract works by conditionally returning a stale value oracle price from the source adapter until a * permissioned actor calls the unlockLatestValue function. The call to unlockLatestValue is submitted via an MEV-share * auction and will be backrun by the winner of the auction. The backrunner has access to the most recent newly unlocked @@ -16,8 +16,8 @@ import {DiamondRootOevShare} from "./DiamondRootOevShare.sol"; * @custom:security-contact bugs@umaproject.org */ -abstract contract OevShare is DiamondRootOevShare { - uint256 public lastUnlockTime; // Timestamp of the latest unlock to the OEVShare. +abstract contract OVAL is DiamondRootOVAL { + uint256 public lastUnlockTime; // Timestamp of the latest unlock to the OVAL. /** * @notice Function called by permissioned actor to unlock the latest value as part of the MEV-share auction flow. @@ -28,7 +28,7 @@ abstract contract OevShare is DiamondRootOevShare { function unlockLatestValue() public { require(canUnlock(msg.sender, lastUnlockTime), "Controller blocked: canUnlock"); - snapshotData(); // If the source connected to this OevShare needs to snapshot data, do it here. Else, no op. + snapshotData(); // If the source connected to this OVAL needs to snapshot data, do it here. Else, no op. lastUnlockTime = block.timestamp; diff --git a/src/adapters/destination-adapters/BaseDestinationAdapter.sol b/src/adapters/destination-adapters/BaseDestinationAdapter.sol index 3e9f05e..8e64de7 100644 --- a/src/adapters/destination-adapters/BaseDestinationAdapter.sol +++ b/src/adapters/destination-adapters/BaseDestinationAdapter.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** - * @title BaseDestinationAdapter contract to expose OEVShare data via the standardized interface. Provides a base + * @title BaseDestinationAdapter contract to expose OVAL data via the standardized interface. Provides a base * implementation that consumers can connect with if they don't want to use an opinionated destination Adapter. * */ -abstract contract BaseDestinationAdapter is DiamondRootOevShare { +abstract contract BaseDestinationAdapter is DiamondRootOVAL { uint8 public constant decimals = 18; /** diff --git a/src/adapters/destination-adapters/ChainlinkDestinationAdapter.sol b/src/adapters/destination-adapters/ChainlinkDestinationAdapter.sol index 1a588e6..a1c3603 100644 --- a/src/adapters/destination-adapters/ChainlinkDestinationAdapter.sol +++ b/src/adapters/destination-adapters/ChainlinkDestinationAdapter.sol @@ -3,13 +3,13 @@ pragma solidity 0.8.17; import {DecimalLib} from "../lib/DecimalLib.sol"; import {IAggregatorV3} from "../../interfaces/chainlink/IAggregatorV3.sol"; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** - * @title ChainlinkDestinationAdapter contract to expose OEVShare data via the standard Chainlink Aggregator interface. + * @title ChainlinkDestinationAdapter contract to expose OVAL data via the standard Chainlink Aggregator interface. */ -abstract contract ChainlinkDestinationAdapter is DiamondRootOevShare, IAggregatorV3 { +abstract contract ChainlinkDestinationAdapter is DiamondRootOVAL, IAggregatorV3 { uint8 public immutable override decimals; event DecimalsSet(uint8 indexed decimals); diff --git a/src/adapters/destination-adapters/ChronicleMedianDestinationAdapter.sol b/src/adapters/destination-adapters/ChronicleMedianDestinationAdapter.sol index cfd3d04..f395328 100644 --- a/src/adapters/destination-adapters/ChronicleMedianDestinationAdapter.sol +++ b/src/adapters/destination-adapters/ChronicleMedianDestinationAdapter.sol @@ -2,13 +2,13 @@ pragma solidity 0.8.17; import {IMedian} from "../../interfaces/chronicle/IMedian.sol"; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** - * @notice ChronicleMedianDestinationAdapter contract to expose OEVShare data via the standard Chronicle interface. + * @notice ChronicleMedianDestinationAdapter contract to expose OVAL data via the standard Chronicle interface. */ -abstract contract ChronicleMedianDestinationAdapter is IMedian, DiamondRootOevShare { +abstract contract ChronicleMedianDestinationAdapter is IMedian, DiamondRootOVAL { constructor(address _sourceAdapter) {} uint8 public constant decimals = 18; // Chronicle price feeds have always have 18 decimals. diff --git a/src/adapters/destination-adapters/OSMDestinationAdapter.sol b/src/adapters/destination-adapters/OSMDestinationAdapter.sol index 0c9ba9b..bc56066 100644 --- a/src/adapters/destination-adapters/OSMDestinationAdapter.sol +++ b/src/adapters/destination-adapters/OSMDestinationAdapter.sol @@ -2,13 +2,13 @@ pragma solidity 0.8.17; import {IOSM} from "../../interfaces/makerdao/IOSM.sol"; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** - * @title OSMDestinationAdapter contract to expose OEVShare data via the standard MakerDAO OSM interface. + * @title OSMDestinationAdapter contract to expose OVAL data via the standard MakerDAO OSM interface. */ -abstract contract OSMDestinationAdapter is IOSM, DiamondRootOevShare { +abstract contract OSMDestinationAdapter is IOSM, DiamondRootOVAL { constructor() {} /** diff --git a/src/adapters/destination-adapters/PythDestinationAdapter.sol b/src/adapters/destination-adapters/PythDestinationAdapter.sol index d64c9b7..a368a93 100644 --- a/src/adapters/destination-adapters/PythDestinationAdapter.sol +++ b/src/adapters/destination-adapters/PythDestinationAdapter.sol @@ -5,21 +5,21 @@ import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol"; import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; import {IPyth} from "../../interfaces/pyth/IPyth.sol"; -import {IOevShare} from "../../interfaces/IOevShare.sol"; +import {IOVAL} from "../../interfaces/IOval.sol"; import {DecimalLib} from "../lib/DecimalLib.sol"; /** - * @notice PythDestinationAdapter contract to expose OEVShare data via the standard pyth interface. + * @notice PythDestinationAdapter contract to expose OVAL data via the standard pyth interface. */ contract PythDestinationAdapter is Ownable, IPyth { - mapping(bytes32 => IOevShare) public idToOevShare; + mapping(bytes32 => IOVAL) public idToOVAL; mapping(bytes32 => uint8) public idToDecimal; mapping(bytes32 => uint256) public idToValidTimePeriod; IPyth public immutable basePythProvider; event BaseSourceSet(address indexed sourceOracle); - event OevShareSet(bytes32 indexed id, uint8 indexed decimals, uint256 validTimePeriod, address indexed oevShare); + event OVALSet(bytes32 indexed id, uint8 indexed decimals, uint256 validTimePeriod, address indexed oval); constructor(IPyth _basePythProvider) { basePythProvider = _basePythProvider; @@ -28,18 +28,18 @@ contract PythDestinationAdapter is Ownable, IPyth { } /** - * @notice Enables the owner to set mapping between pyth identifiers and OEVShares. Done for each identifier. - * @param id The pyth identifier to set the OEVShare for. + * @notice Enables the owner to set mapping between pyth identifiers and OVALs. Done for each identifier. + * @param id The pyth identifier to set the OVAL for. * @param decimals The number of decimals for the identifier. * @param validTimePeriod The number of seconds that a price is valid for. - * @param oevShare The OEVShare to set for the identifier. + * @param oval The OVAL to set for the identifier. */ - function setOevShare(bytes32 id, uint8 decimals, uint256 validTimePeriod, IOevShare oevShare) public onlyOwner { - idToOevShare[id] = oevShare; + function setOVAL(bytes32 id, uint8 decimals, uint256 validTimePeriod, IOVAL oval) public onlyOwner { + idToOVAL[id] = oval; idToDecimal[id] = decimals; idToValidTimePeriod[id] = validTimePeriod; - emit OevShareSet(id, decimals, validTimePeriod, address(oevShare)); + emit OVALSet(id, decimals, validTimePeriod, address(oval)); } /** @@ -48,8 +48,10 @@ contract PythDestinationAdapter is Ownable, IPyth { * @return price the standard pyth price struct. */ function getPriceUnsafe(bytes32 id) public view returns (Price memory) { - if (address(idToOevShare[id]) == address(0)) return basePythProvider.getPriceUnsafe(id); - (int256 answer, uint256 timestamp) = idToOevShare[id].internalLatestData(); + if (address(idToOVAL[id]) == address(0)) { + return basePythProvider.getPriceUnsafe(id); + } + (int256 answer, uint256 timestamp) = idToOVAL[id].internalLatestData(); return Price({ price: SafeCast.toInt64(DecimalLib.convertDecimals(answer, 18, idToDecimal[id])), conf: 0, @@ -66,7 +68,9 @@ contract PythDestinationAdapter is Ownable, IPyth { * @return price the standard pyth price struct. */ function getPrice(bytes32 id) external view returns (Price memory) { - if (address(idToOevShare[id]) == address(0)) return basePythProvider.getPrice(id); + if (address(idToOVAL[id]) == address(0)) { + return basePythProvider.getPrice(id); + } Price memory price = getPriceUnsafe(id); require(_diff(block.timestamp, price.publishTime) <= idToValidTimePeriod[id], "Not within valid window"); return price; diff --git a/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol b/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol index 616d424..06f669a 100644 --- a/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol +++ b/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol @@ -5,24 +5,24 @@ import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol"; import {DecimalLib} from "../lib/DecimalLib.sol"; import {IUniswapAnchoredView} from "../../interfaces/compound/IUniswapAnchoredView.sol"; -import {IOevShare} from "../../interfaces/IOevShare.sol"; +import {IOVAL} from "../../interfaces/IOval.sol"; /** - * @title UniswapAnchoredViewDestinationAdapter contract to expose OEVShare data via the UniswapAnchoredView interface. - * @dev Note that this contract is diffrent to most other destination adapters in that it is not an instance of OEVShare - * via the DiamondRootOevShare contract & inhieretence structure. Rather, this contract has a number of sub OEVShares + * @title UniswapAnchoredViewDestinationAdapter contract to expose OVAL data via the UniswapAnchoredView interface. + * @dev Note that this contract is diffrent to most other destination adapters in that it is not an instance of OVAL + * via the DiamondRootOVAL contract & inhieretence structure. Rather, this contract has a number of sub OVALs * that it uses to return the correct price for each cToken. This is needed as the UniswapAnchoredView interface is a * one to many relationship with cTokens, and so we need to be able to return the correct price for each cToken. */ contract UniswapAnchoredViewDestinationAdapter is Ownable, IUniswapAnchoredView { - mapping(address => address) public cTokenToOevShare; + mapping(address => address) public cTokenToOVAL; mapping(address => uint8) public cTokenToDecimal; IUniswapAnchoredView public immutable uniswapAnchoredViewSource; event BaseSourceSet(address indexed source); - event OevShareSet(address indexed cToken, uint8 indexed decimals, address indexed oevShare); + event OVALSet(address indexed cToken, uint8 indexed decimals, address indexed oval); constructor(IUniswapAnchoredView _source) Ownable() { uniswapAnchoredViewSource = _source; @@ -31,19 +31,19 @@ contract UniswapAnchoredViewDestinationAdapter is Ownable, IUniswapAnchoredView } /** - * @notice Enables the owner to set mapping between cTokens and OEVShares. This is done for each supported cToken. - * @param cToken The cToken to set the OEVShare for. - * @param oevShare The OEVShare to set for the cToken. + * @notice Enables the owner to set mapping between cTokens and OVALs. This is done for each supported cToken. + * @param cToken The cToken to set the OVAL for. + * @param oval The OVAL to set for the cToken. */ - function setOevShare(address cToken, address oevShare) public onlyOwner { - cTokenToOevShare[cToken] = oevShare; + function setOVAL(address cToken, address oval) public onlyOwner { + cTokenToOVAL[cToken] = oval; IUniswapAnchoredView.TokenConfig memory tokenConfig = uniswapAnchoredViewSource.getTokenConfigByCToken(cToken); // Price feed in UniswapAnchoredView is scaled to (36 - underlying decimals). uint8 decimals = 36 - DecimalLib.deriveDecimals(tokenConfig.baseUnit); cTokenToDecimal[cToken] = decimals; - emit OevShareSet(cToken, decimals, oevShare); + emit OVALSet(cToken, decimals, oval); } /** @@ -54,10 +54,10 @@ contract UniswapAnchoredViewDestinationAdapter is Ownable, IUniswapAnchoredView * @return The price of the underlying asset of the cToken. */ function getUnderlyingPrice(address cToken) external view returns (uint256) { - if (cTokenToOevShare[cToken] == address(0)) { + if (cTokenToOVAL[cToken] == address(0)) { return uniswapAnchoredViewSource.getUnderlyingPrice(cToken); } - (int256 answer,) = IOevShare(cTokenToOevShare[cToken]).internalLatestData(); + (int256 answer,) = IOVAL(cTokenToOVAL[cToken]).internalLatestData(); return DecimalLib.convertDecimals(uint256(answer), 18, cTokenToDecimal[cToken]); } diff --git a/src/adapters/source-adapters/ChainlinkSourceAdapter.sol b/src/adapters/source-adapters/ChainlinkSourceAdapter.sol index 0892188..00f4dcd 100644 --- a/src/adapters/source-adapters/ChainlinkSourceAdapter.sol +++ b/src/adapters/source-adapters/ChainlinkSourceAdapter.sol @@ -3,14 +3,14 @@ pragma solidity 0.8.17; import {DecimalLib} from "../lib/DecimalLib.sol"; import {IAggregatorV3Source} from "../../interfaces/chainlink/IAggregatorV3Source.sol"; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** - * @title ChainlinkSourceAdapter contract to read data from Chainlink aggregator and standardize it for the OEV. + * @title ChainlinkSourceAdapter contract to read data from Chainlink aggregator and standardize it for OVAL. * @dev Can fetch information from Chainlink source at a desired timestamp for historic lookups. */ -abstract contract ChainlinkSourceAdapter is DiamondRootOevShare { +abstract contract ChainlinkSourceAdapter is DiamondRootOVAL { IAggregatorV3Source public immutable CHAINLINK_SOURCE; uint8 private immutable SOURCE_DECIMALS; diff --git a/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol b/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol index 25ae12f..4c09e13 100644 --- a/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol +++ b/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol @@ -6,7 +6,7 @@ import {IMedian} from "../../interfaces/chronicle/IMedian.sol"; import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; /** - * @title ChronicleMedianSourceAdapter contract to read data from Chronicle and standardize it for the OEV. + * @title ChronicleMedianSourceAdapter contract to read data from Chronicle and standardize it for OVAL. */ abstract contract ChronicleMedianSourceAdapter is SnapshotSource { diff --git a/src/adapters/source-adapters/OSMSourceAdapter.sol b/src/adapters/source-adapters/OSMSourceAdapter.sol index 36204c1..077ebad 100644 --- a/src/adapters/source-adapters/OSMSourceAdapter.sol +++ b/src/adapters/source-adapters/OSMSourceAdapter.sol @@ -5,7 +5,7 @@ import {SnapshotSource} from "./SnapshotSource.sol"; import {IOSM} from "../../interfaces/makerdao/IOSM.sol"; /** - * @title OSMSourceAdapter contract to read data from MakerDAO OSM and standardize it for the OEV. + * @title OSMSourceAdapter contract to read data from MakerDAO OSM and standardize it for OVAL. */ abstract contract OSMSourceAdapter is SnapshotSource { diff --git a/src/adapters/source-adapters/PythSourceAdapter.sol b/src/adapters/source-adapters/PythSourceAdapter.sol index 8e31296..74cc1d8 100644 --- a/src/adapters/source-adapters/PythSourceAdapter.sol +++ b/src/adapters/source-adapters/PythSourceAdapter.sol @@ -6,7 +6,7 @@ import {SnapshotSource} from "./SnapshotSource.sol"; import {DecimalLib} from "../lib/DecimalLib.sol"; /** - * @title PythSourceAdapter contract to read data from Pyth and standardize it for the OEV. + * @title PythSourceAdapter contract to read data from Pyth and standardize it for OVAL. */ abstract contract PythSourceAdapter is SnapshotSource { diff --git a/src/adapters/source-adapters/SnapshotSource.sol b/src/adapters/source-adapters/SnapshotSource.sol index 607ad4c..b642fe3 100644 --- a/src/adapters/source-adapters/SnapshotSource.sol +++ b/src/adapters/source-adapters/SnapshotSource.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {DiamondRootOevShare} from "../../DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../DiamondRootOval.sol"; /** * @title SnapshotSource contract to be used in conjunction with a source adapter that needs to snapshot historic data. */ -abstract contract SnapshotSource is DiamondRootOevShare { +abstract contract SnapshotSource is DiamondRootOVAL { // Snapshot records the historical answer at a specific timestamp. struct Snapshot { int256 answer; diff --git a/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol b/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol index 7676506..5a4343f 100644 --- a/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol +++ b/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol @@ -8,7 +8,7 @@ import {IUniswapAnchoredView} from "../../interfaces/compound/IUniswapAnchoredVi import {IValidatorProxy} from "../../interfaces/compound/IValidatorProxy.sol"; /** - * @title UniswapAnchoredViewSourceAdapter contract to read data from UniswapAnchoredView and standardize it for the OEV. + * @title UniswapAnchoredViewSourceAdapter contract to read data from UniswapAnchoredView and standardize it for OVAL. * */ diff --git a/src/controllers/BaseController.sol b/src/controllers/BaseController.sol index e8509dc..fce73ee 100644 --- a/src/controllers/BaseController.sol +++ b/src/controllers/BaseController.sol @@ -2,14 +2,14 @@ pragma solidity 0.8.17; import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol"; -import {OevShare} from "../OevShare.sol"; +import {OVAL} from "../Oval.sol"; /** - * @title BaseController providing the simplest possible controller logic to govern who can unlock the OEVShare. - * @dev Custom Controllers can be created to provide more granular control over who can unlock the OEVShare. + * @title BaseController providing the simplest possible controller logic to govern who can unlock the OVAL. + * @dev Custom Controllers can be created to provide more granular control over who can unlock the OVAL. */ -abstract contract BaseController is Ownable, OevShare { +abstract contract BaseController is Ownable, OVAL { // these don't need to be public since they can be accessed via the accessor functions below. uint256 private lockWindow_ = 60; // The lockWindow in seconds. uint256 private maxTraversal_ = 10; // The maximum number of rounds to traverse when looking for historical data. @@ -17,7 +17,7 @@ abstract contract BaseController is Ownable, OevShare { mapping(address => bool) public unlockers; /** - * @notice Enables the owner to set the unlocker status of an address. Once set, the address can unlock the OEVShare + * @notice Enables the owner to set the unlocker status of an address. Once set, the address can unlock the OVAL * and by calling unlockLatestValue as part of an MEV-share auction. * @param unlocker The address to set the unlocker status of. * @param allowed The unlocker status to set. @@ -29,11 +29,11 @@ abstract contract BaseController is Ownable, OevShare { } /** - * @notice Returns true if the caller is allowed to unlock the OEVShare. + * @notice Returns true if the caller is allowed to unlock the OVAL. * @dev This implementation simply checks if the caller is in the unlockers mapping. Custom Controllers can override - * this function to provide more granular control over who can unlock the OEVShare. + * this function to provide more granular control over who can unlock the OVAL. * @param caller The address to check. - * @param _lastUnlockTime The timestamp of the latest unlock to the OEVShare. Might be useful in verification. + * @param _lastUnlockTime The timestamp of the latest unlock to the OVAL. Might be useful in verification. */ function canUnlock(address caller, uint256 _lastUnlockTime) public view override returns (bool) { return unlockers[caller]; @@ -41,7 +41,7 @@ abstract contract BaseController is Ownable, OevShare { /** * @notice Enables the owner to set the lockWindow. - * @dev If changing the lockWindow would cause OEVShare to return different data the permissioned actor must first + * @dev If changing the lockWindow would cause OVAL to return different data the permissioned actor must first * call unlockLatestValue through flashbots via eth_sendPrivateTransaction. * @param newLockWindow The lockWindow to set. */ @@ -50,7 +50,7 @@ abstract contract BaseController is Ownable, OevShare { lockWindow_ = newLockWindow; - // Compare OEVShare results so that change in lock window does not change returned data. + // Compare OVAL results so that change in lock window does not change returned data. (int256 newAnswer, uint256 newTimestamp) = internalLatestData(); require(currentAnswer == newAnswer && currentTimestamp == newTimestamp, "Must unlock first"); diff --git a/src/controllers/ImmutableController.sol b/src/controllers/ImmutableController.sol index d106c09..a97d1f2 100644 --- a/src/controllers/ImmutableController.sol +++ b/src/controllers/ImmutableController.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {OevShare} from "../OevShare.sol"; +import {OVAL} from "../Oval.sol"; /** * @title ImmutableController providing an immutable controller. @@ -11,7 +11,7 @@ import {OevShare} from "../OevShare.sol"; * oracle users). */ -abstract contract ImmutableController is OevShare { +abstract contract ImmutableController is OVAL { uint256 private immutable LOCK_WINDOW; // The lockWindow in seconds. uint256 private immutable MAX_TRAVERSAL; // The maximum number of rounds to traverse when looking for historical data. @@ -31,11 +31,11 @@ abstract contract ImmutableController is OevShare { } /** - * @notice Returns true if the caller is allowed to unlock the OEVShare. + * @notice Returns true if the caller is allowed to unlock the OVAL. * @dev This implementation simply checks if the caller is in the unlockers mapping. Custom Controllers can override - * this function to provide more granular control over who can unlock the OEVShare. + * this function to provide more granular control over who can unlock the OVAL. * @param caller The address to check. - * @param _lastUnlockTime The timestamp of the latest unlock to the OEVShare. Might be useful in verification. + * @param _lastUnlockTime The timestamp of the latest unlock to the OVAL. Might be useful in verification. */ function canUnlock(address caller, uint256 _lastUnlockTime) public view override returns (bool) { return unlockers[caller]; diff --git a/src/interfaces/IOevShare.sol b/src/interfaces/IOval.sol similarity index 90% rename from src/interfaces/IOevShare.sol rename to src/interfaces/IOval.sol index 1d85861..6adc038 100644 --- a/src/interfaces/IOevShare.sol +++ b/src/interfaces/IOval.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -interface IOevShare { +interface IOVAL { event LatestValueUnlocked(uint256 indexed timestamp); function internalLatestData() external view returns (int256 answer, uint256 timestamp); diff --git a/test/fork/aave/AaveV2.Liquidation.sol b/test/fork/aave/AaveV2.Liquidation.sol index 9c03d43..c272fed 100644 --- a/test/fork/aave/AaveV2.Liquidation.sol +++ b/test/fork/aave/AaveV2.Liquidation.sol @@ -17,7 +17,7 @@ interface Usdc is IERC20 { function mint(address _to, uint256 _amount) external returns (bool); } -contract TestedOevShare is BaseController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { +contract TestedOVAL is BaseController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { constructor(IAggregatorV3Source source, uint8 decimals) ChainlinkSourceAdapter(source) BaseController() @@ -43,7 +43,7 @@ contract AaveV2LiquidationTest is CommonTest { // The oracle update that creates the liquidation opportunity is the update of the SUSD price. IAggregatorV3Source sourceChainlinkOracle; - TestedOevShare oevShare; + TestedOVAL oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -76,55 +76,55 @@ contract AaveV2LiquidationTest is CommonTest { function testCanReplaceSourceAndExecuteLiquidation() public { seedLiquidator(); - createOevShareAndUnlock(); - setOevShareAsAaveSource(); + createOVALAndUnlock(); + setOVALAsAaveSource(); updateChainlinkToLatestValue(); - // Even though the chainlink oracle is up to date, the OEVShare is not. This means an attempted liquidation - // will fail because the OEVShare price is stale. + // Even though the chainlink oracle is up to date, the OVAL is not. This means an attempted liquidation + // will fail because the OVAL price is stale. (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(oevShare.latestAnswer() != latestAnswer, "1"); - assertTrue(oevShare.latestTimestamp() != latestTimestamp, "2"); + assertTrue(oval.latestAnswer() != latestAnswer, "1"); + assertTrue(oval.latestTimestamp() != latestTimestamp, "2"); vm.prank(liquidator); vm.expectRevert(bytes("42")); // 42 corresponds with position health being above 1. lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); - //Now, unlock the OEVShare and show that the liquidation can be executed. + //Now, unlock the OVAL and show that the liquidation can be executed. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); (, int256 latestAnswerTwo,, uint256 latestTimestampTwo,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(oevShare.latestAnswer() == latestAnswerTwo); - assertTrue(oevShare.latestTimestamp() == latestTimestampTwo); + assertTrue(oval.latestAnswer() == latestAnswerTwo); + assertTrue(oval.latestTimestamp() == latestTimestampTwo); vm.prank(liquidator); lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); (,,,,, uint256 healthFactorAfter) = lendingPool.getUserAccountData(user); assertTrue(healthFactorAfter > 1e18); // Health factor should be greater than 1 after liquidation. } - function testOevShareGracefullyFallsBackToSourceIfNoUnlockApplied() public { + function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { seedLiquidator(); - createOevShareAndUnlock(); - setOevShareAsAaveSource(); + createOVALAndUnlock(); + setOVALAsAaveSource(); updateChainlinkToLatestValue(); - // Even though the chainlink oracle is up to date, the OEVShare is not. This means an attempted liquidation - // will fail because the OEVShare price is stale. + // Even though the chainlink oracle is up to date, the OVAL is not. This means an attempted liquidation + // will fail because the OVAL price is stale. vm.prank(liquidator); vm.expectRevert(bytes("42")); // 42 corresponds with position health being above 1. lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); - // To show that we can gracefully fall back to the source oracle, we will not unlock the OEVShare and - // rather advance time past the lock window. This will cause the OEVShare to fall back to the source - // oracle and the liquidation will succeed without the OEVShare being unlocked. - vm.warp(block.timestamp + oevShare.lockWindow() + 1); + // To show that we can gracefully fall back to the source oracle, we will not unlock the OVAL and + // rather advance time past the lock window. This will cause the OVAL to fall back to the source + // oracle and the liquidation will succeed without the OVAL being unlocked. + vm.warp(block.timestamp + oval.lockWindow() + 1); // We should see the accessors return the same values, even though the internal values are different. (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(oevShare.latestAnswer() == latestAnswer); - assertTrue(oevShare.latestTimestamp() == latestTimestamp); + assertTrue(oval.latestAnswer() == latestAnswer); + assertTrue(oval.latestTimestamp() == latestTimestamp); - // Now, run the liquidation. It should succeed without the OEVShare being unlocked due to the fallback. + // Now, run the liquidation. It should succeed without the OVAL being unlocked due to the fallback. vm.prank(liquidator); lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); (,,,,, uint256 healthFactorAfter) = lendingPool.getUserAccountData(user); @@ -142,36 +142,36 @@ contract AaveV2LiquidationTest is CommonTest { usdcDebtAsset.approve(address(lendingPool), amountToMint); } - function createOevShareAndUnlock() public { - oevShare = new TestedOevShare(sourceChainlinkOracle, 18); - oevShare.setUnlocker(permissionedUnlocker, true); - // pull the latest price into the OEVShare and check it matches with the source oracle. + function createOVALAndUnlock() public { + oval = new TestedOVAL(sourceChainlinkOracle, 18); + oval.setUnlocker(permissionedUnlocker, true); + // pull the latest price into the OVAL and check it matches with the source oracle. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(latestAnswer == oevShare.latestAnswer()); - assertTrue(latestTimestamp == oevShare.latestTimestamp()); + assertTrue(latestAnswer == oval.latestAnswer()); + assertTrue(latestTimestamp == oval.latestTimestamp()); } - function setOevShareAsAaveSource() public { - // Set the OEVShare as the source oracle for the SUSD asset for Aave. + function setOVALAsAaveSource() public { + // Set the OVAL as the source oracle for the SUSD asset for Aave. address[] memory assets = new address[](1); assets[0] = address(susdDebtAsset); address[] memory sources = new address[](1); - sources[0] = address(oevShare); + sources[0] = address(oval); vm.prank(aaveOracle.owner()); // Prank AaveOracle Owner. aaveOracle.setAssetSources(assets, sources); } function updateChainlinkToLatestValue() public { - // Apply the chainlink update within chainlink. This wont affect the OEVShare price until it is unlocked. + // Apply the chainlink update within chainlink. This wont affect the OVAL price until it is unlocked. (, int256 answerBefore,, uint256 timestampBefore,) = sourceChainlinkOracle.latestRoundData(); vm.rollFork(postOracleUpdateTx); (, int256 answerAfter,, uint256 timestampAfter,) = sourceChainlinkOracle.latestRoundData(); - // Values have changed in chainlink but is stale within OEVShare. + // Values have changed in chainlink but is stale within OVAL. assertTrue(answerBefore != answerAfter && timestampBefore != timestampAfter); - assertTrue(oevShare.latestAnswer() == answerBefore && oevShare.latestTimestamp() == timestampBefore); - assertTrue(oevShare.latestAnswer() != answerAfter && oevShare.latestTimestamp() != timestampAfter); + assertTrue(oval.latestAnswer() == answerBefore && oval.latestTimestamp() == timestampBefore); + assertTrue(oval.latestAnswer() != answerAfter && oval.latestTimestamp() != timestampAfter); } } diff --git a/test/fork/aave/AaveV3.Liquidation.sol b/test/fork/aave/AaveV3.Liquidation.sol index a07b182..7a3d4c6 100644 --- a/test/fork/aave/AaveV3.Liquidation.sol +++ b/test/fork/aave/AaveV3.Liquidation.sol @@ -17,7 +17,7 @@ interface Usdc is IERC20 { function mint(address _to, uint256 _amount) external returns (bool); } -contract TestedOevShare is BaseController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { +contract TestedOVAL is BaseController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { constructor(IAggregatorV3Source source, uint8 decimals) ChainlinkSourceAdapter(source) BaseController() @@ -41,7 +41,7 @@ contract Aave3LiquidationTest is CommonTest { bytes32 postOracleUpdateTx = 0x33ada9fb50abfbf29b59647328bd5fff5121ec04ec43a64f1540de0c898dfd6f; IAggregatorV3Source sourceChainlinkOracle; - TestedOevShare oevShare; + TestedOVAL oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -71,23 +71,23 @@ contract Aave3LiquidationTest is CommonTest { function testCanReplaceSourceAndExecuteLiquidation() public { seedLiquidator(); - createOevShareAndUnlock(); - setOevShareAsAaveSource(); + createOVALAndUnlock(); + setOVALAsAaveSource(); updateChainlinkToLatestValue(); - // Even though the chainlink oracle is up to date, the OEVShare is not. This means an attempted liquidation - // will fail because the OEVShare price is stale. + // Even though the chainlink oracle is up to date, the OVAL is not. This means an attempted liquidation + // will fail because the OVAL price is stale. vm.prank(liquidator); vm.expectRevert(bytes("45")); // 45 corresponds with position health being above 1. lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); - //Now, unlock the OEVShare and show that the liquidation can be executed. + //Now, unlock the OVAL and show that the liquidation can be executed. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(oevShare.latestAnswer() == latestAnswer); - assertTrue(oevShare.latestTimestamp() == latestTimestamp); - assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) == uint256(oevShare.latestAnswer())); + assertTrue(oval.latestAnswer() == latestAnswer); + assertTrue(oval.latestTimestamp() == latestTimestamp); + assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) == uint256(oval.latestAnswer())); assertFalse(isPositionHealthy()); // Post update but pre-liquidation position should be underwater. vm.prank(liquidator); // Run the liquidation from the liquidator. @@ -95,30 +95,30 @@ contract Aave3LiquidationTest is CommonTest { assertTrue(isPositionHealthy()); // Post liquidation position should be healthy again. } - function testOevShareGracefullyFallsBackToSourceIfNoUnlockApplied() public { + function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { seedLiquidator(); - createOevShareAndUnlock(); - setOevShareAsAaveSource(); + createOVALAndUnlock(); + setOVALAsAaveSource(); updateChainlinkToLatestValue(); - // Even though the chainlink oracle is up to date, the OEVShare is not. This means an attempted liquidation - // will fail because the OEVShare price is stale. + // Even though the chainlink oracle is up to date, the OVAL is not. This means an attempted liquidation + // will fail because the OVAL price is stale. vm.prank(liquidator); vm.expectRevert(bytes("45")); // 45 corresponds with position health being above 1. lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); - // To show that we can gracefully fall back to the source oracle, we will not unlock the OEVShare and - // rather advance time past the lock window. This will cause the OEVShare to fall back to the source - // oracle and the liquidation will succeed without the OEVShare being unlocked. - vm.warp(block.timestamp + oevShare.lockWindow() + 1); + // To show that we can gracefully fall back to the source oracle, we will not unlock the OVAL and + // rather advance time past the lock window. This will cause the OVAL to fall back to the source + // oracle and the liquidation will succeed without the OVAL being unlocked. + vm.warp(block.timestamp + oval.lockWindow() + 1); // We should see the accessors return the same values, even though the internal values are different. (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(oevShare.latestAnswer() == latestAnswer); - assertTrue(oevShare.latestTimestamp() == latestTimestamp); + assertTrue(oval.latestAnswer() == latestAnswer); + assertTrue(oval.latestTimestamp() == latestTimestamp); assertFalse(isPositionHealthy()); // Post update but pre-liquidation position should be underwater. - // Now, run the liquidation. It should succeed without the OEVShare being unlocked due to the fallback. + // Now, run the liquidation. It should succeed without the OVAL being unlocked due to the fallback. vm.prank(liquidator); lendingPool.liquidationCall(address(collateralAsset), address(usdcDebtAsset), user, type(uint256).max, false); assertTrue(isPositionHealthy()); // Post liquidation position should be healthy again. @@ -135,40 +135,40 @@ contract Aave3LiquidationTest is CommonTest { usdcDebtAsset.approve(address(lendingPool), amountToMint); } - function createOevShareAndUnlock() public { - oevShare = new TestedOevShare(sourceChainlinkOracle,8); - oevShare.setUnlocker(permissionedUnlocker, true); - // pull the latest price into the OEVShare and check it matches with the source oracle. + function createOVALAndUnlock() public { + oval = new TestedOVAL(sourceChainlinkOracle, 8); + oval.setUnlocker(permissionedUnlocker, true); + // pull the latest price into the OVAL and check it matches with the source oracle. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(latestAnswer == oevShare.latestAnswer()); - assertTrue(latestTimestamp == oevShare.latestTimestamp()); + assertTrue(latestAnswer == oval.latestAnswer()); + assertTrue(latestTimestamp == oval.latestTimestamp()); } - function setOevShareAsAaveSource() public { - // Set the OEVShare as the source oracle for the WETH asset for Aave. + function setOVALAsAaveSource() public { + // Set the OVAL as the source oracle for the WETH asset for Aave. address[] memory assets = new address[](1); assets[0] = address(collateralAsset); address[] memory sources = new address[](1); - sources[0] = address(oevShare); + sources[0] = address(oval); vm.prank(0xEE56e2B3D491590B5b31738cC34d5232F378a8D5); // Prank ACLAdmin. aaveOracle.setAssetSources(assets, sources); } function updateChainlinkToLatestValue() public { - // Apply the chainlink update within chainlink. This wont affect the OEVShare price until it is unlocked. + // Apply the chainlink update within chainlink. This wont affect the OVAL price until it is unlocked. (, int256 answerBefore,, uint256 timestampBefore,) = sourceChainlinkOracle.latestRoundData(); vm.rollFork(postOracleUpdateTx); (, int256 answerAfter,, uint256 timestampAfter,) = sourceChainlinkOracle.latestRoundData(); - // Values have changed in chainlink but is stale within OEVShare. + // Values have changed in chainlink but is stale within OVAL. assertTrue(answerBefore != answerAfter && timestampBefore != timestampAfter); - assertTrue(oevShare.latestAnswer() == answerBefore && oevShare.latestTimestamp() == timestampBefore); - assertTrue(oevShare.latestAnswer() != answerAfter && oevShare.latestTimestamp() != timestampAfter); - // Aave oracle should match the oevShare, not the source oracle. + assertTrue(oval.latestAnswer() == answerBefore && oval.latestTimestamp() == timestampBefore); + assertTrue(oval.latestAnswer() != answerAfter && oval.latestTimestamp() != timestampAfter); + // Aave oracle should match the OVAL, not the source oracle. (, int256 latestAnswer,,,) = sourceChainlinkOracle.latestRoundData(); - assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) == uint256(oevShare.latestAnswer())); + assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) == uint256(oval.latestAnswer())); assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) != uint256(latestAnswer)); } diff --git a/test/fork/adapters/PythSourceAdapter.sol b/test/fork/adapters/PythSourceAdapter.sol index d7bf9a0..23b660c 100644 --- a/test/fork/adapters/PythSourceAdapter.sol +++ b/test/fork/adapters/PythSourceAdapter.sol @@ -126,9 +126,7 @@ contract PythSourceAdapterTest is CommonTest { function _snapshotOnUpdateBlocks() internal returns (int256[] memory, uint256[] memory) { int256[] memory snapshotAnswers = new int256[](updateBlocks.length); - uint256[] memory snapshotTimestamps = new uint256[]( - updateBlocks.length - ); + uint256[] memory snapshotTimestamps = new uint256[](updateBlocks.length); // Fork forward with persistent source adapter and snapshot data at each update block. vm.makePersistent(address(sourceAdapter)); diff --git a/test/fork/adapters/UnionSourceAdapter.sol b/test/fork/adapters/UnionSourceAdapter.sol index 7e94da9..0d75b7b 100644 --- a/test/fork/adapters/UnionSourceAdapter.sol +++ b/test/fork/adapters/UnionSourceAdapter.sol @@ -12,9 +12,13 @@ contract TestedSourceAdapter is UnionSourceAdapter { constructor(IAggregatorV3Source chainlink, IMedian chronicle, IPyth pyth, bytes32 pythPriceId) UnionSourceAdapter(chainlink, chronicle, pyth, pythPriceId) {} + function internalLatestData() public view override returns (int256, uint256) {} + function canUnlock(address caller, uint256 cachedLatestTimestamp) public view virtual override returns (bool) {} + function lockWindow() public view virtual override returns (uint256) {} + function maxTraversal() public view virtual override returns (uint256) {} } @@ -51,7 +55,7 @@ contract UnionSourceAdapterTest is CommonTest { } function testGetLatestSourceDataChainlink() public { - vm.createSelectFork("mainnet", targetChainlinkBlock); + vm.createSelectFork("mainnet", targetChainlinkBlock + 1); _whitelistOnChronicle(); // Latest answer should be the newest of the three sources. At this known block number chainlink was the newest. @@ -102,8 +106,7 @@ contract UnionSourceAdapterTest is CommonTest { } function testLookbackChainlink() public { - // Fork to a block where chainlink was the newest. - vm.createSelectFork("mainnet", targetChainlinkBlock); + vm.createSelectFork("mainnet", targetChainlinkBlock + 1); uint256 targetTimestamp = block.timestamp; _whitelistOnChronicle(); @@ -255,8 +258,11 @@ contract UnionSourceAdapterTest is CommonTest { } function _convertDecimalsWithExponent(int256 answer, int32 expo) internal pure returns (int256) { - if (expo <= 0) return DecimalLib.convertDecimals(answer, uint8(uint32(-expo)), 18); - else return DecimalLib.convertDecimals(answer, 0, 18 + uint8(uint32(expo))); + if (expo <= 0) { + return DecimalLib.convertDecimals(answer, uint8(uint32(-expo)), 18); + } else { + return DecimalLib.convertDecimals(answer, 0, 18 + uint8(uint32(expo))); + } } function _whitelistOnChronicle() internal { diff --git a/test/fork/compound/CompoundV2.Liquidation.sol b/test/fork/compound/CompoundV2.Liquidation.sol index ec9f78a..a648eef 100644 --- a/test/fork/compound/CompoundV2.Liquidation.sol +++ b/test/fork/compound/CompoundV2.Liquidation.sol @@ -24,7 +24,7 @@ interface Usdc is IERC20 { // Juicy liquidation: https://etherscan.io/tx/0xb955a078b9b2a73e111033a3e77142b5768f5729285279d56eff641e43060555 -contract TestedOevShare is BaseController, UniswapAnchoredViewSourceAdapter, BaseDestinationAdapter { +contract TestedOVAL is BaseController, UniswapAnchoredViewSourceAdapter, BaseDestinationAdapter { constructor(IUniswapAnchoredView source, address cToken) UniswapAnchoredViewSourceAdapter(source, cToken) BaseController() @@ -53,7 +53,7 @@ contract CompoundV2LiquidationTest is CommonTest { IAccessControlledAggregatorV3 sourceChainlinkOracle; UniswapAnchoredViewDestinationAdapter DestinationAdapter; UniswapAnchoredViewSourceAdapter sourceAdapter; - TestedOevShare oevShare; + TestedOVAL oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -81,37 +81,37 @@ contract CompoundV2LiquidationTest is CommonTest { } function testCanReplaceSourceAndExecuteLiquidation() public { - createOevShareAndUnlock(); - setOevShareAsCompoundSource(); + createOVALAndUnlock(); + setOVALAsCompoundSource(); updateChainlinkToLatestValue(); // insure config is correct assertTrue(IComptroller(cUSDC.comptroller()).oracle() == address(DestinationAdapter)); vm.prank(sourceChainlinkOracle.owner()); - sourceChainlinkOracle.addAccess(address(oevShare)); + sourceChainlinkOracle.addAccess(address(oval)); // Fetch the current borrowed balance. uint256 borrowBalance = cUSDC.borrowBalanceCurrent(borrower); uint256 liquidatbleAmount = borrowBalance / 2; // 50% liquidation threshold is the max in Compound. - // At this point the OEVShare has a stale price in it. Initiating a liquidation should be a no op. Source oracle - // should have a different price to OEVShare. - uint256 oevPriceBefore = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); + // At this point the OVAL has a stale price in it. Initiating a liquidation should be a no op. Source oracle + // should have a different price to OVAL. + uint256 ovalPriceBefore = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); uint256 sourcePriceBefore = uint256(compoundOracle.getUnderlyingPrice(address(cETH))); - assertTrue(oevPriceBefore != sourcePriceBefore); + assertTrue(ovalPriceBefore != sourcePriceBefore); seedLiquidator(); vm.prank(liquidator); cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); assertTrue(cUSDC.borrowBalanceCurrent(borrower) == borrowBalance); - // Unlock the OEVShare then initiate the liquidation. This time, we should be able to liquidate as per usual. + // Unlock the OVAL then initiate the liquidation. This time, we should be able to liquidate as per usual. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); - uint256 oevPriceAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); - assertTrue(oevPriceAfter < oevPriceBefore); // Price has changed in OEVShare due to calling unlockLatestValue + uint256 ovalPriceAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); + assertTrue(ovalPriceAfter < ovalPriceBefore); // Price has changed in OVAL due to calling unlockLatestValue vm.prank(liquidator); cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); @@ -120,28 +120,28 @@ contract CompoundV2LiquidationTest is CommonTest { assertTrue(cETH.balanceOf(liquidator) > 0); // Some amount of cETH received from the liquidation } - function testOevShareGracefullyFallsBackToSourceIfNoUnlockApplied() public { - createOevShareAndUnlock(); - setOevShareAsCompoundSource(); + function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { + createOVALAndUnlock(); + setOVALAsCompoundSource(); updateChainlinkToLatestValue(); vm.prank(sourceChainlinkOracle.owner()); - sourceChainlinkOracle.addAccess(address(oevShare)); + sourceChainlinkOracle.addAccess(address(oval)); // Fetch the current borrowed balance. uint256 borrowBalance = cUSDC.borrowBalanceCurrent(borrower); uint256 liquidatbleAmount = borrowBalance / 2; // 50% liquidation threshold is the max in Compound. - // At this point the OEVShare has a stale price in it. Initiating a liquidation should be a no op. + // At this point the OVAL has a stale price in it. Initiating a liquidation should be a no op. seedLiquidator(); vm.prank(liquidator); cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); assertTrue(cUSDC.borrowBalanceCurrent(borrower) == borrowBalance); - // To show that we can gracefully fall back to the source oracle, we will not unlock the OEVShare and - // rather advance time past the lock window. This will cause the OEVShare to fall back to the source - // oracle and the liquidation will succeed without the OEVShare being unlocked. - vm.warp(block.timestamp + oevShare.lockWindow() + 1); + // To show that we can gracefully fall back to the source oracle, we will not unlock the OVAL and + // rather advance time past the lock window. This will cause the OVAL to fall back to the source + // oracle and the liquidation will succeed without the OVAL being unlocked. + vm.warp(block.timestamp + oval.lockWindow() + 1); // We should see the accessors return the same values, even though the internal values are different. assertTrue( @@ -149,7 +149,7 @@ contract CompoundV2LiquidationTest is CommonTest { "2" ); - // Now, run the liquidation. It should succeed without the OEVShare being unlocked due to the fallback. + // Now, run the liquidation. It should succeed without the OVAL being unlocked due to the fallback. vm.prank(liquidator); cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); assertTrue(cUSDC.borrowBalanceCurrent(borrower) < borrowBalance); // Debt should not changed. Liquidation was a no op. @@ -168,45 +168,45 @@ contract CompoundV2LiquidationTest is CommonTest { usdcDebtAsset.approve(address(cUSDC), amountToMint); } - function createOevShareAndUnlock() public { + function createOVALAndUnlock() public { DestinationAdapter = new UniswapAnchoredViewDestinationAdapter(getSetCompoundOracle()); - oevShare = new TestedOevShare(getSetCompoundOracle(),address(cETH)); - DestinationAdapter.setOevShare(address(cETH), address(oevShare)); - assertTrue(DestinationAdapter.cTokenToOevShare(address(cETH)) == address(oevShare)); + oval = new TestedOVAL(getSetCompoundOracle(), address(cETH)); + DestinationAdapter.setOVAL(address(cETH), address(oval)); + assertTrue(DestinationAdapter.cTokenToOVAL(address(cETH)) == address(oval)); assertTrue(DestinationAdapter.cTokenToDecimal(address(cETH)) == 18); // (36 - 18 ETH decimals). - oevShare.setUnlocker(permissionedUnlocker, true); - sourceChainlinkOracle = IAccessControlledAggregatorV3(address(oevShare.aggregator())); + oval.setUnlocker(permissionedUnlocker, true); + sourceChainlinkOracle = IAccessControlledAggregatorV3(address(oval.aggregator())); vm.prank(sourceChainlinkOracle.owner()); - sourceChainlinkOracle.addAccess(address(oevShare)); - // pull the latest price into the OEVShare and check it matches with the source oracle. + sourceChainlinkOracle.addAccess(address(oval)); + // pull the latest price into the OVAL and check it matches with the source oracle. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); assertTrue( getSetCompoundOracle().getUnderlyingPrice(address(cETH)) == compoundOracle.getUnderlyingPrice(address(cETH)) ); } - function setOevShareAsCompoundSource() public { + function setOVALAsCompoundSource() public { vm.prank(comptroller.admin()); comptroller._setPriceOracle(address(DestinationAdapter)); assertTrue(comptroller.oracle() == address(DestinationAdapter)); } function updateChainlinkToLatestValue() public { - // Apply the chainlink update within chainlink. This wont affect the OEVShare price until it is unlocked. - uint256 answerFromOevBefore = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); + // Apply the chainlink update within chainlink. This wont affect the OVAL price until it is unlocked. + uint256 answerFromOvalBefore = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); uint256 answerFromChainlinkBefore = uint256(compoundOracle.getUnderlyingPrice(address(cETH))); vm.rollFork(postOracleUpdateTx); vm.prank(sourceChainlinkOracle.owner()); - sourceChainlinkOracle.addAccess(address(oevShare)); - uint256 answerFromOevAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); + sourceChainlinkOracle.addAccess(address(oval)); + uint256 answerFromOvalAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); uint256 answerFromChainlinkAfter = uint256(compoundOracle.getUnderlyingPrice(address(cETH))); - // Values have changed in chainlink but is stale within OEVShare. + // Values have changed in chainlink but is stale within OVAL. - assertTrue(answerFromOevBefore == answerFromOevAfter); // Price has not changed in OEVShare. + assertTrue(answerFromOvalBefore == answerFromOvalAfter); // Price has not changed in OVAL. assertTrue(answerFromChainlinkBefore != answerFromChainlinkAfter); // Price has changed within Chainlink. - assertTrue(DestinationAdapter.getUnderlyingPrice(address(cETH)) == answerFromOevBefore); // destination adapter has not updated yet and should be the same as the oevShare. + assertTrue(DestinationAdapter.getUnderlyingPrice(address(cETH)) == answerFromOvalBefore); // destination adapter has not updated yet and should be the same as the OVAL. } function getSetCompoundOracle() public view returns (IUniswapAnchoredView) { diff --git a/test/mocks/MockSourceAdapter.sol b/test/mocks/MockSourceAdapter.sol index 0b94e89..2be2011 100644 --- a/test/mocks/MockSourceAdapter.sol +++ b/test/mocks/MockSourceAdapter.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {DiamondRootOevShare} from "../../src/DiamondRootOevShare.sol"; +import {DiamondRootOVAL} from "../../src/DiamondRootOval.sol"; -abstract contract MockSourceAdapter is DiamondRootOevShare { +abstract contract MockSourceAdapter is DiamondRootOVAL { uint8 public sourceDecimals; struct RoundData { diff --git a/test/unit/BaseController.sol b/test/unit/BaseController.sol index ae83c56..d832620 100644 --- a/test/unit/BaseController.sol +++ b/test/unit/BaseController.sol @@ -10,7 +10,7 @@ contract TestBaseController is BaseController, MockSourceAdapter, BaseDestinatio constructor(uint8 decimals) MockSourceAdapter(decimals) BaseController() BaseDestinationAdapter() {} } -contract OevShareUnlockLatestValue is CommonTest { +contract OVALUnlockLatestValue is CommonTest { uint256 lastUnlockTime = 1690000000; TestBaseController baseController; diff --git a/test/unit/ImmutableController.sol b/test/unit/ImmutableController.sol index d283d95..90af875 100644 --- a/test/unit/ImmutableController.sol +++ b/test/unit/ImmutableController.sol @@ -14,7 +14,7 @@ contract TestImmutableController is ImmutableController, MockSourceAdapter, Base {} } -contract OevShareUnlockLatestValue is CommonTest { +contract OVALUnlockLatestValue is CommonTest { uint8 decimals = 8; uint256 lockWindow = 60; uint256 maxTraversal = 10; diff --git a/test/unit/OevShare.ChainlinkDestinationAdapter.sol b/test/unit/Oval.ChainlinkDestinationAdapter.sol similarity index 59% rename from test/unit/OevShare.ChainlinkDestinationAdapter.sol rename to test/unit/Oval.ChainlinkDestinationAdapter.sol index dd5211c..40ea0b2 100644 --- a/test/unit/OevShare.ChainlinkDestinationAdapter.sol +++ b/test/unit/Oval.ChainlinkDestinationAdapter.sol @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {ChainlinkDestinationAdapter} from "../../src/adapters/destination-adapters/ChainlinkDestinationAdapter.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; import {CommonTest} from "../Common.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOevShare is BaseController, MockSourceAdapter, ChainlinkDestinationAdapter { +contract TestOVAL is BaseController, MockSourceAdapter, ChainlinkDestinationAdapter { constructor(uint8 decimals) BaseController() MockSourceAdapter(decimals) ChainlinkDestinationAdapter(decimals) {} } -contract OevShareChainlinkDestinationAdapter is CommonTest { +contract OVALChainlinkDestinationAdapter is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; @@ -23,55 +23,55 @@ contract OevShareChainlinkDestinationAdapter is CommonTest { int256 internalDecimalsToSourceDecimals = 1e10; - TestOevShare oevShare; + TestOVAL oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oevShare = new TestOevShare(sourceOracleDecimals); - oevShare.setUnlocker(permissionedUnlocker, true); + oval = new TestOVAL(sourceOracleDecimals); + oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); - oevShare.publishRoundData(initialPrice, initialTimestamp); + oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOevShareMatchesOevShare() public { - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + function verifyOVALMatchesOVAL() public { + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue( - latestAnswer / internalDecimalsToSourceDecimals == oevShare.latestAnswer() - && latestTimestamp == oevShare.latestTimestamp() + latestAnswer / internalDecimalsToSourceDecimals == oval.latestAnswer() + && latestTimestamp == oval.latestTimestamp() ); } - function syncOevShareWithOevShare() public { - assertTrue(oevShare.canUnlock(permissionedUnlocker, oevShare.latestTimestamp())); + function syncOVALWithOVAL() public { + assertTrue(oval.canUnlock(permissionedUnlocker, oval.latestTimestamp())); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevShareMatchesOevShare(); + oval.unlockLatestValue(); + verifyOVALMatchesOVAL(); } function testUpdatesWithinLockWindow() public { // Publish an update to the mock source adapter. - oevShare.publishRoundData(newAnswer, newTimestamp); + oval.publishRoundData(newAnswer, newTimestamp); - syncOevShareWithOevShare(); - assertTrue(oevShare.lastUnlockTime() == block.timestamp); + syncOVALWithOVAL(); + assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an unlock with no diff in source adapter. uint256 unlockTimestamp = block.timestamp + 1 minutes; vm.warp(unlockTimestamp); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); // Check that the update timestamp was unlocked and that the answer and timestamp are unchanged. - assertTrue(oevShare.lastUnlockTime() == unlockTimestamp); - verifyOevShareMatchesOevShare(); + assertTrue(oval.lastUnlockTime() == unlockTimestamp); + verifyOVALMatchesOVAL(); (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = - oevShare.latestRoundData(); + oval.latestRoundData(); - // Check that oevShare return the correct values scaled to the source oracle decimals. + // Check that OVAL return the correct values scaled to the source oracle decimals. assertTrue(roundId == 1); assertTrue(answer == newAnswer / internalDecimalsToSourceDecimals); assertTrue(startedAt == newTimestamp); diff --git a/test/unit/OevShare.ChronicleMedianDestinationAdapter.sol b/test/unit/Oval.ChronicleMedianDestinationAdapter.sol similarity index 58% rename from test/unit/OevShare.ChronicleMedianDestinationAdapter.sol rename to test/unit/Oval.ChronicleMedianDestinationAdapter.sol index e274180..ecd0592 100644 --- a/test/unit/OevShare.ChronicleMedianDestinationAdapter.sol +++ b/test/unit/Oval.ChronicleMedianDestinationAdapter.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {ChronicleMedianDestinationAdapter} from "../../src/adapters/destination-adapters/ChronicleMedianDestinationAdapter.sol"; @@ -9,7 +9,7 @@ import {BaseController} from "../../src/controllers/BaseController.sol"; import {CommonTest} from "../Common.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOevShare is BaseController, MockSourceAdapter, ChronicleMedianDestinationAdapter { +contract TestOVAL is BaseController, MockSourceAdapter, ChronicleMedianDestinationAdapter { constructor(uint8 decimals, address _sourceAdapter) BaseController() MockSourceAdapter(decimals) @@ -19,7 +19,7 @@ contract TestOevShare is BaseController, MockSourceAdapter, ChronicleMedianDesti function kiss(address) external override {} } -contract OevShareChronicleMedianDestinationAdapter is CommonTest { +contract OVALChronicleMedianDestinationAdapter is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; @@ -28,67 +28,67 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { int256 internalDecimalsToSourceDecimals = 1; - TestOevShare oevShare; + TestOVAL oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oevShare = new TestOevShare(18, address(0)); - oevShare.setUnlocker(permissionedUnlocker, true); + oval = new TestOVAL(18, address(0)); + oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); - oevShare.publishRoundData(initialPrice, initialTimestamp); + oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOevOracleMatchesOevOracle() public { - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + function verifyOvalOracleMatchesOvalOracle() public { + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); - (, bool sourceValid) = oevShare.peek(); + (, bool sourceValid) = oval.peek(); assertTrue(sourceValid); - assertTrue(uint256(latestAnswer) == oevShare.read() && latestTimestamp == oevShare.age()); + assertTrue(uint256(latestAnswer) == oval.read() && latestTimestamp == oval.age()); } - function syncOevOracleWithOevOracle() public { - assertTrue(oevShare.canUnlock(permissionedUnlocker, oevShare.age())); + function syncOvalOracleWithOvalOracle() public { + assertTrue(oval.canUnlock(permissionedUnlocker, oval.age())); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevOracleMatchesOevOracle(); + oval.unlockLatestValue(); + verifyOvalOracleMatchesOvalOracle(); } function testUpdatesWithinLockWindow() public { // Publish an update to the mock source adapter. - oevShare.publishRoundData(newAnswer, newTimestamp); + oval.publishRoundData(newAnswer, newTimestamp); - syncOevOracleWithOevOracle(); - assertTrue(oevShare.lastUnlockTime() == block.timestamp); + syncOvalOracleWithOvalOracle(); + assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an update with no diff in source adapter. uint256 updateTimestamp = block.timestamp + 1 minutes; vm.warp(updateTimestamp); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); // Check that the update timestamp was updated and that the answer and timestamp are unchanged. - assertTrue(oevShare.lastUnlockTime() == updateTimestamp); - verifyOevOracleMatchesOevOracle(); + assertTrue(oval.lastUnlockTime() == updateTimestamp); + verifyOvalOracleMatchesOvalOracle(); } function testInvalidPrice() public { // Publish invalid price to the mock source adapter. vm.warp(newTimestamp); - oevShare.publishRoundData(0, newTimestamp); + oval.publishRoundData(0, newTimestamp); // Unlock the invalid value. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); // Verify that the latest data is invalid. - (, bool sourceValid) = oevShare.peek(); + (, bool sourceValid) = oval.peek(); assertFalse(sourceValid); // Verify that the read reverts. vm.expectRevert(); - oevShare.read(); + oval.read(); } } diff --git a/test/unit/OevShare.OSMDestinationAdapter.sol b/test/unit/Oval.OSMDestinationAdapter.sol similarity index 52% rename from test/unit/OevShare.OSMDestinationAdapter.sol rename to test/unit/Oval.OSMDestinationAdapter.sol index e44a954..7aef721 100644 --- a/test/unit/OevShare.OSMDestinationAdapter.sol +++ b/test/unit/Oval.OSMDestinationAdapter.sol @@ -1,67 +1,67 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {OSMDestinationAdapter} from "../../src/adapters/destination-adapters/OSMDestinationAdapter.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; import {CommonTest} from "../Common.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOevShare is BaseController, MockSourceAdapter, OSMDestinationAdapter { +contract TestOVAL is BaseController, MockSourceAdapter, OSMDestinationAdapter { constructor(uint8 decimals) BaseController() MockSourceAdapter(decimals) OSMDestinationAdapter() {} } -contract OevShareChronicleMedianDestinationAdapter is CommonTest { +contract OVALChronicleMedianDestinationAdapter is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; int256 newAnswer = 1900 * 1e18; uint256 newTimestamp = initialTimestamp + 1; - TestOevShare oevShare; + TestOVAL oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oevShare = new TestOevShare(18); - oevShare.setUnlocker(permissionedUnlocker, true); + oval = new TestOVAL(18); + oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); - oevShare.publishRoundData(initialPrice, initialTimestamp); + oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOevOracleMatchesOevOracle() public { - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + function verifyOvalOracleMatchesOvalOracle() public { + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); - (, bool sourceValid) = oevShare.peek(); + (, bool sourceValid) = oval.peek(); assertTrue(sourceValid); - assertTrue(bytes32(uint256(latestAnswer)) == oevShare.read() && uint64(latestTimestamp) == oevShare.zzz()); + assertTrue(bytes32(uint256(latestAnswer)) == oval.read() && uint64(latestTimestamp) == oval.zzz()); } - function syncOevOracleWithOevOracle() public { - assertTrue(oevShare.canUnlock(permissionedUnlocker, oevShare.zzz())); + function syncOvalOracleWithOvalOracle() public { + assertTrue(oval.canUnlock(permissionedUnlocker, oval.zzz())); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevOracleMatchesOevOracle(); + oval.unlockLatestValue(); + verifyOvalOracleMatchesOvalOracle(); } function testUpdatesWithinLockWindow() public { // Publish an update to the mock source adapter. - oevShare.publishRoundData(newAnswer, newTimestamp); + oval.publishRoundData(newAnswer, newTimestamp); - syncOevOracleWithOevOracle(); - assertTrue(oevShare.lastUnlockTime() == block.timestamp); + syncOvalOracleWithOvalOracle(); + assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an update with no diff in source adapter. uint256 updateTimestamp = block.timestamp + 1 minutes; vm.warp(updateTimestamp); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); // Check that the update timestamp was updated and that the answer and timestamp are unchanged. - assertTrue(oevShare.lastUnlockTime() == updateTimestamp); - verifyOevOracleMatchesOevOracle(); + assertTrue(oval.lastUnlockTime() == updateTimestamp); + verifyOvalOracleMatchesOvalOracle(); } } diff --git a/test/unit/OevShare.PythDestinationAdapter.sol b/test/unit/Oval.PythDestinationAdapter.sol similarity index 64% rename from test/unit/OevShare.PythDestinationAdapter.sol rename to test/unit/Oval.PythDestinationAdapter.sol index e5691ba..00ab8e6 100644 --- a/test/unit/OevShare.PythDestinationAdapter.sol +++ b/test/unit/Oval.PythDestinationAdapter.sol @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {PythDestinationAdapter} from "../../src/adapters/destination-adapters/PythDestinationAdapter.sol"; import {IPyth} from "../../src/interfaces/pyth/IPyth.sol"; -import {IOevShare} from "../../src/interfaces/IOevShare.sol"; +import {IOVAL} from "../../src/interfaces/IOval.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; import {CommonTest} from "../Common.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOevShare is BaseController, MockSourceAdapter, PythDestinationAdapter { +contract TestOVAL is BaseController, MockSourceAdapter, PythDestinationAdapter { constructor(uint8 decimals, IPyth _basePythProvider) BaseController() MockSourceAdapter(decimals) @@ -18,7 +18,7 @@ contract TestOevShare is BaseController, MockSourceAdapter, PythDestinationAdapt {} } -contract OevShareChronicleMedianDestinationAdapter is CommonTest { +contract OVALChronicleMedianDestinationAdapter is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; @@ -29,7 +29,7 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { uint8 testDecimals = 8; uint256 testValidTimePeriod = 3600; - address oevShareAddress = makeAddr("oevShareAddress"); + address OVALAddress = makeAddr("OVALAddress"); address basePythProviderAddress = makeAddr("basePythProviderAddress"); PythDestinationAdapter destinationAdapter; @@ -39,19 +39,17 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { destinationAdapter = new PythDestinationAdapter(IPyth(basePythProviderAddress)); } - function testSetOevShare() public { - destinationAdapter.setOevShare(testId, testDecimals, testValidTimePeriod, IOevShare(oevShareAddress)); - assertEq(address(destinationAdapter.idToOevShare(testId)), address(oevShareAddress)); + function testSetOVAL() public { + destinationAdapter.setOVAL(testId, testDecimals, testValidTimePeriod, IOVAL(OVALAddress)); + assertEq(address(destinationAdapter.idToOVAL(testId)), address(OVALAddress)); assertEq(destinationAdapter.idToDecimal(testId), testDecimals); assertEq(destinationAdapter.idToValidTimePeriod(testId), testValidTimePeriod); } function testGetPriceUnsafe() public { - destinationAdapter.setOevShare(testId, testDecimals, testValidTimePeriod, IOevShare(oevShareAddress)); + destinationAdapter.setOVAL(testId, testDecimals, testValidTimePeriod, IOVAL(OVALAddress)); vm.mockCall( - oevShareAddress, - abi.encodeWithSelector(IOevShare.internalLatestData.selector), - abi.encode(newAnswer, newTimestamp) + OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) ); IPyth.Price memory price = destinationAdapter.getPriceUnsafe(testId); @@ -62,12 +60,10 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { } function testGetPrice() public { - destinationAdapter.setOevShare(testId, testDecimals, testValidTimePeriod, IOevShare(oevShareAddress)); + destinationAdapter.setOVAL(testId, testDecimals, testValidTimePeriod, IOVAL(OVALAddress)); uint256 timestamp = block.timestamp; vm.mockCall( - oevShareAddress, - abi.encodeWithSelector(IOevShare.internalLatestData.selector), - abi.encode(newAnswer, timestamp) + OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, timestamp) ); IPyth.Price memory price = destinationAdapter.getPrice(testId); @@ -78,13 +74,11 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { } function testNotWithinValidWindow() public { - destinationAdapter.setOevShare(testId, testDecimals, testValidTimePeriod, IOevShare(oevShareAddress)); + destinationAdapter.setOVAL(testId, testDecimals, testValidTimePeriod, IOVAL(OVALAddress)); vm.warp(newTimestamp + testValidTimePeriod + 1); // Warp to after the valid time period. vm.mockCall( - oevShareAddress, - abi.encodeWithSelector(IOevShare.internalLatestData.selector), - abi.encode(newAnswer, newTimestamp) + OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) ); vm.expectRevert("Not within valid window"); @@ -92,13 +86,11 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { } function testFutureTimestamp() public { - destinationAdapter.setOevShare(testId, testDecimals, testValidTimePeriod, IOevShare(oevShareAddress)); + destinationAdapter.setOVAL(testId, testDecimals, testValidTimePeriod, IOVAL(OVALAddress)); vm.warp(newTimestamp - 1); // Warp to before publish time. vm.mockCall( - oevShareAddress, - abi.encodeWithSelector(IOevShare.internalLatestData.selector), - abi.encode(newAnswer, newTimestamp) + OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) ); IPyth.Price memory price = destinationAdapter.getPrice(testId); @@ -109,8 +101,8 @@ contract OevShareChronicleMedianDestinationAdapter is CommonTest { } function testUnsupportedIdentifier() public { - // We don't set an OEVShare for testId, so it should return the price from the source. - assert(address(destinationAdapter.idToOevShare(testId)) == address(0)); + // We don't set an OVAL for testId, so it should return the price from the source. + assert(address(destinationAdapter.idToOVAL(testId)) == address(0)); vm.mockCall( basePythProviderAddress, diff --git a/test/unit/OevShare.UniswapAnchoredViewDestinationAdapter.sol b/test/unit/Oval.UniswapAnchoredViewDestinationAdapter.sol similarity index 79% rename from test/unit/OevShare.UniswapAnchoredViewDestinationAdapter.sol rename to test/unit/Oval.UniswapAnchoredViewDestinationAdapter.sol index 52248f6..0be543d 100644 --- a/test/unit/OevShare.UniswapAnchoredViewDestinationAdapter.sol +++ b/test/unit/Oval.UniswapAnchoredViewDestinationAdapter.sol @@ -5,17 +5,17 @@ import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/Ba import {UniswapAnchoredViewDestinationAdapter} from "../../src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol"; import {IUniswapAnchoredView} from "../../src/interfaces/compound/IUniswapAnchoredView.sol"; -import {IOevShare} from "../../src/interfaces/IOevShare.sol"; +import {IOVAL} from "../../src/interfaces/IOval.sol"; import {CommonTest} from "../Common.sol"; -contract OevShareUniswapAnchoredViewDestinationAdapter is CommonTest { +contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { int256 newAnswer = 1900 * 1e18; uint256 newTimestamp = 1690000000; int256 internalDecimalsToSourceDecimals = 1e10; address sourceAddress = makeAddr("sourceAddress"); - address oevShareAddress = makeAddr("oevShareAddress"); + address OVALAddress = makeAddr("OVALAddress"); address cTokenAddress = makeAddr("cTokenAddress"); uint8 underlyingDecimals = 8; @@ -23,12 +23,10 @@ contract OevShareUniswapAnchoredViewDestinationAdapter is CommonTest { function setUp() public { vm.clearMockedCalls(); - destinationAdapter = new UniswapAnchoredViewDestinationAdapter( - IUniswapAnchoredView(sourceAddress) - ); + destinationAdapter = new UniswapAnchoredViewDestinationAdapter(IUniswapAnchoredView(sourceAddress)); } - function testSetOevShare() public { + function testSetOVAL() public { vm.mockCall( sourceAddress, abi.encodeWithSelector(IUniswapAnchoredView.getTokenConfigByCToken.selector, cTokenAddress), @@ -47,9 +45,9 @@ contract OevShareUniswapAnchoredViewDestinationAdapter is CommonTest { }) ) ); - destinationAdapter.setOevShare(cTokenAddress, oevShareAddress); + destinationAdapter.setOVAL(cTokenAddress, OVALAddress); - assertEq(destinationAdapter.cTokenToOevShare(cTokenAddress), oevShareAddress); + assertEq(destinationAdapter.cTokenToOVAL(cTokenAddress), OVALAddress); assertEq(destinationAdapter.cTokenToDecimal(cTokenAddress), 36 - underlyingDecimals); } @@ -72,12 +70,10 @@ contract OevShareUniswapAnchoredViewDestinationAdapter is CommonTest { }) ) ); - destinationAdapter.setOevShare(cTokenAddress, oevShareAddress); + destinationAdapter.setOVAL(cTokenAddress, OVALAddress); vm.mockCall( - oevShareAddress, - abi.encodeWithSelector(IOevShare.internalLatestData.selector), - abi.encode(newAnswer, newTimestamp) + OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) ); uint256 underlyingPrice = destinationAdapter.getUnderlyingPrice(cTokenAddress); @@ -85,8 +81,8 @@ contract OevShareUniswapAnchoredViewDestinationAdapter is CommonTest { } function testUnsupportedCToken() public { - // We don't set an OEVShare for this cToken, so it should return the price from the source. - assert(destinationAdapter.cTokenToOevShare(cTokenAddress) == address(0)); + // We don't set an OVAL for this cToken, so it should return the price from the source. + assert(destinationAdapter.cTokenToOVAL(cTokenAddress) == address(0)); vm.mockCall( sourceAddress, diff --git a/test/unit/OevShare.UnlockLatestValue.sol b/test/unit/Oval.UnlockLatestValue.sol similarity index 57% rename from test/unit/OevShare.UnlockLatestValue.sol rename to test/unit/Oval.UnlockLatestValue.sol index 673fae4..8c20c20 100644 --- a/test/unit/OevShare.UnlockLatestValue.sol +++ b/test/unit/Oval.UnlockLatestValue.sol @@ -3,161 +3,161 @@ pragma solidity 0.8.17; import {CommonTest} from "../Common.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOevShare is BaseController, MockSourceAdapter, BaseDestinationAdapter { +contract TestOVAL is BaseController, MockSourceAdapter, BaseDestinationAdapter { constructor(uint8 decimals) MockSourceAdapter(decimals) BaseController() BaseDestinationAdapter() {} } -contract OevShareUnlockLatestValue is CommonTest { +contract OVALUnlockLatestValue is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; int256 newAnswer = 1900 * 1e18; uint256 newTimestamp = initialTimestamp + 1; - TestOevShare oevShare; + TestOVAL oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oevShare = new TestOevShare(18); - oevShare.setUnlocker(permissionedUnlocker, true); + oval = new TestOVAL(18); + oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); - oevShare.publishRoundData(initialPrice, initialTimestamp); + oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOevShareMatchesOevShare() public { - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); - assertTrue(latestAnswer == oevShare.latestAnswer() && latestTimestamp == oevShare.latestTimestamp()); + function verifyOVALMatchesOVAL() public { + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); + assertTrue(latestAnswer == oval.latestAnswer() && latestTimestamp == oval.latestTimestamp()); } - function syncOevShareWithOevShare() public { - assertTrue(oevShare.canUnlock(permissionedUnlocker, oevShare.latestTimestamp())); + function syncOVALWithOVAL() public { + assertTrue(oval.canUnlock(permissionedUnlocker, oval.latestTimestamp())); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevShareMatchesOevShare(); + oval.unlockLatestValue(); + verifyOVALMatchesOVAL(); } function testUnlockWithNoDiffUpdatesUnlockTimestamp() public { - syncOevShareWithOevShare(); - assertTrue(oevShare.lastUnlockTime() == block.timestamp); + syncOVALWithOVAL(); + assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an unlock with no diff in source adapter. uint256 unlockTimestamp = block.timestamp + 1 minutes; vm.warp(unlockTimestamp); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); // Check that the unlock timestamp was updated and that the answer and timestamp are unchanged. - assertTrue(oevShare.lastUnlockTime() == unlockTimestamp); - verifyOevShareMatchesOevShare(); + assertTrue(oval.lastUnlockTime() == unlockTimestamp); + verifyOVALMatchesOVAL(); } function testUnlockerCanUnlockLatestValue() public { - syncOevShareWithOevShare(); + syncOVALWithOVAL(); - oevShare.publishRoundData(newAnswer, newTimestamp); + oval.publishRoundData(newAnswer, newTimestamp); vm.warp(newTimestamp); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevShareMatchesOevShare(); - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + oval.unlockLatestValue(); + verifyOVALMatchesOVAL(); + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == newAnswer && latestTimestamp == newTimestamp); // Advance time. Add a diff to the source adapter and verify that it is applied. vm.warp(newTimestamp + 2); - oevShare.publishRoundData(newAnswer + 1, newTimestamp + 2); + oval.publishRoundData(newAnswer + 1, newTimestamp + 2); vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevShareMatchesOevShare(); + oval.unlockLatestValue(); + verifyOVALMatchesOVAL(); } function testNonUnlockerCannotUnlockLatestValue() public { - syncOevShareWithOevShare(); + syncOVALWithOVAL(); - oevShare.publishRoundData(newAnswer, newTimestamp); + oval.publishRoundData(newAnswer, newTimestamp); vm.warp(newTimestamp); vm.expectRevert("Controller blocked: canUnlock"); vm.prank(random); - oevShare.unlockLatestValue(); + oval.unlockLatestValue(); - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp); } function testUpdatesWithinLockWindow() public { - syncOevShareWithOevShare(); + syncOVALWithOVAL(); // Advance time to within the lock window and update the source. - uint256 beforeLockWindow = block.timestamp + oevShare.lockWindow() - 1; + uint256 beforeLockWindow = block.timestamp + oval.lockWindow() - 1; vm.warp(beforeLockWindow); - oevShare.publishRoundData(newAnswer, beforeLockWindow); + oval.publishRoundData(newAnswer, beforeLockWindow); // Before updating, initial values from cache would be returned. - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp); // After updating we should return the new values. vm.prank(permissionedUnlocker); - oevShare.unlockLatestValue(); - verifyOevShareMatchesOevShare(); + oval.unlockLatestValue(); + verifyOVALMatchesOVAL(); } function testNoUpdatesPastLockWindow() public { - syncOevShareWithOevShare(); + syncOVALWithOVAL(); uint256 unlockTimestamp = block.timestamp; uint256 beforeOEVLockWindow = unlockTimestamp + 59; // Default lock window is 10 minutes. vm.warp(beforeOEVLockWindow); // Advance before the end of the lock window. - oevShare.publishRoundData(newAnswer, beforeOEVLockWindow); // Update the source. + oval.publishRoundData(newAnswer, beforeOEVLockWindow); // Update the source. // Within original lock window (after OEV unlock), initial values from cache would be returned. - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp, "1"); // Advancing time past the original lock window but before new lock window since source update // should not yet pass through source values. uint256 pastOEVLockWindow = beforeOEVLockWindow + 2; vm.warp(pastOEVLockWindow); - (latestAnswer, latestTimestamp) = oevShare.internalLatestData(); + (latestAnswer, latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp); // Advancing time past the new lock window should pass through source values. uint256 pastSourceLockWindow = beforeOEVLockWindow + 69; vm.warp(pastSourceLockWindow); - verifyOevShareMatchesOevShare(); + verifyOVALMatchesOVAL(); } function testRepeatedUpdates() public { - syncOevShareWithOevShare(); + syncOVALWithOVAL(); // Advance time to within the lock window and update the source. - uint256 beforeLockWindow = block.timestamp + oevShare.lockWindow() - 1; + uint256 beforeLockWindow = block.timestamp + oval.lockWindow() - 1; vm.warp(beforeLockWindow); - oevShare.publishRoundData(newAnswer, beforeLockWindow); + oval.publishRoundData(newAnswer, beforeLockWindow); // Before updating, initial values from cache would be returned. - (int256 latestAnswer, uint256 latestTimestamp) = oevShare.internalLatestData(); + (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp); // Sync and verify updated values. - syncOevShareWithOevShare(); + syncOVALWithOVAL(); // Advance time to within the lock window and update the source. - uint256 nextBeforeLockWindow = block.timestamp + oevShare.lockWindow() - 1; + uint256 nextBeforeLockWindow = block.timestamp + oval.lockWindow() - 1; vm.warp(nextBeforeLockWindow); int256 nextNewAnswer = newAnswer + 1e18; - oevShare.publishRoundData(nextNewAnswer, nextBeforeLockWindow); + oval.publishRoundData(nextNewAnswer, nextBeforeLockWindow); // Within lock window, values from previous update would be returned. - (latestAnswer, latestTimestamp) = oevShare.internalLatestData(); + (latestAnswer, latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == newAnswer && latestTimestamp == beforeLockWindow); } } diff --git a/test/unit/SnapshotSource.SnapshotData.sol b/test/unit/SnapshotSource.SnapshotData.sol index 09b24d6..0f92b0e 100644 --- a/test/unit/SnapshotSource.SnapshotData.sol +++ b/test/unit/SnapshotSource.SnapshotData.sol @@ -3,10 +3,10 @@ pragma solidity 0.8.17; import {CommonTest} from "../Common.sol"; import {MockSnapshotSourceAdapter} from "../mocks/MockSnapshotSourceAdapter.sol"; -import {OevShare} from "../../src/OevShare.sol"; +import {OVAL} from "../../src/Oval.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; -contract TestSnapshotSource is MockSnapshotSourceAdapter, OevShare, BaseController {} +contract TestSnapshotSource is MockSnapshotSourceAdapter, OVAL, BaseController {} contract SnapshotSourceSnapshotDataTest is CommonTest { TestSnapshotSource snapshotSource;