Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions bench-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"reclaim_buffer/max_buffers_in_one_instruction": 64,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 9,
"reclaim_order/happy_path_returns_lamports_and_closes_pda": 4,
"settle/finalizes_with_no_pushes": 5,
"settle/pulls_from_multiple_orders": 15,
"settle/pulls_funds_to_destination": 10,
"settle/pulls_to_multiple_destinations": 11,
"settle/pushes_a_single_order": 9,
"settle/pushes_several_orders_from_different_buffers": 13,
"settle/pushes_several_orders_from_one_buffer": 12,
"settle/settles_a_single_order": 9,
"settle/settles_multiple_orders": 17,
"settle/finalizes_with_no_pushes": 6,
"settle/pulls_from_multiple_orders": 16,
"settle/pulls_funds_to_destination": 11,
"settle/pulls_to_multiple_destinations": 12,
"settle/pushes_a_single_order": 10,
"settle/pushes_several_orders_from_different_buffers": 14,
"settle/pushes_several_orders_from_one_buffer": 13,
"settle/settles_a_single_order": 10,
"settle/settles_multiple_orders": 18,
"transfer_authority/manager_can_transfer_manager": 4,
"transfer_authority/manager_can_transfer_reclaim_authority": 4,
"transfer_authority/reclaim_authority_can_transfer_itself": 4
Expand All @@ -29,20 +29,20 @@
"create_buffers/max_buffers_in_one_instruction": 177519,
"create_order/happy_path_creates_order_pda_with_expected_body": 7914,
"initialize/happy_path_initializes_state_pda_with_expected_data": 4519,
"reclaim_buffer/funded_buffer_is_skipped": 6321,
"reclaim_buffer/happy_path_reclaims_empty_buffer_to_the_authority_itself": 7470,
"reclaim_buffer/max_buffers_in_one_instruction": 137046,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 18083,
"reclaim_buffer/funded_buffer_is_skipped": 6364,
"reclaim_buffer/happy_path_reclaims_empty_buffer_to_the_authority_itself": 7512,
"reclaim_buffer/max_buffers_in_one_instruction": 138335,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 18169,
"reclaim_order/happy_path_returns_lamports_and_closes_pda": 2127,
"settle/finalizes_with_no_pushes": 7025,
"settle/pulls_from_multiple_orders": 19713,
"settle/pulls_funds_to_destination": 13390,
"settle/pulls_to_multiple_destinations": 14536,
"settle/pushes_a_single_order": 12241,
"settle/pushes_several_orders_from_different_buffers": 17416,
"settle/pushes_several_orders_from_one_buffer": 17417,
"settle/settles_a_single_order": 12259,
"settle/settles_multiple_orders": 22635,
"settle/finalizes_with_no_pushes": 7097,
"settle/pulls_from_multiple_orders": 20157,
"settle/pulls_funds_to_destination": 13656,
"settle/pulls_to_multiple_destinations": 14802,
"settle/pushes_a_single_order": 12507,
"settle/pushes_several_orders_from_different_buffers": 17856,
"settle/pushes_several_orders_from_one_buffer": 17858,
"settle/settles_a_single_order": 12525,
"settle/settles_multiple_orders": 23257,
"transfer_authority/manager_can_transfer_manager": 3163,
"transfer_authority/manager_can_transfer_reclaim_authority": 3165,
"transfer_authority/reclaim_authority_can_transfer_itself": 3168
Expand All @@ -58,15 +58,15 @@
"reclaim_buffer/max_buffers_in_one_instruction": 332,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 466,
"reclaim_order/happy_path_returns_lamports_and_closes_pda": 236,
"settle/finalizes_with_no_pushes": 289,
"settle/pulls_from_multiple_orders": 655,
"settle/pulls_funds_to_destination": 472,
"settle/pulls_to_multiple_destinations": 513,
"settle/pushes_a_single_order": 431,
"settle/pushes_several_orders_from_different_buffers": 573,
"settle/pushes_several_orders_from_one_buffer": 541,
"settle/settles_a_single_order": 431,
"settle/settles_multiple_orders": 715,
"settle/finalizes_with_no_pushes": 323,
"settle/pulls_from_multiple_orders": 689,
"settle/pulls_funds_to_destination": 506,
"settle/pulls_to_multiple_destinations": 547,
"settle/pushes_a_single_order": 465,
"settle/pushes_several_orders_from_different_buffers": 607,
"settle/pushes_several_orders_from_one_buffer": 575,
"settle/settles_a_single_order": 465,
"settle/settles_multiple_orders": 749,
"transfer_authority/manager_can_transfer_manager": 333,
"transfer_authority/manager_can_transfer_reclaim_authority": 333,
"transfer_authority/reclaim_authority_can_transfer_itself": 333
Expand Down
24 changes: 21 additions & 3 deletions client/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use cow_settlement_interface::{

// Reexport the instruction builders that don't change from the interface.
// We want the client to provide all instruction builders.
pub use cow_settlement_interface::instruction::settle::Pull;
pub use cow_settlement_interface::instruction::settle::{Pull, TokenPrograms};

/// An order ready to be settled, together with the funds to pull from it:
/// `intent` identifies the order and `pulls` lists the [`Pull`]s to make from
Expand All @@ -30,6 +30,10 @@ pub struct BeginSettle<'a> {
/// The off-chain auction this settlement executes, carried so it can be tied
/// back to its auction off-chain.
pub auction_id: i64,
/// The token programs owning the accounts this settlement pulls from and
/// pays into. Leaving one out makes its accounts unsettleable here, so this
/// has to cover every one of them.
pub token_programs: TokenPrograms,
pub orders: &'a [InitializedIntent<'a>],
}

