@curvefi/api 2.66.30 → 2.67.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 (94) hide show
  1. package/lib/boosting.d.ts +33 -32
  2. package/lib/boosting.js +320 -252
  3. package/lib/cached.d.ts +4 -3
  4. package/lib/cached.js +63 -19
  5. package/lib/constants/coins/hyperliquid.d.ts +2 -0
  6. package/lib/constants/coins/hyperliquid.js +5 -0
  7. package/lib/constants/coins/index.d.ts +2 -1
  8. package/lib/constants/coins/index.js +2 -1
  9. package/lib/constants/factory/crypto.d.ts +5 -0
  10. package/lib/constants/factory/crypto.js +8 -0
  11. package/lib/constants/factory/stable.js +3 -0
  12. package/lib/constants/network_constants.js +37 -11
  13. package/lib/constants/pools/hyperliquid.d.ts +2 -0
  14. package/lib/constants/pools/hyperliquid.js +2 -0
  15. package/lib/constants/pools/index.d.ts +2 -1
  16. package/lib/constants/pools/index.js +2 -1
  17. package/lib/constants/utils.d.ts +14 -1
  18. package/lib/constants/utils.js +21 -6
  19. package/lib/constants/volumeNetworks.js +1 -1
  20. package/lib/curve.d.ts +5 -5
  21. package/lib/curve.js +21 -38
  22. package/lib/dao.d.ts +32 -31
  23. package/lib/dao.js +420 -350
  24. package/lib/external-api.d.ts +1 -1
  25. package/lib/external-api.js +2 -2
  26. package/lib/factory/common.d.ts +2 -1
  27. package/lib/factory/common.js +1 -1
  28. package/lib/factory/deploy.d.ts +46 -45
  29. package/lib/factory/deploy.js +630 -551
  30. package/lib/factory/factory-api.d.ts +3 -2
  31. package/lib/factory/factory-api.js +22 -23
  32. package/lib/factory/factory-crypto.d.ts +1 -1
  33. package/lib/factory/factory-crypto.js +12 -15
  34. package/lib/factory/factory-tricrypto.d.ts +1 -1
  35. package/lib/factory/factory-tricrypto.js +14 -15
  36. package/lib/factory/factory-twocrypto.d.ts +1 -1
  37. package/lib/factory/factory-twocrypto.js +12 -13
  38. package/lib/factory/factory.d.ts +4 -3
  39. package/lib/factory/factory.js +21 -24
  40. package/lib/index.d.ts +413 -104
  41. package/lib/index.js +253 -257
  42. package/lib/interfaces.d.ts +2 -0
  43. package/lib/pools/PoolTemplate.d.ts +13 -12
  44. package/lib/pools/PoolTemplate.js +279 -285
  45. package/lib/pools/mixins/common.js +2 -2
  46. package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +12 -4
  47. package/lib/pools/mixins/depositBalancedAmountsMixins.js +1 -15
  48. package/lib/pools/mixins/depositMixins.d.ts +25 -5
  49. package/lib/pools/mixins/depositMixins.js +38 -76
  50. package/lib/pools/mixins/depositWrappedMixins.d.ts +10 -2
  51. package/lib/pools/mixins/depositWrappedMixins.js +17 -33
  52. package/lib/pools/mixins/poolBalancesMixin.d.ts +6 -2
  53. package/lib/pools/mixins/poolBalancesMixin.js +3 -5
  54. package/lib/pools/mixins/swapMixins.d.ts +20 -4
  55. package/lib/pools/mixins/swapMixins.js +36 -70
  56. package/lib/pools/mixins/swapWrappedMixins.d.ts +19 -4
  57. package/lib/pools/mixins/swapWrappedMixins.js +32 -60
  58. package/lib/pools/mixins/withdrawExpectedMixins.d.ts +12 -4
  59. package/lib/pools/mixins/withdrawExpectedMixins.js +6 -11
  60. package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +20 -4
  61. package/lib/pools/mixins/withdrawImbalanceMixins.js +26 -53
  62. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +10 -2
  63. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +12 -27
  64. package/lib/pools/mixins/withdrawMixins.d.ts +25 -5
  65. package/lib/pools/mixins/withdrawMixins.js +33 -67
  66. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +12 -4
  67. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +8 -13
  68. package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +25 -5
  69. package/lib/pools/mixins/withdrawOneCoinMixins.js +32 -66
  70. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +6 -2
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +4 -7
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +10 -2
  73. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +13 -29
  74. package/lib/pools/mixins/withdrawWrappedMixins.d.ts +10 -2
  75. package/lib/pools/mixins/withdrawWrappedMixins.js +14 -28
  76. package/lib/pools/poolConstructor.d.ts +2 -1
  77. package/lib/pools/poolConstructor.js +27 -28
  78. package/lib/pools/subClasses/corePool.d.ts +4 -1
  79. package/lib/pools/subClasses/corePool.js +5 -7
  80. package/lib/pools/subClasses/gaugePool.d.ts +5 -3
  81. package/lib/pools/subClasses/gaugePool.js +19 -18
  82. package/lib/pools/subClasses/statsPool.d.ts +2 -0
  83. package/lib/pools/subClasses/statsPool.js +22 -10
  84. package/lib/pools/subClasses/walletPool.d.ts +2 -1
  85. package/lib/pools/subClasses/walletPool.js +6 -6
  86. package/lib/pools/utils.d.ts +7 -6
  87. package/lib/pools/utils.js +316 -297
  88. package/lib/route-graph.worker.d.ts +2 -2
  89. package/lib/route-graph.worker.js +4 -6
  90. package/lib/router.d.ts +12 -11
  91. package/lib/router.js +331 -295
  92. package/lib/utils.d.ts +34 -33
  93. package/lib/utils.js +483 -435
  94. package/package.json +2 -2
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { PoolTemplate } from "../PoolTemplate.js";
11
- import { curve } from "../../curve.js";
12
11
  import { fromBN, toBN } from "../../utils.js";
