Skip to content

Commit

Permalink
fix: add sanity check for intertimAsset == 0 in approveRefund() […
Browse files Browse the repository at this point in the history
…sup 9337] (#656)
  • Loading branch information
TamaraRingas authored Nov 22, 2024
1 parent 4d26c8d commit 3b6aa9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/router-plus/SuperformRouterPlusAsync.sol
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ contract SuperformRouterPlusAsync is ISuperformRouterPlusAsync, BaseSuperformRou

Refund memory r = refunds[routerPlusPayloadId_];

if (r.interimToken == address(0)) revert INVALID_REFUND_DATA();

approvedRefund[routerPlusPayloadId_] = true;

/// @dev deleting to prevent re-entrancy
Expand Down
6 changes: 6 additions & 0 deletions test/unit/router-plus/SuperformRouterPlus.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,12 @@ contract SuperformRouterPlusTest is ProtocolActions {
SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).approveRefund(1);
vm.stopPrank();

/// @dev testing invalid refund data
vm.startPrank(deployer);
vm.expectRevert(ISuperformRouterPlusAsync.INVALID_REFUND_DATA.selector);
SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).approveRefund(3);
vm.stopPrank();

/// @dev testing valid refund approval
uint256 balanceBefore = MockERC20(refundToken).balanceOf(deployer);
uint256 routerBalanceBefore = MockERC20(refundToken).balanceOf(address(ROUTER_PLUS_ASYNC_SOURCE));
Expand Down

0 comments on commit 3b6aa9c

Please sign in to comment.