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

Added new scripts to the repo #1169

Merged
merged 3 commits into from
Sep 12, 2024
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ RUN anvil --dump-state ./data & ANVIL="$!" && \
sleep 2 && \
npx hardhat fork:mint-eth --address ${ADMIN} --amount 50 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
make deploy && \
npx hardhat registry:add --name ERC4626_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat registry:add --name STETH_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat registry:add-instance --name ERC4626_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat registry:add-instance --name STETH_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat registry:update-governance --address ${ADMIN} --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
./scripts/format-devnet-addresses.sh && \
kill $ANVIL && sleep 1s
Expand Down
2 changes: 1 addition & 1 deletion deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -1237,4 +1237,4 @@
"timestamp": "2024-09-09T20:34:07.406Z"
}
}
}
}
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from "./deploy";
export * from "./factory";
export * from "./fork";
export * from "./market-state";
export * from "./pause";
export * from "./registry";
38 changes: 38 additions & 0 deletions tasks/pause.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { task, types } from "hardhat/config";
import {
HyperdriveDeployNamedTask,
HyperdriveDeployNamedTaskParams,
} from "./deploy";

export type PauseParams = HyperdriveDeployNamedTaskParams & {
status: boolean;
};

HyperdriveDeployNamedTask(task("pause", "pauses the specified Hyperdrive pool"))
.addParam("status", "the pause status to set", undefined, types.boolean)
.setAction(
async (
{ name, status }: Required<PauseParams>,
{ viem, hyperdriveDeploy: { deployments } },
) => {
let deployment = deployments.byName(name);
if (!deployment.contract.endsWith("Hyperdrive"))
throw new Error("not a hyperdrive instance");
let poolContract = await viem.getContractAt(
"IHyperdrive",
deployment.address,
);
console.log(
`the pause status is ${(await poolContract.read.getMarketState()).isPaused}`,
);
console.log(
`setting the pause status of ${name} ${deployment.contract} at ${deployment.address} to ${status} ...`,
);
let tx = await poolContract.write.pause([status]);
let pc = await viem.getPublicClient();
await pc.waitForTransactionReceipt({ hash: tx });
console.log(
`the pause status is now ${(await poolContract.read.getMarketState()).isPaused}`,
);
},
);
56 changes: 56 additions & 0 deletions tasks/registry/add-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { task, types } from "hardhat/config";
import { Address } from "viem";
import {
HyperdriveDeployNamedTask,
HyperdriveDeployNamedTaskParams,
} from "../deploy";

export type AddRegistryParams = HyperdriveDeployNamedTaskParams & {
value: number;
};