13
12
  export function _calcExpectedAmounts(_lpTokenAmount) {
14
13
  return __awaiter(this, void 0, void 0, function* () {
14
+ const { curve } = this;
15
15
  const coinBalancesBN = [];
16
16
  for (let i = 0; i < this.wrappedCoinAddresses.length; i++) {
17
17
  const _balance = yield curve.contracts[this.address].contract.balances(i, curve.constantOptions);
@@ -30,7 +30,7 @@ export function _calcExpectedUnderlyingAmountsMeta(_lpTokenAmount) {
30
30
  const _expectedWrappedAmounts = yield _calcExpectedAmounts.call(this, _lpTokenAmount);
31
31
  const [_expectedMetaCoinAmount] = _expectedWrappedAmounts.splice(this.metaCoinIdx, 1);
32
32
  const _expectedUnderlyingAmounts = _expectedWrappedAmounts;
33
- const basePool = new PoolTemplate(this.basePool);
33
+ const basePool = new PoolTemplate(this.basePool, this.curve);
34
34
  const _basePoolExpectedAmounts = basePool.isMeta ?
35
35
  yield _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount) :
36
36
  yield _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount);
@@ -1,5 +1,13 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const depositBalancedAmountsMixin: PoolTemplate;
3
- export declare const depositBalancedAmountsCryptoMixin: PoolTemplate;
4
- export declare const depositWrappedBalancedAmountsMixin: PoolTemplate;
5
- export declare const depositWrappedBalancedAmountsCryptoMixin: PoolTemplate;
2
+ export declare const depositBalancedAmountsMixin: {
3
+ depositBalancedAmounts(this: PoolTemplate): Promise<string[]>;
4
+ };
5
+ export declare const depositBalancedAmountsCryptoMixin: {
6
+ depositBalancedAmounts(this: PoolTemplate): Promise<string[]>;
7
+ };
8
+ export declare const depositWrappedBalancedAmountsMixin: {
9
+ depositWrappedBalancedAmounts(this: PoolTemplate): Promise<string[]>;
10
+ };
11
+ export declare const depositWrappedBalancedAmountsCryptoMixin: {
12
+ depositWrappedBalancedAmounts(this: PoolTemplate): Promise<string[]>;
13
+ };
@@ -28,28 +28,21 @@ function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
28
28
  const bestScenario = balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN];
29
29
  return bestScenario.map((a, i) => walletBalancesBN[i].isZero() ? "0" : a.toFixed(decimals[i]));
30
30
  }
31
- // @ts-ignore
32
31
  export const depositBalancedAmountsMixin = {
33
32
  depositBalancedAmounts() {
34
33
  return __awaiter(this, void 0, void 0, function* () {
35
- // @ts-ignore
36
34
  const poolBalances = yield this.stats.underlyingBalances();
37
- // @ts-ignore
38
35
  const walletBalances = Object.values(yield this.wallet.underlyingCoinBalances());
39
36
  const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
40
37
  return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
41
38
  });
42
39
  },
43
40
  };
44
- // @ts-ignore
45
41
  export const depositBalancedAmountsCryptoMixin = {
46
42
  depositBalancedAmounts() {
47
43
  return __awaiter(this, void 0, void 0, function* () {
48
- // @ts-ignore
49
44
  const poolBalances = yield this.stats.underlyingBalances();
50
- // @ts-ignore
51
45
  const walletBalances = Object.values(yield this.wallet.underlyingCoinBalances());
52
- // @ts-ignore
53
46
  const prices = yield this._underlyingPrices();
54
47
  const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
55
48
  const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
@@ -58,28 +51,21 @@ export const depositBalancedAmountsCryptoMixin = {
58
51
  });
59
52
  },
60
53
  };
61
- // @ts-ignore
62
54
  export const depositWrappedBalancedAmountsMixin = {
63
55
  depositWrappedBalancedAmounts() {
64
56
  return __awaiter(this, void 0, void 0, function* () {
65
- // @ts-ignore
66
57
  const poolBalances = yield this.stats.wrappedBalances();
67
- // @ts-ignore
68
58
  const walletBalances = Object.values(yield this.wallet.wrappedCoinBalances());
69
59
  const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
70
60
  return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
71
61
  });
72
62
  },
73
63
  };
74
- // @ts-ignore
75
64
  export const depositWrappedBalancedAmountsCryptoMixin = {
76
65
  depositWrappedBalancedAmounts() {
77
66
  return __awaiter(this, void 0, void 0, function* () {
78
- // @ts-ignore
79
67
  const poolBalances = (yield this.stats.wrappedBalances()).map(Number);
80
- // @ts-ignore
81
- const walletBalances = Object.values(yield this.walletWrappedCoinBalances()).map(Number);
82
- // @ts-ignore
68
+ const walletBalances = Object.values(yield this.wallet.wrappedCoinBalances()).map(Number);
83
69
  const prices = yield this._wrappedPrices();
84
70
  const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
85
71
  const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
@@ -1,6 +1,26 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const depositMetaFactoryMixin: PoolTemplate;
3
- export declare const depositCryptoMetaFactoryMixin: PoolTemplate;
4
- export declare const depositZapMixin: PoolTemplate;
5
- export declare const depositLendingOrCryptoMixin: PoolTemplate;
6
- export declare const depositPlainMixin: PoolTemplate;
2
+ export declare const depositMetaFactoryMixin: {
3
+ _deposit(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
4
+ depositEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<string | number | number[]>;
5
+ deposit(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string | number | number[]>;
6
+ };
7
+ export declare const depositCryptoMetaFactoryMixin: {
8
+ _deposit(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
9
+ depositEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number | number[]>;
10
+ deposit(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
11
+ };
12
+ export declare const depositZapMixin: {
13
+ _deposit(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
14
+ depositEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number | number[]>;
15
+ deposit(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
16
+ };
17
+ export declare const depositLendingOrCryptoMixin: {
18
+ _deposit(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
19
+ depositEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number | number[]>;
20
+ deposit(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
21
+ };
22
+ export declare const depositPlainMixin: {
23
+ _deposit(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
24
+ depositEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number | number[]>;
25
+ deposit(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
26
+ };
@@ -7,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { curve } from "../../curve.js";
11
- import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
12
- // @ts-ignore
10
+ import { _ensureAllowance, DIGas, fromBN, getEthIndex, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
13
11
  function _depositCheck(amounts_1) {
14
12
  return __awaiter(this, arguments, void 0, function* (amounts, estimateGas = false) {
15
13
  if (amounts.length !== this.underlyingCoinAddresses.length) {
@@ -21,202 +19,166 @@ function _depositCheck(amounts_1) {
21
19
  throw Error(`Not enough ${this.underlyingCoins[i]}. Actual: ${balances[i]}, required: ${amounts[i]}`);
22
20
  }
23
21
  }
24
- if (estimateGas && !(yield hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address))) {
22
+ if (estimateGas && !(yield hasAllowance.call(this.curve, this.underlyingCoinAddresses, amounts, this.curve.signerAddress, this.zap || this.address))) {
25
23
  throw Error("Token allowance is needed to estimate gas");
26
24
  }
27
25
  if (!estimateGas)
28
- yield curve.updateFeeData();
26
+ yield this.curve.updateFeeData();
29
27
  return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
30
28
  });
31
29
  }
32
30
  function _depositMinAmount(_amounts_1) {
33
31
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage = 0.5) {
34
- // @ts-ignore
35
32
  const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts);
36
33
  const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
37
34
  return fromBN(minAmountBN);
38
35
  });
39
36
  }
40
- // @ts-ignore
41
37
  export const depositMetaFactoryMixin = {
42
- // @ts-ignore
43
38
  _deposit(_amounts_1, slippage_1) {
44
39
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
45
40
  if (!estimateGas)
46
- yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
47
- // @ts-ignore
41
+ yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
48
42
  const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
49
43
  const ethIndex = getEthIndex(this.underlyingCoinAddresses);
50
- const value = _amounts[ethIndex] || curve.parseUnits("0");
51
- const contract = curve.contracts[this.zap].contract;
52
- const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
44
+ const value = _amounts[ethIndex] || parseUnits("0");
45
+ const contract = this.curve.contracts[this.zap].contract;
46
+ const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
53
47
  if (estimateGas)
54
48
  return smartNumber(gas);
55
49
  const gasLimit = mulBy1_3(DIGas(gas));
56
- return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
50
+ return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
57
51
  });
58
52
  },
59
53
  depositEstimateGas(amounts) {
60
54
  return __awaiter(this, void 0, void 0, function* () {
61
- // @ts-ignore
62
55
  const _amounts = yield _depositCheck.call(this, amounts, true);
63
- // @ts-ignore
64
- return yield this._deposit(_amounts, 0.1, true);
56
+ return yield depositMetaFactoryMixin._deposit.call(this, _amounts, 0.1, true);
65
57
  });
66
58
  },
67
59
  deposit(amounts, slippage) {
68
60
  return __awaiter(this, void 0, void 0, function* () {
69
- // @ts-ignore
70
61
  const _amounts = yield _depositCheck.call(this, amounts);
71
- // @ts-ignore
72
- return yield this._deposit(_amounts, slippage);
62
+ return yield depositMetaFactoryMixin._deposit.call(this, _amounts, slippage);
73
63
  });
74
64
  },
75
65
  };
76
- // @ts-ignore
77
66
  export const depositCryptoMetaFactoryMixin = {
78
- // @ts-ignore
79
67
  _deposit(_amounts_1, slippage_1) {
80
68
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
81
69
  if (!estimateGas)
82
- yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
83
- // @ts-ignore
70
+ yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
84
71
  const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
85
72
  const ethIndex = getEthIndex(this.underlyingCoinAddresses);
86
- const value = _amounts[ethIndex] || curve.parseUnits("0");
87
- const contract = curve.contracts[this.zap].contract;
88
- const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
73
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
74
+ const contract = this.curve.contracts[this.zap].contract;
75
+ const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
89
76
  if (estimateGas)
90
77
  return smartNumber(gas);
91
78
  const gasLimit = mulBy1_3(DIGas(gas));
92
- return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
79
+ return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
93
80
  });
94
81
  },
95
82
  depositEstimateGas(amounts) {
96
83
  return __awaiter(this, void 0, void 0, function* () {
97
- // @ts-ignore
98
84
  const _amounts = yield _depositCheck.call(this, amounts, true);
99
- // @ts-ignore
100
- return yield this._deposit(_amounts, 0.1, true);
85
+ return yield depositCryptoMetaFactoryMixin._deposit.call(this, _amounts, 0.1, true);
101
86
  });
102
87
  },
103
88
  deposit(amounts, slippage) {
104
89
  return __awaiter(this, void 0, void 0, function* () {
105
- // @ts-ignore
106
90
  const _amounts = yield _depositCheck.call(this, amounts);
107
- // @ts-ignore
108
- return yield this._deposit(_amounts, slippage);
91
+ return yield depositCryptoMetaFactoryMixin._deposit.call(this, _amounts, slippage);
109
92
  });
110
93
  },
111
94
  };
112
- // @ts-ignore
113
95
  export const depositZapMixin = {
114
- // @ts-ignore
115
96
  _deposit(_amounts_1, slippage_1) {
116
97
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
117
98
  if (!estimateGas)
118
- yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
119
- // @ts-ignore
99
+ yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
120
100
  const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
121
101
  const ethIndex = getEthIndex(this.underlyingCoinAddresses);
122
- const value = _amounts[ethIndex] || curve.parseUnits("0");
123
- const contract = curve.contracts[this.zap].contract;
102
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
103
+ const contract = this.curve.contracts[this.zap].contract;
124
104
  const args = [_amounts, _minMintAmount];
125
105
  if (`add_liquidity(uint256[${this.underlyingCoinAddresses.length}],uint256,bool)` in contract)
126
106
  args.push(true);
127
- const gas = yield contract.add_liquidity.estimateGas(...args, Object.assign(Object.assign({}, curve.constantOptions), { value }));
107
+ const gas = yield contract.add_liquidity.estimateGas(...args, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
128
108
  if (estimateGas)
129
109
  return smartNumber(gas);
130
110
  const gasLimit = mulBy1_3(DIGas(gas));
131
- return (yield contract.add_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
111
+ return (yield contract.add_liquidity(...args, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
132
112
  });
133
113
  },
134
114
  depositEstimateGas(amounts) {
135
115
  return __awaiter(this, void 0, void 0, function* () {
136
- // @ts-ignore
137
116
  const _amounts = yield _depositCheck.call(this, amounts, true);
138
- // @ts-ignore
139
- return yield this._deposit(_amounts, 0.1, true);
117
+ return yield depositZapMixin._deposit.call(this, _amounts, 0.1, true);
140
118
  });
141
119
  },
142
120
  deposit(amounts, slippage) {
143
121
  return __awaiter(this, void 0, void 0, function* () {
144
- // @ts-ignore
145
122
  const _amounts = yield _depositCheck.call(this, amounts);
146
- // @ts-ignore
147
- return yield this._deposit(_amounts, slippage);
123
+ return yield depositZapMixin._deposit.call(this, _amounts, slippage);
148
124
  });
149
125
  },
150
126
  };
151
- // @ts-ignore
152
127
  export const depositLendingOrCryptoMixin = {
153
- // @ts-ignore
154
128
  _deposit(_amounts_1, slippage_1) {
155
129
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
156
130
  if (!estimateGas)
157
- yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address);
158
- // @ts-ignore
131
+ yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.address);
159
132
  const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
160
133
  const ethIndex = getEthIndex(this.underlyingCoinAddresses);
161
- const value = _amounts[ethIndex] || curve.parseUnits("0");
162
- const contract = curve.contracts[this.address].contract;
163
- const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
134
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
135
+ const contract = this.curve.contracts[this.address].contract;
136
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
164
137
  if (estimateGas)
165
138
  return smartNumber(gas);
166
139
  const gasLimit = mulBy1_3(DIGas(gas));
167
- return (yield contract.add_liquidity(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
140
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
168
141
  });
169
142
  },
170
143
  depositEstimateGas(amounts) {
171
144
  return __awaiter(this, void 0, void 0, function* () {
172
- // @ts-ignore
173
145
  const _amounts = yield _depositCheck.call(this, amounts, true);
174
- // @ts-ignore
175
- return yield this._deposit(_amounts, 0.1, true);
146
+ return yield depositLendingOrCryptoMixin._deposit.call(this, _amounts, 0.1, true);
176
147
  });
177
148
  },
178
149
  deposit(amounts, slippage) {
179
150
  return __awaiter(this, void 0, void 0, function* () {
180
- // @ts-ignore
181
151
  const _amounts = yield _depositCheck.call(this, amounts);
182
- // @ts-ignore
183
- return yield this._deposit(_amounts, slippage);
152
+ return yield depositLendingOrCryptoMixin._deposit.call(this, _amounts, slippage);
184
153
  });
185
154
  },
186
155
  };
187
- // @ts-ignore
188
156
  export const depositPlainMixin = {
189
- // @ts-ignore
190
157
  _deposit(_amounts_1, slippage_1) {
191
158
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
192
159
  if (!estimateGas)
193
- yield _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
194
- // @ts-ignore
160
+ yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
195
161
  const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
196
162
  const ethIndex = getEthIndex(this.wrappedCoinAddresses);
197
- const value = _amounts[ethIndex] || curve.parseUnits("0");
198
- const contract = curve.contracts[this.address].contract;
199
- const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
163
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
164
+ const contract = this.curve.contracts[this.address].contract;
165
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
200
166
  if (estimateGas)
201
167
  return smartNumber(gas);
202
168
  const gasLimit = mulBy1_3(DIGas(gas));
203
- return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
169
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
204
170
  });
205
171
  },
206
172
  depositEstimateGas(amounts) {
207
173
  return __awaiter(this, void 0, void 0, function* () {
208
- // @ts-ignore
209
174
  const _amounts = yield _depositCheck.call(this, amounts, true);
210
- // @ts-ignore
211
- return yield this._deposit(_amounts, 0.1, true);
175
+ return yield depositPlainMixin._deposit.call(this, _amounts, 0.1, true);
212
176
  });
213
177
  },
214
178
  deposit(amounts, slippage) {
215
179
  return __awaiter(this, void 0, void 0, function* () {
216
- // @ts-ignore
217
180
  const _amounts = yield _depositCheck.call(this, amounts);
218
- // @ts-ignore
219
- return yield this._deposit(_amounts, slippage);
181
+ return yield depositPlainMixin._deposit.call(this, _amounts, slippage);
220
182
  });
221
183
  },
222
184
  };
@@ -1,3 +1,11 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const depositWrapped2argsMixin: PoolTemplate;
3
- export declare const depositWrapped3argsMixin: PoolTemplate;
2
+ export declare const depositWrapped2argsMixin: {
3
+ _depositWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
4
+ depositWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number>;
5
+ depositWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
6
+ };
7
+ export declare const depositWrapped3argsMixin: {
8
+ _depositWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
9
+ depositWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number>;
10
+ depositWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
11
+ };
@@ -7,8 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { curve } from "../../curve.js";
11
- import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
10
+ import { _ensureAllowance, DIGas, fromBN, getEthIndex, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
12
11
  function _depositWrappedCheck(amounts_1) {
13
12
  return __awaiter(this, arguments, void 0, function* (amounts, estimateGas = false) {
14
13
  if (this.isFake) {
@@ -23,91 +22,76 @@ function _depositWrappedCheck(amounts_1) {
23
22
  throw Error(`Not enough ${this.wrappedCoins[i]}. Actual: ${balances[i]}, required: ${amounts[i]}`);
24
23
  }
25
24
  }
26
- if (estimateGas && !(yield hasAllowance(this.wrappedCoinAddresses, amounts, curve.signerAddress, this.address))) {
25
+ if (estimateGas && !(yield hasAllowance.call(this.curve, this.wrappedCoinAddresses, amounts, this.curve.signerAddress, this.address))) {
27
26
  throw Error("Token allowance is needed to estimate gas");
28
27
  }
29
28
  if (!estimateGas)
30
- yield curve.updateFeeData();
29
+ yield this.curve.updateFeeData();
31
30
  return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i]));
32
31
  });
33
32
  }
34
33
  function _depositWrappedMinAmount(_amounts_1) {
35
34
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage = 0.5) {
36
- // @ts-ignore
37
35
  const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, true, false);
38
36
  const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
39
37
  return fromBN(minAmountBN);
40
38
  });
41
39
  }
42
- // @ts-ignore
43
40
  export const depositWrapped2argsMixin = {
44
- // @ts-ignore
45
41
  _depositWrapped(_amounts_1, slippage_1) {
46
42
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
47
43
  if (!estimateGas)
48
- yield _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
49
- // @ts-ignore
44
+ yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
50
45
  const _minMintAmount = yield _depositWrappedMinAmount.call(this, _amounts, slippage);
51
46
  const ethIndex = getEthIndex(this.wrappedCoinAddresses);
52
- const value = _amounts[ethIndex] || curve.parseUnits("0");
53
- const contract = curve.contracts[this.address].contract;
54
- const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
47
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
48
+ const contract = this.curve.contracts[this.address].contract;
49
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
55
50
  if (estimateGas)
56
51
  return smartNumber(gas);
57
52
  const gasLimit = mulBy1_3(DIGas(gas));
58
- return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
53
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
59
54
  });
60
55
  },
61
56
  depositWrappedEstimateGas(amounts) {
62
57
  return __awaiter(this, void 0, void 0, function* () {
63
- // @ts-ignore
64
58
  const _amounts = yield _depositWrappedCheck.call(this, amounts, true);
65
- // @ts-ignore
66
- return yield this._depositWrapped(_amounts, 0.1, true);
59
+ return yield depositWrapped2argsMixin._depositWrapped.call(this, _amounts, 0.1, true);
67
60
  });
68
61
  },
69
62
  depositWrapped(amounts, slippage) {
70
63
  return __awaiter(this, void 0, void 0, function* () {
71
- // @ts-ignore
72
64
  const _amounts = yield _depositWrappedCheck.call(this, amounts);
73
- // @ts-ignore
74
- return yield this._depositWrapped(_amounts, slippage);
65
+ return yield depositWrapped2argsMixin._depositWrapped.call(this, _amounts, slippage);
75
66
  });
76
67
  },
77
68
  };
78
- // @ts-ignore
79
69
  export const depositWrapped3argsMixin = {
80
- // @ts-ignore
81
70
  _depositWrapped(_amounts_1, slippage_1) {
82
71
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
83
72
  if (!estimateGas)
84
- yield _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
85
- // @ts-ignore
73
+ yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
86
74
  const _minMintAmount = yield _depositWrappedMinAmount.call(this, _amounts, slippage);
87
75
  const ethIndex = getEthIndex(this.wrappedCoinAddresses);
88
- const value = _amounts[ethIndex] || curve.parseUnits("0");
89
- const contract = curve.contracts[this.address].contract;
90
- const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, false, Object.assign(Object.assign({}, curve.constantOptions), { value }));
76
+ const value = _amounts[ethIndex] || this.curve.parseUnits("0");
77
+ const contract = this.curve.contracts[this.address].contract;
78
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, false, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
91
79
  if (estimateGas)
92
80
  return smartNumber(gas);
93
81
  const gasLimit = mulBy1_3(DIGas(gas));
94
- return (yield contract.add_liquidity(_amounts, _minMintAmount, false, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
82
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, false, Object.assign(Object.assign({}, this.curve.options), { gasLimit, value }))).hash;
95
83
  });
96
84
  },
