@curvefi/api 2.66.30 → 2.66.31

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 (81) 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/utils.d.ts +14 -1
  6. package/lib/constants/utils.js +21 -6
  7. package/lib/curve.d.ts +5 -5
  8. package/lib/curve.js +21 -38
  9. package/lib/dao.d.ts +32 -31
  10. package/lib/dao.js +420 -350
  11. package/lib/external-api.d.ts +1 -1
  12. package/lib/external-api.js +2 -2
  13. package/lib/factory/common.d.ts +2 -1
  14. package/lib/factory/common.js +1 -1
  15. package/lib/factory/deploy.d.ts +46 -45
  16. package/lib/factory/deploy.js +630 -551
  17. package/lib/factory/factory-api.d.ts +3 -2
  18. package/lib/factory/factory-api.js +22 -23
  19. package/lib/factory/factory-crypto.d.ts +1 -1
  20. package/lib/factory/factory-crypto.js +12 -15
  21. package/lib/factory/factory-tricrypto.d.ts +1 -1
  22. package/lib/factory/factory-tricrypto.js +14 -15
  23. package/lib/factory/factory-twocrypto.d.ts +1 -1
  24. package/lib/factory/factory-twocrypto.js +12 -13
  25. package/lib/factory/factory.d.ts +4 -3
  26. package/lib/factory/factory.js +21 -24
  27. package/lib/index.d.ts +413 -104
  28. package/lib/index.js +253 -257
  29. package/lib/interfaces.d.ts +2 -0
  30. package/lib/pools/PoolTemplate.d.ts +13 -12
  31. package/lib/pools/PoolTemplate.js +279 -285
  32. package/lib/pools/mixins/common.js +2 -2
  33. package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +12 -4
  34. package/lib/pools/mixins/depositBalancedAmountsMixins.js +1 -15
  35. package/lib/pools/mixins/depositMixins.d.ts +25 -5
  36. package/lib/pools/mixins/depositMixins.js +38 -76
  37. package/lib/pools/mixins/depositWrappedMixins.d.ts +10 -2
  38. package/lib/pools/mixins/depositWrappedMixins.js +17 -33
  39. package/lib/pools/mixins/poolBalancesMixin.d.ts +6 -2
  40. package/lib/pools/mixins/poolBalancesMixin.js +3 -5
  41. package/lib/pools/mixins/swapMixins.d.ts +20 -4
  42. package/lib/pools/mixins/swapMixins.js +36 -70
  43. package/lib/pools/mixins/swapWrappedMixins.d.ts +19 -4
  44. package/lib/pools/mixins/swapWrappedMixins.js +32 -60
  45. package/lib/pools/mixins/withdrawExpectedMixins.d.ts +12 -4
  46. package/lib/pools/mixins/withdrawExpectedMixins.js +6 -11
  47. package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +20 -4
  48. package/lib/pools/mixins/withdrawImbalanceMixins.js +26 -53
  49. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +10 -2
  50. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +12 -27
  51. package/lib/pools/mixins/withdrawMixins.d.ts +25 -5
  52. package/lib/pools/mixins/withdrawMixins.js +33 -67
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +12 -4
  54. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +8 -13
  55. package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +25 -5
  56. package/lib/pools/mixins/withdrawOneCoinMixins.js +32 -66
  57. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +6 -2
  58. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +4 -7
  59. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +10 -2
  60. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +13 -29
  61. package/lib/pools/mixins/withdrawWrappedMixins.d.ts +10 -2
  62. package/lib/pools/mixins/withdrawWrappedMixins.js +14 -28
  63. package/lib/pools/poolConstructor.d.ts +2 -1
  64. package/lib/pools/poolConstructor.js +27 -28
  65. package/lib/pools/subClasses/corePool.d.ts +4 -1
  66. package/lib/pools/subClasses/corePool.js +5 -7
  67. package/lib/pools/subClasses/gaugePool.d.ts +5 -3
  68. package/lib/pools/subClasses/gaugePool.js +19 -18
  69. package/lib/pools/subClasses/statsPool.d.ts +2 -0
  70. package/lib/pools/subClasses/statsPool.js +22 -10
  71. package/lib/pools/subClasses/walletPool.d.ts +2 -1
  72. package/lib/pools/subClasses/walletPool.js +6 -6
  73. package/lib/pools/utils.d.ts +7 -6
  74. package/lib/pools/utils.js +316 -297
  75. package/lib/route-graph.worker.d.ts +2 -2
  76. package/lib/route-graph.worker.js +4 -6
  77. package/lib/router.d.ts +12 -11
  78. package/lib/router.js +331 -295
  79. package/lib/utils.d.ts +34 -33
  80. package/lib/utils.js +481 -435
  81. package/package.json +1 -1
