diff --git a/crates/src/constants.rs b/crates/src/constants.rs index 200e373..529c4e6 100644 --- a/crates/src/constants.rs +++ b/crates/src/constants.rs @@ -198,7 +198,7 @@ pub fn oracle_source_to_owner(context: Context, source: OracleSource) -> Pubkey OracleSource::Switchboard => ids::switchboard_program::ID, OracleSource::SwitchboardOnDemand => ids::switchboard_on_demand::ID, OracleSource::QuoteAsset => DEFAULT_PUBKEY, - OracleSource::Prelaunch => PROGRAM_ID, + OracleSource::Prelaunch | OracleSource::PythLazer => PROGRAM_ID, } } diff --git a/crates/src/drift_idl.rs b/crates/src/drift_idl.rs index ff1d969..086f8fb 100644 --- a/crates/src/drift_idl.rs +++ b/crates/src/drift_idl.rs @@ -2,6 +2,7 @@ #![doc = r""] #![doc = r" Auto-generated IDL types, manual edits do not persist (see `crates/drift-idl-gen`)"] #![doc = r""] +use self::traits::ToAccountMetas; use anchor_lang::{ prelude::{ account, @@ -12,8 +13,6 @@ use anchor_lang::{ }; use serde::{Deserialize, Serialize}; use solana_sdk::{instruction::AccountMeta, pubkey::Pubkey}; - -use self::traits::ToAccountMetas; pub mod traits { use solana_sdk::instruction::AccountMeta; #[doc = r" This is distinct from the anchor_lang version of the trait"] @@ -226,7 +225,6 @@ pub mod instructions { impl anchor_lang::InstructionData for PlaceAndMakeSwiftPerpOrder {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct PlaceSwiftTakerOrder { - pub swift_message_bytes: Vec, pub swift_order_params_message_bytes: Vec, } #[automatically_derived] @@ -535,6 +533,14 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for UpdateUserIdle {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct LogUserBalances {} + #[automatically_derived] + impl anchor_lang::Discriminator for LogUserBalances { + const DISCRIMINATOR: [u8; 8] = [162, 21, 35, 251, 32, 57, 161, 210]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for LogUserBalances {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct DisableUserHighLeverageMode {} #[automatically_derived] impl anchor_lang::Discriminator for DisableUserHighLeverageMode { @@ -1946,6 +1952,26 @@ pub mod instructions { #[automatically_derived] impl anchor_lang::InstructionData for InitializePythPullOracle {} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct InitializePythLazerOracle { + pub feed_id: u32, + } + #[automatically_derived] + impl anchor_lang::Discriminator for InitializePythLazerOracle { + const DISCRIMINATOR: [u8; 8] = [140, 107, 33, 214, 235, 219, 103, 20]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for InitializePythLazerOracle {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] + pub struct PostPythLazerOracleUpdate { + pub pyth_message: Vec, + } + #[automatically_derived] + impl anchor_lang::Discriminator for PostPythLazerOracleUpdate { + const DISCRIMINATOR: [u8; 8] = [218, 237, 170, 245, 39, 143, 166, 33]; + } + #[automatically_derived] + impl anchor_lang::InstructionData for PostPythLazerOracleUpdate {} + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct InitializeHighLeverageModeConfig { pub max_users: u32, } @@ -1990,9 +2016,8 @@ pub mod instructions { } pub mod types { #![doc = r" IDL types"] - use std::ops::Mul; - use super::*; + use std::ops::Mul; #[doc = ""] #[doc = " backwards compatible u128 deserializing data from rust <=1.76.0 when u/i128 was 8-byte aligned"] #[doc = " https://solana.stackexchange.com/questions/7720/using-u128-without-sacrificing-alignment-8"] @@ -2362,27 +2387,11 @@ pub mod types { Debug, PartialEq, )] - pub struct SwiftServerMessage { - pub uuid: [u8; 8], - pub swift_order_signature: Signature, - pub slot: u64, - } - #[repr(C)] - #[derive( - AnchorSerialize, - AnchorDeserialize, - InitSpace, - Serialize, - Deserialize, - Copy, - Clone, - Default, - Debug, - PartialEq, - )] pub struct SwiftOrderParamsMessage { pub swift_order_params: OrderParams, pub sub_account_id: u16, + pub slot: u64, + pub uuid: [u8; 8], pub take_profit_order_params: Option, pub stop_loss_order_params: Option, } @@ -3406,6 +3415,7 @@ pub mod types { Pyth1MPull, PythStableCoinPull, SwitchboardOnDemand, + PythLazer, } #[derive( AnchorSerialize, @@ -4475,6 +4485,67 @@ pub mod accounts { Debug, PartialEq, )] + pub struct PythLazerOracle { + pub price: i64, + pub publish_time: u64, + pub posted_slot: u64, + pub exponent: i32, + #[serde(skip)] + pub padding: Padding<4>, + pub conf: u64, + } + #[automatically_derived] + impl anchor_lang::Discriminator for PythLazerOracle { + const DISCRIMINATOR: [u8; 8] = [159, 7, 161, 249, 34, 81, 121, 133]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for PythLazerOracle {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for PythLazerOracle {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for PythLazerOracle {} + #[automatically_derived] + impl anchor_lang::AccountSerialize for PythLazerOracle { + 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 PythLazerOracle { + 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], @@ -8859,6 +8930,76 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct LogUserBalances { + pub state: Pubkey, + pub authority: Pubkey, + pub user: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for LogUserBalances { + const DISCRIMINATOR: [u8; 8] = [121, 191, 93, 132, 153, 217, 15, 171]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for LogUserBalances {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for LogUserBalances {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for LogUserBalances {} + #[automatically_derived] + impl anchor_lang::InstructionData for LogUserBalances {} + #[automatically_derived] + impl ToAccountMetas for LogUserBalances { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.state, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.authority, + is_signer: true, + is_writable: false, + }, + AccountMeta { + pubkey: self.user, + is_signer: false, + is_writable: true, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for LogUserBalances { + 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 LogUserBalances { + 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 DisableUserHighLeverageMode { pub state: Pubkey, pub authority: Pubkey, @@ -19086,6 +19227,158 @@ pub mod accounts { } #[repr(C)] #[derive(Copy, Clone, Default, AnchorSerialize, AnchorDeserialize, Serialize, Deserialize)] + pub struct InitializePythLazerOracle { + pub admin: Pubkey, + pub lazer_oracle: Pubkey, + pub state: Pubkey, + pub rent: Pubkey, + pub system_program: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for InitializePythLazerOracle { + const DISCRIMINATOR: [u8; 8] = [89, 72, 144, 241, 94, 171, 28, 143]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for InitializePythLazerOracle {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for InitializePythLazerOracle {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for InitializePythLazerOracle {} + #[automatically_derived] + impl anchor_lang::InstructionData for InitializePythLazerOracle {} + #[automatically_derived] + impl ToAccountMetas for InitializePythLazerOracle { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.admin, + is_signer: true, + is_writable: true, + }, + AccountMeta { + pubkey: self.lazer_oracle, + 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 InitializePythLazerOracle { + 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 InitializePythLazerOracle { + 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 PostPythLazerOracleUpdate { + pub keeper: Pubkey, + pub pyth_lazer_storage: Pubkey, + pub ix_sysvar: Pubkey, + } + #[automatically_derived] + impl anchor_lang::Discriminator for PostPythLazerOracleUpdate { + const DISCRIMINATOR: [u8; 8] = [168, 250, 82, 74, 96, 140, 128, 207]; + } + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Pod for PostPythLazerOracleUpdate {} + #[automatically_derived] + unsafe impl anchor_lang::__private::bytemuck::Zeroable for PostPythLazerOracleUpdate {} + #[automatically_derived] + impl anchor_lang::ZeroCopy for PostPythLazerOracleUpdate {} + #[automatically_derived] + impl anchor_lang::InstructionData for PostPythLazerOracleUpdate {} + #[automatically_derived] + impl ToAccountMetas for PostPythLazerOracleUpdate { + fn to_account_metas(&self) -> Vec { + vec![ + AccountMeta { + pubkey: self.keeper, + is_signer: true, + is_writable: true, + }, + AccountMeta { + pubkey: self.pyth_lazer_storage, + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: self.ix_sysvar, + is_signer: false, + is_writable: false, + }, + ] + } + } + #[automatically_derived] + impl anchor_lang::AccountSerialize for PostPythLazerOracleUpdate { + 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 PostPythLazerOracleUpdate { + 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 InitializeHighLeverageModeConfig { pub admin: Pubkey, pub high_leverage_mode_config: Pubkey, @@ -19949,9 +20242,9 @@ pub mod errors { OracleWrongVaaOwner, #[msg("Multi updates must have 2 or fewer accounts passed in remaining accounts")] OracleTooManyPriceAccountUpdates, - #[msg("Don't have the same remaining accounts number and merkle price updates left")] + #[msg("Don't have the same remaining accounts number and pyth updates left")] OracleMismatchedVaaAndPriceUpdates, - #[msg("Remaining account passed is not a valid pda")] + #[msg("Remaining account passed does not match oracle update derived pda")] OracleBadRemainingAccountPublicKey, #[msg("FailedOpenbookV2CPI")] FailedOpenbookV2CPI, @@ -20003,6 +20296,14 @@ pub mod errors { InvalidPoolId, #[msg("Invalid Protected Maker Mode Config")] InvalidProtectedMakerModeConfig, + #[msg("Invalid pyth lazer storage owner")] + InvalidPythLazerStorageOwner, + #[msg("Verification of pyth lazer message failed")] + UnverifiedPythLazerMessage, + #[msg("Invalid pyth lazer message")] + InvalidPythLazerMessage, + #[msg("Pyth lazer message does not correspond to correct fed id")] + PythLazerMessagePriceFeedMismatch, } } pub mod events { diff --git a/res/drift.json b/res/drift.json index 7ec66c7..22561a4 100644 --- a/res/drift.json +++ b/res/drift.json @@ -813,10 +813,6 @@ } ], "args": [ - { - "name": "swiftMessageBytes", - "type": "bytes" - }, { "name": "swiftOrderParamsMessageBytes", "type": "bytes" @@ -1857,6 +1853,27 @@ ], "args": [] }, + { + "name": "logUserBalances", + "accounts": [ + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "user", + "isMut": true, + "isSigner": false + } + ], + "args": [] + }, { "name": "disableUserHighLeverageMode", "accounts": [ @@ -6436,6 +6453,68 @@ } ] }, + { + "name": "initializePythLazerOracle", + "accounts": [ + { + "name": "admin", + "isMut": true, + "isSigner": true + }, + { + "name": "lazerOracle", + "isMut": true, + "isSigner": false + }, + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "feedId", + "type": "u32" + } + ] + }, + { + "name": "postPythLazerOracleUpdate", + "accounts": [ + { + "name": "keeper", + "isMut": true, + "isSigner": true + }, + { + "name": "pythLazerStorage", + "isMut": false, + "isSigner": false + }, + { + "name": "ixSysvar", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "pythMessage", + "type": "bytes" + } + ] + }, { "name": "initializeHighLeverageModeConfig", "accounts": [ @@ -7243,6 +7322,43 @@ ] } }, + { + "name": "PythLazerOracle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" + }, + { + "name": "publishTime", + "type": "u64" + }, + { + "name": "postedSlot", + "type": "u64" + }, + { + "name": "exponent", + "type": "i32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "conf", + "type": "u64" + } + ] + } + }, { "name": "RFQUser", "type": { @@ -8882,50 +8998,33 @@ } }, { - "name": "SwiftServerMessage", + "name": "SwiftOrderParamsMessage", "type": { "kind": "struct", "fields": [ { - "name": "uuid", + "name": "swiftOrderParams", "type": { - "array": [ - "u8", - 8 - ] + "defined": "OrderParams" } }, { - "name": "swiftOrderSignature", - "type": { - "array": [ - "u8", - 64 - ] - } + "name": "subAccountId", + "type": "u16" }, { "name": "slot", "type": "u64" - } - ] - } - }, - { - "name": "SwiftOrderParamsMessage", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "swiftOrderParams", + "name": "uuid", "type": { - "defined": "OrderParams" + "array": [ + "u8", + 8 + ] } }, - { - "name": "subAccountId", - "type": "u16" - }, { "name": "takeProfitOrderParams", "type": { @@ -11173,6 +11272,9 @@ }, { "name": "SwitchboardOnDemand" + }, + { + "name": "PythLazer" } ] } @@ -12066,7 +12168,7 @@ }, { "name": "hash", - "type": "String", + "type": "string", "index": false }, { @@ -14158,12 +14260,12 @@ { "code": 6277, "name": "OracleMismatchedVaaAndPriceUpdates", - "msg": "Don't have the same remaining accounts number and merkle price updates left" + "msg": "Don't have the same remaining accounts number and pyth updates left" }, { "code": 6278, "name": "OracleBadRemainingAccountPublicKey", - "msg": "Remaining account passed is not a valid pda" + "msg": "Remaining account passed does not match oracle update derived pda" }, { "code": 6279, @@ -14289,6 +14391,26 @@ "code": 6303, "name": "InvalidProtectedMakerModeConfig", "msg": "Invalid Protected Maker Mode Config" + }, + { + "code": 6304, + "name": "InvalidPythLazerStorageOwner", + "msg": "Invalid pyth lazer storage owner" + }, + { + "code": 6305, + "name": "UnverifiedPythLazerMessage", + "msg": "Verification of pyth lazer message failed" + }, + { + "code": 6306, + "name": "InvalidPythLazerMessage", + "msg": "Invalid pyth lazer message" + }, + { + "code": 6307, + "name": "PythLazerMessagePriceFeedMismatch", + "msg": "Pyth lazer message does not correspond to correct fed id" } ], "metadata": {