Skip to content

Commit

Permalink
feat: use estimateTotalOrderFees for fees calculation (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshualyguessennd authored Sep 21, 2023
1 parent 2500911 commit 923af89
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/forwarder/Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {IOrderProcessor} from "../../src/orders/IOrderProcessor.sol";
import {PriceAttestationConsumer} from "./PriceAttestationConsumer.sol";
import {Nonces} from "../common/Nonces.sol";
import {SelfPermit} from "../common/SelfPermit.sol";
import {FeeLib} from "../common/FeeLib.sol";
import {IForwarder} from "./IForwarder.sol";

/// @notice Contract for paying gas fees for users and forwarding meta transactions to OrderProcessor contracts.
Expand Down Expand Up @@ -252,9 +251,8 @@ contract Forwarder is IForwarder, Ownable, PriceAttestationConsumer, Nonces, Mul
IERC20(order.assetToken).safeTransferFrom(user, address(this), order.assetTokenQuantity);
IERC20(order.assetToken).safeIncreaseAllowance(target, order.assetTokenQuantity);
} else {
(uint256 flatFee, uint24 percentageRateFee) =
IOrderProcessor(target).getFeeRatesForOrder(order.paymentToken);
uint256 fees = FeeLib.estimateTotalFees(flatFee, percentageRateFee, order.paymentTokenQuantity);
uint256 fees =
IOrderProcessor(target).estimateTotalFeesForOrder(order.paymentToken, order.paymentTokenQuantity);
// slither-disable-next-line arbitrary-send-erc20
IERC20(order.paymentToken).safeTransferFrom(user, address(this), order.paymentTokenQuantity + fees);
IERC20(order.paymentToken).safeIncreaseAllowance(target, order.paymentTokenQuantity + fees);
Expand Down

0 comments on commit 923af89

Please sign in to comment.