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

Add zigzag_arbitrum_base_trades into dex.trades_beta #5279

Merged
merged 3 commits into from
Feb 2, 2024
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
18 changes: 18 additions & 0 deletions models/_sector/dex/trades/arbitrum/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,24 @@ models:
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('apeswap_arbitrum_base_trades_seed')

- name: zigzag_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: dex
pproject: zigzag
contributors: jeff-dude, masquot, soispoke, mtitus6, hosuke
config:
tags: [ 'arbitrum','trades', 'zigzag','dex' ]
description: >
Zigzag V1 contract trades on Arbitrum
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('zigzag_arbitrum_base_trades_seed')

- name: gridex_arbitrum_base_trades
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
, ref('smardex_arbitrum_base_trades')
, ref('swaap_v2_arbitrum_base_trades')
, ref('woofi_arbitrum_base_trades')
, ref('zigzag_arbitrum_base_trades')
, ref('gridex_arbitrum_base_trades')
] %}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{
config(
schema = 'zigzag_arbitrum',
alias = 'base_trades',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

with dexs as (
select
call_block_time as block_time,
from_hex(json_extract_scalar(zzmo.makerOrder, '$.sellToken')) as token_sold_address,
from_hex(json_extract_scalar(zzmo.makerOrder, '$.buyToken')) as token_bought_address,
cast(json_extract_scalar(zzmo.output_matchedFillResults, '$.takerSellFilledAmount') as UINT256) as token_bought_amount_raw,
cast(json_extract_scalar(zzmo.output_matchedFillResults, '$.makerSellFilledAmount') as UINT256) as token_sold_amount_raw,
from_hex(json_extract_scalar(zzmo.makerOrder, '$.user')) as maker,
from_hex(json_extract_scalar(zzmo.takerOrder, '$.user')) as taker,
call_tx_hash as tx_hash,
call_block_number as block_number,
row_number() OVER(PARTITION BY call_tx_hash ORDER BY zzmo.makerOrder) AS evt_index, --prevent duplicates
contract_address as project_contract_address
from
{{ source('zigzag_test_v6_arbitrum', 'zigzag_settelment_call_matchOrders') }} zzmo
where
call_success = true
{% if is_incremental() %}
AND {{ incremental_predicate('zzmo.call_block_time') }}
{% endif %}
)

SELECT
'arbitrum' AS blockchain
, 'zigzag' AS project
, '1' AS version
, CAST(date_trunc('month', dexs.block_time) AS date) AS block_month
, CAST(date_trunc('day', dexs.block_time) AS date) AS block_date
, dexs.block_time
, dexs.block_number
, dexs.token_bought_amount_raw
, dexs.token_sold_amount_raw
, dexs.token_bought_address
, dexs.token_sold_address
, dexs.taker
, dexs.maker
, dexs.project_contract_address
, dexs.tx_hash
, dexs.evt_index
FROM
dexs
Loading