Skip to content

Commit

Permalink
refractor: gateway contract to transfer protocol fee only if it is gr…
Browse files Browse the repository at this point in the history
…eater than zero and emit refund address instead of sender
  • Loading branch information
OnahProsperity authored and chibie committed Sep 27, 2024
1 parent 8e9f59f commit 3c598ee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contracts/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ contract Gateway is IGateway, GatewaySettingManager, PausableUpgradeable {

// emit order created event
emit OrderCreated(
order[orderId].sender,
_refundAddress,
_token,
order[orderId].amount,
_protocolFee,
Expand Down Expand Up @@ -203,8 +203,10 @@ contract Gateway is IGateway, GatewaySettingManager, PausableUpgradeable {
require(!order[_orderId].isRefunded, 'OrderRefunded');
require(order[_orderId].protocolFee >= _fee, 'FeeExceedsProtocolFee');

// transfer refund fee to the treasury
IERC20(order[_orderId].token).transfer(treasuryAddress, _fee);
if (order[_orderId].protocolFee > 0) {
// transfer protocol fee
IERC20(order[_orderId].token).transfer(treasuryAddress, _fee);
}

// reset state values
order[_orderId].isRefunded = true;
Expand Down

0 comments on commit 3c598ee

Please sign in to comment.