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

feat: create StackTokenPair #38

Merged
merged 1 commit into from
Aug 7, 2023
Merged

Conversation

berteotti
Copy link
Collaborator

Screenshot 2023-08-02 at 11 41 59

Creates StackTokenPair section. Formatted balance isn't consistent throughout the code base.

@Diogomartf
Copy link
Collaborator

Diogomartf commented Aug 2, 2023

While testing got Application error.

details

How to reproduce:

  • connected wallet
  • select wxdai
  • error screen

Note: Selecting other tokens seems fine.

image

Looking at the console it looks like:

RangeError: maximumSignificantDigits value is out of range.
` at Number.toLocaleString

image

@Diogomartf
Copy link
Collaborator

Would be nice that the size of decimals was the same as balance on bottom right.

like this 8,0994 instead of 8,099426770481235208

image

@Diogomartf
Copy link
Collaborator

I think we should clean the input when changing tokens,

what do you think?

4899bfc53935811d1e727a2438109f09

@@ -70,6 +86,14 @@ export const Stackbox = () => {
setEndDateTime(new Date(endDateByFrequency[frequency]));
}, [frequency]);

const formattedBalance = (balanceData: NonNullable<typeof balance>) =>
Copy link
Collaborator

@Diogomartf Diogomartf Aug 2, 2023

Choose a reason for hiding this comment

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

this function could be extracted to utils/token file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should uniformize all this formates in the app. And add this formatting to a specific file. If you agree will create a task to do this. But we can keep this function inside Stackbox for this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree on standardizing formats throughout the app but I agree with Diogo to abstract this function into a utils file, because, in my experience, these functions tend to grow and change their signature as the app needs to grow. At some point, I'm sure we will abstract this function, sooner or later.

I don't mind handling that abstraction in a different PR as long as we handle it, either here or in another task.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created this issue to tackle this in our app https://linear.app/swaprdev/issue/STK-104/format-token-amounts

@berteotti
Copy link
Collaborator Author

Would be nice that the size of decimals was the same as balance on bottom right.

like this 8,0994 instead of 8,099426770481235208

image

I think it's important to let the user define the granularity of what he is spending. If we hide tokens he can't know if he is using max balance or just a portion of it.

@berteotti
Copy link
Collaborator Author

I think we should clean the input when changing tokens,

what do you think?

4899bfc53935811d1e727a2438109f09

I think we should let it for now. If the user inputs a custom value and it changes token, I think we probably wants to keep that value. Also thought about this and the behaviour on other apps is to keep the value.

ElRodrigote
ElRodrigote previously approved these changes Aug 3, 2023
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 4, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: f5406ef
Status: ✅  Deploy successful!
Preview URL: https://36fdc472.stackly-ui.pages.dev
Branch Preview URL: https://feat-stk-32-create-stacktoke.stackly-ui.pages.dev

View logs

@Diogomartf
Copy link
Collaborator

Would be nice that the size of decimals was the same as balance on bottom right.
like this 8,0994 instead of 8,099426770481235208
image

I think it's important to let the user define the granularity of what he is spending. If we hide tokens he can't know if he is using max balance or just a portion of it.

Just use the same as balance (as we also choose to not show all the decimals of the balance) and use only that portion not the whole decimals. That's just too many numbers.

We let the user go to that kind of granularity if he wants.

@Diogomartf
Copy link
Collaborator

Diogomartf commented Aug 4, 2023

While testing got Application error.

details

How to reproduce:

  • connected wallet
  • select wxdai
  • error screen

Note: Selecting other tokens seems fine.

image Looking at the console it looks like:

RangeError: maximumSignificantDigits value is out of range. ` at Number.toLocaleString

image

still not fixed

@berteotti
Copy link
Collaborator Author

Would be nice that the size of decimals was the same as balance on bottom right.
like this 8,0994 instead of 8,099426770481235208
image

I think it's important to let the user define the granularity of what he is spending. If we hide tokens he can't know if he is using max balance or just a portion of it.

Just use the same as balance (as we also choose to not show all the decimals of the balance) and use only that portion not the whole decimals. That's just too many numbers.

We let the user go to that kind of granularity if he wants.

How can we let the user define the granularity if he doesn't know the entire balance? If the user clicks Max we have to assume he wants to spend the entire token amount, not just an approximation of that value. What do you think?

@Diogomartf
Copy link
Collaborator

Would be nice that the size of decimals was the same as balance on bottom right.
like this 8,0994 instead of 8,099426770481235208
image

I think it's important to let the user define the granularity of what he is spending. If we hide tokens he can't know if he is using max balance or just a portion of it.

Just use the same as balance (as we also choose to not show all the decimals of the balance) and use only that portion not the whole decimals. That's just too many numbers.
We let the user go to that kind of granularity if he wants.

How can we let the user define the granularity if he doesn't know the entire balance? If the user clicks Max we have to assume he wants to spend the entire token amount, not just an approximation of that value. What do you think?

I would prefer to not be shown so many decimals. It's so small that only adds noise.

But I'll let you decide on it now. We can change it in the future if we want (add/remove decimals).

const formattedBalance = (balanceData: NonNullable<typeof balance>) => {
const SIGNIFICANT_DIGITS = 5;

/* parseFloat as some number size limitations so this is a temporary solution */
Copy link
Collaborator

@Diogomartf Diogomartf Aug 7, 2023

Choose a reason for hiding this comment

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

Suggested change
/* parseFloat as some number size limitations so this is a temporary solution */
/* parseFloat has some number size limitations so this is a temporary solution */

what are the limitations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Description is clearer now.

Diogomartf
Diogomartf previously approved these changes Aug 7, 2023
@berteotti berteotti merged commit 72cf6f3 into develop Aug 7, 2023
2 checks passed
@berteotti berteotti deleted the feat/stk-32-create-stacktokenpair branch August 7, 2023 10:47
berteotti added a commit that referenced this pull request Oct 19, 2023
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.

3 participants