SINAI STANDARD

Max Balance Hook

TransferHook program for per-wallet maximum token balance enforcement

Overview

The Max Balance Hook enforces a maximum token balance per wallet. When a transfer would cause the destination wallet to exceed the configured limit, the transaction is rejected. This prevents concentration violations and supports regulatory caps like Reg D/S investor limits.

Program ID: Ctx9ZtNzPFYyjqxdZSMYLgHdqNNpAS61G6ok1dYVBHWi

How It Works

During execute_transfer_hook, the program reads the destination token account's current balance at byte offset 64 (the amount field in a Token-2022 account). It then checks:

destination_balance + transfer_amount <= max_balance

If the check fails, the transaction reverts with MaxBalanceExceeded.

Accounts

MaxBalanceConfig PDA

Seeds: ["max-balance-config", mint]

FieldTypeDescription
authorityPubkeyAdmin who can manage the config
mintPubkeyThe token mint
max_balanceu64Maximum allowed balance per wallet
is_activeboolKill switch

ExtraAccountMetas PDA

Seeds: ["extra-account-metas", mint]

Instructions

InstructionDescription
initialize_extra_account_metasCreate the ExtraAccountMetas PDA
initialize_max_balance_configCreate the MaxBalanceConfig PDA
update_max_balanceChange the maximum balance limit
toggle_activeEmergency kill switch
update_authorityTransfer admin rights
execute_transfer_hookTransferHook entry point — checks balance + amount does not exceed max_balance

Error Codes

CodeNameDescription
6000UnauthorizedSigner is not the config authority
6001MaxBalanceExceededTransfer would push destination above max_balance
6002InvalidMaxBalancemax_balance must be greater than zero

PDA Seeds

PDASeeds
MaxBalanceConfig["max-balance-config", mint]
ExtraAccountMetas["extra-account-metas", mint]

On this page