// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {
UserOperation
} from "@account-abstraction/contracts/interfaces/UserOperation.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @dev Immutable parameters of a checkout account.
struct CheckoutParams {
bytes32 userOpHash;
bytes32 targetAsset;
uint96 targetChainId;
uint128 targetAmount;
uint128 expiration;
bytes32 recipient;
}
/// @dev State of a checkout account.
struct CheckoutState {
CheckoutParams params;
IERC20 heldAsset;
uint256 heldAmount;
}
struct SwapParams {
address target;
address spender;
bytes callData;
address receivedAsset;
bool isETHSwap;
}
struct BridgeParams {
address target;
address spender;
bytes callData;
IERC20 bridgeReceivedAsset;
uint256 minBridgeReceivedAmount;
}
interface CheckoutPoolInterface {
function deposit(CheckoutState calldata checkoutState) external;
function swap(
address depositAddress,
SwapParams calldata swapParams
) external;
function bridge(
address depositAddress,
BridgeParams calldata bridgeParams
) external;
function execute(
address depositAddress,
UserOperation[] calldata ops // length-1 array (gas optimization)
) external;
function checkoutExists(
address depositAddress
) external view returns (bool);
function getCheckout(
address depositAddress
) external view returns (CheckoutState memory);
function getCheckoutOrZero(
address depositAddress
) external view returns (CheckoutState memory);
function forwardFund(address depositAddress) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
interface Create2ForwarderEventsAndErrors {
error AlreadyForwarded();
error ForwardError(bytes errorData);
error Underfunded(uint256 actualHeldAmount, uint256 minSourceAmount);
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { CheckoutPoolInterface } from "../interfaces/CheckoutPoolInterface.sol";
import {
Create2ForwarderInterface
} from "../interfaces/Create2ForwarderInterface.sol";
import {
Create2ForwarderFactoryInterface
} from "../interfaces/Create2ForwarderFactoryInterface.sol";
import { CheckoutState } from "../interfaces/CheckoutPoolInterface.sol";
import { WETH9Interface } from "../interfaces/WETH9Interface.sol";
import { Create2ForwarderImpl } from "../forwarder/Create2ForwarderImpl.sol";
import { Create2ForwarderProxy } from "./Create2ForwarderProxy.sol";
/**
* @title Create2ForwarderFactory
* @author Fun.xyz
*
* @notice Factory for “counterfactual” forwarder contracts for the Checkout Pools protocol.
*
* A forwarder contract is created for each checkout operation executed by the protocol.
* It is the entry point for funds into the protocol.
*
* Before the forwarder contract is deployed, its CREATE2 address (the “deposit address”)
* is calculated, so that the contract can be deployed only as needed, after funds have
* been deposited.
*
* As a gas optimization, each forwarder contract is deployed as a proxy. All of the proxy
* contracts reference the same implementation logic, which is a constant on the factory contract.
*
* As a gas optimization, checkout parameters that are not expected to change (often) are
* stored as constants on the factory contract. Parameters that do not need to be stored
* on-chain (e.g. the full user operation) are expected to be stored off-chain by the liquidity
* provider that is responsible for executing the checkout.
*
* Constants (same for all forwarders created by the factory).
* - source chain
* - guardian address
* - CheckoutPools contract address (corresponds to a liquidity provider)
* - wrapped native token address
*
* On-chain configuration (different for each forwarder / checkout operation)
* - user op hash
* - target chain
* - target asset and amount
* - source asset and amount
* - expiration timestamp
* - salt (not stored)
*
* Off-chain configuration
* - user op
*/
contract Create2ForwarderFactory is Create2ForwarderFactoryInterface {
error ErrorCreatingProxy();
Create2ForwarderImpl public immutable IMPLEMENTATION;
constructor(
address guardian,
WETH9Interface wrappedNativeToken,
CheckoutPoolInterface checkoutPool
) {
IMPLEMENTATION = new Create2ForwarderImpl(
guardian,
wrappedNativeToken,
checkoutPool
);
}
function create(
CheckoutState calldata checkout,
bytes32 salt
) external returns (Create2ForwarderInterface) {
return _create(checkout, salt);
}
function createAndForward(
CheckoutState calldata checkout,
bytes32 salt
) external returns (Create2ForwarderInterface) {
Create2ForwarderInterface proxy = _create(checkout, salt);
proxy.forward();
return proxy;
}
function getAddress(
CheckoutState calldata checkout,
bytes32 salt
) external view returns (address payable) {
return _getAddress(checkout, salt, block.chainid);
}
/**
* @notice Get the deposit address for a target chain ID.
*
* IMPORTANT NOTE: This implementation assumes that the forwarder factory has the same
* address on each chain. This has to be ensured before a chain ID is added to the allowed
* list of target chain IDs on the CheckoutPools contract.
*/
function getAddressForChain(
CheckoutState calldata checkout,
bytes32 salt,
uint256 chainId
) external view returns (address payable) {
return _getAddress(checkout, salt, chainId);
}
function getProxyCreationCode() external pure returns (bytes memory) {
return type(Create2ForwarderProxy).creationCode;
}
function _create(
CheckoutState calldata checkout,
bytes32 salt
) internal returns (Create2ForwarderInterface) {
Create2ForwarderProxy deployed = new Create2ForwarderProxy{
salt: salt
}(IMPLEMENTATION, checkout, block.chainid);
Create2ForwarderInterface proxy = Create2ForwarderInterface(
address(deployed)
);
return proxy;
}
function _getAddress(
CheckoutState calldata checkout,
bytes32 salt,
uint256 chainId
) internal view returns (address payable) {
bytes32 digest = keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
salt,
keccak256(
abi.encodePacked(
type(Create2ForwarderProxy).creationCode,
abi.encode(IMPLEMENTATION, checkout, chainId)
)
)
)
);
return payable(address(uint160(uint256(digest))));
}
}
// Compare with:
// function create3(bytes32 _salt, bytes memory _creationCode, uint256 _value) internal returns (address addr) {
// // Creation code
// bytes memory creationCode = PROXY_CHILD_BYTECODE;
// // Get target final address
// addr = addressOf(_salt);
// if (codeSize(addr) != 0) revert TargetAlreadyExists();
// // Create CREATE2 proxy
// address proxy; assembly { proxy := create2(0, add(creationCode, 32), mload(creationCode), _salt)}
// if (proxy == address(0)) revert ErrorCreatingProxy();
// // Call proxy with final init code
// (bool success,) = proxy.call{ value: _value }(_creationCode);
// if (!success || codeSize(addr) == 0) revert ErrorCreatingContract();
// }
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {
Create2ForwarderInterface
} from "../interfaces/Create2ForwarderInterface.sol";
import { CheckoutState } from "./CheckoutPoolInterface.sol";
interface Create2ForwarderFactoryInterface {
function createAndForward(
CheckoutState calldata checkout,
bytes32 salt
) external returns (Create2ForwarderInterface);
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { CheckoutPoolInterface } from "../interfaces/CheckoutPoolInterface.sol";
import {
Create2ForwarderInterface
} from "../interfaces/Create2ForwarderInterface.sol";
import {
Create2ForwarderEventsAndErrors
} from "../interfaces/Create2ForwarderEventsAndErrors.sol";
import { WETH9Interface } from "../interfaces/WETH9Interface.sol";
import {
CheckoutParams,
CheckoutState
} from "../interfaces/CheckoutPoolInterface.sol";
import { GuardianRescuable } from "../utils/GuardianRescuable.sol";
import { Create2ForwarderProxy } from "./Create2ForwarderProxy.sol";
/**
* @title Create2ForwarderImpl
* @author Fun.xyz
*
* @notice A forwarder contract (a.k.a. “deposit address”) for the Checkout Pools protocol.
*
* See Create2ForwarderFactory and Create2ForwarderProxy for more info.
*/
contract Create2ForwarderImpl is
GuardianRescuable,
Create2ForwarderInterface,
Create2ForwarderEventsAndErrors
{
using SafeERC20 for IERC20;
address public immutable GUARDIAN;
WETH9Interface public immutable WRAPPED_NATIVE_TOKEN;
CheckoutPoolInterface public immutable CHECKOUT_POOL;
address public immutable USDT_TOKEN = address(0xdAC17F958D2ee523a2206206994597C13D831ec7);
bool internal _FORWARDED_;
receive() external payable {}
/**
* @notice Implementation constructor.
*
* Sets immutable values that are the same across all deployed proxies.
*/
constructor(
address initialGuardian,
WETH9Interface wrappedNativeToken,
CheckoutPoolInterface checkoutPool
) {
GUARDIAN = initialGuardian;
WRAPPED_NATIVE_TOKEN = wrappedNativeToken;
CHECKOUT_POOL = checkoutPool;
}
function guardian() public override view returns (address) {
return GUARDIAN;
}
/**
* @notice Forward deposited funds to the CheckoutPool contract.
*/
function forward() external {
// Forward at most once.
if (_FORWARDED_) {
revert AlreadyForwarded();
}
_FORWARDED_ = true;
// Read checkout state from proxy immutable configuration.
CheckoutState memory checkout = Create2ForwarderProxy(payable(this))
.getCheckout();
IERC20 heldAsset = checkout.heldAsset;
uint256 minSourceAmount = checkout.heldAmount;
// Get native value.
uint256 value = address(this).balance;
// Convert any native value to wrapped native token.
if (value != 0) {
// Note: Intentionally not sanity checking that ERC20 == WRAPPED_NATIVE_TOKEN
// since that's of little help at this point, if the contract is misconfigured.
WRAPPED_NATIVE_TOKEN.deposit{ value: value }();
}
// Get actual held amount.
uint256 actualHeldAmount = heldAsset.balanceOf(address(this));
// Validate and possibly overwrite the source amount.
if (actualHeldAmount < minSourceAmount) {
revert Underfunded(actualHeldAmount, minSourceAmount);
} else if (actualHeldAmount > minSourceAmount) {
checkout.heldAmount = actualHeldAmount;
}
// Note: Using approve() instead of safeIncreaseAllowance() or forceApprove() under the
// assumption that all allowances from this contract will be zero in between transactions.
// We have a condition here if it is USDT, where we will perform a safeApprove as USDT does not return any value
if (block.chainid == 1 && address(heldAsset) == USDT_TOKEN) {
heldAsset.safeApprove(address(CHECKOUT_POOL), type(uint256).max);
} else {
heldAsset.approve(address(CHECKOUT_POOL), type(uint256).max);
}
// Make the external call, reverting on failure.
try CHECKOUT_POOL.deposit(checkout) {} catch (bytes memory errorData) {
revert ForwardError(errorData);
}
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
interface Create2ForwarderInterface {
function forward() external;
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {
SafeERC20
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Create2ForwarderImpl } from "../forwarder/Create2ForwarderImpl.sol";
import { WETH9Interface } from "../interfaces/WETH9Interface.sol";
import { GuardianOwnable } from "../utils/GuardianOwnable.sol";
import {
CheckoutParams,
CheckoutState
} from "../interfaces/CheckoutPoolInterface.sol";
/**
* @title Create2ForwarderProxy
* @author Fun.xyz
*
* @notice A forwarder contract proxy (a.k.a. “deposit address”) for the Checkout Pools protocol.
*
* Intended to be deployed as a “counterfactual” contract.
*
* See Create2ForwarderFactory and Create2ForwarderImpl for more info.
*/
contract Create2ForwarderProxy is Proxy {
using SafeERC20 for IERC20;
Create2ForwarderImpl internal immutable IMPLEMENTATION;
// Expand out the CheckoutState struct so that it can be stored as immutables.
bytes32 public immutable USER_OP_HASH;
uint96 public immutable TARGET_CHAIN_ID;
bytes32 public immutable TARGET_ASSET;
uint128 public immutable TARGET_AMOUNT;
uint128 public immutable EXPIRATION;
bytes32 public immutable RECIPIENT;
IERC20 public immutable HELD_ASSET; // Here represents the source asset.
uint256 public immutable HELD_AMOUNT; // Here represents the min source amount.
receive() external payable override {}
/**
* @notice Proxy constructor.
*
* Sets immutable values that are different between deployed proxy instances.
*
* IMPORTANT: Include chain ID in the constructor to ensure that the deposit address is
* unique for all checkout operations globally. This reduces confusion and allows us to use
* the deposit address as a unique ID in off-chain services. Note that we include the
* chain ID as a constructor param instead of hashing it into the salt, for gas efficiency.
*
* The heldAsset and heldAmount are included in the constructor to ensure that it is possible
* to prove whether a liquidity provider is censoring checkouts (differenting this from the
* case where checkouts are under-funded).
*/
constructor(
Create2ForwarderImpl implementation,
CheckoutState memory checkout,
uint256 /* chainId */
) {
IMPLEMENTATION = implementation;
USER_OP_HASH = checkout.params.userOpHash;
TARGET_ASSET = checkout.params.targetAsset;
TARGET_CHAIN_ID = checkout.params.targetChainId;
TARGET_AMOUNT = checkout.params.targetAmount;
EXPIRATION = checkout.params.expiration;
RECIPIENT = checkout.params.recipient;
HELD_ASSET = checkout.heldAsset;
HELD_AMOUNT = checkout.heldAmount;
}
function getCheckout()
external
view
returns (CheckoutState memory checkout)
{
return
CheckoutState({
params: CheckoutParams({
userOpHash: USER_OP_HASH,
targetAsset: TARGET_ASSET,
targetChainId: TARGET_CHAIN_ID,
targetAmount: TARGET_AMOUNT,
expiration: EXPIRATION,
recipient: RECIPIENT
}),
heldAsset: HELD_ASSET,
heldAmount: HELD_AMOUNT
});
}
function _implementation() internal view override returns (address) {
return address(IMPLEMENTATION);
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { GuardianRescuable } from "./GuardianRescuable.sol";
/**
* @title GuardianOwnable
* @author Fun.xyz
*/
abstract contract GuardianOwnable is Ownable2Step, GuardianRescuable {
error RenounceDisabled();
function guardian() public view override returns (address) {
return owner();
}
function renounceOwnership() public view override onlyOwner {
revert RenounceDisabled();
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {
SafeERC20
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title GuardianRescuable
* @author Fun.xyz
*/
abstract contract GuardianRescuable {
using SafeERC20 for IERC20;
error NotGuardian(address sender);
modifier onlyGuardian() {
if (msg.sender != guardian()) {
revert NotGuardian(msg.sender);
}
_;
}
function guardian() public virtual returns (address);
function withdrawNative(
address payable recipient,
uint256 amount
) external onlyGuardian {
recipient.transfer(amount);
}
function withdrawErc20(
IERC20 token,
address recipient,
uint256 amount
) external onlyGuardian {
token.safeTransfer(recipient, amount);
}
function withdrawAllNative(
address payable recipient
) external onlyGuardian {
recipient.transfer(address(this).balance);
}
function withdrawAllErc20(
IERC20 token,
address recipient
) external onlyGuardian {
uint256 balance = token.balanceOf(address(this));
token.safeTransfer(recipient, balance);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;
/* solhint-disable no-inline-assembly */
/**
* returned data from validateUserOp.
* validateUserOp returns a uint256, with is created by `_packedValidationData` and parsed by `_parseValidationData`
* @param aggregator - address(0) - the account validated the signature by itself.
* address(1) - the account failed to validate the signature.
* otherwise - this is an address of a signature aggregator that must be used to validate the signature.
* @param validAfter - this UserOp is valid only after this timestamp.
* @param validaUntil - this UserOp is valid only up to this timestamp.
*/
struct ValidationData {
address aggregator;
uint48 validAfter;
uint48 validUntil;
}
//extract sigFailed, validAfter, validUntil.
// also convert zero validUntil to type(uint48).max
function _parseValidationData(uint validationData) pure returns (ValidationData memory data) {
address aggregator = address(uint160(validationData));
uint48 validUntil = uint48(validationData >> 160);
if (validUntil == 0) {
validUntil = type(uint48).max;
}
uint48 validAfter = uint48(validationData >> (48 + 160));
return ValidationData(aggregator, validAfter, validUntil);
}
// intersect account and paymaster ranges.
function _intersectTimeRange(uint256 validationData, uint256 paymasterValidationData) pure returns (ValidationData memory) {
ValidationData memory accountValidationData = _parseValidationData(validationData);
ValidationData memory pmValidationData = _parseValidationData(paymasterValidationData);
address aggregator = accountValidationData.aggregator;
if (aggregator == address(0)) {
aggregator = pmValidationData.aggregator;
}
uint48 validAfter = accountValidationData.validAfter;
uint48 validUntil = accountValidationData.validUntil;
uint48 pmValidAfter = pmValidationData.validAfter;
uint48 pmValidUntil = pmValidationData.validUntil;
if (validAfter < pmValidAfter) validAfter = pmValidAfter;
if (validUntil > pmValidUntil) validUntil = pmValidUntil;
return ValidationData(aggregator, validAfter, validUntil);
}
/**
* helper to pack the return value for validateUserOp
* @param data - the ValidationData to pack
*/
function _packValidationData(ValidationData memory data) pure returns (uint256) {
return uint160(data.aggregator) | (uint256(data.validUntil) << 160) | (uint256(data.validAfter) << (160 + 48));
}
/**
* helper to pack the return value for validateUserOp, when not using an aggregator
* @param sigFailed - true for signature failure, false for success
* @param validUntil last timestamp this UserOperation is valid (or zero for infinite)
* @param validAfter first timestamp this UserOperation is valid
*/
function _packValidationData(bool sigFailed, uint48 validUntil, uint48 validAfter) pure returns (uint256) {
return (sigFailed ? 1 : 0) | (uint256(validUntil) << 160) | (uint256(validAfter) << (160 + 48));
}
/**
* keccak function over calldata.
* @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.
*/
function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {
assembly {
let mem := mload(0x40)
let len := data.length
calldatacopy(mem, data.offset, len)
ret := keccak256(mem, len)
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;
/* solhint-disable no-inline-assembly */
import {calldataKeccak} from "../core/Helpers.sol";
/**
* User Operation struct
* @param sender the sender account of this request.
* @param nonce unique value the sender uses to verify it is not a replay.
* @param initCode if set, the account contract will be created by this constructor/
* @param callData the method call to execute on this account.
* @param callGasLimit the gas limit passed to the callData method call.
* @param verificationGasLimit gas used for validateUserOp and validatePaymasterUserOp.
* @param preVerificationGas gas not calculated by the handleOps method, but added to the gas paid. Covers batch overhead.
* @param maxFeePerGas same as EIP-1559 gas parameter.
* @param maxPriorityFeePerGas same as EIP-1559 gas parameter.
* @param paymasterAndData if set, this field holds the paymaster address and paymaster-specific data. the paymaster will pay for the transaction instead of the sender.
* @param signature sender-verified signature over the entire request, the EntryPoint address and the chain ID.
*/
struct UserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
uint256 callGasLimit;
uint256 verificationGasLimit;
uint256 preVerificationGas;
uint256 maxFeePerGas;
uint256 maxPriorityFeePerGas;
bytes paymasterAndData;
bytes signature;
}
/**
* Utility functions helpful when working with UserOperation structs.
*/
library UserOperationLib {
function getSender(UserOperation calldata userOp) internal pure returns (address) {
address data;
//read sender from userOp, which is first userOp member (saves 800 gas...)
assembly {data := calldataload(userOp)}
return address(uint160(data));
}
//relayer/block builder might submit the TX with higher priorityFee, but the user should not
// pay above what he signed for.
function gasPrice(UserOperation calldata userOp) internal view returns (uint256) {
unchecked {
uint256 maxFeePerGas = userOp.maxFeePerGas;
uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
if (maxFeePerGas == maxPriorityFeePerGas) {
//legacy mode (for networks that don't support basefee opcode)
return maxFeePerGas;
}
return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);
}
}
function pack(UserOperation calldata userOp) internal pure returns (bytes memory ret) {
address sender = getSender(userOp);
uint256 nonce = userOp.nonce;
bytes32 hashInitCode = calldataKeccak(userOp.initCode);
bytes32 hashCallData = calldataKeccak(userOp.callData);
uint256 callGasLimit = userOp.callGasLimit;
uint256 verificationGasLimit = userOp.verificationGasLimit;
uint256 preVerificationGas = userOp.preVerificationGas;
uint256 maxFeePerGas = userOp.maxFeePerGas;
uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);
return abi.encode(
sender, nonce,
hashInitCode, hashCallData,
callGasLimit, verificationGasLimit, preVerificationGas,
maxFeePerGas, maxPriorityFeePerGas,
hashPaymasterAndData
);
}
function hash(UserOperation calldata userOp) internal pure returns (bytes32) {
return keccak256(pack(userOp));
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface WETH9Interface is IERC20 {
function deposit() external payable;
function withdraw(uint256) external;
}
{
"compilationTarget": {
"src/forwarder/Create2ForwarderFactory.sol": "Create2ForwarderFactory"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@account-abstraction/contracts/=lib/account-abstraction/contracts/",
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":account-abstraction/=lib/account-abstraction/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"guardian","type":"address"},{"internalType":"contract WETH9Interface","name":"wrappedNativeToken","type":"address"},{"internalType":"contract CheckoutPoolInterface","name":"checkoutPool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ErrorCreatingProxy","type":"error"},{"inputs":[],"name":"IMPLEMENTATION","outputs":[{"internalType":"contract Create2ForwarderImpl","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"bytes32","name":"targetAsset","type":"bytes32"},{"internalType":"uint96","name":"targetChainId","type":"uint96"},{"internalType":"uint128","name":"targetAmount","type":"uint128"},{"internalType":"uint128","name":"expiration","type":"uint128"},{"internalType":"bytes32","name":"recipient","type":"bytes32"}],"internalType":"struct CheckoutParams","name":"params","type":"tuple"},{"internalType":"contract IERC20","name":"heldAsset","type":"address"},{"internalType":"uint256","name":"heldAmount","type":"uint256"}],"internalType":"struct CheckoutState","name":"checkout","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"create","outputs":[{"internalType":"contract Create2ForwarderInterface","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"bytes32","name":"targetAsset","type":"bytes32"},{"internalType":"uint96","name":"targetChainId","type":"uint96"},{"internalType":"uint128","name":"targetAmount","type":"uint128"},{"internalType":"uint128","name":"expiration","type":"uint128"},{"internalType":"bytes32","name":"recipient","type":"bytes32"}],"internalType":"struct CheckoutParams","name":"params","type":"tuple"},{"internalType":"contract IERC20","name":"heldAsset","type":"address"},{"internalType":"uint256","name":"heldAmount","type":"uint256"}],"internalType":"struct CheckoutState","name":"checkout","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"createAndForward","outputs":[{"internalType":"contract Create2ForwarderInterface","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"bytes32","name":"targetAsset","type":"bytes32"},{"internalType":"uint96","name":"targetChainId","type":"uint96"},{"internalType":"uint128","name":"targetAmount","type":"uint128"},{"internalType":"uint128","name":"expiration","type":"uint128"},{"internalType":"bytes32","name":"recipient","type":"bytes32"}],"internalType":"struct CheckoutParams","name":"params","type":"tuple"},{"internalType":"contract IERC20","name":"heldAsset","type":"address"},{"internalType":"uint256","name":"heldAmount","type":"uint256"}],"internalType":"struct CheckoutState","name":"checkout","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"getAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"bytes32","name":"targetAsset","type":"bytes32"},{"internalType":"uint96","name":"targetChainId","type":"uint96"},{"internalType":"uint128","name":"targetAmount","type":"uint128"},{"internalType":"uint128","name":"expiration","type":"uint128"},{"internalType":"bytes32","name":"recipient","type":"bytes32"}],"internalType":"struct CheckoutParams","name":"params","type":"tuple"},{"internalType":"contract IERC20","name":"heldAsset","type":"address"},{"internalType":"uint256","name":"heldAmount","type":"uint256"}],"internalType":"struct CheckoutState","name":"checkout","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getAddressForChain","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProxyCreationCode","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"}]