Switch the indexer off the local path dep onto crates.io 0.5.1 (75-byte
loan, 3-byte principal). Point chipnet deploy constants at TEST18 and
keep continuation UTXOs on partial redeem/repay.
Replace the v1 moria indexer with v1-1 tables and RPC. Chipnet tracks the
live deployment only; mainnet stays idle until a v1-1 deployment exists.
v1-1 rows carry delegate hash, borrow-time allowance deposits, crank fee
takes, and allowance-close recoveries. Policy lives on the parked
allowance (verified nSequence hint or first spend), not on the loan NFT.
Bar/pool history and realized NAV APR are confirmed-blocks only.
Bind the API before IBD so Rocket is up during sync. Empty electrum
header batches shrink the chain instead of panicking.
Depend on published riftenlabs-defi 0.4.6.
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>
Migrate the ido module's arbitrary-precision math from num-bigint to
malachite (already a workspace dependency). BigInt becomes
malachite::Integer throughout; the VM-number byte codec uses
PowerOf2Digits, sign handling uses Integer::sign(), and primitive
conversions use try_from.
Add an IntegerAsStr serde adapter for string-serialized fields, since
malachite's FromStr::Err is () and does not satisfy DisplayFromStr's
Display bound. JSON output is unchanged.
Drop the now-unused num-bigint and num-traits dependencies.
Also fix all clippy warnings in the module surfaced by the migration
(unwrap-after-is_none control flow, a const->static LazyLock bug,
an oversized enum variant boxed, and assorted mechanical lints).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes the indexer crash on chipnet: bitcoincash 0.32.1's
Opcode::classify panicked on BCH re-enabled opcodes (e.g. OP_SPLIT),
which riftenlabs-defi hit while parsing input scriptSigs in
parse_cauldrons_from_tx. bitcoincash 0.32.2 makes classify total and
panic-free (and adds the May 2026 upgrade opcodes); riftenlabs-defi
0.4.1 additionally hardens read_push_from_script to not classify
non-push opcodes at all.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Migrate off the deprecated bitcoincash 0.29 API (Amount/Version types,
FromHex -> FromStr/parse, non-exhaustive Network) across the indexer and
tests.
Add indexing of native token-A <-> token-B (TokenToken) AMM pools:
- tokentoken_pool / tokentoken_pool_history_entry tables in cauldron.db,
created via an always-run idempotent migration (no DB_VERSION bump, so
existing databases upgrade in place)
- block-path indexing sharing the cauldron write transaction and reorg
undo, with creation/swap/withdrawal state tracking and reserve deltas
- mempool indexing: electrum mempool.get filters on the tokentoken
contract code (spends) and the CONJURE op_return hint (creations);
first_seen_timestamp reconciles with mtp on confirmation
- RPC endpoints /tokentoken/pool/active (pair lookup, order-insensitive)
and /tokentoken/tokens
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This makes the application fully async; freeing web server threads to
handle new connections when waiting on SQL queries.
Additionally sqlx will allow easier move to a different database if
needed in the future.
Includes some SQL optimizations as well (slow queries more easliy identifiable
with sqlx).