Full lesson
attention-oracle-program
Source for TWZRD's on-chain programs: the immutable Attention Oracle (vault deposits, Merkle claims, Token-2022 fee harvesting) and the upgradeable wzrd-rails program on Solana mainnet. Includes audit report and self-verification steps.
What it does
From the project README:
The historical Squads V4 multisig `BX2fRy4Jfko3cMttDmn2n6CaHfa9iAqT69YgAKZis9EQ` is retired for `token_2022`; it is not the current upgrade authority.
- Original
- twzrd-sol/attention-oracle-program
- SuperStack fork
- Blockchains/attention-oracle-program @
ebf2f1a - Stars
- 0
- Last push (original)
- 2026-10-09
- Languages
- Rust, TypeScript
- Detected stack
- AnchorPinocchio
- Categories
- DeFi
- Licence
- MIT
Architecture
62 source files. By extension: .rs ×58, .ts ×4.
| Top-level directory | Source files |
|---|---|
programs | 58 |
scripts | 4 |
On-chain programs: programs/attention-oracle, programs/evidence-ledger, programs/wzrd-markets, programs/wzrd-rails
Dapp: devnet deploy pending
⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/attention-oracle-program/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.
Key code, explained
Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.
programs/wzrd-rails/src/lib.rs L1009–1032 @ ebf2f1a · MIT · original &proof, &ctx.accounts.config.comp_merkle_root, ), RailsError::CompensationInvalidProof ); require!( ctx.accounts.comp_vault.amount >= amount, RailsError::CompensationUnavailable ); let slot = Clock::get()?.slot; let config_ai = ctx.accounts.config.to_account_info(); let signer_seeds: &[&[&[u8]]] = &[&[CONFIG_SEED, &[ctx.accounts.config.bump]]]; let transfer_ctx = CpiContext::new_with_signer( ctx.accounts.token_2022_program.to_account_info(), TransferChecked { from: ctx.accounts.comp_vault.to_account_info(), mint: ctx.accounts.ccm_mint.to_account_info(), to: ctx.accounts.user_ccm.to_account_info(), authority: config_ai, }, signer_seeds, ); token_interface::transfer_checked(transfer_ctx, amount, ctx.accounts.ccm_mint.decimals)?;- Line 1014
require!(: An explicit validation that aborts the instruction with an error. - Line 1019
let slot = Clock::get()?.slot;: Reads on-chain time from the Clock sysvar. - Line 1021
let signer_seeds: &[&[&[u8]]] = &[&[CONFIG_SEED, &[ctx.accounts.config.bump]]];: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 1022
let transfer_ctx = CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address. - Line 1023
ctx.accounts.token_2022_program.to_account_info(),: Targets the Token-2022 program instead of the original Token Program. - Line 1024
TransferChecked {: A checked token transfer, which also verifies the mint and decimals.
programs/attention-oracle/src/instructions/vault.rs L289–312 @ ebf2f1a · MIT · original .checked_mul(10_000) .ok_or(OracleError::MathOverflow)? .checked_div(effective_nav) .ok_or(OracleError::MathOverflow)?; require!(shares_to_mint > 0, OracleError::InvalidInputLength); // 3. Mint vLOFI (shares_to_mint) to user (ProtocolState PDA as mint authority) let protocol_bump = ctx.accounts.protocol_state.bump; let protocol_seeds = &[b"protocol_state".as_ref(), &[protocol_bump]]; let signer = &[&protocol_seeds[..]]; let mint_accounts = MintTo { mint: ctx.accounts.vlofi_mint.to_account_info(), to: ctx.accounts.user_vlofi_ata.to_account_info(), authority: ctx.accounts.protocol_state.to_account_info(), }; mint_to( CpiContext::new_with_signer( ctx.accounts.token_program.to_account_info(), mint_accounts, signer, ), shares_to_mint, )?;- Line 289
.checked_mul(10_000): Uses checked arithmetic so overflow fails instead of wrapping. - Line 293
require!(shares_to_mint > 0, OracleError::InvalidInputLength);: An explicit validation that aborts the instruction with an error. - Line 296
let protocol_bump = ctx.accounts.protocol_state.bump;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 297
let protocol_seeds = &[b"protocol_state".as_ref(), &[protocol_bump]];: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 300
let mint_accounts = MintTo {: Mints new tokens. The mint authority must sign. - Line 306
CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address.
programs/attention-oracle/src/instructions/governance.rs L409–432 @ ebf2f1a · MIT · original require!(!protocol_state.paused, OracleError::ProtocolPaused); require!(amount > 0, OracleError::InvalidInputLength); require!(min_reserve > 0, OracleError::InvalidInputLength); let treasury_balance = ctx.accounts.treasury_ata.amount; let balance_after = treasury_balance .checked_sub(amount) .ok_or(OracleError::InsufficientTreasuryBalance)?; require!( balance_after >= min_reserve, OracleError::InsufficientTreasuryBalance ); let seeds: &[&[u8]] = &[PROTOCOL_SEED, mint_key.as_ref(), &[protocol_state.bump]]; let signer_seeds = &[seeds]; transfer_checked( CpiContext::new_with_signer( ctx.accounts.token_program.to_account_info(), TransferChecked { from: ctx.accounts.treasury_ata.to_account_info(), mint: ctx.accounts.mint.to_account_info(), to: ctx.accounts.destination_ata.to_account_info(),- Line 410
require!(!protocol_state.paused, OracleError::ProtocolPaused);: An explicit validation that aborts the instruction with an error. - Line 416
.checked_sub(amount): Uses checked arithmetic so overflow fails instead of wrapping. - Line 423
let seeds: &[&[u8]] = &[PROTOCOL_SEED, mint_key.as_ref(), &[protocol_state.bump]];: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 424
let signer_seeds = &[seeds];: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 426
transfer_checked(: A checked token transfer, which also verifies the mint and decimals. - Line 427
CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address.
programs/wzrd-markets/src/lib.rs L2209–2232 @ ebf2f1a · MIT · original #[account(address = TOKEN_2022_PROGRAM_ID @ MarketsError::InvalidMarketState)] pub outcome_token_program: Program<'info, Token2022>, /// Token program backing the USDC mint (standard SPL or Token-2022). pub usdc_token_program: Interface<'info, TokenInterface>, pub system_program: Program<'info, System>, pub rent: Sysvar<'info, Rent>,} /// Accounts for `mint_complete_set` (Phase 1).////// Deposit N USDC → mint N YES + N NO (the fixed-par rail). The mint-authority/// PDA signs the two `mint_to` CPIs; the depositor signs the USDC transfer-in.#[derive(Accounts)]pub struct MintCompleteSet<'info> { #[account(mut)] pub depositor: Signer<'info>, #[account( seeds = [MARKET_SEED, &market.market_id.to_le_bytes()], bump = market.bump, )] pub market: Account<'info, Market>, #[account(- Line 2209
#[account(address = TOKEN_2022_PROGRAM_ID @ MarketsError::InvalidMarketState)]: Targets the Token-2022 program instead of the original Token Program. - Line 2220
/// PDA signs the two `mint_to` CPIs; the depositor signs the USDC transfer-in.: Mints new tokens. The mint authority must sign. - Line 2224
pub depositor: Signer<'info>,: Requires this account to have signed the transaction. - Line 2227
seeds = [MARKET_SEED, &market.market_id.to_le_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 2228
bump = market.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
How to run, build and test
These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.
| Directory | Command | Runs |
|---|---|---|
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | cargo build | Rust workspace build |
. | cargo test | Rust tests |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)
- Learn the pattern first: SPL Tokens: mints, accounts and transfers