Skip to content

Commit

Permalink
tarot-borrow-amount-bug (#300)
Browse files Browse the repository at this point in the history
* add try_to_number for tarot borrow and repay models

* remove int cast
  • Loading branch information
mattromano authored Jul 29, 2024
1 parent 344fca0 commit 6a6e6e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions models/silver/defi/lending/tarot/silver__tarot_borrows.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 >= (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a6e6e1

Please sign in to comment.