From 411686f390ebf7094b4c565fffa260c7dbfe7431 Mon Sep 17 00:00:00 2001 From: boqdan <304771+bowd@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:01:57 +0200 Subject: [PATCH] fix: update eXOF proposal with EUROCXOF rateFeed (#127) --- bin/cgp-check.sh | 27 ++ bin/cgp.sh | 22 +- .../44787/run-latest.json | 180 --------- .../62320/run-latest.json | 180 --------- contracts/NonrecoverableValueDeltaBreaker.sol | 25 -- package.json | 1 + script/upgrades/eXOF/Config.sol | 27 +- ...XOF-02-Create-Nonupgradeable-Contracts.sol | 51 --- script/upgrades/eXOF/eXOF.sol | 127 ++----- script/upgrades/eXOF/eXOFChecks.base.sol | 3 - script/upgrades/eXOF/eXOFChecks.swap.sol | 5 + script/upgrades/eXOF/eXOFChecks.verify.sol | 129 ++----- script/upgrades/eXOF/eXOFRevert.sol | 351 ++++++++++++++++++ script/utils/Config.sol | 11 +- script/utils/SimulateUpgrade.sol | 10 + 15 files changed, 494 insertions(+), 655 deletions(-) create mode 100755 bin/cgp-check.sh delete mode 100644 broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/44787/run-latest.json delete mode 100644 broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/62320/run-latest.json delete mode 100644 contracts/NonrecoverableValueDeltaBreaker.sol delete mode 100644 script/upgrades/eXOF/deploy/eXOF-02-Create-Nonupgradeable-Contracts.sol create mode 100644 script/upgrades/eXOF/eXOFRevert.sol diff --git a/bin/cgp-check.sh b/bin/cgp-check.sh new file mode 100755 index 00000000..e469b070 --- /dev/null +++ b/bin/cgp-check.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +############################################################################## +# Script for running Governance Proposal Checks on top of a network +# Usage: yarn cgp:check +# -n -- network to submit the proposal to +# -u -- name of the upgrade (MU01) +# Example: yarn cgp:check -n baklava -u MU03 +############################################################################## + +source "$(dirname "$0")/setup.sh" + +NETWORK="" +UPGRADE="" +while getopts n:u:p:sfr flag +do + case "${flag}" in + n) NETWORK=${OPTARG};; + u) UPGRADE=${OPTARG};; + esac +done + +parse_network "$NETWORK" +parse_upgrade "$UPGRADE" + +echo "👀 Checking $UPGRADE" +forge script $(forge_skip $UPGRADE) --rpc-url $RPC_URL --skip .dev.sol --sig "check(string)" script/utils/SimulateUpgrade.sol:SimulateUpgrade $UPGRADE diff --git a/bin/cgp.sh b/bin/cgp.sh index dfc6b8e2..ca6279b4 100755 --- a/bin/cgp.sh +++ b/bin/cgp.sh @@ -6,6 +6,7 @@ # -n -- network to submit the proposal to # -u -- name of the upgrade (MU01) # -s -- simulate the proposal (optional) +# -r -- revert # -f -- use forked network (optional) # Example: yarn cgp -n baklava -u MU01 -p 1 ############################################################################## @@ -16,13 +17,15 @@ NETWORK="" UPGRADE="" SIMULATE=false USE_FORK=false -while getopts n:u:p:sf flag +REVERT=false +while getopts n:u:p:sfr flag do case "${flag}" in n) NETWORK=${OPTARG};; u) UPGRADE=${OPTARG};; s) SIMULATE=true;; f) USE_FORK=true;; + r) REVERT=true;; esac done @@ -36,13 +39,22 @@ if [ "$USE_FORK" = true ] ; then echo "🍴 Submitting to forked network" fi + +if [ "$REVERT" = true ] ; then + CONTRACT=$UPGRADE'Revert' + echo "🔄 Reverting $UPGRADE via $CONTRACT" +else + CONTRACT=$UPGRADE + echo "🔥 Submitting $UPGRADE via $CONTRACT" +fi + if [ "$SIMULATE" = true ] ; then - echo "🥸 Simulating $UPGRADE" - forge script $(forge_skip $UPGRADE) --rpc-url $RPC_URL --skip .dev.sol --sig "run(string)" script/utils/SimulateUpgrade.sol:SimulateUpgrade $UPGRADE + echo "🥸 Simulating $CONTRACT" + forge script $(forge_skip $UPGRADE) --rpc-url $RPC_URL --skip .dev.sol --sig "run(string)" script/utils/SimulateUpgrade.sol:SimulateUpgrade $CONTRACT else - echo "🔥 Submitting $UPGRADE" + echo "🔥 Submitting $CONTRACT" confirm_if_celo "$NETWORK" - forge script $(forge_skip $UPGRADE) --rpc-url $RPC_URL --legacy --broadcast ${UPGRADE} + forge script $(forge_skip $UPGRADE) --rpc-url $RPC_URL --legacy --broadcast ${CONTRACT} fi diff --git a/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/44787/run-latest.json b/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/44787/run-latest.json deleted file mode 100644 index ed40e2ac..00000000 --- a/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/44787/run-latest.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionType": "CREATE", - "contractName": "NonrecoverableValueDeltaBreaker", - "contractAddress": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "function": null, - "arguments": [ - "0", - "0", - "0xFdd8bD58115FfBf04e47411c1d228eCC45E93075", - "[]", - "[]", - "[]" - ], - "transaction": { - "type": "0x00", - "from": "0x56fd3f2bee130e9867942d0f463a16fbe49b8d81", - "gas": "0x1f2d9a", - "value": "0x0", - "data": "0x60806040523480156200001157600080fd5b506040516200242b3803806200242b833981810160405260c08110156200003757600080fd5b8151602083015160408085015160608601805192519496939591949391820192846401000000008211156200006b57600080fd5b9083019060208201858111156200008157600080fd5b82518660208202830111640100000000821117156200009f57600080fd5b82525081516020918201928201910280838360005b83811015620000ce578181015183820152602001620000b4565b5050505090500160405260200180516040519392919084640100000000821115620000f857600080fd5b9083019060208201858111156200010e57600080fd5b82518660208202830111640100000000821117156200012c57600080fd5b82525081516020918201928201910280838360005b838110156200015b57818101518382015260200162000141565b50505050905001604052602001805160405193929190846401000000008211156200018557600080fd5b9083019060208201858111156200019b57600080fd5b8251866020820283011164010000000082111715620001b957600080fd5b82525081516020918201928201910280838360005b83811015620001e8578181015183820152602001620001ce565b5050505090500160405250505085858585858560006200020d620002d660201b60201c565b600480546001600160a01b0319166001600160a01b03831690811790915560405191925090600090600080516020620023ea833981519152908290a3506200025e336001600160e01b03620002da16565b62000272846001600160e01b036200036c16565b62000286866001600160e01b036200046c16565b6200029a856001600160e01b03620004a716565b620002af83836001600160e01b036200058516565b620002c483826001600160e01b03620007d316565b505050505050505050505050620009fd565b3390565b6001600160a01b038116620003215760405162461bcd60e51b8152600401808060200182810382526026815260200180620023c46026913960400191505060405180910390fd5b6004546040516001600160a01b03808416921690600080516020620023ea83398151915290600090a3600480546001600160a01b0319166001600160a01b0392909216919091179055565b6200037f6001600160e01b036200097016565b620003d1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620004185760405162461bcd60e51b81526004018080602001828103825260218152602001806200240a6021913960400191505060405180910390fd5b600580546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b620004bd81620009a160201b620017ea1760201c565b51600255620004fd620004db620009bd602090811b620015a217901c565b6040805160208082019092526002548152919062001804620009e3821b17901c565b6200054f576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b8051825114620005dc576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620007ce5760006001600160a01b03168382815181106200060157fe5b60200260200101516001600160a01b031614156200065a576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b62000664620009ea565b6200068e8383815181106200067557fe5b6020026020010151620009a160201b620017ea1760201c565b9050620006be620006a9620009bd60201b620015a21760201c565b82620009e360201b620018041790919060201c565b62000710576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b80600360008685815181106200072257fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a3398483815181106200078557fe5b60200260200101518484815181106200079a57fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a150600101620005df565b505050565b80518251146200082a576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620007ce5760006001600160a01b03168382815181106200084f57fe5b60200260200101516001600160a01b03161415620008a8576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b818181518110620008b557fe5b602002602001015160016000858481518110620008ce57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c8382815181106200092857fe5b60200260200101518383815181106200093d57fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a16001016200082d565b6004546000906001600160a01b0316620009926001600160e01b03620002d616565b6001600160a01b031614905090565b620009ab620009ea565b50604080516020810190915290815290565b620009c7620009ea565b50604080516020810190915269d3c21bcecceda1000000815290565b5190511090565b6040518060200160405280600081525090565b6119b78062000a0d6000396000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c806368b89d58116100cd5780638f32d59b11610081578063e829902e11610066578063e829902e14610521578063f2fde38b146105e3578063fd165f53146106165761016c565b80638f32d59b14610511578063a44235cb146105195761016c565b8063715018a6116100b2578063715018a6146104c2578063753d8c2f146104ca5780638da5cb5b146105095761016c565b806368b89d58146103b95780636cac543a146104005761016c565b80633932bcc3116101245780634afb215e116101095780634afb215e1461033657806353f5d6f1146103695780635ac3ff701461039c5761016c565b80633932bcc3146102d057806339b84ecf146103035761016c565b8063132e8aa711610155578063132e8aa7146102525780631893304f146102835780632e37ff73146102c85761016c565b8063020323dd1461017157806305e0478514610235575b600080fd5b6102336004803603604081101561018757600080fd5b8101906020810181356401000000008111156101a257600080fd5b8201836020820111156101b457600080fd5b803590602001918460208302840111640100000000831117156101d657600080fd5b9193909290916020810190356401000000008111156101f457600080fd5b82018360208201111561020657600080fd5b8035906020019184602083028401116401000000008311171561022857600080fd5b509092509050610649565b005b6102336004803603602081101561024b57600080fd5b5035610715565b61025a61077a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102b66004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610796565b60408051918252519081900360200190f35b6102b66107a8565b6102b6600480360360208110156102e657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107ae565b6102b66004803603602081101561031957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107c0565b6102336004803603602081101561034c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107fd565b6102b66004803603602081101561037f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610921565b610233600480360360208110156103b257600080fd5b5035610933565b6103ec600480360360208110156103cf57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610995565b604080519115158252519081900360200190f35b6102336004803603604081101561041657600080fd5b81019060208101813564010000000081111561043157600080fd5b82018360208201111561044357600080fd5b8035906020019184602083028401116401000000008311171561046557600080fd5b91939092909160208101903564010000000081111561048357600080fd5b82018360208201111561049557600080fd5b803590602001918460208302840111640100000000831117156104b757600080fd5b5090925090506109a7565b610233610a6d565b6103ec600480360360608110156104e057600080fd5b508035906020810135906040013573ffffffffffffffffffffffffffffffffffffffff16610b35565b61025a610c47565b6103ec610c63565b6102b6610ca3565b6102336004803603604081101561053757600080fd5b81019060208101813564010000000081111561055257600080fd5b82018360208201111561056457600080fd5b8035906020019184602083028401116401000000008311171561058657600080fd5b9193909290916020810190356401000000008111156105a457600080fd5b8201836020820111156105b657600080fd5b803590602001918460208302840111640100000000831117156105d857600080fd5b509092509050610ca9565b610233600480360360208110156105f957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f0e565b6103ec6004803603602081101561062c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f70565b610651610c63565b6106a2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61070f8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061105b92505050565b50505050565b61071d610c63565b61076e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610777816112c7565b50565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60036020526000908152604090205481565b60005481565b60066020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812054806107f55750506000546107f8565b90505b919050565b610805610c63565b610856576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166108a85760405162461bcd60e51b81526004018080602001828103825260218152602001806119626021913960400191505060405180910390fd5b6005805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b60016020526000908152604090205481565b61093b610c63565b61098c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61077781611382565b60006109a082610f70565b1592915050565b6109af610c63565b610a00576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61070f848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506113bd92505050565b610a75610c63565b610ac6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60045460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080516020810190915260025481526000908190610b539061159e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600360209081526040808320815192830190915254815291925090610b939061159e565b90508015610b9f578091505b6000610bb1610bac6115a2565b61159e565b90506000610bc5828563ffffffff6115c616565b90506000610bf369d3c21bcecceda1000000610be78b8563ffffffff61162916565b9063ffffffff61168216565b90506000610c07848763ffffffff6116c416565b90506000610c2969d3c21bcecceda1000000610be78d8563ffffffff61162916565b9050808a1080610c385750828a115b9b9a5050505050505050505050565b60045473ffffffffffffffffffffffffffffffffffffffff1690565b60045460009073ffffffffffffffffffffffffffffffffffffffff16610c87611706565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b60025481565b610cb1610c63565b610d02576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b828114610d56576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b83811015610f07576000858583818110610d6f57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610df5576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b828282818110610e0157fe5b9050602002013560066000878785818110610e1857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fa62a59cb391b90466127d5c2ae9c7cfb59877763680d974867d6abe0c4fd52cb858583818110610ea057fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16848484818110610ec957fe5b6040805173ffffffffffffffffffffffffffffffffffffffff90951685526020918202939093013590840152508051918290030190a1600101610d59565b5050505050565b610f16610c63565b610f67576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6107778161170a565b600554604080517fef90e1b000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528251600094859492169263ef90e1b0926024808301939192829003018186803b158015610fe357600080fd5b505afa158015610ff7573d6000803e3d6000fd5b505050506040513d604081101561100d57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff841660009081526006602052604090205490915080611048576000925050506107f8565b611053818386610b35565b949350505050565b80518251146110b1576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156112c257600073ffffffffffffffffffffffffffffffffffffffff168382815181106110e157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415611152576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b61115a611907565b61117683838151811061116957fe5b60200260200101516117ea565b90506111906111836115a2565b829063ffffffff61180416565b6111e1576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b80600360008685815181106111f257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a33984838151811061126e57fe5b602002602001015184848151811061128257fe5b6020908102919091018101516040805173ffffffffffffffffffffffffffffffffffffffff9094168452918301528051918290030190a1506001016110b4565b505050565b6112d0816117ea565b516002556112fb6112df6115a2565b604080516020810190915260025481529063ffffffff61180416565b61134c576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b8051825114611413576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156112c257600073ffffffffffffffffffffffffffffffffffffffff1683828151811061144357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614156114b4576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b8181815181106114c057fe5b6020026020010151600160008584815181106114d857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c83828151811061154b57fe5b602002602001015183838151811061155f57fe5b6020908102919091018101516040805173ffffffffffffffffffffffffffffffffffffffff9094168452918301528051918290030190a1600101611416565b5190565b6115aa611907565b50604080516020810190915269d3c21bcecceda1000000815290565b600082820183811015611620576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b60008261163857506000611623565b8282028284828161164557fe5b04146116205760405162461bcd60e51b81526004018080602001828103825260218152602001806119416021913960400191505060405180910390fd5b600061162083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061180b565b600061162083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118ad565b3390565b73ffffffffffffffffffffffffffffffffffffffff811661175c5760405162461bcd60e51b815260040180806020018281038252602681526020018061191b6026913960400191505060405180910390fd5b60045460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6117f2611907565b50604080516020810190915290815290565b5190511090565b600081836118975760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561185c578181015183820152602001611844565b50505050905090810190601f1680156118895780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816118a357fe5b0495945050505050565b600081848411156118ff5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561185c578181015183820152602001611844565b505050900390565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536f727465644f7261636c65732061646472657373206d75737420626520736574a265627a7a7231582011765acba939a6b32e46cb228259748701b284c59dfd4ac49f1e8f56ca5fb53864736f6c634300051100324f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573738be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0536f727465644f7261636c65732061646472657373206d7573742062652073657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fdd8bd58115ffbf04e47411c1d228ecc45e9307500000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0xde" - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": "0xd9e9581cb6f5766dd1034f8ec32fd35211a32f53b1441f7f5354a68eb6ddfaf6", - "transactionType": "CALL", - "contractName": "NonrecoverableValueDeltaBreaker", - "contractAddress": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "function": "transferOwnership(address)", - "arguments": [ - "0xAA963FC97281d9632d96700aB62A4D1340F9a28a" - ], - "transaction": { - "type": "0x00", - "from": "0x56fd3f2bee130e9867942d0f463a16fbe49b8d81", - "to": "0x69d7a21025d45d301a396cceffd2d3a80b7c3a5b", - "gas": "0xa387", - "value": "0x0", - "data": "0xf2fde38b000000000000000000000000aa963fc97281d9632d96700ab62a4d1340f9a28a", - "nonce": "0xdf" - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [ - { - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81", - "to": null, - "cumulativeGasUsed": "0x17e762", - "gasUsed": "0x17e762", - "contractAddress": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "logs": [ - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81" - ], - "data": "0x", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "logIndex": "0x0", - "removed": false - }, - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81" - ], - "data": "0x", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "logIndex": "0x1", - "removed": false - }, - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0x590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f7353" - ], - "data": "0x000000000000000000000000fdd8bd58115ffbf04e47411c1d228ecc45e93075", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "logIndex": "0x2", - "removed": false - }, - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0x9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a2" - ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "logIndex": "0x3", - "removed": false - }, - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0xd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d" - ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xae7b6266f181f45dac20be5ca6c0206cb8cbd9f6ccf70a6f6fda9acac756bdb6", - "transactionIndex": "0x0", - "logIndex": "0x4", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000000000000000022800000000000000000080000000000000000000000010000000000001000000000000000000000000000008000000000000000000000000001000000000000000000000000000000800000020000000000000200000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000800000000000000000000008000000000000000000000000000000000000000000000000000000000000000000080000000000000000004000000000000020000004000000000001000000000000000000000000000000000000000020000000", - "type": "0x0", - "effectiveGasPrice": "0x5d21dba00" - }, - { - "transactionHash": "0xd9e9581cb6f5766dd1034f8ec32fd35211a32f53b1441f7f5354a68eb6ddfaf6", - "transactionIndex": "0x1", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81", - "to": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "cumulativeGasUsed": "0x185733", - "gasUsed": "0x6fd1", - "contractAddress": null, - "logs": [ - { - "address": "0x69D7A21025D45D301a396cCeFfD2D3a80b7c3a5B", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81", - "0x000000000000000000000000aa963fc97281d9632d96700ab62a4d1340f9a28a" - ], - "data": "0x", - "blockHash": "0x7d9780620118c967970faec2c79001a43b32a5afb7210f215dc2fa27fb4c3c23", - "blockNumber": "0x1293e7b", - "transactionHash": "0xd9e9581cb6f5766dd1034f8ec32fd35211a32f53b1441f7f5354a68eb6ddfaf6", - "transactionIndex": "0x1", - "logIndex": "0x5", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000020000000000000000000000000000000000020800000000000000000080000004000000000000000010000000000000000000000000000000000000000008000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000", - "type": "0x0", - "effectiveGasPrice": "0x5d21dba00" - } - ], - "libraries": [ - "lib/mento-core-2.0.0/contracts/common/linkedlists/AddressLinkedList.sol:AddressLinkedList:0x2F0F7686fFFEfc3C266403Ad600035581deaedff", - "lib/mento-core-2.0.0/contracts/common/linkedlists/AddressSortedLinkedListWithMedian.sol:AddressSortedLinkedListWithMedian:0x29B1B5e05217c751038861aF2C77494EAB10A257" - ], - "pending": [], - "returns": {}, - "timestamp": 1692783955, - "chain": 44787, - "multi": false, - "commit": "1071d75" -} \ No newline at end of file diff --git a/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/62320/run-latest.json b/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/62320/run-latest.json deleted file mode 100644 index fbfe4e2f..00000000 --- a/broadcast/eXOF-02-Create-Nonupgradeable-Contracts.sol/62320/run-latest.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionType": "CREATE", - "contractName": "NonrecoverableValueDeltaBreaker", - "contractAddress": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "function": null, - "arguments": [ - "0", - "0", - "0x88A187a876290E9843175027902B9f7f1B092c88", - "[]", - "[]", - "[]" - ], - "transaction": { - "type": "0x00", - "from": "0x56fd3f2bee130e9867942d0f463a16fbe49b8d81", - "gas": "0x1f2d9a", - "value": "0x0", - "data": "0x60806040523480156200001157600080fd5b506040516200242b3803806200242b833981810160405260c08110156200003757600080fd5b8151602083015160408085015160608601805192519496939591949391820192846401000000008211156200006b57600080fd5b9083019060208201858111156200008157600080fd5b82518660208202830111640100000000821117156200009f57600080fd5b82525081516020918201928201910280838360005b83811015620000ce578181015183820152602001620000b4565b5050505090500160405260200180516040519392919084640100000000821115620000f857600080fd5b9083019060208201858111156200010e57600080fd5b82518660208202830111640100000000821117156200012c57600080fd5b82525081516020918201928201910280838360005b838110156200015b57818101518382015260200162000141565b50505050905001604052602001805160405193929190846401000000008211156200018557600080fd5b9083019060208201858111156200019b57600080fd5b8251866020820283011164010000000082111715620001b957600080fd5b82525081516020918201928201910280838360005b83811015620001e8578181015183820152602001620001ce565b5050505090500160405250505085858585858560006200020d620002d660201b60201c565b600480546001600160a01b0319166001600160a01b03831690811790915560405191925090600090600080516020620023ea833981519152908290a3506200025e336001600160e01b03620002da16565b62000272846001600160e01b036200036c16565b62000286866001600160e01b036200046c16565b6200029a856001600160e01b03620004a716565b620002af83836001600160e01b036200058516565b620002c483826001600160e01b03620007d316565b505050505050505050505050620009fd565b3390565b6001600160a01b038116620003215760405162461bcd60e51b8152600401808060200182810382526026815260200180620023c46026913960400191505060405180910390fd5b6004546040516001600160a01b03808416921690600080516020620023ea83398151915290600090a3600480546001600160a01b0319166001600160a01b0392909216919091179055565b6200037f6001600160e01b036200097016565b620003d1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620004185760405162461bcd60e51b81526004018080602001828103825260218152602001806200240a6021913960400191505060405180910390fd5b600580546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b620004bd81620009a160201b620017ea1760201c565b51600255620004fd620004db620009bd602090811b620015a217901c565b6040805160208082019092526002548152919062001804620009e3821b17901c565b6200054f576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b8051825114620005dc576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620007ce5760006001600160a01b03168382815181106200060157fe5b60200260200101516001600160a01b031614156200065a576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b62000664620009ea565b6200068e8383815181106200067557fe5b6020026020010151620009a160201b620017ea1760201c565b9050620006be620006a9620009bd60201b620015a21760201c565b82620009e360201b620018041790919060201c565b62000710576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b80600360008685815181106200072257fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a3398483815181106200078557fe5b60200260200101518484815181106200079a57fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a150600101620005df565b505050565b80518251146200082a576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b8251811015620007ce5760006001600160a01b03168382815181106200084f57fe5b60200260200101516001600160a01b03161415620008a8576040805162461bcd60e51b81526020600482015260116024820152701c985d194819995959081a5b9d985b1a59607a1b604482015290519081900360640190fd5b818181518110620008b557fe5b602002602001015160016000858481518110620008ce57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c8382815181106200092857fe5b60200260200101518383815181106200093d57fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a16001016200082d565b6004546000906001600160a01b0316620009926001600160e01b03620002d616565b6001600160a01b031614905090565b620009ab620009ea565b50604080516020810190915290815290565b620009c7620009ea565b50604080516020810190915269d3c21bcecceda1000000815290565b5190511090565b6040518060200160405280600081525090565b6119b78062000a0d6000396000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c806368b89d58116100cd5780638f32d59b11610081578063e829902e11610066578063e829902e14610521578063f2fde38b146105e3578063fd165f53146106165761016c565b80638f32d59b14610511578063a44235cb146105195761016c565b8063715018a6116100b2578063715018a6146104c2578063753d8c2f146104ca5780638da5cb5b146105095761016c565b806368b89d58146103b95780636cac543a146104005761016c565b80633932bcc3116101245780634afb215e116101095780634afb215e1461033657806353f5d6f1146103695780635ac3ff701461039c5761016c565b80633932bcc3146102d057806339b84ecf146103035761016c565b8063132e8aa711610155578063132e8aa7146102525780631893304f146102835780632e37ff73146102c85761016c565b8063020323dd1461017157806305e0478514610235575b600080fd5b6102336004803603604081101561018757600080fd5b8101906020810181356401000000008111156101a257600080fd5b8201836020820111156101b457600080fd5b803590602001918460208302840111640100000000831117156101d657600080fd5b9193909290916020810190356401000000008111156101f457600080fd5b82018360208201111561020657600080fd5b8035906020019184602083028401116401000000008311171561022857600080fd5b509092509050610649565b005b6102336004803603602081101561024b57600080fd5b5035610715565b61025a61077a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102b66004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610796565b60408051918252519081900360200190f35b6102b66107a8565b6102b6600480360360208110156102e657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107ae565b6102b66004803603602081101561031957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107c0565b6102336004803603602081101561034c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107fd565b6102b66004803603602081101561037f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610921565b610233600480360360208110156103b257600080fd5b5035610933565b6103ec600480360360208110156103cf57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610995565b604080519115158252519081900360200190f35b6102336004803603604081101561041657600080fd5b81019060208101813564010000000081111561043157600080fd5b82018360208201111561044357600080fd5b8035906020019184602083028401116401000000008311171561046557600080fd5b91939092909160208101903564010000000081111561048357600080fd5b82018360208201111561049557600080fd5b803590602001918460208302840111640100000000831117156104b757600080fd5b5090925090506109a7565b610233610a6d565b6103ec600480360360608110156104e057600080fd5b508035906020810135906040013573ffffffffffffffffffffffffffffffffffffffff16610b35565b61025a610c47565b6103ec610c63565b6102b6610ca3565b6102336004803603604081101561053757600080fd5b81019060208101813564010000000081111561055257600080fd5b82018360208201111561056457600080fd5b8035906020019184602083028401116401000000008311171561058657600080fd5b9193909290916020810190356401000000008111156105a457600080fd5b8201836020820111156105b657600080fd5b803590602001918460208302840111640100000000831117156105d857600080fd5b509092509050610ca9565b610233600480360360208110156105f957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f0e565b6103ec6004803603602081101561062c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f70565b610651610c63565b6106a2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61070f8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061105b92505050565b50505050565b61071d610c63565b61076e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610777816112c7565b50565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60036020526000908152604090205481565b60005481565b60066020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812054806107f55750506000546107f8565b90505b919050565b610805610c63565b610856576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166108a85760405162461bcd60e51b81526004018080602001828103825260218152602001806119626021913960400191505060405180910390fd5b6005805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f73539181900360200190a150565b60016020526000908152604090205481565b61093b610c63565b61098c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61077781611382565b60006109a082610f70565b1592915050565b6109af610c63565b610a00576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61070f848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506113bd92505050565b610a75610c63565b610ac6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60045460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080516020810190915260025481526000908190610b539061159e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600360209081526040808320815192830190915254815291925090610b939061159e565b90508015610b9f578091505b6000610bb1610bac6115a2565b61159e565b90506000610bc5828563ffffffff6115c616565b90506000610bf369d3c21bcecceda1000000610be78b8563ffffffff61162916565b9063ffffffff61168216565b90506000610c07848763ffffffff6116c416565b90506000610c2969d3c21bcecceda1000000610be78d8563ffffffff61162916565b9050808a1080610c385750828a115b9b9a5050505050505050505050565b60045473ffffffffffffffffffffffffffffffffffffffff1690565b60045460009073ffffffffffffffffffffffffffffffffffffffff16610c87611706565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b60025481565b610cb1610c63565b610d02576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b828114610d56576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b83811015610f07576000858583818110610d6f57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610df5576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b828282818110610e0157fe5b9050602002013560066000878785818110610e1857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fa62a59cb391b90466127d5c2ae9c7cfb59877763680d974867d6abe0c4fd52cb858583818110610ea057fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16848484818110610ec957fe5b6040805173ffffffffffffffffffffffffffffffffffffffff90951685526020918202939093013590840152508051918290030190a1600101610d59565b5050505050565b610f16610c63565b610f67576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6107778161170a565b600554604080517fef90e1b000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528251600094859492169263ef90e1b0926024808301939192829003018186803b158015610fe357600080fd5b505afa158015610ff7573d6000803e3d6000fd5b505050506040513d604081101561100d57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff841660009081526006602052604090205490915080611048576000925050506107f8565b611053818386610b35565b949350505050565b80518251146110b1576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156112c257600073ffffffffffffffffffffffffffffffffffffffff168382815181106110e157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415611152576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b61115a611907565b61117683838151811061116957fe5b60200260200101516117ea565b90506111906111836115a2565b829063ffffffff61180416565b6111e1576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b80600360008685815181106111f257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001559050507fb4610b016800a84a54beff5837e8c18d5deb15ebe20fc28f30b55fb7f183a33984838151811061126e57fe5b602002602001015184848151811061128257fe5b6020908102919091018101516040805173ffffffffffffffffffffffffffffffffffffffff9094168452918301528051918290030190a1506001016110b4565b505050565b6112d0816117ea565b516002556112fb6112df6115a2565b604080516020810190915260025481529063ffffffff61180416565b61134c576040805162461bcd60e51b815260206004820152601960248201527f76616c7565206d757374206265206c657373207468616e203100000000000000604482015290519081900360640190fd5b6040805182815290517fd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d9181900360200190a150565b60008190556040805182815290517f9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a29181900360200190a150565b8051825114611413576040805162461bcd60e51b815260206004820152601660248201527f6172726179206c656e677468206d6973736d6174636800000000000000000000604482015290519081900360640190fd5b60005b82518110156112c257600073ffffffffffffffffffffffffffffffffffffffff1683828151811061144357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614156114b4576040805162461bcd60e51b815260206004820152601160248201527f72617465206665656420696e76616c6964000000000000000000000000000000604482015290519081900360640190fd5b8181815181106114c057fe5b6020026020010151600160008584815181106114d857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f1b2e9cb68f822fa2031c648b0d701fdd3f5330d9c60f3e9f0ca3a5c9e2f6285c83828151811061154b57fe5b602002602001015183838151811061155f57fe5b6020908102919091018101516040805173ffffffffffffffffffffffffffffffffffffffff9094168452918301528051918290030190a1600101611416565b5190565b6115aa611907565b50604080516020810190915269d3c21bcecceda1000000815290565b600082820183811015611620576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b60008261163857506000611623565b8282028284828161164557fe5b04146116205760405162461bcd60e51b81526004018080602001828103825260218152602001806119416021913960400191505060405180910390fd5b600061162083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061180b565b600061162083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118ad565b3390565b73ffffffffffffffffffffffffffffffffffffffff811661175c5760405162461bcd60e51b815260040180806020018281038252602681526020018061191b6026913960400191505060405180910390fd5b60045460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6117f2611907565b50604080516020810190915290815290565b5190511090565b600081836118975760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561185c578181015183820152602001611844565b50505050905090810190601f1680156118895780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816118a357fe5b0495945050505050565b600081848411156118ff5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561185c578181015183820152602001611844565b505050900390565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536f727465644f7261636c65732061646472657373206d75737420626520736574a265627a7a723158202de52c133daa5165b485b36d57f3f0ee8f32fe21677670bf73fc60225c1d889a64736f6c634300051100324f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573738be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0536f727465644f7261636c65732061646472657373206d757374206265207365740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088a187a876290e9843175027902b9f7f1b092c8800000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x289" - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": "0x523a708066be6c24fe2e34d88ea0f12273bc5f80befc9c06ba7126e07e647168", - "transactionType": "CALL", - "contractName": "NonrecoverableValueDeltaBreaker", - "contractAddress": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "function": "transferOwnership(address)", - "arguments": [ - "0x28443b1d87db521320a6517A4F1B6Ead77F8C811" - ], - "transaction": { - "type": "0x00", - "from": "0x56fd3f2bee130e9867942d0f463a16fbe49b8d81", - "to": "0xcf49ddc026a66cbd5312a46eada3176d40b245e5", - "gas": "0xa387", - "value": "0x0", - "data": "0xf2fde38b00000000000000000000000028443b1d87db521320a6517a4f1b6ead77f8c811", - "nonce": "0x28a" - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [ - { - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81", - "to": null, - "cumulativeGasUsed": "0x17fbb2", - "gasUsed": "0x17fbb2", - "contractAddress": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "logs": [ - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81" - ], - "data": "0x", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "logIndex": "0x0", - "removed": false - }, - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81" - ], - "data": "0x", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "logIndex": "0x1", - "removed": false - }, - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0x590fd633a008765ce9e65e8081adfba311e99e11b958a5ecb5000ea3355f7353" - ], - "data": "0x00000000000000000000000088a187a876290e9843175027902b9f7f1b092c88", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "logIndex": "0x2", - "removed": false - }, - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0x9f54ba8283224283655cf1e247079a40dc4c214c156638f09c1c45f59502d7a2" - ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "logIndex": "0x3", - "removed": false - }, - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0xd6eda16822202898d222eeb6da8466a309a480c9319d82df117db598af244c0d" - ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0xde668658a1a8bbf4401f7cd2b372aa7f23b69e3c797b85ed12db60efd1c31d76", - "transactionIndex": "0x0", - "logIndex": "0x4", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000000000000000022800000000000000000000000000000000000000000010000000000001040000000000000000000000000000000000000000000000000000001000000000000000000000000000000800000020000000000000200000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000004000000800000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000020000004000000000041000000000000000000000000000000000000000020000000", - "type": "0x0", - "effectiveGasPrice": "0xbebc200" - }, - { - "transactionHash": "0x523a708066be6c24fe2e34d88ea0f12273bc5f80befc9c06ba7126e07e647168", - "transactionIndex": "0x1", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81", - "to": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "cumulativeGasUsed": "0x186b83", - "gasUsed": "0x6fd1", - "contractAddress": null, - "logs": [ - { - "address": "0xCF49dDc026A66CbD5312a46EADA3176d40B245E5", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81", - "0x00000000000000000000000028443b1d87db521320a6517a4f1b6ead77f8c811" - ], - "data": "0x", - "blockHash": "0x4f9ffceb1921c68818963619b70c697bf12332b2cd50e0acde9edf6dd8b1fa60", - "blockNumber": "0x122015c", - "transactionHash": "0x523a708066be6c24fe2e34d88ea0f12273bc5f80befc9c06ba7126e07e647168", - "transactionIndex": "0x1", - "logIndex": "0x5", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000000000000000020801000000000000000000000000000000000000000010000000000000040000000000000000000000000000000000000000000000000000001000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000004000000000040000000000000000000000000000000000000000000000000", - "type": "0x0", - "effectiveGasPrice": "0xbebc200" - } - ], - "libraries": [ - "lib/mento-core-2.0.0/contracts/common/linkedlists/AddressLinkedList.sol:AddressLinkedList:0x3e2cc57f83093Ce1Ee03482c1590E3B5f4225bd7", - "lib/mento-core-2.0.0/contracts/common/linkedlists/AddressSortedLinkedListWithMedian.sol:AddressSortedLinkedListWithMedian:0x99EDce8143FF8AeFA1fBB6C2103B349Add2B9519" - ], - "pending": [], - "returns": {}, - "timestamp": 1692821216, - "chain": 62320, - "multi": false, - "commit": "ac52f84" -} \ No newline at end of file diff --git a/contracts/NonrecoverableValueDeltaBreaker.sol b/contracts/NonrecoverableValueDeltaBreaker.sol deleted file mode 100644 index bcfcd180..00000000 --- a/contracts/NonrecoverableValueDeltaBreaker.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity ^0.5.13; -import { ISortedOracles } from "mento-core-2.2.0/interfaces/ISortedOracles.sol"; -import { ValueDeltaBreaker } from "mento-core-2.2.0/oracles/breakers/ValueDeltaBreaker.sol"; - -contract NonrecoverableValueDeltaBreaker is ValueDeltaBreaker { - constructor( - uint256 _defaultCooldownTime, - uint256 _defaultRateChangeThreshold, - ISortedOracles _sortedOracles, - address[] memory rateFeedIDs, - uint256[] memory rateChangeThresholds, - uint256[] memory cooldownTimes - ) - public - ValueDeltaBreaker( - _defaultCooldownTime, - _defaultRateChangeThreshold, - _sortedOracles, - rateFeedIDs, - rateChangeThresholds, - cooldownTimes - ) - {} -} diff --git a/package.json b/package.json index 69f6cb67..cbc48f4d 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "cgp": "./bin/cgp.sh", "cgp:pass": "./bin/cgp-pass.sh", "cgp:diff": "./bin/cgp-diff.sh", + "cgp:check": "./bin/cgp-check.sh", "cgp:yaml-to-json": "./bin/cgp-yaml-to-json.sh", "show": "./bin/show.sh", "clean": "./bin/clean.sh", diff --git a/script/upgrades/eXOF/Config.sol b/script/upgrades/eXOF/Config.sol index 8f351541..266be19c 100644 --- a/script/upgrades/eXOF/Config.sol +++ b/script/upgrades/eXOF/Config.sol @@ -28,6 +28,7 @@ library eXOFConfig { // Rate Feeds Config.RateFeed CELOXOF; Config.RateFeed EURXOF; + Config.RateFeed EUROCXOF; Config.RateFeed[] rateFeeds; Config.StableToken stableTokenXOF; } @@ -40,9 +41,10 @@ library eXOFConfig { config.pools[0] = config.eXOFCelo = eXOFCelo_PoolConfig(contracts); config.pools[1] = config.eXOFEUROC = eXOFEUROC_PoolConfig(contracts); - config.rateFeeds = new Config.RateFeed[](2); + config.rateFeeds = new Config.RateFeed[](3); config.rateFeeds[0] = config.CELOXOF = CELOXOF_RateFeedConfig(contracts); - config.rateFeeds[1] = config.EURXOF = EURXOF_RateFeedConfig(contracts); + config.rateFeeds[1] = config.EURXOF = EURXOF_RateFeedConfig(); + config.rateFeeds[2] = config.EUROCXOF = EUROCXOF_RateFeedConfig(); config.stableTokenXOF = stableTokenXOFConfig(); } @@ -54,38 +56,39 @@ library eXOFConfig { */ function CELOXOF_RateFeedConfig( Contracts.Cache storage contracts - ) internal returns (Config.RateFeed memory rateFeedConfig) { + ) internal view returns (Config.RateFeed memory rateFeedConfig) { rateFeedConfig.rateFeedID = contracts.deployed("StableTokenXOFProxy"); rateFeedConfig.medianDeltaBreaker0 = Config.MedianDeltaBreaker({ enabled: true, threshold: FixidityLib.newFixedFraction(3, 100), // 0.03 cooldown: 30 minutes, - smoothingFactor: 0 + smoothingFactor: 1e24 // 1 }); - rateFeedConfig.dependentRateFeeds = Arrays.addresses(contracts.dependency("EURXOFRateFeedAddr")); + rateFeedConfig.dependentRateFeeds = Arrays.addresses(Config.rateFeedID("EURXOF"), Config.rateFeedID("EUROCXOF")); } /** * @dev Returns the configuration for the EURXOF rate feed. */ - function EURXOF_RateFeedConfig( - Contracts.Cache storage contracts - ) internal returns (Config.RateFeed memory rateFeedConfig) { - rateFeedConfig.rateFeedID = contracts.dependency("EURXOFRateFeedAddr"); + function EUROCXOF_RateFeedConfig() internal view returns (Config.RateFeed memory rateFeedConfig) { + rateFeedConfig.rateFeedID = Config.rateFeedID("EUROCXOF"); rateFeedConfig.valueDeltaBreaker0 = Config.ValueDeltaBreaker({ enabled: true, threshold: FixidityLib.newFixedFraction(5, 1000), // 0.005 referenceValue: 655.957 * 10 ** 24, cooldown: 15 minutes }); + rateFeedConfig.dependentRateFeeds = Arrays.addresses(Config.rateFeedID("EURXOF"), Config.rateFeedID("EUROCEUR")); + } - rateFeedConfig.valueDeltaBreaker1 = Config.ValueDeltaBreaker({ + function EURXOF_RateFeedConfig() internal view returns (Config.RateFeed memory rateFeedConfig) { + rateFeedConfig.rateFeedID = Config.rateFeedID("EURXOF"); + rateFeedConfig.valueDeltaBreaker0 = Config.ValueDeltaBreaker({ enabled: true, threshold: FixidityLib.newFixedFraction(10, 100), // 0.10 referenceValue: 655.957 * 10 ** 24, cooldown: 0 seconds }); - rateFeedConfig.dependentRateFeeds = Arrays.addresses(contracts.dependency("EUROCEURRateFeedAddr")); } /* ==================== Pool Configurations ==================== */ @@ -144,7 +147,7 @@ library eXOFConfig { minimumReports: 5, referenceRateResetFrequency: 5 minutes, stablePoolResetSize: 656 * 1_000_000 * 1e18, // 656 * 1.0 million - referenceRateFeedID: contracts.dependency("EURXOFRateFeedAddr"), + referenceRateFeedID: Config.rateFeedID("EUROCXOF"), asset0limits: Config.TradingLimit({ enabled0: true, timeStep0: 5 minutes, diff --git a/script/upgrades/eXOF/deploy/eXOF-02-Create-Nonupgradeable-Contracts.sol b/script/upgrades/eXOF/deploy/eXOF-02-Create-Nonupgradeable-Contracts.sol deleted file mode 100644 index 8e8eeaa6..00000000 --- a/script/upgrades/eXOF/deploy/eXOF-02-Create-Nonupgradeable-Contracts.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity ^0.5.13; - -import { Script } from "script/utils/Script.sol"; -import { Chain } from "script/utils/Chain.sol"; -import { console2 } from "forge-std/Script.sol"; - -import { ISortedOracles } from "mento-core-2.2.0/interfaces/ISortedOracles.sol"; -import { NonrecoverableValueDeltaBreaker } from "contracts/NonrecoverableValueDeltaBreaker.sol"; - -/* - yarn deploy -n -u eXOF -s eXOF-02-Create-Nonupgradeable-Contracts.sol -*/ -contract eXOF_CreateNonupgradeableContracts is Script { - NonrecoverableValueDeltaBreaker private nonrecoverableValueDeltaBreaker; - - function run() public { - address governance = contracts.celoRegistry("Governance"); - address sortedOracles = contracts.celoRegistry("SortedOracles"); - - uint256 _defaultCooldown = 0; - uint256 _defaultThreshold = 0; - - address[] memory __rateFeedIDs = new address[](0); - uint256[] memory __rateChangeThresholds = new uint256[](0); - uint256[] memory __cooldowns = new uint256[](0); - - vm.startBroadcast(Chain.deployerPrivateKey()); - { - nonrecoverableValueDeltaBreaker = new NonrecoverableValueDeltaBreaker( - _defaultCooldown, - _defaultThreshold, - ISortedOracles(sortedOracles), - __rateFeedIDs, - __rateChangeThresholds, - __cooldowns - ); - nonrecoverableValueDeltaBreaker.transferOwnership(governance); - } - vm.stopBroadcast(); - - console2.log("----------"); - console2.log("ValueDeltaBreaker2 deployed at: ", address(nonrecoverableValueDeltaBreaker)); - console2.log( - "ValueDeltaBreaker2(%s) ownership transferred to %s", - address(nonrecoverableValueDeltaBreaker), - governance - ); - console2.log("----------"); - } -} diff --git a/script/upgrades/eXOF/eXOF.sol b/script/upgrades/eXOF/eXOF.sol index 29adcdd4..39710232 100644 --- a/script/upgrades/eXOF/eXOF.sol +++ b/script/upgrades/eXOF/eXOF.sol @@ -50,7 +50,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { address private breakerBox; address private medianDeltaBreaker; address private valueDeltaBreaker; - address private nonrecoverableValueDeltaBreaker; address private brokerProxy; address private biPoolManagerProxy; address private sortedOraclesProxy; @@ -77,7 +76,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { contracts.load("MU03-02-Create-Implementations", "latest"); contracts.load("eXOF-00-Create-Proxies", "latest"); contracts.load("eXOF-01-Create-Implementations", "latest"); - contracts.load("eXOF-02-Create-Nonupgradeable-Contracts", "latest"); } /** @@ -93,7 +91,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { breakerBox = contracts.deployed("BreakerBox"); medianDeltaBreaker = contracts.deployed("MedianDeltaBreaker"); valueDeltaBreaker = contracts.deployed("ValueDeltaBreaker"); - nonrecoverableValueDeltaBreaker = contracts.deployed("NonrecoverableValueDeltaBreaker"); sortedOraclesProxy = contracts.celoRegistry("SortedOracles"); // Swaps @@ -136,7 +133,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); proposal_initializeEXOFToken(config); - proposal_addEXOFToCeloRegistry(); proposal_configureEXOFConstitutionParameters(config.stableTokenXOF); proposal_addEXOFToReserve(); proposal_enableGasPaymentsWithEXOF(); @@ -146,7 +142,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { proposal_configureBreakerBox(config); proposal_configureMedianDeltaBreakers(config); proposal_configureValueDeltaBreaker(config); - proposal_configureNonrecoverableValueDeltaBreaker(config); return transactions; } @@ -184,19 +179,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { } } - /** - * @notice Add the transaction to create a new entry for StableTokenXOF in the CeloRegistry - */ - function proposal_addEXOFToCeloRegistry() private { - transactions.push( - ICeloGovernance.Transaction( - 0, - REGISTRY_ADDRESS, - abi.encodeWithSelector(IRegistry(0).setAddressFor.selector, "StableTokenXOF", eXOFProxy) - ) - ); - } - /** * @notice adds eXOF token to the partial and main reserve */ @@ -219,6 +201,13 @@ contract eXOF is IMentoUpgrade, GovernanceScript { */ function proposal_enableGasPaymentsWithEXOF() private { address feeCurrencyWhitelistProxy = contracts.celoRegistry("FeeCurrencyWhitelist"); + address[] memory whitelist = IFeeCurrencyWhitelist(feeCurrencyWhitelistProxy).getWhitelist(); + for (uint256 i = 0; i < whitelist.length; i++) { + if (whitelist[i] == eXOFProxy) { + console.log("Gas payments with XOF already enabled, skipping"); + return; + } + } transactions.push( ICeloGovernance.Transaction( 0, @@ -349,22 +338,11 @@ contract eXOF is IMentoUpgrade, GovernanceScript { breakerBox, abi.encodeWithSelector( BreakerBox(0).addRateFeeds.selector, - Arrays.addresses(eXOFProxy, contracts.dependency("EURXOFRateFeedAddr")) + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID, config.CELOXOF.rateFeedID) ) ) ); - // Add the Nonrecoverable Value Delta Breaker 2 to the breaker box with the trading mode '3' -> trading halted - if (!BreakerBox(breakerBox).isBreaker(nonrecoverableValueDeltaBreaker)) { - transactions.push( - ICeloGovernance.Transaction( - 0, - breakerBox, - abi.encodeWithSelector(BreakerBox(0).addBreaker.selector, nonrecoverableValueDeltaBreaker, 3) - ) - ); - } - // Set rate feed dependencies for (uint i = 0; i < config.rateFeeds.length; i++) { Config.RateFeed memory rateFeed = config.rateFeeds[i]; @@ -385,8 +363,19 @@ contract eXOF is IMentoUpgrade, GovernanceScript { for (uint i = 0; i < config.rateFeeds.length; i++) { Config.RateFeed memory rateFeed = config.rateFeeds[i]; + // Enable Median Delta Breaker for rate feed if (rateFeed.medianDeltaBreaker0.enabled) { + if (MedianDeltaBreaker(medianDeltaBreaker).medianRatesEMA(rateFeed.rateFeedID) != 0) { + transactions.push( + ICeloGovernance.Transaction( + 0, + medianDeltaBreaker, + abi.encodeWithSelector(MedianDeltaBreaker(0).resetMedianRateEMA.selector, rateFeed.rateFeedID) + ) + ); + } + transactions.push( ICeloGovernance.Transaction( 0, @@ -406,22 +395,6 @@ contract eXOF is IMentoUpgrade, GovernanceScript { ) ); } - - // Enable Nonrecoverable Value Delta Breaker for rate feeds - if (rateFeed.valueDeltaBreaker1.enabled) { - transactions.push( - ICeloGovernance.Transaction( - 0, - breakerBox, - abi.encodeWithSelector( - BreakerBox(0).toggleBreaker.selector, - nonrecoverableValueDeltaBreaker, - rateFeed.rateFeedID, - true - ) - ) - ); - } } } @@ -466,8 +439,8 @@ contract eXOF is IMentoUpgrade, GovernanceScript { valueDeltaBreaker, abi.encodeWithSelector( ValueDeltaBreaker(0).setCooldownTimes.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker0.cooldown) + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints(config.EURXOF.valueDeltaBreaker0.cooldown, config.EUROCXOF.valueDeltaBreaker0.cooldown) ) ) ); @@ -478,8 +451,11 @@ contract eXOF is IMentoUpgrade, GovernanceScript { valueDeltaBreaker, abi.encodeWithSelector( ValueDeltaBreaker(0).setRateChangeThresholds.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker0.threshold.unwrap()) + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints( + config.EURXOF.valueDeltaBreaker0.threshold.unwrap(), + config.EUROCXOF.valueDeltaBreaker0.threshold.unwrap() + ) ) ) ); @@ -490,52 +466,11 @@ contract eXOF is IMentoUpgrade, GovernanceScript { valueDeltaBreaker, abi.encodeWithSelector( ValueDeltaBreaker(0).setReferenceValues.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker0.referenceValue) - ) - ) - ); - } - - /** - * @notice This function creates the transactions to configure the second Value Delta Breaker . - */ - function proposal_configureNonrecoverableValueDeltaBreaker(eXOFConfig.eXOF memory config) private { - // Set the cooldown times - transactions.push( - ICeloGovernance.Transaction( - 0, - nonrecoverableValueDeltaBreaker, - abi.encodeWithSelector( - ValueDeltaBreaker(0).setCooldownTimes.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker1.cooldown) - ) - ) - ); - - // Set the rate change thresholds - transactions.push( - ICeloGovernance.Transaction( - 0, - nonrecoverableValueDeltaBreaker, - abi.encodeWithSelector( - ValueDeltaBreaker(0).setRateChangeThresholds.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker1.threshold.unwrap()) - ) - ) - ); - - // Set the reference values - transactions.push( - ICeloGovernance.Transaction( - 0, - nonrecoverableValueDeltaBreaker, - abi.encodeWithSelector( - ValueDeltaBreaker(0).setReferenceValues.selector, - Arrays.addresses(config.EURXOF.rateFeedID), - Arrays.uints(config.EURXOF.valueDeltaBreaker1.referenceValue) + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints( + config.EURXOF.valueDeltaBreaker0.referenceValue, + config.EUROCXOF.valueDeltaBreaker0.referenceValue + ) ) ) ); diff --git a/script/upgrades/eXOF/eXOFChecks.base.sol b/script/upgrades/eXOF/eXOFChecks.base.sol index be82a447..7b3714b4 100644 --- a/script/upgrades/eXOF/eXOFChecks.base.sol +++ b/script/upgrades/eXOF/eXOFChecks.base.sol @@ -54,7 +54,6 @@ contract eXOFChecksBase is GovernanceScript, Test { address public governance; address public medianDeltaBreaker; address public valueDeltaBreaker; - address public nonrecoverableValueDeltaBreaker; address public biPoolManager; address payable sortedOraclesProxy; address public sortedOracles; @@ -75,7 +74,6 @@ contract eXOFChecksBase is GovernanceScript, Test { contracts.loadSilent("MU03-02-Create-Implementations", "latest"); contracts.loadSilent("eXOF-00-Create-Proxies", "latest"); contracts.loadSilent("eXOF-01-Create-Implementations", "latest"); - contracts.loadSilent("eXOF-02-Create-Nonupgradeable-Contracts", "latest"); // Get proxy addresses eXOF = contracts.deployed("StableTokenXOFProxy"); @@ -95,7 +93,6 @@ contract eXOFChecksBase is GovernanceScript, Test { breakerBox = contracts.deployed("BreakerBox"); medianDeltaBreaker = contracts.deployed("MedianDeltaBreaker"); valueDeltaBreaker = contracts.deployed("ValueDeltaBreaker"); - nonrecoverableValueDeltaBreaker = contracts.deployed("NonrecoverableValueDeltaBreaker"); biPoolManager = contracts.deployed("BiPoolManager"); constantSum = contracts.deployed("ConstantSumPricingModule"); constantProduct = contracts.deployed("ConstantProductPricingModule"); diff --git a/script/upgrades/eXOF/eXOFChecks.swap.sol b/script/upgrades/eXOF/eXOFChecks.swap.sol index 9b649d52..617ad7c7 100644 --- a/script/upgrades/eXOF/eXOFChecks.swap.sol +++ b/script/upgrades/eXOF/eXOFChecks.swap.sol @@ -16,6 +16,7 @@ import { Broker } from "mento-core-2.2.0/swap/Broker.sol"; import { IBiPoolManager } from "mento-core-2.2.0/interfaces/IBiPoolManager.sol"; import { BiPoolManager } from "mento-core-2.2.0/swap/BiPoolManager.sol"; import { SortedOracles } from "mento-core-2.2.0/oracles/SortedOracles.sol"; +import { BreakerBox } from "mento-core-2.2.0/oracles/BreakerBox.sol"; import { eXOFChecksBase } from "./eXOFChecks.base.sol"; import { eXOFConfig, Config } from "./Config.sol"; @@ -34,6 +35,10 @@ contract eXOFChecksSwap is eXOFChecksBase { console.log("\n== Starting eXOF test swaps: =="); + console.log("EUROCXOF tradingMode: ", BreakerBox(breakerBox).getRateFeedTradingMode(config.EUROCXOF.rateFeedID)); + console.log("CELOXOF tradingMode: ", BreakerBox(breakerBox).getRateFeedTradingMode(config.CELOXOF.rateFeedID)); + console.log("EURXOF tradingMode: ", BreakerBox(breakerBox).getRateFeedTradingMode(config.EURXOF.rateFeedID)); + swapCeloToEXOF(config); swapEXOFtoCelo(config); swapBridgedEUROCtoEXOF(config); diff --git a/script/upgrades/eXOF/eXOFChecks.verify.sol b/script/upgrades/eXOF/eXOFChecks.verify.sol index d0cd185a..5ac7d508 100644 --- a/script/upgrades/eXOF/eXOFChecks.verify.sol +++ b/script/upgrades/eXOF/eXOFChecks.verify.sol @@ -49,19 +49,26 @@ contract eXOFChecksVerify is eXOFChecksBase { } function run() public { + eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); console.log("\nStarting eXOF checks:"); + console.log("\n== Rate feeds =="); + console.log(" EUROCXOF: %s", config.EUROCXOF.rateFeedID); + console.log(" EURXOF: %s", config.EURXOF.rateFeedID); + console.log(" CELOXOF: %s", config.CELOXOF.rateFeedID); + + verifyToken(config); + verifyExchanges(config); + verifyCircuitBreaker(config); + } + + function verifyToken(eXOFConfig.eXOF memory config) internal { console.log("\n== Verifying Token Transactions =="); verifyOwner(); verifyEXOFStableToken(); - verifyConstitution(); - verifyEXOFAddedToRegistry(); + verifyConstitution(config); verifyEXOFAddedToReserve(); verifyEXOFAddedToFeeCurrencyWhitelist(); - - verifyExchanges(); - - verifyCircuitBreaker(); } function verifyOwner() internal view { @@ -73,10 +80,6 @@ contract eXOFChecksVerify is eXOFChecksBase { require(Proxy(eXOF)._getOwner() == governance, "StableTokenXOF Proxy ownership not transferred to governance"); - require( - ValueDeltaBreaker(nonrecoverableValueDeltaBreaker).owner() == governance, - "Nonrecoverable Value Delta Breaker ownership not transferred to governance" - ); console.log("🟢 Contract ownerships transferred to governance"); } @@ -96,22 +99,6 @@ contract eXOFChecksVerify is eXOFChecksBase { console.log("🟢 StableTokenXOFProxy has the correct implementation address"); } - function verifyEXOFAddedToRegistry() internal view { - address registryEXOFAddress = IRegistry(REGISTRY_ADDRESS).getAddressForStringOrDie("StableTokenXOF"); - address deployedEXOFAddress = contracts.deployed("StableTokenXOFProxy"); - - if (registryEXOFAddress != deployedEXOFAddress) { - console.log( - "The eXOF address from the registry: %s does not match the deployed address: %s.", - registryEXOFAddress, - deployedEXOFAddress - ); - revert("Deployed eXOF does not match what registry points to. See logs."); - } - - console.log("🟢 eXOF has been added to the registry"); - } - function verifyEXOFAddedToReserve() internal view { if (!Reserve(address(uint160(partialReserve))).isStableAsset(eXOF)) { revert("eXOF has not been added to the partial reserve."); @@ -131,9 +118,7 @@ contract eXOFChecksVerify is eXOFChecksBase { console.log("🟢 eXOF has been added to the fee currency whitelist"); } - function verifyConstitution() internal { - eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); - + function verifyConstitution(eXOFConfig.eXOF memory config) internal view { bytes4[] memory functionSelectors = config.stableTokenXOF.constitutionFunctionSelectors; uint256[] memory expectedThresholdValues = config.stableTokenXOF.constitutionThresholds; @@ -161,9 +146,8 @@ contract eXOFChecksVerify is eXOFChecksBase { } } - function verifyExchanges() internal { + function verifyExchanges(eXOFConfig.eXOF memory config) internal view { console.log("\n== Verifying exchanges =="); - eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); verifyPoolExchange(config); verifyPoolConfig(config); @@ -351,35 +335,29 @@ contract eXOFChecksVerify is eXOFChecksBase { /* ======================== Circuit Breaker ======================= */ /* ================================================================ */ - function verifyCircuitBreaker() internal { + function verifyCircuitBreaker(eXOFConfig.eXOF memory config) internal view { console.log("\n== Checking circuit breaker =="); - eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); verifyBreakerBox(config); verifyBreakersAreEnabled(config); verifyMedianDeltaBreaker(config); verifyValueDeltaBreaker(config); - verifyNonrecoverableValueDeltaBreaker(config); } function verifyBreakerBox(eXOFConfig.eXOF memory config) internal view { - // verify that breakers were set with trading mode 3 - if (BreakerBox(breakerBox).breakerTradingMode(nonrecoverableValueDeltaBreaker) != 3) { - console.log("The Nonrecoverable ValueDeltaBreaker was not set with trading halted ❌"); - revert("Nonrecoverable ValueDeltaBreaker was not set with trading halted"); - } - console.log("🟢 Nonrecoverable ValueDeltaBreaker set with trading mode 3"); - // verify that rate feed dependencies were configured correctly - address EUROCXOFDependency = BreakerBox(breakerBox).rateFeedDependencies(config.EURXOF.rateFeedID, 0); require( - EUROCXOFDependency == config.EURXOF.dependentRateFeeds[0], + BreakerBox(breakerBox).rateFeedDependencies(config.EUROCXOF.rateFeedID, 0) == Config.rateFeedID("EURXOF"), "EUROC/XOF rate feed dependency not set correctly" ); - address CELOXOFDependency = BreakerBox(breakerBox).rateFeedDependencies(config.CELOXOF.rateFeedID, 0); require( - CELOXOFDependency == config.CELOXOF.dependentRateFeeds[0], + BreakerBox(breakerBox).rateFeedDependencies(config.EUROCXOF.rateFeedID, 1) == Config.rateFeedID("EUROCEUR"), + "EUROC/XOF rate feed dependency not set correctly" + ); + + require( + BreakerBox(breakerBox).rateFeedDependencies(config.CELOXOF.rateFeedID, 0) == Config.rateFeedID("EURXOF"), "CELO/XOF rate feed dependency not set correctly" ); @@ -405,17 +383,6 @@ contract eXOFChecksVerify is eXOFChecksBase { revert("ValueDeltaBreaker not enabled for all rate feeds"); } } - - if (rateFeed.valueDeltaBreaker1.enabled) { - bool nonrecoverableValueDeltaEnabled = BreakerBox(breakerBox).isBreakerEnabled( - nonrecoverableValueDeltaBreaker, - rateFeed.rateFeedID - ); - if (!nonrecoverableValueDeltaEnabled) { - console.log("Nonrecoverable ValueDeltaBreaker not enabled for rate feed %s", rateFeed.rateFeedID); - revert("Nonrecoverable ValueDeltaBreaker not enabled for all rate feeds"); - } - } } } console.log("🟢 Breakers enabled for all rate feeds 🗳️"); @@ -427,9 +394,9 @@ contract eXOFChecksVerify is eXOFChecksBase { Config.RateFeed memory rateFeed = config.rateFeeds[i]; if (rateFeed.medianDeltaBreaker0.enabled) { - uint256 cooldown = MedianDeltaBreaker(medianDeltaBreaker).rateFeedCooldownTime(rateFeed.rateFeedID); + uint256 cooldown = MedianDeltaBreaker(medianDeltaBreaker).getCooldown(rateFeed.rateFeedID); uint256 rateChangeThreshold = MedianDeltaBreaker(medianDeltaBreaker).rateChangeThreshold(rateFeed.rateFeedID); - uint256 smoothingFactor = MedianDeltaBreaker(medianDeltaBreaker).smoothingFactors(rateFeed.rateFeedID); + uint256 smoothingFactor = MedianDeltaBreaker(medianDeltaBreaker).getSmoothingFactor(rateFeed.rateFeedID); // verify cooldown period verifyCooldownTime(cooldown, rateFeed.medianDeltaBreaker0.cooldown, rateFeed.rateFeedID, false); @@ -444,6 +411,8 @@ contract eXOFChecksVerify is eXOFChecksBase { // verify smoothing factor if (smoothingFactor != rateFeed.medianDeltaBreaker0.smoothingFactor) { + console.log("expected: %s", rateFeed.medianDeltaBreaker0.smoothingFactor); + console.log("got: %s", smoothingFactor); console.log( "MedianDeltaBreaker smoothing factor not set correctly for the rate feed: %s", rateFeed.rateFeedID @@ -461,7 +430,7 @@ contract eXOFChecksVerify is eXOFChecksBase { Config.RateFeed memory rateFeed = config.rateFeeds[i]; if (rateFeed.valueDeltaBreaker0.enabled) { - uint256 cooldown = ValueDeltaBreaker(valueDeltaBreaker).rateFeedCooldownTime(rateFeed.rateFeedID); + uint256 cooldown = ValueDeltaBreaker(valueDeltaBreaker).getCooldown(rateFeed.rateFeedID); uint256 rateChangeThreshold = ValueDeltaBreaker(valueDeltaBreaker).rateChangeThreshold(rateFeed.rateFeedID); uint256 referenceValue = ValueDeltaBreaker(valueDeltaBreaker).referenceValues(rateFeed.rateFeedID); @@ -486,46 +455,6 @@ contract eXOFChecksVerify is eXOFChecksBase { console.log("🟢 ValueDeltaBreaker cooldown, rate change threshold and reference value set correctly 🔒"); } - function verifyNonrecoverableValueDeltaBreaker(eXOFConfig.eXOF memory config) internal view { - // verify that cooldown period, rate change threshold and reference value were set correctly - for (uint256 i = 0; i < config.rateFeeds.length; i++) { - Config.RateFeed memory rateFeed = config.rateFeeds[i]; - - if (rateFeed.valueDeltaBreaker1.enabled) { - uint256 cooldown = ValueDeltaBreaker(nonrecoverableValueDeltaBreaker).rateFeedCooldownTime(rateFeed.rateFeedID); - uint256 rateChangeThreshold = ValueDeltaBreaker(nonrecoverableValueDeltaBreaker).rateChangeThreshold( - rateFeed.rateFeedID - ); - uint256 referenceValue = ValueDeltaBreaker(nonrecoverableValueDeltaBreaker).referenceValues( - rateFeed.rateFeedID - ); - - // verify cooldown period - verifyCooldownTime(cooldown, rateFeed.valueDeltaBreaker1.cooldown, rateFeed.rateFeedID, true); - - // verify rate change threshold - verifyRateChangeTheshold( - rateChangeThreshold, - rateFeed.valueDeltaBreaker1.threshold.unwrap(), - rateFeed.rateFeedID, - true - ); - - // verify reference value - if (referenceValue != rateFeed.valueDeltaBreaker1.referenceValue) { - console.log( - "Nonrecoverable ValueDeltaBreaker reference value not set correctly for the rate feed: %s", - rateFeed.rateFeedID - ); - revert("Nonrecoverable ValueDeltaBreaker reference values not set correctly for all rate feeds"); - } - } - } - console.log( - "🟢 Nonrecoverable ValueDeltaBreaker cooldown, rate change threshold and reference value set correctly 🔒" - ); - } - function verifyRateChangeTheshold( uint256 currentThreshold, uint256 expectedThreshold, @@ -549,6 +478,8 @@ contract eXOFChecksVerify is eXOFChecksBase { bool isValueDeltaBreaker ) internal view { if (currentCoolDown != expectedCoolDown) { + console.log("currentCoolDown: %s", currentCoolDown); + console.log("expectedCoolDown: %s", expectedCoolDown); if (isValueDeltaBreaker) { console.log("ValueDeltaBreaker cooldown not set correctly for rate feed with id %s", rateFeedID); revert("ValueDeltaBreaker cooldown not set correctly for rate feed"); diff --git a/script/upgrades/eXOF/eXOFRevert.sol b/script/upgrades/eXOF/eXOFRevert.sol new file mode 100644 index 00000000..3846ad63 --- /dev/null +++ b/script/upgrades/eXOF/eXOFRevert.sol @@ -0,0 +1,351 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// solhint-disable func-name-mixedcase, contract-name-camelcase, function-max-lines, var-name-mixedcase +pragma solidity ^0.5.13; +pragma experimental ABIEncoderV2; + +import { GovernanceScript } from "script/utils/Script.sol"; +import { console2 as console } from "forge-std/Script.sol"; +import { Contracts } from "script/utils/Contracts.sol"; +import { Chain } from "script/utils/Chain.sol"; +import { Arrays } from "script/utils/Arrays.sol"; + +import { FixidityLib } from "mento-core-2.2.0/common/FixidityLib.sol"; +import { IBiPoolManager } from "mento-core-2.2.0/interfaces/IBiPoolManager.sol"; +import { IPricingModule } from "mento-core-2.2.0/interfaces/IPricingModule.sol"; +import { IReserve } from "mento-core-2.2.0/interfaces/IReserve.sol"; +import { IRegistry } from "mento-core-2.2.0/common/interfaces/IRegistry.sol"; +import { IFeeCurrencyWhitelist } from "../../interfaces/IFeeCurrencyWhitelist.sol"; +import { Proxy } from "mento-core-2.2.0/common/Proxy.sol"; +import { IERC20Metadata } from "mento-core-2.2.0/common/interfaces/IERC20Metadata.sol"; + +import { BiPoolManagerProxy } from "mento-core-2.2.0/proxies/BiPoolManagerProxy.sol"; +import { BrokerProxy } from "mento-core-2.2.0/proxies/BrokerProxy.sol"; +import { Broker } from "mento-core-2.2.0/swap/Broker.sol"; +import { Exchange } from "mento-core-2.2.0/legacy/Exchange.sol"; +import { TradingLimits } from "mento-core-2.2.0/libraries/TradingLimits.sol"; +import { BreakerBox } from "mento-core-2.2.0/oracles/BreakerBox.sol"; +import { MedianDeltaBreaker } from "mento-core-2.2.0/oracles/breakers/MedianDeltaBreaker.sol"; +import { ValueDeltaBreaker } from "mento-core-2.2.0/oracles/breakers/ValueDeltaBreaker.sol"; +import { SortedOracles } from "mento-core-2.2.0/oracles/SortedOracles.sol"; +import { StableTokenXOF } from "mento-core-2.2.0/legacy/StableTokenXOF.sol"; +import { StableTokenXOFProxy } from "mento-core-2.2.0/legacy/proxies/StableTokenXOFProxy.sol"; + +import { eXOFConfig, Config } from "./Config.sol"; +import { IMentoUpgrade, ICeloGovernance } from "script/interfaces/IMentoUpgrade.sol"; + +/** + forge script {file} --rpc-url $BAKLAVA_RPC_URL + --broadcast --legacy + * @dev depends on: ../deploy/*.sol + */ +contract eXOFRevert is IMentoUpgrade, GovernanceScript { + using TradingLimits for TradingLimits.Config; + using FixidityLib for FixidityLib.Fraction; + + ICeloGovernance.Transaction[] private transactions; + + address payable private eXOFProxy; + address private celo; + address private bridgedEUROC; + address private breakerBox; + address private medianDeltaBreaker; + address private valueDeltaBreaker; + address private brokerProxy; + address private biPoolManagerProxy; + address private sortedOraclesProxy; + address private partialReserveProxy; + + // Helper mapping to store the exchange IDs for the reference rate feeds + mapping(address => bytes32) private referenceRateFeedIDToExchangeId; + + bool public hasChecks = false; + + function prepare() public { + loadDeployedContracts(); + setAddresses(); + setUpConfigs(); + } + + /** + * @dev Loads the deployed contracts from the previous deployment step + */ + function loadDeployedContracts() public { + contracts.load("MU01-00-Create-Proxies", "latest"); + contracts.load("MU01-01-Create-Nonupgradeable-Contracts", "latest"); + contracts.load("MU03-01-Create-Nonupgradeable-Contracts", "latest"); + contracts.load("MU03-02-Create-Implementations", "latest"); + contracts.load("eXOF-00-Create-Proxies", "latest"); + contracts.load("eXOF-01-Create-Implementations", "latest"); + } + + /** + * @dev Sets the addresses of the various contracts needed for the proposal. + */ + function setAddresses() public { + // Tokens + eXOFProxy = contracts.deployed("StableTokenXOFProxy"); + celo = contracts.celoRegistry("GoldToken"); + bridgedEUROC = contracts.dependency("BridgedEUROC"); + + // Oracles + breakerBox = contracts.deployed("BreakerBox"); + medianDeltaBreaker = contracts.deployed("MedianDeltaBreaker"); + valueDeltaBreaker = contracts.deployed("ValueDeltaBreaker"); + sortedOraclesProxy = contracts.celoRegistry("SortedOracles"); + + // Swaps + brokerProxy = contracts.deployed("BrokerProxy"); + biPoolManagerProxy = contracts.deployed("BiPoolManagerProxy"); + partialReserveProxy = contracts.deployed("PartialReserveProxy"); + } + + /** + * @dev Setups up various configuration structs. + * This function is called by the governance script runner. + */ + function setUpConfigs() public { + // Create pool configurations + eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); + + // Set the exchange ID for the reference rate feed + for (uint i = 0; i < config.pools.length; i++) { + referenceRateFeedIDToExchangeId[config.pools[i].referenceRateFeedID] = getXOFExchangeId( + config.pools[i].asset1, + config.pools[i].isConstantSum + ); + } + } + + function run() public { + prepare(); + address governance = contracts.celoRegistry("Governance"); + ICeloGovernance.Transaction[] memory _transactions = buildProposal(); + + vm.startBroadcast(Chain.deployerPrivateKey()); + { + createProposal(_transactions, "eXOF", governance); + } + vm.stopBroadcast(); + } + + function buildProposal() public returns (ICeloGovernance.Transaction[] memory) { + require(transactions.length == 0, "buildProposal() should only be called once"); + eXOFConfig.eXOF memory config = eXOFConfig.get(contracts); + + proposal_destroyExchanges(config); + proposal_revertTradingLimits(config); + proposal_revertBreakerBox(config); + proposal_revertMedianDeltaBreakers(config); + proposal_revertValueDeltaBreaker(config); + + return transactions; + } + + /** + * @notice Destroy the exchanges for the new pools. + */ + function proposal_destroyExchanges(eXOFConfig.eXOF memory config) private { + IBiPoolManager biPoolManager = IBiPoolManager(biPoolManagerProxy); + bytes32[] memory exchangeIds = biPoolManager.getExchangeIds(); + + for (uint256 i = exchangeIds.length - 1; i >= 0; i--) { + bytes32 exchangeId = exchangeIds[i]; + for (uint256 j = 0; j < config.pools.length; j++) { + Config.Pool memory poolConfig = config.pools[j]; + if (exchangeId == getExchangeId(poolConfig.asset0, poolConfig.asset1, poolConfig.isConstantSum)) { + transactions.push( + ICeloGovernance.Transaction( + 0, + biPoolManagerProxy, + abi.encodeWithSelector(IBiPoolManager(0).destroyExchange.selector, exchangeId, i) + ) + ); + } + } + if (i == 0) break; + } + } + + /** + * @notice This function creates the transactions to reset the trading limits. + */ + function proposal_revertTradingLimits(eXOFConfig.eXOF memory config) private { + for (uint256 i = 0; i < config.pools.length; i++) { + Config.Pool memory poolConfig = config.pools[i]; + + // Unset the trading limit for asset0 of the pool + transactions.push( + ICeloGovernance.Transaction( + 0, + brokerProxy, + abi.encodeWithSelector( + Broker(0).configureTradingLimit.selector, + referenceRateFeedIDToExchangeId[poolConfig.referenceRateFeedID], + poolConfig.asset0, + TradingLimits.Config({ timestep0: 0, timestep1: 0, limit0: 0, limit1: 0, limitGlobal: 0, flags: 0 }) + ) + ) + ); + + // Unset the trading limit for asset1 of the pool + transactions.push( + ICeloGovernance.Transaction( + 0, + brokerProxy, + abi.encodeWithSelector( + Broker(0).configureTradingLimit.selector, + referenceRateFeedIDToExchangeId[poolConfig.referenceRateFeedID], + poolConfig.asset1, + TradingLimits.Config({ timestep0: 0, timestep1: 0, limit0: 0, limit1: 0, limitGlobal: 0, flags: 0 }) + ) + ) + ); + } + } + + /** + * @notice This function creates the transactions to reset the BreakerBox. + */ + function proposal_revertBreakerBox(eXOFConfig.eXOF memory config) private { + for (uint i = 0; i < config.rateFeeds.length; i++) { + Config.RateFeed memory rateFeed = config.rateFeeds[i]; + // Disable Median Delta Breaker for rate feed + if (rateFeed.medianDeltaBreaker0.enabled) { + transactions.push( + ICeloGovernance.Transaction( + 0, + breakerBox, + abi.encodeWithSelector(BreakerBox(0).toggleBreaker.selector, medianDeltaBreaker, rateFeed.rateFeedID, false) + ) + ); + } + + // Disable Value Delta Breaker for rate feeds + if (rateFeed.valueDeltaBreaker0.enabled) { + transactions.push( + ICeloGovernance.Transaction( + 0, + breakerBox, + abi.encodeWithSelector(BreakerBox(0).toggleBreaker.selector, valueDeltaBreaker, rateFeed.rateFeedID, false) + ) + ); + } + } + + // Remove rate feeds from breaker box + for (uint256 i = 0; i < config.rateFeeds.length; i++) { + transactions.push( + ICeloGovernance.Transaction( + 0, + breakerBox, + abi.encodeWithSelector(BreakerBox(0).removeRateFeed.selector, config.rateFeeds[i].rateFeedID) + ) + ); + } + } + + /** + * @notice This function creates the transactions to configure the Median Delta Breaker. + */ + function proposal_revertMedianDeltaBreakers(eXOFConfig.eXOF memory config) private { + // Reset the cooldown time + transactions.push( + ICeloGovernance.Transaction( + 0, + medianDeltaBreaker, + abi.encodeWithSelector( + MedianDeltaBreaker(0).setCooldownTime.selector, + Arrays.addresses(config.CELOXOF.rateFeedID), + Arrays.uints(0) + ) + ) + ); + // Reset the rate change threshold + transactions.push( + ICeloGovernance.Transaction( + 0, + medianDeltaBreaker, + abi.encodeWithSelector( + MedianDeltaBreaker(0).setRateChangeThresholds.selector, + Arrays.addresses(config.CELOXOF.rateFeedID), + Arrays.uints(0) + ) + ) + ); + + // Reset the Median Rate EMA + transactions.push( + ICeloGovernance.Transaction( + 0, + medianDeltaBreaker, + abi.encodeWithSelector(MedianDeltaBreaker(0).resetMedianRateEMA.selector, config.CELOXOF.rateFeedID) + ) + ); + } + + /** + * @notice This function creates the transactions to revert the Value Delta Breaker configuration. + */ + function proposal_revertValueDeltaBreaker(eXOFConfig.eXOF memory config) private { + // Reset the cooldown times + transactions.push( + ICeloGovernance.Transaction( + 0, + valueDeltaBreaker, + abi.encodeWithSelector( + ValueDeltaBreaker(0).setCooldownTimes.selector, + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints(0, 0) + ) + ) + ); + // Reset the rate change thresholds + transactions.push( + ICeloGovernance.Transaction( + 0, + valueDeltaBreaker, + abi.encodeWithSelector( + ValueDeltaBreaker(0).setRateChangeThresholds.selector, + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints(0, 0) + ) + ) + ); + // Reset the reference values + transactions.push( + ICeloGovernance.Transaction( + 0, + valueDeltaBreaker, + abi.encodeWithSelector( + ValueDeltaBreaker(0).setReferenceValues.selector, + Arrays.addresses(config.EURXOF.rateFeedID, config.EUROCXOF.rateFeedID), + Arrays.uints(0, 0) + ) + ) + ); + } + + /** + * @notice Helper function to get the exchange ID for a pool. + */ + function getXOFExchangeId(address asset1, bool isConstantSum) internal view returns (bytes32) { + return + keccak256( + abi.encodePacked("eXOF", IERC20Metadata(asset1).symbol(), isConstantSum ? "ConstantSum" : "ConstantProduct") + ); + } + + /** + * @notice Helper function to get the exchange ID for a pool + */ + function getExchangeId(address asset0, address asset1, bool isConstantSum) internal view returns (bytes32) { + return + keccak256( + abi.encodePacked( + IERC20Metadata(asset0).symbol(), + IERC20Metadata(asset1).symbol(), + isConstantSum ? "ConstantSum" : "ConstantProduct" + ) + ); + } +} diff --git a/script/utils/Config.sol b/script/utils/Config.sol index 26075ad2..e0929110 100644 --- a/script/utils/Config.sol +++ b/script/utils/Config.sol @@ -87,10 +87,6 @@ library Config { * @dev List of Value Delta RateFeed Configurations for the rate feed. */ ValueDeltaBreaker valueDeltaBreaker0; - /** - * @dev List of Value Delta RateFeed Configurations for the rate feed. - */ - ValueDeltaBreaker valueDeltaBreaker1; /** * @dev List of dependent rate feeds. */ @@ -314,4 +310,11 @@ library Config { function getSelector(string memory _func) internal pure returns (bytes4) { return bytes4(keccak256(bytes(_func))); } + + /** + * @notice Helper function to compute the rate feed ID for a pair + */ + function rateFeedID(string memory pair) internal pure returns (address) { + return address(uint160(uint256(keccak256(abi.encodePacked(pair))))); + } } diff --git a/script/utils/SimulateUpgrade.sol b/script/utils/SimulateUpgrade.sol index f8b32050..63fae614 100644 --- a/script/utils/SimulateUpgrade.sol +++ b/script/utils/SimulateUpgrade.sol @@ -27,4 +27,14 @@ contract SimulateUpgrade is GovernanceScript { checks.run(); } } + + function check(string memory _upgrade) public { + IMentoUpgrade upgrade = IMentoUpgrade(factory.create(_upgrade)); + if (upgrade.hasChecks()) { + IScript checks = IScript(factory.create(string(abi.encodePacked(_upgrade, "Checks")))); + checks.run(); + } else { + console.log("No checks for %s", _upgrade); + } + } }