@dhedge/v2-sdk 1.1.1 → 1.3.0

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 (59) hide show
  1. package/README.md +60 -3
  2. package/dist/config.d.ts +7 -0
  3. package/dist/entities/pool.d.ts +101 -5
  4. package/dist/entities/utils.d.ts +10 -0
  5. package/dist/services/claim-balancer/claim.service.d.ts +17 -0
  6. package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
  7. package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
  8. package/dist/services/claim-balancer/types.d.ts +54 -0
  9. package/dist/services/uniswap/V3Liquidity.d.ts +9 -0
  10. package/dist/services/uniswap/V3Trade.d.ts +4 -0
  11. package/dist/services/uniswap/types.d.ts +3 -0
  12. package/dist/test/constants.d.ts +12 -0
  13. package/dist/test/txOptions.d.ts +1 -0
  14. package/dist/types.d.ts +20 -6
  15. package/dist/utils/contract.d.ts +14 -0
  16. package/dist/utils/index.d.ts +7 -0
  17. package/dist/utils/merkle.d.ts +22 -0
  18. package/dist/v2-sdk.cjs.development.js +6086 -918
  19. package/dist/v2-sdk.cjs.development.js.map +1 -1
  20. package/dist/v2-sdk.cjs.production.min.js +1 -1
  21. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  22. package/dist/v2-sdk.esm.js +6090 -922
  23. package/dist/v2-sdk.esm.js.map +1 -1
  24. package/package.json +12 -2
  25. package/src/abi/IAaveIncentivesController.json +50 -0
  26. package/src/abi/IBalancerMerkleOrchard.json +353 -0
  27. package/src/abi/IBalancertV2Vault.json +938 -0
  28. package/src/abi/IERC20.json +15 -1
  29. package/src/abi/INonfungiblePositionManager.json +1221 -0
  30. package/src/abi/ISynthetix.json +139 -0
  31. package/src/abi/IUniswapV3Quoter.json +195 -0
  32. package/src/abi/IUniswapV3Router.json +221 -0
  33. package/src/config.ts +48 -8
  34. package/src/entities/dhedge.ts +4 -2
  35. package/src/entities/pool.ts +398 -27
  36. package/src/entities/utils.ts +147 -0
  37. package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
  38. package/src/services/claim-balancer/claim.service.ts +262 -0
  39. package/src/services/claim-balancer/claim.worker.ts +32 -0
  40. package/src/services/claim-balancer/ipfs.service.ts +12 -0
  41. package/src/services/claim-balancer/types.ts +66 -0
  42. package/src/services/uniswap/V3Liquidity.ts +134 -0
  43. package/src/services/uniswap/V3Trade.ts +47 -0
  44. package/src/services/uniswap/types.ts +16 -0
  45. package/src/test/aave.test.ts +73 -0
  46. package/src/test/balancer.test.ts +109 -0
  47. package/src/test/constants.ts +17 -0
  48. package/src/test/oneInch.test.ts +56 -0
  49. package/src/test/pool.test.ts +6 -250
  50. package/src/test/sushi.test.ts +173 -0
  51. package/src/test/synthetix.test.ts +34 -0
  52. package/src/test/txOptions.ts +15 -0
  53. package/src/test/uniswap.test.ts +127 -0
  54. package/src/test/utils.test.ts +41 -26
  55. package/src/test/wallet.ts +5 -1
  56. package/src/types.ts +17 -3
  57. package/src/utils/contract.ts +95 -0
  58. package/src/utils/index.ts +38 -0
  59. package/src/utils/merkle.ts +172 -0
@@ -6,8 +6,19 @@ import { Contract, ethers, Wallet, BigNumber } from "ethers";
6
6
  import IERC20 from "../abi/IERC20.json";
7
7
  import IMiniChefV2 from "../abi/IMiniChefV2.json";
8
8
  import ILendingPool from "../abi/ILendingPool.json";
9
+ import ISynthetix from "../abi/ISynthetix.json";
9
10
  import IUniswapV2Router from "../abi/IUniswapV2Router.json";
