carbon_openbook_v2_decoder/instructions/
set_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 = "0xf21e2e4c6ceb80b5")]
7pub struct SetDelegate {}
8
9pub struct SetDelegateInstructionAccounts {
10    pub owner: solana_pubkey::Pubkey,
11    pub open_orders_account: solana_pubkey::Pubkey,
12    pub delegate_account: solana_pubkey::Pubkey,
13}
14
15impl carbon_core::deserialize::ArrangeAccounts for SetDelegate {
16    type ArrangedAccounts = SetDelegateInstructionAccounts;
17
18    fn arrange_accounts(
19        accounts: &[solana_instruction::AccountMeta],
20    ) -> Option<Self::ArrangedAccounts> {
21        let [owner, open_orders_account, delegate_account, _remaining @ ..] = accounts else {
22            return None;
23        };
24
25        Some(SetDelegateInstructionAccounts {
26            owner: owner.pubkey,
27            open_orders_account: open_orders_account.pubkey,
28            delegate_account: delegate_account.pubkey,
29        })
30    }
31}