@curvefi/llamalend-api 2.0.27 → 2.0.29

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.
@@ -428,7 +428,7 @@ export class LoanBaseModule {
428
428
  const { debt: currentDebt } = yield this.market.userPosition.userState(address);
429
429
  if (Number(currentDebt) === 0)
430
430
  throw Error(`Loan for ${address} does not exist`);
431
- const _debt = parseUnits(debt);
431
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals);
432
432
  const [, n1] = yield this.market.userPosition.userBands(address);
433
433
  const { borrowed } = yield this.market.userPosition.userState(address);
434
434
  const n = (BN(borrowed).gt(0)) ? MAX_ACTIVE_BAND : n1 - 1;
@@ -147,7 +147,7 @@ export class LoanV1Module extends LoanBaseModule {
147
147
  repayHealth(_a) {
148
148
  return __awaiter(this, arguments, void 0, function* ({ debt, full = true, address = "" }) {
149
149
  address = _getAddress.call(this.llamalend, address);
150
- const _debt = parseUnits(debt) * BigInt(-1);
150
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals) * BigInt(-1);
151
151
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
152
152
  const _health = yield contract.health_calculator(address, 0, _debt, full, 0, this.llamalend.constantOptions);
153
153
  return formatUnits(_health * BigInt(100));
@@ -69,7 +69,7 @@ export class LoanV2Module extends LoanBaseModule {
69
69
  repayHealth(_a) {
70
70
  return __awaiter(this, arguments, void 0, function* ({ debt, shrink = false, full = true, address = "" }) {
71
71
  address = _getAddress.call(this.llamalend, address);
72
- const _debt = parseUnits(debt);
72
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals);
73
73
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
74
74
  const _health = yield contract.repay_health_preview(0, _debt, address, shrink, full, this.llamalend.constantOptions);
75
75
  return formatUnits(_health * BigInt(100));
@@ -1094,6 +1094,7 @@ export class MintMarketTemplate {
1094
1094
  // ---------------- REPAY ----------------
1095
1095
  _repayBands(debt, address) {
1096
1096
  return __awaiter(this, void 0, void 0, function* () {
1097
+ address = _getAddress.call(this.llamalend, address);
1097
1098
  const { _collateral: _currentCollateral, _debt: _currentDebt, _stablecoin: _currentStablecoin } = yield this._userState(address);
1098
1099
  if (_currentDebt === BigInt(0))
1099
1100
  throw Error(`Loan for ${address} does not exist`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -431,7 +431,7 @@ export abstract class LoanBaseModule {
431
431
  const { debt: currentDebt } = await this.market.userPosition.userState(address);
432
432
  if (Number(currentDebt) === 0) throw Error(`Loan for ${address} does not exist`);
433
433
 
434
- const _debt = parseUnits(debt);
434
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals);
435
435
  const [, n1] = await this.market.userPosition.userBands(address);
436
436
  const { borrowed } = await this.market.userPosition.userState(address);
437
437
  const n = (BN(borrowed).gt(0)) ? MAX_ACTIVE_BAND : n1 - 1;
@@ -168,7 +168,7 @@ export class LoanV1Module extends LoanBaseModule implements ILoanV1 {
168
168
 
169
169
  public async repayHealth({ debt, full = true, address = "" }: { debt: number | string; full?: boolean; address?: string }): Promise<string> {
170
170
  address = _getAddress.call(this.llamalend, address);
171
- const _debt = parseUnits(debt) * BigInt(-1);
171
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals) * BigInt(-1);
172
172
 
173
173
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
174
174
  const _health = await contract.health_calculator(address, 0, _debt, full, 0, this.llamalend.constantOptions) as bigint;
@@ -64,7 +64,7 @@ export class LoanV2Module extends LoanBaseModule implements ILoanV2 {
64
64
 
65
65
  public async repayHealth({ debt, shrink = false, full = true, address = "" }: { debt: number | string; shrink?: boolean; full?: boolean; address?: string }): Promise<string> {
66
66
  address = _getAddress.call(this.llamalend, address);
67
- const _debt = parseUnits(debt);
67
+ const _debt = parseUnits(debt, this.market.borrowed_token.decimals);
68
68
 
69
69
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
70
70
  const _health = await contract.repay_health_preview(0, _debt, address, shrink, full, this.llamalend.constantOptions) as bigint;
@@ -1136,6 +1136,7 @@ export class MintMarketTemplate {
1136
1136
  // ---------------- REPAY ----------------
1137
1137
 
1138
1138
  private async _repayBands(debt: number | string, address: string): Promise<[bigint, bigint]> {
1139
+ address = _getAddress.call(this.llamalend, address);
1139
1140
  const { _collateral: _currentCollateral, _debt: _currentDebt, _stablecoin: _currentStablecoin } = await this._userState(address);
1140
1141
  if (_currentDebt === BigInt(0)) throw Error(`Loan for ${address} does not exist`);
1141
1142