0xHaM-dPlatform Users
    Updated 2024-04-14
    -- forked from Platform Users @ https://flipsidecrypto.xyz/edit/queries/0cfa50b7-09d8-479f-91f7-20230e39cc6d

    -- forked from Playwo / Platform Users @ https://flipsidecrypto.xyz/Playwo/q/nezppud5x8qs/platform-users

    WITH timeframe AS (
    SELECT date_day AS date
    FROM crosschain.core.dim_dates
    WHERE date_day >= TO_DATE('{{start_date}}')
    AND date_day < CURRENT_DATE()
    ),
    levana_contracts AS (
    SELECT $1 AS contract_address, $2 AS asset, $3 AS asset_decimals
    FROM (VALUES
    ('sei1jvl8avv45sj92q9x9c84fq2ymddya6dkwv9euf7y365tkzma38zq5xldpy', 'ETH', 6),
    ('sei1zjryrejvtufeaaer7w55fxgxurqnajwlshdpuqf5lp4j00uzek8s6sktv3', 'ETH', 6),
    ('sei1rl9z38s9t853jddjfexxkqqpq5d5wpzrqudfg7ruchzymxhms7pq39j645', 'ETH', 6),
    ('sei14j7zhcj50qsk6vhu7dsa48r5e7v37nthnwwx0q8q4nd0h39udy6qhqq6dm','SEI', 6),
    ('sei1tasaxmw8axfmcmzg2m9zp24msuurfkz3m44mga2dl98eh0txcxjspw9rga','BTC', 6),
    ('sei1teg8l8lanhkdxcdffg9anrzt3hhv9d8967ajczlrq3lzdrkzczsskh6733','SOL', 6)
    )
    ),
    open_position_events AS (
    SELECT
    a__contract_address.tx_id,
    a__contract_address.block_timestamp,
    a__contract_address.attribute_value AS contract,
    a_pos_owner.attribute_value AS user,
    a_deposit_collateral.attribute_value AS collateral,
    a_deposit_collateral_usd.attribute_value AS collateral_usd,
    a_direction.attribute_value AS direction,
    a_notional_size.attribute_value AS notional_size
    FROM
    sei.core.fact_msg_attributes AS a__contract_address,
    sei.core.fact_msg_attributes AS a_pos_owner,
    sei.core.fact_msg_attributes AS a_deposit_collateral,
    sei.core.fact_msg_attributes AS a_deposit_collateral_usd,
    QueryRunArchived: QueryRun has been archived