diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png index 04b9fba73..40e8486b2 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png and b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png index 6fa29648d..7c3c27db6 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png index c3c0aeb8e..1ac8d9892 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_range/create/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/create/form.png index 3a0fbc87a..ba6ffdd2d 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/create/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/create/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_range/duplicate/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/duplicate/form.png index 14a1391d8..d2800be38 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/duplicate/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/duplicate/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_range/undercut/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/undercut/form.png index d3ad1c480..165cffdf8 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/undercut/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/undercut/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png b/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png index 73eedbe8e..b8e115da3 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png and b/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/overlapping/Overlapping/create/form.png b/e2e/screenshots/strategy/overlapping/Overlapping/create/form.png index 41de82356..197b894a2 100644 Binary files a/e2e/screenshots/strategy/overlapping/Overlapping/create/form.png and b/e2e/screenshots/strategy/overlapping/Overlapping/create/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/form.png index 37f7557e5..71253b06f 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/my-strategy.png index fd5fa417e..603f6e181 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png index c7a51c046..ef2ea9219 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/duplicate/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/duplicate/form.png index 5c5088093..e0e3e6786 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/duplicate/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/duplicate/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png index 53a57c4c0..b6b378e64 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png index 6220829c2..15553b7f1 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/duplicate/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/duplicate/form.png index ccba7dd4e..2c65e2a7d 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/duplicate/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/duplicate/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png index 4ef67a7aa..3b3dddfd8 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png index c681a82e2..845e614ed 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png index 0d38f6862..21b58136d 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/undercut/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/undercut/form.png index 63cd3b983..d63af7a3b 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/undercut/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/undercut/form.png differ diff --git a/src/pages/simulator/overlapping/index.tsx b/src/pages/simulator/overlapping/index.tsx index 005cba102..e2fac2106 100644 --- a/src/pages/simulator/overlapping/index.tsx +++ b/src/pages/simulator/overlapping/index.tsx @@ -1,4 +1,8 @@ -import { calculateOverlappingPrices } from '@bancor/carbon-sdk/strategy-management'; +import { + calculateOverlappingBuyBudget, + calculateOverlappingPrices, + calculateOverlappingSellBudget, +} from '@bancor/carbon-sdk/strategy-management'; import { useNavigate } from '@tanstack/react-router'; import { Button } from 'components/common/button'; import { CreateOverlappingStrategy } from 'components/simulator/input/overlapping/CreateOverlappingStrategy'; @@ -64,37 +68,60 @@ export const SimulatorInputOverlappingPage = () => { const submit = (e: FormEvent) => { e.preventDefault(); if (isPending || isError || noBudget) return; + if (!state.baseToken || !state.quoteToken) return; const start = state.start ?? defaultStart(); const end = state.end ?? defaultEnd(); + const search = { + baseToken: state.baseToken.address, + quoteToken: state.quoteToken.address, + buyMin: roundSearchParam(state.buy.min), + buyMax: roundSearchParam(state.buy.max), + buyBudget: roundSearchParam(state.buy.budget), + buyMarginal: '', + buyIsRange: true, + sellMin: roundSearchParam(state.sell.min), + sellMax: roundSearchParam(state.sell.max), + sellBudget: roundSearchParam(state.sell.budget), + sellMarginal: '', + sellIsRange: true, + start: start.toString(), + end: end.toString(), + type: 'overlapping' as const, + spread: state.spread, + }; + + if (search.buyBudget) { + search.sellBudget = calculateOverlappingSellBudget( + state.baseToken.decimals, + state.quoteToken.decimals, + state.buy.min, + state.sell.max, + marketPrice!.toString(), + state.spread, + search.buyBudget + ); + } else { + search.buyBudget = calculateOverlappingBuyBudget( + state.baseToken.decimals, + state.quoteToken.decimals, + state.buy.min, + state.sell.max, + marketPrice!.toString(), + state.spread, + search.sellBudget + ); + } + const { buyPriceMarginal, sellPriceMarginal } = calculateOverlappingPrices( formatNumber(state.buy.min), formatNumber(state.sell.max), marketPrice!.toString(), state.spread ); - - navigate({ - to: '/simulate/result', - search: { - baseToken: state.baseToken?.address || '', - quoteToken: state.quoteToken?.address || '', - buyMin: roundSearchParam(state.buy.min), - buyMax: roundSearchParam(state.buy.max), - buyBudget: roundSearchParam(state.buy.budget), - buyMarginal: roundSearchParam(buyPriceMarginal), - buyIsRange: true, - sellMin: roundSearchParam(state.sell.min), - sellMax: roundSearchParam(state.sell.max), - sellBudget: roundSearchParam(state.sell.budget), - sellMarginal: roundSearchParam(sellPriceMarginal), - sellIsRange: true, - start: start.toString(), - end: end.toString(), - type: 'overlapping', - spread: state.spread, - }, - }); + search.buyMarginal = buyPriceMarginal; + search.sellMarginal = sellPriceMarginal; + navigate({ to: '/simulate/result', search }); }; return (