From 308ece6a9a0b0896ea2dc04a96cf990f04f4f5b8 Mon Sep 17 00:00:00 2001 From: fedorovdg Date: Wed, 3 Jul 2024 19:30:57 +0400 Subject: [PATCH 1/2] fix: fixed userLoss api response handle --- src/external-api.ts | 4 ++-- src/llammas/LlammaTemplate.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/external-api.ts b/src/external-api.ts index cbaaf0c..862f8a8 100644 --- a/src/external-api.ts +++ b/src/external-api.ts @@ -16,10 +16,10 @@ export const _getPoolsFromApi = memoize( ) export const _getUserCollateral = memoize( - async (network: INetworkName, controller: string, user: string, collateralDecimals = 18): Promise => { + async (network: INetworkName, controller: string, user: string): Promise => { const url = `https://prices.curve.fi/v1/crvusd/collateral_events/${network}/${controller}/${user}`; const response = await axios.get(url, { validateStatus: () => true }); - return crvusd.formatUnits(crvusd.parseUnits(response.data.total_collateral ?? "0.0", 0), collateralDecimals); + return response.data.total_deposit; }, { promise: true, diff --git a/src/llammas/LlammaTemplate.ts b/src/llammas/LlammaTemplate.ts index 58e20cb..be97038 100644 --- a/src/llammas/LlammaTemplate.ts +++ b/src/llammas/LlammaTemplate.ts @@ -466,7 +466,7 @@ export class LlammaTemplate { public async userLoss(userAddress = ""): Promise<{ deposited_collateral: string, current_collateral_estimation: string, loss: string, loss_pct: string }> { userAddress = _getAddress(userAddress); const [deposited_collateral, _current_collateral_estimation] = await Promise.all([ - _getUserCollateral(crvusd.constants.NETWORK_NAME, this.controller, userAddress, this.collateralDecimals), + _getUserCollateral(crvusd.constants.NETWORK_NAME, this.controller, userAddress), crvusd.contracts[this.address].contract.get_y_up(userAddress), ]); const current_collateral_estimation = crvusd.formatUnits(_current_collateral_estimation, this.collateralDecimals); From 6a9cccb3adcf8d4d23074e74c76640d12dd41e6c Mon Sep 17 00:00:00 2001 From: fedorovdg Date: Wed, 3 Jul 2024 19:35:16 +0400 Subject: [PATCH 2/2] build: v1.5.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e2d449..a9238bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/stablecoin-api", - "version": "1.5.3", + "version": "1.5.4", "description": "JavaScript library for Curve Stablecoin", "main": "lib/index.js", "author": "Macket",