OstiumClient factory methods. Every factory returns a Promise<OstiumClient> and is async, so always await it.
Shared options (all write modes)
These optional fields are accepted bycreateSelfAndSelf, createSelfAndGasless, createDelegatedAndSelf, and createDelegatedAndGasless.
| Option | Type | Default | Description |
|---|---|---|---|
testnet | boolean | false | Use Arbitrum Sepolia. Switches the contracts, subgraph endpoint, builder API endpoint, and the default Pimlico sponsor URL. See Testnet. |
slippageBps | number | 25 | Default slippage tolerance in basis points (25 = 0.25%). Used when a call does not pass its own slippage. |
builder | { address: string; feeBps: number } | — | Builder fee sharing. feeBps is in basis points, range 0–50 (0%–0.5%), in steps of 0.01 bps. Can be overridden per openTrade() call. |
subgraphUrl | string | mainnet/testnet subgraph | Override the Ostium subgraph endpoint used by read methods (getPairs, getOpenPositions, …). Mainnet default is https://builder.ostium.io/v1/subgraph/gn. |
builderApiUrl | string | https://builder.ostium.io | Override the builder API base URL used for live prices, OHLC candles, and the WebSocket price stream. |
alchemyApiKey | string | — | Alchemy API key used by streamAccountUpdates() for the Arbitrum contract-log overlay. Required to start an account stream; can also be passed per stream call. |
alchemyApiKey is only needed if you call streamAccountUpdates(). Set it once at client creation, or pass it per call: client.streamAccountUpdates({ alchemyApiKey }). Without an Alchemy key (from either place), the stream throws INVALID_CONFIG.
Submit-capable vs build-only
Every write mode can be created two ways:- Submit-capable — pass a private key; the SDK signs and submits.
- Build-only — pass addresses only; use
get*Tx()to return unsigned transaction data for your own wallet or Safe flow. No key ever touches the SDK.
createSelfAndSelf
The trader EOA owns funds, signs, and pays gas. See Self + Self.
Submit-capable
| Field | Type | Required | Description |
|---|---|---|---|
traderPrivateKey | 0x${string} | Yes | Private key of the trader EOA. Holds USDC, owns positions, pays gas. |
rpcUrl | string | Yes | Arbitrum One (or Sepolia) RPC URL. |
| Field | Type | Required | Description |
|---|---|---|---|
traderAddress | 0x${string} | Yes | Trader EOA address. Used to build unsigned EOA transactions. |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the chain’s public RPC. |
createSelfAndGasless
The trader EOA owns funds and signs; a Safe derived from the key submits gaslessly. See Self + Gasless.
Submit-capable
| Field | Type | Required | Description |
|---|---|---|---|
traderPrivateKey | 0x${string} | Yes | Private key of the trader EOA. A Safe is derived from this key to relay trades gaslessly. |
pimlicoUrl | string | No | Pimlico-compatible bundler/paymaster RPC URL. Defaults to the Ostium sponsor URL (…/v1/pimlico/sponsor?chainId=42161, or the Sepolia variant on testnet). |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the public Arbitrum RPC. |
sponsorshipPolicyId | string | No | Pimlico sponsorship policy ID. |
| Field | Type | Required | Description |
|---|---|---|---|
traderAddress | 0x${string} | Yes | Trader EOA that owns USDC and positions. |
safeAddress | 0x${string} | Yes | Safe smart-account address that will submit delegated calls. |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the chain’s public RPC. |
createDelegatedAndSelf
A delegate EOA signs and pays gas on behalf of a separate trader. See Delegated + Self.
Submit-capable
| Field | Type | Required | Description |
|---|---|---|---|
delegatePrivateKey | 0x${string} | Yes | Private key of the delegate EOA. Signs and pays gas for all transactions. |
traderAddress | 0x${string} | Yes | Trader this delegate acts for. The trader must have called setDelegate(delegateAddress). |
rpcUrl | string | Yes | Arbitrum One (or Sepolia) RPC URL. |
| Field | Type | Required | Description |
|---|---|---|---|
traderAddress | 0x${string} | Yes | Trader this delegate acts for. |
delegateAddress | 0x${string} | Yes | Delegate EOA that will submit the transaction. |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the chain’s public RPC. |
createDelegatedAndGasless
A Safe derived from the delegate key submits sponsored user operations on behalf of the trader. See Delegated + Gasless.
Submit-capable
| Field | Type | Required | Description |
|---|---|---|---|
delegatePrivateKey | 0x${string} | Yes | Private key of the delegate EOA. A Safe is derived from this key and submits user operations via Pimlico. |
traderAddress | 0x${string} | Yes | Trader this delegate acts for. The trader must have called setDelegate(safeAddress), where safeAddress is the Safe derived from the delegate key (client.getSmartAccountAddress()). |
pimlicoUrl | string | No | Pimlico bundler/paymaster RPC URL. Defaults to the Ostium sponsor URL (chain-aware). |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the public Arbitrum RPC. |
sponsorshipPolicyId | string | No | Pimlico sponsorship policy ID. |
| Field | Type | Required | Description |
|---|---|---|---|
traderAddress | 0x${string} | Yes | Trader this delegate acts for. |
delegateAddress | 0x${string} | Yes | Delegate EOA that owns the Safe. |
safeAddress | 0x${string} | Yes | Safe smart-account address that will submit delegated calls. |
rpcUrl | string | No | RPC URL for reads/simulation. Defaults to the chain’s public RPC. |
createReadOnly
No signer, no submitter, no private key. All read methods work; write methods throw INVALID_CONFIG. See Read-only.
| Field | Type | Required | Description |
|---|---|---|---|
rpcUrl | string | No | Arbitrum RPC URL. Defaults to the chain’s public RPC. |
testnet | boolean | No | Use Arbitrum Sepolia. Defaults to false. |
subgraphUrl | string | No | Override the subgraph endpoint. |
builderApiUrl | string | No | Override the builder API base URL. |
alchemyApiKey | string | No | Alchemy API key for streamAccountUpdates(). |
slippageBps or builder — those only apply to write modes that submit or build trades.
Notes
- All factories are
async—awaitthem. - Mode is inferred from the fields you pass; you don’t set
modedirectly. - Builder fee defaults (
builderat client creation) can be overridden peropenTrade()call viabuilder.address/builder.feeBps. - On
testnet: true, omittedpimlicoUrl,subgraphUrl, andbuilderApiUrlresolve to their Sepolia defaults — you can still override any of them.