diff --git a/.changeset/fifty-pens-train.md b/.changeset/fifty-pens-train.md new file mode 100644 index 000000000..7cbaaf5e1 --- /dev/null +++ b/.changeset/fifty-pens-train.md @@ -0,0 +1,5 @@ +--- +"@nocturne-xyz/deploy": minor +--- + +add goerli config before redeploy, fix regressions in sepolia config (`resetWindowHours` was not included in sepolia deploy config) diff --git a/.changeset/yellow-crews-do.md b/.changeset/yellow-crews-do.md new file mode 100644 index 000000000..a64391340 --- /dev/null +++ b/.changeset/yellow-crews-do.md @@ -0,0 +1,5 @@ +--- +"@nocturne-xyz/deploy": minor +--- + +deploy script conditionally deploys wsteth adapter, takes optional wsteth adapter deploy config in deploy config json diff --git a/apps/snap/snap.manifest.json b/apps/snap/snap.manifest.json index c0290d2cf..50d24a188 100644 --- a/apps/snap/snap.manifest.json +++ b/apps/snap/snap.manifest.json @@ -3,7 +3,7 @@ "description": "Nocturne Snap", "proposedName": "Nocturne Snap", "source": { - "shasum": "TJ399jkXlB9uFpfPr1732t4xvrkxe/vHOzhjtYyB+/c=", + "shasum": "+qafYOYUE4DOQUHhRPKv1/Mba1519GAhhda5kwboeUc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/core/src/operationRequest/builder.ts b/packages/core/src/operationRequest/builder.ts index 3bcb5fe04..7a31e28aa 100644 --- a/packages/core/src/operationRequest/builder.ts +++ b/packages/core/src/operationRequest/builder.ts @@ -23,7 +23,6 @@ import { import { ethers } from "ethers"; import { MapWithObjectKeys } from "../utils"; import { chainIdToNetworkName } from "../utils/constants"; -// import * as JSON from "bigint-json-serialization"; export type OpRequestBuilder = OpRequestBuilderExt; diff --git a/packages/deploy/configs/example.json b/packages/deploy/configs/example.json index 70b226eaa..b2d4f1150 100644 --- a/packages/deploy/configs/example.json +++ b/packages/deploy/configs/example.json @@ -1,5 +1,5 @@ { - "proxyAdminOwner": "0x9dD6B628336ECA9a57e534Fb25F1960fA11038f4", + "proxyAdminOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "screeners": ["0x1DAb396f790699de639cF22d0Ea7744469aCAB1a"], "subtreeBatchFillers": ["0xD20E7a8ADdCB5D983C064f8A184B7aa65ef23f10"], "wethAddress": "0xb16f35c0ae2912430dac15764477e179d9b9ebea", @@ -10,6 +10,7 @@ "address": "0x0000000000000000000000000000000000000000", "globalCapWholeTokens": "500n", "maxDepositSizeWholeTokens": "50n", + "resetWindowHours": "24n", "precision": "18n", "isGasAsset": true } @@ -20,6 +21,7 @@ "address": "0x0000000000000000000000000000000000000000", "globalCapWholeTokens": "500n", "maxDepositSizeWholeTokens": "50n", + "resetWindowHours": "24n", "precision": "18n", "isGasAsset": true } @@ -40,6 +42,10 @@ "leftoverTokenHolder": "0x0000000000000000000000000000000000000123", "opts": { "useMockSubtreeUpdateVerifier": true, + "wstethAdapterDeployConfig": { + "wethAddress": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9", + "wstethAddress": "0x8b79995e5f793a07bc00c21412e50ecae098e710" + }, "confirmations": 1 } } diff --git a/packages/deploy/configs/goerli.json b/packages/deploy/configs/goerli.json new file mode 100644 index 000000000..ec8a9d48f --- /dev/null +++ b/packages/deploy/configs/goerli.json @@ -0,0 +1,72 @@ +{ + "proxyAdminOwner": "0x9dD6B628336ECA9a57e534Fb25F1960fA11038f4", + "screeners": ["0x44cD09776A1c3b803A5Fe30660528a61d36653B4"], + "subtreeBatchFillers": ["0x6556186E3E940930c40068C76BC875De95811E42"], + "wethAddress": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + "erc20s": [ + [ + "TEST-TOKEN", + { + "address": "0x0000000000000000000000000000000000000000", + "globalCapWholeTokens": "1000000n", + "maxDepositSizeWholeTokens": "1000n", + "resetWindowHours": "4n", + "precision": "18n", + "isGasAsset": true + } + ], + [ + "weth", + { + "address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + "globalCapWholeTokens": "1000n", + "maxDepositSizeWholeTokens": "100n", + "resetWindowHours": "4n", + "precision": "18n", + "isGasAsset": true + } + ], + [ + "wsteth", + { + "address": "0x6320cd32aa674d2898a68ec82e869385fc5f7e2f", + "globalCapWholeTokens": "1000n", + "maxDepositSizeWholeTokens": "100n", + "resetWindowHours": "4n", + "precision": "18n", + "isGasAsset": true + } + ], + [ + "dai", + { + "address": "0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844", + "globalCapWholeTokens": "1000000n", + "maxDepositSizeWholeTokens": "100000n", + "resetWindowHours": "4n", + "precision": "18n" + } + ] + ], + "protocolAllowlist": [ + [ + "uniswapV3", + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "functionSignatures": [ + "exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))", + "exactInput((bytes,address,uint256,uint256,uint256))" + ] + } + ] + ], + "leftoverTokenHolder": "0x0000000000000000000000000000000000000000", + "opts": { + "useMockSubtreeUpdateVerifier": false, + "wstethAdapterDeployConfig": { + "wethAddress": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + "wstethAddress": "0x6320cd32aa674d2898a68ec82e869385fc5f7e2f" + }, + "confirmations": 1 + } +} diff --git a/packages/deploy/configs/sepolia.json b/packages/deploy/configs/sepolia.json index b10b7a1f6..a5fdcfaf5 100644 --- a/packages/deploy/configs/sepolia.json +++ b/packages/deploy/configs/sepolia.json @@ -10,6 +10,7 @@ "address": "0x0000000000000000000000000000000000000000", "globalCapWholeTokens": "1000000n", "maxDepositSizeWholeTokens": "1000n", + "resetWindowHours": "4n", "precision": "18n", "isGasAsset": true } @@ -20,6 +21,7 @@ "address": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9", "globalCapWholeTokens": "1000n", "maxDepositSizeWholeTokens": "100n", + "resetWindowHours": "4n", "precision": "18n", "isGasAsset": true } @@ -30,6 +32,7 @@ "address": "0x3e622317f8c93f7328350cf0b56d9ed4c620c5d6", "globalCapWholeTokens": "1000000n", "maxDepositSizeWholeTokens": "100000n", + "resetWindowHours": "4n", "precision": "18n" } ] diff --git a/packages/deploy/src/config.ts b/packages/deploy/src/config.ts index 907d636e2..ead3d69b1 100644 --- a/packages/deploy/src/config.ts +++ b/packages/deploy/src/config.ts @@ -27,10 +27,16 @@ export interface NocturneDeployConfig { export interface NocturneDeployOpts { proxyAdmin?: ProxyAdmin; + wstethAdapterDeployConfig?: WstethAdapterDeployConfig; useMockSubtreeUpdateVerifier?: boolean; confirmations?: number; } +export interface WstethAdapterDeployConfig { + wethAddress: Address; + wstethAddress: Address; +} + export function loadDeployConfigFromJSON(json: string): NocturneDeployConfig { const props: NocturneDeployConfigProperties = JSON.parse(json); return { diff --git a/packages/deploy/src/deploy.ts b/packages/deploy/src/deploy.ts index 53f431a5a..a9f5dbcc3 100644 --- a/packages/deploy/src/deploy.ts +++ b/packages/deploy/src/deploy.ts @@ -15,6 +15,8 @@ import { DepositManager, Handler, CanonAddrSigCheckVerifier__factory, + WstethAdapter__factory, + WstethAdapter, } from "@nocturne-xyz/contracts"; import { ethers } from "ethers"; import { ProxiedContract } from "./proxy"; @@ -41,6 +43,11 @@ export async function deployNocturne( const erc20s = await maybeDeployErc20s(connectedSigner, config.erc20s); config.erc20s = erc20s; + const maybeWstethAdapter = await maybeDeployWstethAdapter( + connectedSigner, + config.opts + ); + // Deploy core contracts const contracts = await deployNocturneCoreContracts(connectedSigner, config); @@ -72,6 +79,14 @@ export async function deployNocturne( config.protocolAllowlist.set(name, addressWithSignatures); } + if (maybeWstethAdapter) { + const addressWithSignature: ProtocolAddressWithMethods = { + address: maybeWstethAdapter.address, + functionSignatures: ["convert(uint256)"], + }; + config.protocolAllowlist.set("wstethAdapter", addressWithSignature); + } + await whitelistTokens(connectedSigner, tokens, handler); await whitelistProtocols(connectedSigner, config.protocolAllowlist, handler); @@ -226,6 +241,25 @@ export async function deployNocturneCoreContracts( }; } +async function maybeDeployWstethAdapter( + connectedSigner: ethers.Wallet, + opts?: NocturneDeployOpts +): Promise { + if (!opts?.wstethAdapterDeployConfig) { + return undefined; + } + + const { wethAddress, wstethAddress } = opts.wstethAdapterDeployConfig; + + console.log("\ndeploying WstethAdapter..."); + const wstethAdapter = await new WstethAdapter__factory( + connectedSigner + ).deploy(wethAddress, wstethAddress); + await wstethAdapter.deployTransaction.wait(opts?.confirmations); + + return wstethAdapter; +} + async function maybeDeployErc20s( connectedSigner: ethers.Wallet, erc20s: Map