Skip to content

Commit

Permalink
Add other versions of kyberswap aggregator, total 5 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nhd98z committed Aug 21, 2023
1 parent 776312d commit d60d564
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 31 deletions.
96 changes: 94 additions & 2 deletions models/kyberswap/arbitrum/kyberswap_aggregator_arbitrum_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,106 @@
)
}}

{% set project_start_date = '2023-01-01' %}
{% set project_start_date = '2021-01-01' %}

WITH meta_router AS
(
SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'2' AS version
,'aggregation_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_arbitrum', 'AggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_arbitrum', 'AggregationRouterV2_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v3' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_arbitrum', 'AggregationRouterV3_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_arbitrum', 'MetaAggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
Expand Down
8 changes: 8 additions & 0 deletions models/kyberswap/arbitrum/kyberswap_arbitrum_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@ sources:
loaded_at_field: evt_block_time
- name: Elastic_Factory_evt_PoolCreated
loaded_at_field: evt_block_time
- name: AggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV2_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV3_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouterV2_evt_Swapped
loaded_at_field: evt_block_time
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,106 @@
)
}}

{% set project_start_date = '2023-01-01' %}
{% set project_start_date = '2021-01-01' %}

WITH meta_router AS
(
SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'2' AS version
,'aggregation_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_avalanche_c', 'AggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_avalanche_c', 'AggregationRouterV2_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v3' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_avalanche_c', 'AggregationRouterV3_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_avalanche_c', 'MetaAggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ sources:
loaded_at_field: evt_block_time
- name: AggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV2_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV3_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouterV2_evt_Swapped
Expand Down
96 changes: 94 additions & 2 deletions models/kyberswap/bnb/kyberswap_aggregator_bnb_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,106 @@
)
}}

{% set project_start_date = '2023-01-01' %}
{% set project_start_date = '2021-01-01' %}

WITH meta_router AS
(
SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'2' AS version
,'aggregation_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_bnb', 'AggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_bnb', 'AggregationRouterV2_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'aggregation_v3' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_bnb', 'AggregationRouterV3_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v1' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
,spentAmount AS token_sold_amount_raw
,CAST(NULL AS DOUBLE) AS amount_usd
,dstToken AS token_bought_address
,srcToken AS token_sold_address
,contract_address AS project_contract_address
,evt_tx_hash AS tx_hash
,evt_index AS evt_index
,ARRAY[-1] AS trace_address
FROM
{{ source('kyber_bnb', 'MetaAggregationRouter_evt_Swapped') }}
{% if is_incremental() %}
WHERE evt_block_time >= date_trunc('day', now() - INTERVAL '7' DAY)
{% endif %}

UNION ALL

SELECT
evt_block_time AS block_time
,'kyberswap' AS project
,'meta_v2' AS version
,sender AS taker
,dstReceiver AS maker
,returnAmount AS token_bought_amount_raw
Expand Down
8 changes: 8 additions & 0 deletions models/kyberswap/bnb/kyberswap_bnb_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ sources:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
tables:
- name: AggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV2_evt_Swapped
loaded_at_field: evt_block_time
- name: AggregationRouterV3_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouter_evt_Swapped
loaded_at_field: evt_block_time
- name: MetaAggregationRouterV2_evt_Swapped
loaded_at_field: evt_block_time

0 comments on commit d60d564

Please sign in to comment.