primitivefinance / DFMM

Smart contracts of the DFMM protocol
https://www.primitive.xyz/blog/dfmm_protocol
18 stars 6 forks source link

fix(DOS): cross pool dos vector removed by refunding eth only if weth… #122

Closed Alexangelj closed 3 months ago

Alexangelj commented 3 months ago

… token

Discussion: https://github.com/primitivefinance/DFMM/pull/89#discussion_r1550020949

For pools with WETH, the _transferFrom will try to use the native ether for the payment if msg.value is >= the amount required.

If msg.value is not zero, but also not enough to make the payment, the else branch will be entered which will pull the full amount of WETH tokens from the sender.

If msg.value is greater than the amount (leaving excess), or the else branch was entered, the remaining ether balance of the contract is sent to the sender. Note this is only if the token is WETH,