Query editor
withbase as (SELECTblock_time, bytearray_ltrim(topic1) as user, bytearray_ltrim(topic2) as token, cast(bytearray_to_int256(bytearray_ltrim(bytearray_substring(data, 1, 32))) as DOUBLE) as supplied_amount, cast(bytearray_to_int256(bytearray_ltrim(bytearray_substring(data, 1 + 32, 32))) as DOUBLE) as borrowed_amount, bytearray_ltrim(bytearray_substring(data, 1 + 64, 32)) as withdraw_to, bytearray_ltrim(bytearray_substring(data, 1 + 96, 32)) as borrow_to, varbinary_to_uint256(bytearray_substring(data, 1 + 128, 32)) as total_amounts, varbinary_to_uint256(bytearray_substring(data, 1 + 160, 32)) as exchange_prices_and_config, data, tx_hashfrom base.logs--where tx_hash = 0xbbb92ea0f390ffec1fc5832ea8f204f05cbcdfb1c75ce1936b84b298e093547a --example tx--where contract_address = 0x52Ef3F34aE6Ed1B4B5044ee7Dc2b929461736254 --liquidity layerwhere contract_address = 0x52Aa899454998Be5b000Ad077a46Bbe360F4e497 --liquidity layerand topic0 = 0x4d93b232a24e82b284ced7461bf4deacffe66759d5c24513e6f29e571ad78d15 --LogOperate)SELECTblock_time as date, user, token, supplied_amount, borrowed_amount, withdraw_to, borrow_to--, total_amounts--, exchange_prices_and_config, CAST((-- Extract supplyExchangePrice and convert BigMath compressed value to normal numberbitwise_and(bitwise_right_shift(exchange_prices_and_config, 91),varbinary_to_uint256(0xFFFFFFFFFFFFFFFF) --64bits) -- / 1e12) AS DOUBLE) AS supply_exchange_price,CAST((-- Extract borrowExchangePrice and convert BigMath compressed value to normal numberbitwise_and(bitwise_right_shift(exchange_prices_and_config, 155),varbinary_to_uint256(0xFFFFFFFFFFFFFFFF) --64bits) -- / 1e12) AS DOUBLE) AS borrow_exchange_price, (bitwise_and(bitwise_right_shift(exchange_prices_and_config, 0),varbinary_to_uint256(0xFFFF) --16bits) / 1e2 / 1e2) AS borrow_rate, (bitwise_and(bitwise_right_shift(exchange_prices_and_config, 16),varbinary_to_uint256(0x3FFF) --14bits) / 1e2 / 1e2) AS fee, (bitwise_and(bitwise_right_shift(exchange_prices_and_config, 30),