Query editor
WITH px AS (SELECT CAST(timestamp AS date) AS day, AVG(price) AS xrp_usdFROM prices.day WHERE symbol='XRP' AND blockchain='bnb' AND source='coinpaprika' AND timestamp >= TIMESTAMP '2023-01-01' GROUP BY 1),gold_px AS (SELECT CAST(minute AS DATE) AS day, AVG(price)/31.1034768 AS usd_per_gramFROM prices.usdWHERE blockchain='ethereum'AND contract_address=0x45804880de22913dafe09f4980848ece6ecbaf78AND minute >= TIMESTAMP '2023-01-01'GROUP BY 1),tok_px AS (SELECT cur, iss, day, AVG(price_xrp) AS price_xrp FROM (SELECT base_token_currency AS cur, base_token_issuer AS iss, ledger_close_date AS day, vwap_price AS price_xrpFROM xrpl.dex_ohlcv_daily WHERE counter_token_currency='XRP' AND vwap_price>0 AND ledger_close_date>=DATE '2023-01-01'UNION ALLSELECT counter_token_currency, counter_token_issuer, ledger_close_date, 1.0/NULLIF(vwap_price,0)FROM xrpl.dex_ohlcv_daily WHERE base_token_currency='XRP' AND vwap_price>0 AND ledger_close_date>=DATE '2023-01-01') GROUP BY 1,2,3),mpt_iss AS (-- Agrify carbon-credit MPTs. MPTokenIssuanceID = issuer sequence (4-byte hex) || issuer AccountID (20-byte hex);-- the AccountID of rLKfWwLeimLe69mrTr3MygNavDxL8tjuUX is D3D74E31D901BBC29F79AAA07911B0274AFA9CE9.-- Face value of the issuance = tonnes x USD per tonne, both declared by the issuer in the on-chain metadata-- (availableTonnes x pricePerTonne for pre-issuance credits, retiredTonnes x artefactPrice for retired ones).-- MPTs cannot exist before the MPTokensV1 amendment (2025), hence the tighter date bound.SELECT mpt_id,TRY_CAST(regexp_extract(metadata, '"(availableTonnes|retiredTonnes)"\s*:\s*"\s*([0-9]+(\.[0-9]+)?)', 2) AS DOUBLE)* TRY_CAST(regexp_extract(metadata, '"(pricePerTonne|artefactPrice)"\s*:\s*"\$?\s*(-?[0-9]+(\.[0-9]+)?)', 2) AS DOUBLE) AS face_value_usdFROM (SELECT upper(lpad(to_base(sequence,16),8,'0')) || 'D3D74E31D901BBC29F79AAA07911B0274AFA9CE9' AS mpt_id,from_utf8(from_hex(mptokenmetadata)) AS metadataFROM xrpl.transactionsWHERE ledger_close_date >= DATE '2025-01-01' AND transaction_type='MPTokenIssuanceCreate' AND result='tesSUCCESS'AND account='rLKfWwLeimLe69mrTr3MygNavDxL8tjuUX')-- test issuances (project name / id / farmer containing "test") are never countedWHERE NOT regexp_like(lower(metadata), '"(projectname|projectid|farmer)"\s*:\s*"[^"]*test')-- Excluded pending confirmation that the 2025-12-02 Releaf transaction was a real commercial deal.AND mpt_id <> '05FC5D4AD3D74E31D901BBC29F79AAA07911B0274AFA9CE9'),mpt_val AS (-- each MPT transfer carrying the Agrify source tag (done through the app) adds the full face value of the-- credit it moves, including issuer mint Payments; untagged transfers and issuance creation / authorization / destruction stay at 0SELECT t.hash AS transaction_hash, i.face_value_usd AS usdFROM xrpl.transactions tJOIN mpt_iss i ON i.mpt_id = t.amount.mpt_issuance_idWHERE t.ledger_close_date >= DATE '2025-01-01' AND t.transaction_type='Payment' AND t.result='tesSUCCESS'AND t.amount.mpt_issuance_id IS NOT NULL AND t.source_tag = 701681681 AND i.face_value_usd > 0),ours AS (SELECT CAST(t.source_tag AS bigint) AS source_tag, t.name AS project, c.cohortFROM (SELECT name, wallet_address, CAST(source_tag AS bigint) AS source_tag, use_case, signing_date, start_date, is_active, tx_vol, vmt_usdFROM dune.xrpl_commons.dataset_xrpl_commons_tracking_sheetWHERE CAST(source_tag AS bigint) IS DISTINCT FROM BIGINT '744925538'AND LOWER(TRIM(name)) IS DISTINCT FROM 'phiwallet'UNION ALLSELECT * FROM (VALUES