1pub mod states;
3
4pub mod instructions;
6
7pub mod roles;
9
10pub mod constants;
12
13use anchor_lang::prelude::*;
14use gmsol_store::utils::CpiAuthenticate;
15use instructions::*;
16
17declare_id!("GTuvYD5SxkTq4FLG6JV1FQ5dkczr1AfgDcBHaFsBdtBg");
18
19#[program]
20pub mod gmsol_treasury {
21
22 use super::*;
23
24 pub fn initialize_config(ctx: Context<InitializeConfig>) -> Result<()> {
26 instructions::initialize_config(ctx)
27 }
28
29 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
31 pub fn set_treasury_vault_config(ctx: Context<SetTreasuryVaultConfig>) -> Result<()> {
32 instructions::unchecked_set_treasury_vault_config(ctx)
33 }
34
35 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
37 pub fn set_gt_factor(ctx: Context<UpdateConfig>, factor: u128) -> Result<()> {
38 instructions::unchecked_set_gt_factor(ctx, factor)
39 }
40
41 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
43 pub fn set_buyback_factor(ctx: Context<UpdateConfig>, factor: u128) -> Result<()> {
44 instructions::unchecked_set_buyback_factor(ctx, factor)
45 }
46
47 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
49 pub fn initialize_treasury_vault_config(
50 ctx: Context<InitializeTreasuryVaultConfig>,
51 index: u16,
52 ) -> Result<()> {
53 instructions::unchecked_initialize_treasury_vault_config(ctx, index)
54 }
55
56 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
61 pub fn insert_token_to_treasury_vault(ctx: Context<InsertTokenToTreasuryVault>) -> Result<()> {
62 instructions::unchecked_insert_token_to_treasury_vault(ctx)
63 }
64
65 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
70 pub fn remove_token_from_treasury_vault(
71 ctx: Context<RemoveTokenFromTreasuryVault>,
72 ) -> Result<()> {
73 instructions::unchecked_remove_token_from_treasury_vault(ctx)
74 }
75
76 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
86 pub fn toggle_token_flag(
87 ctx: Context<ToggleTokenFlag>,
88 flag: String,
89 value: bool,
90 ) -> Result<()> {
91 instructions::unchecked_toggle_token_flag(ctx, &flag, value)
92 }
93
94 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
96 pub fn deposit_to_treasury_vault(ctx: Context<DepositToTreasuryVault>) -> Result<()> {
97 instructions::unchecked_deposit_to_treasury_vault(ctx)
98 }
99
100 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_WITHDRAWER))]
102 pub fn withdraw_from_treasury_vault(
103 ctx: Context<WithdrawFromTreasuryVault>,
104 amount: u64,
105 decimals: u8,
106 ) -> Result<()> {
107 instructions::unchecked_withdraw_from_treasury_vault(ctx, amount, decimals)
108 }
109
110 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
112 pub fn confirm_gt_buyback<'info>(
113 ctx: Context<'_, '_, 'info, 'info, ConfirmGtBuyback<'info>>,
114 ) -> Result<()> {
115 instructions::unchecked_confirm_gt_buyback(ctx)
116 }
117
118 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_OWNER))]
120 pub fn transfer_receiver(ctx: Context<TransferReceiver>) -> Result<()> {
121 instructions::unchecked_transfer_receiver(ctx)
122 }
123
124 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_ADMIN))]
126 pub fn set_referral_reward(ctx: Context<SetReferralReward>, factors: Vec<u128>) -> Result<()> {
127 instructions::unchecked_set_referral_reward(ctx, factors)
128 }
129
130 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
132 pub fn claim_fees(ctx: Context<ClaimFees>, min_amount: u64) -> Result<()> {
133 instructions::unchecked_claim_fees(ctx, min_amount)
134 }
135
136 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
138 pub fn prepare_gt_bank(ctx: Context<PrepareGtBank>) -> Result<()> {
139 instructions::unchecked_prepare_gt_bank(ctx)
140 }
141
142 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_WITHDRAWER))]
144 pub fn sync_gt_bank(ctx: Context<SyncGtBank>) -> Result<()> {
145 instructions::unchecked_sync_gt_bank(ctx)
146 }
147
148 pub fn complete_gt_exchange<'info>(
150 ctx: Context<'_, '_, 'info, 'info, CompleteGtExchange<'info>>,
151 ) -> Result<()> {
152 instructions::complete_gt_exchange(ctx)
153 }
154
155 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
157 pub fn create_swap<'info>(
158 ctx: Context<'_, '_, 'info, 'info, CreateSwap<'info>>,
159 nonce: [u8; 32],
160 swap_path_length: u8,
161 swap_in_amount: u64,
162 min_swap_out_amount: Option<u64>,
163 ) -> Result<()> {
164 instructions::unchecked_create_swap(
165 ctx,
166 nonce,
167 swap_path_length,
168 swap_in_amount,
169 min_swap_out_amount,
170 )
171 }
172
173 #[access_control(CpiAuthenticate::only(&ctx, roles::TREASURY_KEEPER))]
175 pub fn cancel_swap(ctx: Context<CancelSwap>) -> Result<()> {
176 instructions::unchecked_cancel_swap(ctx)
177 }
178}