Query editor
with total_liq as (SELECT cast(value as DOUBLE) / 1e18 as value FROM erc20_arbitrum.evt_Transferwhere contract_address = 0x3082cc23568ea640225c2467653db90e9250aaa0and to = 0xBA12222222228d8Ba445958a75a0704d566BF2C8),liq as(SELECT cast(value as DOUBLE) / 1e18 as value FROM erc20_arbitrum.evt_Transferwhere contract_address = 0x3082cc23568ea640225c2467653db90e9250aaa0and "from" = 0xBA12222222228d8Ba445958a75a0704d566BF2C8),rdnt_price as (SELECT sum(cast(amount_usd as DOUBLE)) / sum(cast(token_bought_amount_raw as DOUBLE) / 1e18) as price from dex.tradeswhere token_bought_address = 0x3082CC23568eA640225c2467653dB90e9250AaA0and block_time > now() - interval '2' hourand cast(amount_usd as DOUBLE) > 0),balancer_rdnt as (SELECT sum(value) - (SELECT sum(value) from liq) as rdnt FROM total_liq),minted_dlp as (SELECT cast(value as DOUBLE) / 1e18 as value FROM erc20_arbitrum.evt_Transferwhere contract_address = 0x32dF62dc3aEd2cD6224193052Ce665DC18165841and "from" = 0x0000000000000000000000000000000000000000UNIONSELECT -cast(value as DOUBLE) / 1e18 as value FROM erc20_arbitrum.evt_Transferwhere contract_address = 0x32dF62dc3aEd2cD6224193052Ce665DC18165841and "to" = 0x0000000000000000000000000000000000000000)-- dlp price = rdnt liq * 1.25 * rdnt_price / dlp_minted,dlp_price as (SELECT 1.25 * price * (SELECT rdnt FROM balancer_rdnt) / (SELECT sum(value) FROM minted_dlp) as price from rdnt_price),compiled as (SELECT call_tx_hash, cast(amount as DOUBLE)/ 1e18 as amount,call_block_time as date_locked, cast(typeIndex as INTEGER) as lock_duration, cast(onBehalfOf as VARCHAR) as locker FROM bayestheorem2_arbitrum.MultiFeeDistribution_call_stakewhere call_success = true),locking as (SELECT amount,cast(call_tx_hash as VARCHAR) as hash,case when lock_duration = 3 thendate_locked + INTERVAL '12' MONTHwhen lock_duration = 2 thendate_locked + INTERVAL '6' MONTHwhen lock_duration = 1 thendate_locked + INTERVAL '3' MONTHwhen lock_duration = 0 thendate_locked + interval '1' MONTH end as locked_till,date_locked,locker FROM compiled)SELECT amount, amount * (SELECT price from dlp_price), date_locked, locked_till, locker, '<a href=https://debank.com/profile/' || locker || ' target=_blank>Debank</a>' as Debank,'<a href=https://arbiscan.io/tx/' || cast(hash as varchar) || ' target=_blank>tx_hash</a>' as tx_hashfrom locking