# Now Trade Meta - v0.6

The trading terminal combines live indexed market charts with **funded testnet capped expiry contracts**. It is part of NowMeta's independent chain. Prices, collateral, fees and payouts use native NMETA; no BNB, external-chain settlement or dollar price feed is required.

The private Site is an interface preview. Live data and signed transactions require the VPS chain/API and deployed contracts. The optional chart example is synthetic, conspicuously labeled, and cannot trade. No real-money derivatives exchange has been launched.

## Markets and charts

Every Token Studio and Now Pump token is discovered from the verified factory's creation events, including tokens with no trades. The service indexes swaps from registered Now Swap pools, Pump curves and their graduated pools. Directly deployed third-party tokens, foreign-chain tokens and unknown venues are not included. A token with no trading history has no invented price.

The terminal includes:

- Search and paginated token discovery; browser-local watchlist.
- Candlestick and line charts with volume, cursor details and selectable visible candle count.
- Intervals: 1 minute, 5 minutes, 15 minutes, 1 hour, 4 hours and 1 day.
- Earlier/latest history windows, accessible OHLC tables and CSV export.
- Last executed price, 24-hour change, native trading volume, trade count and trade timestamp.
- Recent real trades, indexing height, catch-up state and stale-feed warnings.
- Automatic refresh every five seconds while the terminal is visible.

The market price is executed native amount divided by token amount, expressed with 18-decimal integer precision. Pump events exclude the separate curve fee; Swap events follow their recorded input/output convention. Combined history is a tape of actual venue executions, not an external index, oracle or guaranteed executable quote. Missing periods have no fabricated candles. NMETA itself is the quote currency; an NMETA/USD chart needs a separately sourced market.

The service backfills from the token factory's deployment block using existing indexed blocks and private node logs. Its tables reference canonical blocks with cascading deletion, so chain rewinds remove affected registrations, venues, trades and scan checkpoints. A matching restart does not duplicate trades. A change to registered factory addresses requires an explicitly reviewed index migration; it does not silently trust a new registry.

## Futures-style bidding

These are **bilateral capped contracts with a fixed expiry**, not perpetual futures. One trader places a fully funded long bid or short ask. Another trader takes the entire opposite side at that exact entry price and posts the same margin. There is no automatic matching, partial fill, borrowed balance, funding rate, liquidation bot or early close.

1. Connect the verified testnet deployment and your funded test wallet.
2. Select a market, then an expiry series. If needed, create a series on a UTC hour, at least one hour and at most 30 days ahead. There is one series per token/expiry.
3. Choose Long or Short, an entry price, margin and an integer exposure multiplier from 1 to 5. Minimum margin is 0.01 NMETA. Review the payout cap and fee.
4. Set the offer lifetime. New offers cannot remain open within five minutes of expiry. Review and sign the transaction to escrow margin plus the potential matching fee.
5. Another wallet can take the opposite side through the order book. Self-matching by the same address is rejected. This does not prove that two addresses belong to different people.
6. Unmatched offers can be cancelled by their maker. After an offer's deadline, anyone may trigger its refund to the maker's credit. The unmatched margin and fee are returned as withdrawable credit.
7. A matched position remains funded until settlement or the timeout refund. Use **Settle / Refund margin**, then **Withdraw to my wallet** to receive credited funds.

Orders are loaded in pages of 30 global records and filtered to the chosen expiry. Load older orders/series to see earlier records. The UI's indicative P&L uses the latest spot trade, excludes fees and is not authoritative settlement. Contract state and wallet approvals determine actual orders and payouts.

### Accounting and fees

For margin M, exposure multiplier L, entry P0 and final price P1:

```text
change = min(M, floor(M * L * abs(P1 - P0) / P0))
long payout = M + change if P1 >= P0, otherwise M - change
short payout = 2 * M - long payout
```

Maximum profit before fees and maximum loss before fees are each M. The cap is part of the contract. A 5x exposure multiplier does not make losses exceed the deposited margin and does not create credit.

Each matched side pays **0.1% of its posted margin** (10 basis points), plus separate network gas. The matching fee is reserved with an open offer, released to treasury credit only on a fill, and refunded if the offer is cancelled unfilled. Fees remain paid on an eventual settlement timeout. This rate is fixed in this deployment, not an admin-editable setting.

Example: both traders post 10 NMETA margin, with 2x exposure and an entry price of 2 NMETA per token. A final price of 2.5 produces 15 NMETA for the long and 5 for the short. Each additionally paid a 0.01 NMETA matching fee. Both payouts sum to the 20 NMETA collateral; no extra funds or token issuance are created.

Credits use pull withdrawals, including treasury fees. The contract exposes escrowed collateral and total credits for accounting. There is no administrator function to seize collateral or rewrite filled orders. Withdrawals, cancellation and settlement do not require a functioning chart feed; the connected blockchain still must be available.

## Settlement desk and trust model

Settlement uses a **fixed permissioned reporting committee**, initially drawn from the council members at deployment. The deployment records its members and threshold. The terminal reads and displays the actual reporter addresses and threshold from the contract. Treasury council membership rotation does not rotate this committee or change an existing contract's terms.

After expiry, a reporter submits a final NMETA-per-token price and a nonzero 32-byte evidence hash. A reporter may vote once per series. The required number of distinct reporters must agree on both the price and evidence hash within 24 hours. A quorum makes that price final and immutable. Zero is a permitted final price. Anyone can then settle matched positions; payouts always go to their committed participants' credits.

If no matching quorum exists when the 24-hour window ends, matched traders can recover their original margins. Matching fees are not refunded. Late votes cannot defeat this refund route. A disagreement between reporters can therefore cause a timeout.