@@ -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, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
12
- // @ts-ignore
10
+ import { _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
13
11
  function _withdrawImbalanceCheck(amounts_1) {
14
12
  return __awaiter(this, arguments, void 0, function* (amounts, estimateGas = false) {
15
13
  const lpTokenAmount = yield this.withdrawImbalanceExpected(amounts);
@@ -17,147 +15,122 @@ function _withdrawImbalanceCheck(amounts_1) {
17
15
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
18
16
  throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
19
17
  }
20
- if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
18
+ if (estimateGas && this.zap && !(yield hasAllowance.call(this.curve, [this.lpToken], [lpTokenAmount], this.curve.signerAddress, this.zap))) {
21
19
  throw Error("Token allowance is needed to estimate gas");
22
20
  }
23
21
  if (!estimateGas)
24
- yield curve.updateFeeData();
22
+ yield this.curve.updateFeeData();
25
23
  return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
26
24
  });
27
25
  }
28
26
  function _withdrawImbalanceMaxBurnAmount(_amounts_1) {
29
27
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage = 0.5) {
30
- // @ts-ignore
31
28
  const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, false);
32
29
  const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
33
30
  return fromBN(maxBurnAmountBN);
34
31
  });
35
32
  }
36
- // @ts-ignore
37
33
  export const withdrawImbalanceMetaFactoryMixin = {
38
- // @ts-ignore
39
34
  _withdrawImbalance(_amounts_1, slippage_1) {
40
35
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
41
36
  const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
42
37
  if (!estimateGas)
43
- yield _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
44
- const contract = curve.contracts[this.zap].contract;
45
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, curve.constantOptions);
38
+ yield _ensureAllowance.call(this.curve, [this.lpToken], [_maxBurnAmount], this.zap);
39
+ const contract = this.curve.contracts[this.zap].contract;
40
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, this.curve.constantOptions);
46
41
  if (estimateGas)
47
42
  return smartNumber(gas);
48
43
  const gasLimit = mulBy1_3(DIGas(gas));
49
- return (yield contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
44
+ return (yield contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
50
45
  });
51
46
  },
52
47
  withdrawImbalanceEstimateGas(amounts) {
53
48
  return __awaiter(this, void 0, void 0, function* () {
54
- // @ts-ignore
55
49
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
56
- // @ts-ignore
57
- return yield this._withdrawImbalance(_amounts, 0.1, true);
50
+ return yield withdrawImbalanceMetaFactoryMixin._withdrawImbalance.call(this, _amounts, 0.1, true);
58
51
  });
59
52
  },
60
53
  withdrawImbalance(amounts, slippage) {
61
54
  return __awaiter(this, void 0, void 0, function* () {
62
- // @ts-ignore
63
55
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
64
- // @ts-ignore
65
- return yield this._withdrawImbalance(_amounts, slippage);
56
+ return yield withdrawImbalanceMetaFactoryMixin._withdrawImbalance.call(this, _amounts, slippage);
66
57
  });
67
58
  },
68
59
  };
