@dhedge/v2-sdk 1.11.1 → 2.0.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.
Files changed (38) hide show
  1. package/dist/entities/pool.d.ts +91 -91
  2. package/dist/services/flatmoney/stableLp.d.ts +4 -4
  3. package/dist/services/odos/index.d.ts +5 -1
  4. package/dist/services/pendle/index.d.ts +4 -1
  5. package/dist/services/toros/completeWithdrawal.d.ts +7 -0
  6. package/dist/services/toros/easySwapper.d.ts +2 -2
  7. package/dist/services/toros/initWithdrawal.d.ts +3 -0
  8. package/dist/services/toros/retry.d.ts +5 -0
  9. package/dist/services/toros/swapData.d.ts +11 -0
  10. package/dist/types.d.ts +5 -0
  11. package/dist/utils/contract.d.ts +3 -2
  12. package/dist/v2-sdk.cjs.development.js +5716 -2693
  13. package/dist/v2-sdk.cjs.development.js.map +1 -1
  14. package/dist/v2-sdk.cjs.production.min.js +1 -1
  15. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  16. package/dist/v2-sdk.esm.js +5716 -2693
  17. package/dist/v2-sdk.esm.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/abi/IAaveLendingPoolAssetGuard.json +645 -0
  20. package/src/abi/IEasySwapperV2.json +1507 -0
  21. package/src/abi/pendle/PT.json +15 -0
  22. package/src/abi/pendle/SY.json +1 -0
  23. package/src/entities/pool.ts +240 -149
  24. package/src/services/flatmoney/stableLp.ts +27 -21
  25. package/src/services/odos/index.ts +6 -3
  26. package/src/services/pendle/index.ts +43 -8
  27. package/src/services/toros/completeWithdrawal.ts +209 -0
  28. package/src/services/toros/easySwapper.ts +16 -84
  29. package/src/services/toros/initWithdrawal.ts +166 -0
  30. package/src/services/toros/retry.ts +28 -0
  31. package/src/services/toros/swapData.ts +70 -0
  32. package/src/test/constants.ts +1 -1
  33. package/src/test/odos.test.ts +8 -7
  34. package/src/test/oneInch.test.ts +20 -22
  35. package/src/test/pendle.test.ts +63 -37
  36. package/src/test/toros.test.ts +10 -8
  37. package/src/types.ts +8 -0
  38. package/src/utils/contract.ts +70 -16
