1
1
const { getLogs2 } = require ( '../helper/cache/getLogs' )
2
2
3
3
const config = {
4
- bsc : { factory : '0xFe00054AF44E24f0B4bd49b1A2d2984C4264aabE' , fromBlock : 37882077 , } ,
4
+ bsc : {
5
+ factoryV1 : '0xFe00054AF44E24f0B4bd49b1A2d2984C4264aabE' , fromBlockV1 : 37882077 ,
6
+ factoryV2 : '0x70e318f5066597868a9026ecccC0e04D693d0fbD' , fromBlockV2 : 45094649 ,
7
+ } ,
5
8
}
9
+ const USDTBridge = [ "0x55d398326f99059fF775485246999027B3197955" , "0xAEaF85C740C7a6ee94183E848d0e557cB7FbeA47" ] ;
6
10
7
11
Object . keys ( config ) . forEach ( chain => {
8
- const { factory , fromBlock } = config [ chain ]
12
+ const { factoryV1 , factoryV2 , fromBlockV1 , fromBlockV2 } = config [ chain ]
9
13
module . exports [ chain ] = {
10
14
tvl : async ( api ) => {
11
- const logs = await getLogs2 ( { api, factory, eventAbi : 'event PositionOpened (address indexed owner, address indexed position, address ofd, address collateral, uint256 price)' , fromBlock, } )
12
- const tokensAndOwners = logs . map ( log => [ log . collateral , log . position ] )
15
+ const tokensAndOwners = [ USDTBridge ]
16
+ const logsV1 = await getLogs2 ( { api, factory : factoryV1 , eventAbi : 'event PositionOpened (address indexed owner, address indexed position, address ofd, address collateral, uint256 price)' , fromBlock : fromBlockV1 } )
17
+ const logsV2 = await getLogs2 ( { api, factory : factoryV2 , eventAbi : 'event PositionOpened(address indexed owner, address indexed position, address original, address collateral)' , fromBlock : fromBlockV2 } )
18
+ logsV1 . concat ( logsV2 ) . forEach ( log => tokensAndOwners . push ( [ log . collateral , log . position ] ) )
13
19
return api . sumTokens ( { tokensAndOwners } )
14
20
}
15
21
}
16
- } )
22
+ } )
0 commit comments