@@ -154,23 +154,20 @@ const fetchv2Graph = async (_a:any, _b:any, options: FetchOptions) => {
154154}
155155
156156const fetchv3GraphEndpoint = async ( options : FetchOptions ) => {
157- return await v3Graphs ( options . chain . toLowerCase ( ) ) ( options )
157+ return ( await v3Graphs ( options . chain . toLowerCase ( ) ) ( options ) )
158158}
159159
160160const fetchv3AlgebraGraphEndpoint = async ( options : FetchOptions ) => {
161161 return await algebraGraphs ( options . chain . toLowerCase ( ) ) ( options )
162162}
163163
164- const fetchv3PolygonLogs = async ( options : FetchOptions ) => {
164+ const fetchv3PolygonLogs = async ( options : FetchOptions ) : Promise < { dailyFees : number } > => {
165165 const factory = "0x411b0fAcC3489691f28ad58c47006AF5E3Ab3A28"
166166 const poolCreatedEvent = 'event Pool(address indexed token0, address indexed token1, address pool)'
167167 const swapEvent = 'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 price, uint128 liquidity, int24 tick)'
168168 const FeeEvent = 'event Fee(uint16 fee)'
169169
170170 const fromBlock = config_v3 [ options . chain ] ?. startBlock || 0
171- if ( fromBlock == 0 ) {
172- return Error ( 'No start block found' )
173- }
174171 const toBlock = await options . getToBlock ( )
175172
176173 const adapter = getUniV3LogAdapter ( {
@@ -206,8 +203,6 @@ const fetchv3PolygonLogs = async (options: FetchOptions) => {
206203
207204 return {
208205 dailyFees,
209- dailyUserFees : dailyFees ,
210- dailyVolume,
211206 }
212207}
213208
@@ -244,31 +239,32 @@ const fetchV3Dune = async (options: FetchOptions) => {
244239
245240}
246241
247- const fetchv3Graph = async ( _a : any , _b : any , options : FetchOptions ) => {
242+ const getDailyFees = async ( options : FetchOptions ) => {
248243 const chain_config = config_v3 [ options . chain ]
249- let graphData
250-
251244 if ( chain_config . datasource === 'algebra' ) {
252- graphData = await fetchv3AlgebraGraphEndpoint ( options )
245+ return await fetchv3AlgebraGraphEndpoint ( options )
253246 } else if ( chain_config . datasource === 'logs' ) {
254- graphData = await fetchv3PolygonLogs ( options )
247+ return await fetchv3PolygonLogs ( options )
255248 } else if ( chain_config . datasource === 'dune' ) {
256- graphData = await fetchV3Dune ( options )
249+ return await fetchV3Dune ( options )
257250 } else {
258- graphData = await fetchv3GraphEndpoint ( options )
251+ return await fetchv3GraphEndpoint ( options )
259252 }
253+ }
260254
255+ const fetchv3Graph = async ( _a :any , _b :any , options : FetchOptions ) => {
256+ const { dailyFees } = await getDailyFees ( options )
257+ const daily_fees = Number ( dailyFees )
261258 // Apply dynamic fee percentages based on timestamp and chain
262259 const feePercentages = getV3FeePercentages ( options . startTimestamp , options . chain )
263- const totalFees = Number ( graphData ?. dailyFees ) || 0
264260
265261 return {
266- dailyFees : totalFees ,
267- dailyUserFees : totalFees ,
268- dailyRevenue : totalFees * ( feePercentages . Revenue / 100 ) ,
269- dailyProtocolRevenue : totalFees * ( feePercentages . ProtocolRevenue / 100 ) ,
270- dailySupplySideRevenue : totalFees * ( feePercentages . SupplySideRevenue / 100 ) ,
271- dailyHoldersRevenue : totalFees * ( feePercentages . HoldersRevenue / 100 ) ,
262+ dailyFees : daily_fees ,
263+ dailyUserFees : daily_fees ,
264+ dailyRevenue : daily_fees * ( feePercentages . Revenue / 100 ) ,
265+ dailyProtocolRevenue : daily_fees * ( feePercentages . ProtocolRevenue / 100 ) ,
266+ dailySupplySideRevenue : daily_fees * ( feePercentages . SupplySideRevenue / 100 ) ,
267+ dailyHoldersRevenue : daily_fees * ( feePercentages . HoldersRevenue / 100 ) ,
272268 }
273269}
274270
0 commit comments