From 68e21cf1329214b0aa824dad1b8af145a3050168 Mon Sep 17 00:00:00 2001 From: 0xNineteen <0x39015319@gmail.com> Date: Tue, 15 Nov 2022 14:05:47 -0500 Subject: [PATCH] fix spot liab bug --- src/driftpy/clearing_house_user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driftpy/clearing_house_user.py b/src/driftpy/clearing_house_user.py index a36856ba..13ae9c0e 100644 --- a/src/driftpy/clearing_house_user.py +++ b/src/driftpy/clearing_house_user.py @@ -217,7 +217,7 @@ async def get_spot_market_liability( if worst_case_token_amount < 0: baa_value = get_spot_liability_value( - worst_case_token_amount, + abs(worst_case_token_amount), oracle_data, spot_market, margin_category, @@ -226,12 +226,12 @@ async def get_spot_market_liability( ) total_liability += baa_value - if worst_case_quote_amount > 0: + if worst_case_quote_amount < 0: weight = SPOT_WEIGHT_PRECISION if margin_category == MarginCategory.INITIAL: weight = max(weight, user.max_margin_ratio) weighted_value = ( - worst_case_quote_amount * weight / SPOT_WEIGHT_PRECISION + abs(worst_case_quote_amount) * weight / SPOT_WEIGHT_PRECISION ) total_liability += weighted_value