csp88gREF LP Stables calc
    Updated 2025-03-13
    with tokens_in_bot as(
    select
    SPLIT_PART(ACTION_DATA:args:pair_id, ':', 1) as t1,
    SPLIT_PART(ACTION_DATA:args:pair_id, ':', 2) as t2,
    from near.core.ez_actions
    where TX_HASH = 'EnXjXKa8yWtzXrKHbKVZ6M4Ahsx3YCKgmQdRVrp6FbJq'
    and RECEIPT_RECEIVER_ID = 'grid.deltatrade.near'
    )

    select
    ACTION_DATA:args:name as name,
    ACTION_DATA:args:first_base_amount / POW(10,18) as test,
    ACTION_DATA:args:first_base_amount / POW(10,
    (select decimals from near.core.dim_ft_contract_metadata
    where CONTRACT_ADDRESS = (select t1 from tokens_in_bot))
    ) as Deposited_Token_amount,

    (ACTION_DATA:args:last_quote_amount
    / POW(10,
    (select decimals from near.core.dim_ft_contract_metadata
    where CONTRACT_ADDRESS = (select t2 from tokens_in_bot))))
    / (ACTION_DATA:args:last_base_amount / POW(10,
    (select decimals from near.core.dim_ft_contract_metadata
    where CONTRACT_ADDRESS = (select t1 from tokens_in_bot))
    ))
    as sell_price,

    (ACTION_DATA:args:first_quote_amount
    / POW(10,
    (select decimals from near.core.dim_ft_contract_metadata
    where CONTRACT_ADDRESS = (select t2 from tokens_in_bot))))
    / (ACTION_DATA:args:first_base_amount / POW(10,
    (select decimals from near.core.dim_ft_contract_metadata
    where CONTRACT_ADDRESS = (select t1 from tokens_in_bot))
    ))
    as buy_price,
    Last run: 3 months ago
    NAME
    TEST
    DEPOSITED_TOKEN_AMOUNT
    SELL_PRICE
    BUY_PRICE
    ACTION_DATA
    1
    [swing]BRR#1-2
    2227282227280.0028710000040.00235
    {"args":{"entry_price":"2720124960000000","fill_base_or_quote":true,"fir...
    1
    741B
    6s