Skip to content

Commit

Permalink
(limit-orders) Limit Orders status fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lilchizh committed Nov 1, 2023
1 parent 3ec6b10 commit 9dece22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/components/common/Table/limitOrderColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface Ticks {
isClosed: boolean;
killed: boolean;
isFilled: boolean;
zeroToOne: boolean;
}

interface Amount {
Expand Down Expand Up @@ -87,15 +88,16 @@ const LimitOrderStatus = ({ ticks }: { ticks: Ticks }) => {
<span>Completed</span>
</div>

if (!ticks.isFilled && (ticks.tickCurrent > ticks.tickUpper || ticks.tickCurrent < ticks.tickLower )) return <div className="text-left">0%</div>
const progress = (100 * (ticks.tickCurrent - ticks.tickLower) / (ticks.tickUpper - ticks.tickLower))

if (ticks.tickCurrent > 0 && ticks.tickLower < 0 || ticks.tickCurrent < 0 && ticks.tickLower > 0) return <div className="text-left">0%</div>

if (ticks.tickCurrent < ticks.tickLower) return <div className="text-left">0%</div>
if (ticks.zeroToOne ? (progress < 0) : (progress > 0) ) return <div className="text-left">0%</div>

const progress = (100 * (ticks.tickCurrent - ticks.tickLower) / (ticks.tickUpper - ticks.tickLower)).toFixed(1)
if (ticks.zeroToOne ? (progress >= 100) : (progress <= -100) ) return <div className="flex items-center gap-4 text-left">
<CheckCircle2Icon className={'text-green-500'} />
<span>Completed</span>
</div>

return <div className="text-left">{`${progress}%`}</div>
return <div className="text-left">{`${progress.toFixed(1)}%`}</div>

}

Expand Down
6 changes: 4 additions & 2 deletions src/components/limit-orders/LimitOrdersList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const LimitOrdersList = () => {
client: limitOrderClient,
variables: {
account
}
},
pollInterval: 10_000
})

const { data: poolForLimitOrders } = useMultiplePoolsQuery({
Expand Down Expand Up @@ -86,7 +87,8 @@ const LimitOrdersList = () => {
tickCurrent: pool.tickCurrent,
isClosed,
killed,
isFilled: epoch.filled
isFilled: epoch.filled,
zeroToOne
},
rates: {
buy: {
Expand Down

0 comments on commit 9dece22

Please sign in to comment.