@bulletxyz/bullet-sdk 0.26.0 → 0.26.1-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.
@@ -15,7 +15,7 @@ export class BulletWasm {
15
15
  static calculate_account_leverage(user_account: any, margin_calculation_state: any): string;
16
16
  static calculate_available_margin(user_account: any, conservative: boolean, margin_type: MarginType, margin_calculation_state: any): string;
17
17
  static calculate_used_margin(user_account: any, withdrawal: boolean, margin_type: MarginType, margin_calculation_state: any): string;
18
- static calculate_withdrawable_amount_of_asset(user_account: any, asset_id: number, margin_calculation_state: any, asset_registry: any): string;
18
+ static calculate_withdrawable_amount_of_asset(user_account: any, asset_id: number, margin_calculation_state: any): string;
19
19
  static calculate_estimated_liquidation_price(user_account: any, market_id: number, base_asset_id: number, margin_calculation_state: any): string;
20
20
  static calculate_liquidation_risk_percentage(user_account: any, margin_calculation_state: any): string;
21
21
  static calculate_force_cancel_risk_percentage(user_account: any, margin_calculation_state: any): string;
@@ -5,7 +5,7 @@ import { type Endpoints } from "./constants";
5
5
  import type { Orderbook } from "./orderbook";
6
6
  import type { Address, AssetName, MarketName, Network } from "./types";
7
7
  import type { OrderType, PlaceOrderArgs, Side } from "./types";
8
- import { type AccountAddresses, type AssetRegistry, type BorrowLendPools as BorrowLendPools, type GlobalParameters, type MarginConfig, type MarketRegistry, type OraclePrices, type Order, type OrderbookL2, type PerpMarket, type PerpPrices, type TpslOrderIdsToExecute, type UsdcInsuranceFund, type UsdcPnlPool, type UserAccount } from "./zod-types/rest";
8
+ import { type AccountAddresses, type AssetRegistry, type BorrowLendMarkets, type GlobalParameters, type MarginConfig, type MarketRegistry, type OraclePrices, type Order, type OrderbookL2, type PerpMarket, type PerpPrices, type TpslOrderIdsToExecute, type UsdcInsuranceFund, type UsdcPnlPool, type UserAccount } from "./zod-types/rest";
9
9
  export declare class ExchangeConnection extends BaseConnection {
10
10
  private wsManager?;
11
11
  private assetRegistry?;
@@ -37,14 +37,14 @@ export declare class ExchangeConnection extends BaseConnection {
37
37
  getPerpPrices(): Promise<PerpPrices | null>;
38
38
  getUsdcPnlPool(): Promise<UsdcPnlPool | null>;
39
39
  getUsdcInsuranceFund(): Promise<UsdcInsuranceFund | null>;
40
- getBorrowLendMarkets(): Promise<BorrowLendPools>;
40
+ getBorrowLendMarkets(): Promise<BorrowLendMarkets>;
41
41
  getPerpMarket(market: MarketName): Promise<PerpMarket>;
42
42
  getPerpMarkets(markets: MarketName[]): Promise<Map<number, PerpMarket>>;
43
43
  getMarginConfig(): Promise<MarginConfig | null>;
44
44
  getTpslOrderIdsToExecute(market: MarketName): Promise<TpslOrderIdsToExecute | null>;
45
45
  getGlobalParameters(): Promise<GlobalParameters | null>;
46
46
  calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
47
- calculateEntryPrice(market: MarketName, userAccount: UserAccount): Promise<Decimal>;
47
+ calculateEntryPrice(market: MarketName, userAccount: UserAccount): Decimal;
48
48
  calculateTotalPerpUnrealizedPnl(userAccount: UserAccount, MarginCalculationState: {
49
49
  oracle_prices: OraclePrices;
50
50
  perp_prices: PerpPrices;
@@ -79,7 +79,7 @@ export declare class ExchangeConnection extends BaseConnection {
79
79
  oracle_prices: OraclePrices;
80
80
  perp_prices: PerpPrices;
81
81
  margin_config: MarginConfig;
82
- }): Promise<Decimal>;
82
+ }): Decimal;
83
83
  calculateLiquidationRiskPercentage(userAccount: UserAccount, MarginCalculationState: {
84
84
  oracle_prices: OraclePrices;
85
85
  perp_prices: PerpPrices;
@@ -94,64 +94,64 @@ export declare class ExchangeConnection extends BaseConnection {
94
94
  oracle_prices: OraclePrices;
95
95
  perp_prices: PerpPrices;
96
96
  margin_config: MarginConfig;
97
- }): Promise<Decimal>;
97
+ }): Decimal;
98
98
  calculateMaxOrderSize(market: MarketName, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, MarginCalculationState: {
99
99
  oracle_prices: OraclePrices;
100
100
  perp_prices: PerpPrices;
101
101
  margin_config: MarginConfig;
102
- }, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Promise<Decimal>;
102
+ }, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Decimal;
103
103
  simulateUsedMarginOnBorrow(asset: AssetName, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: {
104
104
  oracle_prices: OraclePrices;
105
105
  perp_prices: PerpPrices;
106
106
  margin_config: MarginConfig;
107
- }): Promise<{
107
+ }): {
108
108
  current: Decimal;
109
109
  updated: Decimal;
110
- }>;
110
+ };
111
111
  simulateUsedMarginOnOrder(placeOrderArgs: PlaceOrderArgs, userAccount: UserAccount, MarginCalculationState: {
112
112
  oracle_prices: OraclePrices;
113
113
  perp_prices: PerpPrices;
114
114
  margin_config: MarginConfig;
115
- }, orderbook: OrderbookL2): Promise<{
115
+ }, orderbook: OrderbookL2): {
116
116
  current: Decimal;
117
117
  updated: Decimal;
118
- }>;
118
+ };
119
119
  simulateEstimatedLiquidationPriceOnOrder(placeOrderArgs: PlaceOrderArgs, baseAsset: AssetName, userAccount: UserAccount, MarginCalculationState: {
120
120
  oracle_prices: OraclePrices;
121
121
  perp_prices: PerpPrices;
122
122
  margin_config: MarginConfig;
123
- }, orderbook: OrderbookL2): Promise<{
123
+ }, orderbook: OrderbookL2): {
124
124
  current: Decimal;
125
125
  updated: Decimal;
126
- }>;
126
+ };
127
127
  calculatePositionsAdditionalMetadata(userAccount: UserAccount, MarginCalculationState: {
128
128
  oracle_prices: OraclePrices;
129
129
  perp_prices: PerpPrices;
130
130
  margin_config: MarginConfig;
131
- }): Promise<Map<number, {
131
+ }): Map<number, {
132
132
  projected_funding_payment: Decimal;
133
133
  unrealized_pnl: Decimal;
134
134
  liquidation_price: Decimal;
135
135
  liquidation_risk_percentage: Decimal;
136
136
  max_leverage_to_use: number;
137
- }>>;
138
- calculateBorrowLendMarketAdditionalMetadata(borrowLendMarkets: BorrowLendPools, asset: AssetName): Promise<{
137
+ }>;
138
+ calculateBorrowLendMarketAdditionalMetadata(borrowLendMarkets: BorrowLendMarkets, asset: AssetName): {
139
139
  utilisation_rate: Decimal;
140
140
  current_deposit_rate: Decimal;
141
141
  current_borrow_rate: Decimal;
142
- }>;
142
+ };
143
143
  calculateAccountSummaryBatch(userAccounts: UserAccount[], MarginCalculationState: {
144
144
  oracle_prices: OraclePrices;
145
145
  perp_prices: PerpPrices;
146
146
  margin_config: MarginConfig;
147
- }, useWeightedEquity?: boolean): Promise<{
147
+ }, useWeightedEquity?: boolean): {
148
148
  address: string;
149
149
  unrealized_pnl: Decimal;
150
150
  equity: Decimal;
151
151
  available_initial_margin: Decimal;
152
152
  available_maintenance_margin: Decimal;
153
153
  leverage: Decimal;
154
- }[]>;
154
+ }[];
155
155
  private getWebSocketManager;