97
85
  depositWrappedEstimateGas(amounts) {
98
86
  return __awaiter(this, void 0, void 0, function* () {
99
- // @ts-ignore
100
87
  const _amounts = yield _depositWrappedCheck.call(this, amounts, true);
101
- // @ts-ignore
102
- return yield this._depositWrapped(_amounts, 0.1, true);
88
+ return yield depositWrapped3argsMixin._depositWrapped.call(this, _amounts, 0.1, true);
103
89
  });
104
90
  },
105
91
  depositWrapped(amounts, slippage) {
106
92
  return __awaiter(this, void 0, void 0, function* () {
107
- // @ts-ignore
108
93
  const _amounts = yield _depositWrappedCheck.call(this, amounts);
109
- // @ts-ignore
110
- return yield this._depositWrapped(_amounts, slippage);
94
+ return yield depositWrapped3argsMixin._depositWrapped.call(this, _amounts, slippage);
111
95
  });
112
96
  },
113
97
  };
@@ -1,3 +1,7 @@
1
1
  import { IStatsPool } from "../subClasses/statsPool";
2
- export declare const poolBalancesMetaMixin: IStatsPool;
3
- export declare const poolBalancesLendingMixin: IStatsPool;
2
+ export declare const poolBalancesMetaMixin: {
3
+ underlyingBalances(this: IStatsPool): Promise<string[]>;
4
+ };
5
+ export declare const poolBalancesLendingMixin: {
6
+ underlyingBalances(this: IStatsPool): Promise<string[]>;
7
+ };
@@ -7,19 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { curve } from "../../curve.js";
11
10
  import { PoolTemplate } from "../PoolTemplate.js";
