SharedStake / SharedStake-ui

SharedStake User Interface using vue.js
https://www.sharedstake.org/
GNU General Public License v3.0
15 stars 15 forks source link

[Withdrawals] UI component / button for withdrawals on Goerli #140

Closed chimera-defi closed 1 year ago

chimera-defi commented 1 year ago

[Withdrawals] UI component / button for withdrawals contract: https://goerli.etherscan.io/address/0x4db116ad5cca33ba5d2956dba80d56f27b6b2455

  1. Integrate the ABI here https://github.com/chimera-defi/SharedDeposit/blob/main/data/abi/Withdrawals.json
  2. Connect UI to goerli. As we are not active on mainnet breaking the mainnet link is alright
  3. Add a new page or section with button and number input. similar to stake page
  1. initial state is approve. Check if connectedWallet.balance of vETH2 > veth2.approval(user, withdrawalContract) otherwise show an approve button which triggers max approval and calls veth2.approve(withdrawalContract, maxUint)
  2. If the user has enough tokens approved show a deposit button. Let the user input how many tokens they want to withdraw. With a max button in the number input to let them withdraw all. (See uniswap UI for ex).
  3. deposit button triggers deposit(value) call on withdrawal contract
  4. Show a redeem button. Check if the user wallet connected is in withdrawals.userEntries with balance returned > 0; . And check withdrawalContract ETH balance > userEntries.amount.
    Therefore if the user has any tokens they can redeem show a redeem button.
  5. if the redeem checks fail due to contract not having enough ETH, grey out the redeem button with Please wait. Contract ETH too low
chimera-defi commented 1 year ago

Docs : https://docs.sharedstake.finance/withdrawals/withdrawals/the-merge-and-eth-distribution

WJakub commented 1 year ago

Thanks for documenting the issue @chimera-defi -> making a start on this today.

WJakub commented 1 year ago

Update I'm around half way through this issue, should have it done in the next couple of days.

To do

WJakub commented 1 year ago

Hey @chimera-defi - I didn't see anything in the ABI / withdrawals contract code that allows the frontend to check the amount of vEth2 user has deposited to redeem. Do you need to expose the userEntries first, or am I missing some inherited method/helper to get that?

Need this to check the userEntries[currentUserWalletAddr] balance before showing the Claim button.

chimera-defi commented 1 year ago

Hey @WJakub Yea i realized this after deploying to goerli. Thanks for taking a look!
The new contract has a userEntries field thats public so you can just assume itll be there. ABI here https://github.com/chimera-defi/SharedDeposit/blob/main/data/abi/Withdrawals.json

WJakub commented 1 year ago

Sweet - thanks sir @chimera-defi that makes sense. Other that than progress going well - aiming for v1 this weekend.

chimera-defi commented 1 year ago

Awesome!
Lmk if you think the contract needs anything else and I'll add it. Throw up a PR when you can. Ill deploy a new contract and add it to the PR and test it out on goerli.

WJakub commented 1 year ago

@chimera-defi Still WIP, gonna try and get through more of it tmrw, but wanted to share my progress if you wanna pull the draft PR locally and test it out: https://github.com/SharedStake/SharedStake-ui/pull/143

chimera-defi commented 1 year ago

Hey @WJakub thanks for getting started! I deployed new contracts on goerli here


WithdrawalsvETH2 deployed to 0x0f779f0c7d0c8b9cD6e23e62D9aE51ED39aa256a at https://goerli.etherscan.io/address/0x0f779f0c7d0c8b9cD6e23e62D9aE51ED39aa256a 
Rollover deployed to 0x17b9Ee3963a58c82d64Aa9fdaCce261257834623 at https://goerli.etherscan.io/address/0x17b9Ee3963a58c82d64Aa9fdaCce261257834623 

Rollovers is just withdrawals but the user gets back the new LSD token sgETH
abi's here https://github.com/SharedStake/SharedDeposit/tree/main/data/abi

WJakub commented 1 year ago

Thanks @chimera-defi - will have bit more time on Saturday to sync with the new contracts.

BTW What's the plan in your head? Get the new page up once I finish up the last few bits and get it out for others to test, then roll out to mainnet once done? Perhaps to keep Discord at bay, it'd be good to offer a few step plan - no need to commit to a timeline, but just the final steps we're planning out to get withdrawals on mainnet would IMO help the folks that are managing all the comms at the mo.

WJakub commented 1 year ago

Also could you expand on rollovers please? Do we want to think through UI for that, or are you just sharing for reference?

chimera-defi commented 1 year ago

Yep. Plan: -get it out for others to test,

Since rollovers is just the same contract as withdrawals it should be possible to just copy paste the code for withdrawals.

Users deposit veth2. instead of getting eth back on calling redeem they get sgETH back, the new liquid staking derivative

chimera-defi commented 1 year ago

Also left a comment on #143
Per announcements, a series of screenshots or a gif/vid would be nice for the announcements

WJakub commented 1 year ago

Ahhh okay yeah that makes sense RE rollover, thanks.

Yup I will sort some visuals when I work on this tomorrow (I'm only able to code on this weekends around my job), will share in the PR thread.

chimera-defi commented 1 year ago

@WJakub what do you think is left to do? imo:

Anything I missed?
The withdrawals code seems functional to me.
And anything youre already working on so i dont start on it too?

chimera-defi commented 1 year ago

above done on v2-dev branch at #146