Skip to content

Commit f72ae2f

Browse files
authored
fix: prevent multiple calls to request refund [sup-9336] (#654)
1 parent aa794c7 commit f72ae2f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/interfaces/ISuperformRouterPlusAsync.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ interface ISuperformRouterPlusAsync is IBaseSuperformRouterPlus {
4444
uint256 newOutputAmount, uint256 expectedOutputAmount, uint256 userSlippage
4545
);
4646

47+
/// @notice thrown if the refund is already requested
48+
error REFUND_ALREADY_REQUESTED();
49+
4750
/// @notice thrown to avoid processing the same rebalance payload twice
4851
error REBALANCE_ALREADY_PROCESSED();
4952

src/router-plus/SuperformRouterPlusAsync.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ contract SuperformRouterPlusAsync is ISuperformRouterPlusAsync, BaseSuperformRou
430430
function requestRefund(uint256 routerPlusPayloadId_, uint256 requestedAmount) external {
431431
Refund memory r = refunds[routerPlusPayloadId_];
432432

433+
if (r.amount != 0) revert REFUND_ALREADY_REQUESTED();
434+
433435
if (msg.sender != r.receiver) revert INVALID_REQUESTER();
434436
if (r.interimToken == address(0)) revert INVALID_REFUND_DATA();
435437

test/unit/router-plus/SuperformRouterPlus.t.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,10 @@ contract SuperformRouterPlusTest is ProtocolActions {
24942494
(, address refundToken,) = SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).refunds(1);
24952495
assertEq(refundToken, address(args.interimAsset));
24962496

2497+
// @dev testing refund already requested
2498+
vm.expectRevert(ISuperformRouterPlusAsync.REFUND_ALREADY_REQUESTED.selector);
2499+
SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).requestRefund(1, 100);
2500+
24972501
// Step 6: Approve refund
24982502

24992503
/// @dev testing invalid approver (not core state registry)

0 commit comments

Comments
 (0)