Skip to content

Clear rounding revert#2090

Merged
thedavidmeister merged 2 commits intov4from
2025-08-16-clear-rounding-revert
Aug 18, 2025
Merged

Clear rounding revert#2090
thedavidmeister merged 2 commits intov4from
2025-08-16-clear-rounding-revert

Conversation

@Siddharth2207
Copy link
Copy Markdown
Contributor

@Siddharth2207 Siddharth2207 commented Aug 16, 2025

Motivation

Clear rounding revert

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features

    • None
  • Bug Fixes

    • Improved withdrawal to safely handle extreme amounts without errors.
    • Refined order clearing to ensure fair outcomes across token decimal rounding.
  • Chores

    • Removed Vercel-based docs preview and production deployments.
    • Updated deployment workflow to target the v4 branch/environment.
    • Refreshed subgraph entries for Base and Arbitrum with new addresses and start blocks.
  • Tests

    • Added tests covering rounding behavior in order clearing and withdrawals.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Removes two Vercel docs workflows, updates the remaining Vercel production workflow to target branch/env “v4,” modifies OrderBook.sol rounding logic in withdraw2 and clear2, updates subgraph network addresses and start blocks for OrderBook on Base and Arbitrum One, and adds new tests covering rounding behaviors in withdraw and clear.

Changes

Cohort / File(s) Summary
CI: Remove docs workflows
.github/workflows/vercel-docs-preview.yaml, .github/workflows/vercel-docs-prod.yaml
Deleted preview and production Vercel docs deployment workflows.
CI: Adjust Vercel prod workflow
.github/workflows/vercel-prod.yaml
Changed push branch from main to v4; updated vercel pull env to v4; updated deploy target to v4.
Core: OrderBook rounding updates
src/concrete/ob/OrderBook.sol
withdraw2 now saturates on 18-decimal rescale overflow. clear2 adds rounding-aware IO adjustments using up/down scaling and conditional OIRatio adjustment before computing final outputs.
Data: Subgraph networks
subgraph/networks.json
Updated OrderBook addresses and startBlock for base and arbitrum-one networks.
Tests: Rounding scenarios
test/concrete/ob/OrderBook.clear.rounding.revert.t.sol, test/concrete/ob/OrderBook.withdraw.rounding.t.sol
Added tests for clear2 rounding/IO handling and withdraw2 max-amount rounding/saturation behavior.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant OrderBook
  participant Token
  participant Interpreter

  User->>OrderBook: withdraw2(token, vaultId, targetAmount, tasks)
  OrderBook->>OrderBook: Rescale targetAmount to 18-decimals (saturate on overflow)
  OrderBook->>Interpreter: Execute tasks (if any)
  OrderBook->>Token: transfer to User (up to available balance)
  Token-->>OrderBook: transfer result
  OrderBook-->>User: Emit Withdraw, return
Loading
sequenceDiagram
  participant Alice
  participant OrderBook
  participant Bob

  Alice->>OrderBook: clear2(aliceOrder, bobOrder, config, ctx)
  OrderBook->>OrderBook: Compute aliceInputUp and aliceInput (scale up/down)
  OrderBook->>OrderBook: If mismatch, adjust aliceOutputMax18 via OIRatio
  OrderBook->>OrderBook: Scale aliceOutputMax18 down to aliceOutput
  OrderBook-->>Alice: Settlement based on adjusted amounts
  OrderBook-->>Bob: Settlement counterpart
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Withdraw revert #2085 — Similar rounding changes to OrderBook withdraw/clear logic and related tests; also removes Vercel workflows.
  • clear zero amount error #1926 — Modifies clear2 behavior with additional revert condition; related to current clear2 rounding adjustments.
  • arb and base sg #1964 — Updates subgraph/networks.json OrderBook addresses and startBlocks, overlapping with this data change.

Suggested reviewers

  • hardyjosh
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-08-16-clear-rounding-revert

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Siddharth2207 Siddharth2207 changed the base branch from main to v4 August 16, 2025 17:36
@thedavidmeister thedavidmeister merged commit 1df3554 into v4 Aug 18, 2025
17 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2025
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Oct 11, 2025
4 tasks
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.

3 participants