69
- // @ts-ignore
70
60
  export const withdrawImbalanceZapMixin = {
71
- // @ts-ignore
72
61
  _withdrawImbalance(_amounts_1, slippage_1) {
73
62
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
74
63
  const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
75
64
  if (!estimateGas)
76
- yield _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
77
- const contract = curve.contracts[this.zap].contract;
78
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
65
+ yield _ensureAllowance.call(this.curve, [this.lpToken], [_maxBurnAmount], this.zap);
66
+ const contract = this.curve.contracts[this.zap].contract;
67
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, this.curve.constantOptions);
79
68
  if (estimateGas)
80
69
  return smartNumber(gas);
81
70
  const gasLimit = mulBy1_3(DIGas(gas));
82
- return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
71
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
83
72
  });
84
73
  },
85
74
  withdrawImbalanceEstimateGas(amounts) {
86
75
  return __awaiter(this, void 0, void 0, function* () {
87
- // @ts-ignore
88
76
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
89
- // @ts-ignore
90
- return yield this._withdrawImbalance(_amounts, 0.1, true);
77
+ return yield withdrawImbalanceZapMixin._withdrawImbalance.call(this, _amounts, 0.1, true);
91
78
  });
92
79
  },
93
80
  withdrawImbalance(amounts, slippage) {
94
81
  return __awaiter(this, void 0, void 0, function* () {
95
- // @ts-ignore
96
82
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
97
- // @ts-ignore
98
- return yield this._withdrawImbalance(_amounts, slippage);
83
+ return yield withdrawImbalanceZapMixin._withdrawImbalance.call(this, _amounts, slippage);
99
84
  });
100
85
  },
101
86
  };
102
- // @ts-ignore
103
87
  export const withdrawImbalanceLendingMixin = {
104
- // @ts-ignore
105
88
  _withdrawImbalance(_amounts_1, slippage_1) {
106
89
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
107
90
  const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
108
- const contract = curve.contracts[this.address].contract;
109
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, curve.constantOptions);
91
+ const contract = this.curve.contracts[this.address].contract;
92
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, this.curve.constantOptions);
110
93
  if (estimateGas)
111
94
  return smartNumber(gas);
112
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
113
- return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
95
+ const gasLimit = this.curve.chainId === 137 && this.id === 'ren' ? gas * this.curve.parseUnits("140", 0) / this.curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
96
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
114
97
  });
115
98
  },
116
99
  withdrawImbalanceEstimateGas(amounts) {
117
100
  return __awaiter(this, void 0, void 0, function* () {
118
- // @ts-ignore
119
101
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
120
- // @ts-ignore
121
- return yield this._withdrawImbalance(_amounts, 0.1, true);
102
+ return yield withdrawImbalanceLendingMixin._withdrawImbalance.call(this, _amounts, 0.1, true);
122
103
  });
123
104
  },
124
105
  withdrawImbalance(amounts, slippage) {
125
106
  return __awaiter(this, void 0, void 0, function* () {
126
- // @ts-ignore
127
107
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
128
- // @ts-ignore
129
- return yield this._withdrawImbalance(_amounts, slippage);
108
+ return yield withdrawImbalanceLendingMixin._withdrawImbalance.call(this, _amounts, slippage);
130
109
  });
131
110
  },
132
111
  };
133
- // @ts-ignore
134
112
  export const withdrawImbalancePlainMixin = {
135
- // @ts-ignore
136
113
  _withdrawImbalance(_amounts_1, slippage_1) {
137
114
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
138
115
  const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
139
- const contract = curve.contracts[this.address].contract;
140
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
116
+ const contract = this.curve.contracts[this.address].contract;
117
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, this.curve.constantOptions);
141
118
  if (estimateGas)
142
119
  return smartNumber(gas);
143
120
  const gasLimit = mulBy1_3(DIGas(gas));
144
- return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
121
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
145
122
  });
146
123
  },
147
124
  withdrawImbalanceEstimateGas(amounts) {
148
125
  return __awaiter(this, void 0, void 0, function* () {
149
- // @ts-ignore
150
126
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
151
- // @ts-ignore
152
- return yield this._withdrawImbalance(_amounts, 0.1, true);
127
+ return yield withdrawImbalancePlainMixin._withdrawImbalance.call(this, _amounts, 0.1, true);
153
128
  });
154
129
  },
