Skip to content

Commit

Permalink
Show 'Escape' button even when no collateral asset
Browse files Browse the repository at this point in the history
  • Loading branch information
adamiak committed Nov 8, 2024
1 parent 5c971d8 commit 760d620
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions packages/backend/src/api/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,33 @@ export class UserController {
this.excludeL2TransactionTypes
)

// This is a workaround to show the collateral asset row
// at the top of the assets table when the exchange is frozen
// and user has other perpetual assets but no collateral asset.
// This is because that's where we show the 'Escape' button.
if (
context.tradingMode === 'perpetual' &&
context.freezeStatus === 'frozen' &&
collateralAsset !== undefined &&
!hideAllAssets &&
assetEntries.length > 0
) {
// As per logic before, collateral asset is always the first one
const topAsset = assetEntries[0]
if (topAsset && topAsset.asset.hashOrId !== collateralAsset.assetId) {
assetEntries.unshift({
asset: {
hashOrId: collateralAsset.assetId,
},
balance: 0n,
value: 0n,
vaultOrPositionId: topAsset.vaultOrPositionId,
fundingPayment: undefined,
action: 'ESCAPE',
})
}
}

const content = renderUserPage({
context,
starkKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function UserAssetsTable(props: UserAssetsTableProps) {
</span>
{props.tradingMode === 'perpetual' && (
<span className="mt-2 text-xxs text-zinc-500">
{entry.value
{entry.value !== undefined
? formatWithDecimals(entry.value, 2, { prefix: '$' })
: 'Unknown price'}
</span>
Expand Down

0 comments on commit 760d620

Please sign in to comment.