Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deploy script conditionally deploys wsteth adapter + add goerli config #446

Merged
merged 7 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-pens-train.md
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions .changeset/yellow-crews-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nocturne-xyz/deploy": minor
---

deploy script conditionally deploys wsteth adapter, takes optional wsteth adapter deploy config in deploy config json
2 changes: 1 addition & 1 deletion apps/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Nocturne Snap",
"proposedName": "Nocturne Snap",
"source": {
"shasum": "TJ399jkXlB9uFpfPr1732t4xvrkxe/vHOzhjtYyB+/c=",
"shasum": "+qafYOYUE4DOQUHhRPKv1/Mba1519GAhhda5kwboeUc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/operationRequest/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseOpRequestBuilder>;

Expand Down
8 changes: 7 additions & 1 deletion packages/deploy/configs/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"proxyAdminOwner": "0x9dD6B628336ECA9a57e534Fb25F1960fA11038f4",
"proxyAdminOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"screeners": ["0x1DAb396f790699de639cF22d0Ea7744469aCAB1a"],
"subtreeBatchFillers": ["0xD20E7a8ADdCB5D983C064f8A184B7aa65ef23f10"],
"wethAddress": "0xb16f35c0ae2912430dac15764477e179d9b9ebea",
Expand All @@ -10,6 +10,7 @@
"address": "0x0000000000000000000000000000000000000000",
"globalCapWholeTokens": "500n",
"maxDepositSizeWholeTokens": "50n",
"resetWindowHours": "24n",
"precision": "18n",
"isGasAsset": true
}
Expand All @@ -20,6 +21,7 @@
"address": "0x0000000000000000000000000000000000000000",
"globalCapWholeTokens": "500n",
"maxDepositSizeWholeTokens": "50n",
"resetWindowHours": "24n",
"precision": "18n",
"isGasAsset": true
}
Expand All @@ -40,6 +42,10 @@
"leftoverTokenHolder": "0x0000000000000000000000000000000000000123",
"opts": {
"useMockSubtreeUpdateVerifier": true,
"wstethAdapterDeployConfig": {
"wethAddress": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"wstethAddress": "0x8b79995e5f793a07bc00c21412e50ecae098e710"
},
"confirmations": 1
}
}
72 changes: 72 additions & 0 deletions packages/deploy/configs/goerli.json
Original file line number Diff line number Diff line change
@@ -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
}
}
3 changes: 3 additions & 0 deletions packages/deploy/configs/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"address": "0x0000000000000000000000000000000000000000",
"globalCapWholeTokens": "1000000n",
"maxDepositSizeWholeTokens": "1000n",
"resetWindowHours": "4n",
"precision": "18n",
"isGasAsset": true
}
Expand All @@ -20,6 +21,7 @@
"address": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"globalCapWholeTokens": "1000n",
"maxDepositSizeWholeTokens": "100n",
"resetWindowHours": "4n",
"precision": "18n",
"isGasAsset": true
}
Expand All @@ -30,6 +32,7 @@
"address": "0x3e622317f8c93f7328350cf0b56d9ed4c620c5d6",
"globalCapWholeTokens": "1000000n",
"maxDepositSizeWholeTokens": "100000n",
"resetWindowHours": "4n",
"precision": "18n"
}
]
Expand Down
6 changes: 6 additions & 0 deletions packages/deploy/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 34 additions & 0 deletions packages/deploy/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
DepositManager,
Handler,
CanonAddrSigCheckVerifier__factory,
WstethAdapter__factory,
WstethAdapter,
} from "@nocturne-xyz/contracts";
import { ethers } from "ethers";
import { ProxiedContract } from "./proxy";
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -226,6 +241,25 @@ export async function deployNocturneCoreContracts(
};
}

async function maybeDeployWstethAdapter(
connectedSigner: ethers.Wallet,
opts?: NocturneDeployOpts
): Promise<WstethAdapter | undefined> {
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<string, Erc20Config>
Expand Down
Loading