155
130
  withdrawImbalance(amounts, slippage) {
156
131
  return __awaiter(this, void 0, void 0, function* () {
157
- // @ts-ignore
158
132
  const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
159
- // @ts-ignore
160
- return yield this._withdrawImbalance(_amounts, slippage);
133
+ return yield withdrawImbalancePlainMixin._withdrawImbalance.call(this, _amounts, slippage);
161
134
  });
162
135
  },
163
136
  };
@@ -1,3 +1,11 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const withdrawImbalanceWrapped2argsMixin: PoolTemplate;
3
- export declare const withdrawImbalanceWrapped3argsMixin: PoolTemplate;
2
+ export declare const withdrawImbalanceWrapped2argsMixin: {
3
+ _withdrawImbalanceWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
4
+ withdrawImbalanceWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number>;
5
+ withdrawImbalanceWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
6
+ };
7
+ export declare const withdrawImbalanceWrapped3argsMixin: {
8
+ _withdrawImbalanceWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
9
+ withdrawImbalanceWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise<number>;
10
+ withdrawImbalanceWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise<string>;
11
+ };
@@ -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
10
  import { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
12
- // @ts-ignore
13
11
  function _withdrawImbalanceWrappedCheck(amounts) {
14
12
  return __awaiter(this, void 0, void 0, function* () {
15
13
  const lpTokenAmount = yield this.withdrawImbalanceWrappedExpected(amounts);
@@ -17,77 +15,64 @@ function _withdrawImbalanceWrappedCheck(amounts) {
17
15
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
18
16
  throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
19
17
  }
20
- yield curve.updateFeeData();
18
+ yield this.curve.updateFeeData();
21
19
  return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i]));
22
20
  });
23
21
  }
24
22
  function _withdrawImbalanceWrappedMaxBurnAmount(_amounts_1) {
25
23
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage = 0.5) {
26
- // @ts-ignore
27
24
  const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, false, false);
28
25
  const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
29
26
  return fromBN(maxBurnAmountBN);
30
27
  });
31
28
  }
32
- // @ts-ignore
33
29
  export const withdrawImbalanceWrapped2argsMixin = {
34
- // @ts-ignore
35
30
  _withdrawImbalanceWrapped(_amounts_1, slippage_1) {
36
31
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
37
32
  const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
38
- const contract = curve.contracts[this.address].contract;
39
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
33
+ const contract = this.curve.contracts[this.address].contract;
34
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, this.curve.constantOptions);
40
35
  if (estimateGas)
41
36
  return smartNumber(gas);
42
37
  const gasLimit = mulBy1_3(DIGas(gas));
43
- return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
38
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
44
39
  });
45
40
  },
46
41
  withdrawImbalanceWrappedEstimateGas(amounts) {
47
42
  return __awaiter(this, void 0, void 0, function* () {
48
- // @ts-ignore
49
43
  const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
50
- // @ts-ignore
51
- return yield this._withdrawImbalanceWrapped(_amounts, 0.1, true);
44
+ return yield withdrawImbalanceWrapped2argsMixin._withdrawImbalanceWrapped.call(this, _amounts, 0.1, true);
52
45
  });
53
46
  },
54
47
  withdrawImbalanceWrapped(amounts, slippage) {
55
48
  return __awaiter(this, void 0, void 0, function* () {
56
- // @ts-ignore
57
49
  const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
58
- // @ts-ignore
59
- return yield this._withdrawImbalanceWrapped(_amounts, slippage);
50
+ return yield withdrawImbalanceWrapped2argsMixin._withdrawImbalanceWrapped.call(this, _amounts, slippage);
60
51
  });
61
52
  },
62
53
  };
63
- // @ts-ignore
64
54
  export const withdrawImbalanceWrapped3argsMixin = {
65
- // @ts-ignore
66
55
  _withdrawImbalanceWrapped(_amounts_1, slippage_1) {
67
56
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
68
57
  const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
69
- const contract = curve.contracts[this.address].contract;
70
- const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions);
58
+ const contract = this.curve.contracts[this.address].contract;
59
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, this.curve.constantOptions);
71
60
  if (estimateGas)