156
156
  subscribeOrderbook(market: MarketName): AsyncIterable<Orderbook>;
157
157
  unsubscribeOrderbook(market: MarketName): Promise<void>;
@@ -55,28 +55,27 @@ type PendingTriggerOrderArgs = {
55
55
  pending_sl: TriggerOrderArgs | null;
56
56
  dynamic_size: boolean;
57
57
  };
58
+ type PlacePositionTpslArgs = {
59
+ tp: TriggerOrderArgs | null;
60
+ sl: TriggerOrderArgs | null;
61
+ size: number | null;
62
+ };
58
63
  type ExchangeCallMessage = {
59
64
  set_value: number;
60
65
  deposit: {
61
- args: {
62
- asset_id: AssetId;
63
- amount: number;
64
- };
66
+ asset_id: AssetId;
67
+ amount: number;
65
68
  };
66
69
  withdraw: {
67
- args: {
68
- asset_id: AssetId;
69
- amount: number;
70
- };
70
+ asset_id: AssetId;
71
+ amount: number;
71
72
  };
72
73
  borrow_spot: {
73
- args: {
74
- asset_id: AssetId;
75
- amount: number;
76
- };
74
+ asset_id: AssetId;
75
+ amount: number;
77
76
  };
78
77
  place_order: {
79
- args: {
78
+ order_args: {
80
79
  market_id: MarketId;
81
80
  price: number;
82
81
  size: number;
@@ -89,16 +88,12 @@ type ExchangeCallMessage = {
89
88
  };
90
89
  create_position_tpsl: {
91
90
  market_id: MarketId;
92
- args: {
93
- tp: TriggerOrderArgs | null;
94
- sl: TriggerOrderArgs | null;
95
- size: number | null;
96
- };
91
+ tpsl: PlacePositionTpslArgs;
97
92
  };
98
93
  amend_order: {
99
94
  existing_order_id: string | null;
100
95
  existing_client_order_id: string | null;
101
- args: {
96
+ order_args: {
102
97
  market_id: MarketId;
103
98
  price: number;
104
99
  size: number;
@@ -112,11 +107,9 @@ type ExchangeCallMessage = {
112
107
  cancel_tpsl: {
113
108
  tpsl_order_id: string;
114
109
  };
115
- cancel_orders: {
116
- args: {
117
- order_id: string | null;
118
- client_order_id: string | null;
119
- }[];
110
+ cancel_order: {
111
+ order_id: string | null;
112
+ client_order_id: string | null;
120
113
  };
121
114
  cancel_all_orders_for_market: {
122
115
  market_id: MarketId;
@@ -143,7 +136,7 @@ type ExchangeCallMessage = {
143
136
  update_premium_indexes: {
144
137
  market_ids: MarketId[];
145
138
  };
146
- process_tpsl_buffer: {
139
+ process_tpsl_buffer_for_market: {
147
140
  market_id: MarketId;
148
141
  };
149
142
  update_funding: {
@@ -9,7 +9,6 @@ export type AssetId = number;
9
9
  export type MarketId = number;
10
10
  export type OrderId = bigint;
11
11
  export type ClientOrderId = bigint;
12
- export type MarketKind = "Perp" | "Spot";
13
12
  export type Side = "Bid" | "Ask";
14
13
  export type TriggerDirection = "GreaterThanOrEqual" | "LessThanOrEqual";
15
14
  export type TpslPriceCondition = "Mark" | "Oracle" | "LastTrade";