BagsFeeShare contract that accrues the creator half of the trade fee (1% of every trade, in WETH) for the claimers configured at launch, plus the optional partner’s cut of the protocol half.
Prerequisites
Before starting, make sure you have:- Completed the Environment Setup.
- A token whose
feeShareaddress you can resolve (from launch,factory.feeShareForToken(token), orBagsLens.getTokenState). - A wallet with a positive claimable balance — i.e. one of the token’s configured fee claimers or the optional partner. Check with
claimableOf(token, user)(orfeeShare.claimable(user)).
1. How Fee Sharing Works
The flat 2% trade fee splits into two halves, and the token’sBagsFeeShare is the pull-payment ledger (in WETH) for two independent streams:
- The claimers configured at launch split 100% of the creator half by their bps — the partner never reduces their share.
- The partner (if set at launch) earns its cut from the protocol half at the launch-snapshotted
partnerFeeBps(default2500= 25% of the half). See the Partner Program guide for the partner-side workflow.
claimable[address] until they call claim. This happens automatically as trades occur in both phases — creators earn from bonding-curve trades and pool trades alike.
Post-migration fees first accrue inside the Bags v4 hook and are periodically swept into the fee-share contract (anyone can call
hook.sweep(poolId)). claim pokes that sweep for you, so you don’t need a separate sweep transaction.2. Read Claimable Fees
UseBagsLens.claimableOf(token, user) for the amount claimable right now (already notified to the fee-share, in WETH wei):
read-claimable.ts
The claimer list is not immutable — the fee-share owner can call
setClaimers (mirrored by the ClaimersUpdated event). Re-read getClaimers() rather than caching it forever.3. Claim Fees
Callclaim(unwrap) on the token’s BagsFeeShare. Pass unwrap: true to receive native ETH; false leaves the payout as WETH.
claim-fees.ts
4. Estimate Pending (Un-Swept) Fees
For a fuller picture of what a creator will eventually receive, add the un-swept accrual sitting in the v4 hook for the token’s pool. The hook exposes per-pool config and pending fees in one read:pools(poolId) returns (bondingCurve, feeShare, pendingFees, minted, partner, partnerFeeBps).
pending-estimate.ts
pendingUserEstimate is an estimate — the exact amount is settled when the sweep runs during a claim (FeesSwept(poolId, bagsShare, creatorShare, partnerShare) reports the actual split).Troubleshooting
BagsFeeShare_NothingToClaim— yourclaimablebalance is zero. Wait for trades to accrue fees (or for a sweep to flush hook fees), and checkclaimableOfbefore claiming.BagsFeeShare_NotAuthorized— only the bonding curve and hook may notify fees; you can’t callnotifyFeeyourself. Just callclaim.- Claim succeeds but you received WETH, not ETH — you passed
unwrap: false. Passtruefor native ETH, or unwrap the WETH yourself later. - Not a claimer — only the token’s configured
claimersand its optionalpartneraccrue fees. Verify eligibility withclaimableOf(token, user)(orfeeShare.claimable(user)) being greater than zero. NotefeeShare.getClaimers()lists only the configured claimers — it does not include the partner.
