Paymaster
How the LazorKit protocol fee system works — fee collection, treasury sharding, and payer tracking.
Paymaster
The Paymaster is LazorKit's on-chain fee collection and gas sponsorship layer. It handles protocol revenue, tracks integrator activity, and routes funds to a sharded treasury.
How It Works
Fee collection is opt-in per payer. If a payer has no FeeRecord on-chain, no fee is charged — the protocol behaves identically to the open-source version.
When a payer is registered:
- SDK detects the
FeeRecordPDA keyed by the payer's pubkey (RPC call, cached) - SDK appends 4 accounts to the transaction:
[protocol_config, fee_record, treasury_shard, system_program] - Entrypoint detects these trailing accounts and collects the configured fee
- SOL is transferred from payer to a randomly selected treasury shard
FeeRecordcounters are updated (tx_count,wallet_count,total_fees_paid)- The 4 protocol accounts are stripped before passing to the processor — processor is unchanged
Fee collection applies to: CreateWallet, Execute, and ExecuteDeferred.
Architecture
Sharded Treasury
Fees route to one of N shards (e.g. 16), selected randomly per transaction. This eliminates write contention — parallel transactions hit different shards without blocking each other.
Admin calls WithdrawTreasury once per shard to sweep accumulated SOL to the treasury address.
On-Chain Accounts
ProtocolConfig — ["protocol_config"]
Global configuration. Set once via InitializeProtocol.
| Field | Description |
|---|---|
admin | Protocol admin pubkey |
treasury | Withdrawal destination |
creation_fee | Lamports per CreateWallet |
execution_fee | Lamports per Execute / ExecuteDeferred |
enabled | 0 = disabled, 1 = enabled |
num_shards | Number of treasury shards |
FeeRecord — ["fee_record", payer_pubkey]
Created by admin via RegisterPayer. One per integrator.
| Field | Description |
|---|---|
total_fees_paid | Cumulative lamports paid — used for token reward distribution |
tx_count | Fee-eligible transaction count |
wallet_count | Wallets created by this payer |
registered_at | Registration slot |
TreasuryShard — ["treasury_shard", shard_id]
8-byte account. SOL accumulates as lamport balance. Created once per shard via InitializeTreasuryShard.
Fee Amounts
Fees are configurable. The current values are set by the protocol admin.
| Instruction | Typical Fee |
|---|---|
| CreateWallet | ~5,000 lamports |
| Execute | ~2,000 lamports |
| ExecuteDeferred | ~2,000 lamports |
Per fee-eligible transaction overhead: ~3,000 additional CU and +128 bytes (4 extra accounts).
Token Reward Distribution
FeeRecord.total_fees_paid tracks cumulative fees per payer proportional to usage. When the protocol token launches, rewards are distributed based on this data:
- Snapshot all
FeeRecordaccounts viagetProgramAccounts(filter by discriminator6) - Calculate share:
payer_share = total_fees_paid / sum_all_fees - Distribute via merkle airdrop or direct transfer
Current Status
- Protocol fee system is live on Solana mainnet
- Fee collection operates in native SOL
- Protocol token for governance and fee settlement is not yet deployed
- Future: open Paymaster competition where multiple providers compete on sponsorship terms