11import { BigNumber } from '@ethersproject/bignumber'
22import { AmountInCurrency } from 'components/currency/AmountInCurrency'
3+ import { USDC_ADDRESSES } from 'juice-sdk-core'
4+ import { ETH_TOKEN_ADDRESS } from 'constants/juiceboxTokens'
35import { AnyEvent } from 'packages/v4v5/views/V4V5ProjectDashboard/V4V5ProjectTabs/V4V5ActivityPanel/utils/transformEventsData'
46import { formatActivityAmount } from 'utils/format/formatActivityAmount'
57
8+ // Build currency mapping from SDK constants
9+ // Maps token addresses (lowercase) to their symbols
10+ const CURRENCY_SYMBOLS : Record < string , string > = {
11+ // Add ETH token address
12+ [ ETH_TOKEN_ADDRESS . toLowerCase ( ) ] : 'ETH' ,
13+ // Add USDC addresses for all supported chains
14+ ...Object . values ( USDC_ADDRESSES ) . reduce ( ( acc , address ) => {
15+ acc [ address . toLowerCase ( ) ] = 'USDC'
16+ return acc
17+ } , { } as Record < string , string > ) ,
18+ }
19+
20+ /**
21+ * Get currency symbol from currency address (hex string)
22+ */
23+ function getCurrencySymbol ( currency ?: string | null ) : string {
24+ if ( ! currency ) return 'ETH'
25+ // Normalize to lowercase for lookup
26+ const symbol = CURRENCY_SYMBOLS [ currency . toLowerCase ( ) ]
27+ return symbol || 'ETH'
28+ }
29+
630/**
731 * Translate event data to protocol activity presenter with formatted amounts
832 */
933export function translateEventDataToProtocolPresenter ( event : AnyEvent ) {
34+ // Use projectToken (the actual token address) for currency symbol lookup
35+ const currencySymbol = getCurrencySymbol ( event . projectToken )
36+ // Use project decimals (e.g., 6 for USDC, 18 for ETH)
37+ const decimals = event . projectDecimals ?? 18
38+
1039 switch ( event . type ) {
1140 case 'payEvent' :
1241 return {
1342 event,
1443 header : 'Paid' ,
15- subject : `${ formatActivityAmount ( event . amount . value ) } ETH ` ,
44+ subject : `${ formatActivityAmount ( event . amount . value , decimals ) } ${ currencySymbol } ` ,
1645 }
1746 case 'addToBalanceEvent' :
1847 return {
1948 event,
2049 header : 'Added to balance' ,
21- subject : `${ formatActivityAmount ( event . amount . value ) } ETH ` ,
50+ subject : `${ formatActivityAmount ( event . amount . value , decimals ) } ${ currencySymbol } ` ,
2251 }
2352 case 'manualMintTokensEvent' :
2453 return {
@@ -30,7 +59,7 @@ export function translateEventDataToProtocolPresenter(event: AnyEvent) {
3059 return {
3160 event,
3261 header : 'Cashed out' ,
33- subject : `${ formatActivityAmount ( event . reclaimAmount . value ) } ETH ` ,
62+ subject : `${ formatActivityAmount ( event . reclaimAmount . value , decimals ) } ${ currencySymbol } ` ,
3463 }
3564 case 'deployedERC20Event' :
3665 return {
@@ -48,7 +77,7 @@ export function translateEventDataToProtocolPresenter(event: AnyEvent) {
4877 return {
4978 event,
5079 header : 'Send payouts' ,
51- subject : `${ formatActivityAmount ( event . amount . value ) } ETH ` ,
80+ subject : `${ formatActivityAmount ( event . amount . value , decimals ) } ${ currencySymbol } ` ,
5281 }
5382 case 'distributeReservedTokensEvent' :
5483 return {
@@ -66,13 +95,13 @@ export function translateEventDataToProtocolPresenter(event: AnyEvent) {
6695 return {
6796 event,
6897 header : 'Send to payout split' ,
69- subject : `${ formatActivityAmount ( event . amount . value ) } ETH ` ,
98+ subject : `${ formatActivityAmount ( event . amount . value , decimals ) } ${ currencySymbol } ` ,
7099 }
71100 case 'useAllowanceEvent' :
72101 return {
73102 event,
74103 header : 'Used allowance' ,
75- subject : `${ formatActivityAmount ( event . amount . value ) } ETH ` ,
104+ subject : `${ formatActivityAmount ( event . amount . value , decimals ) } ${ currencySymbol } ` ,
76105 }
77106 case 'manualBurnEvent' :
78107 return {
0 commit comments