Contract Details
Tech Stack
Solidity ^0.8.24 OpenZeppelin v5 Chainlink Foundry
Chains
Ethereum Arbitrum Base Optimism
Description
Pre-trade simulation and slippage protection smart contract module. Simulates swap outcomes on-chain before execution, enforces maximum slippage tolerances, and provides Chainlink oracle-based price validation. Composable module that wraps any DEX router call.
Features
- ✓ Balance-diff swap verification pattern
- ✓ Chainlink oracle price impact validation
- ✓ Static call simulation for slippage estimation
- ✓ Configurable staleness thresholds per oracle
- ✓ Works with fee-on-transfer tokens
- ✓ 12 custom errors with descriptive parameters
- ✓ PriceLib — reusable calculation library
- ✓ Comprehensive fuzz tests + gas benchmarks
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @title Slippage Guard /// @notice Pre-trade simulation + slippage protection module. contract SlippageGuard { address public immutable owner; uint256 public constant VERSION = 1; event Initialized(address indexed deployer); constructor() { owner = msg.sender; emit Initialized(msg.sender); } // ... full implementation in purchased package }