Skip to main content
createDelegatedAndSelf() separates the trader from the executor.
  • the trader EOA owns USDC and positions
  • a delegate EOA signs each action
  • the delegate EOA submits the transaction and pays gas

When to use it

  • backend systems trading on behalf of users
  • managed execution products
  • integrations where users keep custody but your server handles submission

One-time trader setup

Before this mode can trade, the trader must:
await traderClient.approveUsdc('max');
await traderClient.setDelegate('0xDelegateAddress');

Submit-capable client

const client = await OstiumClient.createDelegatedAndSelf({
  delegatePrivateKey: process.env.DELEGATE_PRIVATE_KEY as `0x${string}`,
  traderAddress: '0xTraderAddress',
  rpcUrl: process.env.ARB_RPC_URL!,
});

Build-only client

const client = await OstiumClient.createDelegatedAndSelf({
  traderAddress: '0xTraderAddress',
  delegateAddress: '0xDelegateAddress',
});
In build-only mode, get*Tx() returns an EOA request whose calldata is already wrapped for delegated execution.

Parameters

FieldTypeRequiredNotes
delegatePrivateKey0x${string}Submit-capableDelegate EOA key. Signs and pays gas.
traderAddress0x${string}YesTrader the delegate acts for. Must have called setDelegate(delegateAddress).
delegateAddress0x${string}Build-onlyDelegate EOA that will submit the transaction.
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.