12
11
  import { _calcExpectedAmounts, _calcExpectedUnderlyingAmountsMeta } from "./common.js";
13
- // @ts-ignore
14
12
  export const poolBalancesMetaMixin = {
15
13
  underlyingBalances() {
16
14
  return __awaiter(this, void 0, void 0, function* () {
15
+ const curve = this.pool.curve;
17
16
  const swapContract = curve.contracts[this.pool.address].multicallContract;
18
17
  const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i));
19
18
  const _poolWrappedBalances = yield curve.multicallProvider.all(contractCalls);
20
19
  const [_poolMetaCoinBalance] = _poolWrappedBalances.splice(this.pool.metaCoinIdx, 1);
21
20
  const _poolUnderlyingBalances = _poolWrappedBalances;
22
- const basePool = new PoolTemplate(this.pool.basePool);
21
+ const basePool = new PoolTemplate(this.pool.basePool, curve);
23
22
  const _basePoolExpectedAmounts = basePool.isMeta ?
24
23
  yield _calcExpectedUnderlyingAmountsMeta.call(basePool, _poolMetaCoinBalance) :
25
24
  yield _calcExpectedAmounts.call(basePool, _poolMetaCoinBalance);
@@ -28,14 +27,13 @@ export const poolBalancesMetaMixin = {
28
27
  });
29
28
  },
