Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ ignition/deployments/chain-31337

echidna-corpus
crytic-export

scripts/simulation
9 changes: 9 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,15 @@ task("push-native-token", "Push native currency through a selfdestruct")
console.log("Done.");
});

task("get-proof", "Get proof of a contract")
.addParam("contract", "Contract address")
.setAction(async ({contract}: {contract: string}, hre) => {
console.log(contract);
const proof = await hre.ethers.provider.send("eth_getProof", [contract, [], "latest"]);
console.log(`Proof for the address ${contract}:`);
console.log(proof);
});

const accounts: string[] = isSet(process.env.PRIVATE_KEY) ? [process.env.PRIVATE_KEY || ""] : [];

const config: HardhatUserConfig = {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"dry:deploy-opmainnet": "DRY_RUN=OP_MAINNET VERIFY=false ts-node --files ./scripts/deploy.ts",
"dry:deploy-unichain": "DRY_RUN=UNICHAIN VERIFY=false ts-node --files ./scripts/deploy.ts",
"dry:deploy-base-stage": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deploy.ts",
"dry:deploy-base-simulate": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false SIMULATE=true ts-node --files ./scripts/deploy.ts",
"dry:deploy-arbitrumone-stage": "DRY_RUN=ARBITRUM_ONE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deploy.ts",
"dry:deploy-opmainnet-stage": "DRY_RUN=OP_MAINNET DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deploy.ts",
"dry:deploy-ethereum-stage": "DRY_RUN=ETHEREUM DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deploy.ts",
Expand All @@ -118,6 +119,7 @@
"dry:deploy-erc4626adapterusdc-arbitrumone": "DRY_RUN=ARBITRUM_ONE VERIFY=false ts-node --files ./scripts/deployERC4626Adapter.ts",
"dry:deploy-usdcpool-ethereum-stage": "DRY_RUN=ETHEREUM DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deployUSDCPool.ts",
"dry:deploy-usdcpool-base-stage": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deployUSDCPool.ts",
"dry:deploy-usdcpool-base-simulate": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false SIMULATE=true ts-node --files ./scripts/deployUSDCPool.ts",
"dry:deploy-usdcpoolaave-base-stage": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deployUSDCPoolAave.ts",
"dry:deploy-usdcstablecoinpool-base-stage": "DRY_RUN=BASE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deployUSDCStablecoinPool.ts",
"dry:deploy-usdcpool-opmainnet-stage": "DRY_RUN=OP_MAINNET DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/deployUSDCPool.ts",
Expand Down Expand Up @@ -166,6 +168,7 @@
"dry:upgrade-repayer-arbitrumone-stage": "DRY_RUN=ARBITRUM_ONE DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/upgradeRepayer.ts",
"dry:upgrade-repayer-opmainnet-stage": "DRY_RUN=OP_MAINNET DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/upgradeRepayer.ts",
"dry:upgrade-repayer-ethereum-stage": "DRY_RUN=ETHEREUM DEPLOY_TYPE=STAGE VERIFY=false ts-node --files ./scripts/upgradeRepayer.ts",
"dry:deploy-repayer-base-simulate": "DRY_RUN=BASE SIMULATE=true VERIFY=false ts-node --files ./scripts/deployRepayer.ts",
"lint": "npm run lint:solidity && npm run lint:ts",
"lint:solidity": "solhint 'contracts/**/*.sol'",
"lint:ts": "eslint --ignore-pattern 'coverage/'",
Expand Down
19 changes: 15 additions & 4 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {MaxUint256} from "ethers";
import {MaxUint256, isAddress} from "ethers";
import {toBytes32, resolveProxyXAddress, resolveXAddress, getContractAt, resolveXAddresses} from "../test/helpers";
import {
getVerifier, deployProxyX, getHardhatNetworkConfig, getNetworkConfig, percentsToBps,
Expand All @@ -27,7 +27,18 @@ import {
} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);

const LIQUIDITY_ADMIN_ROLE = toBytes32("LIQUIDITY_ADMIN_ROLE");
const WITHDRAW_PROFIT_ROLE = toBytes32("WITHDRAW_PROFIT_ROLE");
Expand All @@ -37,7 +48,7 @@ export async function main() {
const FEE_SETTER_ROLE = toBytes32("FEE_SETTER_ROLE");

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);

let network: Network;
Expand Down Expand Up @@ -567,7 +578,7 @@ export async function main() {
console.log("InputOutputTokens:");
console.table(flattenInputOutputTokens(inputOutputTokens));
}

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
}

