From a157ff1e055affb864593797704179294f3be758 Mon Sep 17 00:00:00 2001 From: Witold Date: Wed, 6 Dec 2023 18:58:59 +0100 Subject: [PATCH] fix(trading): amend formula for max leverage calc (#5462) Co-authored-by: bwallacee --- apps/trading/e2e/tests/market/test_market.py | 5 ++--- apps/trading/e2e/tests/market/test_market_info.py | 8 ++++---- apps/trading/e2e/tests/market/test_market_selector.py | 4 ++-- .../src/lib/components/market-info/market-info-panels.tsx | 8 ++------ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/trading/e2e/tests/market/test_market.py b/apps/trading/e2e/tests/market/test_market.py index 72e4f7885..5d20e040c 100644 --- a/apps/trading/e2e/tests/market/test_market.py +++ b/apps/trading/e2e/tests/market/test_market.py @@ -31,7 +31,7 @@ initial_spread: float = 0.1 market_name = "BTC:DAI_2023" -@pytest.mark.usefixtures("vega", "page", "simple_market", "risk_accepted") +@pytest.mark.usefixtures("vega", "page", "simple_market", "risk_accepted", "auth") def test_price_monitoring(simple_market, vega: VegaService, page: Page): page.goto(f"/#/markets/all") expect(page.locator(table_row_selector).locator(trading_mode_col)).to_have_text( @@ -109,9 +109,8 @@ def test_price_monitoring(simple_market, vega: VegaService, page: Page): expect( page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value) ).to_have_text("100.00 (>100%)") - vega.forward("10s") - vega.wait_fn(1) + vega.wait_fn(10) vega.wait_for_total_catchup() expect( page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value) diff --git a/apps/trading/e2e/tests/market/test_market_info.py b/apps/trading/e2e/tests/market/test_market_info.py index 2dbe9c5e4..05cf1e229 100644 --- a/apps/trading/e2e/tests/market/test_market_info.py +++ b/apps/trading/e2e/tests/market/test_market_info.py @@ -197,10 +197,10 @@ def test_market_info_risk_factors(page: Page): fields = [ ["Long", "0.05153"], ["Short", "0.05422"], - ["Max Leverage Long", "19.036"], - ["Max Leverage Short", "18.111"], - ["Max Initial Leverage Long", "12.691"], - ["Max Initial Leverage Short", "12.074"], + ["Max Leverage Long", "19.406"], + ["Max Leverage Short", "18.445"], + ["Max Initial Leverage Long", "12.937"], + ["Max Initial Leverage Short", "12.297"], ] validate_info_section(page, fields) diff --git a/apps/trading/e2e/tests/market/test_market_selector.py b/apps/trading/e2e/tests/market/test_market_selector.py index 21602c2de..c0a1e878e 100644 --- a/apps/trading/e2e/tests/market/test_market_selector.py +++ b/apps/trading/e2e/tests/market/test_market_selector.py @@ -59,7 +59,7 @@ def test_market_selector_filter(continuous_market, page: Page): page.get_by_test_id("search-term").fill("btc") expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(1) expect(page.locator('[data-testid="market-selector-list"] a').nth(0)).to_have_text( - "BTC:DAI_2023107.50 tDAI0.00" + "BTC:DAI_2023107.50 tDAI1" ) page.get_by_test_id("search-term").clear() @@ -84,5 +84,5 @@ def test_market_selector_filter(continuous_market, page: Page): page.get_by_role("menuitemcheckbox").nth(0).get_by_text("tDAI").click() expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(1) expect(page.locator('[data-testid="market-selector-list"] a').nth(0)).to_have_text( - "BTC:DAI_2023107.50 tDAI0.00" + "BTC:DAI_2023107.50 tDAI1" ) diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.tsx index 15a2d9dfc..a62a57705 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.tsx @@ -632,13 +632,9 @@ export const RiskFactorsInfoPanel = ({ const { short, long } = market.riskFactors; - const maxLeverageLong = new BigNumber(1).dividedBy( - new BigNumber(market.linearSlippageFactor).plus(long) - ); + const maxLeverageLong = new BigNumber(1).dividedBy(long); - const maxLeverageShort = new BigNumber(1).dividedBy( - new BigNumber(market.linearSlippageFactor).plus(short) - ); + const maxLeverageShort = new BigNumber(1).dividedBy(short); const maxInitialLeverageLong = !market.tradableInstrument.marginCalculator ? undefined