Skip to content

Commit

Permalink
Remove requirement on SwapperCalleePsm amt
Browse files Browse the repository at this point in the history
  • Loading branch information
telome committed Nov 20, 2023
1 parent a310b23 commit 5be7ba4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/funnels/callees/SwapperCalleePsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ contract SwapperCalleePsm {
emit Deny(usr);
}

// Note: To avoid accumulating dust in this contract, `amt` should be a multiple of `to18ConversionFactor` when `src != gem`.
// This constraint is intentionally not enforced in this contract.
function swapCallback(address src, address /* dst */, uint256 amt, uint256 /* minOut */, address to, bytes calldata /* data */) external auth {
if (src == gem) {
PsmLike(psm).sellGemNoFee(to, amt);
} else {
require(amt % to18ConversionFactor == 0, "SwapperCalleePsm/invalid-amt");
PsmLike(psm).buyGemNoFee(to, amt / to18ConversionFactor);
}
if (src == gem) PsmLike(psm).sellGemNoFee(to, amt);
else PsmLike(psm).buyGemNoFee (to, amt / to18ConversionFactor);
}
}
7 changes: 0 additions & 7 deletions test/funnels/callees/SwapperCalleePsm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,4 @@ contract SwapperCalleePsmTest is DssTest {
checkPsmSwap(callee, USDC, DAI);
checkPsmSwap(calleeUSDT, DAI, USDT);
}

function testInvalidSwapAmt() public {
uint256 amt = 10_000 * 10**18 + 10**12 - 1;
GemLike(DAI).transfer(address(callee), amt);
vm.expectRevert("SwapperCalleePsm/invalid-amt");
callee.swapCallback(DAI, USDC, amt, 0, address(this), "");
}
}

0 comments on commit 5be7ba4

Please sign in to comment.