@bulletxyz/bullet-sdk 0.26.0-rc.0 → 0.26.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.
- package/dist/browser/index.js +83 -72
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.js +83 -72
- package/dist/node/index.js.map +2 -2
- package/dist/types/client.d.ts +14 -14
- package/dist/types/exchange.d.ts +26 -23
- package/dist/types/orderbook.d.ts +1 -1
- package/dist/types/rollupTypes.d.ts +22 -0
- package/dist/types/types.d.ts +5 -3
- package/package.json +2 -2
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 MarkPriceUpdateArgs, type Network, type OraclePriceUpdateArgs, type PlaceOrderArgs, type PlacePositionTpslArgs, type TokenId } from "./types";
|
|
7
|
+
import { type Address, type AssetName, type MarkPriceUpdateArgs, type MarketName, type Network, type OraclePriceUpdateArgs, type PlaceOrderArgs, type PlacePositionTpslArgs, type TokenId } from "./types";
|
|
8
8
|
import type { Wallet } from "./wallet";
|
|
9
9
|
export interface TransactionOpts {
|
|
10
10
|
maxPriorityFeeBps: number;
|
|
@@ -111,33 +111,33 @@ export declare class Client {
|
|
|
111
111
|
submitTransaction(runtimeCall: RuntimeCall): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
112
112
|
transfer(to: Address, amount: bigint, tokenId: TokenId): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
113
113
|
mint(to: Address, amount: bigint, tokenId: TokenId): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
114
|
-
deposit(asset:
|
|
115
|
-
withdraw(asset:
|
|
116
|
-
borrowSpot(asset:
|
|
114
|
+
deposit(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
115
|
+
withdraw(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
116
|
+
borrowSpot(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
117
117
|
placeOrder(placeOrderArgs: PlaceOrderArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
118
|
-
createPositionTpsl(market:
|
|
118
|
+
createPositionTpsl(market: MarketName, tpslOrders: PlacePositionTpslArgs): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
119
119
|
amendOrder(options: AmendOrderOptions): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
120
120
|
cancelTpsl(tpslOrderId: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
121
121
|
cancelOrder(orderId?: bigint, clientOrderId?: bigint): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
122
|
-
cancelAllOrdersForMarket(market:
|
|
122
|
+
cancelAllOrdersForMarket(market: MarketName): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
123
123
|
updateOraclePrices(pricesToUpdate: OraclePriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
124
124
|
updateMarkPrices(pricesToUpdate: MarkPriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
125
|
-
updateMaxLeverageForMarket(market:
|
|
126
|
-
updatePremiumIndexes(markets:
|
|
127
|
-
processTpslBufferForMarket(market:
|
|
128
|
-
updateFunding(markets:
|
|
125
|
+
updateMaxLeverageForMarket(market: MarketName, maxLeverage: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
126
|
+
updatePremiumIndexes(markets: MarketName[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
127
|
+
processTpslBufferForMarket(market: MarketName): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
128
|
+
updateFunding(markets: MarketName[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
129
129
|
applyFunding(addresses: Address[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
130
130
|
forceCancelOrders(address: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
131
131
|
forceClosePositions(address: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
132
132
|
liquidatePerpPositions(address: Address, positions?: {
|
|
133
|
-
market:
|
|
133
|
+
market: MarketName;
|
|
134
134
|
size: Decimal;
|
|
135
135
|
}[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
136
|
-
liquidateSpotLiability(address: Address, liabilityAssetId:
|
|
136
|
+
liquidateSpotLiability(address: Address, liabilityAssetId: AssetName, collateralAssetId: AssetName, liabilityAmount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
137
137
|
depositToUsdcPnlPool(amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
138
138
|
depositToInsuranceFund(amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
139
139
|
initAssetMetadata(asset_id: number, assetName: string, tokenId: TokenId, decimals: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
140
|
-
initBorrowLendMarket(asset:
|
|
141
|
-
updateBorrowLendMarket(asset:
|
|
140
|
+
initBorrowLendMarket(asset: AssetName, optimalUtilisationRate: Decimal, minBorrowRate: Decimal, maxBorrowRate: Decimal, optimalBorrowRate: Decimal, assetWeight: Decimal, initialLiabilityWeight: Decimal, maintenanceLiabilityWeight: Decimal, depositLimit: Decimal, borrowLimit: Decimal, liquidationRewardRatio: Decimal, liabilityLiquidationLimitRatio: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
141
|
+
updateBorrowLendMarket(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>>>;
|
|
142
142
|
}
|
|
143
143
|
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, Network } from "./types";
|
|
6
|
+
import type { Address, AssetName, MarketName, Network } from "./types";
|
|
7
7
|
import type { OrderType, PlaceOrderArgs, Side } from "./types";
|
|
8
8
|
import { type AccountAddresses, type AssetRegistry, type BorrowLendMarkets, type GlobalParameters, type MarginConfig, type MarketRegistry, type OraclePrices, type Order, type OrderbookL2, type PerpMarket, type PerpPrices, type TpslOrderIdsToExecute, type UsdcInsuranceFund, type UsdcPnlPool, type UserAccount } from "./zod-types/rest";
|
|
9
9
|
export declare class ExchangeConnection extends BaseConnection {
|
|
@@ -13,20 +13,23 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
13
13
|
private marketRegistry?;
|
|
14
14
|
private marketRegistryReverse?;
|
|
15
15
|
private constructor();
|
|
16
|
-
static fromEndpoints(endpoints: Endpoints): ExchangeConnection
|
|
17
|
-
static fromNetwork(network: Network): ExchangeConnection
|
|
18
|
-
static fromRestUrl(restUrl: string): ExchangeConnection
|
|
16
|
+
static fromEndpoints(endpoints: Endpoints): Promise<ExchangeConnection>;
|
|
17
|
+
static fromNetwork(network: Network): Promise<ExchangeConnection>;
|
|
18
|
+
static fromRestUrl(restUrl: string): Promise<ExchangeConnection>;
|
|
19
|
+
private initializeRegistries;
|
|
20
|
+
private initializeAssetRegistry;
|
|
21
|
+
private initializeMarketRegistry;
|
|
19
22
|
getOrder(orderId: bigint): Promise<Order | null>;
|
|
20
23
|
getMarketRegistry(): Promise<MarketRegistry | null>;
|
|
21
24
|
getAssetRegistry(): Promise<AssetRegistry | null>;
|
|
22
25
|
private getAssetMapping;
|
|
23
26
|
private getMarketMapping;
|
|
24
|
-
getAssetId(asset:
|
|
25
|
-
getAssetName(assetId: number):
|
|
26
|
-
getMarketId(market:
|
|
27
|
-
getMarketName(marketId: number):
|
|
28
|
-
getOrderbookL2(market:
|
|
29
|
-
getOrderbookL2s(markets:
|
|
27
|
+
getAssetId(asset: AssetName): number;
|
|
28
|
+
getAssetName(assetId: number): AssetName;
|
|
29
|
+
getMarketId(market: MarketName): number;
|
|
30
|
+
getMarketName(marketId: number): string;
|
|
31
|
+
getOrderbookL2(market: MarketName, levels?: number): Promise<OrderbookL2>;
|
|
32
|
+
getOrderbookL2s(markets: MarketName[], levels?: number): Promise<Map<number, OrderbookL2>>;
|
|
30
33
|
getUserAccountAddresses(offset?: number, limit?: number): Promise<AccountAddresses>;
|
|
31
34
|
getUserAccount(address: Address): Promise<UserAccount>;
|
|
32
35
|
getUserAccounts(addresses: Address[]): Promise<Map<string, UserAccount>>;
|
|
@@ -35,13 +38,13 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
35
38
|
getUsdcPnlPool(): Promise<UsdcPnlPool | null>;
|
|
36
39
|
getUsdcInsuranceFund(): Promise<UsdcInsuranceFund | null>;
|
|
37
40
|
getBorrowLendMarkets(): Promise<BorrowLendMarkets>;
|
|
38
|
-
getPerpMarket(market:
|
|
39
|
-
getPerpMarkets(markets:
|
|
41
|
+
getPerpMarket(market: MarketName): Promise<PerpMarket>;
|
|
42
|
+
getPerpMarkets(markets: MarketName[]): Promise<Map<number, PerpMarket>>;
|
|
40
43
|
getMarginConfig(): Promise<MarginConfig | null>;
|
|
41
|
-
getTpslOrderIdsToExecute(market:
|
|
44
|
+
getTpslOrderIdsToExecute(market: MarketName): Promise<TpslOrderIdsToExecute | null>;
|
|
42
45
|
getGlobalParameters(): Promise<GlobalParameters | null>;
|
|
43
46
|
calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
|
|
44
|
-
calculateEntryPrice(market:
|
|
47
|
+
calculateEntryPrice(market: MarketName, userAccount: UserAccount): Promise<Decimal>;
|
|
45
48
|
calculateTotalPerpUnrealizedPnl(userAccount: UserAccount, MarginCalculationState: {
|
|
46
49
|
oracle_prices: OraclePrices;
|
|
47
50
|
perp_prices: PerpPrices;
|
|
@@ -67,12 +70,12 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
67
70
|
perp_prices: PerpPrices;
|
|
68
71
|
margin_config: MarginConfig;
|
|
69
72
|
}): Decimal;
|
|
70
|
-
calculateWithdrawableAmountOfAsset(asset:
|
|
73
|
+
calculateWithdrawableAmountOfAsset(asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
|
|
71
74
|
oracle_prices: OraclePrices;
|
|
72
75
|
perp_prices: PerpPrices;
|
|
73
76
|
margin_config: MarginConfig;
|
|
74
77
|
}): Promise<Decimal>;
|
|
75
|
-
calculateEstimatedLiquidationPrice(market:
|
|
78
|
+
calculateEstimatedLiquidationPrice(market: MarketName, asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
|
|
76
79
|
oracle_prices: OraclePrices;
|
|
77
80
|
perp_prices: PerpPrices;
|
|
78
81
|
margin_config: MarginConfig;
|
|
@@ -87,17 +90,17 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
87
90
|
perp_prices: PerpPrices;
|
|
88
91
|
margin_config: MarginConfig;
|
|
89
92
|
}): Decimal;
|
|
90
|
-
calculateMaxBorrowAmount(asset:
|
|
93
|
+
calculateMaxBorrowAmount(asset: AssetName, userAccount: UserAccount, MarginCalculationState: {
|
|
91
94
|
oracle_prices: OraclePrices;
|
|
92
95
|
perp_prices: PerpPrices;
|
|
93
96
|
margin_config: MarginConfig;
|
|
94
97
|
}): Promise<Decimal>;
|
|
95
|
-
calculateMaxOrderSize(market:
|
|
98
|
+
calculateMaxOrderSize(market: MarketName, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, MarginCalculationState: {
|
|
96
99
|
oracle_prices: OraclePrices;
|
|
97
100
|
perp_prices: PerpPrices;
|
|
98
101
|
margin_config: MarginConfig;
|
|
99
102
|
}, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Promise<Decimal>;
|
|
100
|
-
simulateUsedMarginOnBorrow(asset:
|
|
103
|
+
simulateUsedMarginOnBorrow(asset: AssetName, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, MarginCalculationState: {
|
|
101
104
|
oracle_prices: OraclePrices;
|
|
102
105
|
perp_prices: PerpPrices;
|
|
103
106
|
margin_config: MarginConfig;
|
|
@@ -113,7 +116,7 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
113
116
|
current: Decimal;
|
|
114
117
|
updated: Decimal;
|
|
115
118
|
}>;
|
|
116
|
-
simulateEstimatedLiquidationPriceOnOrder(placeOrderArgs: PlaceOrderArgs, baseAsset:
|
|
119
|
+
simulateEstimatedLiquidationPriceOnOrder(placeOrderArgs: PlaceOrderArgs, baseAsset: AssetName, userAccount: UserAccount, MarginCalculationState: {
|
|
117
120
|
oracle_prices: OraclePrices;
|
|
118
121
|
perp_prices: PerpPrices;
|
|
119
122
|
margin_config: MarginConfig;
|
|
@@ -132,7 +135,7 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
132
135
|
liquidation_risk_percentage: Decimal;
|
|
133
136
|
max_leverage_to_use: number;
|
|
134
137
|
}>>;
|
|
135
|
-
calculateBorrowLendMarketAdditionalMetadata(borrowLendMarkets: BorrowLendMarkets, asset:
|
|
138
|
+
calculateBorrowLendMarketAdditionalMetadata(borrowLendMarkets: BorrowLendMarkets, asset: AssetName): Promise<{
|
|
136
139
|
utilisation_rate: Decimal;
|
|
137
140
|
current_deposit_rate: Decimal;
|
|
138
141
|
current_borrow_rate: Decimal;
|
|
@@ -150,6 +153,6 @@ export declare class ExchangeConnection extends BaseConnection {
|
|
|
150
153
|
leverage: Decimal;
|
|
151
154
|
}[]>;
|
|
152
155
|
private getWebSocketManager;
|
|
153
|
-
subscribeOrderbook(market:
|
|
154
|
-
unsubscribeOrderbook(market:
|
|
156
|
+
subscribeOrderbook(market: MarketName): AsyncIterable<Orderbook>;
|
|
157
|
+
unsubscribeOrderbook(market: MarketName): Promise<void>;
|
|
155
158
|
}
|
|
@@ -5,7 +5,7 @@ type Size = Decimal;
|
|
|
5
5
|
export declare class Orderbook {
|
|
6
6
|
bids: Map<string, Size>;
|
|
7
7
|
asks: Map<string, Size>;
|
|
8
|
-
|
|
8
|
+
marketId: number;
|
|
9
9
|
lastUpdated: number;
|
|
10
10
|
constructor(marketId: number, snapshot?: OrderbookUpdate);
|
|
11
11
|
protected updateBid(price: string, size: Size): void;
|
|
@@ -22,6 +22,27 @@ type BankCallMessage = {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
type WarpCallMessage = {
|
|
26
|
+
Register: {
|
|
27
|
+
admin: {
|
|
28
|
+
InsecureOwner: Address;
|
|
29
|
+
};
|
|
30
|
+
ism: {
|
|
31
|
+
MessageIdMultisig: {
|
|
32
|
+
threshold: number;
|
|
33
|
+
validators: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
token_source: {
|
|
37
|
+
Synthetic: {
|
|
38
|
+
remote_token_id: string;
|
|
39
|
+
local_decimals: number;
|
|
40
|
+
remote_decimals: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
remote_routers: [number, string][];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
25
46
|
type TriggerOrderArgs = {
|
|
26
47
|
order_price: number;
|
|
27
48
|
trigger_price: number;
|
|
@@ -193,5 +214,6 @@ type ExchangeCallMessage = {
|
|
|
193
214
|
export type RuntimeCall = ExactlyOne<{
|
|
194
215
|
exchange: ExactlyOne<ExchangeCallMessage>;
|
|
195
216
|
bank: ExactlyOne<BankCallMessage>;
|
|
217
|
+
warp: ExactlyOne<WarpCallMessage>;
|
|
196
218
|
}>;
|
|
197
219
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type PrivateKey = string;
|
|
|
3
3
|
export type PublicKey = string;
|
|
4
4
|
export type Address = string;
|
|
5
5
|
export type TokenId = string;
|
|
6
|
+
export type AssetName = string;
|
|
7
|
+
export type MarketName = string;
|
|
6
8
|
export type AssetId = number;
|
|
7
9
|
export type MarketId = number;
|
|
8
10
|
export type OrderId = bigint;
|
|
@@ -16,7 +18,7 @@ export type MarginType = "Initial" | "Maintenance";
|
|
|
16
18
|
export type EquityType = "Unweighted" | "WeightedInitial" | "WeightedMaintenance";
|
|
17
19
|
export type Network = "Localnet" | "Staging" | "Testnet" | "Mainnet";
|
|
18
20
|
export type PlaceOrderArgs = {
|
|
19
|
-
market:
|
|
21
|
+
market: MarketName;
|
|
20
22
|
price: Decimal;
|
|
21
23
|
size: Decimal;
|
|
22
24
|
side: Side;
|
|
@@ -26,11 +28,11 @@ export type PlaceOrderArgs = {
|
|
|
26
28
|
tpsl?: PendingTriggerOrderArgs;
|
|
27
29
|
};
|
|
28
30
|
export type OraclePriceUpdateArgs = {
|
|
29
|
-
asset:
|
|
31
|
+
asset: AssetName;
|
|
30
32
|
oraclePrice: Decimal;
|
|
31
33
|
};
|
|
32
34
|
export type MarkPriceUpdateArgs = {
|
|
33
|
-
market:
|
|
35
|
+
market: MarketName;
|
|
34
36
|
medianCexPrice: Decimal;
|
|
35
37
|
diffEma: Decimal;
|
|
36
38
|
};
|
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.26.0-rc.
|
|
7
|
+
"version": "0.26.0-rc.1",
|
|
8
8
|
"description": "Bullet SDK",
|
|
9
9
|
"author": "@bulletxyz",
|
|
10
10
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:js": "node build.mjs",
|
|
32
32
|
"clean": "rm -rf dist",
|
|
33
33
|
"build": "pnpm clean && pnpm build:types && pnpm build:js",
|
|
34
|
-
"dev": "tsx --experimental-wasm-modules
|
|
34
|
+
"dev": "tsx --experimental-wasm-modules scripts/test.ts",
|
|
35
35
|
"package": "pnpm build && pnpm pack",
|
|
36
36
|
"prepublishOnly": "pnpm build",
|
|
37
37
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|