@bulletxyz/bullet-sdk 0.27.1-rc.0 → 0.27.2-rc.0
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.
- package/dist/browser/index.js +60 -126
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.js +60 -126
- package/dist/node/index.js.map +2 -2
- package/dist/types/client.d.ts +1 -2
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/exchange.d.ts +3 -5
- package/dist/types/rollupTypes.d.ts +0 -25
- package/dist/types/types.d.ts +0 -6
- package/dist/types/zod-types/rest.d.ts +14 -528
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -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
|
|
@@ -7769,38 +7775,7 @@ var Schemas = {
|
|
|
7769
7775
|
})
|
|
7770
7776
|
)
|
|
7771
7777
|
}),
|
|
7772
|
-
last_trade_price: DecimalSchema
|
|
7773
|
-
taker_fees_tenth_bps: z.array(z.number()),
|
|
7774
|
-
maker_fees_tenth_bps: z.array(z.number())
|
|
7775
|
-
}),
|
|
7776
|
-
SpotMarket: z.object({
|
|
7777
|
-
market_id: MarketId,
|
|
7778
|
-
is_active: z.boolean(),
|
|
7779
|
-
base_asset_id: AssetId,
|
|
7780
|
-
quote_asset_id: AssetId,
|
|
7781
|
-
base_min_lot_size: DecimalSchema,
|
|
7782
|
-
quote_min_lot_size: DecimalSchema,
|
|
7783
|
-
max_orders_per_side: U16Schema,
|
|
7784
|
-
orderbook: z.object({
|
|
7785
|
-
market_id: MarketId,
|
|
7786
|
-
bids: createJsonMap(
|
|
7787
|
-
z.string(),
|
|
7788
|
-
z.object({
|
|
7789
|
-
order_ids: z.array(OrderId),
|
|
7790
|
-
total_size: DecimalSchema
|
|
7791
|
-
})
|
|
7792
|
-
),
|
|
7793
|
-
asks: createJsonMap(
|
|
7794
|
-
z.string(),
|
|
7795
|
-
z.object({
|
|
7796
|
-
order_ids: z.array(OrderId),
|
|
7797
|
-
total_size: DecimalSchema
|
|
7798
|
-
})
|
|
7799
|
-
)
|
|
7800
|
-
}),
|
|
7801
|
-
last_trade_price: DecimalSchema,
|
|
7802
|
-
taker_fees_tenth_bps: z.array(z.number()),
|
|
7803
|
-
maker_fees_tenth_bps: z.array(z.number())
|
|
7778
|
+
last_trade_price: DecimalSchema
|
|
7804
7779
|
}),
|
|
7805
7780
|
MarginConfig: z.object({
|
|
7806
7781
|
perp_liquidation_config: PerpLiquidationConfig,
|
|
@@ -7900,18 +7875,6 @@ var ResponseSchemas = {
|
|
|
7900
7875
|
not_found: z.array(MarketId)
|
|
7901
7876
|
})
|
|
7902
7877
|
),
|
|
7903
|
-
SpotMarket: createBaseResponse(
|
|
7904
|
-
z.object({
|
|
7905
|
-
market_id: MarketId,
|
|
7906
|
-
market: Schemas.SpotMarket
|
|
7907
|
-
})
|
|
7908
|
-
),
|
|
7909
|
-
SpotMarketBulk: createBaseResponse(
|
|
7910
|
-
z.object({
|
|
7911
|
-
found: createJsonMap(MarketId, Schemas.SpotMarket),
|
|
7912
|
-
not_found: z.array(MarketId)
|
|
7913
|
-
})
|
|
7914
|
-
),
|
|
7915
7878
|
MarginConfig: StateResponseSchemas.StateValue(Schemas.MarginConfig),
|
|
7916
7879
|
AccountAddresses: createBaseResponse(Schemas.AccountAddresses)
|
|
7917
7880
|
};
|
|
@@ -8313,7 +8276,6 @@ var ExchangeConnection = class _ExchangeConnection extends BaseConnection {
|
|
|
8313
8276
|
__publicField(this, "assetRegistry");
|
|
8314
8277
|
__publicField(this, "assetRegistryReverse");
|
|
8315
8278
|
__publicField(this, "marketRegistry");
|
|
8316
|
-
// ID and type
|
|
8317
8279
|
__publicField(this, "marketRegistryReverse");
|
|
8318
8280
|
if (endpoints.ws) {
|
|
8319
8281
|
this.wsManager = new WebSocketManager(endpoints.ws);
|
|
@@ -8364,12 +8326,7 @@ var ExchangeConnection = class _ExchangeConnection extends BaseConnection {
|
|
|
8364
8326
|
this.marketRegistryReverse = /* @__PURE__ */ new Map();
|
|
8365
8327
|
for (const info of rawMarketRegistry.metas.values()) {
|
|
8366
8328
|
if (info && typeof info.name === "string") {
|
|
8367
|
-
this.marketRegistry.set(info.name,
|
|
8368
|
-
id: info.id,
|
|
8369
|
-
kind: info.kind,
|
|
8370
|
-
baseAssetId: info.base_asset_id,
|
|
8371
|
-
name: info.name
|
|
8372
|
-
});
|
|
8329
|
+
this.marketRegistry.set(info.name, info.id);
|
|
8373
8330
|
this.marketRegistryReverse.set(info.id, info.name);
|
|
8374
8331
|
}
|
|
8375
8332
|
}
|
|
@@ -8429,9 +8386,6 @@ var ExchangeConnection = class _ExchangeConnection extends BaseConnection {
|
|
|
8429
8386
|
return assetName;
|
|
8430
8387
|
}
|
|
8431
8388
|
getMarketId(market) {
|
|
8432
|
-
return this.getMarketMeta(market).id;
|
|
8433
|
-
}
|
|
8434
|
-
getMarketMeta(market) {
|
|
8435
8389
|
const marketRegistry = this.getMarketMapping();
|
|
8436
8390
|
const marketId = marketRegistry.get(market);
|
|
8437
8391
|
if (marketId === void 0) {
|
|
@@ -8541,24 +8495,6 @@ var ExchangeConnection = class _ExchangeConnection extends BaseConnection {
|
|
|
8541
8495
|
const parsed = ResponseSchemas.PerpMarketBulk.parse(response);
|
|
8542
8496
|
return parsed.found;
|
|
8543
8497
|
}
|
|
8544
|
-
async getSpotMarket(market) {
|
|
8545
|
-
const marketId = this.getMarketId(market);
|
|
8546
|
-
const path = `/modules/exchange/api/v1/spot-market/${marketId}`;
|
|
8547
|
-
const response = await this.fetchApiResource(path);
|
|
8548
|
-
const parsed = ResponseSchemas.SpotMarket.parse(response);
|
|
8549
|
-
return parsed.market;
|
|
8550
|
-
}
|
|
8551
|
-
async getSpotMarkets(markets) {
|
|
8552
|
-
const marketIds = markets.map((market) => {
|
|
8553
|
-
return this.getMarketId(market);
|
|
8554
|
-
});
|
|
8555
|
-
const path = "/modules/exchange/api/v1/spot-market/bulk";
|
|
8556
|
-
const response = await this.fetchBulkApiResource(path, {
|
|
8557
|
-
market_ids: marketIds
|
|
8558
|
-
});
|
|
8559
|
-
const parsed = ResponseSchemas.SpotMarketBulk.parse(response);
|
|
8560
|
-
return parsed.found;
|
|
8561
|
-
}
|
|
8562
8498
|
async getMarginConfig() {
|
|
8563
8499
|
const path = "/modules/exchange/state/margin-config";
|
|
8564
8500
|
const response = await this.fetchApiResource(path);
|
|
@@ -9397,8 +9333,7 @@ onEvent_fn = async function(event, filter) {
|
|
|
9397
9333
|
var DEFAULT_TRANSACTION_OPTS = {
|
|
9398
9334
|
maxPriorityFeeBps: 0,
|
|
9399
9335
|
maxFee: "1000000000",
|
|
9400
|
-
gasLimit: null
|
|
9401
|
-
chainId: 4321
|
|
9336
|
+
gasLimit: null
|
|
9402
9337
|
};
|
|
9403
9338
|
var Client = class _Client {
|
|
9404
9339
|
constructor(endpoints, exchange, wallet, rollup) {
|
|
@@ -9417,7 +9352,7 @@ var Client = class _Client {
|
|
|
9417
9352
|
this.address = wallet.address;
|
|
9418
9353
|
}
|
|
9419
9354
|
// Static convenience constructors
|
|
9420
|
-
static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
|
|
9355
|
+
static async fromEndpoints(endpoints, wallet, txOpts = DEFAULT_TRANSACTION_OPTS, chainId = 4321) {
|
|
9421
9356
|
const rollup = await createStandardRollup({
|
|
9422
9357
|
url: endpoints.rest,
|
|
9423
9358
|
getSerializer: (schema) => new WasmSerializer(schema),
|
|
@@ -9426,7 +9361,7 @@ var Client = class _Client {
|
|
|
9426
9361
|
max_priority_fee_bips: txOpts.maxPriorityFeeBps,
|
|
9427
9362
|
max_fee: txOpts.maxFee,
|
|
9428
9363
|
gas_limit: txOpts.gasLimit,
|
|
9429
|
-
chain_id:
|
|
9364
|
+
chain_id: chainId
|
|
9430
9365
|
}
|
|
9431
9366
|
}
|
|
9432
9367
|
});
|
|
@@ -9439,7 +9374,12 @@ var Client = class _Client {
|
|
|
9439
9374
|
if (!isNetwork(network)) {
|
|
9440
9375
|
throw new Error(`Invalid network: ${network}`);
|
|
9441
9376
|
}
|
|
9442
|
-
return await _Client.fromEndpoints(
|
|
9377
|
+
return await _Client.fromEndpoints(
|
|
9378
|
+
NETWORKS[network],
|
|
9379
|
+
wallet,
|
|
9380
|
+
txOpts,
|
|
9381
|
+
CHAIN_IDS[network]
|
|
9382
|
+
);
|
|
9443
9383
|
}
|
|
9444
9384
|
static async fromRestUrl(restUrl, wallet, txOpts = DEFAULT_TRANSACTION_OPTS) {
|
|
9445
9385
|
return await _Client.fromEndpoints({ rest: restUrl }, wallet, txOpts);
|
|
@@ -9549,58 +9489,51 @@ var Client = class _Client {
|
|
|
9549
9489
|
});
|
|
9550
9490
|
}
|
|
9551
9491
|
async placeOrder(placeOrderArgs) {
|
|
9552
|
-
const
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
size: BulletWasm.convert_rust_decimal_to_json(
|
|
9561
|
-
placeOrderArgs.size.toFixed()
|
|
9562
|
-
),
|
|
9563
|
-
side: placeOrderArgs.side,
|
|
9564
|
-
order_type: placeOrderArgs.orderType,
|
|
9565
|
-
reduce_only: placeOrderArgs.reduceOnly,
|
|
9566
|
-
client_order_id: placeOrderArgs.clientOrderId ? placeOrderArgs.clientOrderId.toString() : null,
|
|
9567
|
-
tpsl: placeOrderArgs.tpsl ? {
|
|
9568
|
-
pending_tp: placeOrderArgs.tpsl.pendingTp ? {
|
|
9569
|
-
order_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9570
|
-
placeOrderArgs.tpsl.pendingTp.orderPrice.toFixed()
|
|
9571
|
-
),
|
|
9572
|
-
trigger_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9573
|
-
placeOrderArgs.tpsl.pendingTp.triggerPrice.toFixed()
|
|
9574
|
-
),
|
|
9575
|
-
trigger_direction: placeOrderArgs.tpsl.pendingTp.triggerDirection,
|
|
9576
|
-
price_condition: placeOrderArgs.tpsl.pendingTp.priceCondition,
|
|
9577
|
-
order_type: placeOrderArgs.tpsl.pendingTp.orderType
|
|
9578
|
-
} : null,
|
|
9579
|
-
pending_sl: placeOrderArgs.tpsl.pendingSl ? {
|
|
9580
|
-
order_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9581
|
-
placeOrderArgs.tpsl.pendingSl.orderPrice.toFixed()
|
|
9492
|
+
const marketId = this.exchange.getMarketId(placeOrderArgs.market);
|
|
9493
|
+
return await this.submitTransaction({
|
|
9494
|
+
exchange: {
|
|
9495
|
+
place_order: {
|
|
9496
|
+
args: {
|
|
9497
|
+
market_id: marketId,
|
|
9498
|
+
price: BulletWasm.convert_rust_decimal_to_json(
|
|
9499
|
+
placeOrderArgs.price.toFixed()
|
|
9582
9500
|
),
|
|
9583
|
-
|
|
9584
|
-
placeOrderArgs.
|
|
9501
|
+
size: BulletWasm.convert_rust_decimal_to_json(
|
|
9502
|
+
placeOrderArgs.size.toFixed()
|
|
9585
9503
|
),
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9504
|
+
side: placeOrderArgs.side,
|
|
9505
|
+
order_type: placeOrderArgs.orderType,
|
|
9506
|
+
reduce_only: placeOrderArgs.reduceOnly,
|
|
9507
|
+
client_order_id: placeOrderArgs.clientOrderId ? placeOrderArgs.clientOrderId.toString() : null,
|
|
9508
|
+
tpsl: placeOrderArgs.tpsl ? {
|
|
9509
|
+
pending_tp: placeOrderArgs.tpsl.pendingTp ? {
|
|
9510
|
+
order_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9511
|
+
placeOrderArgs.tpsl.pendingTp.orderPrice.toFixed()
|
|
9512
|
+
),
|
|
9513
|
+
trigger_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9514
|
+
placeOrderArgs.tpsl.pendingTp.triggerPrice.toFixed()
|
|
9515
|
+
),
|
|
9516
|
+
trigger_direction: placeOrderArgs.tpsl.pendingTp.triggerDirection,
|
|
9517
|
+
price_condition: placeOrderArgs.tpsl.pendingTp.priceCondition,
|
|
9518
|
+
order_type: placeOrderArgs.tpsl.pendingTp.orderType
|
|
9519
|
+
} : null,
|
|
9520
|
+
pending_sl: placeOrderArgs.tpsl.pendingSl ? {
|
|
9521
|
+
order_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9522
|
+
placeOrderArgs.tpsl.pendingSl.orderPrice.toFixed()
|
|
9523
|
+
),
|
|
9524
|
+
trigger_price: BulletWasm.convert_rust_decimal_to_json(
|
|
9525
|
+
placeOrderArgs.tpsl.pendingSl.triggerPrice.toFixed()
|
|
9526
|
+
),
|
|
9527
|
+
trigger_direction: placeOrderArgs.tpsl.pendingSl.triggerDirection,
|
|
9528
|
+
price_condition: placeOrderArgs.tpsl.pendingSl.priceCondition,
|
|
9529
|
+
order_type: placeOrderArgs.tpsl.pendingSl.orderType
|
|
9530
|
+
} : null,
|
|
9531
|
+
dynamic_size: placeOrderArgs.tpsl.dynamicSize
|
|
9532
|
+
} : null
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9601
9535
|
}
|
|
9602
|
-
};
|
|
9603
|
-
return await this.submitTransaction(outerArgsObject);
|
|
9536
|
+
});
|
|
9604
9537
|
}
|
|
9605
9538
|
async createPositionTpsl(market, tpslOrders) {
|
|
9606
9539
|
const marketId = this.exchange.getMarketId(market);
|
|
@@ -10107,6 +10040,7 @@ export {
|
|
|
10107
10040
|
ApiError,
|
|
10108
10041
|
BaseResponseSchemas,
|
|
10109
10042
|
BulletError,
|
|
10043
|
+
CHAIN_IDS,
|
|
10110
10044
|
Client,
|
|
10111
10045
|
Connection,
|
|
10112
10046
|
ExchangeConnection,
|