@bulletxyz/bullet-sdk 0.17.7 → 0.18.0-rc.1

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,18 +1,9 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export enum EquityType {
4
- Unweighted = 0,
5
- WeightedInitial = 1,
6
- WeightedMaintenance = 2,
7
- }
8
- export enum MarginType {
9
- Initial = 0,
10
- Maintenance = 1,
11
- }
12
- export enum Side {
13
- Bid = 0,
14
- Ask = 1,
15
- }
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";
16
7
  export class BulletWasm {
17
8
  free(): void;
18
9
  constructor();
@@ -33,9 +24,10 @@ export class BulletWasm {
33
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
34
25
  */
35
26
  static calculate_max_borrow_amount(asset_id: number, initial_liability_weight: string, user_account: any, margin_context: any): string;
36
- static calculate_max_order_size(user_account: any, asset_id: number, side: Side, price: string, reduce_only: boolean, margin_context: any, maker_book: any, n_iterations: number, error_tolerance: string): string;
27
+ static calculate_max_order_size(asset_id: number, price: string, side: Side, order_type: OrderType, reduce_only: boolean, user_account: any, margin_context: any, maker_book: any, n_iterations: number, error_tolerance: string): string;
37
28
  static simulate_used_margin_on_borrow(asset_id: number, borrow_amount: string, user_account: any, margin_type: MarginType, margin_context: any): any;
38
- static simulate_used_margin_on_order(asset_id: number, side: Side, price: string, size: string, reduce_only: boolean, user_account: any, margin_context: any): any;
29
+ static simulate_used_margin_on_order(place_order_args: any, user_account: any, margin_context: any, maker_book: any): any;
30
+ static simulate_estimated_liquidation_price_on_order(place_order_args: any, user_account: any, margin_context: any, maker_book: any): any;
39
31
  static calculate_positions_additional_metadata(user_account: any, margin_context: any, funding_parameters: any): any;
40
32
  static calculate_borrow_lend_additional_metadata(borrow_lend_market: any): any;
41
33
  static calculate_account_summary_batch(user_accounts: any, margin_context: any): any;
@@ -1,6 +1,6 @@
1
1
  import Decimal from "decimal.js";
2
2
  import { type EquityType, type MarginType } from "./bullet-wasm";
3
- import type { Asset, AssetId, Side } from "./types";
3
+ import type { Asset, AssetId, OrderType, PlaceOrderArgs, Side } from "./types";
4
4
  import type { BorrowLendMarket, MarginConfig, OrderbookData, PerpMarket, Pricing, UserAccount } from "./zod-types/rest";
5
5
  export declare function calculateOrderbookMidpoint(orderbook: OrderbookData): Decimal | undefined;
6
6
  export declare function calculateEntryPrice(asset: Asset, userAccount: UserAccount): Decimal;
@@ -18,11 +18,19 @@ export declare function calculateEstimatedLiquidationPrice(assetId: AssetId, use
18
18
  export declare function calculateLiquidationRiskPercentage(userAccount: UserAccount, marginContext: MarginContext): Decimal;
19
19
  export declare function calculateForceCancelRiskPercentage(userAccount: UserAccount, marginContext: MarginContext): Decimal;
20
20
  export declare function calculateMaxBorrowAmount(assetId: AssetId, initialLiabilityWeight: Decimal, userAccount: UserAccount, marginContext: MarginContext): Decimal;
21
- export declare function calculateMaxOrderSize(assetId: AssetId, side: Side, price: Decimal, reduceOnly: boolean, userAccount: UserAccount, marginContext: MarginContext, makerBook: OrderbookData, n_iterations?: number, error_tolerance?: Decimal): Decimal;
21
+ export declare function calculateMaxOrderSize(asset_id: AssetId, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, marginContext: MarginContext, orderbook: OrderbookData, n_iterations?: number, error_tolerance?: Decimal): Decimal;
22
22
  export declare function simulateUsedMarginOnBorrow(assetId: AssetId, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, marginContext: MarginContext): {
23
23
  current: Decimal;
24
24
  updated: Decimal;
25
25
  };
26
+ export declare function simulateUsedMarginOnOrder(placeOrderArgs: PlaceOrderArgs, userAccount: UserAccount, marginContext: MarginContext, orderbook: OrderbookData): {
27
+ current: Decimal;
28
+ updated: Decimal;
29
+ };
30
+ export declare function simulateEstimatedLiquidationPriceOnOrder(placeOrderArgs: PlaceOrderArgs, userAccount: UserAccount, marginContext: MarginContext, orderbook: OrderbookData): {
31
+ current: Decimal;
32
+ updated: Decimal;
33
+ };
26
34
  export declare function calculatePositionsAdditionalMetadata(userAccount: UserAccount, marginContext: MarginContext, perpMarkets: Map<Asset, PerpMarket>): Map<number, {
27
35
  projected_funding_payment: Decimal;
28
36
  unrealized_pnl: Decimal;
@@ -3,7 +3,7 @@ import type Decimal from "decimal.js";
3
3
  import { Connection } from "./connection";
4
4
  import { ExchangeConnection } from "./exchange";
5
5
  import type { RuntimeCall } from "./rollupTypes";
6
- import { type Address, type Asset, type Network, type OrderType, type Side, type TokenId, type TpslOrder } from "./types";
6
+ import { type Address, type Asset, type Network, type PlaceOrderArgs, type TokenId, type TpslOrder } from "./types";
7
7
  import type { Wallet } from "./wallet";
8
8
  export interface TransactionOpts {
9
9
  maxPriorityFeeBps: number;
@@ -90,9 +90,9 @@ export declare class Client {
90
90
  deposit(asset: Asset, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
91
91
  withdraw(asset: Asset, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
92
92
  borrowSpot(asset: Asset, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
93
- placeOrder(asset: Asset, price: Decimal, size: Decimal, side: Side, orderType?: OrderType, reduceOnly?: boolean, tpslOrders?: TpslOrder[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
93
+ placeOrder(placeOrderArgs: PlaceOrderArgs, tpslOrders?: TpslOrder[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
94
94
  placeTpsls(asset: Asset, tpslOrders: TpslOrder[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
95
- replaceOrder(existingOrderId: bigint, asset: Asset, price: Decimal, size: Decimal, side: Side, orderType?: OrderType, reduceOnly?: boolean, tpslOrders?: TpslOrder[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
95
+ replaceOrder(existingOrderId: bigint, placeOrderArgs: PlaceOrderArgs, tpslOrders?: TpslOrder[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
96
96
  cancelTpsl(tpslOrderId: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
97
97
  cancelOrder(orderId: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
98
98
  cancelAllOrders(asset: Asset): Promise<TransactionResult<Transaction<RuntimeCall>>>;
@@ -1,4 +1,3 @@
1
- export { MarginType, EquityType } from "./bullet-wasm";
2
1
  import type Decimal from "decimal.js";
3
2
  export type PrivateKey = string;
4
3
  export type PublicKey = string;
@@ -29,7 +28,17 @@ export type Side = "Bid" | "Ask";
29
28
  export type TriggerDirection = "GreaterThanOrEqual" | "LessThanOrEqual";
30
29
  export type TpslPriceCondition = "Mark" | "Oracle" | "LastTrade";
31
30
  export type OrderType = "Limit" | "PostOnly" | "FillOrKill" | "ImmediateOrCancel" | "PostOnlySlide" | "PostOnlyFront";
31
+ export type MarginType = "Initial" | "Maintenance";
32
+ export type EquityType = "Unweighted" | "WeightedInitial" | "WeightedMaintenance";
32
33
  export type Network = "Localnet" | "Staging" | "Testnet" | "Mainnet";
34
+ export type PlaceOrderArgs = {
35
+ asset_id: AssetId;
36
+ price: Decimal;
37
+ size: Decimal;
38
+ side: Side;
39
+ order_type: OrderType;
40
+ reduce_only: boolean;
41
+ };
33
42
  export type TpslOrder = {
34
43
  orderPrice: Decimal;
35
44
  triggerPrice: Decimal;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/zetamarkets/bullet-sdk.git"
6
6
  },
7
- "version": "0.17.7",
7
+ "version": "0.18.0-rc.1",
8
8
  "description": "Bullet SDK",
9
9
  "author": "@bulletxyz",
10
10
  "license": "Apache-2.0",