@@ -4,6 +4,7 @@ const { PublicKey, } = require("@solana/web3.js");
4
4
const { TokenAmountLayout, KeyLayoutv4 } = require ( "../helper/utils/solana/layouts/raydium-layout" ) ;
5
5
const { transformDexBalances } = require ( "../helper/portedTokens" ) ;
6
6
const { sleep } = require ( "../helper/utils" ) ;
7
+ const { get } = require ( "../helper/http" ) ;
7
8
8
9
const CLMM = 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK'
9
10
const AmmV4 = '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'
@@ -52,7 +53,7 @@ async function ammV4Tvl(api) {
52
53
await sleep ( 20000 )
53
54
const allPoolKeyInfo = await connection . getProgramAccounts ( new PublicKey ( AmmV4 ) , { filters : [ { dataSize : 752 } ] , dataSlice : { offset : 336 , length : KeyLayoutv4 . span } } )
54
55
55
-
56
+
56
57
let i = 0
57
58
let j = 0
58
59
let data = [ ]
@@ -120,26 +121,26 @@ async function ammV2V3() {
120
121
async function combinedTvl ( api ) {
121
122
try {
122
123
123
- console . time ( 'raydium: combinedTvl' )
124
+ console . time ( 'raydium: combinedTvl' )
124
125
125
- console . time ( 'raydium: tvlCLMM' )
126
- const balancesCLMM = await tvlCLMM ( )
127
- api . addBalances ( balancesCLMM )
128
- console . timeEnd ( 'raydium: tvlCLMM' )
126
+ /* */ console . time ( 'raydium: tvlCLMM' )
127
+ const balancesCLMM = await tvlCLMM ( )
128
+ api . addBalances ( balancesCLMM )
129
+ console . timeEnd ( 'raydium: tvlCLMM' )
129
130
130
- console . time ( 'raydium: ammStableTvl' )
131
- const balancesAmmStable = await ammStableTvl ( )
132
- api . addBalances ( balancesAmmStable )
133
- console . timeEnd ( 'raydium: ammStableTvl' )
131
+ console . time ( 'raydium: ammStableTvl' )
132
+ const balancesAmmStable = await ammStableTvl ( )
133
+ api . addBalances ( balancesAmmStable )
134
+ console . timeEnd ( 'raydium: ammStableTvl' )
134
135
135
- console . time ( 'raydium: ammV2V3' )
136
- const balancesAmmV2V3 = await ammV2V3 ( )
137
- api . addBalances ( balancesAmmV2V3 )
138
- console . timeEnd ( 'raydium: ammV2V3' )
136
+ console . time ( 'raydium: ammV2V3' )
137
+ const balancesAmmV2V3 = await ammV2V3 ( )
138
+ api . addBalances ( balancesAmmV2V3 )
139
+ console . timeEnd ( 'raydium: ammV2V3' )
139
140
140
- console . time ( 'raydium: ammV4Tvl' )
141
- await ammV4Tvl ( api )
142
- console . timeEnd ( 'raydium: ammV4Tvl' )
141
+ console . time ( 'raydium: ammV4Tvl' )
142
+ // await ammV4Tvl(api)
143
+ console . timeEnd ( 'raydium: ammV4Tvl' )
143
144
144
145
} catch ( e ) {
145
146
console . error ( 'raydium' , e )
@@ -148,7 +149,10 @@ async function combinedTvl(api) {
148
149
149
150
console . timeEnd ( 'raydium: combinedTvl' )
150
151
const tvl = await api . getUSDValue ( )
151
- if ( tvl < 1.5e8 ) throw new Error ( 'TVL is too low :' + tvl / 1e6 + 'M' )
152
+ if ( tvl < 1.5e8 ) throw new Error ( 'TVL is too low :' + tvl / 1e6 + 'M' )
153
+
154
+ api . removeTokenBalance ( 'DS4QiZfkp39PsHXYCRV3NkyDUKV9SpTczp2qnAUg6Nt6' ) // ZMB
155
+ api . removeTokenBalance ( 'HDa3zJc12ahykSsBRvgiWzr6WLEByf36yzKKbVvy4gnF' ) // SOS
152
156
return api . getBalances ( )
153
157
}
154
158
@@ -159,7 +163,29 @@ module.exports = {
159
163
hallmarks : [ [ 1667865600 , "FTX collapse" ] ] ,
160
164
161
165
solana : {
162
- tvl : combinedTvl ,
166
+ // tvl: combinedTvl,
167
+ tvl : tvlApi ,
163
168
staking : ( ) => sumTokens2 ( { tokenAccounts : [ '8tnpAECxAT9nHBqR1Ba494Ar5dQMPGhL31MmPJz1zZvY' ] } )
164
169
} ,
165
- } ;
170
+ } ;
171
+
172
+ async function tvlApi ( api ) {
173
+ let hasMore = true
174
+ let page = 1
175
+ const pageSize = 1000
176
+ do {
177
+ const { data : { data } } = await get ( `https://api-v3.raydium.io/pools/info/list?poolType=all&poolSortField=liquidity&sortType=desc&pageSize=${ pageSize } &page=${ page } ` )
178
+ const lastItem = data [ data . length - 1 ]
179
+ hasMore = data . length === pageSize && lastItem . tvl > 1000
180
+ api . log ( 'lastItem' , lastItem . tvl , page )
181
+ data . forEach ( ( { mintA, mintB, mintAmountA, mintAmountB, } ) => {
182
+ api . add ( mintA . address , mintAmountA * ( 10 ** mintA . decimals ) )
183
+ api . add ( mintB . address , mintAmountB * ( 10 ** mintB . decimals ) )
184
+ } )
185
+ page ++
186
+ } while ( hasMore )
187
+
188
+ api . removeTokenBalance ( 'DS4QiZfkp39PsHXYCRV3NkyDUKV9SpTczp2qnAUg6Nt6' ) // ZMB
189
+ api . removeTokenBalance ( 'HDa3zJc12ahykSsBRvgiWzr6WLEByf36yzKKbVvy4gnF' ) // SOS
190
+ return api . getBalances ( )
191
+ }
0 commit comments