mirror of
https://github.com/FlipsideCrypto/flow-models.git
synced 2026-02-06 14:22:06 +00:00
final changes
This commit is contained in:
parent
616c9a9e66
commit
b0864b6db0
@ -18,12 +18,14 @@ SELECT
|
||||
event_index,
|
||||
swap_contract,
|
||||
sender_address,
|
||||
NULL AS recipient_address,
|
||||
recipient_address,
|
||||
platform,
|
||||
token_in_contract,
|
||||
token_out_contract,
|
||||
token_in_amount,
|
||||
token_out_amount,
|
||||
swap_direction,
|
||||
pair_id,
|
||||
raw_data,
|
||||
kittypunch_v2_swaps_id AS source_id,
|
||||
'kittypunch_v2_swaps' AS source_table,
|
||||
@ -42,7 +44,7 @@ WHERE modified_timestamp > (
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
tx_hash AS tx_id,
|
||||
tx_id,
|
||||
block_timestamp,
|
||||
block_height,
|
||||
event_index,
|
||||
@ -54,7 +56,9 @@ SELECT
|
||||
token_out_contract,
|
||||
token_in_amount,
|
||||
token_out_amount,
|
||||
raw_data,
|
||||
swap_direction,
|
||||
pair_id,
|
||||
TRY_PARSE_JSON(raw_data) AS raw_data,
|
||||
kittypunch_v3_swaps_id AS source_id,
|
||||
'kittypunch_v3_swaps' AS source_table,
|
||||
inserted_timestamp AS source_inserted_timestamp,
|
||||
|
||||
@ -159,10 +159,9 @@ FINAL AS (
|
||||
block_number AS block_height,
|
||||
event_index,
|
||||
pair_contract AS swap_contract,
|
||||
sender_address AS trader,
|
||||
sender_address,
|
||||
recipient_address,
|
||||
'kittypunch' AS platform,
|
||||
'v2' AS platform_version,
|
||||
'kittypunch_v2' AS platform,
|
||||
token_in_contract,
|
||||
token_out_contract,
|
||||
token_in_amount_raw AS token_in_amount,
|
||||
@ -173,12 +172,6 @@ FINAL AS (
|
||||
ELSE 'unknown'
|
||||
END AS swap_direction,
|
||||
0 AS pair_id, -- Set default pair_id since we don't extract it in this model
|
||||
CASE
|
||||
WHEN LOWER(token_in_contract) = LOWER('0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e')
|
||||
OR LOWER(token_out_contract) = LOWER('0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e')
|
||||
THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS contains_wflow,
|
||||
data as raw_data
|
||||
FROM
|
||||
swap_details
|
||||
|
||||
@ -23,24 +23,18 @@ models:
|
||||
description: "Contract address of the pair where the swap was executed"
|
||||
tests:
|
||||
- not_null
|
||||
- name: trader
|
||||
- name: sender_address
|
||||
description: "Address that initiated the swap transaction"
|
||||
tests:
|
||||
- not_null
|
||||
- name: recipient_address
|
||||
description: "Address that received the output tokens (may differ from trader)"
|
||||
- name: platform
|
||||
description: "DEX platform identifier, always 'kittypunch' for this model"
|
||||
description: "DEX platform identifier, always 'kittypunch_v2' for this model"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['kittypunch']
|
||||
- name: platform_version
|
||||
description: "Platform version, always 'v2' for this model"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['v2']
|
||||
values: ['kittypunch_v2']
|
||||
- name: token_in_contract
|
||||
description: "Contract address of the token being sold"
|
||||
tests:
|
||||
@ -71,10 +65,6 @@ models:
|
||||
description: "ID of the trading pair from the factory"
|
||||
tests:
|
||||
- not_null
|
||||
- name: contains_wflow
|
||||
description: "Boolean indicating if the swap involves WFLOW token"
|
||||
tests:
|
||||
- not_null
|
||||
- name: raw_data
|
||||
description: "Raw data field from the Swap event"
|
||||
- name: inserted_timestamp
|
||||
|
||||
@ -119,7 +119,7 @@ swap_details AS (
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
tx_hash AS tx_id,
|
||||
block_timestamp,
|
||||
block_number AS block_height,
|
||||
event_index,
|
||||
@ -131,6 +131,8 @@ FINAL AS (
|
||||
token_out_contract,
|
||||
token_in_amount_raw AS token_in_amount,
|
||||
token_out_amount_raw AS token_out_amount,
|
||||
'unknown' AS swap_direction, -- V3 doesn't have clear token0/token1 mapping like V2
|
||||
0 AS pair_id, -- Set default pair_id to match V2 structure
|
||||
raw_data
|
||||
FROM swap_details
|
||||
)
|
||||
@ -138,7 +140,7 @@ FINAL AS (
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash', 'event_index']
|
||||
['tx_id', 'event_index']
|
||||
) }} AS kittypunch_v3_swaps_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
|
||||
@ -23,24 +23,18 @@ models:
|
||||
description: "Contract address of the V3 pool where the swap was executed"
|
||||
tests:
|
||||
- not_null
|
||||
- name: trader
|
||||
- name: sender_address
|
||||
description: "Address that initiated the swap transaction"
|
||||
tests:
|
||||
- not_null
|
||||
- name: recipient_address
|
||||
description: "Address that received the output tokens (may differ from trader)"
|
||||
- name: platform
|
||||
description: "DEX platform identifier, always 'kittypunch' for this model"
|
||||
description: "DEX platform identifier, always 'kittypunch_v3' for this model"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['kittypunch']
|
||||
- name: platform_version
|
||||
description: "Platform version, always 'v3' for this model"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['v3']
|
||||
values: ['kittypunch_v3']
|
||||
- name: token_in_contract
|
||||
description: "Contract address of the token being sold (derived from Transfer events)"
|
||||
tests:
|
||||
@ -67,18 +61,8 @@ models:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['token0_to_token1', 'token1_to_token0', 'unknown']
|
||||
- name: fee_tier
|
||||
description: "Fee tier of the V3 pool in basis points"
|
||||
tests:
|
||||
- not_null
|
||||
- name: tick
|
||||
description: "Current tick after the swap execution"
|
||||
- name: sqrt_price_x96
|
||||
description: "Square root price after swap in Q64.96 format"
|
||||
- name: liquidity
|
||||
description: "Pool liquidity after the swap"
|
||||
- name: contains_wflow
|
||||
description: "Boolean indicating if the swap involves WFLOW token"
|
||||
- name: pair_id
|
||||
description: "ID of the trading pair from the factory (set to 0 for V3)"
|
||||
tests:
|
||||
- not_null
|
||||
- name: raw_data
|
||||
|
||||
Loading…
Reference in New Issue
Block a user