-
Notifications
You must be signed in to change notification settings - Fork 1
Secondary action fee #184
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
Merged
Merged
Secondary action fee #184
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity 0.8.29; | ||
|
|
||
| import { Test } from "forge-std/Test.sol"; | ||
|
|
||
| import { | ||
| ITransparentUpgradeableProxy | ||
| } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
| import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
|
|
||
| import { Controller } from "../../src/controller/Controller.sol"; | ||
| import { GenericVault, IERC20 } from "../../src/vault/GenericVault.sol"; | ||
| import { IChainlinkAggregatorLike } from "../../src/interfaces/IChainlinkAggregatorLike.sol"; | ||
|
|
||
| contract ControllerUpgradeForkTest is Test { | ||
| address constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; | ||
| address constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; | ||
| address constant USDS = 0xdC035D45d973E3EC169d2276DDab16f1e407384F; | ||
|
|
||
| address proxyAdminOwner = 0x3794d7f91b3Dd3b338FEe671aC6AA42BEA5e3D17; | ||
| ProxyAdmin proxyAdmin = ProxyAdmin(0x55835D50EbD78977a4686264E411f93E8ce75bFb); | ||
| Controller controller = Controller(0x3a64D23313E1bEAABa25Ec13149bD8D514C973Ae); | ||
|
|
||
| address user = makeAddr("user"); | ||
|
|
||
| function setUp() public virtual { | ||
| vm.createSelectFork("mainnet"); | ||
|
|
||
| deal(user, 1e18); | ||
| deal(USDC, user, 1_000_000e6); | ||
| } | ||
|
|
||
| function _upgradeController() internal { | ||
| Controller newImpl = new Controller(); | ||
|
|
||
| vm.startPrank(proxyAdminOwner); | ||
| proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(address(controller)), address(newImpl), ""); | ||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| function test_shouldReturnSameStoredValues() public { | ||
| bool origPaused = controller.paused(); | ||
| address origShare = controller.share(); | ||
|
|
||
| address origUsdcMainVault = controller.vaultFor(USDC); | ||
| address origUsdtMainVault = controller.vaultFor(USDT); | ||
| address origUsdsMainVault = controller.vaultFor(USDS); | ||
|
|
||
| (IChainlinkAggregatorLike origUsdcPriceFeed,) = controller.priceFeeds(USDC); | ||
| (IChainlinkAggregatorLike origUsdtPriceFeed,) = controller.priceFeeds(USDT); | ||
| (IChainlinkAggregatorLike origUsdsPriceFeed,) = controller.priceFeeds(USDS); | ||
|
|
||
| _upgradeController(); | ||
|
|
||
| (IChainlinkAggregatorLike newUsdcPriceFeed,) = controller.priceFeeds(USDC); | ||
| (IChainlinkAggregatorLike newUsdtPriceFeed,) = controller.priceFeeds(USDT); | ||
| (IChainlinkAggregatorLike newUsdsPriceFeed,) = controller.priceFeeds(USDS); | ||
|
|
||
| assertEq(controller.paused(), origPaused); | ||
| assertEq(controller.share(), origShare); | ||
| assertEq(controller.vaultFor(USDC), origUsdcMainVault); | ||
| assertEq(controller.vaultFor(USDT), origUsdtMainVault); | ||
| assertEq(controller.vaultFor(USDS), origUsdsMainVault); | ||
| assertEq(address(newUsdcPriceFeed), address(origUsdcPriceFeed)); | ||
| assertEq(address(newUsdtPriceFeed), address(origUsdtPriceFeed)); | ||
| assertEq(address(newUsdsPriceFeed), address(origUsdsPriceFeed)); | ||
| } | ||
|
|
||
| function test_shouldWithdrawSameAfterUpgrade() public { | ||
| GenericVault vault = GenericVault(controller.vaultFor(USDC)); | ||
|
|
||
| vm.startPrank(user); | ||
| IERC20(USDC).approve(controller.vaultFor(USDC), type(uint256).max); | ||
| uint256 shares = vault.deposit(1000e6, user); | ||
| vm.stopPrank(); | ||
|
|
||
| uint256 origWithdrawnAmount = vault.previewRedeem(shares); | ||
|
|
||
| _upgradeController(); | ||
|
|
||
| vm.prank(user); | ||
| uint256 newWithdrawnAmount = vault.redeem(shares, user, user); | ||
|
|
||
| assertEq(origWithdrawnAmount, newWithdrawnAmount); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.29; | ||
|
|
||
| contract Multicall { | ||
| struct Call { | ||
| address target; | ||
| bytes callData; | ||
| } | ||
|
|
||
| function aggregate(Call[] calldata calls) public returns (bytes[] memory returnData) { | ||
| returnData = new bytes[](calls.length); | ||
| for (uint256 i; i < calls.length; ++i) { | ||
| (bool success, bytes memory data) = calls[i].target.call(calls[i].callData); | ||
| if (!success) { | ||
| assembly { | ||
| revert(add(data, 0x20), mload(data)) | ||
| } | ||
| } | ||
| returnData[i] = data; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although transient storage should not alter the storage layout, would you mind generating a before and after of
forge inspect storage --pretty?That should ensure us we are not messing it. Just to fully double check, this is a critical component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original storage:
Updated storage:
You can see that the transient properties are not even there. The new
secondaryActionFeeis at the end even though it fits after_shareaddress.