From 6a6e6e178e67dfeb5bf6880cc726073547a58976 Mon Sep 17 00:00:00 2001 From: Matt Romano <42412983+mattromano@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:13:10 -0700 Subject: [PATCH] tarot-borrow-amount-bug (#300) * add try_to_number for tarot borrow and repay models * remove int cast --- models/silver/defi/lending/tarot/silver__tarot_borrows.sql | 5 +++-- .../silver/defi/lending/tarot/silver__tarot_repayments.sql | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/models/silver/defi/lending/tarot/silver__tarot_borrows.sql b/models/silver/defi/lending/tarot/silver__tarot_borrows.sql index 30823d89..20efa165 100644 --- a/models/silver/defi/lending/tarot/silver__tarot_borrows.sql +++ b/models/silver/defi/lending/tarot/silver__tarot_borrows.sql @@ -42,9 +42,10 @@ log_pull AS ( contract_address, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(topics [2] :: STRING, 25, 40)) AS borrower, + TRY_TO_NUMBER( utils.udf_hex_to_int( segmented_data [0] :: STRING - ) :: INTEGER AS loan_amount_raw, + )) AS loan_amount_raw, _inserted_timestamp, _log_id FROM @@ -59,7 +60,7 @@ log_pull AS ( ) AND topics [0] :: STRING = '0x33f3048bd4e6af45e53afb722adfd57dbde82da7e93e44db921fb4b8c6a70c4b' AND tx_status = 'SUCCESS' - AND loan_amount_raw > 0 --borrow and repay in same log event, value in segmented data determines what kind of event + AND loan_amount_raw > 0 --borrow and repay in same log event, value in segmented data determines if borrow or repay {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/tarot/silver__tarot_repayments.sql b/models/silver/defi/lending/tarot/silver__tarot_repayments.sql index b1ed017f..4905a73a 100644 --- a/models/silver/defi/lending/tarot/silver__tarot_repayments.sql +++ b/models/silver/defi/lending/tarot/silver__tarot_repayments.sql @@ -43,9 +43,10 @@ log_pull AS ( regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(topics [2] :: STRING, 25, 40)) AS borrower, CONCAT('0x', SUBSTR(topics [3] :: STRING, 25, 40)) AS payer, + TRY_TO_NUMBER( utils.udf_hex_to_int( segmented_data [1] :: STRING - ) :: INTEGER AS repay_amount_raw, + )) AS repay_amount_raw, _inserted_timestamp, _log_id FROM