Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions app/components/UI/Perps/utils/transactionTransforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,69 @@ describe('transactionTransforms', () => {
expect(result).toHaveLength(0);
});

it('silently skips Spot Dust Conversion fills without console.error', () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation();
const errorSpy = jest.spyOn(console, 'error').mockImplementation();

const dustFill = {
...mockFill,
direction: 'Spot Dust Conversion',
};

const result = transformFillsToTransactions([dustFill]);

expect(result).toHaveLength(0);
expect(errorSpy).not.toHaveBeenCalled();
expect(warnSpy).not.toHaveBeenCalled();

warnSpy.mockRestore();
errorSpy.mockRestore();
});

it('emits console.warn for unknown fill directions instead of console.error', () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation();
const errorSpy = jest.spyOn(console, 'error').mockImplementation();

const unknownDirFill = {
...mockFill,
direction: 'TBD-NEW-HL-DIRECTION',
};

const result = transformFillsToTransactions([unknownDirFill]);

expect(result).toHaveLength(0);
expect(warnSpy).toHaveBeenCalledWith(
'Unhandled fill direction',
'TBD-NEW-HL-DIRECTION',
);
expect(errorSpy).not.toHaveBeenCalled();

warnSpy.mockRestore();
errorSpy.mockRestore();
});

it('emits console.warn for empty direction instead of console.error', () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation();
const errorSpy = jest.spyOn(console, 'error').mockImplementation();

const noDirectionFill = {
...mockFill,
direction: '',
};

const result = transformFillsToTransactions([noDirectionFill]);

expect(result).toHaveLength(0);
expect(warnSpy).toHaveBeenCalledWith(
'Unknown fill direction',
expect.objectContaining({ direction: '' }),
);
expect(errorSpy).not.toHaveBeenCalled();

warnSpy.mockRestore();
errorSpy.mockRestore();
});

// Integration test for split stop loss bug fix
it('aggregates split stop loss fills and shows combined PnL in transaction', () => {
// Bug scenario: Stop loss split into two fills with different order IDs
Expand Down
7 changes: 5 additions & 2 deletions app/components/UI/Perps/utils/transactionTransforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@ export function transformFillsToTransactions(
action = 'Flipped';
// Will be set based on calculation below
} else if (!direction) {
console.error('Unknown fill direction', fill);
console.warn('Unknown fill direction', fill);
return acc;
} else if (direction === 'Spot Dust Conversion') {
// HL housekeeping — auto-conversion of spot dust to USDC, not a perps trade
return acc;
} else {
console.error('Unknown action', fill);
console.warn('Unhandled fill direction', direction);
return acc;
}

Expand Down
Loading