@bulletxyz/bullet-sdk 0.27.2-rc.4 → 0.27.3
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 +181 -142
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.js +181 -142
- package/dist/node/index.js.map +2 -2
- package/dist/types/bullet-wasm/index.d.ts +2 -2
- package/dist/types/client.d.ts +19 -11
- package/dist/types/exchange.d.ts +3 -3
- package/dist/types/rollupTypes.d.ts +68 -24
- package/dist/types/types.d.ts +2 -3
- package/package.json +1 -1
|
@@ -26,8 +26,8 @@ export class BulletWasm {
|
|
|
26
26
|
static calculate_max_borrow_amount(asset_id: number, user_account: any, margin_calculation_state: any): string;
|
|
27
27
|
static calculate_max_order_size(market_id: number, price: string, side: Side, order_type: OrderType, reduce_only: boolean, user_account: any, margin_calculation_state: any, orderbook: any, n_iterations: number, error_tolerance: string): string;
|
|
28
28
|
static simulate_used_margin_on_borrow(asset_id: number, borrow_amount: string, user_account: any, margin_type: MarginType, margin_calculation_state: any): any;
|
|
29
|
-
static simulate_used_margin_on_order(
|
|
30
|
-
static simulate_estimated_liquidation_price_on_order(
|
|
29
|
+
static simulate_used_margin_on_order(market_id: number, new_order_args: any, user_account: any, margin_calculation_state: any, orderbook: any): any;
|
|
30
|
+
static simulate_estimated_liquidation_price_on_order(market_id: number, new_order_args: any, base_asset: number, user_account: any, margin_calculation_state: any, orderbook: any): any;
|
|
31
31
|
static calculate_positions_additional_metadata(user_account: any, margin_calculation_state: any): any;
|
|
32
32
|
static calculate_borrow_lend_additional_metadata(borrow_lend_market: any): any;
|
|
33
33
|
static calculate_account_summary_batch(user_accounts: any, margin_calculation_state: any, use_weighted_equity: boolean): any;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -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
|
|
7
|
+
import { type Address, type AssetId, type AssetName, type CreatePositionTpslArgs, type MarkPriceUpdateArgs, type MarketName, type Network, type NewOrderArgs, type OraclePriceUpdateArgs, type TokenId } from "./types";
|
|
8
8
|
import type { Wallet } from "./wallet";
|
|
9
9
|
export interface TransactionOpts {
|
|
10
10
|
maxPriorityFeeBps: number;
|
|
@@ -14,11 +14,18 @@ export interface TransactionOpts {
|
|
|
14
14
|
type AmendOrderOptions = {
|
|
15
15
|
existingOrderId: bigint;
|
|
16
16
|
existingClientOrderId?: never;
|
|
17
|
-
|
|
17
|
+
newOrderArgs: NewOrderArgs;
|
|
18
18
|
} | {
|
|
19
19
|
existingOrderId?: never;
|
|
20
20
|
existingClientOrderId: bigint;
|
|
21
|
-
|
|
21
|
+
newOrderArgs: NewOrderArgs;
|
|
22
|
+
};
|
|
23
|
+
type CancelOrderOptions = {
|
|
24
|
+
orderId: bigint;
|
|
25
|
+
clientOrderId?: never;
|
|
26
|
+
} | {
|
|
27
|
+
orderId?: never;
|
|
28
|
+
clientOrderId: bigint;
|
|
22
29
|
};
|
|
23
30
|
export declare class Client {
|
|
24
31
|
connection: Connection;
|
|
@@ -163,14 +170,14 @@ export declare class Client {
|
|
|
163
170
|
deposit(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
164
171
|
withdraw(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
165
172
|
borrowSpot(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
cancelTpsls(tpslOrderIds: bigint[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
170
|
-
|
|
173
|
+
placeOrders(market: MarketName, newOrders: NewOrderArgs[], replace?: boolean): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
174
|
+
createPerpPositionTpsl(market: MarketName, tpslOrders: CreatePositionTpslArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
175
|
+
amendOrders(market: MarketName, options: AmendOrderOptions[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
176
|
+
cancelTpsls(market: MarketName, tpslOrderIds: bigint[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
177
|
+
cancelOrders(market: MarketName, options: CancelOrderOptions[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
171
178
|
adminCancelOrders(address: Address, market: MarketName, orderId: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
172
179
|
adminCancelTpsls(address: Address, market: MarketName, tpslOrderId: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
173
|
-
|
|
180
|
+
cancelAllOrders(market: MarketName): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
174
181
|
updateOraclePrices(pricesToUpdate: OraclePriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
175
182
|
updateMarkPrices(pricesToUpdate: MarkPriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
176
183
|
updateMaxLeverageForMarket(market: MarketName, maxLeverage: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
@@ -190,8 +197,9 @@ export declare class Client {
|
|
|
190
197
|
initAssetMetadata(asset_id: number, assetName: string, tokenId: TokenId, decimals: number, withdrawFee: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
191
198
|
updateAssetMetadata(assetId: number, assetName: string | null, tokenId: TokenId | null, decimals: number | null, withdrawFee: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
192
199
|
initSpotMarket(marketId: number, baseAssetId: number, quoteAssetId: AssetId, baseMinLotSize: Decimal, quoteMinLotSize: Decimal, maxOrdersPerSide: number, takerFeesTenthBps: number[], makerFeesTenthBps: number[], name: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
193
|
-
initPerpMarket(marketId: number, baseAssetId: number, name: string, minTickSize: Decimal, minLotSize: Decimal, maxOrdersPerSide: number, minInterestRateClamp: Decimal, maxInterestRateClamp: Decimal, minFundingRateClamp: Decimal, maxFundingRateClamp: Decimal, impactMargin: Decimal, interestRate: Decimal,
|
|
200
|
+
initPerpMarket(marketId: number, baseAssetId: number, name: string, minTickSize: Decimal, minLotSize: Decimal, maxOrdersPerSide: number, minInterestRateClamp: Decimal, maxInterestRateClamp: Decimal, minFundingRateClamp: Decimal, maxFundingRateClamp: Decimal, impactMargin: Decimal, interestRate: Decimal, leverageTableArgs: Record<string, number>, takerFeesTenthBps: number[], makerFeesTenthBps: number[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
194
201
|
initBorrowLendPool(assetId: number, optimalUtilisationRate: Decimal, minBorrowRate: Decimal, maxBorrowRate: Decimal, optimalBorrowRate: Decimal, assetWeight: Decimal, initialLiabilityWeight: Decimal, maintenanceLiabilityWeight: Decimal, depositLimit: Decimal, borrowLimit: Decimal, liquidationTotalRewardRatio: Decimal, protocolRewardRatio: Decimal, liabilityLiquidationLimitRatio: Decimal, interestFeeTenthBps: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
195
|
-
|
|
202
|
+
updateBorrowLendPool(asset: AssetName, optimalUtilisationRate: Decimal | null, minBorrowRate: Decimal | null, maxBorrowRate: Decimal | null, optimalBorrowRate: Decimal | null, assetWeight: Decimal | null, initialLiabilityWeight: Decimal | null, maintenanceLiabilityWeight: Decimal | null, depositLimit: Decimal | null, borrowLimit: Decimal | null, liquidationRewardRatio: Decimal | null, liabilityLiquidationLimitRatio: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
203
|
+
updateLeverageTable(market: MarketName, leverageTable: Record<string, number>): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
196
204
|
}
|
|
197
205
|
export {};
|
package/dist/types/exchange.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type EquityType, type MarginType } from "./bullet-wasm";
|
|
|
3
3
|
import { BaseConnection } from "./connection";
|
|
4
4
|
import { type Endpoints } from "./constants";
|
|
5
5
|
import type { Orderbook } from "./orderbook";
|
|
6
|
-
import type { Address, AssetName, MarketMetadata, MarketName, Network,
|
|
6
|
+
import type { Address, AssetName, MarketMetadata, MarketName, Network, NewOrderArgs, OrderType, Side } from "./types";
|
|
7
7
|
import { type AccountAddresses, type AssetRegistry, type BorrowLendPools, type GlobalParameters, type MarginConfig, type MarketRegistry, type OraclePrices, type Order, type OrderbookL2, type PerpMarket, type PerpPrices, type SpotMarket, type Tpsl, type TpslOrderIdsToExecute, type UsdcInsuranceFund, type UsdcPnlPool, type UserAccount } from "./zod-types/rest";
|
|
8
8
|
export declare class ExchangeConnection extends BaseConnection {
|
|
9
9
|
private wsManager?;
|
|
@@ -112,7 +112,7 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
112
112
|
current: Decimal;
|
|
113
113
|
updated: Decimal;
|
|
114
114
|
};
|
|
115
|
-
simulateUsedMarginOnOrder(
|
|
115
|
+
simulateUsedMarginOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, userAccount: UserAccount, MarginCalculationState: {
|
|
116
116
|
oracle_prices: OraclePrices;
|
|
117
117
|
perp_prices: PerpPrices;
|
|
118
118
|
margin_config: MarginConfig;
|
|
@@ -120,7 +120,7 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
120
120
|
current: Decimal;
|
|
121
121
|
updated: Decimal;
|
|
122
122
|
};
|
|
123
|
-
simulateEstimatedLiquidationPriceOnOrder(
|
|
123
|
+
simulateEstimatedLiquidationPriceOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, baseAsset: AssetName, userAccount: UserAccount, MarginCalculationState: {
|
|
124
124
|
oracle_prices: OraclePrices;
|
|
125
125
|
perp_prices: PerpPrices;
|
|
126
126
|
margin_config: MarginConfig;
|
|
@@ -88,9 +88,9 @@ type ExchangeCallMessage = {
|
|
|
88
88
|
amount: number;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
place_perp_orders: {
|
|
92
|
+
market_id: MarketId;
|
|
92
93
|
args: {
|
|
93
|
-
market_id: MarketId;
|
|
94
94
|
price: number;
|
|
95
95
|
size: number;
|
|
96
96
|
side: string;
|
|
@@ -98,11 +98,12 @@ type ExchangeCallMessage = {
|
|
|
98
98
|
reduce_only: boolean;
|
|
99
99
|
client_order_id: string | null;
|
|
100
100
|
tpsl: PendingTriggerOrderArgs | null;
|
|
101
|
-
};
|
|
101
|
+
}[];
|
|
102
|
+
replace: boolean;
|
|
102
103
|
};
|
|
103
|
-
|
|
104
|
+
place_spot_orders: {
|
|
105
|
+
market_id: MarketId;
|
|
104
106
|
args: {
|
|
105
|
-
market_id: MarketId;
|
|
106
107
|
price: number;
|
|
107
108
|
size: number;
|
|
108
109
|
side: string;
|
|
@@ -110,9 +111,10 @@ type ExchangeCallMessage = {
|
|
|
110
111
|
reduce_only: boolean;
|
|
111
112
|
client_order_id: string | null;
|
|
112
113
|
tpsl: PendingTriggerOrderArgs | null;
|
|
113
|
-
};
|
|
114
|
+
}[];
|
|
115
|
+
replace: boolean;
|
|
114
116
|
};
|
|
115
|
-
|
|
117
|
+
create_perp_position_tpsl: {
|
|
116
118
|
market_id: MarketId;
|
|
117
119
|
args: {
|
|
118
120
|
tp: TriggerOrderArgs | null;
|
|
@@ -120,24 +122,59 @@ type ExchangeCallMessage = {
|
|
|
120
122
|
size: number | null;
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
existing_client_order_id: string | null;
|
|
125
|
+
amend_perp_orders: {
|
|
126
|
+
market_id: MarketId;
|
|
126
127
|
args: {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
cancel: {
|
|
129
|
+
order_id: string | null;
|
|
130
|
+
client_order_id: string | null;
|
|
131
|
+
};
|
|
132
|
+
place: {
|
|
133
|
+
price: number;
|
|
134
|
+
size: number;
|
|
135
|
+
side: string;
|
|
136
|
+
order_type: string;
|
|
137
|
+
reduce_only: boolean;
|
|
138
|
+
client_order_id: string | null;
|
|
139
|
+
tpsl: PendingTriggerOrderArgs | null;
|
|
140
|
+
};
|
|
141
|
+
}[];
|
|
136
142
|
};
|
|
137
|
-
|
|
143
|
+
amend_spot_orders: {
|
|
144
|
+
market_id: MarketId;
|
|
145
|
+
args: {
|
|
146
|
+
cancel: {
|
|
147
|
+
order_id: string | null;
|
|
148
|
+
client_order_id: string | null;
|
|
149
|
+
};
|
|
150
|
+
place: {
|
|
151
|
+
price: number;
|
|
152
|
+
size: number;
|
|
153
|
+
side: string;
|
|
154
|
+
order_type: string;
|
|
155
|
+
reduce_only: boolean;
|
|
156
|
+
client_order_id: string | null;
|
|
157
|
+
tpsl: PendingTriggerOrderArgs | null;
|
|
158
|
+
};
|
|
159
|
+
}[];
|
|
160
|
+
};
|
|
161
|
+
cancel_perp_tpsls: {
|
|
162
|
+
market_id: MarketId;
|
|
138
163
|
tpsl_order_ids: string[];
|
|
139
164
|
};
|
|
140
|
-
|
|
165
|
+
cancel_spot_tpsls: {
|
|
166
|
+
market_id: MarketId;
|
|
167
|
+
tpsl_order_ids: string[];
|
|
168
|
+
};
|
|
169
|
+
cancel_perp_orders: {
|
|
170
|
+
market_id: MarketId;
|
|
171
|
+
args: {
|
|
172
|
+
order_id: string | null;
|
|
173
|
+
client_order_id: string | null;
|
|
174
|
+
}[];
|
|
175
|
+
};
|
|
176
|
+
cancel_spot_orders: {
|
|
177
|
+
market_id: MarketId;
|
|
141
178
|
args: {
|
|
142
179
|
order_id: string | null;
|
|
143
180
|
client_order_id: string | null;
|
|
@@ -149,7 +186,10 @@ type ExchangeCallMessage = {
|
|
|
149
186
|
admin_cancel_tpsls: {
|
|
150
187
|
args: [Address, MarketId, string][];
|
|
151
188
|
};
|
|
152
|
-
|
|
189
|
+
cancel_all_perp_orders: {
|
|
190
|
+
market_id: MarketId;
|
|
191
|
+
};
|
|
192
|
+
cancel_all_spot_orders: {
|
|
153
193
|
market_id: MarketId;
|
|
154
194
|
};
|
|
155
195
|
update_oracle_prices: {
|
|
@@ -266,7 +306,7 @@ type ExchangeCallMessage = {
|
|
|
266
306
|
max_funding_rate_clamp: number;
|
|
267
307
|
impact_margin: number;
|
|
268
308
|
interest_rate: number;
|
|
269
|
-
leverage_table_args:
|
|
309
|
+
leverage_table_args: Record<string, number>;
|
|
270
310
|
taker_fees_tenth_bps: number[];
|
|
271
311
|
maker_fees_tenth_bps: number[];
|
|
272
312
|
};
|
|
@@ -289,7 +329,7 @@ type ExchangeCallMessage = {
|
|
|
289
329
|
interest_fee_tenth_bps: number;
|
|
290
330
|
};
|
|
291
331
|
};
|
|
292
|
-
|
|
332
|
+
update_borrow_lend_pool: {
|
|
293
333
|
args: {
|
|
294
334
|
asset_id: AssetId;
|
|
295
335
|
optimal_utilisation_rate: number | null;
|
|
@@ -305,6 +345,10 @@ type ExchangeCallMessage = {
|
|
|
305
345
|
liability_liquidation_limit_ratio: number | null;
|
|
306
346
|
};
|
|
307
347
|
};
|
|
348
|
+
update_leverage_table: {
|
|
349
|
+
market_id: MarketId;
|
|
350
|
+
args: Record<string, number>;
|
|
351
|
+
};
|
|
308
352
|
};
|
|
309
353
|
export type RuntimeCall = ExactlyOne<{
|
|
310
354
|
exchange: ExactlyOne<ExchangeCallMessage>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -24,8 +24,7 @@ export type RollupErrorStructure = {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
28
|
-
market: MarketName;
|
|
27
|
+
export type NewOrderArgs = {
|
|
29
28
|
price: Decimal;
|
|
30
29
|
size: Decimal;
|
|
31
30
|
side: Side;
|
|
@@ -55,7 +54,7 @@ export type PendingTriggerOrderArgs = {
|
|
|
55
54
|
pendingSl?: TriggerOrderArgs;
|
|
56
55
|
dynamicSize: boolean;
|
|
57
56
|
};
|
|
58
|
-
export type
|
|
57
|
+
export type CreatePositionTpslArgs = {
|
|
59
58
|
tp?: TriggerOrderArgs;
|
|
60
59
|
sl?: TriggerOrderArgs;
|
|
61
60
|
size?: Decimal;
|