@curvefi/llamalend-api 1.0.18 → 1.0.20

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/llamalend.js CHANGED
@@ -471,9 +471,6 @@ class Llamalend {
471
471
  this.setContract(this.constants.ALIASES.crv, ERC20ABI);
472
472
  this.setContract(this.constants.ALIASES.crvUSD, ERC20ABI);
473
473
  this.setContract(this.constants.ALIASES.st_crvUSD, ERC4626ABI);
474
- this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
475
- this.constants.DECIMALS[this.constants.ALIASES.crvUSD] = 18;
476
- this.constants.DECIMALS[this.constants.ALIASES.st_crvUSD] = 18;
477
474
  this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
478
475
  if (this.signer) {
479
476
  try {
@@ -607,8 +604,7 @@ class Llamalend {
607
604
  }
608
605
  }
609
606
  }
610
- this.constants.DECIMALS = extractDecimals(this.constants.LLAMMAS);
611
- this.constants.DECIMALS[this.crvUsdAddress] = 18;
607
+ this.constants.DECIMALS = Object.assign(Object.assign({}, extractDecimals(this.constants.LLAMMAS)), { [this.crvUsdAddress]: 18, [this.constants.ALIASES.crv]: 18, [this.constants.ALIASES.crvUSD]: 18, [this.constants.ALIASES.st_crvUSD]: 18 });
612
608
  if (L2Networks.includes(this.chainId)) {
613
609
  // eslint-disable-next-line @typescript-eslint/no-this-alias
614
610
  const lendingInstance = this;
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,7 +187,7 @@ 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
  });
@@ -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.18",
3
+ "version": "1.0.20",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -14,8 +14,10 @@
14
14
  "url": "https://github.com/curvefi/curve-lending-js/issues"
15
15
  },
16
16
  "scripts": {
17
- "build": "rm -rf lib && tsc -p tsconfig.build.json",
18
- "lint": "eslint src --ext .ts"
17
+ "build": "rm -rf lib && tsc --project tsconfig.build.json",
18
+ "lint": "eslint src --ext .ts",
19
+ "watch": "tsc --watch",
20
+ "watch:lib": "rm -rf lib && tsc --watch --project tsconfig.build.json"
19
21
  },
20
22
  "engines": {
21
23
  "node": "^22.0.0"
package/src/llamalend.ts CHANGED
@@ -328,9 +328,6 @@ class Llamalend implements ILlamalend {
328
328
  this.setContract(this.constants.ALIASES.crv, ERC20ABI);
329
329
  this.setContract(this.constants.ALIASES.crvUSD, ERC20ABI);
330
330
  this.setContract(this.constants.ALIASES.st_crvUSD, ERC4626ABI);
331
- this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
332
- this.constants.DECIMALS[this.constants.ALIASES.crvUSD] = 18;
333
- this.constants.DECIMALS[this.constants.ALIASES.st_crvUSD] = 18;
334
331
 
335
332
  this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
336
333
 
@@ -480,8 +477,13 @@ class Llamalend implements ILlamalend {
480
477
  }
481
478
  }
482
479
 
483
- this.constants.DECIMALS = extractDecimals(this.constants.LLAMMAS);
484
- this.constants.DECIMALS[this.crvUsdAddress] = 18;
480
+ this.constants.DECIMALS = {
481
+ ...extractDecimals(this.constants.LLAMMAS),
482
+ [this.crvUsdAddress]: 18,
483
+ [this.constants.ALIASES.crv]: 18,
484
+ [this.constants.ALIASES.crvUSD]: 18,
485
+ [this.constants.ALIASES.st_crvUSD]: 18,
486
+ }
485
487
 
486
488
  if(L2Networks.includes(this.chainId)) {
487
489
  // eslint-disable-next-line @typescript-eslint/no-this-alias
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]))
@@ -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)