72
61
  return smartNumber(gas);
73
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
74
- return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
62
+ const gasLimit = this.curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * this.curve.parseUnits("140", 0) / this.curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
63
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
75
64
  });
76
65
  },
77
66
  withdrawImbalanceWrappedEstimateGas(amounts) {
78
67
  return __awaiter(this, void 0, void 0, function* () {
79
- // @ts-ignore
80
68
  const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
81
- // @ts-ignore
82
- return yield this._withdrawImbalanceWrapped(_amounts, 0.1, true);
69
+ return yield withdrawImbalanceWrapped3argsMixin._withdrawImbalanceWrapped.call(this, _amounts, 0.1, true);
83
70
  });
84
71
  },
85
72
  withdrawImbalanceWrapped(amounts, slippage) {
86
73
  return __awaiter(this, void 0, void 0, function* () {
87
- // @ts-ignore
88
74
  const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
89
- // @ts-ignore
90
- return yield this._withdrawImbalanceWrapped(_amounts, slippage);
75
+ return yield withdrawImbalanceWrapped3argsMixin._withdrawImbalanceWrapped.call(this, _amounts, slippage);
91
76
  });
92
77
  },
93
78
  };
@@ -1,6 +1,26 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const withdrawMetaFactoryMixin: PoolTemplate;
3
- export declare const withdrawCryptoMetaFactoryMixin: PoolTemplate;
4
- export declare const withdrawZapMixin: PoolTemplate;
5
- export declare const withdrawLendingOrCryptoMixin: PoolTemplate;
6
- export declare const withdrawPlainMixin: PoolTemplate;
2
+ export declare const withdrawMetaFactoryMixin: {
3
+ _withdraw(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
4
+ withdrawEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise<number | number[]>;
5
+ withdraw(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise<string>;
6
+ };
7
+ export declare const withdrawCryptoMetaFactoryMixin: {
8
+ _withdraw(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
9
+ withdrawEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise<number | number[]>;
10
+ withdraw(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise<string>;
11
+ };
12
+ export declare const withdrawZapMixin: {
13
+ _withdraw(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
14
+ withdrawEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise<number | number[]>;
15
+ withdraw(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise<string>;
16
+ };
17
+ export declare const withdrawLendingOrCryptoMixin: {
18
+ _withdraw(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
19
+ withdrawEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise<number | number[]>;
20
+ withdraw(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise<string>;
21
+ };
22
+ export declare const withdrawPlainMixin: {
23
+ _withdraw(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
24
+ withdrawEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise<number | number[]>;
25
+ withdraw(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise<string>;
26
+ };
@@ -7,194 +7,160 @@ 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, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
12
- // @ts-ignore
10
+ import { _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
13
11
  function _withdrawCheck(lpTokenAmount_1) {
14
12
  return __awaiter(this, arguments, void 0, function* (lpTokenAmount, estimateGas = false) {
15
13
  const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
16
14
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
17
15
  throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
18
16
  }
19
- if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
17
+ if (estimateGas && this.zap && !(yield hasAllowance.call(this.curve, [this.lpToken], [lpTokenAmount], this.curve.signerAddress, this.zap))) {
20
18
  throw Error("Token allowance is needed to estimate gas");
21
19
  }
22
20
  if (!estimateGas)
23
- yield curve.updateFeeData();
21
+ yield this.curve.updateFeeData();
24
22
  return parseUnits(lpTokenAmount);
25
23
  });
26
24
  }
27
25
  function _withdrawMinAmounts(_lpTokenAmount_1) {
28
26
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage = 0.5) {
29
- const expectedAmounts = yield this.withdrawExpected(curve.formatUnits(_lpTokenAmount));
30
- const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.underlyingDecimals[i]));
27
+ const expectedAmounts = yield this.withdrawExpected(this.curve.formatUnits(_lpTokenAmount));
28
+ const _expectedAmounts = expectedAmounts.map((a, i) => this.curve.parseUnits(a, this.underlyingDecimals[i]));
31
29
  const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.underlyingDecimals[i]).times(100 - slippage).div(100));
32
30
  return minRecvAmountsBN.map((a, i) => fromBN(a, this.underlyingDecimals[i]));
33
31
  });
34
32
  }
35
- // @ts-ignore
36
33
  export const withdrawMetaFactoryMixin = {
37
- // @ts-ignore
38
34
  _withdraw(_lpTokenAmount_1, slippage_1) {
39
35
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
40
36
  if (!estimateGas)
41
- yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
37
+ yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
42
38
  const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
43
- const contract = curve.contracts[this.zap].contract;
44
- const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions);
39
+ const contract = this.curve.contracts[this.zap].contract;
40
+ const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, this.curve.constantOptions);
45
41
  if (estimateGas)
46
42
  return smartNumber(gas);
47
43
  const gasLimit = mulBy1_3(DIGas(gas));
48
- return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
44
+ return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
49
45
  });
50
46
  },
51
47
  withdrawEstimateGas(lpTokenAmount) {
52
48
  return __awaiter(this, void 0, void 0, function* () {
53
- // @ts-ignore
54
49
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
55
- // @ts-ignore
56
- return yield this._withdraw(_lpTokenAmount, 0.1, true);
50
+ return yield withdrawMetaFactoryMixin._withdraw.call(this, _lpTokenAmount, 0.1, true);
57
51
  });
58
52
  },
59
53
  withdraw(lpTokenAmount, slippage) {
60
54
  return __awaiter(this, void 0, void 0, function* () {
61
- // @ts-ignore
62
55
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
63
- // @ts-ignore
64
- return yield this._withdraw(_lpTokenAmount, slippage);
56
+ return yield withdrawMetaFactoryMixin._withdraw.call(this, _lpTokenAmount, slippage);
65
57
  });
66
58
  },
67
59
  };
