Query editor
-- indices: latest realized weight composition of the V2 stock basket, one row per asset,-- USDGBuyerDistributorV2 (0x39ADB8acD07427D338b5f1AfAb436A04AbFdB7c4, discovered-- docs/research/2026-08-05-indices-contracts.md, board_decision "board9").---- No on-chain event or config carries an explicit target weight: StockAdded(address token,-- uint24 fee, int24 tickSpacing, address hooks) has no weight field (verified against the-- contract's full verified ABI on Blockscout, 2026-08-06), and the brief's assumed "target-- weights from creation/config events" do not exist for this product. This query reports the-- closest verifiable proxy instead: REALIZED weight, i.e. each stock's share of USDG actually-- spent buying it in the most recent completed round (bounded by the next round's start) (see-- sql/indices_b_treasury_buys.sql for the round derivation and its RialtoBought/CycleStarted-- topic0 verification). This is a revealed weight from real spend, not a declared target, and-- is disclosed as such rather than invented; basket_weight_pct is on a 0-100 percentage scale-- and sums to approximately 100 across the round's rows.---- Completed-round bound, fixed 2026-08-06: an earlier version filtered buys from the latest-- CycleStarted with no upper bound, so a round still filling (accumulating buys, not yet-- superseded by the next CycleStarted) would be reported as "completed" while incomplete. This-- query now finds the most recent cycle that HAS a subsequent CycleStarted and bounds the buy-- window to [cycle_start_N, cycle_start_N+1), guaranteeing the round it reports is fully closed.---- Asset identity: RialtoBought's indexed stockIndex is a raw array position into the contract's-- internal `stocks` array, not a token address. This query reconstructs the index-to-token-- mapping from StockAdded's insertion order (row_number() over event order: block_time, log-- index), then verifies rather than assumes it: the contract has zero StockRemoved events on a-- live topic0 count (checked 2026-08-06), so the array has never been mutated after construction-- and insertion order equals the live index deterministically. Three of the eighteen resolved-- addresses independently match already-verified addresses in docs/notes/robinhood-schema.md-- section 12 (AAPL at index 1, SPCX at index 14, TSLA at index 17), cross-confirming the mapping.---- Data-start caveat: this product is new. USDGBuyerDistributorV2 first_tx 2026-07-28 19:40:13 UTC-- (Task 2's JSON); event coverage cannot predate that deploy. StockTreasury (V1) is excluded here-- for a harder reason than scope: its StocksBought event carries only an aggregate-- (ethSpent, stockCount) with no per-stock breakdown at all, so no per-asset weight is derivable-- from its events under any methodology, not just this one.-- last verified 2026-08-06with stock_roster as (selectrow_number() over (order by block_time asc, index asc) - 1 as stock_index,bytearray_substring(topic1, 13, 20) as token_addrfrom robinhood.logswhere contract_address = 0x39ADB8acD07427D338b5f1AfAb436A04AbFdB7c4and topic0 = 0xa9d5de5dbe859707133f119258028e1bc0529fc5821f001509854acf735bb4a7),cycles as (select block_time as cycle_startfrom robinhood.logswhere contract_address = 0x39ADB8acD07427D338b5f1AfAb436A04AbFdB7c4and topic0 = 0x0e41c903d4f464af8fdd82a2a195fb81a5b17cfe3a20585d2f10d0eeb1f1d33c),cycles_bounded as (selectcycle_start,lead(cycle_start) over (order by cycle_start asc) as next_cycle_startfrom cycles),latest_completed_cycle as (select cycle_start, next_cycle_startfrom cycles_boundedwhere next_cycle_start is not null