Skip to content

Commit

Permalink
Merge pull request #23 from curvefi/fix/fixed-userLoss-api
Browse files Browse the repository at this point in the history
fix: fixed userLoss api response handle
  • Loading branch information
fedorovdg authored Jul 3, 2024
2 parents 00c7734 + 6a9cccb commit b038311
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const _getPoolsFromApi = memoize(
)

export const _getUserCollateral = memoize(
async (network: INetworkName, controller: string, user: string, collateralDecimals = 18): Promise<string> => {
async (network: INetworkName, controller: string, user: string): Promise<string> => {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/llammas/LlammaTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b038311

Please sign in to comment.