datavortexTop Borrowers
    Updated 2025-03-29
    WITH initial_loan AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS transaction_date,
    tx_hash,
    MAX(
    CASE
    WHEN function_name = 'isBorrower' THEN decoded_input_data:input_1::STRING
    WHEN function_name = 'borrower' THEN decoded_output_data:output_1::STRING
    END
    ) AS borrower_address,
    MAX(
    CASE
    WHEN function_name = 'principal' THEN decoded_output_data:output_1::FLOAT / POW(10, 6)
    END
    ) AS principal_amount,
    'initial' AS loan_type
    FROM ethereum.core.ez_decoded_traces
    WHERE function_name IN ('isBorrower', 'borrower', 'principal')
    AND from_address = LOWER('0xdc9b93a8a336fe5dc9db97616ea2118000d70fc0')
    AND tx_hash NOT IN (
    SELECT tx_hash
    FROM ethereum.core.ez_decoded_traces
    WHERE function_name = 'makePayment'
    )
    GROUP BY DATE_TRUNC('day', block_timestamp), tx_hash
    HAVING borrower_address IS NOT NULL
    ),

    refinance_loan AS (
    SELECT
    DATE_TRUNC('day', dt1.block_timestamp) AS transaction_date,
    dt1.tx_hash,
    dt2.decoded_input_data:"from"::STRING AS borrower_address,
    MAX(
    CASE
    WHEN dt1.function_name = 'principal' THEN dt1.decoded_output_data:output_1::FLOAT / POW(10, 6)
    Last run: 3 months ago
    BORROWER_ADDRESS
    TOTAL_BORROWED_AMOUNT
    NUMBER_OF_LOANS
    1
    0x39a578443e2e81190c75a605aca1b2c38ee5c4066689397610
    2
    0x319763bf57f2218a5e7fd60a9ccb56fdbb3c795340939905.8520
    3
    0xda28e780472b5754a1144bce6e83af06a33107d235352881.7233
    4
    0x71e6686f6267b454dbdf6db3399e7d6ced2b5313350700005
    5
    0x615803c1ab56b5b1314d9a7728729f840e7a51cf343420005
    6
    0xc938ba7c04e43d528f987a3c297f1526dcb95ee8320000005
    7
    0x9c7fc6916095d6492fa9fc388e633f7bce3aa9ef317300004
    8
    0xa42f7168d19c9d94e50e5c778e13e3195ce9126b271500007
    9
    0x1d6c52631df36fbd699141f11a4cdc0d08baf176180000002
    10
    0x14968d8b4eb966848ff78e9c17f65e9f1afbb82070000002
    10
    589B
    223s