Skip to content

chore: add eth_truf as order book collateral bridge#1363

Merged
MicBun merged 1 commit into
mainfrom
feat/eth-truf-collateral
Apr 24, 2026
Merged

chore: add eth_truf as order book collateral bridge#1363
MicBun merged 1 commit into
mainfrom
feat/eth-truf-collateral

Conversation

@MicBun
Copy link
Copy Markdown
Contributor

@MicBun MicBun commented Apr 24, 2026

resolves: https://github.com/truflation/website/issues/3492

Summary by CodeRabbit

Release Notes

  • New Features
    • Order book operations now support dynamic routing across multiple collateral bridge contracts during trading execution
    • Collateral management across locking, unlocking, and settlement validation has been extended to intelligently route operations to different bridge implementations based on configuration
    • Balance verification and collateral dispatch logic now correctly select the appropriate bridge for all trading actions

@MicBun MicBun requested a review from pr-time-tracker April 24, 2026 03:15
@MicBun MicBun self-assigned this Apr 24, 2026
@MicBun MicBun merged commit f791aa2 into main Apr 24, 2026
5 of 6 checks passed
@MicBun MicBun deleted the feat/eth-truf-collateral branch April 24, 2026 03:15
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97b55b9c-0401-479a-98fa-219680ef1699

📥 Commits

Reviewing files that changed from the base of the PR and between 279d79f and 0545663.

📒 Files selected for processing (5)
  • internal/migrations/031-order-book-vault.prod.sql
  • internal/migrations/032-order-book-actions.prod.sql
  • internal/migrations/033-order-book-settlement.prod.sql
  • internal/migrations/037-order-book-validation.prod.sql
  • scripts/generate_prod_migrations.py

📝 Walkthrough

Walkthrough

Order book system extended to support multiple collateral bridge contracts (eth_usdc and eth_truf) through conditional dispatch logic. Five SQL migration files and a migration generation script updated to route lock/unlock and validation operations to the appropriate bridge based on a $bridge parameter.

Changes

Cohort / File(s) Summary
Order Book Vault Operations
internal/migrations/031-order-book-vault.prod.sql
Modified ob_lock_collateral and ob_unlock_collateral to conditionally dispatch to eth_usdc or eth_truf based on $bridge parameter, replacing prior eth_usdc-only guards with multi-bridge routing and updated error messaging.
Order Book Actions
internal/migrations/032-order-book-actions.prod.sql
Updated validate_bridge, place_buy_order, place_split_limit_order, and change_bid to dispatch balance checks and collateral locking to the correct bridge instance based on $bridge parameter instead of unconditional eth_usdc usage.
Order Book Settlement
internal/migrations/033-order-book-settlement.prod.sql
Modified ob_batch_unlock_collateral and distribute_fees to select unlock implementation by $bridge, routing to either eth_usdc.unlock or eth_truf.unlock per payout and validator distribution.
Order Book Validation
internal/migrations/037-order-book-validation.prod.sql
Changed bridge balance retrieval from eth_usdc-only to conditional branching that selects appropriate bridge info source and updates validation error messaging.
Migration Generation Script
scripts/generate_prod_migrations.py
Expanded token substitution to map ethereum_bridge to eth_truf and refactored collapse_dispatch into generic multi-branch parser that filters for eth_usdc and eth_truf, reconstructing conditional dispatch chains; updated collapse_validate_and_chain to exclude sepolia_bridge and reference only supported mainnet bridges.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • pr-time-tracker

Poem

🐰 Two bridges now instead of one,
eth_usdc and eth_truf—let the routing run!
Conditional dispatch, so clever and neat,
Makes our order book logic complete! 🌉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/eth-truf-collateral

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@holdex
Copy link
Copy Markdown

holdex Bot commented Apr 24, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 2h Update time Apr 24, 2026, 3:16 AM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@MicBun MicBun changed the title chore: add eth_truf as order book collateral birdge chore: add eth_truf as order book collateral bridge Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant