Skip to content

Commit

Permalink
fix: userLoss
Browse files Browse the repository at this point in the history
  • Loading branch information
Macket committed Aug 26, 2023
1 parent c30e21e commit 8d8e666
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ export const _getPoolsFromApi = memoize(
)

export const _getUserCollateral = memoize(
async (network: INetworkName, collateral: string, user: string, collateralDecimals = 18): Promise<string> => {
console.log(network, collateral, user);
const url = `https://prices.curve.fi/v1/stablecoin/collateral/events/${network}/${collateral}/${user}`;
console.log(url);
async (network: INetworkName, controller: string, user: string, collateralDecimals = 18): Promise<string> => {
const url = `https://prices.curve.fi/v1/stablecoin/controller/events/${network}/${controller}/${user}`;
const response = await axios.get(url, { validateStatus: () => true });
console.log(response);
return crvusd.formatUnits(crvusd.parseUnits(response.data.total_collateral ?? "0.0", 0), collateralDecimals);
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/llammas/LlammaTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,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.collateral, userAddress, this.collateralDecimals),
_getUserCollateral(crvusd.constants.NETWORK_NAME, this.controller, userAddress, this.collateralDecimals),
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 8d8e666

Please sign in to comment.