@bulletxyz/bullet-sdk 0.25.0-rc.1 → 0.25.0-rc.10
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 +55 -70
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.js +55 -70
- package/dist/node/index.js.map +2 -2
- package/dist/types/bullet-wasm/index.d.ts +4 -4
- package/dist/types/calc.d.ts +5 -5
- package/dist/types/client.d.ts +3 -12
- package/dist/types/rollupTypes.d.ts +2 -2
- package/dist/types/types.d.ts +8 -8
- package/dist/types/zod-types/index.d.ts +1 -0
- package/dist/types/zod-types/rest.d.ts +435 -815
- package/package.json +3 -3
|
@@ -23,12 +23,12 @@ export class BulletWasm {
|
|
|
23
23
|
* Calculates the maximum amount that can be borrowed for a given asset
|
|
24
24
|
* @param initial_liability_weight The initial liability weight for the market must be passed in separately since the user may not have a spot ledger for this asset yet
|
|
25
25
|
*/
|
|
26
|
-
static calculate_max_borrow_amount(asset_id: number,
|
|
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
|
-
static simulate_used_margin_on_borrow(asset_id: number, borrow_amount: string,
|
|
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
29
|
static simulate_used_margin_on_order(place_order_args: any, user_account: any, margin_calculation_state: any, orderbook: any): any;
|
|
30
30
|
static simulate_estimated_liquidation_price_on_order(place_order_args: any, base_asset: number, user_account: any, margin_calculation_state: any, orderbook: any): any;
|
|
31
|
-
static calculate_positions_additional_metadata(user_account: any, margin_calculation_state: any
|
|
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
|
-
static calculate_account_summary_batch(user_accounts: any, margin_calculation_state: any): any;
|
|
33
|
+
static calculate_account_summary_batch(user_accounts: any, margin_calculation_state: any, use_weighted_equity: boolean): any;
|
|
34
34
|
}
|
package/dist/types/calc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Decimal from "decimal.js";
|
|
2
2
|
import { type EquityType, type MarginType } from "./bullet-wasm";
|
|
3
3
|
import type { Asset, Market, OrderType, PlaceOrderArgs, Side } from "./types";
|
|
4
|
-
import type { BorrowLendMarkets,
|
|
4
|
+
import type { BorrowLendMarkets, MarginConfig, OraclePrices, OrderbookL2, PerpPrices, UserAccount } from "./zod-types/rest";
|
|
5
5
|
export declare function calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
|
|
6
6
|
export declare function calculateEntryPrice(market: Market, userAccount: UserAccount): Decimal;
|
|
7
7
|
export interface MarginCalculationState {
|
|
@@ -18,9 +18,9 @@ export declare function calculateWithdrawableAmountOfAsset(asset: Asset, userAcc
|
|
|
18
18
|
export declare function calculateEstimatedLiquidationPrice(market: Market, asset: Asset, userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
19
19
|
export declare function calculateLiquidationRiskPercentage(userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
20
20
|
export declare function calculateForceCancelRiskPercentage(userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
21
|
-
export declare function calculateMaxBorrowAmount(asset: Asset,
|
|
21
|
+
export declare function calculateMaxBorrowAmount(asset: Asset, userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
22
22
|
export declare function calculateMaxOrderSize(market: Market, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, MarginCalculationState: MarginCalculationState, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Decimal;
|
|
23
|
-
export declare function simulateUsedMarginOnBorrow(asset: Asset, borrowAmount: Decimal,
|
|
23
|
+
export declare function simulateUsedMarginOnBorrow(asset: Asset, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: MarginCalculationState): {
|
|
24
24
|
current: Decimal;
|
|
25
25
|
updated: Decimal;
|
|
26
26
|
};
|
|
@@ -32,7 +32,7 @@ export declare function simulateEstimatedLiquidationPriceOnOrder(placeOrderArgs:
|
|
|
32
32
|
current: Decimal;
|
|
33
33
|
updated: Decimal;
|
|
34
34
|
};
|
|
35
|
-
export declare function calculatePositionsAdditionalMetadata(userAccount: UserAccount, MarginCalculationState: MarginCalculationState
|
|
35
|
+
export declare function calculatePositionsAdditionalMetadata(userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Map<number, {
|
|
36
36
|
projected_funding_payment: Decimal;
|
|
37
37
|
unrealized_pnl: Decimal;
|
|
38
38
|
liquidation_price: Decimal;
|
|
@@ -44,7 +44,7 @@ export declare function calculateBorrowLendMarketAdditionalMetadata(borrowLendMa
|
|
|
44
44
|
current_deposit_rate: Decimal;
|
|
45
45
|
current_borrow_rate: Decimal;
|
|
46
46
|
};
|
|
47
|
-
export declare function calculateAccountSummaryBatch(userAccounts: UserAccount[], MarginCalculationState: MarginCalculationState): {
|
|
47
|
+
export declare function calculateAccountSummaryBatch(userAccounts: UserAccount[], MarginCalculationState: MarginCalculationState, useWeightedEquity?: boolean): {
|
|
48
48
|
address: string;
|
|
49
49
|
unrealized_pnl: Decimal;
|
|
50
50
|
equity: Decimal;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -31,23 +31,14 @@ export declare class Client {
|
|
|
31
31
|
address: string;
|
|
32
32
|
usdc_ledger: {
|
|
33
33
|
ledger: {
|
|
34
|
-
weights: {
|
|
35
|
-
asset_weight: Decimal;
|
|
36
|
-
initial_liability_weight: Decimal;
|
|
37
|
-
maintenance_liability_weight: Decimal;
|
|
38
|
-
};
|
|
39
34
|
asset: Decimal;
|
|
40
35
|
liability: Decimal;
|
|
41
36
|
};
|
|
42
37
|
unrealized_loss_borrow: Decimal;
|
|
43
38
|
unsettled_perp_profit: Decimal;
|
|
44
39
|
};
|
|
40
|
+
client_order_ids: Map<bigint, bigint>;
|
|
45
41
|
spot_ledgers: Map<number, {
|
|
46
|
-
weights: {
|
|
47
|
-
asset_weight: Decimal;
|
|
48
|
-
initial_liability_weight: Decimal;
|
|
49
|
-
maintenance_liability_weight: Decimal;
|
|
50
|
-
};
|
|
51
42
|
asset: Decimal;
|
|
52
43
|
liability: Decimal;
|
|
53
44
|
}>;
|
|
@@ -94,7 +85,7 @@ export declare class Client {
|
|
|
94
85
|
};
|
|
95
86
|
user_selected_max_leverage: number;
|
|
96
87
|
tpsls: Map<bigint, {
|
|
97
|
-
size: Decimal;
|
|
88
|
+
size: Decimal | null;
|
|
98
89
|
tpsl_order_id: bigint;
|
|
99
90
|
order_price: Decimal;
|
|
100
91
|
trigger_price: Decimal;
|
|
@@ -116,7 +107,7 @@ export declare class Client {
|
|
|
116
107
|
borrowSpot(asset: Asset, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
117
108
|
placeOrder(placeOrderArgs: PlaceOrderArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
118
109
|
placeTpslsForMarket(market: Market, tpslOrders: PlacePositionTpslArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
119
|
-
replaceOrder(existingOrderId: bigint |
|
|
110
|
+
replaceOrder(existingOrderId: bigint | undefined, existingClientOrderId: bigint | undefined, placeOrderArgs: PlaceOrderArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
120
111
|
cancelTpsl(tpslOrderId: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
121
112
|
cancelOrder(orderId: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
122
113
|
cancelAllOrdersForMarket(market: Market): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
@@ -65,9 +65,9 @@ type ExchangeCallMessage = {
|
|
|
65
65
|
tpsl: PendingTriggerOrderArgs | null;
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
place_tpsl_for_market: {
|
|
69
69
|
market_id: MarketId;
|
|
70
|
-
|
|
70
|
+
tpsl: PlacePositionTpslArgs;
|
|
71
71
|
};
|
|
72
72
|
replace_order: {
|
|
73
73
|
existing_order_id: string | null;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type Address = string;
|
|
|
5
5
|
export type TokenId = string;
|
|
6
6
|
export type AssetId = number;
|
|
7
7
|
export type MarketId = number;
|
|
8
|
-
export type OrderId =
|
|
8
|
+
export type OrderId = bigint;
|
|
9
9
|
export type ClientOrderId = bigint;
|
|
10
10
|
export declare enum Asset {
|
|
11
11
|
USDC = 0,
|
|
@@ -59,8 +59,8 @@ export type PlaceOrderArgs = {
|
|
|
59
59
|
side: Side;
|
|
60
60
|
orderType: OrderType;
|
|
61
61
|
reduceOnly: boolean;
|
|
62
|
-
clientOrderId
|
|
63
|
-
tpsl
|
|
62
|
+
clientOrderId?: ClientOrderId;
|
|
63
|
+
tpsl?: PendingTriggerOrderArgs;
|
|
64
64
|
};
|
|
65
65
|
export type OraclePriceUpdateArgs = {
|
|
66
66
|
assetId: AssetId;
|
|
@@ -79,14 +79,14 @@ export type TriggerOrderArgs = {
|
|
|
79
79
|
orderType: OrderType;
|
|
80
80
|
};
|
|
81
81
|
export type PendingTriggerOrderArgs = {
|
|
82
|
-
pendingTp
|
|
83
|
-
pendingSl
|
|
82
|
+
pendingTp?: TriggerOrderArgs;
|
|
83
|
+
pendingSl?: TriggerOrderArgs;
|
|
84
84
|
dynamicSize: boolean;
|
|
85
85
|
};
|
|
86
86
|
export type PlacePositionTpslArgs = {
|
|
87
|
-
tp
|
|
88
|
-
sl
|
|
89
|
-
size
|
|
87
|
+
tp?: TriggerOrderArgs;
|
|
88
|
+
sl?: TriggerOrderArgs;
|
|
89
|
+
size?: Decimal;
|
|
90
90
|
};
|
|
91
91
|
export declare class BulletError extends Error {
|
|
92
92
|
originalError?: Error | undefined;
|
|
@@ -10,6 +10,7 @@ export declare const Base58Address: z.ZodString;
|
|
|
10
10
|
export declare const AssetId: z.ZodNumber;
|
|
11
11
|
export declare const MarketId: z.ZodNumber;
|
|
12
12
|
export declare const OrderId: z.ZodBigInt;
|
|
13
|
+
export declare const ClientOrderId: z.ZodBigInt;
|
|
13
14
|
export declare const TpslOrderId: z.ZodBigInt;
|
|
14
15
|
export declare const Amount: z.ZodBigInt;
|
|
15
16
|
export declare const UnixTimestampMillis: z.ZodBigInt;
|