From 574d131976a56c15fff1482754df081489708b48 Mon Sep 17 00:00:00 2001 From: Filipp Makarov Date: Thu, 12 Dec 2024 16:23:14 +0300 Subject: [PATCH] new salts --- .../bash-deploy/artifacts/BiconomyTokenPaymaster/verify.json | 1 + scripts/foundry/DeployGasdaddy.s.sol | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 scripts/bash-deploy/artifacts/BiconomyTokenPaymaster/verify.json diff --git a/scripts/bash-deploy/artifacts/BiconomyTokenPaymaster/verify.json b/scripts/bash-deploy/artifacts/BiconomyTokenPaymaster/verify.json new file mode 100644 index 0000000..49cb037 --- /dev/null +++ b/scripts/bash-deploy/artifacts/BiconomyTokenPaymaster/verify.json @@ -0,0 +1 @@ +{"language":"Solidity","sources":{"contracts/token/BiconomyTokenPaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.27;\n\nimport { ReentrancyGuardTransient } from \"@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol\";\nimport { IEntryPoint } from \"account-abstraction/interfaces/IEntryPoint.sol\";\nimport { PackedUserOperation, UserOperationLib } from \"account-abstraction/core/UserOperationLib.sol\";\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport { SafeTransferLib } from \"solady/utils/SafeTransferLib.sol\";\nimport { BasePaymaster } from \"../base/BasePaymaster.sol\";\nimport { BiconomyTokenPaymasterErrors } from \"../common/BiconomyTokenPaymasterErrors.sol\";\nimport { IBiconomyTokenPaymaster } from \"../interfaces/IBiconomyTokenPaymaster.sol\";\nimport { IOracle } from \"../interfaces/oracles/IOracle.sol\";\nimport { TokenPaymasterParserLib } from \"../libraries/TokenPaymasterParserLib.sol\";\nimport { SignatureCheckerLib } from \"solady/utils/SignatureCheckerLib.sol\";\nimport { ECDSA as ECDSA_solady } from \"solady/utils/ECDSA.sol\";\nimport { Uniswapper, IV3SwapRouter } from \"./swaps/Uniswapper.sol\";\nimport \"account-abstraction/core/Helpers.sol\";\n\n/**\n * @title BiconomyTokenPaymaster\n * @author ShivaanshK\n * @author livingrockrises\n * @notice Biconomy's Token Paymaster for Entry Point v0.7\n * @dev A paymaster that allows users to pay gas fees in ERC20 tokens. The paymaster uses the precharge and refund\n * model\n * to handle gas remittances.\n *\n * Currently, the paymaster supports two modes:\n * 1. EXTERNAL - Relies on a quoted token price from a trusted entity (verifyingSigner).\n * 2. INDEPENDENT - Relies purely on price oracles (Chainlink and TWAP) which implement the IOracle interface. This mode\n * doesn't require a signature and is \"always available\" to use.\n *\n * The paymaster's owner has full discretion over the supported tokens (for independent mode), price adjustments\n * applied, and how\n * to manage the assets received by the paymaster.\n */\ncontract BiconomyTokenPaymaster is\n IBiconomyTokenPaymaster,\n BasePaymaster,\n ReentrancyGuardTransient,\n BiconomyTokenPaymasterErrors,\n Uniswapper\n{\n using UserOperationLib for PackedUserOperation;\n using TokenPaymasterParserLib for bytes;\n using SignatureCheckerLib for address;\n\n // State variables\n address public verifyingSigner; // entity used to provide external token price and markup\n uint256 public unaccountedGas;\n IOracle public nativeAssetToUsdOracle; // ETH -> USD price oracle\n mapping(address => TokenInfo) public independentTokenDirectory; // mapping of token address => info for tokens\n uint256 private constant _UNACCOUNTED_GAS_LIMIT = 200_000; // Limit for unaccounted gas cost\n uint32 private constant _PRICE_DENOMINATOR = 1e6; // Denominator used when calculating cost with price markup\n uint32 private constant _MAX_PRICE_MARKUP = 2e6; // 100% premium on price (2e6/PRICE_DENOMINATOR)\n uint256 private immutable _NATIVE_TOKEN_DECIMALS; // gas savings\n uint256 private immutable _NATIVE_ASSET_PRICE_EXPIRY_DURATION; // gas savings\n\n /**\n * @dev markup and expiry duration are provided for each token.\n * Price expiry duration should be set to the heartbeat value of the token. \n * Additionally, priceMarkup must be higher than Chainlink’s deviation threshold value.\n * More: https://docs.chain.link/architecture-overview/architecture-decentralized-model \n */\n\n constructor(\n address owner,\n address verifyingSignerArg,\n IEntryPoint entryPoint,\n uint256 unaccountedGasArg,\n uint256 nativeAssetDecimalsArg,\n IOracle nativeAssetToUsdOracleArg,\n uint256 nativeAssetPriceExpiryDurationArg,\n IV3SwapRouter uniswapRouterArg,\n address wrappedNativeArg,\n address[] memory independentTokensArg, // Array of tokens supported in independent mode\n TokenInfo[] memory tokenInfosArg, // Array of corresponding tokenInfo objects\n address[] memory swappableTokens, // Array of tokens that you want swappable by the uniswapper\n uint24[] memory swappableTokenPoolFeeTiers // Array of uniswap pool fee tiers for each swappable token\n )\n BasePaymaster(owner, entryPoint)\n Uniswapper(uniswapRouterArg, wrappedNativeArg, swappableTokens, swappableTokenPoolFeeTiers)\n {\n _NATIVE_TOKEN_DECIMALS = nativeAssetDecimalsArg;\n _NATIVE_ASSET_PRICE_EXPIRY_DURATION = nativeAssetPriceExpiryDurationArg;\n\n if (_isContract(verifyingSignerArg)) {\n revert VerifyingSignerCanNotBeContract();\n }\n if (verifyingSignerArg == address(0)) {\n revert VerifyingSignerCanNotBeZero();\n }\n if (unaccountedGasArg > _UNACCOUNTED_GAS_LIMIT) {\n revert UnaccountedGasTooHigh();\n }\n\n if (independentTokensArg.length != tokenInfosArg.length) {\n revert TokensAndInfoLengthMismatch();\n }\n if (nativeAssetToUsdOracleArg.decimals() != 8) {\n // ETH -> USD will always have 8 decimals for Chainlink and TWAP\n revert InvalidOracleDecimals();\n }\n\n // Set state variables\n assembly (\"memory-safe\") {\n sstore(verifyingSigner.slot, verifyingSignerArg)\n sstore(unaccountedGas.slot, unaccountedGasArg)\n sstore(nativeAssetToUsdOracle.slot, nativeAssetToUsdOracleArg)\n }\n\n for (uint256 i = 0; i < independentTokensArg.length; i++) {\n _validateTokenInfo(tokenInfosArg[i]);\n independentTokenDirectory[independentTokensArg[i]] = tokenInfosArg[i]; \n }\n }\n\n receive() external payable {\n // no need to emit an event here\n }\n\n /**\n * @dev pull tokens out of paymaster in case they were sent to the paymaster at any point.\n * @param token the token deposit to withdraw\n * @param target address to send to\n * @param amount amount to withdraw\n */\n function withdrawERC20(IERC20 token, address target, uint256 amount) external payable onlyOwner nonReentrant {\n _withdrawERC20(token, target, amount);\n }\n\n /**\n * @dev Withdraw ETH from the paymaster\n * @param recipient The address to send the ETH to\n * @param amount The amount of ETH to withdraw\n */\n function withdrawEth(address payable recipient, uint256 amount) external payable onlyOwner nonReentrant {\n (bool success,) = recipient.call{ value: amount }(\"\");\n if (!success) {\n revert WithdrawalFailed();\n }\n emit EthWithdrawn(recipient, amount);\n }\n\n /**\n * @dev pull tokens out of paymaster in case they were sent to the paymaster at any point.\n * @param token the token deposit to withdraw\n * @param target address to send to\n */\n function withdrawERC20Full(IERC20 token, address target) external payable onlyOwner nonReentrant {\n uint256 amount = token.balanceOf(address(this));\n _withdrawERC20(token, target, amount);\n }\n\n /**\n * @dev pull multiple tokens out of paymaster in case they were sent to the paymaster at any point.\n * @param token the tokens deposit to withdraw\n * @param target address to send to\n * @param amount amounts to withdraw\n */\n function withdrawMultipleERC20(\n IERC20[] calldata token,\n address target,\n uint256[] calldata amount\n )\n external\n payable\n onlyOwner\n nonReentrant\n {\n if (token.length != amount.length) {\n revert TokensAndAmountsLengthMismatch();\n }\n unchecked {\n for (uint256 i; i < token.length;) {\n _withdrawERC20(token[i], target, amount[i]);\n ++i;\n }\n }\n }\n\n /**\n * @dev pull multiple tokens out of paymaster in case they were sent to the paymaster at any point.\n * @param token the tokens deposit to withdraw\n * @param target address to send to\n */\n function withdrawMultipleERC20Full(\n IERC20[] calldata token,\n address target\n )\n external\n payable\n onlyOwner\n nonReentrant\n {\n unchecked {\n for (uint256 i; i < token.length;) {\n uint256 amount = token[i].balanceOf(address(this));\n _withdrawERC20(token[i], target, amount);\n ++i;\n }\n }\n }\n\n /**\n * @dev Set a new verifying signer address.\n * Can only be called by the owner of the contract.\n * @param newVerifyingSigner The new address to be set as the verifying signer.\n * @notice If newVerifyingSigner is set to zero address, it will revert with an error.\n * After setting the new signer address, it will emit an event UpdatedVerifyingSigner.\n */\n function setSigner(address newVerifyingSigner) external payable onlyOwner {\n if (_isContract(newVerifyingSigner)) revert VerifyingSignerCanNotBeContract();\n if (newVerifyingSigner == address(0)) {\n revert VerifyingSignerCanNotBeZero();\n }\n address oldSigner = verifyingSigner;\n assembly (\"memory-safe\") {\n sstore(verifyingSigner.slot, newVerifyingSigner)\n }\n emit UpdatedVerifyingSigner(oldSigner, newVerifyingSigner, msg.sender);\n }\n\n /**\n * @dev Set a new unaccountedEPGasOverhead value.\n * @param newUnaccountedGas The new value to be set as the unaccounted gas value\n * @notice only to be called by the owner of the contract.\n */\n function setUnaccountedGas(uint256 newUnaccountedGas) external payable onlyOwner {\n if (newUnaccountedGas > _UNACCOUNTED_GAS_LIMIT) {\n revert UnaccountedGasTooHigh();\n }\n uint256 oldUnaccountedGas = unaccountedGas;\n assembly (\"memory-safe\") {\n sstore(unaccountedGas.slot, newUnaccountedGas)\n }\n emit UpdatedUnaccountedGas(oldUnaccountedGas, newUnaccountedGas);\n }\n\n /**\n * @dev Set a new priceMarkup value.\n * @param newIndependentPriceMarkup The new value to be set as the price markup\n * @notice only to be called by the owner of the contract.\n */\n function setPriceMarkupForToken(address tokenAddress, uint32 newIndependentPriceMarkup) external payable onlyOwner {\n if (newIndependentPriceMarkup > _MAX_PRICE_MARKUP || newIndependentPriceMarkup < _PRICE_DENOMINATOR) {\n // Not between 0% and 100% markup\n revert InvalidPriceMarkup();\n }\n uint32 oldIndependentPriceMarkup = independentTokenDirectory[tokenAddress].priceMarkup;\n independentTokenDirectory[tokenAddress].priceMarkup = newIndependentPriceMarkup;\n emit UpdatedFixedPriceMarkup(oldIndependentPriceMarkup, newIndependentPriceMarkup);\n }\n\n /**\n * @dev Set a new price expiry duration.\n * @param newPriceExpiryDuration The new value to be set as the price expiry duration\n * @notice only to be called by the owner of the contract.\n */\n function setPriceExpiryDurationForToken(address tokenAddress, uint256 newPriceExpiryDuration) external payable onlyOwner {\n if(block.timestamp < newPriceExpiryDuration) revert InvalidPriceExpiryDuration();\n uint256 oldPriceExpiryDuration = independentTokenDirectory[tokenAddress].priceExpiryDuration;\n independentTokenDirectory[tokenAddress].priceExpiryDuration = newPriceExpiryDuration;\n emit UpdatedPriceExpiryDuration(oldPriceExpiryDuration, newPriceExpiryDuration);\n }\n\n /**\n * @dev Update the native oracle address\n * @param oracle The new native asset oracle\n * @notice only to be called by the owner of the contract.\n */\n function setNativeAssetToUsdOracle(IOracle oracle) external payable onlyOwner {\n if (oracle.decimals() != 8) {\n // Native -> USD will always have 8 decimals\n revert InvalidOracleDecimals();\n }\n\n IOracle oldNativeAssetToUsdOracle = nativeAssetToUsdOracle;\n assembly (\"memory-safe\") {\n sstore(nativeAssetToUsdOracle.slot, oracle)\n }\n\n emit UpdatedNativeAssetOracle(oldNativeAssetToUsdOracle, oracle);\n }\n\n /**\n * @dev Set or update a TokenInfo entry in the independentTokenDirectory mapping.\n * @param tokenAddress The token address to add or update in directory\n * @param tokenInfo The TokenInfo struct to add or update\n * @notice only to be called by the owner of the contract.\n */\n function addToTokenDirectory(address tokenAddress, TokenInfo memory tokenInfo) external payable onlyOwner {\n _validateTokenInfo(tokenInfo);\n\n independentTokenDirectory[tokenAddress] = tokenInfo;\n\n emit AddedToTokenDirectory(tokenAddress, tokenInfo.oracle, IERC20Metadata(tokenAddress).decimals());\n }\n\n /**\n * @dev Remove a token from the independentTokenDirectory mapping.\n * @param tokenAddress The token address to remove from directory\n * @notice only to be called by the owner of the contract.\n */\n function removeFromTokenDirectory(address tokenAddress) external payable onlyOwner {\n delete independentTokenDirectory[tokenAddress];\n emit RemovedFromTokenDirectory(tokenAddress);\n }\n\n /**\n * @dev Update or add a swappable token to the Uniswapper\n * @param tokenAddresses The token address to add/update to/for uniswapper\n * @param poolFeeTiers The pool fee tiers for the corresponding token address to use\n * @notice only to be called by the owner of the contract.\n */\n function updateSwappableTokens(\n address[] memory tokenAddresses,\n uint24[] memory poolFeeTiers\n )\n external\n payable\n onlyOwner\n {\n if (tokenAddresses.length != poolFeeTiers.length) {\n revert TokensAndPoolsLengthMismatch();\n }\n\n for (uint256 i = 0; i < tokenAddresses.length; ++i) {\n _setTokenPool(tokenAddresses[i], poolFeeTiers[i]);\n }\n emit SwappableTokensAdded(tokenAddresses);\n }\n\n /**\n * @dev Swap a token in the paymaster for ETH and deposit the amount received into the entry point\n * @param tokenAddress The token address of the token to swap\n * @param tokenAmount The amount of the token to swap\n * @param minEthAmountRecevied The minimum amount of ETH amount recevied post-swap\n * @notice only to be called by the owner of the contract.\n */\n function swapTokenAndDeposit(\n address tokenAddress,\n uint256 tokenAmount,\n uint256 minEthAmountRecevied\n )\n external\n payable\n nonReentrant\n {\n // Swap tokens for WETH\n uint256 amountOut = _swapTokenToWeth(tokenAddress, tokenAmount, minEthAmountRecevied);\n if(amountOut > 0) {\n // Unwrap WETH to ETH\n _unwrapWeth(amountOut);\n // Deposit ETH into EP\n entryPoint.depositTo{ value: amountOut }(address(this));\n }\n emit TokensSwappedAndRefilledEntryPoint(tokenAddress, tokenAmount, amountOut, msg.sender);\n }\n\n /**\n * Add a deposit in native currency for this paymaster, used for paying for transaction fees.\n * This is ideally done by the entity who is managing the received ERC20 gas tokens.\n */\n function deposit() public payable virtual override nonReentrant {\n entryPoint.depositTo{ value: msg.value }(address(this));\n }\n\n /**\n * @dev Withdraws the specified amount of gas tokens from the paymaster's balance and transfers them to the\n * specified address.\n * @param withdrawAddress The address to which the gas tokens should be transferred.\n * @param amount The amount of gas tokens to withdraw.\n */\n function withdrawTo(address payable withdrawAddress, uint256 amount) public override onlyOwner nonReentrant {\n if (withdrawAddress == address(0)) revert CanNotWithdrawToZeroAddress();\n entryPoint.withdrawTo(withdrawAddress, amount);\n }\n\n function setUniswapRouter(IV3SwapRouter uniswapRouterArg) external onlyOwner {\n _setUniswapRouter(uniswapRouterArg);\n }\n\n /**\n * return the hash we're going to sign off-chain (and validate on-chain)\n * this method is called by the off-chain service, to sign the request.\n * it is called on-chain from the validatePaymasterUserOp, to validate the signature.\n * note that this signature covers all fields of the UserOperation, except the \"paymasterAndData\",\n * which will carry the signature itself.\n */\n function getHash(\n PackedUserOperation calldata userOp,\n uint48 validUntil,\n uint48 validAfter,\n address tokenAddress,\n uint256 tokenPrice,\n uint32 appliedPriceMarkup\n )\n public\n view\n returns (bytes32)\n {\n //can't use userOp.hash(), since it contains also the paymasterAndData itself.\n address sender = userOp.getSender();\n return keccak256(\n abi.encode(\n sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.accountGasLimits,\n uint256(bytes32(userOp.paymasterAndData[_PAYMASTER_VALIDATION_GAS_OFFSET:_PAYMASTER_DATA_OFFSET])),\n userOp.preVerificationGas,\n userOp.gasFees,\n block.chainid,\n address(this),\n validUntil,\n validAfter,\n tokenAddress,\n tokenPrice,\n appliedPriceMarkup\n )\n );\n }\n\n /**\n * @dev Get the price of a token in USD\n * @param tokenAddress The address of the token to get the price of\n * @return price The price of the token in USD\n */\n function getPrice(address tokenAddress) public view returns (uint256) {\n return _getPrice(tokenAddress);\n }\n\n /**\n * @dev Check if a token is supported\n * @param tokenAddress The address of the token to check\n * @return bool True if the token is supported, false otherwise\n */\n function isTokenSupported(address tokenAddress) public view returns (bool) {\n return independentTokenDirectory[tokenAddress].oracle != IOracle(address(0));\n }\n\n /**\n * @dev Get the price markup for a token\n * @param tokenAddress The address of the token to get the price markup of\n * @return priceMarkup The price markup for the token\n */\n function independentPriceMarkup(address tokenAddress) public view returns (uint32) {\n return independentTokenDirectory[tokenAddress].priceMarkup;\n }\n\n /**\n * @dev Get the price expiry duration for a token\n * @param tokenAddress The address of the token to get the price expiry duration of\n * @return priceExpiryDuration The price expiry duration for the token\n */\n function independentPriceExpiryDuration(address tokenAddress) public view returns (uint256) {\n return independentTokenDirectory[tokenAddress].priceExpiryDuration;\n }\n\n /**\n * @dev Validate a user operation.\n * This method is abstract in BasePaymaster and must be implemented in derived contracts.\n * @param userOp The user operation.\n * @param userOpHash The hash of the user operation.\n * @param maxCost The maximum cost of the user operation.\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n )\n internal\n override\n returns (bytes memory context, uint256 validationData)\n {\n (PaymasterMode mode, bytes calldata modeSpecificData) = userOp.paymasterAndData.parsePaymasterAndData();\n\n if (uint8(mode) > 1) {\n revert InvalidPaymasterMode();\n }\n\n uint256 maxPenalty = (\n ( uint128(uint256(userOp.accountGasLimits))\n + uint128(bytes16(userOp.paymasterAndData[_PAYMASTER_POSTOP_GAS_OFFSET:_PAYMASTER_DATA_OFFSET]))\n ) * 10 ) / 100;\n\n if (mode == PaymasterMode.EXTERNAL) {\n // Use the price and other params specified in modeSpecificData by the verifyingSigner\n // Useful for supporting tokens which don't have oracle support\n\n (\n uint48 validUntil,\n uint48 validAfter,\n address tokenAddress,\n uint256 tokenPrice,\n uint32 externalPriceMarkup,\n bytes memory signature\n ) = modeSpecificData.parseExternalModeSpecificData();\n\n if (signature.length != 64 && signature.length != 65) {\n revert InvalidSignatureLength();\n }\n\n bool validSig = verifyingSigner.isValidSignatureNow(\n ECDSA_solady.toEthSignedMessageHash(\n getHash(userOp, validUntil, validAfter, tokenAddress, tokenPrice, externalPriceMarkup)\n ),\n signature\n );\n\n //don't revert on signature failure: return SIG_VALIDATION_FAILED\n if (!validSig) {\n return (\"\", _packValidationData(true, validUntil, validAfter));\n }\n\n context = abi.encode(\n userOp.sender,\n tokenAddress,\n maxPenalty,\n tokenPrice,\n externalPriceMarkup,\n userOpHash \n );\n validationData = _packValidationData(false, validUntil, validAfter);\n \n /// INDEPENDENT MODE\n } else if (mode == PaymasterMode.INDEPENDENT) {\n\n address tokenAddress = modeSpecificData.parseIndependentModeSpecificData();\n \n // Use only oracles for the token specified in modeSpecificData\n if (modeSpecificData.length != 20) {\n revert InvalidTokenAddress();\n }\n\n context = abi.encode(\n userOp.sender,\n tokenAddress,\n maxPenalty,\n uint256(0), // pass 0, so we can check the price in _postOp and be 4337 compliant\n independentTokenDirectory[tokenAddress].priceMarkup,\n userOpHash\n );\n validationData = 0; // Validation success and price is valid indefinetly\n }\n }\n\n /**\n * @dev Post-operation handler.\n * This method is abstract in BasePaymaster and must be implemented in derived contracts.\n * @param context The context value returned by validatePaymasterUserOp.\n * @param actualGasCost Actual gas used so far (excluding this postOp call).\n * @param actualUserOpFeePerGas The gas price this UserOp pays.\n */\n function _postOp(\n PostOpMode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n )\n internal\n override\n { \n (\n address userOpSender,\n address tokenAddress,\n uint256 maxPenalty,\n uint256 tokenPrice,\n uint32 appliedPriceMarkup,\n bytes32 userOpHash\n ) = abi.decode(context, (address, address, uint256, uint256, uint32, bytes32));\n\n // If tokenPrice is 0, it means it was not set in the validatePaymasterUserOp => independent mode\n // So we need to get the price of the token from the oracle now\n if(tokenPrice == 0) {\n tokenPrice = _getPrice(tokenAddress);\n // if tokenPrice is still 0, it means the token is not supported\n if(tokenPrice == 0) {\n revert TokenNotSupported();\n }\n }\n\n // Calculate the amount to charge. unaccountedGas and maxPenalty are used, \n // as we do not know the exact gas spent for postop and actual penalty at this point\n // this is obviously overcharge, however, the excess amount can be refunded by backend, \n // when we know the exact gas spent (emitted by EP after executing UserOp)\n uint256 tokenAmount = (\n (actualGasCost + ((unaccountedGas + maxPenalty)) * actualUserOpFeePerGas)) * appliedPriceMarkup * tokenPrice\n / (_NATIVE_TOKEN_DECIMALS * _PRICE_DENOMINATOR);\n\n if (SafeTransferLib.trySafeTransferFrom(tokenAddress, userOpSender, address(this), tokenAmount)) {\n emit PaidGasInTokens(userOpSender, tokenAddress, actualGasCost, tokenAmount, appliedPriceMarkup, tokenPrice, userOpHash);\n } else {\n revert FailedToChargeTokens(userOpSender, tokenAddress, tokenAmount, userOpHash);\n } \n }\n\n function _validateTokenInfo(TokenInfo memory tokenInfo) internal view {\n if (tokenInfo.oracle.decimals() != 8) {\n revert InvalidOracleDecimals();\n }\n if (tokenInfo.priceMarkup > _MAX_PRICE_MARKUP || tokenInfo.priceMarkup < _PRICE_DENOMINATOR) {\n revert InvalidPriceMarkup();\n }\n if (block.timestamp < tokenInfo.priceExpiryDuration) {\n revert InvalidPriceExpiryDuration();\n }\n }\n\n /// @notice Fetches the latest token price.\n /// @return price The latest token price fetched from the oracles.\n function _getPrice(address tokenAddress) internal view returns (uint256 price) {\n // Fetch token information from directory\n TokenInfo memory tokenInfo = independentTokenDirectory[tokenAddress];\n\n if (address(tokenInfo.oracle) == address(0)) {\n // If oracle not set, token isn't supported\n revert TokenNotSupported();\n }\n\n // Calculate price by using token and native oracle\n uint256 tokenPrice = _fetchPrice(tokenInfo.oracle, tokenInfo.priceExpiryDuration);\n uint256 nativeAssetPrice = _fetchPrice(nativeAssetToUsdOracle, _NATIVE_ASSET_PRICE_EXPIRY_DURATION);\n\n // Adjust to token decimals\n price = (nativeAssetPrice * 10**IERC20Metadata(tokenAddress).decimals()) / tokenPrice;\n }\n\n /// @notice Fetches the latest price from the given oracle.\n /// @dev This function is used to get the latest price from the tokenOracle or nativeAssetToUsdOracle.\n /// @param oracle The oracle contract to fetch the price from.\n /// @return price The latest price fetched from the oracle.\n /// Note: We could do this using oracle aggregator, so we can also use Pyth. or Twap based oracle and just not chainlink.\n function _fetchPrice(IOracle oracle, uint256 priceExpiryDuration) internal view returns (uint256 price) {\n (, int256 answer,, uint256 updatedAt,) = oracle.latestRoundData();\n if (answer <= 0) {\n revert OraclePriceNotPositive();\n }\n if (updatedAt < block.timestamp - priceExpiryDuration) {\n revert OraclePriceExpired();\n }\n price = uint256(answer);\n }\n\n function _withdrawERC20(IERC20 token, address target, uint256 amount) private {\n if (target == address(0)) revert CanNotWithdrawToZeroAddress();\n SafeTransferLib.safeTransfer(address(token), target, amount);\n emit TokensWithdrawn(address(token), target, amount, msg.sender);\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuardTransient.sol)\n\npragma solidity ^0.8.24;\n\nimport {TransientSlot} from \"./TransientSlot.sol\";\n\n/**\n * @dev Variant of {ReentrancyGuard} that uses transient storage.\n *\n * NOTE: This variant only works on networks where EIP-1153 is available.\n *\n * _Available since v5.1._\n */\nabstract contract ReentrancyGuardTransient {\n using TransientSlot for *;\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant REENTRANCY_GUARD_STORAGE =\n 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n /**\n * @dev Unauthorized reentrant call.\n */\n error ReentrancyGuardReentrantCall();\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be NOT_ENTERED\n if (_reentrancyGuardEntered()) {\n revert ReentrancyGuardReentrantCall();\n }\n\n // Any calls to nonReentrant after this point will fail\n REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);\n }\n\n function _nonReentrantAfter() private {\n REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false);\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return REENTRANCY_GUARD_STORAGE.asBoolean().tload();\n }\n}\n"},"node_modules/account-abstraction/contracts/interfaces/IEntryPoint.sol":{"content":"/**\n ** Account-Abstraction (EIP-4337) singleton EntryPoint implementation.\n ** Only one instance required on each chain.\n **/\n// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"./PackedUserOperation.sol\";\nimport \"./IStakeManager.sol\";\nimport \"./IAggregator.sol\";\nimport \"./INonceManager.sol\";\n\ninterface IEntryPoint is IStakeManager, INonceManager {\n /***\n * An event emitted after each successful request.\n * @param userOpHash - Unique identifier for the request (hash its entire content, except signature).\n * @param sender - The account that generates this request.\n * @param paymaster - If non-null, the paymaster that pays for this request.\n * @param nonce - The nonce value from the request.\n * @param success - True if the sender transaction succeeded, false if reverted.\n * @param actualGasCost - Actual amount paid (by account or paymaster) for this UserOperation.\n * @param actualGasUsed - Total gas used by this UserOperation (including preVerification, creation,\n * validation and execution).\n */\n event UserOperationEvent(\n bytes32 indexed userOpHash,\n address indexed sender,\n address indexed paymaster,\n uint256 nonce,\n bool success,\n uint256 actualGasCost,\n uint256 actualGasUsed\n );\n\n /**\n * Account \"sender\" was deployed.\n * @param userOpHash - The userOp that deployed this account. UserOperationEvent will follow.\n * @param sender - The account that is deployed\n * @param factory - The factory used to deploy this account (in the initCode)\n * @param paymaster - The paymaster used by this UserOp\n */\n event AccountDeployed(\n bytes32 indexed userOpHash,\n address indexed sender,\n address factory,\n address paymaster\n );\n\n /**\n * An event emitted if the UserOperation \"callData\" reverted with non-zero length.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n * @param revertReason - The return bytes from the (reverted) call to \"callData\".\n */\n event UserOperationRevertReason(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce,\n bytes revertReason\n );\n\n /**\n * An event emitted if the UserOperation Paymaster's \"postOp\" call reverted with non-zero length.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n * @param revertReason - The return bytes from the (reverted) call to \"callData\".\n */\n event PostOpRevertReason(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce,\n bytes revertReason\n );\n\n /**\n * UserOp consumed more than prefund. The UserOperation is reverted, and no refund is made.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n */\n event UserOperationPrefundTooLow(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce\n );\n\n /**\n * An event emitted by handleOps(), before starting the execution loop.\n * Any event emitted before this event, is part of the validation.\n */\n event BeforeExecution();\n\n /**\n * Signature aggregator used by the following UserOperationEvents within this bundle.\n * @param aggregator - The aggregator used for the following UserOperationEvents.\n */\n event SignatureAggregatorChanged(address indexed aggregator);\n\n /**\n * A custom revert error of handleOps, to identify the offending op.\n * Should be caught in off-chain handleOps simulation and not happen on-chain.\n * Useful for mitigating DoS attempts against batchers or for troubleshooting of factory/account/paymaster reverts.\n * NOTE: If simulateValidation passes successfully, there should be no reason for handleOps to fail on it.\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\n * @param reason - Revert reason. The string starts with a unique code \"AAmn\",\n * where \"m\" is \"1\" for factory, \"2\" for account and \"3\" for paymaster issues,\n * so a failure can be attributed to the correct entity.\n */\n error FailedOp(uint256 opIndex, string reason);\n\n /**\n * A custom revert error of handleOps, to report a revert by account or paymaster.\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\n * @param reason - Revert reason. see FailedOp(uint256,string), above\n * @param inner - data from inner cought revert reason\n * @dev note that inner is truncated to 2048 bytes\n */\n error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);\n\n error PostOpReverted(bytes returnData);\n\n /**\n * Error case when a signature aggregator fails to verify the aggregated signature it had created.\n * @param aggregator The aggregator that failed to verify the signature\n */\n error SignatureValidationFailed(address aggregator);\n\n // Return value of getSenderAddress.\n error SenderAddressResult(address sender);\n\n // UserOps handled, per aggregator.\n struct UserOpsPerAggregator {\n PackedUserOperation[] userOps;\n // Aggregator address\n IAggregator aggregator;\n // Aggregated signature\n bytes signature;\n }\n\n /**\n * Execute a batch of UserOperations.\n * No signature aggregator is used.\n * If any account requires an aggregator (that is, it returned an aggregator when\n * performing simulateValidation), then handleAggregatedOps() must be used instead.\n * @param ops - The operations to execute.\n * @param beneficiary - The address to receive the fees.\n */\n function handleOps(\n PackedUserOperation[] calldata ops,\n address payable beneficiary\n ) external;\n\n /**\n * Execute a batch of UserOperation with Aggregators\n * @param opsPerAggregator - The operations to execute, grouped by aggregator (or address(0) for no-aggregator accounts).\n * @param beneficiary - The address to receive the fees.\n */\n function handleAggregatedOps(\n UserOpsPerAggregator[] calldata opsPerAggregator,\n address payable beneficiary\n ) external;\n\n /**\n * Generate a request Id - unique identifier for this request.\n * The request ID is a hash over the content of the userOp (except the signature), the entrypoint and the chainid.\n * @param userOp - The user operation to generate the request ID for.\n * @return hash the hash of this UserOperation\n */\n function getUserOpHash(\n PackedUserOperation calldata userOp\n ) external view returns (bytes32);\n\n /**\n * Gas and return values during simulation.\n * @param preOpGas - The gas used for validation (including preValidationGas)\n * @param prefund - The required prefund for this operation\n * @param accountValidationData - returned validationData from account.\n * @param paymasterValidationData - return validationData from paymaster.\n * @param paymasterContext - Returned by validatePaymasterUserOp (to be passed into postOp)\n */\n struct ReturnInfo {\n uint256 preOpGas;\n uint256 prefund;\n uint256 accountValidationData;\n uint256 paymasterValidationData;\n bytes paymasterContext;\n }\n\n /**\n * Returned aggregated signature info:\n * The aggregator returned by the account, and its current stake.\n */\n struct AggregatorStakeInfo {\n address aggregator;\n StakeInfo stakeInfo;\n }\n\n /**\n * Get counterfactual sender address.\n * Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.\n * This method always revert, and returns the address in SenderAddressResult error\n * @param initCode - The constructor code to be passed into the UserOperation.\n */\n function getSenderAddress(bytes memory initCode) external;\n\n error DelegateAndRevert(bool success, bytes ret);\n\n /**\n * Helper method for dry-run testing.\n * @dev calling this method, the EntryPoint will make a delegatecall to the given data, and report (via revert) the result.\n * The method always revert, so is only useful off-chain for dry run calls, in cases where state-override to replace\n * actual EntryPoint code is less convenient.\n * @param target a target contract to make a delegatecall from entrypoint\n * @param data data to pass to target in a delegatecall\n */\n function delegateAndRevert(address target, bytes calldata data) external;\n}\n"},"node_modules/account-abstraction/contracts/core/UserOperationLib.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable no-inline-assembly */\n\nimport \"../interfaces/PackedUserOperation.sol\";\nimport {calldataKeccak, min} from \"./Helpers.sol\";\n\n/**\n * Utility functions helpful when working with UserOperation structs.\n */\nlibrary UserOperationLib {\n\n uint256 public constant PAYMASTER_VALIDATION_GAS_OFFSET = 20;\n uint256 public constant PAYMASTER_POSTOP_GAS_OFFSET = 36;\n uint256 public constant PAYMASTER_DATA_OFFSET = 52;\n /**\n * Get sender from user operation data.\n * @param userOp - The user operation data.\n */\n function getSender(\n PackedUserOperation calldata userOp\n ) internal pure returns (address) {\n address data;\n //read sender from userOp, which is first userOp member (saves 800 gas...)\n assembly {\n data := calldataload(userOp)\n }\n return address(uint160(data));\n }\n\n /**\n * Relayer/block builder might submit the TX with higher priorityFee,\n * but the user should not pay above what he signed for.\n * @param userOp - The user operation data.\n */\n function gasPrice(\n PackedUserOperation calldata userOp\n ) internal view returns (uint256) {\n unchecked {\n (uint256 maxPriorityFeePerGas, uint256 maxFeePerGas) = unpackUints(userOp.gasFees);\n if (maxFeePerGas == maxPriorityFeePerGas) {\n //legacy mode (for networks that don't support basefee opcode)\n return maxFeePerGas;\n }\n return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);\n }\n }\n\n /**\n * Pack the user operation data into bytes for hashing.\n * @param userOp - The user operation data.\n */\n function encode(\n PackedUserOperation calldata userOp\n ) internal pure returns (bytes memory ret) {\n address sender = getSender(userOp);\n uint256 nonce = userOp.nonce;\n bytes32 hashInitCode = calldataKeccak(userOp.initCode);\n bytes32 hashCallData = calldataKeccak(userOp.callData);\n bytes32 accountGasLimits = userOp.accountGasLimits;\n uint256 preVerificationGas = userOp.preVerificationGas;\n bytes32 gasFees = userOp.gasFees;\n bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\n\n return abi.encode(\n sender, nonce,\n hashInitCode, hashCallData,\n accountGasLimits, preVerificationGas, gasFees,\n hashPaymasterAndData\n );\n }\n\n function unpackUints(\n bytes32 packed\n ) internal pure returns (uint256 high128, uint256 low128) {\n return (uint128(bytes16(packed)), uint128(uint256(packed)));\n }\n\n //unpack just the high 128-bits from a packed value\n function unpackHigh128(bytes32 packed) internal pure returns (uint256) {\n return uint256(packed) >> 128;\n }\n\n // unpack just the low 128-bits from a packed value\n function unpackLow128(bytes32 packed) internal pure returns (uint256) {\n return uint128(uint256(packed));\n }\n\n function unpackMaxPriorityFeePerGas(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackHigh128(userOp.gasFees);\n }\n\n function unpackMaxFeePerGas(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackLow128(userOp.gasFees);\n }\n\n function unpackVerificationGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackHigh128(userOp.accountGasLimits);\n }\n\n function unpackCallGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackLow128(userOp.accountGasLimits);\n }\n\n function unpackPaymasterVerificationGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET]));\n }\n\n function unpackPostOpGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]));\n }\n\n function unpackPaymasterStaticFields(\n bytes calldata paymasterAndData\n ) internal pure returns (address paymaster, uint256 validationGasLimit, uint256 postOpGasLimit) {\n return (\n address(bytes20(paymasterAndData[: PAYMASTER_VALIDATION_GAS_OFFSET])),\n uint128(bytes16(paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET])),\n uint128(bytes16(paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]))\n );\n }\n\n /**\n * Hash the user operation data.\n * @param userOp - The user operation data.\n */\n function hash(\n PackedUserOperation calldata userOp\n ) internal pure returns (bytes32) {\n return keccak256(encode(userOp));\n }\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC-20\n * applications.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Skips emitting an {Approval} event indicating an allowance update. This is not\n * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n *\n * ```solidity\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC1363} from \"../../../interfaces/IERC1363.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC-20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n /**\n * @dev An operation with an ERC-20 token failed.\n */\n error SafeERC20FailedOperation(address token);\n\n /**\n * @dev Indicates a failed `decreaseAllowance` request.\n */\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n *\n * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n forceApprove(token, spender, oldAllowance + value);\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n * value, non-reverting calls are assumed to be successful.\n *\n * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n unchecked {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < requestedDecrease) {\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n }\n forceApprove(token, spender, currentAllowance - requestedDecrease);\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n *\n * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function\n * only sets the \"standard\" allowance. Any temporary allowance will remain active, in addition to the value being\n * set here.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no\n * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * Reverts if the returned value is other than `true`.\n */\n function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n if (to.code.length == 0) {\n safeTransfer(token, to, value);\n } else if (!token.transferAndCall(to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target\n * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * Reverts if the returned value is other than `true`.\n */\n function transferFromAndCallRelaxed(\n IERC1363 token,\n address from,\n address to,\n uint256 value,\n bytes memory data\n ) internal {\n if (to.code.length == 0) {\n safeTransferFrom(token, from, to, value);\n } else if (!token.transferFromAndCall(from, to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no\n * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.\n * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}\n * once without retrying, and relies on the returned value to be true.\n *\n * Reverts if the returned value is other than `true`.\n */\n function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n if (to.code.length == 0) {\n forceApprove(token, to, value);\n } else if (!token.approveAndCall(to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n uint256 returnSize;\n uint256 returnValue;\n assembly (\"memory-safe\") {\n let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n // bubble errors\n if iszero(success) {\n let ptr := mload(0x40)\n returndatacopy(ptr, 0, returndatasize())\n revert(ptr, returndatasize())\n }\n returnSize := returndatasize()\n returnValue := mload(0)\n }\n\n if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly (\"memory-safe\") {\n success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0)\n }\n return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);\n }\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC-20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"},"node_modules/solady/src/utils/SafeTransferLib.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)\n///\n/// @dev Note:\n/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.\nlibrary SafeTransferLib {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ETH transfer has failed.\n error ETHTransferFailed();\n\n /// @dev The ERC20 `transferFrom` has failed.\n error TransferFromFailed();\n\n /// @dev The ERC20 `transfer` has failed.\n error TransferFailed();\n\n /// @dev The ERC20 `approve` has failed.\n error ApproveFailed();\n\n /// @dev The Permit2 operation has failed.\n error Permit2Failed();\n\n /// @dev The Permit2 amount must be less than `2**160 - 1`.\n error Permit2AmountOverflow();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTANTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.\n uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;\n\n /// @dev Suggested gas stipend for contract receiving ETH to perform a few\n /// storage reads and writes, but low enough to prevent griefing.\n uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;\n\n /// @dev The unique EIP-712 domain domain separator for the DAI token contract.\n bytes32 internal constant DAI_DOMAIN_SEPARATOR =\n 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;\n\n /// @dev The address for the WETH9 contract on Ethereum mainnet.\n address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n /// @dev The canonical Permit2 address.\n /// [Github](https://github.com/Uniswap/permit2)\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\n address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ETH OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.\n //\n // The regular variants:\n // - Forwards all remaining gas to the target.\n // - Reverts if the target reverts.\n // - Reverts if the current contract has insufficient balance.\n //\n // The force variants:\n // - Forwards with an optional gas stipend\n // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).\n // - If the target reverts, or if the gas stipend is exhausted,\n // creates a temporary contract to force send the ETH via `SELFDESTRUCT`.\n // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.\n // - Reverts if the current contract has insufficient balance.\n //\n // The try variants:\n // - Forwards with a mandatory gas stipend.\n // - Instead of reverting, returns whether the transfer succeeded.\n\n /// @dev Sends `amount` (in wei) ETH to `to`.\n function safeTransferETH(address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Sends all the ETH in the current contract to `to`.\n function safeTransferAllETH(address to) internal {\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer all the ETH and check if it succeeded or not.\n if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\n function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if lt(selfbalance(), amount) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.\n function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.\n function forceSafeTransferETH(address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if lt(selfbalance(), amount) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.\n function forceSafeTransferAllETH(address to) internal {\n /// @solidity memory-safe-assembly\n assembly {\n // forgefmt: disable-next-item\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\n function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)\n }\n }\n\n /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.\n function trySafeTransferAllETH(address to, uint256 gasStipend)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC20 OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n /// Reverts upon failure.\n ///\n /// The `from` account must have at least `amount` approved for\n /// the current contract to manage.\n function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x60, amount) // Store the `amount` argument.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\n let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n ///\n /// The `from` account must have at least `amount` approved for the current contract to manage.\n function trySafeTransferFrom(address token, address from, address to, uint256 amount)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x60, amount) // Store the `amount` argument.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\n success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n success := lt(or(iszero(extcodesize(token)), returndatasize()), success)\n }\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends all of ERC20 `token` from `from` to `to`.\n /// Reverts upon failure.\n ///\n /// The `from` account must have their entire balance approved for the current contract to manage.\n function safeTransferAllFrom(address token, address from, address to)\n internal\n returns (uint256 amount)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\n // Read the balance, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)\n )\n ) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.\n amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.\n // Perform the transfer, reverting upon failure.\n let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.\n /// Reverts upon failure.\n function safeTransfer(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n // Perform the transfer, reverting upon failure.\n let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sends all of ERC20 `token` from the current contract to `to`.\n /// Reverts upon failure.\n function safeTransferAll(address token, address to) internal returns (uint256 amount) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.\n mstore(0x20, address()) // Store the address of the current contract.\n // Read the balance, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)\n )\n ) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x14, to) // Store the `to` argument.\n amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n // Perform the transfer, reverting upon failure.\n let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\n /// Reverts upon failure.\n function safeApprove(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\n /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,\n /// then retries the approval again (some tokens, e.g. USDT, requires this).\n /// Reverts upon failure.\n function safeApproveWithRetry(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n // Perform the approval, retrying upon failure.\n let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x34, 0) // Store 0 for the `amount`.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.\n mstore(0x34, amount) // Store back the original `amount`.\n // Retry the approval, reverting upon failure.\n success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n if iszero(and(eq(mload(0x00), 1), success)) {\n // Check the `extcodesize` again just in case the token selfdestructs lol.\n if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Returns the amount of ERC20 `token` owned by `account`.\n /// Returns zero if the `token` does not exist.\n function balanceOf(address token, address account) internal view returns (uint256 amount) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, account) // Store the `account` argument.\n mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\n amount :=\n mul( // The arguments of `mul` are evaluated from right to left.\n mload(0x20),\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)\n )\n )\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n /// If the initial attempt fails, try to use Permit2 to transfer the token.\n /// Reverts upon failure.\n ///\n /// The `from` account must have at least `amount` approved for the current contract to manage.\n function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {\n if (!trySafeTransferFrom(token, from, to, amount)) {\n permit2TransferFrom(token, from, to, amount);\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.\n /// Reverts upon failure.\n function permit2TransferFrom(address token, address from, address to, uint256 amount)\n internal\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(add(m, 0x74), shr(96, shl(96, token)))\n mstore(add(m, 0x54), amount)\n mstore(add(m, 0x34), to)\n mstore(add(m, 0x20), shl(96, from))\n // `transferFrom(address,address,uint160,address)`.\n mstore(m, 0x36c78516000000000000000000000000)\n let p := PERMIT2\n let exists := eq(chainid(), 1)\n if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }\n if iszero(\n and(\n call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00),\n lt(iszero(extcodesize(token)), exists) // Token has code and Permit2 exists.\n )\n ) {\n mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.\n revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)\n }\n }\n }\n\n /// @dev Permit a user to spend a given amount of\n /// another user's tokens via native EIP-2612 permit if possible, falling\n /// back to Permit2 if native permit fails or is not implemented on the token.\n function permit2(\n address token,\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n bool success;\n /// @solidity memory-safe-assembly\n assembly {\n for {} shl(96, xor(token, WETH9)) {} {\n mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.\n // Gas stipend to limit gas burn for tokens that don't refund gas when\n // an non-existing function is called. 5K should be enough for a SLOAD.\n staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)\n )\n ) { break }\n // After here, we can be sure that token is a contract.\n let m := mload(0x40)\n mstore(add(m, 0x34), spender)\n mstore(add(m, 0x20), shl(96, owner))\n mstore(add(m, 0x74), deadline)\n if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {\n mstore(0x14, owner)\n mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.\n mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))\n mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.\n // `nonces` is already at `add(m, 0x54)`.\n // `1` is already stored at `add(m, 0x94)`.\n mstore(add(m, 0xb4), and(0xff, v))\n mstore(add(m, 0xd4), r)\n mstore(add(m, 0xf4), s)\n success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)\n break\n }\n mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.\n mstore(add(m, 0x54), amount)\n mstore(add(m, 0x94), and(0xff, v))\n mstore(add(m, 0xb4), r)\n mstore(add(m, 0xd4), s)\n success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)\n break\n }\n }\n if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);\n }\n\n /// @dev Simple permit on the Permit2 contract.\n function simplePermit2(\n address token,\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(m, 0x927da105) // `allowance(address,address,address)`.\n {\n let addressMask := shr(96, not(0))\n mstore(add(m, 0x20), and(addressMask, owner))\n mstore(add(m, 0x40), and(addressMask, token))\n mstore(add(m, 0x60), and(addressMask, spender))\n mstore(add(m, 0xc0), and(addressMask, spender))\n }\n let p := mul(PERMIT2, iszero(shr(160, amount)))\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.\n staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)\n )\n ) {\n mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.\n revert(add(0x18, shl(2, iszero(p))), 0x04)\n }\n mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).\n // `owner` is already `add(m, 0x20)`.\n // `token` is already at `add(m, 0x40)`.\n mstore(add(m, 0x60), amount)\n mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.\n // `nonce` is already at `add(m, 0xa0)`.\n // `spender` is already at `add(m, 0xc0)`.\n mstore(add(m, 0xe0), deadline)\n mstore(add(m, 0x100), 0x100) // `signature` offset.\n mstore(add(m, 0x120), 0x41) // `signature` length.\n mstore(add(m, 0x140), r)\n mstore(add(m, 0x160), s)\n mstore(add(m, 0x180), shl(248, v))\n if iszero( // Revert if token does not have code, or if the call fails.\n mul(extcodesize(token), call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00))) {\n mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n}\n"},"contracts/base/BasePaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.27;\n\n/* solhint-disable reason-string */\n\nimport { SoladyOwnable } from \"../utils/SoladyOwnable.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { IPaymaster } from \"account-abstraction/interfaces/IPaymaster.sol\";\nimport { IEntryPoint } from \"account-abstraction/interfaces/IEntryPoint.sol\";\nimport \"account-abstraction/core/UserOperationLib.sol\";\n\n/**\n * Helper class for creating a paymaster.\n * provides helper methods for staking.\n * Validates that the postOp is called only by the entryPoint.\n */\n\nabstract contract BasePaymaster is IPaymaster, SoladyOwnable {\n IEntryPoint public immutable entryPoint;\n\n uint256 internal constant _PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET;\n uint256 internal constant _PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET;\n uint256 internal constant _PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET;\n\n constructor(address owner, IEntryPoint entryPointArg) SoladyOwnable(owner) {\n _validateEntryPointInterface(entryPointArg);\n entryPoint = entryPointArg;\n }\n\n /**\n * Add stake for this paymaster.\n * This method can also carry eth value to add to the current stake.\n * @param unstakeDelaySec - The unstake delay for this paymaster. Can only be increased.\n */\n function addStake(uint32 unstakeDelaySec) external payable onlyOwner {\n entryPoint.addStake{ value: msg.value }(unstakeDelaySec);\n }\n\n /**\n * Unlock the stake, in order to withdraw it.\n * The paymaster can't serve requests once unlocked, until it calls addStake again\n */\n function unlockStake() external onlyOwner {\n entryPoint.unlockStake();\n }\n\n /**\n * Withdraw the entire paymaster's stake.\n * stake must be unlocked first (and then wait for the unstakeDelay to be over)\n * @param withdrawAddress - The address to send withdrawn value.\n */\n function withdrawStake(address payable withdrawAddress) external onlyOwner {\n entryPoint.withdrawStake(withdrawAddress);\n }\n\n /// @inheritdoc IPaymaster\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n )\n external\n override\n {\n _requireFromEntryPoint();\n _postOp(mode, context, actualGasCost, actualUserOpFeePerGas);\n }\n\n /// @inheritdoc IPaymaster\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n )\n external\n override\n returns (bytes memory context, uint256 validationData)\n {\n _requireFromEntryPoint();\n return _validatePaymasterUserOp(userOp, userOpHash, maxCost);\n }\n\n /**\n * Add a deposit for this paymaster, used for paying for transaction fees.\n */\n function deposit() external payable virtual {\n entryPoint.depositTo{ value: msg.value }(address(this));\n }\n\n /**\n * Withdraw value from the deposit.\n * @param withdrawAddress - Target to send to.\n * @param amount - Amount to withdraw.\n */\n function withdrawTo(address payable withdrawAddress, uint256 amount) external virtual onlyOwner {\n entryPoint.withdrawTo(withdrawAddress, amount);\n }\n\n /**\n * Return current paymaster's deposit on the entryPoint.\n */\n function getDeposit() public view returns (uint256) {\n return entryPoint.balanceOf(address(this));\n }\n\n //sanity check: make sure this EntryPoint was compiled against the same\n // IEntryPoint of this paymaster\n function _validateEntryPointInterface(IEntryPoint entryPointArg) internal virtual {\n require(\n IERC165(address(entryPointArg)).supportsInterface(type(IEntryPoint).interfaceId),\n \"IEntryPoint interface mismatch\"\n );\n }\n\n /**\n * Validate a user operation.\n * @param userOp - The user operation.\n * @param userOpHash - The hash of the user operation.\n * @param maxCost - The maximum cost of the user operation.\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n )\n internal\n virtual\n returns (bytes memory context, uint256 validationData);\n\n /**\n * Post-operation handler.\n * (verified to be called only through the entryPoint)\n * @dev If subclass returns a non-empty context from validatePaymasterUserOp,\n * it must also implement this method.\n * @param mode - Enum with the following options:\n * opSucceeded - User operation succeeded.\n * opReverted - User op reverted. The paymaster still has to pay for gas.\n * postOpReverted - never passed in a call to postOp().\n * @param context - The context value returned by validatePaymasterUserOp\n * @param actualGasCost - Actual gas used so far (without this postOp call).\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\n * and maxPriorityFee (and basefee)\n * It is not the same as tx.gasprice, which is what the bundler pays.\n */\n function _postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n )\n internal\n virtual\n {\n (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params\n // subclass must override this method if validatePaymasterUserOp returns a context\n revert(\"must override\");\n }\n\n /**\n * Validate the call is made from a valid entrypoint\n */\n function _requireFromEntryPoint() internal virtual {\n require(msg.sender == address(entryPoint), \"Sender not EntryPoint\");\n }\n\n /**\n * Check if address is a contract\n */\n function _isContract(address addr) internal view returns (bool) {\n uint256 size;\n assembly (\"memory-safe\") {\n size := extcodesize(addr)\n }\n return size > 0;\n }\n}\n"},"contracts/common/BiconomyTokenPaymasterErrors.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity ^0.8.27;\n\ncontract BiconomyTokenPaymasterErrors {\n /**\n * @notice Throws when the verifiying signer address provided is address(0)\n */\n error VerifyingSignerCanNotBeZero();\n /**\n * @notice Throws when the fee collector address provided is a deployed contract\n */\n error VerifyingSignerCanNotBeContract();\n\n /**\n * @notice Throws when the fee collector address provided is address(0)\n */\n error FeeCollectorCanNotBeZero();\n\n /**\n * @notice Throws when trying unaccountedGas is too high\n */\n error UnaccountedGasTooHigh();\n\n /**\n * @notice Throws when trying to withdraw to address(0)\n */\n error CanNotWithdrawToZeroAddress();\n\n /**\n * @notice Throws when trying to withdraw multiple tokens, but each token doesn't have a corresponding amount\n */\n error TokensAndAmountsLengthMismatch();\n\n /**\n * @notice Throws when invalid signature length in paymasterAndData\n */\n error InvalidPriceMarkup();\n\n /**\n * @notice Throws when each token doesnt have a corresponding oracle\n */\n error TokensAndInfoLengthMismatch();\n\n /**\n * @notice Throws when invalid PaymasterMode specified in paymasterAndData\n */\n error InvalidPaymasterMode();\n\n /**\n * @notice Throws when oracle returns invalid price\n */\n error OraclePriceNotPositive();\n\n /**\n * @notice Throws when oracle price hasn't been updated for a duration of time the owner is comfortable with\n */\n error OraclePriceExpired();\n\n /**\n * @notice Throws when token address to pay with is invalid\n */\n error InvalidTokenAddress();\n\n /**\n * @notice Throws when oracle decimals aren't equal to 8\n */\n error InvalidOracleDecimals();\n\n /**\n * @notice Throws when price expiry duration is in the past\n */\n error InvalidPriceExpiryDuration();\n\n /**\n * @notice Throws when external signer's signature has invalid length\n */\n error InvalidSignatureLength();\n\n /**\n * @notice Throws when ETH withdrawal fails\n */\n error WithdrawalFailed();\n\n\n /**\n * @notice Throws when PM was not able to charge user\n */\n error FailedToChargeTokens(address account, address token, uint256 amount, bytes32 userOpHash);\n}\n"},"contracts/interfaces/IBiconomyTokenPaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.27;\n\nimport { IOracle } from \"./oracles/IOracle.sol\";\n\ninterface IBiconomyTokenPaymaster {\n // Modes that paymaster can be used in\n enum PaymasterMode {\n EXTERNAL, // Price provided by external service. Authenticated using signature from verifyingSigner\n INDEPENDENT // Price queried from oracle. No signature needed from external service.\n }\n\n // Struct for storing information about the token\n struct TokenInfo {\n IOracle oracle;\n uint32 priceMarkup;\n uint256 priceExpiryDuration;\n }\n\n event UpdatedUnaccountedGas(uint256 indexed oldValue, uint256 indexed newValue);\n event UpdatedFixedPriceMarkup(uint32 indexed oldValue, uint32 indexed newValue);\n event UpdatedVerifyingSigner(address indexed oldSigner, address indexed newSigner, address indexed actor);\n event UpdatedFeeCollector(address indexed oldFeeCollector, address indexed newFeeCollector, address indexed actor);\n event UpdatedPriceExpiryDuration(uint256 indexed oldValue, uint256 indexed newValue);\n \n event PaidGasInTokens(\n address indexed userOpSender,\n address indexed token,\n uint256 gasCostBeforePostOpAndPenalty,\n uint256 tokenCharge,\n uint32 priceMarkup,\n uint256 tokenPrice,\n bytes32 userOpHash\n );\n \n event EthWithdrawn(address indexed recipient, uint256 indexed amount);\n\n event Received(address indexed sender, uint256 value);\n event TokensWithdrawn(address indexed token, address indexed to, uint256 indexed amount, address actor);\n event AddedToTokenDirectory(address indexed tokenAddress, IOracle indexed oracle, uint8 decimals);\n event RemovedFromTokenDirectory(address indexed tokenAddress);\n event UpdatedNativeAssetOracle(IOracle indexed oldOracle, IOracle indexed newOracle);\n event TokensSwappedAndRefilledEntryPoint(address indexed tokenAddress, uint256 indexed tokenAmount, uint256 indexed amountOut, address actor);\n event SwappableTokensAdded(address[] indexed tokenAddresses);\n\n function setSigner(address newVerifyingSigner) external payable;\n\n function setUnaccountedGas(uint256 value) external payable;\n\n function setPriceMarkupForToken(address tokenAddress, uint32 newPriceMarkup) external payable;\n\n function setPriceExpiryDurationForToken(address tokenAddress, uint256 newPriceExpiryDuration) external payable;\n\n function setNativeAssetToUsdOracle(IOracle oracle) external payable;\n\n function addToTokenDirectory(address tokenAddress, TokenInfo memory tokenInfo) external payable;\n}\n"},"contracts/interfaces/oracles/IOracle.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.27;\n\ninterface IOracle {\n function decimals() external view returns (uint8);\n\n function latestRoundData()\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\n\n function latestAnswer() external view returns (int256);\n}\n"},"contracts/libraries/TokenPaymasterParserLib.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.27;\n\nimport { IBiconomyTokenPaymaster } from \"../interfaces/IBiconomyTokenPaymaster.sol\";\nimport \"account-abstraction/core/UserOperationLib.sol\";\n\n// A helper library to parse paymaster and data\nlibrary TokenPaymasterParserLib {\n // Start offset of mode in PND\n uint256 private constant PAYMASTER_MODE_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET;\n\n function parsePaymasterAndData(\n bytes calldata paymasterAndData\n )\n internal\n pure\n returns (IBiconomyTokenPaymaster.PaymasterMode mode, bytes calldata modeSpecificData)\n {\n unchecked {\n mode = IBiconomyTokenPaymaster.PaymasterMode(uint8(bytes1(paymasterAndData[PAYMASTER_MODE_OFFSET])));\n modeSpecificData = paymasterAndData[PAYMASTER_MODE_OFFSET + 1:];\n }\n }\n\n function parseExternalModeSpecificData(\n bytes calldata modeSpecificData\n )\n internal\n pure\n returns (\n uint48 validUntil,\n uint48 validAfter,\n address tokenAddress,\n uint256 tokenPrice, \n uint32 appliedPriceMarkup,\n bytes calldata signature\n )\n {\n validUntil = uint48(bytes6(modeSpecificData[:6]));\n validAfter = uint48(bytes6(modeSpecificData[6:12]));\n tokenAddress = address(bytes20(modeSpecificData[12:32]));\n tokenPrice = uint256(bytes32(modeSpecificData[32:64]));\n appliedPriceMarkup = uint32(bytes4(modeSpecificData[64:68]));\n signature = modeSpecificData[68:];\n }\n\n function parseIndependentModeSpecificData(\n bytes calldata modeSpecificData\n )\n internal\n pure\n returns (address tokenAddress)\n {\n tokenAddress = address(bytes20(modeSpecificData[:20]));\n }\n}\n"},"node_modules/solady/src/utils/SignatureCheckerLib.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Signature verification helper that supports both ECDSA signatures from EOAs\n/// and ERC1271 signatures from smart contract wallets like Argent and Gnosis safe.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SignatureCheckerLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol)\n///\n/// @dev Note:\n/// - The signature checking functions use the ecrecover precompile (0x1).\n/// - The `bytes memory signature` variants use the identity precompile (0x4)\n/// to copy memory internally.\n/// - Unlike ECDSA signatures, contract signatures are revocable.\n/// - As of Solady version 0.0.134, all `bytes signature` variants accept both\n/// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.\n/// See: https://eips.ethereum.org/EIPS/eip-2098\n/// This is for calldata efficiency on smart accounts prevalent on L2s.\n///\n/// WARNING! Do NOT use signatures as unique identifiers:\n/// - Use a nonce in the digest to prevent replay attacks on the same contract.\n/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.\n/// EIP-712 also enables readable signing of typed data for better user safety.\n/// This implementation does NOT check if a signature is non-malleable.\nlibrary SignatureCheckerLib {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* SIGNATURE CHECKING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns whether `signature` is valid for `signer` and `hash`.\n /// First, it will try to validate with `ecrecover`, and if the validation fails,\n /// it will try to validate with ERC1271 on `signer`.\n function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature)\n internal\n view\n returns (bool isValid)\n {\n if (signer == address(0)) return isValid;\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n for {} 1 {} {\n switch mload(signature)\n case 64 {\n let vs := mload(add(signature, 0x40))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.\n mstore(0x60, mload(add(signature, 0x40))) // `s`.\n }\n default { break }\n mstore(0x00, hash)\n mstore(0x40, mload(add(signature, 0x20))) // `r`.\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n if iszero(isValid) {\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n // Copy the `signature` over.\n let n := add(0x20, mload(signature))\n pop(staticcall(gas(), 4, signature, n, add(m, 0x44), n))\n isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n }\n\n /// @dev Returns whether `signature` is valid for `signer` and `hash`.\n /// First, it will try to validate with `ecrecover`, and if the validation fails,\n /// it will try to validate with ERC1271 on `signer`.\n function isValidSignatureNowCalldata(address signer, bytes32 hash, bytes calldata signature)\n internal\n view\n returns (bool isValid)\n {\n if (signer == address(0)) return isValid;\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n for {} 1 {} {\n switch signature.length\n case 64 {\n let vs := calldataload(add(signature.offset, 0x20))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, calldataload(signature.offset)) // `r`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.\n calldatacopy(0x40, signature.offset, 0x40) // `r`, `s`.\n }\n default { break }\n mstore(0x00, hash)\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n if iszero(isValid) {\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), signature.length)\n // Copy the `signature` over.\n calldatacopy(add(m, 0x64), signature.offset, signature.length)\n isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n }\n\n /// @dev Returns whether the signature (`r`, `vs`) is valid for `signer` and `hash`.\n /// First, it will try to validate with `ecrecover`, and if the validation fails,\n /// it will try to validate with ERC1271 on `signer`.\n function isValidSignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)\n internal\n view\n returns (bool isValid)\n {\n if (signer == address(0)) return isValid;\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(0x00, hash)\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, r) // `r`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n\n if iszero(isValid) {\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), 65) // Length of the signature.\n mstore(add(m, 0x64), r) // `r`.\n mstore(add(m, 0x84), mload(0x60)) // `s`.\n mstore8(add(m, 0xa4), mload(0x20)) // `v`.\n isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `signer` and `hash`.\n /// First, it will try to validate with `ecrecover`, and if the validation fails,\n /// it will try to validate with ERC1271 on `signer`.\n function isValidSignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)\n internal\n view\n returns (bool isValid)\n {\n if (signer == address(0)) return isValid;\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(0x00, hash)\n mstore(0x20, and(v, 0xff)) // `v`.\n mstore(0x40, r) // `r`.\n mstore(0x60, s) // `s`.\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n\n if iszero(isValid) {\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), 65) // Length of the signature.\n mstore(add(m, 0x64), r) // `r`.\n mstore(add(m, 0x84), s) // `s`.\n mstore8(add(m, 0xa4), v) // `v`.\n isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1271 OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // Note: These ERC1271 operations do NOT have an ECDSA fallback.\n\n /// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.\n function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)\n internal\n view\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n // Copy the `signature` over.\n let n := add(0x20, mload(signature))\n pop(staticcall(gas(), 4, signature, n, add(m, 0x44), n))\n isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n\n /// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.\n function isValidERC1271SignatureNowCalldata(\n address signer,\n bytes32 hash,\n bytes calldata signature\n ) internal view returns (bool isValid) {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), signature.length)\n // Copy the `signature` over.\n calldatacopy(add(m, 0x64), signature.offset, signature.length)\n isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n\n /// @dev Returns whether the signature (`r`, `vs`) is valid for `hash`\n /// for an ERC1271 `signer` contract.\n function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)\n internal\n view\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), 65) // Length of the signature.\n mstore(add(m, 0x64), r) // `r`.\n mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`.\n mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`.\n isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n\n /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash`\n /// for an ERC1271 `signer` contract.\n function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)\n internal\n view\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n let f := shl(224, 0x1626ba7e)\n mstore(m, f) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m, 0x04), hash)\n let d := add(m, 0x24)\n mstore(d, 0x40) // The offset of the `signature` in the calldata.\n mstore(add(m, 0x44), 65) // Length of the signature.\n mstore(add(m, 0x64), r) // `r`.\n mstore(add(m, 0x84), s) // `s`.\n mstore8(add(m, 0xa4), v) // `v`.\n isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)\n isValid := and(eq(mload(d), f), isValid)\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC6492 OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // Note: These ERC6492 operations now include an ECDSA fallback at the very end.\n // The calldata variants are excluded for brevity.\n\n /// @dev Returns whether `signature` is valid for `hash`.\n /// If the signature is postfixed with the ERC6492 magic number, it will attempt to\n /// deploy / prepare the `signer` smart account before doing a regular ERC1271 check.\n /// Note: This function is NOT reentrancy safe.\n function isValidERC6492SignatureNowAllowSideEffects(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) internal returns (bool isValid) {\n /// @solidity memory-safe-assembly\n assembly {\n function callIsValidSignature(signer_, hash_, signature_) -> _isValid {\n let m_ := mload(0x40)\n let f_ := shl(224, 0x1626ba7e)\n mstore(m_, f_) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m_, 0x04), hash_)\n let d_ := add(m_, 0x24)\n mstore(d_, 0x40) // The offset of the `signature` in the calldata.\n let n_ := add(0x20, mload(signature_))\n pop(staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_))\n _isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)\n _isValid := and(eq(mload(d_), f_), _isValid)\n }\n let noCode := iszero(extcodesize(signer))\n let n := mload(signature)\n for {} 1 {} {\n if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {\n if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }\n break\n }\n let o := add(signature, 0x20) // Signature bytes.\n let d := add(o, mload(add(o, 0x20))) // Factory calldata.\n if noCode {\n if iszero(call(gas(), mload(o), 0, add(d, 0x20), mload(d), codesize(), 0x00)) {\n break\n }\n }\n let s := add(o, mload(add(o, 0x40))) // Inner signature.\n isValid := callIsValidSignature(signer, hash, s)\n if iszero(isValid) {\n if call(gas(), mload(o), 0, add(d, 0x20), mload(d), codesize(), 0x00) {\n noCode := iszero(extcodesize(signer))\n if iszero(noCode) { isValid := callIsValidSignature(signer, hash, s) }\n }\n }\n break\n }\n // Do `ecrecover` fallback if `noCode && !isValid`.\n for {} gt(noCode, isValid) {} {\n switch n\n case 64 {\n let vs := mload(add(signature, 0x40))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.\n mstore(0x60, mload(add(signature, 0x40))) // `s`.\n }\n default { break }\n let m := mload(0x40)\n mstore(0x00, hash)\n mstore(0x40, mload(add(signature, 0x20))) // `r`.\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n }\n }\n\n /// @dev Returns whether `signature` is valid for `hash`.\n /// If the signature is postfixed with the ERC6492 magic number, it will attempt\n /// to use a reverting verifier to deploy / prepare the `signer` smart account\n /// and do a `isValidSignature` check via the reverting verifier.\n /// Note: This function is reentrancy safe.\n /// The reverting verifier must be deployed.\n /// Otherwise, the function will return false if `signer` is not yet deployed / prepared.\n /// See: https://gist.github.com/Vectorized/846a474c855eee9e441506676800a9ad\n function isValidERC6492SignatureNow(address signer, bytes32 hash, bytes memory signature)\n internal\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n function callIsValidSignature(signer_, hash_, signature_) -> _isValid {\n let m_ := mload(0x40)\n let f_ := shl(224, 0x1626ba7e)\n mstore(m_, f_) // `bytes4(keccak256(\"isValidSignature(bytes32,bytes)\"))`.\n mstore(add(m_, 0x04), hash_)\n let d_ := add(m_, 0x24)\n mstore(d_, 0x40) // The offset of the `signature` in the calldata.\n let n_ := add(0x20, mload(signature_))\n pop(staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_))\n _isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)\n _isValid := and(eq(mload(d_), f_), _isValid)\n }\n let noCode := iszero(extcodesize(signer))\n let n := mload(signature)\n for {} 1 {} {\n if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {\n if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }\n break\n }\n if iszero(noCode) {\n let o := add(signature, 0x20) // Signature bytes.\n isValid := callIsValidSignature(signer, hash, add(o, mload(add(o, 0x40))))\n if isValid { break }\n }\n let m := mload(0x40)\n mstore(m, signer)\n mstore(add(m, 0x20), hash)\n let willBeZeroIfRevertingVerifierExists :=\n call(\n gas(), // Remaining gas.\n 0x00007bd799e4A591FeA53f8A8a3E9f931626Ba7e, // Reverting verifier.\n 0, // Send zero ETH.\n m, // Start of memory.\n add(returndatasize(), 0x40), // Length of calldata in memory.\n staticcall(gas(), 4, add(signature, 0x20), n, add(m, 0x40), n), // 1.\n 0x00 // Length of returndata to write.\n )\n isValid := gt(returndatasize(), willBeZeroIfRevertingVerifierExists)\n break\n }\n // Do `ecrecover` fallback if `noCode && !isValid`.\n for {} gt(noCode, isValid) {} {\n switch n\n case 64 {\n let vs := mload(add(signature, 0x40))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.\n mstore(0x60, mload(add(signature, 0x40))) // `s`.\n }\n default { break }\n let m := mload(0x40)\n mstore(0x00, hash)\n mstore(0x40, mload(add(signature, 0x20))) // `r`.\n let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HASHING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns an Ethereum Signed Message, created from a `hash`.\n /// This produces a hash corresponding to the one signed with the\n /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)\n /// JSON-RPC method as part of EIP-191.\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, hash) // Store into scratch space for keccak256.\n mstore(0x00, \"\\x00\\x00\\x00\\x00\\x19Ethereum Signed Message:\\n32\") // 28 bytes.\n result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.\n }\n }\n\n /// @dev Returns an Ethereum Signed Message, created from `s`.\n /// This produces a hash corresponding to the one signed with the\n /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)\n /// JSON-RPC method as part of EIP-191.\n /// Note: Supports lengths of `s` up to 999999 bytes.\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n let sLength := mload(s)\n let o := 0x20\n mstore(o, \"\\x19Ethereum Signed Message:\\n\") // 26 bytes, zero-right-padded.\n mstore(0x00, 0x00)\n // Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.\n for { let temp := sLength } 1 {} {\n o := sub(o, 1)\n mstore8(o, add(48, mod(temp, 10)))\n temp := div(temp, 10)\n if iszero(temp) { break }\n }\n let n := sub(0x3a, o) // Header length: `26 + 32 - o`.\n // Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.\n returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))\n mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.\n result := keccak256(add(s, sub(0x20, n)), add(n, sLength))\n mstore(s, sLength) // Restore the length.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EMPTY CALLDATA HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns an empty calldata bytes.\n function emptySignature() internal pure returns (bytes calldata signature) {\n /// @solidity memory-safe-assembly\n assembly {\n signature.length := 0\n }\n }\n}\n"},"node_modules/solady/src/utils/ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Gas optimized ECDSA wrapper.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)\n///\n/// @dev Note:\n/// - The recovery functions use the ecrecover precompile (0x1).\n/// - As of Solady version 0.0.68, the `recover` variants will revert upon recovery failure.\n/// This is for more safety by default.\n/// Use the `tryRecover` variants if you need to get the zero address back\n/// upon recovery failure instead.\n/// - As of Solady version 0.0.134, all `bytes signature` variants accept both\n/// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.\n/// See: https://eips.ethereum.org/EIPS/eip-2098\n/// This is for calldata efficiency on smart accounts prevalent on L2s.\n///\n/// WARNING! Do NOT directly use signatures as unique identifiers:\n/// - The recovery operations do NOT check if a signature is non-malleable.\n/// - Use a nonce in the digest to prevent replay attacks on the same contract.\n/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.\n/// EIP-712 also enables readable signing of typed data for better user safety.\n/// - If you need a unique hash from a signature, please use the `canonicalHash` functions.\nlibrary ECDSA {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTANTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The order of the secp256k1 elliptic curve.\n uint256 internal constant N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141;\n\n /// @dev `N/2 + 1`. Used for checking the malleability of the signature.\n uint256 private constant _HALF_N_PLUS_1 =\n 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The signature is invalid.\n error InvalidSignature();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* RECOVERY OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.\n function recover(bytes32 hash, bytes memory signature) internal view returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n for { let m := mload(0x40) } 1 {\n mstore(0x00, 0x8baa579f) // `InvalidSignature()`.\n revert(0x1c, 0x04)\n } {\n switch mload(signature)\n case 64 {\n let vs := mload(add(signature, 0x40))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.\n mstore(0x60, mload(add(signature, 0x40))) // `s`.\n }\n default { continue }\n mstore(0x00, hash)\n mstore(0x40, mload(add(signature, 0x20))) // `r`.\n result := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n if returndatasize() { break }\n }\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.\n function recoverCalldata(bytes32 hash, bytes calldata signature)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n for { let m := mload(0x40) } 1 {\n mstore(0x00, 0x8baa579f) // `InvalidSignature()`.\n revert(0x1c, 0x04)\n } {\n switch signature.length\n case 64 {\n let vs := calldataload(add(signature.offset, 0x20))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, calldataload(signature.offset)) // `r`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.\n calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.\n }\n default { continue }\n mstore(0x00, hash)\n result := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n if returndatasize() { break }\n }\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`,\n /// and the EIP-2098 short form signature defined by `r` and `vs`.\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal view returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x00, hash)\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, r)\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n result := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n if iszero(returndatasize()) {\n mstore(0x00, 0x8baa579f) // `InvalidSignature()`.\n revert(0x1c, 0x04)\n }\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`,\n /// and the signature defined by `v`, `r`, `s`.\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x00, hash)\n mstore(0x20, and(v, 0xff))\n mstore(0x40, r)\n mstore(0x60, s)\n result := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n if iszero(returndatasize()) {\n mstore(0x00, 0x8baa579f) // `InvalidSignature()`.\n revert(0x1c, 0x04)\n }\n mstore(0x60, 0) // Restore the zero slot.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* TRY-RECOVER OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // WARNING!\n // These functions will NOT revert upon recovery failure.\n // Instead, they will return the zero address upon recovery failure.\n // It is critical that the returned address is NEVER compared against\n // a zero address (e.g. an uninitialized address variable).\n\n /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.\n function tryRecover(bytes32 hash, bytes memory signature)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n for { let m := mload(0x40) } 1 {} {\n switch mload(signature)\n case 64 {\n let vs := mload(add(signature, 0x40))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.\n mstore(0x60, mload(add(signature, 0x40))) // `s`.\n }\n default { break }\n mstore(0x00, hash)\n mstore(0x40, mload(add(signature, 0x20))) // `r`.\n pop(staticcall(gas(), 1, 0x00, 0x80, 0x40, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n result := mload(xor(0x60, returndatasize()))\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.\n function tryRecoverCalldata(bytes32 hash, bytes calldata signature)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n for { let m := mload(0x40) } 1 {} {\n switch signature.length\n case 64 {\n let vs := calldataload(add(signature.offset, 0x20))\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, calldataload(signature.offset)) // `r`.\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n }\n case 65 {\n mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.\n calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.\n }\n default { break }\n mstore(0x00, hash)\n pop(staticcall(gas(), 1, 0x00, 0x80, 0x40, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n result := mload(xor(0x60, returndatasize()))\n mstore(0x40, m) // Restore the free memory pointer.\n break\n }\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`,\n /// and the EIP-2098 short form signature defined by `r` and `vs`.\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x00, hash)\n mstore(0x20, add(shr(255, vs), 27)) // `v`.\n mstore(0x40, r)\n mstore(0x60, shr(1, shl(1, vs))) // `s`.\n pop(staticcall(gas(), 1, 0x00, 0x80, 0x40, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n result := mload(xor(0x60, returndatasize()))\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Recovers the signer's address from a message digest `hash`,\n /// and the signature defined by `v`, `r`, `s`.\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)\n internal\n view\n returns (address result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x00, hash)\n mstore(0x20, and(v, 0xff))\n mstore(0x40, r)\n mstore(0x60, s)\n pop(staticcall(gas(), 1, 0x00, 0x80, 0x40, 0x20))\n mstore(0x60, 0) // Restore the zero slot.\n // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.\n result := mload(xor(0x60, returndatasize()))\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HASHING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns an Ethereum Signed Message, created from a `hash`.\n /// This produces a hash corresponding to the one signed with the\n /// [`eth_sign`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign)\n /// JSON-RPC method as part of EIP-191.\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, hash) // Store into scratch space for keccak256.\n mstore(0x00, \"\\x00\\x00\\x00\\x00\\x19Ethereum Signed Message:\\n32\") // 28 bytes.\n result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.\n }\n }\n\n /// @dev Returns an Ethereum Signed Message, created from `s`.\n /// This produces a hash corresponding to the one signed with the\n /// [`eth_sign`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign)\n /// JSON-RPC method as part of EIP-191.\n /// Note: Supports lengths of `s` up to 999999 bytes.\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n let sLength := mload(s)\n let o := 0x20\n mstore(o, \"\\x19Ethereum Signed Message:\\n\") // 26 bytes, zero-right-padded.\n mstore(0x00, 0x00)\n // Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.\n for { let temp := sLength } 1 {} {\n o := sub(o, 1)\n mstore8(o, add(48, mod(temp, 10)))\n temp := div(temp, 10)\n if iszero(temp) { break }\n }\n let n := sub(0x3a, o) // Header length: `26 + 32 - o`.\n // Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.\n returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))\n mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.\n result := keccak256(add(s, sub(0x20, n)), add(n, sLength))\n mstore(s, sLength) // Restore the length.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CANONICAL HASH FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // The following functions returns the hash of the signature in it's canonicalized format,\n // which is the 65-byte `abi.encodePacked(r, s, uint8(v))`, where `v` is either 27 or 28.\n // If `s` is greater than `N / 2` then it will be converted to `N - s`\n // and the `v` value will be flipped.\n // If the signature has an invalid length, or if `v` is invalid,\n // a uniquely corrupt hash will be returned.\n // These functions are useful for \"poor-mans-VRF\".\n\n /// @dev Returns the canonical hash of `signature`.\n function canonicalHash(bytes memory signature) internal pure returns (bytes32 result) {\n // @solidity memory-safe-assembly\n assembly {\n let l := mload(signature)\n for {} 1 {} {\n mstore(0x00, mload(add(signature, 0x20))) // `r`.\n let s := mload(add(signature, 0x40))\n let v := mload(add(signature, 0x41))\n if eq(l, 64) {\n v := add(shr(255, s), 27)\n s := shr(1, shl(1, s))\n }\n if iszero(lt(s, _HALF_N_PLUS_1)) {\n v := xor(v, 7)\n s := sub(N, s)\n }\n mstore(0x21, v)\n mstore(0x20, s)\n result := keccak256(0x00, 0x41)\n mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.\n break\n }\n\n // If the length is neither 64 nor 65, return a uniquely corrupted hash.\n if iszero(lt(sub(l, 64), 2)) {\n // `bytes4(keccak256(\"InvalidSignatureLength\"))`.\n result := xor(keccak256(add(signature, 0x20), l), 0xd62f1ab2)\n }\n }\n }\n\n /// @dev Returns the canonical hash of `signature`.\n function canonicalHashCalldata(bytes calldata signature)\n internal\n pure\n returns (bytes32 result)\n {\n // @solidity memory-safe-assembly\n assembly {\n for {} 1 {} {\n mstore(0x00, calldataload(signature.offset)) // `r`.\n let s := calldataload(add(signature.offset, 0x20))\n let v := calldataload(add(signature.offset, 0x21))\n if eq(signature.length, 64) {\n v := add(shr(255, s), 27)\n s := shr(1, shl(1, s))\n }\n if iszero(lt(s, _HALF_N_PLUS_1)) {\n v := xor(v, 7)\n s := sub(N, s)\n }\n mstore(0x21, v)\n mstore(0x20, s)\n result := keccak256(0x00, 0x41)\n mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.\n break\n }\n // If the length is neither 64 nor 65, return a uniquely corrupted hash.\n if iszero(lt(sub(signature.length, 64), 2)) {\n calldatacopy(mload(0x40), signature.offset, signature.length)\n // `bytes4(keccak256(\"InvalidSignatureLength\"))`.\n result := xor(keccak256(mload(0x40), signature.length), 0xd62f1ab2)\n }\n }\n }\n\n /// @dev Returns the canonical hash of `signature`.\n function canonicalHash(bytes32 r, bytes32 vs) internal pure returns (bytes32 result) {\n // @solidity memory-safe-assembly\n assembly {\n mstore(0x00, r) // `r`.\n let v := add(shr(255, vs), 27)\n let s := shr(1, shl(1, vs))\n mstore(0x21, v)\n mstore(0x20, s)\n result := keccak256(0x00, 0x41)\n mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.\n }\n }\n\n /// @dev Returns the canonical hash of `signature`.\n function canonicalHash(uint8 v, bytes32 r, bytes32 s) internal pure returns (bytes32 result) {\n // @solidity memory-safe-assembly\n assembly {\n mstore(0x00, r) // `r`.\n if iszero(lt(s, _HALF_N_PLUS_1)) {\n v := xor(v, 7)\n s := sub(N, s)\n }\n mstore(0x21, v)\n mstore(0x20, s)\n result := keccak256(0x00, 0x41)\n mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EMPTY CALLDATA HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns an empty calldata bytes.\n function emptySignature() internal pure returns (bytes calldata signature) {\n /// @solidity memory-safe-assembly\n assembly {\n signature.length := 0\n }\n }\n}\n"},"contracts/token/swaps/Uniswapper.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.27;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\";\nimport { IV3SwapRouter } from \"@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol\";\n\n/**\n * @title Uniswapper\n * @author ShivaanshK\n * @notice An abstract contract to assist the paymaster in swapping tokens to WETH and unwrapping WETH\n * @notice Based on Infinitism's Uniswap Helper contract\n */\nabstract contract Uniswapper {\n\n event SwappingReverted(address tokenIn, uint256 amountIn, bytes reason);\n error UnwrappingReverted(uint256 amount);\n\n /// @notice The ERC-20 token that wraps the native asset for current chain\n address public immutable wrappedNative;\n\n // Token address -> Fee tier of the pool to swap through\n mapping(address => uint24) public tokenToPools;\n\n /// @notice The Uniswap V3 SwapRouter contract\n IV3SwapRouter public uniswapRouter;\n\n // Errors\n error UniswapReverted(address tokenIn, address tokenOut, uint256 amountIn);\n error TokensAndPoolsLengthMismatch();\n error TokenNotSupported();\n\n constructor(\n IV3SwapRouter uniswapRouterArg,\n address wrappedNativeArg,\n address[] memory tokens,\n uint24[] memory tokenPoolFeeTiers\n ) {\n if (tokens.length != tokenPoolFeeTiers.length) {\n revert TokensAndPoolsLengthMismatch();\n }\n\n // Set router and native wrapped asset addresses\n uniswapRouter = uniswapRouterArg;\n wrappedNative = wrappedNativeArg;\n\n for (uint256 i = 0; i < tokens.length; ++i) {\n IERC20(tokens[i]).approve(address(uniswapRouter), type(uint256).max); // one time max approval\n tokenToPools[tokens[i]] = tokenPoolFeeTiers[i]; // set mapping of token to uniswap pool to use for swap\n }\n }\n\n function _setTokenPool(address token, uint24 poolFeeTier) internal {\n SafeERC20.forceApprove(IERC20(token), address(uniswapRouter), type(uint256).max); // one time max approval\n tokenToPools[token] = poolFeeTier; // set mapping of token to uniswap pool to use for swap\n }\n\n function _swapTokenToWeth(address tokenIn, uint256 amountIn, uint256 minAmountOut) internal returns (uint256 amountOut) {\n require(tokenToPools[tokenIn] != 0, TokenNotSupported());\n IV3SwapRouter.ExactInputSingleParams memory params = IV3SwapRouter.ExactInputSingleParams({\n tokenIn: tokenIn,\n tokenOut: wrappedNative,\n fee: tokenToPools[tokenIn],\n recipient: address(this),\n //deadline: block.timestamp, // legacy interface arg. Intentiaonally omitted.\n amountIn: amountIn,\n amountOutMinimum: minAmountOut,\n sqrtPriceLimitX96: 0\n });\n\n try uniswapRouter.exactInputSingle(params) returns (uint256 _amountOut) {\n amountOut = _amountOut;\n } catch (bytes memory reason) {\n emit SwappingReverted(tokenIn, amountIn, reason);\n amountOut = 0;\n }\n }\n\n function _unwrapWeth(uint256 amount) internal {\n if(amount == 0) return;\n (bool success, ) = address(wrappedNative).call(abi.encodeWithSignature(\"withdraw(uint256)\", amount));\n if (!success) revert UnwrappingReverted(amount);\n }\n\n function _setUniswapRouter(IV3SwapRouter uniswapRouterArg) internal {\n uniswapRouter = uniswapRouterArg;\n }\n}\n"},"node_modules/account-abstraction/contracts/core/Helpers.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable no-inline-assembly */\n\n\n /*\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\n * must return this value in case of signature failure, instead of revert.\n */\nuint256 constant SIG_VALIDATION_FAILED = 1;\n\n\n/*\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\n * return this value on success.\n */\nuint256 constant SIG_VALIDATION_SUCCESS = 0;\n\n\n/**\n * Returned data from validateUserOp.\n * validateUserOp returns a uint256, which is created by `_packedValidationData` and\n * parsed by `_parseValidationData`.\n * @param aggregator - address(0) - The account validated the signature by itself.\n * address(1) - The account failed to validate the signature.\n * otherwise - This is an address of a signature aggregator that must\n * be used to validate the signature.\n * @param validAfter - This UserOp is valid only after this timestamp.\n * @param validaUntil - This UserOp is valid only up to this timestamp.\n */\nstruct ValidationData {\n address aggregator;\n uint48 validAfter;\n uint48 validUntil;\n}\n\n/**\n * Extract sigFailed, validAfter, validUntil.\n * Also convert zero validUntil to type(uint48).max.\n * @param validationData - The packed validation data.\n */\nfunction _parseValidationData(\n uint256 validationData\n) pure returns (ValidationData memory data) {\n address aggregator = address(uint160(validationData));\n uint48 validUntil = uint48(validationData >> 160);\n if (validUntil == 0) {\n validUntil = type(uint48).max;\n }\n uint48 validAfter = uint48(validationData >> (48 + 160));\n return ValidationData(aggregator, validAfter, validUntil);\n}\n\n/**\n * Helper to pack the return value for validateUserOp.\n * @param data - The ValidationData to pack.\n */\nfunction _packValidationData(\n ValidationData memory data\n) pure returns (uint256) {\n return\n uint160(data.aggregator) |\n (uint256(data.validUntil) << 160) |\n (uint256(data.validAfter) << (160 + 48));\n}\n\n/**\n * Helper to pack the return value for validateUserOp, when not using an aggregator.\n * @param sigFailed - True for signature failure, false for success.\n * @param validUntil - Last timestamp this UserOperation is valid (or zero for infinite).\n * @param validAfter - First timestamp this UserOperation is valid.\n */\nfunction _packValidationData(\n bool sigFailed,\n uint48 validUntil,\n uint48 validAfter\n) pure returns (uint256) {\n return\n (sigFailed ? 1 : 0) |\n (uint256(validUntil) << 160) |\n (uint256(validAfter) << (160 + 48));\n}\n\n/**\n * keccak function over calldata.\n * @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.\n */\n function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {\n assembly (\"memory-safe\") {\n let mem := mload(0x40)\n let len := data.length\n calldatacopy(mem, data.offset, len)\n ret := keccak256(mem, len)\n }\n }\n\n\n/**\n * The minimum of two numbers.\n * @param a - First number.\n * @param b - Second number.\n */\n function min(uint256 a, uint256 b) pure returns (uint256) {\n return a < b ? a : b;\n }\n"},"node_modules/@openzeppelin/contracts/utils/TransientSlot.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/TransientSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.\n\npragma solidity ^0.8.24;\n\n/**\n * @dev Library for reading and writing value-types to specific transient storage slots.\n *\n * Transient slots are often used to store temporary values that are removed after the current transaction.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * * Example reading and writing values using transient storage:\n * ```solidity\n * contract Lock {\n * using TransientSlot for *;\n *\n * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.\n * bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;\n *\n * modifier locked() {\n * require(!_LOCK_SLOT.asBoolean().tload());\n *\n * _LOCK_SLOT.asBoolean().tstore(true);\n * _;\n * _LOCK_SLOT.asBoolean().tstore(false);\n * }\n * }\n * ```\n *\n * TIP: Consider using this library along with {SlotDerivation}.\n */\nlibrary TransientSlot {\n /**\n * @dev UDVT that represent a slot holding a address.\n */\n type AddressSlot is bytes32;\n\n /**\n * @dev Cast an arbitrary slot to a AddressSlot.\n */\n function asAddress(bytes32 slot) internal pure returns (AddressSlot) {\n return AddressSlot.wrap(slot);\n }\n\n /**\n * @dev UDVT that represent a slot holding a bool.\n */\n type BooleanSlot is bytes32;\n\n /**\n * @dev Cast an arbitrary slot to a BooleanSlot.\n */\n function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {\n return BooleanSlot.wrap(slot);\n }\n\n /**\n * @dev UDVT that represent a slot holding a bytes32.\n */\n type Bytes32Slot is bytes32;\n\n /**\n * @dev Cast an arbitrary slot to a Bytes32Slot.\n */\n function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {\n return Bytes32Slot.wrap(slot);\n }\n\n /**\n * @dev UDVT that represent a slot holding a uint256.\n */\n type Uint256Slot is bytes32;\n\n /**\n * @dev Cast an arbitrary slot to a Uint256Slot.\n */\n function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {\n return Uint256Slot.wrap(slot);\n }\n\n /**\n * @dev UDVT that represent a slot holding a int256.\n */\n type Int256Slot is bytes32;\n\n /**\n * @dev Cast an arbitrary slot to a Int256Slot.\n */\n function asInt256(bytes32 slot) internal pure returns (Int256Slot) {\n return Int256Slot.wrap(slot);\n }\n\n /**\n * @dev Load the value held at location `slot` in transient storage.\n */\n function tload(AddressSlot slot) internal view returns (address value) {\n assembly (\"memory-safe\") {\n value := tload(slot)\n }\n }\n\n /**\n * @dev Store `value` at location `slot` in transient storage.\n */\n function tstore(AddressSlot slot, address value) internal {\n assembly (\"memory-safe\") {\n tstore(slot, value)\n }\n }\n\n /**\n * @dev Load the value held at location `slot` in transient storage.\n */\n function tload(BooleanSlot slot) internal view returns (bool value) {\n assembly (\"memory-safe\") {\n value := tload(slot)\n }\n }\n\n /**\n * @dev Store `value` at location `slot` in transient storage.\n */\n function tstore(BooleanSlot slot, bool value) internal {\n assembly (\"memory-safe\") {\n tstore(slot, value)\n }\n }\n\n /**\n * @dev Load the value held at location `slot` in transient storage.\n */\n function tload(Bytes32Slot slot) internal view returns (bytes32 value) {\n assembly (\"memory-safe\") {\n value := tload(slot)\n }\n }\n\n /**\n * @dev Store `value` at location `slot` in transient storage.\n */\n function tstore(Bytes32Slot slot, bytes32 value) internal {\n assembly (\"memory-safe\") {\n tstore(slot, value)\n }\n }\n\n /**\n * @dev Load the value held at location `slot` in transient storage.\n */\n function tload(Uint256Slot slot) internal view returns (uint256 value) {\n assembly (\"memory-safe\") {\n value := tload(slot)\n }\n }\n\n /**\n * @dev Store `value` at location `slot` in transient storage.\n */\n function tstore(Uint256Slot slot, uint256 value) internal {\n assembly (\"memory-safe\") {\n tstore(slot, value)\n }\n }\n\n /**\n * @dev Load the value held at location `slot` in transient storage.\n */\n function tload(Int256Slot slot) internal view returns (int256 value) {\n assembly (\"memory-safe\") {\n value := tload(slot)\n }\n }\n\n /**\n * @dev Store `value` at location `slot` in transient storage.\n */\n function tstore(Int256Slot slot, int256 value) internal {\n assembly (\"memory-safe\") {\n tstore(slot, value)\n }\n }\n}\n"},"node_modules/account-abstraction/contracts/interfaces/PackedUserOperation.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/**\n * User Operation struct\n * @param sender - The sender account of this request.\n * @param nonce - Unique value the sender uses to verify it is not a replay.\n * @param initCode - If set, the account contract will be created by this constructor/\n * @param callData - The method call to execute on this account.\n * @param accountGasLimits - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\n * @param preVerificationGas - Gas not calculated by the handleOps method, but added to the gas paid.\n * Covers batch overhead.\n * @param gasFees - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.\n * @param paymasterAndData - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\n * The paymaster will pay for the transaction instead of the sender.\n * @param signature - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\n */\nstruct PackedUserOperation {\n address sender;\n uint256 nonce;\n bytes initCode;\n bytes callData;\n bytes32 accountGasLimits;\n uint256 preVerificationGas;\n bytes32 gasFees;\n bytes paymasterAndData;\n bytes signature;\n}\n"},"node_modules/account-abstraction/contracts/interfaces/IStakeManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.7.5;\n\n/**\n * Manage deposits and stakes.\n * Deposit is just a balance used to pay for UserOperations (either by a paymaster or an account).\n * Stake is value locked for at least \"unstakeDelay\" by the staked entity.\n */\ninterface IStakeManager {\n event Deposited(address indexed account, uint256 totalDeposit);\n\n event Withdrawn(\n address indexed account,\n address withdrawAddress,\n uint256 amount\n );\n\n // Emitted when stake or unstake delay are modified.\n event StakeLocked(\n address indexed account,\n uint256 totalStaked,\n uint256 unstakeDelaySec\n );\n\n // Emitted once a stake is scheduled for withdrawal.\n event StakeUnlocked(address indexed account, uint256 withdrawTime);\n\n event StakeWithdrawn(\n address indexed account,\n address withdrawAddress,\n uint256 amount\n );\n\n /**\n * @param deposit - The entity's deposit.\n * @param staked - True if this entity is staked.\n * @param stake - Actual amount of ether staked for this entity.\n * @param unstakeDelaySec - Minimum delay to withdraw the stake.\n * @param withdrawTime - First block timestamp where 'withdrawStake' will be callable, or zero if already locked.\n * @dev Sizes were chosen so that deposit fits into one cell (used during handleOp)\n * and the rest fit into a 2nd cell (used during stake/unstake)\n * - 112 bit allows for 10^15 eth\n * - 48 bit for full timestamp\n * - 32 bit allows 150 years for unstake delay\n */\n struct DepositInfo {\n uint256 deposit;\n bool staked;\n uint112 stake;\n uint32 unstakeDelaySec;\n uint48 withdrawTime;\n }\n\n // API struct used by getStakeInfo and simulateValidation.\n struct StakeInfo {\n uint256 stake;\n uint256 unstakeDelaySec;\n }\n\n /**\n * Get deposit info.\n * @param account - The account to query.\n * @return info - Full deposit information of given account.\n */\n function getDepositInfo(\n address account\n ) external view returns (DepositInfo memory info);\n\n /**\n * Get account balance.\n * @param account - The account to query.\n * @return - The deposit (for gas payment) of the account.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * Add to the deposit of the given account.\n * @param account - The account to add to.\n */\n function depositTo(address account) external payable;\n\n /**\n * Add to the account's stake - amount and delay\n * any pending unstake is first cancelled.\n * @param _unstakeDelaySec - The new lock duration before the deposit can be withdrawn.\n */\n function addStake(uint32 _unstakeDelaySec) external payable;\n\n /**\n * Attempt to unlock the stake.\n * The value can be withdrawn (using withdrawStake) after the unstake delay.\n */\n function unlockStake() external;\n\n /**\n * Withdraw from the (unlocked) stake.\n * Must first call unlockStake and wait for the unstakeDelay to pass.\n * @param withdrawAddress - The address to send withdrawn value.\n */\n function withdrawStake(address payable withdrawAddress) external;\n\n /**\n * Withdraw from the deposit.\n * @param withdrawAddress - The address to send withdrawn value.\n * @param withdrawAmount - The amount to withdraw.\n */\n function withdrawTo(\n address payable withdrawAddress,\n uint256 withdrawAmount\n ) external;\n}\n"},"node_modules/account-abstraction/contracts/interfaces/IAggregator.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\nimport \"./PackedUserOperation.sol\";\n\n/**\n * Aggregated Signatures validator.\n */\ninterface IAggregator {\n /**\n * Validate aggregated signature.\n * Revert if the aggregated signature does not match the given list of operations.\n * @param userOps - Array of UserOperations to validate the signature for.\n * @param signature - The aggregated signature.\n */\n function validateSignatures(\n PackedUserOperation[] calldata userOps,\n bytes calldata signature\n ) external view;\n\n /**\n * Validate signature of a single userOp.\n * This method should be called by bundler after EntryPointSimulation.simulateValidation() returns\n * the aggregator this account uses.\n * First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps.\n * @param userOp - The userOperation received from the user.\n * @return sigForUserOp - The value to put into the signature field of the userOp when calling handleOps.\n * (usually empty, unless account and aggregator support some kind of \"multisig\".\n */\n function validateUserOpSignature(\n PackedUserOperation calldata userOp\n ) external view returns (bytes memory sigForUserOp);\n\n /**\n * Aggregate multiple signatures into a single value.\n * This method is called off-chain to calculate the signature to pass with handleOps()\n * bundler MAY use optimized custom code perform this aggregation.\n * @param userOps - Array of UserOperations to collect the signatures from.\n * @return aggregatedSignature - The aggregated signature.\n */\n function aggregateSignatures(\n PackedUserOperation[] calldata userOps\n ) external view returns (bytes memory aggregatedSignature);\n}\n"},"node_modules/account-abstraction/contracts/interfaces/INonceManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\ninterface INonceManager {\n\n /**\n * Return the next nonce for this sender.\n * Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop)\n * But UserOp with different keys can come with arbitrary order.\n *\n * @param sender the account address\n * @param key the high 192 bit of the nonce\n * @return nonce a full nonce to pass for next UserOp with this sender.\n */\n function getNonce(address sender, uint192 key)\n external view returns (uint256 nonce);\n\n /**\n * Manually increment the nonce of the sender.\n * This method is exposed just for completeness..\n * Account does NOT need to call it, neither during validation, nor elsewhere,\n * as the EntryPoint will update the nonce regardless.\n * Possible use-case is call it with various keys to \"initialize\" their nonces to one, so that future\n * UserOperations will not pay extra for the first transaction with a given key.\n */\n function incrementNonce(uint192 key) external;\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"},"node_modules/@openzeppelin/contracts/utils/Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC-20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC-721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC-1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @title IERC1363\n * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].\n *\n * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract\n * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.\n */\ninterface IERC1363 is IERC20, IERC165 {\n /*\n * Note: the ERC-165 identifier for this interface is 0xb0202a11.\n * 0xb0202a11 ===\n * bytes4(keccak256('transferAndCall(address,uint256)')) ^\n * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^\n * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^\n * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^\n * bytes4(keccak256('approveAndCall(address,uint256)')) ^\n * bytes4(keccak256('approveAndCall(address,uint256,bytes)'))\n */\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferAndCall(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @param data Additional data with no specified format, sent in call to `to`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param from The address which you want to send tokens from.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferFromAndCall(address from, address to, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param from The address which you want to send tokens from.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @param data Additional data with no specified format, sent in call to `to`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function approveAndCall(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n * @param data Additional data with no specified format, sent in call to `spender`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);\n}\n"},"node_modules/@openzeppelin/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert Errors.InsufficientBalance(address(this).balance, amount);\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {Errors.FailedCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert Errors.InsufficientBalance(address(this).balance, value);\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n * of an unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 && target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {Errors.FailedCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n assembly (\"memory-safe\") {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert Errors.FailedCall();\n }\n }\n}\n"},"contracts/utils/SoladyOwnable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.27;\n\nimport { Ownable } from \"solady/auth/Ownable.sol\";\n\ncontract SoladyOwnable is Ownable {\n constructor(address _owner) Ownable() {\n assembly {\n if iszero(shl(96, _owner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _initializeOwner(_owner);\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"node_modules/account-abstraction/contracts/interfaces/IPaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\nimport \"./PackedUserOperation.sol\";\n\n/**\n * The interface exposed by a paymaster contract, who agrees to pay the gas for user's operations.\n * A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.\n */\ninterface IPaymaster {\n enum PostOpMode {\n // User op succeeded.\n opSucceeded,\n // User op reverted. Still has to pay for gas.\n opReverted,\n // Only used internally in the EntryPoint (cleanup after postOp reverts). Never calling paymaster with this value\n postOpReverted\n }\n\n /**\n * Payment validation: check if paymaster agrees to pay.\n * Must verify sender is the entryPoint.\n * Revert to reject this request.\n * Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted).\n * The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns.\n * @param userOp - The user operation.\n * @param userOpHash - Hash of the user's request data.\n * @param maxCost - The maximum cost of this transaction (based on maximum gas and gas price from userOp).\n * @return context - Value to send to a postOp. Zero length to signify postOp is not required.\n * @return validationData - Signature and time-range of this operation, encoded the same as the return\n * value of validateUserOperation.\n * <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\n * other values are invalid for paymaster.\n * <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\"\n * <6-byte> validAfter - first timestamp this operation is valid\n * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) external returns (bytes memory context, uint256 validationData);\n\n /**\n * Post-operation handler.\n * Must verify sender is the entryPoint.\n * @param mode - Enum with the following options:\n * opSucceeded - User operation succeeded.\n * opReverted - User op reverted. The paymaster still has to pay for gas.\n * postOpReverted - never passed in a call to postOp().\n * @param context - The context value returned by validatePaymasterUserOp\n * @param actualGasCost - Actual gas used so far (without this postOp call).\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\n * and maxPriorityFee (and basefee)\n * It is not the same as tx.gasprice, which is what the bundler pays.\n */\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) external;\n}\n"},"node_modules/@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Periphery Payments\n/// @notice Functions to ease deposits and withdrawals of ETH\ninterface IPeripheryPayments {\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\n /// @param recipient The address receiving ETH\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\n\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\n /// that use ether for the input amount\n function refundETH() external payable;\n\n /// @notice Transfers the full amount of a token held by this contract to recipient\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\n /// @param token The contract address of the token which will be transferred to `recipient`\n /// @param amountMinimum The minimum amount of token required for a transfer\n /// @param recipient The destination address of the token\n function sweepToken(\n address token,\n uint256 amountMinimum,\n address recipient\n ) external payable;\n}\n"},"node_modules/@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n"},"node_modules/@openzeppelin/contracts/utils/Errors.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error InsufficientBalance(uint256 balance, uint256 needed);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedCall();\n\n /**\n * @dev The deployment failed.\n */\n error FailedDeployment();\n\n /**\n * @dev A necessary precompile is missing.\n */\n error MissingPrecompile(address);\n}\n"},"node_modules/solady/src/auth/Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple single owner authorization mixin.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\n///\n/// @dev Note:\n/// This implementation does NOT auto-initialize the owner to `msg.sender`.\n/// You MUST call the `_initializeOwner` in the constructor / initializer.\n///\n/// While the ownable portion follows\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\nabstract contract Ownable {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The caller is not authorized to call the function.\n error Unauthorized();\n\n /// @dev The `newOwner` cannot be the zero address.\n error NewOwnerIsZeroAddress();\n\n /// @dev The `pendingOwner` does not have a valid handover request.\n error NoHandoverRequest();\n\n /// @dev Cannot double-initialize.\n error AlreadyInitialized();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\n /// despite it not being as lightweight as a single argument event.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev An ownership handover to `pendingOwner` has been requested.\n event OwnershipHandoverRequested(address indexed pendingOwner);\n\n /// @dev The ownership handover to `pendingOwner` has been canceled.\n event OwnershipHandoverCanceled(address indexed pendingOwner);\n\n /// @dev `keccak256(bytes(\"OwnershipTransferred(address,address)\"))`.\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverRequested(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverCanceled(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The owner slot is given by:\n /// `bytes32(~uint256(uint32(bytes4(keccak256(\"_OWNER_SLOT_NOT\")))))`.\n /// It is intentionally chosen to be a high value\n /// to avoid collision with lower slots.\n /// The choice of manual storage layout is to enable compatibility\n /// with both regular and upgradeable contracts.\n bytes32 internal constant _OWNER_SLOT =\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;\n\n /// The ownership handover slot of `newOwner` is given by:\n /// ```\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\n /// let handoverSlot := keccak256(0x00, 0x20)\n /// ```\n /// It stores the expiry timestamp of the two-step ownership handover.\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.\n function _guardInitializeOwner() internal pure virtual returns (bool guard) {}\n\n /// @dev Initializes the owner directly without authorization guard.\n /// This function must be called upon initialization,\n /// regardless of whether the contract is upgradeable or not.\n /// This is to enable generalization to both regular and upgradeable contracts,\n /// and to save gas in case the initial owner is not the caller.\n /// For performance reasons, this function will not check if there\n /// is an existing owner.\n function _initializeOwner(address newOwner) internal virtual {\n if (_guardInitializeOwner()) {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n if sload(ownerSlot) {\n mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.\n revert(0x1c, 0x04)\n }\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(_OWNER_SLOT, newOwner)\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n }\n }\n\n /// @dev Sets the owner directly without authorization guard.\n function _setOwner(address newOwner) internal virtual {\n if (_guardInitializeOwner()) {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\n }\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, newOwner)\n }\n }\n }\n\n /// @dev Throws if the sender is not the owner.\n function _checkOwner() internal view virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // If the caller is not the stored owner, revert.\n if iszero(eq(caller(), sload(_OWNER_SLOT))) {\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\n /// Override to return a different value if needed.\n /// Made internal to conserve bytecode. Wrap it in a public function if needed.\n function _ownershipHandoverValidFor() internal view virtual returns (uint64) {\n return 48 * 3600;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC UPDATE FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(shl(96, newOwner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _setOwner(newOwner);\n }\n\n /// @dev Allows the owner to renounce their ownership.\n function renounceOwnership() public payable virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /// @dev Request a two-step ownership handover to the caller.\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\n function requestOwnershipHandover() public payable virtual {\n unchecked {\n uint256 expires = block.timestamp + _ownershipHandoverValidFor();\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to `expires`.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), expires)\n // Emit the {OwnershipHandoverRequested} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\n }\n }\n }\n\n /// @dev Cancels the two-step ownership handover to the caller, if any.\n function cancelOwnershipHandover() public payable virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), 0)\n // Emit the {OwnershipHandoverCanceled} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\n }\n }\n\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n let handoverSlot := keccak256(0x0c, 0x20)\n // If the handover does not exist, or has expired.\n if gt(timestamp(), sload(handoverSlot)) {\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\n revert(0x1c, 0x04)\n }\n // Set the handover slot to 0.\n sstore(handoverSlot, 0)\n }\n _setOwner(pendingOwner);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC READ FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the owner of the contract.\n function owner() public view virtual returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := sload(_OWNER_SLOT)\n }\n }\n\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\n function ownershipHandoverExpiresAt(address pendingOwner)\n public\n view\n virtual\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the handover slot.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n // Load the handover slot.\n result := sload(keccak256(0x0c, 0x20))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MODIFIERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Marks a function as only callable by the owner.\n modifier onlyOwner() virtual {\n _checkOwner();\n _;\n }\n}\n"},"node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n"}},"settings":{"remappings":["@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/","@prb/test/=node_modules/@prb/test/","@nexus/=node_modules/nexus/","forge-std/=lib/forge-std/src/","account-abstraction/=node_modules/account-abstraction/contracts/","@ERC4337/account-abstraction/=node_modules/account-abstraction/","@modulekit/=node_modules/modulekit/src/","sentinellist/=node_modules/sentinellist/src/","solady/=node_modules/solady/src/","@uniswap/v3-periphery/contracts/=node_modules/@uniswap/v3-periphery/contracts/","@uniswap/v3-core/contracts/=node_modules/@uniswap/v3-core/contracts/","@uniswap/swap-router-contracts/contracts/=node_modules/@uniswap/swap-router-contracts/contracts/","solady/src/=node_modules/solady/src/","excessively-safe-call/=node_modules/excessively-safe-call/src/","modulekit/=node_modules/@rhinestone/modulekit/src/","module-bases/=node_modules/module-bases/src/","erc7579/=node_modules/erc7579/src/","kernel/=node_modules/@zerodev/kernel/src/","@safe-global/=node_modules/@safe-global/","solarray/=node_modules/solarray/src/","erc7739Validator/=node_modules/erc7739-validator-base/src/","@biconomy-devx/=node_modules/@biconomy-devx/","@erc7579/=node_modules/@erc7579/","@gnosis.pm/=node_modules/@gnosis.pm/","@prb/math/=node_modules/erc7739-validator-base/node_modules/@prb/math/src/","@rhinestone/=node_modules/@rhinestone/","@zerodev/=node_modules/@zerodev/","ExcessivelySafeCall/=node_modules/erc7739-validator-base/node_modules/excessively-safe-call/src/","account-abstraction-v0.6/=node_modules/account-abstraction-v0.6/","accountabstraction/=node_modules/accountabstraction/","base64-sol/=node_modules/base64-sol/","ds-test/=node_modules/ds-test/","enumerableset4337/=node_modules/erc7739-validator-base/node_modules/@erc7579/enumerablemap4337/src/","erc4337-validation/=node_modules/erc7739-validator-base/node_modules/@rhinestone/erc4337-validation/src/","erc7739-validator-base/=node_modules/erc7739-validator-base/","hardhat-deploy/=node_modules/hardhat-deploy/","hardhat/=node_modules/hardhat/","nexus/=node_modules/nexus/","registry/=node_modules/modulekit/node_modules/@rhinestone/registry/src/","safe7579/=node_modules/erc7739-validator-base/node_modules/@rhinestone/safe7579/src/"],"optimizer":{"enabled":true,"runs":800},"metadata":{"useLiteralContent":false,"bytecodeHash":"none","appendCBOR":true},"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"]}},"evmVersion":"cancun","viaIR":true,"libraries":{}}} diff --git a/scripts/foundry/DeployGasdaddy.s.sol b/scripts/foundry/DeployGasdaddy.s.sol index e2e717c..3866a08 100644 --- a/scripts/foundry/DeployGasdaddy.s.sol +++ b/scripts/foundry/DeployGasdaddy.s.sol @@ -27,8 +27,8 @@ contract DeployGasdaddy is Script { } // SALTS - bytes32 constant SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT = 0x3e81534a95d3368136d6c49522f8e20ada0b768931512a65c785c15a83178777; // - bytes32 constant TOKEN_PAYMASTER_DEPLOYMENT_SALT = 0xf5516e76713013dc560228c61d8ad21680be770b25fcaed28edf3071e09bb777; // + bytes32 constant SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT = 0xc9ec6c618ddf6abc86e028d1ec4b5134220e43bf3077b043e67f191f9eb347e1; // ==> 0x000000f05e956f96bbcbf39012809070da94047c + bytes32 constant TOKEN_PAYMASTER_DEPLOYMENT_SALT = 0xaa3606532a9bab499b169e3b3b73d84c75b65a74c34a55188d89a91402de1936; // ==> 0x00000054bbe1c7aefb16e7cc9be4f5ebd7e88361 // CONSTRUCTOR ARGS address constant VERIFYING_PAYMASTER_OWNER = 0x2cf491602ad22944D9047282aBC00D3e52F56B37;