Expand All @@ -50,6 +54,7 @@ impl From<BeginSettle<'_>> for Instruction {
state_pda,
finalize_ix_index: builder.finalize_ix_index,
auction_id: builder.auction_id,
token_programs: builder.token_programs,
order_pdas: &order_pdas,
sell_token_accounts: &sell_token_accounts,
pulls: &pull_lists,
Expand Down Expand Up @@ -81,6 +86,9 @@ pub struct FinalizedIntent<'a> {
pub struct FinalizeSettle<'a> {
pub program_id: Pubkey,
pub begin_ix_index: u16,
/// The token programs owning the buffers and buy token accounts this
/// settlement pushes between, filled the same way as [`BeginSettle`]'s.
pub token_programs: TokenPrograms,
pub orders: &'a [FinalizedIntent<'a>],
}

Expand Down Expand Up @@ -113,6 +121,7 @@ impl From<FinalizeSettle<'_>> for Instruction {
program_id: builder.program_id,
state_pda,
begin_ix_index: builder.begin_ix_index,
token_programs: builder.token_programs,
source_buffers: &source_buffers,
destinations: &destinations,
bumps: &bumps,
Expand Down Expand Up @@ -256,7 +265,8 @@ mod tests {
instruction::{
fixtures::fake_account_from_array,
settle::{
BeginSettleInput, FinalizeSettleInput, INSTRUCTIONS_SYSVAR_ID, SPL_TOKEN_PROGRAM_ID,
BeginSettleInput, FinalizeSettleInput, INSTRUCTIONS_SYSVAR_ID,
SPL_TOKEN_PROGRAM_ID, SYSTEM_PROGRAM_ID,
},
InstructionInputParsing,
},
Expand All @@ -283,6 +293,7 @@ mod tests {
program_id,
finalize_ix_index,
auction_id: 0,
token_programs: TokenPrograms::SPL_TOKEN,
orders: &orders,
});

Expand Down Expand Up @@ -348,6 +359,7 @@ mod tests {
let ix = Instruction::from(FinalizeSettle {
program_id,
begin_ix_index,
token_programs: TokenPrograms::SPL_TOKEN,
orders: &orders,
});

Expand Down Expand Up @@ -393,9 +405,15 @@ mod tests {
let (state_pda, _bump) = find_state_pda(&program_id);
prop_assert_eq!(parsed.state_pda_account.address(), &state_pda);
prop_assert_eq!(
parsed.token_program_account.address(),
parsed.spl_token_program_account.address(),
&SPL_TOKEN_PROGRAM_ID,
);
// These settlements are legacy-only, so Token-2022's slot stands
// empty.
prop_assert_eq!(
parsed.token_2022_program_account.address(),
&SYSTEM_PROGRAM_ID,
);

let parsed_pushes: Vec<_> = parsed.pushes.iter().collect();
prop_assert_eq!(parsed_pushes.len(), expected.len());
Expand Down
3 changes: 3 additions & 0 deletions client/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ mod tests {
use super::*;
use crate::instructions::{
BeginSettle, CreateBuffers, CreateOrder, FinalizeSettle, Initialize, InitializedIntent,
TokenPrograms,
};
use cow_settlement_interface::{
data::intent::{fixtures::sample_intent, OrderKind},
Expand Down Expand Up @@ -111,6 +112,7 @@ mod tests {
program_id,
finalize_ix_index: 1,
auction_id: 42,
token_programs: TokenPrograms::SPL_TOKEN,
orders: &[InitializedIntent {
intent: &intent,
pulls: &[],
Expand All @@ -120,6 +122,7 @@ mod tests {
SettlementInstruction::FinalizeSettle => FinalizeSettle {
program_id,
begin_ix_index: 0,
token_programs: TokenPrograms::SPL_TOKEN,
orders: &[],
}
.into(),
Expand Down
Loading
Loading