Commit f1433f1
S. K. Rotwang MMMMMMMMM
fix(queries): honest operator_activity — defend against phantom wins
The dashboard claimed a "win" that turned out to be a writer-side
arg-misalignment in liquidation-scanner.js (already fixed upstream):
some skip-decision rows ('aave_gas_budget_rejected') were logged with
success=1 because a string was passed where the success boolean
belonged. The string was truthy-coerced to 1.
This commit hardens the read path so the dashboard remains accurate
even if future writer bugs sneak similar junk in:
- liquidation_attempts: COUNT(DISTINCT tx_hash) over rows where
tx_hash is a real on-chain hash (0x + 64 hex). Previously naive
COUNT(*) double-counted every bundle (one submit + one timeout
row per attempt) and triple-counted some failed paths. Skip rows
with no tx_hash are now correctly excluded — they're "we looked
and didn't fire", not attempts.
- liquidations_won: same tx_hash predicate ANDed with success=1.
Now requires both flags to align with a real on-chain hash. Old
query trusted success=1 alone.
- recentLiquidations: same tx_hash hardening applied so the public
feed never surfaces a phantom-win row.
Test fixture extended with a phantom-win row matching the bug
pattern; new regression test asserts the row is excluded.
Adds _nowMs / _windowMs injection seams so tests can pin the
24h cutoff onto 2023-vintage fixtures.
76 tests pass (was 75).1 parent abb5585 commit f1433f1
2 files changed
Lines changed: 90 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
385 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
386 | 395 | | |
387 | 396 | | |
388 | 397 | | |
| |||
393 | 402 | | |
394 | 403 | | |
395 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
396 | 408 | | |
397 | 409 | | |
398 | 410 | | |
| |||
792 | 804 | | |
793 | 805 | | |
794 | 806 | | |
795 | | - | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
796 | 813 | | |
797 | 814 | | |
798 | 815 | | |
| |||
874 | 891 | | |
875 | 892 | | |
876 | 893 | | |
877 | | - | |
| 894 | + | |
878 | 895 | | |
879 | 896 | | |
880 | 897 | | |
| |||
898 | 915 | | |
899 | 916 | | |
900 | 917 | | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
901 | 941 | | |
902 | 942 | | |
903 | | - | |
904 | | - | |
| 943 | + | |
| 944 | + | |
905 | 945 | | |
906 | 946 | | |
| 947 | + | |
907 | 948 | | |
908 | 949 | | |
909 | 950 | | |
910 | | - | |
911 | | - | |
| 951 | + | |
| 952 | + | |
912 | 953 | | |
913 | 954 | | |
| 955 | + | |
914 | 956 | | |
915 | 957 | | |
916 | 958 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | | - | |
85 | | - | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
| 96 | + | |
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
94 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
95 | 114 | | |
96 | 115 | | |
97 | 116 | | |
| |||
407 | 426 | | |
408 | 427 | | |
409 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
410 | 449 | | |
411 | 450 | | |
412 | 451 | | |
| |||
0 commit comments