For the complete documentation index, see llms.txt. This page is also available as Markdown.

Fees & Claims

Net earnings, protocol share, claims and delegated permissions.

Trading fees earned by a range are distributed through a net LP ledger. Claims pay earnings in the pool’s original currencies; they do not exchange assets or mint a reward token.

From gross fees to net earnings

The Hook collects gross trading fees, deducts the effective protocol share, and distributes the remainder through net per-share accumulators. Owner checkpoints and Q128 remainders preserve each holder’s entitlement.

The protocol share applies to fee income, not deposited or withdrawn principal. Direct deposits and withdrawals have no percentage fee on principal. See Fees for trading fees.

The configurable protocol share is at most 2000 bps (20%); that ceiling is not the current rate. On-chain claimFeeBps(poolId) is the current configured rate, while effectiveClaimFee(rangeId) incorporates synchronization history. Do not apply today’s rate retroactively to all earnings.

For example, 100 gross fee units, a 5% protocol share and constant 10% ownership yield 9.5 units before rounding.

Read and prepare a claim with the SDK

Use the Market client created with prepare: true in Quickstart. The example estimates earnings and prepares a self-claim for review, using the caller’s intended recipient and accepted maxFeeBps. It does not broadcast.

import {
  getMarketPoolId,
  getMarketRangeId,
  type MarketClient,
  type MarketClaimParams,
} from "@masterpeach/market-sdk";
import type { Address } from "viem";

export async function prepareOwnFeeClaim(
  client: MarketClient,
  input: MarketClaimParams & { readonly owner: Address },
) {
  const { owner, ...params } = input;
  const rangeId = getMarketRangeId(
    getMarketPoolId(params.key),
    params.tickLower,
    params.tickUpper,
    params.key.tickSpacing,
  );
  const earnings = await client.estimateClaimableFees({
    hook: params.key.hooks, rangeId, owner,
  });
  if (earnings.data.paused) throw new Error("Fee claims are paused");
  if (!earnings.data.hasClaimableAmount) return { earnings, prepared: null };
  const prepared = await client.prepareClaim(params);
  if (!prepared.context.preflight) throw new Error("Use prepare: true");
  if (prepared.request.account.toLowerCase() !== owner.toLowerCase())
    throw new Error("Wallet owner changed; refresh and prepare again");
  return { earnings, prepared };
}

earnings.data.token0 and token1 use their respective token’s base units:

Field
Meaning

settled

Net fees already included in the owner’s owed balance

synchronized

Net fees accumulated by the Hook but not checkpointed to this owner

pending

Additional whole base units estimated from uncollected PoolManager fees

claimable

settled + synchronized + pending

remainderX128

Fractional carry; do not add it as an integer token amount

getPosition().data.settledOwed0/1 is only the settled portion. Do not combine gross growth with net checkpoints; the SDK uses one fixed-block snapshot and rejects invalid or settling reads. Estimates remain available while paused and may change before execution. Retain zero-share positions with historical owed fees; fractional carry survives claims, transfers and full exits.

Claim flows and fee limits

SDK method
Purpose

prepareClaim({ key, tickLower, tickUpper, to, maxFeeBps })

Connected signer claims their own fees

prepareClaimFeesBatch({ items, to })

Connected signer claims 1–100 items on the same chain and Hook, to one recipient

prepareClaimFeesFor({ key, tickLower, tickUpper, owner, to, maxFeeBps })

Separate delegated-claim path requiring range claim authorization and deployment acceptance

prepareWithdrawAndClaim(preview, to, maxFeeBps)

Withdraws principal and claims fees together

Each batch item has { key, tickLower, tickUpper, maxFeeBps }. Group by (chainId, hookAddress.toLowerCase()); the SDK does not split batches or support delegated batch claims. An error reverts the whole transaction. Empty payouts may be skipped after validation.

maxFeeBps caps the effective protocol share: an integer 0–2000, denominator 10,000, independent of swap-fee pips or price slippage. Exceeding the user’s cap reverts; do not silently raise it. Claims have no on-chain deadline; optional validForSeconds only limits local submission with preflight enabled.

Ownership, pauses and confirmation

Share and claim permissions are independent: getShareAuthorization reports both; getClaimOperator reads range claim authorization. Share approval does not grant fee collection. A claim operator can choose the recipient and fee cap. Its permission survives transfers, exits and redeposits until explicitly revoked with prepareSetClaimOperator({ key, tickLower, tickUpper, operator, approved: false }). Transfers checkpoint both parties, so previously earned fees remain with the original owner.

The built-in mainnet presets have claimOperator: "unverified". With prepare: true, delegated-claim preparation is rejected until that deployment capability is separately reviewed. Do not turn off preflight or automatically promote the capability. Ordinary self-claims do not require claim-operator acceptance.

Global or pool pauses block claims and combined withdrawal/claim. Principal-only withdrawal remains available and does not pay earnings. See Providing Liquidity for the separate exit flow.

After user confirmation, use Quickstart’s same-client send-and-receipt helper; require result.status === "confirmed". A successful claim can have no payout events; reconcile matching Hook, owner, range and recipient events, then refresh earnings and balances. Keep the transaction hash on timeout and check its result before retrying.

Earlier direct-contract reference for the older 314ed215 baseline: Ramp ledger, claims and authorization, ClaimFeePolicy historical rate protection; its pause and withdrawal rules differ from the SDK baseline described above.

Last updated

Was this helpful?