{"gen":473,"hash":"491fc65935390f05","source":"// EVOLVE policy program, generation 473\n// Written by the agent, accepted by the verifier. The agent key can call\n// these instructions and nothing else. No mint, no freeze, no withdraw.\nuse anchor_lang::prelude::*;\nuse evolve_lib::{pump, pool, token, vault, merkle, lp_lock, meta, split, Cage};\n\npub const CLAIM_EVERY: i64 = 60;                 // fixed: every minute\npub const AGENT_SHARE: u16 = 8000;               // fixed: 80% of creator fees reach this program\npub const TO_BUYBACK: u16 = 1000;\npub const TO_LP: u16 = 6500;\npub const TO_HOLDERS: u16 = 2500;\npub const BURN_OF_BUYBACK: u16 = 10000;\n\npub const DIP_TRIGGER_PCT: u8 = 3;\npub const CHUNK_BPS: u16 = 120;\npub const SLIPPAGE_BPS: u16 = 90;\npub const BUYBACK_GAP: i64 = 10 * 60;\npub const HOLD_FOR: i64 = 2880 * 60;\npub const MIN_HOLD_BPS: u16 = 1;\npub const WHALE_CAP_BPS: u16 = 300;\n\n#[program]\npub mod evolve_policy_g473 {\n    use super::*;\n\n    /// Distribute the coin's creator fees (pump.fun fee sharing): 80% lands here, 20% goes to the dev for thinking.\n    pub fn claim_creator_fees(ctx: Context<Claim>) -> Result<()> {\n        require!(ctx.accounts.clock.unix_timestamp - ctx.accounts.state.last_claim >= CLAIM_EVERY, Cage::TooSoon);\n        pump::collect_creator_fee(ctx.accounts.into_pump_ctx())?;\n        ctx.accounts.state.last_claim = ctx.accounts.clock.unix_timestamp;\n        split::route(&mut ctx.accounts.state, ctx.accounts.vault.lamports())\n    }\n\n    /// Buy $EVOLVE from the curve or PumpSwap pool with the buyback bucket.\n    pub fn buyback(ctx: Context<Buyback>, lamports: u64) -> Result<()> {\n        let s = &mut ctx.accounts.state;\n        require!(lamports <= s.buyback_bucket, Cage::OverBudget);\n        require!(lamports <= pool::liquidity(&ctx.accounts.pool)? * CHUNK_BPS as u64 / 10_000, Cage::TooBig);\n        require!(ctx.accounts.clock.unix_timestamp - s.last_buyback >= BUYBACK_GAP, Cage::TooSoon);\n        require!(pool::drawdown_pct(&ctx.accounts.pool)? >= DIP_TRIGGER_PCT, Cage::NoDip);\n        let bought = pool::buy(ctx.accounts.into_swap_ctx(), lamports, SLIPPAGE_BPS)?;\n        s.buyback_bucket -= lamports;\n        s.last_buyback = ctx.accounts.clock.unix_timestamp;\n        s.bought_unburned += bought;\n        Ok(())\n    }\n\n    /// Burn the configured share of everything bought back.\n    pub fn burn(ctx: Context<BurnBought>) -> Result<()> {\n        let amount = ctx.accounts.state.bought_unburned * BURN_OF_BUYBACK as u64 / 10_000;\n        token::burn(ctx.accounts.into_burn_ctx(), amount)?;\n        ctx.accounts.state.bought_unburned = 0;\n        Ok(())\n    }\n\n    /// Deepen the PumpSwap pool with the lp bucket (after migration).\n    pub fn add_liquidity(ctx: Context<AddLp>) -> Result<()> {\n        let lamports = std::mem::take(&mut ctx.accounts.state.lp_bucket);\n        pool::deposit_balanced(ctx.accounts.into_deposit_ctx(), lamports, SLIPPAGE_BPS)\n    }\n\n    /// LP tokens go to a vault this program can never take back out of.\n    pub fn lock_lp(ctx: Context<LockLp>) -> Result<()> {\n        lp_lock::lock_forever(ctx.accounts.into_lock_ctx())\n    }\n\n    /// Commit a merkle root of eligible holders (held HOLD_FOR, bag >= MIN_HOLD_BPS).\n    pub fn snapshot_holders(ctx: Context<Snapshot>, root: [u8; 32], total_weight: u64) -> Result<()> {\n        ctx.accounts.state.drop_root = root;\n        ctx.accounts.state.drop_weight = total_weight;\n        Ok(())\n    }\n\n    /// Holders claim their share against the snapshot. Capped per wallet.\n    pub fn airdrop_claim(ctx: Context<DropClaim>, weight: u64, proof: Vec<[u8; 32]>) -> Result<()> {\n        let s = &ctx.accounts.state;\n        merkle::verify(&proof, s.drop_root, ctx.accounts.holder.key(), weight)?;\n        let share = (s.airdrop_bucket * weight / s.drop_weight).min(s.airdrop_bucket * WHALE_CAP_BPS as u64 / 10_000);\n        vault::pay(ctx.accounts.into_pay_ctx(), share)\n    }\n}\n"}