From cef02744b13ca51ffb1580fca9d1766962fff6b5 Mon Sep 17 00:00:00 2001 From: tommyrharper Date: Tue, 9 Jul 2024 13:17:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=20Add=20perps=20to=20A?= =?UTF-8?q?ccount=20contract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Account.sol | 12 ++++++++++-- test/MarginPaymaster.t.sol | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Account.sol b/src/Account.sol index b9e09f5..d6ea54e 100644 --- a/src/Account.sol +++ b/src/Account.sol @@ -9,9 +9,11 @@ import "@openzeppelin/contracts/utils/Create2.sol"; contract Account is IAccount { uint256 public count; address public owner; + address public perpsMarketSNXV3; - constructor(address _owner) { + constructor(address _owner, address _perpsMarketSNXV3) { owner = _owner; + perpsMarketSNXV3 = _perpsMarketSNXV3; } function validateUserOp( @@ -35,13 +37,19 @@ contract Account is IAccount { } contract AccountFactory { + address public perpsMarketSNXV3; + + constructor(address _perpsMarketSNXV3) { + perpsMarketSNXV3 = _perpsMarketSNXV3; + } + function createAccount(address owner) external returns (address) { // create2 is needed so it is deterministic and can have the gas useage confirmed by the bundler (disallowed opcodes) // amount, salt, bytecode bytes32 salt = bytes32(uint256(uint160(owner))); bytes memory bytecode = abi.encodePacked( type(Account).creationCode, - abi.encode(owner) + abi.encode(owner, perpsMarketSNXV3) ); // dont deploy if addr already exists diff --git a/test/MarginPaymaster.t.sol b/test/MarginPaymaster.t.sol index 95d04be..a93f5e1 100644 --- a/test/MarginPaymaster.t.sol +++ b/test/MarginPaymaster.t.sol @@ -16,7 +16,7 @@ contract MarginPaymasterTest is Bootstrap { initializeBase(); - accountFactory = new AccountFactory(); + accountFactory = new AccountFactory(perpsMarketProxyAddress); vm.deal(address(this), initialPaymasterBalance); entryPoint.depositTo{value: initialPaymasterBalance}( marginPaymasterAddress