Implement CollateralValuation trait for multi-asset solver bonds#16
Open
zmanian wants to merge 5 commits into
Open
Implement CollateralValuation trait for multi-asset solver bonds#16zmanian wants to merge 5 commits into
zmanian wants to merge 5 commits into
Conversation
Adds a unified system for accepting multiple collateral types as solver bonds: ## New Types (collateral.rs) - CollateralAsset enum: Native, LsmShare, HydroVault - AssetClass with fixed haircuts: Native 0%, LSM 10%, Hydro 20% - SolverBondPool with multi-asset deposit support - CollateralDeposit with lock/unlock for per-settlement locking - LiquidationIntent and LiquidationBid for intent-based liquidation - Helper functions: apply_haircut, reverse_haircut, calculate_lock_requirement ## Valuation Trait (valuation.rs) - CollateralValuation trait with get_raw_value, get_collateral_value, haircut_bps - NativeValuation: 1:1 for uatom, rejects other denoms - LsmShareValuation: 1:1 with 10% haircut covering slashing risk - HydroVaultValuation: ratio-based using ControlCenterPoolInfo - Same-chain: direct contract query - Cross-chain: cached ICQ with staleness check (1 hour max) - create_valuation factory function - Bond pool valuation helpers ## Tests - 19 new unit tests covering all collateral types - Haircut calculations, staleness checks, lock/unlock operations - All 88 tests pass Implements design from docs/plans/2026-01-05-collateral-valuation-trait.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This integrates the CollateralValuation trait and bond pool management into the settlement contract: Execute handlers: - DepositCollateral: Deposit collateral to solver's bond pool - WithdrawCollateral: Withdraw unlocked collateral from bond pool - UpdatePoolInfo: Cache pool info for cross-chain Hydro vaults (via ICQ) - BidOnLiquidation: Submit bid on a liquidation intent - ExecuteLiquidation: Settle winning bid and transfer collateral - CancelLiquidation: Cancel expired liquidation (admin only) Settlement flow integration: - CreateSettlement now locks 1.5x collateral from solver's bond pool - MarkCompleted now unlocks the collateral - SlashSolver now seizes collateral and creates liquidation intent for non-native assets (LSM shares, Hydro vault shares) Query handlers: - BondPool: Query solver's bond pool deposits - CollateralValue: Query total value after haircuts - AvailableCollateral: Query unlocked collateral value - Liquidation: Query liquidation intent details - PendingLiquidations: List active liquidations - CachedPoolInfo: Query Hydro vault pool info Key features: - Per-settlement 1.5x collateral locking (vs old fixed bond system) - Multi-asset support (Native ATOM, LSM shares, Hydro vault shares) - Fixed haircuts per asset class (0% native, 10% LSM, 20% Hydro) - Intent-based liquidation for non-liquid collateral - Backwards compatibility with legacy fixed bond system 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add comprehensive collateral_tests.rs with 30 tests covering: - Collateral deposits (native, LSM, multiple types) - Withdrawal permissions and limits - Per-settlement collateral locking - Settlement completion unlocking - Slashing and liquidation creation - Pool info caching and staleness - Liquidation auctions (bid, execute, cancel) - Update existing tests to work with new per-settlement locking: - Add deposit_collateral helper function - Modify register_solver to also deposit collateral - Update test_slash_solver_success to verify bond pool behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- cancellation.rs: Remove empty line between doc comments - handlers.rs: Allow too_many_arguments for execute_create_settlement - helpers.rs: Combine identical if blocks in speed_score calculation - adversarial_settlement_tests.rs: - Convert outer doc comments to inner doc comments - Remove unused imports (from_json, query, QueryMsg, SettlementResponse) - Prefix unused result variables with underscore - Add #[allow(dead_code)] to fake_solver field - Add collateral deposit to register_solver helper 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the
CollateralValuationtrait system that unifies support for multiple collateral types as solver bonds:Key features:
Changes
Core Types (
crates/types/)collateral.rs- Core collateral types, bond pools, liquidation intentsvaluation.rs-CollateralValuationtrait and implementationsSettlement Contract (
contracts/settlement/)Related
docs/plans/2026-01-05-collateral-valuation-trait.mddocs/plans/2026-01-03-solver-bond-redesign.mdTest plan
🤖 Generated with Claude Code