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

Locked gno claim 2 #405

Merged
merged 35 commits into from
Apr 29, 2022
Merged

Locked gno claim 2 #405

merged 35 commits into from
Apr 29, 2022

Conversation

nenadV91
Copy link
Contributor

@nenadV91 nenadV91 commented Apr 13, 2022

Summary

@github-actions
Copy link
Contributor

CLA Assistant Lite:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
@jfschwarz
@lint-action
You can retrigger the CLA Action by commenting recheckcla in this Pull Request

@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

@nenadV91 nenadV91 marked this pull request as ready for review April 14, 2022 15:38
@nenadV91 nenadV91 requested a review from a team April 14, 2022 15:39
@elena-zh
Copy link

elena-zh commented Apr 15, 2022

Hey @nenadV91 , great job!
Some issues that I have encountered:

  1. Vested amounts do not match in the tooltip and in the 'Vested' field
    diff vested

  2. Claim button shows a successful state, and disabled when the transaction is failed
    Screenshot_2

  3. I see another COW token address to add to MM. Shouldn't it be the same as for the 'regular' COW token?
    1428

  4. Maybe related to the p/1, but strange amount of vested tokens was claimed: I saw 16 tokens available, but received 1438 to my wallet

  5. Maybe a nitpick, but 'Claim' button is disabled and is not changed to the 'Claiming...' once pressed, but transaction is not yet confirmed in the connected wallet
    nitpick
    However, nevermind: we do the same for the 'Convert 'button

  6. I'm still not sure about what contract to show for the 'View Contract' button. All the rest cards show (v)COW token address, so here, I assume, we also should show COW token address? Or it is better to show a token distribution contract address?
    token distr
    @alfetopito , @fairlighteth , @anxolin , WDYT?

  7. It might not be related to the current task, but an amount of COW from locked GNO is not included into a discount calculation. I think, we should include it. WDYT?
    image
    image
    I have created a separate task Include an amount of COW from locked GNO into discount calculation #409 for this point.

Thank you!

Copy link
Collaborator

@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.

Have not tested the app, just reviewed the code.
Left a couple of nitpicks/suggestions

