Skip to content

ioc => bit_flags on OrderParams #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
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
106 changes: 103 additions & 3 deletions crates/src/drift_idl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anchor_lang::{
};
use serde::{Deserialize, Serialize};
use solana_sdk::{instruction::AccountMeta, pubkey::Pubkey};
pub const IDL_VERSION: &str = "2.118.0";
pub const IDL_VERSION: &str = "2.119.0";
use self::traits::ToAccountMetas;
pub mod traits {
use solana_sdk::instruction::AccountMeta;
Expand Down Expand Up @@ -1893,6 +1893,17 @@ pub mod instructions {
#[automatically_derived]
impl anchor_lang::InstructionData for UpdatePerpMarketFuel {}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)]
pub struct UpdatePerpMarketProtectedMakerParams {
pub protected_maker_limit_price_divisor: Option<u8>,
pub protected_maker_dynamic_divisor: Option<u8>,
}
#[automatically_derived]
impl anchor_lang::Discriminator for UpdatePerpMarketProtectedMakerParams {
const DISCRIMINATOR: &[u8] = &[249, 213, 115, 34, 253, 239, 75, 173];
}
#[automatically_derived]
impl anchor_lang::InstructionData for UpdatePerpMarketProtectedMakerParams {}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)]
pub struct UpdateSpotMarketFuel {
pub fuel_boost_deposits: Option<u8>,
pub fuel_boost_borrows: Option<u8>,
Expand Down Expand Up @@ -2455,7 +2466,7 @@ pub mod types {
pub market_index: u16,
pub reduce_only: bool,
pub post_only: PostOnlyParam,
pub immediate_or_cancel: bool,
pub bit_flags: u8,
pub max_ts: Option<i64>,
pub trigger_price: Option<u64>,
pub trigger_condition: OrderTriggerCondition,
Expand Down Expand Up @@ -2542,7 +2553,7 @@ pub mod types {
pub price: Option<u64>,
pub reduce_only: Option<bool>,
pub post_only: Option<PostOnlyParam>,
pub immediate_or_cancel: Option<bool>,
pub bit_flags: Option<u8>,
pub max_ts: Option<i64>,
pub trigger_price: Option<u64>,
pub trigger_condition: Option<OrderTriggerCondition>,
Expand Down Expand Up @@ -3469,6 +3480,23 @@ pub mod types {
Debug,
PartialEq,
)]
pub enum OrderParamsBitFlag {
#[default]
ImmediateOrCancel,
UpdateHighLeverageMode,
}
#[derive(
AnchorSerialize,
AnchorDeserialize,
InitSpace,
Serialize,
Deserialize,
Copy,
Clone,
Default,
Debug,
PartialEq,
)]
pub enum PostOnlyParam {
#[default]
None,
Expand Down Expand Up @@ -19131,6 +19159,76 @@ pub mod accounts {
}
#[repr(C)]
#[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)]
pub struct UpdatePerpMarketProtectedMakerParams {
pub admin: Pubkey,
pub state: Pubkey,
pub perp_market: Pubkey,
}
#[automatically_derived]
impl anchor_lang::Discriminator for UpdatePerpMarketProtectedMakerParams {
const DISCRIMINATOR: &[u8] = &[31, 187, 231, 244, 165, 74, 103, 137];
}
#[automatically_derived]
unsafe impl anchor_lang::__private::bytemuck::Pod for UpdatePerpMarketProtectedMakerParams {}
#[automatically_derived]
unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdatePerpMarketProtectedMakerParams {}
#[automatically_derived]
impl anchor_lang::ZeroCopy for UpdatePerpMarketProtectedMakerParams {}
#[automatically_derived]
impl anchor_lang::InstructionData for UpdatePerpMarketProtectedMakerParams {}
#[automatically_derived]
impl ToAccountMetas for UpdatePerpMarketProtectedMakerParams {
fn to_account_metas(&self) -> Vec<AccountMeta> {
vec![
AccountMeta {
pubkey: self.admin,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: self.state,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: self.perp_market,
is_signer: false,
is_writable: true,
},
]
}
}
#[automatically_derived]
impl anchor_lang::AccountSerialize for UpdatePerpMarketProtectedMakerParams {
fn try_serialize<W: std::io::Write>(&self, writer: &mut W) -> anchor_lang::Result<()> {
if writer.write_all(Self::DISCRIMINATOR).is_err() {
return Err(anchor_lang::error::ErrorCode::AccountDidNotSerialize.into());
}
if AnchorSerialize::serialize(self, writer).is_err() {
return Err(anchor_lang::error::ErrorCode::AccountDidNotSerialize.into());
}
Ok(())
}
}
#[automatically_derived]
impl anchor_lang::AccountDeserialize for UpdatePerpMarketProtectedMakerParams {
fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
let given_disc = &buf[..8];
if Self::DISCRIMINATOR != given_disc {
return Err(anchor_lang::error!(
anchor_lang::error::ErrorCode::AccountDiscriminatorMismatch
));
}
Self::try_deserialize_unchecked(buf)
}
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
let mut data: &[u8] = &buf[8..];
AnchorDeserialize::deserialize(&mut data)
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize.into())
}
}
#[repr(C)]
#[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)]
pub struct UpdateSpotMarketFuel {
pub admin: Pubkey,
pub state: Pubkey,
Expand Down Expand Up @@ -21221,6 +21319,8 @@ pub mod errors {
InvalidTransferPerpPosition,
#[msg("Invalid SignedMsgUserOrders resize")]
InvalidSignedMsgUserOrdersResize,
#[msg("Could not deserialize high leverage mode config")]
CouldNotDeserializeHighLeverageModeConfig,
}
}
pub mod events {
Expand Down
2 changes: 1 addition & 1 deletion crates/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub fn simulate_place_perp_order(
///
/// Returns `true` if the order's auctions will get sanitized
pub fn simulate_will_auction_params_sanitize(
order_params: &mut types::OrderParams,
order_params: &types::OrderParams,
perp_market: &accounts::PerpMarket,
oracle_price: i64,
is_signed_msg: bool,
Expand Down
2 changes: 1 addition & 1 deletion crates/src/swift_order_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ mod tests {
market_index: 2,
reduce_only: false,
post_only: PostOnlyParam::None,
immediate_or_cancel: false,
bit_flags: 0,
max_ts: None,
trigger_price: None,
trigger_condition: OrderTriggerCondition::Above,
Expand Down
10 changes: 5 additions & 5 deletions crates/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub struct NewOrder {
reduce_only: bool,
market_id: MarketId,
post_only: PostOnlyParam,
ioc: bool,
ioc: u8,
amount: u64,
price: u64,
user_order_id: u8,
Expand Down Expand Up @@ -253,9 +253,9 @@ impl NewOrder {
self.reduce_only = flag;
self
}
/// Set immediate or cancel (default: false)
pub fn ioc(mut self, flag: bool) -> Self {
self.ioc = flag;
/// Set immediate or cancel and other flags (default: false)
pub fn bit_flags(mut self, flags: u8) -> Self {
self.ioc = flags;
self
}
/// Set post-only (default: None)
Expand All @@ -278,7 +278,7 @@ impl NewOrder {
base_asset_amount: self.amount,
reduce_only: self.reduce_only,
direction: self.direction,
immediate_or_cancel: self.ioc,
bit_flags: self.ioc,
post_only: self.post_only,
user_order_id: self.user_order_id,
..Default::default()
Expand Down
65 changes: 59 additions & 6 deletions res/drift.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.118.0",
"version": "2.119.0",
"name": "drift",
"instructions": [
{
Expand Down Expand Up @@ -6415,6 +6415,40 @@
}
]
},
{
"name": "updatePerpMarketProtectedMakerParams",
"accounts": [
{
"name": "admin",
"isMut": false,
"isSigner": true
},
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "protectedMakerLimitPriceDivisor",
"type": {
"option": "u8"
}
},
{
"name": "protectedMakerDynamicDivisor",
"type": {
"option": "u8"
}
}
]
},
{
"name": "updateSpotMarketFuel",
"accounts": [
Expand Down Expand Up @@ -9436,8 +9470,8 @@
}
},
{
"name": "immediateOrCancel",
"type": "bool"
"name": "bitFlags",
"type": "u8"
},
{
"name": "maxTs",
Expand Down Expand Up @@ -9634,9 +9668,9 @@
}
},
{
"name": "immediateOrCancel",
"name": "bitFlags",
"type": {
"option": "bool"
"option": "u8"
}
},
{
Expand Down Expand Up @@ -11714,6 +11748,20 @@
]
}
},
{
"name": "OrderParamsBitFlag",
"type": {
"kind": "enum",
"variants": [
{
"name": "ImmediateOrCancel"
},
{
"name": "UpdateHighLeverageMode"
}
]
}
},
{
"name": "PostOnlyParam",
"type": {
Expand Down Expand Up @@ -15078,9 +15126,14 @@
"code": 6313,
"name": "InvalidSignedMsgUserOrdersResize",
"msg": "Invalid SignedMsgUserOrders resize"
},
{
"code": 6314,
"name": "CouldNotDeserializeHighLeverageModeConfig",
"msg": "Could not deserialize high leverage mode config"
}
],
"metadata": {
"address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
}
}
}