blockful-io / swaplace-contracts

Swaplace is an open-source, ownerless and feeless token swap protocol
https://app.swaplace.xyz/
MIT License
33 stars 33 forks source link

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

Closed 0xneves closed 1 month ago

0xneves commented 3 months ago

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.

blackbeard002 commented 3 months ago

Hey @0xneves can I take this up?

0xneves commented 3 months ago

Hey @0xneves can I take this up?

Yes you may!

blackbeard002 commented 2 months ago

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