@bolt-liquidity-hq/sui-client 0.1.0-beta.12 → 0.1.0-beta.13
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/index.cjs +446 -368
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -64
- package/dist/index.d.ts +170 -64
- package/dist/index.js +435 -364
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainConfig, ClientConfig, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, Address, BaseLiquidityDetails, Coin,
|
|
1
|
+
import { ChainConfig, ClientConfig, Pool, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, Address, BaseLiquidityDetails, Coin, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
|
|
2
2
|
import { SuiClient, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
3
3
|
import { Signer } from '@mysten/sui/cryptography';
|
|
4
4
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
@@ -27,75 +27,108 @@ type SuiClientConfig = ClientConfig<SuiChainConfig> & {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
declare const OracleConfigStruct: _mysten_bcs.BcsStruct<{
|
|
30
|
-
admin: _mysten_bcs.BcsType<string, string, "address">;
|
|
31
30
|
price_threshold_ratio: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
32
31
|
default_price_expiry_seconds: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
33
32
|
}, string>;
|
|
34
33
|
type OracleConfigStructOutput = BcsParsed<typeof OracleConfigStruct>;
|
|
35
34
|
declare const AssetPairStruct: _mysten_bcs.BcsStruct<{
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
base_name: _mysten_bcs.BcsType<string, string, "string">;
|
|
36
|
+
quote_name: _mysten_bcs.BcsType<string, string, "string">;
|
|
38
37
|
base_precision: _mysten_bcs.BcsType<number, number, "u8">;
|
|
39
38
|
quote_precision: _mysten_bcs.BcsType<number, number, "u8">;
|
|
40
39
|
}, string>;
|
|
41
40
|
type AssetPairStructOutput = BcsParsed<typeof AssetPairStruct>;
|
|
42
|
-
declare const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
quote_precision: number;
|
|
53
|
-
}> & {
|
|
54
|
-
length: number;
|
|
41
|
+
declare const TypeNameStruct: _mysten_bcs.BcsStruct<{
|
|
42
|
+
name: _mysten_bcs.BcsType<string, string, "string">;
|
|
43
|
+
}, string>;
|
|
44
|
+
type TypeNameStructOutput = BcsParsed<typeof TypeNameStruct>;
|
|
45
|
+
declare const RawPairStruct: _mysten_bcs.BcsStruct<{
|
|
46
|
+
base: _mysten_bcs.BcsStruct<{
|
|
47
|
+
name: _mysten_bcs.BcsType<string, string, "string">;
|
|
48
|
+
}, string>;
|
|
49
|
+
quote: _mysten_bcs.BcsStruct<{
|
|
50
|
+
name: _mysten_bcs.BcsType<string, string, "string">;
|
|
55
51
|
}, string>;
|
|
56
52
|
}, string>;
|
|
57
|
-
type
|
|
58
|
-
declare const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
type RawPairStructOutput = BcsParsed<typeof RawPairStruct>;
|
|
54
|
+
declare const AssetPairResponseStruct: _mysten_bcs.BcsStruct<{
|
|
55
|
+
pair: _mysten_bcs.BcsStruct<{
|
|
56
|
+
base: _mysten_bcs.BcsStruct<{
|
|
57
|
+
name: _mysten_bcs.BcsType<string, string, "string">;
|
|
58
|
+
}, string>;
|
|
59
|
+
quote: _mysten_bcs.BcsStruct<{
|
|
60
|
+
name: _mysten_bcs.BcsType<string, string, "string">;
|
|
61
|
+
}, string>;
|
|
62
|
+
}, string>;
|
|
63
|
+
info: _mysten_bcs.BcsStruct<{
|
|
64
|
+
base_name: _mysten_bcs.BcsType<string, string, "string">;
|
|
65
|
+
quote_name: _mysten_bcs.BcsType<string, string, "string">;
|
|
66
|
+
base_precision: _mysten_bcs.BcsType<number, number, "u8">;
|
|
67
|
+
quote_precision: _mysten_bcs.BcsType<number, number, "u8">;
|
|
68
|
+
}, string>;
|
|
69
|
+
}, string>;
|
|
70
|
+
type AssetPairResponseStructOutput = BcsParsed<typeof AssetPairResponseStruct>;
|
|
71
|
+
declare const AssetPairsResponseStruct: _mysten_bcs.BcsType<{
|
|
72
|
+
pair: {
|
|
73
|
+
base: {
|
|
74
|
+
name: string;
|
|
75
|
+
};
|
|
76
|
+
quote: {
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
info: {
|
|
81
|
+
base_name: string;
|
|
82
|
+
quote_name: string;
|
|
65
83
|
base_precision: number;
|
|
66
84
|
quote_precision: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
};
|
|
86
|
+
}[], Iterable<{
|
|
87
|
+
pair: {
|
|
88
|
+
base: {
|
|
89
|
+
name: string;
|
|
90
|
+
};
|
|
91
|
+
quote: {
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
info: {
|
|
96
|
+
base_name: string;
|
|
97
|
+
quote_name: string;
|
|
70
98
|
base_precision: number;
|
|
71
99
|
quote_precision: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
};
|
|
101
|
+
}> & {
|
|
102
|
+
length: number;
|
|
103
|
+
}, `vector<${string}>`>;
|
|
104
|
+
type AssetPairsResponseStructOutput = BcsParsed<typeof AssetPairsResponseStruct>;
|
|
105
|
+
declare const RawPriceStruct: _mysten_bcs.BcsStruct<{
|
|
106
|
+
price: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
107
|
+
expiry: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
75
108
|
}, string>;
|
|
76
|
-
type
|
|
109
|
+
type RawPriceStructOutput = BcsParsed<typeof RawPriceStruct>;
|
|
77
110
|
declare const PriceDataStruct: _mysten_bcs.BcsStruct<{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
111
|
+
price: _mysten_bcs.BcsStruct<{
|
|
112
|
+
price: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
113
|
+
expiry: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
114
|
+
}, string>;
|
|
82
115
|
last_updated_ms: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
83
116
|
updater: _mysten_bcs.BcsType<string, string, "address">;
|
|
84
117
|
}, string>;
|
|
85
118
|
type PriceDataStructOutput = BcsParsed<typeof PriceDataStruct>;
|
|
86
119
|
declare const PriceResponseStruct: _mysten_bcs.BcsStruct<{
|
|
87
120
|
pair_data: _mysten_bcs.BcsType<{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
price: {
|
|
122
|
+
price: string;
|
|
123
|
+
expiry: string;
|
|
124
|
+
};
|
|
92
125
|
last_updated_ms: string;
|
|
93
126
|
updater: string;
|
|
94
127
|
} | null, {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
128
|
+
price: {
|
|
129
|
+
price: string | number | bigint;
|
|
130
|
+
expiry: string | number | bigint;
|
|
131
|
+
};
|
|
99
132
|
last_updated_ms: string | number | bigint;
|
|
100
133
|
updater: string;
|
|
101
134
|
} | null | undefined, `Option<${string}>`>;
|
|
@@ -106,17 +139,17 @@ declare const PricesResponsePaginatedStruct: _mysten_bcs.BcsStruct<{
|
|
|
106
139
|
has_next_page: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
107
140
|
next_cursor: _mysten_bcs.BcsType<string | null, string | null | undefined, "Option<string>">;
|
|
108
141
|
prices: _mysten_bcs.BcsType<{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
142
|
+
price: {
|
|
143
|
+
price: string;
|
|
144
|
+
expiry: string;
|
|
145
|
+
};
|
|
113
146
|
last_updated_ms: string;
|
|
114
147
|
updater: string;
|
|
115
148
|
}[], Iterable<{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
149
|
+
price: {
|
|
150
|
+
price: string | number | bigint;
|
|
151
|
+
expiry: string | number | bigint;
|
|
152
|
+
};
|
|
120
153
|
last_updated_ms: string | number | bigint;
|
|
121
154
|
updater: string;
|
|
122
155
|
}> & {
|
|
@@ -225,10 +258,32 @@ declare const BaseLiquidityResponseStruct: _mysten_bcs.BcsStruct<{
|
|
|
225
258
|
}, string>;
|
|
226
259
|
type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;
|
|
227
260
|
|
|
228
|
-
declare const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
261
|
+
declare const PoolInfoStruct: _mysten_bcs.BcsStruct<{
|
|
262
|
+
base_liquidity: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
263
|
+
total_lp_shares: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
264
|
+
admin: _mysten_bcs.BcsType<string, string, "address">;
|
|
265
|
+
is_paused: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
266
|
+
}, string>;
|
|
267
|
+
type PoolInfoStructOutput = BcsParsed<typeof PoolInfoStruct>;
|
|
268
|
+
declare const PoolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
269
|
+
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
270
|
+
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
271
|
+
lp_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
272
|
+
}, string>;
|
|
273
|
+
type PoolFeesInfoStructOutput = BcsParsed<typeof PoolFeesInfoStruct>;
|
|
274
|
+
declare const ProtocolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
275
|
+
bolt_fee_addr: _mysten_bcs.BcsType<string, string, "address">;
|
|
276
|
+
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
277
|
+
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
278
|
+
}, string>;
|
|
279
|
+
type ProtocolFeesInfoStructOutput = BcsParsed<typeof ProtocolFeesInfoStruct>;
|
|
280
|
+
|
|
281
|
+
declare class RouterClient {
|
|
282
|
+
pools: Pool[];
|
|
283
|
+
constructor(pools: Pool[]);
|
|
284
|
+
getPool(denomIn: string, denomOut: string): Pool | undefined;
|
|
285
|
+
getPools(): Pool[];
|
|
286
|
+
}
|
|
232
287
|
|
|
233
288
|
/**
|
|
234
289
|
* Client implementation for interacting with the Bolt Liquidity Outpost on Sui blockchain.
|
|
@@ -273,19 +328,30 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
273
328
|
poolGlobalConfigId: string;
|
|
274
329
|
/**
|
|
275
330
|
* Cached instance of the Signer for transaction execution
|
|
276
|
-
* @private
|
|
277
331
|
*/
|
|
278
332
|
signer?: Signer;
|
|
279
333
|
/**
|
|
280
334
|
* Instance of the Sui client to interact with the blockchain
|
|
281
335
|
*/
|
|
282
336
|
suiClient: SuiClient;
|
|
337
|
+
/**
|
|
338
|
+
* URL for fetching testnet configuration dynamically.
|
|
339
|
+
* Used to load package IDs, oracle addresses, and asset configurations for testnet environments.
|
|
340
|
+
* @private
|
|
341
|
+
*/
|
|
342
|
+
private configFileUrl?;
|
|
343
|
+
/**
|
|
344
|
+
* Router client instance for managing pool configurations and routing calculations.
|
|
345
|
+
* Handles pool discovery and optimal path finding for swaps.
|
|
346
|
+
*/
|
|
347
|
+
routerClient: RouterClient;
|
|
283
348
|
/**
|
|
284
349
|
* Creates a new instance of the BoltSuiClient.
|
|
285
350
|
*
|
|
286
351
|
* The client automatically configures itself based on the specified environment,
|
|
287
352
|
* loading the appropriate contract addresses, chain configuration, native token denomination,
|
|
288
|
-
* and assets from configuration files.
|
|
353
|
+
* and assets from configuration files. For testnet environments, the client can dynamically
|
|
354
|
+
* fetch configuration from a remote URL.
|
|
289
355
|
*
|
|
290
356
|
* @param config - (Optional) Configuration for the client
|
|
291
357
|
* @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'
|
|
@@ -311,7 +377,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
311
377
|
* // Use default configuration (Sui mainnet)
|
|
312
378
|
* const client = new BoltSuiClient();
|
|
313
379
|
*
|
|
314
|
-
* // Use testnet configuration
|
|
380
|
+
* // Use testnet configuration (will fetch config dynamically)
|
|
315
381
|
* const testnetClient = new BoltSuiClient({
|
|
316
382
|
* environment: 'testnet'
|
|
317
383
|
* });
|
|
@@ -391,15 +457,34 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
391
457
|
getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
|
|
392
458
|
/** @inheritdoc */
|
|
393
459
|
getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
|
|
394
|
-
/**
|
|
395
|
-
|
|
460
|
+
/**
|
|
461
|
+
* @inheritdoc
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* In the Sui implementation, both `baseDenom` and `quoteDenom` parameters are required.
|
|
465
|
+
* The Sui architecture uses both asset types to uniquely identify pools for specific
|
|
466
|
+
* trading pairs.
|
|
467
|
+
*
|
|
468
|
+
* @throws Will throw an error if no pool exists for the specified base/quote asset pair
|
|
469
|
+
*/
|
|
470
|
+
getPoolByDenom(baseDenom: string, quoteDenom: string): Promise<Pool>;
|
|
396
471
|
/** @inheritdoc */
|
|
397
472
|
getAllPools(): Promise<Pool[]>;
|
|
473
|
+
/** @inheritdoc */
|
|
398
474
|
getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
|
|
399
475
|
/** @inheritdoc */
|
|
400
476
|
getAssets(): Promise<Asset[]>;
|
|
401
|
-
/**
|
|
402
|
-
|
|
477
|
+
/**
|
|
478
|
+
* @inheritdoc
|
|
479
|
+
*
|
|
480
|
+
* @remarks
|
|
481
|
+
* In the Sui implementation, both `baseDenom` and `quoteDenom` parameters are required.
|
|
482
|
+
* The Sui architecture uses both asset types to uniquely identify pools for specific
|
|
483
|
+
* trading pairs.
|
|
484
|
+
*
|
|
485
|
+
* @throws Will throw an error if no pool exists for the specified base/quote asset pair
|
|
486
|
+
*/
|
|
487
|
+
getPoolConfigByDenom(baseDenom: string, quoteDenom: string): Promise<PoolConfig>;
|
|
403
488
|
/**
|
|
404
489
|
* @inheritdoc
|
|
405
490
|
*
|
|
@@ -458,6 +543,27 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
458
543
|
* - Sui's gas model includes computation, storage, and storage rebates
|
|
459
544
|
*/
|
|
460
545
|
estimateSwapGasFees(params: SwapParams, signer?: Signer, gasAdjustment?: number): Promise<Coin | undefined>;
|
|
546
|
+
/**
|
|
547
|
+
* Loads configuration from a remote URL for testnet environments.
|
|
548
|
+
*
|
|
549
|
+
* This method fetches and applies dynamic configuration including:
|
|
550
|
+
* - Package ID for Bolt contracts
|
|
551
|
+
* - Oracle contract address
|
|
552
|
+
* - Pool global configuration ID
|
|
553
|
+
* - Asset mappings and metadata
|
|
554
|
+
* - Pool configurations
|
|
555
|
+
*
|
|
556
|
+
* The method is called automatically before API operations when a config URL is set.
|
|
557
|
+
* After successful loading, the config URL is cleared to prevent redundant fetches.
|
|
558
|
+
*
|
|
559
|
+
* @private
|
|
560
|
+
* @remarks
|
|
561
|
+
* - Only executes if `configFileUrl` is set (typically for testnet)
|
|
562
|
+
* - Updates testnet-specific asset denoms with their actual deployed addresses
|
|
563
|
+
* - Populates the router client's pool configurations
|
|
564
|
+
* - Normalizes struct tags for consistency
|
|
565
|
+
*/
|
|
566
|
+
private loadConfigFromUrl;
|
|
461
567
|
}
|
|
462
568
|
|
|
463
|
-
export {
|
|
569
|
+
export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BaseLiquidityResponseStruct, type BaseLiquidityResponseStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolFeesInfoStruct, type PoolFeesInfoStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, PricesResponsePaginatedStruct, type PricesResponsePaginatedStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type SuiChainConfig, type SuiClientConfig, TypeNameStruct, type TypeNameStructOutput };
|