Sol.College

Full lesson

DePIN-Reward-Float

Stablecoin microcredit for DePIN operators, underwritten against future token rewards and priced from their verified on-chain payout history on Solana.

What it does

From the project README:

Stablecoin microcredit for DePIN hardware operators, underwritten against **future** token rewards and priced from the verified on-chain history of the payouts they have already received.
Original
ChestDepin/DePIN-Reward-Float
SuperStack fork
Blockchains/DePIN-Reward-Float @ d22492c
Stars
0
Last push (original)
2026-10-27
Languages
TypeScript, Rust, HTML, CSS, JavaScript, Shell
Detected stack
Anchorweb3.js
Categories
DeFiDePIN
Licence
Apache-2.0
Homepage
https://chestdepin.github.io/DePIN-Reward-Float/

Architecture

205 source files. By extension: .ts ×159, .rs ×32, .tsx ×14.

Top-level directorySource files
packages82
apps72
programs32
tests19

On-chain programs: programs/reward-float

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/depin-reward-float/. 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.

ChestDepin/DePIN-Reward-Float · programs/reward-float/src/instructions/init_conversion_vault.rs L13–35 @ d22492c · Apache-2.0 · original
#[derive(Accounts)]pub struct InitConversionVault<'info> {    // The pool authority: the tolerance of FR-015a decides when withholding is skipped,    // and the first caller would otherwise set it for the pool.    #[account(mut)]    pub authority: Signer<'info>,     #[account(has_one = authority @ RewardFloatError::NotPoolAuthority)]    pub pool: Box<Account<'info, Pool>>,     #[account(        init,        payer = authority,        space = 8 + ConversionVault::INIT_SPACE,        seeds = [CONVERSION_SEED, pool.key().as_ref(), reward_mint.key().as_ref()],        bump,    )]    pub conversion_vault: Box<Account<'info, ConversionVault>>,     pub reward_mint: Box<Account<'info, Mint>>,     #[account(address = pool.stable_mint)]    pub stable_mint: Box<Account<'info, Mint>>,
  1. Line 18 pub authority: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 20 #[account(has_one = authority @ RewardFloatError::NotPoolAuthority)]: Checks that a stored pubkey field matches the passed account.
  3. Line 24 init,: Creates and pays for a new account. Space and payer must be specified.
  4. Line 27 seeds = [CONVERSION_SEED, pool.key().as_ref(), reward_mint.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 28 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
ChestDepin/DePIN-Reward-Float · programs/reward-float/src/instructions/borrow.rs L13–36 @ d22492c · Apache-2.0 · original
const BASIS_POINTS: u16 = 10_000; // The rate is in stablecoin base units for this many reward base units.const RATE_UNIT: u128 = 1_000_000_000_000; #[derive(Accounts)]#[instruction(nonce: u64)]pub struct Borrow<'info> {    #[account(mut)]    pub operator: Signer<'info>,     #[account(mut, has_one = vault)]    pub pool: Box<Account<'info, Pool>>,     // Opened by the first loan rather than by an instruction of its own, so that    // borrowing stays one transaction signed by the operator (FR-008).    #[account(        init_if_needed,        payer = operator,        space = 8 + OperatorAccount::INIT_SPACE,        seeds = [OPERATOR_SEED, operator.key().as_ref()],        bump,    )]    pub operator_account: Box<Account<'info, OperatorAccount>>,
  1. Line 22 pub operator: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 24 #[account(mut, has_one = vault)]: Checks that a stored pubkey field matches the passed account.
  3. Line 30 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  4. Line 33 seeds = [OPERATOR_SEED, operator.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 34 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
ChestDepin/DePIN-Reward-Float · programs/reward-float/src/instructions/deposit.rs L1–23 @ d22492c · Apache-2.0 · original
use anchor_lang::prelude::*;use anchor_spl::token::{self, Token, TokenAccount, Transfer}; use crate::error::RewardFloatError;use crate::state::{LenderShare, Pool, SHARE_SEED}; #[derive(Accounts)]pub struct Deposit<'info> {    #[account(mut)]    pub lender: Signer<'info>,     #[account(mut, has_one = vault)]    pub pool: Box<Account<'info, Pool>>,     // Opened by the first deposit, so that lending stays one transaction.    #[account(        init_if_needed,        payer = lender,        space = 8 + LenderShare::INIT_SPACE,        seeds = [SHARE_SEED, pool.key().as_ref(), lender.key().as_ref()],        bump,    )]    pub lender_share: Box<Account<'info, LenderShare>>,
  1. Line 10 pub lender: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 12 #[account(mut, has_one = vault)]: Checks that a stored pubkey field matches the passed account.
  3. Line 17 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  4. Line 20 seeds = [SHARE_SEED, pool.key().as_ref(), lender.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 21 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
ChestDepin/DePIN-Reward-Float · programs/reward-float/src/instructions/sweep.rs L241–264 @ d22492c · Apache-2.0 · original
            }            emit!(SweepSkipped {                operator,                reward_mint,                withheld: total_withheld,                stable_per_trillion_reward: rate,                deviation_bps: check.deviation_bps,                max_slippage_bps: conversion.max_slippage_bps,            });        } else {            let operator_seeds: &[&[u8]] = &[                OPERATOR_SEED,                operator.as_ref(),                &[ctx.accounts.operator_account.bump],            ];            token::transfer(                CpiContext::new_with_signer(                    ctx.accounts.token_program.to_account_info(),                    Transfer {                        from: ctx.accounts.reward_account.to_account_info(),                        to: ctx.accounts.reward_vault.to_account_info(),                        authority: ctx.accounts.operator_account.to_account_info(),                    },                    &[operator_seeds],
  1. Line 242 emit!(SweepSkipped {: Emits an Anchor event that clients can parse from the logs.
  2. Line 254 &[ctx.accounts.operator_account.bump],: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 256 token::transfer(: An SPL token transfer through the Token Program.
  4. Line 257 CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address.

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 buildpnpm -r run build
.npm run testpnpm -r run test
.npm run lintbiome lint .
testsnpm run buildtsc -p tsconfig.json --noEmit
testsnpm run testvitest run --passWithNoTests
apps/webnpm run devvite
apps/webnpm run buildtsc -p tsconfig.json --noEmit && vite build
apps/webnpm run testvitest run --passWithNoTests
apps/apinpm run startnode --env-file-if-exists=../../.env src/index.ts
apps/apinpm run buildtsc -p tsconfig.json
apps/apinpm run testvitest run --passWithNoTests
apps/workernpm run buildtsc -p tsconfig.json
apps/workernpm run testvitest run --passWithNoTests
packages/anchor-clientnpm run buildtsc -p tsconfig.json
packages/anchor-clientnpm run testvitest run --passWithNoTests
packages/sharednpm run buildtsc -p tsconfig.json

What you could build from it

Used in lessons