Skip to content

Commit 1225d2f

Browse files
committed
fixes after review
1 parent e3324b7 commit 1225d2f

5 files changed

Lines changed: 176 additions & 204 deletions

File tree

reviews/otoken-processor-sync-issues.md

Lines changed: 0 additions & 162 deletions
This file was deleted.

squid.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ deploy:
133133
# # BLOCK_FROM: 20919091
134134
- name: os-processor
135135
cmd: ['sqd', 'process:os:prod']
136-
########## HYPEREVM NETWORK ##########
137-
- name: hyperevm-processor
138-
cmd: ['sqd', 'process:hyperevm:prod']
139136
# env:
140137
# ### Fork Setup Stage 1
141138
# ARCHIVE_ONLY: 'true'
@@ -146,6 +143,9 @@ deploy:
146143
# # RPC_SONIC_ENDPOINT: https://virtual.base.rpc.tenderly.co/103020a8-b59a-4d51-9f8b-b156564e9fb8
147144
# ### Time Travel Fix
148145
# # BLOCK_FROM: 20919091
146+
########## HYPEREVM NETWORK ##########
147+
- name: hyperevm-processor
148+
cmd: ['sqd', 'process:hyperevm:prod']
149149
api:
150150
cmd:
151151
- npx

src/main-hyperevm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { processStatus } from '@templates/processor-status'
77
import { DEFAULT_FIELDS } from '@utils/batch-proccesor-fields'
88

99
export const processor = defineSquidProcessor({
10-
chainId: hyperEvm.id as any, // cast needed until squid-utils adds HyperEVM to chainConfigs
10+
chainId: hyperEvm.id,
1111
stateSchema: 'hyperevm-processor',
1212
processors: [
1313
createMorphoVaultApyProcessor({
@@ -25,4 +25,4 @@ if (require.main === module) {
2525
run(processor).catch((error) => {
2626
throw error
2727
})
28-
}
28+
}

src/server-extension/morpho.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { EntityManager, MoreThanOrEqual } from 'typeorm'
44
import { createPublicClient, fallback, http } from 'viem'
55
import { base, hyperEvm, mainnet } from 'viem/chains'
66

7-
import { chainConfigs } from '@originprotocol/squid-utils'
87
import { MorphoVaultApy } from '@model'
8+
import { chainConfigs } from '@originprotocol/squid-utils'
99
import { computeDepositImpact } from '@templates/morpho/deposit-impact'
1010

1111
import './fetch-polyfill'
@@ -19,23 +19,31 @@ function parseWindowMs(window: string): number | null {
1919
return unit === 'h' ? n * 3600 * 1000 : n * 86400 * 1000
2020
}
2121

22+
const clients = {
23+
[mainnet.id]: createPublicClient({
24+
chain: mainnet,
25+
transport: fallback((chainConfigs[mainnet.id]?.endpoints ?? []).map((url) => http(url))),
26+
}),
27+
[base.id]: createPublicClient({
28+
chain: base,
29+
transport: fallback((chainConfigs[base.id]?.endpoints ?? []).map((url) => http(url))),
30+
}),
31+
[hyperEvm.id]: createPublicClient({
32+
chain: hyperEvm,
33+
transport: http(process.env.RPC_HYPEREVM_ENDPOINT ?? 'https://rpc.hyperliquid.xyz/evm'),
34+
}),
35+
}
36+
2237
/** Build a viem PublicClient for a given chainId. */
2338
function getViemClient(chainId: number) {
2439
if (chainId === mainnet.id) {
25-
return createPublicClient({
26-
chain: mainnet,
27-
transport: fallback((chainConfigs[mainnet.id]?.endpoints ?? []).map((url) => http(url))),
28-
})
40+
return clients[mainnet.id]
2941
}
3042
if (chainId === base.id) {
31-
return createPublicClient({
32-
chain: base,
33-
transport: fallback((chainConfigs[base.id]?.endpoints ?? []).map((url) => http(url))),
34-
})
43+
return clients[base.id]
3544
}
3645
if (chainId === hyperEvm.id) {
37-
const rpc = process.env.RPC_HYPEREVM_ENDPOINT ?? 'https://rpc.hyperliquid.xyz/evm'
38-
return createPublicClient({ chain: hyperEvm, transport: http(rpc) })
46+
return clients[hyperEvm.id]
3947
}
4048
throw new Error(`Unsupported chainId: ${chainId}. Supported: ${mainnet.id}, ${base.id}, ${hyperEvm.id}`)
4149
}
@@ -130,9 +138,7 @@ export class MorphoVaultApyResolver {
130138
})
131139

132140
const timeWindowHours = windowMs / 3600000
133-
const averageApy = snapshots.length > 0
134-
? snapshots.reduce((sum, s) => sum + s.apy, 0) / snapshots.length
135-
: 0
141+
const averageApy = snapshots.length > 0 ? snapshots.reduce((sum, s) => sum + s.apy, 0) / snapshots.length : 0
136142

137143
return new MorphoVaultApyAverageResult({ averageApy, timeWindowHours })
138144
}

0 commit comments

Comments
 (0)