@dhedge/v2-sdk 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +60 -3
  2. package/dist/config.d.ts +2 -0
  3. package/dist/entities/pool.d.ts +32 -0
  4. package/dist/entities/utils.d.ts +4 -0
  5. package/dist/services/claim-balancer/claim.service.d.ts +21 -0
  6. package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
  7. package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
  8. package/dist/services/claim-balancer/types.d.ts +54 -0
  9. package/dist/test/constants.d.ts +12 -0
  10. package/dist/types.d.ts +5 -2
  11. package/dist/utils/contract.d.ts +14 -0
  12. package/dist/utils/index.d.ts +7 -0
  13. package/dist/utils/merkle.d.ts +22 -0
  14. package/dist/v2-sdk.cjs.development.js +3623 -672
  15. package/dist/v2-sdk.cjs.development.js.map +1 -1
  16. package/dist/v2-sdk.cjs.production.min.js +1 -1
  17. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  18. package/dist/v2-sdk.esm.js +3623 -672
  19. package/dist/v2-sdk.esm.js.map +1 -1
  20. package/package.json +9 -2
  21. package/src/abi/IAaveIncentivesController.json +50 -0
  22. package/src/abi/IBalancerMerkleOrchard.json +353 -0
  23. package/src/abi/IBalancertV2Vault.json +938 -0
  24. package/src/config.ts +16 -3
  25. package/src/entities/pool.ts +140 -1
  26. package/src/entities/utils.ts +135 -0
  27. package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
  28. package/src/services/claim-balancer/claim.service.ts +324 -0
  29. package/src/services/claim-balancer/claim.worker.ts +32 -0
  30. package/src/services/claim-balancer/ipfs.service.ts +12 -0
  31. package/src/services/claim-balancer/types.ts +66 -0
  32. package/src/test/aave.test.ts +73 -0
  33. package/src/test/balancer.test.ts +109 -0
  34. package/src/test/constants.ts +13 -0
  35. package/src/test/oneInch.test.ts +56 -0
  36. package/src/test/pool.test.ts +5 -249
  37. package/src/test/sushi.test.ts +173 -0
  38. package/src/test/utils.test.ts +41 -26
  39. package/src/types.ts +6 -3
  40. package/src/utils/contract.ts +95 -0
  41. package/src/utils/index.ts +38 -0
  42. package/src/utils/merkle.ts +172 -0
@@ -7,6 +7,14 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var ethers = require('ethers');
8
8
  var sdk = require('@sushiswap/sdk');
9
9
  var axios = _interopDefault(require('axios'));
10
+ var lodash = require('lodash');
11
+ var address = require('@ethersproject/address');
12
+ require('lodash/set');
13
+ var abi$c = require('@ethersproject/abi');
14
+ var BigNumber = _interopDefault(require('bignumber.js'));
15
+ var web3Utils = require('web3-utils');
16
+ var ethereumjsUtil = require('ethereumjs-util');
17
+ var sor = require('@balancer-labs/sor');
10
18
 
11
19
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
20
  try {
@@ -44,6 +52,24 @@ function _asyncToGenerator(fn) {
44
52
  };
45
53
  }
46
54
 
55
+ function _extends() {
56
+ _extends = Object.assign || function (target) {
57
+ for (var i = 1; i < arguments.length; i++) {
58
+ var source = arguments[i];
59
+
60
+ for (var key in source) {
61
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
62
+ target[key] = source[key];
63
+ }
64
+ }
65
+ }
66
+
67
+ return target;
68
+ };
69
+
70
+ return _extends.apply(this, arguments);
71
+ }
72
+
47
73
  function createCommonjsModule(fn, module) {
48
74
  return module = { exports: {} }, fn(module, module.exports), module.exports;
49
75
  }
@@ -3805,6 +3831,7 @@ var ManagerLogic = {
3805
3831
  Dapp["AAVE"] = "aave";
3806
3832
  Dapp["ONEINCH"] = "1inch";
3807
3833
  Dapp["QUICKSWAP"] = "quickswap";
3834
+ Dapp["BALANCER"] = "balancer";
3808
3835
  })(exports.Dapp || (exports.Dapp = {}));
3809
3836
 
3810
3837
  (function (Transaction) {
@@ -3812,19 +3839,22 @@ var ManagerLogic = {
3812
3839
  Transaction["ADD_LIQUIDITY"] = "addLiquidity";
3813
3840
  Transaction["DEPOSIT"] = "deposit";
3814
3841
  Transaction["HARVEST"] = "harvest";
3815
- Transaction["UNSTAKE"] = "withdrawAndHarvest";
3842
+ Transaction["CLAIM_DISTRIBIUTIONS"] = "claimDistributions";
3843
+ Transaction["CLAIM_REWARDS"] = "claimRewards";
3816
3844
  Transaction["REMOVE_LIQUIDITY"] = "removeLiquidity";
3817
3845
  Transaction["BORROW"] = "borrow";
3818
3846
  Transaction["REPAY"] = "repay";
3819
3847
  Transaction["WITHDRAW"] = "withdraw";
3820
3848
  })(exports.Transaction || (exports.Transaction = {}));
3821
3849
 
3822
- var _factoryAddress, _Network$POLYGON, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _stakingAddress, _networkChainIdMap;
3850
+ var _factoryAddress, _Network$POLYGON, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _stakingAddress, _networkChainIdMap, _balancerSubgraph, _multiCallAddress;
3823
3851
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress);
3824
- 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), _routerAddress);
3852
+ 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), _routerAddress);
3825
3853
  var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress);
3826
- var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3), _stakingAddress);
3854
+ 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);
3827
3855
  var networkChainIdMap = (_networkChainIdMap = {}, _networkChainIdMap[exports.Network.POLYGON] = sdk.ChainId.MATIC, _networkChainIdMap);
3856
+ var balancerSubgraph = (_balancerSubgraph = {}, _balancerSubgraph[exports.Network.POLYGON] = "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2", _balancerSubgraph);
3857
+ var multiCallAddress = (_multiCallAddress = {}, _multiCallAddress[exports.Network.POLYGON] = "0x275617327c958bD06b5D6b871E7f491D76113dd8", _multiCallAddress);
3828
3858
 
