> ## Documentation Index
> Fetch the complete documentation index at: https://docs.octav.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from Sim (Dune)

> A 1:1 mapping from the Sim (Dune) API to the Octav API

A drop-in mapping from the **Sim (Dune) API** to Octav. Sim is **token balances only** today, so migrating is mostly additive:

* **Keep your token balances, gain DeFi.** Sim's DeFi Positions API was sunset (it returns HTTP 410), so a DeFi wallet reads as just its loose tokens. Octav returns the same wallet tokens **and** the decoded DeFi positions Sim can no longer provide (lending, LP, staking, perps) from a single [`GET /v1/portfolio`](/api/endpoints/portfolio).
* **Solana included.** Sim's balances are EVM-only. The same Octav endpoint accepts base58 Solana addresses, including Solana DeFi.
* **Human-readable balances.** Sim returns a raw on-chain `amount` you divide by `10^decimals`. Octav returns `balance` already scaled.
* **USD values precomputed.** Octav returns `value` on every asset, plus `networth` for the whole portfolio, so you never sum `value_usd` yourself.

<Info>
  **Get your API key** at [data.octav.fi](https://data.octav.fi/). Base URL: `https://api.octav.fi/v1`.
</Info>

## Endpoint mapping

| Use case                   | Sim (Dune)                                                              | Octav                                                                       |
| -------------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| Wallet tokens (all chains) | `GET /v1/evm/balances/{address}`                                        | [`GET /v1/portfolio`](/api/endpoints/portfolio) → `assetByProtocols.wallet` |
| DeFi positions             | *sunset — returns HTTP 410*                                             | same `GET /v1/portfolio` → `assetByProtocols.<protocol>`                    |
| Net worth                  | *no endpoint (sum `value_usd` yourself)*                                | same response → `networth` + `chains`                                       |
| Transaction history        | `GET /v1/evm/transactions/{address}` / `GET /v1/evm/activity/{address}` | [`GET /v1/transactions`](/api/endpoints/transactions)                       |
| Token metadata / price     | inline on each balance                                                  | inline on every asset (`price`, `value`, `decimal`)                         |

<Tip>
  Everything except history comes from a **single** `GET /v1/portfolio` call. Tokens, DeFi, and net worth arrive together — there is no second request to merge, and no DeFi endpoint to miss.
</Tip>

## Authentication

Sim uses an `X-Sim-Api-Key` header. Octav uses a standard `Authorization: Bearer` token.

<CodeGroup>
  ```bash Sim theme={null}
  curl "https://api.sim.dune.com/v1/evm/balances/0x6426af179aabebe47666f345d69fd9079673f6cd?metadata=logo&exclude_spam_tokens=true" \
    -H "X-Sim-Api-Key: YOUR_SIM_KEY"
  ```

  ```bash Octav theme={null}
  curl "https://api.octav.fi/v1/portfolio?addresses=0x6426af179aabebe47666f345d69fd9079673f6cd" \
    -H "Authorization: Bearer YOUR_OCTAV_KEY"
  ```
</CodeGroup>

## Wallet token balances

Sim's `evm/balances` returns a flat `balances[]` array. In Octav, wallet tokens live under the `wallet` protocol, grouped by chain:

```
assetByProtocols.wallet.chains.<chain>.protocolPositions.WALLET.assets[]
```

<CodeGroup>
  ```javascript JavaScript theme={null}
  const OCTAV_KEY = process.env.OCTAV_API_KEY;
  const address = "0x6426af179aabebe47666f345d69fd9079673f6cd";

  const res = await fetch(
    `https://api.octav.fi/v1/portfolio?addresses=${address}&includeImages=true`,
    { headers: { Authorization: `Bearer ${OCTAV_KEY}` } }
  );
  const [portfolio] = await res.json(); // /v1/portfolio returns one entry per address

  // Flatten wallet tokens across every chain
  const wallet = portfolio.assetByProtocols.wallet;
  const tokens = Object.values(wallet.chains).flatMap((chain) =>
    Object.values(chain.protocolPositions).flatMap((pos) => pos.assets)
  );

  tokens.forEach((t) =>
    console.log(`${t.symbol} on ${t.chainKey}: ${t.balance} ($${t.value})`)
  );
  ```

  ```python Python theme={null}
  import os
  import requests

  OCTAV_KEY = os.environ["OCTAV_API_KEY"]
  address = "0x6426af179aabebe47666f345d69fd9079673f6cd"
  res = requests.get(
      "https://api.octav.fi/v1/portfolio",
      params={"addresses": address, "includeImages": True},
      headers={"Authorization": f"Bearer {OCTAV_KEY}"},
  )
  portfolio = res.json()[0]  # one entry per address

  wallet = portfolio["assetByProtocols"]["wallet"]
  for chain in wallet["chains"].values():
      for pos in chain["protocolPositions"].values():
          for t in pos["assets"]:
              print(f"{t['symbol']} on {t['chainKey']}: {t['balance']} (${t['value']})")
  ```

  ```bash cURL theme={null}
  curl "https://api.octav.fi/v1/portfolio?addresses=0x6426af179aabebe47666f345d69fd9079673f6cd&includeImages=true" \
    -H "Authorization: Bearer YOUR_OCTAV_KEY"
  ```
</CodeGroup>

**Field mapping**

| Sim (`balances[]`)    | Octav (`…assets[]`)                    | Notes                                                                                                         |
| --------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `address`             | `contract`                             | Token address. Native tokens use the zero address in Octav.                                                   |
| `chain`               | `chainKey`                             | e.g. `ethereum`, `arbitrum`. See [supported chains](/api/reference/supported-chains).                         |
| `symbol`              | `symbol`                               |                                                                                                               |
| `name`                | `name`                                 |                                                                                                               |
| `decimals`            | `decimal`                              |                                                                                                               |
| `price_usd`           | `price`                                | USD, precomputed.                                                                                             |
| `amount`              | `balance`                              | Sim returns the **raw** integer; you divide by `10^decimals`. Octav returns `balance` already human-readable. |
| `value_usd`           | `value`                                | Precomputed in both.                                                                                          |
| `token_metadata.logo` | asset logo (with `includeImages=true`) |                                                                                                               |

## Net worth and per-chain breakdown

Sim has no net-worth endpoint — you would sum `value_usd` across the `balances[]` array yourself. Octav returns `networth` and a per-chain breakdown directly on the same portfolio call.

| Sim                         | Octav                                      | Notes                                           |
| --------------------------- | ------------------------------------------ | ----------------------------------------------- |
| `sum(balances[].value_usd)` | `networth`                                 | Total net worth in USD, precomputed.            |
| —                           | `chains.<chain>.value`                     | Per-chain total.                                |
| —                           | `chains.<chain>.key` / `chainId`           | Chain identifier + numeric ID.                  |
| —                           | `chains.<chain>.valuePercentile`           | Share of net worth per chain (Octav adds this). |
| —                           | `openPnl` / `closedPnl` / `totalCostBasis` | P\&L and cost basis (Octav adds these).         |

```javascript JavaScript theme={null}
console.log(`Net worth: $${portfolio.networth}`);
Object.values(portfolio.chains).forEach((c) =>
  console.log(`${c.name}: $${c.value} (${c.valuePercentile}%)`)
);
```

## DeFi positions

Sim's DeFi Positions API was **sunset and now returns HTTP 410**, so there is nothing to map here — a DeFi wallet on Sim shows up as only its loose tokens. This is net-new capability from Octav: the same portfolio call decodes positions under `assetByProtocols`, keyed by protocol, then chain, then position type (`LENDING`, `LIQUIDITYPOOL`, `STAKED`, `FARMING`, …).

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Every protocol except the "wallet" bucket is a DeFi position
  const defi = Object.entries(portfolio.assetByProtocols).filter(
    ([key]) => key !== "wallet"
  );

  defi.forEach(([key, protocol]) => {
    console.log(`${protocol.name}: $${protocol.value}`);
    Object.values(protocol.chains).forEach((chain) => {
      Object.entries(chain.protocolPositions).forEach(([type, pos]) => {
        console.log(`  ${type}: $${pos.totalValue}`);
        pos.assets.forEach((a) => console.log(`    ${a.symbol}: $${a.value}`));
      });
    });
  });
  ```

  ```python Python theme={null}
  for key, protocol in portfolio["assetByProtocols"].items():
      if key == "wallet":
          continue
      print(f"{protocol['name']}: ${protocol['value']}")
      for chain in protocol["chains"].values():
          for ptype, pos in chain["protocolPositions"].items():
              print(f"  {ptype}: ${pos['totalValue']}")
  ```
