From 9d51cfe072786bcddfc3c5e1d43fa0a57241e7de Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Mon, 9 Dec 2024 18:35:13 -0800 Subject: [PATCH] LP inspect fixes (#194) Fix data issues with LP inspect page and restore timeline layout. The rendering still needs to restore the asset icons but this can be done later. --- src/pages/inspect/ui/actions.tsx | 107 ++++++----- src/pages/inspect/ui/executions.tsx | 178 +++++++++++------- src/pages/inspect/ui/result.tsx | 10 +- src/pages/inspect/ui/volume.tsx | 2 +- .../api/server/position/timeline/state.ts | 4 +- 5 files changed, 171 insertions(+), 130 deletions(-) diff --git a/src/pages/inspect/ui/actions.tsx b/src/pages/inspect/ui/actions.tsx index f58a5b49..7831081f 100644 --- a/src/pages/inspect/ui/actions.tsx +++ b/src/pages/inspect/ui/actions.tsx @@ -10,7 +10,7 @@ import { useLpIdInUrl } from '@/pages/inspect/ui/result.tsx'; import { useLpPosition } from '@/pages/inspect/lp/api/position.ts'; import { Skeleton } from '@/shared/ui/skeleton.tsx'; -const PositionClosed = ({ +export const PositionClosed = ({ closingTx, closingTime, closingHeight, @@ -20,67 +20,78 @@ const PositionClosed = ({ closingTx?: string; }) => { return ( - -
-
- {closingTx && ( - - Tx: {closingTx} - - )} -
+
+
+ +
+
+ {closingTx && ( + + Tx: {closingTx} + + )} +
-
- -
+
+
+
+
+
+
- +
); }; -const PositionWithdraw = ({ withdrawal }: { withdrawal: PositionWithdrawal }) => { +export const PositionWithdraw = ({ withdrawal }: { withdrawal: PositionWithdrawal }) => { return ( - -
-
-
- - -
- - - Tx: {withdrawal.txHash} - -
+
+
+ +
+
+
+ + +
-
- -
+ + Tx: {withdrawal.txHash} + +
+
+
+
+
+
- +
); }; -const PositionOpen = ({ state }: { state: PositionStateResponse }) => { +export const PositionOpen = ({ state }: { state: PositionStateResponse }) => { return ( - -
-
-
- - -
- - - Tx: {state.openingTx} - -
+
+
+ +
+
+
+ + +
-
- -
+ + Tx: {state.openingTx} + +
+
+
+
+
+
- +
); }; diff --git a/src/pages/inspect/ui/executions.tsx b/src/pages/inspect/ui/executions.tsx index ec6b97da..d24ca5c2 100644 --- a/src/pages/inspect/ui/executions.tsx +++ b/src/pages/inspect/ui/executions.tsx @@ -1,4 +1,3 @@ -import { PositionExecutions } from '@/shared/api/server/position/timeline/types.ts'; import { Text } from '@penumbra-zone/ui/Text'; import { Card } from '@penumbra-zone/ui/Card'; import { Density } from '@penumbra-zone/ui/Density'; @@ -10,82 +9,114 @@ import { TimeDisplay } from '@/pages/inspect/ui/time.tsx'; import { useLpIdInUrl } from '@/pages/inspect/ui/result.tsx'; import { useLpPosition } from '@/pages/inspect/lp/api/position.ts'; import { Skeleton } from '@/shared/ui/skeleton.tsx'; +import { + PositionExecutions, + PositionStateResponse, + PositionWithdrawal, +} from '@/shared/api/server/position/timeline/types.ts'; +import { PositionWithdraw, PositionClosed, PositionOpen } from '@/pages/inspect/ui/actions.tsx'; -const DataBody = ({ executions }: { executions: PositionExecutions }) => { +interface ExecutionProps { + execution: PositionExecutions['items'][0]; +} + +const Execution = ({ execution: e }: ExecutionProps) => { + return ( +
+
+ +
+
+ + +
+
+
+ + + Trade Input + +
+
+ +
+
+ + + Trade Output + +
+
+ + + LP Fee + +
+
+
+
+ + Routing + + + + +
+
+ + New Reserves + +
+ + +
+
+
+
+
+
+
+
+ ); +}; + +const DataBody = ({ + state, + withdrawals, + executions, +}: { + state: PositionStateResponse; + withdrawals: PositionWithdrawal[]; + executions: PositionExecutions; +}) => { return (
+ {withdrawals.map((w, i) => ( + + ))} + {state.closingTime && state.closingHeight && ( + + )} {executions.items.length === 0 && ( - None + No executions )} {executions.items.map((e, i) => ( -
-
- -
-
- - -
-
-
- - - Trade Input - -
-
- -
-
- - - Trade Output - -
-
- - - LP Fee - -
-
-
-
- - Routing - - - - -
-
- - New Reserves - -
- - -
-
-
-
-
-
-
+
+
))} {executions.skipped > 0 && ( @@ -100,6 +131,7 @@ const DataBody = ({ executions }: { executions: PositionExecutions }) => {
)} +
); }; @@ -188,17 +220,19 @@ const LoadingState = () => { ); }; -export const Executions = () => { +export const Timeline = () => { const id = useLpIdInUrl(); const { data, isLoading } = useLpPosition(id); return (
- Executions + Position Timeline {isLoading && } - {data && } + {data && ( + + )}
); }; diff --git a/src/pages/inspect/ui/result.tsx b/src/pages/inspect/ui/result.tsx index e495a70b..3b8e2c04 100644 --- a/src/pages/inspect/ui/result.tsx +++ b/src/pages/inspect/ui/result.tsx @@ -5,9 +5,8 @@ import { Text } from '@penumbra-zone/ui/Text'; import { useLpPosition } from '@/pages/inspect/lp/api/position.ts'; import { StateDetails } from '@/pages/inspect/ui/state-details.tsx'; import { VolumeAndFeesTable } from '@/pages/inspect/ui/volume.tsx'; -import { Actions } from '@/pages/inspect/ui/actions.tsx'; import { DebugView } from '@/pages/inspect/ui/debug.tsx'; -import { Executions } from '@/pages/inspect/ui/executions.tsx'; +import { Timeline } from '@/pages/inspect/ui/executions.tsx'; const ErrorState = ({ error }: { error: unknown }) => { return {String(error)}; @@ -40,10 +39,7 @@ export const LpInspectResult = () => {
- -
-
- +
{/* DebugView only on larger screens */} @@ -55,7 +51,7 @@ export const LpInspectResult = () => { {/* Second Column */}
- +
diff --git a/src/pages/inspect/ui/volume.tsx b/src/pages/inspect/ui/volume.tsx index 8b93b7b7..b1b6abac 100644 --- a/src/pages/inspect/ui/volume.tsx +++ b/src/pages/inspect/ui/volume.tsx @@ -93,7 +93,7 @@ const DataBody = ({ v }: { v: VolumeAndFeesResponse }) => { - Total + Total (All Routes) {v.totals.executionCount} diff --git a/src/shared/api/server/position/timeline/state.ts b/src/shared/api/server/position/timeline/state.ts index 2f79d6e4..208d66c4 100644 --- a/src/shared/api/server/position/timeline/state.ts +++ b/src/shared/api/server/position/timeline/state.ts @@ -48,14 +48,14 @@ export const getPositionState = async (id: PositionId): Promise