spl: Add cancel orders (#484)

This commit is contained in:
Henry-E 2021-07-06 17:41:45 +01:00 committed by GitHub
parent 97e9e03fb0
commit f26e0f7499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 0 deletions

View File

@ -58,6 +58,30 @@ pub fn new_order_v3<'info>(
Ok(())
}
pub fn cancel_order_v2<'info>(
ctx: CpiContext<'_, '_, '_, 'info, CancelOrderV2<'info>>,
side: Side,
order_id: u128,
) -> ProgramResult {
let ix = serum_dex::instruction::cancel_order(
&ID,
ctx.accounts.market.key,
ctx.accounts.market_bids.key,
ctx.accounts.market_asks.key,
ctx.accounts.open_orders.key,
ctx.accounts.open_orders_authority.key,
ctx.accounts.event_queue.key,
side,
order_id,
)?;
solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
)?;
Ok(())
}
pub fn settle_funds<'info>(
ctx: CpiContext<'_, '_, '_, 'info, SettleFunds<'info>>,
) -> ProgramResult {
@ -158,6 +182,16 @@ pub struct NewOrderV3<'info> {
pub rent: AccountInfo<'info>,
}
#[derive(Accounts)]
pub struct CancelOrderV2<'info> {
pub market: AccountInfo<'info>,
pub market_bids: AccountInfo<'info>,
pub market_asks: AccountInfo<'info>,
pub open_orders: AccountInfo<'info>,
pub open_orders_authority: AccountInfo<'info>,
pub event_queue: AccountInfo<'info>,
}
#[derive(Accounts)]
pub struct SettleFunds<'info> {
pub market: AccountInfo<'info>,