1- import { ChainApi } from '@defillama/sdk'
1+ import { getLogs } from "@defillama/sdk/build/util/logs" ;
2+ import { getProvider } from "@defillama/sdk" ;
23import { LinearAdapterResult , TimeSeriesChainData } from "../../types/adapters" ;
34import { PromisePool } from "@supercharge/promise-pool" ;
45import { getBlock } from "@defillama/sdk/build/computeTVL/blocks" ;
@@ -41,10 +42,6 @@ const VERSIONS: Record<string, VelodromeVersion> = {
4142 }
4243} ;
4344
44- const api = new ChainApi ( {
45- chain : 'optimism'
46- } )
47-
4845export type EmissionType = 'total' | 'gauge' | 'rebase' | 'team' ;
4946
5047interface CacheData {
@@ -87,7 +84,7 @@ async function fetchChainData(version: 'v1' | 'v2'): Promise<VelodromeChainData>
8784
8885 if ( version === 'v2' ) {
8986 const [ mintLogs , tokenMints ] = await Promise . all ( [
90- api . getLogs ( {
87+ getLogs ( {
9188 target : versionConfig . MINTER_ADDRESS ,
9289 eventAbi : mintEventAbi ,
9390 fromBlock : versionConfig . START ,
@@ -96,7 +93,7 @@ async function fetchChainData(version: 'v1' | 'v2'): Promise<VelodromeChainData>
9693 entireLog : true ,
9794 parseLog : true
9895 } ) ,
99- api . getLogs ( {
96+ getLogs ( {
10097 target : versionConfig . VELO_TOKEN ,
10198 topics : [
10299 "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
@@ -136,7 +133,7 @@ async function fetchChainData(version: 'v1' | 'v2'): Promise<VelodromeChainData>
136133 }
137134 } else {
138135 const [ mintLogs , teamTransfers , rebaseTransfers ] = await Promise . all ( [
139- api . getLogs ( {
136+ getLogs ( {
140137 target : versionConfig . MINTER_ADDRESS ,
141138 eventAbi : mintEventAbi ,
142139 fromBlock : versionConfig . START ,
@@ -145,7 +142,7 @@ async function fetchChainData(version: 'v1' | 'v2'): Promise<VelodromeChainData>
145142 entireLog : true ,
146143 parseLog : true
147144 } ) ,
148- api . getLogs ( {
145+ getLogs ( {
149146 target : versionConfig . VELO_TOKEN ,
150147 topics : [
151148 "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
@@ -157,7 +154,7 @@ async function fetchChainData(version: 'v1' | 'v2'): Promise<VelodromeChainData>
157154 chain : "optimism" ,
158155 entireLog : true
159156 } ) ,
160- api . getLogs ( {
157+ getLogs ( {
161158 target : versionConfig . VELO_TOKEN ,
162159 topics : [
163160 "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
@@ -217,7 +214,7 @@ async function processBlocks(mintLogs: any[], chainData: VelodromeChainData) {
217214 await PromisePool . withConcurrency ( 10 )
218215 . for ( blockNumbers )
219216 . process ( async ( blockNum ) => {
220- const block = await api . provider . getBlock ( blockNum ) ;
217+ const block = await getProvider ( "optimism" ) . getBlock ( blockNum ) ;
221218 if ( block ?. timestamp ) {
222219 chainData [ blockNum ] = {
223220 timestamp : block . timestamp ,
0 commit comments