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

refactoring multiple prs on other into this one #3

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions deployment-config/mydeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,21 @@
"address": "0x00000000004F96C07B83e86600D86F0000000000"
},

"queue": {
"queueSalt": "0x69b369df5a15ed01cbbf40000000000000000000000000000000000000000000",
"address": "0x000000000012475236b87af9d3ffc0de73cb6a50"
},

"solver": {
"solverSalt": "0xd800db1e20957502752abd000000000000000000000000000000000000000000",
"address": "0x000000000017b37cc62fed0df40bc89030643f62"
},

"rolesAuthority": {
"rolesAuthoritySalt": "0x66bbc3b3b3000b01466a3a00000000000000000000000000000000000000000a",
"strategist": "0xC2d99d76bb9D46BF8Ec9449E4DfAE48C30CF0839",
"exchangeRateBot": "0x00000000004F96C07B83e86600D86F0000000000",
"solverBot": "0x00000000004F96C07B83e86600D86F0000000000",

"address": "0x00000000004F96C07B83e86600D86F0000000000"
},
Expand Down
1 change: 0 additions & 1 deletion lib/foundry-arbitrum
Submodule foundry-arbitrum deleted from 1ff06d
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable updated from 2d081f to 723f8c
14 changes: 14 additions & 0 deletions script/ConfigReader.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ library ConfigReader {
address[] rateProviders;
address[] priceFeeds;
address base;
bytes32 queueSalt;
address queue;
bytes32 solverSalt;
address solver;
address solverBot;
}

