freemartian2023-12-31 06:06 PM
    Updated 2024-01-01
    with create_remove AS (
    SELECT
    block_timestamp,
    tx_id,
    msg_type,
    msg:attributes[1]:value AS position_id,
    msg:attributes[2]:value AS sender,
    msg:attributes[3]:value AS pool_id,
    (msg:attributes[8]:value)/pow(10,6) AS amount1,
    (msg:attributes[9]:value)/pow(10,6) AS amount2
    FROM osmosis.core.fact_msgs
    WHERE msg:attributes[3]:value IN ('1325','1337')
    AND tx_succeeded
    ),
    add AS (
    SELECT
    msgs.block_timestamp,
    msgs.tx_id,
    'add_position' AS msg_type,
    msg:position_id AS position_id,
    msg:sender AS sender,
    pool_id,
    (msg:amount0)/pow(10,6) AS amount1,
    (msg:amount1)/pow(10,6) AS amount2
    FROM osmosis.core.fact_tx_body_msgs msgs
    INNER JOIN create_remove ON create_remove.position_id = msgs.msg:position_id
    WHERE msgs.msg_type = '/osmosis.concentratedliquidity.v1beta1.MsgAddToPosition'
    AND tx_succeeded
    ),

    final AS (
    SELECT * FROM create_remove
    UNION
    SELECT * FROM add
    QueryRunArchived: QueryRun has been archived