@dhedge/v2-sdk 1.10.16 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,6 @@ import {
19
19
  } from "../../config";
20
20
  import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
21
21
  import IVeldodromePositionManager from "../../abi/IVelodromeNonfungiblePositionManager.json";
22
- import IShadowNonfungiblePositionManager from "../../abi/IShadowNonfungiblePositionManager.json";
23
22
  import IRamsesPositionManager from "../../abi/IRamsesNonfungiblePositionManager.json";
24
23
  import IArrakisV1RouterStaking from "../../abi/IArrakisV1RouterStaking.json";
25
24
  import IPancakeMasterChef from "../../abi/IPancakeMasterChefV3.json";
@@ -78,8 +77,8 @@ export async function getUniswapV3MintTxData(
78
77
  | Dapp.VELODROMECL
79
78
  | Dapp.AERODROMECL
80
79
  | Dapp.RAMSESCL
81
- | Dapp.PANCAKECL
82
- | Dapp.SHADOWCL,
80
+ | Dapp.PANCAKECL,
81
+
83
82
  pool: Pool,
84
83
  assetA: string,
85
84
  assetB: string,
@@ -170,12 +169,6 @@ export async function getUniswapV3MintTxData(
170
169
  mintParams.push(0);
171
170
  }
172
171
 
173
- if (dapp === Dapp.SHADOWCL) {
174
- iNonfungiblePositionManager = new ethers.utils.Interface(
175
- IShadowNonfungiblePositionManager
176
- );
177
- }
178
-
179
172
  return iNonfungiblePositionManager.encodeFunctionData(Transaction.MINT, [
180
173
  mintParams
181
174
  ]);
@@ -196,9 +189,7 @@ export async function getUniswapV3Liquidity(
196
189
  const iNonfungiblePositionManager = new ethers.Contract(
197
190
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
198
191
  nonfungiblePositionManagerAddress[pool.network][dapp]!,
199
- dapp === Dapp.SHADOWCL
200
- ? IShadowNonfungiblePositionManager
201
- : INonfungiblePositionManager.abi,
192
+ INonfungiblePositionManager.abi,
202
193
  pool.signer
203
194
  );
204
195
  const result = await iNonfungiblePositionManager.positions(tokenId);
@@ -218,8 +209,7 @@ export async function getIncreaseLiquidityTxData(
218
209
  dapp === Dapp.VELODROMECL ||
219
210
  dapp === Dapp.AERODROMECL ||
220
211
  dapp === Dapp.RAMSESCL ||
221
- dapp === Dapp.PANCAKECL ||
222
- dapp === Dapp.SHADOWCL
212
+ dapp === Dapp.PANCAKECL
223
213
  ) {
224
214
  const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
225
215
  txData = abi.encodeFunctionData(Transaction.INCREASE_LIQUIDITY, [
@@ -256,8 +246,7 @@ export async function getDecreaseLiquidityTxData(
256
246
  dapp === Dapp.VELODROMECL ||
257
247
  dapp === Dapp.AERODROMECL ||
258
248
  dapp === Dapp.RAMSESCL ||
259
- dapp === Dapp.PANCAKECL ||
260
- dapp === Dapp.SHADOWCL
249
+ dapp === Dapp.PANCAKECL
261
250
  ) {
262
251
  const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
263
252
  const liquidity = (await getUniswapV3Liquidity(dapp, tokenId, pool))
@@ -43,7 +43,7 @@ export const TEST_POOL = {
43
43
  [Network.OPTIMISM]: "0x12573bfdf764ab9d52aca20e2827497a66829716",
44
44
  [Network.ARBITRUM]: "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14",
45
45
  [Network.BASE]: "0x4842b42F68524383F609aa46eAfc18c1459cE3cD",
46
- [Network.SONIC]: ""
46
+ [Network.ETHEREUM]: "0xe8e74f664d2d6a919a18b911990db0979789b6f7"
47
47
  };
48
48
 
49
49
  export const CONTRACT_ADDRESS = {
@@ -63,6 +63,7 @@ export const CONTRACT_ADDRESS = {
63
63
  VELODROME_CL_USDC_WETH_GAUGE: "",
64
64
  VELO: "",
65
65
  COMPOUNDV3_WETH: "",
66
+ FLUID_WETH: "",
66
67
  TOROS: "",
67
68
  UNIT: ""
68
69
  },
@@ -87,6 +88,7 @@ export const CONTRACT_ADDRESS = {
87
88
  VELODROME_CL_USDC_WETH_GAUGE: "0xa75127121d28a9BF848F3B70e7Eea26570aa7700",
88
89
  VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",
89
90
  COMPOUNDV3_WETH: "",
91
+ FLUID_WETH: "",
90
92
  TOROS: "0x49bf093277bf4dde49c48c6aa55a3bda3eedef68" //USDmny
91
93
  },
92
94
  [Network.ARBITRUM]: {
@@ -113,6 +115,7 @@ export const CONTRACT_ADDRESS = {
113
115
  VELODROME_CL_USDC_WETH_GAUGE: "",
114
116
  VELO: "",
115
117
  COMPOUNDV3_WETH: "0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486",
118
+ FLUID_WETH: "0x45df0656f8adf017590009d2f1898eeca4f0a205",
116
119
  TOROS: ""
117
120
  },
118
121
  [Network.BASE]: {
@@ -133,13 +136,14 @@ export const CONTRACT_ADDRESS = {
133
136
  VELODROME_CL_USDC_WETH_GAUGE: "0xF33a96b5932D9E9B9A0eDA447AbD8C9d48d2e0c8",
134
137
  VELO: "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
135
138
  COMPOUNDV3_WETH: "",
139
+ FLUID_WETH: "",
136
140
  TOROS: ""
137
141
  },
138
- [Network.SONIC]: {
139
- USDC: "0x29219dd400f2bf60e5a23d13be72b486d4038894",
142
+ [Network.ETHEREUM]: {
143
+ USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
140
144
  USDT: "",
141
145
  SUSD: "",
142
- WETH: "0x50c42deacd8fc9773493ed674b675be577f2634b",
146
+ WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
143
147
  WBTC: "",
144
148
  SWETH: "",
145
149
  uniswapV3: {
@@ -152,6 +156,7 @@ export const CONTRACT_ADDRESS = {
152
156
  VELODROME_CL_USDC_WETH_GAUGE: "",
153
157
  VELO: "",
154
158
  COMPOUNDV3_WETH: "",
159
+ FLUID_WETH: "",
155
160
  TOROS: "",
156
161
  UNIT: ""
157
162
  }
@@ -164,7 +169,7 @@ export const USDC_BALANCEOF_SLOT = {
164
169
  [Network.ARBITRUM]: 9,
165
170
  [Network.POLYGON]: 0,
166
171
  [Network.BASE]: 9,
167
- [Network.SONIC]: 9
172
+ [Network.ETHEREUM]: 9
168
173
  };
169
174
 
170
175
  export const WETH_BALANCEOF_SLOT = {
@@ -172,5 +177,5 @@ export const WETH_BALANCEOF_SLOT = {
172
177
  [Network.ARBITRUM]: 51,
173
178
  [Network.POLYGON]: 0,
174
179
  [Network.BASE]: 0,
175
- [Network.SONIC]: 0
180
+ [Network.ETHEREUM]: 3
176
181
  };
@@ -0,0 +1,90 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import BigNumber from "bignumber.js";
4
+ import { Dhedge, Pool } from "..";
5
+ import { AssetEnabled, Network } from "../types";
6
+ import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
7
+ import {
8
+ TestingRunParams,
9
+ beforeAfterReset,
10
+ setWETHAmount,
11
+ testingHelper
12
+ } from "./utils/testingHelper";
13
+ import { allowanceDelta, balanceDelta } from "./utils/token";
14
+ import { getWalletData } from "./wallet";
15
+
16
+ const testFluid = ({ network, provider }: TestingRunParams) => {
17
+ const WETH = CONTRACT_ADDRESS[network].WETH;
18
+ const FLUID_WETH = CONTRACT_ADDRESS[network].FLUID_WETH;
19
+
20
+ let dhedge: Dhedge;
21
+ let pool: Pool;
22
+ jest.setTimeout(100000);
23
+
24
+ describe(`[${network}] compound V3 tests`, () => {
25
+ beforeAll(async () => {
26
+ const { wallet } = getWalletData(network);
27
+ // top up ETH (gas)
28
+ await provider.send("hardhat_setBalance", [
29
+ wallet.address,
30
+ "0x100000000000000"
31
+ ]);
32
+ dhedge = new Dhedge(wallet, network);
33
+ pool = await dhedge.loadPool(TEST_POOL[network]);
34
+ await setWETHAmount({
35
+ amount: new BigNumber(1e18).toFixed(0),
36
+ userAddress: pool.address,
37
+ network,
38
+ provider
39
+ });
40
+
41
+ const newAssets: AssetEnabled[] = [
42
+ { asset: WETH, isDeposit: true },
43
+ {
44
+ asset: FLUID_WETH,
45
+ isDeposit: false
46
+ }
47
+ ];
48
+ await pool.managerLogic.changeAssets(newAssets, []);
49
+ });
50
+ beforeAfterReset({ beforeAll, afterAll, provider });
51
+
52
+ it("approves unlimited WETH for fWETH market", async () => {
53
+ await pool.approveSpender(FLUID_WETH, WETH, MAX_AMOUNT);
54
+ const wethAllowanceDelta = await allowanceDelta(
55
+ pool.address,
56
+ WETH,
57
+ FLUID_WETH,
58
+ pool.signer
59
+ );
60
+ await expect(wethAllowanceDelta.gt(0));
61
+ });
62
+
63
+ it("lends WETH to Fluid WETH market", async () => {
64
+ const wethBalance = await pool.utils.getBalance(WETH, pool.address);
65
+ await pool.lendCompoundV3(FLUID_WETH, WETH, wethBalance);
66
+
67
+ const fWETHTokenDelta = await balanceDelta(
68
+ pool.address,
69
+ FLUID_WETH,
70
+ pool.signer
71
+ );
72
+ expect(fWETHTokenDelta.gt(0));
73
+ });
74
+
75
+ it("withdraw WETH from Fluid WETH market", async () => {
76
+ const fWETHBalance = await pool.utils.getBalance(
77
+ FLUID_WETH,
78
+ pool.address
79
+ );
80
+ await pool.withdrawCompoundV3(FLUID_WETH, WETH, fWETHBalance);
81
+ const wethBalance = await balanceDelta(pool.address, WETH, pool.signer);
82
+ expect(wethBalance.gt(0));
83
+ });
84
+ });
85
+ };
86
+
87
+ testingHelper({
88
+ network: Network.ARBITRUM,
89
+ testingRun: testFluid
90
+ });
@@ -34,6 +34,13 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
34
34
  "0x10000000000000000"
35
35
  ]);
36
36
  await provider.send("evm_mine", []);
37
+
38
+ const newAssets = [
39
+ { asset: USDC, isDeposit: true },
40
+ { asset: WETH, isDeposit: true }
41
+ ];
42
+
43
+ await pool.managerLogic.changeAssets(newAssets, []);
37
44
  // top up USDC
38
45
  await setUSDCAmount({
39
46
  amount: new BigNumber(2).times(1e6).toFixed(0),
@@ -104,10 +111,10 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
104
111
  });
105
112
  };
106
113
 
107
- testingHelper({
108
- network: Network.OPTIMISM,
109
- testingRun: testOneInch
110
- });
114
+ // testingHelper({
115
+ // network: Network.OPTIMISM,
116
+ // testingRun: testOneInch
117
+ // });
111
118
 
112
119
  // testingHelper({
113
120
  // network: Network.POLYGON,
@@ -120,3 +127,8 @@ testingHelper({
120
127
  // onFork: false,
121
128
  // testingRun: testOneInch
122
129
  // });
130
+
131
+ testingHelper({
132
+ network: Network.ETHEREUM,
133
+ testingRun: testOneInch
134
+ });
@@ -8,7 +8,7 @@ export const networkPortMap = {
8
8
  [Network.OPTIMISM]: 8544,
9
9
  [Network.ARBITRUM]: 8540,
10
10
  [Network.BASE]: 8546,
11
- [Network.SONIC]: 8547
11
+ [Network.ETHEREUM]: 8547
12
12
  };
13
13
 
14
14
  export const getWalletData = (
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@ export enum Network {
6
6
  OPTIMISM = "optimism",
7
7
  ARBITRUM = "arbitrum",
8
8
  BASE = "base",
9
- SONIC = "sonic"
9
+ ETHEREUM = "ethereum"
10
10
  }
11
11
 
12
12
  export enum Dapp {
@@ -31,7 +31,6 @@ export enum Dapp {
31
31
  PANCAKECL = "pancakeCL",
32
32
  COMPOUNDV3 = "compoundV3",
33
33
  ODOS = "odos",
34
- SHADOWCL = "shadowCL",
35
34
  PENDLE = "pendle"
36
35
  }
37
36