MetricsDAO / harmony_dbt

DBT Project for the Harmony Blockchain
12 stars 8 forks source link

[BugFix] Swaps #62

Closed antonyip closed 2 years ago

antonyip commented 2 years ago
root@6a201762a036:/harmony# dbt test -s swaps 
Running with dbt=0.21.1
Found 48 models, 172 tests, 0 snapshots, 0 analyses, 177 macros, 0 operations, 6 seed files, 2 sources, 0 exposures

06:42:57 | Concurrency: 4 threads (target='dev')
06:42:57 | 
06:42:57 | 1 of 11 START test not_null_swaps_amount0In.......................... [RUN]
06:42:57 | 2 of 11 START test not_null_swaps_amount0Out......................... [RUN]
06:42:57 | 3 of 11 START test not_null_swaps_amount1In.......................... [RUN]
06:42:57 | 4 of 11 START test not_null_swaps_amount1Out......................... [RUN]
06:43:02 | 3 of 11 FAIL 50 not_null_swaps_amount1In............................. [FAIL 50 in 5.05s]
06:43:02 | 5 of 11 START test not_null_swaps_block_timestamp.................... [RUN]
06:43:02 | 1 of 11 FAIL 50 not_null_swaps_amount0In............................. [FAIL 50 in 5.13s]
06:43:02 | 6 of 11 START test not_null_swaps_from_address....................... [RUN]
06:43:02 | 2 of 11 FAIL 50 not_null_swaps_amount0Out............................ [FAIL 50 in 5.18s]
06:43:02 | 7 of 11 START test not_null_swaps_log_id............................. [RUN]
06:43:02 | 4 of 11 FAIL 50 not_null_swaps_amount1Out............................ [FAIL 50 in 5.15s]
06:43:02 | 8 of 11 START test not_null_swaps_pool_address....................... [RUN]
06:43:07 | 5 of 11 PASS not_null_swaps_block_timestamp.......................... [PASS in 4.64s]
06:43:07 | 9 of 11 START test not_null_swaps_to_address......................... [RUN]
06:43:07 | 6 of 11 FAIL 50 not_null_swaps_from_address.......................... [FAIL 50 in 4.73s]
06:43:07 | 10 of 11 START test not_null_swaps_tx_hash........................... [RUN]
06:43:08 | 8 of 11 PASS not_null_swaps_pool_address............................. [PASS in 5.57s]
06:43:08 | 11 of 11 START test unique_swaps_log_id.............................. [RUN]
06:43:08 | 7 of 11 PASS not_null_swaps_log_id................................... [PASS in 5.78s]
06:43:11 | 9 of 11 FAIL 50 not_null_swaps_to_address............................ [FAIL 50 in 4.26s]
06:43:11 | 10 of 11 PASS not_null_swaps_tx_hash................................. [PASS in 4.36s]
06:43:13 | 11 of 11 FAIL 13919 unique_swaps_log_id.............................. [FAIL 13919 in 5.67s]
06:43:13 | 
06:43:13 | Finished running 11 tests in 20.91s.

Time to revisit either the test cases or figure out what is wrong with them.

eevui commented 2 years ago

I'd like to pick this up!

eevui commented 2 years ago

On first look it seems like some rows are coming up empty, and that is because the retrieved log does not relate with a liquidity pool.

Checking some of the transactions not related to a liquidity pool, they indeed aren't swaps. For instance, this one, https://explorer.harmony.one/tx/0x9f82b9609d9d03a6beae1e5653cb685f01554370799b46571233ba0fee7ccbc9?activeTab=0, appears to be a presale mint. It emits a Swap event, which the swaps model takes and assumes as a LP swap.

In fact, all 50 of these rows that come up null are from the same presale event.

A quick fix is to use an inner join, instead of a left join on liquidity pools.