Skip to content

Commit c40a36c

Browse files
committed
fix test
chore: * add oracle signature, merge tokens logic * move around params, fix some namings * decompose process_helper_commands * rename dependencies on contracts * introduce another tag kind for maker replies * update cargo.toml fix: * helpers mint tokens
1 parent ed5120a commit c40a36c

29 files changed

+871
-131
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ dist/
4040
# Logs
4141
logs/*
4242

43-
/.simplicity-dex.config.toml
43+
/.simplicity-dex.config.toml
44+
/.cache
45+
taker/
46+
simplicity-dex

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ nostr = { version = "0.43.1", features = ["std"] }
2929
nostr-sdk = { version = "0.43.0" }
3030
serde_json = { version = "1.0.145" }
3131
serde = { version = "1.0.228" }
32-
simplicity-contracts-adapter = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "69e1f71", package = "contracts-adapter" }
33-
simplicity-contracts = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "69e1f71", package = "contracts" }
32+
contracts-adapter = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "3d5e0ce", package = "contracts-adapter" }
33+
contracts = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "3d5e0ce", package = "contracts" }
3434
simplicity-lang = { version = "0.6.0" }
3535
simplicityhl = { version = "0.2.0" }
36-
simplicityhl-core = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "69e1f71", package = "simplicityhl-core", features = ["encoding"] }
36+
simplicityhl-core = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "3d5e0ce", package = "simplicityhl-core", features = ["encoding"] }
3737
sled = { version = "0.34.7" }
3838
thiserror = { version = "2.0.17" }
3939
tokio = { version = "1.48.0", features = ["macros", "test-util", "rt", "rt-multi-thread"] }

crates/dex-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ global-utils = { workspace = true }
2626
hex = { workspace = true }
2727
nostr = { workspace = true }
2828
serde_json = { workspace = true }
29-
simplicity-contracts = { workspace = true }
30-
simplicity-contracts-adapter = { workspace = true }
29+
contracts = { workspace = true }
30+
contracts-adapter = { workspace = true }
3131
simplicity-lang = { workspace = true }
3232
simplicityhl = { workspace = true }
3333
simplicityhl-core = { workspace = true }

crates/dex-cli/src/cli/helper.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::cli::CommonOrderOptions;
22
use clap::Subcommand;
3+
use nostr::EventId;
34
use simplicity::elements::OutPoint;
45

56
#[derive(Debug, Subcommand)]
@@ -59,4 +60,85 @@ pub enum HelperCommands {
5960
#[command(flatten)]
6061
common_options: CommonOrderOptions,
6162
},
63+
#[command(about = "Sign oracle message with keypair [testing only]")]
64+
OracleSignature {
65+
/// Price at current block height
66+
#[arg(long = "price-at-current-block-height")]
67+
price_at_current_block_height: u64,
68+
/// Settlement height
69+
#[arg(long = "settlement-height")]
70+
settlement_height: u32,
71+
/// Oracle account index to derive key from `SEED_HEX`
72+
#[arg(long = "oracle-account-index")]
73+
oracle_account_index: Option<u32>,
74+
},
75+
#[command(about = "Merge 2 token UTXOs into 1")]
76+
MergeTokens2 {
77+
/// First token UTXO
78+
#[arg(long = "token-utxo-1")]
79+
token_utxo_1: OutPoint,
80+
/// Second token UTXO
81+
#[arg(long = "token-utxo-2")]
82+
token_utxo_2: OutPoint,
83+
/// Fee UTXO
84+
#[arg(long = "fee-utxo")]
85+
fee_utxo: OutPoint,
86+
/// Miner fee in satoshis (LBTC) for the final settlement transaction
87+
#[arg(long = "fee-amount", default_value_t = 1500)]
88+
fee_amount: u64,
89+
/// `EventId` of the Maker\'s original order event on Nostr
90+
#[arg(short = 'i', long)]
91+
maker_order_event_id: EventId,
92+
#[command(flatten)]
93+
common_options: CommonOrderOptions,
94+
},
95+
#[command(about = "Merge 3 token UTXOs into 1")]
96+
MergeTokens3 {
97+
/// First token UTXO
98+
#[arg(long = "token-utxo-1")]
99+
token_utxo_1: OutPoint,
100+
/// Second token UTXO
101+
#[arg(long = "token-utxo-2")]
102+
token_utxo_2: OutPoint,
103+
/// Third token UTXO
104+
#[arg(long = "token-utxo-3")]
105+
token_utxo_3: OutPoint,
106+
/// Fee UTXO
107+
#[arg(long = "fee-utxo")]
108+
fee_utxo: OutPoint,
109+
/// Miner fee in satoshis (LBTC) for the final settlement transaction
110+
#[arg(long = "fee-amount", default_value_t = 1500)]
111+
fee_amount: u64,
112+
/// `EventId` of the Maker\'s original order event on Nostr
113+
#[arg(short = 'i', long)]
114+
maker_order_event_id: EventId,
115+
#[command(flatten)]
116+
common_options: CommonOrderOptions,
117+
},
118+
#[command(about = "Merge 4 token UTXOs into 1")]
119+
MergeTokens4 {
120+
/// First token UTXO
121+
#[arg(long = "token-utxo-1")]
122+
token_utxo_1: OutPoint,
123+
/// Second token UTXO
124+
#[arg(long = "token-utxo-2")]
125+
token_utxo_2: OutPoint,
126+
/// Third token UTXO
127+
#[arg(long = "token-utxo-3")]
128+
token_utxo_3: OutPoint,
129+
/// Fourth token UTXO
130+
#[arg(long = "token-utxo-4")]
131+
token_utxo_4: OutPoint,
132+
/// Fee UTXO
133+
#[arg(long = "fee-utxo")]
134+
fee_utxo: OutPoint,
135+
/// Miner fee in satoshis (LBTC) for the final settlement transaction
136+
#[arg(long = "fee-amount", default_value_t = 1500)]
137+
fee_amount: u64,
138+
/// `EventId` of the Maker\'s original order event on Nostr
139+
#[arg(short = 'i', long)]
140+
maker_order_event_id: EventId,
141+
#[command(flatten)]
142+
common_options: CommonOrderOptions,
143+
},
62144
}

crates/dex-cli/src/cli/maker.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ pub enum MakerCommands {
1010
about = "Mint three DCD token types and create an initial Maker offer for a Taker",
1111
long_about = "Mint three distinct DCD token types and initialize a Maker offer. \
1212
These tokens represent the Maker/Taker claims on collateral and settlement assets \
13-
and are used to manage the contract lifecycle (funding, early termination, settlement)."
13+
and are used to manage the contract lifecycle (funding, early termination, settlement).",
14+
name = "init"
1415
)]
1516
InitOrder {
1617
/// LBTC UTXO used to fund issuance fees and the first DCD token
@@ -65,12 +66,12 @@ pub enum MakerCommands {
6566
/// UTXO containing grantor collateral tokens to be burned for early termination
6667
#[arg(long = "grant-coll-utxo")]
6768
grantor_collateral_token_utxo: OutPoint,
68-
/// UTXO used to pay miner fees for the early-termination collateral transaction
69-
#[arg(long = "fee-utxo")]
70-
fee_utxo: OutPoint,
7169
/// UTXO containing the collateral asset (e.g. LBTC) to be withdrawn by the Maker
7270
#[arg(long = "coll-utxo")]
7371
collateral_token_utxo: OutPoint,
72+
/// UTXO used to pay miner fees for the early-termination collateral transaction
73+
#[arg(long = "fee-utxo")]
74+
fee_utxo: OutPoint,
7475
/// Miner fee in satoshis (LBTC) for the early-termination collateral transaction
7576
#[arg(long = "fee-amount", default_value_t = 1500)]
7677
fee_amount: u64,
@@ -87,15 +88,15 @@ pub enum MakerCommands {
8788
about = "Withdraw Maker settlement asset early by burning grantor settlement tokens (DCD early termination leg)"
8889
)]
8990
TerminationSettlement {
90-
/// UTXO used to pay miner fees for the early-termination settlement transaction
91-
#[arg(long = "fee-utxo")]
92-
fee_utxo: OutPoint,
9391
/// UTXO providing the settlement asset (e.g. LBTC) to be withdrawn by the Maker
9492
#[arg(long = "settl-asset-utxo")]
9593
settlement_asset_utxo: OutPoint,
9694
/// UTXO containing grantor settlement tokens to be burned for early termination
9795
#[arg(long = "grant-settl-utxo")]
9896
grantor_settlement_token_utxo: OutPoint,
97+
/// UTXO used to pay miner fees for the early-termination settlement transaction
98+
#[arg(long = "fee-utxo")]
99+
fee_utxo: OutPoint,
99100
/// Miner fee in satoshis (LBTC) for the early-termination settlement transaction
100101
#[arg(long = "fee-amount", default_value_t = 1500)]
101102
fee_amount: u64,
@@ -118,24 +119,24 @@ pub enum MakerCommands {
118119
/// UTXO containing grantor settlement tokens used in final settlement
119120
#[arg(long = "grant-settl-utxo")]
120121
grantor_settlement_token_utxo: OutPoint,
121-
/// UTXO used to pay miner fees for the final Maker settlement transaction
122-
#[arg(long = "fee-utxo")]
123-
fee_utxo: OutPoint,
124122
/// UTXO providing the asset (collateral or settlement) paid out to the Maker at maturity
125123
#[arg(long = "asset-utxo")]
126124
asset_utxo: OutPoint,
125+
/// UTXO used to pay miner fees for the final Maker settlement transaction
126+
#[arg(long = "fee-utxo")]
127+
fee_utxo: OutPoint,
127128
/// Miner fee in satoshis (LBTC) for the final settlement transaction
128129
#[arg(long = "fee-amount", default_value_t = 1500)]
129130
fee_amount: u64,
131+
/// Amount of grantor (settlement and collateral) tokens (in satoshis) to burn during settlement step
132+
#[arg(long = "grantor-amount-burn")]
133+
grantor_amount_to_burn: u64,
130134
/// Oracle price at current block height used for settlement decision
131-
#[arg(long = "grantor-settl-burn")]
135+
#[arg(long = "price-now")]
132136
price_at_current_block_height: u64,
133137
/// Schnorr signature produced by the oracle over the published price
134138
#[arg(long = "oracle-sign")]
135139
oracle_signature: String,
136-
/// Amount of grantor tokens (in satoshis) to burn during settlement
137-
#[arg(long = "grantor-amount-burn")]
138-
grantor_amount_to_burn: u64,
139140
/// `EventId` of the Maker\'s original order event on Nostr
140141
#[arg(short = 'i', long)]
141142
maker_order_event_id: EventId,

0 commit comments

Comments
 (0)