splitFee
Split a gross USDC amount into protocol, creator, and floor legs at a fee rate.
total = ceil(gross × rate / 1e8). Then 15% of total is platform, the rest is the group. The group splits into protocol share (75% of group), creator share (capped at 25% of group), and floor remainder.
v1 trade rate is 1_250_000 micro-bps (1.25%). Advance rate is 3_000_000 (3%). Creator share defaults to 10_000_000 (10% of the group leg) and cannot exceed 25_000_000.
Import
import { splitFee } from "@repo/contract-client/math";
Usage
import { parseUsdc } from "@repo/contract-client";
import { asMicroBps } from "@repo/contract-client/types";
import { splitFee } from "@repo/contract-client/math";
const fees = splitFee(
parseUsdc("10"),
asMicroBps(1_250_000n),
snapshot.feePolicy.creatorGroupShareMicroBps,
);
fees.totalRaw;
fees.protocolRaw;
fees.creatorRaw;
fees.floorRaw;
Quote helpers already attach this breakdown. Call splitFee only when you need the split without a full quote.
Return Value
FeeBreakdown — { totalRaw, protocolRaw, creatorRaw, floorRaw } as UsdcRaw.
protocolRaw + creatorRaw + floorRaw === totalRaw.
Parameters
gross
- Type:
UsdcRaw
Amount the fee is taken from (buy/sell/redeem/advance gross).
splitFee(parseUsdc("10"), rate, creatorShare);
rate
- Type:
MicroBps
Millionths of 100% (100_000_000 = 100%). 1_250_000 = 1.25%.
creatorShare
- Type:
MicroBps
Creator's fraction of the group leg, not of gross.
splitFee(amount, asMicroBps(1_250_000n), snapshot.feePolicy.creatorGroupShareMicroBps);
Error
ProtocolRevertError InvalidCreatorShare if creatorShare > 25_000_000. ZeroAmount if gross is negative.