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