Skip to content

Commit

Permalink
fix a bug in otoken daily stats
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Dec 24, 2024
1 parent 14982ea commit d37ba0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion scripts/generate-validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LIMIT = 1000
const gql = (query: string) => query

const executeQuery = async (query: string) => {
const response = await fetch('https://origin.squids.live/origin-squid@v65/api/graphql', {
const response = await fetch('https://origin.squids.live/origin-squid@v66/api/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -32,6 +32,10 @@ const takeValidationEntries = (arr: any[]) => {
return arr.filter((entry) => entry.blockNumber % 100000 === 0)
}

const takeEvery = (arr: any[], n: number = 25) => {
return arr.filter((_, i) => i % n === 0)
}

const oTokens = (prefix: string, address: string) => {
return gql(`
${prefix}_oTokens: oTokens(
Expand Down Expand Up @@ -412,6 +416,9 @@ const main = async () => {
}
for (const key of Object.keys(result.data)) {
entities[key] = takeValidationEntries(result.data[key])
if (entities[key].length < 5) {
entities[key] = takeEvery(result.data[key], 25)
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/templates/otoken/otoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ export const createOTokenProcessor = (params: {
const id = `${ctx.chain.id}-${params.otokenAddress}-${dayString}`
let entity = result.dailyStats.get(id)?.entity
if (entity) {
result.dailyStats.set(entity.id, { block, entity })
entity.timestamp = new Date(block.header.timestamp)
entity.blockNumber = block.header.height
return entity
}

Expand Down Expand Up @@ -859,9 +862,6 @@ export const createOTokenProcessor = (params: {

for (const block of ctx.blocks) {
await getOTokenDailyStat(block)
}

for (const block of ctx.blocksWithContent) {
for (const trace of block.traces) {
if (
trace.type === 'call' &&
Expand Down

0 comments on commit d37ba0f

Please sign in to comment.