@dhedge/v2-sdk 1.4.0 → 1.4.3

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$i = require('@ethersproject/abi');
12
+ var abi$j = 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');
@@ -7811,6 +7811,258 @@ var ILiquidityGaugeV4 = {
7811
7811
  abi: abi$c
7812
7812
  };
7813
7813
 
7814
+ var abi$d = [
7815
+ {
7816
+ inputs: [
7817
+ {
7818
+ internalType: "address",
7819
+ name: "user",
7820
+ type: "address"
7821
+ }
7822
+ ],
7823
+ name: "balanceOf",
7824
+ outputs: [
7825
+ {
7826
+ internalType: "uint256",
7827
+ name: "",
7828
+ type: "uint256"
7829
+ }
7830
+ ],
7831
+ stateMutability: "view",
7832
+ type: "function"
7833
+ },
7834
+ {
7835
+ inputs: [
7836
+ {
7837
+ internalType: "address",
7838
+ name: "user",
7839
+ type: "address"
7840
+ }
7841
+ ],
7842
+ name: "claim_rewards",
7843
+ outputs: [
7844
+ ],
7845
+ stateMutability: "nonpayable",
7846
+ type: "function"
7847
+ },
7848
+ {
7849
+ inputs: [
7850
+ {
7851
+ internalType: "address",
7852
+ name: "user",
7853
+ type: "address"
7854
+ },
7855
+ {
7856
+ internalType: "address",
7857
+ name: "receiver",
7858
+ type: "address"
7859
+ }
7860
+ ],
7861
+ name: "claim_rewards",
7862
+ outputs: [
7863
+ ],
7864
+ stateMutability: "nonpayable",
7865
+ type: "function"
7866
+ },
7867
+ {
7868
+ inputs: [
7869
+ ],
7870
+ name: "claim_rewards",
7871
+ outputs: [
7872
+ ],
7873
+ stateMutability: "nonpayable",
7874
+ type: "function"
7875
+ },
7876
+ {
7877
+ inputs: [
7878
+ {
7879
+ internalType: "address",
7880
+ name: "user",
7881
+ type: "address"
7882
+ },
7883
+ {
7884
+ internalType: "address",
7885
+ name: "rewardToken",
7886
+ type: "address"
7887
+ }
7888
+ ],
7889
+ name: "claimable_reward",
7890
+ outputs: [
7891
+ {
7892
+ internalType: "uint256",
7893
+ name: "",
7894
+ type: "uint256"
7895
+ }
7896
+ ],
7897
+ stateMutability: "view",
7898
+ type: "function"
7899
+ },
7900
+ {
7901
+ inputs: [
7902
+ {
7903
+ internalType: "address",
7904
+ name: "user",
7905
+ type: "address"
7906
+ },
7907
+ {
7908
+ internalType: "address",
7909
+ name: "rewardToken",
7910
+ type: "address"
7911
+ }
7912
+ ],
7913
+ name: "claimable_reward_write",
7914
+ outputs: [
7915
+ {
7916
+ internalType: "uint256",
7917
+ name: "",
7918
+ type: "uint256"
7919
+ }
7920
+ ],
7921
+ stateMutability: "nonpayable",
7922
+ type: "function"
7923
+ },
7924
+ {
7925
+ inputs: [
7926
+ {
7927
+ internalType: "uint256",
7928
+ name: "amount",
7929
+ type: "uint256"
7930
+ },
7931
+ {
7932
+ internalType: "address",
7933
+ name: "user",
7934
+ type: "address"
7935
+ }
7936
+ ],
7937
+ name: "deposit",
7938
+ outputs: [
7939
+ ],
7940
+ stateMutability: "nonpayable",
7941
+ type: "function"
7942
+ },
7943
+ {
7944
+ inputs: [
7945
+ {
7946
+ internalType: "uint256",
7947
+ name: "amount",
7948
+ type: "uint256"
7949
+ },
7950
+ {
7951
+ internalType: "address",
7952
+ name: "onBehalf",
7953
+ type: "address"
7954
+ },
7955
+ {
7956
+ internalType: "bool",
7957
+ name: "isClaimRewards",
7958
+ type: "bool"
7959
+ }
7960
+ ],
7961
+ name: "deposit",
7962
+ outputs: [
7963
+ ],
7964
+ stateMutability: "nonpayable",
7965
+ type: "function"
7966
+ },
7967
+ {
7968
+ inputs: [
7969
+ {
7970
+ internalType: "uint256",
7971
+ name: "amount",
7972
+ type: "uint256"
7973
+ }
7974
+ ],
7975
+ name: "deposit",
7976
+ outputs: [
7977
+ ],
7978
+ stateMutability: "nonpayable",
7979
+ type: "function"
7980
+ },
7981
+ {
7982
+ inputs: [
7983
+ ],
7984
+ name: "lp_token",
7985
+ outputs: [
7986
+ {
7987
+ internalType: "address",
7988
+ name: "",
7989
+ type: "address"
7990
+ }
7991
+ ],
7992
+ stateMutability: "view",
7993
+ type: "function"
7994
+ },
7995
+ {
7996
+ inputs: [
7997
+ ],
7998
+ name: "reward_contract",
7999
+ outputs: [
8000
+ {
8001
+ internalType: "address",
8002
+ name: "",
8003
+ type: "address"
8004
+ }
8005
+ ],
8006
+ stateMutability: "view",
8007
+ type: "function"
8008
+ },
8009
+ {
8010
+ inputs: [
8011
+ {
8012
+ internalType: "uint256",
8013
+ name: "index",
8014
+ type: "uint256"
8015
+ }
8016
+ ],
8017
+ name: "reward_tokens",
8018
+ outputs: [
8019
+ {
8020
+ internalType: "address",
8021
+ name: "",
8022
+ type: "address"
8023
+ }
8024
+ ],
8025
+ stateMutability: "view",
8026
+ type: "function"
8027
+ },
8028
+ {
8029
+ inputs: [
8030
+ {
8031
+ internalType: "uint256",
8032
+ name: "amount",
8033
+ type: "uint256"
8034
+ }
8035
+ ],
8036
+ name: "withdraw",
8037
+ outputs: [
8038
+ ],
8039
+ stateMutability: "nonpayable",
8040
+ type: "function"
8041
+ },
8042
+ {
8043
+ inputs: [
8044
+ {
8045
+ internalType: "uint256",
8046
+ name: "amount",
8047
+ type: "uint256"
8048
+ },
8049
+ {
8050
+ internalType: "bool",
8051
+ name: "isClaimRewards",
8052
+ type: "bool"
8053
+ }
8054
+ ],
8055
+ name: "withdraw",
8056
+ outputs: [
8057
+ ],
8058
+ stateMutability: "nonpayable",
8059
+ type: "function"
8060
+ }
8061
+ ];
8062
+ var IBalancerRewardsGauge = {
8063
+ abi: abi$d
8064
+ };
8065
+
7814
8066
  function multicall(_x5, _x6, _x7, _x8, _x9, _x10) {
7815
8067
  return _multicall.apply(this, arguments);
7816
8068
  }
@@ -7831,7 +8083,7 @@ function _multicall() {
7831
8083
  }
7832
8084
 
7833
8085
  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);
7834
- itf = new abi$i.Interface(abi);
8086
+ itf = new abi$j.Interface(abi);
7835
8087
  _context3.prev = 4;
7836
8088
  _context3.next = 7;
