From ae2dc17e6015b40988766c122e55580386ee9fae Mon Sep 17 00:00:00 2001 From: Roman Agureev Date: Mon, 16 Sep 2024 21:25:13 +0300 Subject: [PATCH] chore: bump to 0.3.10 and add hardhat config --- contracts/ChildGaugeFactory.vy | 11 ++++++----- contracts/ProxyAdmin.vy | 5 ++++- contracts/Recover.vy | 2 +- contracts/RewardForwarder.vy | 7 ++++++- contracts/RootGaugeFactory.vy | 3 ++- contracts/RootGaugeFactoryProxy.vy | 3 ++- contracts/Script.vy | 12 ++++++++++-- contracts/implementations/ChildGauge.vy | 3 ++- contracts/implementations/RootGauge.vy | 3 ++- contracts/mocks/MockBridger.vy | 2 +- hardhat.config.js | 12 ++++++++++++ requirements.in | 2 +- 12 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 hardhat.config.js diff --git a/contracts/ChildGaugeFactory.vy b/contracts/ChildGaugeFactory.vy index 820df80..06d90bc 100644 --- a/contracts/ChildGaugeFactory.vy +++ b/contracts/ChildGaugeFactory.vy @@ -1,8 +1,9 @@ -# @version 0.3.7 +# pragma version 0.3.10 """ @title Child Liquidity Gauge Factory @license MIT @author Curve Finance +@custom:version 2.0.0 """ version: public(constant(String[8])) = "2.0.0" @@ -108,7 +109,7 @@ def _psuedo_mint(_gauge: address, _user: address): assert gauge_data != 0 # dev: invalid gauge # if is_mirrored and last_request != this week - if bitwise_and(gauge_data, 2) != 0 and shift(gauge_data, -2) / WEEK != block.timestamp / WEEK: + if gauge_data & 2 != 0 and (gauge_data >> 2) / WEEK != block.timestamp / WEEK: CallProxy(self.call_proxy).anyCall( self, _abi_encode(_gauge, method_id=method_id("transmit_emissions(address)")), @@ -116,7 +117,7 @@ def _psuedo_mint(_gauge: address, _user: address): 1, ) # update last request time - self.gauge_data[_gauge] = shift(block.timestamp, 2) + 3 + self.gauge_data[_gauge] = block.timestamp << 2 + 3 assert ChildGauge(_gauge).user_checkpoint(_user) total_mint: uint256 = ChildGauge(_gauge).integrate_fraction(_user) @@ -257,7 +258,7 @@ def set_mirrored(_gauge: address, _mirrored: bool): assert gauge_data != 0 # dev: invalid gauge assert msg.sender == self.owner # dev: only owner - gauge_data = shift(shift(gauge_data, -2), 2) + 1 # set is_valid_gauge = True + gauge_data = gauge_data | 1 # set is_valid_gauge = True if _mirrored: gauge_data += 2 # set is_mirrored = True @@ -328,4 +329,4 @@ def last_request(_gauge: address) -> uint256: @notice Query the timestamp of the last cross chain request for emissions @param _gauge The address of the gauge of interest """ - return shift(self.gauge_data[_gauge], -2) + return self.gauge_data[_gauge] >> 2 diff --git a/contracts/ProxyAdmin.vy b/contracts/ProxyAdmin.vy index e76f7c4..8e74525 100644 --- a/contracts/ProxyAdmin.vy +++ b/contracts/ProxyAdmin.vy @@ -1,11 +1,14 @@ -# @version 0.3.1 +# pragma version 0.3.10 """ @title ProxyAdmin @notice Thin proxy allowing shared ownership of contracts @author Ben Hauser @license MIT +@custom:version 0.0.1 """ +version: public(constant(String[8])) = "0.0.1" + event TransactionExecuted: admin: indexed(address) diff --git a/contracts/Recover.vy b/contracts/Recover.vy index f116bdd..5bfb7fe 100644 --- a/contracts/Recover.vy +++ b/contracts/Recover.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# pragma version 0.3.10 @pure diff --git a/contracts/RewardForwarder.vy b/contracts/RewardForwarder.vy index e25a464..7bf80cb 100644 --- a/contracts/RewardForwarder.vy +++ b/contracts/RewardForwarder.vy @@ -1,7 +1,12 @@ -# @version 0.3.1 +# pragma version 0.3.10 """ @title Reward Forwarder +@custom:version 0.0.1 """ + +version: public(constant(String[8])) = "0.0.1" + + from vyper.interfaces import ERC20 diff --git a/contracts/RootGaugeFactory.vy b/contracts/RootGaugeFactory.vy index 48a70b9..c2dea6e 100644 --- a/contracts/RootGaugeFactory.vy +++ b/contracts/RootGaugeFactory.vy @@ -1,8 +1,9 @@ -# pragma version 0.3.7 +# pragma version 0.3.10 """ @title Root Liquidity Gauge Factory @license MIT @author Curve Finance +@custom:version 1.0.1 """ version: public(constant(String[8])) = "1.0.1" diff --git a/contracts/RootGaugeFactoryProxy.vy b/contracts/RootGaugeFactoryProxy.vy index f143cef..6117317 100644 --- a/contracts/RootGaugeFactoryProxy.vy +++ b/contracts/RootGaugeFactoryProxy.vy @@ -1,8 +1,9 @@ -# pragma version 0.3.7 +# pragma version 0.3.10 """ @title Root Gauge Factory Proxy Owner @license MIT @author CurveFi +@custom:version 1.0.1 """ version: public(constant(String[8])) = "1.0.1" diff --git a/contracts/Script.vy b/contracts/Script.vy index de05152..1e162ff 100644 --- a/contracts/Script.vy +++ b/contracts/Script.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# pragma version 0.3.10 interface AnyCall: @@ -43,4 +43,12 @@ def __init__(_params: GaugeParams[N_GAUGES]): # increase execution budget for future callbacks used in deployment process AnyCall(ANYCALL).deposit(FACTORY, value=as_wei_value(2, "ether")) - selfdestruct(msg.sender) + send(msg.sender, self.balance) + + +@external +def dummy() -> uint256: + """ + @dev Dummy method for brownie not to fail + """ + return max_value(uint256) diff --git a/contracts/implementations/ChildGauge.vy b/contracts/implementations/ChildGauge.vy index 0ed9273..1c28a31 100644 --- a/contracts/implementations/ChildGauge.vy +++ b/contracts/implementations/ChildGauge.vy @@ -1,10 +1,11 @@ -# pragma version 0.3.7 +# pragma version 0.3.10 # pragma optimize gas """ @title CurveXChainLiquidityGauge @license Copyright (c) Curve.Fi, 2020-2024 - all rights reserved @author Curve.Fi @notice Layer2/Cross-Chain Gauge +@custom:version 1.0.0 """ diff --git a/contracts/implementations/RootGauge.vy b/contracts/implementations/RootGauge.vy index 357a84f..6993332 100644 --- a/contracts/implementations/RootGauge.vy +++ b/contracts/implementations/RootGauge.vy @@ -1,8 +1,9 @@ -# pragma version 0.3.7 +# pragma version 0.3.10 """ @title Root Liquidity Gauge Implementation @license MIT @author Curve Finance +@custom:version 1.0.1 """ version: public(constant(String[8])) = "1.0.1" diff --git a/contracts/mocks/MockBridger.vy b/contracts/mocks/MockBridger.vy index 74592da..63132b2 100644 --- a/contracts/mocks/MockBridger.vy +++ b/contracts/mocks/MockBridger.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# pragma version 0.3.10 @view diff --git a/hardhat.config.js b/hardhat.config.js new file mode 100644 index 0000000..eae744f --- /dev/null +++ b/hardhat.config.js @@ -0,0 +1,12 @@ +module.exports = { + networks: { + hardhat: { + hardfork: "shanghai", + // base fee of 0 allows use of 0 gas price when testing + initialBaseFeePerGas: 0, + // brownie expects calls and transactions to throw on revert + throwOnTransactionFailures: true, + throwOnCallFailures: true + } + } +} diff --git a/requirements.in b/requirements.in index 3248564..2b99c7d 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ black -eth-brownie==1.20.3 +eth-brownie==1.20.6 brownie-token-tester flake8==3.9.2 isort