Fug603helius livequery demo copy
    Updated 2023-06-06
    -- forked from theericstone-pine / helius livequery demo @ https://flipsidecrypto.xyz/theericstone-pine/q/2023-06-06-04-58-pm-Tl6lHT

    with raw as (
    SELECT livequery.live.udf_api(
    'https://api.helius.xyz/v0/addresses/{{soladdress}}/balances?api-key={{helius-key}}'
    ) as response
    ),
    tokens as (
    select
    value:mint::string as token,
    value:amount / pow(10,value:decimals) as amount
    from raw,
    lateral flatten (input => response:data:tokens)
    ),
    nativesol as (
    select 'sol' as token,
    response:data:nativeBalance / pow(10,9) as amount
    from raw
    )
    select * from tokens
    UNION
    select * from nativesol;


    Run a query to Download Data