Skip to content

Commit

Permalink
fix: hide twap status when we don’t know the state (#3993)
Browse files Browse the repository at this point in the history
TWAP orders are missing a backend service where we can ask for the
status. In reality to determine the current twap status we have to
iterrate through all twap parts and look at their individual statuses.
This is not a viable solution for twap orders with many parts,
so we’ve decided to not display the status until CoW comes up with a
backend service.
  • Loading branch information
compojoom authored Jul 25, 2024
1 parent bf02fe9 commit 48d1f1d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/features/swap/components/SwapOrder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type SwapOrderProps = {
txInfo?: Order
}

const TWAP_PARTS_STATUS_THRESHOLD = 10

const AmountRow = ({ order }: { order: Order }) => {
const { sellToken, buyToken, sellAmount, buyAmount, kind } = order
const isSellOrder = kind === 'sell'
Expand Down Expand Up @@ -217,9 +219,9 @@ export const TwapOrder = ({ order }: { order: SwapTwapOrder }) => {
const isPartiallyFilled = isOrderPartiallyFilled(order)
const expires = new Date(validUntil * 1000)
const now = new Date()

const orderKindLabel = capitalize(kind)

const isStatusKnown = Number(numberOfParts) <= TWAP_PARTS_STATUS_THRESHOLD
return (
<DataTable
header={`${orderKindLabel} order`}
Expand Down Expand Up @@ -256,9 +258,13 @@ export const TwapOrder = ({ order }: { order: SwapTwapOrder }) => {
{formatDateTime(validUntil * 1000)}
</DataRow>
),
<DataRow key="Status" title="Status">
<StatusLabel status={isPartiallyFilled ? 'partiallyFilled' : status} />
</DataRow>,
isStatusKnown ? (
<DataRow key="Status" title="Status">
<StatusLabel status={isPartiallyFilled ? 'partiallyFilled' : status} />
</DataRow>
) : (
<Fragment key="status" />
),
]}
/>
)
Expand Down

0 comments on commit 48d1f1d

Please sign in to comment.