Skip to main content
createSelfAndSelf() is the simplest mode.
  • the trader EOA owns USDC and positions
  • the same trader EOA signs transactions
  • transactions are submitted directly on Arbitrum and the trader pays gas

When to use it

  • bots and scripts
  • server-side systems trading a house account
  • wallet-driven apps where the user is comfortable paying gas
  • client-side apps that only need unsigned EOA transaction payloads

Submit-capable client

const client = await OstiumClient.createSelfAndSelf({
  traderPrivateKey: process.env.TRADER_PRIVATE_KEY as `0x${string}`,
  rpcUrl: process.env.ARB_RPC_URL!,
});

Build-only client

const client = await OstiumClient.createSelfAndSelf({
  traderAddress: '0xTraderAddress',
});

const tx = client.getOpenTradeTx({
  pairId: 0,
  buy: true,
  price: '65000',
  collateral: '100',
  leverage: '5',
  type: OrderType.Market,
});
In build-only mode, get*Tx() returns an EOA request with from, to, data, and value so your app can pass it to a wallet for signing.

Parameters

FieldTypeRequiredNotes
traderPrivateKey0x${string}Submit-capableTrader EOA key. Holds USDC, owns positions, pays gas.
traderAddress0x${string}Build-onlyTrader EOA address (no key).
rpcUrlstringSubmit-capable; optional for build-onlyArbitrum RPC URL. Build-only defaults to the public RPC.
Plus the shared options (testnet, slippageBps, builder, subgraphUrl, builderApiUrl, alchemyApiKey). See Client Configuration.