diff --git a/script/upgrade-core/PrepareUpgrade.23.12.1-alpha.Polygon.s.sol b/script/upgrade-core/PrepareUpgrade.23.12.1-alpha.s.sol similarity index 88% rename from script/upgrade-core/PrepareUpgrade.23.12.1-alpha.Polygon.s.sol rename to script/upgrade-core/PrepareUpgrade.23.12.1-alpha.s.sol index f3eb144c..a2152086 100644 --- a/script/upgrade-core/PrepareUpgrade.23.12.1-alpha.Polygon.s.sol +++ b/script/upgrade-core/PrepareUpgrade.23.12.1-alpha.s.sol @@ -3,14 +3,13 @@ pragma solidity ^0.8.23; import {console} from "forge-std/Test.sol"; import "forge-std/Script.sol"; -import "../../chains/PolygonLib.sol"; import "../../src/core/Factory.sol"; import "../../src/core/Zap.sol"; import "../../src/core/vaults/CVault.sol"; import "../../src/core/vaults/RVault.sol"; import "../../src/core/vaults/RMVault.sol"; -contract PrepareUpgrade1Polygon is Script { +contract PrepareUpgrade1 is Script { function run() external { uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); @@ -31,5 +30,5 @@ contract PrepareUpgrade1Polygon is Script { vm.stopBroadcast(); } - function testDeployPolygon() external {} + function testPrepareUpgrade() external {} } diff --git a/script/upgrade-core/PrepareUpgrade.23.12.2-alpha.Polygon.s.sol b/script/upgrade-core/PrepareUpgrade.23.12.2-alpha.s.sol similarity index 72% rename from script/upgrade-core/PrepareUpgrade.23.12.2-alpha.Polygon.s.sol rename to script/upgrade-core/PrepareUpgrade.23.12.2-alpha.s.sol index 9baab23d..6baec2d5 100644 --- a/script/upgrade-core/PrepareUpgrade.23.12.2-alpha.Polygon.s.sol +++ b/script/upgrade-core/PrepareUpgrade.23.12.2-alpha.s.sol @@ -6,9 +6,8 @@ import "../../src/adapters/AlgebraAdapter.sol"; import "../../src/adapters/UniswapV3Adapter.sol"; import "../../src/adapters/KyberAdapter.sol"; import "../../src/core/Zap.sol"; -// import "../../src/strategies/QuickswapV3StaticFarmStrategy.sol"; -contract PrepareUpgrade2Polygon is Script { +contract PrepareUpgrade2 is Script { function run() external { uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); @@ -16,9 +15,8 @@ contract PrepareUpgrade2Polygon is Script { new UniswapV3Adapter(); new KyberAdapter(); new Zap(); - // new QuickSwapV3StaticFarmStrategy(); vm.stopBroadcast(); } - function testDeployPolygon() external {} + function testPrepareUpgrade() external {} } diff --git a/script/upgrade-core/PrepareUpgrade.24.01.0-alpha.Polygon.s.sol b/script/upgrade-core/PrepareUpgrade.24.01.0-alpha.Polygon.s.sol index 5f989415..9284c114 100644 --- a/script/upgrade-core/PrepareUpgrade.24.01.0-alpha.Polygon.s.sol +++ b/script/upgrade-core/PrepareUpgrade.24.01.0-alpha.Polygon.s.sol @@ -6,7 +6,6 @@ import "../../src/core/Factory.sol"; import "../../src/core/vaults/CVault.sol"; import "../../src/core/vaults/RVault.sol"; import "../../src/core/vaults/RMVault.sol"; -// import "../../src/strategies/QuickswapV3StaticFarmStrategy.sol"; contract PrepareUpgrade3Polygon is Script { address public constant PLATFORM = 0xb2a0737ef27b5Cc474D24c779af612159b1c3e60; @@ -14,7 +13,6 @@ contract PrepareUpgrade3Polygon is Script { string internal constant COMPOUNDING = "Compounding"; string internal constant REWARDING = "Rewarding"; string internal constant REWARDING_MANAGED = "Rewarding Managed"; - // string public constant QUICKSWAPV3_STATIC_FARM = "QuickSwapV3 Static Farm"; address public constant TOKEN_USDCe = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; address public constant TOKEN_USDC = 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359; address public constant TOKEN_dQUICK = 0x958d208Cdf087843e9AD98d23823d32E17d723A1; @@ -25,58 +23,15 @@ contract PrepareUpgrade3Polygon is Script { function run() external { uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - // IFactory factory = IFactory(IPlatform(PLATFORM).factory()); - vm.startBroadcast(deployerPrivateKey); // Factory 1.0.2: setVaultStatus updated new Factory(); - // QSF 1.0.2: getRevenue fixed - // new QuickSwapV3StaticFarmStrategy(); - // factory.setStrategyLogicConfig( - // IFactory.StrategyLogicConfig({ - // id: QUICKSWAPV3_STATIC_FARM, - // implementation: impl, - // deployAllowed: true, - // upgradeAllowed: true, - // farming: true, - // tokenId: 0 - // }), - // address(0) - // ); - // Vaults 1.1.0: setName, setSymbol, gas optimization new CVault(); - // factory.setVaultConfig( - // IFactory.VaultConfig({ - // vaultType: COMPOUNDING, - // implementation: impl, - // deployAllowed: true, - // upgradeAllowed: true, - // buildingPrice: 50_000e18 - // }) - // ); new RVault(); - // factory.setVaultConfig( - // IFactory.VaultConfig({ - // vaultType: REWARDING, - // implementation: impl, - // deployAllowed: true, - // upgradeAllowed: true, - // buildingPrice: 50_000e18 - // }) - // ); new RMVault(); - // factory.setVaultConfig( - // IFactory.VaultConfig({ - // vaultType: REWARDING_MANAGED, - // implementation: impl, - // deployAllowed: false, - // upgradeAllowed: false, - // buildingPrice: 100_000e18 - // }) - // ); // route for native USDC ISwapper.AddPoolData[] memory pools = new ISwapper.AddPoolData[](1); @@ -94,36 +49,6 @@ contract PrepareUpgrade3Polygon is Script { thresholdAmount[0] = 1e3; swapper.setThresholds(tokenIn, thresholdAmount); - // new farm for QSF - // IFactory.Farm[] memory _farms = new IFactory.Farm[](1); - // address[] memory rewardAssets; - // address[] memory addresses; - // uint[] memory nums; - // int24[] memory ticks; - // [17] Earn dQUICK, WMATIC by static position in USDCe/USDC pool on QuickSwap V3 - // rewardAssets = new address[](2); - // rewardAssets[0] = TOKEN_dQUICK; - // rewardAssets[1] = TOKEN_WMATIC; - // addresses = new address[](2); - // addresses[0] = QUICKSWAP_POSITION_MANAGER; - // addresses[1] = QUICKSWAP_FARMING_CENTER; - // nums = new uint[](2); - // nums[0] = 1700454552; - // nums[1] = 4104559500; - // ticks = new int24[](2); - // ticks[0] = -60; - // ticks[1] = 60; - // _farms[0] = IFactory.Farm({ - // status: 0, - // pool: POOL_QUICKSWAPV3_USDCe_USDC, - // strategyLogicId: StrategyIdLib.QUICKSWAPV3_STATIC_FARM, - // rewardAssets: rewardAssets, - // addresses: addresses, - // nums: nums, - // ticks: ticks - // }); - // factory.addFarms(_farms); - vm.stopBroadcast(); } diff --git a/script/upgrade-core/PrepareUpgrade.24.05.0-alpha.Polygon.s.sol b/script/upgrade-core/PrepareUpgrade.24.05.0-alpha.s.sol similarity index 90% rename from script/upgrade-core/PrepareUpgrade.24.05.0-alpha.Polygon.s.sol rename to script/upgrade-core/PrepareUpgrade.24.05.0-alpha.s.sol index 6ed2d385..c204210e 100644 --- a/script/upgrade-core/PrepareUpgrade.24.05.0-alpha.Polygon.s.sol +++ b/script/upgrade-core/PrepareUpgrade.24.05.0-alpha.s.sol @@ -8,7 +8,7 @@ import "../../src/core/vaults/RVault.sol"; import "../../src/core/vaults/RMVault.sol"; import "../../src/strategies/YearnStrategy.sol"; -contract PrepareUpgrade5Polygon is Script { +contract PrepareUpgrade5 is Script { function run() external { uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); @@ -31,5 +31,5 @@ contract PrepareUpgrade5Polygon is Script { vm.stopBroadcast(); } - function testDeployPolygon() external {} + function testPrepareUpgrade() external {} } diff --git a/script/upgrade-core/PrepareUpgrade.24.06.1-alpha.Polygon.s.sol b/script/upgrade-core/PrepareUpgrade.24.06.1-alpha.s.sol similarity index 62% rename from script/upgrade-core/PrepareUpgrade.24.06.1-alpha.Polygon.s.sol rename to script/upgrade-core/PrepareUpgrade.24.06.1-alpha.s.sol index b8c86442..94451dce 100644 --- a/script/upgrade-core/PrepareUpgrade.24.06.1-alpha.Polygon.s.sol +++ b/script/upgrade-core/PrepareUpgrade.24.06.1-alpha.s.sol @@ -3,12 +3,8 @@ pragma solidity ^0.8.23; import "forge-std/Script.sol"; import "../../src/core/Factory.sol"; -import "../../src/core/vaults/CVault.sol"; -import "../../src/core/vaults/RVault.sol"; -import "../../src/core/vaults/RMVault.sol"; -import "../../src/strategies/YearnStrategy.sol"; -contract PrepareUpgrade5Polygon is Script { +contract PrepareUpgrade6 is Script { function run() external { uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); @@ -19,5 +15,5 @@ contract PrepareUpgrade5Polygon is Script { vm.stopBroadcast(); } - function testDeployPolygon() external {} + function testPrepareUpgrade() external {} } diff --git a/script/upgrade-core/PrepareUpgrade.25.01.1-alpha.s.sol b/script/upgrade-core/PrepareUpgrade.25.01.1-alpha.s.sol new file mode 100644 index 00000000..8cd23f74 --- /dev/null +++ b/script/upgrade-core/PrepareUpgrade.25.01.1-alpha.s.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.23; + +import "forge-std/Script.sol"; +import "../../src/core/Zap.sol"; + +contract PrepareUpgrade7 is Script { + function run() external { + uint deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + vm.startBroadcast(deployerPrivateKey); + + // Zap 1.0.3: bugfix for Ichi deposit + new Zap(); + + vm.stopBroadcast(); + } + + function testPrepareUpgrade() external {} +} diff --git a/src/core/Zap.sol b/src/core/Zap.sol index 0b0cb12d..66f12a93 100644 --- a/src/core/Zap.sol +++ b/src/core/Zap.sol @@ -25,7 +25,7 @@ contract Zap is Controllable, ReentrancyGuardUpgradeable, IZap { /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @inheritdoc IControllable - string public constant VERSION = "1.0.2"; + string public constant VERSION = "1.0.3"; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INITIALIZATION */ @@ -51,8 +51,6 @@ contract Zap is Controllable, ReentrancyGuardUpgradeable, IZap { uint minSharesOut, address receiver ) external nonReentrant { - // todo check vault - if (amountIn == 0) { revert IControllable.IncorrectZeroArgument(); } @@ -78,6 +76,9 @@ contract Zap is Controllable, ReentrancyGuardUpgradeable, IZap { if (tokenIn == assets[i]) { continue; } + if (swapData[i].length == 0) { + continue; + } //slither-disable-next-line low-level-calls (bool success, bytes memory result) = agg.call(swapData[i]); if (!success) { diff --git a/test/core/Zap.Upgrade.Sonic.t.sol b/test/core/Zap.Upgrade.Sonic.t.sol new file mode 100644 index 00000000..044d1743 --- /dev/null +++ b/test/core/Zap.Upgrade.Sonic.t.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.23; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {console, Test} from "forge-std/Test.sol"; +import {Zap} from "../../src/core/Zap.sol"; +import {IPlatform} from "../../src/interfaces/IPlatform.sol"; +import {IStrategy} from "../../src/interfaces/IStrategy.sol"; +import {IVault} from "../../src/interfaces/IVault.sol"; +import {IZap} from "../../src/interfaces/IZap.sol"; +import {ISwapper} from "../../src/interfaces/ISwapper.sol"; +import {SonicLib} from "../../chains/SonicLib.sol"; + +contract ZapUpgradeSonic is Test { + address public constant PLATFORM = 0x4Aca671A420eEB58ecafE83700686a2AD06b20D8; + + struct ZapTestVars { + address depositToken; + address[] assets; + IStrategy strategy; + uint depositAmount; + uint[] swapAmounts; + } + + constructor() { + vm.selectFork(vm.createFork(vm.envString("SONIC_RPC_URL"))); + vm.rollFork(3032000); // Jan-08-2025 08:39:58 PM +UTC + } + + function testZapUpgrade() public { + address multisig = IPlatform(PLATFORM).multisig(); + IZap zap = IZap(IPlatform(PLATFORM).zap()); + address swapper = IPlatform(PLATFORM).swapper(); + // C-wSSACRA-ISF + address vault = 0x3037a9ec06c25a2190794B533703755cDD137079; + + ZapTestVars memory v; + v.strategy = IVault(vault).strategy(); + v.assets = v.strategy.assets(); + v.depositToken = SonicLib.TOKEN_USDC; + v.depositAmount = 100e6; + (, v.swapAmounts) = zap.getDepositSwapAmounts(vault, v.depositToken, v.depositAmount); + //console.log(v.swapAmounts[0],v.swapAmounts[1]); + + bytes[] memory swapData = new bytes[](2); + swapData[1] = abi.encodeCall(ISwapper.swap, (v.depositToken, v.assets[1], v.swapAmounts[1], 1_000)); + deal(v.depositToken, address(this), v.depositAmount); + IERC20(v.depositToken).approve(address(zap), v.depositAmount); + vm.expectRevert(); + zap.deposit(vault, v.depositToken, v.depositAmount, swapper, swapData, 1, address(this)); + + address newZapImplementation = address(new Zap()); + address[] memory proxies = new address[](1); + proxies[0] = address(address(zap)); + address[] memory implementations = new address[](1); + implementations[0] = newZapImplementation; + vm.startPrank(multisig); + IPlatform(PLATFORM).announcePlatformUpgrade("2025.01.1-alpha", proxies, implementations); + skip(1 days); + IPlatform(PLATFORM).upgrade(); + vm.stopPrank(); + + zap.deposit(vault, v.depositToken, v.depositAmount, swapper, swapData, 1, address(this)); + } +}