Skip to content

Commit

Permalink
Add config check
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Aug 1, 2024
1 parent 7824459 commit 7a82098
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
18 changes: 16 additions & 2 deletions bin/check-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ const checkConfig = async () => {
const configVaultFoundByAddress = configVaultsByAddress[apiVault.earnContractAddress.toLocaleLowerCase()]

if (!configVaultFoundByAddress) {
console.log(`Vault ${apiVault.id} not found in config by address: ${apiVault.earnContractAddress}`)
console.warn(`Vault ${apiVault.id} not found in config by address: ${apiVault.earnContractAddress}`)
} else if (!configVaultFoundById) {
console.log(
console.warn(
`Vault with address ${apiVault.earnContractAddress} has incorrect id ${configVaultFoundByAddress.vaultKey} instead of ${apiVault.id}`,
)
} else {
// OK
}
}

const duplicateConfigByAddress = configVaults.reduce(
(acc, v) => {
acc[v.address.toLocaleLowerCase()] = (acc[v.address.toLocaleLowerCase()] || 0) + 1
return acc
},
{} as Record<string, number>,
)
for (const [address, count] of Object.entries(duplicateConfigByAddress)) {
if (count > 1) {
console.error(`Duplicate config for address ${address}`)
throw new Error(`Duplicate config for address ${address}`)
}
}
}

checkConfig()
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"codegen": "rm -Rf generated && graph codegen",
"build": "graph build",
"format": "prettier . --write",
"test": "yarn run --silent test:lint && yarn run --silent test:unit",
"test": "yarn run --silent test:lint && yarn run --silent test:unit && yarn run --silent test:config",
"test:unit": "graph test",
"test:lint": "prettier . --check",
"check-config": "ts-node --project tsconfig.scripts.json ./bin/check-config.ts",
"test:config": "ts-node --project tsconfig.scripts.json ./bin/check-config.ts",
"infra:start": "docker compose up -d",
"infra:stop": "docker compose down",
"create-local": "graph create beefyfinance/lrt --node http://127.0.0.1:8020",
Expand Down
1 change: 0 additions & 1 deletion src/vault-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function _getChainVaults(network: string): Array<VaultConfig> {
vaults.push(new VaultConfig("uniswap-cow-arb-ezeth-wsteth-rp", PLATFORM_BEEFY_CLM, "0x83368b5e04d8a2c990ef9b5fe41509fafcfba499", ["0xe4c1fc47aDB25506E664Af9748a4c3ee98828318"]))
vaults.push(new VaultConfig("uniswap-cow-arb-rseth-wsteth", PLATFORM_BEEFY_CLM, "0x15cfBd3Db5D24360eeac802b3dde4423eb5C3C70", ["0x8B0345E218B84274154071614641a501821374A6"]))
vaults.push(new VaultConfig("aura-arb-rseth-weth", PLATFORM_BALANCER_AURA, "0x764e4e75e3738615CDBFAeaE0C8527b1616e1123"))
vaults.push(new VaultConfig("uniswap-cow-arb-rseth-weth", PLATFORM_BEEFY_CLM, "0xf3D5c975de1c0Fd358a593Bcef7a41c61366127C", ["0x04D463bf08dF252Cb09a87D6d41a33c535942710"]))
vaults.push(new VaultConfig("camelot-rseth-weth", PLATFORM_BEEFY_CLM, "0xac8246F01197fB783Bf1A80960821835045Ec680", ["0xD9001574E23fb909657A25494f540A9B3804b16e"]))
vaults.push(new VaultConfig("pancake-cow-arb-rseth-weth-vault", PLATFORM_BEEFY_CLM_VAULT, "0x70a9DC4c4c4ea1A621c174e3F438582fA7C99BFA"))
vaults.push(new VaultConfig("pancake-cow-arb-rseth-weth-rp", PLATFORM_BEEFY_CLM, "0x5c1f30297b7997601a2ae2957cdc95cd4783e544", ["0x3ec0e7Bf0DCDA562d67d8d7F27569AA0be080DAb"]))
Expand Down

0 comments on commit 7a82098

Please sign in to comment.