68
- // @ts-ignore
69
60
  export const withdrawCryptoMetaFactoryMixin = {
70
- // @ts-ignore
71
61
  _withdraw(_lpTokenAmount_1, slippage_1) {
72
62
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
73
63
  if (!estimateGas)
74
- yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
64
+ yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
75
65
  const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
76
- const contract = curve.contracts[this.zap].contract;
77
- const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions);
66
+ const contract = this.curve.contracts[this.zap].contract;
67
+ const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, this.curve.constantOptions);
78
68
  if (estimateGas)
79
69
  return smartNumber(gas);
80
70
  const gasLimit = mulBy1_3(DIGas(gas));
81
- return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
71
+ return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
82
72
  });
83
73
  },
84
74
  withdrawEstimateGas(lpTokenAmount) {
85
75
  return __awaiter(this, void 0, void 0, function* () {
86
- // @ts-ignore
87
76
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
88
- // @ts-ignore
89
- return yield this._withdraw(_lpTokenAmount, 0.1, true);
77
+ return yield withdrawCryptoMetaFactoryMixin._withdraw.call(this, _lpTokenAmount, 0.1, true);
90
78
  });
91
79
  },
92
80
  withdraw(lpTokenAmount, slippage) {
93
81
  return __awaiter(this, void 0, void 0, function* () {
94
- // @ts-ignore
95
82
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
96
- // @ts-ignore
97
- return yield this._withdraw(_lpTokenAmount, slippage);
83
+ return yield withdrawCryptoMetaFactoryMixin._withdraw.call(this, _lpTokenAmount, slippage);
98
84
  });
99
85
  },
100
86
  };
