QTC's real price is whatever intents.near settles; index those swaps instead of trusting quotes #27

Closed
opened 2026-10-02 22:11:39 +00:00 by grenade · 5 comments
Owner

Why

Swaps are now live in the Quantus wallet, and NEAR Intents (near.com) is QTC's launch venue. The only other market is SafeTrade, a small exchange that requires KYC. Its CoinGecko ticker shows a 3.1% bid/ask spread, and you can't count on getting coins out of it, so its price is not a reliable reference.

The observer already indexes the Quantus side of every swap. A deposit to a 1Click deposit address is an ordinary Balances::transfer on our chain. What it can't see is the NEAR side, where the trade is actually settled and priced.

NEAR Intents has no pool, oracle or price stored in any contract. intents.near is a settlement contract: solvers and users sign token_diff intents, and the contract executes them atomically. A price exists only as the ratio between amounts in trades that have actually settled, so that is what we should index. 1Click's /v0/quote is an off-chain offer, not a trade, and is out of scope (see below).

State on NEAR at time of writing (block ~218,261,850)

  • qtc.omft.near is deployed. ft_metadata returns {"symbol":"QTC","name":"Quantus","decimals":12}. That's the same decimals as our chain, so amounts map 1:1 in base units.
  • No QTC has been bridged yet. ft_total_supply is "0" and ft_balance_of({"account_id":"intents.near"}) is "0".
  • The asset ID is nep141:qtc.omft.near. Inside intents.near this is the multi-token ID, and it matches the placeholder in the Quantus wallet (AppConstants.quantusIntentsAssetId, quantus-apps PRs #664 and #675).
  • QTC isn't in the public 1Click token list (/v0/tokens, 202 assets) even though the wallet swaps. That's another reason not to rely on 1Click for discovery.

Mechanisms that observe actual swaps

1. Settlement events from intents.near (the price)

Every executed intent logs NEP-297 events, EVENT_JSON:{…}, in the receipt outcome. I checked these on mainnet tx 85uy9uCFfW4htmj2DLq2FbBmGRkVr34vHNz239e8yB2V (block 218,261,895, a ZEC→TRON swap):

{"standard":"dip4","version":"0.4.3","event":"token_diff","data":[{"intent_hash":"812iSW…","account_id":"blockzen-1-main.near",
  "diff":{"nep141:tron-d28a…omft.near":"9036290963","nep141:zec.omft.near":"-702585891"},"fees_collected":{"nep141:zec.omft.near":"703"}}]}
{"standard":"dip4","version":"0.4.3","event":"token_diff","data":[{"intent_hash":"GZEag3…","account_id":"42f3f216…178171",
  "diff":{"nep141:tron-d28a…omft.near":"-9036300000","nep141:zec.omft.near":"702585188"},"referral":"1click-swapkit","fees_collected":{…}}]}
{"standard":"dip4","event":"transfer", …}            fee and app-fee payouts
{"standard":"dip4","event":"ft_withdraw", …}         the user's payout leaving Intents for the destination chain
{"standard":"dip4","event":"intents_executed","data":[{intent_hash, account_id, nonce}, …]}
{"standard":"nep245","event":"mt_transfer" | "mt_burn", …}
  • A swap is two token_diff entries with opposite signs: the solver's and the user's. The user's side is the one with referral (here 1click-swapkit; the Quantus wallet will presumably set its own), and its account_id is a 64-character hex implicit account. The solver's side has a named account, e.g. blockzen-1-main.near.
  • Price = |counter amount| / |QTC amount|, each scaled by its token's decimals. Read decimals from the counter token's own ft_metadata, on-chain, and cache them.
  • Direction: the user's sign on nep141:qtc.omft.near says whether QTC was sold (negative) or bought (positive).
  • Fees: fees_collected is the protocol fee. App and partner fees appear as transfer events. Store both, so prices can be reported with and without fees.
  • Only trust executed intents. A tx can include intents that fail, so treat a token_diff as a trade only when its intent_hash also appears in intents_executed in the same outcome.

2. Bridge mints and burns (liquidity, and a cross-check)

  • QTC enters NEAR when the bridge mints qtc.omft.near to intents.near after a deposit on our chain. Expect nep141 ft_mint and nep245 mt_mint events. I couldn't confirm this until the first QTC deposit lands; supply is 0 today.
  • QTC leaves NEAR through a dip4 ft_withdraw (token: "qtc.omft.near") plus an mt_burn, then a payout transfer on our chain from the bridge's Quantus wallet. The ZEC example withdrew through omni.bridge.near (InitTransferEvent). Which bridge QTC uses (omft/POA vs omni) still needs confirming.
  • Cross-check: qtc.omft.near ft_total_supply should equal the bridge's QTC custody on Quantus. That needs us to identify the bridge's Quantus addresses: deposit addresses sweep into custody, and custody pays out withdrawals. Both are ordinary transfers we already index. This would give a "QTC inside NEAR Intents" figure that can be verified from both chains.
  • Cheap views for an "available liquidity" figure:
    • ft_balance_of(intents.near) on qtc.omft.near
    • mt_balance_of({account_id, token_id:"nep141:qtc.omft.near"}) on intents.near, for solver accounts seen in token_diff

3. Following intents.near in real time

Option A: NEAR RPC only, no third-party indexer. This is what I prototyped.

  1. Find intents.near's shard from EXPERIMENTAL_protocol_config.shard_layout. Today that's layout V3 with boundaries [650, aurora, aurora-0, earn.kaiching, game.hot.tg, game.hot.tg-0, kkuuue2akv_1630967379.near, tge-lockup.sweat, wallet.ka] and shard IDs [10, 11, 1, 8, 9, 6, 7, 4, 12, 13], so intents.near is in range index 6, shard 7. Recompute whenever the layout changes; resharding renumbers shards.
  2. Per block, call chunk {block_id, shard_id}. Keep transactions with receiver_id == "intents.near" and a FunctionCall to execute_intents; the relay signs these as intents.near itself. Pre-filter on the base64-decoded args containing qtc.omft.near; the signed payloads carry the diffs in plain text. Deduplicate by chunk_hash, because a block with no new chunk for the shard returns the previous one.
  3. For matching transactions only, call EXPERIMENTAL_tx_status {tx_hash, sender_account_id, wait_until: "EXECUTED"} and parse the EVENT_JSON logs from receipts_outcome.

Measured: mainnet produces about 1.69 blocks/s. rpc.mainnet.fastnear.com served 11.4 chunk calls/s sequentially without errors, so one call per block keeps up with plenty of headroom. In 40 blocks there were 2 execute_intents transactions across all assets.

Gap: this only sees execute_intents arriving as top-level transactions. Intents reaching the contract any other way, as receipts from cross-contract calls such as mt_transfer_call / ft_transfer_call with a message, would be missed. To catch those, also scan chunk.receipts for receiver_id == "intents.near" and fetch their outcomes.

Option B: block-with-outcomes feeds. FastNEAR's neardata (mainnet.neardata.xyz/v0/block/<height>) returns every shard's receipts and execution outcomes with logs in one request, and is archival, which makes backfill easy. NEAR Lake (S3, requester pays) is the canonical bulk equivalent. Either removes the transaction-vs-receipt gap. It's still raw chain data, just not served by a node we run.

Option C: our own NEAR RPC node. Running a NEAR node is heavy on storage, and archival nodes are far heavier. It's not worth it for one contract unless we index NEAR more widely.

I'd go with A for live tracking plus B for backfill and gap-repair. That mirrors the endpoint-failover reasoning in #7 and #9.

What

  • A near_intents indexer, attached to the quantus chain config with asset: nep141:qtc.omft.near. It stores swaps with:
    • NEAR height, tx hash, receipt ID, intent_hash pair
    • user and solver accounts, side (sell/buy QTC)
    • QTC amount, counter token ID, symbol, decimals and amount
    • fees_collected, app-fee transfers, referral, timestamp
  • Bridge flows: QTC mints and burns on NEAR, joined to the matching Quantus-side transfers once the bridge's addresses are identified.
  • Routes:
    • GET /v1/chains/quantus/intents/swaps?after=<near_height>:<idx>&limit= (oldest first, with a cursor, like #22)
    • GET /v1/chains/quantus/intents/price?window= returning last trade, VWAP, OHLC buckets, volume by counter token, and swap count
    • GET /v1/chains/quantus/intents/supply returning ft_total_supply, the intents.near balance, bridge custody on Quantus, and whether they agree
  • Live: push each new swap on the existing /v1/ws, and add a price tile to the network page.
  • USD: when the counter token is a stablecoin (identified by its on-chain ft_metadata.symbol), use it directly. For BTC, ETH or NEAR counters, convert through the same block window's settled trades of that token against stables. That means also parsing non-QTC token_diffs, so the QTC pre-filter can't be the only filter; keep the stablecoin pairs needed to price the counters. Until then, report prices in counter-token units and don't invent a USD figure.
  • Coverage: responses carry indexed_from / indexed_to NEAR heights, as everywhere else.

Not in scope

  • 1Click /v0/quote and /v0/tokens. Quotes are off-chain offers that can change with the size of the order, and the token list doesn't even include QTC. If they're ever shown, they must be labelled as quotes, not prices.
  • CoinGecko, SafeTrade or any other exchange's ticker.
  • Attributing solvers to real-world entities, beyond showing the named NEAR account.
## Why Swaps are now live in the Quantus wallet, and NEAR Intents (near.com) is QTC's launch venue. The only other market is SafeTrade, a small exchange that requires KYC. Its CoinGecko ticker shows a 3.1% bid/ask spread, and you can't count on getting coins out of it, so its price is not a reliable reference. The observer already indexes the Quantus side of every swap. A deposit to a 1Click deposit address is an ordinary `Balances::transfer` on our chain. What it can't see is the NEAR side, where the trade is actually settled and priced. **NEAR Intents has no pool, oracle or price stored in any contract.** `intents.near` is a settlement contract: solvers and users sign `token_diff` intents, and the contract executes them atomically. A price exists only as the ratio between amounts in trades that have actually settled, so that is what we should index. 1Click's `/v0/quote` is an off-chain offer, not a trade, and is out of scope (see below). ## State on NEAR at time of writing (block ~218,261,850) - **`qtc.omft.near` is deployed.** `ft_metadata` returns `{"symbol":"QTC","name":"Quantus","decimals":12}`. That's the same decimals as our chain, so amounts map 1:1 in base units. - **No QTC has been bridged yet.** `ft_total_supply` is `"0"` and `ft_balance_of({"account_id":"intents.near"})` is `"0"`. - **The asset ID is `nep141:qtc.omft.near`.** Inside `intents.near` this is the multi-token ID, and it matches the placeholder in the Quantus wallet (`AppConstants.quantusIntentsAssetId`, quantus-apps PRs #664 and #675). - **QTC isn't in the public 1Click token list** (`/v0/tokens`, 202 assets) even though the wallet swaps. That's another reason not to rely on 1Click for discovery. ## Mechanisms that observe actual swaps ### 1. Settlement events from `intents.near` (the price) Every executed intent logs NEP-297 events, `EVENT_JSON:{…}`, in the receipt outcome. I checked these on mainnet tx `85uy9uCFfW4htmj2DLq2FbBmGRkVr34vHNz239e8yB2V` (block 218,261,895, a ZEC→TRON swap): ``` {"standard":"dip4","version":"0.4.3","event":"token_diff","data":[{"intent_hash":"812iSW…","account_id":"blockzen-1-main.near", "diff":{"nep141:tron-d28a…omft.near":"9036290963","nep141:zec.omft.near":"-702585891"},"fees_collected":{"nep141:zec.omft.near":"703"}}]} {"standard":"dip4","version":"0.4.3","event":"token_diff","data":[{"intent_hash":"GZEag3…","account_id":"42f3f216…178171", "diff":{"nep141:tron-d28a…omft.near":"-9036300000","nep141:zec.omft.near":"702585188"},"referral":"1click-swapkit","fees_collected":{…}}]} {"standard":"dip4","event":"transfer", …} fee and app-fee payouts {"standard":"dip4","event":"ft_withdraw", …} the user's payout leaving Intents for the destination chain {"standard":"dip4","event":"intents_executed","data":[{intent_hash, account_id, nonce}, …]} {"standard":"nep245","event":"mt_transfer" | "mt_burn", …} ``` - **A swap is two `token_diff` entries with opposite signs**: the solver's and the user's. The user's side is the one with `referral` (here `1click-swapkit`; the Quantus wallet will presumably set its own), and its `account_id` is a 64-character hex implicit account. The solver's side has a named account, e.g. `blockzen-1-main.near`. - **Price** = `|counter amount| / |QTC amount|`, each scaled by its token's decimals. Read decimals from the counter token's own `ft_metadata`, on-chain, and cache them. - **Direction**: the user's sign on `nep141:qtc.omft.near` says whether QTC was sold (negative) or bought (positive). - **Fees**: `fees_collected` is the protocol fee. App and partner fees appear as `transfer` events. Store both, so prices can be reported with and without fees. - **Only trust executed intents.** A tx can include intents that fail, so treat a `token_diff` as a trade only when its `intent_hash` also appears in `intents_executed` in the same outcome. ### 2. Bridge mints and burns (liquidity, and a cross-check) - **QTC enters NEAR** when the bridge mints `qtc.omft.near` to `intents.near` after a deposit on our chain. Expect `nep141` `ft_mint` and `nep245` `mt_mint` events. I couldn't confirm this until the first QTC deposit lands; supply is 0 today. - **QTC leaves NEAR** through a `dip4` `ft_withdraw` (`token: "qtc.omft.near"`) plus an `mt_burn`, then a payout transfer on **our** chain from the bridge's Quantus wallet. The ZEC example withdrew through `omni.bridge.near` (`InitTransferEvent`). Which bridge QTC uses (omft/POA vs omni) still needs confirming. - **Cross-check:** `qtc.omft.near` `ft_total_supply` should equal the bridge's QTC custody on Quantus. That needs us to identify the bridge's Quantus addresses: deposit addresses sweep into custody, and custody pays out withdrawals. Both are ordinary transfers we already index. This would give a **"QTC inside NEAR Intents"** figure that can be verified from both chains. - Cheap views for an "available liquidity" figure: - `ft_balance_of(intents.near)` on `qtc.omft.near` - `mt_balance_of({account_id, token_id:"nep141:qtc.omft.near"})` on `intents.near`, for solver accounts seen in `token_diff` ### 3. Following `intents.near` in real time **Option A: NEAR RPC only, no third-party indexer.** This is what I prototyped. 1. Find `intents.near`'s shard from `EXPERIMENTAL_protocol_config.shard_layout`. Today that's layout V3 with boundaries `[650, aurora, aurora-0, earn.kaiching, game.hot.tg, game.hot.tg-0, kkuuue2akv_1630967379.near, tge-lockup.sweat, wallet.ka]` and shard IDs `[10, 11, 1, 8, 9, 6, 7, 4, 12, 13]`, so `intents.near` is in range index 6, **shard 7**. Recompute whenever the layout changes; resharding renumbers shards. 2. Per block, call `chunk {block_id, shard_id}`. Keep transactions with `receiver_id == "intents.near"` and a `FunctionCall` to `execute_intents`; the relay signs these as `intents.near` itself. Pre-filter on the base64-decoded args containing `qtc.omft.near`; the signed payloads carry the diffs in plain text. Deduplicate by `chunk_hash`, because a block with no new chunk for the shard returns the previous one. 3. For matching transactions only, call `EXPERIMENTAL_tx_status {tx_hash, sender_account_id, wait_until: "EXECUTED"}` and parse the `EVENT_JSON` logs from `receipts_outcome`. **Measured:** mainnet produces about **1.69 blocks/s**. `rpc.mainnet.fastnear.com` served **11.4 chunk calls/s** sequentially without errors, so one call per block keeps up with plenty of headroom. In 40 blocks there were 2 `execute_intents` transactions across all assets. **Gap:** this only sees `execute_intents` arriving as top-level transactions. Intents reaching the contract any other way, as receipts from cross-contract calls such as `mt_transfer_call` / `ft_transfer_call` with a message, would be missed. To catch those, also scan `chunk.receipts` for `receiver_id == "intents.near"` and fetch their outcomes. **Option B: block-with-outcomes feeds.** FastNEAR's neardata (`mainnet.neardata.xyz/v0/block/<height>`) returns every shard's receipts *and* execution outcomes with logs in one request, and is archival, which makes backfill easy. NEAR Lake (S3, requester pays) is the canonical bulk equivalent. Either removes the transaction-vs-receipt gap. It's still raw chain data, just not served by a node we run. **Option C: our own NEAR RPC node.** Running a NEAR node is heavy on storage, and archival nodes are far heavier. It's not worth it for one contract unless we index NEAR more widely. I'd go with A for live tracking plus B for backfill and gap-repair. That mirrors the endpoint-failover reasoning in #7 and #9. ## What - **A `near_intents` indexer**, attached to the `quantus` chain config with `asset: nep141:qtc.omft.near`. It stores swaps with: - NEAR height, tx hash, receipt ID, `intent_hash` pair - user and solver accounts, side (`sell`/`buy` QTC) - QTC amount, counter token ID, symbol, decimals and amount - `fees_collected`, app-fee transfers, `referral`, timestamp - **Bridge flows:** QTC mints and burns on NEAR, joined to the matching Quantus-side transfers once the bridge's addresses are identified. - **Routes:** - `GET /v1/chains/quantus/intents/swaps?after=<near_height>:<idx>&limit=` (oldest first, with a cursor, like #22) - `GET /v1/chains/quantus/intents/price?window=` returning last trade, VWAP, OHLC buckets, volume by counter token, and swap count - `GET /v1/chains/quantus/intents/supply` returning `ft_total_supply`, the `intents.near` balance, bridge custody on Quantus, and whether they agree - **Live:** push each new swap on the existing `/v1/ws`, and add a price tile to the network page. - **USD:** when the counter token is a stablecoin (identified by its on-chain `ft_metadata.symbol`), use it directly. For BTC, ETH or NEAR counters, convert through the same block window's settled trades of that token against stables. That means also parsing non-QTC `token_diff`s, so the QTC pre-filter can't be the only filter; keep the stablecoin pairs needed to price the counters. Until then, report prices in counter-token units and don't invent a USD figure. - **Coverage:** responses carry `indexed_from` / `indexed_to` NEAR heights, as everywhere else. ## Not in scope - **1Click `/v0/quote` and `/v0/tokens`.** Quotes are off-chain offers that can change with the size of the order, and the token list doesn't even include QTC. If they're ever shown, they must be labelled as quotes, not prices. - **CoinGecko, SafeTrade or any other exchange's ticker.** - **Attributing solvers to real-world entities**, beyond showing the named NEAR account.
Author
Owner

2026-10-03: review before building, and what turned out to be wrong

"Swaps are now live in the Quantus wallet" — they are not, and cannot be yet

  • 1Click refuses QTC in both directions. A dry /v0/quote with the wallet's own request shape (referral: quantus, no API key, which is what SwapService() sends) returns tokenIn is not valid / tokenOut is not valid. This is blocker #1 in the wallet's own mobile-app/docs/near-intents-swaps.md.
  • QTC is in neither the 1Click token list (202) nor the POA bridge's supported_tokens (240).
  • qtc.omft.near was deployed by omft.near at NEAR 217,640,747. Its only activity since is one storage_deposit by staging-ref-solver.near at 217,918,989. ft_total_supply is still "0" at 218,262,584.
  • The Android wallet showing a swap is 1.7.1 (144), which matches fba843df. In that commit the swap flow is a demo:
    • getUsdPrice hard-codes QTC at 50.0. The screen's "1 QTC = 0.00059146 BTC" is exactly 50 / 84,539, BTC's price on 1Click.
    • getQuote never calls 1Click. It multiplies by that rate and adds a flat 0.5%.
    • createSwap makes the deposit address 0x plus 40 random hex characters, even for a BTC deposit.
    • The order marks itself complete after five seconds.
    • The screens do say "For demo purposes only - do not send funds!"
    • Only into-QTC exists, and the ⇅ button is onTap: () {}. That matches what is observed on the phone.
    • Swap-out and the real 1Click calls landed after the 144 bump (0f3848e0, fd45f10d, 47e99a10). No release carries them: the last wallet tag is wallet-v1.7.0+142.
    • Swap visibility is the enableSwap remote flag, so this demo is switched on for 144 users. A user who ignores the warning and sends ETH/USDC to the random 0x… address loses it. This is worth telling the wallet team.

No QTC price exists anywhere today. The $50 is a constant in a demo, and the observer must never show it.

Corrections to the mechanism

  1. FastNEAR RPC keeps about 21 hours. status.sync_info.earliest_block_height was 218,135,889 at 01:28Z. Option A alone cannot fill a gap longer than that, and this service restarts several times a day. The archival feed is required, not optional for gap repair.
  2. neardata as the only source, live and backfill. One request per block returns every shard with receipt outcomes and logs. That removes shard-layout tracking, the transaction-vs-receipt gap, and the tx_status round trips. Measured on a quiet block: about 17 KB compressed (68 KB raw), against 0.9 KB for one chunk call. That is roughly 2.5 GB/day at 1.69 blocks/s, a fair price for one code path.
  3. Option A's shard-7 filter only works because the relay signs as intents.near. A transaction lands in its signer's shard. I verified it for 85uy9u… (signer intents.near). Any other relayer would be missed silently.
  4. Filter on the event logs, not on base64 call arguments. Intents are signed under several payload standards, and a substring test on arguments depends on how each encodes.
  5. Price per token_diff, not per pair. Each diff already carries both legs, and one user intent can be filled by several solvers. Telling taker from maker is a heuristic: referral is optional and solvers can be implicit accounts. Volume is counted once per execution, as the sum of positive QTC across diffs, and the side is labelled as inferred. The wallet sends referral: quantus, so wallet-originated trades should be recognisable. That stays an expectation until the first one settles.
  6. Stablecoins by contract ID, never by ft_metadata.symbol. Anyone can deploy a token called USDC.
  7. ft_metadata exists only for nep141. nep245 and nep171 counters are excluded until handled.
  8. ?window=: windows on this site are counts, not durations. Buckets use the NEAR block timestamp, the counterpart of authored_at. Every figure carries its trade count, because a "last price" from one trade hours ago needs to say so.

Plan

  • Phase 1 (now): a near_intents indexer with the asset from config, plus /intents/swaps and /intents/price with prices in counter-token units and indexed_from/indexed_to. It also includes a listing-status block (supply, the intents.near balance, whether 1Click lists it) so the page says "no market yet" with evidence. It starts at the contract's deployment height (217,640,747), and it is tested end to end against nep141:zec.omft.near because QTC has nothing to index.
  • Phase 2: bridge mints and burns, custody on Quantus, and the supply cross-check.
  • Phase 3: USD via allowlisted stable pairs.
## 2026-10-03: review before building, and what turned out to be wrong ### "Swaps are now live in the Quantus wallet" — they are not, and cannot be yet - 1Click refuses QTC in both directions. A dry `/v0/quote` with the wallet's own request shape (`referral: quantus`, no API key, which is what `SwapService()` sends) returns `tokenIn is not valid` / `tokenOut is not valid`. This is blocker #1 in the wallet's own `mobile-app/docs/near-intents-swaps.md`. - QTC is in neither the 1Click token list (202) nor the POA bridge's `supported_tokens` (240). - `qtc.omft.near` was deployed by `omft.near` at NEAR 217,640,747. Its only activity since is one `storage_deposit` by `staging-ref-solver.near` at 217,918,989. `ft_total_supply` is still `"0"` at 218,262,584. - The Android wallet showing a swap is **1.7.1 (144)**, which matches `fba843df`. In that commit the swap flow is a demo: - `getUsdPrice` hard-codes QTC at `50.0`. The screen's "1 QTC = 0.00059146 BTC" is exactly 50 / 84,539, BTC's price on 1Click. - `getQuote` never calls 1Click. It multiplies by that rate and adds a flat 0.5%. - `createSwap` makes the deposit address `0x` plus 40 random hex characters, even for a BTC deposit. - The order marks itself complete after five seconds. - The screens do say "For demo purposes only - do not send funds!" - Only into-QTC exists, and the ⇅ button is `onTap: () {}`. That matches what is observed on the phone. - Swap-out and the real 1Click calls landed after the 144 bump (`0f3848e0`, `fd45f10d`, `47e99a10`). No release carries them: the last wallet tag is `wallet-v1.7.0+142`. - Swap visibility is the `enableSwap` remote flag, so this demo is switched on for 144 users. A user who ignores the warning and sends ETH/USDC to the random `0x…` address loses it. This is worth telling the wallet team. **No QTC price exists anywhere today.** The $50 is a constant in a demo, and the observer must never show it. ### Corrections to the mechanism 1. **FastNEAR RPC keeps about 21 hours.** `status.sync_info.earliest_block_height` was 218,135,889 at 01:28Z. Option A alone cannot fill a gap longer than that, and this service restarts several times a day. The archival feed is required, not optional for gap repair. 2. **neardata as the only source, live and backfill.** One request per block returns every shard with receipt outcomes and logs. That removes shard-layout tracking, the transaction-vs-receipt gap, and the `tx_status` round trips. Measured on a quiet block: about 17 KB compressed (68 KB raw), against 0.9 KB for one `chunk` call. That is roughly 2.5 GB/day at 1.69 blocks/s, a fair price for one code path. 3. **Option A's shard-7 filter only works because the relay signs as `intents.near`.** A transaction lands in its *signer's* shard. I verified it for `85uy9u…` (signer `intents.near`). Any other relayer would be missed silently. 4. **Filter on the event logs, not on base64 call arguments.** Intents are signed under several payload standards, and a substring test on arguments depends on how each encodes. 5. **Price per `token_diff`, not per pair.** Each diff already carries both legs, and one user intent can be filled by several solvers. Telling taker from maker is a heuristic: `referral` is optional and solvers can be implicit accounts. Volume is counted once per execution, as the sum of positive QTC across diffs, and the side is labelled as inferred. The wallet sends `referral: quantus`, so wallet-originated trades should be recognisable. That stays an expectation until the first one settles. 6. **Stablecoins by contract ID, never by `ft_metadata.symbol`.** Anyone can deploy a token called USDC. 7. **`ft_metadata` exists only for `nep141`.** `nep245` and `nep171` counters are excluded until handled. 8. **`?window=`:** windows on this site are counts, not durations. Buckets use the NEAR block timestamp, the counterpart of `authored_at`. Every figure carries its trade count, because a "last price" from one trade hours ago needs to say so. ### Plan - **Phase 1 (now):** a `near_intents` indexer with the asset from config, plus `/intents/swaps` and `/intents/price` with prices in counter-token units and `indexed_from`/`indexed_to`. It also includes a listing-status block (supply, the `intents.near` balance, whether 1Click lists it) so the page says "no market yet" with evidence. It starts at the contract's deployment height (217,640,747), and it is tested end to end against `nep141:zec.omft.near` because QTC has nothing to index. - **Phase 2:** bridge mints and burns, custody on Quantus, and the supply cross-check. - **Phase 3:** USD via allowlisted stable pairs.
Author
Owner

2026-10-03: correction to my previous comment — neardata cannot be the source

Point 2 above ("neardata as the only source") is wrong. Its free tier is rate-limited, and I measured the limit by hitting it:

HTTP/2 429
{"error": "rate-limit exceeded of 30 blocks per minute", "message": "Please get a plan from https://fastnear.com for higher rate limits"}

30 blocks a minute is 0.5/s. NEAR produces 1.69/s, so the free tier falls behind the tip immediately and could never backfill. The "skipped heights" I saw while probing were this limit, not gaps in the chain.

What does work on free endpoints, measured the same evening:

  • rpc.mainnet.fastnear.com: 60 sequential chunk {shard_id: 7} calls in 6.0 s, all HTTP 200. That is about 10/s against a need of 1.69/s.
  • archival-rpc.mainnet.fastnear.com and archival-rpc.mainnet.near.org both answer chunk at 217,640,747 (qtc.omft.near's deploy height). That covers what the ~21 h retention of the non-archival RPC cannot.

So the issue's original Option A is back as the live path: chunk on intents.near's shard per block, then EXPERIMENTAL_tx_status only for execute_intents transactions. The archival RPC handles backfill and any gap. Its known blind spot stands as the issue described it: intents arriving as cross-contract receipts rather than as transactions signed by intents.near are not read. The indexer should count those receipts where it sees them, so that the gap is measured rather than assumed to be empty.

One thing found while fetching the fixture: a failed receipt keeps its logs. NEAR rolls back state on a failed receipt but still reports the outcome's logs. So a token_diff counts only when the receipt outcome is a success and its intent_hash appears in intents_executed. Either check alone is not enough.

A paid FastNEAR plan (neardata at full rate) or NEAR Lake on S3 would remove the blind spot. Both cost money, so that is a decision for later, and the block source sits behind one interface so it can be swapped.

## 2026-10-03: correction to my previous comment — neardata cannot be the source Point 2 above ("neardata as the only source") is wrong. Its free tier is rate-limited, and I measured the limit by hitting it: ``` HTTP/2 429 {"error": "rate-limit exceeded of 30 blocks per minute", "message": "Please get a plan from https://fastnear.com for higher rate limits"} ``` 30 blocks a minute is 0.5/s. NEAR produces 1.69/s, so the free tier falls behind the tip immediately and could never backfill. The "skipped heights" I saw while probing were this limit, not gaps in the chain. What does work on free endpoints, measured the same evening: - `rpc.mainnet.fastnear.com`: 60 sequential `chunk {shard_id: 7}` calls in 6.0 s, all HTTP 200. That is about 10/s against a need of 1.69/s. - `archival-rpc.mainnet.fastnear.com` and `archival-rpc.mainnet.near.org` both answer `chunk` at 217,640,747 (`qtc.omft.near`'s deploy height). That covers what the ~21 h retention of the non-archival RPC cannot. So the issue's original Option A is back as the live path: `chunk` on `intents.near`'s shard per block, then `EXPERIMENTAL_tx_status` only for `execute_intents` transactions. The archival RPC handles backfill and any gap. Its known blind spot stands as the issue described it: intents arriving as cross-contract receipts rather than as transactions signed by `intents.near` are not read. The indexer should count those receipts where it sees them, so that the gap is measured rather than assumed to be empty. One thing found while fetching the fixture: **a failed receipt keeps its logs.** NEAR rolls back state on a failed receipt but still reports the outcome's logs. So a `token_diff` counts only when the receipt outcome is a success *and* its `intent_hash` appears in `intents_executed`. Either check alone is not enough. A paid FastNEAR plan (neardata at full rate) or NEAR Lake on S3 would remove the blind spot. Both cost money, so that is a decision for later, and the block source sits behind one interface so it can be swapped.
Author
Owner

2026-10-03: phase 1 written, off by default, waiting for our own NEAR node

The free RPC is throttled too. FastNEAR's rpc.mainnet.fastnear.com:

  • returns -429 "Rate limits exceeded" after about 20 calls in a burst, and recovers in about 2 s
  • sustains about 2 requests/s: roughly 79 succeeded in 40 s whether the target was 3/s or 6/s

Following one shard at the tip needs about 1.7/s before any transaction lookups, so there is no headroom. We'll run our own NEAR RPC node with TrackedShardsConfig::Accounts(["intents.near"]), which nearcore 2.13.4 supports. The archive is still needed for history before the node starts.

The swap in the sample was not ZEC→TRON. The counter tron-d28a265909efecdcee7c5028585214ea0b96f015.omft.near reports ft_metadata.symbol = "USDT": it's USDT on Tron. Tx 85uy9uCF… swapped 9,036.29 USDT for 7.0259 ZEC, about 1,286 USDT per ZEC. Reading the contract name gave the wrong token, which is exactly why stablecoins must be identified by contract id.

Implementation (branch intents-swaps, commit 49f4d4b, not pushed):

  • GET /v1/chains/{chain}/intents/swaps?after=<near_height>:<trade_index>&limit= returns trades oldest first, with indexed_from/indexed_to.
  • GET /v1/chains/{chain}/intents/price?trades=N returns, per counter token:
    • the last price, the VWAP and the volume over the latest N trades, in counter units
    • the trade count beside every figure
    • a listing block: ft_total_supply, the intents.near balance, whether 1Click lists the token
    • reads, which states the blind spot in words
  • The window is a count of trades, not a duration, the same rule as the mining windows.
  • Gated on [chains.intents], which asset/config/config.toml.tmpl leaves commented out. A test renders the template and fails if the block is enabled; I confirmed it fails when the block is uncommented. With the gate off, deploying adds three empty tables (migration 0009) and nothing else.
  • Verified end to end against mainnet with ZEC configured: the trade at 218,261,895 was recorded within two seconds and served by both routes. ZEC's listing read back as supply 14,394,728,778,344 base units, 3,146,862,258,370 in intents.near, and listed on 1Click.

Still to do: the frontend tile, and the ws push.

## 2026-10-03: phase 1 written, off by default, waiting for our own NEAR node **The free RPC is throttled too.** FastNEAR's `rpc.mainnet.fastnear.com`: - returns `-429 "Rate limits exceeded"` after about 20 calls in a burst, and recovers in about 2 s - sustains about **2 requests/s**: roughly 79 succeeded in 40 s whether the target was 3/s or 6/s Following one shard at the tip needs about 1.7/s before any transaction lookups, so there is no headroom. We'll run our own NEAR RPC node with `TrackedShardsConfig::Accounts(["intents.near"])`, which nearcore 2.13.4 supports. The archive is still needed for history before the node starts. **The swap in the sample was not ZEC→TRON.** The counter `tron-d28a265909efecdcee7c5028585214ea0b96f015.omft.near` reports `ft_metadata.symbol = "USDT"`: it's USDT on Tron. Tx `85uy9uCF…` swapped 9,036.29 USDT for 7.0259 ZEC, about 1,286 USDT per ZEC. Reading the contract name gave the wrong token, which is exactly why stablecoins must be identified by contract id. **Implementation** (branch `intents-swaps`, commit `49f4d4b`, not pushed): - `GET /v1/chains/{chain}/intents/swaps?after=<near_height>:<trade_index>&limit=` returns trades oldest first, with `indexed_from`/`indexed_to`. - `GET /v1/chains/{chain}/intents/price?trades=N` returns, per counter token: - the last price, the VWAP and the volume over the latest N trades, in counter units - the trade count beside every figure - a `listing` block: `ft_total_supply`, the `intents.near` balance, whether 1Click lists the token - `reads`, which states the blind spot in words - The window is a count of trades, not a duration, the same rule as the mining windows. - Gated on `[chains.intents]`, which `asset/config/config.toml.tmpl` leaves commented out. A test renders the template and fails if the block is enabled; I confirmed it fails when the block is uncommented. With the gate off, deploying adds three empty tables (migration 0009) and nothing else. - **Verified end to end against mainnet** with ZEC configured: the trade at 218,261,895 was recorded within two seconds and served by both routes. ZEC's listing read back as supply 14,394,728,778,344 base units, 3,146,862,258,370 in `intents.near`, and listed on 1Click. Still to do: the frontend tile, and the ws push.
Author
Owner

2026-10-03: our NEAR node is synced, and the two open questions are answered

Node. neard 2.13.4 on frankie tracks {"Accounts": ["intents.near"]}. Mesh clients reach it at https://near.internal; the public reaches it at https://near.blackbeard.observer (#29).

State sync needs inbound P2P. Peers deliver state by connecting back on TCP 24567, and the node was stuck until the office WAN forwarded that port to frankie. Once forwarded, it synced like this:

  • state header: within a minute
  • 1,216 parts downloaded: about 30 min
  • parts applied: about 25 min
  • 14,400 blocks caught up to the tip: about 1 h, at roughly 7 blocks/s

tier3_public_addr was not needed; STUN found the right address. The Postgres standby on the same box caught up fully meanwhile (from 32 days behind to 0.07 s).

Probe from bob against near.internal, at the tip:

Check Result
status syncing: false, at FastNEAR's final height
chunk on shard 7 at a recent height ok, 0.01 s
view calls to qtc.omft.near and zec.omft.near UNAVAILABLE_SHARD, as expected. This is why views go to view_urls (FastNEAR), commit 6279b8f
EXPERIMENTAL_tx_status on a cross-shard swap (BBSuQgGz…, which withdrew via omni.bridge.near) see below
wait_until ours token_diff events
NONE / INCLUDED_FINAL 0.01–0.02 s 5 of 5, plus intents_executed
EXECUTED_OPTIMISTIC / EXECUTED 408 after 10 s —

The code used EXECUTED, so it would have stalled forever on the first swap that withdraws to another chain. Fixed in 1f921eb, which uses INCLUDED_FINAL.

End to end. I ran the indexer locally against near.internal, configured for wNEAR. It followed the tip with no errors, read 176 blocks in about a minute, recorded trades, and pushed one live on /v1/ws.

An observation about side inference. That pushed trade's taker leg had referral: 1click-protocol-fees. The leg carrying the referral can be a fee leg, not the user. side is already labelled inferred; this shows how weak the inference is, and it needs a better rule before anything leans on it.

Ready to enable. Merge intents-swaps, uncomment [chains.intents] with rpc_urls = ["https://near.internal"], and delete the gate assertion in config.rs.

## 2026-10-03: our NEAR node is synced, and the two open questions are answered **Node.** neard 2.13.4 on frankie tracks `{"Accounts": ["intents.near"]}`. Mesh clients reach it at `https://near.internal`; the public reaches it at `https://near.blackbeard.observer` (#29). **State sync needs inbound P2P.** Peers deliver state by connecting back on TCP 24567, and the node was stuck until the office WAN forwarded that port to frankie. Once forwarded, it synced like this: - state header: within a minute - 1,216 parts downloaded: about 30 min - parts applied: about 25 min - 14,400 blocks caught up to the tip: about 1 h, at roughly 7 blocks/s `tier3_public_addr` was not needed; STUN found the right address. The Postgres standby on the same box caught up fully meanwhile (from 32 days behind to 0.07 s). **Probe from bob against `near.internal`, at the tip:** | Check | Result | |---|---| | `status` | `syncing: false`, at FastNEAR's final height | | `chunk` on shard 7 at a recent height | ok, 0.01 s | | view calls to `qtc.omft.near` and `zec.omft.near` | `UNAVAILABLE_SHARD`, as expected. This is why views go to `view_urls` (FastNEAR), commit `6279b8f` | | `EXPERIMENTAL_tx_status` on a cross-shard swap (`BBSuQgGz…`, which withdrew via `omni.bridge.near`) | see below | | `wait_until` | ours | `token_diff` events | |---|---|---| | `NONE` / `INCLUDED_FINAL` | 0.01–0.02 s | 5 of 5, plus `intents_executed` | | `EXECUTED_OPTIMISTIC` / `EXECUTED` | 408 after 10 s | — | The code used `EXECUTED`, so it would have stalled forever on the first swap that withdraws to another chain. Fixed in `1f921eb`, which uses `INCLUDED_FINAL`. **End to end.** I ran the indexer locally against `near.internal`, configured for wNEAR. It followed the tip with no errors, read 176 blocks in about a minute, recorded trades, and pushed one live on `/v1/ws`. **An observation about side inference.** That pushed trade's taker leg had `referral: 1click-protocol-fees`. The leg carrying the referral can be a fee leg, not the user. `side` is already labelled inferred; this shows how weak the inference is, and it needs a better rule before anything leans on it. **Ready to enable.** Merge `intents-swaps`, uncomment `[chains.intents]` with `rpc_urls = ["https://near.internal"]`, and delete the gate assertion in `config.rs`.
Author
Owner

2026-10-06: correction, QTC 1Click swaps aren't token_diff trades

This issue, and the NEAR Intents market built on it (#30, #33), assumed a QTC price would come from the ratio inside an executed token_diff. Since swaps went live on 2026-10-06, none has carried QTC.

1Click settles a QTC buy as a solver transferring QTC to a one-off 1Click account, which passes it on. The user's payment happens on their own chain and never appears on NEAR. So the NEAR Intents page's empty price and settlement panels were accurate for what they measured, but measured the wrong event.

The fills are being indexed in #43. The on-chain price is the solver's restock in the Ref pool (#37).

## 2026-10-06: correction, QTC 1Click swaps aren't `token_diff` trades This issue, and the NEAR Intents market built on it (#30, #33), assumed a QTC price would come from the ratio inside an executed `token_diff`. Since swaps went live on 2026-10-06, none has carried QTC. 1Click settles a QTC buy as a solver **transferring** QTC to a one-off 1Click account, which passes it on. The user's payment happens on their own chain and never appears on NEAR. So the NEAR Intents page's empty price and settlement panels were accurate for what they measured, but measured the wrong event. The fills are being indexed in #43. The on-chain price is the solver's restock in the Ref pool (#37).
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blackbeard/observer#27