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 directory | Source files |
|---|---|
packages | 82 |
apps | 72 |
programs | 32 |
tests | 19 |
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.
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>>,- Line 18
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 20
#[account(has_one = authority @ RewardFloatError::NotPoolAuthority)]: Checks that a stored pubkey field matches the passed account. - Line 24
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 28
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
programs/reward-float/src/instructions/borrow.rs L13–36 @ d22492c · Apache-2.0 · originalconst 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>>,- Line 22
pub operator: Signer<'info>,: Requires this account to have signed the transaction. - Line 24
#[account(mut, has_one = vault)]: Checks that a stored pubkey field matches the passed account. - Line 30
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - 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. - Line 34
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
programs/reward-float/src/instructions/deposit.rs L1–23 @ d22492c · Apache-2.0 · originaluse 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>>,- Line 10
pub lender: Signer<'info>,: Requires this account to have signed the transaction. - Line 12
#[account(mut, has_one = vault)]: Checks that a stored pubkey field matches the passed account. - Line 17
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - 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. - Line 21
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
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],- Line 242
emit!(SweepSkipped {: Emits an Anchor event that clients can parse from the logs. - Line 254
&[ctx.accounts.operator_account.bump],: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 256
token::transfer(: An SPL token transfer through the Token Program. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run build | pnpm -r run build |
. | npm run test | pnpm -r run test |
. | npm run lint | biome lint . |
tests | npm run build | tsc -p tsconfig.json --noEmit |
tests | npm run test | vitest run --passWithNoTests |
apps/web | npm run dev | vite |
apps/web | npm run build | tsc -p tsconfig.json --noEmit && vite build |
apps/web | npm run test | vitest run --passWithNoTests |
apps/api | npm run start | node --env-file-if-exists=../../.env src/index.ts |
apps/api | npm run build | tsc -p tsconfig.json |
apps/api | npm run test | vitest run --passWithNoTests |
apps/worker | npm run build | tsc -p tsconfig.json |
apps/worker | npm run test | vitest run --passWithNoTests |
packages/anchor-client | npm run build | tsc -p tsconfig.json |
packages/anchor-client | npm run test | vitest run --passWithNoTests |
packages/shared | npm run build | tsc -p tsconfig.json |
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