New module: candlestick/policy.rs implements the core state machine that judges and applies legs for acceptance based on deviation from a reference price and qualification credit. Key components: - Leg: per-pool per-transaction change (sats_delta, token_delta, post-state reserves) - JudgeResult: verdict on whether a leg is accepted into OHLC - Policy: stateful fold that maintains pool reserves, qualification credit, and a min-depth-weighted median reference price Qualification rules (two-tier): - Tier 1: dev <= F (F=5) always accepted - Tier 2: dev > F but summed_credit >= q*largest_credit (q=5%) also accepted - Everything else is muted (volume still counted) Reference computation: - R = min-depth-weighted median of pool spot ratios - Updated only on reserve events (swaps, creations, withdrawals), never on prints - Depth = min(sats, tokens * R_prev) to zero-weight lopsided pools - Avoids ratchet-walking and qualifies token-heavy reseeds (OLA-like) Tests: 5 passing - unpriceable legs - first leg (no reference yet) - tier 1 acceptance (dev within F) - tier 1 rejection (dev > F, no credit) - credit seeding on accepted prints Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .vscode | ||
| contrib | ||
| internal | ||
| linters | ||
| src | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
Riftenlabs Indexer
RiftenLabs indexer is for indexing DeFi contracts by Riften Labs. It allows for querying historical on-chain data on Bitcoin Cash.
Contributing
All contributors are required to sign a Contributor License Agreement (CLA) before their contributions can be merged into the project.
Contributions are generally welcome. If you intend to make larger changes please discuss them in an issue before MRing them to avoid duplicate work and architectural mismatches.
Installing Rust
Rust can be installed using your package manager of choice or rustup.rs. The former way is considered more secure since it typically doesn't involve trust in the CA system. But you should be aware that the version of Rust shipped by your distribution might be out of date.
Building
The library can be built and tested using cargo:
git clone https://gitlab.com/riftenlabs/riftenlabs-indexer.git
cd riftenlabs-indexer
cargo build
You can run tests with:
cargo test