carbon_drift_v2_decoder/instructions/
update_user_delegate.rs

1use carbon_core::{borsh, CarbonDeserialize};
2
3#[derive(
4    CarbonDeserialize, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Hash,
5)]
6#[carbon(discriminator = "0x8bcd8d8d71245ebb")]
7pub struct UpdateUserDelegate {
8    pub sub_account_id: u16,
9    pub delegate: solana_pubkey::Pubkey,
10}
11
12pub struct UpdateUserDelegateInstructionAccounts {
13    pub user: solana_pubkey::Pubkey,
14    pub authority: solana_pubkey::Pubkey,
15}
16
17impl carbon_core::deserialize::ArrangeAccounts for UpdateUserDelegate {
18    type ArrangedAccounts = UpdateUserDelegateInstructionAccounts;
19
20    fn arrange_accounts(
21        accounts: &[solana_instruction::AccountMeta],
22    ) -> Option<Self::ArrangedAccounts> {
23        let [user, authority, _remaining @ ..] = accounts else {
24            return None;
25        };
26
27        Some(UpdateUserDelegateInstructionAccounts {
28            user: user.pubkey,
29            authority: authority.pubkey,
30        })
31    }
32}