Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Claim investment flow 3 #2200

Merged
merged 15 commits into from
Jan 19, 2022
Merged

Claim investment flow 3 #2200

merged 15 commits into from
Jan 19, 2022

Conversation

nenadV91
Copy link
Contributor

Summary

  • added claim input field functionality

@nenadV91 nenadV91 changed the base branch from develop to claim January 18, 2022 19:44

// divide maxValue with parsed value to get invest amount
return maxValue.multiply(parsedValue).asFraction
enum ErrorMsgs {
Copy link
Contributor

Choose a reason for hiding this comment

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

can move this into types folder

Copy link
Contributor

Choose a reason for hiding this comment

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

mm, not sure. I would say that if this is only local to this component, is better to have it closer to the place you use.

It would be different if we reuse these in different components

Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Build didn't trigger so I could not test it in the PR.
I'll try it locally and report back

@alfetopito
Copy link
Contributor

Looking at claiming on behalf of another account is working as expected

Claiming for yourself though, not so much

Getting divided by 0 error
Screen Shot 2022-01-18 at 14 34 07

When I type stuff into the input.
This account has no funds.
Screen Shot 2022-01-18 at 14 35 35

Also the percentage bar stays at 100%, probably due to the div by 0 error

@W3stside
Copy link
Contributor

@nenadV91 I pushed directly to this branch recommended changes. sorry would normally PR but time is short.

@alfetopito
Copy link
Contributor

alfetopito commented Jan 18, 2022

Working nice after the last changes.

Still, there's this funny bug:

With no funds, press max amount whatever

Screen.Recording.2022-01-18.at.14.45.08.mov

It disables the input and sets bar to 100%

Probably missing:

  1. Run validation on mount (to disable the field when no balance and set error message)
  2. Set 100% to investment amount, not how much the user can invest like the max button (min(balance, investAmount))

@W3stside W3stside force-pushed the claim-investment-flow-3 branch from a9be98e to 6453e28 Compare January 18, 2022 22:54
@W3stside
Copy link
Contributor

Working nice after the last changes.

Still, there's this funny bug:

With no funds, press max amount whatever

Screen.Recording.2022-01-18.at.14.45.08.mov
It disables the input and sets bar to 100%

Probably missing:

  1. Run validation on mount (to disable the field when no balance and set error message)
  2. Set 100% to investment amount, not how much the user can invest like the max button (min(balance, investAmount))

fixed in latest commit 3f94fb6

@github-actions
Copy link
Contributor

  • 🔭 GP Swap: Gnosis Protocol v2 Swap UI

Leandro and others added 2 commits January 18, 2022 17:19
* Added TODO about duplicated const

* Fixing percentage calculation for max values when balance < maxCost

* Refactored _calculatePercentage to return already the formatted %

Co-authored-by: Leandro <[email protected]>
Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Ready to go!

@W3stside W3stside marked this pull request as ready for review January 19, 2022 09:24
@elena-zh
Copy link

elena-zh commented Jan 19, 2022

Working nice after the last changes.

Still, there's this funny bug:

With no funds, press max amount whatever

Screen.Recording.2022-01-18.at.14.45.08.mov
It disables the input and sets bar to 100%

Probably missing:

  1. Run validation on mount (to disable the field when no balance and set error message)
  2. Set 100% to investment amount, not how much the user can invest like the max button (min(balance, investAmount))

Reported in #2201 , so I linked this issue to the PR

@nenadV91
Copy link
Contributor Author

@elena-zh This should be fixed now since the Invest max button will not show if the balance is 0
Screenshot from 2022-01-19 11-55-12

@elena-zh
Copy link

Just to clarify: won't we use percentage buttons on the 'Available investment used' bar?

@elena-zh
Copy link

elena-zh commented Jan 19, 2022

Seems that there is a bit illogical validation message:
image

Moreover, it is not removed when I press on the Max button
image

@nenadV91
Copy link
Contributor Author

Just to clarify: won't we use percentage buttons on the 'Available investment used' bar?, at this point no.

@elena-zh
Copy link

I can't invest ETH
image

or USDC
image

@anxolin
Copy link
Contributor

anxolin commented Jan 19, 2022

I can't invest ETH

@elena-zh This was introduced in another PR. is fixed now that @nenadV91 merged claim branch

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Good one.

For now, just code review. i will try to claim and use it

@@ -10,6 +10,7 @@ export const INITIAL_ALLOWED_SLIPPAGE_PERCENT = new Percent('5', '1000') // 0.5%
export const RADIX_DECIMAL = 10
export const RADIX_HEX = 16

// TODO: remove, this is duplicated with `import { ONE_HUNDRED_PERCENT } from 'constants/misc'`
export const ONE_HUNDRED_PERCENT = new Percent(1, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

good point, would be nice a follow up PR after


// divide maxValue with parsed value to get invest amount
return maxValue.multiply(parsedValue).asFraction
enum ErrorMsgs {
Copy link
Contributor

Choose a reason for hiding this comment

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

mm, not sure. I would say that if this is only local to this component, is better to have it closer to the place you use.

It would be different if we reuse these in different components

@elena-zh
Copy link

elena-zh commented Jan 19, 2022

Still I can't claim: See 'GNO' option:
image

USDC option is also not claimable.
ETH option is claimable.

@anxolin
Copy link
Contributor

anxolin commented Jan 19, 2022

nitpic:

for another PR. If we select a bigger amount than available, shouldn't we leave the investment bar to 100%? it creates a weird effect if you increase the amount

image

Other than that, works great.

We will need to now make use of this values, cause we still invest 100% even if you reduce the amount.

@alfetopito
Copy link
Contributor

The errors claiming investments in this PR are nothing introduced here, simply missing more thing to be implemented.

The amount selected in the inputs is not yet passed down to the contract.

The account I’m testing with has enough to cover 100% investment in GNO and ETH, but has only partial ~40% USDC.

When the contract call is made, it says I’ll invest 100% USDC but I don’t have that much.
Thus, the error.

No error with this PR, good to merge.
Will be fixed when the amounts are passed down to the claim callback

@nenadV91 nenadV91 merged commit e96c340 into claim Jan 19, 2022
@alfetopito alfetopito deleted the claim-investment-flow-3 branch January 19, 2022 18:45
anxolin pushed a commit to anxolin/cowswap that referenced this pull request Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants