Skip to content

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

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

yashdesu
Copy link

@yashdesu yashdesu commented Apr 14, 2023

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.

Copy link
Member

@aggre aggre left a comment

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
Copy link
Member

@aggre aggre left a comment

Choose a reason for hiding this comment

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

Nice nice!!

Copy link
Member

@KukretiShubham KukretiShubham left a comment

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

} 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
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
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