Skip to main content
This page is the complete reference for the parameters accepted by the OstiumClient factory methods. Every factory returns a Promise<OstiumClient> and is async, so always await it.
import { OstiumClient } from '@ostium/builder-sdk';

const client = await OstiumClient.createSelfAndSelf({
  traderPrivateKey: process.env.TRADER_PRIVATE_KEY as `0x${string}`,
  rpcUrl: process.env.ARB_RPC_URL!,
  // shared options below are accepted by every write mode
  testnet: false,
  slippageBps: 25,
  builder: { address: '0xBuilderAddress', feeBps: 10 },
  alchemyApiKey: process.env.ALCHEMY_API_KEY!,
});

Shared options (all write modes)

These optional fields are accepted by createSelfAndSelf, createSelfAndGasless, createDelegatedAndSelf, and createDelegatedAndGasless.
OptionTypeDefaultDescription
testnetbooleanfalseUse Arbitrum Sepolia. Switches the contracts, subgraph endpoint, builder API endpoint, and the default Pimlico sponsor URL. See Testnet.
slippageBpsnumber25Default 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 050 (0%–0.5%), in steps of 0.01 bps. Can be overridden per openTrade() call.
subgraphUrlstringmainnet/testnet subgraphOverride the Ostium subgraph endpoint used by read methods (getPairs, getOpenPositions, …). Mainnet default is https://builder.ostium.io/v1/subgraph/gn.
builderApiUrlstringhttps://builder.ostium.ioOverride the builder API base URL used for live prices, OHLC candles, and the WebSocket price stream.
alchemyApiKeystringAlchemy 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.
The fields below differ between the two variants of each mode.

createSelfAndSelf

The trader EOA owns funds, signs, and pays gas. See Self + Self. Submit-capable
FieldTypeRequiredDescription
traderPrivateKey0x${string}YesPrivate key of the trader EOA. Holds USDC, owns positions, pays gas.
rpcUrlstringYesArbitrum One (or Sepolia) RPC URL.
Build-only
FieldTypeRequiredDescription
traderAddress0x${string}YesTrader EOA address. Used to build unsigned EOA transactions.
rpcUrlstringNoRPC 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
FieldTypeRequiredDescription
traderPrivateKey0x${string}YesPrivate key of the trader EOA. A Safe is derived from this key to relay trades gaslessly.
pimlicoUrlstringNoPimlico-compatible bundler/paymaster RPC URL. Defaults to the Ostium sponsor URL (…/v1/pimlico/sponsor?chainId=42161, or the Sepolia variant on testnet).
rpcUrlstringNoRPC URL for reads/simulation. Defaults to the public Arbitrum RPC.
sponsorshipPolicyIdstringNoPimlico sponsorship policy ID.
Build-only
FieldTypeRequiredDescription
traderAddress0x${string}YesTrader EOA that owns USDC and positions.
safeAddress0x${string}YesSafe smart-account address that will submit delegated calls.
rpcUrlstringNoRPC 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
FieldTypeRequiredDescription
delegatePrivateKey0x${string}YesPrivate key of the delegate EOA. Signs and pays gas for all transactions.
traderAddress0x${string}YesTrader this delegate acts for. The trader must have called setDelegate(delegateAddress).
rpcUrlstringYesArbitrum One (or Sepolia) RPC URL.
Build-only
FieldTypeRequiredDescription
traderAddress0x${string}YesTrader this delegate acts for.
delegateAddress0x${string}YesDelegate EOA that will submit the transaction.
rpcUrlstringNoRPC 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
FieldTypeRequiredDescription
delegatePrivateKey0x${string}YesPrivate key of the delegate EOA. A Safe is derived from this key and submits user operations via Pimlico.
traderAddress0x${string}YesTrader this delegate acts for. The trader must have called setDelegate(safeAddress), where safeAddress is the Safe derived from the delegate key (client.getSmartAccountAddress()).
pimlicoUrlstringNoPimlico bundler/paymaster RPC URL. Defaults to the Ostium sponsor URL (chain-aware).
rpcUrlstringNoRPC URL for reads/simulation. Defaults to the public Arbitrum RPC.
sponsorshipPolicyIdstringNoPimlico sponsorship policy ID.
Build-only
FieldTypeRequiredDescription
traderAddress0x${string}YesTrader this delegate acts for.
delegateAddress0x${string}YesDelegate EOA that owns the Safe.
safeAddress0x${string}YesSafe smart-account address that will submit delegated calls.
rpcUrlstringNoRPC 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.
FieldTypeRequiredDescription
rpcUrlstringNoArbitrum RPC URL. Defaults to the chain’s public RPC.
testnetbooleanNoUse Arbitrum Sepolia. Defaults to false.
subgraphUrlstringNoOverride the subgraph endpoint.
builderApiUrlstringNoOverride the builder API base URL.
alchemyApiKeystringNoAlchemy API key for streamAccountUpdates().
Read-only clients do not accept slippageBps or builder — those only apply to write modes that submit or build trades.

Notes

  • All factories are asyncawait them.
  • Mode is inferred from the fields you pass; you don’t set mode directly.
  • Builder fee defaults (builder at client creation) can be overridden per openTrade() call via builder.address / builder.feeBps.
  • On testnet: true, omitted pimlicoUrl, subgraphUrl, and builderApiUrl resolve to their Sepolia defaults — you can still override any of them.