Run a solver
Commission and payouts
What a proven batch pays its solver, how the program splits it, and how the operator claims the commission.
A solver earns the clearing fee of every batch it clears and proves. The fee is credited by prove_batch, in the same instruction that verifies the proof, so a batch pays at the moment it is proven.
What a batch pays
Every order that fills pays the clearing fee out of what it receives:
fee = floor(gross * clearing_fee_bps / 10000)
gross is the order's output before the fee, in atoms of the token it buys. How fills are decided has the arithmetic.
The solver posts one fee total per batch token with its clearing: the sum of fee over the orders buying that token. The guest checks each total against the orders, and the batch account stores them as fees. Those totals are what the batch pays.
The clearing fee rate is clearingFeeBps from una.protocol(), and it is listed on Parameters.
The tokens fees accrue in
A fee is taken in the token the order buys, so a batch pays in every token that was bought in it. A batch where SOL was sold for USDC and USDC for SOL pays a fee in USDC and a fee in SOL. The solver's account keeps a separate balance for each of the program's 32 token indexes, and each is claimed in its own token.
Fees stay in the program's vault for the token until they are claimed.
The split
prove_batch splits each token's fee total three ways. For one token:
protocol_fee = floor(total_fee * protocol_fee_share_bps / 10000) solver_fee = total_fee - protocol_fee commission = floor(solver_fee * commission_bps / 10000) staker_fee = solver_fee - commission
total_feeu64- The batch's fee total for the token, in the token's atoms.
protocol_fee_share_bpsu16- The protocol's share, from the program's
Config.protocolFeeShareBpsinuna.protocol(). commission_bpsu16- The solver's commission, set at registration.
Both divisions round down. The atom the protocol share rounds away stays with the solver, and the atom the commission rounds away stays with the stakers.
| Part | Where it goes | When |
|---|---|---|
protocol_fee | From the token's vault to the fee recipient's associated token account for that token. | In prove_batch itself. |
commission | Added to operator_commission for the token, in the solver account. | Credited in prove_batch, paid when the operator claims. |
staker_fee | Added to the solver's reward per unit of stake for the token. | Credited in prove_batch, paid when each staker claims. |
What the protocol share is for is on Fees and UNA.
The stakers' part
The program does not pay stakers one by one. It raises one number per token on the solver account:
reward_per_share += floor(staker_fee * 2^64 / total_bond_weight)
total_bond_weight is the stake behind the solver in lamports, each deposit counted at its value when it was made. A stake's reward in the token is the rise in reward_per_share since the stake last synced, times the stake's own weight, divided by 2^64 and rounded down. Rewards follows one stake through it.
The operator's own stake is a stake like any other. It earns its part of staker_fee on top of the commission.
When a solver has no stake weight, or staker_fee is zero, the whole solver_fee for the token is added to operator_commission.
A worked split
The inputs here are sample inputs: a batch whose fee total in USDC is 1,000,000 atoms, a protocol share of 2,000 basis points, and a commission of 1,000 basis points.
| Step | Arithmetic | Result |
|---|---|---|
| Protocol | 1,000,000 × 2,000 / 10,000 | 200,000 atoms to the fee recipient |
| Solver | 1,000,000 − 200,000 | 800,000 atoms |
| Commission | 800,000 × 1,000 / 10,000 | 80,000 atoms to the operator |
| Stakers | 800,000 − 80,000 | 720,000 atoms across the stake |
Accounts prove_batch needs for the split
After the batch's Token accounts, prove_batch takes four accounts for each batch token whose protocol_fee is above zero, in the batch's token order: the token's mint, the token's vault, the fee recipient's associated token account for the mint, and the token program. The node computes which tokens need them from the batch's fees and Config, and adds them.
The program raises InvalidFeeRecipientAta when the four are missing or are not those accounts.
Claim the commission
The operator claims with claim_rewards, one instruction per token, with the operator flag set. The node and the SDK each put one for every token with commission accrued into a single transaction.
SOLVER_KEYPAIR=~/solver-operator.json \
RPC_URL=https://your-rpc-endpoint \
una-solver claim-commissionThe command reads the solver account and claims every listed token whose commission balance is above zero. For each it first creates the operator's associated token account for the token if it does not exist. It signs with the operator key, waits for the transaction to confirm, and prints the token indexes claimed, the signature and the compute units used.
una-solver claim-commission
--tokenu16- A token index. With the flag the command claims that token alone.
When no token has a balance it prints No accrued operator commission to claim. and sends nothing. If the transaction fails it prints claim-commission failed: with the reason and exits with code 1.
// Every token with commission accrued, in one transaction.
const claimed = await una.claimCommission(solverAddress)
console.log(`commission claimed in ${claimed.signature}`)
// One token: wSOL is index 0.
const claimedSol = await una.claimCommission(solverAddress, { tokenIndex: 0 })
console.log(`SOL commission claimed in ${claimedSol.signature}`)una is the bound client made with the operator's key, and solverAddress is the solver's address, as on Register and bond. The API reads the solver account from the chain and builds one transaction: for each token claimed, an instruction that creates the operator's associated token account if it does not exist, then claim_rewards. The call signs, submits and follows it, and resolves with build, tx and signature.
| API error | Answered when |
|---|---|
UNAUTHORIZED | The wallet is not the solver's operator. |
NOTHING_TO_CLAIM | No commission is accrued, in the token named or in any token. |
VALIDATION_ERROR | tokenIndex is not a listed token. |
The instruction
claim_rewards
token_indexu16required- The index of the token to claim, 0 to 31. wSOL is 0.
is_operator_commissionboolrequiredtrueclaims the operator's commission.falseclaims a stake's rewards.
Accounts
ownersignerrequired- The operator. It has to be the solver's
operator. configaccountrequired- The program's
Config, seeds"config". solverwritablerequired- The solver account.
stakewritablerequired- A stake account when claiming a stake's rewards. An operator claim does not read it.
tokenaccountrequired- The
Tokenaccount, seeds"token"and the index as a little-endianu16. mintaccountrequired- The token's mint.
token_vaultwritablerequired- The token's vault.
owner_atawritablerequired- The operator's associated token account for the mint. The instruction pays into it and does not create it.
token_programprogramrequired- The token's token program.
The program pays the whole of operator_commission[token_index] from the token's vault to owner_ata, sets the balance to zero, and emits RewardsClaimed with the solver, the owner, the token index, the amount and is_operator_commission: true.
| Error | Raised when |
|---|---|
InvalidIndex | token_index is 32 or above. |
Unauthorized | The signer is not the solver's operator, or owner_ata is not the signer's associated token account for the token's mint. |
NothingToClaim | The commission balance for that token is zero. |
The program reference has the instruction's full account list as the IDL gives it.
Read what has accrued
Unclaimed commission is the operator_commission array of the solver account: 32 u64 values, one per token index, in that token's atoms. Each prove_batch adds to it and each operator claim empties one slot.
The API returns the same balances as operatorCommission on a solver:
const { operatorCommission } = await una.solver(solverAddress)
for (const c of operatorCommission) console.log(`${c.symbol}: ${c.amount} atoms accrued`)It holds one AccruedCommission for each token with a balance above zero: tokenIndex, mint, symbol, decimals and amount, in the token's atoms. una.solvers() carries it on every solver in the list.
una-solver status prints them on a line accrued_commission, as token# and the index, then the amount in atoms. The line is left out when every balance is zero.
The solver's page at /solvers/[address] shows what the solver has paid its stakers as Fees paid to stakers, and the commission it runs at as Commission.
Claiming a stake's rewards
The operator's own stake claims like any staker's: Claim rewards on /stake, or una.claimRewards(stakeAddress), which sends claim_rewards with the flag false for every token the stake has rewards in. See Rewards.