Skip to content

Commit

Permalink
move position value to user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
torztomasz committed Oct 29, 2024
1 parent 530f4d1 commit 646e63f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
6 changes: 1 addition & 5 deletions packages/backend/src/api/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ export class UserController {
)
}
}
console.log(positionValues)

const assetEntries = userAssets.map((a) =>
toUserAssetEntry(
Expand All @@ -291,7 +290,7 @@ export class UserController {
assetDetailsMap
)
)
console.log(assetEntries)

const balanceChangesEntries = history.map((h) =>
toUserBalanceChangeEntries(h, assetDetailsMap)
)
Expand Down Expand Up @@ -470,9 +469,6 @@ export class UserController {
starkKey,
ethereumAddress: registeredUser?.ethAddress,
assets: hideAllAssets ? [] : assets, // When frozen and escaped, don't show assets
positionValue: postionValues?.positionValue
? postionValues.positionValue / 10000n
: undefined,
...pagination,
total: hideAllAssets ? 0 : userStatistics.assetCount,
})
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/preview/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ const routes: Route[] = [
context,
starkKey: StarkKey.fake(),
ethereumAddress: undefined,
positionValue: 123456n,
assets: repeat(visible, randomUserAssetEntry),
limit,
offset,
Expand Down
8 changes: 0 additions & 8 deletions packages/frontend/src/view/pages/user/UserAssetsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PageContext } from '@explorer/shared'
import { EthereumAddress, StarkKey } from '@explorer/types'
import React from 'react'

import { formatWithDecimals } from '../../../utils/formatting/formatAmount'
import { InfoBanner } from '../../components/InfoBanner'
import { ContentWrapper } from '../../components/page/ContentWrapper'
import { Page } from '../../components/page/Page'
Expand All @@ -16,7 +15,6 @@ interface UserAssetsPageProps {
context: PageContext
starkKey: StarkKey
ethereumAddress: EthereumAddress | undefined
positionValue: bigint | undefined
assets: UserAssetEntry[]
limit: number
offset: number
Expand Down Expand Up @@ -48,12 +46,6 @@ function UserAssetsPage(props: UserAssetsPageProps) {
total={props.total}
>
<InfoBanner className="mb-3 leading-tight">
{props.positionValue !== undefined
? `Estimated value of the position: ${formatWithDecimals(
props.positionValue,
2
)} USDC. `
: ''}
State of assets (proven on Ethereum) is updated every few hours.
</InfoBanner>
<UserAssetsTable
Expand Down
13 changes: 1 addition & 12 deletions packages/frontend/src/view/pages/user/UserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PageContext } from '@explorer/shared'
import { EthereumAddress, StarkKey } from '@explorer/types'
import React from 'react'

import { formatWithDecimals } from '../../../utils/formatting/formatAmount'
import { CountBadge } from '../../components/CountBadge'
import { InfoBanner } from '../../components/InfoBanner'
import { ContentWrapper } from '../../components/page/ContentWrapper'
Expand Down Expand Up @@ -111,6 +110,7 @@ function UserPage(props: UserPageProps) {
starkKey={props.starkKey}
chainId={props.context.chainId}
ethereumAddress={props.ethereumAddress}
positionValue={props.positionValue}
/>
<PerformUserActionsPanel
performUserActions={props.performUserActions}
Expand All @@ -137,17 +137,6 @@ function UserPage(props: UserPageProps) {
content: (
<>
<InfoBanner className="mb-3 leading-tight">
{props.positionValue !== undefined ? (
<span>
Estimated value of the position:{' '}
<strong className="text-lg">
{formatWithDecimals(props.positionValue, 2)} USDC
</strong>
.{' '}
</span>
) : (
''
)}
State of assets (proven on Ethereum) is updated every few
hours.
</InfoBanner>
Expand Down
28 changes: 26 additions & 2 deletions packages/frontend/src/view/pages/user/components/UserProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { UserDetails } from '@explorer/shared'
import { EthereumAddress, StarkKey } from '@explorer/types'
import { AssetId, EthereumAddress, StarkKey } from '@explorer/types'
import React from 'react'

import { assetToInfo } from '../../../../utils/assets'
import { formatWithDecimals } from '../../../../utils/formatting/formatAmount'
import { InfoIcon } from '../../../assets/icons/InfoIcon'
import { AssetWithLogo } from '../../../components/AssetWithLogo'
import { Button } from '../../../components/Button'
import { Card } from '../../../components/Card'
import { EtherscanLink } from '../../../components/EtherscanLink'
import { InfoBanner } from '../../../components/InfoBanner'
import { InlineEllipsis } from '../../../components/InlineEllipsis'
import { LongHash } from '../../../components/LongHash'
import { TooltipWrapper } from '../../../components/Tooltip'

interface UserProfileProps {
user: Partial<UserDetails> | undefined
starkKey: StarkKey
chainId: number
positionValue: bigint | undefined
ethereumAddress?: EthereumAddress
}

Expand All @@ -21,12 +27,13 @@ export function UserProfile({
starkKey,
chainId,
ethereumAddress,
positionValue,
}: UserProfileProps) {
const isMine = user?.starkKey === starkKey
return (
<Card>
<p className="mb-1.5 text-sm font-semibold text-zinc-500">Stark key</p>
<LongHash className="mt-3 font-semibold text-white" withCopy>
<LongHash className="font-semibold text-white" withCopy>
{starkKey.toString()}
</LongHash>
<p className="mb-1.5 mt-6 text-sm font-semibold text-zinc-500 ">
Expand Down Expand Up @@ -79,6 +86,23 @@ export function UserProfile({
)}
</>
)}
{positionValue ? (
<>
<p className="mb-1.5 mt-6 flex items-center gap-0.5 text-sm font-semibold text-zinc-500">
Estimated position value{' '}
<TooltipWrapper content="Exact value of the withdrawal will be calculated by the StarkEx smart contracts">
<InfoIcon className="scale-75" />
</TooltipWrapper>
</p>
<div className="flex items-center gap-2 font-semibold text-white">
{formatWithDecimals(positionValue, 2)}{' '}
<AssetWithLogo
assetInfo={assetToInfo({ hashOrId: AssetId('USDC-6') })}
type="small"
/>
</div>
</>
) : null}
</Card>
)
}

0 comments on commit 646e63f

Please sign in to comment.