Skip to content

Commit

Permalink
feat: rename to oval (#8)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
  • Loading branch information
md0x authored Feb 2, 2024
1 parent 0e585b1 commit 46ac5ef
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std.git
[submodule "lib/oev-contracts"]
path = lib/oev-contracts
url = https://github.com/UMAprotocol/oev-contracts.git
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/oval-contracts"]
path = lib/oval-contracts
url = https://github.com/UMAprotocol/oval-contracts
[submodule "lib/oev-contracts"]
path = lib/oev-contracts
url = https://github.com/UMAprotocol/oev-contracts
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <h1 align="center"> OEV Share HoneyPot Demo </h1>
# <h1 align="center"> Oval HoneyPot Demo </h1>

**This repository is a demonstration of the OEV Share system and a HoneyPot mechanism. It showcases how a backrunner can liquidate a position, in this particular case, how a HoneyPot can be emptied given a specific price change.**
**This repository is a demonstration of the Oval system and a HoneyPot mechanism. It showcases how a backrunner can liquidate a position, in this particular case, how a HoneyPot can be emptied given a specific price change.**

![Github Actions](https://github.com/UMAprotocol/oev-demo/workflows/CI/badge.svg)
![Github Actions](https://github.com/UMAprotocol/oval-demo/workflows/CI/badge.svg)

## Introduction

Expand All @@ -21,7 +21,7 @@ forge test`
## Contracts Overview

- **HoneyPot**: Represents the honey pot, which can be emptied when a price oracle returns a value different from a pre-defined liquidation price. The honey pot's funds can also be reset by its owner.
- **HoneyPotOEVShare**: Acts as the oracle which retrieves prices from various sources like Chainlink, Chronicle, and Pyth.
- **HoneyPotOval**: Acts as the oracle which retrieves prices from various sources like Chainlink, Chronicle, and Pyth.
- **Test Contract**: Sets up the environment, including simulating price changes and testing the mechanisms for creating and emptying the HoneyPot.

## Deploy the Contracts
Expand Down
2 changes: 1 addition & 1 deletion lib/oev-contracts
1 change: 1 addition & 0 deletions lib/oval-contracts
Submodule oval-contracts added at 25afc4
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
oval-contracts/=lib/oval-contracts/src/
oev-contracts/=lib/oev-contracts/src/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
10 changes: 5 additions & 5 deletions script/HoneyPot.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import "forge-std/Script.sol";

import {ChronicleMedianSourceMock} from "../src/mock/ChronicleMedianSourceMock.sol";
import {IMedian} from "oev-contracts/interfaces/chronicle/IMedian.sol";
import {HoneyPotOEVShare} from "../src/HoneyPotOEVShare.sol";
import {HoneyPotOval} from "../src/HoneyPotOval.sol";
import {HoneyPot} from "../src/HoneyPot.sol";
import {HoneyPotDAO} from "../src/HoneyPotDAO.sol";
import {IAggregatorV3Source} from "oev-contracts/interfaces/chainlink/IAggregatorV3Source.sol";
import {IAggregatorV3Source} from "oval-contracts/interfaces/chainlink/IAggregatorV3Source.sol";

contract HoneyPotDeploymentScript is Script {
HoneyPotOEVShare oevShare;
HoneyPotOval oval;
HoneyPot honeyPot;
HoneyPotDAO honeyPotDAO;
ChronicleMedianSourceMock chronicleMock;
Expand All @@ -32,15 +32,15 @@ contract HoneyPotDeploymentScript is Script {
// Create mock ChronicleMedianSource and set the latest source data.
chronicleMock = new ChronicleMedianSourceMock();

oevShare = new HoneyPotOEVShare(
oval = new HoneyPotOval(
chainlink,
address(chronicleMock),
pyth,
pythPriceId,
8
);

honeyPot = new HoneyPot(IAggregatorV3Source(address(oevShare)));
honeyPot = new HoneyPot(IAggregatorV3Source(address(oval)));

honeyPotDAO = new HoneyPotDAO();

Expand Down
4 changes: 2 additions & 2 deletions src/HoneyPot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.17;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IAggregatorV3Source} from "oev-contracts/interfaces/chainlink/IAggregatorV3Source.sol";
import {IAggregatorV3Source} from "oval-contracts/interfaces/chainlink/IAggregatorV3Source.sol";

contract HoneyPot is Ownable {
struct HoneyPotDetails {
Expand All @@ -12,7 +12,7 @@ contract HoneyPot is Ownable {
}

mapping(address => HoneyPotDetails) public honeyPots;
IAggregatorV3Source public oracle; // OEV Share serving as a Chainlink oracle
IAggregatorV3Source public oracle; // Oval serving as a Chainlink oracle

event OracleUpdated(address indexed newOracle);
event HoneyPotCreated(address indexed creator, int256 liquidationPrice, uint256 initialBalance);
Expand Down
2 changes: 1 addition & 1 deletion src/HoneyPotOEVShare.sol → src/HoneyPotOval.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IAggregatorV3Source} from "oev-contracts/interfaces/chainlink/IAggregato
import {IMedian} from "oev-contracts/interfaces/chronicle/IMedian.sol";
import {IPyth} from "oev-contracts/interfaces/pyth/IPyth.sol";

contract HoneyPotOEVShare is BaseController, BoundedUnionSourceAdapter, ChainlinkDestinationAdapter {
contract HoneyPotOval is BaseController, BoundedUnionSourceAdapter, ChainlinkDestinationAdapter {
constructor(
address chainlinkSource,
address chronicleSource,
Expand Down
26 changes: 13 additions & 13 deletions test/HoneyPot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity 0.8.17;

import {CommonTest} from "./Common.sol";
import {IAggregatorV3Source} from "oev-contracts/interfaces/chainlink/IAggregatorV3Source.sol";
import {IAggregatorV3Source} from "oval-contracts/interfaces/chainlink/IAggregatorV3Source.sol";
import {IMedian} from "oev-contracts/interfaces/chronicle/IMedian.sol";
import {IPyth} from "oev-contracts/interfaces/pyth/IPyth.sol";

import {HoneyPotOEVShare} from "../src/HoneyPotOEVShare.sol";
import {HoneyPotOval} from "../src/HoneyPotOval.sol";
import {HoneyPot} from "../src/HoneyPot.sol";
import {HoneyPotDAO} from "../src/HoneyPotDAO.sol";
import {ChronicleMedianSourceMock} from "../src/mock/ChronicleMedianSourceMock.sol";
Expand All @@ -26,7 +26,7 @@ contract HoneyPotTest is CommonTest {

ChronicleMedianSourceMock chronicleMock;

HoneyPotOEVShare oevShare;
HoneyPotOval oval;
HoneyPot honeyPot;
HoneyPotDAO honeyPotDAO;

Expand All @@ -35,26 +35,26 @@ contract HoneyPotTest is CommonTest {

function setUp() public {
vm.createSelectFork("mainnet", 18419040); // Recent block on mainnet
oevShare = new HoneyPotOEVShare(
oval = new HoneyPotOval(
address(chainlink),
address(chronicle),
address(pyth),
pythPriceId,
8
);

honeyPot = new HoneyPot(IAggregatorV3Source(address(oevShare)));
honeyPot = new HoneyPot(IAggregatorV3Source(address(oval)));
honeyPotDAO = new HoneyPotDAO();
_whitelistOnChronicle();
oevShare.setUnlocker(address(this), true);
oval.setUnlocker(address(this), true);
chronicleMock = new ChronicleMedianSourceMock();
}

receive() external payable {}

function _whitelistOnChronicle() internal {
vm.startPrank(0xBE8E3e3618f7474F8cB1d074A26afFef007E98FB); // DSPause that is a ward (can add kiss to chronicle)
chronicle.kiss(address(oevShare));
chronicle.kiss(address(oval));
chronicle.kiss(address(this)); // So that we can read Chronicle directly.
vm.stopPrank();
}
Expand Down Expand Up @@ -96,7 +96,7 @@ contract HoneyPotTest is CommonTest {

function testCrackHoneyPot() public {
// Create HoneyPot for the caller
(, int256 currentPrice,,,) = oevShare.latestRoundData();
(, int256 currentPrice,,,) = oval.latestRoundData();
vm.expectEmit(true, true, true, true);
emit HoneyPotCreated(address(this), currentPrice, honeyPotBalance);
honeyPot.createHoneyPot{value: honeyPotBalance}();
Expand All @@ -111,7 +111,7 @@ contract HoneyPotTest is CommonTest {
mockChainlinkPriceChange();

// Unlock the latest value
oevShare.unlockLatestValue();
oval.unlockLatestValue();

uint256 liquidatorBalanceBefore = liquidator.balance;

Expand Down Expand Up @@ -145,17 +145,17 @@ contract HoneyPotTest is CommonTest {
uint256 read = chronicle.read();
chronicleMock.setLatestSourceData(read, age);

HoneyPotOEVShare oevShare2 = new HoneyPotOEVShare(
HoneyPotOval oval2 = new HoneyPotOval(
address(chainlink),
address(chronicleMock),
address(pyth),
pythPriceId,
8
);
oevShare2.setUnlocker(address(this), true);
oval2.setUnlocker(address(this), true);

HoneyPot honeyPot2 = new HoneyPot(
IAggregatorV3Source(address(oevShare2))
IAggregatorV3Source(address(oval2))
);

// Create HoneyPot for the caller
Expand All @@ -171,7 +171,7 @@ contract HoneyPotTest is CommonTest {
chronicleMock.setLatestSourceData((read * 103) / 100, uint32(block.timestamp - 1));

// Unlock the latest value
oevShare2.unlockLatestValue();
oval2.unlockLatestValue();

uint256 liquidatorBalanceBefore = liquidator.balance;

Expand Down

0 comments on commit 46ac5ef

Please sign in to comment.