-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Filipp Makarov
authored and
Filipp Makarov
committed
Oct 22, 2024
1 parent
146929a
commit 344384f
Showing
2 changed files
with
60 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; | ||
import { IBiconomySponsorshipPaymaster } from "../interfaces/IBiconomySponsorshipPaymaster.sol"; | ||
|
||
import "forge-std/console2.sol"; | ||
|
||
/** | ||
* @title BiconomySponsorshipPaymaster | ||
* @author livingrockrises<[email protected]> | ||
|
@@ -190,6 +192,7 @@ contract BiconomySponsorshipPaymaster is | |
revert RequestNotClearedYet(clearanceTimestamp); | ||
uint256 currentBalance = paymasterIdBalances[paymasterId]; | ||
req.amount = req.amount > currentBalance ? currentBalance : req.amount; | ||
if(req.amount == 0) revert CanNotWithdrawZeroAmount(); | ||
paymasterIdBalances[paymasterId] = currentBalance - req.amount; | ||
delete requests[paymasterId]; | ||
entryPoint.withdrawTo(payable(req.to), req.amount); | ||
|
@@ -319,9 +322,11 @@ contract BiconomySponsorshipPaymaster is | |
|
||
if (prechargedAmount > adjustedGasCost) { | ||
// If overcharged refund the excess | ||
console2.log("overcharged ", prechargedAmount - adjustedGasCost); | ||
paymasterIdBalances[paymasterId] += (prechargedAmount - adjustedGasCost); | ||
} else { | ||
// deduct what needs to be deducted from paymasterId | ||
console2.log("undercharged ", (adjustedGasCost - prechargedAmount)); | ||
paymasterIdBalances[paymasterId] -= (adjustedGasCost - prechargedAmount); | ||
} | ||
// here adjustedGasCost does not account for gasPenalty. prechargedAmount accounts for penalty with maxGasPenalty | ||
|
@@ -386,6 +391,8 @@ contract BiconomySponsorshipPaymaster is | |
uint128(bytes16(userOp.paymasterAndData[_PAYMASTER_POSTOP_GAS_OFFSET : _PAYMASTER_DATA_OFFSET])) | ||
) * 10 * userOp.unpackMaxFeePerGas() / 100; | ||
|
||
console2.log("max penalty ", maxPenalty); | ||
|
||
// Deduct the max gas cost. | ||
uint256 effectiveCost = | ||
((requiredPreFund + unaccountedGas * userOp.unpackMaxFeePerGas()) * priceMarkup / _PRICE_DENOMINATOR); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters