diff --git a/package.json b/package.json index 6949333..283272d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/stablecoin-api", - "version": "1.3.3", + "version": "1.3.4", "description": "JavaScript library for Curve Stablecoin", "main": "lib/index.js", "author": "Macket", diff --git a/src/llammas/LlammaTemplate.ts b/src/llammas/LlammaTemplate.ts index 4d74556..bfe67e2 100644 --- a/src/llammas/LlammaTemplate.ts +++ b/src/llammas/LlammaTemplate.ts @@ -752,7 +752,7 @@ export class LlammaTemplate { const N = await this.userRange(); const _collateral = _currentCollateral.add(parseUnits(collateral, this.collateralDecimals)); - const _debt = _currentDebt.add(parseUnits(debt, this.collateralDecimals)); + const _debt = _currentDebt.add(parseUnits(debt)); const _n1 = await this._calcN1(_collateral, _debt, N); const _n2 = _n1.add(N - 1); @@ -976,7 +976,7 @@ export class LlammaTemplate { if (_currentDebt.eq(0)) throw Error(`Loan for ${address} does not exist`); const N = await this.userRange(address); - const _debt = _currentDebt.sub(parseUnits(debt, this.collateralDecimals)); + const _debt = _currentDebt.sub(parseUnits(debt)); const _n1 = await this._calcN1(_currentCollateral, _debt, N); const _n2 = _n1.add(N - 1); diff --git a/test/general.test.ts b/test/general.test.ts index 94e79fa..de2fcf3 100644 --- a/test/general.test.ts +++ b/test/general.test.ts @@ -4,7 +4,7 @@ import { getLlamma, LlammaTemplate } from "../src/llammas"; import { BN } from "../src/utils"; -const LLAMMAS = ['eth']; +const LLAMMAS = ['sfrxeth', 'wsteth', 'wbtc', 'eth']; const generalTest = (id: string) => { describe(`${id} llamma general test`, function () { @@ -137,7 +137,7 @@ const generalTest = (id: string) => { assert.approximately(Number(removeCollateralPrices[0]), Number(userPrices[0]), 1e-2, 'price 0'); assert.approximately(Number(removeCollateralPrices[1]), Number(userPrices[1]), 1e-2, 'price 1'); - assert.approximately(Number(removeCollateralFullHealth), Number(fullHealth), 1e-3, 'full health'); + assert.approximately(Number(removeCollateralFullHealth), Number(fullHealth), 1e-2, 'full health'); assert.approximately(Number(removeCollateralHealth), Number(health), 1e-4, 'health'); assert.equal(Number(balances.collateral), Number(initialBalances.collateral) + Number(collateralAmount), 'wallet collateral'); assert.equal(Number(balances.stablecoin), Number(initialBalances.stablecoin), 'wallet stablecoin'); @@ -168,7 +168,7 @@ const generalTest = (id: string) => { assert.approximately(Number(repayPrices[0]), Number(userPrices[0]), 1e-2, 'price 0'); assert.approximately(Number(repayPrices[1]), Number(userPrices[1]), 1e-2, 'price 1'); - assert.approximately(Number(repayFullHealth), Number(fullHealth), 1e-3, 'full health'); + assert.approximately(Number(repayFullHealth), Number(fullHealth), 1e-2, 'full health'); assert.approximately(Number(repayHealth), Number(health), 1e-4, 'health'); assert.equal(Number(balances.collateral), Number(initialBalances.collateral), 'wallet collateral'); assert.equal(balances.stablecoin, BN(initialBalances.stablecoin).minus(BN(debtAmount)).toString(), 'wallet stablecoin');