-
Notifications
You must be signed in to change notification settings - Fork 101
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(swap): fix swap out of market #3576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { useSetAtom } from 'jotai' | ||
import { useCallback, useEffect, useMemo, useRef } from 'react' | ||
import { useCallback, useEffect, useRef } from 'react' | ||
|
||
import { priceOutOfRangeAnalytics } from '@cowprotocol/analytics' | ||
import { useTokensBalances } from '@cowprotocol/balances-and-allowances' | ||
|
@@ -44,9 +44,7 @@ export function UnfillableOrdersUpdater(): null { | |
const updatePendingOrderPrices = useSetAtom(updatePendingOrderPricesAtom) | ||
const isWindowVisible = useIsWindowVisible() | ||
|
||
const pendingLimit = useOnlyPendingOrders(chainId, UiOrderType.LIMIT) | ||
const pendingTwap = useOnlyPendingOrders(chainId, UiOrderType.TWAP) | ||
const pending = useMemo(() => pendingLimit.concat(pendingTwap), [pendingLimit, pendingTwap]) | ||
const pending = useOnlyPendingOrders(chainId) | ||
|
||
const setIsOrderUnfillable = useSetIsOrderUnfillable() | ||
const strategy = useGetGpPriceStrategy() | ||
|
@@ -225,6 +223,9 @@ async function _getOrderPrice( | |
|
||
const amount = getRemainderAmount(order.kind, order) | ||
|
||
// Don't quote if there's nothing left to match in this order | ||
if (amount === '0') return null | ||
Comment on lines
+226
to
+227
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bonus: fix for this issue I observed while testing. The order would match but still be in the pending list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, thanks |
||
|
||
if (order.kind === 'sell') { | ||
// this order sell amount is sellAmountAfterFees | ||
// this is an issue as it will be adjusted again in the backend | ||
|
@@ -262,6 +263,8 @@ async function _getOrderPrice( | |
receiver: order.receiver, | ||
isEthFlow, | ||
priceQuality: getPriceQuality({ verifyQuote }), | ||
appData: order.appData ?? undefined, | ||
appDataHash: order.appDataHash ?? undefined, | ||
Comment on lines
+266
to
+267
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bonus: pass the original appData so we can get more precise quotes. |
||
} | ||
try { | ||
return getBestQuote({ strategy, quoteParams, fetchFee: false, isPriceRefresh: false }) | ||
|
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.
We stopped checking for SWAPs since the preparation for TWAP.
This change checks for all order types once again, since we need the indication for all pending orders.