Sol.College

Full lesson

BondLadder

Robo-advisor for bond ladders on Solana — USDC in, five rated maturities out, one transaction. Devnet demo.

What it does

From the project README:

Deposit USDC, pick a risk profile, and the vault spreads it across five tokenized debt instruments with staggered maturities — selected by on-chain credit rating. Exit any time before maturity through a liquidity backstop, with the spread priced off the position's remaining duration.
Original
bondladder/BondLadder
SuperStack fork
Blockchains/BondLadder @ 40b1e78
Stars
0
Last push (original)
2026-10-27
Languages
TypeScript, Rust, HTML, CSS, JavaScript
Detected stack
Anchorweb3.js
Categories
Other
Licence
Apache-2.0
Homepage
https://bondladder.github.io/BondLadder/

Architecture

83 source files. By extension: .ts ×38, .rs ×33, .tsx ×10, .js ×2.

Top-level directorySource files
programs33
apps22
scripts15
packages13

On-chain programs: programs/bond-ladder, programs/mock-issuer, programs/rating-oracle

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/bondladder/. 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.

bondladder/BondLadder · programs/rating-oracle/src/lib.rs L61–84 @ 40b1e78 · Apache-2.0 · original
    )]    pub config: Account<'info, OracleConfig>,     #[account(mut)]    pub authority: Signer<'info>,     pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct PublishRating<'info> {    #[account(        seeds = [OracleConfig::SEED],        bump = config.bump,        has_one = authority,    )]    pub config: Account<'info, OracleConfig>,     // init_if_needed тут безпечний: запис перезаписується цілком, а доступ уже    // звужений has_one на конфізі — повторна ініціалізація не дає authority    // нічого понад те, що він і так може зробити наступною публікацією.    #[account(        init_if_needed,        payer = authority,
  1. Line 65 pub authority: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 73 seeds = [OracleConfig::SEED],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 74 bump = config.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 75 has_one = authority,: Checks that a stored pubkey field matches the passed account.
  5. Line 79 // init_if_needed тут безпечний: запис перезаписується цілком, а доступ уже: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
bondladder/BondLadder · programs/mock-issuer/src/lib.rs L73–96 @ 40b1e78 · Apache-2.0 · original
    #[account(        init,        payer = authority,        space = 8 + IssuerConfig::INIT_SPACE,        seeds = [IssuerConfig::SEED],        bump,    )]    pub config: Account<'info, IssuerConfig>,     pub usdc_mint: Account<'info, Mint>,     #[account(mut)]    pub authority: Signer<'info>,     pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct RegisterInstrument<'info> {    #[account(        seeds = [IssuerConfig::SEED],        bump = config.bump,        has_one = authority,    )]
  1. Line 74 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 77 seeds = [IssuerConfig::SEED],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 78 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 85 pub authority: Signer<'info>,: Requires this account to have signed the transaction.
  5. Line 95 has_one = authority,: Checks that a stored pubkey field matches the passed account.
bondladder/BondLadder · programs/mock-issuer/src/instructions/mint_for_usdc.rs L25–48 @ 40b1e78 · Apache-2.0 · original
pub fn handler(ctx: Context<MintForUsdc>, amount_micro: u64) -> Result<Fill> {    let price_micro = ctx.accounts.instrument.price_micro;    require!(price_micro > 0, IssuerError::InvalidPrice);    require!(        Clock::get()?.unix_timestamp < ctx.accounts.instrument.maturity_ts,        IssuerError::MaturityInThePast    );     let Fill { units, spent_micro } = fill_for_share(amount_micro, price_micro);    require!(units > 0, IssuerError::AmountBelowUnitPrice);     token::transfer(        CpiContext::new(            ctx.accounts.token_program.to_account_info(),            Transfer {                from: ctx.accounts.buyer_usdc.to_account_info(),                to: ctx.accounts.treasury.to_account_info(),                authority: ctx.accounts.buyer.to_account_info(),            },        ),        spent_micro,    )?;     token::mint_to(
  1. Line 27 require!(price_micro > 0, IssuerError::InvalidPrice);: An explicit validation that aborts the instruction with an error.
  2. Line 29 Clock::get()?.unix_timestamp < ctx.accounts.instrument.maturity_ts,: Reads on-chain time from the Clock sysvar.
  3. Line 36 token::transfer(: An SPL token transfer through the Token Program.
  4. Line 37 CpiContext::new(: Makes a cross-program invocation into another program.
  5. Line 48 token::mint_to(: Mints new tokens. The mint authority must sign.
bondladder/BondLadder · programs/bond-ladder/src/instructions/exit_ladder.rs L181–203 @ 40b1e78 · Apache-2.0 · original
        .checked_sub(settled.principal_micro)        .ok_or_else(|| error!(LadderError::MathOverflow))?;    position.fee_accrued = settled.fee_carried_micro;    position.last_fee_ts = now_ts;     Ok(())} /// Holdings arrive in `remaining_accounts`, so the address is checked here/// rather than by a seeds constraint, and the first exit through an/// instrument creates its holding.fn credit_holding<'info>(    holding: &AccountInfo<'info>,    rung: &Rung,    units: u64,    payer: &Signer<'info>,    system_program: &Program<'info, System>,) -> Result<()> {    let (address, bump) = Pubkey::find_program_address(        &[BackstopHolding::SEED, rung.instrument.as_ref()],        &crate::ID,    );    require_keys_eq!(holding.key(), address, ErrorCode::ConstraintSeeds);
  1. Line 181 .checked_sub(settled.principal_micro): Uses checked arithmetic so overflow fails instead of wrapping.
  2. Line 196 payer: &Signer<'info>,: Requires this account to have signed the transaction.
  3. Line 199 let (address, bump) = Pubkey::find_program_address(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.
  4. Line 199 let (address, bump) = Pubkey::find_program_address(: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  5. Line 203 require_keys_eq!(holding.key(), address, ErrorCode::ConstraintSeeds);: An explicit validation that aborts the instruction with an error.

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.

DirectoryCommandRuns
.npm run devturbo run dev
.npm run buildturbo run build
.npm run testturbo run test
.npm run lintbiome lint .
packages/sharednpm run testvitest run --passWithNoTests
apps/webnpm run devvite
apps/webnpm run buildtsc --noEmit && vite build
apps/webnpm run testvitest run
apps/keepernpm run devnode --experimental-strip-types src/index.ts
apps/keepernpm run testvitest run --passWithNoTests
scriptsnpm run testvitest run --passWithNoTests
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testpnpm vitest run tests/
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons