riftenlabs-indexer/src/db/moria_v11/deploy.rs
Dagur Valberg Johannsson a5e91afea8 Cut over to Moria v1-1; drop v1 indexing
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.
2026-08-18 09:15:19 +02:00

53 lines
2.3 KiB
Rust

// Copyright (C) 2024-2026 Whiterun LLC
//
// This software is licensed under the GNU Affero General Public License (AGPL), version 3.0 or later.
// A copy of the license can be found in the LICENSE file or at https://www.gnu.org/licenses/agpl-3.0.html
//! Per-network Moria v1-1 deployment constants.
//!
//! Mainnet is unconfigured until a v1-1 deployment exists (fail-closed).
use bitcoincash::{Network, TokenID};
use riftenlabs_defi::moria_v1_1::MoriaV11TokenIds;
/// Unique tail of the moria v1-1 redeem script. Partial scriptsig match —
/// every moria method spends this body.
const REDEEM_TAIL: [u8; 20] = [
0x51, 0xd2, 0x51, 0xcf, 0x88, 0x52, 0xd1, 0x00, 0x88, 0xc4, 0x53, 0x9c, 0x77, 0x77, 0x77, 0x68,
0x68, 0x68, 0x68, 0x68,
];
/// Chipnet v1-1 token categories and loan P2SH32, or `None` on other networks.
pub fn token_ids(network: Option<Network>) -> Option<MoriaV11TokenIds> {
match network {
Some(Network::Chipnet) => Some(MoriaV11TokenIds {
moria: "56d909e16cd3b4cecae685a7ca45baa292bf7550205c2ad59320a342c73754de"
.parse::<TokenID>()
.expect("valid chipnet moria v1-1 token_id"),
bp_oracle: "a0628bc21d10211a23f986fd12770e836bae43878db93db8b164ab8a5ab33c96"
.parse::<TokenID>()
.expect("valid chipnet bp_oracle v1-1 token_id"),
pool: "a533b7e96435af18136b534b43e465dd759db3ac33e8490b9bfd254b8c27ae48"
.parse::<TokenID>()
.expect("valid chipnet pool v1-1 token_id"),
bar: "bc98b2733ca1c2070586cce1a4216418830ccd9b19ff77b5d43d47542bb3b50d"
.parse::<TokenID>()
.expect("valid chipnet bar v1-1 token_id"),
loan_locking_bytecode: hex::decode(
"aa20415812e068086c90686635a813d77b6c412427e574e89b16e79feeaa48cf0f0787",
)
.expect("valid chipnet loan locking bytecode"),
}),
_ => None,
}
}
/// Electrum `mempool.get` filter for this network's loan lock + redeem tail.
pub fn mempool_filter(network: Option<Network>) -> Option<serde_json::Value> {
let ids = token_ids(network)?;
Some(serde_json::json!({
"scriptsig": hex::encode(REDEEM_TAIL),
"scriptpubkey": hex::encode(&ids.loan_locking_bytecode),
"operation": "union",
}))
}