@@ -0,0 +1,166 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Dapp, ethers, Pool } from "../..";
3
+ import { networkChainIdMap, routerAddress } from "../../config";
4
+ import { retry } from "./retry";
5
+ import AaveLendingPoolAssetGuardAbi from "../../abi/IAaveLendingPoolAssetGuard.json";
6
+ import IEasySwapperV2 from "../../abi/IEasySwapperV2.json";
7
+ import { loadPool } from "./pool";
8
+ import { getSwapDataViaOdos, SWAPPER_ADDERSS } from "./swapData";
9
+ const AAVE_WITHDRAW_ONCHAIN_SWAP_SLIPPAGE = 150; // 1.5% slippage for onchain swap in Aave withdrawal
10
+
11
+ const getCalculateSwapDataParams = async (
12
+ pool: Pool,
13
+ torosAsset: string,
14
+ amountIn: string,
15
+ slippage: number
16
+ ): Promise<{
17
+ offchainSwapNeeded: boolean;
18
+ swapDataParams: any;
19
+ }> => {
20
+ const aaveAssetGuardAddress = await pool.factory.getAssetGuard(
21
+ routerAddress[pool.network][Dapp.AAVEV3] as string
22
+ );
23
+
24
+ const aaveAssetGuard = new ethers.Contract(
25
+ aaveAssetGuardAddress,
26
+ AaveLendingPoolAssetGuardAbi,
27
+ pool.signer
28
+ );
29
+ const swapDataParams = await aaveAssetGuard.callStatic.calculateSwapDataParams(
30
+ torosAsset,
31
+ amountIn,
32
+ slippage
33
+ );
34
+
35
+ return {
36
+ offchainSwapNeeded: swapDataParams.srcData.length !== 0,
37
+ swapDataParams
38
+ };
39
+ };
40
+
41
+ const getAaveAssetWithdrawData = async (
42
+ pool: Pool,
43
+ swapDataParams: any,
44
+ slippage: number
45
+ ) => {
46
+ const { srcData, dstData } = swapDataParams;
47
+
48
+ const srcDataToEncode: unknown[] = [];
49
+ const routerKey = ethers.utils.formatBytes32String("ODOS_V2");
50
+ for (const { asset, amount } of srcData) {
51
+ const swapData = await retry({
52
+ fn: () => {
53
+ return getSwapDataViaOdos({
54
+ srcAsset: asset,
55
+ srcAmount: amount.toString(),
56
+ dstAsset: dstData.asset,
57
+ chainId: networkChainIdMap[pool.network],
58
+ from: SWAPPER_ADDERSS,
59
+ receiver: SWAPPER_ADDERSS,
60
+ slippage
61
+ });
62
+ },
63
+ delayMs: 1500,
64
+ maxRetries: 7
65
+ });
66
+ srcDataToEncode.push([asset, amount, [routerKey, swapData]]);
67
+ }
68
+ const coder = ethers.utils.defaultAbiCoder;
69
+
70
+ const encodedSrcData = coder.encode(
71
+ ["tuple(address, uint256, tuple(bytes32, bytes))[]"],
72
+ [srcDataToEncode]
73
+ );
74
+ const withdrawData = coder.encode(
75
+ ["tuple(bytes, tuple(address, uint256), uint256)"],
76
+ [[encodedSrcData, [dstData.asset, dstData.amount], slippage]]
77
+ );
78
+
79
+ return withdrawData;
80
+ };
81
+
82
+ export const createWithdrawTxArguments = async (
83
+ pool: Pool,
84
+ torosAsset: string,
85
+ amountIn: string,
86
+ slippage: number,
87
+ useOnChainSwap: boolean
88
+ ): Promise<any> => {
89
+ const torosPool = await loadPool(pool, torosAsset);
90
+ const supportedAssets: {
91
+ asset: string;
92
+ }[] = await torosPool.managerLogic.getSupportedAssets();
93
+
94
+ if (useOnChainSwap) {
95
+ return supportedAssets.map(assetObj => {
96
+ return {
97
+ supportedAsset: assetObj.asset,
98
+ withdrawData: "0x",
99
+ slippageTolerance: AAVE_WITHDRAW_ONCHAIN_SWAP_SLIPPAGE
100
+ };
101
+ });
102
+ }
103
+
104
+ // for off-chain swap
105
+ const aaveLendingPoolAddress = routerAddress[pool.network][
106
+ Dapp.AAVEV3
107
+ ] as string;
108
+ return Promise.all(
109
+ supportedAssets.map(async assetObj => {
110
+ if (
111
+ assetObj.asset.toLowerCase() === aaveLendingPoolAddress.toLowerCase()
112
+ ) {
113
+ const {
114
+ offchainSwapNeeded,
115
+ swapDataParams
116
+ } = await getCalculateSwapDataParams(
117
+ pool,
118
+ torosAsset,
119
+ amountIn,
120
+ slippage
121
+ );
122
+ if (offchainSwapNeeded) {
123
+ const withdrawData = await getAaveAssetWithdrawData(
124
+ pool,
125
+ swapDataParams,
126
+ slippage
127
+ );
128
+
129
+ return {
130
+ supportedAsset: assetObj.asset,
131
+ withdrawData,
132
+ slippageTolerance: slippage
133
+ };
134
+ }
135
+ }
136
+
137
+ return {
138
+ supportedAsset: assetObj.asset,
139
+ withdrawData: "0x",
140
+ slippageTolerance: slippage
141
+ };
142
+ })
143
+ );
144
+ };
145
+
146
+ export const getInitWithdrawalTxData = async (
147
+ pool: Pool,
148
+ torosAsset: string,
149
+ amountIn: string,
150
+ slippage: number,
151
+ useOnChainSwap: boolean
152
+ ): Promise<string> => {
153
+ const complexAssetsData = await createWithdrawTxArguments(
154
+ pool,
155
+ torosAsset,
156
+ amountIn,
157
+ slippage,
158
+ useOnChainSwap
159
+ );
160
+ const iEasySwapperV2 = new ethers.utils.Interface(IEasySwapperV2);
161
+ return iEasySwapperV2.encodeFunctionData("initWithdrawal", [
162
+ torosAsset,
163
+ amountIn,
164
+ complexAssetsData
165
+ ]);
166
+ };
@@ -0,0 +1,28 @@
1
+ export async function retry<T>({
2
+ fn,
3
+ maxRetries = 3,
4
+ delayMs = 1000
5
+ }: {
6
+ fn: () => Promise<T>;
7
+ maxRetries?: number;
8
+ delayMs?: number;
9
+ }): Promise<T> {
10
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
11
+ try {
12
+ return await fn();
13
+ } catch (err) {
14
+ if (attempt === maxRetries) {
15
+ throw new Error(`Retry failed after ${maxRetries} attempts: ${err}`);
16
+ }
17
+
18
+ console.warn(
19
+ `Retry ${attempt}/${maxRetries} failed, retrying in ${delayMs}ms`,
20
+ err
21
+ );
22
+ await new Promise(res => setTimeout(res, delayMs));
23
+ }
24
+ }
25
+
26
+ // Should never reach here
27
+ throw new Error("Unexpected retry failure");
28
+ }
@@ -0,0 +1,70 @@
1
+ import axios from "axios";
2
+ import BigNumber from "bignumber.js";
3
+ import { odosBaseUrl } from "../odos";
4
+
5
+ export const SWAPPER_ADDERSS = "0x4F754e0F0924afD74980886b0B479Fa1D7C58D0D";
6
+
7
+ export interface SwapParams {
8
+ srcAsset: string; // Source asset address
9
+ srcAmount: string; // Amount to swap (use string for big numbers)
10
+ dstAsset: string; // Destination asset address
11
+ chainId: number; // Chain ID
12
+ from: string; // Sender address
13
+ receiver: string; // Receiver address
14
+ slippage: number; // Slippage tolerance in basis points (100 = 1%)
15
+ }
16
+
17
+ export const getSwapDataViaOdos = async ({
18
+ srcAsset,
19
+ srcAmount,
20
+ dstAsset,
21
+ chainId,
22
+ from,
23
+ slippage
24
+ }: SwapParams): Promise<string> => {
25
+ let referralCode = 0; // Defaults to 0 for unregistered activity.
26
+ if (
27
+ process.env.ODOS_REFERAL_CODE &&
28
+ Number(process.env.ODOS_REFERAL_CODE) > 0
29
+ ) {
30
+ referralCode = Number(process.env.ODOS_REFERAL_CODE);
31
+ }
32
+ const quoteParams = {
33
+ chainId: chainId,
34
+ inputTokens: [
35
+ {
36
+ tokenAddress: srcAsset,
37
+ amount: srcAmount
38
+ }
39
+ ],
40
+ outputTokens: [
41
+ {
42
+ tokenAddress: dstAsset,
43
+ proportion: 1
44
+ }
45
+ ],
46
+ slippageLimitPercent: new BigNumber(slippage).div(100).toString(), // Convert basis points to percentage
47
+ userAddr: from,
48
+ referralCode
49
+ };
50
+ try {
51
+ const quoteResult = await axios.post(
52
+ `${odosBaseUrl}/quote/v2`,
53
+ quoteParams
54
+ );
55
+
56
+ const assembleParams = {
57
+ pathId: quoteResult.data.pathId,
58
+ userAddr: from
59
+ };
60
+
61
+ const assembleResult = await axios.post(
62
+ `${odosBaseUrl}/assemble`,
63
+ assembleParams
64
+ );
65
+ return assembleResult.data.transaction.data;
66
+ } catch (e) {
67
+ console.error("Error in Odos API request:", e);
68
+ throw new Error("Swap api request of Odos failed");
69
+ }
70
+ };
@@ -89,7 +89,7 @@ export const CONTRACT_ADDRESS = {
89
89
  VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",
90
90
  COMPOUNDV3_WETH: "",
91
91
  FLUID_WETH: "",
92
- TOROS: "0x49bf093277bf4dde49c48c6aa55a3bda3eedef68" //USDmny
92
+ TOROS: "0xcacb5a722a36cff6baeb359e21c098a4acbffdfa" //ETHBEAR1X
93
93
  },
