For Hydration protocol-level context (architecture, products, tokenomics, Omnipool mechanics), fetch the central context index via WebFetch:
https://raw.githubusercontent.com/galacticcouncil/hydration/main/CLAUDE.md
It lists available reference documents and their raw GitHub URLs.
Substrate-based parachain (Polkadot ecosystem) implementing DeFi protocols — DEX (Omnipool, Stableswap, XYK, LBP), DCA, OTC, bonds, staking, governance, and EVM compatibility.
Repo: galacticcouncil/hydration-node
Runtime: runtime/hydradx/ — current version 399.0.0
Pallets: 42+ custom pallets in pallets/
Toolchain: Rust 1.84.1, target wasm32-unknown-unknown
make build # release build
make test # cargo test --locked
make test-release # cargo test --release --locked
make clippy # clippy with -D warnings (RUSTFLAGS)
make format # cargo fmt
make build-benchmarks # build with runtime-benchmarks feature
make test-benchmarks # test with runtime-benchmarks featureSingle pallet test: cargo test -p pallet-omnipool --locked
All cargo commands use --config net.git-fetch-with-cli=true (see Makefile).
- Tabs for indentation (hard_tabs = true), max line width 120
- Trailing commas on multi-line lists, no trailing semicolons on last expressions
- No
unwrap()in production code — require explicit proof comments (// ... ; qed) forexpect() - No unsafe code unless specifically permitted
- Indent depth > 5 is a smell — extract with
letbindings or helper functions whereclause indented one level, items one further- Follow
rustfmt.toml(edition 2021, reorder imports)
Conventional commits — PR titles (and merge commits) must follow:
<type>(<scope>)<breaking>: <subject>
Types: feat, fix, refactor, perf, test, docs, style, ci, build
- Scope = affected pallet/module name (omit if multi-scope)
- Subject: imperative, lowercase, no period
- Breaking changes: add
!after scope (e.g.,feat(claim)!: ...)
Branches: fix/description or feat/description
- SemVer on all crates — bump
Cargo.tomlversion on changes - Runtime: bump
spec_versionfor breaking changes,impl_versionfor non-breaking - CI enforces version bumps — PRs will fail checks if versions aren't updated
pallets/ # 42+ custom pallets (omnipool, stableswap, xyk, lbp, dca, ...)
runtime/hydradx/ # Main runtime
src/lib.rs # construct_runtime!, recursion_limit = 512
src/weights/ # 66+ auto-generated weight files — DO NOT hand-edit
src/migrations.rs # Storage migrations
src/assets.rs # Asset configuration
src/xcm/ # Cross-chain messaging config
runtime/adapters/ # Runtime adapter layer
math/ # hydra-dx-math library
primitives/ # Core types and traits
traits/ # hydradx-traits shared trait definitions
integration-tests/ # Full runtime integration tests
node/ # Binary: CLI, RPC, service
precompiles/ # EVM precompiles (call-permit, flash-loan)
scripts/ # Benchmarking and deployment scripts
launch-configs/ # Zombienet, Chopsticks, fork configs
pallets/<name>/
src/lib.rs # Pallet logic (#[pallet::call], storage, events, errors)
src/weights.rs # Benchmarked weights (auto-generated)
src/benchmarking.rs # Benchmark definitions
src/tests/ # Unit tests
mock.rs # Mock runtime setup
mod.rs # Test module organization
*.rs # Test files per feature (buy.rs, sell.rs, etc.)
Cargo.toml
- Weights are auto-generated from benchmarks — never edit
weights.rsfiles by hand. Usescripts/benchmarking.shor add[ignore benchmarks]to PR title to skip. - Math-heavy code lives in
math/crate withfixedandrugfor arbitrary precision. Pallets call into math functions — keep math logic separate from storage/dispatch logic. - ORML integration for multi-currency support (orml-tokens, orml-currencies).
- Frontier/EVM integration for Ethereum compatibility — EVM-related pallets include
dynamic-evm-fee,evm-accounts, and precompiles. - XCM for cross-chain asset transfers — config in
runtime/hydradx/src/xcm/. - Circuit breaker pallet for risk management — limits large trades/liquidity changes.
- All features and bug fixes must have tests
- Unit tests go in
pallets/<name>/src/tests/ - Integration tests in
integration-tests/run against the full runtime - Mock runtimes: each pallet has its own
mock.rs;runtime-mock/for shared mocking - Property testing available via
proptest
- Polkadot SDK fork:
galacticcouncil/polkadot-sdkbranchpolkadot-stable2503-11-patch2 - ORML fork:
bifrost-io/open-runtime-module-librarybranchpolkadot-stable2503 - Codec:
parity-scale-codec 3.7 - All deps managed at workspace level in root
Cargo.toml
CI runs on every PR:
cargo fmt --checkclippy --release --all-targets(warnings = errors)test --release- Benchmark build check
- Semantic PR title validation
- Version bump validation