Skip to content

Commit b038311

Browse files
authored
Merge pull request #23 from curvefi/fix/fixed-userLoss-api
fix: fixed userLoss api response handle
2 parents 00c7734 + 6a9cccb commit b038311

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@curvefi/stablecoin-api",
3-
"version": "1.5.3",
3+
"version": "1.5.4",
44
"description": "JavaScript library for Curve Stablecoin",
55
"main": "lib/index.js",
66
"author": "Macket",

src/external-api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export const _getPoolsFromApi = memoize(
1616
)
1717

1818
export const _getUserCollateral = memoize(
19-
async (network: INetworkName, controller: string, user: string, collateralDecimals = 18): Promise<string> => {
19+
async (network: INetworkName, controller: string, user: string): Promise<string> => {
2020
const url = `https://prices.curve.fi/v1/crvusd/collateral_events/${network}/${controller}/${user}`;
2121
const response = await axios.get(url, { validateStatus: () => true });
22-
return crvusd.formatUnits(crvusd.parseUnits(response.data.total_collateral ?? "0.0", 0), collateralDecimals);
22+
return response.data.total_deposit;
2323
},
2424
{
2525
promise: true,

src/llammas/LlammaTemplate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ export class LlammaTemplate {
466466
public async userLoss(userAddress = ""): Promise<{ deposited_collateral: string, current_collateral_estimation: string, loss: string, loss_pct: string }> {
467467
userAddress = _getAddress(userAddress);
468468
const [deposited_collateral, _current_collateral_estimation] = await Promise.all([
469-
_getUserCollateral(crvusd.constants.NETWORK_NAME, this.controller, userAddress, this.collateralDecimals),
469+
_getUserCollateral(crvusd.constants.NETWORK_NAME, this.controller, userAddress),
470470
crvusd.contracts[this.address].contract.get_y_up(userAddress),
471471
]);
472472
const current_collateral_estimation = crvusd.formatUnits(_current_collateral_estimation, this.collateralDecimals);

0 commit comments

Comments
 (0)