@curvefi/llamalend-api 1.0.7 → 1.0.8

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.
@@ -6,6 +6,7 @@ export declare const NETWORK_CONSTANTS: {
6
6
  };
7
7
  declare class Llamalend implements ILlamalend {
8
8
  address: string;
9
+ crvUsdAddress: string;
9
10
  provider: ethers.BrowserProvider | ethers.JsonRpcProvider;
10
11
  multicallProvider: MulticallProvider;
11
12
  signer: ethers.Signer | null;
package/lib/llamalend.js CHANGED
@@ -342,7 +342,8 @@ class Llamalend {
342
342
  };
343
343
  });
344
344
  });
345
- this.address = '00000'; //COINS.lending.toLowerCase();
345
+ this.address = '00000';
346
+ this.crvUsdAddress = COINS_ETHEREUM.crvusd;
346
347
  // @ts-ignore
347
348
  this.provider = null;
348
349
  this.signer = null;
@@ -510,6 +511,7 @@ class Llamalend {
510
511
  }
511
512
  }
512
513
  // crvUSD contracts
514
+ this.setContract(this.crvUsdAddress, ERC20ABI);
513
515
  if (this.chainId === 1) {
514
516
  this.setContract(this.constants.COINS.crvusd.toLowerCase(), ERC20ABI);
515
517
  for (const llamma of Object.values(this.constants.LLAMMAS)) {
@@ -603,7 +605,7 @@ class Llamalend {
603
605
  }
604
606
  }
605
607
  this.constants.DECIMALS = extractDecimals(this.constants.LLAMMAS);
606
- this.constants.DECIMALS[this.address] = 18;
608
+ this.constants.DECIMALS[this.crvUsdAddress] = 18;
607
609
  if (L2Networks.includes(this.chainId)) {
608
610
  // eslint-disable-next-line @typescript-eslint/no-this-alias
609
611
  const lendingInstance = this;
@@ -72,7 +72,7 @@ export class MintMarketTemplate {
72
72
  maxAge: 60 * 1000, // 1m
73
73
  });
74
74
  this.statsTotalStablecoin = memoize(() => __awaiter(this, void 0, void 0, function* () {
75
- const stablecoinContract = llamalend.contracts[llamalend.address].multicallContract;
75
+ const stablecoinContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
76
76
  const ammContract = llamalend.contracts[this.address].multicallContract;
77
77
  const [_balance, _fee] = yield llamalend.multicallProvider.all([
78
78
  stablecoinContract.balanceOf(this.address),
@@ -97,7 +97,7 @@ export class MintMarketTemplate {
97
97
  });
98
98
  this.statsCapAndAvailable = memoize(() => __awaiter(this, void 0, void 0, function* () {
99
99
  const factoryContract = llamalend.contracts[llamalend.constants.FACTORY].multicallContract;
100
- const crvusdContract = llamalend.contracts[llamalend.address].multicallContract;
100
+ const crvusdContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
101
101
  const [_cap, _available] = yield llamalend.multicallProvider.all([
102
102
  factoryContract.debt_ceiling(this.controller),
103
103
  crvusdContract.balanceOf(this.controller),
@@ -247,7 +247,7 @@ export class MintMarketTemplate {
247
247
  this.collateralSymbol = llammaData.collateral_symbol;
248
248
  this.collateralDecimals = llammaData.collateral_decimals;
249
249
  this.coins = ["crvUSD", llammaData.collateral_symbol];
250
- this.coinAddresses = [llamalend.address, llammaData.collateral_address];
250
+ this.coinAddresses = [llamalend.crvUsdAddress, llammaData.collateral_address];
251
251
  this.coinDecimals = [18, llammaData.collateral_decimals];
252
252
  this.minBands = llammaData.min_bands;
253
253
  this.maxBands = llammaData.max_bands;
@@ -326,7 +326,7 @@ export class MintMarketTemplate {
326
326
  }
327
327
  statsBalances() {
328
328
  return __awaiter(this, void 0, void 0, function* () {
329
- const crvusdContract = llamalend.contracts[llamalend.address].multicallContract;
329
+ const crvusdContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
330
330
  const collateralContract = llamalend.contracts[isEth(this.collateral) ? llamalend.constants.WETH : this.collateral].multicallContract;
331
331
  const contract = llamalend.contracts[this.address].multicallContract;
332
332
  const calls = [
@@ -550,7 +550,7 @@ export class MintMarketTemplate {
550
550
  // ---------------- WALLET BALANCES ----------------
551
551
  walletBalances() {
552
552
  return __awaiter(this, arguments, void 0, function* (address = "") {
553
- const [collateral, stablecoin] = yield getBalances([this.collateral, llamalend.address], address);
553
+ const [collateral, stablecoin] = yield getBalances([this.collateral, llamalend.crvUsdAddress], address);
554
554
  return { stablecoin, collateral };
555
555
  });
556
556
  }
@@ -1006,17 +1006,17 @@ export class MintMarketTemplate {
1006
1006
  }
1007
1007
  repayIsApproved(debt) {
1008
1008
  return __awaiter(this, void 0, void 0, function* () {
1009
- return yield hasAllowance([llamalend.address], [debt], llamalend.signerAddress, this.controller);
1009
+ return yield hasAllowance([llamalend.crvUsdAddress], [debt], llamalend.signerAddress, this.controller);
1010
1010
  });
1011
1011
  }
1012
1012
  repayApproveEstimateGas(debt) {
1013
1013
  return __awaiter(this, void 0, void 0, function* () {
1014
- return yield ensureAllowanceEstimateGas([llamalend.address], [debt], this.controller);
1014
+ return yield ensureAllowanceEstimateGas([llamalend.crvUsdAddress], [debt], this.controller);
1015
1015
  });
1016
1016
  }
1017
1017
  repayApprove(debt) {
1018
1018
  return __awaiter(this, void 0, void 0, function* () {
1019
- return yield ensureAllowance([llamalend.address], [debt], this.controller);
1019
+ return yield ensureAllowance([llamalend.crvUsdAddress], [debt], this.controller);
1020
1020
  });
1021
1021
  }
1022
1022
  repayHealth(debt_1) {
@@ -1240,19 +1240,19 @@ export class MintMarketTemplate {
1240
1240
  liquidateIsApproved() {
1241
1241
  return __awaiter(this, arguments, void 0, function* (address = "") {
1242
1242
  const tokensToLiquidate = yield this.tokensToLiquidate(address);
1243
- return yield hasAllowance([llamalend.address], [tokensToLiquidate], llamalend.signerAddress, this.controller);
1243
+ return yield hasAllowance([llamalend.crvUsdAddress], [tokensToLiquidate], llamalend.signerAddress, this.controller);
1244
1244
  });
1245
1245
  }
1246
1246
  liquidateApproveEstimateGas() {
1247
1247
  return __awaiter(this, arguments, void 0, function* (address = "") {
1248
1248
  const tokensToLiquidate = yield this.tokensToLiquidate(address);
1249
- return yield ensureAllowanceEstimateGas([llamalend.address], [tokensToLiquidate], this.controller);
1249
+ return yield ensureAllowanceEstimateGas([llamalend.crvUsdAddress], [tokensToLiquidate], this.controller);
1250
1250
  });
1251
1251
  }
1252
1252
  liquidateApprove() {
1253
1253
  return __awaiter(this, arguments, void 0, function* (address = "") {
1254
1254
  const tokensToLiquidate = yield this.tokensToLiquidate(address);
1255
- return yield ensureAllowance([llamalend.address], [tokensToLiquidate], this.controller);
1255
+ return yield ensureAllowance([llamalend.crvUsdAddress], [tokensToLiquidate], this.controller);
1256
1256
  });
1257
1257
  }
1258
1258
  _liquidate(address, slippage, estimateGas) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
package/src/llamalend.ts CHANGED
@@ -171,6 +171,7 @@ export const NETWORK_CONSTANTS: { [index: number]: any } = {
171
171
 
172
172
  class Llamalend implements ILlamalend {
173
173
  address: string;
174
+ crvUsdAddress: string;
174
175
  provider: ethers.BrowserProvider | ethers.JsonRpcProvider;
175
176
  multicallProvider: MulticallProvider;
176
177
  signer: ethers.Signer | null;
@@ -196,7 +197,8 @@ class Llamalend implements ILlamalend {
196
197
  };
197
198
 
198
199
  constructor() {
199
- this.address = '00000'//COINS.lending.toLowerCase();
200
+ this.address = '00000'
201
+ this.crvUsdAddress = COINS_ETHEREUM.crvusd;
200
202
  // @ts-ignore
201
203
  this.provider = null;
202
204
  this.signer = null;
@@ -368,6 +370,7 @@ class Llamalend implements ILlamalend {
368
370
  }
369
371
 
370
372
  // crvUSD contracts
373
+ this.setContract(this.crvUsdAddress, ERC20ABI);
371
374
  if(this.chainId === 1) {
372
375
  this.setContract(this.constants.COINS.crvusd.toLowerCase(), ERC20ABI);
373
376
  for (const llamma of Object.values(this.constants.LLAMMAS)) {
@@ -475,7 +478,7 @@ class Llamalend implements ILlamalend {
475
478
  }
476
479
 
477
480
  this.constants.DECIMALS = extractDecimals(this.constants.LLAMMAS);
478
- this.constants.DECIMALS[this.address] = 18;
481
+ this.constants.DECIMALS[this.crvUsdAddress] = 18;
479
482
 
480
483
  if(L2Networks.includes(this.chainId)) {
481
484
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -131,7 +131,7 @@ export class MintMarketTemplate {
131
131
  this.collateralSymbol = llammaData.collateral_symbol;
132
132
  this.collateralDecimals = llammaData.collateral_decimals;
133
133
  this.coins = ["crvUSD", llammaData.collateral_symbol];
134
- this.coinAddresses = [llamalend.address, llammaData.collateral_address];
134
+ this.coinAddresses = [llamalend.crvUsdAddress, llammaData.collateral_address];
135
135
  this.coinDecimals = [18, llammaData.collateral_decimals];
136
136
  this.minBands = llammaData.min_bands;
137
137
  this.maxBands = llammaData.max_bands;
@@ -248,7 +248,7 @@ export class MintMarketTemplate {
248
248
  });
249
249
 
250
250
  private async statsBalances(): Promise<[string, string]> {
251
- const crvusdContract = llamalend.contracts[llamalend.address].multicallContract;
251
+ const crvusdContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
252
252
  const collateralContract = llamalend.contracts[isEth(this.collateral) ? llamalend.constants.WETH : this.collateral].multicallContract;
253
253
  const contract = llamalend.contracts[this.address].multicallContract;
254
254
  const calls = [
@@ -357,7 +357,7 @@ export class MintMarketTemplate {
357
357
  });
358
358
 
359
359
  private statsTotalStablecoin = memoize(async (): Promise<string> => {
360
- const stablecoinContract = llamalend.contracts[llamalend.address].multicallContract;
360
+ const stablecoinContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
361
361
  const ammContract = llamalend.contracts[this.address].multicallContract;
362
362
 
363
363
  const [_balance, _fee]: bigint[] = await llamalend.multicallProvider.all([
@@ -390,7 +390,7 @@ export class MintMarketTemplate {
390
390
 
391
391
  private statsCapAndAvailable = memoize(async (): Promise<{ "cap": string, "available": string }> => {
392
392
  const factoryContract = llamalend.contracts[llamalend.constants.FACTORY].multicallContract;
393
- const crvusdContract = llamalend.contracts[llamalend.address].multicallContract;
393
+ const crvusdContract = llamalend.contracts[llamalend.crvUsdAddress].multicallContract;
394
394
 
395
395
  const [_cap, _available]: bigint[] = await llamalend.multicallProvider.all([
396
396
  factoryContract.debt_ceiling(this.controller),
@@ -577,7 +577,7 @@ export class MintMarketTemplate {
577
577
  // ---------------- WALLET BALANCES ----------------
578
578
 
579
579
  private async walletBalances(address = ""): Promise<{ collateral: string, stablecoin: string }> {
580
- const [collateral, stablecoin] = await getBalances([this.collateral, llamalend.address], address);
580
+ const [collateral, stablecoin] = await getBalances([this.collateral, llamalend.crvUsdAddress], address);
581
581
  return { stablecoin, collateral }
582
582
  }
583
583
 
@@ -1028,15 +1028,15 @@ export class MintMarketTemplate {
1028
1028
  }
1029
1029
 
1030
1030
  public async repayIsApproved(debt: number | string): Promise<boolean> {
1031
- return await hasAllowance([llamalend.address], [debt], llamalend.signerAddress, this.controller);
1031
+ return await hasAllowance([llamalend.crvUsdAddress], [debt], llamalend.signerAddress, this.controller);
1032
1032
  }
1033
1033
 
1034
1034
  private async repayApproveEstimateGas (debt: number | string): Promise<TGas> {
1035
- return await ensureAllowanceEstimateGas([llamalend.address], [debt], this.controller);
1035
+ return await ensureAllowanceEstimateGas([llamalend.crvUsdAddress], [debt], this.controller);
1036
1036
  }
1037
1037
 
1038
1038
  public async repayApprove(debt: number | string): Promise<string[]> {
1039
- return await ensureAllowance([llamalend.address], [debt], this.controller);
1039
+ return await ensureAllowance([llamalend.crvUsdAddress], [debt], this.controller);
1040
1040
  }
1041
1041
 
1042
1042
  public async repayHealth(debt: number | string, full = true, address = ""): Promise<string> {
@@ -1241,17 +1241,17 @@ export class MintMarketTemplate {
1241
1241
 
1242
1242
  public async liquidateIsApproved(address = ""): Promise<boolean> {
1243
1243
  const tokensToLiquidate = await this.tokensToLiquidate(address);
1244
- return await hasAllowance([llamalend.address], [tokensToLiquidate], llamalend.signerAddress, this.controller);
1244
+ return await hasAllowance([llamalend.crvUsdAddress], [tokensToLiquidate], llamalend.signerAddress, this.controller);
1245
1245
  }
1246
1246
 
1247
1247
  private async liquidateApproveEstimateGas (address = ""): Promise<TGas> {
1248
1248
  const tokensToLiquidate = await this.tokensToLiquidate(address);
1249
- return await ensureAllowanceEstimateGas([llamalend.address], [tokensToLiquidate], this.controller);
1249
+ return await ensureAllowanceEstimateGas([llamalend.crvUsdAddress], [tokensToLiquidate], this.controller);
1250
1250
  }
1251
1251
 
1252
1252
  public async liquidateApprove(address = ""): Promise<string[]> {
1253
1253
  const tokensToLiquidate = await this.tokensToLiquidate(address);
1254
- return await ensureAllowance([llamalend.address], [tokensToLiquidate], this.controller);
1254
+ return await ensureAllowance([llamalend.crvUsdAddress], [tokensToLiquidate], this.controller);
1255
1255
  }
1256
1256
 
1257
1257
  private async _liquidate(address: string, slippage: number, estimateGas: boolean): Promise<string | TGas> {