Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate HorizonAccountingExtension #37

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "forge build",
"build:optimized": "FOUNDRY_PROFILE=optimized forge build",
"coverage": "forge coverage --report summary --report lcov --match-path 'test/unit/*'",
"deploy:arbitrum": "bash -c 'source .env && forge script Deploy --rpc-url $ARBITRUM_RPC --account $ARBITRUM_DEPLOYER_NAME --broadcast --verify --chain arbitrum -vvvvv'",
"deploy:arbitrum": "bash -c 'source .env && forge script Deploy --rpc-url arbitrum --account $ARBITRUM_DEPLOYER_NAME --broadcast --verify --chain arbitrum -vvvvv'",
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
"lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js",
Expand Down
23 changes: 17 additions & 6 deletions script/Constants.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

// Contracts
address constant _GRAPH_TOKEN = 0x9623063377AD1B27544C965cCd7342f7EA7e88C7;
address constant _EPOCH_MANAGER = 0x5A843145c43d328B9bB7a4401d94918f131bB281;
// Arbitrum One
address constant _ARBITRUM_MAINNET_GRAPH_TOKEN = 0x9623063377AD1B27544C965cCd7342f7EA7e88C7;
address constant _ARBITRUM_MAINNET_HORIZON_STAKING = address(0x0);
address constant _ARBITRUM_MAINNET_EPOCH_MANAGER = 0x5A843145c43d328B9bB7a4401d94918f131bB281;
address constant _ARBITRUM_MAINNET_GOVERNOR = address(0x0);
address constant _ARBITRUM_MAINNET_ARBITRATOR = address(0x100);
address constant _ARBITRUM_MAINNET_COUNCIL = address(0x101);

// TODO: EOAs
address constant _ARBITRATOR = address(0x100);
address constant _COUNCIL = address(0x101);
// Arbitrum Sepolia
address constant _ARBITRUM_SEPOLIA_GRAPH_TOKEN = 0x1A1af8B44fD59dd2bbEb456D1b7604c7bd340702;
address constant _ARBITRUM_SEPOLIA_HORIZON_STAKING = 0x3F53F9f9a5d7F36dCC869f8D2F227499c411c0cf;
address constant _ARBITRUM_SEPOLIA_EPOCH_MANAGER = 0x7975475801BEf845f10Ce7784DC69aB1e0344f11;
address constant _ARBITRUM_SEPOLIA_GOVERNOR = 0xadE6B8EB69a49B56929C1d4F4b428d791861dB6f;
address constant _ARBITRUM_SEPOLIA_ARBITRATOR = address(0x100);
address constant _ARBITRUM_SEPOLIA_COUNCIL = address(0x101);

// Data
uint64 constant _MIN_THAWING_PERIOD = 3 days;
64 changes: 41 additions & 23 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
pragma solidity 0.8.26;