Comment on lines +18 to +22
const chainNames = {
[SupportedChainId.MAINNET]: 'mainnet',
[SupportedChainId.RINKEBY]: 'rinkeby',
[SupportedChainId.XDAI]: 'gnosisChain',
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we probably have that mapping somewhere else, don't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +53 to +58
const promise =
chunkCache.get(path) ??
(fetch(
`https://raw.githubusercontent.com/gnosis/locked-gno-cow-merkle-distro/${DISTRO_REPO_BRANCH_NAME}/${path}`
).then((res) => res.json()) as Promise<Record<string, Claim>>)
chunkCache.set(path, promise)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: could it exit earlier in case there's a cache hit and avoid overwriting the cached value on every call?

@@ -0,0 +1,159 @@
[
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this was talked about while I was away, but wouldn't be better to store the claim indexes in the same repo as the claim files instead of adding them to the Cowswap's repo like was done for the airdrop?
Or we expect the amount to be significantly smaller that this is acceptable?

I'm personally not very found of having them here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I second this. I think these are the indexes but, anyways, nice to have to the merkle data project, right?

src/custom/pages/Profile/LockedGnoVesting/hooks.ts Outdated Show resolved Hide resolved
src/custom/pages/Profile/LockedGnoVesting/hooks.ts Outdated Show resolved Hide resolved
src/custom/pages/Profile/LockedGnoVesting/hooks.ts Outdated Show resolved Hide resolved
src/custom/pages/Profile/LockedGnoVesting/index.tsx Outdated Show resolved Hide resolved
src/custom/state/claim/hooks/index.ts Outdated Show resolved Hide resolved
src/custom/state/claim/hooks/index.ts Show resolved Hide resolved
Copy link
Contributor

@W3stside W3stside left a comment

Choose a reason for hiding this comment

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

i think the history got mixed from the develop merge, could you fix it please

@elena-zh
Copy link

It is impossible to claim COW from locked GNO in GC (neither here nor in #364 pr)
image
image

However, it should work based on the commenthttps://github.com/gnosis/cowswap/pull/2599#issuecomment-1084459113

@jfschwarz
Copy link
Contributor

jfschwarz commented Apr 25, 2022

It is impossible to claim COW from locked GNO in GC (neither here nor in #364 pr)

Thank you for finding this, @elena-zh! This is due to a copy&paste mistake in the contract addresses. (see suggested change above)

@jfschwarz
Copy link
Contributor

Vested amounts do not match in the tooltip and in the 'Vested' field

This is because the tooltip shows the total vested balance at the current moment, while in the field we show the amount that can be claimed now, which is the difference of the vested balance and the amount that has been already claimed earlier. We should maybe change the field label to "Claimable" to make this difference more clear?

@elena-zh
Copy link

Vested amounts do not match in the tooltip and in the 'Vested' field

This is because the tooltip shows the total vested balance at the current moment, while in the field we show the amount that can be claimed now, which is the difference of the vested balance and the amount that has been already claimed earlier. We should maybe change the field label to "Claimable" to make this difference more clear?

I think, it would be great!
Due to according to the 'Convert vCOW to COW' logic we simply show the same amount in both fields, so users might be confused in their expectations in what they see and what they will receive.
image
So a better explanation will help to avoid these issues.
Btw, it would be nice to provide a better explanation here, I think
image
A least, to change 'entire vested' to entire 'claimable' amount.

Thanks!

@jfschwarz
Copy link
Contributor

@elena-zh

  1. I see another COW token address to add to MM. Shouldn't it be the same as for the 'regular' COW token?

On rinkeby the test deployment of the vesting contract uses a special COW token (0xc50c011B7a2B960D6cb4ac93deFd04A529fDDB3a). We couldn’t use the existing COW token on rinkeby because we needed to fund the vesting contract with a large number of COW so all the existing accounts can be used for testing.

  1. Maybe related to the p/1, but strange amount of vested tokens was claimed: I saw 16 tokens available, but received 1438 to my wallet

Hum, was that on Rinkeby? Looking at the token transfer history of our testing COW token, I can't see any transfer of 1438, but only one with 16, so it looks like it went through as expected.

@elena-zh
Copy link

@elena-zh

  1. I see another COW token address to add to MM. Shouldn't it be the same as for the 'regular' COW token?

On rinkeby the test deployment of the vesting contract uses a special COW token (0xc50c011B7a2B960D6cb4ac93deFd04A529fDDB3a). We couldn’t use the existing COW token on rinkeby because we needed to fund the vesting contract with a large number of COW so all the existing accounts can be used for testing.

  1. Maybe related to the p/1, but strange amount of vested tokens was claimed: I saw 16 tokens available, but received 1438 to my wallet

Hum, was that on Rinkeby? Looking at the token transfer history of our testing COW token, I can't see any transfer of 1438, but only one with 16, so it looks like it went through as expected.

@jfschwarz , thank you for the explanation!
Regarding to the issue with a transferred token's amount, seems that I did not took into account previously transferred tokens there, so I mistakenly thought that they were added to the wallet in 1 Claim transaction.

image

Anyways, I will retest this issue again with another account.

Thanks!

@elena-zh
Copy link

I have retested changes, so now everything looks much-much better.
However, still we have some issues not resolved:

  1. 'Vested' amounts on the vCOW and locked GNO cards are calculated differently
    image
    image
    so it is better to change the 'Vested' field's label to 'Claimable' on the locked GNO 'card

  2. @nenadV91 , since you have changed 'Convert' button behavior and added 'successful' state to it, I think we need to enhance it a bit more and zero out the claimed amount when 'success' button is displayed. Currenty, it shows a previous claimed balance, and even can still show it when the button enables again
    Screenshot_9

  3. I'm still not sure about what contract to show for the 'View Contract' button. All the rest cards show (v)COW token address, so here, I assume, we also should show COW token address? Or it is better to show a token distribution contract address?
    token distr
    @alfetopito , @fairlighteth , @anxolin , @jfschwarz WDYT?

@jfschwarz
Copy link
Contributor

jfschwarz commented Apr 26, 2022

  1. 'Vested' amounts on the vCOW and locked GNO cards are calculated differently
    so it is better to change the 'Vested' field's label to 'Claimable' on the locked GNO 'card

This is fixed already in this extra PR (I don't have rights to commit to this branch directly)

  1. @nenadV91 , since you have changed 'Convert' button behavior and added 'successful' state to it, I think we need to enhance it a bit more and zero out the claimed amount when 'success' button is displayed. Currenty, it shows a previous claimed balance, and even can still show it when the button enables again

This is actually not the previously claimed balance, but the amount that became vested since you last claimed. So it is correct that the claim button is enabled and the user could theoretically claim every 5 minutes (or however frequently they want).

  1. I'm still not sure about what contract to show for the 'View Contract' button. All the rest cards show (v)COW token address, so here, I assume, we also should show COW token address? Or it is better to show a token distribution contract address?

This button also got fixed in the other PR (the current link is broken). I think the purpose of the link is to give the user confidence and transparency into the contract interaction that will be triggered by pressing the Claim button. So it should really be the vesting contract.

@elena-zh
Copy link

elena-zh commented Apr 26, 2022

This is actually not the previously claimed balance, but the amount that became vested since you last claimed. So it is correct that the claim button is enabled and the user could theoretically claim every 5 minutes (or however frequently they want).

@jfschwarz , I have not recorded the video, but in my case I meant that the amount was not immediately updated.
So right after the convert transaction I saw '0.0463' converted token's amount+ success button, but then in a few (up to 10) seconds the amount was updated with a new value like '0.0001' or so.

@nenadV91
Copy link
Contributor Author

I've noticed another issue, when you logout the locked GNO card is not hidden and it stays there with previously connected account data

@nenadV91 nenadV91 mentioned this pull request Apr 26, 2022
7 tasks
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.

It worked great for me the claiming!

Codewise looks good too.

I would think is good to merge as soon as we get Elena's stamp.

One small detail, please don't need to fix, just commenting. The icons and logos are wrong, because that is the logo for vCOW to COW conversion. It could be GNO and COW logos, or COW to COW. Same for the COW logo in the profile, it could have a GNO small image overign the logo to differentiate from the other. Again, not important at all.

image

What is important though, is to coordinate this with the backend, specially after the change from @nenadV91 where now we use the locked COW also for the discount.

When do we want to release this?

@@ -0,0 +1,159 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

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

I second this. I think these are the indexes but, anyways, nice to have to the merkle data project, right?

const COW = COW_TOKENS[SupportedChainId.MAINNET]

export const MERKLE_DROP_CONTRACT_ADDRESSES: Record<number, string> = {
[SupportedChainId.MAINNET]: '0x64646f112FfD6F1B7533359CFaAF7998F23C8c40',
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these already the final ones with the right allocation?

src/custom/pages/Profile/LockedGnoVesting/hooks.ts Outdated Show resolved Hide resolved
@nenadV91 nenadV91 mentioned this pull request Apr 26, 2022
Copy link
Contributor

@jfschwarz jfschwarz left a comment

Choose a reason for hiding this comment

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

Should we maybe leave the fee discount out of scope for now? Especially considering that work has to be done on the back-end for this first, I think this additional aspect should not block us from releasing the claiming feature. (People are already asking for the claim UI.)


if (account) {
if (vCowBalance) tmpBalance = JSBI.add(tmpBalance, vCowBalance.quotient)
if (lockedGnoBalance) tmpBalance = JSBI.add(tmpBalance, lockedGnoBalance.quotient)
Copy link
Contributor

@jfschwarz jfschwarz Apr 27, 2022

Choose a reason for hiding this comment

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

I think this is not quite correct: We're adding the entire allocation without taking into account how much of it has already been claimed by the user. That share of the allocation that has been claimed is already in the user's wallet as COW and as such is already counted towards the fee discount.

We should use the useCowFromLockedGnoBalances hook instead and then only add allocated - claimed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jfschwarz Good point, I've added fix for this in this PR #460 (in case we want to add this to fee discount).

@elena-zh
Copy link

Hey @nenadV91 , great changes!
A tiny issue: only in this PR 'Forum' link is not clickable when all (convert/claim/balance and banner) cards are displayed on the page
image

Could you please take a look at it?

@elena-zh
Copy link

Also, I have created related issue #487 that might be fixed later.

jfschwarz and others added 21 commits April 29, 2022 12:50
* use new rinkeby contracts

* fix merkle drop contract address on GC

* more specific names

* localize vesting start date

* improve copy

* fix contract address link
* Add cow from locked GNO to combined balance

* Add shimmer effect and handle disconnect
* Added some fixes

* Update combined balance calculation

* Added comments for locked GNO timestamps

* Move locked GNO start date to const file

* Moved some other locked GNO dates to const file

* Added some PR updates

* Small update
@nenadV91 nenadV91 force-pushed the locked-gno-claim-2 branch from 30fac7a to 17234fb Compare April 29, 2022 10:50
Copy link

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

LGTM now!

@nenadV91 nenadV91 requested review from W3stside and alfetopito April 29, 2022 12:47
Copy link
Collaborator

@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.

Looks good code-wise, have not tested the app though

@nenadV91 nenadV91 merged commit 39e1867 into develop Apr 29, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2022
@alfetopito alfetopito deleted the locked-gno-claim-2 branch May 2, 2022 09:31
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.

7 participants