@@ -2,9 +2,39 @@ import { notionClient } from './createNotionClient'
22import { PageObjectResponse } from '@notionhq/client/build/src/api-endpoints'
33import { postSlackMessage } from '../slack/postSlackMessage'
44import { OnRetryableFoundParams } from '../../core/types'
5+ import { ethers } from 'ethers'
6+ import { getTokenPrice } from '../slack/slackMessageFormattingUtils'
57
68const databaseId = process . env . RETRYABLE_MONITORING_NOTION_DB_ID !
79
10+ async function buildTokensDepositedDisplay ( metadata : any ) : Promise < string > {
11+ if (
12+ ! metadata ?. tokenAmountRaw ||
13+ metadata ?. tokenDecimals === undefined ||
14+ ! metadata ?. l1TokenAddress ||
15+ ! metadata ?. tokenSymbol
16+ ) {
17+ return metadata ?. tokensDeposited ?? '-'
18+ }
19+
20+ const amountStr = ethers . utils . formatUnits (
21+ metadata . tokenAmountRaw ,
22+ metadata . tokenDecimals
23+ )
24+ const amountNum = Number ( amountStr )
25+
26+ const price = await getTokenPrice (
27+ String ( metadata . l1TokenAddress ) . toLowerCase ( )
28+ )
29+
30+ if ( price !== undefined ) {
31+ const usd = ( amountNum * price ) . toFixed ( 2 )
32+ return `${ amountStr } ${ metadata . tokenSymbol } ($${ usd } ) (${ metadata . l1TokenAddress } )`
33+ }
34+
35+ return `${ amountStr } ${ metadata . tokenSymbol } (${ metadata . l1TokenAddress } )`
36+ }
37+
838export async function syncRetryableToNotion (
939 input : OnRetryableFoundParams
1040) : Promise < { id : string ; status : string ; isNew : boolean } | undefined > {
@@ -64,11 +94,12 @@ export async function syncRetryableToNotion(
6494 notionProps [ 'TotalRetryableDeposit' ] = {
6595 rich_text : [ { text : { content : metadata . l2CallValue } } ] ,
6696 }
67- if ( metadata . tokensDeposited ) {
68- notionProps [ 'TokensDeposited' ] = {
69- rich_text : [ { text : { content : metadata . tokensDeposited } } ] ,
70- }
97+
98+ const tokensDepositedDisplay = await buildTokensDepositedDisplay ( metadata )
99+ notionProps [ 'TokensDeposited' ] = {
100+ rich_text : [ { text : { content : tokensDepositedDisplay } } ] ,
71101 }
102+
72103 // support verbose column for bot redemption outcome if provided
73104 if ( metadata . botRedemptionStatus ) {
74105 notionProps [ 'Bot Redemption Status' ] = {
0 commit comments