import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol';
import {
BondEscalationAccounting,
IBondEscalationAccounting
} from '@defi-wonderland/prophet-modules/solidity/contracts/extensions/BondEscalationAccounting.sol';
import {
BondEscalationModule,
IBondEscalationModule
Expand All @@ -18,16 +14,29 @@ import {
BondedResponseModule,
IBondedResponseModule
} from '@defi-wonderland/prophet-modules/solidity/contracts/modules/response/BondedResponseModule.sol';
import {
IAccountingExtension,
IBondEscalationAccounting
} from '@defi-wonderland/prophet-modules/solidity/interfaces/extensions/IBondEscalationAccounting.sol';
import {IERC20} from '@openzeppelin/contracts/interfaces/IERC20.sol';
import {IEpochManager} from 'interfaces/external/IEpochManager.sol';
import {IHorizonStaking} from 'interfaces/external/IHorizonStaking.sol';

import {Arbitrable, IArbitrable} from 'contracts/Arbitrable.sol';
import {CouncilArbitrator, ICouncilArbitrator} from 'contracts/CouncilArbitrator.sol';
import {EBOFinalityModule, IEBOFinalityModule} from 'contracts/EBOFinalityModule.sol';
import {EBORequestCreator, IEBORequestCreator} from 'contracts/EBORequestCreator.sol';
import {EBORequestModule, IEBORequestModule} from 'contracts/EBORequestModule.sol';
import {HorizonAccountingExtension, IHorizonAccountingExtension} from 'contracts/HorizonAccountingExtension.sol';

import {_ARBITRATOR, _COUNCIL, _EPOCH_MANAGER, _GRAPH_TOKEN} from './Constants.sol';
import {
_ARBITRUM_SEPOLIA_ARBITRATOR,
_ARBITRUM_SEPOLIA_COUNCIL,
_ARBITRUM_SEPOLIA_EPOCH_MANAGER,
_ARBITRUM_SEPOLIA_GRAPH_TOKEN,
_ARBITRUM_SEPOLIA_HORIZON_STAKING,
_MIN_THAWING_PERIOD
} from 'script/Constants.sol';

import 'forge-std/Script.sol';

Expand All @@ -38,9 +47,6 @@ contract Deploy is Script {
// Oracle
IOracle public oracle;

// Arbitrable
IArbitrable public arbitrable;

// Modules
IEBORequestModule public eboRequestModule;
IBondedResponseModule public bondedResponseModule;
Expand All @@ -49,14 +55,16 @@ contract Deploy is Script {
IEBOFinalityModule public eboFinalityModule;

// Extensions
IBondEscalationAccounting public bondEscalationAccounting;
IHorizonAccountingExtension public horizonAccountingExtension;

// Periphery
IEBORequestCreator public eboRequestCreator;
ICouncilArbitrator public councilArbitrator;
IArbitrable public arbitrable;

// The Graph
IERC20 public graphToken;
IHorizonStaking public horizonStaking;
IEpochManager public epochManager;
address public arbitrator;
address public council;
Expand All @@ -76,20 +84,23 @@ contract Deploy is Script {

function setUp() public virtual {
// Define The Graph accounts
graphToken = IERC20(_GRAPH_TOKEN);
epochManager = IEpochManager(_EPOCH_MANAGER);
arbitrator = _ARBITRATOR;
council = _COUNCIL;
graphToken = IERC20(_ARBITRUM_SEPOLIA_GRAPH_TOKEN);
horizonStaking = IHorizonStaking(_ARBITRUM_SEPOLIA_HORIZON_STAKING);
epochManager = IEpochManager(_ARBITRUM_SEPOLIA_EPOCH_MANAGER);
arbitrator = _ARBITRUM_SEPOLIA_ARBITRATOR;
council = _ARBITRUM_SEPOLIA_COUNCIL;

// TODO: Set production request module params
// Set request module params
paymentAmount = 0 ether;

// TODO: Set production response module params
// Set response module params
// TODO: Review production params (responseBondSize == disputeBondSize)
responseBondSize = 0.5 ether;
responseDeadline = block.timestamp + 5 days;
responseDisputeWindow = block.timestamp + 1 weeks;
0xShaito marked this conversation as resolved.
Show resolved Hide resolved

// TODO: Set production dispute module params
// Set dispute module params
// TODO: Review production params (disputeBondSize == responseBondSize)
disputeBondSize = 0.3 ether;
maxNumberOfEscalations = 2;
disputeDeadline = block.timestamp + 10 days;
Expand All @@ -109,7 +120,7 @@ contract Deploy is Script {
console.log('`Oracle` deployed at:', address(oracle));

// Deploy `Arbitrable`
arbitrable = new Arbitrable(_ARBITRATOR, _COUNCIL);
arbitrable = new Arbitrable(arbitrator, council);
console.log('`Arbitrable` deployed at:', address(arbitrable));

// Deploy `EBORequestModule`
Expand All @@ -132,9 +143,11 @@ contract Deploy is Script {
eboFinalityModule = new EBOFinalityModule(oracle, _precomputedEBORequestCreator, arbitrable);
console.log('`EBOFinalityModule` deployed at:', address(eboFinalityModule));

// Deploy `BondEscalationAccounting`
bondEscalationAccounting = new BondEscalationAccounting(oracle);
console.log('`BondEscalationAccounting` deployed at:', address(bondEscalationAccounting));
// Deploy `HorizonAccountingExtension`
address[] memory _authorizedCallers = _instantiateAuthorizedCallers();
horizonAccountingExtension =
new HorizonAccountingExtension(horizonStaking, oracle, graphToken, _MIN_THAWING_PERIOD, _authorizedCallers);
console.log('`HorizonAccountingExtension` deployed at:', address(horizonAccountingExtension));

// Deploy `CouncilArbitrator`
councilArbitrator = new CouncilArbitrator(arbitratorModule, arbitrable);
Expand Down Expand Up @@ -179,7 +192,7 @@ contract Deploy is Script {
view
returns (IEBORequestModule.RequestParameters memory _requestParams)
{
_requestParams.accountingExtension = bondEscalationAccounting;
_requestParams.accountingExtension = IAccountingExtension(address(horizonAccountingExtension));
_requestParams.paymentAmount = paymentAmount;
}

Expand All @@ -188,7 +201,7 @@ contract Deploy is Script {
view
returns (IBondedResponseModule.RequestParameters memory _responseParams)
{
_responseParams.accountingExtension = bondEscalationAccounting;
_responseParams.accountingExtension = IAccountingExtension(address(horizonAccountingExtension));
_responseParams.bondToken = graphToken;
_responseParams.bondSize = responseBondSize;
_responseParams.deadline = responseDeadline;
Expand All @@ -200,7 +213,7 @@ contract Deploy is Script {
view
returns (IBondEscalationModule.RequestParameters memory _disputeParams)
{
_disputeParams.accountingExtension = bondEscalationAccounting;
_disputeParams.accountingExtension = IBondEscalationAccounting(address(horizonAccountingExtension));
_disputeParams.bondToken = graphToken;
_disputeParams.bondSize = disputeBondSize;
_disputeParams.maxNumberOfEscalations = maxNumberOfEscalations;
Expand All @@ -217,6 +230,11 @@ contract Deploy is Script {
_resolutionParams.arbitrator = address(councilArbitrator);
}

function _instantiateAuthorizedCallers() internal view returns (address[] memory _authorizedCallers) {
_authorizedCallers = new address[](1);
_authorizedCallers[0] = address(bondEscalationModule);
}

function _precomputeCreateAddress(uint256 _deploymentOffset) internal view virtual returns (address _targetAddress) {
// Get nonce for the target deployment
uint256 _targetNonce = vm.getNonce(tx.origin) + _deploymentOffset;
Expand Down
Loading