For a test settlement rehearsal, prepare a documented observation record with the token, expiry, pricing method, source observations and proposed price. Independently review it, hash the exact record and use that hash in each matching vote. A hash commits to a record; it does not prove the price is correct. Archive the record for participants to inspect. Never automatically copy a thin pool's last spot price into settlement and describe it as manipulation-resistant.

The committee can misprice a market if a threshold colludes or its keys are compromised. There is no dispute court, independent oracle feed, automatic median or challenge period in this implementation. This is a concrete test settlement mechanism, not a production oracle. Public real-value derivatives require a separate market design, reliable settlement inputs, security review, operating controls and applicable launch review.

## Install on a new testnet

Follow the base `COMPLETE_GUIDE.md` and `HOSTINGER_VPS_RUNBOOK.md`. In v0.6, fresh `bash ops/run.sh deploy` creates **ten** contract manifest entries, including `tradeMeta`. It also records `tradePolicy` with the initial fixed committee. Do not use the fresh initializer on an existing network.

The updated API automatically creates the market tables in its existing SQLite database. It does not alter private pledge records. The public website uses the same-origin `/api/markets` endpoints, so no new public port or cross-origin credential is needed. Keep node RPC private.

## Upgrade an existing v0.5 testnet

Back up the runtime and preserve the existing genesis, keys, manifest and databases. Put the reviewed updated source in the existing deployment workflow. Check the current council members and threshold before deploying: the additive script reads the live council's member slots, rather than reusing old addresses from a stale membership record.

From the project root, with the existing runtime mounted:

```sh
npm ci
npm test
npm run build
npm run compile
python3 scripts/package-deliverables.py
npm run release:check

docker compose --env-file .runtime/vps/compose.env \
  -f ops/compose.yaml build deployer api web
docker compose --env-file .runtime/vps/compose.env \
  -f ops/compose.yaml --profile deploy run --rm deployer \
  node scripts/deploy-trade.mjs
docker compose --env-file .runtime/vps/compose.env \
  -f ops/compose.yaml up -d --no-deps api web
```

If optional Blockscout is active, include its env file and `-f ops/blockscout.yaml` in manual compose commands, as in the base runbook. Do not start a second compose project or replace the active proxy.

The additive deployer checks chain/genesis and existing runtime-code hashes, preserves old contract addresses, writes an original manifest backup and records preparing/submitted/confirmed deployment states. It refuses a blind retry when its journal or backup already exists. Reconcile transaction hashes and nonce before retrying an interrupted deployment. Do not delete journals to force a new deployment.

Wait for market backfill to catch up. Read `/api/status` and `/api/markets` and verify their genesis, heights and freshness. The gateway's ordinary health endpoint alone does not prove market readiness. Refresh/load the updated manifest in Network operations, then open **Now Trade Meta**.

## API and operator checks

| Endpoint | Response |
|---|---|
| GET /api/markets?search=FOX&offset=0&limit=25 | Searchable tokens with latest price, 24h statistics and venues |
| GET /api/markets/0xTOKEN?interval=15m&limit=300 | OHLCV history and up to 50 recent trades |
| Same with before=UNIX_SECONDS | An earlier chart window |
| GET /api/status | Chain/index status plus separate market readiness/error state |

Intervals must be one of the six supported values. Limits are bounded; detail windows allow at most 500 intervals and process at most 50,000 trades. The response flags a truncated window/statistic instead of claiming it is complete. Use smaller intervals/windows or an expanded analytical store for high-volume production history. Prices and amounts are decimal integer strings, not floating-point settlement values.

Freshness requires a successful recent sync and a market index within five blocks of the chain head. New offer/fill controls are disabled when the UI's feed is stale. The contract itself does not consult the chart API. Existing cancellation, settlement and withdrawal rights remain on-chain.

The metrics endpoint adds `nowmeta_market_indexed_block` and `nowmeta_markets_ready`. Configure appropriate alert delivery and capacity monitoring before operating publicly. Market requests share the existing API's rate limiting.

Before inviting testers, verify:

- Studio creation and Pump creation both appear; a token without trades has a blank price.
- Buy/sell events create correct candles and volume; restarts and a test reorg do not duplicate history.
- Two separate wallets can create, fill, settle and withdraw a test contract.
- Exact margin/fee checks, self-fill rejection, cancellation and expired-order refunds work.
- Early/unauthorized/repeated settlement votes fail; matching quorum and zero-price settlement work.
- A no-quorum series refunds margins after 24 hours and cannot settle late instead.
- Treasury collects fee credits through a council proposal using **Collect Now Trade Meta fees**.
- Example mode cannot sign trades and leaving it clears its synthetic prices.

Automated results and outstanding deployment/browser-wallet checks are recorded in `validation-v06.json` and `SECURITY_AND_VALIDATION.md`. Docker/Hostinger and real installed-wallet end-to-end execution remain separate acceptance work.

## Files and references

Source: `web/trade.html`, `web/trade.mjs`, `sdk/trade.mjs`, `services/markets.mjs`, `contracts/NowTradeMeta.sol`, and `scripts/deploy-trade.mjs`. Contract/API tests are in `test/trade.test.mjs`, `test/markets.test.mjs` and the deployment tests.

Primary technical references checked for this release:

- OpenZeppelin math and reentrancy utilities: https://docs.openzeppelin.com/contracts/5.x/api/utils
- Oracle trust and price manipulation: https://ethereum.org/developers/docs/oracles/
- Smart-contract security considerations: https://ethereum.org/developers/docs/smart-contracts/security/

No external feed or oracle service is connected by those references. Product-specific behavior above is defined by the included source, deployment configuration and tests.
