aave / aave-v3-deploy

Other
45 stars 75 forks source link

Unable to incorporate into hardhat project. #44

Open jguthrie7 opened 1 year ago

jguthrie7 commented 1 year ago

I would like to include aave-v3-deploy in my project in order to integrate with the aave-v3 contracts.

I followed the steps in the README: How to integrate in your Hardhat project

Reproduction steps

------------
bash
------------
mkdir test-ts
cd test-ts/
npm init
npx hardhat init

✔ What do you want to do? · Create a TypeScript project
✔ Hardhat project root: · /Users/john/dev/github/temp/test-ts
✔ Do you want to add a .gitignore? (Y/n) · y
✔ Do you want to install this sample project's dependencies with npm (hardhat @nomicfoundation/hardhat-toolbox)? (Y/n) · n

-------------
.env
-------------
# Name of the Market to deploy. If you want to deploy a custom market, it must be included at `loadPoolConfig` function at ./helpers/market-config-helpers.ts:65
MARKET_NAME=Aave

# Alchemy RPC api key
ALCHEMY_KEY="Valid Key"

# Seed phrase
MNEMONIC="Valid Mnemonic"

# Etherscan API key to verify contracts
ETHERSCAN_KEY=

# Toggle Permissioned Faucet
PERMISSIONED_FAUCET=false

--------------
#package.json
--------------
{
  "name": "test-ts",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@aave/deploy-v3": "^1.55.3",
    "@aave/core-v3": "^1.19.0",
    "@aave/periphery-v3": "^2.4.1",
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "hardhat": "^2.17.0",
    "hardhat-deploy": "^0.11.34"
  },
  "dependencies": {
    "bluebird": "^3.7.2",
    "dotenv": "^16.3.1",
    "ethers": "^5.7.2",
    "jsondiffpatch": "^0.4.1"
  }
}

--------------
hardhat.config.ts
--------------
import dotenv from "dotenv";
dotenv.config();
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

import "hardhat-deploy";
import { DEFAULT_NAMED_ACCOUNTS, hardhatNetworkSettings } from "@aave/deploy-v3";

const autoOrNumberOrUndefined = (value?: "auto" | string | number) => {
  if (value === undefined) return value;
  if (value === "auto") return value;
  if (typeof value === "number") return value;

  return parseFloat(value);
}

const numberOrUndefined = (value?: string | number) => {
  if (value === undefined) return value;
  if (typeof value === "number") return value;

  return parseFloat(value);
}

const config: HardhatUserConfig = {
  solidity: "0.8.18",
  networks: {
    hardhat: {
      ...hardhatNetworkSettings,
      gasPrice: autoOrNumberOrUndefined(hardhatNetworkSettings.gasPrice),
      initialBaseFeePerGas: numberOrUndefined(hardhatNetworkSettings.initialBaseFeePerGas),
    },
  },
  namedAccounts: {
    ...DEFAULT_NAMED_ACCOUNTS
  },
  external: {
    contracts: [
      {
        artifacts: "node_modules/@aave/deploy-v3/artifacts",
        deploy: "node_modules/@aave/deploy-v3/dist/deploy"
      }
    ]
  }
};

export default config;

--------------
bash
--------------
npm i
npx hardhat deploy 

# you eventually get this error:
=== Post deployment hook ===
- Enable stable borrow in selected assets
- Checking reserve DAI , normalized symbol DAI
  - Reserve DAI Borrow Stable Rate follows the expected configuration
- Checking reserve LINK , normalized symbol LINK
  - Reserve LINK Borrow Stable Rate follows the expected configuration
- Checking reserve USDC , normalized symbol USDC
  - Reserve USDC Borrow Stable Rate follows the expected configuration
- Checking reserve WBTC , normalized symbol WBTC
  - Reserve WBTC Borrow Stable Rate follows the expected configuration
- Checking reserve WETH , normalized symbol WETH
  - Reserve WETH Borrow Stable Rate follows the expected configuration
- Checking reserve USDT , normalized symbol USDT
  - Reserve USDT Borrow Stable Rate follows the expected configuration
- Checking reserve AAVE , normalized symbol AAVE
  - Reserve AAVE Borrow Stable Rate follows the expected configuration
- Checking reserve EURS , normalized symbol EURS
  - Reserve EURS Borrow Stable Rate follows the expected configuration
- Review rate strategies
- Checking reserve DAI , normalized symbol DAI
An unexpected error occurred:

Error: ERROR processing /Users/john/dev/github/temp/test-ts/node_modules/@aave/deploy-v3/dist/deploy/01-after-deploy.js:
HardhatError: HH700: Artifact for contract "DefaultReserveInterestRateStrategy" not found.
    at Artifacts._handleWrongArtifactForContractName (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/artifacts.ts:700:11)
    at Artifacts._getArtifactPathFromFiles (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/artifacts.ts:825:19)
    at Artifacts._getArtifactPath (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/artifacts.ts:505:21)
    at async Artifacts.readArtifact (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/artifacts.ts:71:26)
    at async getContractAt (/Users/john/dev/github/temp/test-ts/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:303:22)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/@aave/deploy-v3/dist/tasks/misc/review-rate-strategies.js:49:34)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Object.Environment.run (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async Object.func (/Users/john/dev/github/temp/test-ts/node_modules/@aave/deploy-v3/dist/deploy/01-after-deploy.js:15:5)
    at async DeploymentsManager.executeDeployScripts (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1226:22)
    at async DeploymentsManager.runDeploy (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1049:13)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/index.ts:438:5)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/index.ts:584:32)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at DeploymentsManager.executeDeployScripts (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1229:19)
    at async DeploymentsManager.runDeploy (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1049:13)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/index.ts:438:5)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/index.ts:584:32)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async SimpleTaskDefinition.action (/Users/john/dev/github/temp/test-ts/node_modules/hardhat-deploy/src/index.ts:669:5)
    at async Environment._runTaskDefinition (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async main (/Users/john/dev/github/temp/test-ts/node_modules/hardhat/src/internal/cli/cli.ts:280:7)

I have tried many things but am unable to get past this.

Would appreciate any assistance

jguthrie7 commented 1 year ago

OS: MacOS 13.5

Version information:

node --version
v16.20.1
john@Johns-Mac-mini ~/d/g/t/test-ts> npm --version
8.19.4
john@Johns-Mac-mini ~/d/g/t/test-ts> npx hardhat --version
2.17.0
defispartan commented 1 year ago

I just cloned, added key + mnemonic to .env, and was able to deploy this market :thinking:

Are you sure you're using the latest version of hardhat.config.ts? The output here seems to be missing the dependency array https://github.com/aave/aave-v3-deploy/blob/f032945196f1f9ae09e503c555d15de051b56c0a/hardhat.config.ts#L152

jguthrie7 commented 1 year ago

Hi there @defispartan . Thanks for looking into this.

I can also run aave-v3-deploy as expected when I clone.

I am running into issues when attempting to add it as a dependency to another hardhat project following these instructions: https://github.com/aave/aave-v3-deploy#how-to-integrate-in-your-hardhat-project

In my case DefaultReserveInterestRateStrategy.sol is present along with its artifact, but it isn't found when npc hardhat deploy is run.

npx hardhat --version
2.17.0
Thaddeus19 commented 7 months ago

I have the same issue, when I reach the point of https://github.com/aave/aave-v3-deploy/blob/main/deploy/01-after-deploy.ts#L26 and run the task in the https://github.com/aave/aave-v3-deploy/blob/main/tasks/misc/review-rate-strategies.ts#L78 it doesn't find the artifact of DefaultReserveInterestRateStrategy and throws an error halting the entire deploy.