diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8689b9a..8d98e02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: rustup component add clippy rustfmt - name: install libdrift_ffi_sys run: | - curl -L https://github.com/user-attachments/files/17849111/libdrift_ffi_sys.so.zip > ffi.zip + curl -L https://github.com/drift-labs/drift-ffi-sys/releases/download/v2.103.0/libdrift_ffi_sys.so.zip > ffi.zip unzip ffi.zip ldd libdrift_ffi_sys.so sudo cp libdrift_ffi_sys.so $CARGO_DRIFT_FFI_PATH @@ -50,4 +50,4 @@ jobs: env: TEST_DEVNET_RPC_ENDPOINT: ${{ secrets.DEVNET_RPC_ENDPOINT }} TEST_MAINNET_RPC_ENDPOINT: ${{ secrets.MAINNET_RPC_ENDPOINT }} - TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }} \ No newline at end of file + TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }} diff --git a/README.md b/README.md index be6522b..9b18a5e 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ Experimental, high performance Rust SDK for building offchain clients for [Drift ## Install ```toml # crates.io* -drift-rs = "1.0.0-alpha.3" +drift-rs = "1.0.0-alpha.4" # build from source (also builds and links 'libdrift_ffi_sys') -drift-rs = { git = "https://github.com/drift-labs/drift-rs", tag = "v1.0.0-alpha.3" } +drift-rs = { git = "https://github.com/drift-labs/drift-rs", tag = "v1.0.0-alpha.4" } ``` _*_`drift-rs` uses drift program over ffi. @@ -70,3 +70,10 @@ CARGO_DRIFT_FFI_STATIC=1 # Provide a prebuilt drift_ffi_sys lib CARGO_DRIFT_FFI_PATH="/path/to/libdrift_ffi_sys" ``` +## Development + +## Update IDL types +1) copy updated IDL to `res/drift.json` from protocol-v2 branch +2) `cargo check` +3) commit changes + diff --git a/crates/drift-idl-gen/src/lib.rs b/crates/drift-idl-gen/src/lib.rs index 393b46f..2ef586a 100644 --- a/crates/drift-idl-gen/src/lib.rs +++ b/crates/drift-idl-gen/src/lib.rs @@ -64,6 +64,8 @@ impl ArgType { "Pubkey".to_string() } else if t == "bytes" { "Vec".to_string() + } else if t == "string" { + "String".to_string() } else { t.clone() } diff --git a/crates/src/drift_idl.rs b/crates/src/drift_idl.rs index ae29ea4..b15c0de 100644 --- a/crates/src/drift_idl.rs +++ b/crates/src/drift_idl.rs @@ -380,6 +380,17 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for UpdateUserMarginTradingEnabled {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct UpdateUserPoolId { + pub sub_account_id: u16, + pub pool_id: u8, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserPoolId { + const DISCRIMINATOR: [u8; 8] = [219, 86, 73, 106, 56, 218, 128, 109]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserPoolId {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct UpdateUserDelegate { pub sub_account_id: u16, pub delegate: Pubkey, @@ -413,6 +424,17 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for UpdateUserAdvancedLp {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct UpdateUserProtectedMakerOrders { + pub sub_account_id: u16, + pub protected_maker_orders: bool, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserProtectedMakerOrders { + const DISCRIMINATOR: [u8; 8] = [114, 39, 123, 198, 187, 25, 90, 219]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserProtectedMakerOrders {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct DeleteUser {} #[automatically_derived] impl anchor_lang::Discriminator for DeleteUser { @@ -421,6 +443,14 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for DeleteUser {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct ForceDeleteUser {} + #[automatically_derived] + impl anchor_lang::Discriminator for ForceDeleteUser { + const DISCRIMINATOR: [u8; 8] = [2, 241, 195, 172, 227, 24, 254, 158]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for ForceDeleteUser {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct DeleteSwiftUserOrders {} #[automatically_derived] impl anchor_lang::Discriminator for DeleteSwiftUserOrders { @@ -776,6 +806,16 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for UpdateUserGovTokenInsuranceStake {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct UpdateUserGovTokenInsuranceStakeDevnet { + pub gov_stake_amount: u64, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserGovTokenInsuranceStakeDevnet { + const DISCRIMINATOR: [u8; 8] = [129, 185, 243, 183, 228, 111, 64, 175]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserGovTokenInsuranceStakeDevnet {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct InitializeInsuranceFundStake { pub market_index: u16, } @@ -1219,6 +1259,16 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for UpdateInsuranceFundUnstakingPeriod {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct UpdateSpotMarketPoolId { + pub pool_id: u8, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateSpotMarketPoolId { + const DISCRIMINATOR: [u8; 8] = [22, 213, 197, 160, 139, 193, 81, 149]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateSpotMarketPoolId {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct UpdateSpotMarketLiquidationFee { pub liquidator_fee: u32, pub if_liquidation_fee: u32, @@ -1915,6 +1965,27 @@ pub mod instructions { } #[automatically_derived] impl anchor_lang::InstructionData for UpdateHighLeverageModeConfig {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct InitializeProtectedMakerModeConfig { + pub max_users: u32, + } + #[automatically_derived] + impl anchor_lang::Discriminator for InitializeProtectedMakerModeConfig { + const DISCRIMINATOR: [u8; 8] = [67, 103, 220, 67, 88, 32, 252, 8]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for InitializeProtectedMakerModeConfig {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct UpdateProtectedMakerModeConfig { + pub max_users: u32, + pub reduce_only: bool, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateProtectedMakerModeConfig { + const DISCRIMINATOR: [u8; 8] = [86, 166, 235, 253, 67, 202, 223, 17]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateProtectedMakerModeConfig {} } pub mod types { #![doc = r" IDL types"] @@ -2416,7 +2487,7 @@ pub mod types { pub auction_duration: Option, pub auction_start_price: Option, pub auction_end_price: Option, - pub policy: Option, + pub policy: Option, } #[repr(C)] #[derive( @@ -3367,8 +3438,8 @@ pub mod types { )] pub enum ModifyOrderPolicy { #[default] - TryModify, MustModify, + ExcludePreviousFill, } #[derive( AnchorSerialize, @@ -3659,6 +3730,7 @@ pub mod types { Bankrupt, ReduceOnly, AdvancedLp, + ProtectedMakerOrders, } #[derive( AnchorSerialize, @@ -4284,7 +4356,7 @@ pub mod accounts { pub fuel_boost_position: u8, pub fuel_boost_taker: u8, pub fuel_boost_maker: u8, - pub padding1: u8, + pub pool_id: u8, pub high_leverage_margin_ratio_initial: u16, pub high_leverage_margin_ratio_maintenance: u16, #[serde(skip)] @@ -4342,6 +4414,65 @@ pub mod accounts { Debug, PartialEq, )] + pub struct ProtectedMakerModeConfig { + pub max_users: u32, + pub current_users: u32, + pub reduce_only: u8, + #[serde(skip)] + pub padding: Padding<31>, + } + #[automatically_derived] + impl anchor_lang::Discriminator for ProtectedMakerModeConfig { + const DISCRIMINATOR: [u8; 8] = [47, 86, 90, 9, 224, 255, 10, 69]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for ProtectedMakerModeConfig {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for ProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for ProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::AccountSerialize for ProtectedMakerModeConfig { + fn try_serialize(&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 ProtectedMakerModeConfig { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + let mut data: &[u8] = &buf[8..]; + AnchorDeserialize::deserialize(&mut data) + .map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize.into()) + } + } + #[repr(C)] + #[derive( + AnchorSerialize, + AnchorDeserialize, + InitSpace, + Serialize, + Deserialize, + Copy, + Clone, + Default, + Debug, + PartialEq, + )] pub struct RFQUser { pub user_pubkey: Pubkey, pub rfq_order_data: [RFQOrderId; 32], @@ -4461,8 +4592,9 @@ pub mod accounts { pub fuel_boost_maker: u8, pub fuel_boost_insurance: u8, pub token_program: u8, + pub pool_id: u8, #[serde(skip)] - pub padding: Padding<41>, + pub padding: Padding<40>, } #[automatically_derived] impl anchor_lang::Discriminator for SpotMarket { @@ -4666,7 +4798,8 @@ pub mod accounts { pub open_auctions: u8, pub has_open_auction: bool, pub margin_mode: MarginMode, - pub padding1: [u8; 4], + pub pool_id: u8, + pub padding1: [u8; 3], pub last_fuel_bonus_update_ts: u32, #[serde(skip)] pub padding: Padding<12>, @@ -7514,6 +7647,70 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct UpdateUserPoolId { + pub user: Pubkey, + pub authority: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserPoolId { + const DISCRIMINATOR: [u8; 8] = [215, 193, 254, 33, 60, 226, 249, 100]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for UpdateUserPoolId {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdateUserPoolId {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for UpdateUserPoolId {} + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserPoolId {} + #[automatically_derived] + impl ToAccountMetas for UpdateUserPoolId { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.user, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.authority, + is_signer: true, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for UpdateUserPoolId { + fn try_serialize(&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 UpdateUserPoolId { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 UpdateUserDelegate { pub user: Pubkey, pub authority: Pubkey, @@ -7706,6 +7903,82 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct UpdateUserProtectedMakerOrders { + pub state: Pubkey, + pub user: Pubkey, + pub authority: Pubkey, + pub protected_maker_mode_config: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserProtectedMakerOrders { + const DISCRIMINATOR: [u8; 8] = [220, 255, 63, 84, 125, 9, 84, 92]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for UpdateUserProtectedMakerOrders {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdateUserProtectedMakerOrders {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for UpdateUserProtectedMakerOrders {} + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserProtectedMakerOrders {} + #[automatically_derived] + impl ToAccountMetas for UpdateUserProtectedMakerOrders { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.user, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.authority, + is_signer: true, + is_writable: false, + }, + AccountMeta { + pubkey: self.protected_maker_mode_config, + is_signer: false, + is_writable: true, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for UpdateUserProtectedMakerOrders { + fn try_serialize(&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 UpdateUserProtectedMakerOrders { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 DeleteUser { pub user: Pubkey, pub user_stats: Pubkey, @@ -7744,15 +8017,103 @@ pub mod accounts { is_writable: true, }, AccountMeta { - pubkey: self.authority, - is_signer: true, + pubkey: self.authority, + is_signer: true, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for DeleteUser { + fn try_serialize(&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 DeleteUser { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 ForceDeleteUser { + pub user: Pubkey, + pub user_stats: Pubkey, + pub state: Pubkey, + pub authority: Pubkey, + pub keeper: Pubkey, + pub drift_signer: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for ForceDeleteUser { + const DISCRIMINATOR: [u8; 8] = [224, 206, 23, 192, 99, 164, 175, 251]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for ForceDeleteUser {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for ForceDeleteUser {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for ForceDeleteUser {} + #[automatically_derived] + impl anchor_lang::InstructionData for ForceDeleteUser {} + #[automatically_derived] + impl ToAccountMetas for ForceDeleteUser { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.user, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.user_stats, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.authority, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.keeper, + is_signer: true, + is_writable: true, + }, + AccountMeta { + pubkey: self.drift_signer, + is_signer: false, is_writable: false, }, ] } } #[automatically_derived] - impl anchor_lang::AccountSerialize for DeleteUser { + impl anchor_lang::AccountSerialize for ForceDeleteUser { fn try_serialize(&self, writer: &mut W) -> anchor_lang::Result<()> { if writer.write_all(&Self::DISCRIMINATOR).is_err() { return Err(anchor_lang::error::ErrorCode::AccountDidNotSerialize.into()); @@ -7764,7 +8125,7 @@ pub mod accounts { } } #[automatically_derived] - impl anchor_lang::AccountDeserialize for DeleteUser { + impl anchor_lang::AccountDeserialize for ForceDeleteUser { fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { let given_disc = &buf[..8]; if Self::DISCRIMINATOR != given_disc { @@ -10732,6 +11093,70 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct UpdateUserGovTokenInsuranceStakeDevnet { + pub user_stats: Pubkey, + pub signer: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateUserGovTokenInsuranceStakeDevnet { + const DISCRIMINATOR: [u8; 8] = [7, 243, 156, 21, 134, 61, 166, 81]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for UpdateUserGovTokenInsuranceStakeDevnet {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdateUserGovTokenInsuranceStakeDevnet {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for UpdateUserGovTokenInsuranceStakeDevnet {} + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateUserGovTokenInsuranceStakeDevnet {} + #[automatically_derived] + impl ToAccountMetas for UpdateUserGovTokenInsuranceStakeDevnet { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.user_stats, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.signer, + is_signer: true, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for UpdateUserGovTokenInsuranceStakeDevnet { + fn try_serialize(&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 UpdateUserGovTokenInsuranceStakeDevnet { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 InitializeInsuranceFundStake { pub spot_market: Pubkey, pub insurance_fund_stake: Pubkey, @@ -14060,6 +14485,76 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct UpdateSpotMarketPoolId { + pub admin: Pubkey, + pub state: Pubkey, + pub spot_market: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateSpotMarketPoolId { + const DISCRIMINATOR: [u8; 8] = [221, 222, 116, 19, 147, 70, 109, 228]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for UpdateSpotMarketPoolId {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdateSpotMarketPoolId {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for UpdateSpotMarketPoolId {} + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateSpotMarketPoolId {} + #[automatically_derived] + impl ToAccountMetas for UpdateSpotMarketPoolId { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.admin, + is_signer: true, + is_writable: false, + }, + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.spot_market, + is_signer: false, + is_writable: true, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for UpdateSpotMarketPoolId { + fn try_serialize(&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 UpdateSpotMarketPoolId { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 UpdateSpotMarketLiquidationFee { pub admin: Pubkey, pub state: Pubkey, @@ -18739,6 +19234,158 @@ pub mod accounts { .map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize.into()) } } + #[repr(C)] + #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct InitializeProtectedMakerModeConfig { + pub admin: Pubkey, + pub protected_maker_mode_config: Pubkey, + pub state: Pubkey, + pub rent: Pubkey, + pub system_program: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for InitializeProtectedMakerModeConfig { + const DISCRIMINATOR: [u8; 8] = [71, 150, 108, 182, 19, 30, 72, 149]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for InitializeProtectedMakerModeConfig {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for InitializeProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for InitializeProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::InstructionData for InitializeProtectedMakerModeConfig {} + #[automatically_derived] + impl ToAccountMetas for InitializeProtectedMakerModeConfig { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.admin, + is_signer: true, + is_writable: true, + }, + AccountMeta { + pubkey: self.protected_maker_mode_config, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.rent, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.system_program, + is_signer: false, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for InitializeProtectedMakerModeConfig { + fn try_serialize(&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 InitializeProtectedMakerModeConfig { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + 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 UpdateProtectedMakerModeConfig { + pub admin: Pubkey, + pub protected_maker_mode_config: Pubkey, + pub state: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for UpdateProtectedMakerModeConfig { + const DISCRIMINATOR: [u8; 8] = [189, 135, 186, 140, 137, 238, 182, 65]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for UpdateProtectedMakerModeConfig {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for UpdateProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for UpdateProtectedMakerModeConfig {} + #[automatically_derived] + impl anchor_lang::InstructionData for UpdateProtectedMakerModeConfig {} + #[automatically_derived] + impl ToAccountMetas for UpdateProtectedMakerModeConfig { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.admin, + is_signer: true, + is_writable: true, + }, + AccountMeta { + pubkey: self.protected_maker_mode_config, + is_signer: false, + is_writable: true, + }, + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for UpdateProtectedMakerModeConfig { + fn try_serialize(&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 UpdateProtectedMakerModeConfig { + fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result { + 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 { + let mut data: &[u8] = &buf[8..]; + AnchorDeserialize::deserialize(&mut data) + .map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize.into()) + } + } } pub mod errors { #![doc = r" IDL error types"] @@ -19350,6 +19997,10 @@ pub mod errors { SwiftOrderDoesNotExist, #[msg("Swift order id cannot be 0s")] InvalidSwiftOrderId, + #[msg("Invalid pool id")] + InvalidPoolId, + #[msg("Invalid Protected Maker Mode Config")] + InvalidProtectedMakerModeConfig, } } pub mod events { @@ -19585,4 +20236,12 @@ pub mod events { pub deposit_token_amount_before: u64, pub amount: u64, } + #[event] + pub struct DeleteUserRecord { + pub ts: i64, + pub user_authority: Pubkey, + pub user: Pubkey, + pub sub_account_id: u16, + pub keeper: Option, + } } diff --git a/res/drift.json b/res/drift.json index c72e535..7c2d534 100644 --- a/res/drift.json +++ b/res/drift.json @@ -1,5 +1,5 @@ { - "version": "2.100.0", + "version": "2.103.0", "name": "drift", "instructions": [ { @@ -1357,6 +1357,31 @@ } ] }, + { + "name": "updateUserPoolId", + "accounts": [ + { + "name": "user", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "poolId", + "type": "u8" + } + ] + }, { "name": "updateUserDelegate", "accounts": [ @@ -1432,6 +1457,41 @@ } ] }, + { + "name": "updateUserProtectedMakerOrders", + "accounts": [ + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "user", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "protectedMakerModeConfig", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "protectedMakerOrders", + "type": "bool" + } + ] + }, { "name": "deleteUser", "accounts": [ @@ -1458,6 +1518,42 @@ ], "args": [] }, + { + "name": "forceDeleteUser", + "accounts": [ + { + "name": "user", + "isMut": true, + "isSigner": false + }, + { + "name": "userStats", + "isMut": true, + "isSigner": false + }, + { + "name": "state", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": false + }, + { + "name": "keeper", + "isMut": true, + "isSigner": true + }, + { + "name": "driftSigner", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, { "name": "deleteSwiftUserOrders", "accounts": [ @@ -2737,6 +2833,27 @@ ], "args": [] }, + { + "name": "updateUserGovTokenInsuranceStakeDevnet", + "accounts": [ + { + "name": "userStats", + "isMut": true, + "isSigner": false + }, + { + "name": "signer", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "govStakeAmount", + "type": "u64" + } + ] + }, { "name": "initializeInsuranceFundStake", "accounts": [ @@ -4443,6 +4560,32 @@ } ] }, + { + "name": "updateSpotMarketPoolId", + "accounts": [ + { + "name": "admin", + "isMut": false, + "isSigner": true + }, + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "spotMarket", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "poolId", + "type": "u8" + } + ] + }, { "name": "updateSpotMarketLiquidationFee", "accounts": [ @@ -6358,6 +6501,72 @@ "type": "bool" } ] + }, + { + "name": "initializeProtectedMakerModeConfig", + "accounts": [ + { + "name": "admin", + "isMut": true, + "isSigner": true + }, + { + "name": "protectedMakerModeConfig", + "isMut": true, + "isSigner": false + }, + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + } + ] + }, + { + "name": "updateProtectedMakerModeConfig", + "accounts": [ + { + "name": "admin", + "isMut": true, + "isSigner": true + }, + { + "name": "protectedMakerModeConfig", + "isMut": true, + "isSigner": false + }, + { + "name": "state", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] } ], "accounts": [ @@ -6982,7 +7191,7 @@ "type": "u8" }, { - "name": "padding1", + "name": "poolId", "type": "u8" }, { @@ -7005,6 +7214,35 @@ ] } }, + { + "name": "ProtectedMakerModeConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "currentUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 31 + ] + } + } + ] + } + }, { "name": "RFQUser", "type": { @@ -7518,12 +7756,16 @@ "name": "tokenProgram", "type": "u8" }, + { + "name": "poolId", + "type": "u8" + }, { "name": "padding", "type": { "array": [ "u8", - 41 + 40 ] } } @@ -7904,12 +8146,16 @@ "defined": "MarginMode" } }, + { + "name": "poolId", + "type": "u8" + }, { "name": "padding1", "type": { "array": [ "u8", - 4 + 3 ] } }, @@ -8910,9 +9156,7 @@ { "name": "policy", "type": { - "option": { - "defined": "ModifyOrderPolicy" - } + "option": "u8" } } ] @@ -10805,7 +11049,8 @@ { "name": "PlaceAndTake", "fields": [ - "bool" + "bool", + "u8" ] }, { @@ -10958,10 +11203,10 @@ "kind": "enum", "variants": [ { - "name": "TryModify" + "name": "MustModify" }, { - "name": "MustModify" + "name": "ExcludePreviousFill" } ] } @@ -11277,6 +11522,9 @@ }, { "name": "AdvancedLp" + }, + { + "name": "ProtectedMakerOrders" } ] } @@ -11818,8 +12066,7 @@ }, { "name": "hash", - "doc": "capitalized to (S)tring for drift-idl-gen to work easier", - "type": "String", + "type": "string", "index": false }, { @@ -12488,6 +12735,38 @@ "index": false } ] + }, + { + "name": "DeleteUserRecord", + "fields": [ + { + "name": "ts", + "type": "i64", + "index": false + }, + { + "name": "userAuthority", + "type": "publicKey", + "index": false + }, + { + "name": "user", + "type": "publicKey", + "index": false + }, + { + "name": "subAccountId", + "type": "u16", + "index": false + }, + { + "name": "keeper", + "type": { + "option": "publicKey" + }, + "index": false + } + ] } ], "errors": [ @@ -14000,6 +14279,16 @@ "code": 6301, "name": "InvalidSwiftOrderId", "msg": "Swift order id cannot be 0s" + }, + { + "code": 6302, + "name": "InvalidPoolId", + "msg": "Invalid pool id" + }, + { + "code": 6303, + "name": "InvalidProtectedMakerModeConfig", + "msg": "Invalid Protected Maker Mode Config" } ], "metadata": {