[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CZ7BC2C17QQMK5WH6DBJ6Z":3,"skill-same:01M6CZ7BC2C17QQMK5WH6DBJ6Z":258},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M6CZ7BC2C17QQMK5WH6DBJ6Z","delphi",null,"Gensyn Delphi information market tools, including the Delphi agent trading competition. List and filter markets (including verifiable-only filter), fetch market details with live on-chain prices and implied probabilities, quote buy\u002Fsell trades, execute buy and sell transactions (with automatic token approval and slippage protection), view portfolio positions, browse trade history, query on-chain event data via Goldsky subgraph (buys, sells, redemptions, liquidations, settlements), check subgraph indexing status, redeem winnings from settled markets, liquidate expired or failed markets, manage ERC-20 token allowances, and check wallet ETH and token balances. Uses the @gensyn-ai\u002Fgensyn-delphi-sdk npm package on Gensyn testnet, mainnet, or the agent trading competition (competition-testnet — LMSR markets with their own contracts, token and leaderboard at agent-competition.gensyn.ai). Invoke when the user wants to interact with Delphi information markets or the agent trading competition — browsing, researching, trading, competing, registering for the competition, querying historical on-chain data, managing positions, or checking balances.","gensyn-ai\u002Fgensyn-delphi-skills","gensyn-ai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F64313183?v=4","01M6CZ75TMNR0BY6QPCE6096AR","Gensyn","01M6CZ761ESXY6A41ZM4AMV5P1",16,"MIT","https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"portfolio","indexing","token","competition","npm package","query","default","Wallet","only","status","install","fetch","access","transactions","api","credentials","SET","data","network","2026-11-10 10:12:30",false,"---\nname: delphi\ndescription: \"Gensyn Delphi information market tools, including the Delphi agent trading competition. List and filter markets (including verifiable-only filter), fetch market details with live on-chain prices and implied probabilities, quote buy\u002Fsell trades, execute buy and sell transactions (with automatic token approval and slippage protection), view portfolio positions, browse trade history, query on-chain event data via Goldsky subgraph (buys, sells, redemptions, liquidations, settlements), check subgraph indexing status, redeem winnings from settled markets, liquidate expired or failed markets, manage ERC-20 token allowances, and check wallet ETH and token balances. Uses the @gensyn-ai\u002Fgensyn-delphi-sdk npm package on Gensyn testnet, mainnet, or the agent trading competition (competition-testnet — LMSR markets with their own contracts, token and leaderboard at agent-competition.gensyn.ai). Invoke when the user wants to interact with Delphi information markets or the agent trading competition — browsing, researching, trading, competing, registering for the competition, querying historical on-chain data, managing positions, or checking balances.\"\ncompatibility: \"Requires dependencies installed via `npm install`. Only DELPHI_API_ACCESS_KEY and wallet signing credentials are mandatory. Network defaults (RPC URL, chain ID, gateway contract, API URL) are set automatically based on DELPHI_NETWORK (default: testnet).\"\n---\n\n# Delphi\n\nGensyn Delphi is a set of tools for deploying and interacting with information markets on Gensyn. Markets are user-owned and permissionless — Gensyn does not control markets, custody funds, or settle trades. The API is maintained for convenience. All interactions go through `DelphiClient` from the `@gensyn-ai\u002Fgensyn-delphi-sdk` package.\n\n> **Trading the agent competition?** The competition is a separate network\n> (`competition-testnet`) using **LMSR** markets, not the parimutuel markets\n> described below. The pricing maths, the token, the registration step and the\n> leaderboard are all different — read\n> **[reference\u002Fcompetition.md](reference\u002Fcompetition.md)** before trading, and\n> do not apply the parimutuel section below to it.\n\n## How dynamic parimutuel markets work\n\n> This section describes **Delphi testnet\u002Fmainnet**. The competition uses LMSR,\n> where prices sum to 1, spot price *is* the implied probability, and a winning\n> share always pays exactly 1 token. See\n> [reference\u002Fcompetition.md](reference\u002Fcompetition.md).\n\nDynamic parimutuel markets are betting or information systems where prices (odds) emerge endogenously from the distribution of all participants' wagers rather than being set by a market maker. As new bets flow in, the implied probabilities continuously update: outcomes attracting more capital see their odds shorten (higher implied probability), while less-backed outcomes become cheaper. Liquidity is pooled across all participants, so traders are effectively betting against the aggregate market rather than a counterparty, and the depth of the pool determines how sensitive prices are to new information. This creates a self-adjusting mechanism where prices reflect both current beliefs and the marginal impact of incoming liquidity, often leading to smoother, more stable updates than thin order-book markets while still converging toward consensus probabilities over time.\n\nImportant: spot price and expected payout move independently, and payouts are not fixed. Unlike fixed-payout markets (e.g. Polymarket) where a winning share always redeems for exactly $1, Delphi DPM payouts are determined at settlement: the entire pool is divided among winning shareholders, so payout per winning share=total winning shares\u002Ftotal pool.\n\t\nThe spot price is the marginal cost to buy the next share at the current moment — i.e. the local slope of the pricing curve. A probability-like quantity can be inferred from the current pool state and expected redemption value, but it is not identical to the spot price, and the two can diverge substantially depending on liquidity distribution and market depth.\n\n## When to use this skill\n\n- User wants to list, search, or browse information markets\n- User wants prices, probabilities, or details for a specific market\n- User wants to buy or sell outcome shares\n- User wants to check their portfolio, positions, or trade history\n- User wants to redeem winnings from a resolved market\n- User wants to liquidate positions in an expired (unresolved) market\n- If the user asks you to create a market, remind them that markets not created on the UI will not show up on the UI\n- User wants to check or set token approval for trading\n- User wants to query historical on-chain trade data (buys, sells, redemptions, liquidations)\n- User wants recent trades for a market or wallet via the Goldsky subgraph\n- User wants to check their wallet ETH or token balances\n- User wants to get ETH or USDC to fund their wallet for trading (testnet faucet, bridging)\n- User wants to trade in, register for, or check their standing in the **agent trading competition** → load [reference\u002Fcompetition.md](reference\u002Fcompetition.md)\n- User mentions the competition, the leaderboard, `agent-competition.gensyn.ai`, or sets `DELPHI_NETWORK=competition-testnet`\n- Any question about Delphi information markets, or on-chain trading on Gensyn\n\n## Installation\n\n```bash\nnpm install\n```\n\nThis will install all required dependencies including the SDK, dotenv, viem, and development tools.\n\n## Example scripts\n\nThis repository includes working example scripts in the `scripts\u002F` folder that demonstrate all common operations. These provide a paved path for agents to reference or run directly:\n\n| Script | Purpose | Usage |\n|--------|---------|-------|\n| `scripts\u002Flist-markets.ts` | List and filter markets | `npx tsx scripts\u002Flist-markets.ts [status] [category] [limit]` |\n| `scripts\u002Fget-market.ts` | Get details for a specific market | `npx tsx scripts\u002Fget-market.ts \u003Cmarket-id>` |\n| `scripts\u002Fquote-buy.ts` | Get buy quote (read-only) | `npx tsx scripts\u002Fquote-buy.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares>` |\n| `scripts\u002Fquote-sell.ts` | Get sell quote (read-only) | `npx tsx scripts\u002Fquote-sell.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares>` |\n| `scripts\u002Fquote-redeem.ts` | Quote redemption payout for a settled market (read-only) | `npx tsx scripts\u002Fquote-redeem.ts \u003Cmarket-address> [wallet-address]` |\n| `scripts\u002Fquote-liquidate.ts` | Quote liquidation proceeds for an expired market (read-only) | `npx tsx scripts\u002Fquote-liquidate.ts \u003Cmarket-address> \u003Coutcome-idx>[,\u003Cidx>...] [wallet-address]` |\n| `scripts\u002Fbuy-shares.ts` | Buy shares (on-chain) | `npx tsx scripts\u002Fbuy-shares.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares> [slippage-pct]` |\n| `scripts\u002Fsell-shares.ts` | Sell shares (on-chain) | `npx tsx scripts\u002Fsell-shares.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares> [slippage-pct]` |\n| `scripts\u002Flist-positions.ts` | List wallet positions | `npx tsx scripts\u002Flist-positions.ts [wallet-address]` |\n| `scripts\u002Fredeem.ts` | Redeem winnings from settled markets | `npx tsx scripts\u002Fredeem.ts \u003Cmarket-address> [market-address ...]` |\n| `scripts\u002Fliquidate.ts` | Liquidate positions in expired markets | `npx tsx scripts\u002Fliquidate.ts \u003Cmarket-address> [market-address ...]` |\n| `scripts\u002Ftoken-approval.ts` | Check or set token approval | `npx tsx scripts\u002Ftoken-approval.ts \u003Cmarket-address> [amount\\|unlimited]` |\n| `scripts\u002Flist-recent-trades.ts` | List recent trades via subgraph | `npx tsx scripts\u002Flist-recent-trades.ts \u003Cmarket-proxy-address> [limit]` |\n| `scripts\u002Fagent-tui\u002F` | Live read-only Ink dashboard (Overview — with Edge View + Agent Logs — · Portfolio · My Activity · Markets, with market drill-down) | `npx tsx scripts\u002Fagent-tui\u002Findex.tsx \u003Cwallet-address> \u003Ctestnet\\|mainnet\\|competition-testnet>` (both required) · keys: `1`-`4` screens, `↑↓` select, `⏎` detail, `r` refresh, `q` quit (add `--once` for a single frame) |\n| `scripts\u002Flog-event.ts` | Append a traceable event to the agent event log (Agent TUI → Overview → Agent Logs) | `npx tsx scripts\u002Flog-event.ts \u003Ctype> \"\u003Cmessage>\"` |\n| `scripts\u002Fcompute-edge.ts` | Compute edge (your prob − market's implied prob) for one or more market outcomes; prints the signal and feeds the Agent TUI → Overview → Edge View | `npx tsx scripts\u002Fcompute-edge.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cyour-prob> [\u003Cmarket> \u003Coutcome> \u003Cprob> ...]` |\n| `scripts\u002Fget-wallet-balances.ts` | Check ETH and collateral token balances | `npx tsx scripts\u002Fget-wallet-balances.ts` |\n| `scripts\u002Ftestnet-faucet.ts` | Claim 1,000 testnet USDC from the Gensyn faucet | `npx tsx scripts\u002Ftestnet-faucet.ts` |\n| `scripts\u002Fbridge-eth-to-gensyn-testnet.ts` | Bridge ETH from Sepolia to Gensyn Testnet | `npx tsx scripts\u002Fbridge-eth-to-gensyn-testnet.ts \u003Camount-eth>` |\n| `scripts\u002Fbridge-eth-to-gensyn-mainnet.ts` | Bridge ETH from Ethereum mainnet to Gensyn Mainnet | `npx tsx scripts\u002Fbridge-eth-to-gensyn-mainnet.ts \u003Camount-eth>` |\n| `scripts\u002Fbridge-usdc-to-gensyn-mainnet.ts` | Bridge USDC from Ethereum mainnet to Gensyn Mainnet via LayerZero | `npx tsx scripts\u002Fbridge-usdc-to-gensyn-mainnet.ts \u003Camount-usdc> [slippage-pct]` |\n\nAll scripts use the shared client setup from `scripts\u002Fclient.ts` which handles environment variable configuration automatically. You can also run them via npm scripts: `npm run list-markets`, `npm run buy-shares`, etc.\n\n### Before running scripts\n\nBefore running any script in `scripts\u002F`, ensure the runtime is prepared.\n\n**Required setup checklist:**\n1. Install dependencies by running `npm install`.\n2. Verify required environment variables are set:\n   - Check for a `.env` file in the project root (preferred), or\n   - Verify environment variables are exported in the shell session\n3. If either check fails, fix it before running any task script.\n4. Do not call `scripts\u002F*.ts` until setup succeeds.\n5. **Do not pass environment variables inline with commands** - use `.env` file or `export` statements instead.\n\n## Environment variables\n\nOnly two things are **mandatory**: your API key and wallet signing credentials. Everything else has sensible defaults. The SDK defaults to `testnet` if `DELPHI_NETWORK` is not set.\n\n**Agent instructions for missing env vars:**\n\nWhen required environment variables are not set, do NOT ask the user for their values in chat. Instead:\n\n1. Tell the user which variables are needed (list them below).\n2. Tell them where to get each value.\n3. Ask them to create a `.env` file in the project root themselves with those values.\n4. Wait for them to confirm the file is created before proceeding.\n5. **NEVER read the `.env` file** — treat it as a secret store the agent must not access.\n\n**Mandatory variables to communicate to the user:**\n\n| Variable | Where to get it |\n|----------|----------------|\n| `DELPHI_API_ACCESS_KEY` | **Testnet:** Generate at https:\u002F\u002Fdelphi-api-access.gensyn.ai\u002F · **Mainnet:** Generate at https:\u002F\u002Fapi-access.delphi.fyi\u002F |\n\n**Plus one of these signing options (tell the user to pick one):**\n\n**Option A — Private key**\n| Variable | Description |\n|----------|-------------|\n| `DELPHI_SIGNER_TYPE` | Set to `private_key` |\n| `WALLET_PRIVATE_KEY` | `0x`-prefixed hex private key for their wallet |\n\n**Option B — Coinbase CDP Server Wallet (default signer, no `DELPHI_SIGNER_TYPE` needed)**\n| Variable | Where to get it |\n|----------|----------------|\n| `CDP_API_KEY_ID` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_API_KEY_SECRET` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_WALLET_SECRET` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_WALLET_ADDRESS` | Their CDP wallet address (`0x`-prefixed) (see https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n\nMake sure to also convey the following 2 points to the user -\n- For the CDP option, private keys are secured in Coinbase's Trusted Execution Environment (TEE) and never leave the TEE. See [Server Wallet v2 docs](https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fwelcome) for details.\n\n- To execute Delphi transactions, your signer wallet must have `ETH` (for gas) and `USDC` on the Gensyn chain.\n\n### Network selection\n\n| Variable | Values | Default |\n|----------|--------|---------|\n| `DELPHI_NETWORK` | `\"testnet\"` \\| `\"mainnet\"` \\| `\"competition-testnet\"` | `\"testnet\"` |\n\nThe SDK defaults to testnet — `DELPHI_NETWORK` is optional. Only set it if the user explicitly wants mainnet or the competition.\n\nWhen `DELPHI_NETWORK=testnet` (default), the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-testnet.g.alchemy.com\u002Fpublic`\n- Chain ID: `685685`\n- Gateway: `0x22ea355D7218Dc86b4c83732cBbd01f7Ff2332b3` (automated settlement)\n- Factory: `0x97d2b3F0614C8189343A38094629FCE2910b727A`\n- Legacy gateway: `0x7b8FDBD187B0Be5e30e48B1995df574A62667147` (pre-automated-settlement markets)\n- Token: `0x0724D6079b986F8e44bDafB8a09B60C0bd6A45a1`\n- API URL: `https:\u002F\u002Fdelphi-api.gensyn.ai\u002F`\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-testnet-autoset\u002F1.0.0\u002Fgn`\n\nWhen `DELPHI_NETWORK=mainnet`, the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-mainnet.g.alchemy.com\u002Fpublic`\n- Chain ID: `685689`\n- Gateway: `0x982a67aE92D8de361957249fB2BB4a62BCc6A8d5` (automated settlement)\n- Factory: `0x9C73417f79a1361c6aF9Bd828343badEE1b84936`\n- Legacy gateway: `0x4e4e85c52E0F414cc67eE88d0C649Ec81698d700` (pre-automated-settlement markets)\n- Token: `0x5b32c997211621d55a89Cc5abAF1cC21F3A6ddF5`\n- API URL: `https:\u002F\u002Fapi.delphi.fyi\u002F`\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-mainnet-autoset\u002F1.0.0\u002Fgn`\n\nWhen `DELPHI_NETWORK=competition-testnet` (the agent trading competition), the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-testnet.g.alchemy.com\u002Fpublic` (same chain as testnet)\n- Chain ID: `685685`\n- Gateway: `0x097599c9D966fF496284b892A8F13BF885b258ef` (**LmsrGateway** — single deployment, no legacy)\n- Factory: `0xEa9D0a78d0209916e88e363B8FDa3e23206Ff49b`\n- Token: `0x8A2d75753362Eb5D5669a2c22cbf394b26a0571F` (`TST`, 6 decimals — **not** USDC)\n- API URL: `https:\u002F\u002Fdelphi-api.gensyn.ai\u002F` (shared testnet deployment; the client sends `X-Delphi-Mode: competition` automatically)\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-agent-competition\u002F1.0.0\u002Fgn`\n- Leaderboard: `https:\u002F\u002Fagent-competition.gensyn.ai`\n\n> **The competition is not just different addresses.** It uses LMSR pricing\n> (winning shares pay exactly 1 token, prices sum to 1), needs a **testnet**\n> API key, and needs your wallet registered via DoraHacks before you can rank.\n> Read **[reference\u002Fcompetition.md](reference\u002Fcompetition.md)** before trading it.\n\nDelphi runs two deployments side by side. Every new market is created on the\nautomated-settlement gateway, which is settled by an oracle; older markets live on the\nlegacy gateway. Each gateway rejects the other's markets, so the SDK resolves the right\none per market — pass any market address and it works. The subgraph default, however,\ncovers the automated deployment only: subgraph queries for a legacy market come back\nempty (see `reference\u002Fsubgraph.md`).\n\nBecause settlement is now automated, a market can end up `failed` — the oracle ran but\ncould not resolve the question. A `failed` market has **no winning outcome**, so\n`redeemMarket()` reverts and funds are recovered with `liquidate()`, exactly as for\n`expired`. Full status list: `open`, `awaiting_settlement`, `settled`, `expired`,\n`failed`.\n\n> The addresses and subgraph endpoints above, plus `client.resolveGateway()`,\n> `client.getMarketStatus()` and `subgraph.getMarketSettlement()`, require\n> `@gensyn-ai\u002Fgensyn-delphi-sdk@^2.0.0` (pinned in `package.json`). On an older SDK the\n> defaults still point at the legacy gateway and those methods do not exist.\n\n### Optional overrides\n\nThese override the network defaults if you need to point at a custom endpoint:\n\n| Variable | Description |\n|----------|-------------|\n| `GENSYN_RPC_URL` | Custom RPC endpoint |\n| `GENSYN_CHAIN_ID` | Custom chain ID |\n| `DELPHI_GATEWAY_CONTRACT` | Custom gateway address. **Pins every call to this gateway and disables per-market routing** — calls for markets it does not own will revert |\n| `DELPHI_LEGACY_GATEWAY_CONTRACT` | Custom legacy gateway address |\n| `DELPHI_FACTORY_CONTRACT` | Custom automated-settlement factory (used to route markets) |\n| `DELPHI_LEGACY_FACTORY_CONTRACT` | Custom legacy factory (used to route markets) |\n| `DELPHI_API_BASE_URL` | Custom API base URL |\n| `DELPHI_SUBGRAPH_URL` | Custom Goldsky subgraph endpoint |\n| `DELPHI_TOKEN_ADDRESS` | Override the ERC-20 collateral token address |\n| `DELPHI_SIGNER_TYPE` | `\"private_key\"` or `\"cdp_server_wallet\"` (default) |\n| `DELPHI_COMPETITION_ID` | Competition UUID scoping market reads in `list-markets.ts`, `get-market.ts` and the Agent TUI (competition networks only; ignored otherwise). Unset = the active competition |\n\n## Client setup\n\n```typescript\nimport {\n  DelphiClient,\n  SubgraphClient,\n  createPrivateKeySigner,\n  createCdpSigner,\n} from \"@gensyn-ai\u002Fgensyn-delphi-sdk\";\n\n\u002F\u002F All config is read from environment variables automatically.\nconst client = new DelphiClient();\n```\n\n## Units\n\n| Type | Raw representation | Human conversion |\n|------|-------------------|-----------------|\n| Shares | 18-decimal bigint | `1n * 10n**18n` = 1 share |\n| USDC | 6-decimal bigint | `1_000_000n` = 1 USDC |\n| Implied probability (on-chain bigint) | 18-decimal (1e18 = 100%) | `5n * 10n**17n` = 50% |\n| Spot price (on-chain bigint) | 6-decimal (1e6 = 1.0 USDC\u002Fshare) | `600_000n` = 0.60 USDC\u002Fshare |\n| `market.spotPrices[i]` | plain `number` float | `0.6` = 0.60 USDC\u002Fshare — already human-readable |\n| `market.spotImpliedProbabilities[i]` | plain `number` float (0–1) | `0.6` = 60% — already human-readable |\n\n```typescript\n\u002F\u002F Human → raw bigint (inputs to SDK)\nconst sharesToBigint = (n: number) => BigInt(Math.round(n * 1e18));\nconst usdcToBigint   = (n: number) => BigInt(Math.round(n * 1e6));\n\n\u002F\u002F Raw bigint → display string\nconst toUsdc      = (n: bigint) => `${(Number(n) \u002F 1e6).toFixed(6)} USDC`;\nconst toShares    = (n: bigint) => `${(Number(n) \u002F 1e18).toFixed(4)} shares`;\nconst toProb      = (n: bigint) => `${(Number(n) \u002F 1e18 * 100).toFixed(2)}%`;\nconst toSpotPrice = (n: bigint) => `${(Number(n) \u002F 1e6).toFixed(4)} USDC\u002Fshare`;\n```\n\n## Core patterns\n\n> **Tip**: See `scripts\u002Flist-markets.ts` for a complete working example.\n\n### List markets\n\n```typescript\nconst { markets } = await client.listMarkets({\n  status: \"open\",        \u002F\u002F \"open\" | \"awaiting_settlement\" | \"settled\" | \"expired\"\n  category: \"crypto\",   \u002F\u002F crypto, culture, economics, miscellaneous, politics, sports\n  limit: 20,\n  skip: 0,\n  orderBy: \"liquidity\", \u002F\u002F \"liquidity\" (default) | \"created\" | \"settles_at\" (soonest first)\n  verifiable: true,     \u002F\u002F optional: filter to markets with verifiable settlement\n  pricesAndImpliedProbabilities: true, \u002F\u002F optional: fetch spot prices and implied probabilities\n});\n\nfor (const market of markets ?? []) {\n  const meta = market.metadata; \u002F\u002F typed as MarketMetadata | null — no cast needed\n  console.log(market.id, meta?.question);\n  \u002F\u002F market.id                        = market address — use this as marketAddress in all SDK calls\n  \u002F\u002F market.appMarketId               = UUID identifying the market in the Delphi app\n  \u002F\u002F market.marketUrl                 = direct link to the market on the Delphi app\n  \u002F\u002F market.implementation            = underlying logic contract (NOT used for SDK calls)\n  \u002F\u002F market.category                  = market category string (e.g. \"crypto\")\n  \u002F\u002F market.verifiable                = true if market uses verifiable settlement\n  \u002F\u002F market.tradingFee                = 18-decimal bigint string (e.g. \"20000000000000000\" = 2%); null if no fee\n  \u002F\u002F                                    convert: Number(market.tradingFee) \u002F 1e18 * 100 → fee percentage\n  \u002F\u002F market.winningOutcomeIdx         = set after settlement, otherwise null\n  \u002F\u002F market.resolvesAt                = ISO timestamp for when market resolves, or null\n  \u002F\u002F market.settlesAt                 = ISO timestamp for scheduled settlement, or null\n  \u002F\u002F market.proof                     = settlement proof string, or null\n  \u002F\u002F market.error                     = resolution error message if settlement failed, or null\n  \u002F\u002F market.fetchResponseStatus       = metadata fetch status string (e.g. \"success\"), or null\n  \u002F\u002F market.metadataUriContentHash    = hex hash of the fetched metadata content (e.g. \"0x9434...\")\n  \u002F\u002F market.dataSources               = data source identifiers, or null\n  \u002F\u002F market.spotPrices                = spot price per outcome as human-readable float (only if pricesAndImpliedProbabilities: true)\n  \u002F\u002F market.spotImpliedProbabilities  = implied probability per outcome as 0–1 float (only if pricesAndImpliedProbabilities: true)\n}\n```\n\n### Get a single market\n\n> **Tip**: See `scripts\u002Fget-market.ts` for a complete working example.\n\n```typescript\nconst market = await client.getMarket({ id: \"\u003Cmarket-id>\", pricesAndImpliedProbabilities: true });\nconst meta = market.metadata; \u002F\u002F typed as MarketMetadata | null — no cast needed\n\u002F\u002F market.id                       = use as marketAddress for all SDK calls (quoteBuy, buyShares, etc.)\n\u002F\u002F market.appMarketId              = UUID identifying the market in the Delphi app\n\u002F\u002F market.marketUrl                = direct link to the market on the Delphi app\n\u002F\u002F market.implementation           = the logic contract address — NOT the marketAddress for SDK calls\n\u002F\u002F market.spotPrices               = spot price per outcome as human-readable float (e.g. [0.6, 0.4])\n\u002F\u002F market.spotImpliedProbabilities = implied probability per outcome as 0–1 float (e.g. [0.6, 0.4])\n```\n\n### Live prices\n\nThe simplest way to get live prices is `pricesAndImpliedProbabilities: true` in `listMarkets` or `getMarket` — the SDK fetches them via multicall and returns human-readable floats on the market object:\n\n```typescript\n\u002F\u002F market.spotPrices[i]               — spot price as float (e.g. 0.6 = 0.60 USDC\u002Fshare)\n\u002F\u002F market.spotImpliedProbabilities[i] — implied probability as 0–1 float (e.g. 0.6 = 60%)\nif (market.spotPrices && market.spotImpliedProbabilities) {\n  for (let i = 0; i \u003C (meta?.outcomes?.length ?? 0); i++) {\n    console.log(`[${i}] price: ${market.spotPrices[i].toFixed(4)} USDC\u002Fshare | prob: ${(market.spotImpliedProbabilities[i] * 100).toFixed(2)}%`);\n  }\n}\n```\n\nFor custom on-chain reads (advanced), use the Gateway ABI directly via viem — see [reference\u002Fonchain.md](reference\u002Fonchain.md).\n\n### Quote buy (read-only, no gas)\n\n> **Tip**: See `scripts\u002Fquote-buy.ts` for a complete working example.\n\n```typescript\nconst { tokensIn } = await client.quoteBuy({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIdx: 0,\n  sharesOut: BigInt(Math.round(10 * 1e18)),  \u002F\u002F 10 shares\n});\n\u002F\u002F tokensIn = USDC cost in 6-decimal bigint\nconst costUsdc = Number(tokensIn) \u002F 1e6;\n```\n\n### Quote sell (read-only, no gas)\n\n> **Tip**: See `scripts\u002Fquote-sell.ts` for a complete working example.\n\n```typescript\nconst { tokensOut } = await client.quoteSell({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIdx: 0,\n  sharesIn: BigInt(Math.round(5 * 1e18)),  \u002F\u002F 5 shares\n});\nconst payoutUsdc = Number(tokensOut) \u002F 1e6;\n```\n\n### Quote redeem \u002F liquidate (read-only, no gas)\n\nFor **closed** markets, spot price no longer reflects what a position is worth — the realizable value is the redemption payout (settled) or liquidation proceeds (expired). These quotes simulate the on-chain `redeem`\u002F`liquidate` via `eth_call` (no gas, no state change) and **throw** if the position isn't redeemable\u002Fliquidatable (e.g. a losing settled outcome, or a market not yet closed), so wrap them in try\u002Fcatch.\n\n> **Tip**: See `scripts\u002Fquote-redeem.ts` and `scripts\u002Fquote-liquidate.ts` for complete working examples.\n\n```typescript\n\u002F\u002F Settled market: payout for the caller's winning shares. account defaults to\n\u002F\u002F the configured signer; pass it to quote for any wallet.\nconst { sharesIn, tokensOut } = await client.quoteRedeem({\n  marketAddress: \"0x...\" as `0x${string}`,\n  account: \"0x...\" as `0x${string}`,   \u002F\u002F optional\n});\nconst payoutUsdc = Number(tokensOut) \u002F 1e6;  \u002F\u002F 0 \u002F throws for a losing outcome\n\n\u002F\u002F Expired market: proceeds from liquidating the given outcomes.\nconst { sharesIn: burned, totalTokensOut } = await client.quoteLiquidate({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIndices: [0, 1],\n  account: \"0x...\" as `0x${string}`,   \u002F\u002F optional\n});\nconst proceedsUsdc = Number(totalTokensOut) \u002F 1e6;\n```\n\n> **Valuing a portfolio across statuses**: use spot (`shares × spotPrice`) only for **open** markets. For **settled** markets value the winning outcome via `quoteRedeem` (losing outcomes are worth 0) and for **expired** markets via `quoteLiquidate`. The Agent TUI's Portfolio tab does exactly this and shows a per-position status badge.\n\n### Buy shares (on-chain, with auto-approval)\n\n> **Tip**: See `scripts\u002Fbuy-shares.ts` for a complete working example.\n\n```typescript\nconst marketAddress = \"0x...\" as `0x${string}`;\nconst outcomeIdx = 0;\nconst sharesOut = BigInt(Math.round(10 * 1e18));  \u002F\u002F 10 shares\n\n\u002F\u002F 1. Quote, and cap the spend with 2% slippage\nconst { tokensIn } = await client.quoteBuy({ marketAddress, outcomeIdx, sharesOut });\nconst maxTokensIn = tokensIn * 102n \u002F 100n;\n\n\u002F\u002F 2. Ensure USDC approval (idempotent — only sends tx if needed).\n\u002F\u002F    Approve maxTokensIn, not tokensIn: the buy can spend up to the cap, so an\n\u002F\u002F    allowance sized to the quote reverts if the price moves within slippage.\nawait client.ensureTokenApproval({ marketAddress, minimumAmount: maxTokensIn });\n\n\u002F\u002F 3. Buy\nconst { transactionHash } = await client.buyShares({\n  marketAddress,\n  outcomeIdx,\n  sharesOut,\n  maxTokensIn,\n});\n```\n\n### Sell shares (on-chain)\n\n> **Tip**: See `scripts\u002Fsell-shares.ts` for a complete working example.\n\n```typescript\nconst sharesIn = BigInt(Math.round(5 * 1e18));\n\n\u002F\u002F 1. Quote\nconst { tokensOut } = await client.quoteSell({ marketAddress, outcomeIdx, sharesIn });\n\n\u002F\u002F 2. Sell with 2% slippage\nconst minTokensOut = tokensOut * 98n \u002F 100n;\nconst { transactionHash } = await client.sellShares({\n  marketAddress,\n  outcomeIdx,\n  sharesIn,\n  minTokensOut,\n});\n```\n\n### List positions\n\n> **Tip**: See `scripts\u002Flist-positions.ts` for a complete working example.\n\n> **Important**: Positions with `shares` equal to `0` (i.e. `BigInt(p.shares) === 0n`) represent fully exited stakes. These cannot be redeemed or liquidated since the wallet holds no shares. Always filter out zero-share positions before attempting redeem or liquidate operations.\n\n```typescript\nconst { positions } = await client.listPositions({\n  wallet: \"0x...\",\n  redeemedOrLiquidated: false,  \u002F\u002F only active positions\n  limit: 50,\n});\n\nfor (const p of positions ?? []) {\n  const shares = Number(BigInt(p.shares)) \u002F 1e18;\n  if (shares === 0) continue; \u002F\u002F no stake — skip\n  console.log(`Market ${p.marketProxy} | Outcome ${p.outcomeIdx} | ${shares} shares`);\n}\n```\n\n### Redeem settled positions\n\n> **Tip**: See `scripts\u002Fredeem.ts` for a complete working example.\n\n> **Important**: Only positions with non-zero shares can be redeemed. If `listPositions` returns a position with `shares === \"0\"`, the wallet has no stake in that market and calling `redeemMarket` will fail or return nothing. Always check shares > 0 before redeeming.\n\n```typescript\n\u002F\u002F Single market\nconst { transactionHash, sharesIn, tokensOut } = await client.redeemMarket({\n  marketAddress: \"0x...\" as `0x${string}`,\n});\n\n\u002F\u002F Batch\nconst { results, totalTokensOut } = await client.redeemPositions({\n  marketAddresses: [\"0x...\", \"0x...\"],\n});\nfor (const r of results) {\n  if (r.success) console.log(`Redeemed ${Number(r.tokensOut!) \u002F 1e6} USDC from ${r.marketAddress}`);\n  else console.error(`Failed ${r.marketAddress}: ${r.error}`);\n}\n```\n\n### Liquidate expired positions\n\n> **Tip**: See `scripts\u002Fliquidate.ts` for a complete working example.\n\nLiquidation is for positions in **expired** markets that were never settled. Unlike redemption (which is for settled markets with a winner), liquidation recovers tokens from markets that expired without resolution.\n\n```typescript\n\u002F\u002F Liquidate a single market — pass all outcome indices you hold\nconst { transactionHash, sharesIn, totalTokensOut } = await client.liquidate({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIndices: [0, 1],  \u002F\u002F all outcome indices with positions\n});\n\u002F\u002F sharesIn: bigint[] — shares burned per outcome index\n\u002F\u002F totalTokensOut: bigint — total USDC recovered across all outcomes\n\n\u002F\u002F Derive outcome indices from listPositions:\nconst { positions } = await client.listPositions({ wallet, redeemedOrLiquidated: false });\nconst outcomeIndices = positions!\n  .filter(p => p.marketProxy === marketAddress && BigInt(p.shares) > 0n)\n  .map(p => Number(p.outcomeIdx));\n```\n\n### Token approval\n\n> **Tip**: See `scripts\u002Ftoken-approval.ts` for a complete working example.\n\n```typescript\n\u002F\u002F Check current allowance\nconst { ownerAddress, allowance } = await client.getTokenAllowance({ marketAddress });\n\n\u002F\u002F Approve unlimited\nawait client.approveToken({ marketAddress });\n\n\u002F\u002F Approve specific amount (50 USDC)\nawait client.approveToken({ marketAddress, amount: 50_000_000n });\n\n\u002F\u002F Idempotent: only approves if current allowance is below minimum\n\u002F\u002F Response always includes current allowance, plus transactionHash if a tx was sent\nconst { approvalNeeded, allowance, transactionHash } = await client.ensureTokenApproval({\n  marketAddress,\n  minimumAmount: requiredTokens,\n  approveAmount: 100_000_000n,  \u002F\u002F optional: amount to approve if needed (defaults to max uint256)\n});\n```\n\n### Check wallet balances\n\n> **Tip**: See `scripts\u002Fget-wallet-balances.ts` for a complete working example.\n\n```typescript\n\u002F\u002F ETH (native gas token)\nconst ethBalance = await client.getEthBalance();\nconsole.log(`ETH: ${(Number(ethBalance) \u002F 1e18).toFixed(6)}`);\n\n\u002F\u002F ERC-20 collateral token (defaults to SDK-configured token address)\nconst tokenAddress = client.getTokenAddress(); \u002F\u002F inspect the configured token address\nconst { balance, decimals } = await client.getErc20BalanceWithDecimals();\nconst formatted = (Number(balance) \u002F 10 ** decimals).toFixed(decimals > 6 ? 6 : decimals);\nconsole.log(`Token (${tokenAddress}): ${formatted}`);\n\n\u002F\u002F Or fetch raw balance only (6-decimal for USDC)\nconst raw = await client.getErc20Balance(); \u002F\u002F uses default token; pass address to override\n```\n\n### Query recent trades via subgraph\n\n> **Tip**: See `scripts\u002Flist-recent-trades.ts` for a complete working example.\n\nThe SDK's `SubgraphClient` queries on-chain event data indexed by a Goldsky subgraph. Access it via `client.getSubgraph()`.\n\n```typescript\nconst subgraph = client.getSubgraph();\n\n\u002F\u002F Convenience method: get buys and sells for a market\nconst { buys, sells } = await subgraph.getMarketTrades(\n  \"0x...\" as string,  \u002F\u002F market proxy address\n  { first: 20 }\n);\n\nfor (const buy of buys) {\n  const cost = Number(BigInt(buy.tokensIn ?? \"0\")) \u002F 1e6;\n  const shares = Number(BigInt(buy.sharesOut ?? \"0\")) \u002F 1e18;\n  const time = new Date(Number(buy.timestamp_) * 1000).toLocaleString();\n  console.log(`BUY ${time} | ${cost.toFixed(4)} USDC → ${shares.toFixed(4)} shares`);\n}\n\n\u002F\u002F Arbitrary GraphQL: recent buys across all markets\n\u002F\u002F SubgraphBuy, SubgraphSell, SubgraphMeta are all exported from the SDK for typing:\n\u002F\u002F   import type { SubgraphBuy, SubgraphSell, SubgraphMeta } from \"@gensyn-ai\u002Fgensyn-delphi-sdk\";\nconst data = await subgraph.query\u003C{ gatewayBuys: SubgraphBuy[] }>(`{\n  gatewayBuys(first: 5, orderBy: timestamp_, orderDirection: desc) {\n    id buyer marketProxy tokensIn sharesOut timestamp_\n  }\n}`);\n\n\u002F\u002F Check subgraph indexing status (block number, deployment, error flag)\nconst meta = await subgraph.getMeta();\nconsole.log(`Block: ${meta.block.number}, indexing errors: ${meta.hasIndexingErrors}`);\n```\n\nAvailable entities: `gatewayBuys`, `gatewaySells`, `gatewayRedemptions`, `gatewayLiquidations`, `gatewayMarketSettleds`, `gatewayMarketFaileds`, `marketResolutionRequesteds`. All support filtering (`where`), ordering (`orderBy` + `orderDirection`), and pagination (`first` + `skip`). Note `gatewayWinnerSubmitteds` does **not** exist on the automated-settlement subgraph — querying it is a hard GraphQL error; use `gatewayMarketSettleds`, which has the same payload.\n\n### TUI\n\nThe user can visualize what the agent is doing live with the read-only Agent TUI dashboard — portfolio, positions, activity, markets, an Edge View and an Agent Logs reasoning stream — via `npx tsx scripts\u002Fagent-tui\u002Findex.tsx \u003Cwallet-address> \u003Ctestnet|mainnet|competition-testnet>` (or `npm run agent-tui -- \u003Cwallet-address> \u003Ctestnet|mainnet|competition-testnet>`). The two helpers below feed its Agent Logs and Edge View panels.\n\n#### Tracing your reasoning (Agent Logs)\n\n`log-event` populates the Agent TUI's **Agent Logs** panel. Use it at genuine decision points: log **why** you're acting (`THINK`), then log the action you took. Event types:\n\n| Type | Use for |\n|------|---------|\n| `THINK` | The *reasoning* — what you observed, why the market looks mispriced, what edge you see, why this side and size. The important one. |\n| `BUY` | A buy you executed. |\n| `SELL` | A sell you executed. |\n| `LIQUIDATE` | Liquidating positions in an expired market. |\n| `REDEEM` | Redeeming winnings from a settled market. |\n| `SKIP` | A market you looked at and deliberately passed on (and why). |\n\n```bash\nnpx tsx scripts\u002Flog-event.ts THINK \"\u003Cthe reasoning — why this trade>\"\nnpx tsx scripts\u002Flog-event.ts BUY   \"\u003Cthe action you took>\"\n```\n\n- **`THINK`** is the important one — capture the reasoning. This is what the Agent Logs panel exists to show.\n- The **action** types (`BUY`\u002F`SELL`\u002F`LIQUIDATE`\u002F`REDEEM`) are short notes of what followed the think. Keep them brief — the **My Activity** tab already shows the trade mechanics (amounts, prices, tx hashes), so don't restate them.\n- Use **`SKIP`** to record markets you evaluated but passed on, so the log shows what you considered, not just what you traded.\n\nDo **not** just describe the order. `\"Buy 10 YES on Wild Pandas, 2% slippage\"` is exactly what Activity already shows — log the *why* instead.\n\nGood:\n\n```bash\nnpx tsx scripts\u002Flog-event.ts THINK \"BTC $99,999 by Jun 31: ~12 days left and price is still ~\\$25k away — that move is unlikely, yet the market prices NO at only 71%. Taking NO; small testnet size to validate.\"\nnpx tsx scripts\u002Flog-event.ts BUY   \"10 NO on BTC $99,999\"\n```\n\nLog a THINK→action pair at genuine decision points, not every routine read. The `\u003Ctype>` is case-insensitive and normalised to upper case. Events append to `$DELPHI_AGENT_LOG` (default `~\u002F.delphi\u002Fagent-events.jsonl`); the file is created automatically.\n\n#### Computing edge before trading (Edge View)\n\n**Edge is the core trade signal — always compute it before you autonomously decide to buy or sell a market.** Edge is the gap between your own probability estimate for an outcome and the market's live implied probability:\n\n```\nedge = your probability − market's implied probability\n```\n\nA positive edge means the outcome is **underpriced** relative to your view (a buy candidate); a negative edge means it's **overpriced** (a sell \u002F avoid). The bigger the absolute gap, the stronger the signal.\n\n`scripts\u002Fcompute-edge.ts` fetches the market's live implied probability, computes the edge against your estimate, prints the signal, and persists it so it shows up — ranked by gap size — in the Agent TUI's **Edge View** (Overview screen).\n\n```bash\n# Single market outcome: your probability is 0.30 (or pass 30 for percent)\nnpx tsx scripts\u002Fcompute-edge.ts 0x1234…abcd 1 0.30\n\n# Several at once — repeat the (market, outcome, prob) triple\nnpx tsx scripts\u002Fcompute-edge.ts 0x1234…abcd 1 0.30  0x5678…ef01 0 0.62\n```\n\n`\u003Cyour-prob>` is your estimate for that outcome (0–1 like `0.30`, or a percent like `30`); `\u003Cmarket-address>` is the market id from `listMarkets`\u002F`getMarket`, and `\u003Coutcome-idx>` is the outcome's index. Re-running for the same (market, outcome) supersedes the previous value (latest wins).\n\n**Required decision flow when deciding whether to buy\u002Fsell a market autonomously:**\n\n1. Form your own probability estimate for the outcome.\n2. Run `compute-edge.ts` to compare it against the market's live implied probability.\n3. Use the resulting edge to drive the decision — only trade where the edge is meaningfully positive (buy) or negative (sell), and prefer larger gaps. If the edge is small or the wrong sign, `SKIP`.\n4. Then `log-event THINK` your reasoning (referencing the edge) and `log-event BUY`\u002F`SELL` the action you took.\n\nEdges persist to `$DELPHI_AGENT_EDGES` (default `~\u002F.delphi\u002Fagent-edges.jsonl`); the file is created automatically. The Edge View re-joins your stored probability against the live market price on every refresh, so the displayed edge stays current as the market moves.\n\n## Error handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `TokensInExceedsMax` | Price moved above `maxTokensIn` | Re-quote, increase slippage |\n| `TokensOutBelowMin` | Price moved below `minTokensOut` | Re-quote, increase slippage |\n| `MarketNotOpen` | Market is closed or settled | Check `market.status` first |\n| `SharesInExceedSupply` | Selling more shares than held | Check position before selling |\n| `Requires apiKey` | Missing `DELPHI_API_ACCESS_KEY` | Set env var |\n| `Requires rpcUrl` | Missing `GENSYN_RPC_URL` | Set env var or let network default apply |\n| `Requires privateKey` | Missing `WALLET_PRIVATE_KEY` | Set env var or switch to CDP signer |\n| `CDP signing requires ...` | Missing CDP env vars | Set all `CDP_` vars |\n\n## Reference files (load on demand)\n\n| File | When to load |\n|------|-------------|\n| [reference\u002Fmarkets.md](reference\u002Fmarkets.md) | Full `listMarkets`\u002F`getMarket` params, `Market` type schema, metadata structure |\n| [reference\u002Ftrading.md](reference\u002Ftrading.md) | Trading mechanics, slippage formulas, parimutuel pricing explainer |\n| [reference\u002Fpositions.md](reference\u002Fpositions.md) | `Position`\u002F`Trade` type schemas, batch redemption patterns, portfolio estimation |\n| [reference\u002Fonchain.md](reference\u002Fonchain.md) | Full Gateway ABI function list, direct `viem` read patterns, signing config |\n| [reference\u002Fsubgraph.md](reference\u002Fsubgraph.md) | Goldsky subgraph GraphQL schema, `SubgraphClient` API, entity types, filtering, raw query examples |\n| [reference\u002Ffunding.md](reference\u002Ffunding.md) | Getting ETH and USDC onto Gensyn (testnet faucet, OP Stack bridge, LayerZero USDC bridge) |\n| [reference\u002Fcompetition.md](reference\u002Fcompetition.md) | **The agent trading competition**: LMSR vs parimutuel pricing, registration, trading differences, the leaderboard, subgraph differences, failure modes |\n","# Delphi\n\nGensyn Delphi is a set of tools for deploying and interacting with information markets on Gensyn. Markets are user-owned and permissionless — Gensyn does not control markets, custody funds, or settle trades. The API is maintained for convenience. All interactions go through `DelphiClient` from the `@gensyn-ai\u002Fgensyn-delphi-sdk` package.\n\n> **Trading the agent competition?** The competition is a separate network\n> (`competition-testnet`) using **LMSR** markets, not the parimutuel markets\n> described below. The pricing maths, the token, the registration step and the\n> leaderboard are all different — read\n> **[reference\u002Fcompetition.md](reference\u002Fcompetition.md)** before trading, and\n> do not apply the parimutuel section below to it.\n\n## How dynamic parimutuel markets work\n\n> This section describes **Delphi testnet\u002Fmainnet**. The competition uses LMSR,\n> where prices sum to 1, spot price *is* the implied probability, and a winning\n> share always pays exactly 1 token. See\n> [reference\u002Fcompetition.md](reference\u002Fcompetition.md).\n\nDynamic parimutuel markets are betting or information systems where prices (odds) emerge endogenously from the distribution of all participants' wagers rather than being set by a market maker. As new bets flow in, the implied probabilities continuously update: outcomes attracting more capital see their odds shorten (higher implied probability), while less-backed outcomes become cheaper. Liquidity is pooled across all participants, so traders are effectively betting against the aggregate market rather than a counterparty, and the depth of the pool determines how sensitive prices are to new information. This creates a self-adjusting mechanism where prices reflect both current beliefs and the marginal impact of incoming liquidity, often leading to smoother, more stable updates than thin order-book markets while still converging toward consensus probabilities over time.\n\nImportant: spot price and expected payout move independently, and payouts are not fixed. Unlike fixed-payout markets (e.g. Polymarket) where a winning share always redeems for exactly $1, Delphi DPM payouts are determined at settlement: the entire pool is divided among winning shareholders, so payout per winning share=total winning shares\u002Ftotal pool.\n\t\nThe spot price is the marginal cost to buy the next share at the current moment — i.e. the local slope of the pricing curve. A probability-like quantity can be inferred from the current pool state and expected redemption value, but it is not identical to the spot price, and the two can diverge substantially depending on liquidity distribution and market depth.\n\n## When to use this skill\n\n- User wants to list, search, or browse information markets\n- User wants prices, probabilities, or details for a specific market\n- User wants to buy or sell outcome shares\n- User wants to check their portfolio, positions, or trade history\n- User wants to redeem winnings from a resolved market\n- User wants to liquidate positions in an expired (unresolved) market\n- If the user asks you to create a market, remind them that markets not created on the UI will not show up on the UI\n- User wants to check or set token approval for trading\n- User wants to query historical on-chain trade data (buys, sells, redemptions, liquidations)\n- User wants recent trades for a market or wallet via the Goldsky subgraph\n- User wants to check their wallet ETH or token balances\n- User wants to get ETH or USDC to fund their wallet for trading (testnet faucet, bridging)\n- User wants to trade in, register for, or check their standing in the **agent trading competition** → load [reference\u002Fcompetition.md](reference\u002Fcompetition.md)\n- User mentions the competition, the leaderboard, `agent-competition.gensyn.ai`, or sets `DELPHI_NETWORK=competition-testnet`\n- Any question about Delphi information markets, or on-chain trading on Gensyn\n\n## Installation\n\n```bash\nnpm install\n```\n\nThis will install all required dependencies including the SDK, dotenv, viem, and development tools.\n\n## Example scripts\n\nThis repository includes working example scripts in the `scripts\u002F` folder that demonstrate all common operations. These provide a paved path for agents to reference or run directly:\n\n| Script | Purpose | Usage |\n|--------|---------|-------|\n| `scripts\u002Flist-markets.ts` | List and filter markets | `npx tsx scripts\u002Flist-markets.ts [status] [category] [limit]` |\n| `scripts\u002Fget-market.ts` | Get details for a specific market | `npx tsx scripts\u002Fget-market.ts \u003Cmarket-id>` |\n| `scripts\u002Fquote-buy.ts` | Get buy quote (read-only) | `npx tsx scripts\u002Fquote-buy.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares>` |\n| `scripts\u002Fquote-sell.ts` | Get sell quote (read-only) | `npx tsx scripts\u002Fquote-sell.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares>` |\n| `scripts\u002Fquote-redeem.ts` | Quote redemption payout for a settled market (read-only) | `npx tsx scripts\u002Fquote-redeem.ts \u003Cmarket-address> [wallet-address]` |\n| `scripts\u002Fquote-liquidate.ts` | Quote liquidation proceeds for an expired market (read-only) | `npx tsx scripts\u002Fquote-liquidate.ts \u003Cmarket-address> \u003Coutcome-idx>[,\u003Cidx>...] [wallet-address]` |\n| `scripts\u002Fbuy-shares.ts` | Buy shares (on-chain) | `npx tsx scripts\u002Fbuy-shares.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares> [slippage-pct]` |\n| `scripts\u002Fsell-shares.ts` | Sell shares (on-chain) | `npx tsx scripts\u002Fsell-shares.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cshares> [slippage-pct]` |\n| `scripts\u002Flist-positions.ts` | List wallet positions | `npx tsx scripts\u002Flist-positions.ts [wallet-address]` |\n| `scripts\u002Fredeem.ts` | Redeem winnings from settled markets | `npx tsx scripts\u002Fredeem.ts \u003Cmarket-address> [market-address ...]` |\n| `scripts\u002Fliquidate.ts` | Liquidate positions in expired markets | `npx tsx scripts\u002Fliquidate.ts \u003Cmarket-address> [market-address ...]` |\n| `scripts\u002Ftoken-approval.ts` | Check or set token approval | `npx tsx scripts\u002Ftoken-approval.ts \u003Cmarket-address> [amount\\|unlimited]` |\n| `scripts\u002Flist-recent-trades.ts` | List recent trades via subgraph | `npx tsx scripts\u002Flist-recent-trades.ts \u003Cmarket-proxy-address> [limit]` |\n| `scripts\u002Fagent-tui\u002F` | Live read-only Ink dashboard (Overview — with Edge View + Agent Logs — · Portfolio · My Activity · Markets, with market drill-down) | `npx tsx scripts\u002Fagent-tui\u002Findex.tsx \u003Cwallet-address> \u003Ctestnet\\|mainnet\\|competition-testnet>` (both required) · keys: `1`-`4` screens, `↑↓` select, `⏎` detail, `r` refresh, `q` quit (add `--once` for a single frame) |\n| `scripts\u002Flog-event.ts` | Append a traceable event to the agent event log (Agent TUI → Overview → Agent Logs) | `npx tsx scripts\u002Flog-event.ts \u003Ctype> \"\u003Cmessage>\"` |\n| `scripts\u002Fcompute-edge.ts` | Compute edge (your prob − market's implied prob) for one or more market outcomes; prints the signal and feeds the Agent TUI → Overview → Edge View | `npx tsx scripts\u002Fcompute-edge.ts \u003Cmarket-address> \u003Coutcome-idx> \u003Cyour-prob> [\u003Cmarket> \u003Coutcome> \u003Cprob> ...]` |\n| `scripts\u002Fget-wallet-balances.ts` | Check ETH and collateral token balances | `npx tsx scripts\u002Fget-wallet-balances.ts` |\n| `scripts\u002Ftestnet-faucet.ts` | Claim 1,000 testnet USDC from the Gensyn faucet | `npx tsx scripts\u002Ftestnet-faucet.ts` |\n| `scripts\u002Fbridge-eth-to-gensyn-testnet.ts` | Bridge ETH from Sepolia to Gensyn Testnet | `npx tsx scripts\u002Fbridge-eth-to-gensyn-testnet.ts \u003Camount-eth>` |\n| `scripts\u002Fbridge-eth-to-gensyn-mainnet.ts` | Bridge ETH from Ethereum mainnet to Gensyn Mainnet | `npx tsx scripts\u002Fbridge-eth-to-gensyn-mainnet.ts \u003Camount-eth>` |\n| `scripts\u002Fbridge-usdc-to-gensyn-mainnet.ts` | Bridge USDC from Ethereum mainnet to Gensyn Mainnet via LayerZero | `npx tsx scripts\u002Fbridge-usdc-to-gensyn-mainnet.ts \u003Camount-usdc> [slippage-pct]` |\n\nAll scripts use the shared client setup from `scripts\u002Fclient.ts` which handles environment variable configuration automatically. You can also run them via npm scripts: `npm run list-markets`, `npm run buy-shares`, etc.\n\n### Before running scripts\n\nBefore running any script in `scripts\u002F`, ensure the runtime is prepared.\n\n**Required setup checklist:**\n1. Install dependencies by running `npm install`.\n2. Verify required environment variables are set:\n   - Check for a `.env` file in the project root (preferred), or\n   - Verify environment variables are exported in the shell session\n3. If either check fails, fix it before running any task script.\n4. Do not call `scripts\u002F*.ts` until setup succeeds.\n5. **Do not pass environment variables inline with commands** - use `.env` file or `export` statements instead.\n\n## Environment variables\n\nOnly two things are **mandatory**: your API key and wallet signing credentials. Everything else has sensible defaults. The SDK defaults to `testnet` if `DELPHI_NETWORK` is not set.\n\n**Agent instructions for missing env vars:**\n\nWhen required environment variables are not set, do NOT ask the user for their values in chat. Instead:\n\n1. Tell the user which variables are needed (list them below).\n2. Tell them where to get each value.\n3. Ask them to create a `.env` file in the project root themselves with those values.\n4. Wait for them to confirm the file is created before proceeding.\n5. **NEVER read the `.env` file** — treat it as a secret store the agent must not access.\n\n**Mandatory variables to communicate to the user:**\n\n| Variable | Where to get it |\n|----------|----------------|\n| `DELPHI_API_ACCESS_KEY` | **Testnet:** Generate at https:\u002F\u002Fdelphi-api-access.gensyn.ai\u002F · **Mainnet:** Generate at https:\u002F\u002Fapi-access.delphi.fyi\u002F |\n\n**Plus one of these signing options (tell the user to pick one):**\n\n**Option A — Private key**\n| Variable | Description |\n|----------|-------------|\n| `DELPHI_SIGNER_TYPE` | Set to `private_key` |\n| `WALLET_PRIVATE_KEY` | `0x`-prefixed hex private key for their wallet |\n\n**Option B — Coinbase CDP Server Wallet (default signer, no `DELPHI_SIGNER_TYPE` needed)**\n| Variable | Where to get it |\n|----------|----------------|\n| `CDP_API_KEY_ID` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_API_KEY_SECRET` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_WALLET_SECRET` | Server Wallet v2 Quickstart (https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n| `CDP_WALLET_ADDRESS` | Their CDP wallet address (`0x`-prefixed) (see https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fquickstart) |\n\nMake sure to also convey the following 2 points to the user -\n- For the CDP option, private keys are secured in Coinbase's Trusted Execution Environment (TEE) and never leave the TEE. See [Server Wallet v2 docs](https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fserver-wallets\u002Fv2\u002Fintroduction\u002Fwelcome) for details.\n\n- To execute Delphi transactions, your signer wallet must have `ETH` (for gas) and `USDC` on the Gensyn chain.\n\n### Network selection\n\n| Variable | Values | Default |\n|----------|--------|---------|\n| `DELPHI_NETWORK` | `\"testnet\"` \\| `\"mainnet\"` \\| `\"competition-testnet\"` | `\"testnet\"` |\n\nThe SDK defaults to testnet — `DELPHI_NETWORK` is optional. Only set it if the user explicitly wants mainnet or the competition.\n\nWhen `DELPHI_NETWORK=testnet` (default), the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-testnet.g.alchemy.com\u002Fpublic`\n- Chain ID: `685685`\n- Gateway: `0x22ea355D7218Dc86b4c83732cBbd01f7Ff2332b3` (automated settlement)\n- Factory: `0x97d2b3F0614C8189343A38094629FCE2910b727A`\n- Legacy gateway: `0x7b8FDBD187B0Be5e30e48B1995df574A62667147` (pre-automated-settlement markets)\n- Token: `0x0724D6079b986F8e44bDafB8a09B60C0bd6A45a1`\n- API URL: `https:\u002F\u002Fdelphi-api.gensyn.ai\u002F`\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-testnet-autoset\u002F1.0.0\u002Fgn`\n\nWhen `DELPHI_NETWORK=mainnet`, the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-mainnet.g.alchemy.com\u002Fpublic`\n- Chain ID: `685689`\n- Gateway: `0x982a67aE92D8de361957249fB2BB4a62BCc6A8d5` (automated settlement)\n- Factory: `0x9C73417f79a1361c6aF9Bd828343badEE1b84936`\n- Legacy gateway: `0x4e4e85c52E0F414cc67eE88d0C649Ec81698d700` (pre-automated-settlement markets)\n- Token: `0x5b32c997211621d55a89Cc5abAF1cC21F3A6ddF5`\n- API URL: `https:\u002F\u002Fapi.delphi.fyi\u002F`\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-mainnet-autoset\u002F1.0.0\u002Fgn`\n\nWhen `DELPHI_NETWORK=competition-testnet` (the agent trading competition), the SDK automatically uses:\n- RPC URL: `https:\u002F\u002Fgensyn-testnet.g.alchemy.com\u002Fpublic` (same chain as testnet)\n- Chain ID: `685685`\n- Gateway: `0x097599c9D966fF496284b892A8F13BF885b258ef` (**LmsrGateway** — single deployment, no legacy)\n- Factory: `0xEa9D0a78d0209916e88e363B8FDa3e23206Ff49b`\n- Token: `0x8A2d75753362Eb5D5669a2c22cbf394b26a0571F` (`TST`, 6 decimals — **not** USDC)\n- API URL: `https:\u002F\u002Fdelphi-api.gensyn.ai\u002F` (shared testnet deployment; the client sends `X-Delphi-Mode: competition` automatically)\n- Subgraph URL: `https:\u002F\u002Fapi.goldsky.com\u002Fapi\u002Fpublic\u002Fproject_cmnoqdag1obop01z3efnu8ssq\u002Fsubgraphs\u002Fdelphi-agent-competition\u002F1.0.0\u002Fgn`\n- Leaderboard: `https:\u002F\u002Fagent-competition.gensyn.ai`\n\n> **The competition is not just different addresses.** It uses LMSR pricing\n> (winning shares pay exactly 1 token, prices sum to 1), needs a **testnet**\n> API key, and needs your wallet registered via DoraHacks before you can rank.\n> Read **[reference\u002Fcompetition.md](reference\u002Fcompetition.md)** before trading it.\n\nDelphi runs two deployments side by side. Every new market is created on the\nautomated-settlement gateway, which is settled by an oracle; older markets live on the\nlegacy gateway. Each gateway rejects the other's markets, so the SDK resolves the right\none per market — pass any market address and it works. The subgraph default, however,\ncovers the automated deployment only: subgraph queries for a legacy market come back\nempty (see `reference\u002Fsubgraph.md`).\n\nBecause settlement is now automated, a market can end up `failed` — the oracle ran but\ncould not resolve the question. A `failed` market has **no winning outcome**, so\n`redeemMarket()` reverts and funds are recovered with `liquidate()`, exactly as for\n`expired`. Full status list: `open`, `awaiting_settlement`, `settled`, `expired`,\n`failed`.\n\n> The addresses and subgraph endpoints above, plus `client.resolveGateway()`,\n> `client.getMarketStatus()` and `subgraph.getMarketSettlement()`, require\n> `@gensyn-ai\u002Fgensyn-delphi-sdk@^2.0.0` (pinned in `package.json`). On an older SDK the\n> defaults still point at the legacy gateway and those methods do not exist.\n\n### Optional overrides\n\nThese override the network defaults if you need to point at a custom endpoint:\n\n| Variable | Description |\n|----------|-------------|\n| `GENSYN_RPC_URL` | Custom RPC endpoint |\n| `GENSYN_CHAIN_ID` | Custom chain ID |\n| `DELPHI_GATEWAY_CONTRACT` | Custom gateway address. **Pins every call to this gateway and disables per-market routing** — calls for markets it does not own will revert |\n| `DELPHI_LEGACY_GATEWAY_CONTRACT` | Custom legacy gateway address |\n| `DELPHI_FACTORY_CONTRACT` | Custom automated-settlement factory (used to route markets) |\n| `DELPHI_LEGACY_FACTORY_CONTRACT` | Custom legacy factory (used to route markets) |\n| `DELPHI_API_BASE_URL` | Custom API base URL |\n| `DELPHI_SUBGRAPH_URL` | Custom Goldsky subgraph endpoint |\n| `DELPHI_TOKEN_ADDRESS` | Override the ERC-20 collateral token address |\n| `DELPHI_SIGNER_TYPE` | `\"private_key\"` or `\"cdp_server_wallet\"` (default) |\n| `DELPHI_COMPETITION_ID` | Competition UUID scoping market reads in `list-markets.ts`, `get-market.ts` and the Agent TUI (competition networks only; ignored otherwise). Unset = the active competition |\n\n## Client setup\n\n```typescript\nimport {\n  DelphiClient,\n  SubgraphClient,\n  createPrivateKeySigner,\n  createCdpSigner,\n} from \"@gensyn-ai\u002Fgensyn-delphi-sdk\";\n\n\u002F\u002F All config is read from environment variables automatically.\nconst client = new DelphiClient();\n```\n\n## Units\n\n| Type | Raw representation | Human conversion |\n|------|-------------------|-----------------|\n| Shares | 18-decimal bigint | `1n * 10n**18n` = 1 share |\n| USDC | 6-decimal bigint | `1_000_000n` = 1 USDC |\n| Implied probability (on-chain bigint) | 18-decimal (1e18 = 100%) | `5n * 10n**17n` = 50% |\n| Spot price (on-chain bigint) | 6-decimal (1e6 = 1.0 USDC\u002Fshare) | `600_000n` = 0.60 USDC\u002Fshare |\n| `market.spotPrices[i]` | plain `number` float | `0.6` = 0.60 USDC\u002Fshare — already human-readable |\n| `market.spotImpliedProbabilities[i]` | plain `number` float (0–1) | `0.6` = 60% — already human-readable |\n\n```typescript\n\u002F\u002F Human → raw bigint (inputs to SDK)\nconst sharesToBigint = (n: number) => BigInt(Math.round(n * 1e18));\nconst usdcToBigint   = (n: number) => BigInt(Math.round(n * 1e6));\n\n\u002F\u002F Raw bigint → display string\nconst toUsdc      = (n: bigint) => `${(Number(n) \u002F 1e6).toFixed(6)} USDC`;\nconst toShares    = (n: bigint) => `${(Number(n) \u002F 1e18).toFixed(4)} shares`;\nconst toProb      = (n: bigint) => `${(Number(n) \u002F 1e18 * 100).toFixed(2)}%`;\nconst toSpotPrice = (n: bigint) => `${(Number(n) \u002F 1e6).toFixed(4)} USDC\u002Fshare`;\n```\n\n## Core patterns\n\n> **Tip**: See `scripts\u002Flist-markets.ts` for a complete working example.\n\n### List markets\n\n```typescript\nconst { markets } = await client.listMarkets({\n  status: \"open\",        \u002F\u002F \"open\" | \"awaiting_settlement\" | \"settled\" | \"expired\"\n  category: \"crypto\",   \u002F\u002F crypto, culture, economics, miscellaneous, politics, sports\n  limit: 20,\n  skip: 0,\n  orderBy: \"liquidity\", \u002F\u002F \"liquidity\" (default) | \"created\" | \"settles_at\" (soonest first)\n  verifiable: true,     \u002F\u002F optional: filter to markets with verifiable settlement\n  pricesAndImpliedProbabilities: true, \u002F\u002F optional: fetch spot prices and implied probabilities\n});\n\nfor (const market of markets ?? []) {\n  const meta = market.metadata; \u002F\u002F typed as MarketMetadata | null — no cast needed\n  console.log(market.id, meta?.question);\n  \u002F\u002F market.id                        = market address — use this as marketAddress in all SDK calls\n  \u002F\u002F market.appMarketId               = UUID identifying the market in the Delphi app\n  \u002F\u002F market.marketUrl                 = direct link to the market on the Delphi app\n  \u002F\u002F market.implementation            = underlying logic contract (NOT used for SDK calls)\n  \u002F\u002F market.category                  = market category string (e.g. \"crypto\")\n  \u002F\u002F market.verifiable                = true if market uses verifiable settlement\n  \u002F\u002F market.tradingFee                = 18-decimal bigint string (e.g. \"20000000000000000\" = 2%); null if no fee\n  \u002F\u002F                                    convert: Number(market.tradingFee) \u002F 1e18 * 100 → fee percentage\n  \u002F\u002F market.winningOutcomeIdx         = set after settlement, otherwise null\n  \u002F\u002F market.resolvesAt                = ISO timestamp for when market resolves, or null\n  \u002F\u002F market.settlesAt                 = ISO timestamp for scheduled settlement, or null\n  \u002F\u002F market.proof                     = settlement proof string, or null\n  \u002F\u002F market.error                     = resolution error message if settlement failed, or null\n  \u002F\u002F market.fetchResponseStatus       = metadata fetch status string (e.g. \"success\"), or null\n  \u002F\u002F market.metadataUriContentHash    = hex hash of the fetched metadata content (e.g. \"0x9434...\")\n  \u002F\u002F market.dataSources               = data source identifiers, or null\n  \u002F\u002F market.spotPrices                = spot price per outcome as human-readable float (only if pricesAndImpliedProbabilities: true)\n  \u002F\u002F market.spotImpliedProbabilities  = implied probability per outcome as 0–1 float (only if pricesAndImpliedProbabilities: true)\n}\n```\n\n### Get a single market\n\n> **Tip**: See `scripts\u002Fget-market.ts` for a complete working example.\n\n```typescript\nconst market = await client.getMarket({ id: \"\u003Cmarket-id>\", pricesAndImpliedProbabilities: true });\nconst meta = market.metadata; \u002F\u002F typed as MarketMetadata | null — no cast needed\n\u002F\u002F market.id                       = use as marketAddress for all SDK calls (quoteBuy, buyShares, etc.)\n\u002F\u002F market.appMarketId              = UUID identifying the market in the Delphi app\n\u002F\u002F market.marketUrl                = direct link to the market on the Delphi app\n\u002F\u002F market.implementation           = the logic contract address — NOT the marketAddress for SDK calls\n\u002F\u002F market.spotPrices               = spot price per outcome as human-readable float (e.g. [0.6, 0.4])\n\u002F\u002F market.spotImpliedProbabilities = implied probability per outcome as 0–1 float (e.g. [0.6, 0.4])\n```\n\n### Live prices\n\nThe simplest way to get live prices is `pricesAndImpliedProbabilities: true` in `listMarkets` or `getMarket` — the SDK fetches them via multicall and returns human-readable floats on the market object:\n\n```typescript\n\u002F\u002F market.spotPrices[i]               — spot price as float (e.g. 0.6 = 0.60 USDC\u002Fshare)\n\u002F\u002F market.spotImpliedProbabilities[i] — implied probability as 0–1 float (e.g. 0.6 = 60%)\nif (market.spotPrices && market.spotImpliedProbabilities) {\n  for (let i = 0; i \u003C (meta?.outcomes?.length ?? 0); i++) {\n    console.log(`[${i}] price: ${market.spotPrices[i].toFixed(4)} USDC\u002Fshare | prob: ${(market.spotImpliedProbabilities[i] * 100).toFixed(2)}%`);\n  }\n}\n```\n\nFor custom on-chain reads (advanced), use the Gateway ABI directly via viem — see [reference\u002Fonchain.md](reference\u002Fonchain.md).\n\n### Quote buy (read-only, no gas)\n\n> **Tip**: See `scripts\u002Fquote-buy.ts` for a complete working example.\n\n```typescript\nconst { tokensIn } = await client.quoteBuy({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIdx: 0,\n  sharesOut: BigInt(Math.round(10 * 1e18)),  \u002F\u002F 10 shares\n});\n\u002F\u002F tokensIn = USDC cost in 6-decimal bigint\nconst costUsdc = Number(tokensIn) \u002F 1e6;\n```\n\n### Quote sell (read-only, no gas)\n\n> **Tip**: See `scripts\u002Fquote-sell.ts` for a complete working example.\n\n```typescript\nconst { tokensOut } = await client.quoteSell({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIdx: 0,\n  sharesIn: BigInt(Math.round(5 * 1e18)),  \u002F\u002F 5 shares\n});\nconst payoutUsdc = Number(tokensOut) \u002F 1e6;\n```\n\n### Quote redeem \u002F liquidate (read-only, no gas)\n\nFor **closed** markets, spot price no longer reflects what a position is worth — the realizable value is the redemption payout (settled) or liquidation proceeds (expired). These quotes simulate the on-chain `redeem`\u002F`liquidate` via `eth_call` (no gas, no state change) and **throw** if the position isn't redeemable\u002Fliquidatable (e.g. a losing settled outcome, or a market not yet closed), so wrap them in try\u002Fcatch.\n\n> **Tip**: See `scripts\u002Fquote-redeem.ts` and `scripts\u002Fquote-liquidate.ts` for complete working examples.\n\n```typescript\n\u002F\u002F Settled market: payout for the caller's winning shares. account defaults to\n\u002F\u002F the configured signer; pass it to quote for any wallet.\nconst { sharesIn, tokensOut } = await client.quoteRedeem({\n  marketAddress: \"0x...\" as `0x${string}`,\n  account: \"0x...\" as `0x${string}`,   \u002F\u002F optional\n});\nconst payoutUsdc = Number(tokensOut) \u002F 1e6;  \u002F\u002F 0 \u002F throws for a losing outcome\n\n\u002F\u002F Expired market: proceeds from liquidating the given outcomes.\nconst { sharesIn: burned, totalTokensOut } = await client.quoteLiquidate({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIndices: [0, 1],\n  account: \"0x...\" as `0x${string}`,   \u002F\u002F optional\n});\nconst proceedsUsdc = Number(totalTokensOut) \u002F 1e6;\n```\n\n> **Valuing a portfolio across statuses**: use spot (`shares × spotPrice`) only for **open** markets. For **settled** markets value the winning outcome via `quoteRedeem` (losing outcomes are worth 0) and for **expired** markets via `quoteLiquidate`. The Agent TUI's Portfolio tab does exactly this and shows a per-position status badge.\n\n### Buy shares (on-chain, with auto-approval)\n\n> **Tip**: See `scripts\u002Fbuy-shares.ts` for a complete working example.\n\n```typescript\nconst marketAddress = \"0x...\" as `0x${string}`;\nconst outcomeIdx = 0;\nconst sharesOut = BigInt(Math.round(10 * 1e18));  \u002F\u002F 10 shares\n\n\u002F\u002F 1. Quote, and cap the spend with 2% slippage\nconst { tokensIn } = await client.quoteBuy({ marketAddress, outcomeIdx, sharesOut });\nconst maxTokensIn = tokensIn * 102n \u002F 100n;\n\n\u002F\u002F 2. Ensure USDC approval (idempotent — only sends tx if needed).\n\u002F\u002F    Approve maxTokensIn, not tokensIn: the buy can spend up to the cap, so an\n\u002F\u002F    allowance sized to the quote reverts if the price moves within slippage.\nawait client.ensureTokenApproval({ marketAddress, minimumAmount: maxTokensIn });\n\n\u002F\u002F 3. Buy\nconst { transactionHash } = await client.buyShares({\n  marketAddress,\n  outcomeIdx,\n  sharesOut,\n  maxTokensIn,\n});\n```\n\n### Sell shares (on-chain)\n\n> **Tip**: See `scripts\u002Fsell-shares.ts` for a complete working example.\n\n```typescript\nconst sharesIn = BigInt(Math.round(5 * 1e18));\n\n\u002F\u002F 1. Quote\nconst { tokensOut } = await client.quoteSell({ marketAddress, outcomeIdx, sharesIn });\n\n\u002F\u002F 2. Sell with 2% slippage\nconst minTokensOut = tokensOut * 98n \u002F 100n;\nconst { transactionHash } = await client.sellShares({\n  marketAddress,\n  outcomeIdx,\n  sharesIn,\n  minTokensOut,\n});\n```\n\n### List positions\n\n> **Tip**: See `scripts\u002Flist-positions.ts` for a complete working example.\n\n> **Important**: Positions with `shares` equal to `0` (i.e. `BigInt(p.shares) === 0n`) represent fully exited stakes. These cannot be redeemed or liquidated since the wallet holds no shares. Always filter out zero-share positions before attempting redeem or liquidate operations.\n\n```typescript\nconst { positions } = await client.listPositions({\n  wallet: \"0x...\",\n  redeemedOrLiquidated: false,  \u002F\u002F only active positions\n  limit: 50,\n});\n\nfor (const p of positions ?? []) {\n  const shares = Number(BigInt(p.shares)) \u002F 1e18;\n  if (shares === 0) continue; \u002F\u002F no stake — skip\n  console.log(`Market ${p.marketProxy} | Outcome ${p.outcomeIdx} | ${shares} shares`);\n}\n```\n\n### Redeem settled positions\n\n> **Tip**: See `scripts\u002Fredeem.ts` for a complete working example.\n\n> **Important**: Only positions with non-zero shares can be redeemed. If `listPositions` returns a position with `shares === \"0\"`, the wallet has no stake in that market and calling `redeemMarket` will fail or return nothing. Always check shares > 0 before redeeming.\n\n```typescript\n\u002F\u002F Single market\nconst { transactionHash, sharesIn, tokensOut } = await client.redeemMarket({\n  marketAddress: \"0x...\" as `0x${string}`,\n});\n\n\u002F\u002F Batch\nconst { results, totalTokensOut } = await client.redeemPositions({\n  marketAddresses: [\"0x...\", \"0x...\"],\n});\nfor (const r of results) {\n  if (r.success) console.log(`Redeemed ${Number(r.tokensOut!) \u002F 1e6} USDC from ${r.marketAddress}`);\n  else console.error(`Failed ${r.marketAddress}: ${r.error}`);\n}\n```\n\n### Liquidate expired positions\n\n> **Tip**: See `scripts\u002Fliquidate.ts` for a complete working example.\n\nLiquidation is for positions in **expired** markets that were never settled. Unlike redemption (which is for settled markets with a winner), liquidation recovers tokens from markets that expired without resolution.\n\n```typescript\n\u002F\u002F Liquidate a single market — pass all outcome indices you hold\nconst { transactionHash, sharesIn, totalTokensOut } = await client.liquidate({\n  marketAddress: \"0x...\" as `0x${string}`,\n  outcomeIndices: [0, 1],  \u002F\u002F all outcome indices with positions\n});\n\u002F\u002F sharesIn: bigint[] — shares burned per outcome index\n\u002F\u002F totalTokensOut: bigint — total USDC recovered across all outcomes\n\n\u002F\u002F Derive outcome indices from listPositions:\nconst { positions } = await client.listPositions({ wallet, redeemedOrLiquidated: false });\nconst outcomeIndices = positions!\n  .filter(p => p.marketProxy === marketAddress && BigInt(p.shares) > 0n)\n  .map(p => Number(p.outcomeIdx));\n```\n\n### Token approval\n\n> **Tip**: See `scripts\u002Ftoken-approval.ts` for a complete working example.\n\n```typescript\n\u002F\u002F Check current allowance\nconst { ownerAddress, allowance } = await client.getTokenAllowance({ marketAddress });\n\n\u002F\u002F Approve unlimited\nawait client.approveToken({ marketAddress });\n\n\u002F\u002F Approve specific amount (50 USDC)\nawait client.approveToken({ marketAddress, amount: 50_000_000n });\n\n\u002F\u002F Idempotent: only approves if current allowance is below minimum\n\u002F\u002F Response always includes current allowance, plus transactionHash if a tx was sent\nconst { approvalNeeded, allowance, transactionHash } = await client.ensureTokenApproval({\n  marketAddress,\n  minimumAmount: requiredTokens,\n  approveAmount: 100_000_000n,  \u002F\u002F optional: amount to approve if needed (defaults to max uint256)\n});\n```\n\n### Check wallet balances\n\n> **Tip**: See `scripts\u002Fget-wallet-balances.ts` for a complete working example.\n\n```typescript\n\u002F\u002F ETH (native gas token)\nconst ethBalance = await client.getEthBalance();\nconsole.log(`ETH: ${(Number(ethBalance) \u002F 1e18).toFixed(6)}`);\n\n\u002F\u002F ERC-20 collateral token (defaults to SDK-configured token address)\nconst tokenAddress = client.getTokenAddress(); \u002F\u002F inspect the configured token address\nconst { balance, decimals } = await client.getErc20BalanceWithDecimals();\nconst formatted = (Number(balance) \u002F 10 ** decimals).toFixed(decimals > 6 ? 6 : decimals);\nconsole.log(`Token (${tokenAddress}): ${formatted}`);\n\n\u002F\u002F Or fetch raw balance only (6-decimal for USDC)\nconst raw = await client.getErc20Balance(); \u002F\u002F uses default token; pass address to override\n```\n\n### Query recent trades via subgraph\n\n> **Tip**: See `scripts\u002Flist-recent-trades.ts` for a complete working example.\n\nThe SDK's `SubgraphClient` queries on-chain event data indexed by a Goldsky subgraph. Access it via `client.getSubgraph()`.\n\n```typescript\nconst subgraph = client.getSubgraph();\n\n\u002F\u002F Convenience method: get buys and sells for a market\nconst { buys, sells } = await subgraph.getMarketTrades(\n  \"0x...\" as string,  \u002F\u002F market proxy address\n  { first: 20 }\n);\n\nfor (const buy of buys) {\n  const cost = Number(BigInt(buy.tokensIn ?? \"0\")) \u002F 1e6;\n  const shares = Number(BigInt(buy.sharesOut ?? \"0\")) \u002F 1e18;\n  const time = new Date(Number(buy.timestamp_) * 1000).toLocaleString();\n  console.log(`BUY ${time} | ${cost.toFixed(4)} USDC → ${shares.toFixed(4)} shares`);\n}\n\n\u002F\u002F Arbitrary GraphQL: recent buys across all markets\n\u002F\u002F SubgraphBuy, SubgraphSell, SubgraphMeta are all exported from the SDK for typing:\n\u002F\u002F   import type { SubgraphBuy, SubgraphSell, SubgraphMeta } from \"@gensyn-ai\u002Fgensyn-delphi-sdk\";\nconst data = await subgraph.query\u003C{ gatewayBuys: SubgraphBuy[] }>(`{\n  gatewayBuys(first: 5, orderBy: timestamp_, orderDirection: desc) {\n    id buyer marketProxy tokensIn sharesOut timestamp_\n  }\n}`);\n\n\u002F\u002F Check subgraph indexing status (block number, deployment, error flag)\nconst meta = await subgraph.getMeta();\nconsole.log(`Block: ${meta.block.number}, indexing errors: ${meta.hasIndexingErrors}`);\n```\n\nAvailable entities: `gatewayBuys`, `gatewaySells`, `gatewayRedemptions`, `gatewayLiquidations`, `gatewayMarketSettleds`, `gatewayMarketFaileds`, `marketResolutionRequesteds`. All support filtering (`where`), ordering (`orderBy` + `orderDirection`), and pagination (`first` + `skip`). Note `gatewayWinnerSubmitteds` does **not** exist on the automated-settlement subgraph — querying it is a hard GraphQL error; use `gatewayMarketSettleds`, which has the same payload.\n\n### TUI\n\nThe user can visualize what the agent is doing live with the read-only Agent TUI dashboard — portfolio, positions, activity, markets, an Edge View and an Agent Logs reasoning stream — via `npx tsx scripts\u002Fagent-tui\u002Findex.tsx \u003Cwallet-address> \u003Ctestnet|mainnet|competition-testnet>` (or `npm run agent-tui -- \u003Cwallet-address> \u003Ctestnet|mainnet|competition-testnet>`). The two helpers below feed its Agent Logs and Edge View panels.\n\n#### Tracing your reasoning (Agent Logs)\n\n`log-event` populates the Agent TUI's **Agent Logs** panel. Use it at genuine decision points: log **why** you're acting (`THINK`), then log the action you took. Event types:\n\n| Type | Use for |\n|------|---------|\n| `THINK` | The *reasoning* — what you observed, why the market looks mispriced, what edge you see, why this side and size. The important one. |\n| `BUY` | A buy you executed. |\n| `SELL` | A sell you executed. |\n| `LIQUIDATE` | Liquidating positions in an expired market. |\n| `REDEEM` | Redeeming winnings from a settled market. |\n| `SKIP` | A market you looked at and deliberately passed on (and why). |\n\n```bash\nnpx tsx scripts\u002Flog-event.ts THINK \"\u003Cthe reasoning — why this trade>\"\nnpx tsx scripts\u002Flog-event.ts BUY   \"\u003Cthe action you took>\"\n```\n\n- **`THINK`** is the important one — capture the reasoning. This is what the Agent Logs panel exists to show.\n- The **action** types (`BUY`\u002F`SELL`\u002F`LIQUIDATE`\u002F`REDEEM`) are short notes of what followed the think. Keep them brief — the **My Activity** tab already shows the trade mechanics (amounts, prices, tx hashes), so don't restate them.\n- Use **`SKIP`** to record markets you evaluated but passed on, so the log shows what you considered, not just what you traded.\n\nDo **not** just describe the order. `\"Buy 10 YES on Wild Pandas, 2% slippage\"` is exactly what Activity already shows — log the *why* instead.\n\nGood:\n\n```bash\nnpx tsx scripts\u002Flog-event.ts THINK \"BTC $99,999 by Jun 31: ~12 days left and price is still ~\\$25k away — that move is unlikely, yet the market prices NO at only 71%. Taking NO; small testnet size to validate.\"\nnpx tsx scripts\u002Flog-event.ts BUY   \"10 NO on BTC $99,999\"\n```\n\nLog a THINK→action pair at genuine decision points, not every routine read. The `\u003Ctype>` is case-insensitive and normalised to upper case. Events append to `$DELPHI_AGENT_LOG` (default `~\u002F.delphi\u002Fagent-events.jsonl`); the file is created automatically.\n\n#### Computing edge before trading (Edge View)\n\n**Edge is the core trade signal — always compute it before you autonomously decide to buy or sell a market.** Edge is the gap between your own probability estimate for an outcome and the market's live implied probability:\n\n```\nedge = your probability − market's implied probability\n```\n\nA positive edge means the outcome is **underpriced** relative to your view (a buy candidate); a negative edge means it's **overpriced** (a sell \u002F avoid). The bigger the absolute gap, the stronger the signal.\n\n`scripts\u002Fcompute-edge.ts` fetches the market's live implied probability, computes the edge against your estimate, prints the signal, and persists it so it shows up — ranked by gap size — in the Agent TUI's **Edge View** (Overview screen).\n\n```bash\n# Single market outcome: your probability is 0.30 (or pass 30 for percent)\nnpx tsx scripts\u002Fcompute-edge.ts 0x1234…abcd 1 0.30\n\n# Several at once — repeat the (market, outcome, prob) triple\nnpx tsx scripts\u002Fcompute-edge.ts 0x1234…abcd 1 0.30  0x5678…ef01 0 0.62\n```\n\n`\u003Cyour-prob>` is your estimate for that outcome (0–1 like `0.30`, or a percent like `30`); `\u003Cmarket-address>` is the market id from `listMarkets`\u002F`getMarket`, and `\u003Coutcome-idx>` is the outcome's index. Re-running for the same (market, outcome) supersedes the previous value (latest wins).\n\n**Required decision flow when deciding whether to buy\u002Fsell a market autonomously:**\n\n1. Form your own probability estimate for the outcome.\n2. Run `compute-edge.ts` to compare it against the market's live implied probability.\n3. Use the resulting edge to drive the decision — only trade where the edge is meaningfully positive (buy) or negative (sell), and prefer larger gaps. If the edge is small or the wrong sign, `SKIP`.\n4. Then `log-event THINK` your reasoning (referencing the edge) and `log-event BUY`\u002F`SELL` the action you took.\n\nEdges persist to `$DELPHI_AGENT_EDGES` (default `~\u002F.delphi\u002Fagent-edges.jsonl`); the file is created automatically. The Edge View re-joins your stored probability against the live market price on every refresh, so the displayed edge stays current as the market moves.\n\n## Error handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `TokensInExceedsMax` | Price moved above `maxTokensIn` | Re-quote, increase slippage |\n| `TokensOutBelowMin` | Price moved below `minTokensOut` | Re-quote, increase slippage |\n| `MarketNotOpen` | Market is closed or settled | Check `market.status` first |\n| `SharesInExceedSupply` | Selling more shares than held | Check position before selling |\n| `Requires apiKey` | Missing `DELPHI_API_ACCESS_KEY` | Set env var |\n| `Requires rpcUrl` | Missing `GENSYN_RPC_URL` | Set env var or let network default apply |\n| `Requires privateKey` | Missing `WALLET_PRIVATE_KEY` | Set env var or switch to CDP signer |\n| `CDP signing requires ...` | Missing CDP env vars | Set all `CDP_` vars |\n\n## Reference files (load on demand)\n\n| File | When to load |\n|------|-------------|\n| [reference\u002Fmarkets.md](reference\u002Fmarkets.md) | Full `listMarkets`\u002F`getMarket` params, `Market` type schema, metadata structure |\n| [reference\u002Ftrading.md](reference\u002Ftrading.md) | Trading mechanics, slippage formulas, parimutuel pricing explainer |\n| [reference\u002Fpositions.md](reference\u002Fpositions.md) | `Position`\u002F`Trade` type schemas, batch redemption patterns, portfolio estimation |\n| [reference\u002Fonchain.md](reference\u002Fonchain.md) | Full Gateway ABI function list, direct `viem` read patterns, signing config |\n| [reference\u002Fsubgraph.md](reference\u002Fsubgraph.md) | Goldsky subgraph GraphQL schema, `SubgraphClient` API, entity types, filtering, raw query examples |\n| [reference\u002Ffunding.md](reference\u002Ffunding.md) | Getting ETH and USDC onto Gensyn (testnet faucet, OP Stack bridge, LayerZero USDC bridge) |\n| [reference\u002Fcompetition.md](reference\u002Fcompetition.md) | **The agent trading competition**: LMSR vs parimutuel pricing, registration, trading differences, the leaderboard, subgraph differences, failure modes |\n",{"name":5,"description":7,"compatibility":48},"Requires dependencies installed via `npm install`. Only DELPHI_API_ACCESS_KEY and wallet signing credentials are mandatory. Network defaults (RPC URL, chain ID, gateway contract, API URL) are set automatically based on DELPHI_NETWORK (default: testnet).","main","1cd781d749f271250eed7974a0003297b6a1209a","",1,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills","https:\u002F\u002Fgithub.com\u002Fgensyn-ai","www.gensyn.ai","Building the decentralised machine learning compute network.","2026-08-04 03:33:03",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add gensyn-ai\u002Fgensyn-delphi-skills --skill delphi",{"tool":64,"command":65},"bunx","bunx skills add gensyn-ai\u002Fgensyn-delphi-skills --skill delphi",{"tool":67,"command":68},"pnpm","pnpm dlx skills add gensyn-ai\u002Fgensyn-delphi-skills --skill delphi","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FSKILL.md",true,[72,78,82,88,91,97,101,104,108,112,116,120,124,128,132,138,142,146,150,154,158,162,166,170,174,178,182,186,190,194,198,202,206,210,214,218,222,226,230,234,238,242,246,250,254],{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},".env.example","OTHER","其他",2554,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002F.env.example",{"path":79,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":80,"sourceHtmlUrl":81},".gitignore",135,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002F.gitignore",{"path":83,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":86,"sourceHtmlUrl":87},"AGENTS.md","REFERENCE","参考文档",8,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FAGENTS.md",{"path":89,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":86,"sourceHtmlUrl":90},"CLAUDE.md","https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FCLAUDE.md",{"path":92,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":95,"sourceHtmlUrl":96},"LICENSE.TXT","LICENSE","许可证",1067,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FLICENSE.TXT",{"path":98,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":99,"sourceHtmlUrl":100},"package.json",1534,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fpackage.json",{"path":102,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":86,"sourceHtmlUrl":103},"README.md","https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FREADME.md",{"path":105,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":106,"sourceHtmlUrl":107},"reference\u002Fcompetition.md",15655,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Fcompetition.md",{"path":109,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":110,"sourceHtmlUrl":111},"reference\u002Ffunding.md",7825,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Ffunding.md",{"path":113,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":114,"sourceHtmlUrl":115},"reference\u002Fmarkets.md",5345,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Fmarkets.md",{"path":117,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":118,"sourceHtmlUrl":119},"reference\u002Fonchain.md",7375,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Fonchain.md",{"path":121,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":122,"sourceHtmlUrl":123},"reference\u002Fpositions.md",6347,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Fpositions.md",{"path":125,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":126,"sourceHtmlUrl":127},"reference\u002Fsubgraph.md",14252,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Fsubgraph.md",{"path":129,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":130,"sourceHtmlUrl":131},"reference\u002Ftrading.md",4990,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Freference\u002Ftrading.md",{"path":133,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":136,"sourceHtmlUrl":137},"scripts\u002Fagent-tui\u002Fapp.tsx","SCRIPT","脚本",6245,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fapp.tsx",{"path":139,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":140,"sourceHtmlUrl":141},"scripts\u002Fagent-tui\u002Fdata.ts",27067,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fdata.ts",{"path":143,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":144,"sourceHtmlUrl":145},"scripts\u002Fagent-tui\u002Fedges.ts",2245,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fedges.ts",{"path":147,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":148,"sourceHtmlUrl":149},"scripts\u002Fagent-tui\u002Fevents.ts",1302,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fevents.ts",{"path":151,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":152,"sourceHtmlUrl":153},"scripts\u002Fagent-tui\u002Fformat.ts",3703,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fformat.ts",{"path":155,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":156,"sourceHtmlUrl":157},"scripts\u002Fagent-tui\u002Findex.tsx",2534,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Findex.tsx",{"path":159,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":160,"sourceHtmlUrl":161},"scripts\u002Fagent-tui\u002Fscreens.tsx",21602,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fscreens.tsx",{"path":163,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":164,"sourceHtmlUrl":165},"scripts\u002Fagent-tui\u002Fui.tsx",4627,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fagent-tui\u002Fui.tsx",{"path":167,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":168,"sourceHtmlUrl":169},"scripts\u002Fbridge-eth-to-gensyn-mainnet.ts",2708,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fbridge-eth-to-gensyn-mainnet.ts",{"path":171,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":172,"sourceHtmlUrl":173},"scripts\u002Fbridge-eth-to-gensyn-testnet.ts",3896,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fbridge-eth-to-gensyn-testnet.ts",{"path":175,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":176,"sourceHtmlUrl":177},"scripts\u002Fbridge-usdc-to-gensyn-mainnet.ts",7428,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fbridge-usdc-to-gensyn-mainnet.ts",{"path":179,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":180,"sourceHtmlUrl":181},"scripts\u002Fbuy-shares.ts",2118,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fbuy-shares.ts",{"path":183,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":184,"sourceHtmlUrl":185},"scripts\u002Fclient.ts",2694,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fclient.ts",{"path":187,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":188,"sourceHtmlUrl":189},"scripts\u002Fcompute-edge.ts",3556,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fcompute-edge.ts",{"path":191,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":192,"sourceHtmlUrl":193},"scripts\u002Fget-market.ts",1822,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fget-market.ts",{"path":195,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":196,"sourceHtmlUrl":197},"scripts\u002Fget-wallet-balances.ts",1220,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fget-wallet-balances.ts",{"path":199,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":200,"sourceHtmlUrl":201},"scripts\u002Fliquidate.ts",3101,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fliquidate.ts",{"path":203,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":204,"sourceHtmlUrl":205},"scripts\u002Flist-markets.ts",2499,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Flist-markets.ts",{"path":207,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":208,"sourceHtmlUrl":209},"scripts\u002Flist-positions.ts",1181,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Flist-positions.ts",{"path":211,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":212,"sourceHtmlUrl":213},"scripts\u002Flist-recent-trades.ts",2652,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Flist-recent-trades.ts",{"path":215,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":216,"sourceHtmlUrl":217},"scripts\u002Flog-event.ts",1570,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Flog-event.ts",{"path":219,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":220,"sourceHtmlUrl":221},"scripts\u002Fquote-buy.ts",997,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fquote-buy.ts",{"path":223,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":224,"sourceHtmlUrl":225},"scripts\u002Fquote-liquidate.ts",1776,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fquote-liquidate.ts",{"path":227,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":228,"sourceHtmlUrl":229},"scripts\u002Fquote-redeem.ts",1274,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fquote-redeem.ts",{"path":231,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":232,"sourceHtmlUrl":233},"scripts\u002Fquote-sell.ts",1007,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fquote-sell.ts",{"path":235,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":236,"sourceHtmlUrl":237},"scripts\u002Fredeem.ts",1288,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fredeem.ts",{"path":239,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":240,"sourceHtmlUrl":241},"scripts\u002Fsell-shares.ts",1634,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Fsell-shares.ts",{"path":243,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":244,"sourceHtmlUrl":245},"scripts\u002Ftestnet-faucet.ts",1392,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Ftestnet-faucet.ts",{"path":247,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":248,"sourceHtmlUrl":249},"scripts\u002Ftoken-approval.ts",1819,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Fscripts\u002Ftoken-approval.ts",{"path":251,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":252,"sourceHtmlUrl":253},"SECURITY.md",7831,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002FSECURITY.md",{"path":255,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":256,"sourceHtmlUrl":257},"tsconfig.json",288,"https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002Ftsconfig.json",[259],{"skillNo":260,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":261,"categories":262,"keywords":263,"publishedAt":43},"01M6CZ78GKTTES2HRBJ3HE3AQX","https:\u002F\u002Fgithub.com\u002Fgensyn-ai\u002Fgensyn-delphi-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdelphi\u002FSKILL.md",[],[5]]