HyperdriveDeployNamedTask(
task(
"registry:add-factory",
"adds the specified hyperdrive factory to the registry",
),
)
.addParam(
"value",
"value to set for the factory in the registry",
undefined,
types.int,
)
.setAction(
async (
{ name, value }: Required<AddRegistryParams>,
{ viem, hyperdriveDeploy: { deployments } },
) => {
let deployment = deployments.byName(name);
if (!deployment.contract.endsWith("Factory"))
throw new Error("not a hyperdrive factory");
const registryAddress = deployments.byName(
"DELV Hyperdrive Registry",
).address as `0x${string}`;
const registryContract = await viem.getContractAt(
"HyperdriveRegistry",
registryAddress,
);
let factoryCount =
await registryContract.read.getNumberOfFactories();
console.log(`there are ${factoryCount} factories in the registry`);
console.log(
`adding ${name} ${deployment.contract} at ${deployment.address} to registry with value ${value} ...`,
);
let tx = await registryContract.write.setFactoryInfo([
[deployment.address as Address],
[BigInt(value)],
]);
let pc = await viem.getPublicClient();
await pc.waitForTransactionReceipt({ hash: tx });
factoryCount = await registryContract.read.getNumberOfFactories();
console.log(
`there are now ${factoryCount} factories in the registry`,
);
},
);
4 changes: 2 additions & 2 deletions tasks/registry/add.ts → tasks/registry/add-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type AddRegistryParams = HyperdriveDeployNamedTaskParams & {

HyperdriveDeployNamedTask(
task(
"registry:add",
"registry:add-instance",
"adds the specified hyperdrive instance to the registry",
),
)
Expand All @@ -24,7 +24,7 @@ HyperdriveDeployNamedTask(
.setAction(
async (
{ name, value }: Required<AddRegistryParams>,
{ viem, hyperdriveDeploy: { deployments }, network },
{ viem, hyperdriveDeploy: { deployments } },
) => {
let deployment = deployments.byName(name);
if (!deployment.contract.endsWith("Hyperdrive"))
Expand Down
6 changes: 4 additions & 2 deletions tasks/registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from "./add";
export * from "./remove";
export * from "./add-factory";
export * from "./add-instance";
export * from "./remove-factory";
export * from "./remove-instance";
export * from "./updateGovernance";
53 changes: 53 additions & 0 deletions tasks/registry/remove-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { task, types } from "hardhat/config";
import { Address } from "viem";
import {
HyperdriveDeployBaseTask,
HyperdriveDeployBaseTaskParams,
} from "../deploy";

export type RegistryRemoveParams = HyperdriveDeployBaseTaskParams & {
address: string;
};

HyperdriveDeployBaseTask(
task(
"registry:remove-factory",
"remove the specified hyperdrive factory from the registry",
),
)
.addParam(
"address",
"address of the instance to remove",
undefined,
types.string,
)
.setAction(
async (
{ address }: Required<RegistryRemoveParams>,
{ viem, hyperdriveDeploy: { deployments }, network },
) => {
const registryAddress = deployments.byName(
network.name === "sepolia"
? "SEPOLIA_REGISTRY"
: "DELV Hyperdrive Registry",
).address as `0x${string}`;
const registryContract = await viem.getContractAt(
"IHyperdriveGovernedRegistry",
registryAddress,
);
let factoryCount =
await registryContract.read.getNumberOfFactories();
console.log(`there are ${factoryCount} factories in the registry`);
console.log(`removing ${address} from registry ...`);
let tx = await registryContract.write.setFactoryInfo([
[address as Address],
[0n],
]);
let pc = await viem.getPublicClient();
await pc.waitForTransactionReceipt({ hash: tx });
factoryCount = await registryContract.read.getNumberOfFactories();
console.log(
`there are now ${factoryCount} factories in the registry`,
);
},
);
11 changes: 9 additions & 2 deletions tasks/registry/remove.ts → tasks/registry/remove-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type RegistryRemoveParams = HyperdriveDeployBaseTaskParams & {

HyperdriveDeployBaseTask(
task(
"registry:remove",
"registry:remove-instance",
"remove the specified hyperdrive instance from the registry",
),
)
Expand All @@ -26,7 +26,6 @@ HyperdriveDeployBaseTask(
{ address }: Required<RegistryRemoveParams>,
{ viem, hyperdriveDeploy: { deployments }, network },
) => {
console.log(`removing ${address} from registry ...`);
const registryAddress = deployments.byName(
network.name === "sepolia"
? "SEPOLIA_REGISTRY"
Expand All @@ -36,12 +35,20 @@ HyperdriveDeployBaseTask(
"IHyperdriveGovernedRegistry",
registryAddress,
);
let instanceCount =
await registryContract.read.getNumberOfInstances();
console.log(`there are ${instanceCount} instances in the registry`);
console.log(`removing ${address} from registry ...`);
let tx = await registryContract.write.setInstanceInfo([
[address as Address],
[0n],
[zeroAddress],
]);
let pc = await viem.getPublicClient();
await pc.waitForTransactionReceipt({ hash: tx });
instanceCount = await registryContract.read.getNumberOfInstances();
console.log(
`there are now ${instanceCount} instances in the registry`,
);
},
);
Loading