Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ostium.com/llms.txt

Use this file to discover all available pages before exploring further.

createSelfAndGasless() keeps custody with the trader EOA but submits trades through a Safe smart account.
  • the trader EOA owns USDC and positions
  • the trader EOA signs the underlying trade action
  • the trader’s Safe submits the transaction as a sponsored user operation

When to use it

  • consumer apps that want a gasless UX
  • embedded trading flows where the user should not need ETH after setup
  • client-side apps that already have a Safe execution path

One-time setup

The trader must do two EOA-signed transactions once:
await client.approveUsdc('max');
await client.setupGaslessDelegation();
After that, trading calls can be sent gaslessly through the Safe.

Submit-capable client

const client = await OstiumClient.createSelfAndGasless({
  traderPrivateKey: process.env.TRADER_PRIVATE_KEY as `0x${string}`,
  pimlicoUrl: 'https://builder.ostium.io/v1/pimlico/sponsor?chainId=42161',
});

Build-only client

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

const tx = client.getOpenTradeTx({
  pairId: 0,
  buy: true,
  price: '65000',
  collateral: '100',
  leverage: '5',
  type: OrderType.Market,
});
In build-only mode, get*Tx() returns a Safe-style request with safeAddress and calls.