Skip to content

Commit

Permalink
rm deployer metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Jan 7, 2024
1 parent 63a2ed5 commit 839cd56
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 197 deletions.
10 changes: 2 additions & 8 deletions script/DeployGenericPoolOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
pragma solidity =0.8.19;

import {Script, console2} from "forge-std/Script.sol";
import {
GenericPoolOrderBookV3ArbOrderTaker,
DeployerDiscoverableMetaV3ConstructionConfig
} from "src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol";
import {GenericPoolOrderBookV3ArbOrderTaker} from "src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol";
import {I9R_DEPLOYER} from "./DeployConstants.sol";

/// @title DeployGenericPoolOrderBookV3ArbOrderTaker
Expand All @@ -16,11 +13,8 @@ contract DeployGenericPoolOrderBookV3ArbOrderTaker is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY");

bytes memory meta = hex"";

vm.startBroadcast(deployerPrivateKey);
GenericPoolOrderBookV3ArbOrderTaker deployed =
new GenericPoolOrderBookV3ArbOrderTaker(DeployerDiscoverableMetaV3ConstructionConfig(I9R_DEPLOYER, meta));
GenericPoolOrderBookV3ArbOrderTaker deployed = new GenericPoolOrderBookV3ArbOrderTaker(I9R_DEPLOYER);
(deployed);
vm.stopBroadcast();
}
Expand Down
10 changes: 2 additions & 8 deletions script/DeployGenericPoolOrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
pragma solidity =0.8.19;

import {Script, console2} from "forge-std/Script.sol";
import {
GenericPoolOrderBookV3FlashBorrower,
DeployerDiscoverableMetaV3ConstructionConfig
} from "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol";
import {GenericPoolOrderBookV3FlashBorrower} from "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol";
import {I9R_DEPLOYER} from "./DeployConstants.sol";

/// @title DeployGenericPoolOrderBookV3FlashBorrower
Expand All @@ -16,11 +13,8 @@ contract DeployGenericPoolOrderBookV3FlashBorrower is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY");

bytes memory meta = hex"";

vm.startBroadcast(deployerPrivateKey);
GenericPoolOrderBookV3FlashBorrower deployed =
new GenericPoolOrderBookV3FlashBorrower(DeployerDiscoverableMetaV3ConstructionConfig(I9R_DEPLOYER, meta));
GenericPoolOrderBookV3FlashBorrower deployed = new GenericPoolOrderBookV3FlashBorrower(I9R_DEPLOYER);
(deployed);
vm.stopBroadcast();
}
Expand Down
6 changes: 2 additions & 4 deletions script/DeployOrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
pragma solidity =0.8.19;

import {Script, console2} from "forge-std/Script.sol";
import {OrderBook, DeployerDiscoverableMetaV3ConstructionConfig} from "src/concrete/OrderBook.sol";
import {OrderBook} from "src/concrete/OrderBook.sol";
import {I9R_DEPLOYER} from "./DeployConstants.sol";

contract DeployOrderBook is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY");

bytes memory meta = hex"";

vm.startBroadcast(deployerPrivateKey);
OrderBook deployed = new OrderBook(DeployerDiscoverableMetaV3ConstructionConfig(I9R_DEPLOYER, meta));
OrderBook deployed = new OrderBook(I9R_DEPLOYER);
(deployed);
vm.stopBroadcast();
}
Expand Down
10 changes: 2 additions & 8 deletions script/DeployRouteProcessorOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
pragma solidity =0.8.19;

import {Script, console2} from "forge-std/Script.sol";
import {
RouteProcessorOrderBookV3ArbOrderTaker,
DeployerDiscoverableMetaV3ConstructionConfig
} from "src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol";
import {RouteProcessorOrderBookV3ArbOrderTaker} from "src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol";
import {I9R_DEPLOYER} from "./DeployConstants.sol";

/// @title DeployRouteProcessorOrderBookV3ArbOrderTaker
Expand All @@ -16,11 +13,8 @@ contract DeployRouteProcessorOrderBookV3ArbOrderTaker is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY");

bytes memory meta = hex"";

