Skip to content

Commit

Permalink
add amount_usd column
Browse files Browse the repository at this point in the history
  • Loading branch information
lequangphu committed Nov 28, 2024
1 parent 02c8aee commit 44883fb
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('arbitrum') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'arbitrum'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'arbitrum'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('avalanche_c') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'avalanche_c'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'avalanche_c'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('bnb') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'bnb'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'bnb'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('ethereum') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'ethereum'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'ethereum'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('fantom') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'fantom'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'fantom'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('gnosis') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'gnosis'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'gnosis'
, columns = ['from']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ with chain_transfers as (
destinationChainId,
source_chain,
transfer_id,
amount_usd,
tx_from
from {{ ref('lifi_' ~ chain ~ '_transfers') }}
{% if not loop.last %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ models:
- name: tx_from
description: "Address that initiated the transaction"
- name: transfer_id
description: "Unique identifier for the transfer"
data_tests:
description: "Unique identifier for each transfer"
tests:
- unique
- not_null
- name: amount_usd
description: "USD value of the transfer amount at the time of transfer"
tests:
- not_null: false

- name: lifi_arbitrum_transfers
description: "Arbitrum LiFi transfer events"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

with source_data as (
{{ lifi_extract_bridge_data('zksync') }}
),

price_data as (
select
source_data.*,
p.price * cast(source_data.minAmount as double) / power(10, p.decimals) as amount_usd
from source_data
left join {{ source('prices', 'usd') }} p
on cast(p.contract_address as varchar) = source_data.sendingAssetId
and p.blockchain = 'zksync'
and p.minute = date_trunc('minute', source_data.block_time)
)

{{
add_tx_columns(
model_cte = 'source_data'
model_cte = 'price_data'
, blockchain = 'zksync'
, columns = ['from']
)
Expand Down

0 comments on commit 44883fb

Please sign in to comment.