Skip to content
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

Router.sol - What is "fraction" use for? #2

Open
tcheee opened this issue Sep 21, 2023 · 4 comments
Open

Router.sol - What is "fraction" use for? #2

tcheee opened this issue Sep 21, 2023 · 4 comments

Comments

@tcheee
Copy link

tcheee commented Sep 21, 2023

I see that there is an uint256 in the "StoreOperation" struct but it is not used. What will it be used for?

@pgbrandao
Copy link
Member

fraction has not been implemented yet, but the idea is simple: when fetching a store, fraction will allow to use only a certain percentage of the value. (Since the EVM doesn't have a floating point type, it will have a denominator of 1000000 or something similar.)

@tcheee tcheee changed the title Router.sol - Why is "fraction" use for? Router.sol - What is "fraction" use for? Sep 21, 2023
@tcheee
Copy link
Author

tcheee commented Sep 21, 2023

@pgbrandao so it would be a way to move from various decimals type? Like transforming a value from 10 ** 6 to 10 ** 18?

@pgbrandao
Copy link
Member

The fraction field is a way to facilitate operations that use only a portion of a stored value, specified as a percentage. For example, if you have a sequence of exchanges—you want to convert 100% of token A into token B, then split the resulting amount of token B, converting 50% into token C and keeping the remainder in token B—fraction allows you to specify these percentages. The EVM doesn't support floating-point arithmetic, so fraction will use a denominator (such as 1000000) to represent these percentages with high precision.

I have roughly implemented this idea on this commit: b878605

@tcheee
Copy link
Author

tcheee commented Sep 22, 2023

Ok ok I see, thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants