Skip to main content
The SDK exposes get*Tx() helpers for every write action. Use them when your app wants the SDK to build the correct calldata, but your wallet or Safe flow will handle signing and submission.

Available methods

  • getSetupGaslessDelegationTx()
  • getApproveUsdcTx(amount)
  • getSetDelegateTx(delegateAddress)
  • getRemoveDelegateTx()
  • getOpenTradeTx(params)
  • getCloseTradeTx(params)
  • getCancelOrderTx(params)
  • getModifyOrderTx(params)
  • getUpdateCollateralTx(params)

Return shape

Depending on the mode, the SDK returns one of two request types:
type BuiltTxRequest =
  | {
      kind: 'eoa';
      to: `0x${string}`;
      data: `0x${string}`;
      value: bigint;
      from: `0x${string}`;
      traderAddress: `0x${string}`;
    }
  | {
      kind: 'safe';
      safeAddress: `0x${string}`;
      traderAddress: `0x${string}`;
      calls: [
        {
          to: `0x${string}`;
          data: `0x${string}`;
          value: bigint;
        },
      ];
    };

Example

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

const tx = client.getOpenTradeTx({
  pairId: 0,
  buy: true,
  price: '65000',
  collateral: '100',
  leverage: '5',
  type: OrderType.Market,
});
Use createSelfAndSelf() or createDelegatedAndSelf() for EOA-style build output, and use createSelfAndGasless() or createDelegatedAndGasless() for Safe-style build output.