porter-finance / v1-core

⛰️ Smart contracts powering the Porter protocol.
https://porter.finance
GNU Affero General Public License v3.0
4 stars 3 forks source link

Fix incorrect transfer amount emitted for fee-on-transfer tokens #274

Closed Namaskar-1F64F closed 2 years ago

Namaskar-1F64F commented 2 years ago

https://github.com/spearbit-audits/porter/pull/1/files/9cb5b8ed8d6ba0d95cc4ed8528d23aebbb740890#r863090067

+      uint balanceBefore = IERC20Metadata(paymentToken).balanceOf(address(this));

    IERC20Metadata(paymentToken).safeTransferFrom(
            msg.sender,
            address(this),
            amount
        );

+      uint balanceAfter = IERC20Metadata(paymentToken).balanceOf(address(this));
+      uint amountDiff = balanceAfter - balanceBefore;
+      emit Payment(msg.sender, amountDiff);
Namaskar-1F64F commented 2 years ago

related to https://github.com/spearbit-audits/porter/issues/9