-
Notifications
You must be signed in to change notification settings - Fork 102
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
refactor: quote for LIMIT and TWAP widgets #2544
Conversation
1. Raw state it's what stored into localStorage 2. Full state it's just enriched raw state: token address => Currency
* feat: refactor twap orders code * feat: some small updates * fix: pr comments 1 * fix: pr comments 2
…e-updates feat(twap-orders): twap orders deadline updates (8)
…isplay feat(twap-orders): add parts display to TWAP orders (7)
feat(twap-orders) add quote fetching loading indicator (6)
feat(twap-orders) Add quote fetching part 1 (5)
feat(twap-orders): update no. of parts error and responsivnes (4)
feat(twap-orders): Slippage (3)
Hey @nenadV91 , I did not test the quotes on the TWAP form as I don't know how they should work 'normally'. I have run tests for the Limit orders page.
|
Hey @elena-zh , thank you for review |
fix: use tradeQuote module for all services in Limit orders
@elena-zh Additional
|
f8dbe4a
to
71bf32a
Compare
Reviewed code and tested the behavior. I see that all Elena's issues are fixed. |
import { useUpdateCurrencyAmount } from 'modules/trade/hooks/useUpdateCurrencyAmount' | ||
|
||
export function QuoteObserverUpdater() { | ||
const { state } = useDerivedTradeState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im a bit confused about how this works.
- I can see
QuoteObserverUpdater
is a twap updater (in the TWAP module) - depends on
useDerivedTradeState
to get the state --> the buy amount (in the TRADE module) - on changes, it will update it, but it will do it using
useUpdateCurrencyAmount
(in the TRADE module)
My thinking is, the trade
module exports the state, and a method to update it, and it expects other modules to watch changes on it and call the update method 🧐
Seems a bit strange dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my thinking was this:
-
we have one quote updater in the whole app called
TradeQuoteUpdater
and it will be called inside ofTradeWidget
which is then being used for LIMIT, TWAP and later on SWAP. This quote updater will be responsible for updating the quote state, and this state will of course be used by all those 3 different order types. -
now the second part is, those observers. Their responsibility is to perform some actions when quote update happens. But, different order types, need to perform different actions when quote is changed. For example, the LIMIT order quote observer will update the rate state, that exist only in LIMIT orders, and then based on the rate state changes we update the INPUT/OUTPUT field values. And TWAP order quote observer will just update output currency.
-
useUpdateCurrencyAmount
is exported from trade module, since it will update the shared trade state, and we will use this in TWAP, LIMIT etc.. -
So to summarise, the idea is that we have these observers for each order type, since they perform different actions on quote update, and the quote state is shared. Not sure if I missed the point, but I hope this clarifies things a bit.
Additional cases reported in #2555 (comment) are not fixed:
A new issue is that an error message is not removed from the form when update an amount/token pair/etc. And a price quote is displayed for an empty form when change a network: |
Summary
Fixes #2416
Refactor quote for advanced orders
TradeQuoteUpdater
inTradeWidget
QuoteObserverUpdater
to Limit and Twap order widgets to observe changes in quote and do appropriate actions when the quote is changed.To test