@@ -16,32 +16,26 @@ async function getContractActions(contract, actionNames) {
16
16
let hasMore = true ;
17
17
18
18
while ( hasMore ) {
19
- try {
20
- const response = await post ( `${ endpoint } /history/get_actions` , {
21
- account_name : contract ,
22
- pos : pos ,
23
- offset : - pageSize
24
- } ) ;
25
-
26
- const actions = response . actions || [ ] ;
27
- if ( actions . length === 0 ) break ;
28
-
29
- const filteredActions = actions . filter ( action =>
30
- Array . isArray ( actionNames )
31
- ? actionNames . includes ( action . action_trace . act . name )
32
- : action . action_trace . act . name === actionNames
33
- ) ;
34
-
35
- allActions . push ( ...filteredActions ) ;
19
+ const response = await post ( `${ endpoint } /history/get_actions` , {
20
+ account_name : contract ,
21
+ pos : pos ,
22
+ offset : - pageSize
23
+ } ) ;
24
+
25
+ const actions = response . actions || [ ] ;
26
+ if ( actions . length === 0 ) break ;
27
+
28
+ const filteredActions = actions . filter ( action =>
29
+ Array . isArray ( actionNames )
30
+ ? actionNames . includes ( action . action_trace . act . name )
31
+ : action . action_trace . act . name === actionNames
32
+ ) ;
33
+
34
+ allActions . push ( ...filteredActions ) ;
36
35
37
- const lastAction = actions [ actions . length - 1 ] ;
38
- pos = lastAction . account_action_seq - pageSize + 1 ;
39
- hasMore = actions . length === pageSize ;
40
-
41
- } catch ( error ) {
42
- console . error ( 'Pagination error:' , error . message ) ;
43
- break ;
44
- }
36
+ const lastAction = actions [ actions . length - 1 ] ;
37
+ pos = lastAction . account_action_seq - pageSize + 1 ;
38
+ hasMore = actions . length === pageSize ;
45
39
}
46
40
47
41
return allActions ;
@@ -64,7 +58,9 @@ function calculateBalancesFromActions(actions) {
64
58
}
65
59
66
60
const parsedAmount = parseFloat ( amount ) ;
67
- balances [ symbol ] . amount += name === 'logdeposit1' ? parsedAmount : - parsedAmount ;
61
+ if ( name === 'logdeposit1' || name === 'logwithdraw1' ) {
62
+ balances [ symbol ] . amount += name === 'logdeposit1' ? parsedAmount : - parsedAmount ;
63
+ }
68
64
}
69
65
70
66
return balances ;
@@ -83,14 +79,9 @@ function convertToDefiLlamaFormat(balances) {
83
79
}
84
80
85
81
async function eos ( ) {
86
- try {
87
- const actions = await getContractActions ( "portal.1dex" , [ "logdeposit1" , "logwithdraw1" ] ) ;
88
- const balances = calculateBalancesFromActions ( actions ) ;
89
- return convertToDefiLlamaFormat ( balances ) ;
90
- } catch ( error ) {
91
- console . error ( 'Error fetching 1DEX TVL:' , error ) ;
92
- return { } ;
93
- }
82
+ const actions = await getContractActions ( "portal.1dex" , [ "logdeposit1" , "logwithdraw1" ] ) ;
83
+ const balances = calculateBalancesFromActions ( actions ) ;
84
+ return convertToDefiLlamaFormat ( balances ) ;
94
85
}
95
86
96
87
module . exports = {
0 commit comments