-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
956 additions
and
201 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"Account": "0x5f78a5EdF0B356F50886a6829Fc02B16532e8735", | ||
"Events": "0xe32F27B27F4ea5f10f269b52223910bA83e2933C", | ||
"Account": "0x62b26650A52E1B6a669C21a9d43aFD78AC0Ef84F", | ||
"Events": "0x4533D9eAC2eb200B98fD9BaA306221ad2528e52F", | ||
"Factory": "0x30582eeE34719fe22b1B6c3b607636A3ab94522E", | ||
"Settings": "0x8B9CbD3da94c637c0652c680Abd3CF7f787aBAF4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"Account": "0x6B86c1A6878940666489780871E1C98B366d0aFF", | ||
"Events": "0xB753d2EE5dcA1fF39A83CA3Ec500656c31Be940b", | ||
"Account": "0x9AcbDBABafC7E47dE0769C352b725Fa9fd443Bc2", | ||
"Events": "0x349142D51afCFbB3E9ef70DB1F7dB8437aABC5F7", | ||
"Factory": "0x8234F990b149Ae59416dc260305E565e5DAfEb54", | ||
"Settings": "0x865dA103d126b3Be3599D84caB57109A861F5631" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.18; | ||
|
||
import {Script} from "lib/forge-std/src/Script.sol"; | ||
|
||
import {IAddressResolver} from "script/utils/interfaces/IAddressResolver.sol"; | ||
|
||
import {Account} from "src/Account.sol"; | ||
import {Events} from "src/Events.sol"; | ||
import {Settings} from "src/Settings.sol"; | ||
import {IAccount} from "src/interfaces/IAccount.sol"; | ||
|
||
import { | ||
OPTIMISM_PDAO, | ||
OPTIMISM_GELATO, | ||
OPTIMISM_OPS, | ||
FUTURES_MARKET_MANAGER, | ||
OPTIMISM_FACTORY, | ||
OPTIMISM_EVENTS, | ||
OPTIMISM_SETTINGS, | ||
OPTIMISM_SYNTHETIX_ADDRESS_RESOLVER, | ||
OPTIMISM_UNISWAP_PERMIT2, | ||
OPTIMISM_UNISWAP_UNIVERSAL_ROUTER, | ||
PERPS_V2_EXCHANGE_RATE, | ||
PROXY_SUSD, | ||
SYSTEM_STATUS | ||
} from "script/utils/parameters/OptimismParameters.sol"; | ||
import { | ||
OPTIMISM_GOERLI_DEPLOYER, | ||
OPTIMISM_GOERLI_EVENTS, | ||
OPTIMISM_GOERLI_SETTINGS, | ||
OPTIMISM_GOERLI_FACTORY, | ||
OPTIMISM_GOERLI_GELATO, | ||
OPTIMISM_GOERLI_OPS, | ||
OPTIMISM_GOERLI_SYNTHETIX_ADDRESS_RESOLVER, | ||
OPTIMISM_GOERLI_UNISWAP_PERMIT2, | ||
OPTIMISM_GOERLI_UNISWAP_UNIVERSAL_ROUTER | ||
} from "script/utils/parameters/OptimismGoerliParameters.sol"; | ||
|
||
/// @title Script to upgrade the Account implementation v2.1.1 -> v2.1.2 | ||
/// @author JaredBorders ([email protected]) | ||
|
||
/// @dev steps to deploy and verify on Optimism: | ||
/// (1) load the variables in the .env file via `source .env` | ||
/// (2) run `forge script script/upgrades/v2.1.2/Upgrade.s.sol:UpgradeAccountOptimism --rpc-url $ARCHIVE_NODE_URL_L2 --broadcast --verify -vvvv` | ||
/// (3) Smart Margin Account Factory owner (i.e. Kwenta pDAO) will need to call `upgradeAccountImplementation` on the Factory with the address of the new Account implementation | ||
contract UpgradeAccountOptimism is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
upgrade(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function upgrade() public returns (address implementation) { | ||
IAddressResolver addressResolver = | ||
IAddressResolver(OPTIMISM_SYNTHETIX_ADDRESS_RESOLVER); | ||
|
||
// deploy events | ||
address events = address(new Events({_factory: OPTIMISM_FACTORY})); | ||
|
||
address marginAsset = addressResolver.getAddress({name: PROXY_SUSD}); | ||
address perpsV2ExchangeRate = | ||
addressResolver.getAddress({name: PERPS_V2_EXCHANGE_RATE}); | ||
address futuresMarketManager = | ||
addressResolver.getAddress({name: FUTURES_MARKET_MANAGER}); | ||
address systemStatus = addressResolver.getAddress({name: SYSTEM_STATUS}); | ||
|
||
IAccount.AccountConstructorParams memory params = IAccount | ||
.AccountConstructorParams({ | ||
factory: OPTIMISM_FACTORY, | ||
events: events, | ||
marginAsset: marginAsset, | ||
perpsV2ExchangeRate: perpsV2ExchangeRate, | ||
futuresMarketManager: futuresMarketManager, | ||
systemStatus: systemStatus, | ||
gelato: OPTIMISM_GELATO, | ||
ops: OPTIMISM_OPS, | ||
settings: OPTIMISM_SETTINGS, | ||
universalRouter: OPTIMISM_UNISWAP_UNIVERSAL_ROUTER, | ||
permit2: OPTIMISM_UNISWAP_PERMIT2 | ||
}); | ||
|
||
implementation = address(new Account(params)); | ||
} | ||
} | ||
|
||
/// @dev steps to deploy and verify on Optimism Goerli: | ||
/// (1) load the variables in the .env file via `source .env` | ||
/// (2) run `forge script script/upgrades/v2.1.2/Upgrade.s.sol:UpgradeAccountOptimismGoerli --rpc-url $ARCHIVE_NODE_URL_GOERLI_L2 --broadcast --verify -vvvv` | ||
/// (3) Smart Margin Account Factory owner (i.e. Kwenta pDAO) will need to call `upgradeAccountImplementation` on the Factory with the address of the new Account implementation | ||
contract UpgradeAccountOptimismGoerli is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
upgrade(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function upgrade() public returns (address implementation) { | ||
IAddressResolver addressResolver = | ||
IAddressResolver(OPTIMISM_GOERLI_SYNTHETIX_ADDRESS_RESOLVER); | ||
|
||
// deploy events | ||
address events = | ||
address(new Events({_factory: OPTIMISM_GOERLI_FACTORY})); | ||
|
||
address marginAsset = addressResolver.getAddress({name: PROXY_SUSD}); | ||
address perpsV2ExchangeRate = | ||
addressResolver.getAddress({name: PERPS_V2_EXCHANGE_RATE}); | ||
address futuresMarketManager = | ||
addressResolver.getAddress({name: FUTURES_MARKET_MANAGER}); | ||
address systemStatus = addressResolver.getAddress({name: SYSTEM_STATUS}); | ||
|
||
IAccount.AccountConstructorParams memory params = IAccount | ||
.AccountConstructorParams({ | ||
factory: OPTIMISM_GOERLI_FACTORY, | ||
events: events, | ||
marginAsset: marginAsset, | ||
perpsV2ExchangeRate: perpsV2ExchangeRate, | ||
futuresMarketManager: futuresMarketManager, | ||
systemStatus: systemStatus, | ||
gelato: OPTIMISM_GOERLI_GELATO, | ||
ops: OPTIMISM_GOERLI_OPS, | ||
settings: OPTIMISM_GOERLI_SETTINGS, | ||
universalRouter: OPTIMISM_GOERLI_UNISWAP_UNIVERSAL_ROUTER, | ||
permit2: OPTIMISM_GOERLI_UNISWAP_PERMIT2 | ||
}); | ||
|
||
implementation = address(new Account(params)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ pragma solidity 0.8.18; | |
import {IPerpsV2MarketConsolidated} from | ||
"src/interfaces/synthetix/IPerpsV2MarketConsolidated.sol"; | ||
|
||
/// @title Kwenta Smart Margin Account v2.1.1 Implementation Interface | ||
/// @title Kwenta Smart Margin Account v2.1.2 Implementation Interface | ||
/// @author JaredBorders ([email protected]), JChiaramonte7 ([email protected]) | ||
interface IAccount { | ||
/*/////////////////////////////////////////////////////////////// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.