From 521d85c9913bed731f83fcca277f3feaa69ee6e1 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Mon, 4 Aug 2025 09:51:45 +1000 Subject: [PATCH 1/3] add fx token --- deployments/8453/fx/fxUSDC.json | 4 ++ deployments/901/fx/fxUSDC.json | 5 ++ deployments/957/fx/fxUSDC.json | 5 ++ foundry.toml | 5 +- scripts/deploy-fxUSDC.s.sol | 58 ++++++++++++++++++ src/FX/FXToken.sol | 105 ++++++++++++++++++++++++++++++++ test/ForkBase.t.sol | 6 +- 7 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 deployments/8453/fx/fxUSDC.json create mode 100644 deployments/901/fx/fxUSDC.json create mode 100644 deployments/957/fx/fxUSDC.json create mode 100644 scripts/deploy-fxUSDC.s.sol create mode 100644 src/FX/FXToken.sol diff --git a/deployments/8453/fx/fxUSDC.json b/deployments/8453/fx/fxUSDC.json new file mode 100644 index 0000000..3a76e50 --- /dev/null +++ b/deployments/8453/fx/fxUSDC.json @@ -0,0 +1,4 @@ +{ + "fxUSDC": "0x857011642C31C611b6A11dE6F6c802b6Dd776d3E", + "fxUSDCImp": "0xAA6b1c93aF26636a894dCF9B73FDc287E1C76501" +} \ No newline at end of file diff --git a/deployments/901/fx/fxUSDC.json b/deployments/901/fx/fxUSDC.json new file mode 100644 index 0000000..1075de1 --- /dev/null +++ b/deployments/901/fx/fxUSDC.json @@ -0,0 +1,5 @@ +{ + "fxUSDC": "0xdf986C23f298AfaDeea0b739167Cc2Eac5F9417e", + "fxUSDCImp": "0xc4650837767557B487e91173B653cDcF68672F00", + "fxUSDCAsset": "0x1ddefDd26a10eFf75301d71c65D3d0066F00A4AA" +} \ No newline at end of file diff --git a/deployments/957/fx/fxUSDC.json b/deployments/957/fx/fxUSDC.json new file mode 100644 index 0000000..3cbf0a1 --- /dev/null +++ b/deployments/957/fx/fxUSDC.json @@ -0,0 +1,5 @@ +{ + "fxUSDC": "0xb82E56B142CA4D32BdeE04313139F26e81cE92D2", + "fxUSDCImp": "0xEb4975c0B9f850b292Eb452D274fb9381B21Cb91", + "fxUSDCAsset": "0xD696A90f262324375310992aD73A38E0917DE4cd" +} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 798b799..aeb83fe 100644 --- a/foundry.toml +++ b/foundry.toml @@ -23,4 +23,7 @@ quote_style = 'double' [rpc_endpoints] conduit_prod = "https://l2-prod-testnet-0eakp60405.t.conduit.xyz" conduit_staging = "https://l2-staging-9ns7v94tpj.t.conduit.xyz" -sepolia = "https://sepolia.infura.io/v3/26251a7744c548a3adbc17880fc70764" \ No newline at end of file +sepolia = "https://sepolia.infura.io/v3/26251a7744c548a3adbc17880fc70764" + +[profile.CORE] +src = "lib/v2-core/src" \ No newline at end of file diff --git a/scripts/deploy-fxUSDC.s.sol b/scripts/deploy-fxUSDC.s.sol new file mode 100644 index 0000000..76e3b08 --- /dev/null +++ b/scripts/deploy-fxUSDC.s.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.0; + +import "forge-std/console2.sol"; +import {Utils} from "./utils.sol"; +import "../src/periphery/LyraSettlementUtils.sol"; +import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol"; +import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol"; +import {CashAsset} from "v2-core/src/assets/CashAsset.sol"; +import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol"; +import {ILiquidatableManager} from "v2-core/src/interfaces/ILiquidatableManager.sol"; +import {IMatching} from "../src/interfaces/IMatching.sol"; +import {IDepositModule} from "../src/interfaces/IDepositModule.sol"; +import {IWithdrawalModule} from "../src/interfaces/IWithdrawalModule.sol"; +import {ITradeModule} from "../src/interfaces/ITradeModule.sol"; +import {ISpotFeed} from "v2-core/src/interfaces/ISpotFeed.sol"; +import {IWrappedERC20Asset} from "v2-core/src/interfaces/IWrappedERC20Asset.sol"; +import "../src/tokenizedSubaccounts/CCTSA.sol"; +import "../src/tokenizedSubaccounts/PPTSA.sol"; +import "openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {TokenizedSubAccount} from "../src/tokenizedSubaccounts/TSA.sol"; +import "openzeppelin/proxy/transparent/ProxyAdmin.sol"; +import {TSAShareHandler} from "../src/tokenizedSubaccounts/TSAShareHandler.sol"; +import {Vm} from "forge-std/Vm.sol"; +import {FxToken} from "../src/FX/FXToken.sol"; +import {WrappedERC20Asset} from "v2-core/src/assets/WrappedERC20Asset.sol"; + + +contract DeployFXUSDC is Utils { + /// @dev main function + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + vm.startBroadcast(deployerPrivateKey); + + string name = vm.envString("TOKEN_NAME"); + + address deployer = vm.addr(deployerPrivateKey); + console2.log("deployer: ", deployer); + + FxToken fxTokenImplementation = new FxToken(); + + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(fxTokenImplementation), + address(deployer), + abi.encodeWithSelector(fxTokenImplementation.initialize.selector, name, "fxUSDC", 6) + ); + + + FxToken fxUSDC = FxToken(address(proxy)); + + console2.log("fxUSDC: ", address(fxUSDC)); + console2.log("fxUSDCImp: ", address(fxTokenImplementation)); + + WrappedERC20Asset fxUSDCAsset = new WrappedERC20Asset(ISubAccounts(_loadConfig().subAccounts), fxUSDC); + + console2.log("fxUSDCAsset: ", address(fxUSDCAsset)); + } +} \ No newline at end of file diff --git a/src/FX/FXToken.sol b/src/FX/FXToken.sol new file mode 100644 index 0000000..fe22cc5 --- /dev/null +++ b/src/FX/FXToken.sol @@ -0,0 +1,105 @@ +pragma solidity ^0.8.27; + +import {AccessControlUpgradeable} from "openzeppelin-upgradeable/access/AccessControlUpgradeable.sol"; +import {ERC20Upgradeable, Initializable} from "openzeppelin-upgradeable/token/ERC20/ERC20Upgradeable.sol"; + + +contract FxToken is Initializable, ERC20Upgradeable, AccessControlUpgradeable { + bytes32 public constant MINTER_ROLE = keccak256("MINTER"); + bytes32 public constant BLOCK_MANAGER_ROLE = keccak256("BLOCK_MANAGER"); + // keccak256(abi.encode(uint256(keccak256("FxToken")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant FxTokenStorageLocation = 0xfb8997de7bd810675586dece12917931ae29ba246c9d4d120b17fca6e2b68f00; + + + /// @custom:storage-location erc7201:FxToken + struct FxTokenStorage { + uint8 decimals; + mapping(address user => bool blocked) isBlocked; + } + + function _getStorage() internal pure returns (FxTokenStorage storage s) { + bytes32 position = FxTokenStorageLocation; + assembly { + s.slot := position + } + } + + /////////// + // Setup // + /////////// + + constructor() { + _disableInitializers(); + } + + function initialize(string memory _name, string memory _symbol, uint _decimals) external initializer { + __ERC20_init_unchained(_name, _symbol); + _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); + + FxTokenStorage storage s = _getStorage(); + s.decimals = uint8(_decimals); + } + + //////////////// + // Block List // + //////////////// + + function setBlocked(address user, bool blocked) public onlyRole(BLOCK_MANAGER_ROLE) { + require(user != address(0), "FxToken: cannot block zero address"); + FxTokenStorage storage s = _getStorage(); + s.isBlocked[user] = blocked; + emit Blocked(user, blocked); + } + + function isBlocked(address user) public view returns (bool) { + return _getStorage().isBlocked[user]; + } + + /////////////// + // Mint/Burn // + /////////////// + + function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { + FxTokenStorage storage s = _getStorage(); + require(!s.isBlocked[msg.sender], "FxToken: minter is blocked"); + _mint(to, amount); + } + + function burn(address from, uint256 amount) public onlyRole(MINTER_ROLE) { + FxTokenStorage storage s = _getStorage(); + require(!s.isBlocked[msg.sender], "FxToken: minter is blocked"); + + if (from == address(0)) { + revert ERC20InvalidSender(address(0)); + } + // Skip the _update call to avoid checking blocked status + super._update(from, address(0), amount); + } + + ///////////////////// + // ERC20 Overrides // + ///////////////////// + + function _update(address from, address to, uint256 value) internal override { + FxTokenStorage storage s = _getStorage(); + require(!s.isBlocked[from], "FxToken: sender is blocked"); + require(!s.isBlocked[to], "FxToken: recipient is blocked"); + super._update(from, to, value); + } + + function _spendAllowance(address owner, address spender, uint256 value) internal override { + FxTokenStorage storage s = _getStorage(); + require(!s.isBlocked[spender], "FxToken: spender is blocked"); + super._spendAllowance(owner, spender, value); + } + + function decimals() public view virtual override returns (uint8) { + return _getStorage().decimals; + } + + //////////// + // Events // + //////////// + + event Blocked(address indexed user, bool blocked); +} diff --git a/test/ForkBase.t.sol b/test/ForkBase.t.sol index d3667d6..f3324a0 100644 --- a/test/ForkBase.t.sol +++ b/test/ForkBase.t.sol @@ -14,9 +14,9 @@ contract ForkBase is UtilBase, Test { } function _call(address target, bytes memory data) internal returns (bytes memory) { - console.log(target); - console.log(",0,"); - console.logBytes(data); +// console.log(target); +// console.log(",0,"); +// console.logBytes(data); (bool success, bytes memory result) = target.call(data); require(success, "call failed"); return result; From 5b191e91d9d259a5bf14f3ef8792d961d8807b4f Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Mon, 4 Aug 2025 10:09:59 +1000 Subject: [PATCH 2/3] added tests --- scripts/deploy-fxUSDC.s.sol | 6 +- src/{FX => fx}/FXToken.sol | 2 +- test/fx/FXToken.sol | 132 ++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 4 deletions(-) rename src/{FX => fx}/FXToken.sol (98%) create mode 100644 test/fx/FXToken.sol diff --git a/scripts/deploy-fxUSDC.s.sol b/scripts/deploy-fxUSDC.s.sol index 76e3b08..19081b3 100644 --- a/scripts/deploy-fxUSDC.s.sol +++ b/scripts/deploy-fxUSDC.s.sol @@ -22,7 +22,7 @@ import {TokenizedSubAccount} from "../src/tokenizedSubaccounts/TSA.sol"; import "openzeppelin/proxy/transparent/ProxyAdmin.sol"; import {TSAShareHandler} from "../src/tokenizedSubaccounts/TSAShareHandler.sol"; import {Vm} from "forge-std/Vm.sol"; -import {FxToken} from "../src/FX/FXToken.sol"; +import {FXToken} from "../src/fx/FXToken.sol"; import {WrappedERC20Asset} from "v2-core/src/assets/WrappedERC20Asset.sol"; @@ -37,7 +37,7 @@ contract DeployFXUSDC is Utils { address deployer = vm.addr(deployerPrivateKey); console2.log("deployer: ", deployer); - FxToken fxTokenImplementation = new FxToken(); + FXToken fxTokenImplementation = new FXToken(); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( address(fxTokenImplementation), @@ -46,7 +46,7 @@ contract DeployFXUSDC is Utils { ); - FxToken fxUSDC = FxToken(address(proxy)); + FXToken fxUSDC = FXToken(address(proxy)); console2.log("fxUSDC: ", address(fxUSDC)); console2.log("fxUSDCImp: ", address(fxTokenImplementation)); diff --git a/src/FX/FXToken.sol b/src/fx/FXToken.sol similarity index 98% rename from src/FX/FXToken.sol rename to src/fx/FXToken.sol index fe22cc5..71b1103 100644 --- a/src/FX/FXToken.sol +++ b/src/fx/FXToken.sol @@ -4,7 +4,7 @@ import {AccessControlUpgradeable} from "openzeppelin-upgradeable/access/AccessCo import {ERC20Upgradeable, Initializable} from "openzeppelin-upgradeable/token/ERC20/ERC20Upgradeable.sol"; -contract FxToken is Initializable, ERC20Upgradeable, AccessControlUpgradeable { +contract FXToken is Initializable, ERC20Upgradeable, AccessControlUpgradeable { bytes32 public constant MINTER_ROLE = keccak256("MINTER"); bytes32 public constant BLOCK_MANAGER_ROLE = keccak256("BLOCK_MANAGER"); // keccak256(abi.encode(uint256(keccak256("FxToken")) - 1)) & ~bytes32(uint256(0xff)) diff --git a/test/fx/FXToken.sol b/test/fx/FXToken.sol new file mode 100644 index 0000000..b899af7 --- /dev/null +++ b/test/fx/FXToken.sol @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "forge-std/Test.sol"; +import "openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import {FXToken} from "../../src/fx/FXToken.sol"; + +contract FXTokenTest is Test { + FXToken token; + + address admin = address(0x1); + address minter = address(0x2); + address blocker = address(0x2); + address alice = address(0xa); + address bob = address(0xb); + address charlie = address(0xc); + + function setUp() public { + // admin deploys, so becomes admin + vm.startPrank(admin); + FXToken fxTokenImplementation = new FXToken(); + + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(fxTokenImplementation), + address(alice), + abi.encodeWithSelector(fxTokenImplementation.initialize.selector, "fx USDC", "fxUSDC", 6) + ); + token = FXToken(address(proxy)); + + // Set roles + token.grantRole(token.MINTER_ROLE(), minter); + token.grantRole(token.BLOCK_MANAGER_ROLE(), blocker); + + vm.stopPrank(); + } + + function testInitialSetup() public view { + assertEq(token.name(), "fx USDC"); + assertEq(token.symbol(), "fxUSDC"); + assertEq(token.decimals(), 6); + assertTrue(token.hasRole(token.MINTER_ROLE(), minter)); + assertTrue(token.hasRole(token.BLOCK_MANAGER_ROLE(), blocker)); + } + + function testMint() public { + vm.prank(minter); + token.mint(alice, 100); + + assertEq(token.balanceOf(alice), 100); + } + + function testBurn() public { + vm.prank(minter); + token.mint(alice, 100); + + assertEq(token.balanceOf(alice), 100); + + vm.prank(minter); + token.burn(alice, 50); + + assertEq(token.balanceOf(alice), 50); + } + + function testBlockUser() public { + vm.prank(minter); + token.mint(bob, 100); + + vm.prank(blocker); + token.setBlocked(bob, true); + + assertTrue(token.isBlocked(bob)); + + // Minting to a blocked user should revert + vm.prank(minter); + vm.expectRevert("FxToken: recipient is blocked"); + token.mint(bob, 100); + + // Burning from a blocked user is allowed + vm.prank(minter); + token.burn(bob, 50); + + assertEq(token.balanceOf(bob), 50); + + vm.prank(minter); + token.mint(alice, 100); + + assertEq(token.balanceOf(alice), 100); + + vm.prank(alice); + vm.expectRevert("FxToken: recipient is blocked"); + token.transfer(bob, 50); + + // A blocked user cannot transfer tokens + vm.prank(bob); + vm.expectRevert("FxToken: sender is blocked"); + token.transfer(alice, 50); + + // A blocked user approving is allowed, but the spender cannot transfer + vm.prank(bob); + token.approve(alice, 50); + + vm.prank(alice); + vm.expectRevert("FxToken: sender is blocked"); + token.transferFrom(bob, alice, 50); + + // Cannot transferFrom to a blocked user + vm.prank(alice); + token.approve(charlie, 50); + + vm.prank(charlie); + vm.expectRevert("FxToken: recipient is blocked"); + token.transferFrom(alice, bob, 50); + + // Cannot spend allowance if spender is blocked + vm.prank(alice); + token.approve(bob, 50); + + vm.prank(bob); + vm.expectRevert("FxToken: spender is blocked"); + token.transferFrom(alice, charlie, 50); + } + + function testCannotBlockZeroAddress() public { + vm.prank(blocker); + vm.expectRevert("FxToken: cannot block zero address"); + token.setBlocked(address(0), true); + } + + + +} \ No newline at end of file From e2be2cef11716364476424a53a0a269ec429f11c Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Wed, 14 Jan 2026 13:56:58 +1100 Subject: [PATCH 3/3] fx-token deploy --- deployments/957/fx/fxUSDC.json | 6 +- scripts/deploy-and-dump.sh | 26 ++--- scripts/deploy-fxUSDC.s.sol | 2 +- scripts/update-callees.s.sol | 130 ++++++++++++++++++++- src/periphery/DeriveSettlementUtilsNew.sol | 93 +++++++++++++++ test/ForkBase.t.sol | 6 +- test/SimulateCalldata.t.sol | 127 ++++++++++++++++++++ 7 files changed, 366 insertions(+), 24 deletions(-) create mode 100644 src/periphery/DeriveSettlementUtilsNew.sol create mode 100644 test/SimulateCalldata.t.sol diff --git a/deployments/957/fx/fxUSDC.json b/deployments/957/fx/fxUSDC.json index 3cbf0a1..5ab6b28 100644 --- a/deployments/957/fx/fxUSDC.json +++ b/deployments/957/fx/fxUSDC.json @@ -1,5 +1,5 @@ { - "fxUSDC": "0xb82E56B142CA4D32BdeE04313139F26e81cE92D2", - "fxUSDCImp": "0xEb4975c0B9f850b292Eb452D274fb9381B21Cb91", - "fxUSDCAsset": "0xD696A90f262324375310992aD73A38E0917DE4cd" + "fxUSDC": "0x1fE488C69f895BfF7fc5C4c187380D25854aA7D6", + "fxUSDCImp": "0x97a90EaeBd5CE4Bff8FB5594C620e6766243b584", + "fxUSDCAsset": "0xdcd623570c8a979BeE35f4Ed9932E065F0860c44" } \ No newline at end of file diff --git a/scripts/deploy-and-dump.sh b/scripts/deploy-and-dump.sh index 59e9e64..043c356 100755 --- a/scripts/deploy-and-dump.sh +++ b/scripts/deploy-and-dump.sh @@ -46,19 +46,19 @@ MARKET_NAME=DOGE forge script scripts/deploy-perp-only-market.s.sol --rpc-url $E # Copy previous outputs to deployments folder cd ../../ -#cp lib/v2-core/deployments/$chainId/core.json deployments/$chainId/core.json -#cp lib/v2-core/deployments/$chainId/ETH.json deployments/$chainId/ETH.json -#cp lib/v2-core/deployments/$chainId/ETH_2.json deployments/$chainId/ETH_2.json -#cp lib/v2-core/deployments/$chainId/BTC.json deployments/$chainId/BTC.json -#cp lib/v2-core/deployments/$chainId/BTC_2.json deployments/$chainId/BTC_2.json -#cp lib/v2-core/deployments/$chainId/USDT.json deployments/$chainId/USDT.json -#cp lib/v2-core/deployments/$chainId/SNX.json deployments/$chainId/SNX.json -#cp lib/v2-core/deployments/$chainId/WSTETH.json deployments/$chainId/WSTETH.json -#cp lib/v2-core/deployments/$chainId/strands.json deployments/$chainId/strands.json -#cp lib/v2-core/deployments/$chainId/SFP.json deployments/$chainId/SFP.json -#cp lib/v2-core/deployments/$chainId/SOL.json deployments/$chainId/SOL.json -#cp lib/v2-core/deployments/$chainId/DOGE.json deployments/$chainId/DOGE.json -#cp lib/v2-core/deployments/$chainId/shared.json deployments/$chainId/shared.json +cp lib/v2-core/deployments/$chainId/core.json deployments/$chainId/core.json +cp lib/v2-core/deployments/$chainId/ETH.json deployments/$chainId/ETH.json +cp lib/v2-core/deployments/$chainId/ETH_2.json deployments/$chainId/ETH_2.json +cp lib/v2-core/deployments/$chainId/BTC.json deployments/$chainId/BTC.json +cp lib/v2-core/deployments/$chainId/BTC_2.json deployments/$chainId/BTC_2.json +cp lib/v2-core/deployments/$chainId/USDT.json deployments/$chainId/USDT.json +cp lib/v2-core/deployments/$chainId/SNX.json deployments/$chainId/SNX.json +cp lib/v2-core/deployments/$chainId/WSTETH.json deployments/$chainId/WSTETH.json +cp lib/v2-core/deployments/$chainId/strands.json deployments/$chainId/strands.json +cp lib/v2-core/deployments/$chainId/SFP.json deployments/$chainId/SFP.json +cp lib/v2-core/deployments/$chainId/SOL.json deployments/$chainId/SOL.json +cp lib/v2-core/deployments/$chainId/DOGE.json deployments/$chainId/DOGE.json +cp lib/v2-core/deployments/$chainId/shared.json deployments/$chainId/shared.json echo "Deployed core contracts" diff --git a/scripts/deploy-fxUSDC.s.sol b/scripts/deploy-fxUSDC.s.sol index 19081b3..6d225ba 100644 --- a/scripts/deploy-fxUSDC.s.sol +++ b/scripts/deploy-fxUSDC.s.sol @@ -32,7 +32,7 @@ contract DeployFXUSDC is Utils { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); - string name = vm.envString("TOKEN_NAME"); + string memory name = vm.envString("TOKEN_NAME"); address deployer = vm.addr(deployerPrivateKey); console2.log("deployer: ", deployer); diff --git a/scripts/update-callees.s.sol b/scripts/update-callees.s.sol index 08c33ea..e6caea0 100644 --- a/scripts/update-callees.s.sol +++ b/scripts/update-callees.s.sol @@ -19,13 +19,15 @@ import {IManager} from "v2-core/src/interfaces/IManager.sol"; import {BaseManager} from "v2-core/src/risk-managers/BaseManager.sol"; import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol"; import {IAsset} from "v2-core/src/interfaces/IAsset.sol"; +import {ISpotFeed} from "v2-core/src/interfaces/ISpotFeed.sol"; import {LyraERC20} from "v2-core/src/l2/LyraERC20.sol"; import "forge-std/console2.sol"; import {Deployment, NetworkConfig} from "./types.sol"; import {Utils} from "./utils.sol"; - +import {PMRM_2} from "v2-core/src/risk-managers/PMRM_2.sol"; +import {PMRMLib_2, IPMRMLib_2} from "v2-core/src/risk-managers/PMRMLib_2.sol"; /// @dev For local dev only contract UpdateCallees is Utils { @@ -50,7 +52,7 @@ contract UpdateCallees is Utils { managers[1] = _getPMRM(ethMarket); managers[2] = _getPMRM(btcMarket); - for (uint i=0; i> (i * 32)) & 0xFFFFFFFF); + if (account == 0) break; + ILiquidatableManager(manager).settleOptions(IOptionAsset(option), uint(account)); + } + } + + function settlePerps(address manager, uint[] memory subAccounts) external { + for (uint i = 0; i < subAccounts.length; ++i) { + _settlePerps(manager, subAccounts[i]); + } + } + + function _settlePerps(address manager, uint subAccounts) internal { + for (uint i = 0; i < 8; ++i) { + uint32 account = uint32((subAccounts >> (i * 32)) & 0xFFFFFFFF); + if (account == 0) break; + ILiquidatableManager(manager).settlePerpsWithIndex(uint(account)); + } + } +} diff --git a/test/ForkBase.t.sol b/test/ForkBase.t.sol index f3324a0..d3667d6 100644 --- a/test/ForkBase.t.sol +++ b/test/ForkBase.t.sol @@ -14,9 +14,9 @@ contract ForkBase is UtilBase, Test { } function _call(address target, bytes memory data) internal returns (bytes memory) { -// console.log(target); -// console.log(",0,"); -// console.logBytes(data); + console.log(target); + console.log(",0,"); + console.logBytes(data); (bool success, bytes memory result) = target.call(data); require(success, "call failed"); return result; diff --git a/test/SimulateCalldata.t.sol b/test/SimulateCalldata.t.sol new file mode 100644 index 0000000..74017b4 --- /dev/null +++ b/test/SimulateCalldata.t.sol @@ -0,0 +1,127 @@ +pragma solidity ^0.8.20; + +import "../scripts/config/config.sol"; +import "./ForkBase.t.sol"; +import "forge-std/console.sol"; + +import "forge-std/console2.sol"; +import "openzeppelin/access/Ownable2Step.sol"; +import "v2-core/scripts/types.sol"; +import "v2-core/src/l2/LyraERC20.sol"; +import "v2-core/src/risk-managers/PMRM.sol"; +import "v2-core/src/risk-managers/SRMPortfolioViewer.sol"; +import "v2-core/src/risk-managers/StandardManager.sol"; +import {MockSpotDiffFeed} from "v2-core/test/shared/mocks/MockSpotDiffFeed.sol"; +import "v2-core/src/feeds/LyraForwardFeed.sol"; +import {TradeModule} from "../src/modules/TradeModule.sol"; +import {WLWrappedERC20Asset} from "v2-core/src/assets/WLWrappedERC20Asset.sol"; +import {iOVM_CrossDomainMessenger} from + "v2-core/lib/chainlink/contracts/src/v0.8/vendor/@eth-optimism/contracts/v0.4.7/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_CrossDomainMessenger.sol"; + +struct UserOperation { + address sender; + uint256 nonce; + bytes initCode; + bytes callData; + uint256 callGasLimit; + uint256 verificationGasLimit; + uint256 preVerificationGas; + uint256 maxFeePerGas; + uint256 maxPriorityFeePerGas; + bytes paymasterAndData; + bytes signature; +} + +interface IEntryPoint { + function handleOps(UserOperation[] calldata ops, address payable beneficiary) external; +} + + +contract SimulateUserOp is ForkBase { + function setUp() external {} + + function testFork() external checkFork { + IEntryPoint entryPoint = IEntryPoint(address(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789)); + // "params": [ + // { + // "initCode": "0x000000893A26168158fbeaDD9335Be5bC96592E25fbfb9cf0000000000000000000000002975b8e30ec64c1855dd94e1a8ecd435a323a9b00000000000000000000000000000000000000000000000000000000000000000", + // "sender": "0xFe253598A960A07DCE9de3b3213260c0Cf532f15", + // "nonce": "0x0", + // "callData": "0x47e1da2a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000ce00000000000000000000000000000000000000000000000000000000000000031000000000000000000000000eb8d770ec18db98db922e9d83260a585b9f0dead0000000000000000000000007b35b4c05a90ea5f311aec815be4148b446a68a20000000000000000000000007b35b4c05a90ea5f311aec815be4148b446a68a2000000000000000000000000c419959850d49166c2d5250ee89ff9910679d8c8000000000000000000000000c419959850d49166c2d5250ee89ff9910679d8c8000000000000000000000000c47e2e800a9184cfbd274ac1eecccdf942715db7000000000000000000000000c47e2e800a9184cfbd274ac1eecccdf942715db7000000000000000000000000b82d12742c3728a14eaa43ebe1c0d32bb62216eb000000000000000000000000b82d12742c3728a14eaa43ebe1c0d32bb62216eb000000000000000000000000b56d58ce246c31c4d3a3bfb354996ff28d081db7000000000000000000000000b56d58ce246c31c4d3a3bfb354996ff28d081db70000000000000000000000007215a841215cfccac7f0894f5f194e8faa6e58440000000000000000000000007215a841215cfccac7f0894f5f194e8faa6e58440000000000000000000000001569e57b9e1da866f9b862acd8b134ea16b234f50000000000000000000000001569e57b9e1da866f9b862acd8b134ea16b234f500000000000000000000000036b5c126a3d7b25f6032653a0d18823ee48a890e00000000000000000000000036b5c126a3d7b25f6032653a0d18823ee48a890e0000000000000000000000001ea87f372285409425771f19eb7938b427dab1480000000000000000000000001ea87f372285409425771f19eb7938b427dab1480000000000000000000000004d4e6761d2d8d5adca3646987970d63c00704eb50000000000000000000000004d4e6761d2d8d5adca3646987970d63c00704eb500000000000000000000000030f85847f9f17f219a9a21b93396a3b2eaea500f00000000000000000000000030f85847f9f17f219a9a21b93396a3b2eaea500f000000000000000000000000cfb66706ae87f60120af42f07ec8940be44a34d6000000000000000000000000cfb66706ae87f60120af42f07ec8940be44a34d60000000000000000000000007755c4529017ca8069f57b19e450ffaf128048a60000000000000000000000007755c4529017ca8069f57b19e450ffaf128048a6000000000000000000000000cd6a5dcb5a9b5e4801ac50f3e9171a80017d1ec2000000000000000000000000cd6a5dcb5a9b5e4801ac50f3e9171a80017d1ec2000000000000000000000000a30ab68436d26b3c6c303b777354105055fc3a30000000000000000000000000a30ab68436d26b3c6c303b777354105055fc3a300000000000000000000000006879287835a86f50f784313dbed5e5ccc5bb84810000000000000000000000006879287835a86f50f784313dbed5e5ccc5bb848100000000000000000000000015cecd5190a43c7798dd2058308781d0662e678e00000000000000000000000015cecd5190a43c7798dd2058308781d0662e678e0000000000000000000000009b80ab732a6f1030326af0014f106e12c4db18ec0000000000000000000000009b80ab732a6f1030326af0014f106e12c4db18ec000000000000000000000000954be1803546150bfd887c9ff70fd221f2f505d3000000000000000000000000954be1803546150bfd887c9ff70fd221f2f505d3000000000000000000000000df77b286eda539ccb6326e9edb86aa69d83108a5000000000000000000000000df77b286eda539ccb6326e9edb86aa69d83108a50000000000000000000000002ee0fd70756edc663acc9676658a1497c247693a0000000000000000000000002ee0fd70756edc663acc9676658a1497c247693a0000000000000000000000007499d654422023a407d92e1d83d387d81bc68de10000000000000000000000007499d654422023a407d92e1d83d387d81bc68de10000000000000000000000001fe488c69f895bff7fc5c4c187380d25854aa7d60000000000000000000000001fe488c69f895bff7fc5c4c187380d25854aa7d60000000000000000000000006879287835a86f50f784313dbed5e5ccc5bb8481000000000000000000000000a44e56a6f53b2e27278b468783fe9de6b037e147000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000031000000000000000000000000000000000000000000000000000000000000062000000000000000000000000000000000000000000000000000000000000006a0000000000000000000000000000000000000000000000000000000000000072000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008a0000000000000000000000000000000000000000000000000000000000000092000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000b200000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000d200000000000000000000000000000000000000000000000000000000000000da00000000000000000000000000000000000000000000000000000000000000e200000000000000000000000000000000000000000000000000000000000000ea00000000000000000000000000000000000000000000000000000000000000f200000000000000000000000000000000000000000000000000000000000000fa0000000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000011a0000000000000000000000000000000000000000000000000000000000000122000000000000000000000000000000000000000000000000000000000000012a0000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000013a0000000000000000000000000000000000000000000000000000000000000142000000000000000000000000000000000000000000000000000000000000014a0000000000000000000000000000000000000000000000000000000000000152000000000000000000000000000000000000000000000000000000000000015a0000000000000000000000000000000000000000000000000000000000000162000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000172000000000000000000000000000000000000000000000000000000000000017a0000000000000000000000000000000000000000000000000000000000000182000000000000000000000000000000000000000000000000000000000000018a0000000000000000000000000000000000000000000000000000000000000192000000000000000000000000000000000000000000000000000000000000019a00000000000000000000000000000000000000000000000000000000000001a200000000000000000000000000000000000000000000000000000000000001aa00000000000000000000000000000000000000000000000000000000000001b200000000000000000000000000000000000000000000000000000000000001ba00000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000001ca00000000000000000000000000000000000000000000000000000000000001d200000000000000000000000000000000000000000000000000000000000001da00000000000000000000000000000000000000000000000000000000000001e20000000000000000000000000000000000000000000000000000000000000004447a90d4400000000000000000000000082bf4a7a6de453688ff214e42e21d0f5a9e2410b000000000000000000000000000000000000000000000000000000006a009340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009400cc156dad38a716047a67c897973a29a06710ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009400cc156dad38a716047a67c897973a29a06710ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000009b3fe5e5a3bcea5df4e08c41ce89c4e3ff01ace3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a179c3b32d3ee58353d3f277b32d1e03dd33ffcaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000a44e56a6f53b2e27278b468783fe9de6b037e147ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064c20818d800000000000000000000000057b03e14d409adc7fab6cfc44b5886cad2d5f02b00000000000000000000000000000000000000000000000000000006f3baaa2900000000000000000000000028c9ddf9a3b29c2e6a561c1bc520954e5a33de5d00000000000000000000000000000000000000000000000000000000", + // "signature": "0x9c1a614697a5bd9ee98a52bdcac4a6eb6e13575aaa5a8440850bb07a3aa3eefb268ce15188578f9cebcb840177de7052ec42ac5f2d1cffa586e4d8d767d093d601", + // "paymasterAndData": "0xa179c3b32d3eE58353d3F277b32D1e03DD33fFCA00000000000000000000000000000000000000000000000000000000689df03a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f700a6b7b399864fb92a99fce17916d41a26ac2c7e95370e244c5e376faf3b23079331c1b7c1836075a589a6095094357f4c58982324051cdcca13520b1082431b", + // "maxFeePerGas": "0xf436c", + // "maxPriorityFeePerGas": "0xf4240", + // "callGasLimit": "0x1b5bb8", + // "verificationGasLimit": "0x504b6", + // "preVerificationGas": "0x419f08" + // }, + // "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + // ] + + // {"method":"eth_sendUserOperation","params":[ + // {"initCode":"0x000000893A26168158fbeaDD9335Be5bC96592E25fbfb9cf00000000000000000000000080147b43bb7a0496b6e26dbd0642fdf9b8b7dcb50000000000000000000000000000000000000000000000000000000000000000", + // "sender":"0x3B9EA2EF38A4d9863844e73b05A3bfA62c57FceB", + // "nonce":"0x0", + // "callData":"0x47e1da2a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000003cc154e220c2197c5337b7bd13363dd127bc0c6e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004447a90d440000000000000000000000000431aa26bd5c7eae22ee960f17038b056a6fb1d6000000000000000000000000000000000000000000000000000000006a896a6800000000000000000000000000000000000000000000000000000000", + // "signature":"0x59247efe0b52cc393fea4e103412106066bdf081d6bcb78d5b79a81bfabc911516f45963e984dfef13d04d5e4b1fb950c16f932094139ada03f2a3319cb3d86a1c"," + // paymasterAndData":"0x5a6499b442711feeA0Aa73C6574042EC5E2e594500000000000000000000000000000000000000000000000000000000692575e20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b06abe2952fa8aa1235c892eea85085796e2d2eaa610876d274895ebd65d3fe4a9411d3b5ef17f1bec8cc0492ba7bb6b01cd346f05a8c971ef7ed00b33adbab1c", + // "maxFeePerGas":"0xf436c","maxPriorityFeePerGas":"0xf4240","callGasLimit":"0x83bb","verificationGasLimit":"0x4b698","preVerificationGas":"0x188b8"}, + // "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"]} + + bytes memory signature = hex"59247efe0b52cc393fea4e103412106066bdf081d6bcb78d5b79a81bfabc911516f45963e984dfef13d04d5e4b1fb950c16f932094139ada03f2a3319cb3d86a1c"; + bytes memory paymasterAndData = hex"5a6499b442711feeA0Aa73C6574042EC5E2e594500000000000000000000000000000000000000000000000000000000692575e20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b06abe2952fa8aa1235c892eea85085796e2d2eaa610876d274895ebd65d3fe4a9411d3b5ef17f1bec8cc0492ba7bb6b01cd346f05a8c971ef7ed00b33adbab1c"; + bytes memory callData = hex"47e1da2a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000003cc154e220c2197c5337b7bd13363dd127bc0c6e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004447a90d440000000000000000000000000431aa26bd5c7eae22ee960f17038b056a6fb1d6000000000000000000000000000000000000000000000000000000006a896a6800000000000000000000000000000000000000000000000000000000"; + bytes memory initCode = hex"000000893A26168158fbeaDD9335Be5bC96592E25fbfb9cf00000000000000000000000080147b43bb7a0496b6e26dbd0642fdf9b8b7dcb50000000000000000000000000000000000000000000000000000000000000000"; + + UserOperation memory userOp = UserOperation({ + sender: payable(0x3B9EA2EF38A4d9863844e73b05A3bfA62c57FceB), + nonce: 0, + initCode: initCode, + callData: callData, + callGasLimit: 0x83bb, + verificationGasLimit: 0x4b698, + preVerificationGas: 0x188b8, + maxFeePerGas: 0xf436c, + maxPriorityFeePerGas: 0xf4240, + paymasterAndData: paymasterAndData, + signature: signature + }); + + UserOperation[] memory userOps = new UserOperation[](1); + userOps[0] = userOp; + + entryPoint.handleOps( + userOps, + payable(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789) + ); + // + +// bytes memory signature = hex"fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"; +// bytes memory paymasterAndData = hex"5a6499b442711feeA0Aa73C6574042EC5E2e59450000000000000000000000000000000000000000000000000000000068c9c2ca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffff0000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb1c"; +// bytes memory callData = hex"47e1da2a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000893a26168158fbeadd9335be5bc96592e20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004447a90d44000000000000000000000000eaf429ecb61e76e9f3c2caf3c3d0c5a65a8999a40000000000000000000000000000000000000000000000000000000068c9d06200000000000000000000000000000000000000000000000000000000"; +// bytes memory initCode = new bytes(0); //hex""; +// +// UserOperation memory userOp = UserOperation({ +// sender: payable(0xFe253598A960A07DCE9de3b3213260c0Cf532f15), +// nonce: 0, +// initCode: initCode, +// callData: callData, +// callGasLimit: 0x1b5bb8, +// verificationGasLimit: 0x504b6, +// preVerificationGas: 0x419f08, +// maxFeePerGas: 0xf436c, +// maxPriorityFeePerGas: 0xf4240, +// paymasterAndData: paymasterAndData, +// signature: signature +// }); +// +// UserOperation[] memory userOps = new UserOperation[](1); +// userOps[0] = userOp; +// +// entryPoint.handleOps( +// userOps, +// payable(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789) +// ); + } +}