Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix price inputs on sltp for <1 #788

Conversation

moo-onthelawn
Copy link
Contributor

@moo-onthelawn moo-onthelawn commented Jul 10, 2024

Goal:

  • Update price inputs so that typing '.' will auto update to '0.' instead of just '0' (which ultimately means you need to hit '.' twice to begin typing a decimal)

Non-Goal:

  • Update size input with the above fix - will follow up in separate task but lower prio and sort of messy with the slider

Fix:

  • Have a separate piece of state (triggerFormInputs) in state/inputs.ts to track the values to visually display vs the ones sent back to abacus (this is the same pattern as what we do for trade - see tradeInputs)
    • Minorly messy and annoying but the best solution we have at this point because we want to display the formattedValue but send back the floatValue

Note:

  • limit orders from the SL/TP dialog are not yet enabled, to test, I manually changed my local env.json isSlTpLimitOrdersEnabled to be true (but orders are not expected to successfully be made, just tested the input)
priceInputs.mov
limit.mov

Components

  • LimitPriceInputs
    • Update onLimitInput to additionally set triggerFormInputs
    • Update value to be shown to be read from triggerFormInputs instead of abacus
  • TriggerOrderInputs
    • Update input callbacks to additionally set triggerFormInputs
    • Update values to be shown to be read from triggerFormInputs instead of abacus
    • Add a useEffect hook to update the triggerFormInputs from autocalculated price/usdcDiff/percentDiffs from abacus

Constants/Types

  • constants/triggers.ts
    • Add new CLEARED_TRIGGER_ORDER_INPUTS and CLEARED_TRIGGER_LIMIT_INPUTS consts

Functions

  • lib/abacus/index.ts
    • Update clearTriggerOrdersInputValues to also support just clearing the limit fields, update to also clear the triggerFormInputs state

Hooks

  • hooks/useTriggerOrdersFormInputs
    • Update to also set triggerFormInputs when appropriate

State

  • state/inputs.ts

    • Add new piece of state for trigger form triggerFormInputs
    • Add setter for triggerFormInputs
  • state/inputsSelectors.ts

    • Add getter for triggerFormInputs

Copy link

linear bot commented Jul 10, 2024

Copy link

vercel bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 4:05pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 4:05pm

@moo-onthelawn moo-onthelawn merged commit f54fe60 into main Jul 12, 2024
7 checks passed
@moo-onthelawn moo-onthelawn deleted the mulan/ct-837-fix-input-to-be-more-intuitive-for-tokens-under-1 branch July 12, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants