@@ -2,101 +2,105 @@ import ADDRESSES from '../helpers/coreAssets.json'
22import { FetchOptions , SimpleAdapter } from "../adapters/types" ;
33import { CHAIN } from "../helpers/chains" ;
44import { queryDuneSql } from "../helpers/dune" ;
5- import { queryAllium } from '../helpers/allium' ;
65
76const fetch : any = async ( _a : any , _b : any , options : FetchOptions ) => {
87 const dailyFees = options . createBalances ( ) ;
98
109 // https://dune.com/queries/4313339
11- const value = ( await queryDuneSql ( options ,
10+ const value = ( await queryDuneSql ( options ,
1211 `WITH new_tokens_solana as (
13- SELECT
14- tx_id,
15- from_owner
16- FROM tokens_solana.transfers
17- WHERE outer_executing_account = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'
18- and block_time >= from_unixtime(${ options . startTimestamp } )
19- AND block_time <= from_unixtime(${ options . endTimestamp } )
20- GROUP BY 1,2
21- ),
12+ SELECT
13+ tx_id,
14+ from_owner
15+ FROM tokens_solana.transfers
16+ WHERE outer_executing_account = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'
17+ and block_time >= from_unixtime(${ options . startTimestamp } )
18+ AND block_time <= from_unixtime(${ options . endTimestamp } )
19+ GROUP BY 1,2
20+ ),
2221
23- fees as (
24- SELECT
25- a.tx_id,
26- a.block_time,
27- a.address as tx_signer,
28- 'Sell' as action_type,
29- balance_change/1e9 as total_sol
30- FROM solana.account_activity a
31- LEFT JOIN new_tokens_solana n
32- ON n.tx_id = a.tx_id
33- WHERE DATE(a.block_time) >= DATE('2024-01-14')
34- AND a.block_time >= from_unixtime(${ options . startTimestamp } )
35- AND a.block_time <= from_unixtime(${ options . endTimestamp } )
36- AND (a.address = 'CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM'
37- or a.address = 'FWsW1xNtWscwNmKv6wVsU1iTzRN6wmmk3MjxRP5tT7hz'
38- or a.address = 'G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP'
39- or a.address = '7hTckgnGnLQR6sdH7YkqFTAA7VwTfYFaZ6EhEsU3saCX'
40- or a.address = '9rPYyANsfQZw3DnDmKE3YCQF5E8oD89UXoHn9JFEhJUz'
41- or a.address = '7VtfL8fvgNfhz17qKRMjzQEXgbdpnHHHQRh54R9jP2RJ'
42- or a.address = 'AVmoTthdrX6tKt4nDjco2D775W2YK3sDhxPcMmzUAmTY'
43- or a.address = '62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV')
44- and n.from_owner not in (
45- '39azUYFWPz3VHgKCf3VChUwbpURdCHRxjWVowf5jUJjg',
46- '12xs3VnsaoEduxobnbaxQtCh6PQMDoFUrP4YB1F8pFPX',
47- '49AdQfhKyVgWKb1HPi6maQxm5tqJasePR9K6Mn67hEYA',
48- 'EkuimaBYybHvviYjtMXcnC7eg6WQmzLriDPtvh98fjRg',
49- 'CL9jPThhYnxvPSWNLhR4J7in13WvtMXXBGCe8LEhipmj'
50- )
51- and balance_change > 0
52- and a.token_mint_address is null
22+ fees as (
23+ SELECT
24+ a.tx_id,
25+ a.block_time,
26+ a.address as tx_signer,
27+ 'Sell' as action_type,
28+ balance_change/1e9 as total_sol
29+ FROM solana.account_activity a
30+ LEFT JOIN new_tokens_solana n
31+ ON n.tx_id = a.tx_id
32+ WHERE DATE(a.block_time) >= DATE('2024-01-14')
33+ AND a.block_time >= from_unixtime(${ options . startTimestamp } )
34+ AND a.block_time <= from_unixtime(${ options . endTimestamp } )
35+ AND (a.address = 'CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM'
36+ or a.address = 'FWsW1xNtWscwNmKv6wVsU1iTzRN6wmmk3MjxRP5tT7hz'
37+ or a.address = 'G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP'
38+ or a.address = '7hTckgnGnLQR6sdH7YkqFTAA7VwTfYFaZ6EhEsU3saCX'
39+ or a.address = '9rPYyANsfQZw3DnDmKE3YCQF5E8oD89UXoHn9JFEhJUz'
40+ or a.address = '7VtfL8fvgNfhz17qKRMjzQEXgbdpnHHHQRh54R9jP2RJ'
41+ or a.address = 'AVmoTthdrX6tKt4nDjco2D775W2YK3sDhxPcMmzUAmTY'
42+ or a.address = '62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV')
43+ and n.from_owner not in (
44+ '39azUYFWPz3VHgKCf3VChUwbpURdCHRxjWVowf5jUJjg',
45+ '12xs3VnsaoEduxobnbaxQtCh6PQMDoFUrP4YB1F8pFPX',
46+ '49AdQfhKyVgWKb1HPi6maQxm5tqJasePR9K6Mn67hEYA',
47+ 'EkuimaBYybHvviYjtMXcnC7eg6WQmzLriDPtvh98fjRg',
48+ 'CL9jPThhYnxvPSWNLhR4J7in13WvtMXXBGCe8LEhipmj'
49+ )
50+ and balance_change > 0
51+ and a.token_mint_address is null
5352 )
54-
5553 SELECT
56- SUM(total_sol) as total_sol_revenue
54+ SUM(total_sol) as total_sol_revenue
5755 FROM fees
5856 where block_time >= from_unixtime(${ options . startTimestamp } )
59- and block_time <= from_unixtime(${ options . endTimestamp } )
60- ` )
61- ) ;
57+ and block_time <= from_unixtime(${ options . endTimestamp } )
58+ `
59+ ) ) ;
6260 dailyFees . add ( ADDRESSES . solana . SOL , value [ 0 ] . total_sol_revenue * 1e9 ) ;
6361
6462 const query = `
65- SELECT SUM(raw_amount) as total_amount
66- FROM solana.assets.transfers
67- WHERE to_address = 'G8CcfRffqZWHSAQJXLDfwbAkGE95SddUqVXnTrL4kqjm'
68- AND mint = '${ ADDRESSES . solana . PUMP } '
69- AND block_timestamp BETWEEN TO_TIMESTAMP_NTZ(${ options . startTimestamp } ) AND TO_TIMESTAMP_NTZ(${ options . endTimestamp } )
63+ SELECT
64+ SUM(amount_display) as total_amount
65+ FROM tokens_solana.transfers t
66+ WHERE
67+ block_time >= from_unixtime(${ options . startTimestamp } )
68+ AND block_time <= from_unixtime(${ options . endTimestamp } )
69+ AND from_owner IN (
70+ '3vkpy5YHqnqJTnA5doWTpcgKyZiYsaXYzYM9wm8s3WTi',
71+ '88uq8JNL6ANwmow1og7VQD4hte73Jpw8qsUP77BtF6iE'
72+ )
73+ AND to_owner NOT IN (
74+ '6UJoY1CFEymoqMrnmBLeZoemBGiJcySNdR7Jyj2nF848',
75+ '88uq8JNL6ANwmow1og7VQD4hte73Jpw8qsUP77BtF6iE'
76+ )
77+ AND token_mint_address = 'So11111111111111111111111111111111111111112'
78+ AND amount_usd >= 100
7079 `
71- const res = await queryAllium ( query ) ;
80+ const res = await queryDuneSql ( options , query ) ;
7281 const dailyHoldersRevenue = options . createBalances ( ) ;
73- dailyHoldersRevenue . add ( ADDRESSES . solana . PUMP , res [ 0 ] . total_amount || 0 ) ;
82+ dailyHoldersRevenue . add ( ADDRESSES . solana . SOL , ( res [ 0 ] . total_amount || 0 ) * 1e9 ) ;
7483
75- return {
76- dailyFees,
77- dailyRevenue : dailyFees ,
78- dailyProtocolRevenue : dailyFees ,
84+ return {
85+ dailyFees,
86+ dailyRevenue : dailyFees ,
87+ dailyProtocolRevenue : dailyFees ,
7988 dailyHoldersRevenue
8089 }
8190}
8291
8392const adapter : SimpleAdapter = {
8493 version : 1 ,
85- adapter : {
86- [ CHAIN . SOLANA ] : {
87- fetch : fetch ,
88- start : '2024-01-14' ,
89- meta : {
90- methodology : {
91- Fees : "Trading and launching tokens fees paid by users" ,
92- Revenue : "Trading and launching tokens fees paid by users" ,
93- ProtocolRevenue : "pump.fun takes all fees paid by users" ,
94- HoldersRevenue : "PUMP token buybacks from the revenue"
95- }
96- }
97- } ,
98- } ,
99- isExpensiveAdapter : true
94+ chains : [ CHAIN . SOLANA ] ,
95+ fetch,
96+ isExpensiveAdapter : true ,
97+ start : '2024-01-14' ,
98+ methodology : {
99+ Fees : "Trading and launching tokens fees paid by users" ,
100+ Revenue : "Trading and launching tokens fees paid by users" ,
101+ ProtocolRevenue : "pump.fun takes all fees paid by users" ,
102+ HoldersRevenue : "PUMP token buybacks from the revenue"
103+ }
100104} ;
101105
102106export default adapter ;
0 commit comments