#39 item 4, as replaced: the original check (intents.near's balance against indexed events) could not see the trades it was for, because a trade moves QTC inside intents.near and leaves its total alone. What the balance does move with is deposits and withdrawals, so that is what is recorded. `intentsflow` reads intents.near's `ft_balance_of` on qtc.omft.near at every NEAR block from gargravarr, which tracks the token's shard, forward to its final block and back to the oldest it holds, and records each change (migration 0015). `view_at` treats only UNKNOWN_BLOCK as a skipped height: a garbage-collected block is an error, never "nothing changed". `/v1/chains/{chain}/intents/flows` sums deposits and withdrawals over a span; the NEAR Intents market page shows it after the bridge. Verified on the live chain through a tunnel to gargravarr: the scan's balance at #218,805,000 (36,044.097 QTC) and at #218,811,064 (72,671.542) match direct reads, and across 1,044 rows every balance less its change is the previous balance. Refs #39 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015pkwBsR54NRmZyU4QVhvfj
24 lines
1.1 KiB
SQL
24 lines
1.1 KiB
SQL
-- QTC moving into and out of NEAR Intents, block by block.
|
|
-- blackbeard/observer#39, item 4 as replaced on 2026-10-06.
|
|
--
|
|
-- intents.near's own balance of the token, read at every NEAR block from a
|
|
-- node tracking the token's shard, and recorded only where it changed. A rise
|
|
-- is the token deposited into NEAR Intents, a fall the token withdrawn. Trades
|
|
-- never appear here: they move balances between accounts inside intents.near
|
|
-- and leave its total untouched, which is why this cannot measure the trades
|
|
-- the relay scan misses, only the money arriving and leaving.
|
|
--
|
|
-- Exact for what it is, and blind to who: a deposit and a withdrawal in the
|
|
-- same block net to one row. Amounts are base units.
|
|
create table intents_flow (
|
|
chain text not null references chain (id) on delete cascade,
|
|
asset text not null,
|
|
near_height bigint not null,
|
|
at timestamptz not null,
|
|
-- intents.near's balance after this block.
|
|
balance numeric not null,
|
|
-- Its change from the block before: positive in, negative out.
|
|
delta numeric not null,
|
|
primary key (chain, asset, near_height)
|
|
);
|