$npx -y skills add Uniswap/uniswap-ai --skill index-botThis skill should be used when the user asks to "create an index", "build a basket of top assets", "buy a weighted basket", "make a portfolio of assets", "equal-weight basket", "rebalance my portfolio", "track the top N tokens", or wants an automated, weighted multi-asset basket
| 1 | # Index Bot |
| 2 | |
| 3 | Build a weighted basket of assets from one instruction, buy the whole basket in one pass, and rebalance on a cadence when weights drift. This skill is a thin strategy layer: it decides what to buy and how much, then delegates every quote, approval, swap, and signing step to existing skills. |
| 4 | |
| 5 | > **Runtime Compatibility:** This skill uses `AskUserQuestion` for interactive prompts. If `AskUserQuestion` is not available in your runtime, collect the same parameters through natural language conversation instead. |
| 6 | |
| 7 | ## Overview |
| 8 | |
| 9 | From a single prompt (for example "equal-weight basket of the top 5 RWAs, rebalance weekly"), index-bot: |
| 10 | |
| 11 | 1. Parses the basket spec (explicit assets with weights, or a top-N ranking request). |
| 12 | 2. Resolves each asset to a token address and computes per-leg sizing. |
| 13 | 3. Applies guardrails (spend cap, token allowlist, dry-run). |
| 14 | 4. Delegates each buy to the swap-integration Trading API flow on the target chain. |
| 15 | 5. Records target weights and the last rebalance in a state file. |
| 16 | |
| 17 | On a later invocation by the host scheduler, it reads current positions, computes drift versus target weights, generates the adjusting swaps, and delegates them. |
| 18 | |
| 19 | The trigger is twofold: a prompt to create the basket, and the host scheduler (cron or the agent runtime wake-up) for each rebalance run. |
| 20 | |
| 21 | ## Prerequisites |
| 22 | |
| 23 | This skill does not reimplement swap execution. It depends on: |
| 24 | |
| 25 | - **swap-integration** (uniswap-trading): the only execution path. Every buy and rebalance leg goes through its Trading API flow (`check_approval` then `quote` then `swap`, then sign and broadcast). Do not reimplement any of it. |
| 26 | - **v4-sdk-integration** (uniswap-trading): LP execution, only if a leg also seeds or manages a liquidity position. Default index baskets are spot-only and do not need this. |
| 27 | - **viem-integration** (uniswap-viem): accounts, signing, transaction broadcast, and reading on-chain balances for the drift calculation. |
| 28 | |
| 29 | Read these plugin references before acting and treat them as ground truth: |
| 30 | |
| 31 | - selected target-chain template: chainId, chain name, contract addresses, tradable token source, funding constraints, market-data availability, and template-specific caveats. For the reference Robinhood Chain template, see `../../references/robinhood-chain.md`. |
| 32 | - `../../references/execution-model.md`: the Trading API requirement, execution modes, restrictions, and disclaimer rules. |
| 33 | - `../../references/strategy-state.md`: the shared state file and scheduler pattern. |
| 34 | |
| 35 | ## Template inputs |
| 36 | |
| 37 | The selected target-chain template must provide: |
| 38 | |
| 39 | - chain id, chain name, native gas token, and RPC / read path. |
| 40 | - deployed Uniswap router, Permit2, and quoter / state-reader addresses needed by delegated execution and valuation. |
| 41 | - optional v4 PoolManager / PositionManager addresses if the basket also manages LP positions. |
| 42 | - tradable token resolution rules, including any token list, ranking source, or allowlist source. |
| 43 | - funding constraints, market-data availability, transfer-restriction caveats, and market-hours guidance. |
| 44 | |
| 45 | ## Workflow |
| 46 | |
| 47 | ### Step 1: Parse the basket spec |
| 48 | |
| 49 | Extract the basket definition from the prompt: |
| 50 | |
| 51 | | Parameter | Required | Example | |
| 52 | | ----------------- | -------- | ------------------------------------------ | |
| 53 | | Assets | Yes | explicit list, or "top 5 RWAs" | |
| 54 | | Weighting | Yes | `equal`, or custom weights summing to 1 | |
| 55 | | Total size | Yes | `1000 USDG`, `0.5 ETH` | |
| 56 | | Funding token | Yes | the token spent to buy each leg | |
| 57 | | Rebalance cadence | Yes | `weekly`, `monthly`, `none` | |
| 58 | | Drift threshold | No | rebalance only when a leg drifts > X% | |
| 59 | | Spend caps | Yes | per-run and per-period caps in token terms | |
| 60 | |
| 61 | If the prompt asks for a top-N ranking ("top 5 RWAs"), there is no default ranking source, so do NOT invent or guess a ranking. If the selected template provides an indexer or ranking source and the operator instructs you to use it, use that source. Otherwise ask the user for an explicit asset list via `AskUserQuestion` and proceed from that list. If any other required parameter is mis |