Skip to content

Commit

Permalink
Fix escapable amount formatting for perpetual exchange (#511)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomasz Tórz <[email protected]>
  • Loading branch information
adamiak and torztomasz authored Sep 5, 2024
1 parent 746b056 commit f0f06b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/backend/src/api/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ export class UserController {
escapableAssets: toEscapableBalanceEntries(
escapableMap,
context,
assetDetailsMap
assetDetailsMap,
collateralAsset
),
withdrawableAssets: withdrawableAssets.map((asset) =>
toWithdrawableAssetEntry(
Expand Down Expand Up @@ -651,13 +652,17 @@ function toWithdrawableAssetEntry(
function toEscapableBalanceEntries(
escapableMap: EscapableMap,
context: PageContext,
assetDetailsMap?: AssetDetailsMap
assetDetailsMap?: AssetDetailsMap,
collateralAsset?: CollateralAsset
): EscapableAssetEntry[] {
return Object.entries(escapableMap)
.filter(([_, value]) => value.amount > 0)
.map(([positionOrVaultIdStr, value]) => ({
asset: {
hashOrId: value.assetHash,
hashOrId:
collateralAsset?.assetHash === value.assetHash
? collateralAsset.assetId
: value.assetHash,
details:
context.tradingMode === 'perpetual'
? getCollateralAssetDetails(context.collateralAsset)
Expand Down

0 comments on commit f0f06b5

Please sign in to comment.