Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queries for TON Dune Index metrics #7621

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shuva10v
Copy link

@shuva10v shuva10v commented Feb 4, 2025

Thank you for contributing to Spellbook 🪄

Please open the PR in draft and mark as ready when you want to request a review.

Description:

Adding TON metrics to the Dune Index


quick links for more information:

@github-actions github-actions bot marked this pull request as draft February 4, 2025 12:06
@github-actions github-actions bot added WIP work in progress dbt: daily covers the Daily dbt subproject labels Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@shuva10v
Copy link
Author

shuva10v commented Feb 4, 2025

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 4, 2025
@shuva10v shuva10v force-pushed the feature/ton branch 13 times, most recently from a337674 to 7d00a7e Compare February 4, 2025 16:06
@shuva10v shuva10v marked this pull request as ready for review February 4, 2025 18:24
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Feb 4, 2025
, avg(price) as price
from {{ source('prices', 'usd') }}
where true
and symbol = 'TON'
Copy link

Choose a reason for hiding this comment

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

Add and blockchain IS NOT NULL to filter for only TON prices, the TON symbol on ethereum is Tokamak Network Token (TON) for which the prices are different


-- fee paid for sending messages
select block_date, sum(
coalesce(m.fwd_fee * 1e-9, 0.0) * p.price
Copy link

@beve0x beve0x Feb 12, 2025

Choose a reason for hiding this comment

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

Instead do sum( (COALESCE(m.fwd_fee, 0) + COALESCE(m.import_fee, 0) + COALESCE(m.ihr_fee, 0)) * 1e-9 * p.price ) as fees
For internal transactions, the total message fee = fwd_fee+ihr_fee based on the "forward fees" section here
For external transactions, the total message fee = import_fee
When import_fee != 0 and fwd_fee > 0, we get no results.
When import_fee != 0 and ihr_fee > 0, we also get no results.
So we can do (COALESCE(fwd_fee, 0) + COALESCE(import_fee, 0) + COALESCE(ihr_fee, 0)) to consider both internal and external cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dbt: daily covers the Daily dbt subproject ready-for-review this PR development is complete, please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants