Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add create and withdraw queries #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cl/cl_create_position.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
select
cl.tx_id,
cl.block_timestamp,
cl.sender,
cl.pool_id,
cl.position_id,
cast(cl.amount_asset_1 as numeric)/1000000 as osmo_amount,
cast(cl.amount_asset_1 as numeric)/1000000*p.price_in_usdc as osmo_amount_usd,
cast(cl.amount_asset_2 as numeric)/1000000000000000000 as dai_amount,
cast(upper_tick as numeric) as upper_tick,
cast(lower_tick as numeric) as lower_tick,
cast(upper_tick as numeric) - cast(lower_tick as numeric) as liquidity_range,
case when mp.tx_id is null then 'created_position' else 'migrated_position' end as type
from `numia-data.osmosis.osmosis_create_position` cl
inner join `numia-data.osmosis.osmosis_osmo_price` p on date_trunc(p.time_minutes, minute) = date_trunc(cl.block_timestamp, minute)
left join `numia-data.osmosis.osmosis_migrate_to_position` mp on mp.tx_id = cl.tx_id and cl.message_index = mp.message_index
where cl.pool_id = '1314'
order by cl.block_timestamp desc
17 changes: 17 additions & 0 deletions cl/cl_withdraw_position.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
select
cl.tx_id,
cl.block_timestamp,
cl.sender,
cl.pool_id,
cl.position_id,
cast(cl.amount_asset_1 as numeric)/1000000 as osmo_amount,
cast(cl.amount_asset_1 as numeric)/1000000*p.price_in_usdc as osmo_amount_usd,
cast(cl.amount_asset_2 as numeric)/1000000000000000000 as dai_amount,
cast(upper_tick as numeric) as upper_tick,
cast(lower_tick as numeric) as lower_tick,
cast(upper_tick as numeric) - cast(lower_tick as numeric) as liquidity_range,
'removed_liquidity'
from `numia-data.osmosis.osmosis_withdraw_position` cl
inner join `numia-data.osmosis.osmosis_osmo_price` p on date_trunc(p.time_minutes, minute) = date_trunc(cl.block_timestamp, minute)
where cl.pool_id = '1314'
order by cl.block_timestamp desc