headitmanagerStable Coins Lent on Kashi : first token of pair is UST
    Updated 2022-06-14
    with kashi_USDC_first as
    (
    select
    case
    when EVENT_NAME='LogAddAsset' then EVENT_INPUTS:share/pow(10,DECIMALS)
    when EVENT_NAME='LogRemoveAsset' then -1 * EVENT_INPUTS:share/pow(10,DECIMALS)
    end as Lent_on_Kashi
    ,CONTRACT_ADDRESS,SYMBOL from ethereum_core.fact_event_logs INNER JOIN ethereum_core.dim_contracts
    on ethereum_core.dim_contracts.ADDRESS=ethereum_core.fact_event_logs.CONTRACT_ADDRESS
    where CONTRACT_NAME like '%KashiPair%' and SYMBOL like '%kmUSDC%'
    )
    , kashi_USDC_second as
    (
    select
    case
    when EVENT_NAME='LogAddAsset' then EVENT_INPUTS:share/pow(10,DECIMALS)
    when EVENT_NAME='LogRemoveAsset' then -1 * EVENT_INPUTS:share/pow(10,DECIMALS)
    end as Lent_on_Kashi
    ,CONTRACT_ADDRESS,SYMBOL from ethereum_core.fact_event_logs INNER JOIN ethereum_core.dim_contracts
    on ethereum_core.dim_contracts.ADDRESS=ethereum_core.fact_event_logs.CONTRACT_ADDRESS
    where CONTRACT_NAME like '%KashiPair%' and SYMBOL like '%USDC-LINK%'
    )
    , kashi_USDT_first as
    (
    select
    case
    when EVENT_NAME='LogAddAsset' then EVENT_INPUTS:share/pow(10,DECIMALS)
    when EVENT_NAME='LogRemoveAsset' then -1 * EVENT_INPUTS:share/pow(10,DECIMALS)
    end as Lent_on_Kashi
    ,CONTRACT_ADDRESS,SYMBOL from ethereum_core.fact_event_logs INNER JOIN ethereum_core.dim_contracts
    on ethereum_core.dim_contracts.ADDRESS=ethereum_core.fact_event_logs.CONTRACT_ADDRESS
    where CONTRACT_NAME like '%KashiPair%' and SYMBOL like '%kmUSDT%'
    )
    , kashi_USDT_second as
    (
    select
    Run a query to Download Data