Expand Down
28 changes: 25 additions & 3 deletions scripts/deployCensoredMulticall.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {getVerifier} from "./helpers";
import {getHardhatNetworkConfig, getNetworkConfig, getVerifier} from "./helpers";
import {isAddress} from "ethers";
import {isSet, assert} from "./common";
import {Network, NetworkConfig} from "../network.config";
import {CensoredTransferFromMulticall} from "../typechain-types";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);

let network: Network;
let config: NetworkConfig;
console.log("Deploying contracts set");
({network, config} = await getNetworkConfig());
if (!network) {
({network, config} = await getHardhatNetworkConfig());
}

const censoredTransferFromMulticall = (
await verifier.deployX("CensoredTransferFromMulticall", deployer)
) as CensoredTransferFromMulticall;

console.log(`CensoredTransferFromMulticall: ${censoredTransferFromMulticall.target}`);

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
}

Expand Down
16 changes: 14 additions & 2 deletions scripts/deployERC4626Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ import {ERC4626Adapter} from "../typechain-types";
import {Network, NetworkConfig, ERC4626AdapterUSDCVersions} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isSet(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);

await logDeployers();

Expand All @@ -17,7 +28,7 @@ export async function main() {
const PAUSER_ROLE = toBytes32("PAUSER_ROLE");

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);
let id = ERC4626AdapterUSDCVersions.at(-1);

Expand Down Expand Up @@ -61,6 +72,7 @@ export async function main() {
lastTx = await erc4626AdapterUSDC!.renounceRole(DEFAULT_ADMIN_ROLE, deployer);
}

verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
await lastTx.wait();
}
Expand Down
17 changes: 15 additions & 2 deletions scripts/deployRepayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {isAddress} from "ethers";
import {
getVerifier, deployProxyX, getHardhatNetworkConfig, getNetworkConfig, addLocalPools,
getInputOutputTokens, flattenInputOutputTokens,
Expand All @@ -15,10 +16,21 @@ import {
} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);
let id = "Repayer";

Expand Down Expand Up @@ -119,6 +131,7 @@ export async function main() {
console.table(flattenInputOutputTokens(inputOutputTokens));
}

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
}

Expand Down
18 changes: 15 additions & 3 deletions scripts/deployStandaloneRepayer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {getAddress} from "ethers";
import {getAddress, isAddress} from "ethers";
import {
getVerifier, deployProxyX, getHardhatStandaloneRepayerConfig, getStandaloneRepayerConfig,
getInputOutputTokens, flattenInputOutputTokens,
Expand All @@ -17,11 +17,22 @@ import {
} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);

const REPAYER_ROLE = toBytes32("REPAYER_ROLE");
assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);
const repayerEnv = process.env.STANDALONE_REPAYER_ENV as StandaloneRepayerEnv;
assert(isSet(repayerEnv), "STANDALONE_REPAYER_ENV must be set");
Expand Down Expand Up @@ -138,6 +149,7 @@ export async function main() {
await repayer.renounceRole(DEFAULT_ADMIN_ROLE, deployer);
}

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
}

Expand Down
18 changes: 15 additions & 3 deletions scripts/deployUSDCPool.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {NonceManager} from "ethers";
import {NonceManager, isAddress} from "ethers";
import {getVerifier, getHardhatNetworkConfig, getNetworkConfig, logDeployers} from "./helpers";
import {resolveProxyXAddress, toBytes32} from "../test/helpers";
import {isSet, assert, DEFAULT_ADMIN_ROLE, sameAddress} from "./common";
import {LiquidityPool} from "../typechain-types";
import {Network, NetworkConfig, LiquidityPoolUSDCVersions} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);
const deployerWithNonce = new NonceManager(deployer);

