-
Notifications
You must be signed in to change notification settings - Fork 1
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
Common pool calculations file #26
Conversation
let val: f64 = 1.0001; | ||
|
||
if token_one_decimals != token_two_decimals { | ||
println!("Exchange when token decimals not the same not yet supported"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return an error (anyhow!()) and then anything that uses the fn can choose to print the error or return it etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
@@ -0,0 +1,17 @@ | |||
use uniswap_v3_sdk::prelude::FeeAmount; | |||
|
|||
pub fn fee_to_float(fee: FeeAmount) -> f32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be a float?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the result can be 0.01, for instance. Though the current usage of the result is as a string, it is likely that the result will be used in calculations of the cost of doing a price change.
Handle error, underflow and denominator
Added a file with common pool calculations:
The tick to exchange rate calculation currently does not handle decimals for the tokens being different.