Skip to content
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

[r2r] Use orderbook ticker to calculate swap locktimes #1548

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions mm2src/mm2_main/src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,22 @@ impl TakerOrder {

fn rel_orderbook_ticker(&self) -> &str { self.rel_orderbook_ticker.as_deref().unwrap_or(&self.request.rel) }

/// Returns the orderbook ticker of the taker coin
fn taker_orderbook_ticker(&self) -> &str {
match self.request.action {
TakerAction::Buy => self.rel_orderbook_ticker(),
TakerAction::Sell => self.base_orderbook_ticker(),
}
}

/// Returns the orderbook ticker of the maker coin
fn maker_orderbook_ticker(&self) -> &str {
match self.request.action {
TakerAction::Buy => self.base_orderbook_ticker(),
TakerAction::Sell => self.rel_orderbook_ticker(),
}
}

fn orderbook_topic(&self) -> String {
orderbook_topic_from_base_rel(self.base_orderbook_ticker(), self.rel_orderbook_ticker())
}
Expand Down Expand Up @@ -2878,7 +2894,11 @@ fn lp_connect_start_bob(ctx: MmArc, maker_match: MakerMatch, maker_order: MakerO
},
None => AtomicLocktimeVersion::V1,
};
let lock_time = lp_atomic_locktime(maker_coin.ticker(), taker_coin.ticker(), atomic_locktime_v);
let lock_time = lp_atomic_locktime(
maker_order.base_orderbook_ticker(),
maker_order.rel_orderbook_ticker(),
atomic_locktime_v,
);
log_tag!(
ctx,
"";
Expand Down Expand Up @@ -2972,7 +2992,11 @@ fn lp_connected_alice(ctx: MmArc, taker_order: TakerOrder, taker_match: TakerMat
},
None => AtomicLocktimeVersion::V1,
};
let locktime = lp_atomic_locktime(maker_coin.ticker(), taker_coin.ticker(), atomic_locktime_v);
let locktime = lp_atomic_locktime(
taker_order.maker_orderbook_ticker(),
taker_order.taker_orderbook_ticker(),
atomic_locktime_v,
);
log_tag!(
ctx,
"";
Expand Down