Flipside Data ScienceFebruary Onboarding #1 - Bridge Stablecoins to Stellar Allbridge
    Updated 2025-02-13
    with stellar_prices as (
    Select
    TO_TIMESTAMP(value [0] :: string) as hour,
    'XLM' as token,
    avg(value [1]) as avg_price
    from
    (
    SELECT
    livequery.live.udf_api(
    'https://api.coingecko.com/api/v3/coins/stellar/market_chart?vs_currency=usd&days=365'
    ) as resp
    ),
    LATERAL FLATTEN (input => resp:data:prices)
    group by
    all
    ),
    bridge as (
    SELECT distinct
    t.transaction_hash as tx_id,
    t.block_timestamp as block_timestamp,
    asset_balance_changes[0]:to::string as address,
    1 as action_count,
    TRUE as valid,
    1 as quest_step,
    'XLM' as currency,
    asset_balance_changes[0]:amount::FLOAT AS amount_usd,
    amount_usd/sp.avg_price as token_amount,
    tx.fee_charged/pow(10,7) as fee_amount


    from stellar.core.ez_operations t
    LEFT JOIN stellar.core.fact_transactions tx
    on t.transaction_hash = tx.transaction_hash
    left join stellar_prices sp
    on sp.hour::date = t.block_timestamp::date
    where
    Last run: about 1 month ago
    QUEST_ID
    BLOCK_TIMESTAMP
    TX_ID
    ACTION_COUNT
    ADDRESS
    VALID
    QUEST_STEP
    TOKEN_AMOUNT
    FEE_AMOUNT
    CURRENCY
    1
    :questId2025-01-30 14:43:28.000c4f9f3f960e11e1b456a98ea6c29e81e4a0c13f4862c0ae07d2c446c405445d81GAJGAQP467AQCN2A2VZ7IFII4IIL3SZSUKUUV5IBD2JGXBFA7X5EDPUSTRUE15.0659329150.1887746XLM
    2
    :questId2025-01-30 09:40:53.000f16fccd603ea0531a24060da2897e83d3945b9ce457146be8345567d08bafa4c1GB664P4XTBKNBK3YGPAFFCYPSW2SIO2FR6B6HC6SKFS7KGRTCDQYVUJ7TRUE10.25659941040.8269446XLM
    3
    :questId2025-01-30 17:39:57.000a84af8a6a2b7ba1ed401e3f4ca971c29c9ae1a5473572e130dcbf098ba7a6a4c1GDRFESYWFI6YGWRVMYFDXT577IPTBKFECNPDPKXQOR7PIQCC7XWZGPLVTRUE1253.4287563380.1856263XLM
    4
    :questId2025-01-30 20:38:36.000c6a6d52f7487bbd7ac4313c08c81e32b1b5defe2ab4f60557f86c144439f7c111GD2L6PGWP3N4ECS5SS25XBNDICADKRWKNH5RRG2LBXYB6JRTEA6KKMYBTRUE12913.2823520080.1856714XLM
    5
    :questId2025-01-30 09:44:35.0007f1a3ea41b66d76b5bad32b0286d6c5ae9692b0495d40dedc2d2ddf05dd819951GCXD4CC5JX3NTK3IX5CRK5HCED273TCFWPJBGM3NA5J5LGKIPNGRN2YITRUE10.0228652940.1912518XLM
    5
    1017B
    71s