await logDeployers();
Expand All @@ -19,7 +30,7 @@ export async function main() {
const PAUSER_ROLE = toBytes32("PAUSER_ROLE");

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);
let id = LiquidityPoolUSDCVersions.at(-1);

Expand Down Expand Up @@ -62,6 +73,7 @@ export async function main() {
lastTx = await usdcPool!.renounceRole(DEFAULT_ADMIN_ROLE, deployer);
}

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
await lastTx.wait();
}
Expand Down
18 changes: 15 additions & 3 deletions scripts/deployUSDCPoolAave.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {NonceManager} from "ethers";
import {NonceManager, isAddress} from "ethers";
import {getVerifier, getHardhatNetworkConfig, getNetworkConfig, percentsToBps, logDeployers} from "./helpers";
import {resolveProxyXAddress, toBytes32} from "../test/helpers";
import {isSet, assert, assertAddress, DEFAULT_ADMIN_ROLE, sameAddress} from "./common";
import {LiquidityPoolAave} from "../typechain-types";
import {Network, NetworkConfig, LiquidityPoolAaveUSDCVersions} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);
const deployerWithNonce = new NonceManager(deployer);

await logDeployers();
Expand All @@ -19,7 +30,7 @@ export async function main() {
const PAUSER_ROLE = toBytes32("PAUSER_ROLE");

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);

let id = LiquidityPoolAaveUSDCVersions.at(-1);
Expand Down Expand Up @@ -86,6 +97,7 @@ export async function main() {
console.log("Access control setup complete.");
console.log("Remember to update Rebalancer and Repayer routes in the config and then onchain.");

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
await lastTx.wait();
}
Expand Down
18 changes: 15 additions & 3 deletions scripts/deployUSDCPoolAaveLongTerm.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import dotenv from "dotenv";
dotenv.config();
import hre from "hardhat";
import {NonceManager} from "ethers";
import {NonceManager, isAddress} from "ethers";
import {getVerifier, getHardhatNetworkConfig, getNetworkConfig, percentsToBps, logDeployers} from "./helpers";
import {resolveProxyXAddress, toBytes32} from "../test/helpers";
import {isSet, assert, assertAddress, DEFAULT_ADMIN_ROLE, sameAddress} from "./common";
import {LiquidityPoolAaveLongTerm} from "../typechain-types";
import {Network, NetworkConfig, LiquidityPoolAaveUSDCLongTermVersions} from "../network.config";

export async function main() {
const [deployer] = await hre.ethers.getSigners();
let deployer;

const simulate = process.env.SIMULATE === "true" ? true : false;

if (simulate) {
console.log("Simulation mode enabled");
assert(isAddress(process.env.DEPLOYER_ADDRESS), "Deployer address must be set");
deployer = await hre.ethers.getImpersonatedSigner(process.env.DEPLOYER_ADDRESS!);
} else {
[deployer] = await hre.ethers.getSigners();
}
console.log(`Deployer: ${deployer.address}`);
const deployerWithNonce = new NonceManager(deployer);

await logDeployers();
Expand All @@ -21,7 +32,7 @@ export async function main() {
const REPAYER_ROLE = toBytes32("REPAYER_ROLE");

assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set");
const verifier = getVerifier(process.env.DEPLOY_ID);
const verifier = await getVerifier(deployer, process.env.DEPLOY_ID, simulate);
console.log(`Deployment ID: ${process.env.DEPLOY_ID}`);

let id = LiquidityPoolAaveUSDCLongTermVersions.at(-1);
Expand Down Expand Up @@ -93,6 +104,7 @@ export async function main() {
console.log("Access control setup complete.");
console.log("Remember to update Rebalancer and Repayer routes in the config and then onchain.");

await verifier.performSimulation(config.ChainId.toString(), deployer);
await verifier.verify(process.env.VERIFY === "true");
await lastTx.wait();
}
Expand Down
Loading