-
Notifications
You must be signed in to change notification settings - Fork 23
Labels
Description
🧭 Overview
BridgeWise allows users to execute cross-chain transfers, but high slippage can result in unexpected losses.
This issue introduces a Slippage Alert System that:
- Monitors slippage in real-time
- Notifies users or developers when slippage exceeds safe thresholds
- Integrates with benchmarking (feat: implement centralized configuration module #30), fee estimation (Transaction State Tracking Service (“Heartbeat”) #16), and transaction tracking (feat: Setup Storybook documentation in apps/docs #27)
- Supports headless mode (Logging & Audit Trail for Critical Actions #24) and UI components (
<BridgeCompare />,<BridgeStatus />)
🎯 Problem
- Users may unknowingly execute transfers with excessive slippage
- Developers embedding BridgeWise have no automated alerts
- High slippage can reduce user trust and increase failed transfer complaints
- Without alerts, SDK cannot ensure safe and predictable transfers
💡 Proposed Solution
Implement a Slippage Alert System that:
- Monitors slippage for each transfer in real-time
- Supports configurable thresholds per token, bridge, or network
- Exposes hooks and events:
useSlippageAlert()
- Integrates with UI to show warnings or disable risky routes
- Supports headless mode for custom UI notifications
🛠 Scope of Work
1️⃣ Slippage Alert Hook
const { slippage, threshold, exceeded, errors } = useSlippageAlert({
token: "USDC",
sourceChain: "Ethereum",
destinationChain: "Stellar",
maxSlippagePercent: 1.0,
});slippage: current slippage estimatethreshold: configured maximum slippageexceeded: boolean flag if slippage exceeds thresholderrors: structured error info
2️⃣ Integration With Components
<BridgeCompare />highlights routes exceeding slippage thresholds<BridgeStatus />shows real-time alerts during transaction execution- Optional toast or banner notifications for end-users
3️⃣ Configurable Thresholds
- Developers can configure slippage limits per token or route:
{
USDC: 0.5,
ETH: 1.0,
STX: 0.8
}- Enables fine-grained control for dApp UX
4️⃣ Error Handling & Fallbacks
- Handle missing or delayed quote/slippage data
- Fallback to safe defaults if no live data available
- Ensure hook does not break UI or headless workflows
📊 Expected Outcome
- Users receive alerts when slippage is too high
- Developers can enforce safe transfer limits
- Reduced failed or costly transfers
- Supports headless integration for custom UIs
✅ Acceptance Criteria
-
useSlippageAlert()hook implemented and SSR-safe - Configurable thresholds per token, bridge, or route
- Integration with
<BridgeCompare />and<BridgeStatus /> - Real-time monitoring and alerting functional
- Fallback behavior for missing slippage data
- Unit tests for hook and UI integration
- Documentation updated with usage examples
📈 Measurable Impact
- Minimized user losses due to high slippage
- Improved user trust and experience
- Developers gain fine-grained control over safe transfers
- Enhanced integration with benchmarking and fee monitoring
🧪 Testing Requirements
- Simulate transactions with varying slippage levels
- Verify real-time alerting in hooks and UI components
- Test threshold configurations and overrides
- Confirm fallback behavior for missing or delayed data
- Validate SSR-safe and headless mode compatibility
📚 Documentation Requirements
- Add “Slippage Alert System” section to README
- Provide hook usage example:
const { slippage, threshold, exceeded } = useSlippageAlert({
token: "USDC",
sourceChain: "Ethereum",
destinationChain: "Stellar",
maxSlippagePercent: 1.0,
});- Include examples for UI and headless mode integration
- Document configuration options and fallback behavior
Reactions are currently unavailable