jp12104 [SUSHI] Celsius Sushi - Add & Remove Liquidity
Updated 2022-07-13Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
›
⌄
WITH wallets as (
SELECT *
FROM flipside_prod_db.crosschain.address_labels
WHERE ADDRESS_NAME = 'celsius wallet'
)
SELECT 'Added' as type, block_timestamp::date as date, POOL_NAME, origin_from_address, tx_hash, 2 * AVG(amount) as amount, 2 * AVG(amount_usd) as amount_usd
FROM ethereum.core.ez_token_transfers t LEFT JOIN ethereum.core.dim_dex_liquidity_pools l ON t.to_address = l.pool_address
WHERE ORIGIN_TO_ADDRESS = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f' and origin_function_signature IN ('0xe8e33700', '0xf305d719')
and origin_from_address IN (SELECT ADDRESS FROM wallets) and AMOUNT_USD IS NOT NULL
GROUP BY date, POOL_NAME, origin_from_address, tx_hash
UNION
SELECT 'Removed' as type, date, pool_name, origin_from_address, tx_hash, -2 * AVG(amount) as amount, -2 * AVG(amount_usd) as amount_usd
FROM (
SELECT block_timestamp::date as date, POOL_NAME, origin_from_address, tx_hash, symbol, MAX(amount) as amount, MAX(amount_usd) as amount_usd
FROM ethereum.core.ez_token_transfers t LEFT JOIN ethereum.core.dim_dex_liquidity_pools l ON t.from_address = l.pool_address
WHERE ORIGIN_TO_ADDRESS = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f' and origin_function_signature IN ('0x2195995c', '0xded9382a')
and origin_from_address IN (SELECT ADDRESS FROM wallets) and AMOUNT_USD IS NOT NULL
GROUP BY date, POOL_NAME, origin_from_address, tx_hash, symbol
)
GROUP BY date, POOL_NAME, origin_from_address, tx_hash
Run a query to Download Data