Skip to content

Commit 507cb40

Browse files
committed
solana: add close_redeemed_fast_fill ix
1 parent 62b670b commit 507cb40

File tree

7 files changed

+130
-0
lines changed

7 files changed

+130
-0
lines changed

solana/programs/matching-engine/src/error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub enum MatchingEngineError {
7878
AuctionConfigNotRequired = 0x430,
7979
BestOfferTokenNotRequired = 0x431,
8080
FastFillAlreadyRedeemed = 0x434,
81+
FastFillNotRedeemed = 0x435,
8182

8283
CannotCloseAuctionYet = 0x500,
8384
AuctionHistoryNotFull = 0x502,

solana/programs/matching-engine/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ pub mod matching_engine {
428428
) -> Result<()> {
429429
processor::reserve_fast_fill_sequence_no_auction(ctx)
430430
}
431+
432+
/// This instruction is used to return lamports to the creator of the `FastFill` account only
433+
/// when this fill was redeemed via the Token Router program.
434+
///
435+
/// # Arguments
436+
///
437+
/// * `ctx` - `CloseRedeemedFastFill` context.
438+
pub fn close_redeemed_fast_fill(ctx: Context<CloseRedeemedFastFill>) -> Result<()> {
439+
processor::close_redeemed_fast_fill(ctx)
440+
}
431441
}
432442

433443
#[cfg(test)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::{error::MatchingEngineError, state::FastFill};
2+
use anchor_lang::prelude::*;
3+
4+
#[derive(Accounts)]
5+
pub struct CloseRedeemedFastFill<'info> {
6+
#[account(mut)]
7+
prepared_by: Signer<'info>,
8+
9+
#[account(
10+
mut,
11+
close = prepared_by,
12+
constraint = !fast_fill.redeemed @ MatchingEngineError::FastFillNotRedeemed,
13+
)]
14+
fast_fill: Account<'info, FastFill>,
15+
}
16+
17+
pub fn close_redeemed_fast_fill(_ctx: Context<CloseRedeemedFastFill>) -> Result<()> {
18+
Ok(())
19+
}

solana/programs/matching-engine/src/processor/fast_fill/complete.rs

+7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ use common::wormhole_cctp_solana::wormhole::SOLANA_CHAIN;
1010
/// Accounts required for [complete_fast_fill].
1111
#[derive(Accounts)]
1212
pub struct CompleteFastFill<'info> {
13+
/// Custodian, which may be used in the future.
1314
custodian: CheckedCustodian<'info>,
1415

16+
/// Fast fill account.
17+
///
18+
/// NOTE: This account may have been closed if the fast fill was already redeemed, so this
19+
/// deserialization will fail in this case.
20+
///
21+
/// Seeds must be \["fast-fill", source_chain, order_sender, sequence\].
1522
#[account(
1623
mut,
1724
seeds = [

solana/programs/matching-engine/src/processor/fast_fill/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
mod close_redeemed;
2+
pub use close_redeemed::*;
3+
14
mod complete;
25
pub use complete::*;
36

solana/target/idl/matching_engine.json

+45
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,39 @@
320320
],
321321
"args": []
322322
},
323+
{
324+
"name": "close_redeemed_fast_fill",
325+
"docs": [
326+
"This instruction is used to return lamports to the creator of the `FastFill` account only",
327+
"when this fill was redeemed via the Token Router program.",
328+
"",
329+
"# Arguments",
330+
"",
331+
"* `ctx` - `CloseRedeemedFastFill` context."
332+
],
333+
"discriminator": [
334+
44,
335+
104,
336+
207,
337+
178,
338+
224,
339+
7,
340+
28,
341+
219
342+
],
343+
"accounts": [
344+
{
345+
"name": "prepared_by",
346+
"writable": true,
347+
"signer": true
348+
},
349+
{
350+
"name": "fast_fill",
351+
"writable": true
352+
}
353+
],
354+
"args": []
355+
},
323356
{
324357
"name": "complete_fast_fill",
325358
"docs": [
@@ -353,6 +386,14 @@
353386
},
354387
{
355388
"name": "fast_fill",
389+
"docs": [
390+
"Fast fill account.",
391+
"",
392+
"NOTE: This account may have been closed if the fast fill was already redeemed, so this",
393+
"deserialization will fail in this case.",
394+
"",
395+
"Seeds must be \\[\"fast-fill\", source_chain, order_sender, sequence\\]."
396+
],
356397
"writable": true
357398
},
358399
{
@@ -2955,6 +2996,10 @@
29552996
"code": 7076,
29562997
"name": "FastFillAlreadyRedeemed"
29572998
},
2999+
{
3000+
"code": 7077,
3001+
"name": "FastFillNotRedeemed"
3002+
},
29583003
{
29593004
"code": 7280,
29603005
"name": "CannotCloseAuctionYet"

solana/target/types/matching_engine.ts

+45
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,39 @@ export type MatchingEngine = {
326326
],
327327
"args": []
328328
},
329+
{
330+
"name": "closeRedeemedFastFill",
331+
"docs": [
332+
"This instruction is used to return lamports to the creator of the `FastFill` account only",
333+
"when this fill was redeemed via the Token Router program.",
334+
"",
335+
"# Arguments",
336+
"",
337+
"* `ctx` - `CloseRedeemedFastFill` context."
338+
],
339+
"discriminator": [
340+
44,
341+
104,
342+
207,
343+
178,
344+
224,
345+
7,
346+
28,
347+
219
348+
],
349+
"accounts": [
350+
{
351+
"name": "preparedBy",
352+
"writable": true,
353+
"signer": true
354+
},
355+
{
356+
"name": "fastFill",
357+
"writable": true
358+
}
359+
],
360+
"args": []
361+
},
329362
{
330363
"name": "completeFastFill",
331364
"docs": [
@@ -359,6 +392,14 @@ export type MatchingEngine = {
359392
},
360393
{
361394
"name": "fastFill",
395+
"docs": [
396+
"Fast fill account.",
397+
"",
398+
"NOTE: This account may have been closed if the fast fill was already redeemed, so this",
399+
"deserialization will fail in this case.",
400+
"",
401+
"Seeds must be \\[\"fast-fill\", source_chain, order_sender, sequence\\]."
402+
],
362403
"writable": true
363404
},
364405
{
@@ -2961,6 +3002,10 @@ export type MatchingEngine = {
29613002
"code": 7076,
29623003
"name": "fastFillAlreadyRedeemed"
29633004
},
3005+
{
3006+
"code": 7077,
3007+
"name": "fastFillNotRedeemed"
3008+
},
29643009
{
29653010
"code": 7280,
29663011
"name": "cannotCloseAuctionYet"

0 commit comments

Comments
 (0)