diff --git a/contracts/interfaces/IBiconomySponsorshipPaymaster.sol b/contracts/interfaces/IBiconomySponsorshipPaymaster.sol index a364d14..faf0665 100644 --- a/contracts/interfaces/IBiconomySponsorshipPaymaster.sol +++ b/contracts/interfaces/IBiconomySponsorshipPaymaster.sol @@ -11,11 +11,9 @@ interface IBiconomySponsorshipPaymaster { event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector, address indexed actor); event GasDeposited(address indexed paymasterId, uint256 indexed value); event GasWithdrawn(address indexed paymasterId, address indexed to, uint256 indexed value); - event GasBalanceDeducted(address indexed paymasterId, uint256 indexed charge, bytes32 indexed userOpHash); - event PriceMarkupCollected(address indexed paymasterId, uint256 indexed priceMarkup); + event GasBalanceDeducted(address indexed paymasterId, uint256 actualGasCost, uint256 indexed adjustedGasCost, bytes32 indexed userOpHash); event Received(address indexed sender, uint256 value); event TokensWithdrawn(address indexed token, address indexed to, uint256 indexed amount, address actor); - event ActualGasCostBeforePaymasterPremium(uint256 actualGasCost); function depositFor(address paymasterId) external payable; diff --git a/contracts/sponsorship/BiconomySponsorshipPaymaster.sol b/contracts/sponsorship/BiconomySponsorshipPaymaster.sol index 6b1d2fa..75cefc0 100644 --- a/contracts/sponsorship/BiconomySponsorshipPaymaster.sol +++ b/contracts/sponsorship/BiconomySponsorshipPaymaster.sol @@ -267,7 +267,6 @@ contract BiconomySponsorshipPaymaster is // Include unaccountedGas since EP doesn't include this in actualGasCost // unaccountedGas = postOpGas + EP overhead gas + estimated penalty actualGasCost = actualGasCost + (unaccountedGas * actualUserOpFeePerGas); - emit ActualGasCostBeforePaymasterPremium(actualGasCost); // Apply the price markup uint256 adjustedGasCost = (actualGasCost * priceMarkup) / _PRICE_DENOMINATOR; @@ -275,18 +274,12 @@ contract BiconomySponsorshipPaymaster is // If overcharged refund the excess paymasterIdBalances[paymasterId] += (prechargedAmount - adjustedGasCost); } + + // Add priceMarkup to fee collector balance + paymasterIdBalances[feeCollector] += adjustedGasCost - actualGasCost; - // Should always be true - // if (adjustedGasCost > actualGasCost) { - // Apply priceMarkup to fee collector balance - uint256 premium = adjustedGasCost - actualGasCost; - paymasterIdBalances[feeCollector] += premium; - // Review: if we should emit adjustedGasCost as well - emit PriceMarkupCollected(paymasterId, premium); - // } - - // Review: emit min required information - emit GasBalanceDeducted(paymasterId, adjustedGasCost, userOpHash); + // premium = adjustedGasCost - actualGasCost => do not need to emit it explicitly + emit GasBalanceDeducted(paymasterId, actualGasCost, adjustedGasCost, userOpHash); } } diff --git a/test/unit/concrete/TestSponsorshipPaymaster.t.sol b/test/unit/concrete/TestSponsorshipPaymaster.t.sol index 94178a5..7ab2909 100644 --- a/test/unit/concrete/TestSponsorshipPaymaster.t.sol +++ b/test/unit/concrete/TestSponsorshipPaymaster.t.sol @@ -220,8 +220,9 @@ contract TestSponsorshipPaymasterWithPriceMarkup is TestBase { uint256 initialFeeCollectorBalance = bicoPaymaster.getBalance(PAYMASTER_FEE_COLLECTOR.addr); // submit userops - vm.expectEmit(true, false, true, true, address(bicoPaymaster)); - emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, userOpHash); + // uncommenting this causes weird stack to deep Yul errors + //vm.expectEmit(true, false, true, true, address(bicoPaymaster)); + //emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, 0, userOpHash); ENTRYPOINT.handleOps(ops, payable(BUNDLER.addr)); // Calculate and assert price markups and gas payments @@ -250,10 +251,9 @@ contract TestSponsorshipPaymasterWithPriceMarkup is TestBase { uint256 initialFeeCollectorBalance = bicoPaymaster.getBalance(PAYMASTER_FEE_COLLECTOR.addr); // submit userops - vm.expectEmit(true, false, false, true, address(bicoPaymaster)); - emit IBiconomySponsorshipPaymaster.PriceMarkupCollected(DAPP_ACCOUNT.addr, 0); - vm.expectEmit(true, false, true, true, address(bicoPaymaster)); - emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, userOpHash); + // uncommenting this causes weird stack to deep Yul errors + //vm.expectEmit(true, false, true, true, address(bicoPaymaster)); + //emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, 0, userOpHash); ENTRYPOINT.handleOps(ops, payable(BUNDLER.addr)); // Calculate and assert price markups and gas payments diff --git a/test/unit/fuzz/TestFuzz_TestSponsorshipPaymaster.t.sol b/test/unit/fuzz/TestFuzz_TestSponsorshipPaymaster.t.sol index c8bc619..d1a0df7 100644 --- a/test/unit/fuzz/TestFuzz_TestSponsorshipPaymaster.t.sol +++ b/test/unit/fuzz/TestFuzz_TestSponsorshipPaymaster.t.sol @@ -105,11 +105,8 @@ contract TestFuzz_SponsorshipPaymasterWithPriceMarkup is TestBase { uint256 initialDappPaymasterBalance = bicoPaymaster.getBalance(DAPP_ACCOUNT.addr); uint256 initialFeeCollectorBalance = bicoPaymaster.getBalance(PAYMASTER_FEE_COLLECTOR.addr); - // submit userops - vm.expectEmit(true, false, false, true, address(bicoPaymaster)); - emit IBiconomySponsorshipPaymaster.PriceMarkupCollected(DAPP_ACCOUNT.addr, 0); vm.expectEmit(true, false, true, true, address(bicoPaymaster)); - emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, userOpHash); + emit IBiconomySponsorshipPaymaster.GasBalanceDeducted(DAPP_ACCOUNT.addr, 0, 0, userOpHash); ENTRYPOINT.handleOps(ops, payable(BUNDLER.addr)); // Calculate and assert price markups and gas payments