@@ -54,8 +54,8 @@ export async function alarmFastTransfer(req: any, res: any) {
54
54
// This cloud function is scheduled to run every 30 minutes.
55
55
const alertOrders : DisplayRow [ ] = await getDelayedOrders ( ) ;
56
56
for ( const order of alertOrders ) {
57
- const formattedAmountIn = ( Number ( order . amountIn ) / 1_000_000 ) . toFixed ( 2 ) ;
58
- const formattedAmountOut = ( Number ( order . amountOut ) / 1_000_000 ) . toFixed ( 2 ) ;
57
+ const formattedAmountIn = formatBigInt ( order . amountIn ) ;
58
+ const formattedAmountOut = formatBigInt ( order . amountOut ) ;
59
59
alarmSlackInfo . msg =
60
60
`🚨 Delayed Order Alert!\n` +
61
61
`Source Chain: ${ order . sourceChain } \n` +
@@ -77,6 +77,11 @@ export async function alarmFastTransfer(req: any, res: any) {
77
77
return ;
78
78
}
79
79
80
+ const formatBigInt = ( amt : bigint ) => {
81
+ const str = ( amt / 10_000n ) . toString ( ) . padStart ( 3 , '0' ) ;
82
+ return str . substring ( 0 , str . length - 2 ) + '.' + str . substring ( str . length - 2 ) ;
83
+ } ;
84
+
80
85
async function getDelayedOrders ( ) : Promise < DisplayRow [ ] > {
81
86
console . log ( 'getDelayedOrders' ) ;
82
87
const result = await pg
@@ -112,11 +117,11 @@ async function getDelayedOrders(): Promise<DisplayRow[]> {
112
117
113
118
type DisplayRow = {
114
119
sourceChain : number ; // from fast_vaa_id
115
- sequence : BigInt ; // from fast_vaa_id
120
+ sequence : bigint ; // from fast_vaa_id
116
121
status : string ; // from MarketOrder
117
122
market_order_timestamp : Date ; // from MarketOrder
118
123
destinationChain : number ; // from MarketOrder
119
124
executionTime : number ; // execution_time - market_order_timestamp
120
- amountIn : BigInt ; // from MarketOrder
121
- amountOut : BigInt ; // from FastTransferExecutions
125
+ amountIn : bigint ; // from MarketOrder
126
+ amountOut : bigint ; // from FastTransferExecutions
122
127
} ;
0 commit comments