Query editor
-- FSA headline KPIs in a single row. Designed to feed dashboard counters.-- All amounts in FXRP. Filter: paymentReference byte 01 ∈ {10} ∪ [32,51] (Portal ids; 52 Doppler is an outside app).---- Definitions:-- total_minted_fxrp = full FXRP supply issued via FSA (mintedAmountUBA + poolFeeUBA) / 1e6-- total_redeemed_fxrp = sum of AssetManager.RedemptionRequested per agent-ticket via FSA-tagged instructions-- total_deposited_fxrp= vault Deposit events tied to FSA instructions 32/33 (both vaults)-- withdraw_settled = FXRP actually transferred from vault contracts to FSA smart accounts-- (any settlement path), attributed to FSA by wallet ratio-- withdraw_pending = max(0, requested_shares - transferred / price) * share_price,-- attributed to FSA by wallet ratio-- mint_to_deposit_pct = total_deposited_fxrp / total_minted_fxrp-- idle_fxrp = max(0, total_minted_fxrp - total_deposited_fxrp - total_redeemed_fxrp)-- (minted FXRP that's neither in a vault nor redeemed → sitting in smart accounts)-- active_capital = total_deposited_fxrp - withdraw_settled - withdraw_pending-- net_fxrp_issuance = total_minted_fxrp - total_redeemed_fxrpWITH vault_meta AS (SELECT * FROM (VALUES(2, 0x373d7d201c8134d4a2f7b5c63560da217e3dea28),(3, 0x2439d4bb753a0f3777d4c9011afacc475ba6b951)) AS t(vault_id, vault_address)),fsa_instructions AS (SELECTie.evt_tx_hash,ie.evt_block_time,ie.personalAccount,ie.instructionId,ie.paymentReference,varbinary_to_uint256(varbinary_substring(ie.paymentReference, 2, 1)) AS wallet_idFROM fassets_flare.masteraccountcontroller_evt_instructionexecuted ieWHERE (varbinary_to_uint256(varbinary_substring(ie.paymentReference, 2, 1)) = 10 OR varbinary_to_uint256(varbinary_substring(ie.paymentReference, 2, 1)) BETWEEN 32 AND 51)),-- MINTminted AS (SELECT SUM(me.mintedAmountUBA + me.poolFeeUBA) / 1e6 AS total_minted_fxrpFROM fassets_flare.masteraccountcontroller_evt_collateralreserved crINNER JOIN fassets_flare.assetmanager_evt_mintingexecuted meON me.collateralReservationId = cr.collateralReservationIdWHERE (varbinary_to_uint256(varbinary_substring(cr.paymentReference, 2, 1)) = 10 OR varbinary_to_uint256(varbinary_substring(cr.paymentReference, 2, 1)) BETWEEN 32 AND 51)),-- REDEEMredeemed AS (SELECT SUM(r.valueUBA) / 1e6 AS total_redeemed_fxrpFROM fassets_flare.assetmanager_evt_redemptionrequested rINNER JOIN fsa_instructions fi ON fi.evt_tx_hash = r.evt_tx_hash AND fi.personalAccount = r.redeemer),-- DEPOSITfsa_deposit_instructions AS (SELECT * FROM fsa_instructions WHERE instructionId IN (32, 33)),deposits AS (SELECT SUM(amt) / 1e6 AS total_deposited_fxrp FROM (SELECT d.amountIn AS amt FROM fsa_deposit_instructions fiINNER JOIN upshift_flare.tokenized_vault_evt_deposit d ON d.evt_tx_hash = fi.evt_tx_hash