A 3,000-block survey of intents.near from our own node (350 outcomes, 1,026 legs) showed the referral leg is the user — per-quote implicit accounts, none on a solver — and that its own diff mirrors the rest of the outcome to within the protocol fee in all 576 amounts checked. So each taker leg is now its own trade, priced from what that user gave and got. It also showed the pooling rule counted solver routing as trading: in 45% of outcomes with a taker the solvers traded through a pair no taker touched, usually USDT on Ethereum, and each such leg on the tracked asset became a phantom trade against a token the user never saw. Two takers on one pair — an account round-tripping wNEAR, in the case captured — were merged into one trade with a nonsense price. Now an outcome with any taker yields only the takers' trades; only an outcome with no referral at all (solvers trading with each other) is pooled, as `kind: unattributed`, with no side. `kind` is stored (migration 0010, no re-scan: production held no QTC rows) and on the wire, and the panel says how many of a figure's trades were users'. Tests run on the three captured outcomes. Checked live against near.internal with wNEAR: 18 trades from 18 outcomes, every taker an implicit account, and no counter that was only a hop. Closes #30 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015pkwBsR54NRmZyU4QVhvfj
17 lines
986 B
SQL
17 lines
986 B
SQL
-- Whose trade an intents_trade row is: a taker's, or unattributed.
|
|
-- blackbeard/observer#30.
|
|
--
|
|
-- Rows written before this came from pooling every leg of a pair, which
|
|
-- double-counted solver hops and merged opposite trades. They are marked from
|
|
-- what they recorded — a side meant a single referral leg — but are NOT re-read:
|
|
-- production held no row of the tracked asset when this landed (QTC had no
|
|
-- supply on NEAR at all), so a cursor collapse would re-scan hours of empty
|
|
-- blocks to rebuild a table that is already correctly empty. An environment
|
|
-- that does hold old rows and wants them redone needs its own collapse, the
|
|
-- way 0008 did it for chain events.
|
|
alter table intents_trade add column kind text;
|
|
update intents_trade set kind = case when side is null then 'unattributed' else 'taker' end;
|
|
alter table intents_trade alter column kind set not null;
|
|
alter table intents_trade
|
|
add constraint intents_trade_kind check (kind in ('taker', 'unattributed'));
|