Skip to content

Commit

Permalink
Merge branch 'main' into 2024-09-16-query-sync-order-detail-trades
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyjosh authored Sep 18, 2024
2 parents 95392c2 + 4139db6 commit 023214b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
23 changes: 19 additions & 4 deletions tauri-app/src/lib/components/tables/OrderTradesListTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<TableHeadCell padding="p-0">Transaction Hash</TableHeadCell>
<TableHeadCell padding="p-0">Input</TableHeadCell>
<TableHeadCell padding="p-0">Output</TableHeadCell>
<TableHeadCell padding="p-0">IO Ratio</TableHeadCell>
<TableHeadCell padding="p-0">Input/Output Ratio</TableHeadCell>
<TableHeadCell padding="p-0">Output/Input Ratio</TableHeadCell>
<TableHeadCell padding="p-0"></TableHeadCell>
</svelte:fragment>

Expand Down Expand Up @@ -64,7 +65,7 @@
)}
{item.outputVaultBalanceChange.vault.token.symbol}
</TableBodyCell>
<TableBodyCell tdClass="break-all py-2" data-testid="io-ratio">
<TableBodyCell tdClass="break-all py-2" data-testid="input-output-ratio">
{Math.abs(
Number(
formatUnits(
Expand All @@ -79,8 +80,22 @@
),
),
)}
{item.inputVaultBalanceChange.vault.token.symbol}/{item.outputVaultBalanceChange.vault.token
.symbol}
</TableBodyCell>
<TableBodyCell tdClass="break-all py-2" data-testid="output-input-ratio">
{Math.abs(
Number(
formatUnits(
BigInt(item.outputVaultBalanceChange.amount),
Number(item.outputVaultBalanceChange.vault.token.decimals ?? 0),
),
) /
Number(
formatUnits(
BigInt(item.inputVaultBalanceChange.amount),
Number(item.inputVaultBalanceChange.vault.token.decimals ?? 0),
),
),
)}
</TableBodyCell>
<TableBodyCell tdClass="py-2">
<button
Expand Down
10 changes: 6 additions & 4 deletions tauri-app/src/lib/components/tables/OrderTradesListTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ test('renders table with correct data', async () => {
});

await waitFor(async () => {
// get all the io ratios
const rows = screen.getAllByTestId('io-ratio');
const inputOutputRatios = screen.getAllByTestId('input-output-ratio');
const outputInputRatios = screen.getAllByTestId('output-input-ratio');

// checking the io ratios
for (let i = 0; i < mockTakeOrdersList.length; i++) {
Expand All @@ -203,8 +203,10 @@ test('renders table with correct data', async () => {
BigInt(mockTakeOrdersList[i].outputVaultBalanceChange.amount),
Number(mockTakeOrdersList[i].outputVaultBalanceChange.vault.token.decimals),
);
const expectedRatio = Number(inputDisplay) / Number(outputDisplay);
expect(rows[i]).toHaveTextContent(expectedRatio.toString());
const expectedInputOutputRatio = Math.abs(Number(inputDisplay) / Number(outputDisplay));
const expectedOutputInputRatio = Math.abs(Number(outputDisplay) / Number(inputDisplay));
expect(inputOutputRatios[i]).toHaveTextContent(expectedInputOutputRatio.toString());
expect(outputInputRatios[i]).toHaveTextContent(expectedOutputInputRatio.toString());
}
});
});
Expand Down

0 comments on commit 023214b

Please sign in to comment.