Skip to content

Commit

Permalink
anchor: fund account -> state account
Browse files Browse the repository at this point in the history
  • Loading branch information
yurushao committed Jan 10, 2025
1 parent 4d71452 commit fb15fe2
Show file tree
Hide file tree
Showing 30 changed files with 848 additions and 726 deletions.
10 changes: 5 additions & 5 deletions anchor/libs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ pub fn share_class_signer_seeds(_attr: TokenStream, item: TokenStream) -> TokenS
#(#func_attrs)*
#func_vis #func_sig {
// We assume the fund account and the treasury bump seed are available in the context
let fund_key = ctx.accounts.fund.key();
let state_key = ctx.accounts.state.key();
let seeds = &[
"share".as_bytes(),
&[share_class_id],
fund_key.as_ref(),
state_key.as_ref(),
&[ctx.bumps.share_class_mint],
];
let share_class_signer_seeds = &[&seeds[..]];
Expand All @@ -69,10 +69,10 @@ pub fn vault_signer_seeds(_attr: TokenStream, item: TokenStream) -> TokenStream
#(#func_attrs)*
#func_vis #func_sig {
// We assume the fund account and the vault bump seed are available in the context
let fund_key = ctx.accounts.fund.key();
let state_key = ctx.accounts.state.key();
let seeds = [
b"treasury".as_ref(),
fund_key.as_ref(),
"treasury".as_ref(),
state_key.as_ref(),
&[ctx.bumps.vault],
];
let vault_signer_seeds = &[&seeds[..]];
Expand Down
13 changes: 12 additions & 1 deletion anchor/programs/glam/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ use anchor_lang::prelude::*;
use solana_program::pubkey;

#[constant]
pub const SEED: &str = "anchor";
pub const SEED_STATE: &str = "fund";
#[constant]
pub const SEED_VAULT: &str = "treasury";
#[constant]
pub const SEED_METADATA: &str = "openfunds";
#[constant]
pub const SEED_MINT: &str = "share";

pub const DEFAULT_DRIFT_USER_NAME: [u8; 32] = [
b'G', b'L', b'A', b'M', b' ', b'*', b'.', b'+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
];

pub const MAX_ASSETS: usize = 5;
pub const MAX_SHARE_CLASSES: usize = 3;
Expand Down
107 changes: 52 additions & 55 deletions anchor/programs/glam/src/instructions/drift.rs

Large diffs are not rendered by default.

Loading

0 comments on commit fb15fe2

Please sign in to comment.