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

Airdrop Claims Migration - #1 - Arbitrum - Ready for review #4210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/airdrop/arbitrum/airdrop_arbitrum_claims.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ config(
tags=['dunesql'],
alias = alias('claims'),
post_hook='{{ expose_spells(\'["arbitrum"]\',
"sector",
Expand Down
13 changes: 7 additions & 6 deletions models/arbitrum/arbitrum/arbitrum_arbitrum_airdrop_claims.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{
config(
tags=['dunesql'],
schema = 'arbitrum_arbitrum',
alias = alias('airdrop_claims'),
materialized = 'incremental',
Expand All @@ -20,7 +21,7 @@ WITH early_price AS (
, MIN_BY(price, minute) AS price
FROM {{ source('prices', 'usd') }}
WHERE blockchain = 'arbitrum'
AND contract_address='{{arb_token_address}}'
AND contract_address= {{arb_token_address}}
)

SELECT 'arbitrum' AS blockchain
Expand All @@ -31,21 +32,21 @@ SELECT 'arbitrum' AS blockchain
, t.recipient
, t.contract_address
, t.evt_tx_hash AS tx_hash
, CAST(t.amount AS DECIMAL(38,0)) AS amount_raw
, t.amount as amount_raw
, CAST(t.amount/POWER(10, 18) AS double) AS amount_original
, CASE WHEN t.evt_block_time >= (SELECT minute FROM early_price) THEN CAST(pu.price*t.amount/POWER(10, 18) AS double)
ELSE CAST((SELECT price FROM early_price)*t.amount/POWER(10, 18) AS double)
END AS amount_usd
, '{{arb_token_address}}' AS token_address
, {{arb_token_address}} AS token_address
, 'ARB' AS token_symbol
, t.evt_index
FROM {{ source('arbitrum_arbitrum', 'TokenDistributor_evt_HasClaimed') }} t
LEFT JOIN {{ ref('prices_usd_forward_fill') }} pu ON pu.blockchain = 'arbitrum'
AND pu.contract_address='{{arb_token_address}}'
AND pu.contract_address= {{arb_token_address}}
AND pu.minute=date_trunc('minute', t.evt_block_time)
{% if is_incremental() %}
AND pu.minute >= date_trunc("day", now() - interval '1 week')
AND pu.minute >= date_trunc('day', now() - interval '7' Day)
{% endif %}
{% if is_incremental() %}
WHERE t.evt_block_time >= date_trunc("day", now() - interval '1 week')
WHERE t.evt_block_time >= date_trunc('day', now() - interval '7' Day)
Copy link
Contributor

Choose a reason for hiding this comment

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

The airdrop is only live for the next ~20 days so let's try to remember and remove the incremental run then - Source: https://arbitrum.foundation/

{% endif %}