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

refactor: revert when owner wrongly send ether while swap config is set for owner to be the receiver #227

Closed
2 tasks
0xneves opened this issue May 19, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@0xneves
Copy link
Contributor

0xneves commented May 19, 2024

Refactor Request

Describe the Refactor Request

We should do a sanity check in case msg.value is bigger than 0 and recipient is different than 0. In this case, the user could wrongly send ether to the contract while configuring the ether receiver to be himself (0 = swap.allowed, 1<>255 = swap.owner).

    if (value > 0 && recipient == 0) {
      if (value * 1e12 != msg.value) revert InvalidValue();
    }

Big thanks to @blackbeard002 for pointing out this possibility.

Describe Preferred Solution

Assuming no ethers are being transferred, the value variable inside the config should always match 0. So there should also be a revert to trigger in this case.

  • We should think of a way to revert in case msg.value differs from value but won't revert when they are both equals 0.
  • msg.value should never be bigger than 0 when the recipient is different than 0. (meaning the swap.allowed will send the ether)
@0xneves 0xneves added the enhancement New feature or request label May 19, 2024
@0xneves 0xneves changed the title refactor: refactor: revert when owner wrongly send ether while swap config is set for owner to be the receiver May 19, 2024
@0xneves 0xneves added this to Swaplace May 19, 2024
@github-project-automation github-project-automation bot moved this to 💡 Ideas in Swaplace May 19, 2024
@0xneves 0xneves moved this from 💡 Ideas to 🛠️ In Progress in Swaplace May 19, 2024
@blackbeard002
Copy link
Contributor

Hey @0xneves can I take this up?

@0xneves
Copy link
Contributor Author

0xneves commented May 20, 2024

Hey @0xneves can I take this up?

Yes you may!

blackbeard002 added a commit to blackbeard002/swaplace-contracts that referenced this issue Jun 6, 2024
@blackbeard002
Copy link
Contributor

Hey @0xneves made a PR that closes this #230

@0xneves 0xneves moved this from 🛠️ In Progress to ✅ Done in Swaplace Jun 6, 2024
@0xneves 0xneves closed this as completed in e84906a Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants