From f61c318a0b8def0192e8b1d36bf0e24d71ba1e40 Mon Sep 17 00:00:00 2001 From: Tim Olson <> Date: Fri, 13 Oct 2023 01:48:42 -0400 Subject: [PATCH] order state tweak --- bin/build.sh | 4 ++-- bin/deploy.sh | 3 ++- bin/mock.sh | 2 +- src/OrderLib.sol | 5 ++--- src/OrderStatus.sol | 11 ----------- src/VaultAddress.sol | 2 +- 6 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 src/OrderStatus.sol diff --git a/bin/build.sh b/bin/build.sh index 6e9302d..3ffb85c 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -2,7 +2,7 @@ # this script requires the jq command $(sudo apt install jq) # first-pass build -forge build "$@" +forge build "$@" || exit 1 # calculate the Vault init code hash using the bytecode generated for Vault # shellcheck disable=SC2046 @@ -16,4 +16,4 @@ mkdir gen &> /dev/null echo "export const VAULT_INIT_CODE_HASH='$VAULT_INIT_CODE_HASH';" > gen/vaultHash.js # final build after hash values are set -forge build "$@" +forge build "$@" || exit 1 diff --git a/bin/deploy.sh b/bin/deploy.sh index 9fa3e6b..0839ddc 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash -./bin/build.sh +./bin/build.sh || exit 1 +PRIVATE_KEY=${PRIVATE_KEY:='0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'} forge script script/Deploy.sol -vvvv --fork-url http://localhost:8545 --broadcast diff --git a/bin/mock.sh b/bin/mock.sh index 092c25f..88f3810 100755 --- a/bin/mock.sh +++ b/bin/mock.sh @@ -5,7 +5,7 @@ #db-migrate up #cd ../contract -#source ./bin/build.sh +#./bin/build.sh anvil -f arbitrum_ankr --chain-id 1338 & # todo check anvil result ANVIL_PID=$! diff --git a/src/OrderLib.sol b/src/OrderLib.sol index e4c618b..67c40d8 100644 --- a/src/OrderLib.sol +++ b/src/OrderLib.sol @@ -21,9 +21,8 @@ library OrderLib { event DexorderSwapError (uint64 orderIndex, string reason); - // todo If a tranche fails to fill, an order can stay Open forever without any active tranches. maybe replace state with a simple canceled flag enum SwapOrderState { - Open, Canceled, Filled, Template + Open, Canceled, Filled, Expired // Expired isn't ever shown on-chain. the Expired state is implied by tranche constraints. } enum Exchange { @@ -297,7 +296,7 @@ library OrderLib { function _cancelOrder(OrdersInfo storage self, uint64 orderIndex) internal { SwapOrderState state = self.orders[orderIndex].state; - if( state == SwapOrderState.Open || state == SwapOrderState.Template ) { + if( state == SwapOrderState.Open ) { self.orders[orderIndex].state = SwapOrderState.Canceled; emit DexorderSwapCompleted(orderIndex); } diff --git a/src/OrderStatus.sol b/src/OrderStatus.sol deleted file mode 100644 index 1e553db..0000000 --- a/src/OrderStatus.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.7.6; -pragma abicoder v2; - - -enum OrderStatus { - ACTIVE, // the only status while the order is still executing - CANCELED, // canceled by the owner - FILLED, // full trade amount was filled - EXPIRED // trade ended without completing its fills -} diff --git a/src/VaultAddress.sol b/src/VaultAddress.sol index 4387633..f0c5954 100644 --- a/src/VaultAddress.sol +++ b/src/VaultAddress.sol @@ -10,7 +10,7 @@ library VaultAddress { // keccak-256 hash of the Vault's bytecode (not the deployed bytecode but the initialization bytecode) // can paste into: // https://emn178.github.io/online-tools/keccak_256.html - bytes32 internal constant VAULT_INIT_CODE_HASH = 0x40d5f4d1aa2f505a4b156599c452d0e7df5003430246ca5798a932dc031a9127; + bytes32 internal constant VAULT_INIT_CODE_HASH = 0xe5ccc5781ec7c9aa6e1ca21f73022e0b4606f22aca8dde4e455fd8051007d378; // the contract being constructed must not have any constructor arguments or the determinism will be broken. instead, use a callback to // get construction arguments