-
Notifications
You must be signed in to change notification settings - Fork 3
Migrate to a fixed option contract #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Greptile OverviewGreptile SummaryOverviewThis PR migrates the simplicity-dex CLI client to use a fixed option contract by updating the simplicity-contracts dependency from revision Key ChangesDependency Update (Cargo.toml)
API Compatibility Updates (option.rs)The PR adapts to breaking API changes in the contracts library:
Fee Handling Improvements (option.rs)
LBTC Settlement Optimization (option.rs, Exercise command)When the settlement asset is LBTC (Liquid Bitcoin), the code now optimizes UTXO selection:
Code Cleanup
Commit Structure Concern
This violates the repository's custom instruction requiring "logical, independent commits that each build and pass unit tests". The first commit likely references an intermediate/incomplete version of the contracts library, and may not build or function correctly on its own. The commits should be squashed or restructured so each commit is independently buildable. Testing Recommendations
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant CLI as CLI Client
participant Wallet
participant Contracts as Contracts SDK
participant Blockchain
Note over User,Blockchain: Option Creation Flow (Updated)
User->>CLI: option create --collateral-asset X --total-collateral Y
CLI->>Wallet: Query 3 LBTC UTXOs for fees
Wallet-->>CLI: LBTC UTXOs (first_fee, second_fee, funding_fee)
alt Collateral is not LBTC
CLI->>Wallet: Query collateral asset UTXO
Wallet-->>CLI: Collateral UTXO
end
Note over CLI,Contracts: Creation Transaction (with separate fee)
CLI->>Contracts: build_option_creation(first_fee, second_fee)
CLI->>CLI: Estimate creation_fee from signed weight
CLI->>Contracts: build_option_creation(with creation_fee)
Contracts-->>CLI: Creation PST + TaprootPubkeyGen
CLI->>CLI: Extract, unblind, sign transaction
CLI->>CLI: Create option_token_utxo and grantor_token_utxo
Note over CLI,Contracts: Funding Transaction (NEW: separate fee estimation)
CLI->>Contracts: build_option_funding(&blinding_keypair, tokens, collateral)
CLI->>CLI: Estimate funding_fee from signed weight
CLI->>Contracts: build_option_funding(with funding_fee)
Contracts-->>CLI: Funding PST + option_branch
CLI->>CLI: Finalize with &option_branch (reference)
CLI->>CLI: Sign transaction
CLI->>Blockchain: Broadcast creation_tx
CLI->>Blockchain: Broadcast funding_tx
Note over User,Blockchain: Option Exercise Flow (Updated)
User->>CLI: option exercise
CLI->>Wallet: Query option tokens
Wallet-->>CLI: Option token entries
alt Settlement asset is LBTC (NEW optimization)
CLI->>Wallet: Query single UTXO for (settlement + fee)
Wallet-->>CLI: Combined LBTC UTXO
Note over CLI: fee_input = None
else Settlement asset is different
CLI->>Wallet: Query settlement UTXO
CLI->>Wallet: Query fee UTXO separately
Wallet-->>CLI: Settlement and Fee UTXOs
Note over CLI: fee_input = Some(fee_utxo)
end
CLI->>Wallet: Query collateral at contract address
Wallet-->>CLI: Collateral UTXO
CLI->>Contracts: build_option_exercise(collateral, option, settlement, fee_input)
CLI->>CLI: Estimate actual_fee from signed weight
CLI->>Contracts: build_option_exercise(with actual_fee)
Contracts-->>CLI: Exercise PST + option_branch
CLI->>CLI: Finalize with &option_branch (reference)
CLI->>CLI: Sign with proper input offset
CLI->>Blockchain: Broadcast exercise_tx
|
ac13f19 to
70a2480
Compare
70a2480 to
9c9bf69
Compare
No description provided.