@curvefi/llamalend-api 1.0.17 → 1.0.19

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.
package/lib/utils.js CHANGED
@@ -156,7 +156,7 @@ export const _getBalances = (coinAddresses_1, ...args_1) => __awaiter(void 0, [c
156
156
  });
157
157
  export const getBalances = (coins_1, ...args_1) => __awaiter(void 0, [coins_1, ...args_1], void 0, function* (coins, address = "") {
158
158
  const coinAddresses = _getCoinAddresses(coins);
159
- const decimals = _getCoinDecimals(coinAddresses);
159
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
160
160
  const _balances = yield _getBalances(coinAddresses, address);
161
161
  return _balances.map((_b, i) => formatUnits(_b, decimals[i]));
162
162
  });
@@ -187,14 +187,14 @@ export const _getAllowance = memoize((coins, address, spender) => __awaiter(void
187
187
  // coins can be either addresses or symbols
188
188
  export const getAllowance = (coins, address, spender) => __awaiter(void 0, void 0, void 0, function* () {
189
189
  const coinAddresses = _getCoinAddresses(coins);
190
- const decimals = _getCoinDecimals(coinAddresses);
190
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
191
191
  const _allowance = yield _getAllowance(coinAddresses, address, spender);
192
192
  return _allowance.map((a, i) => llamalend.formatUnits(a, decimals[i]));
193
193
  });
194
194
  // coins can be either addresses or symbols
195
195
  export const hasAllowance = (coins, amounts, address, spender) => __awaiter(void 0, void 0, void 0, function* () {
196
196
  const coinAddresses = _getCoinAddresses(coins);
197
- const decimals = _getCoinDecimals(coinAddresses);
197
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
198
198
  const _allowance = yield _getAllowance(coinAddresses, address, spender);
199
199
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
200
200
  return _allowance.map((a, i) => a >= _amounts[i]).reduce((a, b) => a && b);
@@ -217,7 +217,7 @@ export const _ensureAllowance = (coins_1, _amounts_1, spender_1, ...args_1) => _
217
217
  // coins can be either addresses or symbols
218
218
  export const ensureAllowanceEstimateGas = (coins_1, amounts_1, spender_1, ...args_1) => __awaiter(void 0, [coins_1, amounts_1, spender_1, ...args_1], void 0, function* (coins, amounts, spender, isMax = true) {
219
219
  const coinAddresses = _getCoinAddresses(coins);
220
- const decimals = _getCoinDecimals(coinAddresses);
220
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
221
221
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
222
222
  const _allowance = yield _getAllowance(coinAddresses, llamalend.signerAddress, spender);
223
223
  let gas = [0, 0];
@@ -234,7 +234,7 @@ export const ensureAllowanceEstimateGas = (coins_1, amounts_1, spender_1, ...arg
234
234
  // coins can be either addresses or symbols
235
235
  export const ensureAllowance = (coins_1, amounts_1, spender_1, ...args_1) => __awaiter(void 0, [coins_1, amounts_1, spender_1, ...args_1], void 0, function* (coins, amounts, spender, isMax = true) {
236
236
  const coinAddresses = _getCoinAddresses(coins);
237
- const decimals = _getCoinDecimals(coinAddresses);
237
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
238
238
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
239
239
  return yield _ensureAllowance(coinAddresses, _amounts, spender, isMax);
240
240
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
package/src/utils.ts CHANGED
@@ -180,7 +180,7 @@ export const _getBalances = async (coinAddresses: string[], address = ""): Promi
180
180
 
181
181
  export const getBalances = async (coins: string[], address = ""): Promise<string[]> => {
182
182
  const coinAddresses = _getCoinAddresses(coins);
183
- const decimals = _getCoinDecimals(coinAddresses);
183
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
184
184
  const _balances = await _getBalances(coinAddresses, address);
185
185
 
186
186
  return _balances.map((_b, i: number ) => formatUnits(_b, decimals[i]));
@@ -217,7 +217,7 @@ export const _getAllowance = memoize(async (coins: string[], address: string, sp
217
217
  // coins can be either addresses or symbols
218
218
  export const getAllowance = async (coins: string[], address: string, spender: string): Promise<string[]> => {
219
219
  const coinAddresses = _getCoinAddresses(coins);
220
- const decimals = _getCoinDecimals(coinAddresses);
220
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
221
221
  const _allowance = await _getAllowance(coinAddresses, address, spender);
222
222
 
223
223
  return _allowance.map((a, i) => llamalend.formatUnits(a, decimals[i]))
@@ -226,7 +226,7 @@ export const getAllowance = async (coins: string[], address: string, spender: st
226
226
  // coins can be either addresses or symbols
227
227
  export const hasAllowance = async (coins: string[], amounts: (number | string)[], address: string, spender: string): Promise<boolean> => {
228
228
  const coinAddresses = _getCoinAddresses(coins);
229
- const decimals = _getCoinDecimals(coinAddresses);
229
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
230
230
  const _allowance = await _getAllowance(coinAddresses, address, spender);
231
231
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
232
232
 
@@ -254,7 +254,7 @@ export const _ensureAllowance = async (coins: string[], _amounts: bigint[], spen
254
254
  // coins can be either addresses or symbols
255
255
  export const ensureAllowanceEstimateGas = async (coins: string[], amounts: (number | string)[], spender: string, isMax = true): Promise<TGas> => {
256
256
  const coinAddresses = _getCoinAddresses(coins);
257
- const decimals = _getCoinDecimals(coinAddresses);
257
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
258
258
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
259
259
  const _allowance: bigint[] = await _getAllowance(coinAddresses, llamalend.signerAddress, spender);
260
260
 
@@ -274,7 +274,7 @@ export const ensureAllowanceEstimateGas = async (coins: string[], amounts: (numb
274
274
  // coins can be either addresses or symbols
275
275
  export const ensureAllowance = async (coins: string[], amounts: (number | string)[], spender: string, isMax = true): Promise<string[]> => {
276
276
  const coinAddresses = _getCoinAddresses(coins);
277
- const decimals = _getCoinDecimals(coinAddresses);
277
+ const decimals = _getCoinDecimals(coinAddresses).map((item) => Number(item));
278
278
  const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
279
279
 
280
280
  return await _ensureAllowance(coinAddresses, _amounts, spender, isMax)