@@ -41,7 +41,10 @@ import {
41
41
AuctionUpdatedEvent ,
42
42
} from '../fastTransfer/types' ;
43
43
import knex , { Knex } from 'knex' ;
44
- import { assertEnvironmentVariable } from '@wormhole-foundation/wormhole-monitor-common' ;
44
+ import {
45
+ assertEnvironmentVariable ,
46
+ parseWormholeSequenceFromLogs ,
47
+ } from '@wormhole-foundation/wormhole-monitor-common' ;
45
48
import { getLogger } from '../utils/logger' ;
46
49
import base58 from 'bs58' ;
47
50
import {
@@ -503,7 +506,8 @@ export class FTSolanaWatcher extends SolanaWatcher {
503
506
tx : VersionedTransactionResponse ,
504
507
payerAccount : PublicKey ,
505
508
auctionAccountPubkey : PublicKey ,
506
- fastVaaAccount : PublicKey
509
+ fastVaaAccount : PublicKey ,
510
+ fillVaaId : string
507
511
) : Promise < { id : FastTransferId ; info : FastTransferExecutionInfo } > {
508
512
const vaaAccount = await VaaAccount . fetch (
509
513
this . matchingEngineProgram . program . provider . connection ,
@@ -542,6 +546,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
542
546
execution_time : new Date ( tx . blockTime ! * 1000 ) ,
543
547
execution_tx_hash : tx . transaction . signatures [ 0 ] ,
544
548
execution_slot : BigInt ( tx . slot ) ,
549
+ fill_id : fillVaaId ,
545
550
} ,
546
551
} ;
547
552
}
@@ -556,14 +561,28 @@ export class FTSolanaWatcher extends SolanaWatcher {
556
561
throw new Error ( 'Insufficient account key indexes for parseExecuteFastOrderCctp' ) ;
557
562
}
558
563
const payerAccountPubkey = accountKeys [ accountKeyIndexes [ 0 ] ] ;
564
+ const custodianAccountPubkey = accountKeys [ accountKeyIndexes [ 3 ] ] ;
559
565
const fastVaaAccountPubkey = accountKeys [ accountKeyIndexes [ 4 ] ] ;
560
566
const auctionAccountPubkey = accountKeys [ accountKeyIndexes [ 5 ] ] ;
567
+ const seq = parseWormholeSequenceFromLogs ( res . meta ?. logMessages || [ ] ) ;
568
+
569
+ if ( ! seq ) {
570
+ throw new Error ( 'Cannot find fill sequnece' ) ;
571
+ }
572
+
573
+ // in `execute_fast_order_cctp` (see: https://github.com/wormhole-foundation/example-liquidity-layer/blob/63f2b423026ac1ad8b099bc3ecd44ba4fc64aae2/solana/programs/matching-engine/src/processor/auction/execute_fast_order/cctp.rs#L158)
574
+ // custodian is used as the emitter
575
+ const emitterInHex = custodianAccountPubkey . toBuffer ( ) . toString ( 'hex' ) ;
576
+
577
+ // matching engine only exists in Solana. This only checks for Solana matching engine anyways. So we can be sure that emitter chain is always 1
578
+ const fillVaaId = `1/${ emitterInHex } /${ seq } ` ;
561
579
562
580
const { id, info } = await this . computeExecutionData (
563
581
res ,
564
582
payerAccountPubkey ,
565
583
auctionAccountPubkey ,
566
- fastVaaAccountPubkey
584
+ fastVaaAccountPubkey ,
585
+ fillVaaId
567
586
) ;
568
587
569
588
await this . saveFastTransferInfo ( 'fast_transfer_executions' , info ) ;
@@ -583,18 +602,20 @@ export class FTSolanaWatcher extends SolanaWatcher {
583
602
) {
584
603
const accountKeys = res . transaction . message . getAccountKeys ( ) . staticAccountKeys ;
585
604
const accountKeyIndexes = instruction . accountKeyIndexes ;
586
- if ( accountKeyIndexes . length < 4 ) {
605
+ if ( accountKeyIndexes . length < 5 ) {
587
606
throw new Error ( 'Insufficient account key indexes for parseExecuteFastOrderLocal' ) ;
588
607
}
589
608
const payerAccountPubkey = accountKeys [ accountKeyIndexes [ 0 ] ] ;
590
609
const fastVaaAccountPubkey = accountKeys [ accountKeyIndexes [ 2 ] ] ;
591
610
const auctionAccountPubkey = accountKeys [ accountKeyIndexes [ 3 ] ] ;
611
+ const fastFillAccountPubkey = accountKeys [ accountKeyIndexes [ 4 ] ] ;
592
612
593
613
const { id, info } = await this . computeExecutionData (
594
614
res ,
595
615
payerAccountPubkey ,
596
616
auctionAccountPubkey ,
597
- fastVaaAccountPubkey
617
+ fastVaaAccountPubkey ,
618
+ fastFillAccountPubkey . toBase58 ( )
598
619
) ;
599
620
600
621
await this . saveFastTransferInfo ( 'fast_transfer_executions' , info ) ;
0 commit comments