import { EXPLORERS } from '@components/settings/PreferredExplorerSettings' import FormatNumericValue from '@components/shared/FormatNumericValue' import Tooltip from '@components/shared/Tooltip' import PerpSideBadge from '@components/trade/PerpSideBadge' import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid' import { PublicKey } from '@solana/web3.js' import useLocalStorageState from 'hooks/useLocalStorageState' import useMangoAccount from 'hooks/useMangoAccount' import { useTranslation } from 'next-i18next' import Image from 'next/image' import { PerpTradeActivity } from 'types' import { PREFERRED_EXPLORER_KEY } from 'utils/constants' import { abbreviateAddress } from 'utils/formatting' import { getDecimalCount } from 'utils/numbers' import { formatFee } from './ActivityFeedTable' const PerpTradeDetails = ({ activity }: { activity: PerpTradeActivity }) => { const { t } = useTranslation(['common', 'activity', 'settings', 'trade']) const { mangoAccountAddress } = useMangoAccount() const [preferredExplorer] = useLocalStorageState( PREFERRED_EXPLORER_KEY, EXPLORERS[0] ) const { maker, maker_fee, perp_market_name, price, quantity, signature, taker, taker_fee, taker_side, } = activity.activity_details const isTaker = taker === mangoAccountAddress const side = isTaker ? taker_side : taker_side === 'bid' ? 'ask' : 'bid' const notional = quantity * price const fee = isTaker ? taker_fee * notional : maker_fee * notional const totalPrice = (notional + fee) / quantity const counterpartyPk = isTaker ? maker : taker return (

{t('trade:side')}

{t('trade:size')}

{quantity}{' '} {perp_market_name}

{t('activity:execution-price')}

{' '} USDC

{t('value')}

{t('fee')}

{formatFee(fee)} USDC

{isTaker ? t('trade:taker') : t('trade:maker')}

{t('activity:net-price')}

{' '} USDC

{t('activity:counterparty')}

{abbreviateAddress(new PublicKey(counterpartyPk))}

{t('transaction')}

{t(`settings:${preferredExplorer.name}`)}
) } export default PerpTradeDetails