Skip to content

Commit

Permalink
typechain to help with deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
aazhou1 committed Dec 21, 2024
1 parent 73b8b3b commit 4e477f2
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 43 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-strategy-hardhat-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
- run: yarn install
- run: rm -rf src/test/kontrol/
- run: yarn hardhat compile
- run: yarn hardhat typechain
- run: yarn mainnet:deploy-strategy
env:
ASSET_ADDRESS: ${{ github.event.inputs.asset }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-strategy-hardhat-sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
- run: yarn install
- run: rm -rf src/test/kontrol/
- run: yarn hardhat compile
- run: yarn hardhat typechain
- run: yarn sepolia:deploy-strategy
env:
ASSET_ADDRESS: ${{ github.event.inputs.asset }}
Expand Down
59 changes: 24 additions & 35 deletions hardhat-scripts/deploy-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import dotenv from "dotenv";
import { Signer } from "ethers";
import { promises as fs } from 'fs';
import path from 'path';
import { Strategy } from '../typechain-types/src/Strategy';
type StrategyParamsStruct = Strategy.StrategyParamsStruct;


dotenv.config();
Expand Down Expand Up @@ -49,34 +51,33 @@ async function checkUnderlyingVaultAsset(
}

async function buildStrategyParams(
eventEmitter: string,
_eventEmitter: string,
deployer: string,
managedSigner: Signer
) {
const asset = process.env.ASSET_ADDRESS!;
const yearnVaultAddress = process.env.YEARN_VAULT_ADDRESS!;
const discountRateAdapterAddress = process.env.DISCOUNT_RATE_ADAPTER_ADDRESS!;
const termController = process.env.TERM_CONTROLLER_ADDRESS!;
const discountRateMarkup = process.env.DISCOUNT_RATE_MARKUP!;
const timeToMaturityThreshold = process.env.TIME_TO_MATURITY_THRESHOLD!;
const repoTokenConcentrationLimit =
process.env.REPOTOKEN_CONCENTRATION_LIMIT!;
const newRequiredReserveRatio = process.env.NEW_REQUIRED_RESERVE_RATIO!;

await checkUnderlyingVaultAsset(asset, yearnVaultAddress, managedSigner);
const _asset = process.env.ASSET_ADDRESS!;
const _yearnVault = process.env.YEARN_VAULT_ADDRESS!;
const _discountRateAdapter = process.env.DISCOUNT_RATE_ADAPTER_ADDRESS!;
const _termController = process.env.TERM_CONTROLLER_ADDRESS!;
const _discountRateMarkup = ethers.BigNumber.from(process.env.DISCOUNT_RATE_MARKUP!);
const _timeToMaturityThreshold = ethers.BigNumber.from(process.env.TIME_TO_MATURITY_THRESHOLD!);
const _repoTokenConcentrationLimit = ethers.BigNumber.from(process.env.REPOTOKEN_CONCENTRATION_LIMIT!);
const _requiredReserveRatio = ethers.BigNumber.from(process.env.NEW_REQUIRED_RESERVE_RATIO!);

await checkUnderlyingVaultAsset(_asset, _yearnVault, managedSigner);

return {
asset,
yearnVaultAddress,
discountRateAdapterAddress,
eventEmitter,
deployer,
termController,
repoTokenConcentrationLimit,
timeToMaturityThreshold,
newRequiredReserveRatio,
discountRateMarkup,
};
_asset,
_yearnVault,
_discountRateAdapter,
_eventEmitter,
_governorAddress: deployer,
_termController,
_repoTokenConcentrationLimit,
_timeToMaturityThreshold,
_requiredReserveRatio,
_discountRateMarkup,
} as StrategyParamsStruct;
}

async function deployEventEmitter(managedSigner: Signer) {
Expand Down Expand Up @@ -179,18 +180,6 @@ for (const artifactPath of possibleArtifactPaths) {
const [strategyName, strategySymbol] = strategyMeta.trim().split(",").map(x => x.trim())
console.log(`Deploying strategy with (${strategyName}, ${strategySymbol})`);
// Log the exact values we're passing
console.log("Deploying with:", {
strategyName,
strategySymbol,
params: {
...params,
// Convert BigNumber values to strings for logging
repoTokenConcentrationLimit: params.repoTokenConcentrationLimit.toString(),
timeToMaturityThreshold: params.timeToMaturityThreshold.toString(),
newRequiredReserveRatio: params.newRequiredReserveRatio.toString(),
discountRateMarkup: params.discountRateMarkup.toString()
}
});
console.log("About to deploy with params:", {
funcFragment: Strategy.interface.deploy,
args: [strategyName, strategySymbol, params]
Expand Down
14 changes: 14 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { task } from "hardhat/config";
import path from "path";
import glob from "glob";
import fs from "fs";
import "hardhat-abi-exporter";
import "@typechain/hardhat";



const remappings = fs
.readFileSync("remappings.txt", "utf-8")
Expand Down Expand Up @@ -46,6 +50,16 @@ const config: HardhatUserConfig = {
},
},
},
abiExporter: {
runOnCompile: true,
clear: true,
flat: false,
format: "json",
},
typechain: {
outDir: "typechain-types",
target: "ethers-v5",
},
paths: {
sources: "./src", // Where your contracts are
artifacts: "./artifacts", // Where compiled artifacts go
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"@ethersproject/experimental": "^5.7.0",
"@nomicfoundation/hardhat-foundry": "^1.1.3",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/hardhat": "^6.1.2",
"dotenv": "^16.4.7",
"env-cmd": "^10.1.0",
"ethers": "^5.4.7",
"hardhat": "^2.22.17",
"hardhat-abi-exporter": "^2.10.1",
"path": "^0.12.7",
"prettier": "^2.5.1",
"prettier-plugin-solidity": "^1.0.0-beta.19",
Expand All @@ -16,6 +19,7 @@
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.7.2"
},
"scripts": {
Expand Down
Loading

0 comments on commit 4e477f2

Please sign in to comment.