94
94
  [Network.ARBITRUM]: {
95
95
  USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
@@ -63,7 +63,8 @@ const testOdos = ({ wallet, network, provider }: TestingRunParams) => {
63
63
  await getTxOptions(network),
64
64
  true
65
65
  );
66
- expect(gasEstimate.gt(0));
66
+ expect(gasEstimate.gas.gt(0));
67
+ expect(gasEstimate.minAmountOut).not.toBeNull();
67
68
  });
68
69
 
69
70
  it("trades 2 USDC into WETH on Odos", async () => {
@@ -86,16 +87,16 @@ const testOdos = ({ wallet, network, provider }: TestingRunParams) => {
86
87
  });
87
88
  };
88
89
 
89
- // testingHelper({
90
- // network: Network.OPTIMISM,
91
- // testingRun: testOdos
92
- // });
93
-
94
90
  testingHelper({
95
- network: Network.ARBITRUM,
91
+ network: Network.OPTIMISM,
96
92
  testingRun: testOdos
97
93
  });
98
94
 
95
+ // testingHelper({
96
+ // network: Network.ARBITRUM,
97
+ // testingRun: testOdos
98
+ // });
99
+
99
100
  // testingHelper({
100
101
  // network: Network.POLYGON,
101
102
  // onFork: false,