10
- import { routerAddress, stakingAddress } from "../config";
11
+ import INonfungiblePositionManager from "../abi/INonfungiblePositionManager.json";
12
+ import IBalancerMerkleOrchard from "../abi/IBalancerMerkleOrchard.json";
13
+ import IAaveIncentivesController from "../abi/IAaveIncentivesController.json";
14
+ import {
15
+ deadline,
16
+ MaxUint128,
17
+ nonfungiblePositionManagerAddress,
18
+ routerAddress,
19
+ stakingAddress,
20
+ SYNTHETIX_TRACKING_CODE
21
+ } from "../config";
11
22
  import {
12
23
  Dapp,
13
24
  Transaction,
@@ -17,10 +28,18 @@ import {
17
28
  } from "../types";
18
29
 
19
30
  import { Utils } from "./utils";
31
+ import { ClaimService } from "../services/claim-balancer/claim.service";
32
+ import {
33
+ getUniswapV3Liquidity,
34
+ getUniswapV3MintParams
35
+ } from "../services/uniswap/V3Liquidity";
36
+ import { FeeAmount } from "@uniswap/v3-sdk";
37
+ import { getUniswapV3SwapTxData } from "../services/uniswap/V3Trade";
20
38
 
21
39
  export class Pool {
22
40
  public readonly poolLogic: Contract;
23
41
  public readonly managerLogic: Contract;
42
+ public readonly factory: Contract;
24
43
  public readonly signer: Wallet;
25
44
  public readonly address: string;
26
45
  public readonly utils: Utils;
@@ -31,7 +50,8 @@ export class Pool {
31
50
  signer: Wallet,
32
51
  poolLogic: Contract,
33
52
  mangerLogic: Contract,
34
- utils: Utils
53
+ utils: Utils,
54
+ factory: Contract
35
55
  ) {
36
56
  this.network = network;
37
57
  this.poolLogic = poolLogic;
@@ -39,6 +59,7 @@ export class Pool {
39
59
  this.managerLogic = mangerLogic;
40
60
  this.signer = signer;
41
61
  this.utils = utils;
62
+ this.factory = factory;
42
63
  }
43
64
 
44
65
  /**
@@ -167,13 +188,39 @@ export class Pool {
167
188
  return tx;
168
189
  }
169
190
 
191
+ /**
192
+ * Approve the liquidity pool token for staking
193
+ * @param {Dapp} dapp Platform like Sushiswap or Uniswap
194
+ * @param {string} asset Address of liquidity pool token
195
+ * @param {BigNumber | string} amount Aamount to be approved
196
+ * @param {any} options Transaction options
197
+ * @returns {Promise<any>} Transaction
198
+ */
199
+ async approveUniswapV3Liquidity(
200
+ asset: string,
201
+ amount: BigNumber | string,
202
+ options: any = null
203
+ ): Promise<any> {
204
+ const iERC20 = new ethers.utils.Interface(IERC20.abi);
205
+ const approveTxData = iERC20.encodeFunctionData("approve", [
206
+ nonfungiblePositionManagerAddress[this.network],
207
+ amount
208
+ ]);
209
+ const tx = await this.poolLogic.execTransaction(
210
+ asset,
211
+ approveTxData,
212
+ options
213
+ );
214
+ return tx;
215
+ }
216
+
170
217
  /**
171
218
  * Trade an asset into another asset
172
219
  * @param {Dapp} dapp Platform like Sushiswap or Uniswap
173
220
  * @param {string} assetFrom Asset to trade from
174
221
  * @param {string} assetTo Asset to trade into
175
222
  * @param {BigNumber | string} amountIn Amount
176
- * @param {BigNumber | string} minAmountOut Minumum amount to receive
223
+ * @param {number} slippage Slippage tolerance in %
177
224
  * @param {any} options Transaction options
178
225
  * @returns {Promise<any>} Transaction
179
226
  */
@@ -194,6 +241,27 @@ export class Pool {
194
241
  }&slippage=${slippage.toString()}&disableEstimate=true`;
195
242
  const response = await axios.get(apiUrl);
196
243
  swapTxData = response.data.tx.data;
244
+ } else if (dapp === Dapp.BALANCER) {
245
+ swapTxData = await this.utils.getBalancerSwapTx(
246
+ this,
247
+ assetFrom,
248
+ assetTo,
249
+ amountIn,
250
+ slippage
251
+ );
252
+ } else if (dapp === Dapp.SYNTHETIX) {
253
+ const iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
254
+ const assets = [assetFrom, assetTo].map(asset =>
255
+ ethers.utils.formatBytes32String(asset)
256
+ );
257
+ const daoAddress = await this.factory.owner();
258
+ swapTxData = iSynthetix.encodeFunctionData(Transaction.SWAP_SYNTHS, [
259
+ assets[0],
260
+ amountIn,
261
+ assets[1],
262
+ daoAddress,
263
+ SYNTHETIX_TRACKING_CODE
264
+ ]);
197
265
  } else {
198
266
  const iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
199
267
  const minAmountOut = await this.utils.getMinAmountOut(
@@ -208,7 +276,7 @@ export class Pool {
208
276
  minAmountOut,
209
277
  [assetFrom, assetTo],
210
278
  this.address,
211
- Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
279
+ deadline
212
280
  ]);
213
281
  }
214
282
  const tx = await this.poolLogic.execTransaction(
@@ -240,16 +308,7 @@ export class Pool {
240
308
  const iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
241
309
  const addLiquidityTxData = iUniswapV2Router.encodeFunctionData(
242
310
  Transaction.ADD_LIQUIDITY,
243
- [
244
- assetA,
245
- assetB,
246
- amountA,
247
- amountB,
248
- 0,
249
- 0,
250
- this.address,
251
- Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
252
- ]
311
+ [assetA, assetB, amountA, amountB, 0, 0, this.address, deadline]
253
312
  );
254
313
  const tx = await this.poolLogic.execTransaction(
255
314
  routerAddress[this.network][dapp],
@@ -278,15 +337,7 @@ export class Pool {
278
337
  const iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
279
338
  const removeLiquidityTxData = iUniswapV2Router.encodeFunctionData(
280
339
  Transaction.REMOVE_LIQUIDITY,
281
- [
282
- assetA,
283
- assetB,
284
- amount,
285
- 0,
286
- 0,
287
- this.address,
288
- Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
289
- ]
340
+ [assetA, assetB, amount, 0, 0, this.address, deadline]
290
341
  );
291
342
  const tx = await this.poolLogic.execTransaction(
292
343
  routerAddress[this.network][dapp],
@@ -342,7 +393,7 @@ export class Pool {
342
393
  ): Promise<any> {
343
394
  const iMiniChefV2 = new ethers.utils.Interface(IMiniChefV2.abi);
344
395
  const poolId = await this.utils.getLpPoolId(dapp, asset);
345
- const unStakeTxData = iMiniChefV2.encodeFunctionData(Transaction.UNSTAKE, [
396
+ const unStakeTxData = iMiniChefV2.encodeFunctionData(Transaction.WITHDRAW, [
346
397
  poolId,
347
398
  amount,
348
399
  this.address
@@ -359,7 +410,8 @@ export class Pool {
359
410
  * Lend asset to a lending pool
360
411
  * @param {Dapp} dapp Platform like Aave
361
412
  * @param {string} asset Asset
362
- * @param {BigNumber | string} amount Amount of asset to lend
413
+ * @param {BigNumber | string} amount Amount of asset to lend
414
+ * @param {number} referrralCode Code from Aave referral program
363
415
  * @param {any} options Transaction options
364
416
  * @returns {Promise<any>} Transaction
365
417
  */
@@ -367,6 +419,7 @@ export class Pool {
367
419
  dapp: Dapp,
368
420
  asset: string,
369
421
  amount: BigNumber | string,
422
+ referrralCode = 0,
370
423
  options: any = null
371
424
  ): Promise<any> {
372
425
  const iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
@@ -374,7 +427,7 @@ export class Pool {
374
427
  asset,
375
428
  amount,
376
429
  this.address,
377
- 0
430
+ referrralCode
378
431
  ]);
379
432
  const tx = await this.poolLogic.execTransaction(
380
433
  routerAddress[this.network][dapp],
@@ -416,6 +469,7 @@ export class Pool {
416
469
  * @param {Dapp} dapp Platform like Aave
417
470
  * @param {string} asset Asset
418
471
  * @param {BigNumber | string} amount Amount of asset to lend
472
+ * @param {number} referrralCode Code from Aave referral program
419
473
  * @param {any} options Transaction options
420
474
  * @returns {Promise<any>} Transaction
421
475
  */
@@ -423,6 +477,7 @@ export class Pool {
423
477
  dapp: Dapp,
424
478
  asset: string,
425
479
  amount: BigNumber | string,
480
+ referrralCode = 0,
426
481
  options: any = null
427
482
  ): Promise<any> {
428
483
  const iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
@@ -430,7 +485,7 @@ export class Pool {
430
485
  asset,
431
486
  amount,
432
487
  2,
433
- 0,
488
+ referrralCode,
434
489
  this.address
435
490
  ]);
436
491
  const tx = await this.poolLogic.execTransaction(
@@ -531,4 +586,320 @@ export class Pool {
531
586
  const tx = await this.managerLogic.setTrader(trader, options);
532
587
  return tx;
533
588
  }
589
+
590
+ /**
591
+ * Invest into a Balancer pool
592
+ * @param {string} poolId Balancer pool id
593
+ * @param {string[] | } assetsIn Array of balancer pool assets
594
+ * @param {BigNumber[] | string[]} amountsIn Array of maximum amounts to provide to pool
595
+ * @param {any} options Transaction options
596
+ * @returns {Promise<any>} Transaction
597
+ */
598
+ async joinBalancerPool(
599
+ poolId: string,
600
+ assets: string[],
601
+ amountsIn: string[] | BigNumber[],
602
+ options: any = null
603
+ ): Promise<any> {
604
+ const joinPoolTxData = this.utils.getBalancerJoinPoolTx(
605
+ this,
606
+ poolId,
607
+ assets,
608
+ amountsIn
609
+ );
610
+ const tx = await this.poolLogic.execTransaction(
611
+ routerAddress[this.network][Dapp.BALANCER],
612
+ joinPoolTxData,
613
+ options
614
+ );
615
+ return tx;
616
+ }
617
+
618
+ /**
619
+ * Invest into a Balancer pool
620
+ * @param {string} poolId Balancer pool id
621
+ * @param {string[] | } assets Array of balancer pool assets
622
+ * @param {BigNumber | string } amount Amount of pool tokens to withdraw
623
+ * @param {any} options Transaction options
624
+ * @returns {Promise<any>} Transaction
625
+ */
626
+ async exitBalancerPool(
627
+ poolId: string,
628
+ assets: string[],
629
+ amount: string | BigNumber,
630
+ options: any = null
631
+ ): Promise<any> {
632
+ const exitPoolTxData = this.utils.getBalancerExitPoolTx(
633
+ this,
634
+ poolId,
635
+ assets,
636
+ amount
637
+ );
638
+ const tx = await this.poolLogic.execTransaction(
639
+ routerAddress[this.network][Dapp.BALANCER],
640
+ exitPoolTxData,
641
+ options
642
+ );
643
+ return tx;
644
+ }
645
+
646
+ /**
647
+ * Claim rewards from Balancer pools
648
+ * @param {string[]} assets Array of tokens being claimed
649
+ * @param {any} options Transaction options
650
+ * @returns {Promise<any>} Transaction
651
+ */
652
+ async harvestBalancerRewards(options: any = null): Promise<any> {
653
+ const claimService = new ClaimService(this.network, this.signer);
654
+ const multiTokenPendingClaims = await claimService.getMultiTokensPendingClaims(
655
+ this.address
656
+ );
657
+ const tokens = multiTokenPendingClaims.map(
658
+ tokenPendingClaims => tokenPendingClaims.tokenClaimInfo.token
659
+ );
660
+ const claims = await claimService.multiTokenClaimRewards(
661
+ this.address,
662
+ multiTokenPendingClaims
663
+ );
664
+ const iBalancerMerkleOrchard = new ethers.utils.Interface(
665
+ IBalancerMerkleOrchard.abi
666
+ );
667
+ const harvestTxData = iBalancerMerkleOrchard.encodeFunctionData(
668
+ Transaction.CLAIM_DISTRIBIUTIONS,
669
+ [this.address, claims, tokens]
670
+ );
671
+ const tx = await this.poolLogic.execTransaction(
672
+ stakingAddress[this.network][Dapp.BALANCER],
673
+ harvestTxData,
674
+ options
675
+ );
676
+ return tx;
677
+ }
678
+
679
+ /**
680
+ * Claim rewards from Aave platform
681
+ * @param {string[]} assets Aave tokens (deposit/debt) hold by pool
682
+ * @param {any} options Transaction options
683
+ * @returns {Promise<any>} Transaction
684
+ */
685
+ async harvestAaveRewards(
686
+ assets: string[],
687
+ options: any = null
688
+ ): Promise<any> {
689
+ const aaveIncentivesAddress = stakingAddress[this.network][
690
+ Dapp.AAVE
691
+ ] as string;
692
+ const iAaveIncentivesController = new ethers.utils.Interface(
693
+ IAaveIncentivesController.abi
694
+ );
695
+ const aaveIncentivesController = new ethers.Contract(
696
+ aaveIncentivesAddress,
697
+ iAaveIncentivesController,
698
+ this.signer
699
+ );
700
+ const amount = await aaveIncentivesController.getUserUnclaimedRewards(
701
+ this.address
702
+ );
703
+ const claimTxData = iAaveIncentivesController.encodeFunctionData(
704
+ Transaction.CLAIM_REWARDS,
705
+ [assets, amount, this.address]
706
+ );
707
+ const tx = await this.poolLogic.execTransaction(
708
+ aaveIncentivesAddress,
709
+ claimTxData,
710
+ options
711
+ );
712
+ return tx;
713
+ }
714
+
715
+ /**
716
+ * Create UniswapV3 liquidity pool
717
+ * @param {string} assetA First asset
718
+ * @param {string} assetB Second asset
719
+ * @param {BigNumber | string} amountA Amount first asset
720
+ * @param {BigNumber | string} amountB Amount second asset
721
+ * @param { number } minPrice Lower price range (assetB per assetA)
722
+ * @param { number } maxPrice Upper price range (assetB per assetA)
723
+ * @param { number } minTick Lower tick range
724
+ * @param { number } maxTick Upper tick range
725
+ * @param { FeeAmount } feeAmount Fee tier (Low 0.05%, Medium 0.3%, High 1%)
726
+ * @param {any} options Transaction options
727
+ * @returns {Promise<any>} Transaction
728
+ */
729
+ async addLiquidityUniswapV3(
730
+ assetA: string,
731
+ assetB: string,
732
+ amountA: BigNumber | string,
733
+ amountB: BigNumber | string,
734
+ minPrice: number | null,
735
+ maxPrice: number | null,
736
+ minTick: number | null,
737
+ maxTick: number | null,
738
+ feeAmount: FeeAmount,
739
+ options: any = null
740
+ ): Promise<any> {
741
+ if ((!minPrice || !maxPrice) && (!minTick || !maxTick))
742
+ throw new Error("Need to provide price or tick range");
743
+
744
+ const iNonfungiblePositionManager = new ethers.utils.Interface(
745
+ INonfungiblePositionManager.abi
746
+ );
747
+
748
+ const mintTxParams = await getUniswapV3MintParams(
749
+ this,
750
+ assetA,
751
+ assetB,
752
+ amountA,
753
+ amountB,
754
+ minPrice,
755
+ maxPrice,
756
+ minTick,
757
+ maxTick,
758
+ feeAmount
759
+ );
760
+ const mintTxData = iNonfungiblePositionManager.encodeFunctionData(
761
+ Transaction.MINT,
762
+ [mintTxParams]
763
+ );
764
+ const tx = await this.poolLogic.execTransaction(
765
+ nonfungiblePositionManagerAddress[this.network],
766
+ mintTxData,
767
+ options
768
+ );
769
+ return tx;
770
+ }
771
+
772
+ /**
773
+ * Remove liquidity from an UniswapV3 liquidity pool
774
+ * @param {string} tokenId Token Id of UniswapV3 position
775
+ * @param {number} amount Amount in percent of assets to be removed
776
+ * @param {any} options Transaction options
777
+ * @returns {Promise<any>} Transaction
778
+ */
779
+ async removeLiquidityUniswapV3(
780
+ tokenId: string,
781
+ amount = 100,
782
+ options: any = null
783
+ ): Promise<any> {
784
+ const iNonfungiblePositionManager = new ethers.utils.Interface(
785
+ INonfungiblePositionManager.abi
786
+ );
787
+ const liquidity = (await getUniswapV3Liquidity(tokenId, this))
788
+ .mul(amount)
789
+ .div(100);
790
+ const decreaseLiquidityTxData = iNonfungiblePositionManager.encodeFunctionData(
791
+ Transaction.DECREASE_LIQUIDITY,
792
+ [[tokenId, liquidity, 0, 0, deadline]]
793
+ );
794
+ const collectTxData = iNonfungiblePositionManager.encodeFunctionData(
795
+ Transaction.COLLECT,
796
+ [[tokenId, this.address, MaxUint128, MaxUint128]]
797
+ );
798
+
799
+ const multicallParams = [decreaseLiquidityTxData, collectTxData];
800
+
801
+ if (amount === 100) {
802
+ const burnTxData = iNonfungiblePositionManager.encodeFunctionData(
803
+ Transaction.BURN,
804
+ [tokenId]
805
+ );
806
+ multicallParams.push(burnTxData);
807
+ }
808
+ const multicallTxData = iNonfungiblePositionManager.encodeFunctionData(
809
+ Transaction.MULTI_CALL,
810
+ [multicallParams]
811
+ );
812
+ const tx = await this.poolLogic.execTransaction(
813
+ nonfungiblePositionManagerAddress[this.network],
814
+ multicallTxData,
815
+ options
816
+ );
817
+ return tx;
818
+ }
819
+
820
+ /**
821
+ * Increase liquidity of an UniswapV3 liquidity pool
822
+ * @param {string} tokenId Token Id of UniswapV3 position
823
+ * @param {BigNumber | string} amountA Amount first asset
824
+ * @param {BigNumber | string} amountB Amount second asset
825
+ * @param {any} options Transaction options
826
+ * @returns {Promise<any>} Transaction
827
+ */
828
+ async increaseLiquidityUniswapV3(
829
+ tokenId: string,
830
+ amountA: BigNumber | string,
831
+ amountB: BigNumber | string,
832
+ options: any = null
833
+ ): Promise<any> {
834
+ const iNonfungiblePositionManager = new ethers.utils.Interface(
835
+ INonfungiblePositionManager.abi
836
+ );
837
+ const increaseLiquidityTxData = iNonfungiblePositionManager.encodeFunctionData(
838
+ Transaction.INCREASE_LIQUIDITY,
839
+ [[tokenId, amountA, amountB, 0, 0, deadline]]
840
+ );
841
+ const tx = await this.poolLogic.execTransaction(
842
+ nonfungiblePositionManagerAddress[this.network],
843
+ increaseLiquidityTxData,
844
+ options
845
+ );
846
+ return tx;
847
+ }
848
+
849
+ /**
850
+ * Claim fees of an UniswapV3 liquidity pool
851
+ * @param {string} tokenId Token Id of UniswapV3 position
852
+ * @param {any} options Transaction options
853
+ * @returns {Promise<any>} Transaction
854
+ */
855
+ async claimFeesUniswapV3(tokenId: string, options: any = null): Promise<any> {
856
+ const iNonfungiblePositionManager = new ethers.utils.Interface(
857
+ INonfungiblePositionManager.abi
858
+ );
859
+ const collectTxData = iNonfungiblePositionManager.encodeFunctionData(
860
+ Transaction.COLLECT,
861
+ [[tokenId, this.address, MaxUint128, MaxUint128]]
862
+ );
863
+ const tx = await this.poolLogic.execTransaction(
864
+ nonfungiblePositionManagerAddress[this.network],
865
+ collectTxData,
866
+ options
867
+ );
868
+ return tx;
869
+ }
870
+
871
+ /**
872
+ * Trade an asset into another asset
873
+ * @param {Dapp} dapp Platform like Sushiswap or Uniswap
874
+ * @param {string} assetFrom Asset to trade from
875
+ * @param {string} assetTo Asset to trade into
876
+ * @param {BigNumber | string} amountIn Amount
877
+ * @param { FeeAmount } feeAmount Fee tier (Low 0.05%, Medium 0.3%, High 1%)
878
+ * @param {number} slippage Slippage tolerance in %
879
+ * @param {any} options Transaction options
880
+ * @returns {Promise<any>} Transaction
881
+ */
882
+ async tradeUniswapV3(
883
+ assetFrom: string,
884
+ assetTo: string,
885
+ amountIn: BigNumber | string,
886
+ feeAmount: FeeAmount,
887
+ slippage = 0.5,
888
+ options: any = null
889
+ ): Promise<any> {
890
+ const swapxData = await getUniswapV3SwapTxData(
891
+ this,
892
+ assetFrom,
893
+ assetTo,
894
+ amountIn,
895
+ slippage,
896
+ feeAmount
897
+ );
898
+ const tx = await this.poolLogic.execTransaction(
899
+ routerAddress[this.network][Dapp.UNISWAPV3],
900
+ swapxData,
901
+ options
902
+ );
903
+ return tx;
904
+ }
534
905
  }