7837
8089
  return multi.tryAggregate( // if false, allows individual calls to fail without causing entire multicall to fail
@@ -8614,7 +8866,7 @@ function _getUniswapV3Liquidity() {
8614
8866
  return _getUniswapV3Liquidity.apply(this, arguments);
8615
8867
  }
8616
8868
 
8617
- var abi$d = [
8869
+ var abi$e = [
8618
8870
  {
8619
8871
  inputs: [
8620
8872
  {
@@ -8835,10 +9087,10 @@ var abi$d = [
8835
9087
  }
8836
9088
  ];
8837
9089
  var IUniswapV3Router = {
8838
- abi: abi$d
9090
+ abi: abi$e
8839
9091
  };
8840
9092
 
8841
- var abi$e = [
9093
+ var abi$f = [
8842
9094
  {
8843
9095
  inputs: [
8844
9096
  {
@@ -9035,7 +9287,7 @@ var abi$e = [
9035
9287
  }
9036
9288
  ];
9037
9289
  var IUniswapV3Quoter = {
9038
- abi: abi$e
9290
+ abi: abi$f
9039
9291
  };
9040
9292
 
9041
9293
  function getUniswapV3SwapTxData(_x, _x2, _x3, _x4, _x5, _x6) {
@@ -9398,6 +9650,52 @@ var Pool = /*#__PURE__*/function () {
9398
9650
 
9399
9651
  return approveUniswapV3Liquidity;
9400
9652
  }()
9653
+ /**
9654
+ * Approve the asset for provided spender address
9655
+ * @param {string} spender Spender address
9656
+ * @param {string} asset Address of asset
9657
+ * @param {BigNumber | string} amount to be approved
9658
+ * @param {any} options Transaction options
9659
+ * @returns {Promise<any>} Transaction
9660
+ */
9661
+ ;
9662
+
9663
+ _proto.approveSpender =
9664
+ /*#__PURE__*/
9665
+ function () {
9666
+ var _approveSpender = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(spender, asset, amount, options) {
9667
+ var iERC20, approveTxData, tx;
9668
+ return runtime_1.wrap(function _callee8$(_context8) {
9669
+ while (1) {
9670
+ switch (_context8.prev = _context8.next) {
9671
+ case 0:
9672
+ if (options === void 0) {
9673
+ options = null;
9674
+ }
9675
+
9676
+ iERC20 = new ethers.ethers.utils.Interface(IERC20.abi);
9677
+ approveTxData = iERC20.encodeFunctionData("approve", [spender, amount]);
9678
+ _context8.next = 5;
9679
+ return this.poolLogic.execTransaction(asset, approveTxData, options);
9680
+
9681
+ case 5:
9682
+ tx = _context8.sent;
9683
+ return _context8.abrupt("return", tx);
9684
+
9685
+ case 7:
9686
+ case "end":
9687
+ return _context8.stop();
9688
+ }
9689
+ }
9690
+ }, _callee8, this);
9691
+ }));
9692
+
9693
+ function approveSpender(_x20, _x21, _x22, _x23) {
9694
+ return _approveSpender.apply(this, arguments);
9695
+ }
9696
+
9697
+ return approveSpender;
9698
+ }()
9401
9699
  /**
9402
9700
  * Trade an asset into another asset
9403
9701
  * @param {Dapp} dapp Platform like Sushiswap or Uniswap
@@ -9413,11 +9711,11 @@ var Pool = /*#__PURE__*/function () {
9413
9711
  _proto.trade =
9414
9712
  /*#__PURE__*/
9415
9713
  function () {
9416
- var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(dapp, assetFrom, assetTo, amountIn, slippage, options) {
9714
+ var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(dapp, assetFrom, assetTo, amountIn, slippage, options) {
9417
9715
  var swapTxData, chainId, apiUrl, response, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
9418
- return runtime_1.wrap(function _callee8$(_context8) {
9716
+ return runtime_1.wrap(function _callee9$(_context9) {
9419
9717
  while (1) {
9420
- switch (_context8.prev = _context8.next) {
9718
+ switch (_context9.prev = _context9.next) {
9421
9719
  case 0:
9422
9720
  if (slippage === void 0) {
9423
9721
  slippage = 0.5;
@@ -9428,38 +9726,38 @@ var Pool = /*#__PURE__*/function () {
9428
9726
  }
9429
9727
 
9430
9728
  if (!(dapp === exports.Dapp.ONEINCH)) {
9431
- _context8.next = 11;
9729
+ _context9.next = 11;
9432
9730
  break;
9433
9731
  }
9434
9732
 
9435
9733
  chainId = networkChainIdMap[this.network];
9436
9734
  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;
9735
+ _context9.next = 7;
9438
9736
  return axios.get(apiUrl);
9439
9737
 
9440
9738
  case 7:
9441
- response = _context8.sent;
9739
+ response = _context9.sent;
9442
9740
  swapTxData = response.data.tx.data;
9443
- _context8.next = 31;
9741
+ _context9.next = 31;
9444
9742
  break;
9445
9743
 
9446
9744
  case 11:
9447
9745
  if (!(dapp === exports.Dapp.BALANCER)) {
9448
- _context8.next = 17;
9746
+ _context9.next = 17;
9449
9747
  break;
9450
9748
  }
9451
9749
 
9452
- _context8.next = 14;
9750
+ _context9.next = 14;
9453
9751
  return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
9454
9752
 
9455
9753
  case 14:
9456
- swapTxData = _context8.sent;
9457
- _context8.next = 31;
9754
+ swapTxData = _context9.sent;
9755
+ _context9.next = 31;
9458
9756
  break;
9459
9757
 
9460
9758
  case 17:
9461
9759
  if (!(dapp === exports.Dapp.SYNTHETIX)) {
9462
- _context8.next = 26;
9760
+ _context9.next = 26;
9463
9761
  break;
9464
9762
  }
9465
9763
 
@@ -9467,41 +9765,41 @@ var Pool = /*#__PURE__*/function () {
9467
9765
  assets = [assetFrom, assetTo].map(function (asset) {
9468
9766
  return ethers.ethers.utils.formatBytes32String(asset);
9469
9767
  });
9470
- _context8.next = 22;
9768
+ _context9.next = 22;
9471
9769
  return this.factory.owner();
9472
9770
 
9473
9771
  case 22:
9474
- daoAddress = _context8.sent;
9772
+ daoAddress = _context9.sent;
9475
9773
  swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
9476
- _context8.next = 31;
9774
+ _context9.next = 31;
9477
9775
  break;
9478
9776
 
9479
9777
  case 26:
9480
9778
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
9481
- _context8.next = 29;
9779
+ _context9.next = 29;
9482
9780
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
9483
9781
 
9484
9782
  case 29:
9485
- minAmountOut = _context8.sent;
9783
+ minAmountOut = _context9.sent;
9486
9784
  swapTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.SWAP, [amountIn, minAmountOut, [assetFrom, assetTo], this.address, deadline]);
9487
9785
 
9488
9786
  case 31:
9489
- _context8.next = 33;
9787
+ _context9.next = 33;
9490
9788
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], swapTxData, options);
9491
9789
 
9492
9790
  case 33:
9493
- tx = _context8.sent;
9494
- return _context8.abrupt("return", tx);
9791
+ tx = _context9.sent;
9792
+ return _context9.abrupt("return", tx);
9495
9793
 
9496
9794
  case 35:
9497
9795
  case "end":
9498
- return _context8.stop();
9796
+ return _context9.stop();
9499
9797
  }
9500
9798
  }
9501
- }, _callee8, this);
9799
+ }, _callee9, this);
9502
9800
  }));
9503
9801
 
9504
- function trade(_x20, _x21, _x22, _x23, _x24, _x25) {
9802
+ function trade(_x24, _x25, _x26, _x27, _x28, _x29) {
9505
9803
  return _trade.apply(this, arguments);
9506
9804
  }
9507
9805
 
@@ -9522,11 +9820,11 @@ var Pool = /*#__PURE__*/function () {
9522
9820
  _proto.addLiquidity =
9523
9821
  /*#__PURE__*/
9524
9822
  function () {
9525
- var _addLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(dapp, assetA, assetB, amountA, amountB, options) {
9823
+ var _addLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetA, assetB, amountA, amountB, options) {
9526
9824
  var iUniswapV2Router, addLiquidityTxData, tx;
9527
- return runtime_1.wrap(function _callee9$(_context9) {
9825
+ return runtime_1.wrap(function _callee10$(_context10) {
9528
9826
  while (1) {
9529
- switch (_context9.prev = _context9.next) {
9827
+ switch (_context10.prev = _context10.next) {
9530
9828
  case 0:
9531
9829
  if (options === void 0) {
9532
9830
  options = null;
@@ -9534,22 +9832,22 @@ var Pool = /*#__PURE__*/function () {
9534
9832
 
9535
9833
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
9536
9834
  addLiquidityTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.ADD_LIQUIDITY, [assetA, assetB, amountA, amountB, 0, 0, this.address, deadline]);
9537
- _context9.next = 5;
9835
+ _context10.next = 5;
9538
9836
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], addLiquidityTxData, options);
9539
9837
 
9540
9838
  case 5:
9541
- tx = _context9.sent;
9542
- return _context9.abrupt("return", tx);
9839
+ tx = _context10.sent;
9840
+ return _context10.abrupt("return", tx);
9543
9841
 
9544
9842
  case 7:
9545
9843
  case "end":
9546
- return _context9.stop();
9844
+ return _context10.stop();
9547
9845
  }
9548
9846
  }
9549
- }, _callee9, this);
9847
+ }, _callee10, this);
9550
9848
  }));
9551
9849
 
9552
- function addLiquidity(_x26, _x27, _x28, _x29, _x30, _x31) {
9850
+ function addLiquidity(_x30, _x31, _x32, _x33, _x34, _x35) {
9553
9851
  return _addLiquidity.apply(this, arguments);
9554
9852
  }
9555
9853
 
@@ -9569,11 +9867,11 @@ var Pool = /*#__PURE__*/function () {
9569
9867
  _proto.removeLiquidity =
9570
9868
  /*#__PURE__*/
9571
9869
  function () {
9572
- var _removeLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetA, assetB, amount, options) {
9870
+ var _removeLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(dapp, assetA, assetB, amount, options) {
9573
9871
  var iUniswapV2Router, removeLiquidityTxData, tx;
9574
- return runtime_1.wrap(function _callee10$(_context10) {
9872
+ return runtime_1.wrap(function _callee11$(_context11) {
9575
9873
  while (1) {
9576
- switch (_context10.prev = _context10.next) {
9874
+ switch (_context11.prev = _context11.next) {
9577
9875
  case 0:
9578
9876
  if (options === void 0) {
9579
9877
  options = null;
@@ -9581,22 +9879,22 @@ var Pool = /*#__PURE__*/function () {
9581
9879
 
9582
9880
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
9583
9881
  removeLiquidityTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.REMOVE_LIQUIDITY, [assetA, assetB, amount, 0, 0, this.address, deadline]);
9584
- _context10.next = 5;
9882
+ _context11.next = 5;
9585
9883
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], removeLiquidityTxData, options);
9586
9884
 
9587
9885
  case 5:
9588
- tx = _context10.sent;
9589
- return _context10.abrupt("return", tx);
9886
+ tx = _context11.sent;
9887
+ return _context11.abrupt("return", tx);
9590
9888
 
9591
9889
  case 7:
9592
9890
  case "end":
9593
- return _context10.stop();
9891
+ return _context11.stop();
9594
9892
  }
9595
9893
  }
9596
- }, _callee10, this);
9894
+ }, _callee11, this);
9597
9895
  }));
9598
9896
 
9599
- function removeLiquidity(_x32, _x33, _x34, _x35, _x36) {
9897
+ function removeLiquidity(_x36, _x37, _x38, _x39, _x40) {
9600
9898
  return _removeLiquidity.apply(this, arguments);
9601
9899
  }
9602
9900
 
@@ -9615,44 +9913,89 @@ var Pool = /*#__PURE__*/function () {
9615
9913
  _proto.stake =
9616
9914
  /*#__PURE__*/
9617
9915
  function () {
9618
- var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(dapp, asset, amount, options) {
9916
+ var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(dapp, asset, amount, options) {
9619
9917
  var iMiniChefV2, poolId, stakeTxData, tx;
9620
- return runtime_1.wrap(function _callee11$(_context11) {
9918
+ return runtime_1.wrap(function _callee12$(_context12) {
9621
9919
  while (1) {
9622
- switch (_context11.prev = _context11.next) {
9920
+ switch (_context12.prev = _context12.next) {
9623
9921
  case 0:
9624
9922
  if (options === void 0) {
9625
9923
  options = null;
9626
9924
  }
9627
9925
 
9628
9926
  iMiniChefV2 = new ethers.ethers.utils.Interface(IMiniChefV2.abi);
9629
- _context11.next = 4;
9927
+ _context12.next = 4;
9630
9928
  return this.utils.getLpPoolId(dapp, asset);
9631
9929
 
9632
9930
  case 4:
9633
- poolId = _context11.sent;
9931
+ poolId = _context12.sent;
9634
9932
  stakeTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.DEPOSIT, [poolId, amount, this.address]);
9635
- _context11.next = 8;
9933
+ _context12.next = 8;
9636
9934
  return this.poolLogic.execTransaction(stakingAddress[this.network][dapp], stakeTxData, options);
9637
9935
 
9638
9936
  case 8:
9639
- tx = _context11.sent;
9640
- return _context11.abrupt("return", tx);
9937
+ tx = _context12.sent;
9938
+ return _context12.abrupt("return", tx);
9641
9939
 
9642
9940
  case 10:
9643
9941
  case "end":
9644
- return _context11.stop();
9942
+ return _context12.stop();
9645
9943
  }
9646
9944
  }
9647
- }, _callee11, this);
9945
+ }, _callee12, this);
9648
9946
  }));
9649
9947
 
9650
- function stake(_x37, _x38, _x39, _x40) {
9948
+ function stake(_x41, _x42, _x43, _x44) {
9651
9949
  return _stake.apply(this, arguments);
9652
9950
  }
9653
9951
 
9654
9952
  return stake;
9655
9953
  }()
9954
+ /**
9955
+ * Stake liquidity pool tokens in gauge contract
9956
+ * @param {string} gauge Gauge contract address
9957
+ * @param {BigNumber | string} amount Amount of liquidity pool tokens
9958
+ * @param {any} options Transaction options
9959
+ * @returns {Promise<any>} Transaction
9960
+ */
9961
+ ;
9962
+
9963
+ _proto.stakeInGauge =
9964
+ /*#__PURE__*/
9965
+ function () {
9966
+ var _stakeInGauge = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(gauge, amount, options) {
9967
+ var rewardsGauge, stakeTxData, tx;
9968
+ return runtime_1.wrap(function _callee13$(_context13) {
9969
+ while (1) {
9970
+ switch (_context13.prev = _context13.next) {
9971
+ case 0:
9972
+ if (options === void 0) {
9973
+ options = null;
9974
+ }
9975
+
9976
+ rewardsGauge = new ethers.ethers.utils.Interface(IBalancerRewardsGauge.abi);
9977
+ stakeTxData = rewardsGauge.encodeFunctionData("deposit(uint256)", [amount]);
9978
+ _context13.next = 5;
9979
+ return this.poolLogic.execTransaction(gauge, stakeTxData, options);
9980
+
9981
+ case 5:
9982
+ tx = _context13.sent;
9983
+ return _context13.abrupt("return", tx);
9984
+
9985
+ case 7:
9986
+ case "end":
9987
+ return _context13.stop();
9988
+ }
9989
+ }
9990
+ }, _callee13, this);
9991
+ }));
9992
+
9993
+ function stakeInGauge(_x45, _x46, _x47) {
9994
+ return _stakeInGauge.apply(this, arguments);
9995
+ }
9996
+
9997
+ return stakeInGauge;
9998
+ }()
9656
9999
  /**
9657
10000
  * Unstake liquidity pool tokens from a yield farm
9658
10001
  * @param {Dapp} dapp Platform like Sushiswap or Uniswap
@@ -9666,50 +10009,95 @@ var Pool = /*#__PURE__*/function () {
9666
10009
  _proto.unStake =
9667
10010
  /*#__PURE__*/
9668
10011
  function () {
9669
- var _unStake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(dapp, asset, amount, options) {
9670
- var iMiniChefV2, poolId, unStakeTxData, tx;
9671
- return runtime_1.wrap(function _callee12$(_context12) {
10012
+ var _unStake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(dapp, asset, amount, options) {
10013
+ var iMiniChefV2, poolId, unStakeTxData, tx;
10014
+ return runtime_1.wrap(function _callee14$(_context14) {
10015
+ while (1) {
10016
+ switch (_context14.prev = _context14.next) {
10017
+ case 0:
10018
+ if (options === void 0) {
10019
+ options = null;
10020
+ }
10021
+
10022
+ iMiniChefV2 = new ethers.ethers.utils.Interface(IMiniChefV2.abi);
10023
+ _context14.next = 4;
10024
+ return this.utils.getLpPoolId(dapp, asset);
10025
+
10026
+ case 4:
10027
+ poolId = _context14.sent;
10028
+ unStakeTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.WITHDRAW, [poolId, amount, this.address]);
10029
+ _context14.next = 8;
10030
+ return this.poolLogic.execTransaction(stakingAddress[this.network][dapp], unStakeTxData, options);
10031
+
10032
+ case 8:
10033
+ tx = _context14.sent;
10034
+ return _context14.abrupt("return", tx);
10035
+
10036
+ case 10:
10037
+ case "end":
10038
+ return _context14.stop();
10039
+ }
10040
+ }
10041
+ }, _callee14, this);
10042
+ }));
10043
+
10044
+ function unStake(_x48, _x49, _x50, _x51) {
10045
+ return _unStake.apply(this, arguments);
10046
+ }
10047
+
10048
+ return unStake;
10049
+ }()
10050
+ /**
10051
+ * Unstake liquidity pool tokens from gauge contract
10052
+ * @param {string} gauge Gauge contract address
10053
+ * @param {BigNumber | string} amount Amount of liquidity pool tokens
10054
+ * @param {any} options Transaction options
10055
+ * @returns {Promise<any>} Transaction
10056
+ */
10057
+ ;
10058
+
10059
+ _proto.unstakeFromGauge =
10060
+ /*#__PURE__*/
10061
+ function () {
10062
+ var _unstakeFromGauge = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(gauge, amount, options) {
10063
+ var rewardsGauge, unstakeTxData, tx;
10064
+ return runtime_1.wrap(function _callee15$(_context15) {
9672
10065
  while (1) {
9673
- switch (_context12.prev = _context12.next) {
10066
+ switch (_context15.prev = _context15.next) {
9674
10067
  case 0:
9675
10068
  if (options === void 0) {
9676
10069
  options = null;
9677
10070
  }
9678
10071
 
9679
- iMiniChefV2 = new ethers.ethers.utils.Interface(IMiniChefV2.abi);
9680
- _context12.next = 4;
9681
- return this.utils.getLpPoolId(dapp, asset);
9682
-
9683
- case 4:
9684
- poolId = _context12.sent;
9685
- unStakeTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.WITHDRAW, [poolId, amount, this.address]);
9686
- _context12.next = 8;
9687
- return this.poolLogic.execTransaction(stakingAddress[this.network][dapp], unStakeTxData, options);
10072
+ rewardsGauge = new ethers.ethers.utils.Interface(IBalancerRewardsGauge.abi);
10073
+ unstakeTxData = rewardsGauge.encodeFunctionData("withdraw(uint256)", [amount]);
10074
+ _context15.next = 5;
10075
+ return this.poolLogic.execTransaction(gauge, unstakeTxData, options);
9688
10076
 
9689
- case 8:
9690
- tx = _context12.sent;
9691
- return _context12.abrupt("return", tx);
10077
+ case 5:
10078
+ tx = _context15.sent;
10079
+ return _context15.abrupt("return", tx);
9692
10080
 
9693
- case 10:
10081
+ case 7:
9694
10082
  case "end":
9695
- return _context12.stop();
10083
+ return _context15.stop();
9696
10084
  }
9697
10085
  }
9698
- }, _callee12, this);
10086
+ }, _callee15, this);
9699
10087
  }));
9700
10088
 
9701
- function unStake(_x41, _x42, _x43, _x44) {
9702
- return _unStake.apply(this, arguments);
10089
+ function unstakeFromGauge(_x52, _x53, _x54) {
10090
+ return _unstakeFromGauge.apply(this, arguments);
9703
10091
  }
9704
10092
 
9705
- return unStake;
10093
+ return unstakeFromGauge;
9706
10094
  }()
9707
10095
  /**
9708
10096
  * Lend asset to a lending pool
9709
10097
  * @param {Dapp} dapp Platform like Aave
9710
10098
  * @param {string} asset Asset
9711
10099
  * @param {BigNumber | string} amount Amount of asset to lend
9712
- * @param {number} referrralCode Code from Aave referral program
10100
+ * @param {number} referralCode Code from Aave referral program
9713
10101
  * @param {any} options Transaction options
9714
10102
  * @returns {Promise<any>} Transaction
9715
10103
  */
@@ -9718,14 +10106,14 @@ var Pool = /*#__PURE__*/function () {
9718
10106
  _proto.lend =
9719
10107
  /*#__PURE__*/
9720
10108
  function () {
9721
- var _lend = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(dapp, asset, amount, referrralCode, options) {
10109
+ var _lend = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(dapp, asset, amount, referralCode, options) {
9722
10110
  var iLendingPool, depositTxData, tx;
9723
- return runtime_1.wrap(function _callee13$(_context13) {
10111
+ return runtime_1.wrap(function _callee16$(_context16) {
9724
10112
  while (1) {
9725
- switch (_context13.prev = _context13.next) {
10113
+ switch (_context16.prev = _context16.next) {
9726
10114
  case 0:
9727
- if (referrralCode === void 0) {
9728
- referrralCode = 0;
10115
+ if (referralCode === void 0) {
10116
+ referralCode = 0;
9729
10117
  }
9730
10118
 
9731
10119
  if (options === void 0) {
@@ -9733,23 +10121,23 @@ var Pool = /*#__PURE__*/function () {
9733
10121
  }
9734
10122
 
9735
10123
  iLendingPool = new ethers.ethers.utils.Interface(ILendingPool.abi);
9736
- depositTxData = iLendingPool.encodeFunctionData(exports.Transaction.DEPOSIT, [asset, amount, this.address, referrralCode]);
9737
- _context13.next = 6;
10124
+ depositTxData = iLendingPool.encodeFunctionData(exports.Transaction.DEPOSIT, [asset, amount, this.address, referralCode]);
10125
+ _context16.next = 6;
9738
10126
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], depositTxData, options);
9739
10127
 
9740
10128
  case 6:
9741
- tx = _context13.sent;
9742
- return _context13.abrupt("return", tx);
10129
+ tx = _context16.sent;
10130
+ return _context16.abrupt("return", tx);
9743
10131
 
9744
10132
  case 8:
9745
10133
  case "end":
9746
- return _context13.stop();
10134
+ return _context16.stop();
9747
10135
  }
9748
10136
  }
9749
- }, _callee13, this);
10137
+ }, _callee16, this);
9750
10138
  }));
9751
10139
 
9752
- function lend(_x45, _x46, _x47, _x48, _x49) {
10140
+ function lend(_x55, _x56, _x57, _x58, _x59) {
9753
10141
  return _lend.apply(this, arguments);
9754
10142
  }
9755
10143
 
@@ -9768,11 +10156,11 @@ var Pool = /*#__PURE__*/function () {
9768
10156
  _proto.withdrawDeposit =
9769
10157
  /*#__PURE__*/
9770
10158
  function () {
9771
- var _withdrawDeposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(dapp, asset, amount, options) {
10159
+ var _withdrawDeposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(dapp, asset, amount, options) {
9772
10160
  var iLendingPool, withdrawTxData, tx;
9773
- return runtime_1.wrap(function _callee14$(_context14) {
10161
+ return runtime_1.wrap(function _callee17$(_context17) {
9774
10162
  while (1) {
9775
- switch (_context14.prev = _context14.next) {
10163
+ switch (_context17.prev = _context17.next) {
9776
10164
  case 0:
9777
10165
  if (options === void 0) {
9778
10166
  options = null;
@@ -9780,22 +10168,22 @@ var Pool = /*#__PURE__*/function () {
9780
10168
 
9781
10169
  iLendingPool = new ethers.ethers.utils.Interface(ILendingPool.abi);
9782
10170
  withdrawTxData = iLendingPool.encodeFunctionData(exports.Transaction.WITHDRAW, [asset, amount, this.address]);
9783
- _context14.next = 5;
10171
+ _context17.next = 5;
9784
10172
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], withdrawTxData, options);
9785
10173
 
9786
10174
  case 5:
9787
- tx = _context14.sent;
9788
- return _context14.abrupt("return", tx);
10175
+ tx = _context17.sent;
10176
+ return _context17.abrupt("return", tx);
9789
10177
 
9790
10178
  case 7:
9791
10179
  case "end":
9792
- return _context14.stop();
10180
+ return _context17.stop();
9793
10181
  }
9794
10182
  }
9795
- }, _callee14, this);
10183
+ }, _callee17, this);
9796
10184
  }));
9797
10185
 
9798
- function withdrawDeposit(_x50, _x51, _x52, _x53) {
10186
+ function withdrawDeposit(_x60, _x61, _x62, _x63) {
9799
10187
  return _withdrawDeposit.apply(this, arguments);
9800
10188
  }
9801
10189
 
@@ -9806,7 +10194,7 @@ var Pool = /*#__PURE__*/function () {
9806
10194
  * @param {Dapp} dapp Platform like Aave
9807
10195
  * @param {string} asset Asset
9808
10196
  * @param {BigNumber | string} amount Amount of asset to lend
9809
- * @param {number} referrralCode Code from Aave referral program
10197
+ * @param {number} referralCode Code from Aave referral program
9810
10198
  * @param {any} options Transaction options
9811
10199
  * @returns {Promise<any>} Transaction
9812
10200
  */
@@ -9815,14 +10203,14 @@ var Pool = /*#__PURE__*/function () {
9815
10203
  _proto.borrow =
9816
10204
  /*#__PURE__*/
9817
10205
  function () {
9818
- var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(dapp, asset, amount, referrralCode, options) {
10206
+ var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18(dapp, asset, amount, referralCode, options) {
9819
10207
  var iLendingPool, borrowTxData, tx;
9820
- return runtime_1.wrap(function _callee15$(_context15) {
10208
+ return runtime_1.wrap(function _callee18$(_context18) {
9821
10209
  while (1) {
9822
- switch (_context15.prev = _context15.next) {
10210
+ switch (_context18.prev = _context18.next) {
9823
10211
  case 0:
9824
- if (referrralCode === void 0) {
9825
- referrralCode = 0;
10212
+ if (referralCode === void 0) {
10213
+ referralCode = 0;
9826
10214
  }
9827
10215
 
9828
10216
  if (options === void 0) {
@@ -9830,23 +10218,23 @@ var Pool = /*#__PURE__*/function () {
9830
10218
  }
9831
10219
 
9832
10220
  iLendingPool = new ethers.ethers.utils.Interface(ILendingPool.abi);
9833
- borrowTxData = iLendingPool.encodeFunctionData(exports.Transaction.BORROW, [asset, amount, 2, referrralCode, this.address]);
9834
- _context15.next = 6;
10221
+ borrowTxData = iLendingPool.encodeFunctionData(exports.Transaction.BORROW, [asset, amount, 2, referralCode, this.address]);
10222
+ _context18.next = 6;
9835
10223
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], borrowTxData, options);
9836
10224
 
9837
10225
  case 6:
9838
- tx = _context15.sent;
9839
- return _context15.abrupt("return", tx);
10226
+ tx = _context18.sent;
10227
+ return _context18.abrupt("return", tx);
9840
10228
 
9841
10229
  case 8:
9842
10230
  case "end":
9843
- return _context15.stop();
10231
+ return _context18.stop();
9844
10232
  }
9845
10233
  }
9846
- }, _callee15, this);
10234
+ }, _callee18, this);
9847
10235
  }));
9848
10236
 
9849
- function borrow(_x54, _x55, _x56, _x57, _x58) {
10237
+ function borrow(_x64, _x65, _x66, _x67, _x68) {
9850
10238
  return _borrow.apply(this, arguments);
9851
10239
  }
9852
10240
 
@@ -9865,11 +10253,11 @@ var Pool = /*#__PURE__*/function () {
9865
10253
  _proto.repay =
9866
10254
  /*#__PURE__*/
9867
10255
  function () {
9868
- var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(dapp, asset, amount, options) {
10256
+ var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19(dapp, asset, amount, options) {
9869
10257
  var iLendingPool, repayTxData, tx;
9870
- return runtime_1.wrap(function _callee16$(_context16) {
10258
+ return runtime_1.wrap(function _callee19$(_context19) {
9871
10259
  while (1) {
9872
- switch (_context16.prev = _context16.next) {
10260
+ switch (_context19.prev = _context19.next) {
9873
10261
  case 0:
9874
10262
  if (options === void 0) {
9875
10263
  options = null;
@@ -9877,22 +10265,22 @@ var Pool = /*#__PURE__*/function () {
9877
10265
 
9878
10266
  iLendingPool = new ethers.ethers.utils.Interface(ILendingPool.abi);
9879
10267
  repayTxData = iLendingPool.encodeFunctionData(exports.Transaction.REPAY, [asset, amount, 2, this.address]);
9880
- _context16.next = 5;
10268
+ _context19.next = 5;
9881
10269
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], repayTxData, options);
9882
10270
 
9883
10271
  case 5:
9884
- tx = _context16.sent;
9885
- return _context16.abrupt("return", tx);
10272
+ tx = _context19.sent;
10273
+ return _context19.abrupt("return", tx);
9886
10274
 
9887
10275
  case 7:
9888
10276
  case "end":
9889
- return _context16.stop();
10277
+ return _context19.stop();
9890
10278
  }
9891
10279
  }
9892
- }, _callee16, this);
10280
+ }, _callee19, this);
9893
10281
  }));
9894
10282
 
9895
- function repay(_x59, _x60, _x61, _x62) {
10283
+ function repay(_x69, _x70, _x71, _x72) {
9896
10284
  return _repay.apply(this, arguments);
9897
10285
  }
9898
10286
 
@@ -9910,39 +10298,39 @@ var Pool = /*#__PURE__*/function () {
9910
10298
  _proto.harvestRewards =
9911
10299
  /*#__PURE__*/
9912
10300
  function () {
9913
- var _harvestRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(dapp, asset, options) {
10301
+ var _harvestRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee20(dapp, asset, options) {
9914
10302
  var iMiniChefV2, poolId, harvestTxData, tx;
9915
- return runtime_1.wrap(function _callee17$(_context17) {
10303
+ return runtime_1.wrap(function _callee20$(_context20) {
9916
10304
  while (1) {
9917
- switch (_context17.prev = _context17.next) {
10305
+ switch (_context20.prev = _context20.next) {
9918
10306
  case 0:
9919
10307
  if (options === void 0) {
9920
10308
  options = null;
9921
10309
  }
9922
10310
 
9923
10311
  iMiniChefV2 = new ethers.ethers.utils.Interface(IMiniChefV2.abi);
9924
- _context17.next = 4;
10312
+ _context20.next = 4;
9925
10313
  return this.utils.getLpPoolId(dapp, asset);
9926
10314
 
9927
10315
  case 4:
9928
- poolId = _context17.sent;
10316
+ poolId = _context20.sent;
9929
10317
  harvestTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.HARVEST, [poolId, this.address]);
9930
- _context17.next = 8;
10318
+ _context20.next = 8;
9931
10319
  return this.poolLogic.execTransaction(stakingAddress[this.network][dapp], harvestTxData, options);
9932
10320
 
9933
10321
  case 8:
9934
- tx = _context17.sent;
9935
- return _context17.abrupt("return", tx);
10322
+ tx = _context20.sent;
10323
+ return _context20.abrupt("return", tx);
9936
10324
 
9937
10325
  case 10:
9938
10326
  case "end":
9939
- return _context17.stop();
10327
+ return _context20.stop();
9940
10328
  }
9941
10329
  }
9942
- }, _callee17, this);
10330
+ }, _callee20, this);
9943
10331
  }));
9944
10332
 
9945
- function harvestRewards(_x63, _x64, _x65) {
10333
+ function harvestRewards(_x73, _x74, _x75) {
9946
10334
  return _harvestRewards.apply(this, arguments);
9947
10335
  }
9948
10336
 
@@ -9959,21 +10347,21 @@ var Pool = /*#__PURE__*/function () {
9959
10347
  _proto.changeAssets =
9960
10348
  /*#__PURE__*/
9961
10349
  function () {
9962
- var _changeAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18(assets, options) {
10350
+ var _changeAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee21(assets, options) {
9963
10351
  var currentAssetsEnabled, currentAssets, newAssets, removedAssets, changedAssets, tx;
9964
- return runtime_1.wrap(function _callee18$(_context18) {
10352
+ return runtime_1.wrap(function _callee21$(_context21) {
9965
10353
  while (1) {
9966
- switch (_context18.prev = _context18.next) {
10354
+ switch (_context21.prev = _context21.next) {
9967
10355
  case 0:
9968
10356
  if (options === void 0) {
9969
10357
  options = null;
9970
10358
  }
9971
10359
 
9972
- _context18.next = 3;
10360
+ _context21.next = 3;
9973
10361
  return this.getComposition();
9974
10362
 
9975
10363
  case 3:
9976
- currentAssetsEnabled = _context18.sent;
10364
+ currentAssetsEnabled = _context21.sent;
9977
10365
  currentAssets = currentAssetsEnabled.map(function (e) {
9978
10366
  return e.asset.toLocaleLowerCase();
9979
10367
  });
@@ -9986,22 +10374,22 @@ var Pool = /*#__PURE__*/function () {
9986
10374
  changedAssets = assets.map(function (e) {
9987
10375
  return [e.asset, e.isDeposit];
9988
10376
  });
9989
- _context18.next = 10;
10377
+ _context21.next = 10;
9990
10378
  return this.managerLogic.changeAssets(changedAssets, removedAssets, options);
9991
10379
 
9992
10380
  case 10:
9993
- tx = _context18.sent;
9994
- return _context18.abrupt("return", tx);
10381
+ tx = _context21.sent;
10382
+ return _context21.abrupt("return", tx);
9995
10383
 
9996
10384
  case 12:
9997
10385
  case "end":
9998
- return _context18.stop();
10386
+ return _context21.stop();
9999
10387
  }
10000
10388
  }
10001
- }, _callee18, this);
10389
+ }, _callee21, this);
10002
10390
  }));
10003
10391
 
10004
- function changeAssets(_x66, _x67) {
10392
+ function changeAssets(_x76, _x77) {
10005
10393
  return _changeAssets.apply(this, arguments);
10006
10394
  }
10007
10395
 
@@ -10018,32 +10406,32 @@ var Pool = /*#__PURE__*/function () {
10018
10406
  _proto.setTrader =
10019
10407
  /*#__PURE__*/
10020
10408
  function () {
10021
- var _setTrader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19(trader, options) {
10409
+ var _setTrader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee22(trader, options) {
10022
10410
  var tx;
10023
- return runtime_1.wrap(function _callee19$(_context19) {
10411
+ return runtime_1.wrap(function _callee22$(_context22) {
10024
10412
  while (1) {
10025
- switch (_context19.prev = _context19.next) {
10413
+ switch (_context22.prev = _context22.next) {
10026
10414
  case 0:
10027
10415
  if (options === void 0) {
10028
10416
  options = null;
10029
10417
  }
10030
10418
 
10031
- _context19.next = 3;
10419
+ _context22.next = 3;
10032
10420
  return this.managerLogic.setTrader(trader, options);
10033
10421
 
10034
10422
  case 3:
10035
- tx = _context19.sent;
10036
- return _context19.abrupt("return", tx);
10423
+ tx = _context22.sent;
10424
+ return _context22.abrupt("return", tx);
10037
10425
 
10038
10426
  case 5:
10039
10427
  case "end":
10040
- return _context19.stop();
10428
+ return _context22.stop();
10041
10429
  }
10042
10430
  }
10043
- }, _callee19, this);
10431
+ }, _callee22, this);
10044
10432
  }));
10045
10433
 
10046
- function setTrader(_x68, _x69) {
10434
+ function setTrader(_x78, _x79) {
10047
10435
  return _setTrader.apply(this, arguments);
10048
10436
  }
10049
10437
 
@@ -10062,33 +10450,33 @@ var Pool = /*#__PURE__*/function () {
10062
10450
  _proto.joinBalancerPool =
10063
10451
  /*#__PURE__*/
10064
10452
  function () {
10065
- var _joinBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee20(poolId, assets, amountsIn, options) {
10453
+ var _joinBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee23(poolId, assets, amountsIn, options) {
10066
10454
  var joinPoolTxData, tx;
10067
- return runtime_1.wrap(function _callee20$(_context20) {
10455
+ return runtime_1.wrap(function _callee23$(_context23) {
10068
10456
  while (1) {
10069
- switch (_context20.prev = _context20.next) {
10457
+ switch (_context23.prev = _context23.next) {
10070
10458
  case 0:
10071
10459
  if (options === void 0) {
10072
10460
  options = null;
10073
10461
  }
10074
10462
 
10075
10463
  joinPoolTxData = this.utils.getBalancerJoinPoolTx(this, poolId, assets, amountsIn);
10076
- _context20.next = 4;
10464
+ _context23.next = 4;
10077
10465
  return this.poolLogic.execTransaction(routerAddress[this.network][exports.Dapp.BALANCER], joinPoolTxData, options);
10078
10466
 
10079
10467
  case 4:
10080
- tx = _context20.sent;
10081
- return _context20.abrupt("return", tx);
10468
+ tx = _context23.sent;
10469
+ return _context23.abrupt("return", tx);
10082
10470
 
10083
10471
  case 6:
10084
10472
  case "end":
10085
- return _context20.stop();
10473
+ return _context23.stop();
10086
10474
  }
10087
10475
  }
10088
- }, _callee20, this);
10476
+ }, _callee23, this);
10089
10477
  }));
10090
10478
 
10091
- function joinBalancerPool(_x70, _x71, _x72, _x73) {
10479
+ function joinBalancerPool(_x80, _x81, _x82, _x83) {
10092
10480
  return _joinBalancerPool.apply(this, arguments);
10093
10481
  }
10094
10482
 
@@ -10099,6 +10487,7 @@ var Pool = /*#__PURE__*/function () {
10099
10487
  * @param {string} poolId Balancer pool id
10100
10488
  * @param {string[] | } assets Array of balancer pool assets
10101
10489
  * @param {BigNumber | string } amount Amount of pool tokens to withdraw
10490
+ * @param { null | number } singleExitAssetIndex Index of asset to withdraw to
10102
10491
  * @param {any} options Transaction options
10103
10492
  * @returns {Promise<any>} Transaction
10104
10493
  */
@@ -10107,33 +10496,37 @@ var Pool = /*#__PURE__*/function () {
10107
10496
  _proto.exitBalancerPool =
10108
10497
  /*#__PURE__*/
10109
10498
  function () {
10110
- var _exitBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee21(poolId, assets, amount, options) {
10499
+ var _exitBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee24(poolId, assets, amount, singleExitAssetIndex, options) {
10111
10500
  var exitPoolTxData, tx;
10112
- return runtime_1.wrap(function _callee21$(_context21) {
10501
+ return runtime_1.wrap(function _callee24$(_context24) {
10113
10502
  while (1) {
10114
- switch (_context21.prev = _context21.next) {
10503
+ switch (_context24.prev = _context24.next) {
10115
10504
  case 0:
10505
+ if (singleExitAssetIndex === void 0) {
10506
+ singleExitAssetIndex = null;
10507
+ }
10508
+
10116
10509
  if (options === void 0) {
10117
10510
  options = null;
10118
10511
  }
10119
10512
 
10120
- exitPoolTxData = this.utils.getBalancerExitPoolTx(this, poolId, assets, amount);
10121
- _context21.next = 4;
10513
+ exitPoolTxData = this.utils.getBalancerExitPoolTx(this, poolId, assets, singleExitAssetIndex, amount);
10514
+ _context24.next = 5;
10122
10515
  return this.poolLogic.execTransaction(routerAddress[this.network][exports.Dapp.BALANCER], exitPoolTxData, options);
10123
10516
 
10124
- case 4:
10125
- tx = _context21.sent;
10126
- return _context21.abrupt("return", tx);
10517
+ case 5:
10518
+ tx = _context24.sent;
10519
+ return _context24.abrupt("return", tx);
10127
10520
 
10128
- case 6:
10521
+ case 7:
10129
10522
  case "end":
10130
- return _context21.stop();
10523
+ return _context24.stop();
10131
10524
  }
10132
10525
  }
10133
- }, _callee21, this);
10526
+ }, _callee24, this);
10134
10527
  }));
10135
10528
 
10136
- function exitBalancerPool(_x74, _x75, _x76, _x77) {
10529
+ function exitBalancerPool(_x84, _x85, _x86, _x87, _x88) {
10137
10530
  return _exitBalancerPool.apply(this, arguments);
10138
10531
  }
10139
10532
 
@@ -10150,48 +10543,48 @@ var Pool = /*#__PURE__*/function () {
10150
10543
  _proto.harvestBalancerRewards =
10151
10544
  /*#__PURE__*/
10152
10545
  function () {
10153
- var _harvestBalancerRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee22(options) {
10546
+ var _harvestBalancerRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee25(options) {
10154
10547
  var claimService, multiTokenPendingClaims, tokens, claims, iBalancerMerkleOrchard, harvestTxData, tx;
10155
- return runtime_1.wrap(function _callee22$(_context22) {
10548
+ return runtime_1.wrap(function _callee25$(_context25) {
10156
10549
  while (1) {
10157
- switch (_context22.prev = _context22.next) {
10550
+ switch (_context25.prev = _context25.next) {
10158
10551
  case 0:
10159
10552
  if (options === void 0) {
10160
10553
  options = null;
10161
10554
  }
10162
10555
 
10163
10556
  claimService = new ClaimService(this.network, this.signer);
10164
- _context22.next = 4;
10557
+ _context25.next = 4;
10165
10558
  return claimService.getMultiTokensPendingClaims(this.address);
10166
10559
 
10167
10560
  case 4:
10168
- multiTokenPendingClaims = _context22.sent;
10561
+ multiTokenPendingClaims = _context25.sent;
10169
10562
  tokens = multiTokenPendingClaims.map(function (tokenPendingClaims) {
10170
10563
  return tokenPendingClaims.tokenClaimInfo.token;
10171
10564
  });
10172
- _context22.next = 8;
10565
+ _context25.next = 8;
10173
10566
  return claimService.multiTokenClaimRewards(this.address, multiTokenPendingClaims);
10174
10567
 
10175
10568
  case 8:
10176
- claims = _context22.sent;
10569
+ claims = _context25.sent;
10177
10570
  iBalancerMerkleOrchard = new ethers.ethers.utils.Interface(IBalancerMerkleOrchard.abi);
10178
10571
  harvestTxData = iBalancerMerkleOrchard.encodeFunctionData(exports.Transaction.CLAIM_DISTRIBIUTIONS, [this.address, claims, tokens]);
10179
- _context22.next = 13;
10572
+ _context25.next = 13;
10180
10573
  return this.poolLogic.execTransaction(stakingAddress[this.network][exports.Dapp.BALANCER], harvestTxData, options);
10181
10574
 
10182
10575
  case 13:
10183
- tx = _context22.sent;
10184
- return _context22.abrupt("return", tx);
10576
+ tx = _context25.sent;
10577
+ return _context25.abrupt("return", tx);
10185
10578
 
10186
10579
  case 15:
10187
10580
  case "end":
10188
- return _context22.stop();
10581
+ return _context25.stop();
10189
10582
  }
10190
10583
  }
10191
- }, _callee22, this);
10584
+ }, _callee25, this);
10192
10585
  }));
10193
10586
 
10194
- function harvestBalancerRewards(_x78) {
10587
+ function harvestBalancerRewards(_x89) {
10195
10588
  return _harvestBalancerRewards.apply(this, arguments);
10196
10589
  }
10197
10590
 
@@ -10208,11 +10601,11 @@ var Pool = /*#__PURE__*/function () {
10208
10601
  _proto.harvestAaveRewards =
10209
10602
  /*#__PURE__*/
10210
10603
  function () {
10211
- var _harvestAaveRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee23(assets, options) {
10604
+ var _harvestAaveRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26(assets, options) {
10212
10605
  var aaveIncentivesAddress, iAaveIncentivesController, aaveIncentivesController, amount, claimTxData, tx;
10213
- return runtime_1.wrap(function _callee23$(_context23) {
10606
+ return runtime_1.wrap(function _callee26$(_context26) {
10214
10607
  while (1) {
10215
- switch (_context23.prev = _context23.next) {
10608
+ switch (_context26.prev = _context26.next) {
10216
10609
  case 0:
10217
10610
  if (options === void 0) {
10218
10611
  options = null;
@@ -10221,28 +10614,28 @@ var Pool = /*#__PURE__*/function () {
10221
10614
  aaveIncentivesAddress = stakingAddress[this.network][exports.Dapp.AAVE];
10222
10615
  iAaveIncentivesController = new ethers.ethers.utils.Interface(IAaveIncentivesController.abi);
10223
10616
  aaveIncentivesController = new ethers.ethers.Contract(aaveIncentivesAddress, iAaveIncentivesController, this.signer);
10224
- _context23.next = 6;
10617
+ _context26.next = 6;
10225
10618
  return aaveIncentivesController.getUserUnclaimedRewards(this.address);
10226
10619
 
10227
10620
  case 6:
10228
- amount = _context23.sent;
10621
+ amount = _context26.sent;
10229
10622
  claimTxData = iAaveIncentivesController.encodeFunctionData(exports.Transaction.CLAIM_REWARDS, [assets, amount, this.address]);
10230
- _context23.next = 10;
10623
+ _context26.next = 10;
10231
10624
  return this.poolLogic.execTransaction(aaveIncentivesAddress, claimTxData, options);
10232
10625
 
10233
10626
  case 10:
10234
- tx = _context23.sent;
10235
- return _context23.abrupt("return", tx);
10627
+ tx = _context26.sent;
10628
+ return _context26.abrupt("return", tx);
10236
10629
 
10237
10630
  case 12:
10238
10631
  case "end":
10239
- return _context23.stop();
10632
+ return _context26.stop();
10240
10633
  }
10241
10634
  }
10242
- }, _callee23, this);
10635
+ }, _callee26, this);
10243
10636
  }));
10244
10637
 
10245
- function harvestAaveRewards(_x79, _x80) {
10638
+ function harvestAaveRewards(_x90, _x91) {
10246
10639
  return _harvestAaveRewards.apply(this, arguments);
10247
10640
  }
10248
10641
 
@@ -10267,18 +10660,18 @@ var Pool = /*#__PURE__*/function () {
10267
10660
  _proto.addLiquidityUniswapV3 =
10268
10661
  /*#__PURE__*/
10269
10662
  function () {
10270
- var _addLiquidityUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee24(assetA, assetB, amountA, amountB, minPrice, maxPrice, minTick, maxTick, feeAmount, options) {
10663
+ var _addLiquidityUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27(assetA, assetB, amountA, amountB, minPrice, maxPrice, minTick, maxTick, feeAmount, options) {
10271
10664
  var iNonfungiblePositionManager, mintTxParams, mintTxData, tx;
10272
- return runtime_1.wrap(function _callee24$(_context24) {
10665
+ return runtime_1.wrap(function _callee27$(_context27) {
10273
10666
  while (1) {
10274
- switch (_context24.prev = _context24.next) {
10667
+ switch (_context27.prev = _context27.next) {
10275
10668
  case 0:
10276
10669
  if (options === void 0) {
10277
10670
  options = null;
10278
10671
  }
10279
10672
 
10280
10673
  if (!((!minPrice || !maxPrice) && (!minTick || !maxTick))) {
10281
- _context24.next = 3;
10674
+ _context27.next = 3;
10282
10675
  break;
10283
10676
  }
10284
10677
 
@@ -10286,28 +10679,28 @@ var Pool = /*#__PURE__*/function () {
10286
10679
 
10287
10680
  case 3:
10288
10681
  iNonfungiblePositionManager = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10289
- _context24.next = 6;
10682
+ _context27.next = 6;
10290
10683
  return getUniswapV3MintParams(this, assetA, assetB, amountA, amountB, minPrice, maxPrice, minTick, maxTick, feeAmount);
10291
10684
 
10292
10685
  case 6:
10293
- mintTxParams = _context24.sent;
10686
+ mintTxParams = _context27.sent;
10294
10687
  mintTxData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.MINT, [mintTxParams]);
10295
- _context24.next = 10;
10688
+ _context27.next = 10;
10296
10689
  return this.poolLogic.execTransaction(nonfungiblePositionManagerAddress[this.network], mintTxData, options);
10297
10690
 
10298
10691
  case 10:
10299
- tx = _context24.sent;
10300
- return _context24.abrupt("return", tx);
10692
+ tx = _context27.sent;
10693
+ return _context27.abrupt("return", tx);
10301
10694
 
10302
10695
  case 12:
10303
10696
  case "end":
10304
- return _context24.stop();
10697
+ return _context27.stop();
10305
10698
  }
10306
10699
  }
10307
- }, _callee24, this);
10700
+ }, _callee27, this);
10308
10701
  }));
10309
10702
 
10310
- function addLiquidityUniswapV3(_x81, _x82, _x83, _x84, _x85, _x86, _x87, _x88, _x89, _x90) {
10703
+ function addLiquidityUniswapV3(_x92, _x93, _x94, _x95, _x96, _x97, _x98, _x99, _x100, _x101) {
10311
10704
  return _addLiquidityUniswapV.apply(this, arguments);
10312
10705
  }
10313
10706
 
@@ -10326,12 +10719,12 @@ var Pool = /*#__PURE__*/function () {
10326
10719
  _proto.decreaseLiquidity =
10327
10720
  /*#__PURE__*/
10328
10721
  function () {
10329
- var _decreaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee25(dapp, tokenId, amount, options) {
10722
+ var _decreaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee28(dapp, tokenId, amount, options) {
10330
10723
  var txData, dappAddress, abi, liquidity, decreaseLiquidityTxData, collectTxData, multicallParams, burnTxData, _abi, _liquidity, tx;
10331
10724
 
10332
- return runtime_1.wrap(function _callee25$(_context25) {
10725
+ return runtime_1.wrap(function _callee28$(_context28) {
10333
10726
  while (1) {
10334
- switch (_context25.prev = _context25.next) {
10727
+ switch (_context28.prev = _context28.next) {
10335
10728
  case 0:
10336
10729
  if (amount === void 0) {
10337
10730
  amount = 100;
@@ -10342,17 +10735,17 @@ var Pool = /*#__PURE__*/function () {
10342
10735
  }
10343
10736
 
10344
10737
  if (!(dapp === exports.Dapp.UNISWAPV3)) {
10345
- _context25.next = 15;
10738
+ _context28.next = 15;
10346
10739
  break;
10347
10740
  }
10348
10741
 
10349
10742
  dappAddress = nonfungiblePositionManagerAddress[this.network];
10350
10743
  abi = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10351
- _context25.next = 7;
10744
+ _context28.next = 7;
10352
10745
  return getUniswapV3Liquidity(tokenId, this);
10353
10746
 
10354
10747
  case 7:
10355
- liquidity = _context25.sent.mul(amount).div(100);
10748
+ liquidity = _context28.sent.mul(Math.round(amount * 1e4)).div(1e6);
10356
10749
  decreaseLiquidityTxData = abi.encodeFunctionData(exports.Transaction.DECREASE_LIQUIDITY, [[tokenId, liquidity, 0, 0, deadline]]);
10357
10750
  collectTxData = abi.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10358
10751
  multicallParams = [decreaseLiquidityTxData, collectTxData];
@@ -10363,46 +10756,46 @@ var Pool = /*#__PURE__*/function () {
10363
10756
  }
10364
10757
 
10365
10758
  txData = abi.encodeFunctionData(exports.Transaction.MULTI_CALL, [multicallParams]);
10366
- _context25.next = 25;
10759
+ _context28.next = 25;
10367
10760
  break;
10368
10761
 
10369
10762
  case 15:
10370
10763
  if (!(dapp === exports.Dapp.ARRAKIS)) {
10371
- _context25.next = 24;
10764
+ _context28.next = 24;
10372
10765
  break;
10373
10766
  }
10374
10767
 
10375
10768
  dappAddress = routerAddress[this.network][dapp];
10376
10769
  _abi = new ethers.ethers.utils.Interface(IArrakisV1RouterStaking.abi);
10377
- _context25.next = 20;
10770
+ _context28.next = 20;
10378
10771
  return this.utils.getBalance(tokenId, this.address);
10379
10772
 
10380
10773
  case 20:
10381
- _liquidity = _context25.sent.mul(amount).div(100);
10774
+ _liquidity = _context28.sent.mul(Math.round(amount * 1e4)).div(1e6);
10382
10775
  txData = _abi.encodeFunctionData(exports.Transaction.REMOVE_LIQUIDITY_UNSTAKE, [tokenId, _liquidity, 0, 0, this.address]);
10383
- _context25.next = 25;
10776
+ _context28.next = 25;
10384
10777
  break;
10385
10778
 
10386
10779
  case 24:
10387
10780
  throw new Error("dapp not supported");
10388
10781
 
10389
10782
  case 25:
10390
- _context25.next = 27;
10783
+ _context28.next = 27;
10391
10784
  return this.poolLogic.execTransaction(dappAddress, txData, options);
10392
10785
 
10393
10786
  case 27:
10394
- tx = _context25.sent;
10395
- return _context25.abrupt("return", tx);
10787
+ tx = _context28.sent;
10788
+ return _context28.abrupt("return", tx);
10396
10789
 
10397
10790
  case 29:
10398
10791
  case "end":
10399
- return _context25.stop();
10792
+ return _context28.stop();
10400
10793
  }
10401
10794
  }
10402
- }, _callee25, this);
10795
+ }, _callee28, this);
10403
10796
  }));
10404
10797
 
10405
- function decreaseLiquidity(_x91, _x92, _x93, _x94) {
10798
+ function decreaseLiquidity(_x102, _x103, _x104, _x105) {
10406
10799
  return _decreaseLiquidity.apply(this, arguments);
10407
10800
  }
10408
10801
 
@@ -10422,60 +10815,60 @@ var Pool = /*#__PURE__*/function () {
10422
10815
  _proto.increaseLiquidity =
10423
10816
  /*#__PURE__*/
10424
10817
  function () {
10425
- var _increaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26(dapp, tokenId, amountA, amountB, options) {
10818
+ var _increaseLiquidity = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee29(dapp, tokenId, amountA, amountB, options) {
10426
10819
  var txData, dappAddress, abi, _abi2, tx;
10427
10820
 
10428
- return runtime_1.wrap(function _callee26$(_context26) {
10821
+ return runtime_1.wrap(function _callee29$(_context29) {
10429
10822
  while (1) {
10430
- switch (_context26.prev = _context26.next) {
10823
+ switch (_context29.prev = _context29.next) {
10431
10824
  case 0:
10432
10825
  if (options === void 0) {
10433
10826
  options = null;
10434
10827
  }
10435
10828
 
10436
10829
  if (!(dapp === exports.Dapp.UNISWAPV3)) {
10437
- _context26.next = 7;
10830
+ _context29.next = 7;
10438
10831
  break;
10439
10832
  }
10440
10833
 
10441
10834
  dappAddress = nonfungiblePositionManagerAddress[this.network];
10442
10835
  abi = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10443
10836
  txData = abi.encodeFunctionData(exports.Transaction.INCREASE_LIQUIDITY, [[tokenId, amountA, amountB, 0, 0, deadline]]);
10444
- _context26.next = 14;
10837
+ _context29.next = 14;
10445
10838
  break;
10446
10839
 
10447
10840
  case 7:
10448
10841
  if (!(dapp === exports.Dapp.ARRAKIS)) {
10449
- _context26.next = 13;
10842
+ _context29.next = 13;
10450
10843
  break;
10451
10844
  }
10452
10845
 
10453
10846
  dappAddress = routerAddress[this.network][dapp];
10454
10847
  _abi2 = new ethers.ethers.utils.Interface(IArrakisV1RouterStaking.abi);
10455
10848
  txData = _abi2.encodeFunctionData(exports.Transaction.ADD_LIQUIDITY_STAKE, [tokenId, amountA, amountB, 0, 0, this.address]);
10456
- _context26.next = 14;
10849
+ _context29.next = 14;
10457
10850
  break;
10458
10851
 
10459
10852
  case 13:
10460
10853
  throw new Error("dapp not supported");
10461
10854
 
10462
10855
  case 14:
10463
- _context26.next = 16;
10856
+ _context29.next = 16;
10464
10857
  return this.poolLogic.execTransaction(dappAddress, txData, options);
10465
10858
 
10466
10859
  case 16:
10467
- tx = _context26.sent;
10468
- return _context26.abrupt("return", tx);
10860
+ tx = _context29.sent;
10861
+ return _context29.abrupt("return", tx);
10469
10862
 
10470
10863
  case 18:
10471
10864
  case "end":
10472
- return _context26.stop();
10865
+ return _context29.stop();
10473
10866
  }
10474
10867
  }
10475
- }, _callee26, this);
10868
+ }, _callee29, this);
10476
10869
  }));
10477
10870
 
10478
- function increaseLiquidity(_x95, _x96, _x97, _x98, _x99) {
10871
+ function increaseLiquidity(_x106, _x107, _x108, _x109, _x110) {
10479
10872
  return _increaseLiquidity.apply(this, arguments);
10480
10873
  }
10481
10874
 
@@ -10484,8 +10877,8 @@ var Pool = /*#__PURE__*/function () {
10484
10877
  /**
10485
10878
  * Claim fees of an UniswapV3 liquidity or Arrakis pool
10486
10879
  * @param {Dapp} dapp Platform either UniswapV3 or Arrakis
10487
- * @param {string} tokenId Token Id of UniswapV3 or Arrakis position
10488
- * @param {any} options Transaction options
10880
+ * @param {string} tokenId Token Id of UniswapV3 or Gauge address
10881
+ * @param {any} options Transaction option
10489
10882
  * @returns {Promise<any>} Transaction
10490
10883
  */
10491
10884
  ;
@@ -10493,59 +10886,59 @@ var Pool = /*#__PURE__*/function () {
10493
10886
  _proto.claimFees =
10494
10887
  /*#__PURE__*/
10495
10888
  function () {
10496
- var _claimFees = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27(dapp, tokenId, options) {
10889
+ var _claimFees = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee30(dapp, tokenId, options) {
10497
10890
  var txData, contractAddress, iNonfungiblePositionManager, abi, tx;
10498
- return runtime_1.wrap(function _callee27$(_context27) {
10891
+ return runtime_1.wrap(function _callee30$(_context30) {
10499
10892
  while (1) {
10500
- switch (_context27.prev = _context27.next) {
10893
+ switch (_context30.prev = _context30.next) {
10501
10894
  case 0:
10502
10895
  if (options === void 0) {
10503
10896
  options = null;
10504
10897
  }
10505
10898
 
10506
10899
  if (!(dapp === exports.Dapp.UNISWAPV3)) {
10507
- _context27.next = 7;
10900
+ _context30.next = 7;
10508
10901
  break;
10509
10902
  }
10510
10903
 
10511
10904
  contractAddress = nonfungiblePositionManagerAddress[this.network];
10512
10905
  iNonfungiblePositionManager = new ethers.ethers.utils.Interface(INonfungiblePositionManager.abi);
10513
10906
  txData = iNonfungiblePositionManager.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10514
- _context27.next = 14;
10907
+ _context30.next = 14;
10515
10908
  break;
10516
10909
 
10517
10910
  case 7:
10518
- if (!(dapp === exports.Dapp.ARRAKIS)) {
10519
- _context27.next = 13;
10911
+ if (!(dapp === exports.Dapp.ARRAKIS || dapp === exports.Dapp.BALANCER)) {
10912
+ _context30.next = 13;
10520
10913
  break;
10521
10914
  }
10522
10915
 
10523
10916
  contractAddress = tokenId;
10524
10917
  abi = new ethers.ethers.utils.Interface(ILiquidityGaugeV4.abi);
10525
10918
  txData = abi.encodeFunctionData("claim_rewards()", []);
10526
- _context27.next = 14;
10919
+ _context30.next = 14;
10527
10920
  break;
10528
10921
 
10529
10922
  case 13:
10530
10923
  throw new Error("dapp not supported");
10531
10924
 
10532
10925
  case 14:
10533
- _context27.next = 16;
10926
+ _context30.next = 16;
10534
10927
  return this.poolLogic.execTransaction(contractAddress, txData, options);
10535
10928
 
10536
10929
  case 16:
10537
- tx = _context27.sent;
10538
- return _context27.abrupt("return", tx);
10930
+ tx = _context30.sent;
10931
+ return _context30.abrupt("return", tx);
10539
10932
 
10540
10933
  case 18:
10541
10934
  case "end":
10542
- return _context27.stop();
10935
+ return _context30.stop();
10543
10936
  }
10544
10937
  }
10545
- }, _callee27, this);
10938
+ }, _callee30, this);
10546
10939
  }));
10547
10940
 
10548
- function claimFees(_x100, _x101, _x102) {
10941
+ function claimFees(_x111, _x112, _x113) {
10549
10942
  return _claimFees.apply(this, arguments);
10550
10943
  }
10551
10944
 
@@ -10567,11 +10960,11 @@ var Pool = /*#__PURE__*/function () {
10567
10960
  _proto.tradeUniswapV3 =
10568
10961
  /*#__PURE__*/
10569
10962
  function () {
10570
- var _tradeUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee28(assetFrom, assetTo, amountIn, feeAmount, slippage, options) {
10963
+ var _tradeUniswapV = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee31(assetFrom, assetTo, amountIn, feeAmount, slippage, options) {
10571
10964
  var swapxData, tx;
10572
- return runtime_1.wrap(function _callee28$(_context28) {
10965
+ return runtime_1.wrap(function _callee31$(_context31) {
10573
10966
  while (1) {
10574
- switch (_context28.prev = _context28.next) {
10967
+ switch (_context31.prev = _context31.next) {
10575
10968
  case 0:
10576
10969
  if (slippage === void 0) {
10577
10970
  slippage = 0.5;
@@ -10581,27 +10974,27 @@ var Pool = /*#__PURE__*/function () {
10581
10974
  options = null;
10582
10975
  }
10583
10976
 
10584
- _context28.next = 4;
10977
+ _context31.next = 4;
10585
10978
  return getUniswapV3SwapTxData(this, assetFrom, assetTo, amountIn, slippage, feeAmount);
10586
10979
 
10587
10980
  case 4:
10588
- swapxData = _context28.sent;
10589
- _context28.next = 7;
10981
+ swapxData = _context31.sent;
10982
+ _context31.next = 7;
10590
10983
  return this.poolLogic.execTransaction(routerAddress[this.network][exports.Dapp.UNISWAPV3], swapxData, options);
10591
10984
 
10592
10985
  case 7:
10593
- tx = _context28.sent;
10594
- return _context28.abrupt("return", tx);
10986
+ tx = _context31.sent;
10987
+ return _context31.abrupt("return", tx);
10595
10988
 
10596
10989
  case 9:
10597
10990
  case "end":
10598
- return _context28.stop();
10991
+ return _context31.stop();
10599
10992
  }
10600
10993
  }
10601
- }, _callee28, this);
10994
+ }, _callee31, this);
10602
10995
  }));
10603
10996
 
10604
- function tradeUniswapV3(_x103, _x104, _x105, _x106, _x107, _x108) {
10997
+ function tradeUniswapV3(_x114, _x115, _x116, _x117, _x118, _x119) {
10605
10998
  return _tradeUniswapV.apply(this, arguments);
10606
10999
  }
10607
11000
 
@@ -10611,7 +11004,7 @@ var Pool = /*#__PURE__*/function () {
10611
11004
  return Pool;
10612
11005
  }();
10613
11006
 
10614
- var abi$f = [
11007
+ var abi$g = [
10615
11008
  {
10616
11009
  inputs: [
10617
11010
  {
@@ -10835,10 +11228,10 @@ var abi$f = [
10835
11228
  }
10836
11229
  ];
10837
11230
  var UniswapV2Factory = {
10838
- abi: abi$f
11231
+ abi: abi$g
10839
11232
  };
10840
11233
 
10841
- var abi$g = [
11234
+ var abi$h = [
10842
11235
  {
10843
11236
  anonymous: false,
10844
11237
  inputs: [
@@ -11582,7 +11975,7 @@ var evm = {
11582
11975
  }
11583
11976
  };
11584
11977
  var UniswapV2Pair = {
11585
- abi: abi$g,
11978
+ abi: abi$h,
11586
11979
  evm: evm,
11587
11980
  "interface": [
11588
11981
  {
@@ -12313,7 +12706,7 @@ var UniswapV2Pair = {
12313
12706
  ]
12314
12707
  };
12315
12708
 
12316
- var abi$h = [
12709
+ var abi$i = [
12317
12710
  {
12318
12711
  inputs: [
12319
12712
  {
@@ -13508,7 +13901,7 @@ var abi$h = [
13508
13901
  }
13509
13902
  ];
13510
13903
  var IBalancerV2Vault = {
13511
- abi: abi$h
13904
+ abi: abi$i
13512
13905
  };
13513
13906
 
13514
13907
  var Utils = /*#__PURE__*/function () {
@@ -13891,20 +14284,21 @@ var Utils = /*#__PURE__*/function () {
13891
14284
  }();
13892
14285
 
13893
14286
  _proto.getBalancerExitPoolTx = /*#__PURE__*/function () {
13894
- var _getBalancerExitPoolTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(pool, balancerPoolId, assets, amount // eslint-disable-next-line @typescript-eslint/no-explicit-any
14287
+ var _getBalancerExitPoolTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(pool, balancerPoolId, assets, singleExitAssetIndex, amount // eslint-disable-next-line @typescript-eslint/no-explicit-any
13895
14288
  ) {
13896
- var minimumAmountOut, iBalancerV2Vault, txData, exitPoolTx;
14289
+ var minimumAmountOut, iBalancerV2Vault, userTxData, txData, exitPoolTx;
13897
14290
  return runtime_1.wrap(function _callee8$(_context8) {
13898
14291
  while (1) {
13899
14292
  switch (_context8.prev = _context8.next) {
13900
14293
  case 0:
13901
14294
  minimumAmountOut = new Array(assets.length).fill(0);
13902
14295
  iBalancerV2Vault = new ethers.ethers.utils.Interface(IBalancerV2Vault.abi);
13903
- txData = [balancerPoolId, pool.address, pool.address, [assets, minimumAmountOut, ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256"], [1, amount]), false]];
14296
+ userTxData = singleExitAssetIndex === null ? ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256"], [1, amount]) : ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256", "uint256"], [0, amount, singleExitAssetIndex]);
14297
+ txData = [balancerPoolId, pool.address, pool.address, [assets, minimumAmountOut, userTxData, false]];
13904
14298
  exitPoolTx = iBalancerV2Vault.encodeFunctionData("exitPool", txData);
13905
14299
  return _context8.abrupt("return", exitPoolTx);
13906
14300
 
13907
- case 5:
14301
+ case 6:
13908
14302
  case "end":
13909
14303
  return _context8.stop();
13910
14304
  }
@@ -13912,7 +14306,7 @@ var Utils = /*#__PURE__*/function () {
13912
14306
  }, _callee8);
13913
14307
  }));
13914
14308
 
13915
- function getBalancerExitPoolTx(_x23, _x24, _x25, _x26) {
14309
+ function getBalancerExitPoolTx(_x23, _x24, _x25, _x26, _x27) {
13916
14310
  return _getBalancerExitPoolTx.apply(this, arguments);
13917
14311
  }
13918
14312
 
@@ -14023,17 +14417,16 @@ var Dhedge = /*#__PURE__*/function () {
14023
14417
  while (1) {
14024
14418
  switch (_context2.prev = _context2.next) {
14025
14419
  case 0:
14026
- this.validatePool(address);
14027
14420
  poolLogic = new ethers.Contract(address, PoolLogic.abi, this.signer);
14028
- _context2.next = 4;
14421
+ _context2.next = 3;
14029
14422
  return poolLogic.poolManagerLogic();
14030
14423
 
14031
- case 4:
14424
+ case 3:
14032
14425
  managerLogicAddress = _context2.sent;
14033
14426
  managerLogic = new ethers.Contract(managerLogicAddress, ManagerLogic.abi, this.signer);
14034
14427
  return _context2.abrupt("return", new Pool(this.network, this.signer, poolLogic, managerLogic, this.utils, this.factory));
14035
14428
 
14036
- case 7:
14429
+ case 6:
14037
14430
  case "end":
14038
14431
  return _context2.stop();
14039
14432
  }
@@ -14046,49 +14439,6 @@ var Dhedge = /*#__PURE__*/function () {
14046
14439
  }
14047
14440
 
14048
14441
  return loadPool;
14049
- }()
14050
- /**
14051
- * Check if pool address is valid
14052
- * @param {string} address Pool address
14053
- * @returns {boolean} Is valid pool address
14054
- */
14055
- ;
14056
-
14057
- _proto.validatePool =
14058
- /*#__PURE__*/
14059
- function () {
14060
- var _validatePool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(address) {
14061
- var isPool;
14062
- return runtime_1.wrap(function _callee3$(_context3) {
14063
- while (1) {
14064
- switch (_context3.prev = _context3.next) {
14065
- case 0:
14066
- _context3.next = 2;
14067
- return this.factory.isPool(address);
14068
-
14069
- case 2:
14070
- isPool = _context3.sent;
14071
-
14072
- if (isPool) {
14073
- _context3.next = 5;
14074
- break;
14075
- }
14076
-
14077
- throw new Error("Given address not a pool");
14078
-
14079
- case 5:
14080
- case "end":
14081
- return _context3.stop();
14082
- }
14083
- }
14084
- }, _callee3, this);
14085
- }));
14086
-
14087
- function validatePool(_x8) {
14088
- return _validatePool.apply(this, arguments);
14089
- }
14090
-
14091
- return validatePool;
14092
14442
  }();
14093
14443
 
14094
14444
  return Dhedge;