Skip to content

Conversation

b-tarczynski
Copy link
Contributor

It calculates Spark Liquidity Layer revenue - it sums up breakdown of revenue based on Dune queries used for this Dune dashboard. The difference is that the queries used for defiLlama are using daily data instead of monthly.

Could you guys add missing token prices for sUSDS and sUSDC (on Mainnet it's available) or should I handle it in the code instead?

@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Thu, 31 Jul 2025 06:19:52 GMT
End Date:	Fri, 01 Aug 2025 06:19:52 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async calculateDomainRevenue (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:69:25)
    at async fetchForeignDomainData (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:61:3)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:183:18)
    at async Promise.all (index 1)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:146:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'base'
}

@noateden noateden self-assigned this Aug 1, 2025
@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Thu, 31 Jul 2025 07:12:36 GMT
End Date:	Fri, 01 Aug 2025 07:12:36 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async calculateDomainRevenue (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:66:25)
    at async fetchMainnetData (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:32:3)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:183:18)
    at async Promise.all (index 0)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:146:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'ethereum'
}

}

function getSusdsIntegratorRevenueQuery(date: string, chain: string) {
return `select sum(tw_reward) as revenue from query_5562275 where dt = date '${date}' and blockchain = '${chain}';`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pls convert query_5562275 to raw SQL?

Copy link
Contributor

@noateden noateden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @b-tarczynski thanks for the PR. Can you pls convert all Dune sub-queries to raw SQL?

@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Sun, 03 Aug 2025 06:04:35 GMT
End Date:	Mon, 04 Aug 2025 06:04:35 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetch (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:18:28)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:183:18)
    at async Promise.all (index 0)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:146:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'ethereum'
}

@noateden noateden marked this pull request as draft August 21, 2025 10:00
@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Sun, 31 Aug 2025 10:04:46 GMT
End Date:	Mon, 01 Sep 2025 10:04:46 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetch (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:19:20)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:206:18)
    at async Promise.all (index 0)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:159:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'ethereum'
}

@b-tarczynski
Copy link
Contributor Author

Hey @noateden, thanks for the review. The queries on Diune were modified and now I include complete query SQL in a single file. Could you take a look at the modified code?

Also one question: in case if the returned data changes due to adding some historical revenue later on, is there an option to rerun historical data on defiLlama? Or how does it work in cases like this?

@b-tarczynski b-tarczynski marked this pull request as ready for review September 1, 2025 12:39
@noateden
Copy link
Contributor

noateden commented Sep 2, 2025

@b-tarczynski can you check SQL query, I got this error:
Error: Line 133:44: Column 'sl.asset_rev_amount' cannot be resolved at line 133, position 44

@b-tarczynski
Copy link
Contributor Author

@b-tarczynski can you check SQL query, I got this error: Error: Line 133:44: Column 'sl.asset_rev_amount' cannot be resolved at line 133, position 44

Sorry for that, the data has changed after I created the PR. I pushed changes and now the query runs successfully

@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Mon, 01 Sep 2025 17:44:18 GMT
End Date:	Tue, 02 Sep 2025 17:44:18 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetch (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:19:20)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:206:18)
    at async Promise.all (index 0)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:159:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'ethereum'
}

@llamabutler
Copy link

The spark-liquidity-layer adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees spark-liquidity-layer

🦙 Running SPARK-LIQUIDITY-LAYER adapter 🦙
---------------------------------------------------
Start Date:	Tue, 02 Sep 2025 09:49:03 GMT
End Date:	Wed, 03 Sep 2025 09:49:03 GMT
---------------------------------------------------

Error: Request failed with status code 401
    at queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:121:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetch (/home/runner/work/dimension-adapters/dimension-adapters/fees/spark-liquidity-layer/index.ts:14:20)
    at async getChainResult (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:206:18)
    at async Promise.all (index 0)
    at async _runAdapter (/home/runner/work/dimension-adapters/dimension-adapters/adapters/utils/runAdapter.ts:159:20)
    at async /home/runner/work/dimension-adapters/dimension-adapters/cli/testAdapter.ts:69:24 {
  axiosError: 'Dune API Key is invalid',
  chain: 'ethereum'
}

@noateden
Copy link
Contributor

noateden commented Sep 3, 2025

hello @b-tarczynski, codes look good to me. Two morequestions:

  1. Is this revenue metric equal to total yields generated by all assets deposited into Spark Liquidity Layer? If not, can you pls help to get it which is needed for dailyFees metric?
  2. All revenue are collected by Spark protocol, right?

@b-tarczynski
Copy link
Contributor Author

b-tarczynski commented Sep 3, 2025

Hey @noateden,

  1. Is this revenue metric equal to total yields generated by all assets deposited into Spark Liquidity Layer? If not, can you pls help to get it which is needed for dailyFees metric?

Yes, that is total yield generated by assets that Spark Liquidity Layer manages

  1. All revenue are collected by Spark protocol, right?

Yes, the data in the PR already subtracts all costs (Sky Base Rate etc)

@noateden noateden merged commit 226a466 into DefiLlama:master Sep 3, 2025
2 checks passed
@b-tarczynski b-tarczynski deleted the bartek/spark-liquidity-layer-revenue-new branch September 22, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants