Skip to content

Commit f2af328

Browse files
committed
Fix arb and bsc firstBlock
1 parent 1f33563 commit f2af328

File tree

4 files changed

+45
-33
lines changed

4 files changed

+45
-33
lines changed

bin/check-config.ts

+42-30
Original file line numberDiff line numberDiff line change
@@ -339,30 +339,30 @@ async function main() {
339339
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
340340
// // write data files with missing holder counts
341341
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
342-
// for (const chain of Object.keys(dataFileContentPerChain)) {
343-
// const fs = require("fs")
342+
for (const chain of Object.keys(dataFileContentPerChain)) {
343+
const fs = require("fs")
344344

345-
// // only if the chain has a config file
346-
// if (!fs.existsSync(`./config/${chain}.json`)) {
347-
// continue
348-
// }
345+
// only if the chain has a config file
346+
if (!fs.existsSync(`./config/${chain}.json`)) {
347+
continue
348+
}
349349

350-
// const targetFile = `./data/${chain}_data.json`
351-
// const dataFileContent = dataFileContentPerChain[chain]
352-
// const existingDataFileContentIfAny = fs.existsSync(targetFile)
353-
// ? JSON.parse(fs.readFileSync(targetFile, "utf8"))
354-
// : { no_factory_vaults: [], no_factory_boosts: [] }
350+
const targetFile = `./data/${chain}_data.json`
351+
const dataFileContent = dataFileContentPerChain[chain]
352+
const existingDataFileContentIfAny = fs.existsSync(targetFile)
353+
? JSON.parse(fs.readFileSync(targetFile, "utf8"))
354+
: { no_factory_vaults: [], no_factory_boosts: [] }
355355

356-
// dataFileContent.no_factory_vaults = dataFileContent.no_factory_vaults.concat(existingDataFileContentIfAny.no_factory_vaults)
357-
// dataFileContent.no_factory_boosts = dataFileContent.no_factory_boosts.concat(existingDataFileContentIfAny.no_factory_boosts)
358-
// dataFileContent.no_factory_vaults = Array.from(new Set(dataFileContent.no_factory_vaults))
359-
// dataFileContent.no_factory_boosts = Array.from(new Set(dataFileContent.no_factory_boosts))
356+
dataFileContent.no_factory_vaults = dataFileContent.no_factory_vaults.concat(existingDataFileContentIfAny.no_factory_vaults)
357+
dataFileContent.no_factory_boosts = dataFileContent.no_factory_boosts.concat(existingDataFileContentIfAny.no_factory_boosts)
358+
dataFileContent.no_factory_vaults = Array.from(new Set(dataFileContent.no_factory_vaults))
359+
dataFileContent.no_factory_boosts = Array.from(new Set(dataFileContent.no_factory_boosts))
360360

361-
// dataFileContent.no_factory_vaults.sort()
362-
// dataFileContent.no_factory_boosts.sort()
361+
dataFileContent.no_factory_vaults.sort()
362+
dataFileContent.no_factory_boosts.sort()
363363

364-
// fs.writeFileSync(targetFile, JSON.stringify(dataFileContent, null, 2))
365-
// }
364+
fs.writeFileSync(targetFile, JSON.stringify(dataFileContent, null, 2))
365+
}
366366

367367
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
368368
// display top 30 missing TVL to focus on the most important vaults
@@ -488,7 +488,7 @@ async function main() {
488488
})
489489

490490
if (!result.ok) {
491-
console.error(`Failed to fetch data from subgraph: ${result.statusText}`)
491+
console.error(`Failed to fetch data from ${subgraphUrl} subgraph ${chain} (${result.statusText}): ${gql}`)
492492
console.error(await result.text())
493493
continue
494494
}
@@ -503,7 +503,8 @@ async function main() {
503503
| { errors: { location: string[]; message: string }[] }
504504

505505
if ("errors" in resultData) {
506-
console.error(`Failed to fetch data from subgraph: ${JSON.stringify(resultData.errors, null, 2)}`)
506+
console.error(`Failed to fetch data from ${subgraphUrl} subgraph ${chain} (${result.statusText}): ${gql}`)
507+
console.error(JSON.stringify(resultData.errors, null, 2))
507508
continue
508509
}
509510

@@ -530,8 +531,12 @@ async function main() {
530531
}
531532

532533
const gql = `{
533-
tokens(where: {balances_: {rawAmount_lt: 0}}) {
534-
id
534+
tokenBalances(where: {rawAmount_lt: 0}, skip: 0, first: 1000) {
535+
token {
536+
id
537+
}
538+
amount
539+
rawAmount
535540
}
536541
}`
537542

@@ -544,36 +549,43 @@ async function main() {
544549
})
545550

