@curvefi/api 2.68.35 → 2.68.36

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.
@@ -7,7 +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 { _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
10
+ import { abiInfoBuild, _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
11
11
  function _depositCheck(amounts_1) {
12
12
  return __awaiter(this, arguments, void 0, function* (amounts, estimateGas = false) {
13
13
  if (amounts.length !== this.underlyingCoinAddresses.length) {
@@ -39,11 +39,7 @@ export const depositMetaFactoryMixin = {
39
39
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
40
40
  const contract = this.curve.contracts[this.zap].contract;
41
41
  if (getInfo) {
42
- return {
43
- address: this.zap,
44
- method: 'add_liquidity',
45
- abi: contract.add_liquidity.fragment,
46
- };
42
+ return abiInfoBuild(this.zap, 'add_liquidity', contract.add_liquidity.fragment);
47
43
  }
48
44
  if (!estimateGas)
49
45
  yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
@@ -80,11 +76,7 @@ export const depositCryptoMetaFactoryMixin = {
80
76
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
81
77
  const contract = this.curve.contracts[this.zap].contract;
82
78
  if (getInfo) {
83
- return {
84
- address: this.zap,
85
- method: 'add_liquidity',
86
- abi: contract.add_liquidity.fragment,
87
- };
79
+ return abiInfoBuild(this.zap, 'add_liquidity', contract.add_liquidity.fragment);
88
80
  }
89
81
  if (!estimateGas)
90
82
  yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
@@ -121,11 +113,7 @@ export const depositZapMixin = {
121
113
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
122
114
  const contract = this.curve.contracts[this.zap].contract;
123
115
  if (getInfo) {
124
- return {
125
- address: this.zap,
126
- method: 'add_liquidity',
127
- abi: contract.add_liquidity.fragment,
128
- };
116
+ return abiInfoBuild(this.zap, 'add_liquidity', contract.add_liquidity.fragment);
129
117
  }
130
118
  if (!estimateGas)
131
119
  yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.zap);
@@ -165,11 +153,7 @@ export const depositLendingOrCryptoMixin = {
165
153
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
166
154
  const contract = this.curve.contracts[this.address].contract;
167
155
  if (getInfo) {
168
- return {
169
- address: this.address,
170
- method: 'add_liquidity',
171
- abi: contract.add_liquidity.fragment,
172
- };
156
+ return abiInfoBuild(this.address, 'add_liquidity', contract.add_liquidity.fragment);
173
157
  }
174
158
  if (!estimateGas)
175
159
  yield _ensureAllowance.call(this.curve, this.underlyingCoinAddresses, _amounts, this.address);
@@ -206,11 +190,7 @@ export const depositPlainMixin = {
206
190
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
207
191
  const contract = this.curve.contracts[this.address].contract;
208
192
  if (getInfo) {
209
- return {
210
- address: this.address,
211
- method: 'add_liquidity',
212
- abi: contract.add_liquidity.fragment,
213
- };
193
+ return abiInfoBuild(this.address, 'add_liquidity', contract.add_liquidity.fragment);
214
194
  }
215
195
  if (!estimateGas)
216
196
  yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
@@ -7,7 +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 { _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
10
+ import { abiInfoBuild, _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
11
11
  function _depositWrappedCheck(amounts_1) {
12
12
  return __awaiter(this, arguments, void 0, function* (amounts, estimateGas = false) {
13
13
  if (this.isFake) {
@@ -42,11 +42,7 @@ export const depositWrapped2argsMixin = {
42
42
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
43
43
  const contract = this.curve.contracts[this.address].contract;
44
44
  if (getInfo) {
45
- return {
46
- address: this.address,
47
- method: 'add_liquidity',
48
- abi: contract.add_liquidity.fragment,
49
- };
45
+ return abiInfoBuild(this.address, 'add_liquidity', contract.add_liquidity.fragment);
50
46
  }
51
47
  if (!estimateGas)
52
48
  yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
@@ -83,11 +79,7 @@ export const depositWrapped3argsMixin = {
83
79
  return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false, getInfo = false) {
84
80
  const contract = this.curve.contracts[this.address].contract;
85
81
  if (getInfo) {
86
- return {
87
- address: this.address,
88
- method: 'add_liquidity',
89
- abi: contract.add_liquidity.fragment,
90
- };
82
+ return abiInfoBuild(this.address, 'add_liquidity', contract.add_liquidity.fragment);
91
83
  }
92
84
  if (!estimateGas)
93
85
  yield _ensureAllowance.call(this.curve, this.wrappedCoinAddresses, _amounts, this.address);
@@ -7,7 +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 { _ensureAllowance, _getCoinDecimals, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
10
+ import { abiInfoBuild, _ensureAllowance, _getCoinDecimals, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
11
11
  function _swapCheck(inputCoin_1, outputCoin_1, amount_1) {
12
12
  return __awaiter(this, arguments, void 0, function* (inputCoin, outputCoin, amount, estimateGas = false) {
13
13
  const contractAddress = this._swapContractAddress();
@@ -41,11 +41,7 @@ export const swapTricrypto2Mixin = {
41
41
  const contract = this.curve.contracts[contractAddress].contract;
42
42
  const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
43
43
  if (getInfo) {
44
- return {
45
- address: contractAddress,
46
- method: exchangeMethod,
47
- abi: contract[exchangeMethod].fragment,
48
- };
44
+ return abiInfoBuild(contractAddress, exchangeMethod, contract[exchangeMethod].fragment);
49
45
  }
50
46
  if (!estimateGas)
51
47
  yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
@@ -83,11 +79,7 @@ export const swapMetaFactoryMixin = {
83
79
  const contract = this.curve.contracts[contractAddress].contract;
84
80
  const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
85
81
  if (getInfo) {
86
- return {
87
- address: contractAddress,
88
- method: exchangeMethod,
89
- abi: contract[exchangeMethod].fragment,
90
- };
82
+ return abiInfoBuild(contractAddress, exchangeMethod, contract[exchangeMethod].fragment);
91
83
  }
92
84
  if (!estimateGas)
93
85
  yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
@@ -125,11 +117,7 @@ export const swapCryptoMetaFactoryMixin = {
125
117
  const contract = this.curve.contracts[contractAddress].contract;
126
118
  const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
127
119
  if (getInfo) {
128
- return {
129
- address: contractAddress,
130
- method: exchangeMethod,
131
- abi: contract[exchangeMethod].fragment,
132
- };
120
+ return abiInfoBuild(contractAddress, exchangeMethod, contract[exchangeMethod].fragment);
133
121
  }
134
122
  if (!estimateGas)
135
123
  yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
@@ -167,11 +155,7 @@ export const swapMixin = {
167
155
  const contract = this.curve.contracts[contractAddress].contract;
168
156
  const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
169
157
  if (getInfo) {
170
- return {
171
- address: contractAddress,
172
- method: exchangeMethod,
173
- abi: contract[exchangeMethod].fragment,
174
- };
158
+ return abiInfoBuild(contractAddress, exchangeMethod, contract[exchangeMethod].fragment);
175
159
  }
176
160
  if (!estimateGas)
177
161
  yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
@@ -7,7 +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 { _ensureAllowance, _getCoinDecimals, DIGas, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
10
+ import { abiInfoBuild, _ensureAllowance, _getCoinDecimals, DIGas, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from '../../utils.js';
11
11
  function _swapWrappedCheck(inputCoin_1, outputCoin_1, amount_1) {
12
12
  return __awaiter(this, arguments, void 0, function* (inputCoin, outputCoin, amount, estimateGas = false) {
13
13
  const i = this._getCoinIdx(inputCoin, false);
@@ -38,11 +38,7 @@ export const swapWrappedTricrypto2Mixin = {
38
38
  return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
39
39
  const contract = this.curve.contracts[this.address].contract;
40
40
  if (getInfo) {
41
- return {
42
- address: this.address,
43
- method: 'exchange',
44
- abi: contract.exchange.fragment,
45
- };
41
+ return abiInfoBuild(this.address, 'exchange', contract.exchange.fragment);
46
42
  }
47
43
  if (!estimateGas)
48
44
  yield _ensureAllowance.call(this.curve, [this.wrappedCoinAddresses[i]], [_amount], this.address);
@@ -78,11 +74,7 @@ export const swapWrappedMixin = {
78
74
  return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
79
75
  const contract = this.curve.contracts[this.address].contract;
80
76
  if (getInfo) {
81
- return {
82
- address: this.address,
83
- method: 'exchange',
84
- abi: contract.exchange.fragment,
85
- };
77
+ return abiInfoBuild(this.address, 'exchange', contract.exchange.fragment);
86
78
  }
87
79
  if (!estimateGas)
88
80
  yield _ensureAllowance.call(this.curve, [this.wrappedCoinAddresses[i]], [_amount], this.address);
@@ -7,7 +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 { _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
10
+ import { abiInfoBuild, _ensureAllowance, DIGas, fromBN, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
11
11
  function _withdrawOneCoinCheck(lpTokenAmount_1, coin_1) {
12
12
  return __awaiter(this, arguments, void 0, function* (lpTokenAmount, coin, estimateGas = false) {
13
13
  const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
@@ -36,11 +36,7 @@ export const withdrawOneCoinMetaFactoryMixin = {
36
36
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
37
37
  const contract = this.curve.contracts[this.zap].contract;
38
38
  if (getInfo) {
39
- return {
40
- address: this.zap,
41
- method: 'remove_liquidity_one_coin',
42
- abi: contract.remove_liquidity_one_coin.fragment,
43
- };
39
+ return abiInfoBuild(this.zap, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
44
40
  }
45
41
  if (!estimateGas)
46
42
  yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
@@ -75,11 +71,7 @@ export const withdrawOneCoinCryptoMetaFactoryMixin = {
75
71
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
76
72
  const contract = this.curve.contracts[this.zap].contract;
77
73
  if (getInfo) {
78
- return {
79
- address: this.zap,
80
- method: 'remove_liquidity_one_coin',
81
- abi: contract.remove_liquidity_one_coin.fragment,
82
- };
74
+ return abiInfoBuild(this.zap, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
83
75
  }
84
76
  if (!estimateGas)
85
77
  yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
@@ -114,11 +106,7 @@ export const withdrawOneCoinZapMixin = {
114
106
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
115
107
  const contract = this.curve.contracts[this.zap].contract;
116
108
  if (getInfo) {
117
- return {
118
- address: this.zap,
119
- method: 'remove_liquidity_one_coin',
120
- abi: contract.remove_liquidity_one_coin.fragment,
121
- };
109
+ return abiInfoBuild(this.zap, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
122
110
  }
123
111
  if (!estimateGas)
124
112
  yield _ensureAllowance.bind(this.curve, [this.lpToken], [_lpTokenAmount], this.zap);
@@ -156,11 +144,7 @@ export const withdrawOneCoinLendingOrCryptoMixin = {
156
144
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
157
145
  const contract = this.curve.contracts[this.address].contract;
158
146
  if (getInfo) {
159
- return {
160
- address: this.address,
161
- method: 'remove_liquidity_one_coin',
162
- abi: contract.remove_liquidity_one_coin.fragment,
163
- };
147
+ return abiInfoBuild(this.address, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
164
148
  }
165
149
  const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
166
150
  const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, this.curve.constantOptions);
@@ -193,11 +177,7 @@ export const withdrawOneCoinPlainMixin = {
193
177
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
194
178
  const contract = this.curve.contracts[this.address].contract;
195
179
  if (getInfo) {
196
- return {
197
- address: this.address,
198
- method: 'remove_liquidity_one_coin',
199
- abi: contract.remove_liquidity_one_coin.fragment,
200
- };
180
+ return abiInfoBuild(this.address, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
201
181
  }
202
182
  const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
203
183
  const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, this.curve.constantOptions);
@@ -7,7 +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 { DIGas, fromBN, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
10
+ import { abiInfoBuild, DIGas, fromBN, mulBy1_3, parseUnits, smartNumber, toBN } from '../../utils.js';
11
11
  function _withdrawOneCoinWrappedCheck(lpTokenAmount, coin) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
@@ -32,11 +32,7 @@ export const withdrawOneCoinWrappedLendingOrCryptoMixin = {
32
32
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
33
33
  const contract = this.curve.contracts[this.address].contract;
34
34
  if (getInfo) {
35
- return {
36
- address: this.address,
37
- method: 'remove_liquidity_one_coin',
38
- abi: contract.remove_liquidity_one_coin.fragment,
39
- };
35
+ return abiInfoBuild(this.address, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
40
36
  }
41
37
  const _minAmount = yield _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
42
38
  const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, false, this.curve.constantOptions);
@@ -69,11 +65,7 @@ export const withdrawOneCoinWrappedMixin = {
69
65
  return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false, getInfo = false) {
70
66
  const contract = this.curve.contracts[this.address].contract;
71
67
  if (getInfo) {
72
- return {
73
- address: this.address,
74
- method: 'remove_liquidity_one_coin',
75
- abi: contract.remove_liquidity_one_coin.fragment,
76
- };
68
+ return abiInfoBuild(this.address, 'remove_liquidity_one_coin', contract.remove_liquidity_one_coin.fragment);
77
69
  }
78
70
  const _minAmount = yield _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
79
71
  const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, this.curve.constantOptions);
package/lib/utils.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { Contract, TransactionLike } from 'ethers';
2
2
  import { Contract as MulticallContract } from "@curvefi/ethcall";
3
3
  import BigNumber from 'bignumber.js';
4
- import { Abi, AbiFunction, IBasePoolShortItem, IChainId, ICurveLiteNetwork, IDict, INetworkName, IRewardFromApi, IVolumeAndAPYs, REFERENCE_ASSET } from './interfaces';
4
+ import { Abi, AbiFunction, IBasePoolShortItem, IChainId, ICurveLiteNetwork, IDict, IMethodInfo, INetworkName, IRewardFromApi, IVolumeAndAPYs, REFERENCE_ASSET } from './interfaces';
5
5
  import { Curve } from "./curve.js";
6
6
  export declare const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
7
7
  export declare const MAX_ALLOWANCE: bigint;
8
+ export declare const abiInfoBuild: (address: string, method: string, abi: any) => IMethodInfo;
8
9
  export declare const _cutZeros: (strn: string) => string;
9
10
  export declare const checkNumber: (n: number | string) => number | string;
10
11
  export declare const formatNumber: (n: number | string, decimals?: number) => string;
package/lib/utils.js CHANGED
@@ -21,6 +21,11 @@ import { formatUnits } from "./constants/utils.js";
21
21
  export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
22
22
  // export const MAX_ALLOWANCE = curve.parseUnits(new BigNumber(2).pow(256).minus(1).toFixed(), 0);
23
23
  export const MAX_ALLOWANCE = BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"); // 2**256 - 1
24
+ export const abiInfoBuild = (address, method, abi) => ({
25
+ address,
26
+ method,
27
+ abi,
28
+ });
24
29
  // Formatting numbers
25
30
  export const _cutZeros = (strn) => {
26
31
  return strn.replace(/(\.\d*[1-9])0+$/gi, '$1').replace(/\.0+$/gi, '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.68.35",
3
+ "version": "2.68.36",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",