Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid function overlaoding #302

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/GenericSwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract GenericSwap is IGenericSwap, TokenCollector, EIP712 {
/// @param taker Claimed taker address
/// @param takerSig Taker signature
/// @return returnAmount Output amount of the swap
function executeSwap(
function executeSwapWithSig(
GenericSwapData calldata swapData,
bytes calldata takerTokenPermit,
address taker,
Expand Down
2 changes: 1 addition & 1 deletion contracts/RFQ.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract RFQ is IRFQ, Ownable, TokenCollector, EIP712 {
_fillRFQ(rfqTx, makerSignature, makerTokenPermit, takerTokenPermit, bytes(""));
}

function fillRFQ(
function fillRFQWithSig(
RFQTx calldata rfqTx,
bytes calldata makerSignature,
bytes calldata makerTokenPermit,
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IGenericSwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface IGenericSwap {

function executeSwap(GenericSwapData calldata swapData, bytes calldata takerTokenPermit) external payable returns (uint256 returnAmount);

function executeSwap(
function executeSwapWithSig(
GenericSwapData calldata swapData,
bytes calldata takerTokenPermit,
address taker,
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IRFQ.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface IRFQ {

function fillRFQ(RFQTx calldata rfqTx, bytes calldata makerSignature, bytes calldata makerTokenPermit, bytes calldata takerTokenPermit) external payable;

function fillRFQ(
function fillRFQWithSig(
RFQTx calldata rfqTx,
bytes calldata makerSignature,
bytes calldata makerTokenPermit,
Expand Down
8 changes: 4 additions & 4 deletions test/forkMainnet/GenericSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ contract GenericSwapTest is Test, Tokens, BalanceUtil, Permit2Helper, SigHelper
);

bytes memory takerSig = signGenericSwap(takerPrivateKey, defaultGSData, address(genericSwap));
genericSwap.executeSwap(defaultGSData, defaultTakerPermit, taker, takerSig);
genericSwap.executeSwapWithSig(defaultGSData, defaultTakerPermit, taker, takerSig);

takerTakerToken.assertChange(-int256(defaultGSData.takerTokenAmount));
// the makerTokenAmount in the defaultGSData is the exact quote from strategy
Expand All @@ -296,14 +296,14 @@ contract GenericSwapTest is Test, Tokens, BalanceUtil, Permit2Helper, SigHelper

vm.expectRevert(IGenericSwap.InvalidSignature.selector);
// submit with user address as expected signer
genericSwap.executeSwap(defaultGSData, defaultTakerPermit, taker, randomSig);
genericSwap.executeSwapWithSig(defaultGSData, defaultTakerPermit, taker, randomSig);
}

function testCannotReplayGenericSwapSig() public {
bytes memory takerSig = signGenericSwap(takerPrivateKey, defaultGSData, address(genericSwap));
genericSwap.executeSwap(defaultGSData, defaultTakerPermit, taker, takerSig);
genericSwap.executeSwapWithSig(defaultGSData, defaultTakerPermit, taker, takerSig);

vm.expectRevert(IGenericSwap.AlreadyFilled.selector);
genericSwap.executeSwap(defaultGSData, defaultTakerPermit, taker, takerSig);
genericSwap.executeSwapWithSig(defaultGSData, defaultTakerPermit, taker, takerSig);
}
}
6 changes: 3 additions & 3 deletions test/forkMainnet/RFQ.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ contract RFQTest is Test, Tokens, BalanceUtil, Permit2Helper, SigHelper {
);

vm.prank(txRelayer, txRelayer);
rfq.fillRFQ(defaultRFQTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, takerSig);
rfq.fillRFQWithSig(defaultRFQTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, takerSig);

takerTakerToken.assertChange(-int256(defaultRFQOffer.takerTokenAmount));
takerMakerToken.assertChange(int256(0));
Expand All @@ -593,7 +593,7 @@ contract RFQTest is Test, Tokens, BalanceUtil, Permit2Helper, SigHelper {

vm.expectRevert(IRFQ.InvalidSignature.selector);
vm.prank(txRelayer, txRelayer);
rfq.fillRFQ(defaultRFQTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, randomSig);
rfq.fillRFQWithSig(defaultRFQTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, randomSig);
}

function testCannotFillWithInvalidFeeFactor() public {
Expand All @@ -603,7 +603,7 @@ contract RFQTest is Test, Tokens, BalanceUtil, Permit2Helper, SigHelper {

vm.expectRevert(IRFQ.InvalidFeeFactor.selector);
vm.prank(txRelayer, txRelayer);
rfq.fillRFQ(rfqTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, takerSig);
rfq.fillRFQWithSig(rfqTx, defaultMakerSig, defaultMakerPermit, defaultTakerPermit, takerSig);
}

function testCannotFillIfMakerAmountIsZero() public {
Expand Down
Loading