Skip to content

feat: update onBeforeMint logic to allow direct DEV staking - #210

Open
yashdesu wants to merge 9 commits into
mainfrom
feat-direct-dev-staking
Open

feat: update onBeforeMint logic to allow direct DEV staking#210
yashdesu wants to merge 9 commits into
mainfrom
feat-direct-dev-staking

Conversation

@yashdesu

@yashdesu yashdesu commented Apr 14, 2023

Copy link
Copy Markdown

This changes introduces business logic in SimpleCollections that allows direct staking of DEV. The condition checks whether the DEV staked satisfies the minimum required condition or not.

NOTE: Whenever the user stakes ETH, the ETH is converted into DEV. This DEV is then staked. But the pool price must have changed by now. Even if we consider that there were no external changes to the pool, the swap we just made to stake DEV itself might have moved the pool price by a bit at the least (and more in edge cases). Hence, since we have removed direct comparison of original ETH input by user (via .gatewayOf) and replace it with checking for DEV staked equivalence there might be some transaction failures because of movement of price. Also we can no longer validate Fee here because there is no swapAndStake contract for direct DEV staking and there is no Fee associated with direct DEV staking.

@aggre aggre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this great change! Your implementation is correct, but when img.requiredETHFee is not 0, this contract still needs to refer .gatewayOf and validates the input fee, I think.

@yashdesu
yashdesu requested a review from aggre April 17, 2023 09:22

@aggre aggre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice nice!!

@KukretiShubham KukretiShubham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Otherwise your approach seems good to me

Comment thread contracts/SimpleCollections.sol Outdated
} else {
// This condition validates input `DEV` equivalent `ETH` with required.
// Fetch the `amount of ETH` the `DEV staked` is equal to.
uint256 equivalentETHStaked = swapAndStake.getEstimatedEthForDev(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure if we can use this function. Since this uses
quoteExactInputSingle function which is a lens contract by uniswap meant only for off-chain calling since they are gas inefficient. here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch. But how else can DEV:ETH equivalence be verified on-chain?

@yashdesu
yashdesu requested a review from stuartwk May 15, 2023 08:36
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.

4 participants