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

# TypeScript Trading and Fees

> Use the TypeScript V2 trading defaults and keep protocol fees, builder attribution, and application fees distinct.

Install only the dependencies for the execution model you use. The injected
wallet/user-owned flow needs only:

For optional zero-builder attribution backed by the signing wallet, see [User-owned execution](/sdks/user-owned-execution). For an injected-wallet application, follow [Connect Wallet to order](/sdks/user-owned-web-app).

```bash theme={null}
npm install polynode-sdk@^0.14.2 viem
```

For a server-signer trader, add the CLOB client and SQLite only when that
process uses them:

```bash theme={null}
npm install @polymarket/clob-client@^5.8.1 better-sqlite3
```

Only a separate shared-builder relayer integration needs these peers:

```bash theme={null}
npm install @polymarket/builder-relayer-client@0.0.10 \
  @polymarket/builder-signing-sdk@^1.0.0
```

<Warning>
  The optional official Polymarket relayer client currently brings legacy
  Axios/ethers audit advisories into a full trading install. Polynode SDK 0.14.2
  does not bundle that dependency tree: its only direct runtime dependency is
  `viem`. Pin the relayer client to the SDK's declared peer version, keep relayer
  destinations fixed, and review upstream updates before changing that pin.
</Warning>

Polymarket V2 is the default. You do not need to set `exchangeVersion`, but setting it explicitly can make a migration easier to review:

```typescript theme={null}
import { PolyNodeTrader } from 'polynode-sdk';

const apiKey = process.env.POLYNODE_API_KEY;
const privateKey = process.env.POLYGON_PRIVATE_KEY;
if (!apiKey || !privateKey) throw new Error('Set the required environment variables');

const trader = new PolyNodeTrader({
  polynodeKey: apiKey,
  exchangeVersion: 'v2',
  builderCode: process.env.POLYMARKET_BUILDER_CODE,
});

const ready = await trader.ensureReady(privateKey);
console.log('funder address', ready.funderAddress);
```

`ensureReady()` can deploy or approve wallet contracts and is state-changing for a new wallet. After the returned funder address is funded, `trader.order(...)` places a real order.

V2 fees are applied by Polymarket at match time. Do not add legacy `feeRateBps`, `nonce`, or `taker` fields to a V2 signed order. A builder code attributes eligible volume; it does not itself charge an application fee. `feeConfig` is a separate, optional application-fee feature and remains disabled unless you configure it.

```typescript theme={null}
try {
  const result = await trader.order({
    tokenId: process.env.POLYMARKET_TOKEN_ID!,
    side: 'BUY',
    price: 0.55,
    size: 10,
    type: 'GTC',
    postOnly: true,
  });
  if (!result.success) throw new Error(result.error ?? 'Order rejected');
  console.log(result.orderId);
} finally {
  trader.close();
}
```

Read [Trading and fees](/sdks/trading) before running state-changing examples. It covers funding, cancellations, builder overrides, current V2 fee behavior, position operations, and cleanup.
