From 63752423c68f3cdec1b221b5b0b3f7f3ebbc5597 Mon Sep 17 00:00:00 2001 From: Pablo Maldonado Date: Tue, 19 Dec 2023 10:14:30 +0000 Subject: [PATCH] feat: rename oval camel case (#1) Signed-off-by: Pablo Maldonado --- README.md | 10 ++-- scripts/README.md | 4 +- scripts/package.json | 2 +- 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 +++++++++---------- src/DiamondRootOval.sol | 12 ++-- src/Oval.sol | 10 ++-- .../BaseDestinationAdapter.sol | 6 +- .../ChainlinkDestinationAdapter.sol | 6 +- .../UniswapAnchoredViewDestinationAdapter.sol | 28 +++++----- .../ChainlinkSourceAdapter.sol | 6 +- .../source-adapters/SnapshotSource.sol | 4 +- .../UniswapAnchoredViewSourceAdapter.sol | 2 +- src/controllers/BaseController.sol | 20 +++---- src/controllers/ImmutableController.sol | 10 ++-- src/interfaces/IOval.sol | 2 +- test/fork/aave/AaveV2.Liquidation.sol | 46 +++++++-------- test/fork/aave/AaveV3.Liquidation.sol | 48 ++++++++-------- test/fork/compound/CompoundV2.Liquidation.sol | 52 ++++++++--------- test/mocks/MockSourceAdapter.sol | 4 +- test/unit/BaseController.sol | 2 +- test/unit/ImmutableController.sol | 2 +- .../unit/Oval.ChainlinkDestinationAdapter.sol | 22 ++++---- ....UniswapAnchoredViewDestinationAdapter.sol | 20 +++---- test/unit/Oval.UnlockLatestValue.sol | 40 ++++++------- test/unit/SnapshotSource.SnapshotData.sol | 4 +- 30 files changed, 321 insertions(+), 321 deletions(-) diff --git a/README.md b/README.md index 37c2166..870a7a8 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@


-

OVAL

+

Oval


-

OVAL enables the redirection and capture of Oracle Extractable Value.

+

Oval enables the redirection and capture of Oracle Extractable Value.


-OVAL is designed as an enhancement over the standard oracles like Chainlink, wrapping around them to introduce a novel functionality: the unlocking of price updates. This unique feature allows OVAL-enabled projects to capture _Oracle Extractable Value_(OEV), a form of value generated from oracle updates within a project. By disrupting the traditional MEV (Miner Extractable Value) supply chain, OVAL opens up new revenue streams for projects. For instance, in a money market scenario, the protocol could earn revenue each time liquidations occur within its system. This is achieved by controlling the timing and accessibility of oracle updates, thus allowing the projects to strategically position themselves to benefit from the resulting market movements. This approach sets OVAL apart, leveraging the reliability and familiarity of Chainlink's data while introducing a strategic layer for maximizing the value extracted from oracle updates. +Oval is designed as an enhancement over the standard oracles like Chainlink, wrapping around them to introduce a novel functionality: the unlocking of price updates. This unique feature allows Oval-enabled projects to capture _Oracle Extractable Value_(OEV), a form of value generated from oracle updates within a project. By disrupting the traditional MEV (Miner Extractable Value) supply chain, Oval opens up new revenue streams for projects. For instance, in a money market scenario, the protocol could earn revenue each time liquidations occur within its system. This is achieved by controlling the timing and accessibility of oracle updates, thus allowing the projects to strategically position themselves to benefit from the resulting market movements. This approach sets Oval apart, leveraging the reliability and familiarity of Chainlink's data while introducing a strategic layer for maximizing the value extracted from oracle updates. -For more information on how OVAL works and how to integrate with it see [oval.docs.uma.xyz](). +For more information on how Oval works and how to integrate with it see [oval.docs.uma.xyz](). # Repo contents -This repository contains the main smart contracts for the OVAL Oracle. 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/scripts/README.md b/scripts/README.md index ae118b5..b741dc2 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,6 +1,6 @@ -# OVAL scripts +# Oval scripts -This package contains scripts for gas profiling of OVAL. +This package contains scripts for gas profiling of Oval. ## Installation diff --git a/scripts/package.json b/scripts/package.json index a8e7194..fe76ca7 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -1,7 +1,7 @@ { "name": "oval-contract-scripts", "version": "1.0.0", - "description": "OVAL simulation scripts", + "description": "Oval simulation scripts", "main": "dist/index.js", "repository": "git@github.com:UMAprotocol/oval-contracts.git", "author": "UMA team", diff --git a/scripts/src/gasProfiling/aaveV2Borrow.ts b/scripts/src/gasProfiling/aaveV2Borrow.ts index 36db94a..4b4f86b 100644 --- a/scripts/src/gasProfiling/aaveV2Borrow.ts +++ b/scripts/src/gasProfiling/aaveV2Borrow.ts @@ -11,8 +11,8 @@ import { TenderlySimulationResult, simulateTenderlyTx, } from "../TenderlyHelpers/TenderlySimulation"; -// Have to import TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/AaveV2.Liquidation.sol/TestedOVAL__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 = 18426914; @@ -75,9 +75,9 @@ const regularAaveV2Borrow = async (): Promise => { return simulation.gasUsed; }; -const OVALAaveV2Borrow = async (): Promise => { +const OvalAaveV2Borrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALAaveV2Borrow = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( "0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46", 18 ); - await testedOVAL.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 OVAL"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy Oval"); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // setOVALAsAaveSource + // setOvalAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOVAL.address]] + [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOval.address]] ); simulation = await simulateTenderlyTx({ @@ -138,20 +138,20 @@ const OVALAaveV2Borrow = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OVAL as Aave source", + description: "Change Oval as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALAaveV2BorrowGas = await OVALAaveV2Borrow(); - const gasDiff = OVALAaveV2BorrowGas - 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 3f680f0..90ddea8 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 TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/AaveV2.Liquidation.sol/TestedOVAL__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 OVALAaveV2Liquidation = async (): Promise => { +const OvalAaveV2Liquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALAaveV2Liquidation = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( "0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757", 18 ); - await testedOVAL.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 OVAL"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy Oval"); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // setOVALAsAaveSource + // setOvalAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"], [testedOVAL.address]] + [["0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"], [testedOval.address]] ); simulation = await simulateTenderlyTx({ @@ -154,20 +154,20 @@ const OVALAaveV2Liquidation = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OVAL as Aave source", + description: "Change Oval as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALAaveV2LiquidationGas = await OVALAaveV2Liquidation(); - const gasDiff = OVALAaveV2LiquidationGas - 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 d691014..23d9c91 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 TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOVAL__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 OVALAaveV3Borrow = async (): Promise => { +const OvalAaveV3Borrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALAaveV3Borrow = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( "0x3E7d1eAB13ad0104d2750B8863b489D65364e32D", 8 ); - await testedOVAL.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 OVAL"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy Oval"); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // setOVALAsAaveSource + // setOvalAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOVAL.address]] + [["0xdac17f958d2ee523a2206206994597c13d831ec7"], [testedOval.address]] ); simulation = await simulateTenderlyTx({ @@ -137,20 +137,20 @@ const OVALAaveV3Borrow = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OVAL as Aave source", + description: "Change Oval as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALAaveV3BorrowGas = await OVALAaveV3Borrow(); - const gasDiff = OVALAaveV3BorrowGas - 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 298f151..880fcdd 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 TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/AaveV3.Liquidation.sol/TestedOVAL__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 OVALAaveV3Liquidation = async (): Promise => { +const OvalAaveV3Liquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALAaveV3Liquidation = async (): Promise => { const ownerSigner = provider.getSigner(ownerAddress); const forkTimestamp = (await provider.getBlock(blockNumber)).timestamp; - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419", 8 ); - await testedOVAL.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 OVAL"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy Oval"); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // setOVALAsAaveSource + // setOvalAsAaveSource const aaveOracleInterface = new utils.Interface(aaveOracleAbi); const aaveOracleCallData = aaveOracleInterface.encodeFunctionData( "setAssetSources", - [["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], [testedOVAL.address]] + [["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], [testedOval.address]] ); simulation = await simulateTenderlyTx({ @@ -138,20 +138,20 @@ const OVALAaveV3Liquidation = async (): Promise => { input: aaveOracleCallData, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Change OVAL as Aave source", + description: "Change Oval as Aave source", }); // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALAaveV3LiquidationGas = await OVALAaveV3Liquidation(); - const gasDiff = OVALAaveV3LiquidationGas - 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 af1984a..77593d4 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 TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOVAL__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 OVALCompoundBorrow = async (): Promise => { +const OvalCompoundBorrow = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALCompoundBorrow = async (): Promise => { "Deploy UniswapAnchoredViewDestinationAdapter" ); - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( uniswapAnchoredViewSourceAddress, cETHAddress ); - await testedOVAL.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 OVAL" + "Deploy Oval" ); - // Set TestedOVAL on UniswapAnchoredViewDestinationAdapter. - const setOVALInput = - uavDestinationAdapterFactory.interface.encodeFunctionData("setOVAL", [ + // Set TestedOval on UniswapAnchoredViewDestinationAdapter. + const setOvalInput = + uavDestinationAdapterFactory.interface.encodeFunctionData("setOval", [ cETHAddress, - testedOVAL.address, + testedOval.address, ]); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, to: uavDestinationAdapter.address, - input: setOVALInput, + input: setOvalInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Set OVAL", + description: "Set Oval", }); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // Whitelist TestedOVAL on chainlink + // Whitelist TestedOval on chainlink const sourceChainlinkOracleAddress = - await testedOVAL.callStatic.aggregator(); + await testedOval.callStatic.aggregator(); const sourceChainlinkOracle = new Contract( sourceChainlinkOracleAddress, accessControlledOffchainAggregatorAbi, @@ -220,7 +220,7 @@ const OVALCompoundBorrow = async (): Promise => { await sourceChainlinkOracle.callStatic.owner(); const addAccessInput = sourceChainlinkOracle.interface.encodeFunctionData( "addAccess", - [testedOVAL.address] + [testedOval.address] ); simulation = await simulateTenderlyTx({ chainId, @@ -229,7 +229,7 @@ const OVALCompoundBorrow = async (): Promise => { input: addAccessInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Whitelist OVAL on Chainlink", + description: "Whitelist Oval on Chainlink", }); // Point Comptroller to UniswapAnchoredViewDestinationAdapter. @@ -255,15 +255,15 @@ const OVALCompoundBorrow = async (): Promise => { // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALCompoundBorrowGas = await OVALCompoundBorrow(); - const gasDiff = OVALCompoundBorrowGas - 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 1ef7078..cd3b2ca 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 TestedOVAL manually since it is not unique. -import { TestedOVAL__factory } from "../../contract-types/factories/CompoundV2.Liquidation.sol/TestedOVAL__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 OVALCompoundLiquidation = async (): Promise => { +const OvalCompoundLiquidation = async (): Promise => { // Create and share new fork (delete the old one if it exists). - const alias = "OVAL 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 OVALCompoundLiquidation = async (): Promise => { "Deploy UniswapAnchoredViewDestinationAdapter" ); - // Deploy OVAL. - const testedOVALFactory = new TestedOVAL__factory(ownerSigner); - const testedOVAL = await testedOVALFactory.deploy( + // Deploy Oval. + const testedOvalFactory = new TestedOval__factory(ownerSigner); + const testedOval = await testedOvalFactory.deploy( uniswapAnchoredViewSourceAddress, cETHAddress ); - await testedOVAL.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 OVAL"); + await setForkSimulationDescription(fork.id, fork.headId, "Deploy Oval"); - // Set TestedOVAL on UniswapAnchoredViewDestinationAdapter. - const setOVALInput = - uavDestinationAdapterFactory.interface.encodeFunctionData("setOVAL", [ + // Set TestedOval on UniswapAnchoredViewDestinationAdapter. + const setOvalInput = + uavDestinationAdapterFactory.interface.encodeFunctionData("setOval", [ cETHAddress, - testedOVAL.address, + testedOval.address, ]); let simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, to: uavDestinationAdapter.address, - input: setOVALInput, + input: setOvalInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: fork.headId }, - description: "Set OVAL", + description: "Set Oval", }); - // Enable unlocker on TestedOVAL. - const setUnlockerInput = testedOVALFactory.interface.encodeFunctionData( + // Enable unlocker on TestedOval. + const setUnlockerInput = testedOvalFactory.interface.encodeFunctionData( "setUnlocker", [unlockerAddress, true] ); simulation = await simulateTenderlyTx({ chainId, from: ownerAddress, - to: testedOVAL.address, + to: testedOval.address, input: setUnlockerInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Enable unlocker on OVAL", + description: "Enable unlocker on Oval", }); - // Whitelist TestedOVAL on chainlink + // Whitelist TestedOval on chainlink const sourceChainlinkOracleAddress = - await testedOVAL.callStatic.aggregator(); + await testedOval.callStatic.aggregator(); const sourceChainlinkOracle = new Contract( sourceChainlinkOracleAddress, accessControlledOffchainAggregatorAbi, @@ -186,7 +186,7 @@ const OVALCompoundLiquidation = async (): Promise => { await sourceChainlinkOracle.callStatic.owner(); const addAccessInput = sourceChainlinkOracle.interface.encodeFunctionData( "addAccess", - [testedOVAL.address] + [testedOval.address] ); simulation = await simulateTenderlyTx({ chainId, @@ -195,7 +195,7 @@ const OVALCompoundLiquidation = async (): Promise => { input: addAccessInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Whitelist OVAL on Chainlink", + description: "Whitelist Oval on Chainlink", }); // Point Comptroller to UniswapAnchoredViewDestinationAdapter. @@ -221,15 +221,15 @@ const OVALCompoundLiquidation = async (): Promise => { // Unlock latest value. const unlockLatestValueInput = - testedOVALFactory.interface.encodeFunctionData("unlockLatestValue"); + testedOvalFactory.interface.encodeFunctionData("unlockLatestValue"); simulation = await simulateTenderlyTx({ chainId, from: unlockerAddress, - to: testedOVAL.address, + to: testedOval.address, input: unlockLatestValueInput, timestampOverride: forkTimestamp, fork: { id: fork.id, root: simulation.id }, - description: "Unlock latest value on OVAL", + 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 OVALCompoundBorrowGas = await OVALCompoundLiquidation(); - const gasDiff = OVALCompoundBorrowGas - regularCompoundBorrowGas; + const OvalCompoundBorrowGas = await OvalCompoundLiquidation(); + const gasDiff = OvalCompoundBorrowGas - regularCompoundBorrowGas; console.log("Gas difference: " + gasDiff); }; diff --git a/src/DiamondRootOval.sol b/src/DiamondRootOval.sol index 77e9ccb..062b483 100644 --- a/src/DiamondRootOval.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 {IOVAL} from "./interfaces/IOval.sol"; +import {IOval} from "./interfaces/IOval.sol"; /** - * @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 + * @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 DiamondRootOVAL is IBaseController, IOVAL, 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 DiamondRootOVAL is IBaseController, IOVAL, IBaseOracleAdapter function tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) public view virtual returns (int256, uint256); /** - * @notice Returns the latest data from the source. Depending on when the OVAL 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 DiamondRootOVAL is IBaseController, IOVAL, IBaseOracleAdapter function snapshotData() public virtual; /** - * @notice Permissioning function to control who can unlock the OVAL. + * @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/Oval.sol b/src/Oval.sol index 08a0801..6209f10 100644 --- a/src/Oval.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 {DiamondRootOVAL} from "./DiamondRootOval.sol"; +import {DiamondRootOval} from "./DiamondRootOval.sol"; /** - * @title OVAL 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 {DiamondRootOVAL} from "./DiamondRootOval.sol"; * @custom:security-contact bugs@umaproject.org */ -abstract contract OVAL is DiamondRootOVAL { - uint256 public lastUnlockTime; // Timestamp of the latest unlock to the OVAL. +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 OVAL is DiamondRootOVAL { function unlockLatestValue() public { require(canUnlock(msg.sender, lastUnlockTime), "Controller blocked: canUnlock"); - snapshotData(); // If the source connected to this OVAL 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 8e64de7..9cd3d77 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 {DiamondRootOVAL} from "../../DiamondRootOval.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; /** - * @title BaseDestinationAdapter contract to expose OVAL 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 DiamondRootOVAL { +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 a1c3603..4bd7c79 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 {DiamondRootOVAL} from "../../DiamondRootOval.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; /** - * @title ChainlinkDestinationAdapter contract to expose OVAL data via the standard Chainlink Aggregator interface. + * @title ChainlinkDestinationAdapter contract to expose Oval data via the standard Chainlink Aggregator interface. */ -abstract contract ChainlinkDestinationAdapter is DiamondRootOVAL, IAggregatorV3 { +abstract contract ChainlinkDestinationAdapter is DiamondRootOval, IAggregatorV3 { uint8 public immutable override decimals; event DecimalsSet(uint8 indexed decimals); diff --git a/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol b/src/adapters/destination-adapters/UniswapAnchoredViewDestinationAdapter.sol index 06f669a..cc4db89 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 {IOVAL} from "../../interfaces/IOval.sol"; +import {IOval} from "../../interfaces/IOval.sol"; /** - * @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 + * @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 cTokenToOVAL; + mapping(address => address) public cTokenToOval; mapping(address => uint8) public cTokenToDecimal; IUniswapAnchoredView public immutable uniswapAnchoredViewSource; event BaseSourceSet(address indexed source); - event OVALSet(address indexed cToken, uint8 indexed decimals, address indexed oval); + 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 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. + * @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 setOVAL(address cToken, address oval) public onlyOwner { - cTokenToOVAL[cToken] = oval; + 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 OVALSet(cToken, decimals, oval); + 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 (cTokenToOVAL[cToken] == address(0)) { + if (cTokenToOval[cToken] == address(0)) { return uniswapAnchoredViewSource.getUnderlyingPrice(cToken); } - (int256 answer,) = IOVAL(cTokenToOVAL[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 00f4dcd..a3d8850 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 {DiamondRootOVAL} from "../../DiamondRootOval.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; /** - * @title ChainlinkSourceAdapter contract to read data from Chainlink aggregator and standardize it for OVAL. + * @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 DiamondRootOVAL { +abstract contract ChainlinkSourceAdapter is DiamondRootOval { IAggregatorV3Source public immutable CHAINLINK_SOURCE; uint8 private immutable SOURCE_DECIMALS; diff --git a/src/adapters/source-adapters/SnapshotSource.sol b/src/adapters/source-adapters/SnapshotSource.sol index b642fe3..251abf0 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 {DiamondRootOVAL} from "../../DiamondRootOval.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 DiamondRootOVAL { +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 5a4343f..a96a2b7 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 OVAL. + * @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 fce73ee..216acbe 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 {OVAL} from "../Oval.sol"; +import {Oval} from "../Oval.sol"; /** - * @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. + * @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, OVAL { +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, OVAL { mapping(address => bool) public unlockers; /** - * @notice Enables the owner to set the unlocker status of an address. Once set, the address can unlock the OVAL + * @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, OVAL { } /** - * @notice Returns true if the caller is allowed to unlock the OVAL. + * @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 OVAL. + * 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 OVAL. 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, OVAL { /** * @notice Enables the owner to set the lockWindow. - * @dev If changing the lockWindow would cause OVAL 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, OVAL { lockWindow_ = newLockWindow; - // Compare OVAL 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 a97d1f2..80ed8d6 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 {OVAL} from "../Oval.sol"; +import {Oval} from "../Oval.sol"; /** * @title ImmutableController providing an immutable controller. @@ -11,7 +11,7 @@ import {OVAL} from "../Oval.sol"; * oracle users). */ -abstract contract ImmutableController is OVAL { +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 OVAL { } /** - * @notice Returns true if the caller is allowed to unlock the OVAL. + * @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 OVAL. + * 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 OVAL. 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/IOval.sol b/src/interfaces/IOval.sol index 6adc038..3cf1679 100644 --- a/src/interfaces/IOval.sol +++ b/src/interfaces/IOval.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.17; -interface IOVAL { +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 c272fed..8437ccd 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 TestedOVAL 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; - TestedOVAL oval; + TestedOval oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -76,12 +76,12 @@ contract AaveV2LiquidationTest is CommonTest { function testCanReplaceSourceAndExecuteLiquidation() public { seedLiquidator(); - createOVALAndUnlock(); - setOVALAsAaveSource(); + createOvalAndUnlock(); + setOvalAsAaveSource(); updateChainlinkToLatestValue(); - // 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. + // 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(oval.latestAnswer() != latestAnswer, "1"); assertTrue(oval.latestTimestamp() != latestTimestamp, "2"); @@ -90,7 +90,7 @@ contract AaveV2LiquidationTest is CommonTest { 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 OVAL and show that the liquidation can be executed. + //Now, unlock the Oval and show that the liquidation can be executed. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); (, int256 latestAnswerTwo,, uint256 latestTimestampTwo,) = sourceChainlinkOracle.latestRoundData(); @@ -102,21 +102,21 @@ contract AaveV2LiquidationTest is CommonTest { assertTrue(healthFactorAfter > 1e18); // Health factor should be greater than 1 after liquidation. } - function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { + function testOvalGracefullyFallsBackToSourceIfNoUnlockApplied() public { seedLiquidator(); - createOVALAndUnlock(); - setOVALAsAaveSource(); + createOvalAndUnlock(); + setOvalAsAaveSource(); updateChainlinkToLatestValue(); - // 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. + // 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 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. + // 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. @@ -124,7 +124,7 @@ contract AaveV2LiquidationTest is CommonTest { assertTrue(oval.latestAnswer() == latestAnswer); assertTrue(oval.latestTimestamp() == latestTimestamp); - // Now, run the liquidation. It should succeed without the OVAL 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,10 +142,10 @@ contract AaveV2LiquidationTest is CommonTest { usdcDebtAsset.approve(address(lendingPool), amountToMint); } - function createOVALAndUnlock() public { - oval = new TestedOVAL(sourceChainlinkOracle, 18); + 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. + // pull the latest price into the Oval and check it matches with the source oracle. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); @@ -153,8 +153,8 @@ contract AaveV2LiquidationTest is CommonTest { assertTrue(latestTimestamp == oval.latestTimestamp()); } - function setOVALAsAaveSource() public { - // Set the OVAL 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); @@ -164,12 +164,12 @@ contract AaveV2LiquidationTest is CommonTest { } function updateChainlinkToLatestValue() public { - // Apply the chainlink update within chainlink. This wont affect the OVAL 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 OVAL. + // Values have changed in chainlink but is stale within Oval. assertTrue(answerBefore != answerAfter && timestampBefore != 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 7a3d4c6..38c1181 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 TestedOVAL 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; - TestedOVAL oval; + TestedOval oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -71,17 +71,17 @@ contract Aave3LiquidationTest is CommonTest { function testCanReplaceSourceAndExecuteLiquidation() public { seedLiquidator(); - createOVALAndUnlock(); - setOVALAsAaveSource(); + createOvalAndUnlock(); + setOvalAsAaveSource(); updateChainlinkToLatestValue(); - // 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. + // 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 OVAL and show that the liquidation can be executed. + //Now, unlock the Oval and show that the liquidation can be executed. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); @@ -95,21 +95,21 @@ contract Aave3LiquidationTest is CommonTest { assertTrue(isPositionHealthy()); // Post liquidation position should be healthy again. } - function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { + function testOvalGracefullyFallsBackToSourceIfNoUnlockApplied() public { seedLiquidator(); - createOVALAndUnlock(); - setOVALAsAaveSource(); + createOvalAndUnlock(); + setOvalAsAaveSource(); updateChainlinkToLatestValue(); - // 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. + // 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 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. + // 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. @@ -118,7 +118,7 @@ contract Aave3LiquidationTest is CommonTest { assertTrue(oval.latestTimestamp() == latestTimestamp); assertFalse(isPositionHealthy()); // Post update but pre-liquidation position should be underwater. - // Now, run the liquidation. It should succeed without the OVAL 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,10 +135,10 @@ contract Aave3LiquidationTest is CommonTest { usdcDebtAsset.approve(address(lendingPool), amountToMint); } - function createOVALAndUnlock() public { - oval = new TestedOVAL(sourceChainlinkOracle, 8); + 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. + // pull the latest price into the Oval and check it matches with the source oracle. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); (, int256 latestAnswer,, uint256 latestTimestamp,) = sourceChainlinkOracle.latestRoundData(); @@ -146,8 +146,8 @@ contract Aave3LiquidationTest is CommonTest { assertTrue(latestTimestamp == oval.latestTimestamp()); } - function setOVALAsAaveSource() public { - // Set the OVAL 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); @@ -157,16 +157,16 @@ contract Aave3LiquidationTest is CommonTest { } function updateChainlinkToLatestValue() public { - // Apply the chainlink update within chainlink. This wont affect the OVAL 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 OVAL. + // Values have changed in chainlink but is stale within Oval. assertTrue(answerBefore != answerAfter && timestampBefore != timestampAfter); assertTrue(oval.latestAnswer() == answerBefore && oval.latestTimestamp() == timestampBefore); assertTrue(oval.latestAnswer() != answerAfter && oval.latestTimestamp() != timestampAfter); - // Aave oracle should match the OVAL, not the source oracle. + // Aave oracle should match the Oval, not the source oracle. (, int256 latestAnswer,,,) = sourceChainlinkOracle.latestRoundData(); assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) == uint256(oval.latestAnswer())); assertTrue(aaveOracle.getAssetPrice(address(collateralAsset)) != uint256(latestAnswer)); diff --git a/test/fork/compound/CompoundV2.Liquidation.sol b/test/fork/compound/CompoundV2.Liquidation.sol index a648eef..5e27b38 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 TestedOVAL 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; - TestedOVAL oval; + TestedOval oval; function setUp() public { vm.createSelectFork("mainnet", oracleUpdateBlock - 1); // Rolling to the block before the oracle update to start off all tests. @@ -81,8 +81,8 @@ contract CompoundV2LiquidationTest is CommonTest { } function testCanReplaceSourceAndExecuteLiquidation() public { - createOVALAndUnlock(); - setOVALAsCompoundSource(); + createOvalAndUnlock(); + setOvalAsCompoundSource(); updateChainlinkToLatestValue(); // insure config is correct @@ -95,8 +95,8 @@ contract CompoundV2LiquidationTest is CommonTest { uint256 borrowBalance = cUSDC.borrowBalanceCurrent(borrower); uint256 liquidatbleAmount = borrowBalance / 2; // 50% liquidation threshold is the max in Compound. - // 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. + // 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(ovalPriceBefore != sourcePriceBefore); @@ -105,13 +105,13 @@ contract CompoundV2LiquidationTest is CommonTest { cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); assertTrue(cUSDC.borrowBalanceCurrent(borrower) == borrowBalance); - // Unlock the OVAL 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); oval.unlockLatestValue(); uint256 ovalPriceAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); - assertTrue(ovalPriceAfter < ovalPriceBefore); // Price has changed in OVAL due to calling unlockLatestValue + assertTrue(ovalPriceAfter < ovalPriceBefore); // Price has changed in Oval due to calling unlockLatestValue vm.prank(liquidator); cUSDC.liquidateBorrow(borrower, liquidatbleAmount, address(cETH)); @@ -120,9 +120,9 @@ contract CompoundV2LiquidationTest is CommonTest { assertTrue(cETH.balanceOf(liquidator) > 0); // Some amount of cETH received from the liquidation } - function testOVALGracefullyFallsBackToSourceIfNoUnlockApplied() public { - createOVALAndUnlock(); - setOVALAsCompoundSource(); + function testOvalGracefullyFallsBackToSourceIfNoUnlockApplied() public { + createOvalAndUnlock(); + setOvalAsCompoundSource(); updateChainlinkToLatestValue(); vm.prank(sourceChainlinkOracle.owner()); @@ -132,15 +132,15 @@ contract CompoundV2LiquidationTest is CommonTest { uint256 borrowBalance = cUSDC.borrowBalanceCurrent(borrower); uint256 liquidatbleAmount = borrowBalance / 2; // 50% liquidation threshold is the max in Compound. - // At this point the OVAL 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 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. + // 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. @@ -149,7 +149,7 @@ contract CompoundV2LiquidationTest is CommonTest { "2" ); - // Now, run the liquidation. It should succeed without the OVAL 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,17 +168,17 @@ contract CompoundV2LiquidationTest is CommonTest { usdcDebtAsset.approve(address(cUSDC), amountToMint); } - function createOVALAndUnlock() public { + function createOvalAndUnlock() public { DestinationAdapter = new UniswapAnchoredViewDestinationAdapter(getSetCompoundOracle()); - oval = new TestedOVAL(getSetCompoundOracle(), address(cETH)); - DestinationAdapter.setOVAL(address(cETH), address(oval)); - assertTrue(DestinationAdapter.cTokenToOVAL(address(cETH)) == address(oval)); + 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). oval.setUnlocker(permissionedUnlocker, true); sourceChainlinkOracle = IAccessControlledAggregatorV3(address(oval.aggregator())); vm.prank(sourceChainlinkOracle.owner()); sourceChainlinkOracle.addAccess(address(oval)); - // pull the latest price into the OVAL and check it matches with the source oracle. + // pull the latest price into the Oval and check it matches with the source oracle. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); assertTrue( @@ -186,14 +186,14 @@ contract CompoundV2LiquidationTest is CommonTest { ); } - function setOVALAsCompoundSource() 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 OVAL price until it is unlocked. + // 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); @@ -202,11 +202,11 @@ contract CompoundV2LiquidationTest is CommonTest { uint256 answerFromOvalAfter = uint256(getSetCompoundOracle().getUnderlyingPrice(address(cETH))); uint256 answerFromChainlinkAfter = uint256(compoundOracle.getUnderlyingPrice(address(cETH))); - // Values have changed in chainlink but is stale within OVAL. + // Values have changed in chainlink but is stale within Oval. - assertTrue(answerFromOvalBefore == answerFromOvalAfter); // Price has not changed in OVAL. + assertTrue(answerFromOvalBefore == answerFromOvalAfter); // Price has not changed in Oval. assertTrue(answerFromChainlinkBefore != answerFromChainlinkAfter); // Price has changed within Chainlink. - assertTrue(DestinationAdapter.getUnderlyingPrice(address(cETH)) == answerFromOvalBefore); // destination adapter has not updated yet and should be the same as the OVAL. + 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 2be2011..55aebc9 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 {DiamondRootOVAL} from "../../src/DiamondRootOval.sol"; +import {DiamondRootOval} from "../../src/DiamondRootOval.sol"; -abstract contract MockSourceAdapter is DiamondRootOVAL { +abstract contract MockSourceAdapter is DiamondRootOval { uint8 public sourceDecimals; struct RoundData { diff --git a/test/unit/BaseController.sol b/test/unit/BaseController.sol index d832620..bcdc16a 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 OVALUnlockLatestValue is CommonTest { +contract OvalUnlockLatestValue is CommonTest { uint256 lastUnlockTime = 1690000000; TestBaseController baseController; diff --git a/test/unit/ImmutableController.sol b/test/unit/ImmutableController.sol index 90af875..725e692 100644 --- a/test/unit/ImmutableController.sol +++ b/test/unit/ImmutableController.sol @@ -14,7 +14,7 @@ contract TestImmutableController is ImmutableController, MockSourceAdapter, Base {} } -contract OVALUnlockLatestValue is CommonTest { +contract OvalUnlockLatestValue is CommonTest { uint8 decimals = 8; uint256 lockWindow = 60; uint256 maxTraversal = 10; diff --git a/test/unit/Oval.ChainlinkDestinationAdapter.sol b/test/unit/Oval.ChainlinkDestinationAdapter.sol index 40ea0b2..a695b23 100644 --- a/test/unit/Oval.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 {OVAL} from "../../src/Oval.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 TestOVAL is BaseController, MockSourceAdapter, ChainlinkDestinationAdapter { +contract TestOval is BaseController, MockSourceAdapter, ChainlinkDestinationAdapter { constructor(uint8 decimals) BaseController() MockSourceAdapter(decimals) ChainlinkDestinationAdapter(decimals) {} } -contract OVALChainlinkDestinationAdapter is CommonTest { +contract OvalChainlinkDestinationAdapter is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; @@ -23,20 +23,20 @@ contract OVALChainlinkDestinationAdapter is CommonTest { int256 internalDecimalsToSourceDecimals = 1e10; - TestOVAL oval; + TestOval oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oval = new TestOVAL(sourceOracleDecimals); + oval = new TestOval(sourceOracleDecimals); oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOVALMatchesOVAL() public { + function verifyOvalMatchesOval() public { (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue( latestAnswer / internalDecimalsToSourceDecimals == oval.latestAnswer() @@ -44,18 +44,18 @@ contract OVALChainlinkDestinationAdapter is CommonTest { ); } - function syncOVALWithOVAL() public { + function syncOvalWithOval() public { assertTrue(oval.canUnlock(permissionedUnlocker, oval.latestTimestamp())); vm.prank(permissionedUnlocker); oval.unlockLatestValue(); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testUpdatesWithinLockWindow() public { // Publish an update to the mock source adapter. oval.publishRoundData(newAnswer, newTimestamp); - syncOVALWithOVAL(); + syncOvalWithOval(); assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an unlock with no diff in source adapter. @@ -66,12 +66,12 @@ contract OVALChainlinkDestinationAdapter is CommonTest { // Check that the update timestamp was unlocked and that the answer and timestamp are unchanged. assertTrue(oval.lastUnlockTime() == unlockTimestamp); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = oval.latestRoundData(); - // Check that OVAL 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/Oval.UniswapAnchoredViewDestinationAdapter.sol b/test/unit/Oval.UniswapAnchoredViewDestinationAdapter.sol index 0be543d..17d7a3e 100644 --- a/test/unit/Oval.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 {IOVAL} from "../../src/interfaces/IOval.sol"; +import {IOval} from "../../src/interfaces/IOval.sol"; import {CommonTest} from "../Common.sol"; -contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { +contract OvalUniswapAnchoredViewDestinationAdapter is CommonTest { int256 newAnswer = 1900 * 1e18; uint256 newTimestamp = 1690000000; int256 internalDecimalsToSourceDecimals = 1e10; address sourceAddress = makeAddr("sourceAddress"); - address OVALAddress = makeAddr("OVALAddress"); + address OvalAddress = makeAddr("OvalAddress"); address cTokenAddress = makeAddr("cTokenAddress"); uint8 underlyingDecimals = 8; @@ -26,7 +26,7 @@ contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { destinationAdapter = new UniswapAnchoredViewDestinationAdapter(IUniswapAnchoredView(sourceAddress)); } - function testSetOVAL() public { + function testSetOval() public { vm.mockCall( sourceAddress, abi.encodeWithSelector(IUniswapAnchoredView.getTokenConfigByCToken.selector, cTokenAddress), @@ -45,9 +45,9 @@ contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { }) ) ); - destinationAdapter.setOVAL(cTokenAddress, OVALAddress); + destinationAdapter.setOval(cTokenAddress, OvalAddress); - assertEq(destinationAdapter.cTokenToOVAL(cTokenAddress), OVALAddress); + assertEq(destinationAdapter.cTokenToOval(cTokenAddress), OvalAddress); assertEq(destinationAdapter.cTokenToDecimal(cTokenAddress), 36 - underlyingDecimals); } @@ -70,10 +70,10 @@ contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { }) ) ); - destinationAdapter.setOVAL(cTokenAddress, OVALAddress); + destinationAdapter.setOval(cTokenAddress, OvalAddress); vm.mockCall( - OVALAddress, abi.encodeWithSelector(IOVAL.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) + OvalAddress, abi.encodeWithSelector(IOval.internalLatestData.selector), abi.encode(newAnswer, newTimestamp) ); uint256 underlyingPrice = destinationAdapter.getUnderlyingPrice(cTokenAddress); @@ -81,8 +81,8 @@ contract OVALUniswapAnchoredViewDestinationAdapter is CommonTest { } function testUnsupportedCToken() public { - // We don't set an OVAL for this cToken, so it should return the price from the source. - assert(destinationAdapter.cTokenToOVAL(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/Oval.UnlockLatestValue.sol b/test/unit/Oval.UnlockLatestValue.sol index 8c20c20..36de050 100644 --- a/test/unit/Oval.UnlockLatestValue.sol +++ b/test/unit/Oval.UnlockLatestValue.sol @@ -3,48 +3,48 @@ pragma solidity 0.8.17; import {CommonTest} from "../Common.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; -import {OVAL} from "../../src/Oval.sol"; +import {Oval} from "../../src/Oval.sol"; import {BaseDestinationAdapter} from "../../src/adapters/destination-adapters/BaseDestinationAdapter.sol"; import {MockSourceAdapter} from "../mocks/MockSourceAdapter.sol"; -contract TestOVAL is BaseController, MockSourceAdapter, BaseDestinationAdapter { +contract TestOval is BaseController, MockSourceAdapter, BaseDestinationAdapter { constructor(uint8 decimals) MockSourceAdapter(decimals) BaseController() BaseDestinationAdapter() {} } -contract OVALUnlockLatestValue is CommonTest { +contract OvalUnlockLatestValue is CommonTest { int256 initialPrice = 1895 * 1e18; uint256 initialTimestamp = 1690000000; int256 newAnswer = 1900 * 1e18; uint256 newTimestamp = initialTimestamp + 1; - TestOVAL oval; + TestOval oval; function setUp() public { vm.warp(initialTimestamp); vm.startPrank(owner); - oval = new TestOVAL(18); + oval = new TestOval(18); oval.setUnlocker(permissionedUnlocker, true); vm.stopPrank(); oval.publishRoundData(initialPrice, initialTimestamp); } - function verifyOVALMatchesOVAL() public { + function verifyOvalMatchesOval() public { (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == oval.latestAnswer() && latestTimestamp == oval.latestTimestamp()); } - function syncOVALWithOVAL() public { + function syncOvalWithOval() public { assertTrue(oval.canUnlock(permissionedUnlocker, oval.latestTimestamp())); vm.prank(permissionedUnlocker); oval.unlockLatestValue(); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testUnlockWithNoDiffUpdatesUnlockTimestamp() public { - syncOVALWithOVAL(); + syncOvalWithOval(); assertTrue(oval.lastUnlockTime() == block.timestamp); // Apply an unlock with no diff in source adapter. @@ -55,18 +55,18 @@ contract OVALUnlockLatestValue is CommonTest { // Check that the unlock timestamp was updated and that the answer and timestamp are unchanged. assertTrue(oval.lastUnlockTime() == unlockTimestamp); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testUnlockerCanUnlockLatestValue() public { - syncOVALWithOVAL(); + syncOvalWithOval(); oval.publishRoundData(newAnswer, newTimestamp); vm.warp(newTimestamp); vm.prank(permissionedUnlocker); oval.unlockLatestValue(); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); (int256 latestAnswer, uint256 latestTimestamp) = oval.internalLatestData(); assertTrue(latestAnswer == newAnswer && latestTimestamp == newTimestamp); @@ -75,11 +75,11 @@ contract OVALUnlockLatestValue is CommonTest { oval.publishRoundData(newAnswer + 1, newTimestamp + 2); vm.prank(permissionedUnlocker); oval.unlockLatestValue(); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testNonUnlockerCannotUnlockLatestValue() public { - syncOVALWithOVAL(); + syncOvalWithOval(); oval.publishRoundData(newAnswer, newTimestamp); vm.warp(newTimestamp); @@ -93,7 +93,7 @@ contract OVALUnlockLatestValue is CommonTest { } function testUpdatesWithinLockWindow() public { - syncOVALWithOVAL(); + syncOvalWithOval(); // Advance time to within the lock window and update the source. uint256 beforeLockWindow = block.timestamp + oval.lockWindow() - 1; @@ -107,11 +107,11 @@ contract OVALUnlockLatestValue is CommonTest { // After updating we should return the new values. vm.prank(permissionedUnlocker); oval.unlockLatestValue(); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testNoUpdatesPastLockWindow() public { - syncOVALWithOVAL(); + syncOvalWithOval(); uint256 unlockTimestamp = block.timestamp; uint256 beforeOEVLockWindow = unlockTimestamp + 59; // Default lock window is 10 minutes. @@ -132,11 +132,11 @@ contract OVALUnlockLatestValue is CommonTest { // Advancing time past the new lock window should pass through source values. uint256 pastSourceLockWindow = beforeOEVLockWindow + 69; vm.warp(pastSourceLockWindow); - verifyOVALMatchesOVAL(); + verifyOvalMatchesOval(); } function testRepeatedUpdates() public { - syncOVALWithOVAL(); + syncOvalWithOval(); // Advance time to within the lock window and update the source. uint256 beforeLockWindow = block.timestamp + oval.lockWindow() - 1; @@ -148,7 +148,7 @@ contract OVALUnlockLatestValue is CommonTest { assertTrue(latestAnswer == initialPrice && latestTimestamp == initialTimestamp); // Sync and verify updated values. - syncOVALWithOVAL(); + syncOvalWithOval(); // Advance time to within the lock window and update the source. uint256 nextBeforeLockWindow = block.timestamp + oval.lockWindow() - 1; diff --git a/test/unit/SnapshotSource.SnapshotData.sol b/test/unit/SnapshotSource.SnapshotData.sol index 0f92b0e..168842a 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 {OVAL} from "../../src/Oval.sol"; +import {Oval} from "../../src/Oval.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; -contract TestSnapshotSource is MockSnapshotSourceAdapter, OVAL, BaseController {} +contract TestSnapshotSource is MockSnapshotSourceAdapter, Oval, BaseController {} contract SnapshotSourceSnapshotDataTest is CommonTest { TestSnapshotSource snapshotSource;