From 74de3c5c7909dcab11f2c01f2b9275cf1608b657 Mon Sep 17 00:00:00 2001 From: Filipp Makarov Date: Tue, 5 Nov 2024 20:42:39 +0300 Subject: [PATCH] fix maxPenalty --- contracts/token/BiconomyTokenPaymaster.sol | 4 +++- test/base/TestBase.sol | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contracts/token/BiconomyTokenPaymaster.sol b/contracts/token/BiconomyTokenPaymaster.sol index 094cb30..1f6777b 100644 --- a/contracts/token/BiconomyTokenPaymaster.sol +++ b/contracts/token/BiconomyTokenPaymaster.sol @@ -491,7 +491,9 @@ contract BiconomyTokenPaymaster is // Transfer full amount to this address. Unused amount will be refunded in postOP SafeTransferLib.safeTransferFrom(tokenAddress, userOp.sender, address(this), tokenAmount); - context = abi.encode(userOp.sender, tokenAddress, tokenAmount, tokenPrice, externalPriceMarkup, userOpHash); + console2.log("max pnalty in validatePaymasterUserOp", maxPenalty); + + context = abi.encode(userOp.sender, tokenAddress, tokenAmount-maxPenalty, tokenPrice, externalPriceMarkup, userOpHash); validationData = _packValidationData(false, validUntil, validAfter); } else if (mode == PaymasterMode.INDEPENDENT) { // Use only oracles for the token specified in modeSpecificData diff --git a/test/base/TestBase.sol b/test/base/TestBase.sol index ba15ec1..3cf2fa4 100644 --- a/test/base/TestBase.sol +++ b/test/base/TestBase.sol @@ -471,6 +471,7 @@ abstract contract TestBase is CheatCodes, TestHelper, BaseEventsAndErrors { console2.log("gasCollectedInERC20ByPaymaster", gasCollectedInERC20ByPaymaster); console2.log("maxPenalty", maxPenalty); console2.log("totalGasFeePaid", totalGasFeePaid); + console2.log(uint256(1226028000000) + uint256(1794876000000)); // Note: yet to figure out why we're charging too low in tokens vs bundler is paying high gas fees! // Review we will also need to update premium numbers in below if there is premium: multiply by 1e6 / premium @@ -499,3 +500,13 @@ abstract contract TestBase is CheatCodes, TestHelper, BaseEventsAndErrors { return array; } } +/* +1226028000000 +1794876000000 + +2921664000000 +3020904000000 + +1800000000000 max penalty + +*/ \ No newline at end of file