Skip to content
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

Allow EIP2612, gas-less approvals in the staking flow #50

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

Doy-lee
Copy link
Collaborator

@Doy-lee Doy-lee commented Jul 12, 2024

Note C++ tests are failing because they need the updated Ethyl branch of which I have a PR siting that I think is still failing and needs to be tweaked more.

bytes32 r,
bytes32 s
) public onlyOperator {
IERC20Permit(address(SENT)).permit(msg.sender, address(this), amount, deadline, v, r, s);
Copy link
Contributor

@tewinget tewinget Jul 12, 2024

Choose a reason for hiding this comment

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

In theory you should be able to do SENT.permit(...)

Also, I agree with zeppelin's example: I think that "try to use the permit, but continue regardless" is ok. If the meat of "contribute funds" fails, the worst case is the same as if the eth wallet that triggered this already did SENT.approve(...).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No bueno cause they're just interfaces, SENT is instantiated as IERC20 which lets us use transferFrom, approve e.t.c but not permit since that's part of IERC20Permit interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added the try-catch, it took the weekend but I get why they want it, specifically to allow the code to run incase someone front-runs, someone can permanently deny you from interacting with the contract if they copied just the permit input data and constantly front-run someone if they observe the TX in the mempool.

bytes32 r,
bytes32 s
) public {
IERC20Permit(address(SENT)).permit(msg.sender, address(this), amount, deadline, v, r, s);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this can be SENT.permit(...) I would prefer that. If not, I'm curious as to why this (what you've put, which I assume works) works but SENT.permit(...) does not work.

bytes32 r,
bytes32 s
) external whenNotPaused {
IERC20Permit(address(designatedToken)).permit(msg.sender, address(this), _stakingRequirement, deadline, v, r, s);
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my question above, it feels like this should be SENT.permit(...)

@Doy-lee
Copy link
Collaborator Author

Doy-lee commented Jul 15, 2024

re: The interface problem, the solution is to have an interface for SENT but this turns into busy work because you have to go and replicate the entire interface of ERC20 and ERC20Permit since there's no inheritance for interface, rather than just cast to the necessary interface 3 times.

@Doy-lee Doy-lee merged commit fedbba1 into oxen-io:integration Jul 15, 2024
1 of 2 checks passed
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.

2 participants