@bulletxyz/bullet-sdk 0.27.1 → 0.27.2-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3315,6 +3315,12 @@ var NETWORKS = {
3315
3315
  ws: "wss://ws.mainnet.bullet.xyz/ws"
3316
3316
  }
3317
3317
  };
3318
+ var CHAIN_IDS = {
3319
+ Localnet: 4321,
3320
+ Staging: 4323,
3321
+ Testnet: 4322,
3322
+ Mainnet: 4321
3323
+ };
3318
3324
  var GLOBAL_DEFAULT_MAX_LEVERAGE = 1e3;
3319
3325
 
3320
3326
  // src/utils.ts
@@ -7554,8 +7560,7 @@ var BaseResponseSchemas = {
7554
7560
  id: z.string(),
7555
7561
  status: z.string()
7556
7562
  })
7557
- ),
7558
- NonceResponse: createBaseResponse(z.object({ nonce: z.number() }))
7563
+ )
7559
7564
  };
7560
7565
  var PriceLevel = z.tuple([DecimalSchema, DecimalSchema]);
7561
7566
  var Position = z.object({
@@ -7616,6 +7621,7 @@ var Order = z.object({
7616
7621
  side: z.enum(SIDES),
7617
7622
  market_id: MarketId,
7618
7623
  order_id: OrderId,
7624
+ client_order_id: ClientOrderId.nullable(),
7619
7625
  price: DecimalSchema,
7620
7626
  remaining_size: DecimalSchema,
7621
7627
  reduce_only: z.boolean(),
@@ -7820,6 +7826,7 @@ var Schemas = {
7820
7826
  var ResponseSchemas = {
7821
7827
  DummyValue: StateResponseSchemas.StateValue(Schemas.DummyValue),
7822
7828
  Order: StateResponseSchemas.StateMapElement(OrderId, Order),
7829
+ Tpsl: StateResponseSchemas.StateMapElement(TpslOrderId, Tpsl),
7823
7830
  TpslOrderIdsToExecute: StateResponseSchemas.StateMapElement(
7824
7831
  MarketId,
7825
7832
  TpslOrderIdsToExecute
@@ -7919,14 +7926,6 @@ var BaseConnection = class {
7919
7926
  }
7920
7927
  };
7921
7928
  var Connection = class extends BaseConnection {
7922
- async getNonce(address) {
7923
- const addressHex = base58ToHex(address);
7924
- const path = `/rollup/addresses/${addressHex}/dedup`;
7925
- const response = await this.fetchApiResource(path);
7926
- const parsed = BaseResponseSchemas.NonceResponse.parse(response);
7927
- const nonce = parsed.nonce;
7928
- return nonce;
7929
- }
7930
7929
  async getTokenBalance(address, token_id) {
7931
7930
  const response = await this.fetchApiResource(
7932
7931
  `/modules/bank/tokens/${token_id}/balances/${address}`
@@ -8338,6 +8337,12 @@ var ExchangeConnection = class _ExchangeConnection extends BaseConnection {
8338
8337
  const parsed = ResponseSchemas.Order.parse(response);
8339
8338
  return parsed.value;
8340
8339
  }
8340
+ async getTpslOrder(tpslOrderId) {
8341
+ const path = `/modules/exchange/state/tpsls/items/${tpslOrderId.toString()}`;
8342
+ const response = await this.fetchApiResource(path);
8343
+ const parsed = ResponseSchemas.Tpsl.parse(response);
8344
+ return parsed.value;
8345
+ }
8341
8346
  async getMarketRegistry() {
8342
8347
  const path = "/modules/exchange/state/market-registry";
8343
8348
  const response = await this.fetchApiResource(path);
@@ -9327,9 +9332,8 @@ onEvent_fn = async function(event, filter) {
9327
9332
  // src/client.ts
9328
9333
  var DEFAULT_TRANSACTION_OPTS = {
9329
9334
  maxPriorityFeeBps: 0,
9330
- maxFee: "1000000000",
9331
- gasLimit: null,
9332
- chainId: 4321
9335
+ maxFee: "10000000000",
9336
+ gasLimit: null
9333
9337
  };
9334
9338
  var Client = class _Client {
9335
9339
  constructor(endpoints, exchange, wallet, rollup) {
@@ -9348,7 +9352,7 @@ var Client = class _Client {
9348
9352
  this.address = wallet.address;
9349
9353
  }
9350
9354
  // Static convenience constructors
9351
- static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
9355
+ static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS, chainId = 4321) {
9352
9356
  const rollup = await createStandardRollup({
9353
9357
  url: endpoints.rest,
9354
9358
  getSerializer: (schema) => new WasmSerializer(schema),
@@ -9357,7 +9361,7 @@ var Client = class _Client {
9357
9361
  max_priority_fee_bips: txOpts.maxPriorityFeeBps,
9358
9362
  max_fee: txOpts.maxFee,
9359
9363
  gas_limit: txOpts.gasLimit,
9360
- chain_id: txOpts.chainId
9364
+ chain_id: chainId
9361
9365
  }
9362
9366
  }
9363
9367
  });
@@ -9370,7 +9374,12 @@ var Client = class _Client {
9370
9374
  if (!isNetwork(network)) {
9371
9375
  throw new Error(`Invalid network: ${network}`);
9372
9376
  }
9373
- return await _Client.fromEndpoints(NETWORKS[network], wallet, txOpts);
9377
+ return await _Client.fromEndpoints(
9378
+ NETWORKS[network],
9379
+ wallet,
9380
+ txOpts,
9381
+ CHAIN_IDS[network]
9382
+ );
9374
9383
  }
9375
9384
  static async fromRestUrl(restUrl, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
9376
9385
  return await _Client.fromEndpoints({ rest: restUrl }, wallet, txOpts);
@@ -9638,6 +9647,22 @@ var Client = class _Client {
9638
9647
  }
9639
9648
  });
9640
9649
  }
9650
+ async adminCancelOrders(address, market, orderId) {
9651
+ const marketId = this.exchange.getMarketId(market);
9652
+ return await this.submitTransaction({
9653
+ exchange: {
9654
+ admin_cancel_orders: { args: [[address, marketId, orderId]] }
9655
+ }
9656
+ });
9657
+ }
9658
+ async adminCancelTpsls(address, market, tpslOrderId) {
9659
+ const marketId = this.exchange.getMarketId(market);
9660
+ return await this.submitTransaction({
9661
+ exchange: {
9662
+ admin_cancel_tpsls: { args: [[address, marketId, tpslOrderId]] }
9663
+ }
9664
+ });
9665
+ }
9641
9666
  async cancelAllOrdersForMarket(market) {
9642
9667
  const marketId = this.exchange.getMarketId(market);
9643
9668
  return await this.submitTransaction({
@@ -10015,6 +10040,7 @@ export {
10015
10040
  ApiError,
10016
10041
  BaseResponseSchemas,
10017
10042
  BulletError,
10043
+ CHAIN_IDS,
10018
10044
  Client,
10019
10045
  Connection,
10020
10046
  ExchangeConnection,