@@ -108,16 +108,13 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
108
108
) {
109
109
const ownerOrAssistant = new SolanaAddress ( sender ) . unwrap ( ) ;
110
110
const mintRecipient = tokenAccount
111
- ? new SolanaAddress ( tokenAccount ) . toUniversalAddress ( ) . toUint8Array ( )
111
+ ? Array . from ( new SolanaAddress ( tokenAccount ) . toUniversalAddress ( ) . toUint8Array ( ) )
112
112
: null ;
113
+ const address = Array . from ( router . toUniversalAddress ( ) . toUint8Array ( ) ) ;
114
+
113
115
const ix = await this . addCctpRouterEndpointIx (
114
116
{ ownerOrAssistant } ,
115
- {
116
- chain : toChainId ( chain ) ,
117
- cctpDomain : cctpDomain ,
118
- address : Array . from ( router . toUniversalAddress ( ) . toUint8Array ( ) ) ,
119
- mintRecipient : mintRecipient ? Array . from ( mintRecipient ) : null ,
120
- } ,
117
+ { chain : toChainId ( chain ) , cctpDomain, address, mintRecipient } ,
121
118
) ;
122
119
123
120
const transaction = await this . createTx ( ownerOrAssistant , [ ix ] ) ;
@@ -133,17 +130,12 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
133
130
) {
134
131
const owner = new SolanaAddress ( sender ) . unwrap ( ) ;
135
132
const mintRecipient = tokenAccount
136
- ? new SolanaAddress ( tokenAccount ) . toUniversalAddress ( ) . toUint8Array ( )
133
+ ? Array . from ( new SolanaAddress ( tokenAccount ) . toUniversalAddress ( ) . toUint8Array ( ) )
137
134
: null ;
138
-
135
+ const address = Array . from ( router . toUniversalAddress ( ) . toUint8Array ( ) ) ;
139
136
const ix = await this . updateCctpRouterEndpointIx (
140
137
{ owner } ,
141
- {
142
- chain : toChainId ( chain ) ,
143
- cctpDomain : cctpDomain ,
144
- address : Array . from ( router . toUniversalAddress ( ) . toUint8Array ( ) ) ,
145
- mintRecipient : mintRecipient ? Array . from ( mintRecipient ) : null ,
146
- } ,
138
+ { chain : toChainId ( chain ) , cctpDomain, address, mintRecipient } ,
147
139
) ;
148
140
149
141
const transaction = await this . createTx ( owner , [ ix ] ) ;
@@ -152,6 +144,7 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
152
144
153
145
async * disableRouter < RC extends Chain > ( sender : AnySolanaAddress , chain : RC ) {
154
146
const owner = new SolanaAddress ( sender ) . unwrap ( ) ;
147
+
155
148
const ix = await this . disableRouterEndpointIx ( { owner } , toChainId ( chain ) ) ;
156
149
157
150
const transaction = await this . createTx ( owner , [ ix ] ) ;
@@ -329,8 +322,20 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
329
322
// If the finalized VAA and CCTP message/attestation are passed
330
323
// we may try to prepare the order response
331
324
// this yields its own transaction
332
- if ( finalized && cctp )
333
- yield * this . prepareOrderResponse ( sender , fast , finalized , cctp , lookupTables ) ;
325
+ const ixs = [ ] ;
326
+ if ( finalized && cctp ) {
327
+ // TODO: how do we decide?
328
+ const combine = true ;
329
+ // try to include the prepare order instruction in the same transaction
330
+ if ( combine ) {
331
+ const ix = await this . _prepareOrderResponseIx ( sender , fast , finalized , cctp ) ;
332
+ if ( ix !== undefined ) {
333
+ ixs . push ( ix , ComputeBudgetProgram . setComputeUnitLimit ( { units : 300_000 } ) ) ;
334
+ }
335
+ } else {
336
+ yield * this . prepareOrderResponse ( sender , fast , finalized , cctp , lookupTables ) ;
337
+ }
338
+ }
334
339
335
340
const digest = keccak256 ( fast . hash ) ;
336
341
const preparedOrderResponse = this . preparedOrderResponseAddress ( digest ) ;
@@ -364,11 +369,14 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
364
369
return await this . settleAuctionCompleteIx ( {
365
370
executor : payer ,
366
371
preparedOrderResponse,
372
+ auction,
367
373
} ) ;
368
374
}
369
375
} ) ( ) ;
370
376
371
- const transaction = await this . createTx ( payer , [ settleIx ] , undefined , lookupTables ) ;
377
+ ixs . push ( settleIx ) ;
378
+
379
+ const transaction = await this . createTx ( payer , ixs , undefined , lookupTables ) ;
372
380
373
381
yield this . createUnsignedTx ( { transaction } , "MatchingEngine.settleAuctionComplete" ) ;
374
382
}
0 commit comments