546551
if (!result.ok) {
547-
console.error(`Failed to fetch data from subgraph ${chain}: ${result.statusText}`)
552+
console.error(`Failed to fetch data from ${subgraphUrl} subgraph ${chain} (${result.statusText}): ${gql}`)
548553
console.error(await result.text())
549554
continue
550555
}
551556

552557
const resultData = (await result.json()) as
553558
| {
554559
data: {
555-
tokens: {
556-
id: string
560+
tokenBalances: {
561+
token: {
562+
id: string
563+
}
564+
amount: string
565+
rawAmount: string
557566
}[]
558567
}
559568
}
560569
| { errors: { location: string[]; message: string }[] }
561570

562571
if ("errors" in resultData) {
563-
console.error(`Failed to fetch data from subgraph: ${JSON.stringify(resultData.errors, null, 2)}`)
572+
console.error(`Failed to fetch data from ${subgraphUrl} subgraph ${chain} (${result.statusText}): ${gql}`)
573+
console.error(JSON.stringify(resultData.errors, null, 2))
564574
continue
565575
}
566576

567-
if (resultData.data.tokens.length > 0) {
577+
if (resultData.data.tokenBalances.length > 0) {
568578
const duneChain = chain === "bsc" ? "bnb" : chain === "avax" ? "avalanche_c" : chain
569579
const duneQuery = `
570580
SELECT to, min(block_number)
571581
FROM ${duneChain}.transactions
572-
WHERE ${resultData.data.tokens.map((t) => `to = ${t.id}`).join("\n OR ")}
582+
WHERE ${uniq(resultData.data.tokenBalances.map((t) => t.token.id))
583+
.map((t) => `to = ${t}`)
584+
.join("\n OR ")}
573585
group by to
574586
order by min(block_number)
575587
`
576-
console.error(`${chain}: Found ${resultData.data.tokens.length} tokens with balances below 0, please fix firstBlock in config.
588+
console.error(`${chain}: Found ${resultData.data.tokenBalances.length} token balances with balances below 0, please fix firstBlock in config.
577589
${duneQuery}
578590
`)
579591
}

config/arbitrum.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"indexerHintPrune": 20000000,
44
"shareTokenMintAddress": "0x0000000000000000000000000000000000000000",
55
"burnAddress": "0x000000000000000000000000000000000000dead",
6-
"firstBlock": 1365253,
6+
"firstBlock": 1362980,
77

88
"clmManagerFactoryAddress": "0xD41Ce2c0a0596635FC09BDe2C35946a984b8cB7A",
99
"clmManagerFactoryStartBlock": 219696027,

config/bsc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"indexerHintPrune": 2000000,
44
"shareTokenMintAddress": "0x0000000000000000000000000000000000000000",
55
"burnAddress": "0x000000000000000000000000000000000000dead",
6-
"firstBlock": 1573192,
6+
"firstBlock": 1174850,
77

88
"clmManagerFactoryAddress": "0xAe8b53413862984C4e10929D41735800E0A4EdF9",
99
"clmManagerFactoryStartBlock": 40991490,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "yarn run --silent test:lint && yarn run --silent test:unit",
1010
"test:unit": "echo 'No unit tests defined'",
1111
"test:lint": "prettier . --check",
12-
"test:config": "ts-node --project tsconfig.scripts.json ./bin/check-config.ts",
12+
"test:config": "ts-node --project tsconfig.scripts.json ./bin/check-config.ts; yarn format",
1313
"update:addressbook": "ncu --upgrade blockchain-addressbook viem && yarn install",
1414
"configure": "./bin/prepare.sh "
1515
},

0 commit comments

Comments
 (0)