</CodeGroup>

<Tip>
  Because Octav decodes DeFi in the same call, migrating off Sim closes the gap its sunset left: lending, LP, staking, and perps positions (on EVM **and** Solana) come back priced, with no extra endpoint.
</Tip>

## Transaction history

Swap Sim's `evm/transactions` and `evm/activity` for [`GET /v1/transactions`](/api/endpoints/transactions).

<CodeGroup>
  ```bash Sim theme={null}
  curl "https://api.sim.dune.com/v1/evm/activity/0x6426af179aabebe47666f345d69fd9079673f6cd" \
    -H "X-Sim-Api-Key: YOUR_SIM_KEY"
  ```

  ```bash Octav theme={null}
  curl "https://api.octav.fi/v1/transactions?addresses=0x6426af179aabebe47666f345d69fd9079673f6cd" \
    -H "Authorization: Bearer YOUR_OCTAV_KEY"
  ```
</CodeGroup>

Octav categorizes each transaction (swap, deposit, stake, bridge, …) and prices transfers in USD. See the [transaction types reference](/api/reference/transaction-types).

## Key differences

* **Scope.** Sim is token balances only; its DeFi Positions API is sunset (HTTP 410). Octav returns wallet tokens **and** decoded DeFi positions from one `GET /v1/portfolio`.
* **Chains.** Sim's balances are EVM-only. Octav covers EVM **and** Solana from the same endpoint and shape, including Solana DeFi.
* **Balances.** Sim returns a raw `amount` you divide by `10^decimals`. Octav returns `balance` already human-readable.
* **Values.** Sim returns `value_usd` per token but no portfolio total. Octav also returns `networth` and a per-chain breakdown, so you never sum values yourself.
* **Grouping.** Sim returns a flat `balances[]` array. Octav groups `assetByProtocols` → `chains` → `protocolPositions` → `assets[]`, with a dedicated `wallet` bucket for loose tokens.
* **Billing.** Sim's free tier is winding down. Octav charges **1 credit per call** (see [pricing](/api/pricing)).
* **P\&L.** Octav adds `openPnl`, `closedPnl`, and `totalCostBasis` at no extra call.

## Need help migrating?

<CardGroup cols={2}>
  <Card title="Join our Discord" icon="discord" href="https://discord.com/invite/qvcknAa73A">
    Share your Sim response shape and we'll map it.
  </Card>

  <Card title="Portfolio endpoint" icon="chart-pie" href="/api/endpoints/portfolio">
    Full reference for the endpoint you'll be calling.
  </Card>
</CardGroup>
