Fees
Every fee rate on Hadal, who pays it, how it is computed and rounded, where it goes, and the network costs of an action.
Hadal charges three fees: on a sweep, on a cross and on a deal. Each is computed inside the computation that fills the trade, on sealed amounts, and is included in the trade's receipt. Depositing, withdrawing, placing, collecting, cancelling and changing liquidity carry no fee of Hadal's.
Rates
| Fee | Rate | Paid by, and where it goes |
|---|---|---|
Sweep | 0.3% | Paid by the swap, on the part it trades against the pool. It stays in the pool for its liquidity providers, less the protocol's share. |
Cross | 0.05% per side | Paid by both orders of a cross, on the quote crossed. A protocol fee. |
Deal | 0.05% per side | Paid by the maker and the taker of a deal, on the quote traded. A protocol fee. |
In basis points: sweep 30, cross 5 a side, deal 5 a side. The rates are held in the venue's configuration and are the same in every market. A client reads them from GET /v1/markets/:market/config.
How a rate is applied
Amounts are in atoms and prices are scaled by 2^32: see Units. A rate in basis points is turned into the same scale once, and applying it is a multiplication and a shift.
rate(bps) = floor(bps * 2^32 / 10000)In the formulas below floor rounds down and ceil rounds up. Every product is taken in 128 bits before it is divided, and a trade whose amounts would not fit 64 bits is void and pays no fee.
Cross fee
Both orders of a cross pay the same fee, in quote, on the quote that crossed.
q = floor(fill * mid / 2^32)
cross_fee = floor(q * rate(cross_bps) / 2^32)
the buyer pays q + cross_fee
the seller receives q - cross_feefill is the base crossed with one resting order and mid is the pool's mid. The fee is computed for each resting order an incoming order fills against, and rounds down each time. It is the same whether an order is the one resting or the one arriving.
Both fees, 2 * cross_fee, go to the protocol, in quote.
A resting bid locks its cross fee in advance, with its notional: see What a dark order locks.
Sweep fee
The swap pays the sweep fee on what it trades against the curve. It is charged in the token the order pays with.
A buy pays it in quote, on top of what the curve takes:
net_in = ceil(pool_quote * rem / (pool_base - rem))
gross_rate = ceil(10000 * 2^32 / (10000 - sweep_bps))
gross_in = ceil(net_in * gross_rate / 2^32)
sweep_fee = gross_in - net_inThe order pays gross_in, and net_in is gross_in less 0.3% of it. The limit check of the sweep is made on gross_in, so the fee is inside the limit.
A sell pays it in base, before the curve:
sweep_fee = floor(rem * rate(sweep_bps) / 2^32)
net = rem - sweep_fee
quote_out = floor(pool_quote * net / (pool_base + net))The order delivers rem base and net of it is priced by the curve. The limit check is made on quote_out against the whole of rem, so the fee is inside the limit here too.
In the receipt, fee is in quote. A sell's sweep fee is converted at the mid the computation started with: floor(sweep_fee * mid / 2^32).
Where the sweep fee goes
The fee is split between the pool and the protocol.
protocol = floor(sweep_fee * rate(share_bps) / 2^32)
pool keeps sweep_fee - protocolThe share, share_bps, is held in the venue's configuration in basis points of the sweep fee. A client reads it as fees.protocolShareOfSweepBps from the market's config route. Orders are processed only once the share is set.
The pool's part stays in the reserves, in quote after a buy and in base after a sell, and belongs to the liquidity providers: see What a liquidity provider earns. The protocol's part is taken in the same token.
Deal fee
The maker and the taker of a deal pay the same fee, in quote, on the quote the deal trades.
price = floor((maker_limit + taker_limit) / 2)
q = floor(fill * price / 2^32)
deal_fee = floor(q * rate(deal_bps) / 2^32)
the buyer pays q + deal_fee
the seller receives q - deal_feeBoth fees, 2 * deal_fee, go to the protocol, in quote. A maker who buys locks the fee with the escrow when opening the deal. How a deal trades is in Deals.
Protocol fees
Three amounts are protocol fees: both cross fees of every cross, both deal fees of every deal, and the protocol's share of every sweep fee.
Accrue, sealed
Each market keeps two sealed totals beside its pool, one in base and one in quote. Cross fees and the protocol's share of a buy's sweep fee are added to the quote total, and the share of a sell's sweep fee to the base total, in the computation that fills the order. A deal's fees are added to the quote total when the deal is closed and settled. The tokens stay in the market's vaults.
Revealed at a sounding
Each sounding reveals the two totals accrued since the previous one, and resets them to zero. The revealed amounts are recorded on the market as fees owed and are in the sounding's public event.
Paid to the fee recipient
pay_feestransfers the fees owed, in both tokens, from the market's vaults to the token accounts of the fee recipient named in the venue's configuration. Anyone can send it. It can only pay that recipient and only the amounts soundings revealed.
Between soundings nobody can read how much a market has accrued. What the fee recipient does with the fees is told in The token.
Network costs
Besides Hadal's fees, an action costs what the network charges for its transaction. The measured figures are in Limits.
| Cost | Paid for | When |
|---|---|---|
Transaction fee | Solana | Every transaction you sign. |
Account rent | Solana | When an action opens an account: your balance in a market (once), each order, each deal, your attempts record on a deal you answer, and a token account for a withdrawn token if the wallet has none. |
Computation fee | Arcium | When your transaction queues a computation: Deposit, Withdraw, Collect, Cancel on a resting order, Add liquidity, Remove liquidity, Open deal, Answer, closing a deal. The transaction also pays the rent of the computation's account. |
Placing an order queues no computation. The order's computation is queued, and its computation fee paid, by the transaction that processes it from the market's queue.