> Treat every fee rate, margin ratio, order limit, minimum and address in this documentation as an illustration of the shape of the value, never as a constant to hardcode - the live values are served by GET /markets and GET /config on the Perps API.

# CoreWriter Integration

> Bridge assets directly into HyperCore (Hyperliquid spot) via the CoreWriter flow.

The CoreWriter flow extends the standard bridge integration to deliver funds **directly into HyperCore** (Hyperliquid spot) or into HyperEVM tokens in one step. It builds on the [Bridge Integration](/developers/bridge-integration) flow, adding CoreWriter-specific parameters and constraints.

**Base URL:** `https://bridge-ag-api.hyperflow.fun/v1` — mainnet only. Full parameter documentation in the [OpenAPI spec](https://bridge-ag-api.hyperflow.fun/v1/swagger).

### Get your partner code

Before initiating CoreWriter bridge transactions, obtain a unique **partner code** (e.g. `lifi`) from the HyperFlow team:

* Discord: [discord.gg/GGDmD4K9CK](https://discord.gg/GGDmD4K9CK)
* Telegram: [t.me/hyperflow_fun](https://t.me/hyperflow_fun)
* X: [@HyperFlow_fun](https://x.com/HyperFlow_fun)

### Generate a quote

Call `/quote` as in the base bridge flow, with these CoreWriter-specific rules:

* `fromChain` must always be **`hyperevm`**.
* `toChain` must be **`hypercore`** or **`hyperevm`**:
  * If `toChain = "hypercore"`, `toToken` must be a **token id** retrieved from the [Hyperliquid Spot Metadata API](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata):

    ```bash
    curl --location 'https://api.hyperliquid.xyz/info' \
      --header 'Content-Type: application/json' \
      --data '{ "type": "spotMeta" }'
    ```
  * If `toChain = "hyperevm"`, the amount must be worth at least **\$100** (based on the source token value) for quotes to be returned.
* `source` must include your partner code.

**Example 1 — bridge 10 HYPE from hyperevm → hypercore:**

```javascript
const params = {
  fromChain: "hyperevm",
  fromToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  toChain: "hypercore",
  toToken: "0x0d01dc56dcaaca66ad901c959b4011ec",
  amount: "10000000000000000000",
  protocols: "kyberswap,hyperflow,wrapnative,hypercorespot,hypercore,layerzero,hyperunit,gaszip,relay,mayan",
  sender: "0xYourWalletAddress",
  receiver: "0xYourWalletAddress",
  slippage: "100",
  source: "lifi"
};
```

**Example 2 — bridge 10 HYPE to USD₮0 (USDT0) on HyperEVM (similar to a swap):**

```javascript
const params = {
  fromChain: "hyperevm",
  fromToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  toChain: "hyperevm",
  toToken: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
  amount: "10000000000000000000",
  protocols: "kyberswap,hyperflow,wrapnative,hypercorespot,hypercore,layerzero,hyperunit,gaszip,relay,mayan",
  sender: "0xYourWalletAddress",
  receiver: "0xYourWalletAddress",
  slippage: "100",
  source: "lifi"
};
```

> **Warning**
>
> The response includes a `requestId` required for the next step. It expires after **30 seconds**.

### Assemble the transaction

Identical to the base bridge flow — request encoded transaction data from `/encode` with the `requestId`:

```javascript
const txData = await fetch(`${api}/encode`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    requestId: quote.requestId,
    quoteIdx: selectedQuoteIndex,
  }),
}).then((r) => r.json());
```

`/encode` returns the transaction under `data` (fields `to`, `value`, `data` — see the [Bridge Integration](/developers/bridge-integration) for the full response shape). Since CoreWriter flows always start from HyperEVM, submit on the HyperEVM RPC.

### Submit the transaction

Submit on-chain with any EOA wallet or contract execution method:

```javascript
const provider = new ethers.JsonRpcProvider("https://rpc.hyperliquid.xyz/evm"); // HyperEVM
const wallet = new ethers.Wallet(process.env.PRV_KEY, provider);
const txRes = await wallet.sendTransaction(txData.data); // { to, value, data }
console.log("tx_hash:", txRes.hash);
const receipt = await txRes.wait();
console.log("mined_block:", receipt.blockNumber);
```

### Check the bridge status

Track progress via `/hyperbridge/orders?src_tx=<tx_hash>`:

```javascript
const status = await fetch(`${api}/hyperbridge/orders?src_tx=${txRes.hash}`).then((r) => r.json());
if (status.orders.length > 0) console.log("order state:", status.orders[0].state);
```

The `state` field:

| State      | Meaning                                                                                                              |
| ---------- | -------------------------------------------------------------------------------------------------------------------- |
| `done`     | The full amount was delivered as `dstToken` on `dstChain`                                                            |
| `refunded` | The user receives up to two tokens covering the full value; refunds land on **Hyperliquid** regardless of `dstChain` |
| `pending`  | The bridge is still in progress                                                                                      |
| `failed`   | The transaction failed — wait for a retry or contact the HyperFlow team                                              |

## Need help?

* Base flow details: [Bridge Integration](/developers/bridge-integration)
* Partnership setup: contact the HyperFlow team
* Live support: [Discord](https://discord.gg/GGDmD4K9CK)