-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Pika Protocol v4 added for optimism #7427
base: main
Are you sure you want to change the base?
Pika Protocol v4 added for optimism #7427
Conversation
WHEN productId = UINT256 '1' OR productId = UINT256 '16' THEN 'ETH' | ||
WHEN productId = UINT256 '2' OR productId = UINT256 '17' THEN 'BTC' | ||
WHEN productId = UINT256 '3' OR productId = UINT256 '18' THEN 'LINK' | ||
WHEN productId = UINT256 '4' OR productId = UINT256 '19' THEN 'SNX' | ||
WHEN productId = UINT256 '5' OR productId = UINT256 '20' THEN 'SOL' | ||
WHEN productId = UINT256 '6' OR productId = UINT256 '21' THEN 'AVAX' | ||
WHEN productId = UINT256 '7' OR productId = UINT256 '22' THEN 'MATIC' | ||
WHEN productId = UINT256 '8' THEN 'LUNA' | ||
WHEN productId = UINT256 '9' OR productId = UINT256 '23' THEN 'AAVE' | ||
WHEN productId = UINT256 '10' OR productId = UINT256 '24' THEN 'APE' | ||
WHEN productId = UINT256 '11' OR productId = UINT256 '25' THEN 'AXS' | ||
WHEN productId = UINT256 '12' OR productId = UINT256 '26' THEN 'UNI' | ||
ELSE CONCAT ('product_id_', CAST(productId as VARCHAR)) | ||
END AS virtual_asset | ||
|
||
,CASE | ||
WHEN productId = UINT256 '1' OR productId = UINT256 '16' THEN 'ETH' | ||
WHEN productId = UINT256 '2' OR productId = UINT256 '17' THEN 'BTC' | ||
WHEN productId = UINT256 '3' OR productId = UINT256 '18' THEN 'LINK' | ||
WHEN productId = UINT256 '4' OR productId = UINT256 '19' THEN 'SNX' | ||
WHEN productId = UINT256 '5' OR productId = UINT256 '20' THEN 'SOL' | ||
WHEN productId = UINT256 '6' OR productId = UINT256 '21' THEN 'AVAX' | ||
WHEN productId = UINT256 '7' OR productId = UINT256 '22' THEN 'MATIC' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no way of getting these productId <> token symbols from onchain data?
If not I would make a separate model containing the static mapping and then join it in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no way of getting these productId <> token symbols from onchain data? If not I would make a separate model containing the static mapping and then join it in here.
No, the productId and token symbols are not coming from on-chain data. They are part of a static mapping defined within the protocol's architecture, which cannot be queried directly on-chain.
I agree with your suggestion—it makes sense to create a separate model containing this static mapping and join it here for better maintainability and clarity. This will also simplify any future updates if new mappings are introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to add some seed for testing pika_v4_optimism_perpetual_trades
, you can add the seed here:
https://github.com/duneanalytics/spellbook/blob/d09fa392c8e07e6443cf26c4e59c97f1c7e41e8d/dbt_subprojects/hourly_spellbook/seeds/_sector/perpetual/trades/perpetual_trades_seed.csv
post_hook='{{ expose_spells(\'["optimism"]\', | ||
"project", | ||
"pika", | ||
\'["msilb7", "drethereum", "rplust","princi"]\') }}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can apply the new post_hook format here.
i.e.
post_hook='{{ expose_spells(blockchains = \'["fantom", "optimism"]\', |
,'4' AS version | ||
FROM {{ source('pika_protocol_v4_optimism', 'PikaPerpV4_evt_NewPosition') }} | ||
{% if is_incremental() %} | ||
WHERE evt_block_time >= DATE_TRUNC('DAY', NOW() - INTERVAL '7' Day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use incremental_predicate
for incremental filters:
WHERE evt_block_time >= DATE_TRUNC('DAY', NOW() - INTERVAL '7' Day) | |
WHERE {{incremental_predicate('evt_block_time')}} |
,'4' AS version | ||
FROM {{ source('pika_protocol_v4_optimism', 'PikaPerpV4_evt_ClosePosition') }} | ||
{% if is_incremental() %} | ||
WHERE evt_block_time >= DATE_TRUNC('DAY', NOW() - INTERVAL '7' Day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
AND tx.block_time >= DATE '{{project_start_date}}' | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND tx.block_time >= DATE_TRUNC('DAY', NOW() - INTERVAL '7' Day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
…ncremental filters
…redicate for increamental filters
Please apply the |
AND tx.block_time >= DATE '{{project_start_date}}' | ||
{% endif %} | ||
{% if is_incremental() %} | ||
AND tx.block_time >= DATE_TRUNC('DAY', NOW() - INTERVAL '7' Day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the incremental filter.
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index'], | ||
post_hook='{{ expose_spells(blockchains = \'["optimism"]\', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent in tab or space in all PRs. We prefer spaces.
WHEN productId = UINT256 '10' OR productId = UINT256 '24' THEN 'APE' | ||
WHEN productId = UINT256 '11' OR productId = UINT256 '25' THEN 'AXS' | ||
WHEN productId = UINT256 '12' OR productId = UINT256 '26' THEN 'UNI' | ||
ELSE CONCAT ('product_id_', CAST(productId as VARCHAR)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
ELSE CONCAT ('product_id_', CAST(productId as VARCHAR)) | |
'product_id_' || productId |
data_tests: | ||
- dbt_utils.unique_combination_of_columns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_tests: | |
- dbt_utils.unique_combination_of_columns: | |
data_tests: | |
- check_perpetuals_seed: | |
blockchain: optimism | |
project: Pika | |
version: 4 | |
- dbt_utils.unique_combination_of_columns: |
...llbook/models/_sector/perpetual/projects/pika/optimism/pika_v4_optimism_perpetual_trades.sql
Show resolved
Hide resolved
WHEN productId = UINT256 '10' OR productId = UINT256 '24' THEN 'APE' | ||
WHEN productId = UINT256 '11' OR productId = UINT256 '25' THEN 'AXS' | ||
WHEN productId = UINT256 '12' OR productId = UINT256 '26' THEN 'UNI' | ||
ELSE 'product_id_' || productId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ELSE 'product_id_' || productId | |
ELSE 'product_id_' || CAST(productId AS VARCHAR) |
WHEN productId = UINT256 '10' OR productId = UINT256 '24' THEN 'APE' | ||
WHEN productId = UINT256 '11' OR productId = UINT256 '25' THEN 'AXS' | ||
WHEN productId = UINT256 '12' OR productId = UINT256 '26' THEN 'UNI' | ||
ELSE 'product_id_' || productId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ELSE 'product_id_' || productId | |
ELSE 'product_id_' || CAST(productId AS VARCHAR) |
Thank you for contributing to Spellbook 🪄
Please open the PR in draft and mark as ready when you want to request a review.
Description:
[...]
quick links for more information: