From ef946f7e7e940530dd632916734fb0c17b7def90 Mon Sep 17 00:00:00 2001 From: whalehunting <143016036+whalehunting@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:21:54 +0100 Subject: [PATCH 1/4] chore-add-additional-openocean-fee-wallet-for-flokibot --- .../models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql index 63eade0c94a..a6b0b03e0a7 100644 --- a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql @@ -71,7 +71,8 @@ with select evt_block_time as block_time, evt_tx_hash as tx_hash from {{ source('openocean_v2_bnb', 'OpenOceanExchange_evt_Swapped') }} where - referrer = {{ treasury_fee_wallet_3 }} + referrer = {{ treasury_fee_wallet_2 }} + OR referrer {{ treasury_fee_wallet_3 }} {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} {% else %} and evt_block_time >= timestamp '{{project_start_date}}' From 79b8c19b6387275e40e045ed5efc0e8af036dffe Mon Sep 17 00:00:00 2001 From: whalehunting <143016036+whalehunting@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:32:18 +0100 Subject: [PATCH 2/4] fix: add missing referrer --- .../bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql index a6b0b03e0a7..e39b7dc91e3 100644 --- a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql @@ -71,8 +71,9 @@ with select evt_block_time as block_time, evt_tx_hash as tx_hash from {{ source('openocean_v2_bnb', 'OpenOceanExchange_evt_Swapped') }} where - referrer = {{ treasury_fee_wallet_2 }} - OR referrer {{ treasury_fee_wallet_3 }} + referrer = {{ aggregator_fee_wallet_1 }} + OR referrer = {{ treasury_fee_wallet_2 }} + OR referrer = {{ treasury_fee_wallet_3 }} {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} {% else %} and evt_block_time >= timestamp '{{project_start_date}}' From b3636f8319a000ca7f3da0d440e9d196a4345ee4 Mon Sep 17 00:00:00 2001 From: whalehunting <143016036+whalehunting@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:44:33 +0100 Subject: [PATCH 3/4] chore: use same fee wallets across all custom routers + aggregators --- .../base/flokibot_base_bot_trades.sql | 19 +++++++++++++++++++ .../flokibot/bnb/flokibot_bnb_bot_trades.sql | 8 +++++++- .../ethereum/flokibot_ethereum_bot_trades.sql | 8 +++++++- .../openocean/base/openocean_base_sources.yml | 6 ++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 sources/openocean/base/openocean_base_sources.yml diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql index 6414dedc79d..dbdbdc01f5d 100644 --- a/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/base/flokibot_base_bot_trades.sql @@ -40,6 +40,7 @@ with ( to = {{ treasury_fee_wallet_1 }} or to = {{ treasury_fee_wallet_2 }} + or to = {{ aggregator_fee_wallet_1 }} or to = {{ buyback_fee_wallet_1 }} ) and tx_success = true @@ -56,7 +57,9 @@ with where ( varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 ) and call_success {% if is_incremental() %} @@ -64,12 +67,28 @@ with {% else %} and call_block_time >= timestamp '{{project_start_date}}' {% endif %} ), + openocean_aggregator_trades as ( + select evt_block_time as block_time, evt_tx_hash as tx_hash + from {{ source('openocean_v2_base', 'OpenOceanExchange_evt_Swapped') }} + where + referrer = {{ aggregator_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_2 }} + or referrer = {{ buyback_fee_wallet_1 }} + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), trade_transactions as ( select block_time, address, null as tx_hash from bot_contracts union all select block_time, null as address, tx_hash from oneinch_aggregator_trades + union all + select block_time, null as address, tx_hash + from openocean_aggregator_trades ), bot_trades as ( select diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql index e39b7dc91e3..0ae3261690a 100644 --- a/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/bnb/flokibot_bnb_bot_trades.sql @@ -40,8 +40,10 @@ with from {{ source('bnb', 'traces') }} where ( - to = {{ treasury_fee_wallet_1 }} + to = {{ aggregator_fee_wallet_1 }} + or to = {{ treasury_fee_wallet_1 }} or to = {{ treasury_fee_wallet_2 }} + or to = {{ treasury_fee_wallet_3 }} or to = {{ buyback_fee_wallet_1 }} ) and tx_success = true @@ -58,8 +60,10 @@ with where ( varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 or varbinary_position(data, {{ treasury_fee_wallet_3 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 ) and call_success {% if is_incremental() %} @@ -72,8 +76,10 @@ with from {{ source('openocean_v2_bnb', 'OpenOceanExchange_evt_Swapped') }} where referrer = {{ aggregator_fee_wallet_1 }} + OR referrer = {{ treasury_fee_wallet_1 }} OR referrer = {{ treasury_fee_wallet_2 }} OR referrer = {{ treasury_fee_wallet_3 }} + OR referrer = {{ buyback_fee_wallet_1 }} {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} {% else %} and evt_block_time >= timestamp '{{project_start_date}}' diff --git a/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql b/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql index 767d546a6c9..65b05a754c4 100644 --- a/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql +++ b/dbt_subprojects/dex/models/bot_trades/flokibot/ethereum/flokibot_ethereum_bot_trades.sql @@ -40,6 +40,7 @@ with ( to = {{ treasury_fee_wallet_1 }} or to = {{ treasury_fee_wallet_2 }} + or to = {{ aggregator_fee_wallet_1 }} or to = {{ buyback_fee_wallet_1 }} ) and tx_success = true @@ -56,7 +57,9 @@ with where ( varbinary_position(data, {{ aggregator_fee_wallet_1 }}) > 0 + or varbinary_position(data, {{ treasury_fee_wallet_1 }}) > 0 or varbinary_position(data, {{ treasury_fee_wallet_2 }}) > 0 + or varbinary_position(data, {{ buyback_fee_wallet_1 }}) > 0 ) and call_success {% if is_incremental() %} @@ -68,7 +71,10 @@ with select evt_block_time as block_time, evt_tx_hash as tx_hash from {{ source('openocean_v2_ethereum', 'OpenOceanExchangeProxy_evt_Swapped') }} where - referrer = {{ treasury_fee_wallet_2 }} + referrer = {{ treasury_fee_wallet_1 }} + or referrer = {{ treasury_fee_wallet_2 }} + or referrer = {{ aggregator_fee_wallet_1 }} + or referrer = {{ buyback_fee_wallet_1 }} {% if is_incremental() %} and {{ incremental_predicate('evt_block_time') }} {% else %} and evt_block_time >= timestamp '{{project_start_date}}' diff --git a/sources/openocean/base/openocean_base_sources.yml b/sources/openocean/base/openocean_base_sources.yml new file mode 100644 index 00000000000..37f46a9c018 --- /dev/null +++ b/sources/openocean/base/openocean_base_sources.yml @@ -0,0 +1,6 @@ +version: 2 + +sources: + - name: openocean_v2_base + tables: + - name: OpenOceanExchange_evt_Swapped From 158e39c1c3c56fa4665372ce2066b468e1f75b7a Mon Sep 17 00:00:00 2001 From: whalehunting <143016036+whalehunting@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:54:31 +0100 Subject: [PATCH 4/4] fix: remove duplicated source --- sources/openocean/base/openocean_base_sources.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 sources/openocean/base/openocean_base_sources.yml diff --git a/sources/openocean/base/openocean_base_sources.yml b/sources/openocean/base/openocean_base_sources.yml deleted file mode 100644 index 37f46a9c018..00000000000 --- a/sources/openocean/base/openocean_base_sources.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 - -sources: - - name: openocean_v2_base - tables: - - name: OpenOceanExchange_evt_Swapped