@@ -71,24 +71,22 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
71
71
  await getTxOptions(network),
72
72
  true
73
73
  );
74
- expect(gasEstimate.gt(0));
74
+ expect(gasEstimate.gas.gt(0));
75
+ expect(gasEstimate.minAmountOut).not.toBeNull();
75
76
  });
76
77
 
77
78
  it("gets error on gas estimation for 200 USDC into WETH on 1Inch", async () => {
78
79
  await wait(1);
79
- let gasEstimate = null;
80
- try {
81
- gasEstimate = await pool.trade(
82
- Dapp.ONEINCH,
83
- USDC,
84
- WETH,
85
- "200000000",
86
- 1,
87
- await getTxOptions(network),
88
- true
89
- );
90
- } catch (err) {}
91
- expect(gasEstimate).toBeNull();
80
+ const gasEstimate = await pool.trade(
81
+ Dapp.ONEINCH,
82
+ USDC,
83
+ WETH,
84
+ "200000000",
85
+ 1,
86
+ await getTxOptions(network),
87
+ true
88
+ );
89
+ expect(gasEstimate.gasEstimationError).not.toBeNull();
92
90
  });
93
91
 
94
92
  it("trades 2 USDC into WETH on 1Inch", async () => {
@@ -111,10 +109,10 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
111
109
  });
112
110
  };
113
111
 
114
- // testingHelper({
115
- // network: Network.OPTIMISM,
116
- // testingRun: testOneInch
117
- // });
112
+ testingHelper({
113
+ network: Network.OPTIMISM,
114
+ testingRun: testOneInch
115
+ });
118
116
 
119
117
  // testingHelper({
120
118
  // network: Network.POLYGON,
@@ -128,7 +126,7 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
128
126
  // testingRun: testOneInch
129
127
  // });
130
128
 
131
- testingHelper({
132
- network: Network.ETHEREUM,
133
- testingRun: testOneInch
134
- });
129
+ // testingHelper({
130
+ // network: Network.ETHEREUM,
131
+ // testingRun: testOneInch
132
+ // });
@@ -8,8 +8,7 @@ import {
8
8
  TestingRunParams,
9
9
  setTokenAmount,
10
10
  setUSDCAmount,
11
- testingHelper,
12
- wait
11
+ testingHelper
13
12
  } from "./utils/testingHelper";
14
13
 
15
14
  import { getTxOptions } from "./txOptions";
@@ -19,7 +18,7 @@ import { balanceDelta } from "./utils/token";
19
18
  const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
20
19
  const USDC = CONTRACT_ADDRESS[network].USDC;
21
20
  const weETH = "0x35751007a407ca6feffe80b3cb397736d2cf4dbe";
22
- const PTweETH = "0xb33808ea0e883138680ba29311a220a7377cdb92";
21
+ // const PTweETH = "0xb33808ea0e883138680ba29311a220a7377cdb92";
23
22
  const PTweETH_matured = "0xe2b2d203577c7cb3d043e89ccf90b5e24d19b66f";
24
23
 
25
24
  let dhedge: Dhedge;
@@ -54,33 +53,62 @@ const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
54
53
  );
55
54
  });
56
55
 
