Back to docs
DOCS · 03

Four Anchor programs.
Open source. Verifiable.

The protocol is four small Anchor programs that move money, defend price, pay stakers, and issue badges. All code is public. All upgrades require multisig. Upgrade authority revoked by month 6.

★ In plain English

Smart contracts that do the work. COCKY isn't just a token — it's a system. Four programs run permissionlessly on Solana, doing what they're programmed to do, regardless of whether the team shows up to work tomorrow.

fee_router picks up the trading-fee revenue and splits it five ways. floor_defender buys when price drops. staking pays you for locking. sbt_minter issues the diamond-hand badge.

Anyone can read the source. Anyone can audit it. Once we revoke upgrade authority, even we can't change it.

★ The programs
fee_router
FeeRou1eR1111111

Routes Token-2022 transfer fees into the waterfall.

floor_defender
F1oorDefen111111

Reads oracles, conditionally buys + burns when price < floor.

staking
5tak1ng111111111

Lock-and-earn with cumulative_per_share accumulator. No inflation.

sbt_minter
SBTMinter1111111

Verifies Merkle proof, mints non-transferable Token-2022 NFT.

fee_router — the keystone

Owns the Token-2022 withdraw-withheld authority. Anyone can call harvest_and_route() to crank the system. Splits configured on-chain as basis points; ops cut hard-capped at 10%.

Key instructions

initialize
Multisig-signed. Sets governance, mint, and waterfall bps. Validates sum to 10,000.
harvest_and_route
Permissionless. Withdraws withheld fees → Jupiter swap for buyback → splits to LP / floor / staking / ops → emits WaterfallExecuted event.
update_split
Multisig-signed. Adjusts bps within hard caps. Cannot raise ops > 10%.

State shape

#[account]
pub struct Config {
    pub bump: u8,
    pub governance: Pubkey,       // 3-of-5 Squads multisig
    pub mint: Pubkey,             // COCKY mint
    pub buyback_bps: u16,         // 4000 (40%)
    pub lp_bps: u16,              // 2000 (20%)
    pub floor_bps: u16,           // 2000 (20%)
    pub staking_bps: u16,         // 1500 (15%)
    pub ops_bps: u16,             // 500  (5%, capped)
    pub harvest_threshold: u64,   // trigger amount
    pub last_harvest_ts: i64,
    pub cumulative_buybacks: u64, // ratchets the floor
}

Events

#[event]
pub struct WaterfallExecuted {
    pub harvested: u64,
    pub buyback: u64,
    pub lp: u64,
    pub floor: u64,
    pub staking: u64,
    pub ops: u64,
    pub timestamp: i64,
}
floor_defender — the bouncer

Holds a SOL reserve. On defend() calls (permissionless), reads price from Pyth + pool TWAP and conditionally executes a market buy.

Floor formula

floor_usd = base_floor + (ratchet_coeff * cumulative_buybacks) / 1e6

If pool_price_usd < floor_usd && now - last_trigger > COOLDOWN:
    spend_sol = min(reserve_balance, max_per_trigger)
    swap_sol_for_cocky(spend_sol)   // via Jupiter CPI
    burn_cocky(received)            // deflationary
    last_trigger_ts = now
    tokens_defended += received

Key parameters

COOLDOWN_SECONDS
600 (10 minutes between triggers)
base_floor_usd_e6
Starts at e.g., 60% of opening price. Multisig-tunable.
ratchet_coefficient_e6
How fast floor rises with cumulative_buybacks. Multisig-tunable.
max_per_trigger_lamports
Caps single-trigger spend. Limits flash exploits.
pyth_price_feed
Pyth SOL/USD feed account
pool_twap_oracle
Raydium/Meteora pool's 5-min TWAP source

Failure modes

  • · Reserve empty → returns error, doesn't crash
  • · Cooldown not elapsed → returns error
  • · Pyth oracle stale > 60s → returns error (no defense on bad data)
  • · Price above floor → returns error (no defense needed)
staking — yield without dilution

Classic Masterchef-style accumulator. Yield comes from the 15% of fees deposited each harvest — not from inflation.

Math

stake_weight = staked_amount * lock_multiplier * sbt_multiplier
// lock_multiplier: 7d=1.0, 30d=1.5, 90d=2.5, 180d=4.0
// sbt_multiplier:  default 1.0, SBT-holder 1.5

// On each fee_router::harvest_and_route, the staking
// program receives a deposit_rewards(amount) CPI:

acc_reward_per_share += (amount * PRECISION) / total_weight

// On user actions (stake / unstake / claim):
pending = position.weight * acc_reward_per_share / PRECISION - position.reward_debt
position.reward_debt = position.weight * acc_reward_per_share / PRECISION

Lock tiers

7 days
1.0× weight — flexible
30 days
1.5× weight — committed
90 days
2.5× weight — conviction
180 days
4.0× weight — diamond

Early withdraw

If now < unlock_ts on unstake: forfeit all pending rewards AND pay a 10% principal penalty back into the reward pool. Existing stakers benefit when someone breaks early.

sbt_minter — soulbound badges

Token-2022 with NonTransferable extension. Issued by an off-chain indexer that publishes daily Merkle roots committing to (wallet, hold_days, tier).

Flow

  1. Indexer reads all token holders + their hold history from block-1 (via Helius webhooks).
  2. Computes daily a Merkle tree of (wallet, tier, epoch) tuples for every wallet meeting balance ≥ threshold AND hold_days ≥ tier_days.
  3. Multisig signs publish_root(new_root). Stored on-chain in the program State.
  4. Eligible wallet calls claim_sbt(proof, tier) — the program verifies the Merkle proof against the current root and mints a non-transferable Token-2022 NFT with TokenMetadata.
  5. Mint authority is a program PDA. Each wallet can hold at most one SBT per tier.

Tier ladder

Bronze
hold ≥ 0.1% supply for ≥ 30 days
Silver
hold ≥ 0.1% supply for ≥ 90 days
Gold
hold ≥ 0.1% supply for ≥ 180 days
Black Diamond
hold ≥ 0.1% supply for ≥ 365 days