101
- // @ts-ignore
102
87
  export const withdrawZapMixin = {
103
- // @ts-ignore
104
88
  _withdraw(_lpTokenAmount_1, slippage_1) {
105
89
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
106
90
  if (!estimateGas)
107
- yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
108
- // @ts-ignore
91
+ yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
109
92
  const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
110
- const contract = curve.contracts[this.zap].contract;
93
+ const contract = this.curve.contracts[this.zap].contract;
111
94
  const args = [_lpTokenAmount, _minAmounts];
112
95
  if (`remove_liquidity(uint256,uint256[${this.underlyingCoinAddresses.length}],bool)` in contract)
113
96
  args.push(true);
114
- const gas = yield contract.remove_liquidity.estimateGas(...args, curve.constantOptions);
97
+ const gas = yield contract.remove_liquidity.estimateGas(...args, this.curve.constantOptions);
115
98
  if (estimateGas)
116
99
  return smartNumber(gas);
117
100
  const gasLimit = mulBy1_3(DIGas(gas));
118
- return (yield contract.remove_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
101
+ return (yield contract.remove_liquidity(...args, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
119
102
  });
120
103
  },
121
104
  withdrawEstimateGas(lpTokenAmount) {
122
105
  return __awaiter(this, void 0, void 0, function* () {
123
- // @ts-ignore
124
106
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
125
- // @ts-ignore
126
- return yield this._withdraw(_lpTokenAmount, 0.1, true);
107
+ return yield withdrawZapMixin._withdraw.call(this, _lpTokenAmount, 0.1, true);
127
108
  });
128
109
  },
129
110
  withdraw(lpTokenAmount, slippage) {
130
111
  return __awaiter(this, void 0, void 0, function* () {
131
- // @ts-ignore
132
112
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
133
- // @ts-ignore
134
- return yield this._withdraw(_lpTokenAmount, slippage);
113
+ return yield withdrawZapMixin._withdraw.call(this, _lpTokenAmount, slippage);
135
114
  });
136
115
  },
137
116
  };
138
- // @ts-ignore
139
117
  export const withdrawLendingOrCryptoMixin = {
140
- // @ts-ignore
141
118
  _withdraw(_lpTokenAmount_1, slippage_1) {
142
119
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
143
120
  const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
144
- const contract = curve.contracts[this.address].contract;
145
- const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions);
121
+ const contract = this.curve.contracts[this.address].contract;
122
+ const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, this.curve.constantOptions);
146
123
  if (estimateGas)
147
124
  return smartNumber(gas);
148
125
  const gasLimit = mulBy1_3(DIGas(gas));
149
- return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
126
+ return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
150
127
  });
151
128
  },
152
129
  withdrawEstimateGas(lpTokenAmount) {
153
130
  return __awaiter(this, void 0, void 0, function* () {
154
- // @ts-ignore
155
131
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
156
- // @ts-ignore
157
- return yield this._withdraw(_lpTokenAmount, 0.1, true);
132
+ return yield withdrawLendingOrCryptoMixin._withdraw.call(this, _lpTokenAmount, 0.1, true);
158
133
  });
159
134
  },
160
135
  withdraw(lpTokenAmount, slippage) {
161
136
  return __awaiter(this, void 0, void 0, function* () {
162
- // @ts-ignore
163
137
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
164
- // @ts-ignore
165
- return yield this._withdraw(_lpTokenAmount, slippage);
138
+ return yield withdrawLendingOrCryptoMixin._withdraw.call(this, _lpTokenAmount, slippage);
166
139
  });
167
140
  },
168
141
  };
169
- // @ts-ignore
170
142
  export const withdrawPlainMixin = {
171
- // @ts-ignore
172
143
  _withdraw(_lpTokenAmount_1, slippage_1) {
173
144
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
174
- // @ts-ignore
175
145
  const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
176
- const contract = curve.contracts[this.address].contract;
177
- const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
146
+ const contract = this.curve.contracts[this.address].contract;
147
+ const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, this.curve.constantOptions);
178
148
  if (estimateGas)
179
149
  return smartNumber(gas);
180
150
  const gasLimit = mulBy1_3(DIGas(gas));
181
- return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
151
+ return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, this.curve.options), { gasLimit }))).hash;
182
152
  });
183
153
  },
