@dhedge/v2-sdk 1.3.0 → 1.4.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.
@@ -9,7 +9,7 @@ var axios = _interopDefault(require('axios'));
9
9
  var lodash = require('lodash');
10
10
  var address = require('@ethersproject/address');
11
11
  require('lodash/set');
12
- var abi$g = require('@ethersproject/abi');
12
+ var abi$i = require('@ethersproject/abi');
13
13
  var BigNumber = _interopDefault(require('bignumber.js'));
14
14
  var web3Utils = require('web3-utils');
15
15
  var ethereumjsUtil = require('ethereumjs-util');
@@ -3838,6 +3838,8 @@ var ManagerLogic = {
3838
3838
  Dapp["BALANCER"] = "balancer";
3839
3839
  Dapp["UNISWAPV3"] = "uniswapV3";
3840
3840
  Dapp["SYNTHETIX"] = "synthetix";
3841
+ Dapp["AAVEV3"] = "aavev3";
3842
+ Dapp["ARRAKIS"] = "arrakis";
3841
3843
  })(exports.Dapp || (exports.Dapp = {}));
3842
3844
 
3843
3845
  (function (Transaction) {
@@ -3858,6 +3860,8 @@ var ManagerLogic = {
3858
3860
  Transaction["MINT"] = "mint";
3859
3861
  Transaction["BURN"] = "burn";
3860
3862
  Transaction["SWAP_SYNTHS"] = "exchangeWithTracking";
3863
+ Transaction["ADD_LIQUIDITY_STAKE"] = "addLiquidityAndStake";
3864
+ Transaction["REMOVE_LIQUIDITY_UNSTAKE"] = "removeLiquidityAndUnstake";
3861
3865
  })(exports.Transaction || (exports.Transaction = {}));
3862
3866
 
3863
3867
  var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _stakingAddress, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress;
@@ -3865,7 +3869,7 @@ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _routerAddress, _Netwo
3865
3869
  require("dotenv").config();
3866
3870
 
3867
3871
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress);
3868
- var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x1111111254fb6c44bac0bed2854e76f90643097d", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM), _routerAddress);
3872
+ var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x1111111254fb6c44bac0bed2854e76f90643097d", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xbc91a120cCD8F80b819EAF32F0996daC3Fa76a6C", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x1111111254760F7ab3F16433eea9304126DCd199", _Network$OPTIMISM), _routerAddress);
3869
3873
  var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[exports.Network.OPTIMISM] = {}, _dappFactoryAddress);
3870
3874
  var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[exports.Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[exports.Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3), _stakingAddress[exports.Network.OPTIMISM] = {}, _stakingAddress);
3871
3875
  var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM[exports.Network.OPTIMISM] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM);
@@ -7535,6 +7539,278 @@ var IAaveIncentivesController = {
7535
7539
  deployedLinkReferences: deployedLinkReferences
7536
7540
  };
7537
7541
 
