Skip to content

Commit 34210b5

Browse files
authored
Show 'Escape' button even when no collateral asset (#534)
1 parent 5c971d8 commit 34210b5

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/backend/src/api/controllers/UserController.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,33 @@ export class UserController {
318318
this.excludeL2TransactionTypes
319319
)
320320

321+
// This is a workaround to show the collateral asset row
322+
// at the top of the assets table when the exchange is frozen
323+
// and user has other perpetual assets but no collateral asset.
324+
// This is because that's where we show the 'Escape' button.
325+
if (
326+
context.tradingMode === 'perpetual' &&
327+
context.freezeStatus === 'frozen' &&
328+
collateralAsset !== undefined &&
329+
!hideAllAssets &&
330+
assetEntries.length > 0
331+
) {
332+
// As per logic before, collateral asset is always the first one
333+
const topAsset = assetEntries[0]
334+
if (topAsset && topAsset.asset.hashOrId !== collateralAsset.assetId) {
335+
assetEntries.unshift({
336+
asset: {
337+
hashOrId: collateralAsset.assetId,
338+
},
339+
balance: 0n,
340+
value: 0n,
341+
vaultOrPositionId: topAsset.vaultOrPositionId,
342+
fundingPayment: undefined,
343+
action: 'ESCAPE',
344+
})
345+
}
346+
}
347+
321348
const content = renderUserPage({
322349
context,
323350
starkKey,

packages/frontend/src/view/pages/user/components/UserAssetTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function UserAssetsTable(props: UserAssetsTableProps) {
6666
</span>
6767
{props.tradingMode === 'perpetual' && (
6868
<span className="mt-2 text-xxs text-zinc-500">
69-
{entry.value
69+
{entry.value !== undefined
7070
? formatWithDecimals(entry.value, 2, { prefix: '$' })
7171
: 'Unknown price'}
7272
</span>

0 commit comments

Comments
 (0)