Skip to content

Add preflight_swap read-only validation endpoint#114

Merged
ameeribro4-sudo merged 1 commit into
OpenPeerX:mainfrom
merlik787-droi:fix/issue-77-preflight-validation
Jul 21, 2026
Merged

Add preflight_swap read-only validation endpoint#114
ameeribro4-sudo merged 1 commit into
OpenPeerX:mainfrom
merlik787-droi:fix/issue-77-preflight-validation

Conversation

@merlik787-droi

Copy link
Copy Markdown
Contributor

Summary

Implemented a production-ready pre-flight validation function following the Stripe-like pattern requested in the issue.

Changes

  • errors.rs: Added SwapChecklist struct (9 boolean fields covering every swap guard) and SwapChecklistError enum with typed error variants
  • lib.rs: Added mod validation to wire the previously orphaned validation module into the contract
  • lib.rs: Added preflight_swap read-only entry point that mirrors all guards from swap() — balance, KYC, rate-limit, slippage, oracle freshness, pool depth, circuit breaker, trading pause, and pair validity — without mutating state or requiring authentication
  • Reused existing validation::validate_swap_pair, RateLimiter::check_swap_limit, kyc::KYCSystem::is_verified, risk_management::CircuitBreaker::is_circuit_breaker_active, and oracle::get_stored_price for all checks
  • Verified formatting
  • No unrelated changes introduced

Closes #77

Implement a Stripe-like pre-flight validation function that lets traders
verify swap viability before signing and submitting a transaction.

- Add SwapChecklist struct with balance, KYC, rate-limit, slippage,
  oracle freshness, pool depth, circuit breaker, trading pause, and
  pair validity checks
- Add SwapChecklistError enum for typed error decoding
- Wire orphaned validation.rs module into the contract
- Reuse existing validation helpers, rate limiter, KYC system, oracle,
  and risk management modules for all checks

Closes OpenPeerX#77

@ameeribro4-sudo ameeribro4-sudo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ameeribro4-sudo
ameeribro4-sudo merged commit 39b8451 into OpenPeerX:main Jul 21, 2026
3 checks passed
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.

[PeerX Backlog # 77] Add a Stripe-like pattern: pre-flight validation function

2 participants