> ## 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.

# Rust Trading and Fees

> Enable Rust trading, use the V2 default, and distinguish protocol fees, builder attribution, and application fees.

```toml Cargo.toml theme={null}
[dependencies]
polynode = { version = "0.17.1", features = ["trading"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

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).

Polymarket V2 is the default:

```rust theme={null}
use polynode::trading::{
    ExchangeVersion, PolyNodeTrader, PrivateKeySigner, TraderConfig,
};

let mut trader = PolyNodeTrader::new(TraderConfig {
    polynode_key: std::env::var("POLYNODE_API_KEY")?,
    exchange_version: ExchangeVersion::V2, // Optional: already the default
    ..Default::default()
})?;

let signer = PrivateKeySigner::from_hex(&std::env::var("POLYGON_PRIVATE_KEY")?)?;
let ready = trader.ensure_ready(Box::new(signer), None).await?;
println!("funder address: {}", ready.funder_address);
```

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

```rust theme={null}
use polynode::trading::{OrderParams, OrderSide, OrderType};

let result = trader.order(OrderParams {
    token_id: std::env::var("POLYMARKET_TOKEN_ID")?,
    side: OrderSide::Buy,
    price: 0.55,
    size: 10.0,
    order_type: OrderType::GTC,
    expiration: None,
    post_only: true,
    fee_config: None,
    builder: None,
}).await?;

if !result.success {
    return Err(polynode::Error::Trading(
        result.error.unwrap_or_else(|| "order rejected".into()),
    ));
}
println!("{:?}", result.order_id);
trader.close();
```

V2 protocol fees are applied by Polymarket at match time. Do not add legacy `fee_rate_bps`, `nonce`, or `taker` fields to a V2 signed order. `builder_code` attributes eligible volume; it does not itself charge an application fee. `fee_config` is separate and disabled unless configured.

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