SINAI STANDARD

TaxManager

Manage the Tax Transfer Hook — automated transfer fees on Token-2022 tokens

Import

import { TaxManager } from "@sinai-standard/sdk";
const mgr = new TaxManager(anchorProgram, mintPubkey);

Properties

PropertyTypeDescription
configPDAPublicKeyThe TaxConfig PDA address
extraAccountMetasPDAPublicKeyThe ExtraAccountMetas PDA address
delegatePDAPublicKeyThe TaxDelegate PDA (permanent delegate)

Methods

initialize(authority, taxBps, maxTaxBps, taxVault)

Creates the TaxConfig PDA for the mint.

ParameterTypeDescription
authorityPublicKeyAdmin who can update settings
taxBpsnumberTax rate in basis points (100 = 1%)
maxTaxBpsnumberHard cap that taxBps can never exceed
taxVaultPublicKeyDestination for collected taxes

initializeExtraAccountMetas(payer)

Creates the ExtraAccountMetaList PDA.

Must be called before any transfer.

updateTaxRate(authority, newBps)

Updates the tax rate. Cannot exceed maxTaxBps.

updateTaxVault(authority, newVault)

Changes the tax collection wallet.

addExemptWallets(authority, wallets)

Exempts wallets from tax (e.g., market makers, treasury).

removeExemptWallets(authority, wallets)

Removes tax exemptions.

toggleActive(authority, isActive)

Kill switch. When isActive=false, no tax is collected on transfers.

updateAuthority(authority, newAuthority)

Transfers admin rights.

fetchConfig()

Fetches the current on-chain tax config.

interface TaxConfigData {
  authority: PublicKey;
  mint: PublicKey;
  taxVault: PublicKey;
  taxBps: number;
  maxTaxBps: number;
  isActive: boolean;
  exemptCount: number;
  exemptWallets: PublicKey[];
}

calculateTax(amount, bps)

Utility to compute expected tax: amount * bps / 10000.

const taxAmount = tax.calculateTax(BigInt(1_000_000), 200);
// => 20_000n (2% of 1M)