Skip to content

Charge taker fee + maker rebate on fills#171

Merged
ozpool merged 1 commit into
mainfrom
feat/fee-rebate-engine
May 29, 2026
Merged

Charge taker fee + maker rebate on fills#171
ozpool merged 1 commit into
mainfrom
feat/fee-rebate-engine

Conversation

@ozpool
Copy link
Copy Markdown
Owner

@ozpool ozpool commented May 29, 2026

What

Point-7 economics. Every fill recorded feeUsdc: "0" — the per-market takerFeeBps/makerRebateBps were defined but never applied. So no fees were collected and makers had no economic reason to quote.

How

On each fill, compute the fee/rebate as bps of notional, stamp them on the fill records, and settle into vault balances:

  • Taker is debited takerFeeBps of notional (feeUsdc positive on the taker fill).
  • Maker is credited makerRebateBps (feeUsdc negative = credit on the maker fill). The default schedule's rebate is negative (−2bps), so the maker is also debited — the engine handles the signed case.
  • Vault balances clamp at zero. The net (taker_fee − maker_rebate) is the protocol's take.

Test

  • New e2e fills_charge_fee_and_settle_vault: a matched fill now carries a non-zero, positive taker fee, and the taker's vault is debited by it.
  • 34 lib + all integration tests green; fmt + clippy clean.

Notes

  • No explicit protocol/insurance balance yet — the net take isn't credited anywhere, it just leaves the traders' vaults. That account lands with on-chain settlement.
  • Recruiting external makers + designing an incentive/points program is business, out of code scope.

Every fill recorded feeUsdc "0" — the per-market takerFeeBps/makerRebateBps
were defined but never applied, so no fees were collected and makers had no
economic reason to quote. Compute the fee and rebate per fill (bps of
notional), stamp them on the taker/maker fill records, and settle both into
the vault balances: the taker is debited the fee, the maker credited the
rebate (signed — the default schedule's negative rebate debits the maker
too). The net is the protocol's take; an explicit protocol/insurance balance
lands with on-chain settlement.

Adds an e2e test: a matched fill now carries a non-zero taker fee and the
taker's vault is debited by it.
@ozpool ozpool merged commit 8b8c192 into main May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant