Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

BigFloat panics #59

Open
0xOsiris opened this issue Feb 3, 2023 · 2 comments
Open

BigFloat panics #59

0xOsiris opened this issue Feb 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@0xOsiris
Copy link
Collaborator

0xOsiris commented Feb 3, 2023

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

@0xOsiris 0xOsiris added the bug Something isn't working label Feb 3, 2023
@0xKitsune
Copy link
Owner

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.

@0xKitsune
Copy link
Owner

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.

0xKitsune added a commit that referenced this issue Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants