@@ -410,19 +410,32 @@ export async function getSolanaReceived({ options, balances, target, targets, bl
410410
411411 // Construct SQL query to get sum of received token values in USD and native amount
412412 const query = `
413- SELECT '${ ADDRESSES . solana . USDC } ' as token, SUM(usd_amount * 1000000) as amount
414- FROM solana.assets.transfers
415- WHERE to_address IN (${ formattedAddresses } )
416- AND block_timestamp BETWEEN TO_TIMESTAMP_NTZ(${ options . startTimestamp } ) AND TO_TIMESTAMP_NTZ(${ options . endTimestamp } )
417- ${ blacklistCondition }
418- ${ blacklist_signersCondition }
419- ${ blacklist_mintsCondition }
420- GROUP BY mint
421- ` ;
413+ SELECT '${ ADDRESSES . solana . USDC } ' as token, SUM(usd_amount * 1000000) as amount
414+ FROM solana.assets.transfers
415+ WHERE to_address IN (${ formattedAddresses } )
416+ AND block_timestamp BETWEEN TO_TIMESTAMP_NTZ(${ options . startTimestamp } ) AND TO_TIMESTAMP_NTZ(${ options . endTimestamp } )
417+ ${ blacklistCondition }
418+ ${ blacklist_signersCondition }
419+ ${ blacklist_mintsCondition }
420+ GROUP BY mint
421+ ` ;
422422
423423 // Execute query against Allium database
424424 const res = await queryAllium ( query ) ;
425425
426+ // for debug purpose
427+ // const query2 = `
428+ // SELECT mint, SUM(usd_amount * 1000000) as amount
429+ // FROM solana.assets.transfers
430+ // WHERE to_address IN (${formattedAddresses})
431+ // AND block_timestamp BETWEEN TO_TIMESTAMP_NTZ(${options.startTimestamp}) AND TO_TIMESTAMP_NTZ(${options.endTimestamp})
432+ // ${blacklistCondition}
433+ // ${blacklist_signersCondition}
434+ // ${blacklist_mintsCondition}
435+ // GROUP BY mint
436+ // ORDER BY amount DESC
437+ // `;
438+
426439 // Add the USD value to the balances object (defaulting to 0 if no results)
427440 res . forEach ( ( row : any ) => {
428441 balances ! . add ( row . token , row . amount )
0 commit comments