-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: honeypotdao and deployment script (#5)
Signed-off-by: Evaldo Felipe <contato@evaldofelipe.com> Signed-off-by: Pablo Maldonado <pablo@umaproject.org> Co-authored-by: Evaldo Felipe <contato@evaldofelipe.com>
- Loading branch information
1 parent
ccf1f9b
commit 3ee5280
Showing
6 changed files
with
197 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
cache/ | ||
out/ | ||
broadcast/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/console2.sol"; | ||
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 {HoneyPot} from "../src/HoneyPot.sol"; | ||
import {HoneyPotDAO} from "../src/HoneyPotDAO.sol"; | ||
import {IAggregatorV3Source} from "oev-contracts/interfaces/chainlink/IAggregatorV3Source.sol"; | ||
|
||
contract HoneyPotDeploymentScript is Script { | ||
HoneyPotOEVShare oevShare; | ||
HoneyPot honeyPot; | ||
HoneyPotDAO honeyPotDAO; | ||
ChronicleMedianSourceMock chronicleMock; | ||
|
||
function run() external { | ||
vm.startBroadcast(); | ||
|
||
address chainlink = vm.envOr("CHAINLINK_SOURCE", 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); | ||
address pyth = vm.envOr("PYTH_SOURCE", 0x4305FB66699C3B2702D4d05CF36551390A4c69C6); | ||
|
||
bytes32 defaultId = 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace; | ||
bytes32 pythPriceId = vm.envOr("PYTH_PRICE_ID", bytes32(0)); | ||
if (pythPriceId == bytes32(0)) { | ||
pythPriceId = defaultId; | ||
} | ||
|
||
// Create mock ChronicleMedianSource and set the latest source data. | ||
chronicleMock = new ChronicleMedianSourceMock(); | ||
|
||
oevShare = new HoneyPotOEVShare( | ||
chainlink, | ||
address(chronicleMock), | ||
pyth, | ||
pythPriceId, | ||
8 | ||
); | ||
|
||
honeyPot = new HoneyPot(IAggregatorV3Source(address(oevShare))); | ||
|
||
honeyPotDAO = new HoneyPotDAO(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity 0.8.17; | ||
|
||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
contract HoneyPotDAO is Ownable { | ||
// Define events | ||
event ReceivedEther(address sender, uint256 amount); | ||
event DrainedEther(address to, uint256 amount); | ||
|
||
receive() external payable { | ||
emit ReceivedEther(msg.sender, msg.value); | ||
} | ||
|
||
function drain() external onlyOwner { | ||
uint256 balance = address(this).balance; | ||
Address.sendValue(payable(owner()), balance); | ||
emit DrainedEther(owner(), balance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity 0.8.17; | ||
|
||
import {IMedian} from "oev-contracts/interfaces/chronicle/IMedian.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract ChronicleMedianSourceMock is IMedian, Ownable { | ||
uint256 public value; | ||
uint32 public ageValue; | ||
|
||
function age() external view returns (uint32) { | ||
return ageValue; | ||
} | ||
|
||
function read() external view returns (uint256) { | ||
return value; | ||
} | ||
|
||
function peek() external view returns (uint256, bool) { | ||
return (value, true); | ||
} | ||
|
||
function setLatestSourceData(uint256 _value, uint32 _age) public onlyOwner { | ||
value = _value; | ||
ageValue = _age; | ||
} | ||
|
||
function kiss(address) external override {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters