Charge taker fee + maker rebate on fills#171
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Point-7 economics. Every fill recorded
feeUsdc: "0"— the per-markettakerFeeBps/makerRebateBpswere 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:
takerFeeBpsof notional (feeUsdcpositive on the taker fill).makerRebateBps(feeUsdcnegative = 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.taker_fee − maker_rebate) is the protocol's take.Test
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.Notes