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.
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.
Factories do not pre-fetch the pair list during construction. Pair metadata is loaded lazily by read methods and streams when they need it. Submit-capable gasless factories still derive the Safe address with one eth_call unless you pass a known safeAddress.
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
Build-only
createSelfAndGasless
The trader EOA owns funds and signs; a Safe derived from the key submits gaslessly. See Self + Gasless.
Submit-capable
Build-only
createDelegatedAndSelf
A delegate EOA signs and pays gas on behalf of a separate trader. See Delegated + Self.
Submit-capable
Build-only
createDelegatedAndGasless
A Safe derived from the delegate key submits sponsored user operations on behalf of the trader. See Delegated + Gasless.
Submit-capable
Build-only
createReadOnly
No signer, no submitter, no private key. All read methods work; write methods throw INVALID_CONFIG. See Read-only.
Read-only clients do not accept
slippageBps or builder — those only apply to write modes that submit or build trades.
Notes
- All factories are
async—awaitthem. - Client creation does not fetch pair metadata from the subgraph. Reads and streams populate that cache lazily.
- 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.