vm.startBroadcast(deployerPrivateKey);
RouteProcessorOrderBookV3ArbOrderTaker deployed =
new RouteProcessorOrderBookV3ArbOrderTaker(DeployerDiscoverableMetaV3ConstructionConfig(I9R_DEPLOYER, meta));
RouteProcessorOrderBookV3ArbOrderTaker deployed = new RouteProcessorOrderBookV3ArbOrderTaker(I9R_DEPLOYER);
(deployed);
vm.stopBroadcast();
}
Expand Down
13 changes: 4 additions & 9 deletions src/abstract/OrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {Initializable} from "openzeppelin-contracts/contracts/proxy/utils/Initializable.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";
import {
DeployerDiscoverableMetaV3,
DeployerDiscoverableMetaV3ConstructionConfig,
LibMeta
} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibDeployerDiscoverable} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {EvaluableConfigV3, SignedContextV1} from "rain.interpreter/src/interface/IInterpreterCallerV2.sol";
import {SourceIndexV2} from "rain.interpreter/src/interface/unstable/IInterpreterV2.sol";
import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/ICloneableV2.sol";
Expand Down Expand Up @@ -55,7 +51,6 @@ abstract contract OrderBookV3ArbOrderTaker is
ReentrancyGuard,
Initializable,
ICloneableV2,
DeployerDiscoverableMetaV3,
ERC165
{
using SafeERC20 for IERC20;
Expand All @@ -67,9 +62,9 @@ abstract contract OrderBookV3ArbOrderTaker is
IInterpreterV2 public sI9r;
IInterpreterStoreV1 public sI9rStore;

constructor(bytes32 metaHash, DeployerDiscoverableMetaV3ConstructionConfig memory config)
DeployerDiscoverableMetaV3(metaHash, config)
{
constructor(address deployer) {
LibDeployerDiscoverable.touchDeployerV3(deployer);

_disableInitializers();
}

Expand Down
13 changes: 4 additions & 9 deletions src/abstract/OrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
import {Initializable} from "openzeppelin-contracts/contracts/proxy/utils/Initializable.sol";
import {
DeployerDiscoverableMetaV3,
DeployerDiscoverableMetaV3ConstructionConfig,
LibMeta
} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibDeployerDiscoverable} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibEncodedDispatch, EncodedDispatch} from "rain.interpreter/src/lib/caller/LibEncodedDispatch.sol";
import {LibContext} from "rain.interpreter/src/lib/caller/LibContext.sol";
import {LibBytecode} from "rain.interpreter/src/lib/bytecode/LibBytecode.sol";
Expand Down Expand Up @@ -98,7 +94,6 @@ abstract contract OrderBookV3FlashBorrower is
ICloneableV2,
ReentrancyGuard,
Initializable,
DeployerDiscoverableMetaV3,
ERC165
{
using Address for address;
Expand All @@ -119,9 +114,9 @@ abstract contract OrderBookV3FlashBorrower is
/// The associated store for the interpreter.
IInterpreterStoreV1 public sI9rStore;

constructor(bytes32 metaHash, DeployerDiscoverableMetaV3ConstructionConfig memory config)
DeployerDiscoverableMetaV3(metaHash, config)
{
constructor(address deployer) {
LibDeployerDiscoverable.touchDeployerV3(deployer);

// Arb contracts are expected to be cloned proxies so allowing
// initialization of the implementation is a security risk.
_disableInitializers();
Expand Down
6 changes: 1 addition & 5 deletions src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.so
import {SafeERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "lib/openzeppelin-contracts/contracts/utils/Address.sol";

bytes32 constant CALLER_META_HASH = bytes32(0xe1d075e6f17f6706d942759ec359deb7f354ab4ac55e58eda2870c0ab3a89fa5);

contract GenericPoolOrderBookV3ArbOrderTaker is OrderBookV3ArbOrderTaker {
using SafeERC20 for IERC20;
using Address for address;

constructor(DeployerDiscoverableMetaV3ConstructionConfig memory config)
OrderBookV3ArbOrderTaker(CALLER_META_HASH, config)
{}
constructor(address deployer) OrderBookV3ArbOrderTaker(deployer) {}

/// @inheritdoc OrderBookV3ArbOrderTaker
function onTakeOrders(
Expand Down
26 changes: 14 additions & 12 deletions src/concrete/GenericPoolOrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.19;

import "src/interface/ierc3156/IERC3156FlashLender.sol";
import "src/interface/ierc3156/IERC3156FlashBorrower.sol";

import "src/abstract/OrderBookV3FlashBorrower.sol";

/// @dev Metadata hash for `DeployerDiscoverableMetaV1`.
/// - ABI for GenericPoolOrderBookV3FlashBorrower
/// - Interpreter caller metadata V1 for GenericPoolOrderBookV3FlashBorrower
bytes32 constant CALLER_META_HASH = bytes32(0x52cdec296c4ecb0b2452c9e314df50e1b5d52fef03927934b7426ff6f150f0fe);
import {IERC3156FlashLender} from "src/interface/ierc3156/IERC3156FlashLender.sol";
import {IERC3156FlashBorrower} from "src/interface/ierc3156/IERC3156FlashBorrower.sol";

import {
OrderBookV3FlashBorrower,
OrderBookV3FlashBorrowerConfigV2,
ICloneableV2,
MinimumOutput,
SafeERC20,
IERC20,
Address,
TakeOrdersConfigV2
} from "src/abstract/OrderBookV3FlashBorrower.sol";

/// @title GenericPoolOrderBookV3FlashBorrower
/// Implements the OrderBookV3FlashBorrower interface for a external liquidity
Expand All @@ -25,9 +29,7 @@ contract GenericPoolOrderBookV3FlashBorrower is OrderBookV3FlashBorrower {
using SafeERC20 for IERC20;
using Address for address;

constructor(DeployerDiscoverableMetaV3ConstructionConfig memory config)
OrderBookV3FlashBorrower(CALLER_META_HASH, config)
{}
constructor(address deployer) OrderBookV3FlashBorrower(deployer) {}

/// @inheritdoc OrderBookV3FlashBorrower
function _exchange(TakeOrdersConfigV2 memory takeOrders, bytes memory exchangeData) internal virtual override {
Expand Down
19 changes: 7 additions & 12 deletions src/concrete/OrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import {LibFixedPointDecimalArithmeticOpenZeppelin} from
import {LibFixedPointDecimalScale} from "rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol";
import {LibEncodedDispatch, EncodedDispatch} from "rain.interpreter/src/lib/caller/LibEncodedDispatch.sol";
import {LibContext} from "rain.interpreter/src/lib/caller/LibContext.sol";
import {
DeployerDiscoverableMetaV3,
DeployerDiscoverableMetaV3ConstructionConfig,
LibMeta
} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibDeployerDiscoverable} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibBytecode} from "rain.interpreter/src/lib/bytecode/LibBytecode.sol";
import {
SourceIndexV2, StateNamespace, IInterpreterV2
Expand All @@ -42,6 +38,8 @@ import {EvaluableV2} from "rain.interpreter/src/lib/caller/LibEvaluable.sol";
import {IInterpreterStoreV1} from "rain.interpreter/src/interface/IInterpreterStoreV1.sol";
import {IExpressionDeployerV3} from "rain.interpreter/src/interface/unstable/IExpressionDeployerV3.sol";
import {LibNamespace} from "rain.interpreter/src/lib/ns/LibNamespace.sol";
import {LibMeta} from "rain.metadata/LibMeta.sol";
import {IMetaV1} from "rain.metadata/IMetaV1.sol";

/// This will exist in a future version of Open Zeppelin if their main branch is
/// to be believed.
Expand Down Expand Up @@ -154,9 +152,6 @@ uint256 constant CONTEXT_VAULT_IO_BALANCE_DIFF = 4;
/// @dev Length of a vault IO column.
uint256 constant CONTEXT_VAULT_IO_ROWS = 5;

/// @dev Hash of the caller contract metadata for construction.
bytes32 constant CALLER_META_HASH = bytes32(0x4383dd3c5a557f161038940161f880963e1d4a31e8f2da771427b891956ad831);

/// All information resulting from an order calculation that allows for vault IO
/// to be calculated and applied, then the handle IO entrypoint to be dispatched.
/// @param outputMax The UNSCALED maximum output calculated by the order
Expand Down Expand Up @@ -203,7 +198,7 @@ type Input18Amount is uint256;

/// @title OrderBook
/// See `IOrderBookV1` for more documentation.
contract OrderBook is IOrderBookV3, ReentrancyGuard, Multicall, OrderBookV3FlashLender, DeployerDiscoverableMetaV3 {
contract OrderBook is IOrderBookV3, IMetaV1, ReentrancyGuard, Multicall, OrderBookV3FlashLender {
using LibUint256Array for uint256[];
using SafeERC20 for IERC20;
using LibOrder for OrderV2;
Expand Down Expand Up @@ -235,9 +230,9 @@ contract OrderBook is IOrderBookV3, ReentrancyGuard, Multicall, OrderBookV3Flash
/// Open Zeppelin upgradeable contracts. Orderbook itself does NOT support
/// factory deployments as each order is a unique expression deployment
/// rather than needing to wrap up expressions with proxies.
constructor(DeployerDiscoverableMetaV3ConstructionConfig memory config)
DeployerDiscoverableMetaV3(CALLER_META_HASH, config)
{}
constructor(address deployer) {
LibDeployerDiscoverable.touchDeployerV3(deployer);
}

/// @inheritdoc IOrderBookV3
function vaultBalance(address owner, address token, uint256 vaultId) external view override returns (uint256) {
Expand Down
14 changes: 7 additions & 7 deletions src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.19;

import "sushixswap-v2/src/interfaces/IRouteProcessor.sol";
import {IRouteProcessor} from "sushixswap-v2/src/interfaces/IRouteProcessor.sol";

import "../abstract/OrderBookV3ArbOrderTaker.sol";
import {
OrderBookV3ArbOrderTaker,
OrderBookV3ArbOrderTakerConfigV1,
MinimumOutput
} from "../abstract/OrderBookV3ArbOrderTaker.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "lib/openzeppelin-contracts/contracts/utils/Address.sol";

bytes32 constant CALLER_META_HASH = bytes32(0xb5923e408032e4f76298ae26c496091f2d8f16a7c968bbd5ee83bf90b5aca00e);

contract RouteProcessorOrderBookV3ArbOrderTaker is OrderBookV3ArbOrderTaker {
using SafeERC20 for IERC20;
using Address for address;

IRouteProcessor public sRouteProcessor;

constructor(DeployerDiscoverableMetaV3ConstructionConfig memory config)
OrderBookV3ArbOrderTaker(CALLER_META_HASH, config)
{}
constructor(address deployer) OrderBookV3ArbOrderTaker(deployer) {}

/// @inheritdoc OrderBookV3ArbOrderTaker
function _beforeInitialize(bytes memory data) internal virtual override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {GenericPoolOrderBookV3ArbOrderTakerTest} from "test/util/abstract/Generi

import {
GenericPoolOrderBookV3ArbOrderTaker,
DeployerDiscoverableMetaV3ConstructionConfig,
OrderBookV3ArbOrderTakerConfigV1,
MinimumOutput
} from "src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol";
Expand Down
14 changes: 4 additions & 10 deletions test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ pragma solidity =0.8.19;

import {ArbTest, ArbTestConstructorConfig} from "test/util/abstract/ArbTest.sol";

import {GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_META_PATH} from
"test/util/lib/LibGenericPoolOrderBookV3FlashBorrowerConstants.sol";

import {
GenericPoolOrderBookV3FlashBorrower,
DeployerDiscoverableMetaV3ConstructionConfig,
CALLER_META_HASH as GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_CALLER_META_HASH,
MinimumOutput,
ICloneableV2,
OrderBookV3FlashBorrowerConfigV2
Expand All @@ -24,11 +19,10 @@ import {

contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest {
function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) {
(address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = buildConstructorConfig(
GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_META_PATH,
GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_CALLER_META_HASH
);
return ArbTestConstructorConfig(deployer, address(new GenericPoolOrderBookV3FlashBorrower(config)));
address deployer = buildConstructorConfig();
address iArb = address(new GenericPoolOrderBookV3FlashBorrower(deployer));
vm.label(iArb, "iArb");
return ArbTestConstructorConfig(deployer, iArb);
}

constructor() ArbTest(buildArbTestConstructorConfig()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from "src/interface/unstable/IOrderBookV3.sol";
import {
RouteProcessorOrderBookV3ArbOrderTaker,
DeployerDiscoverableMetaV3ConstructionConfig,
OrderBookV3ArbOrderTakerConfigV1,
MinimumOutput
} from "src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol";
Expand Down
Loading

0 comments on commit 839cd56

Please sign in to comment.