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

fix: validate token precision multiplier #241

Merged
merged 2 commits into from
Aug 7, 2023

Conversation

bayological
Copy link
Member

@bayological bayological commented Aug 2, 2023

Description

This change adds validation to the function BiPoolManager.setTokenPrecisionMultipliers similar to that in the create pool function. The change verifies the tokens being added to the mapping are known by the reserve and the precisions are within the allowed range.

Other changes

  • Added an event to be emitted when the multipliers are updated

Tested

  • Unit tests were added to verify the change functions as expected.

Related issues

Backwards compatibility

  • N/A

Documentation

  • N/A

@bayological bayological changed the title fix:validate token precision multiplier fix: validate token precision multiplier Aug 2, 2023
Copy link
Contributor

@philbow61 philbow61 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if we want to go down this route 👍
I personally would argue there is no need for the setTokenPrecisionMultipliers function in the beginning.
They are automatically set in the createExchange function by calling decimals() on the token contract. The only context where these multipliers are used is in quotes/swaps and those only work on a valid exchanges. So what is the use case for this function in my opinion it can only cause problems by setting wrong values, but maybe I am missing something 😁

@bayological
Copy link
Member Author

LGTM if we want to go down this route 👍 I personally would argue there is no need for the setTokenPrecisionMultipliers function in the beginning. They are automatically set in the createExchange function by calling decimals() on the token contract. The only context where these multipliers are used is in quotes/swaps and those only work on a valid exchanges. So what is the use case for this function in my opinion it can only cause problems by setting wrong values, but maybe I am missing something grin

I agree with you. I don't feel strongly about keeping this function, it does not add much. However, there is no harm in having it there 🤷‍♂️. The only use case that comes to mind is if the multiplier was set incorrectly when creating an exchange, this would allow that to be corrected without recreating the exchange.

@nvtaveras
Copy link
Collaborator

nvtaveras commented Aug 7, 2023

Agree with @philipraetsch here that this function seems a bit pointless.

The only use case that comes to mind is if the multiplier was set incorrectly when creating an exchange, this would allow that to be corrected without recreating the exchange.

The value added doesn't seem worth it to me. In the spirit of having less code, I would say let's remove it


Update: chatted with the big boss offline and he said: "kill it with fire" 🔥

@nvtaveras nvtaveras requested review from nvtaveras and removed request for nvtaveras August 7, 2023 09:00
@nvtaveras nvtaveras self-assigned this Aug 7, 2023
@nvtaveras nvtaveras force-pushed the fix/validate-token-precision-multiplier branch from 66f8ccc to 22febd7 Compare August 7, 2023 10:01
Copy link
Contributor

@philbow61 philbow61 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@ninabarbakadze ninabarbakadze merged commit aa5520d into develop Aug 7, 2023
16 checks passed
@nvtaveras nvtaveras deleted the fix/validate-token-precision-multiplier branch August 7, 2023 10:51
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

Successfully merging this pull request may close these issues.

[M-1] setTokenPrecisionMultipliers allows arbitrary decimal multipliers
4 participants