Unique-Divine/jiyuu / ai-skills/sai
sai
VerifiedTrade and inspect Sai perpetuals on Nibiru with the open-source `sai` CLI and its MCP server, and query or reconcile Sai Perps data from live contracts, Sai Keeper GraphQL, and DexPal REST. Use for Sai markets, prices, positions, balances, trade history, live watches, connecting a Sai account, previewing or submitting trades, checking intents, installing or configuring the Sai MCP server, `sai config`, `sai doctor`, `sai update`, `sai logs`, fees, open interest, SLP vaults, referrals, or disagreements between on-chain and indexed data. Use agent skill `sai-ops` for contract and operator mutations.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.1 KB |
| cli.md | markdown | 11.0 KB |
| examples/prompts.md | markdown | 2.1 KB |
| mcp.md | markdown | 8.1 KB |
| references/contracts.md | markdown | 28.1 KB |
| references/graphql.md | markdown | 4.5 KB |
| references/reconciliation.md | markdown | 3.4 KB |
| references/referrals.md | markdown | 6.9 KB |
| references/rest.md | markdown | 7.1 KB |
| references/vaults.md | markdown | 23.7 KB |
| trading-safety.md | markdown | 11.2 KB |
references/reconciliation.md
View on GitHub# Sai Reconciliation
Use this reference when a Sai operator question compares two or more truth
surfaces: on-chain contracts, Sai Keeper GraphQL, DexPal REST, the `sai-keeper`
Postgres database, or operator records such as spreadsheets and notes.
## Source-of-truth model
- On-chain Sai contract state owns live protocol facts: market and collateral
config, OI limits, borrowing state, fee config, vault mappings, referral code
ownership, user deposits, and trading-credit balances.
- Sai Keeper GraphQL owns indexed app/backend facts: trade history, referral
redemptions, LP history, fee analytics, oracle prices as indexed by the app,
and subscription payloads.
- DexPal REST owns public aggregate responses: stats, market details, metrics,
yield, referral reports, and health checks.
- The `sai-keeper` Postgres database explains how GraphQL and REST facts are
stored, refreshed, and aggregated.
- Operator records, such as a referral spreadsheet or deal notes, hold
human-maintained metadata: names, deal terms, share URLs, and labels. They
are precedent, not live state.
## Reconciliation workflow
1. Name each layer involved in the mismatch. For example: contract state,
GraphQL field `trades`, REST endpoint `GET /dexpal/v1/stats`, database table
`stats_perp_oi_daily`, or a spreadsheet column.
2. Decide which layer owns the requested fact.
3. Check freshness before interpreting values. Use block heights, timestamps,
daily buckets, `lastUpdatedBlock`, and DB `MAX(ts)` queries where available.
4. Normalize units before comparing. Contract, GraphQL, and DB integer amounts
are often base units; REST may expose human or USD values.
5. Explain differences by source. Example: "contract state says X, GraphQL has
indexed Y through block Z, REST aggregates table `stats_perp_oi_daily`, and
the spreadsheet label is human metadata."
## Common mismatch patterns
- REST endpoint `GET /dexpal/v1/stats` can show zero open interest when table
`stats_perp_oi_daily` lacks a current-day row, even while contract state and
table `perp_trade` show open positions.
- REST endpoint `GET /dexpal/v1/stats` builds its 24-hour volume, trade, and
user figures from daily date buckets, not a rolling wall-clock window. REST
endpoint `GET /dexpal/v1/markets/details` computes a separate 24-hour view
and can use a latest-block timestamp anchor. A trade missing from an
aggregate has two possible causes: it falls in another day's bucket, or
ingestion or the daily rollup is behind. Check which bucket the trade's
timestamp belongs to and how fresh the aggregate is before naming one. See
[24-hour time-window semantics](rest.md#24-hour-time-window-semantics).
- GraphQL fields expose indexed state, not necessarily the same moment as a live
contract query.
- Referral spreadsheet rows can be stale or incomplete because they are operator
metadata. Verify code ownership and discounts on-chain.
- SLP Vault smart queries can hide details that raw state explains, especially
around `acc_pnl_per_token_used`, `current_max_supply`, daily resets, and reward
distribution accounting.
## Relevant references
- Contract state and query payloads: [`contracts.md`](contracts.md)
- SLP Vault health and raw state: [`vaults.md`](vaults.md)
- GraphQL fields and subscriptions: [`graphql.md`](graphql.md)
- REST endpoint semantics: [`rest.md`](rest.md)
- DB tables and SQL snippets: private agent skill `sai-db`
- Referral checks: [`referrals.md`](referrals.md)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |