From 0c38404eb962a324b4aad76dc1c5084773034274 Mon Sep 17 00:00:00 2001 From: macket Date: Fri, 25 Aug 2023 22:55:30 +0400 Subject: [PATCH 1/3] fix: debt decimals --- src/llammas/LlammaTemplate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From b73ea8d22f556b97b4c7bdebc6ed45bceb1c87c8 Mon Sep 17 00:00:00 2001 From: macket Date: Fri, 25 Aug 2023 22:56:10 +0400 Subject: [PATCH 2/3] test: reduced full health precision from 1e-3 to 1e-2 --- test/general.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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'); From e3700d2d27e9190b03c1df13168c55110461cd49 Mon Sep 17 00:00:00 2001 From: macket Date: Fri, 25 Aug 2023 22:56:53 +0400 Subject: [PATCH 3/3] build: v1.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",