Skip to content

Commit ee8c0a9

Browse files
author
Vadim Nicolai
committed
Small improvement.
1 parent 663ae46 commit ee8c0a9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/model/src/defi/dex.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,14 @@ impl Display for Dex {
9999
write!(f, "Dex(chain={}, name={})", self.chain, self.name)
100100
}
101101
}
102-
103102
impl From<Pool> for CurrencyPair {
104103
fn from(p: Pool) -> Self {
105-
let sym_str = format!("{}/{}", p.token0.symbol, p.token1.symbol);
106-
let symbol = Symbol::from(sym_str.as_str());
107-
104+
let symbol = Symbol::from(format!("{}/{}", p.token0.symbol, p.token1.symbol));
108105
let id = InstrumentId::new(symbol, Venue::from("DEFI"));
109106

110-
let price_precision = 6;
111-
let size_precision = 6;
107+
let size_precision = p.token0.decimals;
108+
let price_precision = p.token0.decimals.saturating_add(p.token1.decimals);
109+
112110
let price_increment = Price::new(10f64.powi(-(price_precision as i32)), price_precision);
113111
let size_increment = Quantity::new(10f64.powi(-(size_precision as i32)), size_precision);
114112

0 commit comments

Comments
 (0)