30
29
  };
31
- // @ts-ignore
32
30
  export const poolBalancesLendingMixin = {
33
31
  underlyingBalances() {
34
32
  return __awaiter(this, void 0, void 0, function* () {
33
+ const curve = this.pool.curve;
35
34
  const swapContract = curve.contracts[this.pool.address].multicallContract;
36
35
  const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i));
37
36
  const _poolWrappedBalances = yield curve.multicallProvider.all(contractCalls);
38
- // @ts-ignore
39
37
  const _rates = yield this.pool._getRates();
40
38
  const _poolUnderlyingBalances = _poolWrappedBalances.map((_b, i) => _b * _rates[i] / curve.parseUnits(String(Math.pow(10, 18)), 0));
41
39
  return _poolUnderlyingBalances.map((_b, i) => curve.formatUnits(_b, this.pool.underlyingDecimals[i]));
@@ -1,5 +1,21 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const swapTricrypto2Mixin: PoolTemplate;
3
- export declare const swapMetaFactoryMixin: PoolTemplate;
4
- export declare const swapCryptoMetaFactoryMixin: PoolTemplate;
5
- export declare const swapMixin: PoolTemplate;
2
+ export declare const swapTricrypto2Mixin: {
3
+ _swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
4
+ swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
5
+ swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
6
+ };
7
+ export declare const swapMetaFactoryMixin: {
8
+ _swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
9
+ swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
10
+ swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
11
+ };
12
+ export declare const swapCryptoMetaFactoryMixin: {
13
+ _swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
14
+ swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
15
+ swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
16
+ };
17
+ export declare const swapMixin: {
18
+ _swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
19
+ swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
20
+ swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
21
+ };