Skip to content

Commit

Permalink
revert change to prune orders
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider committed Apr 7, 2024
1 parent 9d7173a commit e643344
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
7 changes: 6 additions & 1 deletion idl/openbook_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,12 @@
"isSigner": false
}
],
"args": []
"args": [
{
"name": "limit",
"type": "u8"
}
]
},
{
"name": "stubOracleCreate",
Expand Down
4 changes: 2 additions & 2 deletions programs/openbook-v2/src/instructions/prune_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::accounts_ix::*;
use crate::error::*;
use crate::state::*;

pub fn prune_orders(ctx: Context<PruneOrders>) -> Result<()> {
pub fn prune_orders(ctx: Context<PruneOrders>, limit: u8) -> Result<()> {
let mut account = ctx.accounts.open_orders_account.load_mut()?;
let market = ctx.accounts.market.load()?;

Expand All @@ -18,7 +18,7 @@ pub fn prune_orders(ctx: Context<PruneOrders>) -> Result<()> {
asks: ctx.accounts.asks.load_mut()?,
};

book.cancel_all_orders(&mut account, *market, u8::MAX, None, None)?;
book.cancel_all_orders(&mut account, *market, limit, None, None)?;

Ok(())
}
4 changes: 2 additions & 2 deletions programs/openbook-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ pub mod openbook_v2 {

/// Remove orders from the book when the market is expired (only
/// [`close_market_admin`](crate::state::Market::close_market_admin)).
pub fn prune_orders(ctx: Context<PruneOrders>) -> Result<()> {
pub fn prune_orders(ctx: Context<PruneOrders>, limit: u8) -> Result<()> {
#[cfg(feature = "enable-gpl")]
instructions::prune_orders(ctx)?;
instructions::prune_orders(ctx, limit)?;
Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,11 @@ export class OpenBookV2Client {
marketPublicKey: PublicKey,
market: MarketAccount,
openOrdersPublicKey: PublicKey,
limit: number,
closeMarketAdmin: Keypair | null = null,
): Promise<[TransactionInstruction, Signer[]]> {
const ix = await this.program.methods
.pruneOrders()
.pruneOrders(limit)
.accounts({
closeMarketAdmin: market.closeMarketAdmin.key,
openOrdersAccount: openOrdersPublicKey,
Expand Down
14 changes: 12 additions & 2 deletions ts/client/src/openbook_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,12 @@ export type OpenbookV2 = {
isSigner: false;
},
];
args: [];
args: [
{
name: 'limit';
type: 'u8';
},
];
},
{
name: 'stubOracleCreate';
Expand Down Expand Up @@ -5316,7 +5321,12 @@ export const IDL: OpenbookV2 = {
isSigner: false,
},
],
args: [],
args: [
{
name: 'limit',
type: 'u8',
},
],
},
{
name: 'stubOracleCreate',
Expand Down

0 comments on commit e643344

Please sign in to comment.