function toConfig(string memory _config, string memory _chainConfig) internal pure returns (Config memory config) {
Expand Down Expand Up @@ -83,11 +88,20 @@ library ConfigReader {
config.assets = _config.readAddressArray(".teller.assets");
config.peerEid = uint32(_config.readUint(".teller.peerEid"));

// Reading from the 'queue' section
config.queueSalt = _config.readBytes32(".queue.queueSalt");
config.queue = _config.readAddress(".queue.address");

// Reading from the 'solver' section
config.solverSalt = _config.readBytes32(".solver.solverSalt");
config.solver = _config.readAddress(".solver.address");

// Reading from the 'rolesAuthority' section
config.rolesAuthority = _config.readAddress(".rolesAuthority.address");
config.rolesAuthoritySalt = _config.readBytes32(".rolesAuthority.rolesAuthoritySalt");
config.strategist = _config.readAddress(".rolesAuthority.strategist");
config.exchangeRateBot = _config.readAddress(".rolesAuthority.exchangeRateBot");
config.solverBot = _config.readAddress(".rolesAuthority.solverBot");

// Reading from the 'decoder' section
config.decoderSalt = _config.readBytes32(".decoder.decoderSalt");
Expand Down
14 changes: 11 additions & 3 deletions script/deploy/deployAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { DeployCrossChainOPTellerWithMultiAssetSupport } from
"./single/05a_DeployCrossChainOPTellerWithMultiAssetSupport.s.sol";
import { DeployMultiChainLayerZeroTellerWithMultiAssetSupport } from
"./single/05b_DeployMultiChainLayerZeroTellerWithMultiAssetSupport.s.sol";
import { DeployRolesAuthority } from "./single/06_DeployRolesAuthority.s.sol";
import { TellerSetup } from "./single/07_TellerSetup.s.sol";
import { SetAuthorityAndTransferOwnerships } from "./single/08_SetAuthorityAndTransferOwnerships.s.sol";
import { DeployAtomicQueueV2 } from "./single/06_DeployAtomicQueueV2.s.sol";
import { DeployAtomicSolverV4 } from "./single/07_DeployAtomicSolverV4.s.sol";
import { DeployRolesAuthority } from "./single/08_DeployRolesAuthority.s.sol";
import { TellerSetup } from "./single/09_TellerSetup.s.sol";
import { SetAuthorityAndTransferOwnerships } from "./single/10_SetAuthorityAndTransferOwnerships.s.sol";

import { ConfigReader, IAuthority } from "../ConfigReader.s.sol";
import { console } from "forge-std/console.sol";
Expand Down Expand Up @@ -77,6 +79,12 @@ contract DeployAll is BaseScript {
new TellerSetup().deploy(config);
console.log("Teller setup complete");

address queue = new DeployAtomicQueueV2().deploy(config);
config.queue = queue;

address solver = new DeployAtomicSolverV4().deploy(config);
config.solver = solver;

address rolesAuthority = new DeployRolesAuthority().deploy(config);
config.rolesAuthority = rolesAuthority;
console.log("Roles Authority: ", rolesAuthority);
Expand Down
27 changes: 27 additions & 0 deletions script/deploy/single/06_DeployAtomicQueueV2.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { AtomicQueueV2 } from "./../../../src/atomic-queue/AtomicQueueV2.sol";
import { BaseScript } from "../../Base.s.sol";
import { stdJson as StdJson } from "forge-std/StdJson.sol";
import { ConfigReader } from "../../ConfigReader.s.sol";

contract DeployAtomicQueueV2 is BaseScript {
using StdJson for string;

function run() public returns (address manager) {
manager = deploy(getConfig());
}

function deploy(ConfigReader.Config memory config) public override broadcast returns (address) {
// Require config Values
require(config.queueSalt != bytes32(0), "queue salt must not be zero");

// Create Contract
bytes memory creationCode = type(AtomicQueueV2).creationCode;

AtomicQueueV2 queue = AtomicQueueV2(CREATEX.deployCreate3(config.queueSalt, abi.encodePacked(creationCode)));

return address(queue);
}
}
29 changes: 29 additions & 0 deletions script/deploy/single/07_DeployAtomicSolverV4.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { AtomicSolverV4 } from "./../../../src/atomic-queue/AtomicSolverV4.sol";
import { BaseScript } from "../../Base.s.sol";
import { stdJson as StdJson } from "forge-std/StdJson.sol";
import { ConfigReader } from "../../ConfigReader.s.sol";

contract DeployAtomicSolverV4 is BaseScript {
using StdJson for string;

function run() public returns (address manager) {
manager = deploy(getConfig());
}

function deploy(ConfigReader.Config memory config) public override broadcast returns (address) {
// Require config Values
require(config.solverSalt != bytes32(0), "solver salt must not be zero");

// Create Contract
bytes memory creationCode = type(AtomicSolverV4).creationCode;

AtomicSolverV4 solver = AtomicSolverV4(
CREATEX.deployCreate3(config.solverSalt, abi.encodePacked(creationCode, abi.encode(broadcaster)))
);

return address(solver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ManagerWithMerkleVerification } from "./../../../src/base/Roles/Manager
import { BoringVault } from "./../../../src/base/BoringVault.sol";
import { TellerWithMultiAssetSupport } from "./../../../src/base/Roles/TellerWithMultiAssetSupport.sol";
import { AccountantWithRateProviders } from "./../../../src/base/Roles/AccountantWithRateProviders.sol";
import { AtomicSolverV4 } from "./../../../src/atomic-queue/AtomicSolverV4.sol";
import { BaseScript } from "../../Base.s.sol";
import { ConfigReader } from "../../ConfigReader.s.sol";
import { CrossChainTellerBase } from "../../../src/base/Roles/CrossChain/CrossChainTellerBase.sol";
Expand All @@ -21,6 +22,9 @@ contract DeployRolesAuthority is BaseScript {
uint8 public constant MANAGER_ROLE = 2;
uint8 public constant TELLER_ROLE = 3;
uint8 public constant UPDATE_EXCHANGE_RATE_ROLE = 4;
uint8 public constant SOLVER_ROLE = 5;
uint8 public constant QUEUE_ROLE = 6; // queue role is for calling finishSolve in solver
uint8 public constant SOLVER_CALLER_ROLE = 7;

function run() public virtual returns (address rolesAuthority) {
return deploy(getConfig());
Expand All @@ -32,6 +36,8 @@ contract DeployRolesAuthority is BaseScript {
require(config.manager.code.length != 0, "manager must have code");
require(config.teller.code.length != 0, "teller must have code");
require(config.accountant.code.length != 0, "accountant must have code");
require(config.queue.code.length != 0, "queue must have code");
require(config.solver.code.length != 0, "solver must have code");
require(config.boringVault != address(0), "boringVault");
require(config.manager != address(0), "manager");
require(config.teller != address(0), "teller");
Expand All @@ -58,6 +64,10 @@ contract DeployRolesAuthority is BaseScript {
// 1. VAULT_STRATEGIST (BOT EOA)
// 2. MANAGER (CONTRACT)
// 3. TELLER (CONTRACT)
// 4. EXCHANGE_RATE_BOT (BOT EOA)
// 5. SOLVER (CONTRACT)
// 6. QUEUE (CONTRACT)
// 7. SOLVER_BOT (BOT EOA)
// --- Roles ---
// 1. STRATEGIST_ROLE
// - manager.manageVaultWithMerkleVerification
Expand All @@ -69,6 +79,16 @@ contract DeployRolesAuthority is BaseScript {
// - boringVault.enter()
// - boringVault.exit()
// - assigned to TELLER
// 5. SOLVER_ROLE
// - teller.bulkWithdraw
// - assigned to SOLVER
// 6. QUEUE_ROLE
// - solver.finshSolve
// - assigned to QUEUE
// 7. SOLVER_CALLER_ROLE
// - solver.p2pSolve
// - solver.redeemSolve
// - assigned to SOLVER_BOT
// --- Public ---
// 1. teller.deposit
rolesAuthority.setRoleCapability(
Expand Down Expand Up @@ -101,6 +121,16 @@ contract DeployRolesAuthority is BaseScript {
UPDATE_EXCHANGE_RATE_ROLE, config.accountant, AccountantWithRateProviders.updateExchangeRate.selector, true
);

rolesAuthority.setRoleCapability(
SOLVER_ROLE, config.teller, TellerWithMultiAssetSupport.bulkWithdraw.selector, true
);

rolesAuthority.setRoleCapability(QUEUE_ROLE, config.solver, AtomicSolverV4.finishSolve.selector, true);

rolesAuthority.setRoleCapability(SOLVER_CALLER_ROLE, config.solver, AtomicSolverV4.p2pSolve.selector, true);

rolesAuthority.setRoleCapability(SOLVER_CALLER_ROLE, config.solver, AtomicSolverV4.redeemSolve.selector, true);

// --- Assign roles to users ---

rolesAuthority.setUserRole(config.strategist, STRATEGIST_ROLE, true);
Expand All @@ -111,6 +141,12 @@ contract DeployRolesAuthority is BaseScript {

rolesAuthority.setUserRole(config.exchangeRateBot, UPDATE_EXCHANGE_RATE_ROLE, true);

rolesAuthority.setUserRole(config.solver, SOLVER_ROLE, true);

rolesAuthority.setUserRole(config.queue, QUEUE_ROLE, true);

rolesAuthority.setUserRole(config.solverBot, SOLVER_CALLER_ROLE, true);

// Post Deploy Checks
require(
rolesAuthority.doesUserHaveRole(config.strategist, STRATEGIST_ROLE),
Expand All @@ -122,6 +158,12 @@ contract DeployRolesAuthority is BaseScript {
rolesAuthority.doesUserHaveRole(config.exchangeRateBot, UPDATE_EXCHANGE_RATE_ROLE),
"exchangeRateBot should have UPDATE_EXCHANGE_RATE_ROLE"
);
require(rolesAuthority.doesUserHaveRole(config.solver, SOLVER_ROLE), "solver should have SOLVER_ROLE");
require(rolesAuthority.doesUserHaveRole(config.queue, QUEUE_ROLE), "queue should have QUEUE_ROLE");
require(
rolesAuthority.doesUserHaveRole(config.solverBot, SOLVER_CALLER_ROLE),
"solverBot should have SOLVER_CALLER_ROLE"
);
require(
rolesAuthority.canCall(
config.strategist,
Expand Down Expand Up @@ -158,6 +200,22 @@ contract DeployRolesAuthority is BaseScript {
),
"exchangeRateBot should be able to call accountant.updateExchangeRate"
);
require(
rolesAuthority.canCall(config.solver, config.teller, TellerWithMultiAssetSupport.bulkWithdraw.selector),
"solver should be able to call teller.bulkWithdraw"
);
require(
rolesAuthority.canCall(config.queue, config.solver, AtomicSolverV4.finishSolve.selector),
"queue should be able to call solver.finishSolve"
);
require(
rolesAuthority.canCall(config.solverBot, config.solver, AtomicSolverV4.p2pSolve.selector),
"solverBot should be able to call solver.p2pSolve"
);
require(
rolesAuthority.canCall(config.solverBot, config.solver, AtomicSolverV4.redeemSolve.selector),
"solverBot should be able to call solver.redeemSolve"
);
require(
rolesAuthority.canCall(address(1), config.teller, TellerWithMultiAssetSupport.deposit.selector),
"anyone should be able to call teller.deposit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract SetAuthorityAndTransferOwnerships is BaseScript {
require(address(config.manager).code.length != 0, "manager must have code");
require(address(config.teller).code.length != 0, "teller must have code");
require(address(config.accountant).code.length != 0, "accountant must have code");
require(address(config.solver).code.length != 0, "solver must have code");
require(address(config.boringVault) != address(0), "boringVault");
require(address(config.manager) != address(0), "manager");
require(address(config.accountant) != address(0), "accountant");
Expand All @@ -34,16 +35,19 @@ contract SetAuthorityAndTransferOwnerships is BaseScript {
IAuthority(config.accountant).setAuthority(config.rolesAuthority);
IAuthority(config.manager).setAuthority(config.rolesAuthority);
IAuthority(config.teller).setAuthority(config.rolesAuthority);
IAuthority(config.solver).setAuthority(config.rolesAuthority);
IAuthority(config.boringVault).transferOwnership(config.protocolAdmin);
IAuthority(config.manager).transferOwnership(config.protocolAdmin);
IAuthority(config.accountant).transferOwnership(config.protocolAdmin);
IAuthority(config.teller).transferOwnership(config.protocolAdmin);
IAuthority(config.solver).transferOwnership(config.protocolAdmin);
IAuthority(config.rolesAuthority).transferOwnership(config.protocolAdmin);

// Post Configuration Check
require(IAuthority(config.boringVault).owner() == config.protocolAdmin, "boringVault");
require(IAuthority(config.manager).owner() == config.protocolAdmin, "manager");
require(IAuthority(config.accountant).owner() == config.protocolAdmin, "accountant");
require(IAuthority(config.teller).owner() == config.protocolAdmin, "teller");
require(IAuthority(config.solver).owner() == config.protocolAdmin, "solver");
}
}
30 changes: 30 additions & 0 deletions script/deploy/single/11_DeployDecoderAndSanitizer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { IonPoolDecoderAndSanitizer } from "../../src/base/DecodersAndSanitizers/IonPoolDecoderAndSanitizer.sol";
import { BaseScript } from "../Base.s.sol";
import { stdJson as StdJson } from "@forge-std/StdJson.sol";
import { ConfigReader } from "../ConfigReader.s.sol";

contract DeployDecoderAndSanitizer is BaseScript {
using StdJson for string;

function run() public returns (address decoder) {
return deploy(getConfig());
}

function deploy(ConfigReader.Config memory config) public override broadcast returns (address) {
// Require config Values
require(config.boringVault.code.length != 0, "boringVault must have code");
require(config.decoderSalt != bytes32(0), "decoder salt must not be zero");
require(config.boringVault != address(0), "boring vault must be set");

// Create Contract
bytes memory creationCode = type(IonPoolDecoderAndSanitizer).creationCode;
IonPoolDecoderAndSanitizer decoder = IonPoolDecoderAndSanitizer(
CREATEX.deployCreate3(config.decoderSalt, abi.encodePacked(creationCode, abi.encode(config.boringVault)))
);

return address(decoder);
}
}
Loading