184
154
  withdrawEstimateGas(lpTokenAmount) {
185
155
  return __awaiter(this, void 0, void 0, function* () {
186
- // @ts-ignore
187
156
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
188
- // @ts-ignore
189
- return yield this._withdraw(_lpTokenAmount, 0.1, true);
157
+ return yield withdrawPlainMixin._withdraw.call(this, _lpTokenAmount, 0.1, true);
190
158
  });
191
159
  },
192
160
  withdraw(lpTokenAmount, slippage) {
193
161
  return __awaiter(this, void 0, void 0, function* () {
194
- // @ts-ignore
195
162
  const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
196
- // @ts-ignore
197
- return yield this._withdraw(_lpTokenAmount, slippage);
163
+ return yield withdrawPlainMixin._withdraw.call(this, _lpTokenAmount, slippage);
198
164
  });
199
165
  },
200
166
  };
@@ -1,5 +1,13 @@
1
1
  import { PoolTemplate } from "../PoolTemplate.js";
2
- export declare const withdrawOneCoinExpectedMetaFactoryMixin: PoolTemplate;
3
- export declare const withdrawOneCoinExpectedZapMixin: PoolTemplate;
4
- export declare const withdrawOneCoinExpected3argsMixin: PoolTemplate;
5
- export declare const withdrawOneCoinExpected2argsMixin: PoolTemplate;
2
+ export declare const withdrawOneCoinExpectedMetaFactoryMixin: {
3
+ _withdrawOneCoinExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
4
+ };
5
+ export declare const withdrawOneCoinExpectedZapMixin: {
6
+ _withdrawOneCoinExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
7
+ };
8
+ export declare const withdrawOneCoinExpected3argsMixin: {
9
+ _withdrawOneCoinExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
10
+ };
11
+ export declare const withdrawOneCoinExpected2argsMixin: {
12
+ _withdrawOneCoinExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
13
+ };
@@ -7,40 +7,35 @@ 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
- // @ts-ignore
12
10
  export const withdrawOneCoinExpectedMetaFactoryMixin = {
13
11
  _withdrawOneCoinExpected(_lpTokenAmount, i) {
14
12
  return __awaiter(this, void 0, void 0, function* () {
15
- const contract = curve.contracts[this.zap].contract;
16
- return yield contract.calc_withdraw_one_coin(this.address, _lpTokenAmount, i, curve.constantOptions);
13
+ const contract = this.curve.contracts[this.zap].contract;
14
+ return yield contract.calc_withdraw_one_coin(this.address, _lpTokenAmount, i, this.curve.constantOptions);
17
15
  });
18
16
  },
19
17
  };
20
- // @ts-ignore
21
18
  export const withdrawOneCoinExpectedZapMixin = {
22
19
  _withdrawOneCoinExpected(_lpTokenAmount, i) {
23
20
  return __awaiter(this, void 0, void 0, function* () {
24
- const contract = curve.contracts[this.zap].contract;
25
- return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve.constantOptions);
21
+ const contract = this.curve.contracts[this.zap].contract;
22
+ return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions);
26
23
  });
27
24
  },
28
25
  };
29
- // @ts-ignore
30
26
  export const withdrawOneCoinExpected3argsMixin = {
31
27
  _withdrawOneCoinExpected(_lpTokenAmount, i) {
32
28
  return __awaiter(this, void 0, void 0, function* () {
33
- const contract = curve.contracts[this.address].contract;
34
- return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, true, curve.constantOptions);
29
+ const contract = this.curve.contracts[this.address].contract;
30
+ return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, true, this.curve.constantOptions);
35
31
  });
36
32
  },
37
33
  };
38
- // @ts-ignore
39
34
  export const withdrawOneCoinExpected2argsMixin = {
40
35
  _withdrawOneCoinExpected(_lpTokenAmount, i) {
41
36
  return __awaiter(this, void 0, void 0, function* () {
42
- const contract = curve.contracts[this.address].contract;
43
- return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve.constantOptions);
37
+ const contract = this.curve.contracts[this.address].contract;
38
+ return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions);
44
39
  });
45
40
  },
46
41
  };