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

Prevent users to tunnel less than the minimum amount allowed by the token decimals #895

Open
gndelia opened this issue Feb 21, 2025 · 7 comments
Labels
bug Something isn't working Tunnel Related to the Tunnel app

Comments

@gndelia
Copy link
Contributor

gndelia commented Feb 21, 2025

Let's say a token, like USDC, has 6 decimals in the contract definition. That means the smaller amount of USDC possible is 0.000001. Currently, there's no restriction on the minimum amount to tunnel. So users could try to tunnel 0.00000000000001 USDC, which the UI parses as 0.
The contracts do allow trying to tunnel 0, see this tunnel deposit.
However, allowing this kind of transaction is useless, as no tokens are minted on Hemi, and they are only a waste of fees. We should prevent that

We should restrict the amount to tunnel to/from Hemi, preventing it from operating less than the minimum amount. This needs to be validated in the tunnel form as well.

@gndelia gndelia added bug Something isn't working Tunnel Related to the Tunnel app labels Feb 21, 2025
@qgatssdev
Copy link
Contributor

@gndelia How would you like this carried out? If the user tries to pass 0, do we disable the button or prompt a toast. What's the intended solution?
Also what should be the minimum amount that can be tunnel to/from Hemi?

@gndelia
Copy link
Contributor Author

gndelia commented Feb 28, 2025

@qgatssdev The minimum is dictated by the amount of decimals defined in the Token contract.

USDC has defined decimals as 6. Then , the smallest amount possible then is 0.000001. It's impossible to tunnel less than that because smaller values can't be represented. Less than that is zero, which should be prevented. If the amount written in the input by the user is invalid, the submit button should be disabled, similar to how we disable the submit button when the user tries to tunnel more than the balance amount.

TBD by @dvnahuel how we would show to users that the amount is invalid

@qgatssdev
Copy link
Contributor

@qgatssdev The minimum is dictated by the amount of decimals defined in the Token contract.

USDC has defined decimals as 6. Then , the smallest amount possible then is 0.000001. It's impossible to tunnel less than that because smaller values can't be represented. Less than that is zero, which should be prevented. If the amount written in the input by the user is invalid, the submit button should be disabled, similar to how we disable the submit button when the user tries to tunnel more than the balance amount.

TBD by @dvnahuel how we would show to users that the amount is invalid

Okay I get what you mean, please assign this to me. I'll love feedback from @dvnahuel so I know how we want to present the error.

@qgatssdev
Copy link
Contributor

@gndelia Any update on this? I have a branch fixing this but currently don't know how the data is to be presented.

@dvnahuel
Copy link

dvnahuel commented Mar 4, 2025

Hey @qgatssdev ! Still working on how to fix this issue, as it’s more about how we showcase the warning across various use cases in the tunnel rather than just one solution. I should have this figured out in the next couple of days.

@qgatssdev
Copy link
Contributor

@dvnahuel Hey! no problem, Just tag me when it's ready.

@dvnahuel
Copy link

dvnahuel commented Mar 5, 2025

@dvnahuel Hey! no problem, Just tag me when it's ready.

I’ll tag you as soon as it’s ready. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Tunnel Related to the Tunnel app
Projects
None yet
Development

No branches or pull requests

3 participants