@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);
@@ -9341,9 +9346,8 @@ onEvent_fn = async function(event, filter) {
9341
9346
  // src/client.ts
9342
9347
  var DEFAULT_TRANSACTION_OPTS = {
9343
9348
  maxPriorityFeeBps: 0,
9344
- maxFee: "1000000000",
9345
- gasLimit: null,
9346
- chainId: 4321
9349
+ maxFee: "10000000000",
9350
+ gasLimit: null
9347
9351
  };
9348
9352
  var Client = class _Client {
9349
9353
  constructor(endpoints, exchange, wallet, rollup) {
@@ -9362,7 +9366,7 @@ var Client = class _Client {
9362
9366
  this.address = wallet.address;
9363
9367
  }
9364
9368
  // Static convenience constructors
9365
- static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
9369
+ static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS, chainId = 4321) {
9366
9370
  const rollup = await createStandardRollup({
9367
9371
  url: endpoints.rest,
9368
9372
  getSerializer: (schema) => new WasmSerializer(schema),
@@ -9371,7 +9375,7 @@ var Client = class _Client {
9371
9375
  max_priority_fee_bips: txOpts.maxPriorityFeeBps,
9372
9376
  max_fee: txOpts.maxFee,
9373
9377
  gas_limit: txOpts.gasLimit,
9374
- chain_id: txOpts.chainId
9378
+ chain_id: chainId
9375
9379
  }
9376
9380
  }
9377
9381
  });
@@ -9384,7 +9388,12 @@ var Client = class _Client {
9384
9388
  if (!isNetwork(network)) {
9385
9389
  throw new Error(`Invalid network: ${network}`);
9386
9390
  }
9387
- return await _Client.fromEndpoints(NETWORKS[network], wallet, txOpts);
9391
+ return await _Client.fromEndpoints(
9392
+ NETWORKS[network],
9393
+ wallet,
9394
+ txOpts,
9395
+ CHAIN_IDS[network]
9396
+ );
9388
9397
  }
9389
9398
  static async fromRestUrl(restUrl, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
9390
9399
  return await _Client.fromEndpoints({ rest: restUrl }, wallet, txOpts);
@@ -9652,6 +9661,22 @@ var Client = class _Client {
9652
9661
  }
9653
9662
  });
9654
9663
  }
9664
+ async adminCancelOrders(address, market, orderId) {
9665
+ const marketId = this.exchange.getMarketId(market);
9666
+ return await this.submitTransaction({
9667
+ exchange: {
9668
+ admin_cancel_orders: { args: [[address, marketId, orderId]] }
9669
+ }
9670
+ });
9671
+ }
9672
+ async adminCancelTpsls(address, market, tpslOrderId) {
9673
+ const marketId = this.exchange.getMarketId(market);
9674
+ return await this.submitTransaction({
9675
+ exchange: {
9676
+ admin_cancel_tpsls: { args: [[address, marketId, tpslOrderId]] }
9677
+ }
9678
+ });
9679
+ }
9655
9680
  async cancelAllOrdersForMarket(market) {
9656
9681
  const marketId = this.exchange.getMarketId(market);
9657
9682
  return await this.submitTransaction({
@@ -10075,6 +10100,7 @@ export {
10075
10100
  ApiError,
10076
10101
  BaseResponseSchemas,
10077
10102
  BulletError,
10103
+ CHAIN_IDS,
10078
10104
  Client,
10079
10105
  Connection,
10080
10106
  ExchangeConnection,