@bulletxyz/bullet-sdk 0.21.0-rc.8 → 0.22.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.
- package/dist/browser/index.js +131 -73
- package/dist/browser/index.js.map +3 -3
- package/dist/node/index.js +131 -73
- package/dist/node/index.js.map +3 -3
- package/dist/types/bullet-wasm/index.d.ts +1 -1
- package/dist/types/calc.d.ts +2 -2
- package/dist/types/client.d.ts +4 -1
- package/dist/types/connection.d.ts +1 -1
- package/dist/types/constants.d.ts +5 -4
- package/dist/types/exchange.d.ts +7 -2
- package/dist/types/utils.d.ts +6 -0
- package/dist/types/zod-types/rest.d.ts +14 -0
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ export class BulletWasm {
|
|
|
25
25
|
*/
|
|
26
26
|
static calculate_max_borrow_amount(asset_id: number, initial_liability_weight: string, user_account: any, margin_calculation_state: any): string;
|
|
27
27
|
static calculate_max_order_size(asset_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, user_account: any, margin_type: MarginType, margin_calculation_state: any): any;
|
|
28
|
+
static simulate_used_margin_on_borrow(asset_id: number, borrow_amount: string, borrow_lend_risk_weights: any, 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, user_account: any, margin_calculation_state: any, orderbook: any): any;
|
|
31
31
|
static calculate_positions_additional_metadata(user_account: any, margin_calculation_state: any, funding_parameters: any): any;
|
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, AssetId, OrderType, PlaceOrderArgs, Side } from "./types";
|
|
4
|
-
import type { BorrowLendMarket, MarginConfig, OraclePrices, OrderbookL2, PerpMarket, PerpPrices, UserAccount } from "./zod-types/rest";
|
|
4
|
+
import type { BorrowLendMarket, BorrowLendRiskWeights, MarginConfig, OraclePrices, OrderbookL2, PerpMarket, PerpPrices, UserAccount } from "./zod-types/rest";
|
|
5
5
|
export declare function calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
|
|
6
6
|
export declare function calculateEntryPrice(asset: Asset, userAccount: UserAccount): Decimal;
|
|
7
7
|
export interface MarginCalculationState {
|
|
@@ -20,7 +20,7 @@ export declare function calculateLiquidationRiskPercentage(userAccount: UserAcco
|
|
|
20
20
|
export declare function calculateForceCancelRiskPercentage(userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
21
21
|
export declare function calculateMaxBorrowAmount(asset_id: AssetId, initialLiabilityWeight: Decimal, userAccount: UserAccount, MarginCalculationState: MarginCalculationState): Decimal;
|
|
22
22
|
export declare function calculateMaxOrderSize(asset: Asset, 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_id: AssetId, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: MarginCalculationState): {
|
|
23
|
+
export declare function simulateUsedMarginOnBorrow(asset_id: AssetId, borrowAmount: Decimal, borrowLendRiskWeights: BorrowLendRiskWeights, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: MarginCalculationState): {
|
|
24
24
|
current: Decimal;
|
|
25
25
|
updated: Decimal;
|
|
26
26
|
};
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Transaction, type TransactionResult } from "@sovereign-sdk/web3";
|
|
2
2
|
import type Decimal from "decimal.js";
|
|
3
3
|
import { Connection } from "./connection";
|
|
4
|
+
import { Endpoints } from "./constants";
|
|
4
5
|
import { ExchangeConnection } from "./exchange";
|
|
5
6
|
import type { RuntimeCall } from "./rollupTypes";
|
|
6
7
|
import { type Address, type Asset, type MarkPriceUpdateArgs, type Network, type OraclePriceUpdateArgs, type PlaceOrderArgs, type TokenId, type TpslOrder } from "./types";
|
|
@@ -20,7 +21,9 @@ export declare class Client {
|
|
|
20
21
|
private queue;
|
|
21
22
|
private generationOverride;
|
|
22
23
|
private constructor();
|
|
23
|
-
static
|
|
24
|
+
static fromEndpoints(endpoints: Endpoints, wallet: Wallet, txOpts?: TransactionOpts): Promise<Client>;
|
|
25
|
+
static fromNetwork(network: Network, wallet: Wallet, txOpts?: TransactionOpts): Promise<Client>;
|
|
26
|
+
static fromRestUrl(restUrl: string, wallet: Wallet, txOpts?: TransactionOpts): Promise<Client>;
|
|
24
27
|
setGenerationOverride(generation: (() => number) | undefined): void;
|
|
25
28
|
getNonce(): Promise<import("@sovereign-sdk/web3").Dedup>;
|
|
26
29
|
getTokenBalance(tokenId: string): Promise<bigint>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, TokenId } from "./types";
|
|
2
2
|
export declare class BaseConnection {
|
|
3
3
|
endpoint: string;
|
|
4
|
-
constructor(rawEndpoint
|
|
4
|
+
constructor(rawEndpoint: string);
|
|
5
5
|
protected fetchApiResource<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
6
6
|
protected fetchBulkApiResource<T>(path: string, body: Record<string, unknown>, params?: Record<string, string>): Promise<T>;
|
|
7
7
|
}
|
|
@@ -19,8 +19,9 @@ export declare const TOKEN_ADDRESSES: {
|
|
|
19
19
|
readonly TIA: "token_185jxgchq6kpxskn4eggjfeju3t4sjxxfxj5mx9dn6wgydud7mtys4glllf";
|
|
20
20
|
readonly ZEX: "token_1g3hhmzp0c358t0s2dxht8jqqrfnnrgerk423mgs4cxd96u8ux24stetj0c";
|
|
21
21
|
};
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
export interface Endpoints {
|
|
23
|
+
rest: string;
|
|
24
|
+
ws?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const NETWORKS: Record<Network, Endpoints>;
|
|
26
27
|
export declare const GLOBAL_DEFAULT_MAX_LEVERAGE = 1000;
|
package/dist/types/exchange.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { BaseConnection } from "./connection";
|
|
2
|
+
import { Endpoints } from "./constants";
|
|
2
3
|
import type { Orderbook } from "./orderbook";
|
|
3
4
|
import type { Address, Asset, AssetId, Network } from "./types";
|
|
4
5
|
import { AccountAddresses, type BorrowLendMarket, type MarginConfig, type OraclePrices, type Order, type OrderbookL2, type PerpMarket, type PerpPrices, type UsdcInsuranceFund, type UsdcPnlPool, type UserAccount } from "./zod-types/rest";
|
|
5
6
|
export declare class ExchangeConnection extends BaseConnection {
|
|
6
|
-
private wsManager
|
|
7
|
-
constructor(
|
|
7
|
+
private wsManager?;
|
|
8
|
+
private constructor();
|
|
9
|
+
static fromEndpoints(endpoints: Endpoints): ExchangeConnection;
|
|
10
|
+
static fromNetwork(network: Network): ExchangeConnection;
|
|
11
|
+
static fromRestUrl(restUrl: string): ExchangeConnection;
|
|
8
12
|
getValue(): Promise<number | null>;
|
|
9
13
|
getOrder(order_id: bigint): Promise<Order | null>;
|
|
10
14
|
getOrderbookL2(asset: Asset, levels?: number): Promise<OrderbookL2>;
|
|
@@ -23,6 +27,7 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
23
27
|
getMarginConfig(): Promise<MarginConfig | null>;
|
|
24
28
|
getPerpAssets(): Promise<Map<Asset, string>>;
|
|
25
29
|
getBorrowLendAssets(): Promise<Map<Asset, string>>;
|
|
30
|
+
private getWebSocketManager;
|
|
26
31
|
subscribeOrderbook(assetId: AssetId): AsyncIterable<Orderbook>;
|
|
27
32
|
unsubscribeOrderbook(assetId: AssetId): Promise<void>;
|
|
28
33
|
}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Network } from "./types";
|
|
2
|
+
import { Endpoints } from "./constants";
|
|
1
3
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
2
4
|
export declare function hexToBytes(hex: string): Uint8Array;
|
|
3
5
|
export declare function hexToBase64(hex: string): string;
|
|
@@ -7,3 +9,7 @@ export declare function base58ToHex(base58: string): string;
|
|
|
7
9
|
export declare function sleep(ms: number): Promise<void>;
|
|
8
10
|
export declare function isNode(): boolean;
|
|
9
11
|
export declare function serialize<T>(value: T): T;
|
|
12
|
+
export declare const isNetwork: (value: string) => value is Network;
|
|
13
|
+
export declare const isValidHttpUrl: (url: string) => boolean;
|
|
14
|
+
export declare const isValidWsUrl: (url: string) => boolean;
|
|
15
|
+
export declare const validateEndpoints: (endpoints: Endpoints) => void;
|
|
@@ -363,6 +363,19 @@ export declare const BaseResponseSchemas: {
|
|
|
363
363
|
}>;
|
|
364
364
|
};
|
|
365
365
|
declare const PriceLevel: z.ZodTuple<[z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, import("decimal.js").Decimal, string | number>, z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, import("decimal.js").Decimal, string | number>], null>;
|
|
366
|
+
declare const BorrowLendRiskWeights: z.ZodObject<{
|
|
367
|
+
asset_weight: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, import("decimal.js").Decimal, string | number>;
|
|
368
|
+
initial_liability_weight: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, import("decimal.js").Decimal, string | number>;
|
|
369
|
+
maintenance_liability_weight: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, import("decimal.js").Decimal, string | number>;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
asset_weight: import("decimal.js").Decimal;
|
|
372
|
+
initial_liability_weight: import("decimal.js").Decimal;
|
|
373
|
+
maintenance_liability_weight: import("decimal.js").Decimal;
|
|
374
|
+
}, {
|
|
375
|
+
asset_weight: string | number;
|
|
376
|
+
initial_liability_weight: string | number;
|
|
377
|
+
maintenance_liability_weight: string | number;
|
|
378
|
+
}>;
|
|
366
379
|
declare const Order: z.ZodObject<{
|
|
367
380
|
side: z.ZodEnum<["Bid", "Ask"]>;
|
|
368
381
|
asset_id: z.ZodNumber;
|
|
@@ -4653,4 +4666,5 @@ export type MarginConfig = z.infer<typeof Schemas.MarginConfig>;
|
|
|
4653
4666
|
export type Assets = z.infer<typeof Schemas.Assets>;
|
|
4654
4667
|
export type Tpsl = z.infer<typeof Tpsl>;
|
|
4655
4668
|
export type AccountAddresses = z.infer<typeof Schemas.AccountAddresses>;
|
|
4669
|
+
export type BorrowLendRiskWeights = z.infer<typeof BorrowLendRiskWeights>;
|
|
4656
4670
|
export {};
|