57
- it("swaps weETH to PTweETH on Pendle", async () => {
58
- await pool.approve(Dapp.PENDLE, weETH, MAX_AMOUNT);
59
- const weEthBalance = await pool.utils.getBalance(weETH, pool.address);
60
- await pool.trade(
61
- Dapp.PENDLE,
62
- weETH,
63
- PTweETH,
64
- weEthBalance,
65
- 0.5,
66
- await getTxOptions(network)
67
- );
68
- const ptWeEthBalanceDelta = await balanceDelta(
69
- pool.address,
70
- PTweETH,
71
- pool.signer
72
- );
73
- expect(ptWeEthBalanceDelta.gt(0));
74
- });
56
+ // it("swaps weETH to PTweETH on Pendle", async () => {
57
+ // await pool.approve(Dapp.PENDLE, weETH, MAX_AMOUNT);
58
+ // const weEthBalance = await pool.utils.getBalance(weETH, pool.address);
59
+ // await pool.trade(
60
+ // Dapp.PENDLE,
61
+ // weETH,
62
+ // PTweETH,
63
+ // weEthBalance,
64
+ // 0.5,
65
+ // await getTxOptions(network)
66
+ // );
67
+ // const ptWeEthBalanceDelta = await balanceDelta(
68
+ // pool.address,
69
+ // PTweETH,
70
+ // pool.signer
71
+ // );
72
+ // expect(ptWeEthBalanceDelta.gt(0));
73
+ // });
74
+
75
+ // it("swaps PTweETH to weETH on Pendle", async () => {
76
+ // await pool.approve(Dapp.PENDLE, PTweETH, MAX_AMOUNT);
77
+ // const PTweEthBalance = await pool.utils.getBalance(PTweETH, pool.address);
78
+ // console.log("PTweEthBalance", PTweEthBalance.toString());
79
+ // await wait(3);
80
+ // await pool.trade(
81
+ // Dapp.PENDLE,
82
+ // PTweETH,
83
+ // weETH,
84
+ // PTweEthBalance,
85
+ // 0.5,
86
+ // await getTxOptions(network)
87
+ // );
88
+ // const weEthBalanceDelta = await balanceDelta(
89
+ // pool.address,
90
+ // weETH,
91
+ // pool.signer
92
+ // );
93
+ // expect(weEthBalanceDelta.gt(0));
94
+ // });
75
95
 
76
- it("swaps PTweETH to weETH on Pendle", async () => {
77
- await pool.approve(Dapp.PENDLE, PTweETH, MAX_AMOUNT);
78
- const PTweEthBalance = await pool.utils.getBalance(PTweETH, pool.address);
79
- console.log("PTweEthBalance", PTweEthBalance.toString());
80
- await wait(3);
96
+ it("exit matured PTweETH to weETH on Pendle", async () => {
97
+ await setTokenAmount({
98
+ amount: new BigNumber(1).times(1e18).toString(),
99
+ provider,
100
+ tokenAddress: PTweETH_matured,
101
+ slot: 0,
102
+ userAddress: pool.address
103
+ });
104
+ await pool.approve(Dapp.PENDLE, PTweETH_matured, MAX_AMOUNT);
105
+ const PTweEthBalance = await pool.utils.getBalance(
106
+ PTweETH_matured,
107
+ pool.address
108
+ );
81
109
  await pool.trade(
82
110
  Dapp.PENDLE,
83
- PTweETH,
111
+ PTweETH_matured,
84
112
  weETH,
85
113
  PTweEthBalance,
86
114
  0.5,
@@ -91,7 +119,7 @@ const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
91
119
  weETH,
92
120
  pool.signer
93
121
  );
94
- expect(weEthBalanceDelta.gt(0));
122
+ expect(weEthBalanceDelta.eq(PTweEthBalance));
95
123
  });
96
124
 
97
125
  it("exit matured PTweETH to weETH on Pendle", async () => {
@@ -107,21 +135,19 @@ const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
107
135
  PTweETH_matured,
108
136
  pool.address
109
137
  );
110
- await wait(3);
111
- await pool.trade(
138
+ const result = await pool.trade(
112
139
  Dapp.PENDLE,
113
140
  PTweETH_matured,
114
141
  weETH,
115
142
  PTweEthBalance,
116
143
  0.5,
117
- await getTxOptions(network)
118
- );
119
- const weEthBalanceDelta = await balanceDelta(
120
- pool.address,
121
- weETH,
122
- pool.signer
144
+ await getTxOptions(network),
145
+ true
123
146
  );
124
- expect(weEthBalanceDelta.eq(PTweEthBalance));
147
+
148
+ expect(result.gas).not.toBeNull();
149
+ expect(result.minAmountOut).not.toBeNull();
150
+ expect(result.gasEstimationError).toBeNull();
125
151
  });
126
152
  });
