-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: best trade swap router rpc #944
base: master
Are you sure you want to change the base?
Conversation
79a71d6
to
84d010b
Compare
path: Vec<TradingPath>, | ||
) -> Self { | ||
let execution_price = | ||
FixedU128::checked_from_rational(output_amount.value, input_amount.value).unwrap_or_default(); |
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.
Won't this limit the precision of the comparisons? Why don't we just compare input/output amounts directly, rather than constructing the ratio?
token0: CurrencyId, | ||
token1: CurrencyId, | ||
reserve0: u128, | ||
reserve1: u128, |
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.
Would be slightly cleaner if this just holds 2 Amount
s
input_amount: T::Balance, | ||
input_currency: T::CurrencyId, |
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.
Take Amount
? In general, when you have a (Balance, Currency)
pair, I think it's best to construct the Amount
as soon as possible
} | ||
} | ||
|
||
fn get_output_amount( |
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 function is not very well tested. I think only rpc_find_best_trade
hits this code code at all
Signed-off-by: Gregory Hill <[email protected]>
84d010b
to
29548ee
Compare
Ported from https://github.com/zenlinkpro/dex-sdk
Closes #927