7542
+ var abi$b = [
7543
+ {
7544
+ inputs: [
7545
+ {
7546
+ internalType: "address",
7547
+ name: "gauge",
7548
+ type: "address"
7549
+ },
7550
+ {
7551
+ internalType: "uint256",
7552
+ name: "amount0Max",
7553
+ type: "uint256"
7554
+ },
7555
+ {
7556
+ internalType: "uint256",
7557
+ name: "amount1Max",
7558
+ type: "uint256"
7559
+ },
7560
+ {
7561
+ internalType: "uint256",
7562
+ name: "amount0Min",
7563
+ type: "uint256"
7564
+ },
7565
+ {
7566
+ internalType: "uint256",
7567
+ name: "amount1Min",
7568
+ type: "uint256"
7569
+ },
7570
+ {
7571
+ internalType: "address",
7572
+ name: "receiver",
7573
+ type: "address"
7574
+ }
7575
+ ],
7576
+ name: "addLiquidityAndStake",
7577
+ outputs: [
7578
+ {
7579
+ internalType: "uint256",
7580
+ name: "amount0",
7581
+ type: "uint256"
7582
+ },
7583
+ {
7584
+ internalType: "uint256",
7585
+ name: "amount1",
7586
+ type: "uint256"
7587
+ },
7588
+ {
7589
+ internalType: "uint256",
7590
+ name: "mintAmount",
7591
+ type: "uint256"
7592
+ }
7593
+ ],
7594
+ stateMutability: "nonpayable",
7595
+ type: "function"
7596
+ },
7597
+ {
7598
+ inputs: [
7599
+ {
7600
+ internalType: "address",
7601
+ name: "gauge",
7602
+ type: "address"
7603
+ },
7604
+ {
7605
+ internalType: "uint256",
7606
+ name: "burnAmount",
7607
+ type: "uint256"
7608
+ },
7609
+ {
7610
+ internalType: "uint256",
7611
+ name: "amount0Min",
7612
+ type: "uint256"
7613
+ },
7614
+ {
7615
+ internalType: "uint256",
7616
+ name: "amount1Min",
7617
+ type: "uint256"
7618
+ },
7619
+ {
7620
+ internalType: "address",
7621
+ name: "receiver",
7622
+ type: "address"
7623
+ }
7624
+ ],
7625
+ name: "removeLiquidityAndUnstake",
7626
+ outputs: [
7627
+ {
7628
+ internalType: "uint256",
7629
+ name: "amount0",
7630
+ type: "uint256"
7631
+ },
7632
+ {
7633
+ internalType: "uint256",
7634
+ name: "amount1",
7635
+ type: "uint256"
7636
+ },
7637
+ {
7638
+ internalType: "uint128",
7639
+ name: "liquidityBurned",
7640
+ type: "uint128"
7641
+ }
7642
+ ],
7643
+ stateMutability: "nonpayable",
7644
+ type: "function"
7645
+ }
7646
+ ];
7647
+ var IArrakisV1RouterStaking = {
7648
+ abi: abi$b
7649
+ };
7650
+
7651
+ var abi$c = [
7652
+ {
7653
+ inputs: [
7654
+ {
7655
+ internalType: "address",
7656
+ name: "user",
7657
+ type: "address"
7658
+ }
7659
+ ],
7660
+ name: "claim_rewards",
7661
+ outputs: [
7662
+ ],
7663
+ stateMutability: "nonpayable",
7664
+ type: "function"
7665
+ },
7666
+ {
7667
+ inputs: [
7668
+ {
7669
+ internalType: "address",
7670
+ name: "user",
7671
+ type: "address"
7672
+ },
7673
+ {
7674
+ internalType: "address",
7675
+ name: "receiver",
7676
+ type: "address"
7677
+ }
7678
+ ],
7679
+ name: "claim_rewards",
7680
+ outputs: [
7681
+ ],
7682
+ stateMutability: "nonpayable",
7683
+ type: "function"
7684
+ },
7685
+ {
7686
+ inputs: [
7687
+ ],
7688
+ name: "claim_rewards",
7689
+ outputs: [
7690
+ ],
7691
+ stateMutability: "nonpayable",
7692
+ type: "function"
7693
+ },
7694
+ {
7695
+ inputs: [
7696
+ {
7697
+ internalType: "address",
7698
+ name: "user",
7699
+ type: "address"
7700
+ },
7701
+ {
7702
+ internalType: "address",
7703
+ name: "rewardToken",
7704
+ type: "address"
7705
+ }
7706
+ ],
7707
+ name: "claimable_reward",
7708
+ outputs: [
7709
+ {
7710
+ internalType: "uint256",
7711
+ name: "",
7712
+ type: "uint256"
7713
+ }
7714
+ ],
7715
+ stateMutability: "view",
7716
+ type: "function"
7717
+ },
7718
+ {
7719
+ inputs: [
7720
+ ],
7721
+ name: "reward_count",
7722
+ outputs: [
7723
+ {
7724
+ internalType: "uint256",
7725
+ name: "",
7726
+ type: "uint256"
7727
+ }
7728
+ ],
7729
+ stateMutability: "view",
7730
+ type: "function"
7731
+ },
7732
+ {
7733
+ inputs: [
7734
+ {
7735
+ internalType: "address",
7736
+ name: "token",
7737
+ type: "address"
7738
+ }
7739
+ ],
7740
+ name: "reward_data",
7741
+ outputs: [
7742
+ {
7743
+ internalType: "address",
7744
+ name: "",
7745
+ type: "address"
7746
+ },
7747
+ {
7748
+ internalType: "address",
7749
+ name: "",
7750
+ type: "address"
7751
+ },
7752
+ {
7753
+ internalType: "uint256",
7754
+ name: "",
7755
+ type: "uint256"
7756
+ },
7757
+ {
7758
+ internalType: "uint256",
7759
+ name: "",
7760
+ type: "uint256"
7761
+ },
7762
+ {
7763
+ internalType: "uint256",
7764
+ name: "",
7765
+ type: "uint256"
7766
+ },
7767
+ {
7768
+ internalType: "uint256",
7769
+ name: "",
7770
+ type: "uint256"
7771
+ }
7772
+ ],
7773
+ stateMutability: "view",
7774
+ type: "function"
7775
+ },
7776
+ {
7777
+ inputs: [
7778
+ {
7779
+ internalType: "uint256",
7780
+ name: "index",
7781
+ type: "uint256"
7782
+ }
7783
+ ],
7784
+ name: "reward_tokens",
7785
+ outputs: [
7786
+ {
7787
+ internalType: "address",
7788
+ name: "",
7789
+ type: "address"
7790
+ }
7791
+ ],
7792
+ stateMutability: "view",
7793
+ type: "function"
7794
+ },
7795
+ {
7796
+ inputs: [
7797
+ ],
7798
+ name: "staking_token",
7799
+ outputs: [
7800
+ {
7801
+ internalType: "address",
7802
+ name: "",
7803
+ type: "address"
7804
+ }
7805
+ ],
7806
+ stateMutability: "view",
7807
+ type: "function"
7808
+ }
7809
+ ];
7810
+ var ILiquidityGaugeV4 = {
7811
+ abi: abi$c
7812
+ };
7813
+
7538
7814
  function multicall(_x5, _x6, _x7, _x8, _x9, _x10) {
7539
7815
  return _multicall.apply(this, arguments);
7540
7816
  }
@@ -7555,7 +7831,7 @@ function _multicall() {
7555
7831
  }
7556
7832
 
7557
7833
  multi = new ethers.ethers.Contract(multiCallAddress[network], ["function tryAggregate(bool requireSuccess, tuple(address, bytes)[] memory calls) public view returns (tuple(bool, bytes)[] memory returnData)"], provider);
7558
- itf = new abi$g.Interface(abi);
7834
+ itf = new abi$i.Interface(abi);
7559
7835
  _context3.prev = 4;
7560
7836
  _context3.next = 7;
7561
7837
  return multi.tryAggregate( // if false, allows individual calls to fail without causing entire multicall to fail
@@ -8338,7 +8614,7 @@ function _getUniswapV3Liquidity() {
8338
8614
  return _getUniswapV3Liquidity.apply(this, arguments);
8339
8615
  }
8340
8616
 
8341
- var abi$b = [
8617
+ var abi$d = [
8342
8618
  {
8343
8619
  inputs: [
8344
8620
  {
@@ -8559,10 +8835,10 @@ var abi$b = [
8559
8835
  }
8560
8836
  ];
8561
8837
  var IUniswapV3Router = {
8562
- abi: abi$b
8838
+ abi: abi$d
8563
8839
  };
8564
8840
 
8565
- var abi$c = [
8841
+ var abi$e = [
8566
8842
  {
8567
8843
  inputs: [
8568
8844
  {
@@ -8759,7 +9035,7 @@ var abi$c = [
8759
9035
  }
8760
9036
  ];
8761
9037
  var IUniswapV3Quoter = {
8762
- abi: abi$c
9038
+ abi: abi$e
8763
9039
  };
8764
9040
 
8765
9041
  function getUniswapV3SwapTxData(_x, _x2, _x3, _x4, _x5, _x6) {
@@ -9138,7 +9414,7 @@ var Pool = /*#__PURE__*/function () {
9138
9414
  /*#__PURE__*/
9139
9415
  function () {
9140
9416
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(dapp, assetFrom, assetTo, amountIn, slippage, options) {
9141
- var swapTxData, apiUrl, response, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
9417
+ var swapTxData, chainId, apiUrl, response, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
9142
9418
  return runtime_1.wrap(function _callee8$(_context8) {
9143
9419
  while (1) {
9144
9420
  switch (_context8.prev = _context8.next) {
@@ -9152,37 +9428,38 @@ var Pool = /*#__PURE__*/function () {
9152
9428
  }
9153
9429
 
9154
9430
  if (!(dapp === exports.Dapp.ONEINCH)) {
9155
- _context8.next = 10;
9431
+ _context8.next = 11;
9156
9432
  break;
9157
9433
  }
9158
9434
 
9159
- apiUrl = "https://api.1inch.exchange/v4.0/137/swap?fromTokenAddress=" + assetFrom + "&toTokenAddress=" + assetTo + "&amount=" + amountIn.toString() + "&fromAddress=" + this.address + "&destReceiver=" + this.address + "&slippage=" + slippage.toString() + "&disableEstimate=true";
9160
- _context8.next = 6;
9435
+ chainId = networkChainIdMap[this.network];
9436
+ apiUrl = "https://api.1inch.exchange/v4.0/" + chainId + "/swap?fromTokenAddress=" + assetFrom + "&toTokenAddress=" + assetTo + "&amount=" + amountIn.toString() + "&fromAddress=" + this.address + "&destReceiver=" + this.address + "&slippage=" + slippage.toString() + "&disableEstimate=true";
9437
+ _context8.next = 7;
9161
9438
  return axios.get(apiUrl);
9162
9439
 
9163
- case 6:
9440
+ case 7:
9164
9441
  response = _context8.sent;
9165
9442
  swapTxData = response.data.tx.data;
9166
- _context8.next = 30;
9443
+ _context8.next = 31;
9167
9444
  break;
9168
9445
 
9169
- case 10:
9446
+ case 11:
9170
9447
  if (!(dapp === exports.Dapp.BALANCER)) {
9171
- _context8.next = 16;
9448
+ _context8.next = 17;
9172
9449
  break;
9173
9450
  }
9174
9451
 
9175
- _context8.next = 13;
9452
+ _context8.next = 14;
9176
9453
  return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
9177
9454
 
9178
- case 13:
9455
+ case 14:
9179
9456
  swapTxData = _context8.sent;
9180
- _context8.next = 30;
9457
+ _context8.next = 31;
9181
9458
  break;
9182
9459
 
9183
- case 16:
9460
+ case 17:
9184
9461
  if (!(dapp === exports.Dapp.SYNTHETIX)) {
9185
- _context8.next = 25;
9462
+ _context8.next = 26;
9186
9463
  break;
9187
9464
  }
9188
9465
 
@@ -9190,33 +9467,33 @@ var Pool = /*#__PURE__*/function () {
9190
9467
  assets = [assetFrom, assetTo].map(function (asset) {
9191
9468
  return ethers.ethers.utils.formatBytes32String(asset);
9192
9469
  });
9193
- _context8.next = 21;
9470
+ _context8.next = 22;
9194
9471
  return this.factory.owner();
9195
9472
 
9196
- case 21:
9473
+ case 22:
9197
9474
  daoAddress = _context8.sent;
9198
9475
  swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
9199
- _context8.next = 30;
9476
+ _context8.next = 31;
9200
9477
  break;
9201
9478
 
9202
- case 25:
9479
+ case 26:
9203
9480
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
9204
- _context8.next = 28;
9481
+ _context8.next = 29;
9205
9482
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
9206
9483
 
9207
- case 28:
9484
+ case 29:
9208
9485
  minAmountOut = _context8.sent;
9209
9486
  swapTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.SWAP, [amountIn, minAmountOut, [assetFrom, assetTo], this.address, deadline]);
9210
9487
 
9211
- case 30:
9212
- _context8.next = 32;
9488
+ case 31:
9489
+ _context8.next = 33;
9213
9490
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], swapTxData, options);
9214
9491
 
9215
- case 32:
9492
+ case 33:
9216
9493
  tx = _context8.sent;
9217
9494
  return _context8.abrupt("return", tx);
9218
9495
 
9219
- case 34:
9496
+ case 35:
9220
9497
  case "end":
9221
9498
  return _context8.stop();
9222
9499
  }
@@ -10037,7 +10314,8 @@ var Pool = /*#__PURE__*/function () {
10037
10314
  return addLiquidityUniswapV3;
10038
10315
  }()
10039
10316
  /**
10040
- * Remove liquidity from an UniswapV3 liquidity pool
10317
+ * Remove liquidity from an UniswapV3 or Arrakis liquidity pool
10318
+ * @param {Dapp} dapp Platform either UniswapV3 or Arrakis
10041
10319
  * @param {string} tokenId Token Id of UniswapV3 position
10042
10320
  * @param {number} amount Amount in percent of assets to be removed
10043
10321
  * @param {any} options Transaction options
@@ -10045,11 +10323,12 @@ var Pool = /*#__PURE__*/function () {
10045
10323
  */
10046
10324
  ;
10047
10325
 
10048
- _proto.removeLiquidityUniswapV3 =
10326
+ _proto.decreaseLiquidity =
10049
10327
  /*#__PURE__*/
10050
10328
  function () {
10051
- var _removeLiquidityUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee25(tokenId, amount, options) {
10052
- var iNonfungiblePositionManager, liquidity, decreaseLiquidityTxData, collectTxData, multicallParams, burnTxData, multicallTxData, tx;
10329
+ var _decreaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee25(dapp, tokenId, amount, options) {
10330
+ var txData, dappAddress, abi, liquidity, decreaseLiquidityTxData, collectTxData, multicallParams, burnTxData, _abi, _liquidity, tx;
10331
+
10053
10332
  return runtime_1.wrap(function _callee25$(_context25) {
10054
10333
  while (1) {
10055
10334
  switch (_context25.prev = _context25.next) {
@@ -10062,30 +10341,60 @@ var Pool = /*#__PURE__*/function () {
10062
10341
  options = null;
10063
10342
  }
10064
10343
 
10065
- iNonfungiblePositionManager = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10066
- _context25.next = 5;
10344
+ if (!(dapp === exports.Dapp.UNISWAPV3)) {
10345
+ _context25.next = 15;
10346
+ break;
10347
+ }
10348
+
10349
+ dappAddress = nonfungiblePositionManagerAddress[this.network];
10350
+ abi = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10351
+ _context25.next = 7;
10067
10352
  return getUniswapV3Liquidity(tokenId, this);
10068
10353
 
10069
- case 5:
10354
+ case 7:
10070
10355
  liquidity = _context25.sent.mul(amount).div(100);
10071
- decreaseLiquidityTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.DECREASE_LIQUIDITY, [[tokenId, liquidity, 0, 0, deadline]]);
10072
- collectTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10356
+ decreaseLiquidityTxData = abi.encodeFunctionData(exports.Transaction.DECREASE_LIQUIDITY, [[tokenId, liquidity, 0, 0, deadline]]);
10357
+ collectTxData = abi.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10073
10358
  multicallParams = [decreaseLiquidityTxData, collectTxData];
10074
10359
 
10075
10360
  if (amount === 100) {
10076
- burnTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.BURN, [tokenId]);
10361
+ burnTxData = abi.encodeFunctionData(exports.Transaction.BURN, [tokenId]);
10077
10362
  multicallParams.push(burnTxData);
10078
10363
  }
10079
10364
 
10080
- multicallTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.MULTI_CALL, [multicallParams]);
10081
- _context25.next = 13;
10082
- return this.poolLogic.execTransaction(nonfungiblePositionManagerAddress[this.network], multicallTxData, options);
10365
+ txData = abi.encodeFunctionData(exports.Transaction.MULTI_CALL, [multicallParams]);
10366
+ _context25.next = 25;
10367
+ break;
10083
10368
 
10084
- case 13:
10369
+ case 15:
10370
+ if (!(dapp === exports.Dapp.ARRAKIS)) {
10371
+ _context25.next = 24;
10372
+ break;
10373
+ }
10374
+
10375
+ dappAddress = routerAddress[this.network][dapp];
10376
+ _abi = new ethers.ethers.utils.Interface(IArrakisV1RouterStaking.abi);
10377
+ _context25.next = 20;
10378
+ return this.utils.getBalance(tokenId, this.address);
10379
+
10380
+ case 20:
10381
+ _liquidity = _context25.sent.mul(amount).div(100);
10382
+ txData = _abi.encodeFunctionData(exports.Transaction.REMOVE_LIQUIDITY_UNSTAKE, [tokenId, _liquidity, 0, 0, this.address]);
10383
+ _context25.next = 25;
10384
+ break;
10385
+
10386
+ case 24:
10387
+ throw new Error("dapp not supported");
10388
+
10389
+ case 25:
10390
+ _context25.next = 27;
10391
+ return this.poolLogic.execTransaction(dappAddress, txData, options);
10392
+
10393
+ case 27:
10085
10394
  tx = _context25.sent;
10086
10395
  return _context25.abrupt("return", tx);
10087
10396
 
10088
- case 15:
10397
+ case 29:
10089
10398
  case "end":
10090
10399
  return _context25.stop();
10091
10400
  }
@@ -10093,14 +10402,15 @@ var Pool = /*#__PURE__*/function () {
10093
10402
  }, _callee25, this);
10094
10403
  }));
10095
10404
 
10096
- function removeLiquidityUniswapV3(_x91, _x92, _x93) {
10097
- return _removeLiquidityUniswapV.apply(this, arguments);
10405
+ function decreaseLiquidity(_x91, _x92, _x93, _x94) {
10406
+ return _decreaseLiquidity.apply(this, arguments);
10098
10407
  }
10099
10408
 
10100
- return removeLiquidityUniswapV3;
10409
+ return decreaseLiquidity;
10101
10410
  }()
10102
10411
  /**
10103
- * Increase liquidity of an UniswapV3 liquidity pool
10412
+ * Increase liquidity of an UniswapV3 or Arrakis liquidity pool
10413
+ * @param {Dapp} dapp Platform either UniswapV3 or Arrakis
10104
10414
  * @param {string} tokenId Token Id of UniswapV3 position
10105
10415
  * @param {BigNumber | string} amountA Amount first asset
10106
10416
  * @param {BigNumber | string} amountB Amount second asset
@@ -10109,11 +10419,12 @@ var Pool = /*#__PURE__*/function () {
10109
10419
  */
10110
10420
  ;
10111
10421
 
10112
- _proto.increaseLiquidityUniswapV3 =
10422
+ _proto.increaseLiquidity =
10113
10423
  /*#__PURE__*/
10114
10424
  function () {
10115
- var _increaseLiquidityUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26(tokenId, amountA, amountB, options) {
10116
- var iNonfungiblePositionManager, increaseLiquidityTxData, tx;
10425
+ var _increaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26(dapp, tokenId, amountA, amountB, options) {
10426
+ var txData, dappAddress, abi, _abi2, tx;
10427
+
10117
10428
  return runtime_1.wrap(function _callee26$(_context26) {
10118
10429
  while (1) {
10119
10430
  switch (_context26.prev = _context26.next) {
@@ -10122,16 +10433,41 @@ var Pool = /*#__PURE__*/function () {
10122
10433
  options = null;
10123
10434
  }
10124
10435
 
10125
- iNonfungiblePositionManager = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10126
- increaseLiquidityTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.INCREASE_LIQUIDITY, [[tokenId, amountA, amountB, 0, 0, deadline]]);
10127
- _context26.next = 5;
10128
- return this.poolLogic.execTransaction(nonfungiblePositionManagerAddress[this.network], increaseLiquidityTxData, options);
10436
+ if (!(dapp === exports.Dapp.UNISWAPV3)) {
10437
+ _context26.next = 7;
10438
+ break;
10439
+ }
10129
10440
 
10130
- case 5:
10441
+ dappAddress = nonfungiblePositionManagerAddress[this.network];
10442
+ abi = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10443
+ txData = abi.encodeFunctionData(exports.Transaction.INCREASE_LIQUIDITY, [[tokenId, amountA, amountB, 0, 0, deadline]]);
10444
+ _context26.next = 14;
10445
+ break;
10446
+
10447
+ case 7:
10448
+ if (!(dapp === exports.Dapp.ARRAKIS)) {
10449
+ _context26.next = 13;
10450
+ break;
10451
+ }
10452
+
10453
+ dappAddress = routerAddress[this.network][dapp];
10454
+ _abi2 = new ethers.ethers.utils.Interface(IArrakisV1RouterStaking.abi);
10455
+ txData = _abi2.encodeFunctionData(exports.Transaction.ADD_LIQUIDITY_STAKE, [tokenId, amountA, amountB, 0, 0, this.address]);
10456
+ _context26.next = 14;
10457
+ break;
10458
+
10459
+ case 13:
10460
+ throw new Error("dapp not supported");
10461
+
10462
+ case 14:
10463
+ _context26.next = 16;
10464
+ return this.poolLogic.execTransaction(dappAddress, txData, options);
10465
+
10466
+ case 16:
10131
10467
  tx = _context26.sent;
10132
10468
  return _context26.abrupt("return", tx);
10133
10469
 
10134
- case 7:
10470
+ case 18:
10135
10471
  case "end":
10136
10472
  return _context26.stop();
10137
10473
  }
@@ -10139,25 +10475,26 @@ var Pool = /*#__PURE__*/function () {
10139
10475
  }, _callee26, this);
10140
10476
  }));
10141
10477
 
10142
- function increaseLiquidityUniswapV3(_x94, _x95, _x96, _x97) {
10143
- return _increaseLiquidityUniswapV.apply(this, arguments);
10478
+ function increaseLiquidity(_x95, _x96, _x97, _x98, _x99) {
10479
+ return _increaseLiquidity.apply(this, arguments);
10144
10480
  }
10145
10481
 
10146
- return increaseLiquidityUniswapV3;
10482
+ return increaseLiquidity;
10147
10483
  }()
10148
10484
  /**
10149
- * Claim fees of an UniswapV3 liquidity pool
10150
- * @param {string} tokenId Token Id of UniswapV3 position
10485
+ * Claim fees of an UniswapV3 liquidity or Arrakis pool
10486
+ * @param {Dapp} dapp Platform either UniswapV3 or Arrakis
10487
+ * @param {string} tokenId Token Id of UniswapV3 or Arrakis position
10151
10488
  * @param {any} options Transaction options
10152
10489
  * @returns {Promise<any>} Transaction
10153
10490
  */
10154
10491
  ;
10155
10492
 
10156
- _proto.claimFeesUniswapV3 =
10493
+ _proto.claimFees =
10157
10494
  /*#__PURE__*/
10158
10495
  function () {
10159
- var _claimFeesUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27(tokenId, options) {
10160
- var iNonfungiblePositionManager, collectTxData, tx;
10496
+ var _claimFees = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27(dapp, tokenId, options) {
10497
+ var txData, contractAddress, iNonfungiblePositionManager, abi, tx;
10161
10498
  return runtime_1.wrap(function _callee27$(_context27) {
10162
10499
  while (1) {
10163
10500
  switch (_context27.prev = _context27.next) {
@@ -10166,16 +10503,41 @@ var Pool = /*#__PURE__*/function () {
10166
10503
  options = null;
10167
10504
  }
10168
10505
 
10506
+ if (!(dapp === exports.Dapp.UNISWAPV3)) {
10507
+ _context27.next = 7;
10508
+ break;
10509
+ }
10510
+
10511
+ contractAddress = nonfungiblePositionManagerAddress[this.network];
10169
10512
  iNonfungiblePositionManager = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10170
- collectTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10171
- _context27.next = 5;
10172
- return this.poolLogic.execTransaction(nonfungiblePositionManagerAddress[this.network], collectTxData, options);
10513
+ txData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10514
+ _context27.next = 14;
10515
+ break;
10173
10516
 
10174
- case 5:
10517
+ case 7:
10518
+ if (!(dapp === exports.Dapp.ARRAKIS)) {
10519
+ _context27.next = 13;
10520
+ break;
10521
+ }
10522
+
10523
+ contractAddress = tokenId;
10524
+ abi = new ethers.ethers.utils.Interface(ILiquidityGaugeV4.abi);
10525
+ txData = abi.encodeFunctionData("claim_rewards()", []);
10526
+ _context27.next = 14;
10527
+ break;
10528
+
10529
+ case 13:
10530
+ throw new Error("dapp not supported");
10531
+
10532
+ case 14:
10533
+ _context27.next = 16;
10534
+ return this.poolLogic.execTransaction(contractAddress, txData, options);
10535
+
10536
+ case 16:
10175
10537
  tx = _context27.sent;
10176
10538
  return _context27.abrupt("return", tx);
10177
10539
 
10178
- case 7:
10540
+ case 18:
10179
10541
  case "end":
10180
10542
  return _context27.stop();
10181
10543
  }
@@ -10183,11 +10545,11 @@ var Pool = /*#__PURE__*/function () {
10183
10545
  }, _callee27, this);
10184
10546
  }));
10185
10547
 
10186
- function claimFeesUniswapV3(_x98, _x99) {
10187
- return _claimFeesUniswapV.apply(this, arguments);
10548
+ function claimFees(_x100, _x101, _x102) {
10549
+ return _claimFees.apply(this, arguments);
10188
10550
  }
10189
10551
 
10190
- return claimFeesUniswapV3;
10552
+ return claimFees;
10191
10553
  }()
10192
10554
  /**
10193
10555
  * Trade an asset into another asset
@@ -10239,7 +10601,7 @@ var Pool = /*#__PURE__*/function () {
10239
10601
  }, _callee28, this);
10240
10602
  }));
10241
10603
 
10242
- function tradeUniswapV3(_x100, _x101, _x102, _x103, _x104, _x105) {
10604
+ function tradeUniswapV3(_x103, _x104, _x105, _x106, _x107, _x108) {
10243
10605
  return _tradeUniswapV.apply(this, arguments);
10244
10606
  }
10245
10607
 
@@ -10249,7 +10611,7 @@ var Pool = /*#__PURE__*/function () {
10249
10611
  return Pool;
10250
10612
  }();
10251
10613
 
10252
- var abi$d = [
10614
+ var abi$f = [
10253
10615
  {
10254
10616
  inputs: [
10255
10617
  {
@@ -10473,10 +10835,10 @@ var abi$d = [
10473
10835
  }
10474
10836
  ];
10475
10837
  var UniswapV2Factory = {
10476
- abi: abi$d
10838
+ abi: abi$f
10477
10839
  };
10478
10840
 
10479
- var abi$e = [
10841
+ var abi$g = [
10480
10842
  {
10481
10843
  anonymous: false,
10482
10844
  inputs: [
@@ -11220,7 +11582,7 @@ var evm = {
11220
11582
  }
11221
11583
  };
11222
11584
  var UniswapV2Pair = {
11223
- abi: abi$e,
11585
+ abi: abi$g,
11224
11586
  evm: evm,
11225
11587
  "interface": [
11226
11588
  {
@@ -11951,7 +12313,7 @@ var UniswapV2Pair = {
11951
12313
  ]
11952
12314
  };
11953
12315
 
11954
- var abi$f = [
12316
+ var abi$h = [
11955
12317
  {
11956
12318
  inputs: [
11957
12319
  {
@@ -13146,7 +13508,7 @@ var abi$f = [
13146
13508
  }
13147
13509
  ];
13148
13510
  var IBalancerV2Vault = {
13149
- abi: abi$f
13511
+ abi: abi$h
13150
13512
  };
13151
13513
 
13152
13514
  var Utils = /*#__PURE__*/function () {