127
153
  };
@@ -1,18 +1,19 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
2
 
3
+ import BigNumber from "bignumber.js";
3
4
  import { Dhedge, Pool } from "..";
4
5
  import { routerAddress } from "../config";
5
6
 
6
7
  import { Dapp, Network } from "../types";
7
8
  import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
8
9
  import {
9
- TestingRunParams,
10
10
  setChainlinkTimeout,
11
11
  setUSDCAmount,
12
- testingHelper
12
+ testingHelper,
13
+ TestingRunParams
13
14
  } from "./utils/testingHelper";
15
+
14
16
  import { allowanceDelta, balanceDelta } from "./utils/token";
15
- import BigNumber from "bignumber.js";
16
17
 
17
18
  const testToros = ({ wallet, network, provider }: TestingRunParams) => {
18
19
  const USDC = CONTRACT_ADDRESS[network].USDC;
@@ -34,7 +35,7 @@ const testToros = ({ wallet, network, provider }: TestingRunParams) => {
34
35
  ]);
35
36
  await provider.send("evm_mine", []);
36
37
  // top up USDC
37
- const amount = new BigNumber(1000).times(1e6).toFixed(0);
38
+ const amount = new BigNumber(100).times(1e6).toFixed(0);
38
39
  await setUSDCAmount({
39
40
  amount,
40
41
  userAddress: pool.address,
@@ -56,7 +57,7 @@ const testToros = ({ wallet, network, provider }: TestingRunParams) => {
56
57
 
57
58
  it("trades USDC balance into Toros Token", async () => {
58
59
  const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
59
- await pool.trade(Dapp.TOROS, USDC, TOROS, usdcBalance, 1);
60
+ await pool.trade(Dapp.TOROS, USDC, TOROS, usdcBalance, 1.5);
60
61
  const torosBalanceDelta = await balanceDelta(
61
62
  pool.address,
62
63
  TOROS,
@@ -70,7 +71,7 @@ const testToros = ({ wallet, network, provider }: TestingRunParams) => {
70
71
  await provider.send("evm_mine", []);
71
72
  const torosBalance = await pool.utils.getBalance(TOROS, pool.address);
72
73
  await pool.approve(Dapp.TOROS, TOROS, MAX_AMOUNT);
73
- await pool.trade(Dapp.TOROS, TOROS, USDC, torosBalance, 1);
74
+ await pool.trade(Dapp.TOROS, TOROS, USDC, torosBalance, 1.5);
74
75
  const torosBalanceDelta = await balanceDelta(
75
76
  pool.address,
76
77
  TOROS,
@@ -80,7 +81,7 @@ const testToros = ({ wallet, network, provider }: TestingRunParams) => {
80
81
  });
81
82
 
82
83
  it("complete withdrawal from Toros asset", async () => {
83
- await pool.completeTorosWithdrawal(USDC, 1);
84
+ await pool.completeTorosWithdrawal(USDC, 1.5);
84
85
  const usdcBalanceDelta = await balanceDelta(
85
86
  pool.address,
86
87
  USDC,
@@ -93,5 +94,6 @@ const testToros = ({ wallet, network, provider }: TestingRunParams) => {
93
94
 
94
95
  testingHelper({
95
96
  network: Network.OPTIMISM,
96
- testingRun: testToros
97
+ testingRun: testToros,
98
+ onFork: true
97
99
  });
package/src/types.ts CHANGED
@@ -101,3 +101,11 @@ export type LyraPosition = {
101
101
  collateral: BigNumber;
102
102
  state: number;
103
103
  };
104
+
105
+ export type SDKOptions =
106
+ | {
107
+ estimateGas: boolean;
108
+ onlyGetTxData?: boolean;
109
+ useTraderAddressAsFrom?: boolean;
110
+ }
111
+ | boolean; // shorthand for { estimateGas: true/false }; for backward compatibility