Expand description
§jiminy
The zero-copy standard library for Solana programs.
Every pinocchio needs a conscience.
You chose pinocchio because you wanted raw performance and full control over your on-chain program. No allocator, no borsh, no framework opinions. Just bytes.
But you’re still writing the same signer check for the tenth time. You’re
still hand-rolling amount * price / 10_000 and praying it doesn’t overflow
at 4.2 billion tokens. And every check you forget to write is one exploit
away from draining your vault.
jiminy is the standard library that pinocchio doesn’t ship. Every guard,
check, reader, and piece of math that DeFi programs need – packaged as
plain functions and declarative macros. no_std, no_alloc, no proc
macros, every function #[inline(always)], pinocchio under the hood.
use jiminy::prelude::*;§Modules
§Ring 1 – jiminy_core
| Module | |
|---|---|
account | Header, reader, writer, cursor, lifecycle, pod, overlay, collection, list, bits |
abi | Alignment-safe LE wire types (LeU64, FieldRef, FieldMut) |
check | Validation checks, asserts, PDA derivation & verification |
math | Checked arithmetic, BPS, scaling |
instruction | Transaction introspection (sysvar Instructions) |
interface | Read-only foreign account interface macro |
state | State machine transition checks |
sysvar | Clock & Rent sysvar readers |
time | Deadline, cooldown, staleness checks |
event | Zero-alloc event emission via sol_log_data |
programs | Well-known program IDs (feature: programs) |
§Ring 2 – jiminy_solana
| Module | |
|---|---|
token | SPL Token account readers, mint readers, Token-2022 extension screening |
cpi | Safe CPI wrappers, reentrancy guards, return data readers |
crypto | Ed25519 precompile verification, Merkle proof verification |
authority | Two-step authority rotation (propose + accept) |
balance | Pre/post CPI balance delta guards |
compute | Compute budget guards |
compose | Transaction composition guards (flash-loan detection) |
introspect | Raw transaction introspection |
oracle | Pyth V2 price feed readers |
twap | TWAP accumulators |
upgrade | Program upgrade authority verification (feature: programs) |
§Ring 3+
| Crate | |
|---|---|
jiminy_finance | AMM math, slippage / economic bounds |
jiminy_lending | Lending protocol primitives |
jiminy_staking | Staking reward accumulators |
jiminy_vesting | Vesting schedule helpers |
jiminy_multisig | M-of-N multi-signer threshold |
jiminy_distribute | Dust-safe proportional distribution |
§Macros
All macros are declarative (macro_rules!). No proc macros, no build
dependency, no compile-time surprises.
| Macro | |
|---|---|
require! | if !cond { return Err(e) } – the universal guard |
require_keys_eq! | Two addresses must match |
require_keys_neq! | Two addresses must differ |
require_gte! | a >= b |
require_gt! | a > b |
require_lt! | a < b |
require_lte! | a <= b |
require_eq! | Scalar equality |
require_neq! | Scalar inequality |
require_flag! | Bit must be set |
check_accounts_unique! | Pairwise uniqueness for any N accounts |
error_codes! | Sequential error constants + Into<ProgramError> |
instruction_dispatch! | Byte-tag dispatch to handler functions |
impl_pod! | Batch unsafe impl Pod for primitive types |
Re-exports§
pub use jiminy_core;pub use jiminy_solana;pub use jiminy_finance;pub use jiminy_lending;pub use jiminy_staking;pub use jiminy_vesting;pub use jiminy_multisig;pub use jiminy_distribute;pub use pinocchio;pub use pinocchio_system;pub use pinocchio_token;
Modules§
- abi
- Jiminy ABI field primitives — alignment-1 wire types.
- account
- Account-centric types: header, zero-copy IO, lifecycle, POD, iteration.
- amm
- AMM math: integer square root, constant-product swap formulas, LP minting.
- authority
- Two-step authority handoff (propose + accept).
- balance
- Balance delta checks for CPI composition.
- check
- Account and instruction validation checks.
- compat
- Compatibility modules for optional external crate integrations.
- compose
- Transaction composition guards.
- compute
- Compute unit budget guards.
- cpi
- Safe CPI wrappers, reentrancy guards, and return data readers.
- crypto
- Cryptographic verification: Ed25519 precompile and Merkle proofs.
- distribute
- Dust-safe proportional distribution and fee extraction.
- event
- Zero-alloc event emission via
sol_log_data. - instruction
- Unified instruction access via Sysvar Instructions.
- interface
- Cross-program ABI interface for read-only foreign account access.
- introspect
- Transaction introspection via Sysvar Instructions.
- lending
- Lending protocol primitives: collateralization, liquidation, interest.
- math
- multisig
- M-of-N multi-signer threshold checks.
- oracle
- Zero-copy Pyth V2 price feed readers.
- prelude
- Convenience re-exports for the common Jiminy usage pattern.
- programs
- slippage
- Slippage and economic bound checks.
- staking
- Staking reward accumulators (MasterChef-style).
- state
- State machine transition checks.
- sysvar
- Zero-copy sysvar readers.
- time
- Time and deadline constraint checks for DeFi programs.
- token
- SPL Token readers, mint readers, and Token-2022 extension screening.
- twap
- TWAP (time-weighted average price) accumulator math.
- upgrade
- Program upgrade authority verification.
- vesting
- Vesting schedule helpers: linear, cliff, stepped, periodic.
Macros§
- check_
account - Composable account constraint macro.
- check_
accounts_ unique - Verify that all passed accounts have unique addresses.
- close_
account - Close a Jiminy account: transfer lamports and write close sentinel.
- error_
codes - Define numbered program error codes that map to
ProgramError::Custom. - impl_
pod - Batch
unsafe impl Podfor a list of types. - init_
account - Initialize a Jiminy account: CPI CreateAccount, zero-init, write header.
- instruction_
dispatch - Route instruction data to handler functions based on a single-byte tag.
- require
- Require a boolean condition: return
$err(converted viaInto) if false. - require_
accounts_ ne - Require two accounts to have different addresses.
- require_
eq - Require
a == bfor scalar types. - require_
flag - Require bit
nto be set in$byte, else return$err. - require_
gt - Require
a > b. - require_
gte - Require
a >= b. - require_
keys_ eq - Require two
Addressvalues to be equal. - require_
keys_ neq - Require two
Addressvalues to be different. - require_
lt - Require
a < b. - require_
lte - Require
a <= b. - require_
neq - Require
a != bfor scalar types.
Structs§
- Account
View - Wrapper struct for a
RuntimeAccount. - Address
- The address of a Solana account.
Enums§
- Program
Error - Reasons the program may fail