At Inference.net, we provide developers and enterprises with access to top-performing large language models (LLMs) through our efficient and cost-effective inference platform.
A Solana on-chain program that manages staking and unstaking of tokens to operator managed pools, custodies delegated tokens, and distributes rewards and USDC earnings.
The Inference.net Staking System allows users to stake tokens to Operator-managed pools. Operators can set commission rates and receive rewards based on network performance, while delegators can stake to Operators to earn passive income.
- Support for up to 10,000 active Operators (no fixed cap)
- Delegation system for external holders
- Cooldown period on unstaking (no rewards during cooldown)
- Slashing penalties for Operators (no slashing risk for delegators)
- Dual commission rates for Operators: token rewards and USDC earnings
- Configurable Operator commission rates
- Reward distribution per 24/48 hour epochs
- Automatic compounding via operator commission fee auto-staking
- USDC revenue share for delegators
- Efficient reward distribution with off-chain storage and on-chain Merkle Tree proof verification.
- On-chain reward emission schedule for transparency and auditability.
The program consists of several key accounts:
- PoolOverview: Manages global staking parameters and tracks total pools
- OperatorPool: Represents an Operator's staking pool with configuration and state
- StakingRecord: Tracks individual staking positions for Operators and delegators
- RewardRecord: Stores Merkle roots for reward distributions by epoch
CreateOperatorPool: Create a new staking pool for an OperatorUpdateOperatorPool: Modify commission rates and delegation settingsChangeOperatorPoolAdmin: Change admin authority for poolChangeOperatorStakingRecord: Change associated operator staking record for poolWithdrawOperatorRewardCommission: Withdraw earned commission feesWithdrawOperatorUsdcCommission: Withdraw earned USDC commission feesCloseOperatorPool: Permanently close a poolSweepClosedPoolUsdcDust: Sweep USDC dust from a closed poolAccrueRewardEmergencyBypass: Accrue reward to a pool when the pool is not included in a reward record payout
CreateStakingRecord: Create a new account to record position in a poolStake: Delegate tokens to an Operator poolUnstake: Begin the process of unstaking tokensCancelUnstake: Cancel a pending unstake operationCloseStakingRecord: Close staking record account after zeroingClaimUsdcEarnings: Claim USDC earnings from a pool
CreatePoolOverview: Initialize the program after deploymentUpdatePoolOverviewAuthorities: Modify authorites on PoolOverviewUpdatePoolOverview: Modify global staking parametersCreateRewardRecord: Finalize a reward epoch by committing the Merkle rootSlashStake: Penalize an Operator by slashing their stakeSetHaltStatus: Halt an Operator from staking, unstaking or claiming from their pool
AccrueReward: Accrue reward issued to a poolClaimUnstake: Withdraw tokens after the unstaking delay period
Rewards are computed off-chain based on network performance metrics and distributed using a Merkle-based reward system:
- Off-chain service computes rewards per
OperatorPooland generates Merkle trees - Merkle roots are committed on-chain via
CreateRewardRecord - Rewards are claimed permissionlessly using Merkle proofs via
AccrueReward- Operators receive commission fees and delegators receive staking rewards and USDC earnings
- Rewards auto-compound when added to the staking pool
- USDC earnings are distributed to delegators
On-chain accounting is managed by two mechanisms:
-
Pool Shares: A proportional ownership system where delegators receive shares representing their stake in a pool. Token rewards automatically increase share value without requiring additional transactions, allowing all participants to benefit passively based on their stake proportion.
-
USDC Revenue Sharing: A hybrid accounting model using a cumulative per-share index system that tracks USDC earnings over the pool's lifetime. Delegators can claim USDC earnings independently from their staked tokens, with settlements calculated using checkpoints to ensure accurate accounting.
Start here: https://www.anchor-lang.com/docs/installation.
- Rust toolchain: 1.85.0
- Solana CLI: Solana 2.1.16 (Other versions may be supported)
- Anchor framework (AVM 0.31.0)
- Bun (v1.2.5 or higher)
# Install dependencies bun install # Install SDK dependencies cd sdk && bun install cd .. # Setup (back at root level) bun run setup # Run formatting bun run format # Run linting bun run lint # Run all static checks bun run check # Build the program and generate the IDL bun run buildThe tests folder contains a full suite of integrations tests for the program which can be run with Anchor. The tests will run whichever test suite is specified in the Anchor.toml file (there are multiple test suites - additional tests are commented out, you can run them all with the test-all command).
# Run unit tests bun run test:unit # Run Program unit tests bun run test:program:unit # Run program tests bun run test # Run tests without spinning up a local validator (requires a local validator to be running) bun run test:skip-local-validator # Run all program tests bun run test-allYou can deploy the program with the deploy-localnet.sh script in the scripts folder for local testing and development.
A TypeScript client SDK is provided in the sdk package.
