From a890017b7e654c723fda00ea51ca75693cf3a39b Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Wed, 18 Oct 2023 23:21:15 -0600 Subject: [PATCH 1/6] chore: remove dependencies --- .gitmodules | 10 +--------- lib/tokenized-strategy | 1 - lib/yearn-vaults-v3 | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) delete mode 160000 lib/tokenized-strategy delete mode 160000 lib/yearn-vaults-v3 diff --git a/.gitmodules b/.gitmodules index 40e17ab..6542c1d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,12 +5,4 @@ [submodule "lib/openzeppelin-contracts"] path = lib/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts - branch = v4.8.2 -[submodule "lib/tokenized-strategy"] - path = lib/tokenized-strategy - url = https://github.com/yearn/tokenized-strategy - branch = v3.0.1 -[submodule "lib/yearn-vaults-v3"] - path = lib/yearn-vaults-v3 - url = https://github.com/yearn/yearn-vaults-v3 - branch = v3.0.1 \ No newline at end of file + branch = v4.8.2 \ No newline at end of file diff --git a/lib/tokenized-strategy b/lib/tokenized-strategy deleted file mode 160000 index 718194e..0000000 --- a/lib/tokenized-strategy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 718194eeb58768aa168969c882dfef80252c477c diff --git a/lib/yearn-vaults-v3 b/lib/yearn-vaults-v3 deleted file mode 160000 index 45b5d6b..0000000 --- a/lib/yearn-vaults-v3 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 45b5d6b48da5b875dc9b7997275f8708d9e41656 From e486a79417b3b4680ce1a482c76290b139d1a1e6 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Wed, 18 Oct 2023 23:21:51 -0600 Subject: [PATCH 2/6] forge install: tokenized-strategy v3.0.1 --- .gitmodules | 5 ++++- lib/tokenized-strategy | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 160000 lib/tokenized-strategy diff --git a/.gitmodules b/.gitmodules index 6542c1d..04a7cea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,4 +5,7 @@ [submodule "lib/openzeppelin-contracts"] path = lib/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts - branch = v4.8.2 \ No newline at end of file + branch = v4.8.2 +[submodule "lib/tokenized-strategy"] + path = lib/tokenized-strategy + url = https://github.com/yearn/tokenized-strategy diff --git a/lib/tokenized-strategy b/lib/tokenized-strategy new file mode 160000 index 0000000..c5c34db --- /dev/null +++ b/lib/tokenized-strategy @@ -0,0 +1 @@ +Subproject commit c5c34db64df9b68f87627996596d91479e3b4f90 From c06bfec96bc37edcf0f7b6ad6131d591811fbd13 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Wed, 18 Oct 2023 23:22:16 -0600 Subject: [PATCH 3/6] forge install: yearn-vaults-v3 v3.0.1 --- .gitmodules | 3 +++ lib/yearn-vaults-v3 | 1 + 2 files changed, 4 insertions(+) create mode 160000 lib/yearn-vaults-v3 diff --git a/.gitmodules b/.gitmodules index 04a7cea..5a58462 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,3 +9,6 @@ [submodule "lib/tokenized-strategy"] path = lib/tokenized-strategy url = https://github.com/yearn/tokenized-strategy +[submodule "lib/yearn-vaults-v3"] + path = lib/yearn-vaults-v3 + url = https://github.com/yearn/yearn-vaults-v3 diff --git a/lib/yearn-vaults-v3 b/lib/yearn-vaults-v3 new file mode 160000 index 0000000..9a25833 --- /dev/null +++ b/lib/yearn-vaults-v3 @@ -0,0 +1 @@ +Subproject commit 9a258338c4c8d2cf96dae7755922258812df1923 From ff07ea74bbea648fea1eae765bafcc196e3ce632 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Wed, 18 Oct 2023 23:23:54 -0600 Subject: [PATCH 4/6] chore: update to interface --- .gitmodules | 2 ++ src/AprOracle/AprOracle.sol | 3 +++ src/ReportTrigger/CommonReportTrigger.sol | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 5a58462..c495f89 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,6 +9,8 @@ [submodule "lib/tokenized-strategy"] path = lib/tokenized-strategy url = https://github.com/yearn/tokenized-strategy + branch = 3.0.1 [submodule "lib/yearn-vaults-v3"] path = lib/yearn-vaults-v3 url = https://github.com/yearn/yearn-vaults-v3 + branch = 3.0.1 \ No newline at end of file diff --git a/src/AprOracle/AprOracle.sol b/src/AprOracle/AprOracle.sol index ba5e929..5713488 100644 --- a/src/AprOracle/AprOracle.sol +++ b/src/AprOracle/AprOracle.sol @@ -125,6 +125,9 @@ contract AprOracle { ) public view returns (uint256 apr) { IVault vault = IVault(_vault); + // Check if the full profit has already been unlocked. + if(vault.fullProfitUnlockDate() <= block.timestamp) return 0; + // Need the total assets in the vault post delta. uint256 assets = uint256(int256(vault.totalAssets()) + _delta); diff --git a/src/ReportTrigger/CommonReportTrigger.sol b/src/ReportTrigger/CommonReportTrigger.sol index 7619534..c3cbf76 100644 --- a/src/ReportTrigger/CommonReportTrigger.sol +++ b/src/ReportTrigger/CommonReportTrigger.sol @@ -356,7 +356,7 @@ contract CommonReportTrigger is Governance { IVault vault = IVault(_vault); // Don't report if the vault is shutdown. - if (vault.shutdown()) return (false, bytes("Shutdown")); + if (vault.isShutdown()) return (false, bytes("Shutdown")); // Cache the strategy parameters. IVault.StrategyParams memory params = vault.strategies(_strategy); From aa03095a0fbd184816c90be3aed2bbfbbd0ba088 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Wed, 18 Oct 2023 23:26:24 -0600 Subject: [PATCH 5/6] fix: lint --- src/AprOracle/AprOracle.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AprOracle/AprOracle.sol b/src/AprOracle/AprOracle.sol index 5713488..0382f2f 100644 --- a/src/AprOracle/AprOracle.sol +++ b/src/AprOracle/AprOracle.sol @@ -126,7 +126,7 @@ contract AprOracle { IVault vault = IVault(_vault); // Check if the full profit has already been unlocked. - if(vault.fullProfitUnlockDate() <= block.timestamp) return 0; + if (vault.fullProfitUnlockDate() <= block.timestamp) return 0; // Need the total assets in the vault post delta. uint256 assets = uint256(int256(vault.totalAssets()) + _delta); From 7260ceac674596bb6ada7e13a9271c7a150e5f01 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Thu, 19 Oct 2023 00:02:46 -0600 Subject: [PATCH 6/6] chore: update readme --- README.md | 15 +++++++++++++++ src/test/utils/Setup.sol | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 551a1f4..44c5e79 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,21 @@ Run tests make test ``` +### Deployment + +Deployment of periphery contracts such as the [Apr Oracle](https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/AprOracle/AprOracle.sol) or [Common Report Trigger](https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/ReportTrigger/CommonReportTrigger.sol) are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain. + +This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on. + +1. Add your deployers Private key under PRIVATE_KEY in your .env file. + - NOTE: make sure to add `0x` to the beginning of the key. +2. Run the deployment script + ```sh + forge script script/Deploy.s.sol:Deploy --broadcast --rpc-url YOUR_RPC + ``` + - You can do a dry run before officially deploying by removing the `--broadcast` flag. + - For chains that don't support 1559 tx's you may need to add a `--legacy` flag. +3. The address the contract was deployed at will print in the console and should match any other chain the same version has been deployed on. ## Swapper helper contracts For strategies that need to swap reward tokens back into 'asset' a series of 'swapper' contracts have been pre-developed to make your preferred method as easy as possible to use. diff --git a/src/test/utils/Setup.sol b/src/test/utils/Setup.sol index 5c0708c..201f4d8 100644 --- a/src/test/utils/Setup.sol +++ b/src/test/utils/Setup.sol @@ -13,7 +13,6 @@ import {VaultConstants, Roles} from "@yearn-vaults/interfaces/VaultConstants.sol import {IVaultFactory} from "@yearn-vaults/interfaces/IVaultFactory.sol"; import {MockStrategy} from "../mocks/MockStrategy.sol"; -import {Governance} from "../../utils/Governance.sol"; contract Setup is ExtendedTest { VyperDeployer public vyperDeployer = new VyperDeployer(); @@ -189,7 +188,7 @@ contract Setup is ExtendedTest { } function setFees(uint16 _protocolFee, uint16 _performanceFee) public { - address gov = Governance(address(vaultFactory)).governance(); + address gov = vaultFactory.governance(); // Need to make sure there is a protocol fee recipient to set the fee. vm.prank(gov);