diff --git a/.gas-snapshot b/.gas-snapshot index d89d4fd..c050368 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,118 +1,120 @@ -ApproveAndSwapTest:testSwap() (gas: 273935) -ApproveAndSwapTest:testSwapFailsIfWeExpectedTooMuch() (gas: 335013) -ApproveAndSwapTest:testSwapFailsWithNoApproval() (gas: 92109) -CCTPBridge:testBridgeToBase() (gas: 128036) -CometClaimRewardsTest:testClaimComp() (gas: 127404) -CometRepayAndWithdrawMultipleAssetsTest:testInvalidInput() (gas: 44602) -CometRepayAndWithdrawMultipleAssetsTest:testRepayAndWithdrawMultipleAssets() (gas: 134584) -CometSupplyMultipleAssetsAndBorrowTest:testInvalidInput() (gas: 44546) -CometSupplyMultipleAssetsAndBorrowTest:testSupplyMultipleAssetsAndBorrow() (gas: 276105) -ConditionalMulticallTest:testConditionalRunEmptyInputIsValid() (gas: 44953) -ConditionalMulticallTest:testConditionalRunInvalidInput() (gas: 45053) -ConditionalMulticallTest:testConditionalRunMulticallError() (gas: 288790) -ConditionalMulticallTest:testConditionalRunOnPeriodicRepay() (gas: 276093) -ConditionalMulticallTest:testConditionalRunPassed() (gas: 266956) -ConditionalMulticallTest:testConditionalRunUnmet() (gas: 76859) -EthcallTest:testEthcallCallReraiseError() (gas: 53333) -EthcallTest:testEthcallCounter() (gas: 65125) -EthcallTest:testEthcallShouldReturnCallResult() (gas: 45940) -EthcallTest:testEthcallSupplyUSDCToComet() (gas: 152864) -EthcallTest:testEthcallWithdrawUSDCFromComet() (gas: 305482) -GetDripTest:testDrip() (gas: 117212) -MorphoActionsTest:testRepayAndWithdrawCollateral() (gas: 124949) -MorphoActionsTest:testRepayMaxAndWithdrawCollateral() (gas: 99344) -MorphoActionsTest:testSupplyCollateralAndBorrow() (gas: 246334) +ApproveAndSwapTest:testSwap() (gas: 275122) +ApproveAndSwapTest:testSwapFailsIfWeExpectedTooMuch() (gas: 339569) +ApproveAndSwapTest:testSwapFailsWithNoApproval() (gas: 96664) +CCTPBridge:testBridgeToBase() (gas: 128986) +CometClaimRewardsTest:testClaimComp() (gas: 128593) +CometRepayAndWithdrawMultipleAssetsTest:testInvalidInput() (gas: 45788) +CometRepayAndWithdrawMultipleAssetsTest:testRepayAndWithdrawMultipleAssets() (gas: 135531) +CometSupplyMultipleAssetsAndBorrowTest:testInvalidInput() (gas: 45732) +CometSupplyMultipleAssetsAndBorrowTest:testSupplyMultipleAssetsAndBorrow() (gas: 277062) +ConditionalMulticallTest:testConditionalRunEmptyInputIsValid() (gas: 46140) +ConditionalMulticallTest:testConditionalRunInvalidInput() (gas: 46239) +ConditionalMulticallTest:testConditionalRunMulticallError() (gas: 290012) +ConditionalMulticallTest:testConditionalRunOnPeriodicRepay() (gas: 282038) +ConditionalMulticallTest:testConditionalRunPassed() (gas: 268155) +ConditionalMulticallTest:testConditionalRunUnmet() (gas: 78046) +EthcallTest:testEthcallCallReraiseError() (gas: 54519) +EthcallTest:testEthcallCounter() (gas: 66310) +EthcallTest:testEthcallShouldReturnCallResult() (gas: 47126) +EthcallTest:testEthcallSupplyUSDCToComet() (gas: 155234) +EthcallTest:testEthcallWithdrawUSDCFromComet() (gas: 309037) +GetDripTest:testDrip() (gas: 118389) +MorphoActionsTest:testRepayAndWithdrawCollateral() (gas: 126133) +MorphoActionsTest:testRepayMaxAndWithdrawCollateral() (gas: 100292) +MorphoActionsTest:testSupplyCollateralAndBorrow() (gas: 247518) MorphoInfoTest:testBaseMainnet() (gas: 1622233) MorphoInfoTest:testBaseSepolia() (gas: 743646) MorphoInfoTest:testEthMainnet() (gas: 2636638) MorphoInfoTest:testEthSepolia() (gas: 644206) -MorphoRewardsActionsTest:testClaim() (gas: 107567) -MorphoRewardsActionsTest:testClaimAll() (gas: 179400) -MorphoVaultActionsTest:testDeposit() (gas: 758763) -MorphoVaultActionsTest:testWithdraw() (gas: 567620) -MulticallTest:testCallcodeToMulticallSucceedsWhenUninitialized() (gas: 73035) -MulticallTest:testCreateSubWalletAndExecute() (gas: 602078) -MulticallTest:testEmptyInputIsValid() (gas: 44599) -MulticallTest:testExecutorCanMulticallAcrossSubwallets() (gas: 251487) -MulticallTest:testInvalidInput() (gas: 44813) -MulticallTest:testInvokeCounterTwice() (gas: 73189) -MulticallTest:testMulticallError() (gas: 281688) -MulticallTest:testMulticallShouldReturnCallResults() (gas: 75670) +MorphoRewardsActionsTest:testClaim() (gas: 108754) +MorphoRewardsActionsTest:testClaimAll() (gas: 180588) +MorphoVaultActionsTest:testDeposit() (gas: 759946) +MorphoVaultActionsTest:testWithdraw() (gas: 568804) +MulticallTest:testCallcodeToMulticallSucceedsWhenUninitialized() (gas: 74223) +MulticallTest:testCreateSubWalletAndExecute() (gas: 603893) +MulticallTest:testEmptyInputIsValid() (gas: 45785) +MulticallTest:testExecutorCanMulticallAcrossSubwallets() (gas: 253685) +MulticallTest:testInvalidInput() (gas: 45999) +MulticallTest:testInvokeCounterTwice() (gas: 74377) +MulticallTest:testMulticallError() (gas: 282876) +MulticallTest:testMulticallShouldReturnCallResults() (gas: 76844) MulticallTest:testRevertsForInvalidCallContext() (gas: 11543) -MulticallTest:testSupplyWETHWithdrawUSDCOnComet() (gas: 246618) +MulticallTest:testSupplyWETHWithdrawUSDCOnComet() (gas: 247803) PaycallTest:testInitializeProperlyFromConstructor() (gas: 6412) -PaycallTest:testPaycallAddress() (gas: 204118) -PaycallTest:testPaycallForPayWithUSDT() (gas: 115625) -PaycallTest:testPaycallForPayWithWBTC() (gas: 108765) -PaycallTest:testPaycallRevertsWhenCallReverts() (gas: 49555) -PaycallTest:testReturnCallResult() (gas: 85461) -PaycallTest:testRevertWhenCostIsMoreThanMaxPaymentCost() (gas: 95221) +PaycallTest:testPaycallAddress() (gas: 204488) +PaycallTest:testPaycallForPayWithUSDT() (gas: 116809) +PaycallTest:testPaycallForPayWithWBTC() (gas: 109949) +PaycallTest:testPaycallRevertsWhenCallReverts() (gas: 50738) +PaycallTest:testReturnCallResult() (gas: 86647) +PaycallTest:testRevertWhenCostIsMoreThanMaxPaymentCost() (gas: 96405) PaycallTest:testRevertsForInvalidCallContext() (gas: 15789) -PaycallTest:testSimpleCounterAndPayWithUSDC() (gas: 136629) -PaycallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 137984) -PaycallTest:testSupplyWETHWithdrawUSDCOnCometAndPayWithUSDC() (gas: 289774) +PaycallTest:testSimpleCounterAndPayWithUSDC() (gas: 137814) +PaycallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 139168) +PaycallTest:testSupplyWETHWithdrawUSDCOnCometAndPayWithUSDC() (gas: 290960) QuotecallTest:testInitializeProperlyFromConstructor() (gas: 6996) -QuotecallTest:testQuotecallForPayWithUSDT() (gas: 115729) -QuotecallTest:testQuotecallForPayWithWBTC() (gas: 108950) -QuotecallTest:testQuotecallRevertsWhenCallReverts() (gas: 85838) -QuotecallTest:testReturnCallResult() (gas: 105548) +QuotecallTest:testQuotecallForPayWithUSDT() (gas: 116913) +QuotecallTest:testQuotecallForPayWithWBTC() (gas: 110134) +QuotecallTest:testQuotecallRevertsWhenCallReverts() (gas: 87021) +QuotecallTest:testReturnCallResult() (gas: 106734) QuotecallTest:testRevertsForInvalidCallContext() (gas: 15764) -QuotecallTest:testRevertsWhenQuoteTooHigh() (gas: 131301) -QuotecallTest:testRevertsWhenQuoteTooLow() (gas: 131143) -QuotecallTest:testSimpleCounterAndPayWithUSDC() (gas: 136765) -QuotecallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 138132) -RecurringSwapTest:testCancelRecurringSwap() (gas: 272600) -RecurringSwapTest:testRecurringSwapCanSwapMultipleTimes() (gas: 337021) -RecurringSwapTest:testRecurringSwapExactInAlternateSwap() (gas: 216061) -RecurringSwapTest:testRecurringSwapExactInSwap() (gas: 223781) -RecurringSwapTest:testRecurringSwapExactOutAlternateSwap() (gas: 219405) -RecurringSwapTest:testRecurringSwapExactOutSwap() (gas: 225744) -RecurringSwapTest:testRecurringSwapWithDifferentCalldata() (gas: 570083) -RecurringSwapTest:testRecurringSwapWithMultiplePriceFeeds() (gas: 240880) -RecurringSwapTest:testRevertsForExpiredQuarkOperation() (gas: 9578) -RecurringSwapTest:testRevertsForInvalidInput() (gas: 91043) -RecurringSwapTest:testRevertsForSwapBeforeNextSwapWindow() (gas: 245871) +QuotecallTest:testRevertsWhenQuoteTooHigh() (gas: 132485) +QuotecallTest:testRevertsWhenQuoteTooLow() (gas: 132327) +QuotecallTest:testSimpleCounterAndPayWithUSDC() (gas: 137950) +QuotecallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 139316) +RecurringSwapTest:testCancelRecurringSwap() (gas: 275992) +RecurringSwapTest:testRecurringSwapCanSwapMultipleTimes() (gas: 340719) +RecurringSwapTest:testRecurringSwapCannotSwapMultipleTimesForMissedWindows() (gas: 341492) +RecurringSwapTest:testRecurringSwapExactInAlternateSwap() (gas: 217681) +RecurringSwapTest:testRecurringSwapExactInSwap() (gas: 225425) +RecurringSwapTest:testRecurringSwapExactOutAlternateSwap() (gas: 220999) +RecurringSwapTest:testRecurringSwapExactOutSwap() (gas: 227339) +RecurringSwapTest:testRecurringSwapWithDifferentCalldata() (gas: 577151) +RecurringSwapTest:testRecurringSwapWithMultiplePriceFeeds() (gas: 242483) +RecurringSwapTest:testRevertsForExpiredQuarkOperation() (gas: 9916) +RecurringSwapTest:testRevertsForInvalidInput() (gas: 93610) +RecurringSwapTest:testRevertsForSwapBeforeNextSwapWindow() (gas: 248353) RecurringSwapTest:testRevertsForSwapBeforeStartTime() (gas: 9223372036854754743) -RecurringSwapTest:testRevertsWhenSlippageParamsConfiguredWrong() (gas: 227765) -RecurringSwapTest:testRevertsWhenSlippageTooHigh() (gas: 227969) -SupplyActionsTest:testInvalidInput() (gas: 44611) -SupplyActionsTest:testRepayBorrow() (gas: 70904) -SupplyActionsTest:testSupply() (gas: 113213) -SupplyActionsTest:testSupplyFrom() (gas: 93016) -SupplyActionsTest:testSupplyMultipleCollateral() (gas: 251264) -SupplyActionsTest:testSupplyTo() (gas: 112708) -TransferActionsTest:testRevertsForTransferERC777ReentrancyAttackWithReentrancyGuard() (gas: 98027) -TransferActionsTest:testRevertsForTransferReentrancyAttackWithReentrancyGuard() (gas: 78814) -TransferActionsTest:testRevertsForTransferReentrancyAttackWithoutCallbackEnabled() (gas: 73817) -TransferActionsTest:testRevertsForTransferReentrantAttackWithStolenSignature() (gas: 84625) -TransferActionsTest:testTransferERC20TokenToEOA() (gas: 51656) -TransferActionsTest:testTransferERC20TokenToQuarkWallet() (gas: 52976) -TransferActionsTest:testTransferERC777SuccessWithEvilReceiverWithoutAttackAttempt() (gas: 74483) -TransferActionsTest:testTransferERC777TokenReentrancyAttackSuccessWithCallbackEnabled() (gas: 110337) -TransferActionsTest:testTransferNativeTokenToEOA() (gas: 75996) -TransferActionsTest:testTransferNativeTokenToQuarkWallet() (gas: 50662) -TransferActionsTest:testTransferReentrancyAttackSuccessWithCallbackEnabled() (gas: 93738) -TransferActionsTest:testTransferSuccessWithEvilReceiverWithoutAttackAttempt() (gas: 54853) -UniswapFlashLoanTest:testFlashLoanForCollateralSwapOnCompound() (gas: 368458) -UniswapFlashLoanTest:testRevertsForInsufficientFundsToRepayFlashLoan() (gas: 138730) -UniswapFlashLoanTest:testRevertsForInvalidCaller() (gas: 46273) -UniswapFlashLoanTest:testTokensOrderInvariant() (gas: 81719) -UniswapFlashSwapExactOutTest:testInvalidCallerFlashSwap() (gas: 46469) -UniswapFlashSwapExactOutTest:testNotEnoughToPayFlashSwap() (gas: 233929) +RecurringSwapTest:testRevertsForSwapWhenSwapWindowIsClosed() (gas: 342645) +RecurringSwapTest:testRevertsWhenSlippageParamsConfiguredWrong() (gas: 229363) +RecurringSwapTest:testRevertsWhenSlippageTooHigh() (gas: 229583) +SupplyActionsTest:testInvalidInput() (gas: 45797) +SupplyActionsTest:testRepayBorrow() (gas: 71850) +SupplyActionsTest:testSupply() (gas: 114160) +SupplyActionsTest:testSupplyFrom() (gas: 93963) +SupplyActionsTest:testSupplyMultipleCollateral() (gas: 252211) +SupplyActionsTest:testSupplyTo() (gas: 113656) +TransferActionsTest:testRevertsForTransferERC777ReentrancyAttackWithReentrancyGuard() (gas: 99528) +TransferActionsTest:testRevertsForTransferReentrancyAttackWithReentrancyGuard() (gas: 80304) +TransferActionsTest:testRevertsForTransferReentrancyAttackWithoutCallbackEnabled() (gas: 75206) +TransferActionsTest:testRevertsForTransferReentrantAttackWithStolenSignature() (gas: 87371) +TransferActionsTest:testTransferERC20TokenToEOA() (gas: 52858) +TransferActionsTest:testTransferERC20TokenToQuarkWallet() (gas: 54177) +TransferActionsTest:testTransferERC777SuccessWithEvilReceiverWithoutAttackAttempt() (gas: 75987) +TransferActionsTest:testTransferERC777TokenReentrancyAttackSuccessWithCallbackEnabled() (gas: 111522) +TransferActionsTest:testTransferNativeTokenToEOA() (gas: 77491) +TransferActionsTest:testTransferNativeTokenToQuarkWallet() (gas: 52157) +TransferActionsTest:testTransferReentrancyAttackSuccessWithCallbackEnabled() (gas: 94922) +TransferActionsTest:testTransferSuccessWithEvilReceiverWithoutAttackAttempt() (gas: 56348) +UniswapFlashLoanTest:testFlashLoanForCollateralSwapOnCompound() (gas: 369646) +UniswapFlashLoanTest:testRevertsForInsufficientFundsToRepayFlashLoan() (gas: 139917) +UniswapFlashLoanTest:testRevertsForInvalidCaller() (gas: 47459) +UniswapFlashLoanTest:testTokensOrderInvariant() (gas: 82904) +UniswapFlashSwapExactOutTest:testInvalidCallerFlashSwap() (gas: 47655) +UniswapFlashSwapExactOutTest:testNotEnoughToPayFlashSwap() (gas: 235116) UniswapFlashSwapExactOutTest:testRevertsIfCalledDirectly() (gas: 104305) -UniswapFlashSwapExactOutTest:testUniswapFlashSwapExactOutLeverageComet() (gas: 311072) -UniswapSwapActionsTest:testApprovalRefund() (gas: 159188) -UniswapSwapActionsTest:testBuyAssetOneStop() (gas: 250010) -UniswapSwapActionsTest:testBuyAssetTwoStops() (gas: 363122) -UniswapSwapActionsTest:testSellAssetOneStop() (gas: 246694) -UniswapSwapActionsTest:testSellAssetTwoStops() (gas: 368042) -WithdrawActionsTest:testBorrow() (gas: 150239) -WithdrawActionsTest:testInvalidInput() (gas: 44591) -WithdrawActionsTest:testWithdraw() (gas: 64886) -WithdrawActionsTest:testWithdrawFrom() (gas: 64296) -WithdrawActionsTest:testWithdrawMultipleAssets() (gas: 139993) -WithdrawActionsTest:testWithdrawTo() (gas: 64824) -WrapperScriptsTest:testUnwrapWETH() (gas: 39141) -WrapperScriptsTest:testUnwrapWstETH() (gas: 87724) -WrapperScriptsTest:testWrapETH() (gas: 73485) -WrapperScriptsTest:testWrapStETH() (gas: 105947) \ No newline at end of file +UniswapFlashSwapExactOutTest:testUniswapFlashSwapExactOutLeverageComet() (gas: 312269) +UniswapSwapActionsTest:testApprovalRefund() (gas: 160372) +UniswapSwapActionsTest:testBuyAssetOneStop() (gas: 252378) +UniswapSwapActionsTest:testBuyAssetTwoStops() (gas: 365490) +UniswapSwapActionsTest:testSellAssetOneStop() (gas: 249062) +UniswapSwapActionsTest:testSellAssetTwoStops() (gas: 370410) +WithdrawActionsTest:testBorrow() (gas: 151422) +WithdrawActionsTest:testInvalidInput() (gas: 45776) +WithdrawActionsTest:testWithdraw() (gas: 65832) +WithdrawActionsTest:testWithdrawFrom() (gas: 65244) +WithdrawActionsTest:testWithdrawMultipleAssets() (gas: 140950) +WithdrawActionsTest:testWithdrawTo() (gas: 65772) +WrapperScriptsTest:testUnwrapWETH() (gas: 40088) +WrapperScriptsTest:testUnwrapWstETH() (gas: 88908) +WrapperScriptsTest:testWrapETH() (gas: 74669) +WrapperScriptsTest:testWrapStETH() (gas: 106893) \ No newline at end of file diff --git a/lib/quark b/lib/quark index 4d89e84..4e5ba95 160000 --- a/lib/quark +++ b/lib/quark @@ -1 +1 @@ -Subproject commit 4d89e844dfcb8c4767b1f4830e1b9ac9c219a23e +Subproject commit 4e5ba95ac5118cca5456d41c8ddd9415eb443530 diff --git a/src/Cancel.sol b/src/Cancel.sol index c37f653..0a9613d 100644 --- a/src/Cancel.sol +++ b/src/Cancel.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause pragma solidity 0.8.27; -import {IQuarkWallet} from "quark-core/src/QuarkWallet.sol"; +import {IQuarkWallet} from "quark-core/src/interfaces/IQuarkWallet.sol"; import {QuarkNonceManager} from "quark-core/src/QuarkNonceManager.sol"; /** diff --git a/src/DeFiScripts.sol b/src/DeFiScripts.sol index 1c0e48b..b460b0d 100644 --- a/src/DeFiScripts.sol +++ b/src/DeFiScripts.sol @@ -198,7 +198,7 @@ contract TransferActions is QuarkScript { * @param recipient The recipient address * @param amount The amount to transfer */ - function transferERC20Token(address token, address recipient, uint256 amount) external onlyWallet { + function transferERC20Token(address token, address recipient, uint256 amount) external nonReentrant { IERC20(token).safeTransfer(recipient, amount); } @@ -207,7 +207,7 @@ contract TransferActions is QuarkScript { * @param recipient The recipient address * @param amount The amount to transfer */ - function transferNativeToken(address recipient, uint256 amount) external onlyWallet { + function transferNativeToken(address recipient, uint256 amount) external nonReentrant { (bool success, bytes memory data) = payable(recipient).call{value: amount}(""); if (!success) { revert DeFiScriptErrors.TransferFailed(data); diff --git a/src/RecurringSwap.sol b/src/RecurringSwap.sol index ebae2e2..7352bae 100644 --- a/src/RecurringSwap.sol +++ b/src/RecurringSwap.sol @@ -132,7 +132,7 @@ contract RecurringSwap is QuarkScript { // Emit the swap event emit SwapExecuted( - msg.sender, + address(this), config.swapParams.recipient, config.swapParams.tokenIn, config.swapParams.tokenOut, diff --git a/test/ApproveAndSwap.t.sol b/test/ApproveAndSwap.t.sol index b1cac62..6027e0e 100644 --- a/test/ApproveAndSwap.t.sol +++ b/test/ApproveAndSwap.t.sol @@ -58,11 +58,11 @@ contract ApproveAndSwapTest is Test { abi.encodeCall(ApproveAndSwap.run, (ZEROX_PROXY, USDC, sellAmount, WETH, buyAmount, data)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // The swap will always yield the same amount of WETH since we test at a specific block assertEq(IERC20(WETH).balanceOf(address(wallet)), 420691117291334340); @@ -91,12 +91,12 @@ contract ApproveAndSwapTest is Test { abi.encodeCall(ApproveAndSwap.run, (ZEROX_PROXY, USDC, sellAmount, WETH, buyAmount, data)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectRevert(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // The swap will always yield the same amount of WETH since we test at a specific block assertEq(IERC20(WETH).balanceOf(address(wallet)), 0); @@ -125,12 +125,12 @@ contract ApproveAndSwapTest is Test { abi.encodeCall(ApproveAndSwap.run, (ZEROX_PROXY, USDC, sellAmount, WETH, buyAmount, data)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectRevert(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // The swap will always yield the same amount of WETH since we test at a specific block assertEq(IERC20(WETH).balanceOf(address(wallet)), 0); diff --git a/test/CCTPBridgeActions.t.sol b/test/CCTPBridgeActions.t.sol index c611747..51ef93b 100644 --- a/test/CCTPBridgeActions.t.sol +++ b/test/CCTPBridgeActions.t.sol @@ -59,11 +59,11 @@ contract CCTPBridge is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1_000_000e6); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 500_000e6); } } diff --git a/test/CometClaimRewards.t.sol b/test/CometClaimRewards.t.sol index 8bad92e..097bbf4 100644 --- a/test/CometClaimRewards.t.sol +++ b/test/CometClaimRewards.t.sol @@ -69,11 +69,11 @@ contract CometClaimRewardsTest is Test { abi.encodeCall(CometClaimRewards.claim, (cometRewards, comets, address(wallet))), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(COMP).balanceOf(address(wallet)), 0e6); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertGt(IERC20(COMP).balanceOf(address(wallet)), 0e6); } diff --git a/test/CometRepayAndWithdrawMultipleAssets.t.sol b/test/CometRepayAndWithdrawMultipleAssets.t.sol index 12c8c1c..b71d217 100644 --- a/test/CometRepayAndWithdrawMultipleAssets.t.sol +++ b/test/CometRepayAndWithdrawMultipleAssets.t.sol @@ -71,12 +71,12 @@ contract CometRepayAndWithdrawMultipleAssetsTest is Test { abi.encodeCall(CometRepayAndWithdrawMultipleAssets.run, (comet, assets, amounts, USDC, 100e6)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0); assertEq(IERC20(LINK).balanceOf(address(wallet)), 0); assertEq(IERC20(USDC).balanceOf(address(wallet)), 100e6); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(LINK).balanceOf(address(wallet)), 10e18); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0); @@ -100,10 +100,10 @@ contract CometRepayAndWithdrawMultipleAssetsTest is Test { abi.encodeCall(CometRepayAndWithdrawMultipleAssets.run, (comet, assets, amounts, USDC, 100e6)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(DeFiScriptErrors.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } } diff --git a/test/CometSupplyActions.t.sol b/test/CometSupplyActions.t.sol index fc9f6eb..c4ed716 100644 --- a/test/CometSupplyActions.t.sol +++ b/test/CometSupplyActions.t.sol @@ -57,11 +57,11 @@ contract SupplyActionsTest is Test { abi.encodeWithSelector(CometSupplyActions.supply.selector, comet, WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); } @@ -79,11 +79,11 @@ contract SupplyActionsTest is Test { abi.encodeWithSelector(CometSupplyActions.supplyTo.selector, comet, address(wallet2), WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet2), WETH), 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet2), WETH), 10 ether); } @@ -107,11 +107,11 @@ contract SupplyActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet2)), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet2)), 0 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); } @@ -134,11 +134,11 @@ contract SupplyActionsTest is Test { abi.encodeWithSelector(CometSupplyActions.supply.selector, comet, USDC, 1000e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IComet(comet).borrowBalanceOf(address(wallet)), 1000e6); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).borrowBalanceOf(address(wallet)), 0e6); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); } @@ -166,11 +166,11 @@ contract SupplyActionsTest is Test { abi.encodeWithSelector(CometSupplyActions.supplyMultipleAssets.selector, comet, assets, amounts), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(LINK).balanceOf(address(wallet)), 10e18); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), LINK), 10e18); assertApproxEqAbs(IComet(comet).balanceOf(address(wallet)), 1000e6, 1); @@ -194,10 +194,10 @@ contract SupplyActionsTest is Test { abi.encodeWithSelector(CometSupplyActions.supplyMultipleAssets.selector, comet, assets, amounts), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(DeFiScriptErrors.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } } diff --git a/test/CometSupplyMultipleAssetsAndBorrow.t.sol b/test/CometSupplyMultipleAssetsAndBorrow.t.sol index 3b6f99d..560f278 100644 --- a/test/CometSupplyMultipleAssetsAndBorrow.t.sol +++ b/test/CometSupplyMultipleAssetsAndBorrow.t.sol @@ -65,13 +65,13 @@ contract CometSupplyMultipleAssetsAndBorrowTest is Test { abi.encodeWithSelector(CometSupplyMultipleAssetsAndBorrow.run.selector, comet, assets, amounts, USDC, 100e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(LINK).balanceOf(address(wallet)), 10e18); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0e6); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), LINK), 10e18); assertEq(IERC20(USDC).balanceOf(address(wallet)), 100e6); @@ -95,10 +95,10 @@ contract CometSupplyMultipleAssetsAndBorrowTest is Test { abi.encodeWithSelector(CometSupplyMultipleAssetsAndBorrow.run.selector, comet, assets, amounts, USDC, 100e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(DeFiScriptErrors.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } } diff --git a/test/CometWithdrawActions.t.sol b/test/CometWithdrawActions.t.sol index 3d15e5f..a0af8c5 100644 --- a/test/CometWithdrawActions.t.sol +++ b/test/CometWithdrawActions.t.sol @@ -63,9 +63,9 @@ contract WithdrawActionsTest is Test { abi.encodeWithSelector(CometWithdrawActions.withdraw.selector, comet, WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0 ether); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); @@ -91,9 +91,9 @@ contract WithdrawActionsTest is Test { abi.encodeWithSelector(CometWithdrawActions.withdrawTo.selector, comet, address(wallet2), WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0 ether); assertEq(IERC20(WETH).balanceOf(address(wallet2)), 10 ether); @@ -122,9 +122,9 @@ contract WithdrawActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet2), WETH), 0 ether); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); @@ -147,7 +147,7 @@ contract WithdrawActionsTest is Test { abi.encodeWithSelector(CometWithdrawActions.withdraw.selector, comet, USDC, 100e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0e6); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); @@ -155,7 +155,7 @@ contract WithdrawActionsTest is Test { // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 100e6); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); @@ -197,7 +197,7 @@ contract WithdrawActionsTest is Test { abi.encodeWithSelector(CometWithdrawActions.withdrawMultipleAssets.selector, comet, assets, amounts), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 10 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), LINK), 1000e18); @@ -206,7 +206,7 @@ contract WithdrawActionsTest is Test { assertEq(IERC20(USDC).balanceOf(address(wallet)), 0e6); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0 ether); assertEq(IComet(comet).collateralBalanceOf(address(wallet), LINK), 0e18); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); @@ -231,10 +231,10 @@ contract WithdrawActionsTest is Test { abi.encodeWithSelector(CometWithdrawActions.withdrawMultipleAssets.selector, comet, assets, amounts), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(DeFiScriptErrors.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } } diff --git a/test/ConditionalMulticall.t.sol b/test/ConditionalMulticall.t.sol index 8a24bb6..9e968e4 100644 --- a/test/ConditionalMulticall.t.sol +++ b/test/ConditionalMulticall.t.sol @@ -123,9 +123,9 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // When reaches here, meaning all checks are passed assertEq(IERC20(USDC).balanceOf(address(wallet)), 1_000_000_000); @@ -169,7 +169,7 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert( abi.encodeWithSelector( @@ -181,7 +181,7 @@ contract ConditionalMulticallTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testConditionalRunInvalidInput() public { @@ -206,11 +206,11 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(ConditionalMulticall.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testConditionalRunMulticallError() public { @@ -273,7 +273,7 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert( abi.encodeWithSelector( ConditionalMulticall.MulticallError.selector, @@ -283,7 +283,7 @@ contract ConditionalMulticallTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testConditionalRunEmptyInputIsValid() public { @@ -302,11 +302,11 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // Empty array is a valid input representing a no-op, and it should not revert vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testConditionalRunOnPeriodicRepay() public { @@ -367,7 +367,7 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // Wallet doesn't have USDC, condition will fail vm.expectRevert( abi.encodeWithSelector( @@ -379,7 +379,7 @@ contract ConditionalMulticallTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); vm.pauseGasMetering(); // Wallet has accrue 400 USDC @@ -392,9 +392,9 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); vm.pauseGasMetering(); // Wallet has accrued another 400 USDC @@ -405,9 +405,9 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); vm.pauseGasMetering(); // Wallet has accrued another 400 USDC @@ -418,9 +418,9 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); vm.pauseGasMetering(); // Wallet no longer borrows from Comet, condition 2 will fail @@ -432,7 +432,7 @@ contract ConditionalMulticallTest is Test { abi.encodeWithSelector(ConditionalMulticall.run.selector, callContracts, callDatas, conditions, checkValues), ScriptType.ScriptAddress ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert( abi.encodeWithSelector( ConditionalChecker.CheckFailed.selector, @@ -443,7 +443,7 @@ contract ConditionalMulticallTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // Wallet fully pays off debt assertEq(IComet(comet).borrowBalanceOf(address(wallet)), 0); diff --git a/test/Ethcall.t.sol b/test/Ethcall.t.sol index eef0a37..e1caceb 100644 --- a/test/Ethcall.t.sol +++ b/test/Ethcall.t.sol @@ -65,11 +65,11 @@ contract EthcallTest is Test { ); assertEq(counter.number(), 0); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(counter.number(), 1); } @@ -89,11 +89,11 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(comet).balanceOf(address(wallet)), 0); @@ -108,11 +108,11 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // Since there is rouding diff, assert on diff is less than 10 wei assertApproxEqAbs(1000e6, IComet(comet).balanceOf(address(wallet)), 2); @@ -135,11 +135,11 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // gas: do not meter set-up vm.pauseGasMetering(); @@ -152,11 +152,11 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // gas: do not meter set-up vm.pauseGasMetering(); @@ -169,11 +169,11 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (v, r, s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + (signature) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } @@ -195,12 +195,12 @@ contract EthcallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert("ERC20: transfer amount exceeds balance"); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testEthcallShouldReturnCallResult() public { @@ -218,11 +218,11 @@ contract EthcallTest is Test { ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - bytes memory quarkReturn = wallet.executeQuarkOperation(op, v, r, s); + bytes memory quarkReturn = wallet.executeQuarkOperation(op, signature); bytes memory returnData = abi.decode(quarkReturn, (bytes)); assertEq(counter.number(), 4); diff --git a/test/GetDrip.t.sol b/test/GetDrip.t.sol index 1529074..0e46322 100644 --- a/test/GetDrip.t.sol +++ b/test/GetDrip.t.sol @@ -42,12 +42,12 @@ contract GetDripTest is Test { QuarkWallet.QuarkOperation memory op = new QuarkOperationHelper().newBasicOpWithCalldata( wallet, getDripScript, abi.encodeCall(GetDrip.drip, (fauceteer, USDC)), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // The drip always gives this amount assertNotEq(IERC20(USDC).balanceOf(address(wallet)), 0); diff --git a/test/MorphoActions.t.sol b/test/MorphoActions.t.sol index dfdc105..112059f 100644 --- a/test/MorphoActions.t.sol +++ b/test/MorphoActions.t.sol @@ -65,7 +65,7 @@ contract MorphoActionsTest is Test { abi.encodeWithSelector(MorphoActions.repayAndWithdrawCollateral.selector, morpho, marketParams, 800e6, 5e18), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 0); (,, uint128 totalBorrowAssets, uint128 totalBorrowShares,,) = IMorpho(morpho).market(marketId(marketParams)); @@ -75,7 +75,7 @@ contract MorphoActionsTest is Test { ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 200e6); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 5e18); @@ -102,12 +102,12 @@ contract MorphoActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 10e18); assertEq(IMorpho(morpho).position(marketId(marketParams), address(wallet)).collateral, 0); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 0); assertEq(IMorpho(morpho).position(marketId(marketParams), address(wallet)).collateral, 10e18); @@ -136,7 +136,7 @@ contract MorphoActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1100e6); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 0); (,, uint128 totalBorrowAssets, uint128 totalBorrowShares,,) = IMorpho(morpho).market(marketId(marketParams)); @@ -146,7 +146,7 @@ contract MorphoActionsTest is Test { ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertApproxEqAbs(IERC20(USDC).balanceOf(address(wallet)), 100e6, 0.01e6); assertEq(IMorpho(morpho).position(marketId(marketParams), address(wallet)).borrowShares, 0); diff --git a/test/MorphoRewardsActions.t.sol b/test/MorphoRewardsActions.t.sol index 406944f..1543e1c 100644 --- a/test/MorphoRewardsActions.t.sol +++ b/test/MorphoRewardsActions.t.sol @@ -99,11 +99,11 @@ contract MorphoRewardsActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(0xc55126051B22eBb829D00368f4B12Bde432de5Da).balanceOf(sampleAccount), 0); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(0xc55126051B22eBb829D00368f4B12Bde432de5Da).balanceOf(sampleAccount), 547387349612); } @@ -121,12 +121,12 @@ contract MorphoRewardsActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(0xc55126051B22eBb829D00368f4B12Bde432de5Da).balanceOf(sampleAccount), 0); assertEq(IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7).balanceOf(sampleAccount), 0); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(0xc55126051B22eBb829D00368f4B12Bde432de5Da).balanceOf(sampleAccount), 547387349612); assertEq(IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7).balanceOf(sampleAccount), 116); diff --git a/test/MorphoVaultActions.t.sol b/test/MorphoVaultActions.t.sol index 239b6ae..12dbc18 100644 --- a/test/MorphoVaultActions.t.sol +++ b/test/MorphoVaultActions.t.sol @@ -56,12 +56,12 @@ contract MorphoVaultActionsTest is Test { abi.encodeWithSelector(MorphoVaultActions.deposit.selector, morphoVault, USDC, 10_000e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 10_000e6); assertEq(IERC4626(morphoVault).balanceOf(address(wallet)), 0); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0); assertApproxEqAbs( @@ -82,12 +82,12 @@ contract MorphoVaultActionsTest is Test { abi.encodeWithSelector(MorphoVaultActions.withdraw.selector, morphoVault, 10_000e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(USDC).balanceOf(address(wallet)), 0e6); assertEq(IERC4626(morphoVault).balanceOf(address(wallet)), 10_000e18); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 10_000e6); } diff --git a/test/Multicall.t.sol b/test/Multicall.t.sol index af62d87..0b1c1ae 100644 --- a/test/Multicall.t.sol +++ b/test/Multicall.t.sol @@ -110,11 +110,11 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(counter.number(), 15); } @@ -149,11 +149,11 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(counter.number(), 15); } @@ -199,11 +199,11 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); assertEq(IComet(cUSDCv3).collateralBalanceOf(address(wallet), WETH), 100 ether); assertApproxEqAbs(IComet(cUSDCv3).borrowBalanceOf(address(wallet)), 1000e6, 2); @@ -231,12 +231,12 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.expectRevert(abi.encodeWithSelector(Multicall.InvalidInput.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testMulticallError() public { @@ -290,7 +290,7 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.expectRevert( @@ -302,7 +302,7 @@ contract MulticallTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testEmptyInputIsValid() public { @@ -319,12 +319,12 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); // Empty array is a valid input representing a no-op, and it should not revert - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testMulticallShouldReturnCallResults() public { @@ -358,11 +358,11 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - bytes memory quarkReturn = wallet.executeQuarkOperation(op, v, r, s); + bytes memory quarkReturn = wallet.executeQuarkOperation(op, signature); bytes[] memory returnDatas = abi.decode(quarkReturn, (bytes[])); assertEq(counter.number(), 15); @@ -471,12 +471,12 @@ contract MulticallTest is Test { QuarkWallet.QuarkOperation memory op = new QuarkOperationHelper().newBasicOpWithCalldata( primary, multicall, abi.encodeWithSelector(Multicall.run.selector, targets, calls), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, primary, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, primary, op); // gas: meter execute vm.resumeGasMetering(); - primary.executeQuarkOperation(op, v, r, s); + primary.executeQuarkOperation(op, signature); // wallet A should still have 0.5 ether... assertEq(IERC20(WETH).balanceOf(address(walletA)), 0.5 ether); // wallet B should have 0 ether... @@ -566,10 +566,10 @@ contract MulticallTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IComet(cUSDCv3).collateralBalanceOf(address(wallet), WETH), 100 ether); assertEq(IComet(cUSDCv3).borrowBalanceOf(address(wallet)), 10_000e6); assertApproxEqAbs(IComet(cWETHv3).balanceOf(address(subWallet1)), 2 ether, 1); diff --git a/test/Paycall.t.sol b/test/Paycall.t.sol index f1e81a0..f46e8ee 100644 --- a/test/Paycall.t.sol +++ b/test/Paycall.t.sol @@ -166,13 +166,13 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, false); // We ignore the amount because it will differ based on via-IR emit PayForGas(address(wallet), tx.origin, USDC, 10_658_763); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(counter.number(), 15); assertApproxEqAbs(IERC20(USDC).balanceOf(address(wallet)), 989e6, 1e6); @@ -203,13 +203,13 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, false); // We ignore the amount because it will differ based on via-IR emit PayForGas(address(wallet), tx.origin, USDC, 10_921_630); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertApproxEqAbs(IERC20(USDC).balanceOf(address(wallet)), 979e6, 1e6); assertEq(IERC20(USDC).balanceOf(address(this)), 10e6); @@ -264,13 +264,13 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, false); // We ignore the amount because it will differ based on via-IR emit PayForGas(address(wallet), tx.origin, USDC, 21_450_507); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertApproxEqAbs(IERC20(USDC).balanceOf(address(wallet)), 978e6, 1e6); assertEq(IComet(cUSDCv3).collateralBalanceOf(address(wallet), WETH), 100 ether); @@ -299,11 +299,11 @@ contract PaycallTest is Test { ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - bytes memory quarkReturn = wallet.executeQuarkOperation(op, v, r, s); + bytes memory quarkReturn = wallet.executeQuarkOperation(op, signature); bytes memory returnData = abi.decode(quarkReturn, (bytes)); bytes memory returnData2 = abi.decode(returnData, (bytes)); @@ -337,12 +337,12 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectEmit(true, true, true, false); // We ignore the amount because it will differ based on via-IR emit PayForGas(address(wallet), tx.origin, USDT, 10_488_771); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(this)), 1 ether); // About $8 in USD fees @@ -375,12 +375,12 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectEmit(true, true, true, false); // We ignore the amount because it will differ based on via-IR emit PayForGas(address(wallet), tx.origin, WBTC, 30_228); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(this)), 1 ether); // Fees in WBTC will be around ~ 0.00021 WBTC @@ -413,11 +413,11 @@ contract PaycallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(Paycall.TransactionTooExpensive.selector, 5_000_000, 10_478_744)); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } @@ -437,12 +437,12 @@ contract PaycallTest is Test { abi.encodeWithSelector(Paycall.run.selector, revertsAddress, "", 20e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(Reverts.Whoops.selector)); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } diff --git a/test/Quotecall.t.sol b/test/Quotecall.t.sol index 35464c7..08501a3 100644 --- a/test/Quotecall.t.sol +++ b/test/Quotecall.t.sol @@ -172,13 +172,13 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); emit PayForGas(address(wallet), tx.origin, USDC, 10e6); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(counter.number(), 15); assertEq(IERC20(USDC).balanceOf(address(wallet)), 990e6); @@ -209,13 +209,13 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); emit PayForGas(address(wallet), tx.origin, USDC, 10e6); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 980e6); assertEq(IERC20(USDC).balanceOf(address(this)), 10e6); @@ -244,11 +244,11 @@ contract QuotecallTest is Test { ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - bytes memory quarkReturn = wallet.executeQuarkOperation(op, v, r, s); + bytes memory quarkReturn = wallet.executeQuarkOperation(op, signature); bytes memory returnData = abi.decode(quarkReturn, (bytes)); bytes memory returnData2 = abi.decode(returnData, (bytes)); @@ -282,12 +282,12 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); emit PayForGas(address(wallet), tx.origin, USDT, 10e6); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(this)), 1 ether); // About $8 in USD fees @@ -320,12 +320,12 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); emit PayForGas(address(wallet), tx.origin, WBTC, 30e3); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(this)), 1 ether); assertEq(IERC20(WBTC).balanceOf(address(wallet)), 99_970_000); @@ -357,11 +357,11 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(Quotecall.QuoteToleranceExceeded.selector)); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } @@ -392,11 +392,11 @@ contract QuotecallTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(Quotecall.QuoteToleranceExceeded.selector)); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } @@ -416,12 +416,12 @@ contract QuotecallTest is Test { abi.encodeWithSelector(Quotecall.run.selector, revertsAddress, "", 8e6), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(Reverts.Whoops.selector)); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(USDC).balanceOf(address(wallet)), 1000e6); } diff --git a/test/RecurringSwap.t.sol b/test/RecurringSwap.t.sol index 3f170c4..1c587cf 100644 --- a/test/RecurringSwap.t.sol +++ b/test/RecurringSwap.t.sol @@ -101,7 +101,7 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC); @@ -118,7 +118,7 @@ contract RecurringSwapTest is Test { 1_674_115_383_192_806_353, // 1.674 WETH abi.encodePacked(USDC, uint24(500), WETH) ); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertGt(IERC20(WETH).balanceOf(address(aliceWallet)), expectedAmountOutMinimum); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC - amountToSell); @@ -147,7 +147,7 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC); @@ -164,7 +164,7 @@ contract RecurringSwapTest is Test { 10 ether, abi.encodePacked(WETH, uint24(500), USDC) ); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); assertLt(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC); @@ -209,7 +209,7 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), startingWETH); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), 0e6); @@ -226,7 +226,7 @@ contract RecurringSwapTest is Test { 17_901_866_835, // 17,901.86 USDC abi.encodePacked(WETH, uint24(500), USDC) ); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), startingWETH - amountToSell); assertGt(IERC20(USDC).balanceOf(address(aliceWallet)), expectedAmountOutMinimum); @@ -270,7 +270,7 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), startingWETH); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), 0e6); @@ -287,7 +287,7 @@ contract RecurringSwapTest is Test { amountToSwap, abi.encodePacked(USDC, uint24(500), WETH) ); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertLt(IERC20(WETH).balanceOf(address(aliceWallet)), startingWETH); assertGt(IERC20(WETH).balanceOf(address(aliceWallet)), startingWETH - expectedAmountInMaximum); @@ -316,14 +316,14 @@ contract RecurringSwapTest is Test { 1 ); op.expiry = type(uint256).max; - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1. Execute recurring swap for the first time - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); @@ -336,11 +336,11 @@ contract RecurringSwapTest is Test { block.timestamp ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); // 2b. Execute recurring swap a second time after warping 1 day vm.warp(block.timestamp + SWAP_WINDOW_INTERVAL); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap); } @@ -367,23 +367,23 @@ contract RecurringSwapTest is Test { 2 ); op.expiry = type(uint256).max; - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); QuarkWallet.QuarkOperation memory cancelOp = new QuarkOperationHelper().cancelReplayableByNop(aliceWallet, op); cancelOp.nonce = op.nonce; - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1. Execute recurring swap for the first time - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); // 2. Cancel replayable transaction - aliceWallet.executeQuarkOperationWithSubmissionToken(cancelOp, submissionTokens[1], v2, r2, s2); + aliceWallet.executeQuarkOperationWithSubmissionToken(cancelOp, submissionTokens[1], signature2); // 3. Replayable transaction can no longer be executed vm.warp(block.timestamp + SWAP_WINDOW_INTERVAL); @@ -392,14 +392,14 @@ contract RecurringSwapTest is Test { QuarkNonceManager.NonReplayableNonce.selector, address(aliceWallet), op.nonce, submissionTokens[1] ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); vm.expectRevert( abi.encodeWithSelector( QuarkNonceManager.NonReplayableNonce.selector, address(aliceWallet), op.nonce, submissionTokens[2] ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); } @@ -433,14 +433,14 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC); // gas: meter execute vm.resumeGasMetering(); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertGt(IERC20(WETH).balanceOf(address(aliceWallet)), expectedAmountOutMinimum); assertEq(IERC20(USDC).balanceOf(address(aliceWallet)), startingUSDC - amountToSell); @@ -495,21 +495,21 @@ contract RecurringSwapTest is Test { cancelOp.expiry = type(uint256).max; cancelOp.nonce = op1.nonce; } - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op2); - (uint8 v3, bytes32 r3, bytes32 s3) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op2); + bytes memory signature3 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1a. Execute recurring swap order #1 - aliceWallet.executeQuarkOperation(op1, v1, r1, s1); + aliceWallet.executeQuarkOperation(op1, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap1); // 1b. Execute recurring swap order #2 - aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[1], v2, r2, s2); + aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[1], signature2); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap1 + amountToSwap2); @@ -517,17 +517,17 @@ contract RecurringSwapTest is Test { vm.warp(block.timestamp + SWAP_WINDOW_INTERVAL); // 3a. Execute recurring swap order #1 - aliceWallet.executeQuarkOperationWithSubmissionToken(op1, submissionTokens[2], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op1, submissionTokens[2], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap1 + amountToSwap2); // 3b. Execute recurring swap order #2 - aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[3], v2, r2, s2); + aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[3], signature2); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap1 + 2 * amountToSwap2); // 4. Cancel replayable transaction - aliceWallet.executeQuarkOperationWithSubmissionToken(cancelOp, submissionTokens[4], v3, r3, s3); + aliceWallet.executeQuarkOperationWithSubmissionToken(cancelOp, submissionTokens[4], signature3); // 5. Warp until next swap period vm.warp(block.timestamp + SWAP_WINDOW_INTERVAL); @@ -538,13 +538,13 @@ contract RecurringSwapTest is Test { QuarkNonceManager.NonReplayableNonce.selector, address(aliceWallet), op1.nonce, submissionTokens[4] ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op1, submissionTokens[4], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op1, submissionTokens[4], signature1); vm.expectRevert( abi.encodeWithSelector( QuarkNonceManager.NonReplayableNonce.selector, address(aliceWallet), op2.nonce, submissionTokens[5] ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[5], v2, r2, s2); + aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[5], signature2); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap1 + 2 * amountToSwap2); } @@ -571,14 +571,14 @@ contract RecurringSwapTest is Test { 2 ); op.expiry = type(uint256).max; - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1. Execute recurring swap for the first time - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); @@ -586,7 +586,7 @@ contract RecurringSwapTest is Test { vm.warp(block.timestamp + 10 * SWAP_WINDOW_INTERVAL); // 3. Execute recurring swap a second time - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap); @@ -599,7 +599,7 @@ contract RecurringSwapTest is Test { block.timestamp ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap); } @@ -647,16 +647,16 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, invalidSwapConfig2), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op2); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op2); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(RecurringSwap.InvalidInput.selector); - aliceWallet.executeQuarkOperation(op1, v1, r1, s1); + aliceWallet.executeQuarkOperation(op1, signature1); vm.expectRevert(RecurringSwap.InvalidInput.selector); - aliceWallet.executeQuarkOperation(op2, v2, r2, s2); + aliceWallet.executeQuarkOperation(op2, signature2); } function testRevertsForSwapBeforeNextSwapWindow() public { @@ -680,14 +680,14 @@ contract RecurringSwapTest is Test { ScriptType.ScriptAddress, 1 ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1. Execute recurring swap for the first time - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); @@ -700,7 +700,7 @@ contract RecurringSwapTest is Test { block.timestamp ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); } @@ -728,20 +728,20 @@ contract RecurringSwapTest is Test { 2 ); op.expiry = type(uint256).max; - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); // 1. Execute recurring swap for the first time - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), amountToSwap); // 2. Warp a window into the future and execute a second swap vm.warp(block.timestamp + SWAP_WINDOW_INTERVAL); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[1], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap); @@ -753,7 +753,7 @@ contract RecurringSwapTest is Test { RecurringSwap.SwapWindowClosed.selector, lastWindowStart, windowLength, block.timestamp ) ); - aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], v1, r1, s1); + aliceWallet.executeQuarkOperationWithSubmissionToken(op, submissionTokens[2], signature1); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 2 * amountToSwap); } @@ -777,7 +777,7 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); @@ -787,7 +787,7 @@ contract RecurringSwapTest is Test { RecurringSwap.SwapWindowNotOpen.selector, block.timestamp + 100, SWAP_WINDOW_LENGTH, block.timestamp ) ); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); } function testRevertsForExpiredQuarkOperation() public { @@ -810,12 +810,12 @@ contract RecurringSwapTest is Test { ScriptType.ScriptAddress ); op.expiry = block.timestamp - 1; // Set Quark operation expiry to always expire - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(QuarkWallet.SignatureExpired.selector); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); } function testRevertsWhenSlippageTooHigh() public { @@ -843,14 +843,14 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(bytes("Too little received")); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); } function testRevertsWhenSlippageParamsConfiguredWrong() public { @@ -878,14 +878,14 @@ contract RecurringSwapTest is Test { abi.encodeWithSelector(RecurringSwap.swap.selector, swapConfig), ScriptType.ScriptAddress ); - (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); + bytes memory signature1 = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); assertEq(IERC20(WETH).balanceOf(address(aliceWallet)), 0 ether); // gas: meter execute vm.resumeGasMetering(); vm.expectRevert(bytes("Too little received")); - aliceWallet.executeQuarkOperation(op, v1, r1, s1); + aliceWallet.executeQuarkOperation(op, signature1); } /* ===== helper functions ===== */ diff --git a/test/TransferActions.t.sol b/test/TransferActions.t.sol index 40aac16..8381b98 100644 --- a/test/TransferActions.t.sol +++ b/test/TransferActions.t.sol @@ -72,9 +72,9 @@ contract TransferActionsTest is Test { ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(IERC20(WETH).balanceOf(bob), 10 ether); } @@ -93,9 +93,9 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(TransferActions.transferERC20Token.selector, WETH, address(walletBob), 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(IERC20(WETH).balanceOf(address(walletBob)), 10 ether); } @@ -114,9 +114,9 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(TransferActions.transferNativeToken.selector, bob, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // assert on native ETH balance assertEq(address(wallet).balance, 0 ether); assertEq(bob.balance, 10 ether); @@ -133,11 +133,11 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(TransferActions.transferNativeToken.selector, address(walletBob), 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(address(wallet).balance, 10 ether); assertEq(address(walletBob).balance, 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // assert on native ETH balance assertEq(address(wallet).balance, 0 ether); assertEq(address(walletBob).balance, 10 ether); @@ -169,12 +169,12 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(address(wallet).balance, 7 ether); assertEq(address(evilReceiver).balance, 3 ether); } @@ -209,12 +209,12 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // Attacker successfully transfers 3 eth by exploiting reentrancy in 1eth transfers assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 7 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 3 ether); @@ -246,12 +246,12 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(address(wallet).balance, 9 ether); assertEq(address(evilReceiver).balance, 1 ether); } @@ -286,12 +286,12 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 9 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 1 ether); } @@ -321,7 +321,7 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); @@ -336,7 +336,7 @@ contract TransferActionsTest is Test { ) ) ); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); } @@ -370,7 +370,7 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(Multicall.run.selector, callContracts, callDatas), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 0 ether); @@ -383,7 +383,7 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(QuarkScript.ReentrantCall.selector) ) ); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(victimERC777).balanceOf(address(wallet)), 10 ether); assertEq(IERC20(victimERC777).balanceOf(address(evilReceiver)), 0 ether); } @@ -402,7 +402,7 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(TransferActions.transferNativeToken.selector, address(evilReceiver), 1 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); @@ -413,7 +413,7 @@ contract TransferActionsTest is Test { ) ); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); } @@ -432,8 +432,8 @@ contract TransferActionsTest is Test { abi.encodeWithSelector(TransferActions.transferNativeToken.selector, address(evilReceiver), 1 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); - evilReceiver.stealSignature(EvilReceiver.StolenSignature(op, v, r, s)); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + evilReceiver.stealSignature(EvilReceiver.StolenSignature(op, signature)); assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); @@ -447,7 +447,7 @@ contract TransferActionsTest is Test { ) ) ); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // assert on native ETH balance assertEq(address(wallet).balance, 10 ether); assertEq(address(evilReceiver).balance, 0 ether); diff --git a/test/UniswapFlashLoan.t.sol b/test/UniswapFlashLoan.t.sol index b894cb1..9c35a4b 100644 --- a/test/UniswapFlashLoan.t.sol +++ b/test/UniswapFlashLoan.t.sol @@ -177,9 +177,9 @@ contract UniswapFlashLoanTest is Test { ), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // Verify that user now has no WETH collateral on Comet, but only LINK assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 0); @@ -214,10 +214,10 @@ contract UniswapFlashLoanTest is Test { ), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(UniswapFlashLoan.InvalidCaller.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testRevertsForInsufficientFundsToRepayFlashLoan() public { @@ -243,10 +243,10 @@ contract UniswapFlashLoanTest is Test { abi.encodeWithSelector(UniswapFlashLoan.run.selector, payload), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert("ERC20: transfer amount exceeds balance"); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testTokensOrderInvariant() public { @@ -274,8 +274,8 @@ contract UniswapFlashLoanTest is Test { ), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); - wallet.executeQuarkOperation(op, v, r, s); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + wallet.executeQuarkOperation(op, signature); // Lose 1 USDC to flash loan fee assertEq(IERC20(USDC).balanceOf(address(wallet)), 9999e6); @@ -302,9 +302,9 @@ contract UniswapFlashLoanTest is Test { ), ScriptType.ScriptAddress ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); // Lose 1 USDC to flash loan fee assertEq(IERC20(USDC).balanceOf(address(wallet)), 9998e6); diff --git a/test/UniswapFlashSwapExactOut.t.sol b/test/UniswapFlashSwapExactOut.t.sol index cca5e46..4db67c9 100644 --- a/test/UniswapFlashSwapExactOut.t.sol +++ b/test/UniswapFlashSwapExactOut.t.sol @@ -108,9 +108,9 @@ contract UniswapFlashSwapExactOutTest is Test { abi.encodeWithSelector(UniswapFlashSwapExactOut.run.selector, payload), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); // Verify that user is now supplying 10 + 1 WETH assertEq(IComet(comet).collateralBalanceOf(address(wallet), WETH), 11 ether); @@ -143,10 +143,10 @@ contract UniswapFlashSwapExactOutTest is Test { ), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert(abi.encodeWithSelector(UniswapFlashSwapExactOut.InvalidCaller.selector)); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testNotEnoughToPayFlashSwap() public { @@ -187,10 +187,10 @@ contract UniswapFlashSwapExactOutTest is Test { abi.encodeWithSelector(UniswapFlashSwapExactOut.run.selector, payload), ScriptType.ScriptAddress ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.expectRevert("ERC20: transfer amount exceeds balance"); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); } function testRevertsIfCalledDirectly() public { diff --git a/test/UniswapSwapActions.t.sol b/test/UniswapSwapActions.t.sol index b7e6102..b509599 100644 --- a/test/UniswapSwapActions.t.sol +++ b/test/UniswapSwapActions.t.sol @@ -73,10 +73,10 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); // gas: meter execute vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); uint256 wethBalance = IERC20(WETH).balanceOf(address(wallet)); uint256 usdcBalance = IERC20(USDC).balanceOf(address(wallet)); @@ -102,9 +102,9 @@ contract UniswapSwapActionsTest is Test { ScriptType.ScriptSource ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); assertEq(IERC20(WETH).balanceOf(address(wallet)), wethBalance + 1 ether); assertGe(IERC20(USDC).balanceOf(address(wallet)), usdcBalance - 2000e6); } @@ -133,9 +133,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); uint256 compBalance = IERC20(COMP).balanceOf(address(wallet)); uint256 usdcBalance = IERC20(USDC).balanceOf(address(wallet)); assertGe(compBalance, 40e18); @@ -159,9 +159,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); assertEq(IERC20(COMP).balanceOf(address(wallet)), compBalance + 40e18); assertGe(IERC20(USDC).balanceOf(address(wallet)), usdcBalance - 2000e6); } @@ -190,9 +190,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); uint256 wethBalance = IERC20(WETH).balanceOf(address(wallet)); uint256 usdcBalance = IERC20(USDC).balanceOf(address(wallet)); assertEq(wethBalance, 1 ether); @@ -215,9 +215,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); assertGe(IERC20(WETH).balanceOf(address(wallet)), 0); assertEq(IERC20(USDC).balanceOf(address(wallet)), usdcBalance + 1600e6); } @@ -246,9 +246,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); uint256 compBalance = IERC20(COMP).balanceOf(address(wallet)); uint256 usdcBalance = IERC20(USDC).balanceOf(address(wallet)); assertEq(compBalance, 50e18); @@ -271,9 +271,9 @@ contract UniswapSwapActionsTest is Test { ), ScriptType.ScriptSource ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); assertGe(IERC20(COMP).balanceOf(address(wallet)), 0); assertEq(IERC20(USDC).balanceOf(address(wallet)), usdcBalance + 1500e6); } @@ -305,9 +305,9 @@ contract UniswapSwapActionsTest is Test { ScriptType.ScriptSource ); - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); + bytes memory signature2 = new SignatureHelper().signOp(alicePrivateKey, wallet, op2); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op2, v2, r2, s2); + wallet.executeQuarkOperation(op2, signature2); assertEq(IERC20(WETH).balanceOf(address(wallet)), wethBalance + 1 ether); assertGe(IERC20(USDC).balanceOf(address(wallet)), usdcBalance - 2000e6); assertEq(IERC20(USDC).allowance(address(wallet), uniswapRouter), 0); diff --git a/test/WrapperScripts.t.sol b/test/WrapperScripts.t.sol index 4adc574..320f577 100644 --- a/test/WrapperScripts.t.sol +++ b/test/WrapperScripts.t.sol @@ -55,12 +55,12 @@ contract WrapperScriptsTest is Test { abi.encodeWithSelector(WrapperActions.wrapETH.selector, WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(address(wallet).balance, 10 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(address(wallet).balance, 0 ether); } @@ -77,12 +77,12 @@ contract WrapperScriptsTest is Test { abi.encodeWithSelector(WrapperActions.unwrapWETH.selector, WETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(WETH).balanceOf(address(wallet)), 10 ether); assertEq(address(wallet).balance, 0 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(WETH).balanceOf(address(wallet)), 0 ether); assertEq(address(wallet).balance, 10 ether); } @@ -104,12 +104,12 @@ contract WrapperScriptsTest is Test { abi.encodeWithSelector(WrapperActions.wrapLidoStETH.selector, wstETH, stETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 0 ether); assertApproxEqAbs(IERC20(stETH).balanceOf(address(wallet)), 10 ether, 0.01 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertEq(IERC20(stETH).balanceOf(address(wallet)), 0 ether); assertApproxEqAbs(IERC20(wstETH).balanceOf(address(wallet)), 8.74 ether, 0.01 ether); } @@ -126,12 +126,12 @@ contract WrapperScriptsTest is Test { abi.encodeWithSelector(WrapperActions.unwrapLidoWstETH.selector, wstETH, 10 ether), ScriptType.ScriptSource ); - (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, wallet, op); + bytes memory signature = new SignatureHelper().signOp(alicePrivateKey, wallet, op); assertEq(IERC20(stETH).balanceOf(address(wallet)), 0 ether); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 10 ether); vm.resumeGasMetering(); - wallet.executeQuarkOperation(op, v, r, s); + wallet.executeQuarkOperation(op, signature); assertApproxEqAbs(IERC20(stETH).balanceOf(address(wallet)), 11.44 ether, 0.01 ether); assertEq(IERC20(wstETH).balanceOf(address(wallet)), 0 ether); } diff --git a/test/lib/AllowCallbacks.sol b/test/lib/AllowCallbacks.sol index 296b5c8..5fd45c4 100644 --- a/test/lib/AllowCallbacks.sol +++ b/test/lib/AllowCallbacks.sol @@ -13,6 +13,6 @@ contract AllowCallbacks is QuarkScript { } function clear() public { - clearCallback(); + disallowCallback(); } } diff --git a/test/lib/CallcodeReentrancy.sol b/test/lib/CallcodeReentrancy.sol index 9346864..e08b114 100644 --- a/test/lib/CallcodeReentrancy.sol +++ b/test/lib/CallcodeReentrancy.sol @@ -23,11 +23,10 @@ contract ExploitableScript is QuarkScript, CallbackReceiver { return result; } - // protected by `onlyWallet`, but still susceptible to recursive re-entrancy due to using `delegatecall` function callMeBackDelegateCall(address target, bytes calldata call, uint256 fee) external payable - onlyWallet + nonReentrant returns (bytes memory) { allowCallback(); @@ -56,7 +55,7 @@ contract ProtectedScript is QuarkScript, CallbackReceiver { function callMeBack(address target, bytes calldata call, uint256 fee) external payable - onlyWallet + nonReentrant returns (bytes memory) { allowCallback(); diff --git a/test/lib/EvilReceiver.sol b/test/lib/EvilReceiver.sol index 1a0e4f4..7c00bf3 100644 --- a/test/lib/EvilReceiver.sol +++ b/test/lib/EvilReceiver.sol @@ -21,9 +21,7 @@ contract EvilReceiver { struct StolenSignature { QuarkWallet.QuarkOperation op; - uint8 v; - bytes32 r; - bytes32 s; + bytes signature; } uint256 public loop = 1; @@ -57,9 +55,7 @@ contract EvilReceiver { } if (attack.attackType == AttackType.STOLEN_SIGNATURE) { - QuarkWallet(payable(msg.sender)).executeQuarkOperation( - stolenSignature.op, stolenSignature.v, stolenSignature.r, stolenSignature.s - ); + QuarkWallet(payable(msg.sender)).executeQuarkOperation(stolenSignature.op, stolenSignature.signature); } } } diff --git a/test/lib/SignatureHelper.sol b/test/lib/SignatureHelper.sol index 070e426..2d7e4ce 100644 --- a/test/lib/SignatureHelper.sol +++ b/test/lib/SignatureHelper.sol @@ -5,13 +5,16 @@ import "forge-std/Test.sol"; import "quark-core/src/QuarkWallet.sol"; contract SignatureHelper is Test { + error InvalidSignatureLength(); + function signOp(uint256 privateKey, QuarkWallet wallet, QuarkWallet.QuarkOperation memory op) external view - returns (uint8, bytes32, bytes32) + returns (bytes memory) { bytes32 digest = opDigest(address(wallet), op); - return vm.sign(privateKey, digest); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest); + return abi.encodePacked(r, s, v); } /* @@ -20,19 +23,28 @@ contract SignatureHelper is Test { function signOpForAddress(uint256 privateKey, address walletAddress, QuarkWallet.QuarkOperation memory op) external view - returns (uint8, bytes32, bytes32) + returns (bytes memory) { bytes32 digest = opDigest(walletAddress, op); - return vm.sign(privateKey, digest); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest); + return abi.encodePacked(r, s, v); } - function signMultiOp(uint256 privateKey, bytes32[] memory opDigests) - external - pure - returns (uint8, bytes32, bytes32) - { + function signMultiOp(uint256 privateKey, bytes32[] memory opDigests) external pure returns (bytes memory) { bytes32 digest = multiOpDigest(opDigests); - return vm.sign(privateKey, digest); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest); + return abi.encodePacked(r, s, v); + } + + function decodeSignature(bytes memory signature) external pure returns (uint8 v, bytes32 r, bytes32 s) { + if (signature.length != 65) { + revert InvalidSignatureLength(); + } + assembly { + r := mload(add(signature, 0x20)) + s := mload(add(signature, 0x40)) + v := byte(0, mload(add(signature, 0x60))) + } } function opDigest(address walletAddress, QuarkWallet.QuarkOperation memory op) public view returns (bytes32) {