@@ -12,9 +12,11 @@ use crate::state::{
12
12
use anchor_lang:: prelude:: * ;
13
13
use anchor_spl:: token:: spl_token;
14
14
use common:: messages:: raw:: LiquidityLayerDepositMessage ;
15
+ use common:: messages:: raw:: LiquidityLayerMessage ;
15
16
use common:: messages:: raw:: SlowOrderResponse ;
16
17
use common:: wormhole_cctp_solana:: cctp:: message_transmitter_program;
17
18
use common:: wormhole_cctp_solana:: cpi:: ReceiveMessageArgs ;
19
+ use common:: wormhole_cctp_solana:: utils:: CctpMessage ;
18
20
use solana_program:: instruction:: Instruction ;
19
21
use solana_program:: keccak;
20
22
use solana_program:: program:: invoke_signed_unchecked;
@@ -225,6 +227,29 @@ pub fn prepare_order_response_cctp_shim(
225
227
let system_program = & accounts[ 27 ] ;
226
228
let receive_message_args = data. to_receive_message_args ( ) ;
227
229
let finalized_vaa_message = data. finalized_vaa_message ;
230
+
231
+ let deposit_option = LiquidityLayerMessage :: parse ( & finalized_vaa_message. vaa_payload )
232
+ . map_err ( |_| MatchingEngineError :: InvalidDeposit ) ?;
233
+ let deposit = deposit_option
234
+ . deposit ( )
235
+ . ok_or ( MatchingEngineError :: InvalidDepositPayloadId ) ?;
236
+ let cctp_message = CctpMessage :: parse ( & receive_message_args. encoded_message )
237
+ . map_err ( |_| MatchingEngineError :: InvalidCctpMessage ) ?;
238
+ require_eq ! (
239
+ cctp_message. source_domain( ) ,
240
+ deposit. source_cctp_domain( ) ,
241
+ MatchingEngineError :: InvalidCctpMessage
242
+ ) ;
243
+ require_eq ! (
244
+ cctp_message. destination_domain( ) ,
245
+ deposit. destination_cctp_domain( ) ,
246
+ MatchingEngineError :: InvalidCctpMessage
247
+ ) ;
248
+ require_eq ! (
249
+ cctp_message. nonce( ) ,
250
+ deposit. cctp_nonce( ) ,
251
+ MatchingEngineError :: InvalidCctpMessage
252
+ ) ;
228
253
// Load accounts
229
254
let fast_market_order_account_data = fast_market_order. data . borrow ( ) ;
230
255
let fast_market_order_zero_copy =
@@ -295,28 +320,27 @@ pub fn prepare_order_response_cctp_shim(
295
320
Pubkey :: find_program_address ( & prepared_custody_token_seeds, program_id) ;
296
321
297
322
// Check custodian account
298
- require ! ( custodian. owner == program_id, ErrorCode :: ConstraintOwner ) ;
323
+ require_eq ! ( custodian. owner, program_id, ErrorCode :: ConstraintOwner ) ;
299
324
300
325
require ! ( !checked_custodian. paused, MatchingEngineError :: Paused ) ;
301
326
302
327
// Check usdc mint
303
- require ! (
304
- usdc. key( ) == common:: USDC_MINT ,
328
+ require_eq ! (
329
+ usdc. key( ) ,
330
+ common:: USDC_MINT ,
305
331
MatchingEngineError :: InvalidMint
306
332
) ;
307
333
308
334
// Check from_endpoint owner
309
- require ! (
310
- from_endpoint. owner == program_id,
311
- ErrorCode :: ConstraintOwner
312
- ) ;
335
+ require_eq ! ( from_endpoint. owner, program_id, ErrorCode :: ConstraintOwner ) ;
313
336
314
337
// Check to_endpoint owner
315
- require ! ( to_endpoint. owner == program_id, ErrorCode :: ConstraintOwner ) ;
338
+ require_eq ! ( to_endpoint. owner, program_id, ErrorCode :: ConstraintOwner ) ;
316
339
317
340
// Check that the from and to endpoints are different
318
- require ! (
319
- from_endpoint_account. chain != to_endpoint_account. chain,
341
+ require_neq ! (
342
+ from_endpoint_account. chain,
343
+ to_endpoint_account. chain,
320
344
MatchingEngineError :: SameEndpoint
321
345
) ;
322
346
@@ -339,39 +363,47 @@ pub fn prepare_order_response_cctp_shim(
339
363
) ;
340
364
341
365
// Check that to endpoint chain is equal to the fast_market_order target_chain
342
- require ! (
343
- to_endpoint_account. chain == fast_market_order_zero_copy. target_chain,
366
+ require_eq ! (
367
+ to_endpoint_account. chain,
368
+ fast_market_order_zero_copy. target_chain,
344
369
MatchingEngineError :: InvalidTargetRouter
345
370
) ;
346
371
347
- require ! (
348
- prepared_order_response_pda == prepared_order_response. key( ) ,
372
+ require_eq ! (
373
+ prepared_order_response_pda,
374
+ prepared_order_response. key( ) ,
349
375
MatchingEngineError :: InvalidPda
350
376
) ;
351
377
352
- require ! (
353
- prepared_custody_token_pda == prepared_custody_token. key( ) ,
378
+ require_eq ! (
379
+ prepared_custody_token_pda,
380
+ prepared_custody_token. key( ) ,
354
381
MatchingEngineError :: InvalidPda
355
382
) ;
356
383
357
384
// Check the base token fee key is not equal to the prepared custody token key
358
- require ! (
359
- base_fee_token. key( ) != prepared_custody_token. key( ) ,
385
+ // TODO: Check that base fee token is actually a token account
386
+ require_neq ! (
387
+ base_fee_token. key( ) ,
388
+ prepared_custody_token. key( ) ,
360
389
MatchingEngineError :: InvalidBaseFeeToken
361
390
) ;
362
391
363
- require ! (
364
- token_program. key( ) == spl_token:: ID ,
392
+ require_eq ! (
393
+ token_program. key( ) ,
394
+ spl_token:: ID ,
365
395
MatchingEngineError :: InvalidProgram
366
396
) ;
367
397
368
- require ! (
369
- _verify_shim_program. key( ) == wormhole_svm_definitions:: solana:: VERIFY_VAA_SHIM_PROGRAM_ID ,
398
+ require_eq ! (
399
+ _verify_shim_program. key( ) ,
400
+ wormhole_svm_definitions:: solana:: VERIFY_VAA_SHIM_PROGRAM_ID ,
370
401
MatchingEngineError :: InvalidProgram
371
402
) ;
372
403
373
- require ! (
374
- system_program. key( ) == solana_program:: system_program:: ID ,
404
+ require_eq ! (
405
+ system_program. key( ) ,
406
+ solana_program:: system_program:: ID ,
375
407
MatchingEngineError :: InvalidProgram
376
408
) ;
377
409
0 commit comments