Skip to content

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windmill Stability Nexus

 

Static Badge

Telegram Badge    X (formerly Twitter) Badge    Discord Badge    OpenSSF Scorecard


Windmill EVM Contracts

Windmill EVM Contracts contains the core smart contracts of Windmill Exchange — a decentralized on-chain order matching engine with configurable dynamic pricing curves and autonomous keeper matching.

Orders (buy and sell) are submitted on-chain and continuously matched by keeper bots. Matching rewards are earned by keepers based on configurable price curves, and all settlements happen atomically on-chain.


🔗 Repository Links

  1. Web UI
  2. Keeper Bots
  3. Main Repository

🚀 Features

  • On-chain order matching: buy and sell orders stored on-chain in OrderStorage and PairStorage and matched atomically.
  • Dynamic pricing curves: configurable PriceCurve and MathUtils libraries drive matching rewards.
  • Safe token handling: TokenTransfer library with reentrancy-aware ERC20 transfers.
  • Auction-based incentive model: keepers earn on each executed match.
  • Foundry toolchain: build, fuzz, gas-snapshot, and Slither workflows out of the box.

Architecture

src/
├── core/
│   └── WindmillExchange.sol   # Core exchange + matching logic
├── interfaces/
│   ├── IWindmillExchange.sol  # Public exchange interface
│   └── IERC20.sol             # Minimal ERC20 interface
├── libraries/
│   ├── MathUtils.sol          # Safe math helpers
│   ├── PriceCurve.sol         # Configurable dynamic pricing curves
│   └── TokenTransfer.sol      # Reentrancy-aware token transfers
└── storage/
    ├── OrderStorage.sol       # Order book storage
    └── PairStorage.sol        # Trading pair storage

script/
└── DeployWindmill.s.sol       # Deployment script (Foundry)

test/
└── WindmillExchange.t.sol     # Core test suite

Flow

flowchart LR
    U[User / Trader] -->|placeOrder| X(WindmillExchange)
    K[Keeper Bot] -->|match/matchExecution| X
    X -->|store| OS[(OrderStorage)]
    X -->|price curve| PC[[PriceCurve]]
    X -->|transfer| TT[[TokenTransfer]]
    X -->|settle + pay keeper| U
    K -.->|scan events| X
Loading

🛠️ Tech Stack

Layer Technology
Language Solidity ^0.8.23
Framework Foundry (forge, cast, anvil)
Libraries OpenZeppelin + forge-std (via lib/)
Static analysis Slither (CI)

📁 Repository Structure

.
├── .github/workflows/     # CI, security, gas, fuzz, release pipelines
├── lib/                   # Foundry dependencies (git submodules)
├── public/                # Logos and static assets
├── script/                # Forge deployment scripts
├── src/                   # Solidity source contracts
├── test/                  # Forge test suite
├── foundry.toml           # Foundry config (RPCs, verifiers)
├── foundry.lock           # Locked dependency versions
├── Deployments.md         # Deployment records
└── README.md

🚀 Getting Started

Prerequisites

Tool Version Install
git any git-scm.com
foundryup latest See getfoundry.sh
forge / cast / anvil latest run foundryup after install

Verify installation:

forge --version
anvil --version
cast --version

Installation

# 1. Clone with submodules
git clone --recurse-submodules https://github.com/StabilityNexus/Windmill-EVM-Contracts
cd Windmill-EVM-Contracts

# 2. If you forgot --recurse-submodules
git submodule update --init --recursive

# 3. Install/update Foundry dependencies
forge install

Build

forge build

Test

# Run all tests
forge test

# Verbose output (logs and traces)
forge test -vvv

# Run a specific test
forge test --match-test testMatchOrders -vvv

Coverage

forge coverage
forge coverage --report lcov
genhtml lcov.info --output-directory coverage/

Gas Snapshot

forge snapshot          # generate snapshot
forge snapshot --diff   # compare against last snapshot

Format & Lint

forge fmt              # format Solidity files
forge fmt --check      # check without writing (used in CI)

🔧 Deployment

Make sure your .env is configured before deploying. See .env.example and Deployments.md.

# Fork-test / local deployment with Anvil
anvil   # in one terminal

# Deploy (set RPC url for your target network)
forge script script/DeployWindmill.s.sol \
  --rpc-url <RPC_URL> \
  --broadcast \
  --verify \
  -vvvv

RPC aliases (ethereum, sepolia, base, polygon, etc.) are pre-configured in foundry.toml.


Supported Networks

Network Chain ID
Ethereum (Mainnet) 1
Ethereum Classic (Mainnet) 61
Polygon PoS (Mainnet) 137
BNB Smart Chain (Mainnet) 56
Base (Mainnet) 8453
Avalanche C-Chain (Mainnet) 43114
Sepolia (Testnet) 11155111
Mordor (ETC Testnet) 63

CI/CD Workflows

Workflow Trigger What it does
ci.yml Push / PR Format check → Build → Unit tests → Coverage report
security-slither.yml Push / PR Slither static analysis for vulnerabilities
gas-snapshot.yml Push / PR Gas baseline and regression checks
nightly-fuzz.yml Nightly (cron) Deep fuzz & invariant testing
release.yml Tag push Builds and publishes release artifacts

🔒 Security

  • Static analysis is run on every PR via Slither (.github/workflows/security-slither.yml).
  • CodeRabbit AI review is enabled via .coderabbit.yaml.
  • Deep fuzz runs nightly to catch edge cases.

Found a vulnerability? Please do not open a public issue. Contact the Stability Nexus team privately via Discord or Telegram.


🙌 Contributing

⭐ Don't forget to star this repository if you find it useful! ⭐

Thank you for considering contributing to this project! Please read our Contribution Guidelines first — they cover the mandatory Discord workflow and our AI-use disclosure policy.


📍 License

See COPYRIGHT.md and DCO.md for intellectual property and sign-off details.


💪 Thanks To All Contributors

Contributors

© Stability Nexus

About

Auction-Based Order-Book Exchange

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages