11import { DSKit } from 'dskit-eth'
2- import { Address , PublicClient } from 'viem'
2+ import { Address , GetLogsReturnType , PublicClient } from 'viem'
33import {
44 LIQUIDATION_ROUTER_ADDRESSES ,
55 POOL_WIDE_TWAB_REWARDS_ADDRESSES ,
66 TWAB_REWARDS_ADDRESSES
77} from '../constants'
88import { getLiquidationPairAddresses } from './liquidations'
99
10+ const depositEventABI = {
11+ inputs : [
12+ { indexed : true , internalType : 'address' , name : 'sender' , type : 'address' } ,
13+ { indexed : true , internalType : 'address' , name : 'owner' , type : 'address' } ,
14+ { indexed : false , internalType : 'uint256' , name : 'assets' , type : 'uint256' } ,
15+ { indexed : false , internalType : 'uint256' , name : 'shares' , type : 'uint256' }
16+ ] ,
17+ name : 'Deposit' ,
18+ type : 'event'
19+ } as const
20+
1021/**
1122 * Returns `Deposit` events
1223 * @param publicClient a public Viem client to query through
@@ -18,23 +29,16 @@ export const getDepositEvents = async (
1829 publicClient : PublicClient ,
1930 vaultAddresses : Address [ ] ,
2031 options ?: { sender ?: Address [ ] ; owner ?: Address [ ] ; fromBlock ?: bigint ; toBlock ?: bigint }
21- ) => {
22- return await publicClient . getLogs ( {
32+ ) : Promise < GetLogsReturnType < typeof depositEventABI , [ typeof depositEventABI ] , true > > => {
33+ // @ts -ignore
34+ const dskit = new DSKit ( { viemPublicClient : publicClient } )
35+
36+ return await dskit . event . query ( {
2337 address : vaultAddresses ,
24- event : {
25- inputs : [
26- { indexed : true , internalType : 'address' , name : 'sender' , type : 'address' } ,
27- { indexed : true , internalType : 'address' , name : 'owner' , type : 'address' } ,
28- { indexed : false , internalType : 'uint256' , name : 'assets' , type : 'uint256' } ,
29- { indexed : false , internalType : 'uint256' , name : 'shares' , type : 'uint256' }
30- ] ,
31- name : 'Deposit' ,
32- type : 'event'
33- } ,
38+ event : depositEventABI ,
3439 args : { sender : options ?. sender ?? null , owner : options ?. owner ?? null } ,
35- fromBlock : options ?. fromBlock ,
36- toBlock : options ?. toBlock ?? 'latest' ,
37- strict : true
40+ fromBlock : options ?. fromBlock ?? 1n ,
41+ toBlock : options ?. toBlock ?? 'latest'
3842 } )
3943}
4044
@@ -245,7 +249,7 @@ export const getLiquidationEvents = async (
245249 args : { ...lpEvent . args , liquidationPair : lpEvent . address }
246250 } ) )
247251
248- const routerEvents = await publicClient . getLogs ( {
252+ const routerEvents = await dskit . event . query ( {
249253 address : liqRouterContractAddress ,
250254 event : {
251255 inputs : [
@@ -265,9 +269,8 @@ export const getLiquidationEvents = async (
265269 name : 'SwappedExactAmountOut' ,
266270 type : 'event'
267271 } ,
268- fromBlock : options ?. fromBlock ,
269- toBlock : options ?. toBlock ?? 'latest' ,
270- strict : true
272+ fromBlock : options ?. fromBlock ?? 1n ,
273+ toBlock : options ?. toBlock ?? 'latest'
271274 } )
272275
273276 return [ ...routerEvents , ...formattedLpEvents ] . sort ( ( a , b ) =>
0 commit comments