@bolt-liquidity-hq/sui-client 0.1.0-beta.21 → 0.1.0-beta.23
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 +108 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -24
- package/dist/index.d.ts +23 -24
- package/dist/index.js +108 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainConfig, ClientConfig, Pool, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig,
|
|
1
|
+
import { ChainConfig, ClientConfig, Pool, Address, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, BaseLiquidityDetails, Coin, PoolConfig, Asset, SwapParams, SwapResult, SwapRequiredParams, SimulateSwapResult } 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 { WalletContextState } from '@suiet/wallet-kit';
|
|
@@ -218,26 +218,6 @@ declare const MarketsResponsePaginatedStruct: _mysten_bcs.BcsStruct<{
|
|
|
218
218
|
}, string>;
|
|
219
219
|
}, string>;
|
|
220
220
|
type MarketsResponsePaginatedStructOutput = BcsParsed<typeof MarketsResponsePaginatedStruct>;
|
|
221
|
-
declare const BaseLiquidityInfoStruct: _mysten_bcs.BcsStruct<{
|
|
222
|
-
denom: _mysten_bcs.BcsType<string, string, "string">;
|
|
223
|
-
amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
224
|
-
}, string>;
|
|
225
|
-
type BaseLiquidityInfoStructOutput = BcsParsed<typeof BaseLiquidityInfoStruct>;
|
|
226
|
-
declare const BaseLiquidityResponseStruct: _mysten_bcs.BcsStruct<{
|
|
227
|
-
total_count: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
228
|
-
has_next_page: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
229
|
-
next_cursor: _mysten_bcs.BcsType<string | null, string | null | undefined, "Option<string>">;
|
|
230
|
-
base_assets: _mysten_bcs.BcsType<{
|
|
231
|
-
denom: string;
|
|
232
|
-
amount: string;
|
|
233
|
-
}[], Iterable<{
|
|
234
|
-
denom: string;
|
|
235
|
-
amount: string | number | bigint;
|
|
236
|
-
}> & {
|
|
237
|
-
length: number;
|
|
238
|
-
}, string>;
|
|
239
|
-
}, string>;
|
|
240
|
-
type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;
|
|
241
221
|
declare const SwapSimulationResultStruct: _mysten_bcs.BcsStruct<{
|
|
242
222
|
base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
223
|
quote_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -255,12 +235,24 @@ type RouterPool = Pool & {
|
|
|
255
235
|
};
|
|
256
236
|
|
|
257
237
|
declare const PoolInfoStruct: _mysten_bcs.BcsStruct<{
|
|
238
|
+
id: _mysten_bcs.BcsType<string, string, "string">;
|
|
258
239
|
base_liquidity: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
240
|
+
net_base_added: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
259
241
|
total_lp_shares: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
242
|
+
protocol_base_fees: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
260
243
|
admin: _mysten_bcs.BcsType<string, string, "address">;
|
|
261
244
|
is_paused: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
262
245
|
}, string>;
|
|
263
246
|
type PoolInfoStructOutput = BcsParsed<typeof PoolInfoStruct>;
|
|
247
|
+
type PoolInfo = {
|
|
248
|
+
id: string;
|
|
249
|
+
baseLiquidity: string;
|
|
250
|
+
netBaseAdded: string;
|
|
251
|
+
totalLpShares: string;
|
|
252
|
+
protocolBaseFees: string;
|
|
253
|
+
admin: Address;
|
|
254
|
+
isPaused: boolean;
|
|
255
|
+
};
|
|
264
256
|
declare const PoolConfigStruct: _mysten_bcs.BcsStruct<{
|
|
265
257
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
266
258
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -275,6 +267,11 @@ declare const ProtocolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
|
275
267
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
276
268
|
}, string>;
|
|
277
269
|
type ProtocolFeesInfoStructOutput = BcsParsed<typeof ProtocolFeesInfoStruct>;
|
|
270
|
+
declare const BaseLiquidityInfoStruct: _mysten_bcs.BcsStruct<{
|
|
271
|
+
base_reserve: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
272
|
+
total_lp_shares: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
273
|
+
}, string>;
|
|
274
|
+
type BaseLiquidityInfoStructOutput = BcsParsed<typeof BaseLiquidityInfoStruct>;
|
|
278
275
|
|
|
279
276
|
declare class RouterClient {
|
|
280
277
|
pools: Pool[];
|
|
@@ -470,8 +467,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
470
467
|
getAllPools(): Promise<Pool[]>;
|
|
471
468
|
/** @inheritdoc */
|
|
472
469
|
getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
|
|
473
|
-
/** @inheritdoc */
|
|
474
|
-
getAssets(): Promise<Asset[]>;
|
|
475
470
|
/**
|
|
476
471
|
* @inheritdoc
|
|
477
472
|
*
|
|
@@ -483,6 +478,10 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
483
478
|
* @throws Will throw an error if no pool exists for the specified base/quote asset pair
|
|
484
479
|
*/
|
|
485
480
|
getPoolConfigByDenom(baseDenom: string, quoteDenom: string): Promise<PoolConfig>;
|
|
481
|
+
/** @inheritdoc */
|
|
482
|
+
getPoolBaseLiquidity(poolContractAddress: string): Promise<BaseLiquidityDetails>;
|
|
483
|
+
/** @inheritdoc */
|
|
484
|
+
getAssets(): Promise<Asset[]>;
|
|
486
485
|
/**
|
|
487
486
|
* @inheritdoc
|
|
488
487
|
*
|
|
@@ -566,4 +565,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
566
565
|
private loadConfigFromUrl;
|
|
567
566
|
}
|
|
568
567
|
|
|
569
|
-
export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput,
|
|
568
|
+
export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolConfigStruct, type PoolConfigStructOutput, type PoolInfo, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type RouterPool, type SuiChainConfig, type SuiClientConfig, SwapSimulationResultStruct, type SwapSimulationResultStructOutput, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainConfig, ClientConfig, Pool, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig,
|
|
1
|
+
import { ChainConfig, ClientConfig, Pool, Address, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, BaseLiquidityDetails, Coin, PoolConfig, Asset, SwapParams, SwapResult, SwapRequiredParams, SimulateSwapResult } 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 { WalletContextState } from '@suiet/wallet-kit';
|
|
@@ -218,26 +218,6 @@ declare const MarketsResponsePaginatedStruct: _mysten_bcs.BcsStruct<{
|
|
|
218
218
|
}, string>;
|
|
219
219
|
}, string>;
|
|
220
220
|
type MarketsResponsePaginatedStructOutput = BcsParsed<typeof MarketsResponsePaginatedStruct>;
|
|
221
|
-
declare const BaseLiquidityInfoStruct: _mysten_bcs.BcsStruct<{
|
|
222
|
-
denom: _mysten_bcs.BcsType<string, string, "string">;
|
|
223
|
-
amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
224
|
-
}, string>;
|
|
225
|
-
type BaseLiquidityInfoStructOutput = BcsParsed<typeof BaseLiquidityInfoStruct>;
|
|
226
|
-
declare const BaseLiquidityResponseStruct: _mysten_bcs.BcsStruct<{
|
|
227
|
-
total_count: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
228
|
-
has_next_page: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
229
|
-
next_cursor: _mysten_bcs.BcsType<string | null, string | null | undefined, "Option<string>">;
|
|
230
|
-
base_assets: _mysten_bcs.BcsType<{
|
|
231
|
-
denom: string;
|
|
232
|
-
amount: string;
|
|
233
|
-
}[], Iterable<{
|
|
234
|
-
denom: string;
|
|
235
|
-
amount: string | number | bigint;
|
|
236
|
-
}> & {
|
|
237
|
-
length: number;
|
|
238
|
-
}, string>;
|
|
239
|
-
}, string>;
|
|
240
|
-
type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;
|
|
241
221
|
declare const SwapSimulationResultStruct: _mysten_bcs.BcsStruct<{
|
|
242
222
|
base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
223
|
quote_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -255,12 +235,24 @@ type RouterPool = Pool & {
|
|
|
255
235
|
};
|
|
256
236
|
|
|
257
237
|
declare const PoolInfoStruct: _mysten_bcs.BcsStruct<{
|
|
238
|
+
id: _mysten_bcs.BcsType<string, string, "string">;
|
|
258
239
|
base_liquidity: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
240
|
+
net_base_added: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
259
241
|
total_lp_shares: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
242
|
+
protocol_base_fees: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
260
243
|
admin: _mysten_bcs.BcsType<string, string, "address">;
|
|
261
244
|
is_paused: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
262
245
|
}, string>;
|
|
263
246
|
type PoolInfoStructOutput = BcsParsed<typeof PoolInfoStruct>;
|
|
247
|
+
type PoolInfo = {
|
|
248
|
+
id: string;
|
|
249
|
+
baseLiquidity: string;
|
|
250
|
+
netBaseAdded: string;
|
|
251
|
+
totalLpShares: string;
|
|
252
|
+
protocolBaseFees: string;
|
|
253
|
+
admin: Address;
|
|
254
|
+
isPaused: boolean;
|
|
255
|
+
};
|
|
264
256
|
declare const PoolConfigStruct: _mysten_bcs.BcsStruct<{
|
|
265
257
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
266
258
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -275,6 +267,11 @@ declare const ProtocolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
|
275
267
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
276
268
|
}, string>;
|
|
277
269
|
type ProtocolFeesInfoStructOutput = BcsParsed<typeof ProtocolFeesInfoStruct>;
|
|
270
|
+
declare const BaseLiquidityInfoStruct: _mysten_bcs.BcsStruct<{
|
|
271
|
+
base_reserve: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
272
|
+
total_lp_shares: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
273
|
+
}, string>;
|
|
274
|
+
type BaseLiquidityInfoStructOutput = BcsParsed<typeof BaseLiquidityInfoStruct>;
|
|
278
275
|
|
|
279
276
|
declare class RouterClient {
|
|
280
277
|
pools: Pool[];
|
|
@@ -470,8 +467,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
470
467
|
getAllPools(): Promise<Pool[]>;
|
|
471
468
|
/** @inheritdoc */
|
|
472
469
|
getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
|
|
473
|
-
/** @inheritdoc */
|
|
474
|
-
getAssets(): Promise<Asset[]>;
|
|
475
470
|
/**
|
|
476
471
|
* @inheritdoc
|
|
477
472
|
*
|
|
@@ -483,6 +478,10 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
483
478
|
* @throws Will throw an error if no pool exists for the specified base/quote asset pair
|
|
484
479
|
*/
|
|
485
480
|
getPoolConfigByDenom(baseDenom: string, quoteDenom: string): Promise<PoolConfig>;
|
|
481
|
+
/** @inheritdoc */
|
|
482
|
+
getPoolBaseLiquidity(poolContractAddress: string): Promise<BaseLiquidityDetails>;
|
|
483
|
+
/** @inheritdoc */
|
|
484
|
+
getAssets(): Promise<Asset[]>;
|
|
486
485
|
/**
|
|
487
486
|
* @inheritdoc
|
|
488
487
|
*
|
|
@@ -566,4 +565,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
566
565
|
private loadConfigFromUrl;
|
|
567
566
|
}
|
|
568
567
|
|
|
569
|
-
export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput,
|
|
568
|
+
export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolConfigStruct, type PoolConfigStructOutput, type PoolInfo, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type RouterPool, type SuiChainConfig, type SuiClientConfig, SwapSimulationResultStruct, type SwapSimulationResultStructOutput, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var MainnetContracts = {
|
|
|
23
23
|
oracle: "0xfa3975b98f3d0e3df18ed88ae6e69db31836b3f4212df02fae144b1e5a89ca8e",
|
|
24
24
|
router: " "
|
|
25
25
|
};
|
|
26
|
-
var MainnetPackageId = "
|
|
26
|
+
var MainnetPackageId = "0xbffcccd9d24e319c729e724a0a0e6d0a403b24a03f643da4bbdb0fe6c925f82b";
|
|
27
27
|
var MainnetPoolGlobalConfigId = "0x7bcd5035a991f42fa84c5a42216b5638cb3f1a8c4f065063093b0a3d5f165d63";
|
|
28
28
|
var MainnetNativeTokenDenom = SUI_TOKEN_DENOM;
|
|
29
29
|
var MainnetAssets = {
|
|
@@ -893,14 +893,6 @@ var MarketsResponsePaginatedStruct = bcs5.struct("MarketsResponsePaginated", {
|
|
|
893
893
|
markets: bcs5.vector(MarketStruct),
|
|
894
894
|
...PaginationStruct
|
|
895
895
|
});
|
|
896
|
-
var BaseLiquidityInfoStruct = bcs5.struct("BaseLiquidityInfo", {
|
|
897
|
-
denom: bcs5.string(),
|
|
898
|
-
amount: bcs5.u64()
|
|
899
|
-
});
|
|
900
|
-
var BaseLiquidityResponseStruct = bcs5.struct("BaseLiquidityResponse", {
|
|
901
|
-
base_assets: bcs5.vector(BaseLiquidityInfoStruct),
|
|
902
|
-
...PaginationStruct
|
|
903
|
-
});
|
|
904
896
|
var SwapSimulationResultStruct = bcs5.struct("SwapSimulationResult", {
|
|
905
897
|
base_out: bcs5.u64(),
|
|
906
898
|
quote_out: bcs5.u64(),
|
|
@@ -916,8 +908,11 @@ var SwapSimulationResultStruct = bcs5.struct("SwapSimulationResult", {
|
|
|
916
908
|
// src/types/pool.ts
|
|
917
909
|
import { bcs as bcs6 } from "@mysten/bcs";
|
|
918
910
|
var PoolInfoStruct = bcs6.struct("PoolInfo", {
|
|
911
|
+
id: bcs6.string(),
|
|
919
912
|
base_liquidity: bcs6.u64(),
|
|
913
|
+
net_base_added: bcs6.u64(),
|
|
920
914
|
total_lp_shares: bcs6.u64(),
|
|
915
|
+
protocol_base_fees: bcs6.u64(),
|
|
921
916
|
admin: BcsAddressType,
|
|
922
917
|
is_paused: bcs6.bool()
|
|
923
918
|
});
|
|
@@ -933,6 +928,10 @@ var ProtocolFeesInfoStruct = bcs6.struct("ProtocolFeesInfo", {
|
|
|
933
928
|
swap_fee_pct: bcs6.u64(),
|
|
934
929
|
lp_withdrawal_fee_pct: bcs6.u64()
|
|
935
930
|
});
|
|
931
|
+
var BaseLiquidityInfoStruct = bcs6.struct("BaseLiquidityInfo", {
|
|
932
|
+
base_reserve: bcs6.u64(),
|
|
933
|
+
total_lp_shares: bcs6.u64()
|
|
934
|
+
});
|
|
936
935
|
|
|
937
936
|
// src/lib/oracle/get-asset-pairs.ts
|
|
938
937
|
var getAssetPairs = async (client) => {
|
|
@@ -1067,26 +1066,97 @@ var estimateSwapExactInGasFees = async (client, swapParams, signer, gasAdjustmen
|
|
|
1067
1066
|
);
|
|
1068
1067
|
};
|
|
1069
1068
|
|
|
1069
|
+
// src/lib/settlement/get-pool-base-liquidity.ts
|
|
1070
|
+
import { NotFoundError as NotFoundError3 } from "@bolt-liquidity-hq/core";
|
|
1071
|
+
|
|
1072
|
+
// src/lib/settlement/parsers.ts
|
|
1073
|
+
import { BigNumber as BigNumber4 } from "bignumber.js";
|
|
1074
|
+
var parsePoolConfigStructOutput = (routerClient, poolConfig, priceOracleContract) => {
|
|
1075
|
+
return {
|
|
1076
|
+
priceOracleContract,
|
|
1077
|
+
protocolFeeRecipient: "0x",
|
|
1078
|
+
// TODO: get real fee recipient
|
|
1079
|
+
protocolFee: BigNumber4(poolConfig.swap_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1080
|
+
lpFee: BigNumber4(poolConfig.lp_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1081
|
+
allowanceMode: "allow",
|
|
1082
|
+
// Should come from pool config
|
|
1083
|
+
lps: routerClient.getPools().map((item) => item.poolAddress),
|
|
1084
|
+
minBaseOut: BigNumber4(poolConfig.min_base_out).toFixed()
|
|
1085
|
+
};
|
|
1086
|
+
};
|
|
1087
|
+
var parseBaseLiquidityInfoStructOutput = (baseLiquidityInfo, baseDenom) => {
|
|
1088
|
+
return {
|
|
1089
|
+
baseLiquidity: {
|
|
1090
|
+
denom: baseDenom,
|
|
1091
|
+
amount: BigNumber4(baseLiquidityInfo.base_reserve).toFixed()
|
|
1092
|
+
},
|
|
1093
|
+
totalShares: BigNumber4(baseLiquidityInfo.total_lp_shares).toFixed()
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
// src/lib/settlement/get-pool-base-liquidity.ts
|
|
1098
|
+
var getPoolBaseLiquidity = async (client, contractAddress) => {
|
|
1099
|
+
const GET_BASE_LIQUIDITY_INFO_FUNCTION = "get_base_liquidity_info";
|
|
1100
|
+
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1101
|
+
if (!pool) {
|
|
1102
|
+
throw new NotFoundError3(`Pool with the address ${contractAddress}`);
|
|
1103
|
+
}
|
|
1104
|
+
const baseLiquidityInfo = await queryDevInspect(
|
|
1105
|
+
client.suiClient,
|
|
1106
|
+
[client.packageId, POOL_MODULE, GET_BASE_LIQUIDITY_INFO_FUNCTION],
|
|
1107
|
+
[contractAddress],
|
|
1108
|
+
[pool.baseDenom]
|
|
1109
|
+
);
|
|
1110
|
+
const output = parseDevInspectResult(baseLiquidityInfo, BaseLiquidityInfoStruct);
|
|
1111
|
+
return parseBaseLiquidityInfoStructOutput(output, pool.baseDenom);
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
// src/lib/settlement/get-pool-config.ts
|
|
1115
|
+
import { NotFoundError as NotFoundError4 } from "@bolt-liquidity-hq/core";
|
|
1116
|
+
var getPoolConfig = async (client, contractAddress) => {
|
|
1117
|
+
const GET_POOL_CONFIG_FUNCTION = "get_pool_config";
|
|
1118
|
+
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1119
|
+
if (!pool) {
|
|
1120
|
+
throw new NotFoundError4(`Pool with the address ${contractAddress}`);
|
|
1121
|
+
}
|
|
1122
|
+
const poolConfig = await queryDevInspect(
|
|
1123
|
+
client.suiClient,
|
|
1124
|
+
[client.packageId, POOL_MODULE, GET_POOL_CONFIG_FUNCTION],
|
|
1125
|
+
[contractAddress],
|
|
1126
|
+
[pool.baseDenom]
|
|
1127
|
+
);
|
|
1128
|
+
const output = parseDevInspectResult(poolConfig, PoolConfigStruct);
|
|
1129
|
+
return parsePoolConfigStructOutput(client.routerClient, output, client.contracts.oracle);
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
// src/lib/settlement/get-pool-config-by-denom.ts
|
|
1133
|
+
var getPoolConfigByDenom = async (client, baseDenom, quoteDenom) => {
|
|
1134
|
+
const pool = await getPoolByDenom(client, baseDenom, quoteDenom);
|
|
1135
|
+
return await getPoolConfig(client, pool.poolAddress);
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1070
1138
|
// src/lib/router/get-all-base-liquidity.ts
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1139
|
+
var getAllBaseLiquidity = async (client) => {
|
|
1140
|
+
const result = {};
|
|
1141
|
+
for (const pool of client.routerClient.pools) {
|
|
1142
|
+
const baseLiquidity = await getPoolBaseLiquidity(client, pool.poolAddress);
|
|
1143
|
+
result[pool.poolAddress] = baseLiquidity;
|
|
1144
|
+
}
|
|
1145
|
+
return result;
|
|
1076
1146
|
};
|
|
1077
1147
|
|
|
1078
1148
|
// src/lib/router/get-all-quotes-for-user.ts
|
|
1079
|
-
import { NotImplementedError
|
|
1149
|
+
import { NotImplementedError } from "@bolt-liquidity-hq/core";
|
|
1080
1150
|
var getAllQuotesForUser = async (_client, _lpAddress) => {
|
|
1081
|
-
throw new
|
|
1151
|
+
throw new NotImplementedError("getRouterConfig on Sui Client");
|
|
1082
1152
|
};
|
|
1083
1153
|
|
|
1084
1154
|
// src/lib/router/get-pool-by-denom.ts
|
|
1085
|
-
import { NotFoundError as
|
|
1155
|
+
import { NotFoundError as NotFoundError5 } from "@bolt-liquidity-hq/core";
|
|
1086
1156
|
var getPoolByDenom = async (client, baseDenom, quoteDenom) => {
|
|
1087
1157
|
const result = await client.routerClient.getPool(quoteDenom, baseDenom);
|
|
1088
1158
|
if (!result) {
|
|
1089
|
-
throw new
|
|
1159
|
+
throw new NotFoundError5("Pool", `Didn't find a pool to swap ${quoteDenom} for ${baseDenom}`);
|
|
1090
1160
|
}
|
|
1091
1161
|
return result;
|
|
1092
1162
|
};
|
|
@@ -1097,14 +1167,14 @@ var getPools = async (client) => {
|
|
|
1097
1167
|
};
|
|
1098
1168
|
|
|
1099
1169
|
// src/lib/router/get-router-config.ts
|
|
1100
|
-
import { NotImplementedError as
|
|
1170
|
+
import { NotImplementedError as NotImplementedError2 } from "@bolt-liquidity-hq/core";
|
|
1101
1171
|
var getRouterConfig = async (_client) => {
|
|
1102
|
-
throw new
|
|
1172
|
+
throw new NotImplementedError2("getRouterConfig on Sui Client");
|
|
1103
1173
|
};
|
|
1104
1174
|
|
|
1105
1175
|
// src/lib/router/parsers.ts
|
|
1106
|
-
import { NotFoundError as
|
|
1107
|
-
import { BigNumber as
|
|
1176
|
+
import { NotFoundError as NotFoundError6 } from "@bolt-liquidity-hq/core";
|
|
1177
|
+
import { BigNumber as BigNumber5 } from "bignumber.js";
|
|
1108
1178
|
var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
1109
1179
|
return {
|
|
1110
1180
|
poolAddress,
|
|
@@ -1112,7 +1182,7 @@ var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
|
1112
1182
|
assetOut,
|
|
1113
1183
|
protocolFee: output.protocol_fee,
|
|
1114
1184
|
lpFee: output.lp_fee,
|
|
1115
|
-
dynamicFeePercentage:
|
|
1185
|
+
dynamicFeePercentage: BigNumber5(output.dynamic_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1116
1186
|
totalFees: output.swap_fee
|
|
1117
1187
|
};
|
|
1118
1188
|
};
|
|
@@ -1153,14 +1223,14 @@ var RouterClient = class {
|
|
|
1153
1223
|
|
|
1154
1224
|
// src/lib/router/simulate-swap.ts
|
|
1155
1225
|
import {
|
|
1156
|
-
NotFoundError as
|
|
1226
|
+
NotFoundError as NotFoundError7
|
|
1157
1227
|
} from "@bolt-liquidity-hq/core";
|
|
1158
1228
|
import { bcs as bcs7 } from "@mysten/bcs";
|
|
1159
1229
|
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui/utils";
|
|
1160
1230
|
var simulateSwap = async (client, { assetIn, amountIn, assetOut }) => {
|
|
1161
|
-
const pool =
|
|
1231
|
+
const pool = client.routerClient.getPool(assetIn, assetOut);
|
|
1162
1232
|
if (!pool) {
|
|
1163
|
-
throw new
|
|
1233
|
+
throw new NotFoundError7("Pool", `Didn't find a pool to swap ${assetIn} for ${assetOut}`);
|
|
1164
1234
|
}
|
|
1165
1235
|
const FUNCTION_NAME = pool.isInverse ? "simulate_sell_swap" : "simulate_buy_swap";
|
|
1166
1236
|
const response = await queryDevInspect(
|
|
@@ -1193,48 +1263,6 @@ var swapExactIn = async (client, swapParams, signer) => {
|
|
|
1193
1263
|
};
|
|
1194
1264
|
};
|
|
1195
1265
|
|
|
1196
|
-
// src/lib/settlement/get-pool-info.ts
|
|
1197
|
-
import { NotFoundError as NotFoundError6 } from "@bolt-liquidity-hq/core";
|
|
1198
|
-
|
|
1199
|
-
// src/lib/settlement/parsers.ts
|
|
1200
|
-
import { BigNumber as BigNumber5 } from "bignumber.js";
|
|
1201
|
-
var parsePoolConfigStructOutput = (routerClient, poolConfig, priceOracleContract) => {
|
|
1202
|
-
return {
|
|
1203
|
-
priceOracleContract,
|
|
1204
|
-
protocolFeeRecipient: "0x",
|
|
1205
|
-
// TODO: get real fee recipient
|
|
1206
|
-
protocolFee: BigNumber5(poolConfig.swap_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1207
|
-
lpFee: BigNumber5(poolConfig.lp_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1208
|
-
allowanceMode: "allow",
|
|
1209
|
-
// Should come from pool config
|
|
1210
|
-
lps: routerClient.getPools().map((item) => item.poolAddress),
|
|
1211
|
-
minBaseOut: BigNumber5(poolConfig.min_base_out).toFixed()
|
|
1212
|
-
};
|
|
1213
|
-
};
|
|
1214
|
-
|
|
1215
|
-
// src/lib/settlement/get-pool-info.ts
|
|
1216
|
-
var getPoolInfo = async (client, contractAddress) => {
|
|
1217
|
-
const GET_POOL_CONFIG_FUNCTION = "get_pool_config";
|
|
1218
|
-
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1219
|
-
if (!pool) {
|
|
1220
|
-
throw new NotFoundError6(`Pool with the address ${contractAddress}`);
|
|
1221
|
-
}
|
|
1222
|
-
const poolConfig = await queryDevInspect(
|
|
1223
|
-
client.suiClient,
|
|
1224
|
-
[client.packageId, POOL_MODULE, GET_POOL_CONFIG_FUNCTION],
|
|
1225
|
-
[contractAddress],
|
|
1226
|
-
[pool.baseDenom]
|
|
1227
|
-
);
|
|
1228
|
-
const output = parseDevInspectResult(poolConfig, PoolConfigStruct);
|
|
1229
|
-
return parsePoolConfigStructOutput(client.routerClient, output, client.contracts.oracle);
|
|
1230
|
-
};
|
|
1231
|
-
|
|
1232
|
-
// src/lib/settlement/get-pool-info-by-denom.ts
|
|
1233
|
-
var getPoolInfoByDenom = async (client, baseDenom, quoteDenom) => {
|
|
1234
|
-
const pool = await getPoolByDenom(client, baseDenom, quoteDenom);
|
|
1235
|
-
return await getPoolInfo(client, pool.poolAddress);
|
|
1236
|
-
};
|
|
1237
|
-
|
|
1238
1266
|
// src/lib/client.ts
|
|
1239
1267
|
var BoltSuiClient = class extends BaseClient {
|
|
1240
1268
|
/**
|
|
@@ -1471,12 +1499,7 @@ var BoltSuiClient = class extends BaseClient {
|
|
|
1471
1499
|
/** @inheritdoc */
|
|
1472
1500
|
async getPoolConfig(poolContractAddress) {
|
|
1473
1501
|
await this.loadConfigFromUrl();
|
|
1474
|
-
return await
|
|
1475
|
-
}
|
|
1476
|
-
/** @inheritdoc */
|
|
1477
|
-
async getAssets() {
|
|
1478
|
-
await this.loadConfigFromUrl();
|
|
1479
|
-
return await getAssets(this);
|
|
1502
|
+
return await getPoolConfig(this, poolContractAddress);
|
|
1480
1503
|
}
|
|
1481
1504
|
/**
|
|
1482
1505
|
* @inheritdoc
|
|
@@ -1490,7 +1513,17 @@ var BoltSuiClient = class extends BaseClient {
|
|
|
1490
1513
|
*/
|
|
1491
1514
|
async getPoolConfigByDenom(baseDenom, quoteDenom) {
|
|
1492
1515
|
await this.loadConfigFromUrl();
|
|
1493
|
-
return await
|
|
1516
|
+
return await getPoolConfigByDenom(this, baseDenom, quoteDenom);
|
|
1517
|
+
}
|
|
1518
|
+
/** @inheritdoc */
|
|
1519
|
+
async getPoolBaseLiquidity(poolContractAddress) {
|
|
1520
|
+
await this.loadConfigFromUrl();
|
|
1521
|
+
return await getPoolBaseLiquidity(this, poolContractAddress);
|
|
1522
|
+
}
|
|
1523
|
+
/** @inheritdoc */
|
|
1524
|
+
async getAssets() {
|
|
1525
|
+
await this.loadConfigFromUrl();
|
|
1526
|
+
return await getAssets(this);
|
|
1494
1527
|
}
|
|
1495
1528
|
/**
|
|
1496
1529
|
* @inheritdoc
|
|
@@ -1624,7 +1657,6 @@ export {
|
|
|
1624
1657
|
AssetPairStruct,
|
|
1625
1658
|
AssetPairsResponseStruct,
|
|
1626
1659
|
BaseLiquidityInfoStruct,
|
|
1627
|
-
BaseLiquidityResponseStruct,
|
|
1628
1660
|
BcsAddressType,
|
|
1629
1661
|
BoltSuiClient,
|
|
1630
1662
|
MarketResponseStruct,
|