Skip to content

feat: slippage-fee-calculation#38

Open
pradeep-selvaraju wants to merge 6 commits intomainfrom
feat/slippage-fee-calculation
Open

feat: slippage-fee-calculation#38
pradeep-selvaraju wants to merge 6 commits intomainfrom
feat/slippage-fee-calculation

Conversation

@pradeep-selvaraju
Copy link
Copy Markdown

@pradeep-selvaraju pradeep-selvaraju commented May 4, 2026

Note

Medium Risk
Changes how V2 BUY orders are sized when user_usdc_balance is provided, which can alter on-chain order amounts and potentially reject orders that previously succeeded. Risk is mitigated by strict validation, defaulting to no padding, and extensive unit/integration tests.

Overview
Adds a new fee_slippage percentage (default 0) at both Config and OrderBuilder levels to pad the platform-fee reserve for BUY orders, with validation that it is 0 or in [1, 100].

Introduces clob::fees with shared fee-reservation logic and updates V2 BUY limit and market order building to conservatively shrink notional/size/amount when user_usdc_balance is set so principal + (padded platform fee) + builder fee ≤ balance, erroring if truncation would produce a zero-sized order. Existing adjust_market_buy_amount is refactored to delegate to the new logic (with slippage disabled), and tests are updated/added to lock in the new behavior.

Reviewed by Cursor Bugbot for commit 88080c9. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/clob/order_builder.rs
@pradeep-selvaraju pradeep-selvaraju changed the title geat/slippage-fee-calculation feat/slippage-fee-calculation May 4, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit daca72c. Configure here.

Comment thread src/clob/order_builder.rs Outdated
@pradeep-selvaraju pradeep-selvaraju changed the title feat/slippage-fee-calculation feat: slippage-fee-calculation May 4, 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.

2 participants