-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice nice!!
There was a problem hiding this 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
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
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 noFee
associated with directDEV
staking.