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

RunAll task for running on multiple networks #716

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion scripts/calculateMinichefOwed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers, deployments, network, getChainId, config } from "hardhat"
import { BigNumber } from "ethers"
import { config, deployments, ethers, getChainId, network } from "hardhat"
import fetch from "node-fetch"
import { MiniChefV2, SDL } from "../build/typechain"
import { getNetworkNameFromChainId } from "../utils/network"
Expand Down Expand Up @@ -153,6 +153,10 @@ async function main() {
)
}

export function calculateMinichefOwed() {
main()
}

main()
.then(() => process.exit(0))
.catch((error) => {
Expand Down
83 changes: 83 additions & 0 deletions scripts/minichefSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { ethers, network } from "hardhat"
import { MiniChefV2 } from "../build/typechain"
import { logNetworkDetails } from "./utils"

async function main() {
// Prints out all entries held in the pool registry
// Specify what data to display in console.table() below.
// Run with runAll comand to fetch data from all networks.

// Print network details
await logNetworkDetails(ethers.provider, network)
const minichef = (await ethers.getContract("MiniChefV2")) as MiniChefV2
const poolLegth = await minichef.poolLength()
type PoolInfo = {
lpTokenName: string
accSaddlePerShare: string
lastRewardTime: string
allocPoint: string
rewarder?: string
}
let PoolInfos: { [lpToken: string]: Partial<PoolInfo> } = {}
let lpTokenNames: { [lpTokenAddress: string]: string } = {}
let rewarders: { [lpToken: string]: string } = {}

// Get all LPToken deployment jsons
const fs = require("fs")
const path = require("path")
const files = fs.readdirSync(
path.join(__dirname + "/..", "deployments", network.name),
)
// itterate through all LPToken json files in deployments/networkname

files.forEach((file: any) => {
if (file != "LPToken.json" && file.includes("LPToken.json")) {
const fileJson = require(path.join(
__dirname + "/..",
"deployments",
network.name,
file,
))
const name = file.split(".")[0]
lpTokenNames[fileJson.address] = name
}
})
for (let i = 1; i < poolLegth.toNumber(); i++) {
const pool = await minichef.poolInfo(i)
const lpToken = await minichef.lpToken(i)
PoolInfos[lpToken] = {
lpTokenName: lpTokenNames[lpToken],
accSaddlePerShare: pool.accSaddlePerShare.toString(),
lastRewardTime: pool.lastRewardTime.toString(),
allocPoint: pool.allocPoint.toString(),
}

if (
(await minichef.rewarder(i)) !=
"0x0000000000000000000000000000000000000000"
) {
rewarders[lpTokenNames[lpToken]] = await minichef.rewarder(i)
}
}
// remove lptToken 0xc55E8C79e5A6c3216D4023769559D06fa9A7732e as it is an error
delete PoolInfos["0xc55E8C79e5A6c3216D4023769559D06fa9A7732e"]
console.log(`MiniChef info on ${network.name}:`)
console.log("MiniChef Saddle per second: ", await minichef.saddlePerSecond())
// specify table columns from above object to display here
console.table(PoolInfos, [
"lpTokenName",
"accSaddlePerShare",
"lastRewardTime",
"allocPoint",
])
if (Object.keys(rewarders).length > 0) {
console.log(`Rewarders on ${network.name}:`)
console.table(rewarders)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
50 changes: 50 additions & 0 deletions scripts/poolRegistryPrintout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ethers, network } from "hardhat"
import { PoolRegistry } from "../build/typechain"
import { logNetworkDetails } from "./utils"

async function main() {
// Prints out all entries held in the pool registry
// Specify what data to display in console.table() below.
// Run with runAll comand to fetch data from all networks.

// Print network details
await logNetworkDetails(ethers.provider, network)

// const signers = await ethers.getSigners()
const poolRegistry = (await ethers.getContract(
"PoolRegistry",
)) as PoolRegistry

// get all pools from pool registry
let poolRegLegnth: number = (await poolRegistry.getPoolsLength()).toNumber()
// let poolEntries: { [poolname: string]: IPoolRegistry.PoolDataStructOutput } =
// {}
let poolEntries: { [poolname: string]: any } = {}
for (let pid = 0; pid < poolRegLegnth; pid++) {
const entry = await poolRegistry.getPoolDataAtIndex(pid)
const poolName = ethers.utils.parseBytes32String(entry.poolName)
poolEntries[poolName] = {
poolAddress: entry.poolAddress,
lptokenAddress: entry.lpToken,
typeOfAsset: entry.typeOfAsset,
poolName: poolName,
targetAddress: entry.targetAddress,
tokens: entry.tokens,
underlyingTokens: entry.underlyingTokens,
basePoolAddress: entry.basePoolAddress,
metaSwapDepositAddress: entry.metaSwapDepositAddress,
isSaddleApproved: entry.isSaddleApproved,
isRemoved: entry.isRemoved,
isGuarded: entry.isGuarded,
}
}
console.log(`Pool Registry Entries on ${network.name}:`)
// specify table columns from above object to display here
console.table(poolEntries, ["poolAddress", "lptokenAddress"])
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
Loading