Feat/holographic consensus - #339
Conversation
fetches the user staking token balance. If it has none, it won't show the option to open the stake modal. If it does, then the user can use the slider to choose a staking amount
…d fixed bug then token had 0 decimals
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
IMO using "predictions" as a name for the action is wrong, it is a stake or a bet where you PAY for a specific outcome. There is no money in predictions, I can predict that tomorrow will rain for free, but on stakes and bets there is money involved, like here. |
rulfo71
left a comment
There was a problem hiding this comment.
Looks good to me, great job!!
Some comments regarding my UX impression:
- When i'm approving amount to stake i receive this alert from metamask:
here i can put a different amount from the one i put before on the slider. Afterwards the app uses the one from metamask which sounds fair, but i don't know if maybe we can send the amount to the approval transaction so that the user doesn't have to insert it twice.
- On my first impression it was weird to have to click twice the thumbs up (or thumbs down). Once on the proposal page and another on the modal. Maybe the first time could be just a stake button and afterwards which staking option you want...
- Once i already staked that the previous staked selection is 'clicked' maybe we can disable the other option?
Anyway, just opinions here, you can try them and see how they look or maybe a designer can have a better opinion


Description
https://www.loom.com/share/e8ca35fc435e4dea87cbd3ca8a67f9ea
Holographic consensus
Added a sidebar component, modal, and logic to stake tokens, that will be shown on an active proposal on Gov 1.5 DAOs. The option to stake tokens will only show if the user has a balance on the staking token.
The component shows a speedometer to reflect the token amount staked on either option.
Clicking on the stake amounts or the expand button on the card header will toggle the stake details. Each new stake is shown in a new line, so if a user stakes multiple times, it will show multiple stakes (not just one staked with the total stakes of the user).
If the user hasn't already staked on the proposal, it must choose an option and an amount. The amount varies between 0 and the user token balance. To set the amount, either use the slider, or click on the "Max" button to set it to all the available balance.
If the user already staked in the proposal, it won't be able to change its option, just increasing the stakes.
While staking, it will calculate the potential reward, assuming that the user-selected option will win (if it loses, it will lose all the staked tokens).
The "Lock" button will show an "Approve" text if the selected staking amount exceeds the current token allowance. If the user needs to approve, an
approvetransaction will be created with the required amount by default.Notes
Pending things:
Subgraph
Hooks
useStakeOnProposalto 1.5 hook store. It is not supported in guilds.useApproveTokensto 1.5 hook storeschemeIdtouseGetSubDAOsto fetch data of only one scheme. If that's null, then it will fetch all schemesuseProposalhook will also return the stakes on the proposalTypes
subDao,totalStaked,stakesdetails,daoBounty, andholographicConsensusStateto the proposal typings.holographicConsensusState: this is a state that reflects only the voting machine state, not the complete state of the proposal, meaning it might or might not be the same as the proposal state as theuseProposalStatehook returns. In my opinion, this is a temporary state and should be replaced once we implement theuseProposalStatehook.IDandstakingTokenAddressto thevotingMachineproperty of the SubDAO interfaceGeneral stuff
<SidebarCard/><Slider/>componentfullWidthandgapproperties to<Flex/>component<Text/>typography component. This is meant to be used to style body text according to what's defined in the themeuseBigNumberToNumberanduseBigNumberToString. The hook version memoizes the values, but the drawback is that we lose flexibility on where to call them. If deemed beneficial, we can replace hook versions with non-hook ones to avoid duplication. I also added tests.dev-scripts/src/development.js)Closes #16 (issue)
Type of change
How Has This Been Tested?
I extracted functions that deal with numbers into
utils, and added unit tests.Setup to test the staking functionality:
packages/dxdao-contracts/deploy/avatarScheme.jsand set this default parameters (they increase the time to interact with the proposal):http://localhost:3000/#/localhost/0x77f7df7de7ab705eb54982a12d8e1ac65bfa05d3hardhat.config.js) since those are the ones with DXD token balance and thus can stakeCurrently, there's no way to redeem or finish the proposal.
Checklist: