protobook_api/
sdk.rs

1use steel::*;
2
3use crate::prelude::*;
4
5pub fn open(authority: Pubkey, amount_a: u64, amount_b: u64, expires_at: i64, fee: u64, id: [u8; 32], mint_a: Pubkey, mint_b: Pubkey) -> Instruction {
6    let sender = spl_associated_token_account::get_associated_token_address(&authority, &mint_a);
7    Instruction {
8        program_id: crate::ID,
9        accounts: vec![
10            AccountMeta::new(authority, true),
11            AccountMeta::new(mint_a, false),
12            AccountMeta::new(mint_b, false),
13            AccountMeta::new(order_pda(authority, id).0, false),
14            AccountMeta::new(sender, false),
15            AccountMeta::new_readonly(system_program::ID, false),
16        ],
17        data: Open {
18            amount_a,
19            amount_b,
20            expires_at,
21            fee,
22            id,
23        }.to_bytes()
24    }
25}