Serum: Prefix instructions with serum3_ and related renames
This commit is contained in:
parent
a40eb94833
commit
9d05db68f9
|
@ -32,7 +32,7 @@ pub fn create_account(ctx: Context<CreateAccount>, account_num: u8) -> Result<()
|
|||
owner: ctx.accounts.owner.key(),
|
||||
delegate: Pubkey::default(),
|
||||
token_account_map: TokenAccountMap::new(),
|
||||
serum_account_map: SerumAccountMap::new(),
|
||||
serum3_account_map: Serum3AccountMap::new(),
|
||||
being_liquidated: false,
|
||||
is_bankrupt: false,
|
||||
account_num,
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
pub use self::margin_trade::*;
|
||||
pub use create_account::*;
|
||||
pub use create_group::*;
|
||||
pub use create_serum_open_orders::*;
|
||||
pub use create_stub_oracle::*;
|
||||
pub use deposit::*;
|
||||
pub use place_serum_order::*;
|
||||
pub use register_serum_market::*;
|
||||
pub use register_token::*;
|
||||
pub use serum3_create_open_orders::*;
|
||||
pub use serum3_place_order::*;
|
||||
pub use serum3_register_market::*;
|
||||
pub use set_stub_oracle::*;
|
||||
pub use withdraw::*;
|
||||
|
||||
mod create_account;
|
||||
mod create_group;
|
||||
mod create_serum_open_orders;
|
||||
mod create_stub_oracle;
|
||||
mod deposit;
|
||||
mod margin_trade;
|
||||
mod place_serum_order;
|
||||
mod register_serum_market;
|
||||
mod register_token;
|
||||
mod serum3_create_open_orders;
|
||||
mod serum3_place_order;
|
||||
mod serum3_register_market;
|
||||
mod set_stub_oracle;
|
||||
mod withdraw;
|
||||
|
|
|
@ -5,7 +5,7 @@ use dex::serum_dex;
|
|||
use crate::state::*;
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct CreateSerumOpenOrders<'info> {
|
||||
pub struct Serum3CreateOpenOrders<'info> {
|
||||
// TODO: do we even need the group?
|
||||
pub group: AccountLoader<'info, Group>,
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub struct CreateSerumOpenOrders<'info> {
|
|||
has_one = serum_program,
|
||||
has_one = serum_market_external,
|
||||
)]
|
||||
pub serum_market: AccountLoader<'info, SerumMarket>,
|
||||
pub serum_market: AccountLoader<'info, Serum3Market>,
|
||||
|
||||
// TODO: limit?
|
||||
pub serum_program: UncheckedAccount<'info>,
|
||||
|
@ -30,7 +30,7 @@ pub struct CreateSerumOpenOrders<'info> {
|
|||
// initialized by this instruction via cpi to serum
|
||||
#[account(
|
||||
init,
|
||||
seeds = [account.key().as_ref(), b"SerumOO".as_ref(), serum_market.key().as_ref()],
|
||||
seeds = [account.key().as_ref(), b"Serum3OO".as_ref(), serum_market.key().as_ref()],
|
||||
bump,
|
||||
payer = payer,
|
||||
owner = serum_program.key(),
|
||||
|
@ -48,7 +48,7 @@ pub struct CreateSerumOpenOrders<'info> {
|
|||
pub rent: Sysvar<'info, Rent>,
|
||||
}
|
||||
|
||||
pub fn create_serum_open_orders(ctx: Context<CreateSerumOpenOrders>) -> Result<()> {
|
||||
pub fn serum3_create_open_orders(ctx: Context<Serum3CreateOpenOrders>) -> Result<()> {
|
||||
let serum_market = ctx.accounts.serum_market.load()?;
|
||||
let context = CpiContext::new(
|
||||
ctx.accounts.serum_program.to_account_info(),
|
||||
|
@ -71,7 +71,7 @@ pub fn create_serum_open_orders(ctx: Context<CreateSerumOpenOrders>) -> Result<(
|
|||
|
||||
let mut account = ctx.accounts.account.load_mut()?;
|
||||
let serum_account = account
|
||||
.serum_account_map
|
||||
.serum3_account_map
|
||||
.create(serum_market.market_index)?;
|
||||
serum_account.open_orders = ctx.accounts.open_orders.key();
|
||||
serum_account.base_token_index = serum_market.base_token_index;
|
|
@ -102,7 +102,7 @@ impl BorshSerialize for NewOrderInstructionData {
|
|||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct PlaceSerumOrder<'info> {
|
||||
pub struct Serum3PlaceOrder<'info> {
|
||||
pub group: AccountLoader<'info, Group>,
|
||||
|
||||
#[account(
|
||||
|
@ -122,7 +122,7 @@ pub struct PlaceSerumOrder<'info> {
|
|||
has_one = serum_program,
|
||||
has_one = serum_market_external,
|
||||
)]
|
||||
pub serum_market: AccountLoader<'info, SerumMarket>,
|
||||
pub serum_market: AccountLoader<'info, Serum3Market>,
|
||||
pub serum_program: UncheckedAccount<'info>,
|
||||
#[account(mut)]
|
||||
pub serum_market_external: UncheckedAccount<'info>,
|
||||
|
@ -163,8 +163,8 @@ pub struct PlaceSerumOrder<'info> {
|
|||
pub rent: Sysvar<'info, Rent>,
|
||||
}
|
||||
|
||||
pub fn place_serum_order(
|
||||
ctx: Context<PlaceSerumOrder>,
|
||||
pub fn serum3_place_order(
|
||||
ctx: Context<Serum3PlaceOrder>,
|
||||
order: NewOrderInstructionData,
|
||||
) -> Result<()> {
|
||||
//
|
||||
|
@ -177,7 +177,7 @@ pub fn place_serum_order(
|
|||
// Validate open_orders
|
||||
require!(
|
||||
account
|
||||
.serum_account_map
|
||||
.serum3_account_map
|
||||
.find(serum_market.market_index)
|
||||
.ok_or(error!(MangoError::SomeError))?
|
||||
.open_orders
|
||||
|
@ -257,7 +257,7 @@ pub fn place_serum_order(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cpi_place_order(ctx: &Context<PlaceSerumOrder>, order: NewOrderInstructionV3) -> Result<()> {
|
||||
fn cpi_place_order(ctx: &Context<Serum3PlaceOrder>, order: NewOrderInstructionV3) -> Result<()> {
|
||||
let order_payer_token_account = match order.side {
|
||||
Side::Bid => &ctx.accounts.quote_vault,
|
||||
Side::Ask => &ctx.accounts.base_vault,
|
||||
|
@ -305,7 +305,7 @@ fn cpi_place_order(ctx: &Context<PlaceSerumOrder>, order: NewOrderInstructionV3)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cpi_settle_funds(ctx: &Context<PlaceSerumOrder>) -> Result<()> {
|
||||
fn cpi_settle_funds(ctx: &Context<Serum3PlaceOrder>) -> Result<()> {
|
||||
let data = serum_dex::instruction::MarketInstruction::SettleFunds.pack();
|
||||
let instruction = solana_program::instruction::Instruction {
|
||||
program_id: *ctx.accounts.serum_program.key,
|
|
@ -4,7 +4,7 @@ use crate::error::MangoError;
|
|||
use crate::state::*;
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct RegisterSerumMarket<'info> {
|
||||
pub struct Serum3RegisterMarket<'info> {
|
||||
#[account(
|
||||
mut,
|
||||
has_one = admin,
|
||||
|
@ -19,12 +19,12 @@ pub struct RegisterSerumMarket<'info> {
|
|||
#[account(
|
||||
init,
|
||||
// using the serum_market_external in the seed guards against registering the same market twice
|
||||
seeds = [group.key().as_ref(), b"SerumMarket".as_ref(), serum_market_external.key().as_ref()],
|
||||
seeds = [group.key().as_ref(), b"Serum3Market".as_ref(), serum_market_external.key().as_ref()],
|
||||
bump,
|
||||
payer = payer,
|
||||
space = 8 + std::mem::size_of::<SerumMarket>(),
|
||||
space = 8 + std::mem::size_of::<Serum3Market>(),
|
||||
)]
|
||||
pub serum_market: AccountLoader<'info, SerumMarket>,
|
||||
pub serum_market: AccountLoader<'info, Serum3Market>,
|
||||
|
||||
#[account(mut)]
|
||||
pub payer: Signer<'info>,
|
||||
|
@ -33,9 +33,9 @@ pub struct RegisterSerumMarket<'info> {
|
|||
}
|
||||
|
||||
// TODO: should this be "configure_serum_market", which allows reconfiguring?
|
||||
pub fn register_serum_market(
|
||||
ctx: Context<RegisterSerumMarket>,
|
||||
market_index: SerumMarketIndex,
|
||||
pub fn serum3_register_market(
|
||||
ctx: Context<Serum3RegisterMarket>,
|
||||
market_index: Serum3MarketIndex,
|
||||
base_token_index: TokenIndex,
|
||||
quote_token_index: TokenIndex,
|
||||
) -> Result<()> {
|
||||
|
@ -43,7 +43,7 @@ pub fn register_serum_market(
|
|||
// TODO: verify that base_token_index and quote_token_index are correct!
|
||||
|
||||
let mut serum_market = ctx.accounts.serum_market.load_init()?;
|
||||
*serum_market = SerumMarket {
|
||||
*serum_market = Serum3Market {
|
||||
group: ctx.accounts.group.key(),
|
||||
serum_program: ctx.accounts.serum_program.key(),
|
||||
serum_market_external: ctx.accounts.serum_market_external.key(),
|
|
@ -14,7 +14,7 @@ pub mod error;
|
|||
pub mod instructions;
|
||||
pub mod state;
|
||||
|
||||
use state::{SerumMarketIndex, TokenIndex};
|
||||
use state::{Serum3MarketIndex, TokenIndex};
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
|
@ -77,24 +77,24 @@ pub mod mango_v4 {
|
|||
instructions::margin_trade(ctx, banks_len, cpi_data)
|
||||
}
|
||||
|
||||
pub fn register_serum_market(
|
||||
ctx: Context<RegisterSerumMarket>,
|
||||
market_index: SerumMarketIndex,
|
||||
pub fn serum3_register_market(
|
||||
ctx: Context<Serum3RegisterMarket>,
|
||||
market_index: Serum3MarketIndex,
|
||||
base_token_index: TokenIndex,
|
||||
quote_token_index: TokenIndex,
|
||||
) -> Result<()> {
|
||||
instructions::register_serum_market(ctx, market_index, base_token_index, quote_token_index)
|
||||
instructions::serum3_register_market(ctx, market_index, base_token_index, quote_token_index)
|
||||
}
|
||||
|
||||
pub fn create_serum_open_orders(ctx: Context<CreateSerumOpenOrders>) -> Result<()> {
|
||||
instructions::create_serum_open_orders(ctx)
|
||||
pub fn serum3_create_open_orders(ctx: Context<Serum3CreateOpenOrders>) -> Result<()> {
|
||||
instructions::serum3_create_open_orders(ctx)
|
||||
}
|
||||
|
||||
pub fn place_serum_order(
|
||||
ctx: Context<PlaceSerumOrder>,
|
||||
pub fn serum3_place_order(
|
||||
ctx: Context<Serum3PlaceOrder>,
|
||||
order: instructions::NewOrderInstructionData,
|
||||
) -> Result<()> {
|
||||
instructions::place_serum_order(ctx, order)
|
||||
instructions::serum3_place_order(ctx, order)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::util::LoadZeroCopy;
|
|||
|
||||
pub fn compute_health(account: &MangoAccount, ais: &[AccountInfo]) -> Result<I80F48> {
|
||||
let active_token_len = account.token_account_map.iter_active().count();
|
||||
let active_serum_len = account.serum_account_map.iter_active().count();
|
||||
let active_serum_len = account.serum3_account_map.iter_active().count();
|
||||
let expected_ais = active_token_len * 2 // banks + oracles
|
||||
+ active_serum_len; // open_orders
|
||||
require!(ais.len() == expected_ais, MangoError::SomeError);
|
||||
|
@ -143,7 +143,7 @@ fn compute_health_detail(
|
|||
|
||||
// token contribution from serum accounts
|
||||
for (serum_account, oo_ai) in
|
||||
util::zip!(account.serum_account_map.iter_active(), serum_oos.iter())
|
||||
util::zip!(account.serum3_account_map.iter_active(), serum_oos.iter())
|
||||
{
|
||||
// This assumes serum open orders are passed in order
|
||||
require!(
|
||||
|
|
|
@ -115,10 +115,10 @@ impl TokenAccountMap {
|
|||
}
|
||||
|
||||
#[zero_copy]
|
||||
pub struct SerumAccount {
|
||||
pub struct Serum3Account {
|
||||
pub open_orders: Pubkey,
|
||||
|
||||
pub market_index: SerumMarketIndex,
|
||||
pub market_index: Serum3MarketIndex,
|
||||
|
||||
/// Store the base/quote token index, so health computations don't need
|
||||
/// to get passed the static SerumMarket to find which tokens a market
|
||||
|
@ -128,21 +128,21 @@ pub struct SerumAccount {
|
|||
}
|
||||
// TODO: static assert the size and alignment
|
||||
|
||||
impl SerumAccount {
|
||||
impl Serum3Account {
|
||||
pub fn is_active(&self) -> bool {
|
||||
self.market_index != SerumMarketIndex::MAX
|
||||
self.market_index != Serum3MarketIndex::MAX
|
||||
}
|
||||
|
||||
pub fn is_active_for_market(&self, market_index: SerumMarketIndex) -> bool {
|
||||
pub fn is_active_for_market(&self, market_index: Serum3MarketIndex) -> bool {
|
||||
self.market_index == market_index
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SerumAccount {
|
||||
impl Default for Serum3Account {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
open_orders: Pubkey::default(),
|
||||
market_index: SerumMarketIndex::MAX,
|
||||
market_index: Serum3MarketIndex::MAX,
|
||||
base_token_index: TokenIndex::MAX,
|
||||
quote_token_index: TokenIndex::MAX,
|
||||
}
|
||||
|
@ -150,25 +150,25 @@ impl Default for SerumAccount {
|
|||
}
|
||||
|
||||
#[zero_copy]
|
||||
pub struct SerumAccountMap {
|
||||
pub values: [SerumAccount; MAX_SERUM_OPEN_ORDERS],
|
||||
pub struct Serum3AccountMap {
|
||||
pub values: [Serum3Account; MAX_SERUM_OPEN_ORDERS],
|
||||
}
|
||||
|
||||
impl SerumAccountMap {
|
||||
impl Serum3AccountMap {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
values: [SerumAccount::default(); MAX_SERUM_OPEN_ORDERS],
|
||||
values: [Serum3Account::default(); MAX_SERUM_OPEN_ORDERS],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create(&mut self, market_index: SerumMarketIndex) -> Result<&mut SerumAccount> {
|
||||
pub fn create(&mut self, market_index: Serum3MarketIndex) -> Result<&mut Serum3Account> {
|
||||
if self.find(market_index).is_some() {
|
||||
return err!(MangoError::SomeError); // exists already
|
||||
}
|
||||
if let Some(v) = self.values.iter_mut().find(|p| !p.is_active()) {
|
||||
*v = SerumAccount {
|
||||
market_index: market_index as SerumMarketIndex,
|
||||
..SerumAccount::default()
|
||||
*v = Serum3Account {
|
||||
market_index: market_index as Serum3MarketIndex,
|
||||
..Serum3Account::default()
|
||||
};
|
||||
Ok(v)
|
||||
} else {
|
||||
|
@ -177,14 +177,14 @@ impl SerumAccountMap {
|
|||
}
|
||||
|
||||
pub fn deactivate(&mut self, index: usize) {
|
||||
self.values[index].market_index = SerumMarketIndex::MAX;
|
||||
self.values[index].market_index = Serum3MarketIndex::MAX;
|
||||
}
|
||||
|
||||
pub fn iter_active(&self) -> impl Iterator<Item = &SerumAccount> {
|
||||
pub fn iter_active(&self) -> impl Iterator<Item = &Serum3Account> {
|
||||
self.values.iter().filter(|p| p.is_active())
|
||||
}
|
||||
|
||||
pub fn find(&self, market_index: SerumMarketIndex) -> Option<&SerumAccount> {
|
||||
pub fn find(&self, market_index: Serum3MarketIndex) -> Option<&Serum3Account> {
|
||||
self.values
|
||||
.iter()
|
||||
.find(|p| p.is_active_for_market(market_index))
|
||||
|
@ -205,7 +205,7 @@ pub struct MangoAccount {
|
|||
|
||||
// Maps serum_market_index -> open orders for each serum market
|
||||
// that is active on this MangoAccount.
|
||||
pub serum_account_map: SerumAccountMap,
|
||||
pub serum3_account_map: Serum3AccountMap,
|
||||
|
||||
/// This account cannot open new positions or borrow until `init_health >= 0`
|
||||
pub being_liquidated: bool, // TODO: for strict Pod compat, these should be u8, not bool
|
||||
|
|
|
@ -4,7 +4,7 @@ pub use health::*;
|
|||
pub use mango_account::*;
|
||||
pub use mint_info::*;
|
||||
pub use oracle::*;
|
||||
pub use serum_market::*;
|
||||
pub use serum3_market::*;
|
||||
|
||||
mod bank;
|
||||
mod group;
|
||||
|
@ -12,4 +12,4 @@ mod health;
|
|||
mod mango_account;
|
||||
mod mint_info;
|
||||
mod oracle;
|
||||
mod serum_market;
|
||||
mod serum3_market;
|
||||
|
|
|
@ -2,15 +2,15 @@ use anchor_lang::prelude::*;
|
|||
|
||||
use crate::state::*;
|
||||
|
||||
pub type SerumMarketIndex = u16;
|
||||
pub type Serum3MarketIndex = u16;
|
||||
|
||||
#[account(zero_copy)]
|
||||
pub struct SerumMarket {
|
||||
pub struct Serum3Market {
|
||||
pub group: Pubkey,
|
||||
pub serum_program: Pubkey,
|
||||
pub serum_market_external: Pubkey,
|
||||
|
||||
pub market_index: SerumMarketIndex,
|
||||
pub market_index: Serum3MarketIndex,
|
||||
pub base_token_index: TokenIndex,
|
||||
pub quote_token_index: TokenIndex,
|
||||
|
||||
|
@ -23,7 +23,7 @@ macro_rules! serum_market_seeds {
|
|||
( $acc:expr ) => {
|
||||
&[
|
||||
$acc.group.as_ref(),
|
||||
b"SerumMarket".as_ref(),
|
||||
b"Serum3Market".as_ref(),
|
||||
$acc.serum_market_external.as_ref(),
|
||||
&[$acc.bump],
|
||||
]
|
|
@ -137,7 +137,7 @@ async fn derive_health_check_remaining_account_metas(
|
|||
}
|
||||
|
||||
let serum_oos = account
|
||||
.serum_account_map
|
||||
.serum3_account_map
|
||||
.iter_active()
|
||||
.map(|&s| s.open_orders);
|
||||
|
||||
|
@ -631,7 +631,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct RegisterSerumMarketInstruction<'keypair> {
|
||||
pub struct Serum3RegisterMarketInstruction<'keypair> {
|
||||
pub group: Pubkey,
|
||||
pub admin: &'keypair Keypair,
|
||||
pub payer: &'keypair Keypair,
|
||||
|
@ -639,14 +639,14 @@ pub struct RegisterSerumMarketInstruction<'keypair> {
|
|||
pub serum_program: Pubkey,
|
||||
pub serum_market_external: Pubkey,
|
||||
|
||||
pub market_index: SerumMarketIndex,
|
||||
pub market_index: Serum3MarketIndex,
|
||||
pub base_token_index: TokenIndex,
|
||||
pub quote_token_index: TokenIndex,
|
||||
}
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl<'keypair> ClientInstruction for RegisterSerumMarketInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::RegisterSerumMarket;
|
||||
type Instruction = mango_v4::instruction::RegisterSerumMarket;
|
||||
impl<'keypair> ClientInstruction for Serum3RegisterMarketInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::Serum3RegisterMarket;
|
||||
type Instruction = mango_v4::instruction::Serum3RegisterMarket;
|
||||
async fn to_instruction(
|
||||
&self,
|
||||
_account_loader: impl ClientAccountLoader + 'async_trait,
|
||||
|
@ -661,7 +661,7 @@ impl<'keypair> ClientInstruction for RegisterSerumMarketInstruction<'keypair> {
|
|||
let serum_market = Pubkey::find_program_address(
|
||||
&[
|
||||
self.group.as_ref(),
|
||||
b"SerumMarket".as_ref(),
|
||||
b"Serum3Market".as_ref(),
|
||||
self.serum_market_external.as_ref(),
|
||||
],
|
||||
&program_id,
|
||||
|
@ -687,16 +687,16 @@ impl<'keypair> ClientInstruction for RegisterSerumMarketInstruction<'keypair> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct CreateSerumOpenOrdersInstruction<'keypair> {
|
||||
pub struct Serum3CreateOpenOrdersInstruction<'keypair> {
|
||||
pub account: Pubkey,
|
||||
pub serum_market: Pubkey,
|
||||
pub owner: &'keypair Keypair,
|
||||
pub payer: &'keypair Keypair,
|
||||
}
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl<'keypair> ClientInstruction for CreateSerumOpenOrdersInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::CreateSerumOpenOrders;
|
||||
type Instruction = mango_v4::instruction::CreateSerumOpenOrders;
|
||||
impl<'keypair> ClientInstruction for Serum3CreateOpenOrdersInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::Serum3CreateOpenOrders;
|
||||
type Instruction = mango_v4::instruction::Serum3CreateOpenOrders;
|
||||
async fn to_instruction(
|
||||
&self,
|
||||
account_loader: impl ClientAccountLoader + 'async_trait,
|
||||
|
@ -705,11 +705,11 @@ impl<'keypair> ClientInstruction for CreateSerumOpenOrdersInstruction<'keypair>
|
|||
let instruction = Self::Instruction {};
|
||||
|
||||
let account: MangoAccount = account_loader.load(&self.account).await.unwrap();
|
||||
let serum_market: SerumMarket = account_loader.load(&self.serum_market).await.unwrap();
|
||||
let serum_market: Serum3Market = account_loader.load(&self.serum_market).await.unwrap();
|
||||
let open_orders = Pubkey::find_program_address(
|
||||
&[
|
||||
self.account.as_ref(),
|
||||
b"SerumOO".as_ref(),
|
||||
b"Serum3OO".as_ref(),
|
||||
self.serum_market.as_ref(),
|
||||
],
|
||||
&program_id,
|
||||
|
@ -738,7 +738,7 @@ impl<'keypair> ClientInstruction for CreateSerumOpenOrdersInstruction<'keypair>
|
|||
}
|
||||
}
|
||||
|
||||
pub struct PlaceSerumOrderInstruction<'keypair> {
|
||||
pub struct Serum3PlaceOrderInstruction<'keypair> {
|
||||
pub side: u8,
|
||||
pub limit_price: u64,
|
||||
pub max_base_qty: u64,
|
||||
|
@ -754,9 +754,9 @@ pub struct PlaceSerumOrderInstruction<'keypair> {
|
|||
pub serum_market: Pubkey,
|
||||
}
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl<'keypair> ClientInstruction for PlaceSerumOrderInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::PlaceSerumOrder;
|
||||
type Instruction = mango_v4::instruction::PlaceSerumOrder;
|
||||
impl<'keypair> ClientInstruction for Serum3PlaceOrderInstruction<'keypair> {
|
||||
type Accounts = mango_v4::accounts::Serum3PlaceOrder;
|
||||
type Instruction = mango_v4::instruction::Serum3PlaceOrder;
|
||||
async fn to_instruction(
|
||||
&self,
|
||||
account_loader: impl ClientAccountLoader + 'async_trait,
|
||||
|
@ -781,9 +781,9 @@ impl<'keypair> ClientInstruction for PlaceSerumOrderInstruction<'keypair> {
|
|||
};
|
||||
|
||||
let account: MangoAccount = account_loader.load(&self.account).await.unwrap();
|
||||
let serum_market: SerumMarket = account_loader.load(&self.serum_market).await.unwrap();
|
||||
let serum_market: Serum3Market = account_loader.load(&self.serum_market).await.unwrap();
|
||||
let open_orders = account
|
||||
.serum_account_map
|
||||
.serum3_account_map
|
||||
.find(serum_market.market_index)
|
||||
.unwrap()
|
||||
.open_orders;
|
||||
|
|
|
@ -223,7 +223,7 @@ async fn test_health_compute_serum() -> Result<(), TransportError> {
|
|||
serum_markets.push(
|
||||
send_tx(
|
||||
solana,
|
||||
RegisterSerumMarketInstruction {
|
||||
Serum3RegisterMarketInstruction {
|
||||
group,
|
||||
admin,
|
||||
serum_program: context.serum.program_id,
|
||||
|
@ -247,7 +247,7 @@ async fn test_health_compute_serum() -> Result<(), TransportError> {
|
|||
println!("adding market {}", i);
|
||||
send_tx(
|
||||
solana,
|
||||
CreateSerumOpenOrdersInstruction {
|
||||
Serum3CreateOpenOrdersInstruction {
|
||||
account,
|
||||
serum_market,
|
||||
owner,
|
||||
|
|
|
@ -140,7 +140,7 @@ async fn test_serum() -> Result<(), TransportError> {
|
|||
//
|
||||
let serum_market = send_tx(
|
||||
solana,
|
||||
RegisterSerumMarketInstruction {
|
||||
Serum3RegisterMarketInstruction {
|
||||
group,
|
||||
admin,
|
||||
serum_program: context.serum.program_id,
|
||||
|
@ -160,7 +160,7 @@ async fn test_serum() -> Result<(), TransportError> {
|
|||
//
|
||||
let open_orders = send_tx(
|
||||
solana,
|
||||
CreateSerumOpenOrdersInstruction {
|
||||
Serum3CreateOpenOrdersInstruction {
|
||||
account,
|
||||
serum_market,
|
||||
owner,
|
||||
|
@ -174,7 +174,7 @@ async fn test_serum() -> Result<(), TransportError> {
|
|||
let account_data: MangoAccount = solana.get_account(account).await;
|
||||
assert_eq!(
|
||||
account_data
|
||||
.serum_account_map
|
||||
.serum3_account_map
|
||||
.iter_active()
|
||||
.map(|v| (v.open_orders, v.market_index))
|
||||
.collect::<Vec<_>>(),
|
||||
|
@ -186,7 +186,7 @@ async fn test_serum() -> Result<(), TransportError> {
|
|||
//
|
||||
send_tx(
|
||||
solana,
|
||||
PlaceSerumOrderInstruction {
|
||||
Serum3PlaceOrderInstruction {
|
||||
side: 0, // TODO: Bid
|
||||
limit_price: 10, // in quote_lot (10) per base lot (100)
|
||||
max_base_qty: 1, // in base lot (100)
|
||||
|
|
Loading…
Reference in New Issue