From 6752fad9e9999e9f73fc7ec8ea681d050c3afac8 Mon Sep 17 00:00:00 2001 From: nledo Date: Fri, 26 Apr 2024 16:57:08 -0300 Subject: [PATCH] DAO, LTD and KPK disassemble policy update --- .../abis/mainnet/curve/steth_ng_f_pool.json | 1 + packages/sdk/eth-sdk/config.ts | 1 + packages/sdk/package.json | 2 +- .../GnosisDAO/deFiDisassembleGnosisDAO.ts | 268 ++++++++++------ .../GnosisLTD/deFiDisassembleGnosisLTD.ts | 288 +++++++++++------- .../presets/mainnet/KPK/deFiDisassembleKPK.ts | 224 ++++++++++++++ .../mainnet/Test_Presets/test_payload_kpk.ts | 67 ---- packages/sdk/src/presets/mainnet/addresses.ts | 2 + packages/sdk/tasks/manageEnsRoles.ts | 27 -- packages/sdk/tasks/manageKarpatkeyRoles.ts | 80 ++--- 10 files changed, 609 insertions(+), 351 deletions(-) create mode 100644 packages/sdk/eth-sdk/abis/mainnet/curve/steth_ng_f_pool.json create mode 100644 packages/sdk/src/presets/mainnet/KPK/deFiDisassembleKPK.ts delete mode 100644 packages/sdk/src/presets/mainnet/Test_Presets/test_payload_kpk.ts diff --git a/packages/sdk/eth-sdk/abis/mainnet/curve/steth_ng_f_pool.json b/packages/sdk/eth-sdk/abis/mainnet/curve/steth_ng_f_pool.json new file mode 100644 index 000000000..18f0c5e9d --- /dev/null +++ b/packages/sdk/eth-sdk/abis/mainnet/curve/steth_ng_f_pool.json @@ -0,0 +1 @@ +[{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"TokenExchange","inputs":[{"name":"buyer","type":"address","indexed":true},{"name":"sold_id","type":"int128","indexed":false},{"name":"tokens_sold","type":"uint256","indexed":false},{"name":"bought_id","type":"int128","indexed":false},{"name":"tokens_bought","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"AddLiquidity","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"invariant","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidity","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidityOne","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amount","type":"uint256","indexed":false},{"name":"coin_amount","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidityImbalance","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"invariant","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RampA","inputs":[{"name":"old_A","type":"uint256","indexed":false},{"name":"new_A","type":"uint256","indexed":false},{"name":"initial_time","type":"uint256","indexed":false},{"name":"future_time","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"StopRampA","inputs":[{"name":"A","type":"uint256","indexed":false},{"name":"t","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"CommitNewFee","inputs":[{"name":"new_fee","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"ApplyNewFee","inputs":[{"name":"fee","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"initialize","inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_coins","type":"address[4]"},{"name":"_rate_multipliers","type":"uint256[4]"},{"name":"_A","type":"uint256"},{"name":"_fee","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"permit","inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_deadline","type":"uint256"},{"name":"_v","type":"uint8"},{"name":"_r","type":"bytes32"},{"name":"_s","type":"bytes32"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"last_price","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"ema_price","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"stored_rates","inputs":[],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"view","type":"function","name":"balances","inputs":[{"name":"i","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"admin_fee","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"A_precise","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_p","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"price_oracle","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_virtual_price","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_token_amount","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_is_deposit","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"payable","type":"function","name":"add_liquidity","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_min_mint_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"payable","type":"function","name":"add_liquidity","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_min_mint_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dy","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dx","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"payable","type":"function","name":"exchange","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"payable","type":"function","name":"exchange","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[2]"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[2]"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_max_burn_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_max_burn_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_withdraw_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_received","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_received","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"ramp_A","inputs":[{"name":"_future_A","type":"uint256"},{"name":"_future_time","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"stop_ramp_A","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"withdraw_admin_fees","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"commit_new_fee","inputs":[{"name":"_new_fee","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"apply_new_fee","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_ma_exp_time","inputs":[{"name":"_ma_exp_time","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_oracle","inputs":[{"name":"_method_id","type":"bytes4"},{"name":"_oracle","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"version","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"coins","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"admin_balances","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"fee","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"future_fee","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"admin_action_deadline","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"initial_A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"future_A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"initial_A_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"future_A_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"oracle_method","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32"}]},{"stateMutability":"view","type":"function","name":"nonces","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"ma_exp_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"ma_last_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]}] \ No newline at end of file diff --git a/packages/sdk/eth-sdk/config.ts b/packages/sdk/eth-sdk/config.ts index 68e034541..01b977155 100644 --- a/packages/sdk/eth-sdk/config.ts +++ b/packages/sdk/eth-sdk/config.ts @@ -113,6 +113,7 @@ export default defineConfig({ x3CRV_pool: "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7", cvxETH_pool: "0xB576491F1E6e5E62f1d8F26062Ee822B40B0E0d4", ankrETH_pool: "0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2", + steth_ng_f_pool: "0x21E27a5E5513D6e65C4f830167390997aA84843a", }, idle: { stEthCdo: "0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index c822fe592..9ab0dd114 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -47,7 +47,7 @@ "apply:ens:eth:harvest": "hardhat encodeApplyPresetHarvestENS --network mainnet --safe ENS_ETH", "apply:ens:eth:swap": "hardhat encodeApplyPresetSwapENS --network mainnet --safe ENS_ETH", "apply:ens:eth:spark": "hardhat encodeApplyPresetsSpark --network mainnet --safe ENS_ETH", - "apply:ens:eth:kpk": "hardhat encodeApplyPresetsTestKPK --network mainnet --safe ENS_ETH", + "apply:kpk:eth:disassemble": "hardhat encodeApplyPresetsDisassembleKPKmainnet --network mainnet --safe KPK_ETH", "apply:ens:eth:univ3": "hardhat encodeApplyPresetsTestUniV3 --network mainnet --safe ENS_ETH", "apply:ens:eth:maker": "hardhat encodeApplyPresetsTestMaker --network mainnet --safe ENS_ETH", "apply:ens:eth:rocket": "hardhat encodeApplyPresetsTestRocket --network mainnet --safe ENS_ETH", diff --git a/packages/sdk/src/presets/mainnet/GnosisDAO/deFiDisassembleGnosisDAO.ts b/packages/sdk/src/presets/mainnet/GnosisDAO/deFiDisassembleGnosisDAO.ts index 3cef9dfdb..34ee47b38 100644 --- a/packages/sdk/src/presets/mainnet/GnosisDAO/deFiDisassembleGnosisDAO.ts +++ b/packages/sdk/src/presets/mainnet/GnosisDAO/deFiDisassembleGnosisDAO.ts @@ -3,10 +3,11 @@ import { auraExitStrategy2 } from "../../helpers/ExitStrategies/AuraExitStrategi import { balancerExitStrategy1 } from "../../helpers/ExitStrategies/BalancerExitStrategies" import { HoldingsExitStrategy } from "../../helpers/ExitStrategies/HoldingsExitStrategies" import { lidoExitStrategyAll } from "../../helpers/ExitStrategies/LidoExitStrategies" -import { staticEqual } from "../../helpers/utils" +import { staticEqual, staticOneOf } from "../../helpers/utils" import { AVATAR } from "../../placeholders" -import { USDC, aura, balancer, compound_v2, compound_v3 } from "../addresses" +import { DAI, USDC, USDT, rETH, stETH, WETH, wstETH, aura, balancer, compound_v2, compound_v3, curve, uniswapv3 } from "../addresses" import { RolePreset } from "../../types" +import { allowErc20Approve } from "../../helpers/erc20" const preset = { network: 1, @@ -23,15 +24,6 @@ const preset = { ...HoldingsExitStrategy(1), // 1 = mainnet - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aura wstETH/WETH + Balancer wstETH/WETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // ...auraExitStrategy2( - // aura.auraB_stETH_STABLE_REWARDER, - // balancer.B_stETH_STABLE_pId - // ), - //--------------------------------------------------------------------------------------------------------------------------------- // Aura B-80BAL-20WETH/auraBAL + Balancer B-80BAL-20WETH/auraBAL + Balancer B-80BAL-20WETH //--------------------------------------------------------------------------------------------------------------------------------- @@ -53,15 +45,6 @@ const preset = { balancer.B_rETH_STABLE_pId ), - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aura GNO/WETH + Balancer GNO/WETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // ...auraExitStrategy2( - // aura.auraB_80GNO_20WETH_REWARDER, - // balancer.B_80GNO_20WETH_pId - // ), - //--------------------------------------------------------------------------------------------------------------------------------- // Aura GNO/COW + Balancer GNO/COW //--------------------------------------------------------------------------------------------------------------------------------- @@ -71,24 +54,6 @@ const preset = { balancer.B_50COW_50GNO_pId ), - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aura LDO/wstETH + Balancer LDO/wstETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // ...auraExitStrategy2( - // aura.aura50WSTETH_50LDO_REWARDER, - // balancer.B_50WSTETH_50LDO_pId - // ), - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aura WETH/AURA + Balancer WETH/AURA - // //--------------------------------------------------------------------------------------------------------------------------------- - - // ...auraExitStrategy2( - // aura.aura50WETH_50AURA_REWARDER, - // balancer.B_50WETH_50AURA_pId - // ), - //--------------------------------------------------------------------------------------------------------------------------------- // Aura WETH/COW + Balancer WETH/COW //--------------------------------------------------------------------------------------------------------------------------------- @@ -98,24 +63,6 @@ const preset = { balancer.B_50COW_50WETH_pId ), - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aura GHO/3pool + Balancer GHO/3pool + Balancer 3pool - // //--------------------------------------------------------------------------------------------------------------------------------- - - // ...auraExitStrategy2(aura.auraGHO_3POOL_REWARDER, balancer.B_GHO_3POOL_pId), - - // // Remove Liquidity from 3pool - // { - // targetAddress: balancer.VAULT, - // signature: - // "exitPool(bytes32,address,address,(address[],uint256[],bytes,bool))", - // params: { - // [0]: staticEqual(balancer.B_USDC_DAI_USDT_pId, "bytes32"), // Balancer PoolId - // [1]: staticEqual(AVATAR), - // [2]: staticEqual(AVATAR), - // }, - // }, - //--------------------------------------------------------------------------------------------------------------------------------- // Classic auraBAL //--------------------------------------------------------------------------------------------------------------------------------- @@ -153,6 +100,132 @@ const preset = { // Unlock allow.mainnet.balancer.veBAL["withdraw"](), + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer rETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap rETH for WETH + ...allowErc20Approve([rETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(rETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for rETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(rETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer wstETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap wstETH for WETH + ...allowErc20Approve([wstETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(wstETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for wstETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(wstETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + //--------------------------------------------------------------------------------------------------------------------------------- // CONVEX //--------------------------------------------------------------------------------------------------------------------------------- @@ -254,6 +327,27 @@ const preset = { // Unstake allow.mainnet.curve.cDAIcUSDC_gauge["withdraw"](), + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - 3pool - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT], [curve.x3CRV_POOL]), + + allow.mainnet.curve.x3CRV_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH (steCRV) - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ETH_POOL]), + + allow.mainnet.curve.steth_eth_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH (stETH-ng-f) - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ng_f_POOL]), + + allow.mainnet.curve.steth_ng_f_pool["exchange(int128,int128,uint256,uint256)"](), + //--------------------------------------------------------------------------------------------------------------------------------- // Compound V2 //--------------------------------------------------------------------------------------------------------------------------------- @@ -343,44 +437,30 @@ const preset = { }, }, - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Spark - // //--------------------------------------------------------------------------------------------------------------------------------- - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Spark - wstETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // // Withdraw - // allow.mainnet.spark.sparkLendingPoolV3["withdraw"]( - // wstETH, - // undefined, - // AVATAR - // ), - - // // Repay - DAI - // ...allowErc20Approve([DAI], [spark.LENDING_POOL_V3]), - // allow.mainnet.spark.sparkLendingPoolV3["repay"]( - // DAI, - // undefined, - // undefined, - // AVATAR - // ), - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aave V3 - // //--------------------------------------------------------------------------------------------------------------------------------- - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Aave V3 - wstETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // // Withdraw - // allow.mainnet.aave_v3.pool_v3["withdraw"](wstETH, undefined, AVATAR), - - // // Repay - WBTC - // ...allowErc20Approve([WBTC], [aave_v3.POOL_V3]), - // allow.mainnet.aave_v3.pool_v3["repay"](WBTC, undefined, undefined, AVATAR), + //--------------------------------------------------------------------------------------------------------------------------------- + // Uniswap V3 - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT, WETH, wstETH], [uniswapv3.ROUTER_2]), + + { + targetAddress: uniswapv3.ROUTER_2, + signature: + "exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))", + params: { + [0]: staticOneOf( + [ + DAI, + USDC, + USDT, + WETH, + wstETH + ], + "address" + ), + [1]: staticOneOf([DAI, USDC, USDT, WETH, wstETH], "address"), + [3]: staticEqual(AVATAR), + }, + }, ], placeholders: { AVATAR }, } satisfies RolePreset diff --git a/packages/sdk/src/presets/mainnet/GnosisLTD/deFiDisassembleGnosisLTD.ts b/packages/sdk/src/presets/mainnet/GnosisLTD/deFiDisassembleGnosisLTD.ts index eaf4b2f1e..8af0f6e50 100644 --- a/packages/sdk/src/presets/mainnet/GnosisLTD/deFiDisassembleGnosisLTD.ts +++ b/packages/sdk/src/presets/mainnet/GnosisLTD/deFiDisassembleGnosisLTD.ts @@ -3,8 +3,10 @@ import { auraExitStrategy2 } from "../../helpers/ExitStrategies/AuraExitStrategi import { HoldingsExitStrategy } from "../../helpers/ExitStrategies/HoldingsExitStrategies" import { lidoExitStrategyAll } from "../../helpers/ExitStrategies/LidoExitStrategies" import { AVATAR } from "../../placeholders" -import { USDC, aura, balancer } from "../addresses" +import { DAI, USDC, USDT, rETH, stETH, WETH, wstETH, aura, balancer, curve, uniswapv3 } from "../addresses" import { RolePreset } from "../../types" +import { allowErc20Approve } from "../../helpers/erc20" +import { staticEqual, staticOneOf } from "../../helpers/utils" const preset = { network: 1, @@ -48,79 +50,131 @@ const preset = { // BALANCER //--------------------------------------------------------------------------------------------------------------------------------- - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Compound V2 - // //--------------------------------------------------------------------------------------------------------------------------------- - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Compound V2 - USDC - // //--------------------------------------------------------------------------------------------------------------------------------- - - // // Withdrawing: sender redeems uint256 cTokens, it is called when MAX is withdrawn - // // { - // // targetAddress: cUSDC, - // // signature: "redeem(uint256)", - // // }, - // allow.mainnet.compound_v2.cUSDC["redeem"](), - - // // Withdrawing: sender redeems cTokens in exchange for a specified amount of underlying asset (uint256), it is called when MAX isn't withdrawn - // // { - // // targetAddress: cUSDC, - // // signature: "redeemUnderlying(uint256)", - // // }, - // allow.mainnet.compound_v2.cUSDC["redeemUnderlying"](), - - // // Stop using as Collateral - // // { - // // targetAddress: COMPTROLLER, - // // signature: "exitMarket(address)", - // // params: { - // // [0]: staticEqual(cUSDC, "address"), - // // }, - // // }, - // allow.mainnet.compound_v2.comptroller["exitMarket"](compound_v2.cUSDC), - - // // Repay specified borrowed amount of underlying asset (uint256) - // // { - // // targetAddress: cUSDC, - // // signature: "repayBorrow(uint256)", - // // }, - // allow.mainnet.compound_v2.cUSDC["repayBorrow"](), - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Compound V2 - DAI - // //--------------------------------------------------------------------------------------------------------------------------------- - - // // Withdrawing: sender redeems uint256 cTokens, it is called when MAX is withdrawn - // // { - // // targetAddress: cDAI, - // // signature: "redeem(uint256)", - // // }, - // allow.mainnet.compound_v2.cDAI["redeem"](), - - // // Withdrawing: sender redeems cTokens in exchange for a specified amount of underlying asset (uint256), it is called when MAX isn't withdrawn - // // { - // // targetAddress: cDAI, - // // signature: "redeemUnderlying(uint256)", - // // }, - // allow.mainnet.compound_v2.cDAI["redeemUnderlying"](), - - // // Stop using as Collateral - // // { - // // targetAddress: COMPTROLLER, - // // signature: "exitMarket(address)", - // // params: { - // // [0]: staticEqual(cDAI, "address"), - // // }, - // // }, - // allow.mainnet.compound_v2.comptroller["exitMarket"](compound_v2.cDAI), - - // // Repay specified borrowed amount of underlying asset (uint256) - // // { - // // targetAddress: cDAI, - // // signature: "repayBorrow(uint256)", - // // }, - // allow.mainnet.compound_v2.cDAI["repayBorrow"](), + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer rETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap rETH for WETH + ...allowErc20Approve([rETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(rETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for rETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(rETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer wstETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap wstETH for WETH + ...allowErc20Approve([wstETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(wstETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for wstETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(wstETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, //--------------------------------------------------------------------------------------------------------------------------------- // Compound V3 @@ -133,47 +187,51 @@ const preset = { // Withdraw/Borrow allow.mainnet.compound_v3.cUSDCv3["withdraw"](USDC), - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Compound V3 - ETH - // //--------------------------------------------------------------------------------------------------------------------------------- - - // // Withdraw - // { - // targetAddress: compound_v3.MainnetBulker, - // signature: "invoke(bytes32[],bytes[])", - // params: { - // [0]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000040", - // "bytes32" - // ), // Offset of bytes32[] from beginning 64=32*2 - // [1]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000080", - // "bytes32" - // ), // Offset of bytes[] from beginning 128=32*4 - // [2]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000001", - // "bytes32" - // ), // Length of bytes32[] = 1 - // [3]: staticEqual( - // "0x414354494f4e5f57495448445241575f4e41544956455f544f4b454e00000000", - // "bytes32" - // ), // ACTION_WITHDRAW_NATIVE_TOKEN Encoded - // [4]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000001", - // "bytes32" - // ), // Length of bytes[] = 1 - // [5]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000020", - // "bytes32" - // ), // Offset of the first element of the bytes[] from beginning of bytes[] 32=32*1 - // [6]: staticEqual( - // "0x0000000000000000000000000000000000000000000000000000000000000060", - // "bytes32" - // ), // Length of the first element of the bytes[] 96=32*3 - // [7]: staticEqual(compound_v3.cUSDCv3, "address"), - // [8]: staticEqual(AVATAR), - // }, - // }, + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - 3pool - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT], [curve.x3CRV_POOL]), + + allow.mainnet.curve.x3CRV_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ETH_POOL]), + + allow.mainnet.curve.steth_eth_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH (stETH-ng-f) - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ng_f_POOL]), + + allow.mainnet.curve.steth_ng_f_pool["exchange(int128,int128,uint256,uint256)"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Uniswap V3 - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT, WETH, wstETH], [uniswapv3.ROUTER_2]), + + { + targetAddress: uniswapv3.ROUTER_2, + signature: + "exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))", + params: { + [0]: staticOneOf( + [ + DAI, + USDC, + USDT, + WETH, + wstETH + ], + "address" + ), + [1]: staticOneOf([DAI, USDC, USDT, WETH, wstETH], "address"), + [3]: staticEqual(AVATAR), + }, + }, ], placeholders: { AVATAR }, } satisfies RolePreset diff --git a/packages/sdk/src/presets/mainnet/KPK/deFiDisassembleKPK.ts b/packages/sdk/src/presets/mainnet/KPK/deFiDisassembleKPK.ts new file mode 100644 index 000000000..14cf960db --- /dev/null +++ b/packages/sdk/src/presets/mainnet/KPK/deFiDisassembleKPK.ts @@ -0,0 +1,224 @@ +import { + DAI, + USDC, + USDT, + rETH, + stETH, + WETH, + wstETH, + E_ADDRESS, + aura, + balancer, + cowswap, + curve, + uniswapv3 +} from "../addresses" +import { staticEqual, staticOneOf } from "../../helpers/utils" +import { allowErc20Approve } from "../../helpers/erc20" +import { lidoExitStrategyAll } from "../../helpers/ExitStrategies/LidoExitStrategies" +import { auraExitStrategy2 } from "../../helpers/ExitStrategies/AuraExitStrategies" +import { AVATAR } from "../../placeholders" +import { RolePreset } from "../../types" +import { allow } from "../../allow" + +const preset = { + network: 1, + allow: [ + //--------------------------------------------------------------------------------------------------------------------------------- + // Lido + //--------------------------------------------------------------------------------------------------------------------------------- + ...lidoExitStrategyAll(), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Aura wstETH/WETH + Balancer wstETH/WETH + //--------------------------------------------------------------------------------------------------------------------------------- + + ...auraExitStrategy2( + aura.auraB_stETH_STABLE_REWARDER, + balancer.B_stETH_STABLE_pId + ), + + // allow.mainnet.lido.stETH["submit"](ZERO_ADDRESS, { + // send: true, + // }), + + //--------------------------------------------------------------------------------------------------------------------------------- + // BALANCER + //--------------------------------------------------------------------------------------------------------------------------------- + + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer rETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap rETH for WETH + ...allowErc20Approve([rETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(rETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for rETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "bytes32" + ), // rETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(rETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + //--------------------------------------------------------------------------------------------------------------------------------- + // Balancer wstETH/WETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + // Swap wstETH for WETH + ...allowErc20Approve([wstETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(wstETH, "address"), // Asset in + [10]: staticEqual(WETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + // Swap WETH for wstETH + ...allowErc20Approve([WETH], [balancer.VAULT]), + { + targetAddress: balancer.VAULT, + signature: + "swap((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + params: { + [0]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000e0", + "bytes32" + ), // Offset of the tuple from beginning 224=32*7 + [1]: staticEqual(AVATAR), // recipient + [3]: staticEqual(AVATAR), // sender + [7]: staticEqual( + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + "bytes32" + ), // wstETH-WETH pool ID + [9]: staticEqual(WETH, "address"), // Asset in + [10]: staticEqual(wstETH, "address"), // Asset out + [12]: staticEqual( + "0x00000000000000000000000000000000000000000000000000000000000000c0", + "bytes32" + ), // Offset of bytes from beginning of tuple 192=32*6 + [13]: staticEqual( + "0x0000000000000000000000000000000000000000000000000000000000000000", + "bytes32" + ), // bytes (userData) = for all current Balancer pools this can be left empty + }, + }, + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - 3pool - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT], [curve.x3CRV_POOL]), + + allow.mainnet.curve.x3CRV_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ETH_POOL]), + + allow.mainnet.curve.steth_eth_pool["exchange"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Curve - ETH/stETH (stETH-ng-f) - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([stETH], [curve.stETH_ng_f_POOL]), + + allow.mainnet.curve.steth_ng_f_pool["exchange(int128,int128,uint256,uint256)"](), + + //--------------------------------------------------------------------------------------------------------------------------------- + // Uniswap V3 - Swaps + //--------------------------------------------------------------------------------------------------------------------------------- + ...allowErc20Approve([DAI, USDC, USDT, WETH, wstETH], [uniswapv3.ROUTER_2]), + + { + targetAddress: uniswapv3.ROUTER_2, + signature: + "exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))", + params: { + [0]: staticOneOf( + [ + DAI, + USDC, + USDT, + WETH, + wstETH + ], + "address" + ), + [1]: staticOneOf([DAI, USDC, USDT, WETH, wstETH], "address"), + [3]: staticEqual(AVATAR), + }, + }, + ], + placeholders: { AVATAR }, +} satisfies RolePreset + +export default preset diff --git a/packages/sdk/src/presets/mainnet/Test_Presets/test_payload_kpk.ts b/packages/sdk/src/presets/mainnet/Test_Presets/test_payload_kpk.ts deleted file mode 100644 index 5a7060eae..000000000 --- a/packages/sdk/src/presets/mainnet/Test_Presets/test_payload_kpk.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { - stETH, - ZERO_ADDRESS, - aura, - balancer, - cowswap, - E_ADDRESS -} from "../addresses" -import { staticEqual, staticOneOf } from "../../helpers/utils" -import { allowErc20Approve } from "../../helpers/erc20" -import { lidoExitStrategy1 } from "../../helpers/ExitStrategies/LidoExitStrategies" -import { auraExitStrategy2 } from "../../helpers/ExitStrategies/AuraExitStrategies" -import { AVATAR } from "../../placeholders" -import { RolePreset } from "../../types" -import { allow } from "../../allow" - -const preset = { - network: 1, - allow: [ - //--------------------------------------------------------------------------------------------------------------------------------- - // Lido - //--------------------------------------------------------------------------------------------------------------------------------- - ...lidoExitStrategy1(), - - //--------------------------------------------------------------------------------------------------------------------------------- - // Aura wstETH/WETH + Balancer wstETH/WETH - //--------------------------------------------------------------------------------------------------------------------------------- - - ...auraExitStrategy2( - aura.auraB_stETH_STABLE_REWARDER, - balancer.B_stETH_STABLE_pId - ), - - // allow.mainnet.lido.stETH["submit"](ZERO_ADDRESS, { - // send: true, - // }), - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // BALANCER - // //--------------------------------------------------------------------------------------------------------------------------------- - - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Balancer - wstETH/WETH pool - // //--------------------------------------------------------------------------------------------------------------------------------- - // // Unstake - // allow.mainnet.balancer.B_stETH_stable_gauge["withdraw(uint256)"](), - - //--------------------------------------------------------------------------------------------------------------------------------- - // Cowswap - //--------------------------------------------------------------------------------------------------------------------------------- - - { - targetAddress: cowswap.ORDER_SIGNER, - signature: - "signOrder((address,address,address,uint256,uint256,uint32,bytes32,uint256,bytes32,bool,bytes32,bytes32),uint32,uint256)", - params: { - // [0]: staticEqual(stETH, "address"), - // [1]: staticEqual(E_ADDRESS, "address"), - [2]: staticEqual(AVATAR), - }, - delegatecall: true, - }, - ], - placeholders: { AVATAR }, -} satisfies RolePreset - -export default preset diff --git a/packages/sdk/src/presets/mainnet/addresses.ts b/packages/sdk/src/presets/mainnet/addresses.ts index 04277675f..e10967a83 100644 --- a/packages/sdk/src/presets/mainnet/addresses.ts +++ b/packages/sdk/src/presets/mainnet/addresses.ts @@ -228,6 +228,8 @@ export const curve = { cxvETH_POOL: "0xb576491f1e6e5e62f1d8f26062ee822b40b0e0d4", ankrETH_POOL: "0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2", + + stETH_ng_f_POOL: "0x21E27a5E5513D6e65C4f830167390997aA84843a" } export const lido = { diff --git a/packages/sdk/tasks/manageEnsRoles.ts b/packages/sdk/tasks/manageEnsRoles.ts index f69141398..ffa16de14 100644 --- a/packages/sdk/tasks/manageEnsRoles.ts +++ b/packages/sdk/tasks/manageEnsRoles.ts @@ -13,7 +13,6 @@ import mainnetDeFiHarvestENSPreset from "../src/presets/mainnet/ENS/deFiHarvestE import mainnetDeFiManageENSPreset from "../src/presets/mainnet/ENS/deFiManageENS" import mainnetDeFiSwapENSPreset from "../src/presets/mainnet/ENS/deFiSwapENS" // import sparkRepayDebtDAI from "../src/presets/mainnet/Test_Presets/sparkRepayDebtDAI" -import test_payload_kpk from "../src/presets/mainnet/Test_Presets/test_payload_kpk" import test_payload_univ3 from "../src/presets/mainnet/Test_Presets/test_uniswapv3" // import test_payload_maker from "../src/presets/mainnet/Test_Presets/test_payload_maker" import test_safe_preset from "../src/presets/mainnet/Test_Presets/TestSafePreset" @@ -270,32 +269,6 @@ task("encodeApplyPresetsTestSafe").setAction(async (taskArgs, hre) => { console.log(`Transaction builder JSON written to ${filePath}`) }) -task("encodeApplyPresetsTestKPK").setAction(async (taskArgs, hre) => { - const { config } = await processArgs(taskArgs, hre) - const txBatches = await encodeApplyPresetTxBuilder( - config.MODULE, - config.ROLE_IDS.MANAGER, - test_payload_kpk, - { AVATAR: config.AVATAR }, - { - network: config.NETWORK as NetworkId, - } - ) - - const filePath = path.join( - __dirname, - "..", - "/presets-output/mainnet/ENS/test_payload_kpk.json" - ) - if (!existsSync(filePath)) { - // Create the directory structure if it doesn't exist - mkdirSync(path.dirname(filePath), { recursive: true }) - } - // Write the JSON data to the file - writeFileSync(filePath, JSON.stringify(txBatches, undefined, 2)) - console.log(`Transaction builder JSON written to ${filePath}`) -}) - task("encodeApplyPresetsTestUniV3").setAction(async (taskArgs, hre) => { const { config } = await processArgs(taskArgs, hre) const txBatches = await encodeApplyPresetTxBuilder( diff --git a/packages/sdk/tasks/manageKarpatkeyRoles.ts b/packages/sdk/tasks/manageKarpatkeyRoles.ts index fed1cfef4..e431f0380 100644 --- a/packages/sdk/tasks/manageKarpatkeyRoles.ts +++ b/packages/sdk/tasks/manageKarpatkeyRoles.ts @@ -1,6 +1,6 @@ import "@nomiclabs/hardhat-ethers" -import { writeFileSync } from "fs" +import { writeFileSync, existsSync, mkdirSync } from "fs" import path from "path" import { task as baseTask, types } from "hardhat/config" @@ -11,6 +11,7 @@ import addMembers from "../src/addMembers" import { encodeApplyPresetTxBuilder } from "../src/applyPreset" // import gnosisChainDeFiHarvestPreset from "../src/presets/gnosisChain/deFiHarvest" // import gnosisChainDeFiManagePreset from "../src/presets/gnosisChain/deFiManage" +import mainnetDeFiDisassembleKPKPreset from "../src/presets/mainnet/KPK/deFiDisassembleKPK" import gnosisChainDeFiManagePreset from "../src/presets/gnosisChain/deFiManageTest" import mainnetDeFiManageTestPreset from "../src/presets/mainnet/deFiManageTest" import { NetworkId } from "../src/types" @@ -34,11 +35,11 @@ interface Config { } } -export const KARPATKEY_ADDRESSES = { +export const KPK_ADDRESSES = { KPK_ETH: { AVATAR: "0x58e6c7ab55Aa9012eAccA16d1ED4c15795669E1C", - MODULE: "", - MANAGER: "", + MODULE: "0x8C33ee6E439C874713a9912f3D3debfF1Efb90Da", + MANAGER: "0x8072470f155c69c0706dd6016d6720d7eb0438fb", // Used as DISASSEMBLER REVOKER: "", HARVESTER: "", DISASSEMBLER: "", @@ -111,16 +112,16 @@ const task = (name: string) => const processArgs = async (taskArgs: any, hre: HardhatRuntimeEnvironment) => { const { dryRun, safe } = taskArgs - if (!(safe in KARPATKEY_ADDRESSES)) { + if (!(safe in KPK_ADDRESSES)) { throw new Error(`safe param value '${safe}' not supported`) } - const safeKey = safe as keyof typeof KARPATKEY_ADDRESSES - if (hre.network.config.chainId !== KARPATKEY_ADDRESSES[safeKey].NETWORK) { + const safeKey = safe as keyof typeof KPK_ADDRESSES + if (hre.network.config.chainId !== KPK_ADDRESSES[safeKey].NETWORK) { throw new Error(`using wrong network!`) } const roles = await getContract(safe, hre) - return { dryRun, safe, roles, config: KARPATKEY_ADDRESSES[safeKey] } + return { dryRun, safe, roles, config: KPK_ADDRESSES[safeKey] } } const getContract = async (safe: string, hre: HardhatRuntimeEnvironment) => { @@ -236,43 +237,28 @@ task("encodeApplyPresetManageTestGNO").setAction(async (taskArgs, hre) => { ) }) -// task("encodeApplyPresetManage").setAction(async (taskArgs, hre) => { -// const { config } = await processArgs(taskArgs, hre) -// const txBatches = await encodeApplyPresetTxBuilder( -// config.MODULE, -// 1, -// gnosisChainDeFiManagePreset, // TODO use mainnetDeFiManagePreset if on mainnet -// { -// BRIDGE_RECIPIENT_MAINNET: config.BRIDGED_SAFE, -// AVATAR: config.AVATAR, -// }, -// { -// network: config.NETWORK as NetworkId, -// } -// ) - -// writeFileSync( -// path.join(__dirname, "..", "txData.json"), -// JSON.stringify(txBatches, undefined, 2) -// ) -// console.log(`Transaction builder JSON written to packages/sdk/txData.json`) -// }) - -// task("encodeApplyPresetHarvest").setAction(async (taskArgs, hre) => { -// const { config } = await processArgs(taskArgs, hre) -// const txBatches = await encodeApplyPresetTxBuilder( -// config.MODULE, -// 2, -// gnosisChainDeFiHarvestPreset, // TODO use mainnetDeFiHarvestPreset if on mainnet -// { AVATAR: config.AVATAR }, -// { -// network: config.NETWORK as NetworkId, -// } -// ) +task("encodeApplyPresetsDisassembleKPKmainnet").setAction(async (taskArgs, hre) => { + const { config } = await processArgs(taskArgs, hre) + const txBatches = await encodeApplyPresetTxBuilder( + config.MODULE, + config.ROLE_IDS.MANAGER, + mainnetDeFiDisassembleKPKPreset, + { AVATAR: config.AVATAR }, + { + network: config.NETWORK as NetworkId, + } + ) -// writeFileSync( -// path.join(__dirname, "..", "txData.json"), -// JSON.stringify(txBatches, undefined, 2) -// ) -// console.log(`Transaction builder JSON written to packages/sdk/txData.json`) -// }) + const filePath = path.join( + __dirname, + "..", + "/presets-output/mainnet/KPK/txDataDisassembleKPKmainnet.json" + ) + if (!existsSync(filePath)) { + // Create the directory structure if it doesn't exist + mkdirSync(path.dirname(filePath), { recursive: true }) + } + // Write the JSON data to the file + writeFileSync(filePath, JSON.stringify(txBatches, undefined, 2)) + console.log(`Transaction builder JSON written to ${filePath}`) +})