Skip to content

Commit

Permalink
Celo: fixing token transfers (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Dec 16, 2024
1 parent 4898bf1 commit c1eecea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions models/projects/celo/raw/ez_celo_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ select
from {{ref('fact_celo_native_token_transfers')}}
{% if is_incremental() %}
where block_timestamp >= (select max(block_timestamp) from {{ this }})
and contract_address = 'native-token:42220'
{% endif %}
union all
select
Expand All @@ -44,4 +45,5 @@ select
from {{ref('fact_celo_token_transfers')}}
{% if is_incremental() %}
where block_timestamp >= (select max(block_timestamp) from {{ this }})
and contract_address <> 'native-token:42220'
{% endif %}
6 changes: 3 additions & 3 deletions models/staging/celo/fact_celo_native_token_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ prices as ({{get_coingecko_price_with_latest('celo')}})
'native-token:42220' as contract_address,
t1.from_address,
t1.to_address,
t1.value as amount,
try_to_number(t1.value) as amount,
t1.status as tx_status
from {{ ref("fact_celo_traces") }} t1
left join {{ ref("fact_celo_transactions") }} t2 using(transaction_hash)
Expand All @@ -37,7 +37,7 @@ prices as ({{get_coingecko_price_with_latest('celo')}})
'native-token:42220' as contract_address,
t1.from_address,
t2.miner as to_address,
t1.gas * t1.gas_price as amount,
try_to_number(t1.gas * t1.gas_price) as amount,
1 as tx_status -- Fees are paid whether or not the transaction is successful
from {{ref("fact_celo_transactions")}} t1
left join {{ref("fact_celo_blocks")}} t2 using (block_number)
Expand All @@ -62,5 +62,5 @@ select
tx_status
from celo_native_transfers
left join prices on block_timestamp::date = prices.date
where amount is not null and amount > 0
where amount is not null and amount > 0 and block_timestamp < to_date(sysdate())

0 comments on commit c1eecea

Please sign in to comment.