cfmms-rs
cfmms-rs copied to clipboard
`BigFloat` panics
Remove num-bigfloat
crate from all price calculations because of unexpected panic in division.
Panic Example:
use num_bigfloat::BigFloat;
fn main() {
let x = BigFloat::from(1);
let y = BigFloat::from(2);
let z = x / y;
println!("{z:?}");
}
Addresses #7
This affects the calculate_price
functions in uniswap_v2.rs
& uniswap_v3.rs
Just dropping a note here from our conversation.
Lets strip out the num-bigfloat
and calculate the price without floats. Then we can have a function for each pool that returns the price as an f64
and another function that returns a fixed point number.
Right now, we are going to use div_uu
to compute a 64_x_64 value when calculating price. We will have function to convert this to f64
as well.
We are also going to look into the pros and cons of using rug
instead.