Skip to content

Commit

Permalink
Airdrop Claims Migration - #1 - Arbitrum - Ready for review (duneanal…
Browse files Browse the repository at this point in the history
…ytics#4210)

Airdropclaims Migration - #1 - Arbitrum
  • Loading branch information
henrystats committed Sep 6, 2023
1 parent b595160 commit 505ef15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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)
{% endif %}

0 comments on commit 505ef15

Please sign in to comment.