Query editor
select bond_time as block_time ,bonder as userfrom(WITHmarkets AS (SELECTevt_block_time,id,initialPrice,payoutToken,quoteToken,vestingFROM bondprotocol_arbitrum.BondFixedTermSDA_evt_MarketCreated),bonds AS (SELECTb.evt_block_time,b.evt_tx_hash,b.id,CAST(b.amount AS DOUBLE) AS amount,CAST(b.payout AS DOUBLE) AS payout,s.to AS bonderFROM bondprotocol_arbitrum.BondFixedTermTeller_evt_Bonded bLEFT JOIN bondprotocol_arbitrum.BondFixedTermTeller_evt_TransferSingle sON s.evt_tx_hash = b.evt_tx_hash),token_decimals AS (SELECTcontract_address,symbol,decimalsFROM tokens.erc20WHERE blockchain = 'arbitrum'UNION ALLSELECT0xdc132116a76683f5355042e1b67819551aaf34e5 AS contract_address,'xGRAIL' AS symbol,18 AS decimals),bonding_raw AS (-- Raw table before pricing logicSELECTb.evt_block_time AS bond_time,b.id,b.bonder,b.amount / POWER(10, dq.decimals) AS quoteAmount,b.payout / POWER(10, dp.decimals) AS payoutAmount,m.quoteToken,m.payoutToken,dq.symbol AS quoteSymbol,dp.symbol AS payoutSymbol,m.vesting AS vesting_duration,DATE_ADD('second', m.vesting, b.evt_block_time) AS vesting_endtime,(b.amount / POWER(10, dq.decimals)) / (b.payout / POWER(10, dp.decimals)) AS bondRatio,evt_tx_hashFROM bonds bINNER JOIN markets m ON b.id = m.idLEFT JOIN token_decimals dq ON m.quoteToken = dq.contract_addressLEFT JOIN token_decimals dp ON m.payoutToken = dp.contract_address),paprika_prices AS (