Skip to content

Instantly share code, notes, and snippets.

@alecchendev
Created April 9, 2022 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecchendev/5a456b42db7c83d732f6c203f013a443 to your computer and use it in GitHub Desktop.
Save alecchendev/5a456b42db7c83d732f6c203f013a443 to your computer and use it in GitHub Desktop.
// in `state.rs`
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::pubkey::Pubkey;
#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
pub struct Pool {
pub mint_a: Pubkey,
pub mint_b: Pubkey,
pub mint: Pubkey,
pub fee: u64,
pub fee_decimals: u64,
}
// code inside of `process_instruction`
// pool_account is of type `AccountInfo` retrieved previously
let pool = Pool::try_from_slice(&pool_account.try_borrow_data()?)?;
msg!("pool fee: {}", pool.fee);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment