Skip to content

Commit

Permalink
adjust temporary health_ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
djeck1432 committed Dec 4, 2024
1 parent 5bc25c2 commit b651661
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 0 additions & 3 deletions web_app/api/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ async def get_dashboard(wallet_id: str) -> DashboardResponse:
contract_address
)

# Fetch balances (assuming you have a method for this)
wallet_balances = await DashboardMixin.get_wallet_balances(wallet_id)
current_sum = await DashboardMixin.get_current_position_sum(first_opened_position)
start_sum = await DashboardMixin.get_start_position_sum(
first_opened_position["start_price"],
first_opened_position["amount"],
)
return DashboardResponse(
balances=wallet_balances,
health_ratio=health_ratio,
multipliers={"ETH": first_opened_position["multiplier"]},
start_dates={"ETH": first_opened_position["created_at"]},
Expand Down
12 changes: 5 additions & 7 deletions web_app/api/serializers/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ class DashboardResponse(BaseModel):
"""
DashboardResponse class for dashboard details.
"""
health_ratio: dict[str, str] = Field(
..., example={"health_factor": "2.0", "ltv": "0.5"}, description="The health ratio of the user."
)
balances: Dict[str, Any] = Field(
...,
example={"ETH": 5.0, "USDC": 1000.0},
description="The wallet balances for the user.",
# health_ratio: dict[str, str] = Field(
# ..., example={"health_factor": "2.0", "ltv": "0.5"}, description="The health ratio of the user."
# )
health_ratio: str = Field(
..., example="2.0", description="The health ratio of the user."
)
multipliers: Dict[str, int | None] = Field(
..., example={"ETH": 1.5}, description="The multipliers applied to each asset."
Expand Down
11 changes: 6 additions & 5 deletions web_app/contract_tools/mixins/health_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def _get_borrowed_token(
@classmethod
async def get_health_ratio(
cls, deposit_contract_address: str
) -> dict[str, str]:
) -> str:
"""
Calculate the health ratio of a deposit contract.
Expand All @@ -137,10 +137,11 @@ async def get_health_ratio(
* prices[borrowed_token]
/ 10 ** int(TokenParams.get_token_decimals(borrowed_address))
)
return {
"health_factor": f"{round(deposit_usdc / Decimal(debt_usdc), 2)}" if debt_usdc != 0 else "0",
"ltv": f"{round((debt_usdc / TokenParams.get_borrow_factor(borrowed_token)) / deposit_usdc, 2)}"
}
# return {
# "health_factor": f"{round(deposit_usdc / Decimal(debt_usdc), 2)}" if debt_usdc != 0 else "0",
# "ltv": f"{round((debt_usdc / TokenParams.get_borrow_factor(borrowed_token)) / deposit_usdc, 2)}"
# }
return f"{round(deposit_usdc / Decimal(debt_usdc), 2)}" if debt_usdc != 0 else "0"


if __name__ == "__main__":
Expand Down

0 comments on commit b651661

Please sign in to comment.