Pine AnalyticsLAIKA copy
    Updated 2024-11-02
    -- forked from LAIKA @ https://flipsidecrypto.xyz/studio/queries/ba5e8765-0df7-4940-abaf-a5c09258abb4

    with tab1 as (
    SELECT
    tx_id,
    signers
    FROM
    eclipse.core.fact_transactions t,
    TABLE(FLATTEN(log_messages)) f
    where
    value like 'Program log: INVARIANT: SWAP'
    and SUCCEEDED
    ),
    tab2 as (
    SELECT
    block_timestamp,
    a.tx_id as tx_out,
    signers [0] as wallet_out,
    mint as mint_out,
    case
    when mint in (
    'So11111111111111111111111111111111111111112',
    'Eth1111111111111111111111111111111111111111'
    ) then 'ETH'
    when mint like 'AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE' then 'USDC'
    when mint like '841P4tebEgNux2jaWSjCoi9LhrVr9eHGjLc758Va3RPH' then 'WIF'
    when mint like 'BeRUj3h7BqkbdfFU7FBNYbodgf8GCHodzKvF9aVjNNfL' then 'SOL'
    when mint like 'GU7NS9xCwgNPiAdJ69iusFrRfawjDDPjeMBovhV1d4kn' then 'tETH'
    when mint like 'LaihKXA47apnS599tyEyasY2REfEzBNe4heunANhsMx' then 'LAIKA'
    when mint like 'trbts2EsWyMdnCjsHUFBKLtgudmBD7Rfbz8zCg1s4EK' then 'Turbo'
    else 'Other'
    end as token_out,
    amount as amount_out,
    decimal as decimal_out
    FROM
    eclipse.core.fact_transfers as a