diff --git a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png index 8629403e5..2c5f8765c 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_limit_range/form.png b/e2e/screenshots/simulator/recurring/Recurring_limit_range/form.png index 54cbc496d..7f5c84d65 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_limit_range/form.png and b/e2e/screenshots/simulator/recurring/Recurring_limit_range/form.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png index aab57abc6..66444396e 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-input-price.png index 5d55a6e28..6a056ab1a 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-input-price.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 7ffcff6d3..252ed4714 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 c3e5a1330..85642eee9 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_limit/duplicate/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/duplicate/form.png index 4a60aa919..a5e8bcbe5 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/duplicate/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/duplicate/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/editPrices/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/editPrices/form.png index 97997da3e..42e681bf0 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/editPrices/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/editPrices/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 07e5114f1..9a4afe41f 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/deposit/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png index dd94bb0de..1a87002b9 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_range/editPrices/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/editPrices/form.png index be34152f2..3a2f1384c 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/editPrices/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_sell_limit/editPrices/form.png b/e2e/screenshots/strategy/disposable/Disposable_sell_limit/editPrices/form.png index 7e75b0e13..3f9f36c17 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_sell_limit/editPrices/form.png and b/e2e/screenshots/strategy/disposable/Disposable_sell_limit/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_sell_range/editPrices/form.png b/e2e/screenshots/strategy/disposable/Disposable_sell_range/editPrices/form.png index 28d48f33d..f37458af8 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_sell_range/editPrices/form.png and b/e2e/screenshots/strategy/disposable/Disposable_sell_range/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/overlapping/Overlapping/editPrices/form.png b/e2e/screenshots/strategy/overlapping/Overlapping/editPrices/form.png index 79e1d251d..e7f300675 100644 Binary files a/e2e/screenshots/strategy/overlapping/Overlapping/editPrices/form.png and b/e2e/screenshots/strategy/overlapping/Overlapping/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/editPrices/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/editPrices/form.png index 698854055..35417251b 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/editPrices/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/renew/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/renew/form.png index 7e443937a..a7335b278 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/renew/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/renew/form.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 472c8d886..1be058dc7 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/editPrices/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/editPrices/form.png index 89fee7517..5117d40b1 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/editPrices/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/renew/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/renew/form.png index ca9f445e6..cb0af50da 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/renew/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/renew/form.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 726e121ba..a49c517b5 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_limit/editPrices/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/editPrices/form.png index 8e885dbe6..63eee871a 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/editPrices/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/renew/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/renew/form.png index eaec685b7..c75e01d4d 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/renew/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/renew/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png index 3dafce6ae..8e37ce347 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/editPrices/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/editPrices/form.png index 1b91c8d52..50fcbfdea 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/editPrices/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/editPrices/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/renew/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/renew/form.png index 598c002e1..9b8d1e9f7 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/renew/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/renew/form.png differ diff --git a/src/components/common/TokenInputField/TokenInputField.tsx b/src/components/common/TokenInputField/TokenInputField.tsx index 7e189b87a..d9f16733d 100644 --- a/src/components/common/TokenInputField/TokenInputField.tsx +++ b/src/components/common/TokenInputField/TokenInputField.tsx @@ -126,7 +126,12 @@ export const TokenInputField: FC = (props) => { {slippage && value && }

{user && !withoutWallet && isBalanceLoading && ( - )} diff --git a/src/components/strategies/common/BudgetDistribution.tsx b/src/components/strategies/common/BudgetDistribution.tsx index 92e78e04d..713af99df 100644 --- a/src/components/strategies/common/BudgetDistribution.tsx +++ b/src/components/strategies/common/BudgetDistribution.tsx @@ -13,7 +13,7 @@ interface Props { initialBudget: string; withdraw: string; deposit: string; - balance: string; + balance?: string; isSimulator?: boolean; } @@ -70,7 +70,7 @@ export const BudgetDistribution: FC = (props) => { Number(initialBudget), Number(withdraw), Number(deposit), - Number(balance), + Number(balance ?? '0'), isSimulator ); const color = buy ? 'bg-buy' : 'bg-sell'; @@ -81,16 +81,20 @@ export const BudgetDistribution: FC = (props) => {
{!isSimulator && ( )}
diff --git a/src/components/strategies/create/CreateOverlappingBudget.tsx b/src/components/strategies/create/CreateOverlappingBudget.tsx index 3d6558913..5e662cd17 100644 --- a/src/components/strategies/create/CreateOverlappingBudget.tsx +++ b/src/components/strategies/create/CreateOverlappingBudget.tsx @@ -103,7 +103,7 @@ export const CreateOverlappingBudget: FC = (props) => { initialBudget="0" withdraw="0" deposit={budgetError ? '0' : order1.budget} - balance={baseBalance || '0'} + balance={baseBalance} isSimulator={!user} /> {!!user && ( @@ -121,7 +121,7 @@ export const CreateOverlappingBudget: FC = (props) => { initialBudget="0" withdraw="0" deposit={budgetError ? '0' : order0.budget} - balance={quoteBalance || '0'} + balance={quoteBalance} isSimulator={!user} buy /> diff --git a/src/components/strategies/edit/EditBudgetFields.tsx b/src/components/strategies/edit/EditBudgetFields.tsx index fcbb4c9f2..4edbbc099 100644 --- a/src/components/strategies/edit/EditBudgetFields.tsx +++ b/src/components/strategies/edit/EditBudgetFields.tsx @@ -87,7 +87,10 @@ export const EditStrategyBudgetField: FC = ({ {order.min !== order.max && !isZero(budget) && ( - + )} = (props) => { initialBudget={initialSellBudget} withdraw={budgetError ? '0' : withdrawSellBudget} deposit={budgetError ? '0' : depositSellBudget} - balance={baseBalance ?? '0'} + balance={baseBalance} /> = (props) => { initialBudget={initialBuyBudget} withdraw={budgetError ? '0' : withdrawBuyBudget} deposit={budgetError ? '0' : depositBuyBudget} - balance={quoteBalance ?? '0'} + balance={quoteBalance} buy /> = (props) => { initialBudget={initialSellBudget} withdraw={budgetError ? '0' : withdrawSellBudget} deposit={budgetError ? '0' : depositSellBudget} - balance={baseBalance ?? '0'} + balance={baseBalance} /> = (props) => { initialBudget={initialBuyBudget} withdraw={budgetError ? '0' : withdrawBuyBudget} deposit={budgetError ? '0' : depositBuyBudget} - balance={quoteBalance ?? '0'} + balance={quoteBalance} buy /> ) => void; settings?: ReactNode; warnings?: (string | undefined)[]; @@ -27,8 +31,9 @@ interface Props { export const EditStrategyPriceField: FC = ({ order, - initialBudget, + initialOrder, budget, + hasPriceChanged, setOrder, buy = false, settings, @@ -39,7 +44,7 @@ export const EditStrategyPriceField: FC = ({ const { base, quote } = strategy; const token = buy ? quote : base; const balance = useGetTokenBalance(token); - + const initialBudget = initialOrder.balance; const titleId = useId(); const tooltipText = `This section will define the order details in which you are willing to ${ buy ? 'buy' : 'sell' @@ -68,20 +73,36 @@ export const EditStrategyPriceField: FC = ({ ); const setPrice = (price: string) => setOrder({ min: price, max: price }); - const setMin = (min: string) => setOrder({ min }); - const setMax = (max: string) => setOrder({ max }); + const setMin = (min: string) => setOrder({ min, marginalPrice: undefined }); + const setMax = (max: string) => setOrder({ max, marginalPrice: undefined }); const setBudget = (budget: string) => setOrder({ budget }); + const setMarginalPrice = (marginalPrice: string) => { + setOrder({ marginalPrice }); + }; const setAction = (action: 'deposit' | 'withdraw') => { - setOrder({ action, budget: undefined }); + setOrder({ action, budget: undefined, marginalPrice: undefined }); }; const setSettings = (settings: StrategySettings) => { setOrder({ settings, min: undefined, max: undefined, + marginalPrice: undefined, }); }; + const showDistribution = (() => { + if (hasPriceChanged) return false; + if (order.min === order.max) return false; + if (isZero(budget)) return false; + if (isZero(initialBudget)) return false; + if (new SafeDecimal(order.budget).lte(0)) return false; + if (!balance.data || new SafeDecimal(budget).gt(balance.data)) return false; + if (buy && initialOrder.marginalRate === order.max) return false; + if (!buy && initialOrder.marginalRate === order.min) return false; + return true; + })(); + const headerProps = { titleId, order, base, buy, setSettings }; return ( @@ -144,13 +165,25 @@ export const EditStrategyPriceField: FC = ({ setBudget={setBudget} buyBudget={strategy.order0.balance} sellBudget={strategy.order1.balance} - /> + > + {showDistribution && ( +
+ +
+ )} + , to: '/strategies/edit/$strategyId/prices/disposable', text: 'Buy or sell at a specific price, or gradually scale in or out of a position.', id: 'disposable', }, { label: 'Recurring', - svg: , to: '/strategies/edit/$strategyId/prices/recurring', text: 'Create an automated trading cycle of buy low/sell high with two separate orders.', id: 'recurring', }, { label: 'Concentrated', - svg: , to: '/strategies/edit/$strategyId/prices/overlapping', text: 'Buy and sell within custom parameters with custom fee tier and auto-compounding fees.', id: 'overlapping', @@ -54,7 +48,7 @@ export const EditPriceNav = ({ editType }: { editType: EditTypes }) => {