@bulletxyz/bullet-sdk 0.31.0-rc.0 → 0.31.0-rc.2

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.
@@ -1,9 +1,9 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- type EquityType = "Unweighted" | "WeightedInitial" | "WeightedMaintenance";
4
- type MarginType = "Initial" | "Maintenance";
5
- type OrderType = "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
6
- type Side = "Bid" | "Ask";
3
+ type EquityType = "unweighted" | "weighted_initial" | "weighted_maintenance";
4
+ type MarginType = "initial" | "maintenance";
5
+ type OrderType = "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
6
+ type Side = "bid" | "ask";
7
7
  export class BulletWasm {
8
8
  free(): void;
9
9
  [Symbol.dispose](): void;
@@ -4,7 +4,7 @@ import { Connection } from "./connection";
4
4
  import { type Endpoints } from "./constants";
5
5
  import { ExchangeConnection } from "./exchange";
6
6
  import type { RuntimeCall } from "./rollupTypes";
7
- import { type Address, type AssetId, type AssetName, type MarkPriceUpdateArgs, type MarketName, type Network, type NewOrderArgs, type OraclePriceUpdateArgs, type TokenId, type TpslPair } from "./types";
7
+ import { type Address, type AssetId, type AssetName, type MarkPriceUpdateArgs, type MarketName, type Network, type NewOrderArgs, type OraclePriceUpdateArgs, SpotCollateralTransferDirection, type TokenId, type TpslPair } from "./types";
8
8
  import type { Wallet } from "./wallet";
9
9
  export interface TransactionOpts {
10
10
  maxPriorityFeeBps: number;
@@ -44,13 +44,14 @@ export declare class Client {
44
44
  getTokenBalance(tokenId: string): Promise<bigint>;
45
45
  getUserAccount(): Promise<{
46
46
  account_variant: {
47
- Master: number[];
47
+ type: "master";
48
+ sub_account_indices: number[];
48
49
  } | {
49
- Sub: null;
50
+ type: "sub";
50
51
  } | {
51
- Vault: null;
52
+ type: "vault";
52
53
  } | {
53
- ProtocolVault: null;
54
+ type: "protocol_vault";
54
55
  };
55
56
  address: string;
56
57
  usdc_ledger: {
@@ -68,7 +69,7 @@ export declare class Client {
68
69
  }>;
69
70
  perp_ledgers: Map<number, {
70
71
  orders: Map<bigint, {
71
- side: "Bid" | "Ask";
72
+ side: "bid" | "ask";
72
73
  market_id: number;
73
74
  order_id: bigint;
74
75
  client_order_id: bigint | null;
@@ -94,20 +95,20 @@ export declare class Client {
94
95
  size: Decimal | null;
95
96
  order_price: Decimal;
96
97
  trigger_price: Decimal;
97
- price_condition: "Mark" | "Oracle" | "LastTrade";
98
- order_type: "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
99
- side: "Bid" | "Ask";
98
+ price_condition: "mark" | "oracle" | "last_trade";
99
+ order_type: "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
100
+ side: "bid" | "ask";
100
101
  market_id: number;
101
102
  owner: string;
102
103
  trigger_order_id: bigint;
103
- trigger_direction: "GreaterThanOrEqual" | "LessThanOrEqual";
104
+ trigger_direction: "greater_than_or_equal" | "less_than_or_equal";
104
105
  last_update_timestamp: bigint;
105
106
  linked_trigger_order_id: bigint | null;
106
107
  }>;
107
108
  }>;
108
109
  spot_ledgers: Map<number, {
109
110
  orders: Map<bigint, {
110
- side: "Bid" | "Ask";
111
+ side: "bid" | "ask";
111
112
  market_id: number;
112
113
  order_id: bigint;
113
114
  client_order_id: bigint | null;
@@ -123,31 +124,31 @@ export declare class Client {
123
124
  size: Decimal | null;
124
125
  order_price: Decimal;
125
126
  trigger_price: Decimal;
126
- price_condition: "Mark" | "Oracle" | "LastTrade";
127
- order_type: "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
128
- side: "Bid" | "Ask";
127
+ price_condition: "mark" | "oracle" | "last_trade";
128
+ order_type: "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
129
+ side: "bid" | "ask";
129
130
  market_id: number;
130
131
  owner: string;
131
132
  trigger_order_id: bigint;
132
- trigger_direction: "GreaterThanOrEqual" | "LessThanOrEqual";
133
+ trigger_direction: "greater_than_or_equal" | "less_than_or_equal";
133
134
  last_update_timestamp: bigint;
134
135
  linked_trigger_order_id: bigint | null;
135
136
  }>;
136
137
  }>;
137
- fee_tiers: Map<number, "Tier0" | "Tier1" | "Tier2" | "Tier3" | "Tier4">;
138
+ fee_tiers: Map<number, "tier0" | "tier1" | "tier2" | "tier3" | "tier4">;
138
139
  pending_tpsl_pairs: Map<string, {
139
140
  tpsl_pair: {
140
141
  tp: {
141
142
  order_price: Decimal;
142
143
  trigger_price: Decimal;
143
- price_condition: "Mark" | "Oracle" | "LastTrade";
144
- order_type: "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
144
+ price_condition: "mark" | "oracle" | "last_trade";
145
+ order_type: "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
145
146
  } | null;
146
147
  sl: {
147
148
  order_price: Decimal;
148
149
  trigger_price: Decimal;
149
- price_condition: "Mark" | "Oracle" | "LastTrade";
150
- order_type: "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
150
+ price_condition: "mark" | "oracle" | "last_trade";
151
+ order_type: "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
151
152
  } | null;
152
153
  };
153
154
  dynamic_size: boolean;
@@ -162,7 +163,7 @@ export declare class Client {
162
163
  borrowSpot(asset: AssetName, amount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
163
164
  depositSpotCollateral(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
164
165
  withdrawSpotCollateral(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
165
- transferSpotCollateral(direction: "MarginToSpot" | "SpotToMargin", asset: AssetName, amount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
166
+ transferSpotCollateral(direction: SpotCollateralTransferDirection, asset: AssetName, amount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
166
167
  placeOrders(market: MarketName, newOrders: NewOrderArgs[], replace?: boolean, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
167
168
  createPerpPositionTpsl(market: MarketName, tpslPair: TpslPair, size?: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
168
169
  amendOrders(market: MarketName, options: AmendOrderOptions[], subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
@@ -50,77 +50,77 @@ export declare class ExchangeConnection extends BaseConnection {
50
50
  getGlobalParameters(): Promise<GlobalParameters | null>;
51
51
  calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
52
52
  calculateEntryPrice(market: MarketName, userAccount: UserAccount): Decimal;
53
- calculateTotalPerpUnrealizedPnl(userAccount: UserAccount, MarginCalculationState: {
53
+ calculateTotalPerpUnrealizedPnl(userAccount: UserAccount, marginCalculationState: {
54
54
  oracle_prices: OraclePrices;
55
55
  perp_prices: PerpPrices;
56
56
  margin_config: MarginConfig;
57
57
  }): Decimal;
58
- calculateAccountEquity(equityType: EquityType, conservative: boolean, userAccount: UserAccount, MarginCalculationState: {
58
+ calculateAccountEquity(equityType: EquityType, conservative: boolean, userAccount: UserAccount, marginCalculationState: {
59
59
  oracle_prices: OraclePrices;
60
60
  perp_prices: PerpPrices;
61
61
  margin_config: MarginConfig;
62
62
  }): Decimal;
63
- calculateAccountLeverage(userAccount: UserAccount, MarginCalculationState: {
63
+ calculateAccountLeverage(userAccount: UserAccount, marginCalculationState: {
64
64
  oracle_prices: OraclePrices;
65
65
  perp_prices: PerpPrices;
66
66
  margin_config: MarginConfig;
67
67
  }): Decimal;
68
- calculateAvailableMargin(marginType: MarginType, conservative: boolean, userAccount: UserAccount, MarginCalculationState: {
68
+ calculateAvailableMargin(marginType: MarginType, conservative: boolean, userAccount: UserAccount, marginCalculationState: {
69
69
  oracle_prices: OraclePrices;
70
70
  perp_prices: PerpPrices;
71
71
  margin_config: MarginConfig;
72
72
  }): Decimal;
73
- calculateUsedMargin(withdrawal: boolean, marginType: MarginType, userAccount: UserAccount, MarginCalculationState: {
73
+ calculateUsedMargin(withdrawal: boolean, marginType: MarginType, userAccount: UserAccount, marginCalculationState: {
74
74
  oracle_prices: OraclePrices;
75
75
  perp_prices: PerpPrices;
76
76
  margin_config: MarginConfig;
77
77
  }): Decimal;
78
- calculateUsedPerpMargin(userAccount: UserAccount, marginType: MarginType, MarginCalculationState: {
78
+ calculateUsedPerpMargin(userAccount: UserAccount, marginType: MarginType, marginCalculationState: {
79
79
  oracle_prices: OraclePrices;
80
80
  perp_prices: PerpPrices;
81
81
  margin_config: MarginConfig;
82
82
  }): Decimal;
83
- calculateUsedSpotMargin(userAccount: UserAccount, marginType: MarginType, MarginCalculationState: {
83
+ calculateUsedSpotMargin(userAccount: UserAccount, marginType: MarginType, marginCalculationState: {
84
84
  oracle_prices: OraclePrices;
85
85
  perp_prices: PerpPrices;
86
86
  margin_config: MarginConfig;
87
87
  }): Decimal;
88
- calculateWithdrawableAmountOfAsset(asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
88
+ calculateWithdrawableAmountOfAsset(asset: AssetName, userAccount: UserAccount, marginCalculationState: {
89
89
  oracle_prices: OraclePrices;
90
90
  perp_prices: PerpPrices;
91
91
  margin_config: MarginConfig;
92
92
  }): Promise<Decimal>;
93
- calculateEstimatedLiquidationPrice(market: MarketName, asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
93
+ calculateEstimatedLiquidationPrice(market: MarketName, asset: AssetName, userAccount: UserAccount, marginCalculationState: {
94
94
  oracle_prices: OraclePrices;
95
95
  perp_prices: PerpPrices;
96
96
  margin_config: MarginConfig;
97
97
  }): Decimal;
98
- calculateLiquidationRiskPercentage(userAccount: UserAccount, MarginCalculationState: {
98
+ calculateLiquidationRiskPercentage(userAccount: UserAccount, marginCalculationState: {
99
99
  oracle_prices: OraclePrices;
100
100
  perp_prices: PerpPrices;
101
101
  margin_config: MarginConfig;
102
102
  }): Decimal;
103
- calculateMarginBalance(userAccount: UserAccount, MarginCalculationState: {
103
+ calculateMarginBalance(userAccount: UserAccount, marginCalculationState: {
104
104
  oracle_prices: OraclePrices;
105
105
  perp_prices: PerpPrices;
106
106
  margin_config: MarginConfig;
107
107
  }): Decimal;
108
- calculateForceCancelRiskPercentage(userAccount: UserAccount, MarginCalculationState: {
108
+ calculateForceCancelRiskPercentage(userAccount: UserAccount, marginCalculationState: {
109
109
  oracle_prices: OraclePrices;
110
110
  perp_prices: PerpPrices;
111
111
  margin_config: MarginConfig;
112
112
  }): Decimal;
113
- calculateMaxBorrowAmount(asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
113
+ calculateMaxBorrowAmount(asset: AssetName, userAccount: UserAccount, marginCalculationState: {
114
114
  oracle_prices: OraclePrices;
115
115
  perp_prices: PerpPrices;
116
116
  margin_config: MarginConfig;
117
117
  }): Decimal;
118
- calculateMaxOrderSize(market: MarketName, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, MarginCalculationState: {
118
+ calculateMaxOrderSize(market: MarketName, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, marginCalculationState: {
119
119
  oracle_prices: OraclePrices;
120
120
  perp_prices: PerpPrices;
121
121
  margin_config: MarginConfig;
122
122
  }, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Decimal;
123
- simulateUsedMarginOnBorrow(asset: AssetName, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: {
123
+ simulateUsedMarginOnBorrow(asset: AssetName, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, marginCalculationState: {
124
124
  oracle_prices: OraclePrices;
125
125
  perp_prices: PerpPrices;
126
126
  margin_config: MarginConfig;
@@ -128,7 +128,7 @@ export declare class ExchangeConnection extends BaseConnection {
128
128
  current: Decimal;
129
129
  updated: Decimal;
130
130
  };
131
- simulateUsedMarginOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, userAccount: UserAccount, MarginCalculationState: {
131
+ simulateUsedMarginOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, userAccount: UserAccount, marginCalculationState: {
132
132
  oracle_prices: OraclePrices;
133
133
  perp_prices: PerpPrices;
134
134
  margin_config: MarginConfig;
@@ -136,7 +136,7 @@ export declare class ExchangeConnection extends BaseConnection {
136
136
  current: Decimal;
137
137
  updated: Decimal;
138
138
  };
139
- simulateEstimatedLiquidationPriceOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, baseAsset: AssetName, userAccount: UserAccount, MarginCalculationState: {
139
+ simulateEstimatedLiquidationPriceOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, baseAsset: AssetName, userAccount: UserAccount, marginCalculationState: {
140
140
  oracle_prices: OraclePrices;
141
141
  perp_prices: PerpPrices;
142
142
  margin_config: MarginConfig;
@@ -144,7 +144,7 @@ export declare class ExchangeConnection extends BaseConnection {
144
144
  current: Decimal;
145
145
  updated: Decimal;
146
146
  };
147
- calculatePositionsAdditionalMetadata(userAccount: UserAccount, MarginCalculationState: {
147
+ calculatePositionsAdditionalMetadata(userAccount: UserAccount, marginCalculationState: {
148
148
  oracle_prices: OraclePrices;
149
149
  perp_prices: PerpPrices;
150
150
  margin_config: MarginConfig;
@@ -160,7 +160,7 @@ export declare class ExchangeConnection extends BaseConnection {
160
160
  current_deposit_rate: Decimal;
161
161
  current_borrow_rate: Decimal;
162
162
  };
163
- calculateAccountSummaryBatch(userAccounts: UserAccount[], MarginCalculationState: {
163
+ calculateAccountSummaryBatch(userAccounts: UserAccount[], marginCalculationState: {
164
164
  oracle_prices: OraclePrices;
165
165
  perp_prices: PerpPrices;
166
166
  margin_config: MarginConfig;
@@ -1,4 +1,4 @@
1
- import type { Address, AssetId, MarketId, TokenId } from "./types";
1
+ import type { Address, AssetId, MarketId, SpotCollateralTransferDirection, TokenId } from "./types";
2
2
  type ExactlyOne<T, Keys extends keyof T = keyof T> = {
3
3
  [K in Keys]: {
4
4
  [P in K]: T[P];
@@ -370,7 +370,7 @@ type ExchangeCallMessage = {
370
370
  };
371
371
  };
372
372
  transfer_spot_collateral: {
373
- direction: "MarginToSpot" | "SpotToMargin";
373
+ direction: SpotCollateralTransferDirection;
374
374
  args: {
375
375
  asset_id: AssetId;
376
376
  amount: number;
@@ -9,13 +9,14 @@ 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
- export type Side = "Bid" | "Ask";
14
- export type TriggerDirection = "GreaterThanOrEqual" | "LessThanOrEqual";
15
- export type TriggerPriceCondition = "Mark" | "Oracle" | "LastTrade";
16
- export type OrderType = "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
17
- export type MarginType = "Initial" | "Maintenance";
18
- export type EquityType = "Unweighted" | "WeightedInitial" | "WeightedMaintenance";
12
+ export type MarketKind = "perp" | "spot";
13
+ export type Side = "bid" | "ask";
14
+ export type SpotCollateralTransferDirection = "margin_to_spot" | "spot_to_margin";
15
+ export type TriggerDirection = "greater_than_or_equal" | "less_than_or_equal";
16
+ export type TriggerPriceCondition = "mark" | "oracle" | "last_trade";
17
+ export type OrderType = "limit" | "post_only" | "fill_or_kill" | "immediate_or_cancel" | "post_only_slide" | "post_only_front";
18
+ export type MarginType = "initial" | "maintenance";
19
+ export type EquityType = "unweighted" | "weighted_initial" | "weighted_maintenance";
19
20
  export type Network = "Localnet" | "Staging" | "Testnet" | "Mainnet";
20
21
  export type RollupErrorStructure = {
21
22
  error?: {
@@ -75,8 +76,8 @@ export declare class BulletError extends Error {
75
76
  shortMessage: string;
76
77
  verboseMessage: string;
77
78
  httpStatus?: number;
78
- responseData?: any;
79
- constructor(code: string, shortMessage: string, verboseMessage: string, originalError?: Error | undefined, httpStatus?: number, responseData?: any);
79
+ responseData?: unknown;
80
+ constructor(code: string, shortMessage: string, verboseMessage: string, originalError?: Error | undefined, httpStatus?: number, responseData?: unknown);
80
81
  static fromModuleError(error: unknown): BulletError;
81
82
  toJSON(): {
82
83
  name: string;
@@ -85,6 +86,6 @@ export declare class BulletError extends Error {
85
86
  shortMessage: string;
86
87
  verboseMessage: string;
87
88
  httpStatus: number | undefined;
88
- responseData: any;
89
+ responseData: unknown;
89
90
  };
90
91
  }