/** * Vault Snapshot Module - The Brain * * This module calculates ALL vault intelligence from simple contract state. * It is the single source of truth for vault health metrics. * * Architecture: * - Smart Contract: Stores simple state (ucdDebt, termStartTimestamp, btcCollateralSats) * - This Module: Calculates everything else (ratios, thresholds, risk metrics) * * The vault-snapshot is used by: * - Minting authorization (check if sufficient collateral) * - Liquidation detection (check if under threshold) * - UI display (show vault health to user) * - Repayment calculations (how much can be repaid) */ import { VaultSnapshot, VaultSnapshotConfig } from "../interfaces/chunks/vault-snapshot.i"; /** * NOTE: In the LIT Actions runtime, `ethers` is provided as a global. * We declare it here so TypeScript can type-check this module when building * the package without bundling ethers or importing it as a module. */ /** * Vault Snapshot Module * * The intelligence layer that transforms simple contract state into * comprehensive vault health metrics. */ export declare class VaultSnapshotModule { private config; constructor(config: VaultSnapshotConfig); /** * Get complete vault snapshot * * This is the main entry point. Returns everything you need to know * about a vault's health in a single call. * * @param positionId - Position to snapshot * @returns Complete VaultSnapshot with all metrics */ getVaultSnapshot(positionId: string): Promise; /** * Query position state from smart contract * * Gets the simple state that contract stores: * - positionId, pkpId, borrower, vaultAddress * - ucdDebt * - termStartTimestamp * - selectedTerm * - status */ protected queryPositionState(positionId: string): Promise<{ positionId: string; pkpId: string; borrower: string; vaultAddress: string; ucdDebt: bigint; termStartTimestamp: number; selectedTerm: number; status: number; expiryAt: number; previousExpiryAt: number; totalTerm: number; lastRenewedAt: number; }>; /** * Quick check if position is liquidatable * * Convenience method when you only need to know if position can be liquidated. * * @param positionId - Position to check * @returns True if position is liquidatable */ isLiquidatable(positionId: string): Promise; /** * Get collateral ratio for position * * Convenience method when you only need the collateral ratio. * * @param positionId - Position to check * @returns Collateral ratio in basis points */ getCollateralRatio(positionId: string): Promise; /** * Get available BTC balance * * Convenience method when you only need available balance. * * @param positionId - Position to check * @returns Available BTC in satoshis */ getAvailableBalance(positionId: string): Promise; /** * Check if position has sufficient collateral for new debt * * Used by minting authorization to validate new mints. * * @param positionId - Position to check * @param additionalDebt - Additional UCD debt to add * @param requiredRatioBps - Required collateral ratio (e.g., 11000 for 110%) * @returns True if sufficient collateral exists */ hasSufficientCollateral(positionId: string, additionalDebt: bigint, requiredRatioBps: number): Promise; } /** * Factory function to create VaultSnapshotModule * * @param config - Configuration * @returns VaultSnapshotModule instance */ export declare function createVaultSnapshotModule(config: VaultSnapshotConfig): VaultSnapshotModule; /** * USAGE EXAMPLE: * * ```typescript * import { createVaultSnapshotModule } from './modules/vault-snapshot'; * import { BitcoinDataProvider } from './modules/bitcoin-data-provider.module'; * import { PriceOracleModule } from './modules/price-oracle.module'; * * // Initialize dependencies * const bitcoinProvider = new BitcoinDataProvider({ * providerUrl: 'https://blockstream.info/testnet/api' * }); * * const priceOracle = new PriceOracleModule('mainnet'); * * // Create vault balance module * const vaultBalance = createVaultBalanceModule({ * contractAddress: '0x...', * chain: 'sepolia', * bitcoinProvider, * minConfirmations: 6 * }); * * // Create vault snapshot module * const vaultSnapshot = createVaultSnapshotModule({ * contractAddress: '0x...', * chain: 'sepolia', * vaultBalance, * priceOracle, * }); * * // Get complete snapshot * const snapshot = await vaultSnapshot.getVaultSnapshot('position123'); * * console.log('Position:', snapshot.positionId); * console.log('Collateral Ratio:', snapshot.collateralRatioBps / 100, '%'); * console.log('Liquidatable:', snapshot.isLiquidatable); * console.log('Days Until Expiry:', snapshot.daysUntilExpiry); * console.log('Available BTC:', snapshot.availableBTCSats, 'sats'); * * // Or use convenience methods * const isLiquidatable = await vaultSnapshot.isLiquidatable('position123'); * const collateralRatio = await vaultSnapshot.getCollateralRatio('position123'); * const availableBalance = await vaultSnapshot.getAvailableBalance('position123'); * * // Check if can mint more UCD * const canMint = await vaultSnapshot.hasSufficientCollateral( * 'position123', * BigInt(5000), // Want to mint 5000 more UCD * 11000 // Required 110% ratio * ); * ``` */ //# sourceMappingURL=vault-snapshot.d.ts.map