Fees and rounding

Trace each input atom from the trader to inventory or a fee recipient. The settlement unit is a single filled bin.

On this page

The input-denominated fee

The hosted canonical pool charges 20 basis points on each direct fill. For gross amount g spent in a bin and rate r, ObeliskMath.split computes the fee as the residual after rounding down net input. The cut is denominated in tUSDC on a buy and WHYPE on a sell.

F = g − ⌊g · (10,000 − r) / 10,000⌋
= ⌈g · r / 10,000⌉

The treasury allocation is T = ⌊F/5⌋, the creator allocation is C = ⌊F/10⌋ and the LP allocation is L = F − T − C. For a 1 tUSDC fill the gross amount is 1,000,000 input atoms and the fee is 2,000 atoms.

Allocation of a 2,000-atom input feeFor a one tUSDC fill at twenty basis points, 1,400 atoms stay in the bin, 400 accrue to the treasury, and 200 accrue to the creator. FEE ON 1 tUSDC · 2,000 ATOMS LP 70% Treasury 20% Creator 10%
This input divides exactly at each allocation boundary. The LP portion absorbs the remainder when integer atoms prevent an exact split.

Reserve and fee accounting

On a buy with output y, the bin’s base reserve falls by y and its quote reserve increases by g − T − C. A sell exchanges those reserve roles. This retained input consists of the net consideration and the LP fee. The fill leaves share supply unchanged, assigning the retained fee to incumbent shareholders through their reserve claim.

g = net + L + T + C
Δreservein = net + L = g − T − C

The two external fee allocations accrue to separate base/quote ledgers. An authorized recipient calls claimFees() to collect its balance. If treasury and creator coincide, the same call collects both allocations. LPs realize their share through withdrawal. On buys, the lpFeeBase field of BinFilled translates the quote-denominated LP fee into base atoms at the fill midpoint using ⌊L · S / pᵢ⌋. The inventory credit itself remains in quote.

Reconciling a multi-bin receipt

For the 150 tUSDC two-bin buy, the ledger reconciles as follows. Every number in the table is a tUSDC atom, with six decimal places per whole token.

BinFeeTreasuryCreatorLP
10201,40340,28020,140140,983
1198,59819,7199,85969,020
Total300,00159,99929,999210,003

Multiplying the total input by 20 bps gives 300,000 fee atoms. The receipt contains 300,001 because settlement takes the fee ceiling twice. A reconciler must split each fill before summing beneficiary balances. Applying the split once to the aggregate fee would credit a different number of atoms to each beneficiary. Inspect the underlying fill amounts →