3829
3859
  var abi$3 = [
3830
3860
  {
@@ -5562,253 +5592,1624 @@ var IUniswapV2Router = {
5562
5592
  abi: abi$6
5563
5593
  };
5564
5594
 
5565
- var Pool = /*#__PURE__*/function () {
5566
- function Pool(network, signer, poolLogic, mangerLogic, utils) {
5567
- this.network = network;
5568
- this.poolLogic = poolLogic;
5569
- this.address = poolLogic.address;
5570
- this.managerLogic = mangerLogic;
5571
- this.signer = signer;
5572
- this.utils = utils;
5573
- }
5574
- /**
5575
- * Return the assets with balances and deposit info of a pool
5576
- * @returns {Promise<FundComposition[]>} Composition of assets with balance, deposit info
5577
- */
5578
-
5579
-
5580
- var _proto = Pool.prototype;
5581
-
5582
- _proto.getComposition =
5583
- /*#__PURE__*/
5584
- function () {
5585
- var _getComposition = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
5586
- var result, fundComposition;
5587
- return runtime_1.wrap(function _callee$(_context) {
5588
- while (1) {
5589
- switch (_context.prev = _context.next) {
5590
- case 0:
5591
- _context.next = 2;
5592
- return this.managerLogic.getFundComposition();
5593
-
5594
- case 2:
5595
- result = _context.sent;
5596
- fundComposition = result[0].map(function (item, index) {
5597
- var asset = item.asset,
5598
- isDeposit = item.isDeposit;
5599
- return {
5600
- asset: asset,
5601
- isDeposit: isDeposit,
5602
- balance: result[1][index],
5603
- rate: result[2][index]
5604
- };
5605
- });
5606
- return _context.abrupt("return", fundComposition);
5607
-
5608
- case 5:
5609
- case "end":
5610
- return _context.stop();
5611
- }
5612
- }
5613
- }, _callee, this);
5614
- }));
5615
-
5616
- function getComposition() {
5617
- return _getComposition.apply(this, arguments);
5618
- }
5619
-
5620
- return getComposition;
5621
- }() //Invest functions
5622
-
5623
- /**
5624
- * Approve the asset that can be deposited into a pool
5625
- * @param {string} nasset Address of deposit asset
5626
- * @param {BigNumber | string} amount Amount to be approved
5627
- * @param {any} options Transaction options
5628
- * @returns {Promise<any>} Transaction
5629
- */
5630
- ;
5631
-
5632
- _proto.approveDeposit =
5633
- /*#__PURE__*/
5634
- function () {
5635
- var _approveDeposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(asset, amount, options) {
5636
- var iERC20, tx;
5637
- return runtime_1.wrap(function _callee2$(_context2) {
5638
- while (1) {
5639
- switch (_context2.prev = _context2.next) {
5640
- case 0:
5641
- if (options === void 0) {
5642
- options = null;
5643
- }
5644
-
5645
- iERC20 = new ethers.ethers.Contract(asset, IERC20.abi, this.signer);
5646
- _context2.next = 4;
5647
- return iERC20.approve(this.address, amount, options);
5648
-
5649
- case 4:
5650
- tx = _context2.sent;
5651
- return _context2.abrupt("return", tx);
5652
-
5653
- case 6:
5654
- case "end":
5655
- return _context2.stop();
5656
- }
5657
- }
5658
- }, _callee2, this);
5659
- }));
5660
-
5661
- function approveDeposit(_x, _x2, _x3) {
5662
- return _approveDeposit.apply(this, arguments);
5663
- }
5664
-
5665
- return approveDeposit;
5666
- }()
5667
- /**
5668
- * Deposit asset into a pool
5669
- * @param {string} asset Address of asset
5670
- * @param {BigNumber | string} amount Amount to be deposited
5671
- * @param {any} options Transaction options
5672
- * @returns {Promise<any>} Transaction
5673
- */
5674
- ;
5675
-
5676
- _proto.deposit =
5677
- /*#__PURE__*/
5678
- function () {
5679
- var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(asset, amount, options) {
5680
- var tx;
5681
- return runtime_1.wrap(function _callee3$(_context3) {
5682
- while (1) {
5683
- switch (_context3.prev = _context3.next) {
5684
- case 0:
5685
- if (options === void 0) {
5686
- options = null;
5687
- }
5688
-
5689
- _context3.next = 3;
5690
- return this.poolLogic.deposit(asset, amount, options);
5691
-
5692
- case 3:
5693
- tx = _context3.sent;
5694
- return _context3.abrupt("return", tx);
5695
-
5696
- case 5:
5697
- case "end":
5698
- return _context3.stop();
5699
- }
5700
- }
5701
- }, _callee3, this);
5702
- }));
5703
-
5704
- function deposit(_x4, _x5, _x6) {
5705
- return _deposit.apply(this, arguments);
5706
- }
5707
-
5708
- return deposit;
5709
- }()
5710
- /**
5711
- * Withdraw assets from a pool
5712
- * @param fundTokenAmount Amount of pool tokens to be withdrawn
5713
- * @param {any} options Transaction options
5714
- * @returns {Promise<any>} Transaction
5715
- */
5716
- ;
5717
-
5718
- _proto.withdraw =
5719
- /*#__PURE__*/
5720
- function () {
5721
- var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(fundTokenAmount, options) {
5722
- var tx;
5723
- return runtime_1.wrap(function _callee4$(_context4) {
5724
- while (1) {
5725
- switch (_context4.prev = _context4.next) {
5726
- case 0:
5727
- if (options === void 0) {
5728
- options = null;
5729
- }
5730
-
5731
- _context4.next = 3;
5732
- return this.poolLogic.withdraw(fundTokenAmount, options);
5733
-
5734
- case 3:
5735
- tx = _context4.sent;
5736
- return _context4.abrupt("return", tx);
5737
-
5738
- case 5:
5739
- case "end":
5740
- return _context4.stop();
5741
- }
5742
- }
5743
- }, _callee4, this);
5744
- }));
5745
-
5746
- function withdraw(_x7, _x8) {
5747
- return _withdraw.apply(this, arguments);
5748
- }
5749
-
5750
- return withdraw;
5751
- }() //Manager functions
5752
-
5753
- /**
5754
- * Approve the asset for trading and providing liquidity
5755
- * @param {Dapp} dapp Platform like Sushiswap or Uniswap
5756
- * @param {string} asset Address of asset
5757
- * @param @param {BigNumber | string} Amount to be approved
5758
- * @param {any} options Transaction options
5759
- * @returns {Promise<any>} Transaction
5760
- */
5761
- ;
5762
-
5763
- _proto.approve =
5764
- /*#__PURE__*/
5765
- function () {
5766
- var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(dapp, asset, amount, options) {
5767
- var iERC20, approveTxData, tx;
5768
- return runtime_1.wrap(function _callee5$(_context5) {
5769
- while (1) {
5770
- switch (_context5.prev = _context5.next) {
5771
- case 0:
5772
- if (options === void 0) {
5773
- options = null;
5774
- }
5775
-
5776
- iERC20 = new ethers.ethers.utils.Interface(IERC20.abi);
5777
- approveTxData = iERC20.encodeFunctionData("approve", [routerAddress[this.network][dapp], amount]);
5778
- _context5.next = 5;
5779
- return this.poolLogic.execTransaction(asset, approveTxData, options);
5780
-
5781
- case 5:
5782
- tx = _context5.sent;
5783
- return _context5.abrupt("return", tx);
5784
-
5785
- case 7:
5786
- case "end":
5787
- return _context5.stop();
5788
- }
5789
- }
5790
- }, _callee5, this);
5791
- }));
5792
-
5793
- function approve(_x9, _x10, _x11, _x12) {
5794
- return _approve.apply(this, arguments);
5795
- }
5796
-
5797
- return approve;
5798
- }()
5799
- /**
5800
- * Approve the liquidity pool token for staking
5801
- * @param {Dapp} dapp Platform like Sushiswap or Uniswap
5802
- * @param {string} asset Address of liquidity pool token
5803
- * @param {BigNumber | string} amount Aamount to be approved
5804
- * @param {any} options Transaction options
5805
- * @returns {Promise<any>} Transaction
5806
- */
5807
- ;
5808
-
5809
- _proto.approveStaking =
5810
- /*#__PURE__*/
5811
- function () {
5595
+ var abi$7 = [
5596
+ {
5597
+ inputs: [
5598
+ {
5599
+ internalType: "contract IVault",
5600
+ name: "vault",
5601
+ type: "address"
5602
+ }
5603
+ ],
5604
+ stateMutability: "nonpayable",
5605
+ type: "constructor"
5606
+ },
5607
+ {
5608
+ anonymous: false,
5609
+ inputs: [
5610
+ {
5611
+ indexed: true,
5612
+ internalType: "address",
5613
+ name: "distributor",
5614
+ type: "address"
5615
+ },
5616
+ {
5617
+ indexed: true,
5618
+ internalType: "contract IERC20",
5619
+ name: "token",
5620
+ type: "address"
5621
+ },
5622
+ {
5623
+ indexed: false,
5624
+ internalType: "uint256",
5625
+ name: "distributionId",
5626
+ type: "uint256"
5627
+ },
5628
+ {
5629
+ indexed: false,
5630
+ internalType: "bytes32",
5631
+ name: "merkleRoot",
5632
+ type: "bytes32"
5633
+ },
5634
+ {
5635
+ indexed: false,
5636
+ internalType: "uint256",
5637
+ name: "amount",
5638
+ type: "uint256"
5639
+ }
5640
+ ],
5641
+ name: "DistributionAdded",
5642
+ type: "event"
5643
+ },
5644
+ {
5645
+ anonymous: false,
5646
+ inputs: [
5647
+ {
5648
+ indexed: true,
5649
+ internalType: "address",
5650
+ name: "distributor",
5651
+ type: "address"
5652
+ },
5653
+ {
5654
+ indexed: true,
5655
+ internalType: "contract IERC20",
5656
+ name: "token",
5657
+ type: "address"
5658
+ },
5659
+ {
5660
+ indexed: false,
5661
+ internalType: "uint256",
5662
+ name: "distributionId",
5663
+ type: "uint256"
5664
+ },
5665
+ {
5666
+ indexed: true,
5667
+ internalType: "address",
5668
+ name: "claimer",
5669
+ type: "address"
5670
+ },
5671
+ {
5672
+ indexed: false,
5673
+ internalType: "address",
5674
+ name: "recipient",
5675
+ type: "address"
5676
+ },
5677
+ {
5678
+ indexed: false,
5679
+ internalType: "uint256",
5680
+ name: "amount",
5681
+ type: "uint256"
5682
+ }
5683
+ ],
5684
+ name: "DistributionClaimed",
5685
+ type: "event"
5686
+ },
5687
+ {
5688
+ inputs: [
5689
+ {
5690
+ internalType: "address",
5691
+ name: "claimer",
5692
+ type: "address"
5693
+ },
5694
+ {
5695
+ components: [
5696
+ {
5697
+ internalType: "uint256",
5698
+ name: "distributionId",
5699
+ type: "uint256"
5700
+ },
5701
+ {
5702
+ internalType: "uint256",
5703
+ name: "balance",
5704
+ type: "uint256"
5705
+ },
5706
+ {
5707
+ internalType: "address",
5708
+ name: "distributor",
5709
+ type: "address"
5710
+ },
5711
+ {
5712
+ internalType: "uint256",
5713
+ name: "tokenIndex",
5714
+ type: "uint256"
5715
+ },
5716
+ {
5717
+ internalType: "bytes32[]",
5718
+ name: "merkleProof",
5719
+ type: "bytes32[]"
5720
+ }
5721
+ ],
5722
+ internalType: "struct MerkleOrchard.Claim[]",
5723
+ name: "claims",
5724
+ type: "tuple[]"
5725
+ },
5726
+ {
5727
+ internalType: "contract IERC20[]",
5728
+ name: "tokens",
5729
+ type: "address[]"
5730
+ }
5731
+ ],
5732
+ name: "claimDistributions",
5733
+ outputs: [
5734
+ ],
5735
+ stateMutability: "nonpayable",
5736
+ type: "function"
5737
+ },
5738
+ {
5739
+ inputs: [
5740
+ {
5741
+ internalType: "address",
5742
+ name: "claimer",
5743
+ type: "address"
5744
+ },
5745
+ {
5746
+ components: [
5747
+ {
5748
+ internalType: "uint256",
5749
+ name: "distributionId",
5750
+ type: "uint256"
5751
+ },
5752
+ {
5753
+ internalType: "uint256",
5754
+ name: "balance",
5755
+ type: "uint256"
5756
+ },
5757
+ {
5758
+ internalType: "address",
5759
+ name: "distributor",
5760
+ type: "address"
5761
+ },
5762
+ {
5763
+ internalType: "uint256",
5764
+ name: "tokenIndex",
5765
+ type: "uint256"
5766
+ },
5767
+ {
5768
+ internalType: "bytes32[]",
5769
+ name: "merkleProof",
5770
+ type: "bytes32[]"
5771
+ }
5772
+ ],
5773
+ internalType: "struct MerkleOrchard.Claim[]",
5774
+ name: "claims",
5775
+ type: "tuple[]"
5776
+ },
5777
+ {
5778
+ internalType: "contract IERC20[]",
5779
+ name: "tokens",
5780
+ type: "address[]"
5781
+ }
5782
+ ],
5783
+ name: "claimDistributionsToInternalBalance",
5784
+ outputs: [
5785
+ ],
5786
+ stateMutability: "nonpayable",
5787
+ type: "function"
5788
+ },
5789
+ {
5790
+ inputs: [
5791
+ {
5792
+ internalType: "address",
5793
+ name: "claimer",
5794
+ type: "address"
5795
+ },
5796
+ {
5797
+ components: [
5798
+ {
5799
+ internalType: "uint256",
5800
+ name: "distributionId",
5801
+ type: "uint256"
5802
+ },
5803
+ {
5804
+ internalType: "uint256",
5805
+ name: "balance",
5806
+ type: "uint256"
5807
+ },
5808
+ {
5809
+ internalType: "address",
5810
+ name: "distributor",
5811
+ type: "address"
5812
+ },
5813
+ {
5814
+ internalType: "uint256",
5815
+ name: "tokenIndex",
5816
+ type: "uint256"
5817
+ },
5818
+ {
5819
+ internalType: "bytes32[]",
5820
+ name: "merkleProof",
5821
+ type: "bytes32[]"
5822
+ }
5823
+ ],
5824
+ internalType: "struct MerkleOrchard.Claim[]",
5825
+ name: "claims",
5826
+ type: "tuple[]"
5827
+ },
5828
+ {
5829
+ internalType: "contract IERC20[]",
5830
+ name: "tokens",
5831
+ type: "address[]"
5832
+ },
5833
+ {
5834
+ internalType: "contract IDistributorCallback",
5835
+ name: "callbackContract",
5836
+ type: "address"
5837
+ },
5838
+ {
5839
+ internalType: "bytes",
5840
+ name: "callbackData",
5841
+ type: "bytes"
5842
+ }
5843
+ ],
5844
+ name: "claimDistributionsWithCallback",
5845
+ outputs: [
5846
+ ],
5847
+ stateMutability: "nonpayable",
5848
+ type: "function"
5849
+ },
5850
+ {
5851
+ inputs: [
5852
+ {
5853
+ internalType: "contract IERC20",
5854
+ name: "token",
5855
+ type: "address"
5856
+ },
5857
+ {
5858
+ internalType: "bytes32",
5859
+ name: "merkleRoot",
5860
+ type: "bytes32"
5861
+ },
5862
+ {
5863
+ internalType: "uint256",
5864
+ name: "amount",
5865
+ type: "uint256"
5866
+ },
5867
+ {
5868
+ internalType: "uint256",
5869
+ name: "distributionId",
5870
+ type: "uint256"
5871
+ }
5872
+ ],
5873
+ name: "createDistribution",
5874
+ outputs: [
5875
+ ],
5876
+ stateMutability: "nonpayable",
5877
+ type: "function"
5878
+ },
5879
+ {
5880
+ inputs: [
5881
+ {
5882
+ internalType: "contract IERC20",
5883
+ name: "token",
5884
+ type: "address"
5885
+ },
5886
+ {
5887
+ internalType: "address",
5888
+ name: "distributor",
5889
+ type: "address"
5890
+ },
5891
+ {
5892
+ internalType: "uint256",
5893
+ name: "distributionId",
5894
+ type: "uint256"
5895
+ }
5896
+ ],
5897
+ name: "getDistributionRoot",
5898
+ outputs: [
5899
+ {
5900
+ internalType: "bytes32",
5901
+ name: "",
5902
+ type: "bytes32"
5903
+ }
5904
+ ],
5905
+ stateMutability: "view",
5906
+ type: "function"
5907
+ },
5908
+ {
5909
+ inputs: [
5910
+ {
5911
+ internalType: "contract IERC20",
5912
+ name: "token",
5913
+ type: "address"
5914
+ },
5915
+ {
5916
+ internalType: "address",
5917
+ name: "distributor",
5918
+ type: "address"
5919
+ }
5920
+ ],
5921
+ name: "getNextDistributionId",
5922
+ outputs: [
5923
+ {
5924
+ internalType: "uint256",
5925
+ name: "",
5926
+ type: "uint256"
5927
+ }
5928
+ ],
5929
+ stateMutability: "view",
5930
+ type: "function"
5931
+ },
5932
+ {
5933
+ inputs: [
5934
+ {
5935
+ internalType: "contract IERC20",
5936
+ name: "token",
5937
+ type: "address"
5938
+ },
5939
+ {
5940
+ internalType: "address",
5941
+ name: "distributor",
5942
+ type: "address"
5943
+ }
5944
+ ],
5945
+ name: "getRemainingBalance",
5946
+ outputs: [
5947
+ {
5948
+ internalType: "uint256",
5949
+ name: "",
5950
+ type: "uint256"
5951
+ }
5952
+ ],
5953
+ stateMutability: "view",
5954
+ type: "function"
5955
+ },
5956
+ {
5957
+ inputs: [
5958
+ ],
5959
+ name: "getVault",
5960
+ outputs: [
5961
+ {
5962
+ internalType: "contract IVault",
5963
+ name: "",
5964
+ type: "address"
5965
+ }
5966
+ ],
5967
+ stateMutability: "view",
5968
+ type: "function"
5969
+ },
5970
+ {
5971
+ inputs: [
5972
+ {
5973
+ internalType: "contract IERC20",
5974
+ name: "token",
5975
+ type: "address"
5976
+ },
5977
+ {
5978
+ internalType: "address",
5979
+ name: "distributor",
5980
+ type: "address"
5981
+ },
5982
+ {
5983
+ internalType: "uint256",
5984
+ name: "distributionId",
5985
+ type: "uint256"
5986
+ },
5987
+ {
5988
+ internalType: "address",
5989
+ name: "claimer",
5990
+ type: "address"
5991
+ }
5992
+ ],
5993
+ name: "isClaimed",
5994
+ outputs: [
5995
+ {
5996
+ internalType: "bool",
5997
+ name: "",
5998
+ type: "bool"
5999
+ }
6000
+ ],
6001
+ stateMutability: "view",
6002
+ type: "function"
6003
+ },
6004
+ {
6005
+ inputs: [
6006
+ {
6007
+ internalType: "contract IERC20",
6008
+ name: "token",
6009
+ type: "address"
6010
+ },
6011
+ {
6012
+ internalType: "address",
6013
+ name: "distributor",
6014
+ type: "address"
6015
+ },
6016
+ {
6017
+ internalType: "uint256",
6018
+ name: "distributionId",
6019
+ type: "uint256"
6020
+ },
6021
+ {
6022
+ internalType: "address",
6023
+ name: "claimer",
6024
+ type: "address"
6025
+ },
6026
+ {
6027
+ internalType: "uint256",
6028
+ name: "claimedBalance",
6029
+ type: "uint256"
6030
+ },
6031
+ {
6032
+ internalType: "bytes32[]",
6033
+ name: "merkleProof",
6034
+ type: "bytes32[]"
6035
+ }
6036
+ ],
6037
+ name: "verifyClaim",
6038
+ outputs: [
6039
+ {
6040
+ internalType: "bool",
6041
+ name: "",
6042
+ type: "bool"
6043
+ }
6044
+ ],
6045
+ stateMutability: "view",
6046
+ type: "function"
6047
+ }
6048
+ ];
6049
+ var IBalancerMerkleOrchard = {
6050
+ abi: abi$7
6051
+ };
6052
+
6053
+ var abi$8 = [
6054
+ {
6055
+ inputs: [
6056
+ {
6057
+ internalType: "address[]",
6058
+ name: "assets",
6059
+ type: "address[]"
6060
+ },
6061
+ {
6062
+ internalType: "uint256",
6063
+ name: "amount",
6064
+ type: "uint256"
6065
+ },
6066
+ {
6067
+ internalType: "address",
6068
+ name: "to",
6069
+ type: "address"
6070
+ }
6071
+ ],
6072
+ name: "claimRewards",
6073
+ outputs: [
6074
+ ],
6075
+ stateMutability: "nonpayable",
6076
+ type: "function"
6077
+ },
6078
+ {
6079
+ inputs: [
6080
+ {
6081
+ internalType: "address",
6082
+ name: "user",
6083
+ type: "address"
6084
+ }
6085
+ ],
6086
+ name: "getUserUnclaimedRewards",
6087
+ outputs: [
6088
+ {
6089
+ internalType: "uint256",
6090
+ name: "rewards",
6091
+ type: "uint256"
6092
+ }
6093
+ ],
6094
+ stateMutability: "view",
6095
+ type: "function"
6096
+ }
6097
+ ];
6098
+ var bytecode = "0x";
6099
+ var deployedBytecode = "0x";
6100
+ var linkReferences = {
6101
+ };
6102
+ var deployedLinkReferences = {
6103
+ };
6104
+ var IAaveIncentivesController = {
6105
+ abi: abi$8,
6106
+ bytecode: bytecode,
6107
+ deployedBytecode: deployedBytecode,
6108
+ linkReferences: linkReferences,
6109
+ deployedLinkReferences: deployedLinkReferences
6110
+ };
6111
+
6112
+ function multicall(_x5, _x6, _x7, _x8, _x9, _x10) {
6113
+ return _multicall.apply(this, arguments);
6114
+ }
6115
+
6116
+ function _multicall() {
6117
+ _multicall = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(network, provider, abi, calls, options, requireSuccess) {
6118
+ var multi, itf, res;
6119
+ return runtime_1.wrap(function _callee3$(_context3) {
6120
+ while (1) {
6121
+ switch (_context3.prev = _context3.next) {
6122
+ case 0:
6123
+ if (options === void 0) {
6124
+ options = {};
6125
+ }
6126
+
6127
+ if (requireSuccess === void 0) {
6128
+ requireSuccess = false;
6129
+ }
6130
+
6131
+ 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);
6132
+ itf = new abi$c.Interface(abi);
6133
+ _context3.prev = 4;
6134
+ _context3.next = 7;
6135
+ return multi.tryAggregate( // if false, allows individual calls to fail without causing entire multicall to fail
6136
+ requireSuccess, calls.map(function (call) {
6137
+ return [call[0].toLowerCase(), itf.encodeFunctionData(call[1], call[2])];
6138
+ }), options);
6139
+
6140
+ case 7:
6141
+ res = _context3.sent;
6142
+ return _context3.abrupt("return", res.map(function (_ref, i) {
6143
+ var success = _ref[0],
6144
+ returnData = _ref[1];
6145
+ if (!success) return null;
6146
+ var decodedResult = itf.decodeFunctionResult(calls[i][1], returnData); // Automatically unwrap any simple return values
6147
+
6148
+ // Automatically unwrap any simple return values
6149
+ return decodedResult.length > 1 ? decodedResult : decodedResult[0];
6150
+ }));
6151
+
6152
+ case 11:
6153
+ _context3.prev = 11;
6154
+ _context3.t0 = _context3["catch"](4);
6155
+ return _context3.abrupt("return", Promise.reject(_context3.t0));
6156
+
6157
+ case 14:
6158
+ case "end":
6159
+ return _context3.stop();
6160
+ }
6161
+ }
6162
+ }, _callee3, null, [[4, 11]]);
6163
+ }));
6164
+ return _multicall.apply(this, arguments);
6165
+ }
6166
+
6167
+ var MerkleTree = /*#__PURE__*/function () {
6168
+ function MerkleTree(elements) {
6169
+ this.elements = elements.filter(function (el) {
6170
+ return el;
6171
+ }).map(function (el) {
6172
+ return Buffer.from(web3Utils.hexToBytes(el));
6173
+ }); // Sort elements
6174
+
6175
+ this.elements.sort(Buffer.compare); // Deduplicate elements
6176
+
6177
+ this.elements = this.bufDedup(this.elements); // Create layers
6178
+
6179
+ this.layers = this.getLayers(this.elements);
6180
+ }
6181
+
6182
+ var _proto = MerkleTree.prototype;
6183
+
6184
+ _proto.getLayers = function getLayers(elements) {
6185
+ if (elements.length === 0) {
6186
+ return [[""]];
6187
+ }
6188
+
6189
+ var layers = [];
6190
+ layers.push(elements); // Get next layer until we reach the root=
6191
+
6192
+ while (layers[layers.length - 1].length > 1) {
6193
+ // @ts-ignore
6194
+ layers.push(this.getNextLayer(layers[layers.length - 1]));
6195
+ }
6196
+
6197
+ return layers;
6198
+ };
6199
+
6200
+ _proto.getNextLayer = function getNextLayer(elements) {
6201
+ var _this = this;
6202
+
6203
+ return elements.reduce(function (layer, el, idx, arr) {
6204
+ if (idx % 2 === 0) {
6205
+ // Hash the current element with its pair element
6206
+ layer.push(_this.combinedHash(el, arr[idx + 1]));
6207
+ }
6208
+
6209
+ return layer;
6210
+ }, []);
6211
+ };
6212
+
6213
+ _proto.combinedHash = function combinedHash(first, second) {
6214
+ if (!first) {
6215
+ return second;
6216
+ }
6217
+
6218
+ if (!second) {
6219
+ return first;
6220
+ }
6221
+
6222
+ return ethereumjsUtil.keccak256(this.sortAndConcat(first, second));
6223
+ };
6224
+
6225
+ _proto.getRoot = function getRoot() {
6226
+ return this.layers[this.layers.length - 1][0];
6227
+ };
6228
+
6229
+ _proto.getHexRoot = function getHexRoot() {
6230
+ return ethereumjsUtil.bufferToHex(this.getRoot());
6231
+ };
6232
+
6233
+ _proto.getProof = function getProof(el) {
6234
+ var _this2 = this;
6235
+
6236
+ var idx = this.bufIndexOf(el, this.elements);
6237
+
6238
+ if (idx === -1) {
6239
+ throw new Error("Element does not exist in Merkle tree");
6240
+ }
6241
+
6242
+ return this.layers.reduce(function (proof, layer) {
6243
+ var pairElement = _this2.getPairElement(idx, layer);
6244
+
6245
+ if (pairElement) {
6246
+ proof.push(pairElement);
6247
+ }
6248
+
6249
+ idx = Math.floor(idx / 2);
6250
+ return proof;
6251
+ }, []);
6252
+ } // external call - convert to buffer
6253
+ ;
6254
+
6255
+ _proto.getHexProof = function getHexProof(_el) {
6256
+ var el = Buffer.from(web3Utils.hexToBytes(_el));
6257
+ var proof = this.getProof(el);
6258
+ return this.bufArrToHexArr(proof);
6259
+ };
6260
+
6261
+ _proto.getPairElement = function getPairElement(idx, layer) {
6262
+ var pairIdx = idx % 2 === 0 ? idx + 1 : idx - 1;
6263
+
6264
+ if (pairIdx < layer.length) {
6265
+ return layer[pairIdx];
6266
+ } else {
6267
+ return null;
6268
+ }
6269
+ };
6270
+
6271
+ _proto.bufIndexOf = function bufIndexOf(el, arr) {
6272
+ var hash; // Convert element to 32 byte hash if it is not one already
6273
+
6274
+ if (el.length !== 32 || !Buffer.isBuffer(el)) {
6275
+ hash = ethereumjsUtil.keccakFromString(el);
6276
+ } else {
6277
+ hash = el;
6278
+ }
6279
+
6280
+ for (var i = 0; i < arr.length; i++) {
6281
+ if (hash.equals(arr[i])) {
6282
+ return i;
6283
+ }
6284
+ }
6285
+
6286
+ return -1;
6287
+ };
6288
+
6289
+ _proto.bufDedup = function bufDedup(elements) {
6290
+ return elements.filter(function (el, idx) {
6291
+ return idx === 0 || !elements[idx - 1].equals(el);
6292
+ });
6293
+ };
6294
+
6295
+ _proto.bufArrToHexArr = function bufArrToHexArr(arr) {
6296
+ if (arr.some(function (el) {
6297
+ return !Buffer.isBuffer(el);
6298
+ })) {
6299
+ throw new Error("Array is not an array of buffers");
6300
+ }
6301
+
6302
+ return arr.map(function (el) {
6303
+ return "0x" + el.toString("hex");
6304
+ });
6305
+ };
6306
+
6307
+ _proto.sortAndConcat = function sortAndConcat() {
6308
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6309
+ args[_key] = arguments[_key];
6310
+ }
6311
+
6312
+ return Buffer.concat([].concat(args).sort(Buffer.compare));
6313
+ };
6314
+
6315
+ return MerkleTree;
6316
+ }();
6317
+
6318
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6319
+ function scale(input, decimalPlaces) {
6320
+ var unscaled = typeof input === "string" ? new BigNumber(input) : input;
6321
+ var scalePow = new BigNumber(decimalPlaces.toString());
6322
+ var scaleMul = new BigNumber(10).pow(scalePow);
6323
+ return unscaled.times(scaleMul);
6324
+ }
6325
+ function loadTree(balances, decimals) {
6326
+ if (decimals === void 0) {
6327
+ decimals = 18;
6328
+ }
6329
+
6330
+ var elements = [];
6331
+ Object.keys(balances).forEach(function (address) {
6332
+ var balance = scale(balances[address], decimals).toString(10);
6333
+ var leaf = web3Utils.soliditySha3({
6334
+ t: "address",
6335
+ v: address
6336
+ }, {
6337
+ t: "uint",
6338
+ v: balance
6339
+ }); // @ts-ignore
6340
+
6341
+ elements.push(leaf);
6342
+ });
6343
+ return new MerkleTree(elements);
6344
+ }
6345
+ function bnum(val) {
6346
+ var number = typeof val === "string" ? val : val ? val.toString() : "0";
6347
+ return new BigNumber(number);
6348
+ }
6349
+
6350
+ var IpfsService = /*#__PURE__*/function () {
6351
+ function IpfsService() {}
6352
+
6353
+ var _proto = IpfsService.prototype;
6354
+
6355
+ _proto.get = /*#__PURE__*/function () {
6356
+ var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(hash, protocol) {
6357
+ var _yield$axios$get, data;
6358
+
6359
+ return runtime_1.wrap(function _callee$(_context) {
6360
+ while (1) {
6361
+ switch (_context.prev = _context.next) {
6362
+ case 0:
6363
+ if (protocol === void 0) {
6364
+ protocol = "ipfs";
6365
+ }
6366
+
6367
+ _context.next = 3;
6368
+ return axios.get("https://cloudflare-ipfs.com/" + protocol + "/" + hash);
6369
+
6370
+ case 3:
6371
+ _yield$axios$get = _context.sent;
6372
+ data = _yield$axios$get.data;
6373
+ return _context.abrupt("return", data);
6374
+
6375
+ case 6:
6376
+ case "end":
6377
+ return _context.stop();
6378
+ }
6379
+ }
6380
+ }, _callee);
6381
+ }));
6382
+
6383
+ function get(_x, _x2) {
6384
+ return _get.apply(this, arguments);
6385
+ }
6386
+
6387
+ return get;
6388
+ }();
6389
+
6390
+ return IpfsService;
6391
+ }();
6392
+ var ipfsService = /*#__PURE__*/new IpfsService();
6393
+
6394
+ var MultiTokenClaim = {
6395
+ "1": [
6396
+ {
6397
+ label: "BAL",
6398
+ distributor: "0xd2EB7Bd802A7CA68d9AcD209bEc4E664A9abDD7b",
6399
+ token: "0xba100000625a3754423978a60c9317c58a424e3d",
6400
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current.json",
6401
+ weekStart: 52
6402
+ },
6403
+ {
6404
+ label: "UNN",
6405
+ distributor: "0xBfbd6e720ffdF0497f69C95E5C03a4861C65A6E7",
6406
+ token: "0x226f7b842E0F0120b7E194D05432b3fd14773a9D",
6407
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-union.json",
6408
+ weekStart: 1
6409
+ },
6410
+ {
6411
+ label: "BANK",
6412
+ distributor: "0x9d20FE66eC5Dd15a3D3213556534C77cA20318bE",
6413
+ token: "0x2d94AA3e47d9D5024503Ca8491fcE9A2fB4DA198",
6414
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-bankless.json",
6415
+ weekStart: 1
6416
+ },
6417
+ {
6418
+ label: "NOTE",
6419
+ distributor: "0xF1C2dD9bD863f2444086B739383F1043E6b88F69",
6420
+ token: "0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5",
6421
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-note.json",
6422
+ weekStart: 1
6423
+ },
6424
+ {
6425
+ label: "NEXO",
6426
+ distributor: "0x0000000000000000000000000000000000000000",
6427
+ token: "0xB62132e35a6c13ee1EE0f84dC5d40bad8d815206",
6428
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-nexo.json",
6429
+ weekStart: 1
6430
+ }
6431
+ ],
6432
+ "42": [
6433
+ {
6434
+ label: "BAL",
6435
+ distributor: "0x95FaE1C936B4Cd6c5099d7A705D792ee6aC9FEc3",
6436
+ token: "0x41286Bb1D3E870f3F750eB7E1C25d7E48c8A1Ac7",
6437
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/sample-tree/reports-kovan/_current.json",
6438
+ weekStart: 52
6439
+ },
6440
+ {
6441
+ label: "DAI",
6442
+ distributor: "0x95FaE1C936B4Cd6c5099d7A705D792ee6aC9FEc3",
6443
+ token: "0x04DF6e4121c27713ED22341E7c7Df330F56f289B",
6444
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/sample-tree/reports-kovan/_current-dai.json",
6445
+ weekStart: 1
6446
+ }
6447
+ ],
6448
+ "137": [
6449
+ {
6450
+ label: "BAL",
6451
+ distributor: "0xd2EB7Bd802A7CA68d9AcD209bEc4E664A9abDD7b",
6452
+ token: "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",
6453
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-polygon.json",
6454
+ weekStart: 1
6455
+ },
6456
+ {
6457
+ label: "WMATIC",
6458
+ distributor: "0x087A7AFB6975A2837453BE685EB6272576c0bC06",
6459
+ token: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
6460
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-wmatic-polygon.json",
6461
+ weekStart: 1
6462
+ },
6463
+ {
6464
+ label: "WMATIC",
6465
+ distributor: "0xBd44C01EC7d623372B4572247afB6231eDD8486F",
6466
+ token: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
6467
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-wmatic-polygon.json",
6468
+ weekStart: 4
6469
+ },
6470
+ {
6471
+ label: "WMATIC",
6472
+ distributor: "0x632208491602Dd205da8Cb9C0BA98620fc19854A",
6473
+ token: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
6474
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-wmatic-polygon.json",
6475
+ weekStart: 5
6476
+ },
6477
+ {
6478
+ label: "TUSD",
6479
+ distributor: "0x09f3010ec0f6d72ef8ff2008f8e756d60482c9a8",
6480
+ token: "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",
6481
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-tusd-polygon.json",
6482
+ weekStart: 1
6483
+ }
6484
+ ],
6485
+ "42161": [
6486
+ {
6487
+ label: "BAL",
6488
+ distributor: "0xd2EB7Bd802A7CA68d9AcD209bEc4E664A9abDD7b",
6489
+ token: "0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8",
6490
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-arbitrum.json",
6491
+ weekStart: 6
6492
+ },
6493
+ {
6494
+ label: "MCB",
6495
+ distributor: "0x25c646adf184051b35a405b9aaeba321e8d5342a",
6496
+ token: "0x4e352cf164e64adcbad318c3a1e222e9eba4ce42",
6497
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-mcdex-arbitrum.json",
6498
+ weekStart: 4
6499
+ },
6500
+ {
6501
+ label: "PICKLE",
6502
+ distributor: "0xf02CeB58d549E4b403e8F85FBBaEe4c5dfA47c01",
6503
+ token: "0x965772e0e9c84b6f359c8597c891108dcf1c5b1a",
6504
+ manifest: "https://raw.githubusercontent.com/balancer-labs/bal-mining-scripts/master/reports/_current-pickle-arbitrum.json",
6505
+ weekStart: 4
6506
+ }
6507
+ ]
6508
+ };
6509
+
6510
+ var ClaimService = /*#__PURE__*/function () {
6511
+ function ClaimService(network, signer) {
6512
+ this.network = network;
6513
+ this.signer = signer;
6514
+ }
6515
+
6516
+ var _proto = ClaimService.prototype;
6517
+
6518
+ _proto.getMultiTokensPendingClaims = /*#__PURE__*/function () {
6519
+ var _getMultiTokensPendingClaims = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(account) {
6520
+ var _this = this;
6521
+
6522
+ var tokenClaimsInfo, multiTokenPendingClaims, multiTokenPendingClaimsWithRewards;
6523
+ return runtime_1.wrap(function _callee$(_context) {
6524
+ while (1) {
6525
+ switch (_context.prev = _context.next) {
6526
+ case 0:
6527
+ tokenClaimsInfo = this.getTokenClaimsInfo();
6528
+
6529
+ if (!(tokenClaimsInfo != null)) {
6530
+ _context.next = 7;
6531
+ break;
6532
+ }
6533
+
6534
+ _context.next = 4;
6535
+ return Promise.all(tokenClaimsInfo.map(function (tokenClaimInfo) {
6536
+ return _this.getTokenPendingClaims(tokenClaimInfo, address.getAddress(account));
6537
+ }));
6538
+
6539
+ case 4:
6540
+ multiTokenPendingClaims = _context.sent;
6541
+ multiTokenPendingClaimsWithRewards = multiTokenPendingClaims.filter(function (pendingClaim) {
6542
+ return Number(pendingClaim.availableToClaim) > 0;
6543
+ });
6544
+ return _context.abrupt("return", multiTokenPendingClaimsWithRewards);
6545
+
6546
+ case 7:
6547
+ return _context.abrupt("return", []);
6548
+
6549
+ case 8:
6550
+ case "end":
6551
+ return _context.stop();
6552
+ }
6553
+ }
6554
+ }, _callee, this);
6555
+ }));
6556
+
6557
+ function getMultiTokensPendingClaims(_x) {
6558
+ return _getMultiTokensPendingClaims.apply(this, arguments);
6559
+ }
6560
+
6561
+ return getMultiTokensPendingClaims;
6562
+ }();
6563
+
6564
+ _proto.getTokenPendingClaims = /*#__PURE__*/function () {
6565
+ var _getTokenPendingClaims = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tokenClaimInfo, account) {
6566
+ var snapshot, weekStart, claimStatus, pendingWeeks, reports, claims, availableToClaim;
6567
+ return runtime_1.wrap(function _callee2$(_context2) {
6568
+ while (1) {
6569
+ switch (_context2.prev = _context2.next) {
6570
+ case 0:
6571
+ _context2.next = 2;
6572
+ return this.getSnapshot(tokenClaimInfo.manifest);
6573
+
6574
+ case 2:
6575
+ snapshot = _context2.sent;
6576
+ weekStart = tokenClaimInfo.weekStart;
6577
+ _context2.next = 6;
6578
+ return this.getClaimStatus(Object.keys(snapshot).length, account, tokenClaimInfo);
6579
+
6580
+ case 6:
6581
+ claimStatus = _context2.sent;
6582
+ pendingWeeks = claimStatus.map(function (status, i) {
6583
+ return [i + weekStart, status];
6584
+ }).filter(function (_ref) {
6585
+ var status = _ref[1];
6586
+ return !status;
6587
+ }).map(function (_ref2) {
6588
+ var i = _ref2[0];
6589
+ return i;
6590
+ });
6591
+ _context2.next = 10;
6592
+ return this.getReports(snapshot, pendingWeeks);
6593
+
6594
+ case 10:
6595
+ reports = _context2.sent;
6596
+ claims = Object.entries(reports).filter(function (report) {
6597
+ return report[1][account];
6598
+ }).map(function (report) {
6599
+ return {
6600
+ id: report[0],
6601
+ amount: report[1][account]
6602
+ };
6603
+ }); //console.log("claims", claims);
6604
+
6605
+ availableToClaim = claims.map(function (claim) {
6606
+ return parseFloat(claim.amount);
6607
+ }).reduce(function (total, amount) {
6608
+ return total.plus(amount);
6609
+ }, bnum(0)).toString();
6610
+ return _context2.abrupt("return", {
6611
+ claims: claims,
6612
+ reports: reports,
6613
+ tokenClaimInfo: tokenClaimInfo,
6614
+ availableToClaim: availableToClaim
6615
+ });
6616
+
6617
+ case 14:
6618
+ case "end":
6619
+ return _context2.stop();
6620
+ }
6621
+ }
6622
+ }, _callee2, this);
6623
+ }));
6624
+
6625
+ function getTokenPendingClaims(_x2, _x3) {
6626
+ return _getTokenPendingClaims.apply(this, arguments);
6627
+ }
6628
+
6629
+ return getTokenPendingClaims;
6630
+ }();
6631
+
6632
+ _proto.getMultiTokensCurrentRewardsEstimate = /*#__PURE__*/function () {
6633
+ var _getMultiTokensCurrentRewardsEstimate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(account) {
6634
+ var response, multiTokenLiquidityProviders, multiTokenCurrentRewardsEstimate, multiTokenLiquidityProvidersByToken, _i, _multiTokenLiquidityP, _liquidityProvider$fi, _liquidityProvider$fi2, _multiTokenLiquidityP2, token, liquidityProvider, rewards, velocity;
6635
+
6636
+ return runtime_1.wrap(function _callee3$(_context3) {
6637
+ while (1) {
6638
+ switch (_context3.prev = _context3.next) {
6639
+ case 0:
6640
+ _context3.prev = 0;
6641
+ _context3.next = 3;
6642
+ return axios.get("https://api.balancer.finance/liquidity-mining/v1/liquidity-provider-multitoken/" + account);
6643
+
6644
+ case 3:
6645
+ response = _context3.sent;
6646
+
6647
+ if (!response.data.success) {
6648
+ _context3.next = 10;
6649
+ break;
6650
+ }
6651
+
6652
+ multiTokenLiquidityProviders = response.data.result["liquidity-providers"].filter(function (incentive) {
6653
+ return incentive.chain_id === 137;
6654
+ }).map(function (incentive) {
6655
+ return _extends({}, incentive, {
6656
+ token_address: address.getAddress(incentive.token_address)
6657
+ });
6658
+ });
6659
+ multiTokenCurrentRewardsEstimate = [];
6660
+ multiTokenLiquidityProvidersByToken = Object.entries(lodash.groupBy(multiTokenLiquidityProviders, "token_address"));
6661
+
6662
+ for (_i = 0, _multiTokenLiquidityP = multiTokenLiquidityProvidersByToken; _i < _multiTokenLiquidityP.length; _i++) {
6663
+ _multiTokenLiquidityP2 = _multiTokenLiquidityP[_i], token = _multiTokenLiquidityP2[0], liquidityProvider = _multiTokenLiquidityP2[1];
6664
+ rewards = liquidityProvider.reduce(function (total, _ref3) {
6665
+ var current_estimate = _ref3.current_estimate;
6666
+ return total.plus(current_estimate);
6667
+ }, bnum(0)).toString();
6668
+ velocity = (_liquidityProvider$fi = (_liquidityProvider$fi2 = liquidityProvider.find(function (liquidityProvider) {
6669
+ return Number(liquidityProvider.velocity) > 0;
6670
+ })) == null ? void 0 : _liquidityProvider$fi2.velocity.toString()) != null ? _liquidityProvider$fi : "0";
6671
+
6672
+ if (Number(rewards) > 0) {
6673
+ multiTokenCurrentRewardsEstimate.push({
6674
+ rewards: rewards,
6675
+ velocity: velocity,
6676
+ token: address.getAddress(token)
6677
+ });
6678
+ }
6679
+ }
6680
+
6681
+ return _context3.abrupt("return", {
6682
+ data: multiTokenCurrentRewardsEstimate,
6683
+ timestamp: response.data.result.current_timestamp
6684
+ });
6685
+
6686
+ case 10:
6687
+ _context3.next = 15;
6688
+ break;
6689
+
6690
+ case 12:
6691
+ _context3.prev = 12;
6692
+ _context3.t0 = _context3["catch"](0);
6693
+ console.log("[Claim] Current Rewards Estimate Error", _context3.t0);
6694
+
6695
+ case 15:
6696
+ return _context3.abrupt("return", {
6697
+ data: [],
6698
+ timestamp: null
6699
+ });
6700
+
6701
+ case 16:
6702
+ case "end":
6703
+ return _context3.stop();
6704
+ }
6705
+ }
6706
+ }, _callee3, null, [[0, 12]]);
6707
+ }));
6708
+
6709
+ function getMultiTokensCurrentRewardsEstimate(_x4) {
6710
+ return _getMultiTokensCurrentRewardsEstimate.apply(this, arguments);
6711
+ }
6712
+
6713
+ return getMultiTokensCurrentRewardsEstimate;
6714
+ }();
6715
+
6716
+ _proto.multiTokenClaimRewards = /*#__PURE__*/function () {
6717
+ var _multiTokenClaimRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(account, multiTokenPendingClaims) {
6718
+ var _this2 = this;
6719
+
6720
+ var multiTokenClaims;
6721
+ return runtime_1.wrap(function _callee4$(_context4) {
6722
+ while (1) {
6723
+ switch (_context4.prev = _context4.next) {
6724
+ case 0:
6725
+ _context4.prev = 0;
6726
+ _context4.next = 3;
6727
+ return Promise.all(multiTokenPendingClaims.map(function (tokenPendingClaims, tokenIndex) {
6728
+ return _this2.computeClaimProofs(tokenPendingClaims, address.getAddress(account), tokenIndex);
6729
+ }));
6730
+
6731
+ case 3:
6732
+ multiTokenClaims = _context4.sent;
6733
+ return _context4.abrupt("return", lodash.flatten(multiTokenClaims));
6734
+
6735
+ case 7:
6736
+ _context4.prev = 7;
6737
+ _context4.t0 = _context4["catch"](0);
6738
+ console.log("[Claim] Claim Rewards Error:", _context4.t0);
6739
+ return _context4.abrupt("return", Promise.reject(_context4.t0));
6740
+
6741
+ case 11:
6742
+ case "end":
6743
+ return _context4.stop();
6744
+ }
6745
+ }
6746
+ }, _callee4, null, [[0, 7]]);
6747
+ }));
6748
+
6749
+ function multiTokenClaimRewards(_x5, _x6) {
6750
+ return _multiTokenClaimRewards.apply(this, arguments);
6751
+ }
6752
+
6753
+ return multiTokenClaimRewards;
6754
+ }();
6755
+
6756
+ _proto.computeClaimProofs = /*#__PURE__*/function () {
6757
+ var _computeClaimProofs = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(tokenPendingClaims, account, tokenIndex) {
6758
+ var _this3 = this;
6759
+
6760
+ return runtime_1.wrap(function _callee5$(_context5) {
6761
+ while (1) {
6762
+ switch (_context5.prev = _context5.next) {
6763
+ case 0:
6764
+ return _context5.abrupt("return", Promise.all(tokenPendingClaims.claims.map(function (claim) {
6765
+ var payload = {
6766
+ account: account,
6767
+ distributor: tokenPendingClaims.tokenClaimInfo.distributor,
6768
+ tokenIndex: tokenIndex,
6769
+ decimals: tokenPendingClaims.tokenClaimInfo.decimals,
6770
+ // objects must be cloned
6771
+ report: _extends({}, tokenPendingClaims.reports[claim.id]),
6772
+ claim: _extends({}, claim)
6773
+ };
6774
+ return _this3.computeClaimProof(payload);
6775
+ })));
6776
+
6777
+ case 1:
6778
+ case "end":
6779
+ return _context5.stop();
6780
+ }
6781
+ }
6782
+ }, _callee5);
6783
+ }));
6784
+
6785
+ function computeClaimProofs(_x7, _x8, _x9) {
6786
+ return _computeClaimProofs.apply(this, arguments);
6787
+ }
6788
+
6789
+ return computeClaimProofs;
6790
+ }();
6791
+
6792
+ _proto.computeClaimProof = function computeClaimProof(payload) {
6793
+ var report = payload.report,
6794
+ account = payload.account,
6795
+ claim = payload.claim,
6796
+ distributor = payload.distributor,
6797
+ tokenIndex = payload.tokenIndex,
6798
+ decimals = payload.decimals;
6799
+ var claimAmount = claim.amount;
6800
+ var merkleTree = loadTree(report, decimals);
6801
+ var scaledBalance = scale(claimAmount, decimals).toString(10);
6802
+ var proof = merkleTree.getHexProof(web3Utils.soliditySha3({
6803
+ t: "address",
6804
+ v: account
6805
+ }, {
6806
+ t: "uint",
6807
+ v: scaledBalance
6808
+ }));
6809
+ return [parseInt(claim.id), scaledBalance, distributor, tokenIndex, proof];
6810
+ };
6811
+
6812
+ _proto.getTokenClaimsInfo = function getTokenClaimsInfo() {
6813
+ var tokenClaims = MultiTokenClaim["137"];
6814
+
6815
+ if (tokenClaims != null) {
6816
+ return tokenClaims.map(function (tokenClaim) {
6817
+ return _extends({}, tokenClaim, {
6818
+ token: address.getAddress(tokenClaim.token),
6819
+ decimals: 18
6820
+ });
6821
+ });
6822
+ }
6823
+
6824
+ return null;
6825
+ };
6826
+
6827
+ _proto.getSnapshot = /*#__PURE__*/function () {
6828
+ var _getSnapshot = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(manifest) {
6829
+ var response;
6830
+ return runtime_1.wrap(function _callee6$(_context6) {
6831
+ while (1) {
6832
+ switch (_context6.prev = _context6.next) {
6833
+ case 0:
6834
+ _context6.prev = 0;
6835
+ _context6.next = 3;
6836
+ return axios.get(manifest);
6837
+
6838
+ case 3:
6839
+ response = _context6.sent;
6840
+ return _context6.abrupt("return", response.data || {});
6841
+
6842
+ case 7:
6843
+ _context6.prev = 7;
6844
+ _context6.t0 = _context6["catch"](0);
6845
+ return _context6.abrupt("return", {});
6846
+
6847
+ case 10:
6848
+ case "end":
6849
+ return _context6.stop();
6850
+ }
6851
+ }
6852
+ }, _callee6, null, [[0, 7]]);
6853
+ }));
6854
+
6855
+ function getSnapshot(_x10) {
6856
+ return _getSnapshot.apply(this, arguments);
6857
+ }
6858
+
6859
+ return getSnapshot;
6860
+ }();
6861
+
6862
+ _proto.getClaimStatus = /*#__PURE__*/function () {
6863
+ var _getClaimStatus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(totalWeeks, account, tokenClaimInfo) {
6864
+ var _this4 = this;
6865
+
6866
+ var token, distributor, weekStart, claimStatusCalls, rootCalls, result, chunks, claimedResult, distributionRootResult;
6867
+ return runtime_1.wrap(function _callee7$(_context7) {
6868
+ while (1) {
6869
+ switch (_context7.prev = _context7.next) {
6870
+ case 0:
6871
+ token = tokenClaimInfo.token, distributor = tokenClaimInfo.distributor, weekStart = tokenClaimInfo.weekStart;
6872
+ claimStatusCalls = Array.from({
6873
+ length: totalWeeks
6874
+ }).map(function (_, i) {
6875
+ return [stakingAddress[_this4.network][exports.Dapp.BALANCER], "isClaimed", [token, distributor, weekStart + i, account]];
6876
+ });
6877
+ rootCalls = Array.from({
6878
+ length: totalWeeks
6879
+ }).map(function (_, i) {
6880
+ return [stakingAddress[_this4.network][exports.Dapp.BALANCER], "getDistributionRoot", [token, distributor, weekStart + i]];
6881
+ });
6882
+ _context7.prev = 3;
6883
+ _context7.next = 6;
6884
+ return multicall(this.network, this.signer, IBalancerMerkleOrchard.abi, [].concat(claimStatusCalls, rootCalls), {}, true);
6885
+
6886
+ case 6:
6887
+ result = _context7.sent;
6888
+
6889
+ if (!(result.length > 0)) {
6890
+ _context7.next = 12;
6891
+ break;
6892
+ }
6893
+
6894
+ chunks = lodash.chunk(lodash.flatten(result), totalWeeks);
6895
+ claimedResult = chunks[0];
6896
+ distributionRootResult = chunks[1];
6897
+ return _context7.abrupt("return", claimedResult.filter(function (_, index) {
6898
+ return distributionRootResult[index] !== ethers.ethers.constants.HashZero;
6899
+ }));
6900
+
6901
+ case 12:
6902
+ _context7.next = 17;
6903
+ break;
6904
+
6905
+ case 14:
6906
+ _context7.prev = 14;
6907
+ _context7.t0 = _context7["catch"](3);
6908
+ console.log("[Claim] Claim Status Error:", _context7.t0);
6909
+
6910
+ case 17:
6911
+ return _context7.abrupt("return", []);
6912
+
6913
+ case 18:
6914
+ case "end":
6915
+ return _context7.stop();
6916
+ }
6917
+ }
6918
+ }, _callee7, this, [[3, 14]]);
6919
+ }));
6920
+
6921
+ function getClaimStatus(_x11, _x12, _x13) {
6922
+ return _getClaimStatus.apply(this, arguments);
6923
+ }
6924
+
6925
+ return getClaimStatus;
6926
+ }();
6927
+
6928
+ _proto.getReports = /*#__PURE__*/function () {
6929
+ var _getReports = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(snapshot, weeks) {
6930
+ var reports;
6931
+ return runtime_1.wrap(function _callee8$(_context8) {
6932
+ while (1) {
6933
+ switch (_context8.prev = _context8.next) {
6934
+ case 0:
6935
+ _context8.next = 2;
6936
+ return Promise.all(weeks.filter(function (week) {
6937
+ return snapshot[week] != null;
6938
+ }).map(function (week) {
6939
+ return ipfsService.get(snapshot[week]);
6940
+ }));
6941
+
6942
+ case 2:
6943
+ reports = _context8.sent;
6944
+ return _context8.abrupt("return", Object.fromEntries(reports.map(function (report, i) {
6945
+ return [weeks[i], report];
6946
+ })));
6947
+
6948
+ case 4:
6949
+ case "end":
6950
+ return _context8.stop();
6951
+ }
6952
+ }
6953
+ }, _callee8);
6954
+ }));
6955
+
6956
+ function getReports(_x14, _x15) {
6957
+ return _getReports.apply(this, arguments);
6958
+ }
6959
+
6960
+ return getReports;
6961
+ }();
6962
+
6963
+ return ClaimService;
6964
+ }();
6965
+
6966
+ var Pool = /*#__PURE__*/function () {
6967
+ function Pool(network, signer, poolLogic, mangerLogic, utils) {
6968
+ this.network = network;
6969
+ this.poolLogic = poolLogic;
6970
+ this.address = poolLogic.address;
6971
+ this.managerLogic = mangerLogic;
6972
+ this.signer = signer;
6973
+ this.utils = utils;
6974
+ }
6975
+ /**
6976
+ * Return the assets with balances and deposit info of a pool
6977
+ * @returns {Promise<FundComposition[]>} Composition of assets with balance, deposit info
6978
+ */
6979
+
6980
+
6981
+ var _proto = Pool.prototype;
6982
+
6983
+ _proto.getComposition =
6984
+ /*#__PURE__*/
6985
+ function () {
6986
+ var _getComposition = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
6987
+ var result, fundComposition;
6988
+ return runtime_1.wrap(function _callee$(_context) {
6989
+ while (1) {
6990
+ switch (_context.prev = _context.next) {
6991
+ case 0:
6992
+ _context.next = 2;
6993
+ return this.managerLogic.getFundComposition();
6994
+
6995
+ case 2:
6996
+ result = _context.sent;
6997
+ fundComposition = result[0].map(function (item, index) {
6998
+ var asset = item.asset,
6999
+ isDeposit = item.isDeposit;
7000
+ return {
7001
+ asset: asset,
7002
+ isDeposit: isDeposit,
7003
+ balance: result[1][index],
7004
+ rate: result[2][index]
7005
+ };
7006
+ });
7007
+ return _context.abrupt("return", fundComposition);
7008
+
7009
+ case 5:
7010
+ case "end":
7011
+ return _context.stop();
7012
+ }
7013
+ }
7014
+ }, _callee, this);
7015
+ }));
7016
+
7017
+ function getComposition() {
7018
+ return _getComposition.apply(this, arguments);
7019
+ }
7020
+
7021
+ return getComposition;
7022
+ }() //Invest functions
7023
+
7024
+ /**
7025
+ * Approve the asset that can be deposited into a pool
7026
+ * @param {string} nasset Address of deposit asset
7027
+ * @param {BigNumber | string} amount Amount to be approved
7028
+ * @param {any} options Transaction options
7029
+ * @returns {Promise<any>} Transaction
7030
+ */
7031
+ ;
7032
+
7033
+ _proto.approveDeposit =
7034
+ /*#__PURE__*/
7035
+ function () {
7036
+ var _approveDeposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(asset, amount, options) {
7037
+ var iERC20, tx;
7038
+ return runtime_1.wrap(function _callee2$(_context2) {
7039
+ while (1) {
7040
+ switch (_context2.prev = _context2.next) {
7041
+ case 0:
7042
+ if (options === void 0) {
7043
+ options = null;
7044
+ }
7045
+
7046
+ iERC20 = new ethers.ethers.Contract(asset, IERC20.abi, this.signer);
7047
+ _context2.next = 4;
7048
+ return iERC20.approve(this.address, amount, options);
7049
+
7050
+ case 4:
7051
+ tx = _context2.sent;
7052
+ return _context2.abrupt("return", tx);
7053
+
7054
+ case 6:
7055
+ case "end":
7056
+ return _context2.stop();
7057
+ }
7058
+ }
7059
+ }, _callee2, this);
7060
+ }));
7061
+
7062
+ function approveDeposit(_x, _x2, _x3) {
7063
+ return _approveDeposit.apply(this, arguments);
7064
+ }
7065
+
7066
+ return approveDeposit;
7067
+ }()
7068
+ /**
7069
+ * Deposit asset into a pool
7070
+ * @param {string} asset Address of asset
7071
+ * @param {BigNumber | string} amount Amount to be deposited
7072
+ * @param {any} options Transaction options
7073
+ * @returns {Promise<any>} Transaction
7074
+ */
7075
+ ;
7076
+
7077
+ _proto.deposit =
7078
+ /*#__PURE__*/
7079
+ function () {
7080
+ var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(asset, amount, options) {
7081
+ var tx;
7082
+ return runtime_1.wrap(function _callee3$(_context3) {
7083
+ while (1) {
7084
+ switch (_context3.prev = _context3.next) {
7085
+ case 0:
7086
+ if (options === void 0) {
7087
+ options = null;
7088
+ }
7089
+
7090
+ _context3.next = 3;
7091
+ return this.poolLogic.deposit(asset, amount, options);
7092
+
7093
+ case 3:
7094
+ tx = _context3.sent;
7095
+ return _context3.abrupt("return", tx);
7096
+
7097
+ case 5:
7098
+ case "end":
7099
+ return _context3.stop();
7100
+ }
7101
+ }
7102
+ }, _callee3, this);
7103
+ }));
7104
+
7105
+ function deposit(_x4, _x5, _x6) {
7106
+ return _deposit.apply(this, arguments);
7107
+ }
7108
+
7109
+ return deposit;
7110
+ }()
7111
+ /**
7112
+ * Withdraw assets from a pool
7113
+ * @param fundTokenAmount Amount of pool tokens to be withdrawn
7114
+ * @param {any} options Transaction options
7115
+ * @returns {Promise<any>} Transaction
7116
+ */
7117
+ ;
7118
+
7119
+ _proto.withdraw =
7120
+ /*#__PURE__*/
7121
+ function () {
7122
+ var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(fundTokenAmount, options) {
7123
+ var tx;
7124
+ return runtime_1.wrap(function _callee4$(_context4) {
7125
+ while (1) {
7126
+ switch (_context4.prev = _context4.next) {
7127
+ case 0:
7128
+ if (options === void 0) {
7129
+ options = null;
7130
+ }
7131
+
7132
+ _context4.next = 3;
7133
+ return this.poolLogic.withdraw(fundTokenAmount, options);
7134
+
7135
+ case 3:
7136
+ tx = _context4.sent;
7137
+ return _context4.abrupt("return", tx);
7138
+
7139
+ case 5:
7140
+ case "end":
7141
+ return _context4.stop();
7142
+ }
7143
+ }
7144
+ }, _callee4, this);
7145
+ }));
7146
+
7147
+ function withdraw(_x7, _x8) {
7148
+ return _withdraw.apply(this, arguments);
7149
+ }
7150
+
7151
+ return withdraw;
7152
+ }() //Manager functions
7153
+
7154
+ /**
7155
+ * Approve the asset for trading and providing liquidity
7156
+ * @param {Dapp} dapp Platform like Sushiswap or Uniswap
7157
+ * @param {string} asset Address of asset
7158
+ * @param @param {BigNumber | string} Amount to be approved
7159
+ * @param {any} options Transaction options
7160
+ * @returns {Promise<any>} Transaction
7161
+ */
7162
+ ;
7163
+
7164
+ _proto.approve =
7165
+ /*#__PURE__*/
7166
+ function () {
7167
+ var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(dapp, asset, amount, options) {
7168
+ var iERC20, approveTxData, tx;
7169
+ return runtime_1.wrap(function _callee5$(_context5) {
7170
+ while (1) {
7171
+ switch (_context5.prev = _context5.next) {
7172
+ case 0:
7173
+ if (options === void 0) {
7174
+ options = null;
7175
+ }
7176
+
7177
+ iERC20 = new ethers.ethers.utils.Interface(IERC20.abi);
7178
+ approveTxData = iERC20.encodeFunctionData("approve", [routerAddress[this.network][dapp], amount]);
7179
+ _context5.next = 5;
7180
+ return this.poolLogic.execTransaction(asset, approveTxData, options);
7181
+
7182
+ case 5:
7183
+ tx = _context5.sent;
7184
+ return _context5.abrupt("return", tx);
7185
+
7186
+ case 7:
7187
+ case "end":
7188
+ return _context5.stop();
7189
+ }
7190
+ }
7191
+ }, _callee5, this);
7192
+ }));
7193
+
7194
+ function approve(_x9, _x10, _x11, _x12) {
7195
+ return _approve.apply(this, arguments);
7196
+ }
7197
+
7198
+ return approve;
7199
+ }()
7200
+ /**
7201
+ * Approve the liquidity pool token for staking
7202
+ * @param {Dapp} dapp Platform like Sushiswap or Uniswap
7203
+ * @param {string} asset Address of liquidity pool token
7204
+ * @param {BigNumber | string} amount Aamount to be approved
7205
+ * @param {any} options Transaction options
7206
+ * @returns {Promise<any>} Transaction
7207
+ */
7208
+ ;
7209
+
7210
+ _proto.approveStaking =
7211
+ /*#__PURE__*/
7212
+ function () {
5812
7213
  var _approveStaking = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(dapp, asset, amount, options) {
5813
7214
  var iERC20, approveTxData, tx;
5814
7215
  return runtime_1.wrap(function _callee6$(_context6) {
@@ -5883,28 +7284,42 @@ var Pool = /*#__PURE__*/function () {
5883
7284
  case 6:
5884
7285
  response = _context7.sent;
5885
7286
  swapTxData = response.data.tx.data;
5886
- _context7.next = 15;
7287
+ _context7.next = 21;
5887
7288
  break;
5888
7289
 
5889
7290
  case 10:
5890
- iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
7291
+ if (!(dapp === exports.Dapp.BALANCER)) {
7292
+ _context7.next = 16;
7293
+ break;
7294
+ }
7295
+
5891
7296
  _context7.next = 13;
5892
- return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
7297
+ return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
5893
7298
 
5894
7299
  case 13:
7300
+ swapTxData = _context7.sent;
7301
+ _context7.next = 21;
7302
+ break;
7303
+
7304
+ case 16:
7305
+ iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
7306
+ _context7.next = 19;
7307
+ return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
7308
+
7309
+ case 19:
5895
7310
  minAmountOut = _context7.sent;
5896
7311
  swapTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.SWAP, [amountIn, minAmountOut, [assetFrom, assetTo], this.address, Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
5897
7312
  ]);
5898
7313
 
5899
- case 15:
5900
- _context7.next = 17;
7314
+ case 21:
7315
+ _context7.next = 23;
5901
7316
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], swapTxData, options);
5902
7317
 
5903
- case 17:
7318
+ case 23:
5904
7319
  tx = _context7.sent;
5905
7320
  return _context7.abrupt("return", tx);
5906
7321
 
5907
- case 19:
7322
+ case 25:
5908
7323
  case "end":
5909
7324
  return _context7.stop();
5910
7325
  }
@@ -6095,7 +7510,7 @@ var Pool = /*#__PURE__*/function () {
6095
7510
 
6096
7511
  case 4:
6097
7512
  poolId = _context11.sent;
6098
- unStakeTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.UNSTAKE, [poolId, amount, this.address]);
7513
+ unStakeTxData = iMiniChefV2.encodeFunctionData(exports.Transaction.WITHDRAW, [poolId, amount, this.address]);
6099
7514
  _context11.next = 8;
6100
7515
  return this.poolLogic.execTransaction(stakingAddress[this.network][dapp], unStakeTxData, options);
6101
7516
 
@@ -6451,77 +7866,895 @@ var Pool = /*#__PURE__*/function () {
6451
7866
  }
6452
7867
 
6453
7868
  return setTrader;
7869
+ }()
7870
+ /**
7871
+ * Invest into a Balancer pool
7872
+ * @param {string} poolId Balancer pool id
7873
+ * @param {string[] | } assetsIn Array of balancer pool assets
7874
+ * @param {BigNumber[] | string[]} amountsIn Array of maximum amounts to provide to pool
7875
+ * @param {any} options Transaction options
7876
+ * @returns {Promise<any>} Transaction
7877
+ */
7878
+ ;
7879
+
7880
+ _proto.joinBalancerPool =
7881
+ /*#__PURE__*/
7882
+ function () {
7883
+ var _joinBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19(poolId, assets, amountsIn, options) {
7884
+ var joinPoolTxData, tx;
7885
+ return runtime_1.wrap(function _callee19$(_context19) {
7886
+ while (1) {
7887
+ switch (_context19.prev = _context19.next) {
7888
+ case 0:
7889
+ if (options === void 0) {
7890
+ options = null;
7891
+ }
7892
+
7893
+ joinPoolTxData = this.utils.getBalancerJoinPoolTx(this, poolId, assets, amountsIn);
7894
+ _context19.next = 4;
7895
+ return this.poolLogic.execTransaction(routerAddress[this.network][exports.Dapp.BALANCER], joinPoolTxData, options);
7896
+
7897
+ case 4:
7898
+ tx = _context19.sent;
7899
+ return _context19.abrupt("return", tx);
7900
+
7901
+ case 6:
7902
+ case "end":
7903
+ return _context19.stop();
7904
+ }
7905
+ }
7906
+ }, _callee19, this);
7907
+ }));
7908
+
7909
+ function joinBalancerPool(_x65, _x66, _x67, _x68) {
7910
+ return _joinBalancerPool.apply(this, arguments);
7911
+ }
7912
+
7913
+ return joinBalancerPool;
7914
+ }()
7915
+ /**
7916
+ * Invest into a Balancer pool
7917
+ * @param {string} poolId Balancer pool id
7918
+ * @param {string[] | } assets Array of balancer pool assets
7919
+ * @param {BigNumber | string } amount Amount of pool tokens to withdraw
7920
+ * @param {any} options Transaction options
7921
+ * @returns {Promise<any>} Transaction
7922
+ */
7923
+ ;
7924
+
7925
+ _proto.exitBalancerPool =
7926
+ /*#__PURE__*/
7927
+ function () {
7928
+ var _exitBalancerPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee20(poolId, assets, amount, options) {
7929
+ var exitPoolTxData, tx;
7930
+ return runtime_1.wrap(function _callee20$(_context20) {
7931
+ while (1) {
7932
+ switch (_context20.prev = _context20.next) {
7933
+ case 0:
7934
+ if (options === void 0) {
7935
+ options = null;
7936
+ }
7937
+
7938
+ exitPoolTxData = this.utils.getBalancerExitPoolTx(this, poolId, assets, amount);
7939
+ _context20.next = 4;
7940
+ return this.poolLogic.execTransaction(routerAddress[this.network][exports.Dapp.BALANCER], exitPoolTxData, options);
7941
+
7942
+ case 4:
7943
+ tx = _context20.sent;
7944
+ return _context20.abrupt("return", tx);
7945
+
7946
+ case 6:
7947
+ case "end":
7948
+ return _context20.stop();
7949
+ }
7950
+ }
7951
+ }, _callee20, this);
7952
+ }));
7953
+
7954
+ function exitBalancerPool(_x69, _x70, _x71, _x72) {
7955
+ return _exitBalancerPool.apply(this, arguments);
7956
+ }
7957
+
7958
+ return exitBalancerPool;
7959
+ }()
7960
+ /**
7961
+ * Claim rewards from Balancer pools
7962
+ * @param {string[]} assets Array of tokens being claimed
7963
+ * @param {any} options Transaction options
7964
+ * @returns {Promise<any>} Transaction
7965
+ */
7966
+ ;
7967
+
7968
+ _proto.harvestBalancerRewards =
7969
+ /*#__PURE__*/
7970
+ function () {
7971
+ var _harvestBalancerRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee21(options) {
7972
+ var claimService, multiTokenPendingClaims, tokens, claims, iBalancerMerkleOrchard, harvestTxData, tx;
7973
+ return runtime_1.wrap(function _callee21$(_context21) {
7974
+ while (1) {
7975
+ switch (_context21.prev = _context21.next) {
7976
+ case 0:
7977
+ if (options === void 0) {
7978
+ options = null;
7979
+ }
7980
+
7981
+ claimService = new ClaimService(this.network, this.signer);
7982
+ _context21.next = 4;
7983
+ return claimService.getMultiTokensPendingClaims(this.address);
7984
+
7985
+ case 4:
7986
+ multiTokenPendingClaims = _context21.sent;
7987
+ tokens = multiTokenPendingClaims.map(function (tokenPendingClaims) {
7988
+ return tokenPendingClaims.tokenClaimInfo.token;
7989
+ });
7990
+ _context21.next = 8;
7991
+ return claimService.multiTokenClaimRewards(this.address, multiTokenPendingClaims);
7992
+
7993
+ case 8:
7994
+ claims = _context21.sent;
7995
+ iBalancerMerkleOrchard = new ethers.ethers.utils.Interface(IBalancerMerkleOrchard.abi);
7996
+ harvestTxData = iBalancerMerkleOrchard.encodeFunctionData(exports.Transaction.CLAIM_DISTRIBIUTIONS, [this.address, claims, tokens]);
7997
+ _context21.next = 13;
7998
+ return this.poolLogic.execTransaction(stakingAddress[this.network][exports.Dapp.BALANCER], harvestTxData, options);
7999
+
8000
+ case 13:
8001
+ tx = _context21.sent;
8002
+ return _context21.abrupt("return", tx);
8003
+
8004
+ case 15:
8005
+ case "end":
8006
+ return _context21.stop();
8007
+ }
8008
+ }
8009
+ }, _callee21, this);
8010
+ }));
8011
+
8012
+ function harvestBalancerRewards(_x73) {
8013
+ return _harvestBalancerRewards.apply(this, arguments);
8014
+ }
8015
+
8016
+ return harvestBalancerRewards;
8017
+ }()
8018
+ /**
8019
+ * Claim rewards from Aave platform
8020
+ * @param {string[]} assets Aave tokens (deposit/debt) hold by pool
8021
+ * @param {any} options Transaction options
8022
+ * @returns {Promise<any>} Transaction
8023
+ */
8024
+ ;
8025
+
8026
+ _proto.harvestAaveRewards =
8027
+ /*#__PURE__*/
8028
+ function () {
8029
+ var _harvestAaveRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee22(assets, options) {
8030
+ var aaveIncentivesAddress, iAaveIncentivesController, aaveIncentivesController, amount, claimTxData, tx;
8031
+ return runtime_1.wrap(function _callee22$(_context22) {
8032
+ while (1) {
8033
+ switch (_context22.prev = _context22.next) {
8034
+ case 0:
8035
+ if (options === void 0) {
8036
+ options = null;
8037
+ }
8038
+
8039
+ aaveIncentivesAddress = stakingAddress[this.network][exports.Dapp.AAVE];
8040
+ iAaveIncentivesController = new ethers.ethers.utils.Interface(IAaveIncentivesController.abi);
8041
+ aaveIncentivesController = new ethers.ethers.Contract(aaveIncentivesAddress, iAaveIncentivesController, this.signer);
8042
+ _context22.next = 6;
8043
+ return aaveIncentivesController.getUserUnclaimedRewards(this.address);
8044
+
8045
+ case 6:
8046
+ amount = _context22.sent;
8047
+ claimTxData = iAaveIncentivesController.encodeFunctionData(exports.Transaction.CLAIM_REWARDS, [assets, amount, this.address]);
8048
+ _context22.next = 10;
8049
+ return this.poolLogic.execTransaction(aaveIncentivesAddress, claimTxData, options);
8050
+
8051
+ case 10:
8052
+ tx = _context22.sent;
8053
+ return _context22.abrupt("return", tx);
8054
+
8055
+ case 12:
8056
+ case "end":
8057
+ return _context22.stop();
8058
+ }
8059
+ }
8060
+ }, _callee22, this);
8061
+ }));
8062
+
8063
+ function harvestAaveRewards(_x74, _x75) {
8064
+ return _harvestAaveRewards.apply(this, arguments);
8065
+ }
8066
+
8067
+ return harvestAaveRewards;
6454
8068
  }();
6455
8069
 
6456
8070
  return Pool;
6457
8071
  }();
6458
8072
 
6459
- var abi$7 = [
8073
+ var abi$9 = [
8074
+ {
8075
+ inputs: [
8076
+ {
8077
+ internalType: "address",
8078
+ name: "_feeToSetter",
8079
+ type: "address"
8080
+ }
8081
+ ],
8082
+ stateMutability: "nonpayable",
8083
+ type: "constructor"
8084
+ },
8085
+ {
8086
+ anonymous: false,
8087
+ inputs: [
8088
+ {
8089
+ indexed: true,
8090
+ internalType: "address",
8091
+ name: "token0",
8092
+ type: "address"
8093
+ },
8094
+ {
8095
+ indexed: true,
8096
+ internalType: "address",
8097
+ name: "token1",
8098
+ type: "address"
8099
+ },
8100
+ {
8101
+ indexed: false,
8102
+ internalType: "address",
8103
+ name: "pair",
8104
+ type: "address"
8105
+ },
8106
+ {
8107
+ indexed: false,
8108
+ internalType: "uint256",
8109
+ name: "",
8110
+ type: "uint256"
8111
+ }
8112
+ ],
8113
+ name: "PairCreated",
8114
+ type: "event"
8115
+ },
8116
+ {
8117
+ inputs: [
8118
+ {
8119
+ internalType: "uint256",
8120
+ name: "",
8121
+ type: "uint256"
8122
+ }
8123
+ ],
8124
+ name: "allPairs",
8125
+ outputs: [
8126
+ {
8127
+ internalType: "address",
8128
+ name: "",
8129
+ type: "address"
8130
+ }
8131
+ ],
8132
+ stateMutability: "view",
8133
+ type: "function"
8134
+ },
8135
+ {
8136
+ inputs: [
8137
+ ],
8138
+ name: "allPairsLength",
8139
+ outputs: [
8140
+ {
8141
+ internalType: "uint256",
8142
+ name: "",
8143
+ type: "uint256"
8144
+ }
8145
+ ],
8146
+ stateMutability: "view",
8147
+ type: "function"
8148
+ },
8149
+ {
8150
+ inputs: [
8151
+ {
8152
+ internalType: "address",
8153
+ name: "tokenA",
8154
+ type: "address"
8155
+ },
8156
+ {
8157
+ internalType: "address",
8158
+ name: "tokenB",
8159
+ type: "address"
8160
+ }
8161
+ ],
8162
+ name: "createPair",
8163
+ outputs: [
8164
+ {
8165
+ internalType: "address",
8166
+ name: "pair",
8167
+ type: "address"
8168
+ }
8169
+ ],
8170
+ stateMutability: "nonpayable",
8171
+ type: "function"
8172
+ },
8173
+ {
8174
+ inputs: [
8175
+ ],
8176
+ name: "feeTo",
8177
+ outputs: [
8178
+ {
8179
+ internalType: "address",
8180
+ name: "",
8181
+ type: "address"
8182
+ }
8183
+ ],
8184
+ stateMutability: "view",
8185
+ type: "function"
8186
+ },
8187
+ {
8188
+ inputs: [
8189
+ ],
8190
+ name: "feeToSetter",
8191
+ outputs: [
8192
+ {
8193
+ internalType: "address",
8194
+ name: "",
8195
+ type: "address"
8196
+ }
8197
+ ],
8198
+ stateMutability: "view",
8199
+ type: "function"
8200
+ },
8201
+ {
8202
+ inputs: [
8203
+ {
8204
+ internalType: "address",
8205
+ name: "",
8206
+ type: "address"
8207
+ },
8208
+ {
8209
+ internalType: "address",
8210
+ name: "",
8211
+ type: "address"
8212
+ }
8213
+ ],
8214
+ name: "getPair",
8215
+ outputs: [
8216
+ {
8217
+ internalType: "address",
8218
+ name: "",
8219
+ type: "address"
8220
+ }
8221
+ ],
8222
+ stateMutability: "view",
8223
+ type: "function"
8224
+ },
8225
+ {
8226
+ inputs: [
8227
+ ],
8228
+ name: "migrator",
8229
+ outputs: [
8230
+ {
8231
+ internalType: "address",
8232
+ name: "",
8233
+ type: "address"
8234
+ }
8235
+ ],
8236
+ stateMutability: "view",
8237
+ type: "function"
8238
+ },
8239
+ {
8240
+ inputs: [
8241
+ ],
8242
+ name: "pairCodeHash",
8243
+ outputs: [
8244
+ {
8245
+ internalType: "bytes32",
8246
+ name: "",
8247
+ type: "bytes32"
8248
+ }
8249
+ ],
8250
+ stateMutability: "pure",
8251
+ type: "function"
8252
+ },
8253
+ {
8254
+ inputs: [
8255
+ {
8256
+ internalType: "address",
8257
+ name: "_feeTo",
8258
+ type: "address"
8259
+ }
8260
+ ],
8261
+ name: "setFeeTo",
8262
+ outputs: [
8263
+ ],
8264
+ stateMutability: "nonpayable",
8265
+ type: "function"
8266
+ },
8267
+ {
8268
+ inputs: [
8269
+ {
8270
+ internalType: "address",
8271
+ name: "_feeToSetter",
8272
+ type: "address"
8273
+ }
8274
+ ],
8275
+ name: "setFeeToSetter",
8276
+ outputs: [
8277
+ ],
8278
+ stateMutability: "nonpayable",
8279
+ type: "function"
8280
+ },
8281
+ {
8282
+ inputs: [
8283
+ {
8284
+ internalType: "address",
8285
+ name: "_migrator",
8286
+ type: "address"
8287
+ }
8288
+ ],
8289
+ name: "setMigrator",
8290
+ outputs: [
8291
+ ],
8292
+ stateMutability: "nonpayable",
8293
+ type: "function"
8294
+ }
8295
+ ];
8296
+ var UniswapV2Factory = {
8297
+ abi: abi$9
8298
+ };
8299
+
8300
+ var abi$a = [
8301
+ {
8302
+ anonymous: false,
8303
+ inputs: [
8304
+ {
8305
+ indexed: true,
8306
+ internalType: "address",
8307
+ name: "owner",
8308
+ type: "address"
8309
+ },
8310
+ {
8311
+ indexed: true,
8312
+ internalType: "address",
8313
+ name: "spender",
8314
+ type: "address"
8315
+ },
8316
+ {
8317
+ indexed: false,
8318
+ internalType: "uint256",
8319
+ name: "value",
8320
+ type: "uint256"
8321
+ }
8322
+ ],
8323
+ name: "Approval",
8324
+ type: "event"
8325
+ },
8326
+ {
8327
+ anonymous: false,
8328
+ inputs: [
8329
+ {
8330
+ indexed: true,
8331
+ internalType: "address",
8332
+ name: "sender",
8333
+ type: "address"
8334
+ },
8335
+ {
8336
+ indexed: false,
8337
+ internalType: "uint256",
8338
+ name: "amount0",
8339
+ type: "uint256"
8340
+ },
8341
+ {
8342
+ indexed: false,
8343
+ internalType: "uint256",
8344
+ name: "amount1",
8345
+ type: "uint256"
8346
+ },
8347
+ {
8348
+ indexed: true,
8349
+ internalType: "address",
8350
+ name: "to",
8351
+ type: "address"
8352
+ }
8353
+ ],
8354
+ name: "Burn",
8355
+ type: "event"
8356
+ },
8357
+ {
8358
+ anonymous: false,
8359
+ inputs: [
8360
+ {
8361
+ indexed: true,
8362
+ internalType: "address",
8363
+ name: "sender",
8364
+ type: "address"
8365
+ },
8366
+ {
8367
+ indexed: false,
8368
+ internalType: "uint256",
8369
+ name: "amount0",
8370
+ type: "uint256"
8371
+ },
8372
+ {
8373
+ indexed: false,
8374
+ internalType: "uint256",
8375
+ name: "amount1",
8376
+ type: "uint256"
8377
+ }
8378
+ ],
8379
+ name: "Mint",
8380
+ type: "event"
8381
+ },
8382
+ {
8383
+ anonymous: false,
8384
+ inputs: [
8385
+ {
8386
+ indexed: true,
8387
+ internalType: "address",
8388
+ name: "sender",
8389
+ type: "address"
8390
+ },
8391
+ {
8392
+ indexed: false,
8393
+ internalType: "uint256",
8394
+ name: "amount0In",
8395
+ type: "uint256"
8396
+ },
8397
+ {
8398
+ indexed: false,
8399
+ internalType: "uint256",
8400
+ name: "amount1In",
8401
+ type: "uint256"
8402
+ },
8403
+ {
8404
+ indexed: false,
8405
+ internalType: "uint256",
8406
+ name: "amount0Out",
8407
+ type: "uint256"
8408
+ },
8409
+ {
8410
+ indexed: false,
8411
+ internalType: "uint256",
8412
+ name: "amount1Out",
8413
+ type: "uint256"
8414
+ },
8415
+ {
8416
+ indexed: true,
8417
+ internalType: "address",
8418
+ name: "to",
8419
+ type: "address"
8420
+ }
8421
+ ],
8422
+ name: "Swap",
8423
+ type: "event"
8424
+ },
8425
+ {
8426
+ anonymous: false,
8427
+ inputs: [
8428
+ {
8429
+ indexed: false,
8430
+ internalType: "uint112",
8431
+ name: "reserve0",
8432
+ type: "uint112"
8433
+ },
8434
+ {
8435
+ indexed: false,
8436
+ internalType: "uint112",
8437
+ name: "reserve1",
8438
+ type: "uint112"
8439
+ }
8440
+ ],
8441
+ name: "Sync",
8442
+ type: "event"
8443
+ },
8444
+ {
8445
+ anonymous: false,
8446
+ inputs: [
8447
+ {
8448
+ indexed: true,
8449
+ internalType: "address",
8450
+ name: "from",
8451
+ type: "address"
8452
+ },
8453
+ {
8454
+ indexed: true,
8455
+ internalType: "address",
8456
+ name: "to",
8457
+ type: "address"
8458
+ },
8459
+ {
8460
+ indexed: false,
8461
+ internalType: "uint256",
8462
+ name: "value",
8463
+ type: "uint256"
8464
+ }
8465
+ ],
8466
+ name: "Transfer",
8467
+ type: "event"
8468
+ },
8469
+ {
8470
+ constant: true,
8471
+ inputs: [
8472
+ ],
8473
+ name: "DOMAIN_SEPARATOR",
8474
+ outputs: [
8475
+ {
8476
+ internalType: "bytes32",
8477
+ name: "",
8478
+ type: "bytes32"
8479
+ }
8480
+ ],
8481
+ payable: false,
8482
+ stateMutability: "view",
8483
+ type: "function"
8484
+ },
8485
+ {
8486
+ constant: true,
8487
+ inputs: [
8488
+ ],
8489
+ name: "MINIMUM_LIQUIDITY",
8490
+ outputs: [
8491
+ {
8492
+ internalType: "uint256",
8493
+ name: "",
8494
+ type: "uint256"
8495
+ }
8496
+ ],
8497
+ payable: false,
8498
+ stateMutability: "pure",
8499
+ type: "function"
8500
+ },
8501
+ {
8502
+ constant: true,
8503
+ inputs: [
8504
+ ],
8505
+ name: "PERMIT_TYPEHASH",
8506
+ outputs: [
8507
+ {
8508
+ internalType: "bytes32",
8509
+ name: "",
8510
+ type: "bytes32"
8511
+ }
8512
+ ],
8513
+ payable: false,
8514
+ stateMutability: "pure",
8515
+ type: "function"
8516
+ },
8517
+ {
8518
+ constant: true,
8519
+ inputs: [
8520
+ {
8521
+ internalType: "address",
8522
+ name: "owner",
8523
+ type: "address"
8524
+ },
8525
+ {
8526
+ internalType: "address",
8527
+ name: "spender",
8528
+ type: "address"
8529
+ }
8530
+ ],
8531
+ name: "allowance",
8532
+ outputs: [
8533
+ {
8534
+ internalType: "uint256",
8535
+ name: "",
8536
+ type: "uint256"
8537
+ }
8538
+ ],
8539
+ payable: false,
8540
+ stateMutability: "view",
8541
+ type: "function"
8542
+ },
8543
+ {
8544
+ constant: false,
8545
+ inputs: [
8546
+ {
8547
+ internalType: "address",
8548
+ name: "spender",
8549
+ type: "address"
8550
+ },
8551
+ {
8552
+ internalType: "uint256",
8553
+ name: "value",
8554
+ type: "uint256"
8555
+ }
8556
+ ],
8557
+ name: "approve",
8558
+ outputs: [
8559
+ {
8560
+ internalType: "bool",
8561
+ name: "",
8562
+ type: "bool"
8563
+ }
8564
+ ],
8565
+ payable: false,
8566
+ stateMutability: "nonpayable",
8567
+ type: "function"
8568
+ },
8569
+ {
8570
+ constant: true,
8571
+ inputs: [
8572
+ {
8573
+ internalType: "address",
8574
+ name: "owner",
8575
+ type: "address"
8576
+ }
8577
+ ],
8578
+ name: "balanceOf",
8579
+ outputs: [
8580
+ {
8581
+ internalType: "uint256",
8582
+ name: "",
8583
+ type: "uint256"
8584
+ }
8585
+ ],
8586
+ payable: false,
8587
+ stateMutability: "view",
8588
+ type: "function"
8589
+ },
8590
+ {
8591
+ constant: false,
8592
+ inputs: [
8593
+ {
8594
+ internalType: "address",
8595
+ name: "to",
8596
+ type: "address"
8597
+ }
8598
+ ],
8599
+ name: "burn",
8600
+ outputs: [
8601
+ {
8602
+ internalType: "uint256",
8603
+ name: "amount0",
8604
+ type: "uint256"
8605
+ },
8606
+ {
8607
+ internalType: "uint256",
8608
+ name: "amount1",
8609
+ type: "uint256"
8610
+ }
8611
+ ],
8612
+ payable: false,
8613
+ stateMutability: "nonpayable",
8614
+ type: "function"
8615
+ },
8616
+ {
8617
+ constant: true,
8618
+ inputs: [
8619
+ ],
8620
+ name: "decimals",
8621
+ outputs: [
8622
+ {
8623
+ internalType: "uint8",
8624
+ name: "",
8625
+ type: "uint8"
8626
+ }
8627
+ ],
8628
+ payable: false,
8629
+ stateMutability: "pure",
8630
+ type: "function"
8631
+ },
6460
8632
  {
8633
+ constant: true,
6461
8634
  inputs: [
8635
+ ],
8636
+ name: "factory",
8637
+ outputs: [
6462
8638
  {
6463
8639
  internalType: "address",
6464
- name: "_feeToSetter",
8640
+ name: "",
6465
8641
  type: "address"
6466
8642
  }
6467
8643
  ],
6468
- stateMutability: "nonpayable",
6469
- type: "constructor"
8644
+ payable: false,
8645
+ stateMutability: "view",
8646
+ type: "function"
6470
8647
  },
6471
8648
  {
6472
- anonymous: false,
8649
+ constant: true,
6473
8650
  inputs: [
8651
+ ],
8652
+ name: "getReserves",
8653
+ outputs: [
6474
8654
  {
6475
- indexed: true,
6476
- internalType: "address",
6477
- name: "token0",
6478
- type: "address"
8655
+ internalType: "uint112",
8656
+ name: "reserve0",
8657
+ type: "uint112"
6479
8658
  },
6480
8659
  {
6481
- indexed: true,
8660
+ internalType: "uint112",
8661
+ name: "reserve1",
8662
+ type: "uint112"
8663
+ },
8664
+ {
8665
+ internalType: "uint32",
8666
+ name: "blockTimestampLast",
8667
+ type: "uint32"
8668
+ }
8669
+ ],
8670
+ payable: false,
8671
+ stateMutability: "view",
8672
+ type: "function"
8673
+ },
8674
+ {
8675
+ constant: false,
8676
+ inputs: [
8677
+ {
6482
8678
  internalType: "address",
6483
- name: "token1",
8679
+ name: "",
6484
8680
  type: "address"
6485
8681
  },
6486
8682
  {
6487
- indexed: false,
6488
8683
  internalType: "address",
6489
- name: "pair",
8684
+ name: "",
6490
8685
  type: "address"
6491
- },
8686
+ }
8687
+ ],
8688
+ name: "initialize",
8689
+ outputs: [
8690
+ ],
8691
+ payable: false,
8692
+ stateMutability: "nonpayable",
8693
+ type: "function"
8694
+ },
8695
+ {
8696
+ constant: true,
8697
+ inputs: [
8698
+ ],
8699
+ name: "kLast",
8700
+ outputs: [
6492
8701
  {
6493
- indexed: false,
6494
8702
  internalType: "uint256",
6495
8703
  name: "",
6496
8704
  type: "uint256"
6497
8705
  }
6498
8706
  ],
6499
- name: "PairCreated",
6500
- type: "event"
8707
+ payable: false,
8708
+ stateMutability: "view",
8709
+ type: "function"
6501
8710
  },
6502
8711
  {
8712
+ constant: false,
6503
8713
  inputs: [
8714
+ {
8715
+ internalType: "address",
8716
+ name: "to",
8717
+ type: "address"
8718
+ }
8719
+ ],
8720
+ name: "mint",
8721
+ outputs: [
6504
8722
  {
6505
8723
  internalType: "uint256",
6506
- name: "",
8724
+ name: "liquidity",
6507
8725
  type: "uint256"
6508
8726
  }
6509
8727
  ],
6510
- name: "allPairs",
8728
+ payable: false,
8729
+ stateMutability: "nonpayable",
8730
+ type: "function"
8731
+ },
8732
+ {
8733
+ constant: true,
8734
+ inputs: [
8735
+ ],
8736
+ name: "name",
6511
8737
  outputs: [
6512
8738
  {
6513
- internalType: "address",
8739
+ internalType: "string",
6514
8740
  name: "",
6515
- type: "address"
8741
+ type: "string"
6516
8742
  }
6517
8743
  ],
6518
- stateMutability: "view",
8744
+ payable: false,
8745
+ stateMutability: "pure",
6519
8746
  type: "function"
6520
8747
  },
6521
8748
  {
8749
+ constant: true,
6522
8750
  inputs: [
8751
+ {
8752
+ internalType: "address",
8753
+ name: "owner",
8754
+ type: "address"
8755
+ }
6523
8756
  ],
6524
- name: "allPairsLength",
8757
+ name: "nonces",
6525
8758
  outputs: [
6526
8759
  {
6527
8760
  internalType: "uint256",
@@ -6529,75 +8762,167 @@ var abi$7 = [
6529
8762
  type: "uint256"
6530
8763
  }
6531
8764
  ],
8765
+ payable: false,
6532
8766
  stateMutability: "view",
6533
8767
  type: "function"
6534
8768
  },
6535
8769
  {
8770
+ constant: false,
6536
8771
  inputs: [
6537
8772
  {
6538
8773
  internalType: "address",
6539
- name: "tokenA",
8774
+ name: "owner",
6540
8775
  type: "address"
6541
8776
  },
6542
8777
  {
6543
8778
  internalType: "address",
6544
- name: "tokenB",
8779
+ name: "spender",
6545
8780
  type: "address"
8781
+ },
8782
+ {
8783
+ internalType: "uint256",
8784
+ name: "value",
8785
+ type: "uint256"
8786
+ },
8787
+ {
8788
+ internalType: "uint256",
8789
+ name: "deadline",
8790
+ type: "uint256"
8791
+ },
8792
+ {
8793
+ internalType: "uint8",
8794
+ name: "v",
8795
+ type: "uint8"
8796
+ },
8797
+ {
8798
+ internalType: "bytes32",
8799
+ name: "r",
8800
+ type: "bytes32"
8801
+ },
8802
+ {
8803
+ internalType: "bytes32",
8804
+ name: "s",
8805
+ type: "bytes32"
6546
8806
  }
6547
8807
  ],
6548
- name: "createPair",
8808
+ name: "permit",
6549
8809
  outputs: [
6550
- {
6551
- internalType: "address",
6552
- name: "pair",
6553
- type: "address"
6554
- }
6555
8810
  ],
8811
+ payable: false,
6556
8812
  stateMutability: "nonpayable",
6557
8813
  type: "function"
6558
8814
  },
6559
8815
  {
8816
+ constant: true,
6560
8817
  inputs: [
6561
8818
  ],
6562
- name: "feeTo",
8819
+ name: "price0CumulativeLast",
6563
8820
  outputs: [
6564
8821
  {
6565
- internalType: "address",
8822
+ internalType: "uint256",
6566
8823
  name: "",
6567
- type: "address"
8824
+ type: "uint256"
6568
8825
  }
6569
8826
  ],
8827
+ payable: false,
6570
8828
  stateMutability: "view",
6571
8829
  type: "function"
6572
8830
  },
6573
8831
  {
8832
+ constant: true,
6574
8833
  inputs: [
6575
8834
  ],
6576
- name: "feeToSetter",
8835
+ name: "price1CumulativeLast",
6577
8836
  outputs: [
6578
8837
  {
6579
- internalType: "address",
8838
+ internalType: "uint256",
6580
8839
  name: "",
6581
- type: "address"
8840
+ type: "uint256"
6582
8841
  }
6583
8842
  ],
8843
+ payable: false,
6584
8844
  stateMutability: "view",
6585
8845
  type: "function"
6586
8846
  },
6587
8847
  {
8848
+ constant: false,
6588
8849
  inputs: [
6589
8850
  {
6590
8851
  internalType: "address",
6591
- name: "",
8852
+ name: "to",
6592
8853
  type: "address"
8854
+ }
8855
+ ],
8856
+ name: "skim",
8857
+ outputs: [
8858
+ ],
8859
+ payable: false,
8860
+ stateMutability: "nonpayable",
8861
+ type: "function"
8862
+ },
8863
+ {
8864
+ constant: false,
8865
+ inputs: [
8866
+ {
8867
+ internalType: "uint256",
8868
+ name: "amount0Out",
8869
+ type: "uint256"
8870
+ },
8871
+ {
8872
+ internalType: "uint256",
8873
+ name: "amount1Out",
8874
+ type: "uint256"
6593
8875
  },
6594
8876
  {
6595
8877
  internalType: "address",
6596
- name: "",
8878
+ name: "to",
6597
8879
  type: "address"
8880
+ },
8881
+ {
8882
+ internalType: "bytes",
8883
+ name: "data",
8884
+ type: "bytes"
6598
8885
  }
6599
8886
  ],
6600
- name: "getPair",
8887
+ name: "swap",
8888
+ outputs: [
8889
+ ],
8890
+ payable: false,
8891
+ stateMutability: "nonpayable",
8892
+ type: "function"
8893
+ },
8894
+ {
8895
+ constant: true,
8896
+ inputs: [
8897
+ ],
8898
+ name: "symbol",
8899
+ outputs: [
8900
+ {
8901
+ internalType: "string",
8902
+ name: "",
8903
+ type: "string"
8904
+ }
8905
+ ],
8906
+ payable: false,
8907
+ stateMutability: "pure",
8908
+ type: "function"
8909
+ },
8910
+ {
8911
+ constant: false,
8912
+ inputs: [
8913
+ ],
8914
+ name: "sync",
8915
+ outputs: [
8916
+ ],
8917
+ payable: false,
8918
+ stateMutability: "nonpayable",
8919
+ type: "function"
8920
+ },
8921
+ {
8922
+ constant: true,
8923
+ inputs: [
8924
+ ],
8925
+ name: "token0",
6601
8926
  outputs: [
6602
8927
  {
6603
8928
  internalType: "address",
@@ -6605,13 +8930,15 @@ var abi$7 = [
6605
8930
  type: "address"
6606
8931
  }
6607
8932
  ],
8933
+ payable: false,
6608
8934
  stateMutability: "view",
6609
8935
  type: "function"
6610
8936
  },
6611
8937
  {
8938
+ constant: true,
6612
8939
  inputs: [
6613
8940
  ],
6614
- name: "migrator",
8941
+ name: "token1",
6615
8942
  outputs: [
6616
8943
  {
6617
8944
  internalType: "address",
@@ -6619,71 +8946,104 @@ var abi$7 = [
6619
8946
  type: "address"
6620
8947
  }
6621
8948
  ],
8949
+ payable: false,
6622
8950
  stateMutability: "view",
6623
8951
  type: "function"
6624
8952
  },
6625
8953
  {
8954
+ constant: true,
6626
8955
  inputs: [
6627
8956
  ],
6628
- name: "pairCodeHash",
8957
+ name: "totalSupply",
6629
8958
  outputs: [
6630
8959
  {
6631
- internalType: "bytes32",
8960
+ internalType: "uint256",
6632
8961
  name: "",
6633
- type: "bytes32"
8962
+ type: "uint256"
6634
8963
  }
6635
8964
  ],
6636
- stateMutability: "pure",
8965
+ payable: false,
8966
+ stateMutability: "view",
6637
8967
  type: "function"
6638
8968
  },
6639
8969
  {
8970
+ constant: false,
6640
8971
  inputs: [
6641
8972
  {
6642
8973
  internalType: "address",
6643
- name: "_feeTo",
8974
+ name: "to",
6644
8975
  type: "address"
8976
+ },
8977
+ {
8978
+ internalType: "uint256",
8979
+ name: "value",
8980
+ type: "uint256"
6645
8981
  }
6646
8982
  ],
6647
- name: "setFeeTo",
8983
+ name: "transfer",
6648
8984
  outputs: [
8985
+ {
8986
+ internalType: "bool",
8987
+ name: "",
8988
+ type: "bool"
8989
+ }
6649
8990
  ],
8991
+ payable: false,
6650
8992
  stateMutability: "nonpayable",
6651
8993
  type: "function"
6652
8994
  },
6653
8995
  {
8996
+ constant: false,
6654
8997
  inputs: [
6655
8998
  {
6656
8999
  internalType: "address",
6657
- name: "_feeToSetter",
9000
+ name: "from",
6658
9001
  type: "address"
6659
- }
6660
- ],
6661
- name: "setFeeToSetter",
6662
- outputs: [
6663
- ],
6664
- stateMutability: "nonpayable",
6665
- type: "function"
6666
- },
6667
- {
6668
- inputs: [
9002
+ },
6669
9003
  {
6670
9004
  internalType: "address",
6671
- name: "_migrator",
9005
+ name: "to",
6672
9006
  type: "address"
9007
+ },
9008
+ {
9009
+ internalType: "uint256",
9010
+ name: "value",
9011
+ type: "uint256"
6673
9012
  }
6674
9013
  ],
6675
- name: "setMigrator",
9014
+ name: "transferFrom",
6676
9015
  outputs: [
9016
+ {
9017
+ internalType: "bool",
9018
+ name: "",
9019
+ type: "bool"
9020
+ }
6677
9021
  ],
9022
+ payable: false,
6678
9023
  stateMutability: "nonpayable",
6679
9024
  type: "function"
6680
9025
  }
6681
9026
  ];
6682
- var UniswapV2Factory = {
6683
- abi: abi$7
9027
+ var evm = {
9028
+ bytecode: {
9029
+ linkReferences: {
9030
+ },
9031
+ object: "",
9032
+ opcodes: "",
9033
+ sourceMap: ""
9034
+ },
9035
+ deployedBytecode: {
9036
+ linkReferences: {
9037
+ },
9038
+ object: "",
9039
+ opcodes: "",
9040
+ sourceMap: ""
9041
+ }
6684
9042
  };
6685
-
6686
- var abi$8 = [
9043
+ var UniswapV2Pair = {
9044
+ abi: abi$a,
9045
+ evm: evm,
9046
+ "interface": [
6687
9047
  {
6688
9048
  anonymous: false,
6689
9049
  inputs: [
@@ -7409,50 +9769,78 @@ var abi$8 = [
7409
9769
  stateMutability: "nonpayable",
7410
9770
  type: "function"
7411
9771
  }
7412
- ];
7413
- var evm = {
7414
- bytecode: {
7415
- linkReferences: {
7416
- },
7417
- object: "",
7418
- opcodes: "",
7419
- sourceMap: ""
7420
- },
7421
- deployedBytecode: {
7422
- linkReferences: {
7423
- },
7424
- object: "",
7425
- opcodes: "",
7426
- sourceMap: ""
7427
- }
9772
+ ]
7428
9773
  };
7429
- var UniswapV2Pair = {
7430
- abi: abi$8,
7431
- evm: evm,
7432
- "interface": [
9774
+
9775
+ var abi$b = [
9776
+ {
9777
+ inputs: [
9778
+ {
9779
+ internalType: "contract IAuthorizer",
9780
+ name: "authorizer",
9781
+ type: "address"
9782
+ },
9783
+ {
9784
+ internalType: "contract IWETH",
9785
+ name: "weth",
9786
+ type: "address"
9787
+ },
9788
+ {
9789
+ internalType: "uint256",
9790
+ name: "pauseWindowDuration",
9791
+ type: "uint256"
9792
+ },
9793
+ {
9794
+ internalType: "uint256",
9795
+ name: "bufferPeriodDuration",
9796
+ type: "uint256"
9797
+ }
9798
+ ],
9799
+ stateMutability: "nonpayable",
9800
+ type: "constructor"
9801
+ },
7433
9802
  {
7434
9803
  anonymous: false,
7435
9804
  inputs: [
7436
9805
  {
7437
9806
  indexed: true,
7438
- internalType: "address",
7439
- name: "owner",
9807
+ internalType: "contract IAuthorizer",
9808
+ name: "newAuthorizer",
9809
+ type: "address"
9810
+ }
9811
+ ],
9812
+ name: "AuthorizerChanged",
9813
+ type: "event"
9814
+ },
9815
+ {
9816
+ anonymous: false,
9817
+ inputs: [
9818
+ {
9819
+ indexed: true,
9820
+ internalType: "contract IERC20",
9821
+ name: "token",
7440
9822
  type: "address"
7441
9823
  },
7442
9824
  {
7443
9825
  indexed: true,
7444
9826
  internalType: "address",
7445
- name: "spender",
9827
+ name: "sender",
9828
+ type: "address"
9829
+ },
9830
+ {
9831
+ indexed: false,
9832
+ internalType: "address",
9833
+ name: "recipient",
7446
9834
  type: "address"
7447
9835
  },
7448
9836
  {
7449
9837
  indexed: false,
7450
9838
  internalType: "uint256",
7451
- name: "value",
9839
+ name: "amount",
7452
9840
  type: "uint256"
7453
9841
  }
7454
9842
  ],
7455
- name: "Approval",
9843
+ name: "ExternalBalanceTransfer",
7456
9844
  type: "event"
7457
9845
  },
7458
9846
  {
@@ -7460,55 +9848,192 @@ var UniswapV2Pair = {
7460
9848
  inputs: [
7461
9849
  {
7462
9850
  indexed: true,
7463
- internalType: "address",
7464
- name: "sender",
9851
+ internalType: "contract IFlashLoanRecipient",
9852
+ name: "recipient",
9853
+ type: "address"
9854
+ },
9855
+ {
9856
+ indexed: true,
9857
+ internalType: "contract IERC20",
9858
+ name: "token",
7465
9859
  type: "address"
7466
9860
  },
7467
9861
  {
7468
9862
  indexed: false,
7469
9863
  internalType: "uint256",
7470
- name: "amount0",
9864
+ name: "amount",
7471
9865
  type: "uint256"
7472
9866
  },
7473
9867
  {
7474
9868
  indexed: false,
7475
9869
  internalType: "uint256",
7476
- name: "amount1",
9870
+ name: "feeAmount",
7477
9871
  type: "uint256"
9872
+ }
9873
+ ],
9874
+ name: "FlashLoan",
9875
+ type: "event"
9876
+ },
9877
+ {
9878
+ anonymous: false,
9879
+ inputs: [
9880
+ {
9881
+ indexed: true,
9882
+ internalType: "address",
9883
+ name: "user",
9884
+ type: "address"
9885
+ },
9886
+ {
9887
+ indexed: true,
9888
+ internalType: "contract IERC20",
9889
+ name: "token",
9890
+ type: "address"
9891
+ },
9892
+ {
9893
+ indexed: false,
9894
+ internalType: "int256",
9895
+ name: "delta",
9896
+ type: "int256"
9897
+ }
9898
+ ],
9899
+ name: "InternalBalanceChanged",
9900
+ type: "event"
9901
+ },
9902
+ {
9903
+ anonymous: false,
9904
+ inputs: [
9905
+ {
9906
+ indexed: false,
9907
+ internalType: "bool",
9908
+ name: "paused",
9909
+ type: "bool"
9910
+ }
9911
+ ],
9912
+ name: "PausedStateChanged",
9913
+ type: "event"
9914
+ },
9915
+ {
9916
+ anonymous: false,
9917
+ inputs: [
9918
+ {
9919
+ indexed: true,
9920
+ internalType: "bytes32",
9921
+ name: "poolId",
9922
+ type: "bytes32"
7478
9923
  },
7479
9924
  {
7480
9925
  indexed: true,
7481
9926
  internalType: "address",
7482
- name: "to",
9927
+ name: "liquidityProvider",
9928
+ type: "address"
9929
+ },
9930
+ {
9931
+ indexed: false,
9932
+ internalType: "contract IERC20[]",
9933
+ name: "tokens",
9934
+ type: "address[]"
9935
+ },
9936
+ {
9937
+ indexed: false,
9938
+ internalType: "int256[]",
9939
+ name: "deltas",
9940
+ type: "int256[]"
9941
+ },
9942
+ {
9943
+ indexed: false,
9944
+ internalType: "uint256[]",
9945
+ name: "protocolFeeAmounts",
9946
+ type: "uint256[]"
9947
+ }
9948
+ ],
9949
+ name: "PoolBalanceChanged",
9950
+ type: "event"
9951
+ },
9952
+ {
9953
+ anonymous: false,
9954
+ inputs: [
9955
+ {
9956
+ indexed: true,
9957
+ internalType: "bytes32",
9958
+ name: "poolId",
9959
+ type: "bytes32"
9960
+ },
9961
+ {
9962
+ indexed: true,
9963
+ internalType: "address",
9964
+ name: "assetManager",
9965
+ type: "address"
9966
+ },
9967
+ {
9968
+ indexed: true,
9969
+ internalType: "contract IERC20",
9970
+ name: "token",
7483
9971
  type: "address"
9972
+ },
9973
+ {
9974
+ indexed: false,
9975
+ internalType: "int256",
9976
+ name: "cashDelta",
9977
+ type: "int256"
9978
+ },
9979
+ {
9980
+ indexed: false,
9981
+ internalType: "int256",
9982
+ name: "managedDelta",
9983
+ type: "int256"
7484
9984
  }
7485
9985
  ],
7486
- name: "Burn",
9986
+ name: "PoolBalanceManaged",
7487
9987
  type: "event"
7488
9988
  },
7489
9989
  {
7490
9990
  anonymous: false,
7491
9991
  inputs: [
9992
+ {
9993
+ indexed: true,
9994
+ internalType: "bytes32",
9995
+ name: "poolId",
9996
+ type: "bytes32"
9997
+ },
7492
9998
  {
7493
9999
  indexed: true,
7494
10000
  internalType: "address",
7495
- name: "sender",
10001
+ name: "poolAddress",
7496
10002
  type: "address"
7497
10003
  },
7498
10004
  {
7499
10005
  indexed: false,
7500
- internalType: "uint256",
7501
- name: "amount0",
7502
- type: "uint256"
10006
+ internalType: "enum IVault.PoolSpecialization",
10007
+ name: "specialization",
10008
+ type: "uint8"
10009
+ }
10010
+ ],
10011
+ name: "PoolRegistered",
10012
+ type: "event"
10013
+ },
10014
+ {
10015
+ anonymous: false,
10016
+ inputs: [
10017
+ {
10018
+ indexed: true,
10019
+ internalType: "address",
10020
+ name: "relayer",
10021
+ type: "address"
10022
+ },
10023
+ {
10024
+ indexed: true,
10025
+ internalType: "address",
10026
+ name: "sender",
10027
+ type: "address"
7503
10028
  },
7504
10029
  {
7505
10030
  indexed: false,
7506
- internalType: "uint256",
7507
- name: "amount1",
7508
- type: "uint256"
10031
+ internalType: "bool",
10032
+ name: "approved",
10033
+ type: "bool"
7509
10034
  }
7510
10035
  ],
7511
- name: "Mint",
10036
+ name: "RelayerApprovalChanged",
7512
10037
  type: "event"
7513
10038
  },
7514
10039
  {
@@ -7516,39 +10041,33 @@ var UniswapV2Pair = {
7516
10041
  inputs: [
7517
10042
  {
7518
10043
  indexed: true,
7519
- internalType: "address",
7520
- name: "sender",
7521
- type: "address"
10044
+ internalType: "bytes32",
10045
+ name: "poolId",
10046
+ type: "bytes32"
7522
10047
  },
7523
10048
  {
7524
- indexed: false,
7525
- internalType: "uint256",
7526
- name: "amount0In",
7527
- type: "uint256"
10049
+ indexed: true,
10050
+ internalType: "contract IERC20",
10051
+ name: "tokenIn",
10052
+ type: "address"
7528
10053
  },
7529
10054
  {
7530
- indexed: false,
7531
- internalType: "uint256",
7532
- name: "amount1In",
7533
- type: "uint256"
10055
+ indexed: true,
10056
+ internalType: "contract IERC20",
10057
+ name: "tokenOut",
10058
+ type: "address"
7534
10059
  },
7535
10060
  {
7536
10061
  indexed: false,
7537
10062
  internalType: "uint256",
7538
- name: "amount0Out",
10063
+ name: "amountIn",
7539
10064
  type: "uint256"
7540
10065
  },
7541
10066
  {
7542
10067
  indexed: false,
7543
10068
  internalType: "uint256",
7544
- name: "amount1Out",
10069
+ name: "amountOut",
7545
10070
  type: "uint256"
7546
- },
7547
- {
7548
- indexed: true,
7549
- internalType: "address",
7550
- name: "to",
7551
- type: "address"
7552
10071
  }
7553
10072
  ],
7554
10073
  name: "Swap",
@@ -7558,19 +10077,19 @@ var UniswapV2Pair = {
7558
10077
  anonymous: false,
7559
10078
  inputs: [
7560
10079
  {
7561
- indexed: false,
7562
- internalType: "uint112",
7563
- name: "reserve0",
7564
- type: "uint112"
10080
+ indexed: true,
10081
+ internalType: "bytes32",
10082
+ name: "poolId",
10083
+ type: "bytes32"
7565
10084
  },
7566
10085
  {
7567
10086
  indexed: false,
7568
- internalType: "uint112",
7569
- name: "reserve1",
7570
- type: "uint112"
10087
+ internalType: "contract IERC20[]",
10088
+ name: "tokens",
10089
+ type: "address[]"
7571
10090
  }
7572
10091
  ],
7573
- name: "Sync",
10092
+ name: "TokensDeregistered",
7574
10093
  type: "event"
7575
10094
  },
7576
10095
  {
@@ -7578,584 +10097,877 @@ var UniswapV2Pair = {
7578
10097
  inputs: [
7579
10098
  {
7580
10099
  indexed: true,
7581
- internalType: "address",
7582
- name: "from",
7583
- type: "address"
10100
+ internalType: "bytes32",
10101
+ name: "poolId",
10102
+ type: "bytes32"
7584
10103
  },
7585
10104
  {
7586
- indexed: true,
7587
- internalType: "address",
7588
- name: "to",
7589
- type: "address"
10105
+ indexed: false,
10106
+ internalType: "contract IERC20[]",
10107
+ name: "tokens",
10108
+ type: "address[]"
7590
10109
  },
7591
10110
  {
7592
10111
  indexed: false,
7593
- internalType: "uint256",
7594
- name: "value",
7595
- type: "uint256"
10112
+ internalType: "address[]",
10113
+ name: "assetManagers",
10114
+ type: "address[]"
7596
10115
  }
7597
10116
  ],
7598
- name: "Transfer",
10117
+ name: "TokensRegistered",
7599
10118
  type: "event"
7600
10119
  },
7601
10120
  {
7602
- constant: true,
7603
10121
  inputs: [
7604
10122
  ],
7605
- name: "DOMAIN_SEPARATOR",
10123
+ name: "WETH",
7606
10124
  outputs: [
7607
10125
  {
7608
- internalType: "bytes32",
10126
+ internalType: "contract IWETH",
7609
10127
  name: "",
7610
- type: "bytes32"
10128
+ type: "address"
7611
10129
  }
7612
10130
  ],
7613
- payable: false,
7614
10131
  stateMutability: "view",
7615
10132
  type: "function"
7616
10133
  },
7617
10134
  {
7618
- constant: true,
7619
10135
  inputs: [
7620
- ],
7621
- name: "MINIMUM_LIQUIDITY",
7622
- outputs: [
10136
+ {
10137
+ internalType: "enum IVault.SwapKind",
10138
+ name: "kind",
10139
+ type: "uint8"
10140
+ },
10141
+ {
10142
+ components: [
10143
+ {
10144
+ internalType: "bytes32",
10145
+ name: "poolId",
10146
+ type: "bytes32"
10147
+ },
10148
+ {
10149
+ internalType: "uint256",
10150
+ name: "assetInIndex",
10151
+ type: "uint256"
10152
+ },
10153
+ {
10154
+ internalType: "uint256",
10155
+ name: "assetOutIndex",
10156
+ type: "uint256"
10157
+ },
10158
+ {
10159
+ internalType: "uint256",
10160
+ name: "amount",
10161
+ type: "uint256"
10162
+ },
10163
+ {
10164
+ internalType: "bytes",
10165
+ name: "userData",
10166
+ type: "bytes"
10167
+ }
10168
+ ],
10169
+ internalType: "struct IVault.BatchSwapStep[]",
10170
+ name: "swaps",
10171
+ type: "tuple[]"
10172
+ },
10173
+ {
10174
+ internalType: "contract IAsset[]",
10175
+ name: "assets",
10176
+ type: "address[]"
10177
+ },
10178
+ {
10179
+ components: [
10180
+ {
10181
+ internalType: "address",
10182
+ name: "sender",
10183
+ type: "address"
10184
+ },
10185
+ {
10186
+ internalType: "bool",
10187
+ name: "fromInternalBalance",
10188
+ type: "bool"
10189
+ },
10190
+ {
10191
+ internalType: "address payable",
10192
+ name: "recipient",
10193
+ type: "address"
10194
+ },
10195
+ {
10196
+ internalType: "bool",
10197
+ name: "toInternalBalance",
10198
+ type: "bool"
10199
+ }
10200
+ ],
10201
+ internalType: "struct IVault.FundManagement",
10202
+ name: "funds",
10203
+ type: "tuple"
10204
+ },
10205
+ {
10206
+ internalType: "int256[]",
10207
+ name: "limits",
10208
+ type: "int256[]"
10209
+ },
7623
10210
  {
7624
10211
  internalType: "uint256",
7625
- name: "",
10212
+ name: "deadline",
7626
10213
  type: "uint256"
7627
10214
  }
7628
10215
  ],
7629
- payable: false,
7630
- stateMutability: "pure",
10216
+ name: "batchSwap",
10217
+ outputs: [
10218
+ {
10219
+ internalType: "int256[]",
10220
+ name: "assetDeltas",
10221
+ type: "int256[]"
10222
+ }
10223
+ ],
10224
+ stateMutability: "payable",
7631
10225
  type: "function"
7632
10226
  },
7633
10227
  {
7634
- constant: true,
7635
10228
  inputs: [
7636
- ],
7637
- name: "PERMIT_TYPEHASH",
7638
- outputs: [
7639
10229
  {
7640
10230
  internalType: "bytes32",
7641
- name: "",
10231
+ name: "poolId",
7642
10232
  type: "bytes32"
10233
+ },
10234
+ {
10235
+ internalType: "contract IERC20[]",
10236
+ name: "tokens",
10237
+ type: "address[]"
7643
10238
  }
7644
10239
  ],
7645
- payable: false,
7646
- stateMutability: "pure",
10240
+ name: "deregisterTokens",
10241
+ outputs: [
10242
+ ],
10243
+ stateMutability: "nonpayable",
7647
10244
  type: "function"
7648
10245
  },
7649
10246
  {
7650
- constant: true,
7651
10247
  inputs: [
10248
+ {
10249
+ internalType: "bytes32",
10250
+ name: "poolId",
10251
+ type: "bytes32"
10252
+ },
7652
10253
  {
7653
10254
  internalType: "address",
7654
- name: "owner",
10255
+ name: "sender",
7655
10256
  type: "address"
7656
10257
  },
7657
10258
  {
7658
- internalType: "address",
7659
- name: "spender",
10259
+ internalType: "address payable",
10260
+ name: "recipient",
7660
10261
  type: "address"
10262
+ },
10263
+ {
10264
+ components: [
10265
+ {
10266
+ internalType: "contract IAsset[]",
10267
+ name: "assets",
10268
+ type: "address[]"
10269
+ },
10270
+ {
10271
+ internalType: "uint256[]",
10272
+ name: "minAmountsOut",
10273
+ type: "uint256[]"
10274
+ },
10275
+ {
10276
+ internalType: "bytes",
10277
+ name: "userData",
10278
+ type: "bytes"
10279
+ },
10280
+ {
10281
+ internalType: "bool",
10282
+ name: "toInternalBalance",
10283
+ type: "bool"
10284
+ }
10285
+ ],
10286
+ internalType: "struct IVault.ExitPoolRequest",
10287
+ name: "request",
10288
+ type: "tuple"
7661
10289
  }
7662
10290
  ],
7663
- name: "allowance",
10291
+ name: "exitPool",
7664
10292
  outputs: [
7665
- {
7666
- internalType: "uint256",
7667
- name: "",
7668
- type: "uint256"
7669
- }
7670
10293
  ],
7671
- payable: false,
7672
- stateMutability: "view",
10294
+ stateMutability: "nonpayable",
7673
10295
  type: "function"
7674
10296
  },
7675
10297
  {
7676
- constant: false,
7677
10298
  inputs: [
7678
10299
  {
7679
- internalType: "address",
7680
- name: "spender",
10300
+ internalType: "contract IFlashLoanRecipient",
10301
+ name: "recipient",
7681
10302
  type: "address"
7682
10303
  },
7683
10304
  {
7684
- internalType: "uint256",
7685
- name: "value",
7686
- type: "uint256"
10305
+ internalType: "contract IERC20[]",
10306
+ name: "tokens",
10307
+ type: "address[]"
10308
+ },
10309
+ {
10310
+ internalType: "uint256[]",
10311
+ name: "amounts",
10312
+ type: "uint256[]"
10313
+ },
10314
+ {
10315
+ internalType: "bytes",
10316
+ name: "userData",
10317
+ type: "bytes"
7687
10318
  }
7688
10319
  ],
7689
- name: "approve",
10320
+ name: "flashLoan",
7690
10321
  outputs: [
7691
- {
7692
- internalType: "bool",
7693
- name: "",
7694
- type: "bool"
7695
- }
7696
10322
  ],
7697
- payable: false,
7698
10323
  stateMutability: "nonpayable",
7699
10324
  type: "function"
7700
10325
  },
7701
10326
  {
7702
- constant: true,
7703
10327
  inputs: [
7704
10328
  {
7705
- internalType: "address",
7706
- name: "owner",
7707
- type: "address"
10329
+ internalType: "bytes4",
10330
+ name: "selector",
10331
+ type: "bytes4"
7708
10332
  }
7709
10333
  ],
7710
- name: "balanceOf",
10334
+ name: "getActionId",
7711
10335
  outputs: [
7712
10336
  {
7713
- internalType: "uint256",
10337
+ internalType: "bytes32",
7714
10338
  name: "",
7715
- type: "uint256"
10339
+ type: "bytes32"
7716
10340
  }
7717
10341
  ],
7718
- payable: false,
7719
10342
  stateMutability: "view",
7720
10343
  type: "function"
7721
10344
  },
7722
10345
  {
7723
- constant: false,
7724
10346
  inputs: [
10347
+ ],
10348
+ name: "getAuthorizer",
10349
+ outputs: [
7725
10350
  {
7726
- internalType: "address",
7727
- name: "to",
10351
+ internalType: "contract IAuthorizer",
10352
+ name: "",
7728
10353
  type: "address"
7729
10354
  }
7730
10355
  ],
7731
- name: "burn",
10356
+ stateMutability: "view",
10357
+ type: "function"
10358
+ },
10359
+ {
10360
+ inputs: [
10361
+ ],
10362
+ name: "getDomainSeparator",
7732
10363
  outputs: [
7733
10364
  {
7734
- internalType: "uint256",
7735
- name: "amount0",
7736
- type: "uint256"
7737
- },
7738
- {
7739
- internalType: "uint256",
7740
- name: "amount1",
7741
- type: "uint256"
10365
+ internalType: "bytes32",
10366
+ name: "",
10367
+ type: "bytes32"
7742
10368
  }
7743
10369
  ],
7744
- payable: false,
7745
- stateMutability: "nonpayable",
10370
+ stateMutability: "view",
7746
10371
  type: "function"
7747
10372
  },
7748
10373
  {
7749
- constant: true,
7750
10374
  inputs: [
10375
+ {
10376
+ internalType: "address",
10377
+ name: "user",
10378
+ type: "address"
10379
+ },
10380
+ {
10381
+ internalType: "contract IERC20[]",
10382
+ name: "tokens",
10383
+ type: "address[]"
10384
+ }
7751
10385
  ],
7752
- name: "decimals",
10386
+ name: "getInternalBalance",
7753
10387
  outputs: [
7754
10388
  {
7755
- internalType: "uint8",
7756
- name: "",
7757
- type: "uint8"
10389
+ internalType: "uint256[]",
10390
+ name: "balances",
10391
+ type: "uint256[]"
7758
10392
  }
7759
10393
  ],
7760
- payable: false,
7761
- stateMutability: "pure",
10394
+ stateMutability: "view",
7762
10395
  type: "function"
7763
10396
  },
7764
10397
  {
7765
- constant: true,
7766
10398
  inputs: [
10399
+ {
10400
+ internalType: "address",
10401
+ name: "user",
10402
+ type: "address"
10403
+ }
7767
10404
  ],
7768
- name: "factory",
10405
+ name: "getNextNonce",
7769
10406
  outputs: [
7770
10407
  {
7771
- internalType: "address",
10408
+ internalType: "uint256",
7772
10409
  name: "",
7773
- type: "address"
10410
+ type: "uint256"
7774
10411
  }
7775
10412
  ],
7776
- payable: false,
7777
10413
  stateMutability: "view",
7778
10414
  type: "function"
7779
10415
  },
7780
10416
  {
7781
- constant: true,
7782
10417
  inputs: [
7783
10418
  ],
7784
- name: "getReserves",
10419
+ name: "getPausedState",
7785
10420
  outputs: [
7786
10421
  {
7787
- internalType: "uint112",
7788
- name: "reserve0",
7789
- type: "uint112"
10422
+ internalType: "bool",
10423
+ name: "paused",
10424
+ type: "bool"
7790
10425
  },
7791
10426
  {
7792
- internalType: "uint112",
7793
- name: "reserve1",
7794
- type: "uint112"
10427
+ internalType: "uint256",
10428
+ name: "pauseWindowEndTime",
10429
+ type: "uint256"
7795
10430
  },
7796
10431
  {
7797
- internalType: "uint32",
7798
- name: "blockTimestampLast",
7799
- type: "uint32"
10432
+ internalType: "uint256",
10433
+ name: "bufferPeriodEndTime",
10434
+ type: "uint256"
7800
10435
  }
7801
10436
  ],
7802
- payable: false,
7803
10437
  stateMutability: "view",
7804
10438
  type: "function"
7805
10439
  },
7806
10440
  {
7807
- constant: false,
7808
10441
  inputs: [
10442
+ {
10443
+ internalType: "bytes32",
10444
+ name: "poolId",
10445
+ type: "bytes32"
10446
+ }
10447
+ ],
10448
+ name: "getPool",
10449
+ outputs: [
7809
10450
  {
7810
10451
  internalType: "address",
7811
10452
  name: "",
7812
10453
  type: "address"
7813
10454
  },
7814
10455
  {
7815
- internalType: "address",
10456
+ internalType: "enum IVault.PoolSpecialization",
7816
10457
  name: "",
7817
- type: "address"
10458
+ type: "uint8"
7818
10459
  }
7819
10460
  ],
7820
- name: "initialize",
7821
- outputs: [
7822
- ],
7823
- payable: false,
7824
- stateMutability: "nonpayable",
10461
+ stateMutability: "view",
7825
10462
  type: "function"
7826
10463
  },
7827
10464
  {
7828
- constant: true,
7829
10465
  inputs: [
10466
+ {
10467
+ internalType: "bytes32",
10468
+ name: "poolId",
10469
+ type: "bytes32"
10470
+ },
10471
+ {
10472
+ internalType: "contract IERC20",
10473
+ name: "token",
10474
+ type: "address"
10475
+ }
7830
10476
  ],
7831
- name: "kLast",
10477
+ name: "getPoolTokenInfo",
7832
10478
  outputs: [
7833
10479
  {
7834
10480
  internalType: "uint256",
7835
- name: "",
10481
+ name: "cash",
10482
+ type: "uint256"
10483
+ },
10484
+ {
10485
+ internalType: "uint256",
10486
+ name: "managed",
10487
+ type: "uint256"
10488
+ },
10489
+ {
10490
+ internalType: "uint256",
10491
+ name: "lastChangeBlock",
7836
10492
  type: "uint256"
10493
+ },
10494
+ {
10495
+ internalType: "address",
10496
+ name: "assetManager",
10497
+ type: "address"
7837
10498
  }
7838
10499
  ],
7839
- payable: false,
7840
10500
  stateMutability: "view",
7841
10501
  type: "function"
7842
10502
  },
7843
10503
  {
7844
- constant: false,
7845
10504
  inputs: [
7846
10505
  {
7847
- internalType: "address",
7848
- name: "to",
7849
- type: "address"
10506
+ internalType: "bytes32",
10507
+ name: "poolId",
10508
+ type: "bytes32"
7850
10509
  }
7851
10510
  ],
7852
- name: "mint",
10511
+ name: "getPoolTokens",
7853
10512
  outputs: [
10513
+ {
10514
+ internalType: "contract IERC20[]",
10515
+ name: "tokens",
10516
+ type: "address[]"
10517
+ },
10518
+ {
10519
+ internalType: "uint256[]",
10520
+ name: "balances",
10521
+ type: "uint256[]"
10522
+ },
7854
10523
  {
7855
10524
  internalType: "uint256",
7856
- name: "liquidity",
10525
+ name: "lastChangeBlock",
7857
10526
  type: "uint256"
7858
10527
  }
7859
10528
  ],
7860
- payable: false,
7861
- stateMutability: "nonpayable",
10529
+ stateMutability: "view",
7862
10530
  type: "function"
7863
10531
  },
7864
10532
  {
7865
- constant: true,
7866
10533
  inputs: [
7867
10534
  ],
7868
- name: "name",
10535
+ name: "getProtocolFeesCollector",
7869
10536
  outputs: [
7870
10537
  {
7871
- internalType: "string",
10538
+ internalType: "contract ProtocolFeesCollector",
7872
10539
  name: "",
7873
- type: "string"
10540
+ type: "address"
7874
10541
  }
7875
10542
  ],
7876
- payable: false,
7877
- stateMutability: "pure",
10543
+ stateMutability: "view",
7878
10544
  type: "function"
7879
10545
  },
7880
10546
  {
7881
- constant: true,
7882
10547
  inputs: [
7883
10548
  {
7884
10549
  internalType: "address",
7885
- name: "owner",
10550
+ name: "user",
10551
+ type: "address"
10552
+ },
10553
+ {
10554
+ internalType: "address",
10555
+ name: "relayer",
7886
10556
  type: "address"
7887
10557
  }
7888
10558
  ],
7889
- name: "nonces",
10559
+ name: "hasApprovedRelayer",
7890
10560
  outputs: [
7891
10561
  {
7892
- internalType: "uint256",
10562
+ internalType: "bool",
7893
10563
  name: "",
7894
- type: "uint256"
10564
+ type: "bool"
7895
10565
  }
7896
10566
  ],
7897
- payable: false,
7898
10567
  stateMutability: "view",
7899
10568
  type: "function"
7900
10569
  },
7901
10570
  {
7902
- constant: false,
7903
10571
  inputs: [
7904
10572
  {
7905
- internalType: "address",
7906
- name: "owner",
7907
- type: "address"
10573
+ internalType: "bytes32",
10574
+ name: "poolId",
10575
+ type: "bytes32"
7908
10576
  },
7909
10577
  {
7910
10578
  internalType: "address",
7911
- name: "spender",
10579
+ name: "sender",
7912
10580
  type: "address"
7913
10581
  },
7914
10582
  {
7915
- internalType: "uint256",
7916
- name: "value",
7917
- type: "uint256"
7918
- },
7919
- {
7920
- internalType: "uint256",
7921
- name: "deadline",
7922
- type: "uint256"
7923
- },
7924
- {
7925
- internalType: "uint8",
7926
- name: "v",
7927
- type: "uint8"
10583
+ internalType: "address",
10584
+ name: "recipient",
10585
+ type: "address"
7928
10586
  },
7929
10587
  {
7930
- internalType: "bytes32",
7931
- name: "r",
7932
- type: "bytes32"
7933
- },
10588
+ components: [
10589
+ {
10590
+ internalType: "contract IAsset[]",
10591
+ name: "assets",
10592
+ type: "address[]"
10593
+ },
10594
+ {
10595
+ internalType: "uint256[]",
10596
+ name: "maxAmountsIn",
10597
+ type: "uint256[]"
10598
+ },
10599
+ {
10600
+ internalType: "bytes",
10601
+ name: "userData",
10602
+ type: "bytes"
10603
+ },
10604
+ {
10605
+ internalType: "bool",
10606
+ name: "fromInternalBalance",
10607
+ type: "bool"
10608
+ }
10609
+ ],
10610
+ internalType: "struct IVault.JoinPoolRequest",
10611
+ name: "request",
10612
+ type: "tuple"
10613
+ }
10614
+ ],
10615
+ name: "joinPool",
10616
+ outputs: [
10617
+ ],
10618
+ stateMutability: "payable",
10619
+ type: "function"
10620
+ },
10621
+ {
10622
+ inputs: [
7934
10623
  {
7935
- internalType: "bytes32",
7936
- name: "s",
7937
- type: "bytes32"
10624
+ components: [
10625
+ {
10626
+ internalType: "enum IVault.PoolBalanceOpKind",
10627
+ name: "kind",
10628
+ type: "uint8"
10629
+ },
10630
+ {
10631
+ internalType: "bytes32",
10632
+ name: "poolId",
10633
+ type: "bytes32"
10634
+ },
10635
+ {
10636
+ internalType: "contract IERC20",
10637
+ name: "token",
10638
+ type: "address"
10639
+ },
10640
+ {
10641
+ internalType: "uint256",
10642
+ name: "amount",
10643
+ type: "uint256"
10644
+ }
10645
+ ],
10646
+ internalType: "struct IVault.PoolBalanceOp[]",
10647
+ name: "ops",
10648
+ type: "tuple[]"
7938
10649
  }
7939
10650
  ],
7940
- name: "permit",
10651
+ name: "managePoolBalance",
7941
10652
  outputs: [
7942
10653
  ],
7943
- payable: false,
7944
10654
  stateMutability: "nonpayable",
7945
10655
  type: "function"
7946
10656
  },
7947
10657
  {
7948
- constant: true,
7949
10658
  inputs: [
10659
+ {
10660
+ components: [
10661
+ {
10662
+ internalType: "enum IVault.UserBalanceOpKind",
10663
+ name: "kind",
10664
+ type: "uint8"
10665
+ },
10666
+ {
10667
+ internalType: "contract IAsset",
10668
+ name: "asset",
10669
+ type: "address"
10670
+ },
10671
+ {
10672
+ internalType: "uint256",
10673
+ name: "amount",
10674
+ type: "uint256"
10675
+ },
10676
+ {
10677
+ internalType: "address",
10678
+ name: "sender",
10679
+ type: "address"
10680
+ },
10681
+ {
10682
+ internalType: "address payable",
10683
+ name: "recipient",
10684
+ type: "address"
10685
+ }
10686
+ ],
10687
+ internalType: "struct IVault.UserBalanceOp[]",
10688
+ name: "ops",
10689
+ type: "tuple[]"
10690
+ }
7950
10691
  ],
7951
- name: "price0CumulativeLast",
10692
+ name: "manageUserBalance",
7952
10693
  outputs: [
10694
+ ],
10695
+ stateMutability: "payable",
10696
+ type: "function"
10697
+ },
10698
+ {
10699
+ inputs: [
7953
10700
  {
7954
- internalType: "uint256",
7955
- name: "",
7956
- type: "uint256"
10701
+ internalType: "enum IVault.SwapKind",
10702
+ name: "kind",
10703
+ type: "uint8"
10704
+ },
10705
+ {
10706
+ components: [
10707
+ {
10708
+ internalType: "bytes32",
10709
+ name: "poolId",
10710
+ type: "bytes32"
10711
+ },
10712
+ {
10713
+ internalType: "uint256",
10714
+ name: "assetInIndex",
10715
+ type: "uint256"
10716
+ },
10717
+ {
10718
+ internalType: "uint256",
10719
+ name: "assetOutIndex",
10720
+ type: "uint256"
10721
+ },
10722
+ {
10723
+ internalType: "uint256",
10724
+ name: "amount",
10725
+ type: "uint256"
10726
+ },
10727
+ {
10728
+ internalType: "bytes",
10729
+ name: "userData",
10730
+ type: "bytes"
10731
+ }
10732
+ ],
10733
+ internalType: "struct IVault.BatchSwapStep[]",
10734
+ name: "swaps",
10735
+ type: "tuple[]"
10736
+ },
10737
+ {
10738
+ internalType: "contract IAsset[]",
10739
+ name: "assets",
10740
+ type: "address[]"
10741
+ },
10742
+ {
10743
+ components: [
10744
+ {
10745
+ internalType: "address",
10746
+ name: "sender",
10747
+ type: "address"
10748
+ },
10749
+ {
10750
+ internalType: "bool",
10751
+ name: "fromInternalBalance",
10752
+ type: "bool"
10753
+ },
10754
+ {
10755
+ internalType: "address payable",
10756
+ name: "recipient",
10757
+ type: "address"
10758
+ },
10759
+ {
10760
+ internalType: "bool",
10761
+ name: "toInternalBalance",
10762
+ type: "bool"
10763
+ }
10764
+ ],
10765
+ internalType: "struct IVault.FundManagement",
10766
+ name: "funds",
10767
+ type: "tuple"
7957
10768
  }
7958
10769
  ],
7959
- payable: false,
7960
- stateMutability: "view",
7961
- type: "function"
7962
- },
7963
- {
7964
- constant: true,
7965
- inputs: [
7966
- ],
7967
- name: "price1CumulativeLast",
10770
+ name: "queryBatchSwap",
7968
10771
  outputs: [
7969
10772
  {
7970
- internalType: "uint256",
10773
+ internalType: "int256[]",
7971
10774
  name: "",
7972
- type: "uint256"
10775
+ type: "int256[]"
7973
10776
  }
7974
10777
  ],
7975
- payable: false,
7976
- stateMutability: "view",
10778
+ stateMutability: "nonpayable",
7977
10779
  type: "function"
7978
10780
  },
7979
10781
  {
7980
- constant: false,
7981
10782
  inputs: [
7982
10783
  {
7983
- internalType: "address",
7984
- name: "to",
7985
- type: "address"
10784
+ internalType: "enum IVault.PoolSpecialization",
10785
+ name: "specialization",
10786
+ type: "uint8"
7986
10787
  }
7987
10788
  ],
7988
- name: "skim",
10789
+ name: "registerPool",
7989
10790
  outputs: [
10791
+ {
10792
+ internalType: "bytes32",
10793
+ name: "",
10794
+ type: "bytes32"
10795
+ }
7990
10796
  ],
7991
- payable: false,
7992
10797
  stateMutability: "nonpayable",
7993
10798
  type: "function"
7994
10799
  },
7995
10800
  {
7996
- constant: false,
7997
10801
  inputs: [
7998
10802
  {
7999
- internalType: "uint256",
8000
- name: "amount0Out",
8001
- type: "uint256"
8002
- },
8003
- {
8004
- internalType: "uint256",
8005
- name: "amount1Out",
8006
- type: "uint256"
10803
+ internalType: "bytes32",
10804
+ name: "poolId",
10805
+ type: "bytes32"
8007
10806
  },
8008
10807
  {
8009
- internalType: "address",
8010
- name: "to",
8011
- type: "address"
10808
+ internalType: "contract IERC20[]",
10809
+ name: "tokens",
10810
+ type: "address[]"
8012
10811
  },
8013
10812
  {
8014
- internalType: "bytes",
8015
- name: "data",
8016
- type: "bytes"
10813
+ internalType: "address[]",
10814
+ name: "assetManagers",
10815
+ type: "address[]"
8017
10816
  }
8018
10817
  ],
8019
- name: "swap",
10818
+ name: "registerTokens",
8020
10819
  outputs: [
8021
10820
  ],
8022
- payable: false,
8023
10821
  stateMutability: "nonpayable",
8024
10822
  type: "function"
8025
10823
  },
8026
10824
  {
8027
- constant: true,
8028
10825
  inputs: [
8029
- ],
8030
- name: "symbol",
8031
- outputs: [
8032
10826
  {
8033
- internalType: "string",
8034
- name: "",
8035
- type: "string"
10827
+ internalType: "contract IAuthorizer",
10828
+ name: "newAuthorizer",
10829
+ type: "address"
8036
10830
  }
8037
10831
  ],
8038
- payable: false,
8039
- stateMutability: "pure",
8040
- type: "function"
8041
- },
8042
- {
8043
- constant: false,
8044
- inputs: [
8045
- ],
8046
- name: "sync",
10832
+ name: "setAuthorizer",
8047
10833
  outputs: [
8048
10834
  ],
8049
- payable: false,
8050
10835
  stateMutability: "nonpayable",
8051
10836
  type: "function"
8052
10837
  },
8053
10838
  {
8054
- constant: true,
8055
- inputs: [
8056
- ],
8057
- name: "token0",
8058
- outputs: [
8059
- {
8060
- internalType: "address",
8061
- name: "",
8062
- type: "address"
8063
- }
8064
- ],
8065
- payable: false,
8066
- stateMutability: "view",
8067
- type: "function"
8068
- },
8069
- {
8070
- constant: true,
8071
10839
  inputs: [
8072
- ],
8073
- name: "token1",
8074
- outputs: [
8075
10840
  {
8076
- internalType: "address",
8077
- name: "",
8078
- type: "address"
10841
+ internalType: "bool",
10842
+ name: "paused",
10843
+ type: "bool"
8079
10844
  }
8080
10845
  ],
8081
- payable: false,
8082
- stateMutability: "view",
8083
- type: "function"
8084
- },
8085
- {
8086
- constant: true,
8087
- inputs: [
8088
- ],
8089
- name: "totalSupply",
10846
+ name: "setPaused",
8090
10847
  outputs: [
8091
- {
8092
- internalType: "uint256",
8093
- name: "",
8094
- type: "uint256"
8095
- }
8096
10848
  ],
8097
- payable: false,
8098
- stateMutability: "view",
10849
+ stateMutability: "nonpayable",
8099
10850
  type: "function"
8100
10851
  },
8101
10852
  {
8102
- constant: false,
8103
10853
  inputs: [
8104
10854
  {
8105
10855
  internalType: "address",
8106
- name: "to",
10856
+ name: "sender",
8107
10857
  type: "address"
8108
10858
  },
8109
10859
  {
8110
- internalType: "uint256",
8111
- name: "value",
8112
- type: "uint256"
8113
- }
8114
- ],
8115
- name: "transfer",
8116
- outputs: [
10860
+ internalType: "address",
10861
+ name: "relayer",
10862
+ type: "address"
10863
+ },
8117
10864
  {
8118
10865
  internalType: "bool",
8119
- name: "",
10866
+ name: "approved",
8120
10867
  type: "bool"
8121
10868
  }
8122
10869
  ],
8123
- payable: false,
10870
+ name: "setRelayerApproval",
10871
+ outputs: [
10872
+ ],
8124
10873
  stateMutability: "nonpayable",
8125
10874
  type: "function"
8126
10875
  },
8127
10876
  {
8128
- constant: false,
8129
10877
  inputs: [
8130
10878
  {
8131
- internalType: "address",
8132
- name: "from",
8133
- type: "address"
10879
+ components: [
10880
+ {
10881
+ internalType: "bytes32",
10882
+ name: "poolId",
10883
+ type: "bytes32"
10884
+ },
10885
+ {
10886
+ internalType: "enum IVault.SwapKind",
10887
+ name: "kind",
10888
+ type: "uint8"
10889
+ },
10890
+ {
10891
+ internalType: "contract IAsset",
10892
+ name: "assetIn",
10893
+ type: "address"
10894
+ },
10895
+ {
10896
+ internalType: "contract IAsset",
10897
+ name: "assetOut",
10898
+ type: "address"
10899
+ },
10900
+ {
10901
+ internalType: "uint256",
10902
+ name: "amount",
10903
+ type: "uint256"
10904
+ },
10905
+ {
10906
+ internalType: "bytes",
10907
+ name: "userData",
10908
+ type: "bytes"
10909
+ }
10910
+ ],
10911
+ internalType: "struct IVault.SingleSwap",
10912
+ name: "singleSwap",
10913
+ type: "tuple"
8134
10914
  },
8135
10915
  {
8136
- internalType: "address",
8137
- name: "to",
8138
- type: "address"
10916
+ components: [
10917
+ {
10918
+ internalType: "address",
10919
+ name: "sender",
10920
+ type: "address"
10921
+ },
10922
+ {
10923
+ internalType: "bool",
10924
+ name: "fromInternalBalance",
10925
+ type: "bool"
10926
+ },
10927
+ {
10928
+ internalType: "address payable",
10929
+ name: "recipient",
10930
+ type: "address"
10931
+ },
10932
+ {
10933
+ internalType: "bool",
10934
+ name: "toInternalBalance",
10935
+ type: "bool"
10936
+ }
10937
+ ],
10938
+ internalType: "struct IVault.FundManagement",
10939
+ name: "funds",
10940
+ type: "tuple"
8139
10941
  },
8140
10942
  {
8141
10943
  internalType: "uint256",
8142
- name: "value",
10944
+ name: "limit",
10945
+ type: "uint256"
10946
+ },
10947
+ {
10948
+ internalType: "uint256",
10949
+ name: "deadline",
8143
10950
  type: "uint256"
8144
10951
  }
8145
10952
  ],
8146
- name: "transferFrom",
10953
+ name: "swap",
8147
10954
  outputs: [
8148
10955
  {
8149
- internalType: "bool",
8150
- name: "",
8151
- type: "bool"
10956
+ internalType: "uint256",
10957
+ name: "amountCalculated",
10958
+ type: "uint256"
8152
10959
  }
8153
10960
  ],
8154
- payable: false,
8155
- stateMutability: "nonpayable",
10961
+ stateMutability: "payable",
8156
10962
  type: "function"
10963
+ },
10964
+ {
10965
+ stateMutability: "payable",
10966
+ type: "receive"
8157
10967
  }
8158
- ]
10968
+ ];
10969
+ var IBalancerV2Vault = {
10970
+ abi: abi$b
8159
10971
  };
8160
10972
 
8161
10973
  var Utils = /*#__PURE__*/function () {
@@ -8389,6 +11201,145 @@ var Utils = /*#__PURE__*/function () {
8389
11201
  return getMinAmountOut;
8390
11202
  }();
8391
11203
 
11204
+ _proto.getBalancerSwapTx = /*#__PURE__*/function () {
11205
+ var _getBalancerSwapTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(pool, assetFrom, assetTo, amountIn, slippage // eslint-disable-next-line @typescript-eslint/no-explicit-any
11206
+ ) {
11207
+ var sor$1, isFetched, swapType, _yield$sor$getSwaps, swaps, tokenAddresses, returnAmount, minimumAmountOut, iBalancerV2Vault, swap, swapTx, limits, _swapTx;
11208
+
11209
+ return runtime_1.wrap(function _callee5$(_context5) {
11210
+ while (1) {
11211
+ switch (_context5.prev = _context5.next) {
11212
+ case 0:
11213
+ sor$1 = new sor.SOR(this.signer.provider, networkChainIdMap[this.network], balancerSubgraph[this.network]); // isFetched will be true on success
11214
+
11215
+ _context5.next = 3;
11216
+ return sor$1.fetchPools();
11217
+
11218
+ case 3:
11219
+ isFetched = _context5.sent;
11220
+
11221
+ if (isFetched) {
11222
+ _context5.next = 6;
11223
+ break;
11224
+ }
11225
+
11226
+ throw new Error("Error fetching balancer pools");
11227
+
11228
+ case 6:
11229
+ swapType = sor.SwapTypes.SwapExactIn;
11230
+ _context5.next = 9;
11231
+ return sor$1.getSwaps(assetFrom, assetTo, swapType, ethers.ethers.BigNumber.from(amountIn));
11232
+
11233
+ case 9:
11234
+ _yield$sor$getSwaps = _context5.sent;
11235
+ swaps = _yield$sor$getSwaps.swaps;
11236
+ tokenAddresses = _yield$sor$getSwaps.tokenAddresses;
11237
+ returnAmount = _yield$sor$getSwaps.returnAmount;
11238
+ minimumAmountOut = returnAmount.mul(10000 - slippage * 100).div(10000);
11239
+ iBalancerV2Vault = new ethers.ethers.utils.Interface(IBalancerV2Vault.abi);
11240
+
11241
+ if (!(swaps.length === 1)) {
11242
+ _context5.next = 21;
11243
+ break;
11244
+ }
11245
+
11246
+ swap = swaps[0]; //do single swap
11247
+
11248
+ swapTx = iBalancerV2Vault.encodeFunctionData("swap", [[swap.poolId, sor.SwapTypes.SwapExactIn, tokenAddresses[swap.assetInIndex], tokenAddresses[swap.assetOutIndex], swap.amount, swap.userData], [pool.address, false, pool.address, false], minimumAmountOut, Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
11249
+ ]);
11250
+ return _context5.abrupt("return", swapTx);
11251
+
11252
+ case 21:
11253
+ // Limits:
11254
+ // +ve means max to send
11255
+ // -ve mean min to receive
11256
+ // For a multihop the intermediate tokens should be 0
11257
+ limits = [];
11258
+ tokenAddresses.forEach(function (token, i) {
11259
+ if (token.toLowerCase() === assetFrom.toLowerCase()) {
11260
+ limits[i] = amountIn.toString();
11261
+ } else if (token.toLowerCase() === assetTo.toLowerCase()) {
11262
+ limits[i] = minimumAmountOut.mul(-1).toString();
11263
+ } else {
11264
+ limits[i] = "0";
11265
+ }
11266
+ });
11267
+ _swapTx = iBalancerV2Vault.encodeFunctionData("batchSwap", [sor.SwapTypes.SwapExactIn, swaps, tokenAddresses, [pool.address, false, pool.address, false], limits, Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time
11268
+ ]);
11269
+ return _context5.abrupt("return", _swapTx);
11270
+
11271
+ case 25:
11272
+ case "end":
11273
+ return _context5.stop();
11274
+ }
11275
+ }
11276
+ }, _callee5, this);
11277
+ }));
11278
+
11279
+ function getBalancerSwapTx(_x13, _x14, _x15, _x16, _x17) {
11280
+ return _getBalancerSwapTx.apply(this, arguments);
11281
+ }
11282
+
11283
+ return getBalancerSwapTx;
11284
+ }();
11285
+
11286
+ _proto.getBalancerJoinPoolTx = /*#__PURE__*/function () {
11287
+ var _getBalancerJoinPoolTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(pool, balancerPoolId, assets, amountsIn // eslint-disable-next-line @typescript-eslint/no-explicit-any
11288
+ ) {
11289
+ var iBalancerV2Vault, txData, joinPoolTx;
11290
+ return runtime_1.wrap(function _callee6$(_context6) {
11291
+ while (1) {
11292
+ switch (_context6.prev = _context6.next) {
11293
+ case 0:
11294
+ iBalancerV2Vault = new ethers.ethers.utils.Interface(IBalancerV2Vault.abi);
11295
+ txData = [balancerPoolId, pool.address, pool.address, [assets, amountsIn, ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256[]", "uint256"], [1, amountsIn, 0]), false]];
11296
+ joinPoolTx = iBalancerV2Vault.encodeFunctionData("joinPool", txData);
11297
+ return _context6.abrupt("return", joinPoolTx);
11298
+
11299
+ case 4:
11300
+ case "end":
11301
+ return _context6.stop();
11302
+ }
11303
+ }
11304
+ }, _callee6);
11305
+ }));
11306
+
11307
+ function getBalancerJoinPoolTx(_x18, _x19, _x20, _x21) {
11308
+ return _getBalancerJoinPoolTx.apply(this, arguments);
11309
+ }
11310
+
11311
+ return getBalancerJoinPoolTx;
11312
+ }();
11313
+
11314
+ _proto.getBalancerExitPoolTx = /*#__PURE__*/function () {
11315
+ var _getBalancerExitPoolTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(pool, balancerPoolId, assets, amount // eslint-disable-next-line @typescript-eslint/no-explicit-any
11316
+ ) {
11317
+ var minimumAmountOut, iBalancerV2Vault, txData, exitPoolTx;
11318
+ return runtime_1.wrap(function _callee7$(_context7) {
11319
+ while (1) {
11320
+ switch (_context7.prev = _context7.next) {
11321
+ case 0:
11322
+ minimumAmountOut = new Array(assets.length).fill(0);
11323
+ iBalancerV2Vault = new ethers.ethers.utils.Interface(IBalancerV2Vault.abi);
11324
+ txData = [balancerPoolId, pool.address, pool.address, [assets, minimumAmountOut, ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256"], [1, amount]), false]];
11325
+ exitPoolTx = iBalancerV2Vault.encodeFunctionData("exitPool", txData);
11326
+ return _context7.abrupt("return", exitPoolTx);
11327
+
11328
+ case 5:
11329
+ case "end":
11330
+ return _context7.stop();
11331
+ }
11332
+ }
11333
+ }, _callee7);
11334
+ }));
11335
+
11336
+ function getBalancerExitPoolTx(_x22, _x23, _x24, _x25) {
11337
+ return _getBalancerExitPoolTx.apply(this, arguments);
11338
+ }
11339
+
11340
+ return getBalancerExitPoolTx;
11341
+ }();
11342
+
8392
11343
  return Utils;
8393
11344
  }();
8394
11345