add swaps to activity feed
This commit is contained in:
parent
95a833fa02
commit
63e3d187b1
|
@ -30,6 +30,7 @@ import ActivityFeedTable from './ActivityFeedTable'
|
|||
interface Filters {
|
||||
deposit: boolean
|
||||
liquidate_token_with_token: boolean
|
||||
swap: boolean
|
||||
withdraw: boolean
|
||||
}
|
||||
|
||||
|
@ -44,6 +45,7 @@ interface AdvancedFilters {
|
|||
const DEFAULT_FILTERS = {
|
||||
deposit: true,
|
||||
liquidate_token_with_token: true,
|
||||
swap: true,
|
||||
withdraw: true,
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,12 @@ const DEFAULT_ADVANCED_FILTERS = {
|
|||
'usd-upper': '',
|
||||
}
|
||||
|
||||
const DEFAULT_PARAMS = ['deposit', 'liquidate_token_with_token', 'withdraw']
|
||||
const DEFAULT_PARAMS = [
|
||||
'deposit',
|
||||
'liquidate_token_with_token',
|
||||
'swap',
|
||||
'withdraw',
|
||||
]
|
||||
|
||||
const ActivityFeed = () => {
|
||||
const activityFeed = mangoStore((s) => s.activityFeed.feed)
|
||||
|
@ -282,7 +289,7 @@ const ActivityFilters = ({
|
|||
<div
|
||||
onClick={() => setShowMobileFilters(!showMobileFilters)}
|
||||
role="button"
|
||||
className={`default-transition w-full border-b border-th-bkg-3 bg-th-bkg-2 px-6 py-4 hover:bg-th-bkg-3`}
|
||||
className={`default-transition w-full border-b border-th-bkg-3 bg-th-bkg-2 p-4 hover:bg-th-bkg-3`}
|
||||
>
|
||||
<Disclosure.Button
|
||||
className={`flex h-full w-full items-center justify-between rounded-none`}
|
||||
|
@ -361,6 +368,14 @@ const ActivityTypeFiltersForm = ({
|
|||
<span className="text-sm">{t('withdrawals')}</span>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div className="flex h-8 flex-1 items-center lg:h-12 lg:border-l lg:border-th-bkg-4 lg:p-4">
|
||||
<Checkbox
|
||||
checked={filters.swap}
|
||||
onChange={(e) => updateFilters(e, 'swap')}
|
||||
>
|
||||
<span className="text-sm">{t('swaps')}</span>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div className="flex h-8 flex-1 items-center lg:h-12 lg:border-l lg:border-th-bkg-4 lg:p-4">
|
||||
<Checkbox
|
||||
checked={filters.liquidate_token_with_token}
|
||||
|
|
|
@ -86,6 +86,22 @@ const ActivityFeedTable = ({
|
|||
credit = { value: '0', symbol: '' }
|
||||
debit = { value: formatDecimal(quantity * -1), symbol }
|
||||
}
|
||||
if (activity_type === 'swap') {
|
||||
const {
|
||||
swap_in_amount,
|
||||
swap_in_symbol,
|
||||
swap_out_amount,
|
||||
swap_out_symbol,
|
||||
} = activity.activity_details
|
||||
credit = {
|
||||
value: formatDecimal(swap_out_amount),
|
||||
symbol: swap_out_symbol,
|
||||
}
|
||||
debit = {
|
||||
value: formatDecimal(swap_in_amount * -1),
|
||||
symbol: swap_in_symbol,
|
||||
}
|
||||
}
|
||||
return { credit, debit }
|
||||
}
|
||||
|
||||
|
@ -106,6 +122,18 @@ const ActivityFeedTable = ({
|
|||
value =
|
||||
activity_type === 'withdraw' ? usd_equivalent * -1 : usd_equivalent
|
||||
}
|
||||
if (activity_type === 'swap') {
|
||||
const {
|
||||
loan_origination_fee,
|
||||
swap_in_amount,
|
||||
swap_in_price_usd,
|
||||
swap_out_amount,
|
||||
swap_out_price_usd,
|
||||
} = activity.activity_details
|
||||
value =
|
||||
(swap_in_amount + loan_origination_fee) * swap_in_price_usd -
|
||||
swap_out_amount * swap_out_price_usd
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
|
@ -280,10 +308,11 @@ const MobileActivityFeedItem = ({
|
|||
const { activity_type, block_datetime } = activity
|
||||
const { signature } = activity.activity_details
|
||||
const isLiquidation = activity_type === 'liquidate_token_with_token'
|
||||
const isSwap = activity_type === 'swap'
|
||||
const activityName = isLiquidation ? 'liquidation' : activity_type
|
||||
const value = getValue(activity)
|
||||
return (
|
||||
<div key={signature} className="border-b border-th-bkg-3 px-6 py-4">
|
||||
<div key={signature} className="border-b border-th-bkg-3 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm text-th-fgd-1">
|
||||
|
@ -301,6 +330,28 @@ const MobileActivityFeedItem = ({
|
|||
<p className="text-right font-mono text-sm text-th-fgd-1">
|
||||
{isLiquidation ? (
|
||||
formatFixedDecimals(value, true)
|
||||
) : isSwap ? (
|
||||
<>
|
||||
<span className="mr-1">
|
||||
{activity.activity_details.swap_in_amount.toLocaleString(
|
||||
undefined,
|
||||
{ maximumFractionDigits: 6 }
|
||||
)}
|
||||
</span>
|
||||
<span className="font-body tracking-wide text-th-fgd-3">
|
||||
{activity.activity_details.swap_in_symbol}
|
||||
</span>
|
||||
<span className="mx-1 font-body text-th-fgd-3">for</span>
|
||||
<span className="mr-1">
|
||||
{activity.activity_details.swap_out_amount.toLocaleString(
|
||||
undefined,
|
||||
{ maximumFractionDigits: 6 }
|
||||
)}
|
||||
</span>
|
||||
<span className="font-body tracking-wide text-th-fgd-3">
|
||||
{activity.activity_details.swap_out_symbol}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="mr-1">
|
||||
|
|
|
@ -32,7 +32,7 @@ const SwapHistoryTable = ({
|
|||
swapHistory,
|
||||
loading,
|
||||
}: {
|
||||
swapHistory: Array<SwapHistoryItem>
|
||||
swapHistory: SwapHistoryItem[]
|
||||
loading: boolean
|
||||
}) => {
|
||||
const { t } = useTranslation(['common', 'settings', 'swap'])
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
"liquidation-details": "Liquidation Details",
|
||||
"reset-filters": "Reset Filters",
|
||||
"select-tokens": "Select Tokens",
|
||||
"swap": "Swap",
|
||||
"swaps": "Swaps",
|
||||
"update": "Update",
|
||||
"value-from": "Value From",
|
||||
"value-to": "Value To",
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
"liquidation-details": "Liquidation Details",
|
||||
"reset-filters": "Reset Filters",
|
||||
"select-tokens": "Select Tokens",
|
||||
"swap": "Swap",
|
||||
"swaps": "Swaps",
|
||||
"update": "Update",
|
||||
"value-from": "Value From",
|
||||
"value-to": "Value To",
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
"liquidation-details": "Liquidation Details",
|
||||
"reset-filters": "Reset Filters",
|
||||
"select-tokens": "Select Tokens",
|
||||
"swap": "Swap",
|
||||
"swaps": "Swaps",
|
||||
"update": "Update",
|
||||
"value-from": "Value From",
|
||||
"value-to": "Value To",
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
"liquidation-details": "Liquidation Details",
|
||||
"reset-filters": "Reset Filters",
|
||||
"select-tokens": "Select Tokens",
|
||||
"swap": "Swap",
|
||||
"swaps": "Swaps",
|
||||
"update": "Update",
|
||||
"value-from": "Value From",
|
||||
"value-to": "Value To",
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
"liquidation-details": "Liquidation Details",
|
||||
"reset-filters": "Reset Filters",
|
||||
"select-tokens": "Select Tokens",
|
||||
"swap": "Swap",
|
||||
"swaps": "Swaps",
|
||||
"update": "Update",
|
||||
"value-from": "Value From",
|
||||
"value-to": "Value To",
|
||||
|
|
Loading…
Reference in New Issue