Skip to content

⚠️ Implement Slippage Alert System #78

@mijinummi

Description

@mijinummi

🧭 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:


🎯 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 estimate
  • threshold: configured maximum slippage
  • exceeded: boolean flag if slippage exceeds threshold
  • errors: 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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions