Kruys-CollinsArbitrum Vault Token Prices copy
    Updated 2024-11-07
    WITH token_list AS (
    SELECT column1 as t_address, LOWER(column2) as symbol
    FROM VALUES
    ('0xd4d42f0b6def4ce0383636770ef773390d85c61a', 'sushi'),
    ('0x82af49447d8a07e3bd95bd0d56f35241523fbab1', 'weth'),
    ('0x3e6648c5a70a150a88bce65f4ad4d506fe15d2af', 'spell'),
    ('0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a', 'mim'),
    ('0x8d9ba570d6cb60c7e3e0f31343efe75ab8e65fb1', 'gohm'),
    ('0xeb4c2781e4eba804ce9a9803c67d0893436bb27d', 'renbtc'),
    ('0xaf88d065e77c8cC2239327C5EDb3A432268e5831', 'usdc'),
    ('0xB1F1ee126e9c96231Cc3d3fAD7C08b4cf873b1f1', 'bifi'),
    ('0x7f90122bf0700f9e7e1f688fe926940e8839f353', '2crv'),
    ('0x539bdE0d7Dbd336b79148AA742883198BBF60342', 'magic'),
    ('0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f', 'wbtc'),
    ('0xf97f4df75117a78c1A5a0DBb814Af92458539FB4', 'link'),
    ('0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', 'usdt'),
    ('0xdd1a646123855564af8e44812c2cdb1f485412de', 'tricrypto')
    ),
    latest_prices AS (
    -- Arbitrum swaps
    SELECT
    token_in as token_address,
    token_out as token_address_out,
    LOWER(symbol_in) as symbol,
    LOWER(symbol_out) as symbol_out,
    block_timestamp,
    CASE
    WHEN amount_in > 0 AND amount_in_usd IS NOT NULL THEN amount_in_usd/amount_in
    WHEN amount_in > 0 AND amount_out_usd IS NOT NULL THEN amount_out_usd/amount_out * (amount_out/amount_in)
    ELSE NULL
    END as price_from_in,
    CASE
    WHEN amount_out > 0 AND amount_out_usd IS NOT NULL THEN amount_out_usd/amount_out
    WHEN amount_out > 0 AND amount_in_usd IS NOT NULL THEN amount_in_usd/amount_in * (amount_in/amount_out)
    ELSE NULL
    END as price_from_out,
    QueryRunArchived: QueryRun has been archived