Skip to content

Commit

Permalink
Update dbt models
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-snx committed Oct 6, 2024
1 parent fe64b36 commit 34ef206
Show file tree
Hide file tree
Showing 40 changed files with 781 additions and 330 deletions.
2 changes: 1 addition & 1 deletion transformers/synthetix/macros/convert_wei.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro convert_wei(column_name) %}
cast({{ column_name }} as UInt256) / 1e18
{{ column_name }} / 1e18
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ with market_updated as (
contract,
event_name,
market_id,
net_issuance,
cast(net_issuance as Int128) as net_issuance,
sender,
collateral_type,
credit_capacity,
token_amount
cast(credit_capacity as Int128) as credit_capacity,
cast(token_amount as UInt256) as token_amount
from
{{ ref('core_market_updated_arbitrum_sepolia') }}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ with rewards_distributed as (
collateral_type,
distributor,
{{ convert_wei('amount') }} as amount,
FROM_UNIXTIME(CAST("start" AS INTEGER)) as ts_start,
"duration"
FROM_UNIXTIME(start) as ts_start,
duration
from
{{ ref('core_rewards_distributed_arbitrum_sepolia') }}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ atomics as (
select
ts,
block_number,
'0' as synth_market_id,
0 as synth_market_id,
amount * price * -1 as change_amount
from
{{ ref('fct_spot_atomics_arbitrum_sepolia') }}
Expand All @@ -30,15 +30,15 @@ usd_changes as (
select
block_timestamp as ts,
block_number,
'0' as synth_market_id,
0 as synth_market_id,
{{ convert_wei("amount") }} as change_amount
from
{{ ref('core_usd_minted_arbitrum_sepolia') }}
union all
select
block_timestamp as ts,
block_number,
'0' as synth_market_id,
0 as synth_market_id,
-1 * {{ convert_wei("amount") }} as change_amount
from
{{ ref('core_usd_burned_arbitrum_sepolia') }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'account_created'
) }}
with core_account_created as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'account_created'
) }}
)

select
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
id,
cast(account_id as UInt128) as account_id,
owner
from core_account_created
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'delegation_updated'
) }}
with delegation_updated as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'delegation_updated'
) }}
)

select
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
id,
sender,
cast(account_id as UInt128) as account_id,
cast(pool_id as UInt128) as pool_id,
collateral_type,
cast(amount as UInt256) as amount,
cast(leverage as UInt256) as leverage
from
delegation_updated
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'deposited'
) }}
with core_deposited as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'deposited'
) }}
)

select
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
id,
sender,
cast(account_id as UInt128) as account_id,
collateral_type,
cast(token_amount as UInt256) as token_amount
from core_deposited
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'liquidation'
) }}
with core_liquidation as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'liquidation'
) }}
)

select
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
id,
sender,
liquidation_data,
cast(account_id as UInt128) as account_id,
cast(pool_id as UInt128) as pool_id,
collateral_type,
cast(liquidate_as_account_id as UInt128) as liquidate_as_account_id
from core_liquidation
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'market_registered'
) }}
with core_market_registered as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'market_registered'
) }}
)

select
id,
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
sender,
market,
cast(market_id as UInt128) as market_id
from core_market_registered
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ with events as (
transaction_hash,
contract,
event_name,
market_id,
net_issuance,
deposited_collateral_value,
sender,
collateral_type,
credit_capacity,
token_amount
cast(market_id as UInt128) as market_id,
cast(net_issuance as Int128) as net_issuance,
cast(deposited_collateral_value as UInt256) as deposited_collateral_value,
cast(credit_capacity as Int128) as credit_capacity,
cast(token_amount as UInt256) as token_amount
from
(
{{ get_event_data(
Expand All @@ -30,13 +30,13 @@ with events as (
transaction_hash,
contract,
event_name,
market_id,
net_issuance,
deposited_collateral_value,
sender,
collateral_type,
credit_capacity,
token_amount
cast(market_id as UInt128) as market_id,
cast(net_issuance as Int128) as net_issuance,
cast(deposited_collateral_value as UInt256) as deposited_collateral_value,
cast(credit_capacity as Int128) as credit_capacity,
cast(token_amount as UInt256) as token_amount
from
(
{{ get_event_data(
Expand All @@ -54,13 +54,13 @@ with events as (
transaction_hash,
contract,
event_name,
market_id,
net_issuance,
deposited_collateral_value,
target as sender,
'USD' as collateral_type,
credit_capacity,
amount as token_amount
cast(market_id as UInt128) as market_id,
cast(net_issuance as Int128) as net_issuance,
cast(deposited_collateral_value as UInt256) as deposited_collateral_value,
cast(credit_capacity as Int128) as credit_capacity,
cast(amount as UInt256) as token_amount
from
(
{{ get_event_data(
Expand All @@ -78,13 +78,13 @@ with events as (
transaction_hash,
contract,
event_name,
market_id,
net_issuance,
deposited_collateral_value,
target as sender,
'USD' as collateral_type,
credit_capacity,
amount as token_amount
cast(market_id as UInt128) as market_id,
cast(net_issuance as Int128) as net_issuance,
cast(deposited_collateral_value as UInt256) as deposited_collateral_value,
cast(credit_capacity as Int128) as credit_capacity,
cast(amount as UInt256) as token_amount
from
(
{{ get_event_data(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'pool_created'
) }}
with core_pool_created as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'pool_created'
) }}
)

select
id,
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
sender,
owner,
cast(pool_id as UInt128) as pool_id
from core_pool_created
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'rewards_claimed'
) }}
with core_rewards_claimed as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'rewards_claimed'
) }}
)

select
id,
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
cast(account_id as UInt128) as account_id,
cast(pool_id as UInt128) as pool_id,
collateral_type,
distributor,
cast(amount as UInt256) as amount
from core_rewards_claimed
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'rewards_distributed'
) }}
with core_rewards_distributed as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'rewards_distributed'
) }}
)

select
id,
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
cast(pool_id as UInt128) as pool_id,
collateral_type,
distributor,
cast(amount as UInt256) as amount,
cast(start as UInt256) as start,
cast(duration as UInt256) as duration
from core_rewards_distributed
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'usd_burned'
) }}
with core_usd_burned as (
{{ get_event_data(
'arbitrum',
'sepolia',
'core_proxy',
'usd_burned'
) }}
)

select
id,
block_timestamp,
block_number,
transaction_hash,
contract,
event_name,
sender,
cast(account_id as UInt128) as account_id,
cast(pool_id as UInt128) as pool_id,
collateral_type,
cast(amount as UInt256) as amount
from core_usd_burned
Loading

0 comments on commit 34ef206

Please sign in to comment.