Skip to content

Commit

Permalink
taker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RantumBits committed Nov 27, 2024
1 parent 7425907 commit d7cf59c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dbt_subprojects/dex/macros/models/_project/zeroex/zeroex_v2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ WITH tbl_all_logs AS (
logs.block_time,
logs.block_number,
index,
{% if is_direct %} tx_from
{% else %} case when (varbinary_substring(logs.topic1, 13, 20) in (tx_from)) then varbinary_substring(logs.topic1, 13, 20) end
{% endif %}
as taker,
case when tx_to in (0x0000000000001fF3684f28c67538d4D072C22734,
0x0000000000005E88410CcDFaDe4a5EfaE4b49562,
0x000000000000175a8b9bC6d539B3708EEd92EA6c) then tx_from
when (varbinary_substring(logs.topic2, 13, 20) in (settler_address)) then varbinary_substring(logs.topic1, 13, 20) end as taker_,
case when (varbinary_substring(logs.topic1, 13, 20) in (tx_from, settler_address)) then logs.contract_address end as taker_token_,
case when (varbinary_substring(logs.topic2, 13, 20) in (settler_address, tx_from)) then logs.contract_address end as maker_token_,
first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) AS int256)) OVER (PARTITION BY logs.tx_hash ORDER BY index) AS taker_amount,
Expand Down Expand Up @@ -133,6 +133,8 @@ WITH tbl_all_logs AS (
tbl_valid_logs AS (
SELECT
*
,FIRST_VALUE(taker_) IGNORE NULLS OVER (PARTITION BY tx_hash ORDER BY index
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS taker
,LAST_VALUE(maker_token_) IGNORE NULLS OVER (PARTITION BY tx_hash ORDER BY index
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS maker_token
,FIRST_VALUE(taker_token_) IGNORE NULLS OVER (PARTITION BY tx_hash ORDER BY index
Expand Down Expand Up @@ -183,7 +185,7 @@ results AS (
"from" AS tx_from,
"to" AS tx_to,
trades.index AS tx_index,
CASE WHEN varbinary_substring(tr.data,1,4) = 0x500c22bc THEN "from" ELSE taker END AS taker,
taker,
CAST(NULL AS varbinary) AS maker,
taker_token,
taker_token AS token_sold_address,
Expand Down

0 comments on commit d7cf59c

Please sign in to comment.