KAGURA 神楽

KAGURA is a continuous-time DeFi primitive on Solana. Two on-chain Anchor programs: a tick-attestation registry, and a USDC funding vault that compounds yield every block instead of every hour.

contact: hello@kagura.network
神楽KAGURA/ docs
v0.1.0 · pre-deployment← back to sitegithub →
operations·treasury top-up

treasury top-up

the showcase vault drains its treasury at rate × principal × dt. operators must top it up before it hits zero. this page is the cadence and the automation pattern.

the instruction

kagura-vault::top_up_treasuryrust
1pub fn top_up_treasury(ctx: Context<TopUpTreasury>, amount: u64) -> Result<()>2 3#[derive(Accounts)]4pub struct TopUpTreasury<'info> {5    pub authority: Signer<'info>,6    #[account(seeds = [VAULT_SEED, authority.key().as_ref()], bump = vault.bump,7              has_one = authority)]8    pub vault: Account<'info, Vault>,9    #[account(mut, address = vault.treasury_account)]10    pub treasury_account: Account<'info, TokenAccount>,11    #[account(mut)]12    pub funder_token_account: Account<'info, TokenAccount>,13    #[account(mut)]14    pub funder: Signer<'info>,15    pub token_program: Program<'info, Token>,16}

cadence formula

how often to top uptext
1per-day drain = principal × rate × 1 day in years2              = principal × rate / 365.253 4example:5  principal = 100,000 USDC      (TVL, the actual money working)6  rate      = 22%7 8  per-day drain = 100,000 × 0.22 / 365.259              ≈ 60.23 USDC / day10 11  if you top up monthly with a 50% buffer, send ≈ 2,710 USDC / month

automation script

The shipped scripts/init-vault.ts includes top-up logic. For an ongoing operation, run a daily cron that checks the treasury balance and tops up if below threshold:

cron/top-up.tsts
1const treasury = await getAccount(conn, treasuryPda);2const balance  = Number(treasury.amount) / 1e6;3 4const principal = await getAccount(conn, principalPda);5const principalUsdc = Number(principal.amount) / 1e6;6 7const dailyDrain = principalUsdc * (RATE_BPS / 10_000) / 365.25;8const minBuffer  = dailyDrain * 14;            // 2 weeks runway9 10if (balance < minBuffer) {11    const topUpAmount = Math.ceil((dailyDrain * 30 - balance) * 1e6); // micro-USDC12    await vault.methods.topUpTreasury(new BN(topUpAmount)).accountsPartial({13        authority: wallet.publicKey,14        vault: vaultPda,15        treasuryAccount: treasuryPda,16        funderTokenAccount: walletAta,17        funder: wallet.publicKey,18        tokenProgram: TOKEN_PROGRAM_ID,19    }).rpc();20    console.log(`topped up ${topUpAmount / 1e6} usdc`);21}

when to replace the treasury model

A pre-funded treasury is fine for a hackathon, a grant deliverable, or an early beta. For production at meaningful TVL, replace the synthetic source with one that produces real yield. See concepts/treasury-model for the roadmap.