@cetusprotocol/aggregator-sdk 1.4.5 → 1.4.7

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,9 +1,8 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
- import { SuiClient, DevInspectResults, SuiMoveObject } from '@mysten/sui/client';
3
2
  import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
3
  import BN from 'bn.js';
5
4
  import Decimal from 'decimal.js';
6
- import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
7
6
  import { Signer } from '@mysten/sui/cryptography';
8
7
 
9
8
  interface FindRouterParams {
@@ -119,10 +118,15 @@ type ExtendedDetails = {
119
118
  obric_coin_b_price_seed?: string;
120
119
  obric_coin_a_price_id?: string;
121
120
  obric_coin_b_price_id?: string;
121
+ /** @deprecated SevenK DEX is no longer active. */
122
122
  sevenk_coin_a_price_seed?: string;
123
+ /** @deprecated SevenK DEX is no longer active. */
123
124
  sevenk_coin_b_price_seed?: string;
125
+ /** @deprecated SevenK DEX is no longer active. */
124
126
  sevenk_oracle_config_a?: string;
127
+ /** @deprecated SevenK DEX is no longer active. */
125
128
  sevenk_oracle_config_b?: string;
129
+ /** @deprecated SevenK DEX is no longer active. */
126
130
  sevenk_lp_cap_type?: string;
127
131
  };
128
132
  type Path = {
@@ -286,6 +290,35 @@ interface DexRouter {
286
290
  swap(txb: Transaction, flattenedPath: FlattenedPath, swapContext: TransactionObjectArgument, _extends?: Extends): void;
287
291
  }
288
292
 
293
+ type ObjectId = string;
294
+ interface PriceTableInfo {
295
+ id: ObjectId;
296
+ fieldType: string;
297
+ }
298
+ declare class PythAdapter {
299
+ private client;
300
+ private hermesClients;
301
+ private pythStateId;
302
+ private wormholeStateId;
303
+ private pythPackageId;
304
+ private wormholePackageId;
305
+ private priceTableInfo;
306
+ private priceFeedObjectIdCache;
307
+ private baseUpdateFee;
308
+ constructor(client: SuiGrpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
309
+ getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
310
+ getBaseUpdateFee(): Promise<number>;
311
+ getPackageId(objectId: ObjectId): Promise<string>;
312
+ getWormholePackageId(): Promise<string>;
313
+ getPythPackageId(): Promise<string>;
314
+ getPriceFeedObjectId(feedId: string): Promise<string | undefined>;
315
+ getPriceTableInfo(): Promise<PriceTableInfo>;
316
+ extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Buffer): Buffer;
317
+ private verifyVaas;
318
+ private verifyVaasAndGetHotPotato;
319
+ updatePriceFeeds(tx: Transaction, updates: Buffer[], feedIds: string[]): Promise<ObjectId[]>;
320
+ }
321
+
289
322
  declare const CETUS = "CETUS";
290
323
  declare const DEEPBOOKV2 = "DEEPBOOK";
291
324
  declare const KRIYA = "KRIYA";
@@ -313,6 +346,7 @@ declare const STEAMM_OMM = "STEAMM_OMM";
313
346
  declare const MOMENTUM = "MOMENTUM";
314
347
  declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
315
348
  declare const MAGMA = "MAGMA";
349
+ /** @deprecated SevenK DEX is no longer active. Will be removed in a future version. */
316
350
  declare const SEVENK = "SEVENK";
317
351
  declare const HAEDALHMMV2 = "HAEDALHMMV2";
318
352
  declare const FULLSAIL = "FULLSAIL";
@@ -365,7 +399,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
365
399
  type AggregatorClientParams = {
366
400
  endpoint?: string;
367
401
  signer?: string;
368
- client?: SuiClient;
402
+ client?: SuiGrpcClient;
369
403
  env?: Env;
370
404
  pythUrls?: string[];
371
405
  apiKey?: string;
@@ -377,18 +411,16 @@ type AggregatorClientParams = {
377
411
  declare class AggregatorClient {
378
412
  endpoint: string;
379
413
  signer: string;
380
- client: SuiClient;
414
+ client: SuiGrpcClient;
381
415
  env: Env;
382
416
  apiKey: string;
383
- protected pythConnections: SuiPriceServiceConnection[];
384
- protected pythClient: SuiPythClient;
417
+ protected pythAdapter: PythAdapter;
385
418
  protected overlayFeeRate: number;
386
419
  protected overlayFeeReceiver: string;
387
420
  protected partner?: string;
388
421
  protected cetusDlmmPartner?: string;
389
422
  private static readonly CONFIG;
390
423
  constructor(params: AggregatorClientParams);
391
- newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
392
424
  deepbookv3DeepFeeType(): string;
393
425
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
394
426
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
@@ -421,8 +453,15 @@ declare class AggregatorClient {
421
453
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
422
454
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
423
455
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
424
- devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
425
- sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
456
+ devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.SuiClientTypes.SimulateTransactionResult<{
457
+ events: true;
458
+ effects: true;
459
+ }>>;
460
+ sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
461
+ effects: true;
462
+ events: true;
463
+ balanceChanges: true;
464
+ }>>;
426
465
  }
427
466
 
428
467
  /**
@@ -455,7 +494,7 @@ type GetOrCreateAccountCapResult = {
455
494
  accountCap: TransactionObjectArgument;
456
495
  isCreate: boolean;
457
496
  };
458
- declare function getOrCreateAccountCap(txb: Transaction, client: SuiClient, owner: string): Promise<GetOrCreateAccountCapResult>;
497
+ declare function getOrCreateAccountCap(txb: Transaction, client: SuiGrpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
459
498
 
460
499
  /**
461
500
  * Represents a SUI address, which is a string.
@@ -604,6 +643,69 @@ interface Dex {
604
643
  swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
605
644
  }
606
645
 
646
+ /**
647
+ * Matches the shape of SuiClientTypes.SimulateTransactionResult with effects included.
648
+ * Using a local type so gas.ts can be used without importing the full SDK.
649
+ */
650
+ type SimulateTransactionResult = {
651
+ $kind: 'Transaction' | 'FailedTransaction';
652
+ Transaction?: {
653
+ status: {
654
+ success: true;
655
+ error: null;
656
+ } | {
657
+ success: false;
658
+ error: {
659
+ message: string;
660
+ };
661
+ };
662
+ effects?: {
663
+ status: {
664
+ success: true;
665
+ error: null;
666
+ } | {
667
+ success: false;
668
+ error: {
669
+ message: string;
670
+ };
671
+ };
672
+ gasUsed: {
673
+ computationCost: string;
674
+ storageCost: string;
675
+ storageRebate: string;
676
+ nonRefundableStorageFee: string;
677
+ };
678
+ };
679
+ };
680
+ FailedTransaction?: {
681
+ status: {
682
+ success: true;
683
+ error: null;
684
+ } | {
685
+ success: false;
686
+ error: {
687
+ message: string;
688
+ };
689
+ };
690
+ effects?: {
691
+ status: {
692
+ success: true;
693
+ error: null;
694
+ } | {
695
+ success: false;
696
+ error: {
697
+ message: string;
698
+ };
699
+ };
700
+ gasUsed: {
701
+ computationCost: string;
702
+ storageCost: string;
703
+ storageRebate: string;
704
+ nonRefundableStorageFee: string;
705
+ };
706
+ };
707
+ };
708
+ };
607
709
  interface GasMetrics {
608
710
  computationCost: string;
609
711
  storageCost: string;
@@ -641,9 +743,9 @@ interface ComparisonResult {
641
743
  };
642
744
  }
643
745
  /**
644
- * Extract gas metrics from DevInspectResults
746
+ * Extract gas metrics from a simulateTransaction result.
645
747
  */
646
- declare function extractGasMetrics(result: DevInspectResults): GasMetrics;
748
+ declare function extractGasMetrics(result: SimulateTransactionResult): GasMetrics;
647
749
  /**
648
750
  * Calculate gas efficiency (amount out per gas unit)
649
751
  */
@@ -891,6 +993,11 @@ interface PythConfig {
891
993
  pythStateId: string;
892
994
  }
893
995
 
996
+ interface SuiMoveObject {
997
+ type: string;
998
+ fields: Record<string, unknown>;
999
+ }
1000
+
894
1001
  declare const DEFAULT_GAS_BUDGET_FOR_SPLIT = 1000;
895
1002
  declare const DEFAULT_GAS_BUDGET_FOR_MERGE = 500;
896
1003
  declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER = 100;
@@ -1012,4 +1119,4 @@ declare class CoinUtils {
1012
1119
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
1013
1120
  }
1014
1121
 
1015
- export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
1122
+ export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
- import { SuiClient, DevInspectResults, SuiMoveObject } from '@mysten/sui/client';
3
2
  import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
3
  import BN from 'bn.js';
5
4
  import Decimal from 'decimal.js';
6
- import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
7
6
  import { Signer } from '@mysten/sui/cryptography';
8
7
 
9
8
  interface FindRouterParams {
@@ -119,10 +118,15 @@ type ExtendedDetails = {
119
118
  obric_coin_b_price_seed?: string;
120
119
  obric_coin_a_price_id?: string;
121
120
  obric_coin_b_price_id?: string;
121
+ /** @deprecated SevenK DEX is no longer active. */
122
122
  sevenk_coin_a_price_seed?: string;
123
+ /** @deprecated SevenK DEX is no longer active. */
123
124
  sevenk_coin_b_price_seed?: string;
125
+ /** @deprecated SevenK DEX is no longer active. */
124
126
  sevenk_oracle_config_a?: string;
127
+ /** @deprecated SevenK DEX is no longer active. */
125
128
  sevenk_oracle_config_b?: string;
129
+ /** @deprecated SevenK DEX is no longer active. */
126
130
  sevenk_lp_cap_type?: string;
127
131
  };
128
132
  type Path = {
@@ -286,6 +290,35 @@ interface DexRouter {
286
290
  swap(txb: Transaction, flattenedPath: FlattenedPath, swapContext: TransactionObjectArgument, _extends?: Extends): void;
287
291
  }
288
292
 
293
+ type ObjectId = string;
294
+ interface PriceTableInfo {
295
+ id: ObjectId;
296
+ fieldType: string;
297
+ }
298
+ declare class PythAdapter {
299
+ private client;
300
+ private hermesClients;
301
+ private pythStateId;
302
+ private wormholeStateId;
303
+ private pythPackageId;
304
+ private wormholePackageId;
305
+ private priceTableInfo;
306
+ private priceFeedObjectIdCache;
307
+ private baseUpdateFee;
308
+ constructor(client: SuiGrpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
309
+ getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
310
+ getBaseUpdateFee(): Promise<number>;
311
+ getPackageId(objectId: ObjectId): Promise<string>;
312
+ getWormholePackageId(): Promise<string>;
313
+ getPythPackageId(): Promise<string>;
314
+ getPriceFeedObjectId(feedId: string): Promise<string | undefined>;
315
+ getPriceTableInfo(): Promise<PriceTableInfo>;
316
+ extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Buffer): Buffer;
317
+ private verifyVaas;
318
+ private verifyVaasAndGetHotPotato;
319
+ updatePriceFeeds(tx: Transaction, updates: Buffer[], feedIds: string[]): Promise<ObjectId[]>;
320
+ }
321
+
289
322
  declare const CETUS = "CETUS";
290
323
  declare const DEEPBOOKV2 = "DEEPBOOK";
291
324
  declare const KRIYA = "KRIYA";
@@ -313,6 +346,7 @@ declare const STEAMM_OMM = "STEAMM_OMM";
313
346
  declare const MOMENTUM = "MOMENTUM";
314
347
  declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
315
348
  declare const MAGMA = "MAGMA";
349
+ /** @deprecated SevenK DEX is no longer active. Will be removed in a future version. */
316
350
  declare const SEVENK = "SEVENK";
317
351
  declare const HAEDALHMMV2 = "HAEDALHMMV2";
318
352
  declare const FULLSAIL = "FULLSAIL";
@@ -365,7 +399,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
365
399
  type AggregatorClientParams = {
366
400
  endpoint?: string;
367
401
  signer?: string;
368
- client?: SuiClient;
402
+ client?: SuiGrpcClient;
369
403
  env?: Env;
370
404
  pythUrls?: string[];
371
405
  apiKey?: string;
@@ -377,18 +411,16 @@ type AggregatorClientParams = {
377
411
  declare class AggregatorClient {
378
412
  endpoint: string;
379
413
  signer: string;
380
- client: SuiClient;
414
+ client: SuiGrpcClient;
381
415
  env: Env;
382
416
  apiKey: string;
383
- protected pythConnections: SuiPriceServiceConnection[];
384
- protected pythClient: SuiPythClient;
417
+ protected pythAdapter: PythAdapter;
385
418
  protected overlayFeeRate: number;
386
419
  protected overlayFeeReceiver: string;
387
420
  protected partner?: string;
388
421
  protected cetusDlmmPartner?: string;
389
422
  private static readonly CONFIG;
390
423
  constructor(params: AggregatorClientParams);
391
- newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
392
424
  deepbookv3DeepFeeType(): string;
393
425
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
394
426
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
@@ -421,8 +453,15 @@ declare class AggregatorClient {
421
453
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
422
454
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
423
455
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
424
- devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
425
- sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
456
+ devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.SuiClientTypes.SimulateTransactionResult<{
457
+ events: true;
458
+ effects: true;
459
+ }>>;
460
+ sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
461
+ effects: true;
462
+ events: true;
463
+ balanceChanges: true;
464
+ }>>;
426
465
  }
427
466
 
428
467
  /**
@@ -455,7 +494,7 @@ type GetOrCreateAccountCapResult = {
455
494
  accountCap: TransactionObjectArgument;
456
495
  isCreate: boolean;
457
496
  };
458
- declare function getOrCreateAccountCap(txb: Transaction, client: SuiClient, owner: string): Promise<GetOrCreateAccountCapResult>;
497
+ declare function getOrCreateAccountCap(txb: Transaction, client: SuiGrpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
459
498
 
460
499
  /**
461
500
  * Represents a SUI address, which is a string.
@@ -604,6 +643,69 @@ interface Dex {
604
643
  swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
605
644
  }
606
645
 
646
+ /**
647
+ * Matches the shape of SuiClientTypes.SimulateTransactionResult with effects included.
648
+ * Using a local type so gas.ts can be used without importing the full SDK.
649
+ */
650
+ type SimulateTransactionResult = {
651
+ $kind: 'Transaction' | 'FailedTransaction';
652
+ Transaction?: {
653
+ status: {
654
+ success: true;
655
+ error: null;
656
+ } | {
657
+ success: false;
658
+ error: {
659
+ message: string;
660
+ };
661
+ };
662
+ effects?: {
663
+ status: {
664
+ success: true;
665
+ error: null;
666
+ } | {
667
+ success: false;
668
+ error: {
669
+ message: string;
670
+ };
671
+ };
672
+ gasUsed: {
673
+ computationCost: string;
674
+ storageCost: string;
675
+ storageRebate: string;
676
+ nonRefundableStorageFee: string;
677
+ };
678
+ };
679
+ };
680
+ FailedTransaction?: {
681
+ status: {
682
+ success: true;
683
+ error: null;
684
+ } | {
685
+ success: false;
686
+ error: {
687
+ message: string;
688
+ };
689
+ };
690
+ effects?: {
691
+ status: {
692
+ success: true;
693
+ error: null;
694
+ } | {
695
+ success: false;
696
+ error: {
697
+ message: string;
698
+ };
699
+ };
700
+ gasUsed: {
701
+ computationCost: string;
702
+ storageCost: string;
703
+ storageRebate: string;
704
+ nonRefundableStorageFee: string;
705
+ };
706
+ };
707
+ };
708
+ };
607
709
  interface GasMetrics {
608
710
  computationCost: string;
609
711
  storageCost: string;
@@ -641,9 +743,9 @@ interface ComparisonResult {
641
743
  };
642
744
  }
643
745
  /**
644
- * Extract gas metrics from DevInspectResults
746
+ * Extract gas metrics from a simulateTransaction result.
645
747
  */
646
- declare function extractGasMetrics(result: DevInspectResults): GasMetrics;
748
+ declare function extractGasMetrics(result: SimulateTransactionResult): GasMetrics;
647
749
  /**
648
750
  * Calculate gas efficiency (amount out per gas unit)
649
751
  */
@@ -891,6 +993,11 @@ interface PythConfig {
891
993
  pythStateId: string;
892
994
  }
893
995
 
996
+ interface SuiMoveObject {
997
+ type: string;
998
+ fields: Record<string, unknown>;
999
+ }
1000
+
894
1001
  declare const DEFAULT_GAS_BUDGET_FOR_SPLIT = 1000;
895
1002
  declare const DEFAULT_GAS_BUDGET_FOR_MERGE = 500;
896
1003
  declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER = 100;
@@ -1012,4 +1119,4 @@ declare class CoinUtils {
1012
1119
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
1013
1120
  }
1014
1121
 
1015
- export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
1122
+ export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };