Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updates to periphery #35

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ docs/
node_modules/
.gas-snapshot

yarn.lock
yarn.lock
.DS_Store
11 changes: 6 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
branch = master
[submodule "lib/tokenized-strategy"]
path = lib/tokenized-strategy
url = https://github.com/yearn/tokenized-strategy
branch = v3.0.2-1
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
src = 'src'
out = 'out'
libs = ['lib']
solc = "0.8.18"
solc = "0.8.23"

remappings = [
"@openzeppelin/=lib/openzeppelin-contracts/",
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenized-strategy-periphery
Submodule tokenized-strategy-periphery updated 59 files
+1 −0 foundry.toml
+1 −1 script/DeployAprOracle.s.sol
+1 −1 script/DeployAuctionFactory.sol
+1 −1 script/DeployCommonTrigger.s.sol
+1 −1 src/AprOracle/AprOracle.sol
+1 −1 src/AprOracle/AprOracleBase.sol
+2 −2 src/Auctions/Auction.sol
+1 −1 src/Auctions/AuctionFactory.sol
+1 −1 src/Bases/4626Compounder/Base4626Compounder.sol
+1 −1 src/Bases/4626Compounder/IBase4626Compounder.sol
+619 −0 src/Bases/Auctioneer/BaseAuctioneer.sol
+97 −0 src/Bases/Auctioneer/IBaseAuctioneer.sol
+5 −3 src/Bases/HealthCheck/BaseHealthCheck.sol
+1 −1 src/Bases/HealthCheck/IBaseHealthCheck.sol
+1 −1 src/Bases/Hooks/BaseHooks.sol
+1 −1 src/Bases/Hooks/Hooks.sol
+1 −1 src/ReportTrigger/CommonReportTrigger.sol
+1 −1 src/ReportTrigger/CustomStrategyTriggerBase.sol
+1 −1 src/ReportTrigger/CustomVaultTriggerBase.sol
+1 −1 src/interfaces/ITaker.sol
+5 −5 src/interfaces/Solidly/ISolidly.sol
+1 −1 src/interfaces/TradeFactory/ITradeFactory.sol
+1 −1 src/libraries/Maths.sol
+1 −1 src/swappers/AuctionSwapper.sol
+1 −1 src/swappers/SolidlySwapper.sol
+85 −30 src/swappers/TradeFactorySwapper.sol
+1 −1 src/swappers/UniswapV2Swapper.sol
+1 −1 src/swappers/UniswapV3Swapper.sol
+1 −1 src/swappers/interfaces/IAuctionSwapper.sol
+1 −1 src/swappers/interfaces/ISolidlySwapper.sol
+1 −1 src/swappers/interfaces/ITradeFactorySwapper.sol
+1 −1 src/swappers/interfaces/IUniswapV2Swapper.sol
+1 −1 src/swappers/interfaces/IUniswapV3Swapper.sol
+1 −1 src/test/Auction.t.sol
+1 −1 src/test/AuctionSwapper.t.sol
+1 −1 src/test/Base4626.t.sol
+455 −0 src/test/BaseAuctioneer.t.sol
+1 −1 src/test/BaseHook.t.sol
+1 −1 src/test/CommonTrigger.t.sol
+1 −1 src/test/HealthCheck.t.sol
+1 −1 src/test/SolidlySwapper.t.sol
+1 −1 src/test/UniV2Swapper.t.sol
+1 −1 src/test/UniV3Swapper.t.sol
+1 −1 src/test/mocks/MockAuctionSwapper.sol
+95 −0 src/test/mocks/MockAuctioneer.sol
+1 −1 src/test/mocks/MockCustomStrategyTrigger.sol
+1 −1 src/test/mocks/MockCustomVaultTrigger.sol
+1 −1 src/test/mocks/MockHealthCheck.sol
+1 −1 src/test/mocks/MockHooks.sol
+1 −1 src/test/mocks/MockSolidlySwapper.sol
+1 −1 src/test/mocks/MockStrategy.sol
+1 −1 src/test/mocks/MockUniswapV2Swapper.sol
+1 −1 src/test/mocks/MockUniswapV3Swapper.sol
+1 −1 src/test/utils/ExtendedTest.sol
+1 −1 src/test/utils/Setup.sol
+1 −1 src/test/utils/VyperDeployer.sol
+1 −1 src/utils/Clonable.sol
+1 −1 src/utils/Governance.sol
+1 −1 src/utils/Governance2Step.sol
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Strategy.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -43,7 +43,7 @@
* @param _amount The amount of 'asset' that the strategy can attempt
* to deposit in the yield source.
*/
function _deployFunds(uint256 _amount) internal override {

Check warning on line 46 in src/Strategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Code contains empty blocks
// TODO: implement deposit logic EX:
//
// lendingPool.deposit(address(asset), _amount ,0);
Expand All @@ -70,7 +70,7 @@
*
* @param _amount, The amount of 'asset' to be freed.
*/
function _freeFunds(uint256 _amount) internal override {

Check warning on line 73 in src/Strategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Code contains empty blocks
// TODO: implement withdraw logic EX:
//
// lendingPool.withdraw(address(asset), _amount);
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IStrategyInterface.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.18;
pragma solidity ^0.8.18;

import {IStrategy} from "@tokenized-strategy/interfaces/IStrategy.sol";

interface IStrategyInterface is IStrategy {

Check warning on line 6 in src/interfaces/IStrategyInterface.sol

View workflow job for this annotation

GitHub Actions / solidity

Code contains empty blocks
//TODO: Add your specific implementation interface in here.
}
2 changes: 1 addition & 1 deletion src/periphery/StrategyAprOracle.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -26,8 +26,8 @@
* @return . The expected apr for the strategy represented as 1e18.
*/
function aprAfterDebtChange(
address _strategy,

Check warning on line 29 in src/periphery/StrategyAprOracle.sol

View workflow job for this annotation

GitHub Actions / solidity

Variable "_strategy" is unused
int256 _delta

Check warning on line 30 in src/periphery/StrategyAprOracle.sol

View workflow job for this annotation

GitHub Actions / solidity

Variable "_delta" is unused
) external view override returns (uint256) {
// TODO: Implement any necessary logic to return the most accurate
// APR estimation for the strategy.
Expand Down
2 changes: 1 addition & 1 deletion src/test/FunctionSignature.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import "forge-std/console.sol";
import "forge-std/console2.sol";

Check warning on line 4 in src/test/FunctionSignature.t.sol

View workflow job for this annotation

GitHub Actions / solidity

global import of path forge-std/console2.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol";

Check warning on line 5 in src/test/FunctionSignature.t.sol

View workflow job for this annotation

GitHub Actions / solidity

imported name IStrategyInterface is not used

contract FunctionSignatureTest is Setup {
function setUp() public virtual override {
Expand All @@ -12,7 +12,7 @@
// This test should not be overridden and checks that
// no function signature collisions occurred from the custom functions.
// Does not check functions that are strategy dependant and will be checked in other tests
function test_functionCollisions() public {

Check warning on line 15 in src/test/FunctionSignature.t.sol

View workflow job for this annotation

GitHub Actions / solidity

Function body contains 76 lines but allowed no more than 50 lines

Check warning on line 15 in src/test/FunctionSignature.t.sol

View workflow job for this annotation

GitHub Actions / solidity

Function name must be in mixedCase
uint256 wad = 1e18;
vm.expectRevert("initialized");
strategy.initialize(
Expand Down
4 changes: 2 additions & 2 deletions src/test/Operation.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import "forge-std/console.sol";
import "forge-std/console2.sol";

Check warning on line 4 in src/test/Operation.t.sol

View workflow job for this annotation

GitHub Actions / solidity

global import of path forge-std/console2.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import {Setup, ERC20, IStrategyInterface} from "./utils/Setup.sol";

contract OperationTest is Setup {
Expand All @@ -10,7 +10,7 @@
}

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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/Oracle.t.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/test/Shutdown.t.sol
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/utils/ExtendedTest.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
4 changes: 2 additions & 2 deletions src/test/utils/Setup.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Loading