carbon_token_2022_decoder/instructions/
update_multiplier_scaled_ui_mint.rs

1//! This code was AUTOGENERATED using the Codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun Codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12
13/// Update the multiplier. Only supported for mints that include the
14/// `ScaledUiAmountConfig` extension.
15/// You can set a specific timestamp for the multiplier to take effect.
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
18pub struct UpdateMultiplierScaledUiMint {
19    pub scaled_ui_amount_mint_discriminator: u8,
20    /// The new multiplier for the scaled UI extension
21    pub multiplier: f64,
22    /// The timestamp at which the new multiplier will take effect
23    pub effective_timestamp: i64,
24}
25
26#[derive(Debug, Clone, PartialEq)]
27#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
28pub struct UpdateMultiplierScaledUiMintInstructionAccounts {
29    pub mint: solana_pubkey::Pubkey,
30    pub authority: solana_pubkey::Pubkey,
31    pub remaining: Vec<solana_instruction::AccountMeta>,
32}
33
34impl UpdateMultiplierScaledUiMint {
35    pub fn decode(data: &[u8]) -> Option<Self> {
36        if data.len() < 2 {
37            return None;
38        }
39        let discriminator = &data[0..1];
40        if discriminator != [43] {
41            return None;
42        }
43        let scaled_ui_amount_mint_discriminator = data[1];
44        if scaled_ui_amount_mint_discriminator != 1 {
45            return None;
46        }
47
48        let data_slice = data;
49
50        let data_slice = &data_slice[1..];
51
52        Self::deserialize(data_slice)
53    }
54}
55
56impl ArrangeAccounts for UpdateMultiplierScaledUiMint {
57    type ArrangedAccounts = UpdateMultiplierScaledUiMintInstructionAccounts;
58
59    fn arrange_accounts(
60        accounts: &[solana_instruction::AccountMeta],
61    ) -> Option<Self::ArrangedAccounts> {
62        let mut iter = accounts.iter();
63
64        let mint = next_account(&mut iter)?;
65        let authority = next_account(&mut iter)?;
66
67        let remaining = iter.as_slice();
68
69        Some(UpdateMultiplierScaledUiMintInstructionAccounts {
70            mint,
71            authority,
72            remaining: remaining.to_vec(),
73        })
74    }
75}