From d185c78a4210a4950d4c412eb23eb776461c7b09 Mon Sep 17 00:00:00 2001 From: Schlag <89420541+Schlagonia@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:07:40 -0600 Subject: [PATCH] chore: updates to periphery (#35) * chore: remove old * forge install: tokenized-strategy-periphery 6ce8d29b1e107a89754dd9f17337582734989b4d * fix: remove version * forge install: tokenized-strategy v3.0.2-1 * fix: module versions * chore: bump version (#34) * chore: bump version bump to 0.8.23 * chore: update submodules * fix: greater than 18 * fix: redo requirements * feat: one more bump * fix: use console2 --------- Co-authored-by: Schlag <89420541+Schlagonia@users.noreply.github.com> * feat: comment --------- Co-authored-by: dudesahn <23222916+dudesahn@users.noreply.github.com> --- .gitignore | 3 ++- .gitmodules | 11 ++++++----- .solhint.json | 2 +- .vscode/settings.json | 2 +- Makefile | 15 +++++++++++++-- README.md | 2 ++ foundry.toml | 2 +- lib/forge-std | 2 +- lib/tokenized-strategy | 2 +- lib/tokenized-strategy-periphery | 2 +- package.json | 2 +- src/Strategy.sol | 2 +- src/interfaces/IStrategyInterface.sol | 2 +- src/periphery/StrategyAprOracle.sol | 2 +- src/test/FunctionSignature.t.sol | 2 +- src/test/Operation.t.sol | 4 ++-- src/test/Oracle.t.sol | 2 +- src/test/Shutdown.t.sol | 2 +- src/test/utils/ExtendedTest.sol | 2 +- src/test/utils/Setup.sol | 4 ++-- 20 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 01c15f79..dc0661d1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ docs/ node_modules/ .gas-snapshot -yarn.lock \ No newline at end of file +yarn.lock +.DS_Store diff --git a/.gitmodules b/.gitmodules index dc57e40f..37f73502 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,14 +2,15 @@ path = lib/forge-std url = https://github.com/foundry-rs/forge-std branch = master -[submodule "lib/tokenized-strategy"] - path = lib/tokenized-strategy - url = https://github.com/yearn/tokenized-strategy - release = v3.0.2 [submodule "lib/openzeppelin-contracts"] path = lib/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts + branch = v4.9.5 [submodule "lib/tokenized-strategy-periphery"] path = lib/tokenized-strategy-periphery url = https://github.com/yearn/tokenized-strategy-periphery - branch = master \ No newline at end of file + branch = master +[submodule "lib/tokenized-strategy"] + path = lib/tokenized-strategy + url = https://github.com/yearn/tokenized-strategy + branch = v3.0.2-1 \ No newline at end of file diff --git a/.solhint.json b/.solhint.json index d5e18963..f40d9b02 100644 --- a/.solhint.json +++ b/.solhint.json @@ -2,7 +2,7 @@ "extends": "solhint:recommended", "plugins": [], "rules": { - "compiler-version": ["error", "0.8.18"], + "compiler-version": ["error", "^0.8.18"], "code-complexity": "warn", "const-name-snakecase": "warn", "function-max-lines": "warn", diff --git a/.vscode/settings.json b/.vscode/settings.json index d43cdd74..eb095a44 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "solidity.compileUsingRemoteVersion": "v0.8.18", + "solidity.compileUsingRemoteVersion": "v0.8.23", "solidity.remappings": [ "@openzeppelin/=./lib/openzeppelin-contracts/", "forge-std/=lib/forge-std/src/", diff --git a/Makefile b/Makefile index 9a7a7d10..4ab15174 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,12 @@ size :; forge build --sizes # storage inspection inspect :; forge inspect ${contract} storage-layout --pretty -FORK_URL := ${ETH_RPC_URL} +# specify which fork to use. set this in our .env +# if we want to test multiple forks in one go, remove this as an argument below +FORK_URL := ${ETH_RPC_URL} # BASE_RPC_URL, ETH_RPC_URL, ARBITRUM_RPC_URL + +# if we want to run only matching tests, set that here +test := test_ # local tests without fork test :; forge test -vv --fork-url ${FORK_URL} @@ -18,9 +23,15 @@ test-contract :; forge test -vv --match-contract $(contract) --fork-url ${FORK_ test-contract-gas :; forge test --gas-report --match-contract ${contract} --fork-url ${FORK_URL} trace-contract :; forge test -vvv --match-contract $(contract) --fork-url ${FORK_URL} test-test :; forge test -vv --match-test $(test) --fork-url ${FORK_URL} -trace-test :; forge test -vvv --match-test $(test) --fork-url ${FORK_URL} +test-test-trace :; forge test -vvv --match-test $(test) --fork-url ${FORK_URL} +trace-test :; forge test -vvvvv --match-test $(test) --fork-url ${FORK_URL} snapshot :; forge snapshot -vv --fork-url ${FORK_URL} snapshot-diff :; forge snapshot --diff -vv --fork-url ${FORK_URL} +trace-setup :; forge test -vvvv --fork-url ${FORK_URL} +trace-max :; forge test -vvvvv --fork-url ${FORK_URL} +coverage :; forge coverage --fork-url ${FORK_URL} +coverage-report :; forge coverage --report lcov --fork-url ${FORK_URL} +coverage-debug :; forge coverage --report debug --fork-url ${FORK_URL} clean :; forge clean diff --git a/README.md b/README.md index a793f001..5a810072 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ make test For a complete guide to creating a Tokenized Strategy please visit: https://docs.yearn.fi/developers/v3/strategy_writing_guide +NOTE: Compiler defaults to 8.23 but it can be adjusted in the foundry toml. + ## Testing Due to the nature of the BaseStrategy utilizing an external contract for the majority of its logic, the default interface for any tokenized strategy will not allow proper testing of all functions. Testing of your Strategy should utilize the pre-built [IStrategyInterface](https://github.com/yearn/tokenized-strategy-foundry-mix/blob/master/src/interfaces/IStrategyInterface.sol) to cast any deployed strategy through for testing, as seen in the Setup example. You can add any external functions that you add for your specific strategy to this interface to be able to test all functions with one variable. diff --git a/foundry.toml b/foundry.toml index f3e432f9..262de881 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,7 +2,7 @@ src = 'src' out = 'out' libs = ['lib'] -solc = "0.8.18" +solc = "0.8.23" remappings = [ "@openzeppelin/=lib/openzeppelin-contracts/", diff --git a/lib/forge-std b/lib/forge-std index bb4ceea9..fc560fa3 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit bb4ceea94d6f10eeb5b41dc2391c6c8bf8e734ef +Subproject commit fc560fa34fa12a335a50c35d92e55a6628ca467c diff --git a/lib/tokenized-strategy b/lib/tokenized-strategy index 0d90dee1..7bf18701 160000 --- a/lib/tokenized-strategy +++ b/lib/tokenized-strategy @@ -1 +1 @@ -Subproject commit 0d90dee170d53a0e04af3ff41d2f7a4f3ac395bd +Subproject commit 7bf187015f5f7159276f80cd52204431ab1b3b8b diff --git a/lib/tokenized-strategy-periphery b/lib/tokenized-strategy-periphery index bbc3a035..6ce8d29b 160000 --- a/lib/tokenized-strategy-periphery +++ b/lib/tokenized-strategy-periphery @@ -1 +1 @@ -Subproject commit bbc3a0354f45dab087a4c82650e42225433c8fef +Subproject commit 6ce8d29b1e107a89754dd9f17337582734989b4d diff --git a/package.json b/package.json index 441bb9f0..2a4917ea 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "prettier": "^2.5.1", "prettier-plugin-solidity": "^1.0.0-beta.19", "pretty-quick": "^3.1.3", - "solc": "0.8.18", + "solc": "0.8.23", "solhint": "^3.3.7", "solhint-plugin-prettier": "^0.0.5" }, diff --git a/src/Strategy.sol b/src/Strategy.sol index b97517cf..def08717 100644 --- a/src/Strategy.sol +++ b/src/Strategy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import {BaseStrategy, ERC20} from "@tokenized-strategy/BaseStrategy.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/src/interfaces/IStrategyInterface.sol b/src/interfaces/IStrategyInterface.sol index 49799bac..917e2d0c 100644 --- a/src/interfaces/IStrategyInterface.sol +++ b/src/interfaces/IStrategyInterface.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import {IStrategy} from "@tokenized-strategy/interfaces/IStrategy.sol"; diff --git a/src/periphery/StrategyAprOracle.sol b/src/periphery/StrategyAprOracle.sol index ac2ae6e0..1c0bfb8f 100644 --- a/src/periphery/StrategyAprOracle.sol +++ b/src/periphery/StrategyAprOracle.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import {AprOracleBase} from "@periphery/AprOracle/AprOracleBase.sol"; diff --git a/src/test/FunctionSignature.t.sol b/src/test/FunctionSignature.t.sol index ea8ad4f6..0389a271 100644 --- a/src/test/FunctionSignature.t.sol +++ b/src/test/FunctionSignature.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.18; -import "forge-std/console.sol"; +import "forge-std/console2.sol"; import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol"; contract FunctionSignatureTest is Setup { diff --git a/src/test/Operation.t.sol b/src/test/Operation.t.sol index bfaad36a..9a3f25be 100644 --- a/src/test/Operation.t.sol +++ b/src/test/Operation.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.18; -import "forge-std/console.sol"; +import "forge-std/console2.sol"; import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol"; contract OperationTest is Setup { @@ -10,7 +10,7 @@ contract OperationTest is Setup { } function test_setupStrategyOK() public { - console.log("address of strategy", address(strategy)); + console2.log("address of strategy", address(strategy)); assertTrue(address(0) != address(strategy)); assertEq(strategy.asset(), address(asset)); assertEq(strategy.management(), management); diff --git a/src/test/Oracle.t.sol b/src/test/Oracle.t.sol index 4b1f80dd..f7c349c4 100644 --- a/src/test/Oracle.t.sol +++ b/src/test/Oracle.t.sol @@ -1,6 +1,6 @@ pragma solidity ^0.8.18; -import "forge-std/console.sol"; +import "forge-std/console2.sol"; import {Setup} from "./utils/Setup.sol"; import {StrategyAprOracle} from "../periphery/StrategyAprOracle.sol"; diff --git a/src/test/Shutdown.t.sol b/src/test/Shutdown.t.sol index b8313328..a9ce1e5e 100644 --- a/src/test/Shutdown.t.sol +++ b/src/test/Shutdown.t.sol @@ -1,6 +1,6 @@ pragma solidity ^0.8.18; -import "forge-std/console.sol"; +import "forge-std/console2.sol"; import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol"; contract ShutdownTest is Setup { diff --git a/src/test/utils/ExtendedTest.sol b/src/test/utils/ExtendedTest.sol index e8fcc6ce..4dfd4f1f 100644 --- a/src/test/utils/ExtendedTest.sol +++ b/src/test/utils/ExtendedTest.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import {Test} from "forge-std/Test.sol"; diff --git a/src/test/utils/Setup.sol b/src/test/utils/Setup.sol index 99793794..a24c4dc5 100644 --- a/src/test/utils/Setup.sol +++ b/src/test/utils/Setup.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; -import "forge-std/console.sol"; +import "forge-std/console2.sol"; import {ExtendedTest} from "./ExtendedTest.sol"; import {Strategy, ERC20} from "../../Strategy.sol";