-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[transfer-fee] calculate_inverse_fee logic error when transfer_fee_basis_points is MAX_FEE_BASIS_POINTS #6451
Comments
This comment was marked as spam.
This comment was marked as spam.
This appears to be intentional behavior. When calculating the solana-program-library/token/program-2022/src/extension/transfer_fee/mod.rs Lines 95 to 96 in c609163
Then of course that resolved solana-program-library/token/program-2022/src/extension/transfer_fee/mod.rs Lines 61 to 62 in c609163
Are you sure |
It's still wrong because it cannot be the case that the fee is always 0 for Imagine a token that has the rate set as |
@metamania01 It's not that the fee is
You'd end up dividing by zero for the pre fee: solana-program-library/token/program-2022/src/extension/transfer_fee/mod.rs Lines 98 to 100 in c609163
It seems you're suggesting |
This is a good point, thanks for bringing it up! we were a bit lazy in bailing out if the fee is 100%. You're definitely right, so let's go through the situations:
Keep in mind that the maximum fee is important here, however. If it's set to What do you think about all this? |
I think generally, these functions are not perfect because the solution is not really well-defined in some edge cases.
It seems like the fee could have also been 0 in this case since the I think the question is what to do when there are multiple solutions possible. For So if we add this special case to
then things are consistent in that both |
when transfer_fee_basis_points is MAX_FEE_BASIS_POINTS, the function should return the maximum fee. Otherwise, the following test will fail.
The text was updated successfully, but these errors were encountered: