@dhedge/v2-sdk 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { ethers } from "ethers";
2
2
  import { Pool } from "../..";
3
- export declare function getPoolDepositAsset(pool: Pool, poolAddress: string): Promise<string | undefined>;
3
+ export declare function getPoolDepositAsset(pool: Pool, poolAddress: string, investAsset: string): Promise<string | undefined>;
4
4
  export declare function getTorosPoolTokenPrice(pool: Pool, poolAddress: string): Promise<ethers.BigNumber>;
5
5
  export declare function getEasySwapperDepositQuote(pool: Pool, torosAsset: string, investAsset: string, depositAsset: string, amountIn: ethers.BigNumber): Promise<ethers.BigNumber>;
6
6
  export declare function getEasySwapperWithdrawalQuote(pool: Pool, torosAsset: string, investAsset: string, amountIn: ethers.BigNumber): Promise<ethers.BigNumber>;
@@ -10722,13 +10722,13 @@ function _isPool() {
10722
10722
  return _isPool.apply(this, arguments);
10723
10723
  }
10724
10724
 
10725
- function getPoolDepositAsset(_x, _x2) {
10725
+ function getPoolDepositAsset(_x, _x2, _x3) {
10726
10726
  return _getPoolDepositAsset.apply(this, arguments);
10727
10727
  }
10728
10728
 
10729
10729
  function _getPoolDepositAsset() {
10730
- _getPoolDepositAsset = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, poolAddress) {
10731
- var _composition$find;
10730
+ _getPoolDepositAsset = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, poolAddress, investAsset) {
10731
+ var _composition$find, _composition$find2;
10732
10732
 
10733
10733
  var torosPool, composition;
10734
10734
  return runtime_1.wrap(function _callee$(_context) {
@@ -10745,11 +10745,22 @@ function _getPoolDepositAsset() {
10745
10745
 
10746
10746
  case 5:
10747
10747
  composition = _context.sent;
10748
- return _context.abrupt("return", (_composition$find = composition.find(function (e) {
10748
+
10749
+ if (!((_composition$find = composition.find(function (e) {
10750
+ return e.asset.toLowerCase() === investAsset.toLowerCase();
10751
+ })) != null && _composition$find.isDeposit)) {
10752
+ _context.next = 8;
10753
+ break;
10754
+ }
10755
+
10756
+ return _context.abrupt("return", investAsset);
10757
+
10758
+ case 8:
10759
+ return _context.abrupt("return", (_composition$find2 = composition.find(function (e) {
10749
10760
  return e.isDeposit;
10750
- })) == null ? void 0 : _composition$find.asset);
10761
+ })) == null ? void 0 : _composition$find2.asset);
10751
10762
 
10752
- case 7:
10763
+ case 9:
10753
10764
  case "end":
10754
10765
  return _context.stop();
10755
10766
  }
@@ -10759,7 +10770,7 @@ function _getPoolDepositAsset() {
10759
10770
  return _getPoolDepositAsset.apply(this, arguments);
10760
10771
  }
10761
10772
 
10762
- function getTorosPoolTokenPrice(_x3, _x4) {
10773
+ function getTorosPoolTokenPrice(_x4, _x5) {
10763
10774
  return _getTorosPoolTokenPrice.apply(this, arguments);
10764
10775
  }
10765
10776
 
@@ -10791,7 +10802,7 @@ function _getTorosPoolTokenPrice() {
10791
10802
  return _getTorosPoolTokenPrice.apply(this, arguments);
10792
10803
  }
10793
10804
 
10794
- function getEasySwapperDepositQuote(_x5, _x6, _x7, _x8, _x9) {
10805
+ function getEasySwapperDepositQuote(_x6, _x7, _x8, _x9, _x10) {
10795
10806
  return _getEasySwapperDepositQuote.apply(this, arguments);
10796
10807
  }
10797
10808
 
@@ -10819,7 +10830,7 @@ function _getEasySwapperDepositQuote() {
10819
10830
  return _getEasySwapperDepositQuote.apply(this, arguments);
10820
10831
  }
10821
10832
 
10822
- function getEasySwapperWithdrawalQuote(_x10, _x11, _x12, _x13) {
10833
+ function getEasySwapperWithdrawalQuote(_x11, _x12, _x13, _x14) {
10823
10834
  return _getEasySwapperWithdrawalQuote.apply(this, arguments);
10824
10835
  }
10825
10836
 
@@ -10851,7 +10862,7 @@ function _getEasySwapperWithdrawalQuote() {
10851
10862
  return _getEasySwapperWithdrawalQuote.apply(this, arguments);
10852
10863
  }
10853
10864
 
10854
- function getEasySwapperTxData(_x14, _x15, _x16, _x17, _x18) {
10865
+ function getEasySwapperTxData(_x15, _x16, _x17, _x18, _x19) {
10855
10866
  return _getEasySwapperTxData.apply(this, arguments);
10856
10867
  }
10857
10868
 
@@ -10886,7 +10897,7 @@ function _getEasySwapperTxData() {
10886
10897
 
10887
10898
  case 12:
10888
10899
  _context5.next = 14;
10889
- return getPoolDepositAsset(pool, torosAsset);
10900
+ return getPoolDepositAsset(pool, torosAsset, investAsset);
10890
10901
 
10891
10902
  case 14:
10892
10903
  depositAsset = _context5.sent;
@@ -18691,17 +18702,23 @@ var Utils = /*#__PURE__*/function () {
18691
18702
  _proto.getBalancerJoinPoolTx = /*#__PURE__*/function () {
18692
18703
  var _getBalancerJoinPoolTx = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(pool, balancerPoolId, assets, amountsIn // eslint-disable-next-line @typescript-eslint/no-explicit-any
18693
18704
  ) {
18694
- var iBalancerV2Vault, txData, joinPoolTx;
18705
+ var iBalancerV2Vault, bptAddress, bptIndex, poolAssetsAmounts, txData, joinPoolTx;
18695
18706
  return runtime_1.wrap(function _callee7$(_context7) {
18696
18707
  while (1) {
18697
18708
  switch (_context7.prev = _context7.next) {
18698
18709
  case 0:
18699
18710
  iBalancerV2Vault = new ethers.ethers.utils.Interface(IBalancerV2Vault.abi);
18700
- txData = [balancerPoolId, pool.address, pool.address, [assets, amountsIn, ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256[]", "uint256"], [1, amountsIn, 0]), false]];
18711
+ bptAddress = ethers.ethers.utils.getAddress(balancerPoolId.slice(0, 42));
18712
+ bptIndex = assets.findIndex(function (e) {
18713
+ return e.toLowerCase() === bptAddress.toLocaleLowerCase();
18714
+ });
18715
+ poolAssetsAmounts = amountsIn.slice();
18716
+ if (bptIndex >= 0) poolAssetsAmounts.splice(bptIndex, 1);
18717
+ txData = [balancerPoolId, pool.address, pool.address, [assets, amountsIn, ethers.ethers.utils.defaultAbiCoder.encode(["uint256", "uint256[]", "uint256"], [1, poolAssetsAmounts, 0]), false]];
18701
18718
  joinPoolTx = iBalancerV2Vault.encodeFunctionData("joinPool", txData);
18702
18719
  return _context7.abrupt("return", joinPoolTx);
18703
18720
 
18704
- case 4:
18721
+ case 8:
18705
18722
  case "end":
18706
18723
  return _context7.stop();
18707
18724
  }