Backend indexer for Riften Labs BCH DeFi contracts (Cauldron, Moria). Mirror of gitlab.com/riftenlabs/riftenlabs-indexer (AGPL-3.0). Author: Riften Labs.
Find a file
Hossein Zoda dcebaf2648 tokentoken/tokenbch: index delegation pools, replace the pre-delegation AMM
Replace the old P2SH32/CONJURE TokenToken AMM indexer (never in
production; its tables are dropped by an always-run migration) with the
delegation-model indexers from riftenlabs-defi 0.4.5:

- tokentoken: two co-created bare-P2S UTXOs (thin main + storage
  sibling). tokenbch (new): single-UTXO token<->BCH pool with the
  runtime feePaidInToken fee side. Both admitted purely by the constant
  locking derived from the per-network delegation-pool platform NFTH.
- src/db/orbconstants.rs: ONE platform NFTH serves both contracts —
  chipnet pins the deployed ORB v0 value (libriften orb/v0/chipnet.ts),
  mainnet is the all-zero placeholder: while unconfigured NOTHING
  delegation-related is parsed, fetched or indexed (fail-closed).
- Schema: immutable config (nftOwner, tokens, poolFeeRate, minFee,
  virtualX/Y, tokenbch feePaidInToken) on the pool row; per-state
  history carries raw reserves, owed, platformFeeRate (both mutable by
  platform sweeps) and deltas. History rows now FK tx(txid) ON DELETE
  CASCADE, so evicted mempool txs clean up after themselves (the old
  tokentoken indexer leaked those).
- LP teardowns carry no pool output: ingestion probes every
  blob-presenting tx's spent outpoints against the recorded pool set
  and flags a known pool UTXO spent without successor as withdrawn
  (withdrawn_in_txid FK ON DELETE SET NULL reverts an evicted teardown;
  reorg undo reverts a confirmed one).
- electrum mempool filters: the combined logic blob (scriptsig; every
  spend incl. teardowns) + the constant thin-main locking (scriptpubkey;
  creations), per contract, skipped while unconfigured.
- RPC: /tokentoken responses gain owed_a, platform/pool fee rates,
  minFee and virtual offsets; new /tokenbch (pool/active?token, pools,
  tokens) mirrors it for BCH pairs.
- deps: bitcoincash 0.32.4 (token.amount -> .to_int() in the ido
  indexer), riftenlabs-defi 0.4.5. NOTE: 0.4.5 (rust-riftenlabs-defi
  7c65f66) is not on crates.io yet — until it is published, build with
  a local [patch.crates-io] pointing at the sibling checkout (the
  committed Cargo.lock carries the path-patched entry). Also fixes a
  latent test bug (ido_params_nft_commitment_roundtrip never wrote
  createExecutionFee after the 127-byte layout shift).

Verified: cargo build, test (232 passing), clippy (no new warnings)
and fmt all clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-12 10:06:13 +03:00
.vscode Convert hash columns from TEXT to BLOB storage 2026-01-22 08:30:17 +01:00
contrib Delphi v2 support 2026-05-04 15:03:40 +02:00
internal Expose authchain head + optional local IPFS gateway for BCMR downloads 2026-06-24 11:07:31 +00:00
linters Fix potential API hangs from write lock contention 2026-02-02 21:01:50 +01:00
src tokentoken/tokenbch: index delegation pools, replace the pre-delegation AMM 2026-08-12 10:06:13 +03:00
.gitignore Add Chipnet support 2026-01-09 13:46:58 +01:00
.gitlab-ci.yml ci: Use lockfile as cache key 2026-02-02 11:52:09 +01:00
build.rs missing build file 2024-10-25 15:28:40 +02:00
Cargo.lock tokentoken/tokenbch: index delegation pools, replace the pre-delegation AMM 2026-08-12 10:06:13 +03:00
Cargo.toml tokentoken/tokenbch: index delegation pools, replace the pre-delegation AMM 2026-08-12 10:06:13 +03:00
LICENSE use AGPL 2024-02-05 16:32:27 +01:00
README.md README: contributors license 2024-03-14 10:54:44 +01:00

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