aftermath-ts-sdk 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,42 @@ import { MultiSigPublicKey } from '@mysten/sui/multisig';
6
6
  import { BcsType } from '@mysten/sui/bcs';
7
7
  import { Keypair } from '@mysten/sui/cryptography';
8
8
 
9
- type SuiNetwork = "DEVNET" | "TESTNET" | "LOCAL" | "MAINNET" | "INTERNAL" | (string & {});
9
+ /**
10
+ * Represents the body payload sent to the dynamic gas service,
11
+ * which includes the serialized transaction and any user-provided
12
+ * gas configuration (e.g., coin type).
13
+ */
14
+ interface ApiDynamicGasBody {
15
+ /**
16
+ * The serialized transaction block in base64 or similar format.
17
+ */
18
+ serializedTx: SerializedTransaction;
19
+ /**
20
+ * The address of the user for whom the dynamic gas is being set.
21
+ */
22
+ walletAddress: SuiAddress;
23
+ /**
24
+ * The coin type to be used for gas payment (e.g., "0x2::sui::SUI").
25
+ */
26
+ gasCoinType: CoinType;
27
+ }
28
+ /**
29
+ * Represents the response from the dynamic gas service, typically returning
30
+ * updated transaction bytes and possibly a sponsored signature if the
31
+ * transaction gas is being partially or fully sponsored.
32
+ */
33
+ interface ApiDynamicGasResponse {
34
+ /**
35
+ * The modified transaction bytes that incorporate a gas coin or sponsor information.
36
+ */
37
+ txBytes: SerializedTransaction;
38
+ /**
39
+ * A signature used to sponsor or verify the updated transaction, if applicable.
40
+ */
41
+ sponsoredSignature: string;
42
+ }
43
+
44
+ type SuiNetwork = "DEVNET" | "TESTNET" | "LOCAL" | "MAINNET";
10
45
 
11
46
  /**
12
47
  * Represents a token or currency balance in the system, defined as a bigint.
@@ -339,13 +374,27 @@ interface IndexerDataWithCursorQueryParams {
339
374
  */
340
375
  interface CallerConfig {
341
376
  /**
342
- * The target Sui network (e.g., "MAINNET", "TESTNET").
377
+ * The target Sui network (e.g., "MAINNET", "TESTNET"). Determines the
378
+ * default API host when `baseUrl` is not supplied.
343
379
  */
344
380
  network?: SuiNetwork;
381
+ /**
382
+ * Explicit override for the API host (e.g. `"http://localhost:8080"`).
383
+ * Takes precedence over the network-derived default. Use this to point
384
+ * the SDK at a custom or local backend.
385
+ */
386
+ baseUrl?: string;
345
387
  /**
346
388
  * Access token used for authenticated requests, if required.
347
389
  */
348
390
  accessToken?: string;
391
+ /**
392
+ * URL path segment placed between the host and the package prefix when
393
+ * building API call URLs (`{host}/{apiEndpoint}/{package}/...`).
394
+ * Defaults to `"api"`. Override only when targeting a backend that
395
+ * mounts the Aftermath API under a different path.
396
+ */
397
+ apiEndpoint?: string;
349
398
  }
350
399
  interface ApiTransactionResponse {
351
400
  txKind: SerializedTransaction;
@@ -355,6 +404,51 @@ interface SdkTransactionResponse {
355
404
  tx: Transaction;
356
405
  }
357
406
 
407
+ interface KioskOwnerCapObject extends Object$1 {
408
+ kioskObjectId: ObjectId;
409
+ }
410
+ interface KioskObject extends Object$1 {
411
+ kioskOwnerCapId: ObjectId;
412
+ nfts: Nft[];
413
+ isPersonal: boolean;
414
+ }
415
+ interface Nft {
416
+ info: NftInfo;
417
+ display: NftDisplay;
418
+ }
419
+ interface NftInfo {
420
+ objectId: ObjectId;
421
+ objectType: AnyObjectType;
422
+ }
423
+ interface NftDisplay {
424
+ suggested: NftDisplaySuggested;
425
+ other: NftDisplayOther;
426
+ }
427
+ interface NftDisplaySuggested {
428
+ name?: string;
429
+ link?: Url;
430
+ imageUrl?: Url;
431
+ description?: string;
432
+ projectUrl?: Url;
433
+ creator?: string;
434
+ }
435
+ type NftDisplayOther = Record<string, string>;
436
+
437
+ type CoinGeckoChain = Lowercase<"Ethereum" | "Arbitrum" | "Bsc" | "Solana" | "Sui" | "Polygon" | "Avalanche" | "Optimism" | "Base">;
438
+ type CoinGeckoCoinApiId = string;
439
+ interface CoinGeckoCoinData {
440
+ chain: CoinGeckoChain | "";
441
+ apiId: CoinGeckoCoinApiId;
442
+ name: string;
443
+ symbol: CoinSymbol;
444
+ coinType: CoinType;
445
+ }
446
+ interface CoinGeckoCoinSymbolData {
447
+ apiId: CoinGeckoCoinApiId;
448
+ name: string;
449
+ symbol: CoinSymbol;
450
+ }
451
+
358
452
  type RpcEndpoint = string;
359
453
  interface ConfigAddresses {
360
454
  faucet?: FaucetAddresses;
@@ -529,84 +623,19 @@ interface NftsAddresses {
529
623
  };
530
624
  }
531
625
 
532
- interface KioskOwnerCapObject extends Object$1 {
533
- kioskObjectId: ObjectId;
534
- }
535
- interface KioskObject extends Object$1 {
536
- kioskOwnerCapId: ObjectId;
537
- nfts: Nft[];
538
- isPersonal: boolean;
539
- }
540
- interface Nft {
541
- info: NftInfo;
542
- display: NftDisplay;
543
- }
544
- interface NftInfo {
545
- objectId: ObjectId;
546
- objectType: AnyObjectType;
547
- }
548
- interface NftDisplay {
549
- suggested: NftDisplaySuggested;
550
- other: NftDisplayOther;
551
- }
552
- interface NftDisplaySuggested {
553
- name?: string;
554
- link?: Url;
555
- imageUrl?: Url;
556
- description?: string;
557
- projectUrl?: Url;
558
- creator?: string;
559
- }
560
- type NftDisplayOther = Record<string, string>;
561
-
562
- /**
563
- * Represents the body payload sent to the dynamic gas service,
564
- * which includes the serialized transaction and any user-provided
565
- * gas configuration (e.g., coin type).
566
- */
567
- interface ApiDynamicGasBody {
568
- /**
569
- * The serialized transaction block in base64 or similar format.
570
- */
571
- serializedTx: SerializedTransaction;
572
- /**
573
- * The address of the user for whom the dynamic gas is being set.
574
- */
575
- walletAddress: SuiAddress;
576
- /**
577
- * The coin type to be used for gas payment (e.g., "0x2::sui::SUI").
578
- */
579
- gasCoinType: CoinType;
580
- }
581
- /**
582
- * Represents the response from the dynamic gas service, typically returning
583
- * updated transaction bytes and possibly a sponsored signature if the
584
- * transaction gas is being partially or fully sponsored.
585
- */
586
- interface ApiDynamicGasResponse {
587
- /**
588
- * The modified transaction bytes that incorporate a gas coin or sponsor information.
589
- */
590
- txBytes: SerializedTransaction;
591
- /**
592
- * A signature used to sponsor or verify the updated transaction, if applicable.
593
- */
594
- sponsoredSignature: string;
626
+ interface MoveErrorsInterface {
627
+ readonly moveErrors: MoveErrors;
595
628
  }
596
-
597
- type CoinGeckoChain = Lowercase<"Ethereum" | "Arbitrum" | "Bsc" | "Solana" | "Sui" | "Polygon" | "Avalanche" | "Optimism" | "Base">;
598
- type CoinGeckoCoinApiId = string;
599
- interface CoinGeckoCoinData {
600
- chain: CoinGeckoChain | "";
601
- apiId: CoinGeckoCoinApiId;
602
- name: string;
603
- symbol: CoinSymbol;
604
- coinType: CoinType;
629
+ type MoveErrors = Record<PackageId, Record<"ANY" | ModuleName, Record<MoveErrorCode, string>>>;
630
+ /** Parsed location of a Move abort, the output of `Helpers.parseMoveErrorMessage`. */
631
+ interface ParsedMoveError {
632
+ errorCode: MoveErrorCode;
633
+ packageId: ObjectId;
634
+ module: ModuleName;
605
635
  }
606
- interface CoinGeckoCoinSymbolData {
607
- apiId: CoinGeckoCoinApiId;
608
- name: string;
609
- symbol: CoinSymbol;
636
+ /** Parsed Move abort plus the human-readable message resolved from the registry. */
637
+ interface TranslatedMoveError extends ParsedMoveError {
638
+ error: string;
610
639
  }
611
640
 
612
641
  /**
@@ -1380,7 +1409,7 @@ type ApiFarmsTopUpStakingPoolRewardsBody = {
1380
1409
  /**
1381
1410
  * Request body for increasing the emissions for specified reward coins in a pool (owner only).
1382
1411
  */
1383
- type ApiFarmsIncreaseStakingPoolRewardsEmissionsBody = {
1412
+ interface ApiFarmsIncreaseStakingPoolRewardsEmissionsBody {
1384
1413
  ownerCapId: ObjectId;
1385
1414
  stakingPoolId: ObjectId;
1386
1415
  stakeCoinType: CoinType;
@@ -1390,7 +1419,7 @@ type ApiFarmsIncreaseStakingPoolRewardsEmissionsBody = {
1390
1419
  emissionRate: bigint;
1391
1420
  }[];
1392
1421
  walletAddress: SuiAddress;
1393
- };
1422
+ }
1394
1423
  /**
1395
1424
  * Request body for fetching staking pool owner caps owned by a user.
1396
1425
  */
@@ -1406,13 +1435,13 @@ interface ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody {
1406
1435
  /**
1407
1436
  * Request body for granting a one-time admin cap of a particular reward coin to another user.
1408
1437
  */
1409
- type ApiFarmsGrantOneTimeAdminCapBody = {
1438
+ interface ApiFarmsGrantOneTimeAdminCapBody {
1410
1439
  ownerCapId: ObjectId;
1411
1440
  recipientAddress: SuiAddress;
1412
1441
  rewardCoinType: CoinType;
1413
1442
  walletAddress: SuiAddress;
1414
1443
  isSponsoredTx?: boolean;
1415
- };
1444
+ }
1416
1445
 
1417
1446
  interface FaucetMintCoinEvent extends Event$1 {
1418
1447
  minter: SuiAddress;
@@ -2380,7 +2409,7 @@ type ApiPerpetualsAccountCollateralHistoryResponse = ApiPerpetualsHistoricalData
2380
2409
  * - Funding settlements
2381
2410
  * - Trading fees
2382
2411
  */
2383
- type PerpetualsAccountCollateralChange = {
2412
+ interface PerpetualsAccountCollateralChange {
2384
2413
  /** When the change occurred. */
2385
2414
  timestamp: Timestamp;
2386
2415
  /** Sui transaction digest that produced this change. */
@@ -2405,7 +2434,7 @@ type PerpetualsAccountCollateralChange = {
2405
2434
  } | {
2406
2435
  netFeesUsd: number;
2407
2436
  };
2408
- };
2437
+ }
2409
2438
  /**
2410
2439
  * Cursor-based response wrapping a list of orders for an account.
2411
2440
  */
@@ -2443,7 +2472,7 @@ interface PerpetualsAccountMarginHistoryData {
2443
2472
  /**
2444
2473
  * Individual order affecting an account.
2445
2474
  */
2446
- type PerpetualsAccountOrderHistoryData = {
2475
+ interface PerpetualsAccountOrderHistoryData {
2447
2476
  /** Timestamp of the order. */
2448
2477
  timestamp: Timestamp;
2449
2478
  /** Sui transaction digest. */
@@ -2480,7 +2509,7 @@ type PerpetualsAccountOrderHistoryData = {
2480
2509
  pnl?: number;
2481
2510
  /** Fees charged for this order event, if applicable. */
2482
2511
  fees?: number;
2483
- };
2512
+ }
2484
2513
  /**
2485
2514
  * Event emitted when collateral is deposited into an account.
2486
2515
  */
@@ -3671,13 +3700,13 @@ type ApiPerpetualsDepositCollateralBody = {
3671
3700
  /**
3672
3701
  * Request body for withdrawing collateral from an account.
3673
3702
  */
3674
- type ApiPerpetualsWithdrawCollateralBody = {
3703
+ interface ApiPerpetualsWithdrawCollateralBody {
3675
3704
  accountId: PerpetualsAccountId;
3676
3705
  withdrawAmount: Balance;
3677
3706
  recipientAddress?: SuiAddress;
3678
3707
  txKind?: SerializedTransaction;
3679
3708
  sponsor?: PerpetualsSponsorConfig;
3680
- };
3709
+ }
3681
3710
  /**
3682
3711
  * Response body for withdraw-collateral transactions.
3683
3712
  *
@@ -3778,7 +3807,7 @@ type ApiPerpetualsPlaceStopOrdersBody = {
3778
3807
  * SDK-level inputs for placing stop-loss / take-profit orders bound to a
3779
3808
  * specific market and position side.
3780
3809
  */
3781
- type SdkPerpetualsPlaceSlTpOrdersInputs = {
3810
+ interface SdkPerpetualsPlaceSlTpOrdersInputs {
3782
3811
  marketId: PerpetualsMarketId;
3783
3812
  /** Optional target size for SL/TP orders (scaled base units). */
3784
3813
  size?: bigint;
@@ -3796,7 +3825,7 @@ type SdkPerpetualsPlaceSlTpOrdersInputs = {
3796
3825
  isSponsoredTx?: boolean;
3797
3826
  /** Optional gas pool sponsorship configuration. */
3798
3827
  sponsor?: PerpetualsSponsorConfig;
3799
- };
3828
+ }
3800
3829
  /**
3801
3830
  * API request body for placing SL/TP orders bound to a position.
3802
3831
  */
@@ -3986,14 +4015,14 @@ type ApiPerpetualsScaleOrderBody = {
3986
4015
  /**
3987
4016
  * A single order to place as part of a cancel-and-place batch.
3988
4017
  */
3989
- type ApiPerpetualsOrderToPlace = {
4018
+ interface ApiPerpetualsOrderToPlace {
3990
4019
  /** Order side: `0` = bid (long), `1` = ask (short). */
3991
4020
  side: PerpetualsOrderSide;
3992
4021
  /** Limit price (scaled bigint). */
3993
4022
  price: bigint;
3994
4023
  /** Order size in scaled base units. */
3995
4024
  size: bigint;
3996
- };
4025
+ }
3997
4026
  /**
3998
4027
  * API request body for atomically canceling existing orders and placing
3999
4028
  * new ones in a single transaction.
@@ -4238,14 +4267,14 @@ interface ApiPerpetualsMarketsPricesResponse {
4238
4267
  * - **Method 2 (composed flow)**: Provide `deferred` with argument references
4239
4268
  * from a deferred `getCreateAccountTx` call.
4240
4269
  */
4241
- type ApiPerpetualsGrantAgentWalletTxBody = {
4270
+ interface ApiPerpetualsGrantAgentWalletTxBody {
4242
4271
  recipientAddress: SuiAddress;
4243
4272
  /** Perpetuals account ID (Method 1). */
4244
4273
  accountId?: PerpetualsAccountId;
4245
4274
  /** Composed PTB args from deferred create-account (Method 2). */
4246
4275
  deferred?: DeferredAccountArgs;
4247
4276
  txKind?: SerializedTransaction;
4248
- };
4277
+ }
4249
4278
  /**
4250
4279
  * Request body for revoking an Agent Wallet from a perpetuals account.
4251
4280
  *
@@ -4254,12 +4283,12 @@ type ApiPerpetualsGrantAgentWalletTxBody = {
4254
4283
  * The resulting on-chain transaction must be signed by the **account admin** wallet.
4255
4284
  * `accountCapId` is the object ID of the assistant capability to revoke.
4256
4285
  */
4257
- type ApiPerpetualsRevokeAgentWalletTxBody = {
4286
+ interface ApiPerpetualsRevokeAgentWalletTxBody {
4258
4287
  accountId: PerpetualsAccountId;
4259
4288
  accountCapId: ObjectId;
4260
4289
  txKind?: SerializedTransaction;
4261
- };
4262
- type ApiPerpetualsTransferCapTxBody = {
4290
+ }
4291
+ interface ApiPerpetualsTransferCapTxBody {
4263
4292
  /**
4264
4293
  * Recipient wallet address that should receive the capability object.
4265
4294
  *
@@ -4285,7 +4314,7 @@ type ApiPerpetualsTransferCapTxBody = {
4285
4314
  */
4286
4315
  txKind?: SerializedTransaction;
4287
4316
  sponsor?: PerpetualsSponsorConfig;
4288
- };
4317
+ }
4289
4318
  /**
4290
4319
  * Request body for sharing a Perpetuals account that was created with deferred sharing.
4291
4320
  *
@@ -6999,19 +7028,33 @@ interface ApiOwnedStakedSuiFrensBody {
6999
7028
  walletAddress: SuiAddress;
7000
7029
  }
7001
7030
 
7002
- type ResponseWithTxKind = {
7031
+ interface ResponseWithTxKind {
7003
7032
  txKind: SerializedTransaction;
7004
7033
  sponsorSignature?: string;
7005
- } & (Record<string, unknown> | {});
7034
+ }
7006
7035
  declare class Caller {
7007
- config: CallerConfig;
7008
- private readonly apiUrlPrefix;
7009
7036
  protected readonly apiBaseUrl?: Url;
7010
7037
  protected readonly apiEndpoint: Url;
7038
+ config: CallerConfig;
7039
+ private readonly apiUrlPrefix;
7011
7040
  constructor(config?: CallerConfig, apiUrlPrefix?: Url);
7012
7041
  private static fetchResponseToType;
7013
- private static apiBaseUrlForNetwork;
7014
- private urlForApiCall;
7042
+ private static readonly TRAILING_SLASHES_REGEX;
7043
+ private static readonly HTTP_PROTOCOL_REGEX;
7044
+ private static readonly NETWORK_API_BASE_URLS;
7045
+ private static readonly NETWORK_FULLNODE_URLS;
7046
+ /**
7047
+ * Resolves the canonical Aftermath API base URL for a given network.
7048
+ * To target a non-canonical host (custom deployment, local backend, etc.)
7049
+ * pass `baseUrl` on `CallerConfig` instead.
7050
+ */
7051
+ static apiBaseUrlForNetwork(network: SuiNetwork): Url;
7052
+ /**
7053
+ * Resolves the canonical Sui fullnode URL for a given network. Falls back
7054
+ * to the mainnet fullnode when `network` is undefined.
7055
+ */
7056
+ static defaultFullnodeUrl(network: SuiNetwork | undefined): Url;
7057
+ private readonly urlForApiCall;
7015
7058
  protected fetchApi<Output, BodyType = undefined>(url: Url, body?: BodyType, signal?: AbortSignal, options?: {
7016
7059
  disableBigIntJsonParsing?: boolean;
7017
7060
  }): Promise<Output>;
@@ -7194,8 +7237,7 @@ declare class Auth extends Caller {
7194
7237
  * @example
7195
7238
  * ```typescript
7196
7239
  *
7197
- * const afSdk = new Aftermath("MAINNET");
7198
- * await afSdk.init(); // initialize provider
7240
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
7199
7241
  *
7200
7242
  * const coin = afSdk.Coin("0x2::sui::SUI");
7201
7243
  *
@@ -7204,7 +7246,7 @@ declare class Auth extends Caller {
7204
7246
  */
7205
7247
  declare class Coin extends Caller {
7206
7248
  readonly coinType: CoinType | undefined;
7207
- readonly Provider?: AftermathApi | undefined;
7249
+ readonly api?: AftermathApi | undefined;
7208
7250
  /**
7209
7251
  * Static configuration and defaults for Sui coin types, including the standard
7210
7252
  * SUI coin type, default decimals, and coin object type path.
@@ -7264,9 +7306,9 @@ declare class Coin extends Caller {
7264
7306
  *
7265
7307
  * @param coinType - The coin's type string (e.g., "0x2::sui::SUI"). If omitted, methods that require a type will need it passed in manually.
7266
7308
  * @param config - Optional caller configuration (network, access token).
7267
- * @param Provider - An optional `AftermathApi` instance for coin-specific API calls.
7309
+ * @param api - An optional `AftermathApi` instance for coin-specific API calls.
7268
7310
  */
7269
- constructor(coinType?: CoinType | undefined, config?: CallerConfig, Provider?: AftermathApi | undefined);
7311
+ constructor(coinType?: CoinType | undefined, config?: CallerConfig, api?: AftermathApi | undefined);
7270
7312
  /**
7271
7313
  * Retrieves the decimals for multiple coins by calling the Aftermath API for metadata
7272
7314
  * and extracting the `decimals` property.
@@ -7495,11 +7537,6 @@ declare class Coin extends Caller {
7495
7537
  coinType: CoinType;
7496
7538
  coinSymbolToCoinTypes: CoinSymbolToCoinTypes;
7497
7539
  }) => CoinSymbol | undefined;
7498
- /**
7499
- * Internal method to retrieve a specialized coin-related API from `AftermathApi`.
7500
- * Throws an error if no provider is set.
7501
- */
7502
- private useProvider;
7503
7540
  }
7504
7541
 
7505
7542
  /**
@@ -7511,15 +7548,15 @@ declare class Coin extends Caller {
7511
7548
  */
7512
7549
  declare class FarmsStakingPool extends Caller {
7513
7550
  stakingPool: FarmsStakingPoolObject;
7514
- readonly Provider?: AftermathApi | undefined;
7551
+ readonly api?: AftermathApi | undefined;
7515
7552
  /**
7516
7553
  * Creates a `FarmsStakingPool` instance based on on-chain pool data.
7517
7554
  *
7518
7555
  * @param stakingPool - The on-chain data object describing the pool.
7519
7556
  * @param config - An optional `CallerConfig` for network settings.
7520
- * @param Provider - An optional `AftermathApi` for transaction building.
7557
+ * @param api - An optional `AftermathApi` for transaction building.
7521
7558
  */
7522
- constructor(stakingPool: FarmsStakingPoolObject, config?: CallerConfig, Provider?: AftermathApi | undefined);
7559
+ constructor(stakingPool: FarmsStakingPoolObject, config?: CallerConfig, api?: AftermathApi | undefined);
7523
7560
  /**
7524
7561
  * Fetches the total value locked (TVL) for this staking pool alone.
7525
7562
  *
@@ -7780,7 +7817,7 @@ declare class FarmsStakingPool extends Caller {
7780
7817
  /**
7781
7818
  * Provides access to the farm-specific provider methods for building transactions.
7782
7819
  */
7783
- private useProvider;
7820
+ private readonly farmsApi;
7784
7821
  }
7785
7822
 
7786
7823
  /**
@@ -7791,7 +7828,7 @@ declare class FarmsStakingPool extends Caller {
7791
7828
  */
7792
7829
  declare class FarmsStakedPosition extends Caller {
7793
7830
  stakedPosition: FarmsStakedPositionObject;
7794
- readonly Provider?: AftermathApi | undefined;
7831
+ readonly api?: AftermathApi | undefined;
7795
7832
  /**
7796
7833
  * The timestamp (in ms) when rewards were last harvested for this position, possibly overriding the
7797
7834
  * on-chain data if provided in the constructor.
@@ -7803,9 +7840,9 @@ declare class FarmsStakedPosition extends Caller {
7803
7840
  * @param stakedPosition - The on-chain data object representing the user's staked position.
7804
7841
  * @param trueLastHarvestRewardsTimestamp - Optionally overrides the last harvest time from the on-chain data.
7805
7842
  * @param config - Optional configuration for the underlying `Caller`.
7806
- * @param Provider - Optional `AftermathApi` instance for transaction building.
7843
+ * @param api - Optional `AftermathApi` instance for transaction building.
7807
7844
  */
7808
- constructor(stakedPosition: FarmsStakedPositionObject, trueLastHarvestRewardsTimestamp?: Timestamp | undefined, config?: CallerConfig, Provider?: AftermathApi | undefined);
7845
+ constructor(stakedPosition: FarmsStakedPositionObject, trueLastHarvestRewardsTimestamp?: Timestamp | undefined, config?: CallerConfig, api?: AftermathApi | undefined);
7809
7846
  /**
7810
7847
  * Returns the version of the farm system that this position belongs to (1 or 2).
7811
7848
  */
@@ -8001,11 +8038,11 @@ declare class FarmsStakedPosition extends Caller {
8001
8038
  * Determines if this position is unlocked based on the lock end timestamp, the emission end timestamp,
8002
8039
  * or a forced unlock condition in the pool.
8003
8040
  */
8004
- private isUnlocked;
8041
+ private readonly isUnlocked;
8005
8042
  /**
8006
8043
  * Provides access to the `Farms` provider in the `AftermathApi`.
8007
8044
  */
8008
- private useProvider;
8045
+ private readonly farmsApi;
8009
8046
  }
8010
8047
 
8011
8048
  /**
@@ -8016,7 +8053,7 @@ declare class FarmsStakedPosition extends Caller {
8016
8053
  * with the farming system.
8017
8054
  */
8018
8055
  declare class Farms extends Caller {
8019
- readonly Provider?: AftermathApi | undefined;
8056
+ readonly api?: AftermathApi | undefined;
8020
8057
  /**
8021
8058
  * Contains constants relevant to farming, including minimum rewards to claim
8022
8059
  * and maximum lock multipliers.
@@ -8036,9 +8073,9 @@ declare class Farms extends Caller {
8036
8073
  * farm-related transactions.
8037
8074
  *
8038
8075
  * @param config - Optional configuration, including network and access token.
8039
- * @param Provider - An optional `AftermathApi` instance for advanced transaction building.
8076
+ * @param api - An optional `AftermathApi` instance for advanced transaction building.
8040
8077
  */
8041
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
8078
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
8042
8079
  /**
8043
8080
  * Fetches a single staking pool by its `objectId` from the farm API/indexer.
8044
8081
  *
@@ -8220,81 +8257,219 @@ declare class Farms extends Caller {
8220
8257
  * Retrieves an instance of the `Farms` provider from the passed `AftermathApi`,
8221
8258
  * throwing an error if not available.
8222
8259
  */
8223
- private useProvider;
8260
+ private readonly farmsApi;
8224
8261
  }
8225
8262
 
8226
8263
  declare class Faucet extends Caller {
8227
- readonly Provider?: AftermathApi | undefined;
8264
+ readonly api?: AftermathApi | undefined;
8228
8265
  static readonly constants: {
8229
8266
  defaultRequestAmountUsd: number;
8230
8267
  };
8231
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
8268
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
8232
8269
  getSupportedCoins(): Promise<CoinType[]>;
8233
- getRequestCoinTransaction(inputs: ApiFaucetRequestBody): Promise<Transaction>;
8234
- getMintSuiFrenTransaction(inputs: ApiFaucetMintSuiFrenBody): Promise<Transaction>;
8235
- private useProvider;
8270
+ getRequestCoinTransaction(inputs: ApiFaucetRequestBody): Promise<_mysten_sui_transactions.Transaction>;
8271
+ getMintSuiFrenTransaction(inputs: ApiFaucetMintSuiFrenBody): Promise<_mysten_sui_transactions.Transaction>;
8272
+ private readonly faucetApi;
8236
8273
  }
8237
8274
 
8238
8275
  /**
8239
- * The `Pool` class encapsulates all the functionality needed to interact
8240
- * with a specific AMM pool on the Aftermath platform. It allows you to
8241
- * calculate trade amounts, deposit/withdraw amounts, fetch transactions,
8242
- * and retrieve on-chain statistics and event data.
8276
+ * The `GasPools` class provides methods for interacting with shared gas pool
8277
+ * endpoints on the Aftermath platform. This includes querying pool details
8278
+ * and building transactions for creating, depositing into, withdrawing from,
8279
+ * sponsoring, granting access to, and revoking access from gas pools.
8243
8280
  *
8244
8281
  * @example
8245
8282
  * ```typescript
8246
- * const afSdk = new Aftermath("MAINNET");
8247
- * await afSdk.init(); // initialize provider
8283
+ * const gasPools = new GasPools({ network: "MAINNET" });
8248
8284
  *
8249
- * const pools = afSdk.Pools();
8250
- * const pool = await pools.getPool({ objectId: "0x..." });
8285
+ * // Get gas pool details
8286
+ * const pool = await gasPools.getPool({
8287
+ * walletAddress: "0x..."
8288
+ * });
8251
8289
  *
8252
- * const stats = await pool.getStats();
8253
- * const tradeTx = await pool.getTradeTransaction({
8290
+ * // Build a deposit transaction
8291
+ * const { tx } = await gasPools.getDepositTx({
8254
8292
  * walletAddress: "0x...",
8255
- * coinInType: "0x2::sui::SUI",
8256
- * coinInAmount: BigInt(1e9),
8257
- * coinOutType: "0x<yourCoin>",
8258
- * slippage: 0.01,
8293
+ * depositAmount: 100_000_000n
8259
8294
  * });
8260
8295
  * ```
8261
8296
  */
8262
- declare class Pool extends Caller {
8263
- readonly pool: PoolObject;
8264
- readonly Provider?: AftermathApi | undefined;
8265
- /**
8266
- * Internal margin of error used in trade calculations to prevent
8267
- * exceeding maximum allowed percentages of pool balances.
8268
- */
8269
- private static readonly constants;
8270
- /**
8271
- * An optional cached object containing statistical data about the pool
8272
- * (volume, fees, APR, etc.).
8273
- */
8274
- stats: PoolStats | undefined;
8297
+ declare class GasPools extends Caller {
8298
+ readonly api?: AftermathApi | undefined;
8299
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
8275
8300
  /**
8276
- * Creates a new instance of the `Pool` class for on-chain interaction.
8301
+ * Fetches the gas pool details for a given wallet address.
8277
8302
  *
8278
- * @param pool - The fetched `PoolObject` from Aftermath API or on-chain query.
8279
- * @param config - Optional caller configuration (e.g., network, access token).
8280
- * @param Provider - An optional `AftermathApi` instance for advanced transaction usage.
8303
+ * @param inputs - {@link ApiGasPoolBody}
8304
+ * @returns {@link ApiGasPoolResponse} containing pool ID, balance, and whitelisted addresses.
8281
8305
  */
8282
- constructor(pool: PoolObject, config?: CallerConfig, Provider?: AftermathApi | undefined);
8306
+ getPool(inputs: ApiGasPoolBody): Promise<ApiGasPoolResponse>;
8283
8307
  /**
8284
- * Builds or fetches a deposit transaction to add liquidity to this pool.
8285
- * The resulting `Transaction` can be signed and submitted by the user.
8308
+ * Builds a transaction to create a new gas pool for the given wallet.
8286
8309
  *
8287
- * @param inputs - The deposit parameters including coin amounts, slippage, etc.
8288
- * @returns A `Transaction` to deposit funds into the pool.
8310
+ * When `deferShare` is `true`, the response includes `gasPoolArg` and
8311
+ * `sharePolicyArg` so you can compose additional commands (e.g. deposit,
8312
+ * grant) before calling {@link getShareTx} to finalize.
8289
8313
  *
8290
- * @example
8291
- * ```typescript
8292
- * const depositTx = await pool.getDepositTransaction({
8293
- * walletAddress: "0x...",
8294
- * amountsIn: { "0x<coin>": BigInt(1000000) },
8295
- * slippage: 0.01,
8296
- * });
8297
- * ```
8314
+ * @param inputs.walletAddress - Wallet address to create the gas pool for.
8315
+ * @param inputs.initialDepositAmount - Optional initial deposit amount in MIST.
8316
+ * @param inputs.deferShare - When true, returns args without sharing yet.
8317
+ * @param inputs.tx - Optional transaction to extend.
8318
+ * @returns `tx` plus optional `gasPoolArg` and `sharePolicyArg` when deferred.
8319
+ */
8320
+ getCreateTx(inputs: Omit<ApiGasPoolCreateBody, "txKind"> & {
8321
+ tx?: Transaction;
8322
+ }): Promise<Omit<ApiGasPoolCreateResponse, "txKind"> & {
8323
+ tx: Transaction;
8324
+ }>;
8325
+ /**
8326
+ * Builds a transaction to deposit into the gas pool.
8327
+ *
8328
+ * Supports SUI and non-SUI deposits. For non-SUI deposits, the input coin
8329
+ * is swapped into SUI via the Aftermath router before depositing.
8330
+ *
8331
+ * @param inputs.walletAddress - Wallet address submitting the deposit.
8332
+ * @param inputs.isSponsoredTx - Whether to build the transaction for sponsored gas. Defaults to false.
8333
+ * @param inputs.coinType - Coin type to deposit. Defaults to SUI.
8334
+ * @param inputs.amount - Amount to deposit (required when sourcing from wallet or for non-SUI).
8335
+ * @param inputs.coinArg - PTB coin argument to use as input (if omitted, sourced from wallet).
8336
+ * @param inputs.slippage - Slippage tolerance for non-SUI swaps (defaults to 0.01).
8337
+ * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
8338
+ * @param inputs.tx - Optional transaction to extend.
8339
+ * @returns {@link SdkTransactionResponse} with `tx`.
8340
+ */
8341
+ getDepositTx(inputs: Omit<ApiGasPoolDepositBody, "txKind"> & {
8342
+ tx?: Transaction;
8343
+ }): Promise<SdkTransactionResponse>;
8344
+ /**
8345
+ * Builds a transaction to withdraw SUI from the gas pool.
8346
+ *
8347
+ * When `deferTransfer` is `true`, the withdrawn coin is not transferred.
8348
+ * Instead, `withdrawnCoinArg` is returned for further PTB composition.
8349
+ *
8350
+ * @param inputs.walletAddress - Wallet address submitting the withdrawal.
8351
+ * @param inputs.amount - Amount of SUI to withdraw in MIST.
8352
+ * @param inputs.recipientAddress - Optional recipient (defaults to `walletAddress`).
8353
+ * @param inputs.deferTransfer - When true, returns the withdrawn coin arg instead of transferring.
8354
+ * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
8355
+ * @param inputs.tx - Optional transaction to extend.
8356
+ * @returns `tx` plus optional `withdrawnCoinArg` when deferred.
8357
+ */
8358
+ getWithdrawTx(inputs: Omit<ApiGasPoolWithdrawBody, "txKind"> & {
8359
+ tx?: Transaction;
8360
+ }): Promise<Omit<ApiGasPoolWithdrawResponse, "txKind"> & {
8361
+ tx: Transaction;
8362
+ }>;
8363
+ /**
8364
+ * Builds a transaction to sponsor (rebate) the transaction sender
8365
+ * using SUI from the gas pool.
8366
+ *
8367
+ * @param inputs.walletAddress - Wallet address submitting the sponsor transaction.
8368
+ * @param inputs.amount - Amount of SUI to rebate in MIST.
8369
+ * @param inputs.tx - Optional transaction to extend.
8370
+ * @returns {@link SdkTransactionResponse} with `tx`.
8371
+ */
8372
+ getSponsorTx(inputs: Omit<ApiGasPoolSponsorBody, "txKind"> & {
8373
+ tx?: Transaction;
8374
+ }): Promise<SdkTransactionResponse>;
8375
+ /**
8376
+ * Builds a transaction to grant another wallet access to the gas pool.
8377
+ *
8378
+ * @param inputs.walletAddress - Owner wallet address.
8379
+ * @param inputs.targetWalletAddress - Wallet address to grant access to.
8380
+ * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
8381
+ * @param inputs.tx - Optional transaction to extend.
8382
+ * @returns {@link SdkTransactionResponse} with `tx`.
8383
+ */
8384
+ getGrantTx(inputs: Omit<ApiGasPoolGrantBody, "txKind"> & {
8385
+ tx?: Transaction;
8386
+ }): Promise<SdkTransactionResponse>;
8387
+ /**
8388
+ * Builds a transaction to revoke another wallet's access to the gas pool.
8389
+ *
8390
+ * @param inputs.walletAddress - Owner wallet address.
8391
+ * @param inputs.targetWalletAddress - Wallet address to revoke access from.
8392
+ * @param inputs.tx - Optional transaction to extend.
8393
+ * @returns {@link SdkTransactionResponse} with `tx`.
8394
+ */
8395
+ getRevokeTx(inputs: Omit<ApiGasPoolRevokeBody, "txKind"> & {
8396
+ tx?: Transaction;
8397
+ }): Promise<SdkTransactionResponse>;
8398
+ /**
8399
+ * Builds a transaction to share a gas pool that was created with `deferShare: true`.
8400
+ *
8401
+ * Use this after composing additional commands (deposit, grant, etc.) with
8402
+ * the `gasPoolArg` returned by {@link getCreateTx}.
8403
+ *
8404
+ * @param inputs.gasPoolArg - Gas pool argument from a deferred create.
8405
+ * @param inputs.sharePolicyArg - Share policy argument from a deferred create.
8406
+ * @param inputs.tx - Optional transaction to extend.
8407
+ * @returns {@link SdkTransactionResponse} with `tx`.
8408
+ */
8409
+ getShareTx(inputs: Omit<ApiGasPoolShareBody, "txKind"> & {
8410
+ tx?: Transaction;
8411
+ }): Promise<SdkTransactionResponse>;
8412
+ }
8413
+
8414
+ /**
8415
+ * The `Pool` class encapsulates all the functionality needed to interact
8416
+ * with a specific AMM pool on the Aftermath platform. It allows you to
8417
+ * calculate trade amounts, deposit/withdraw amounts, fetch transactions,
8418
+ * and retrieve on-chain statistics and event data.
8419
+ *
8420
+ * @example
8421
+ * ```typescript
8422
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
8423
+ *
8424
+ * const pools = afSdk.Pools();
8425
+ * const pool = await pools.getPool({ objectId: "0x..." });
8426
+ *
8427
+ * const stats = await pool.getStats();
8428
+ * const tradeTx = await pool.getTradeTransaction({
8429
+ * walletAddress: "0x...",
8430
+ * coinInType: "0x2::sui::SUI",
8431
+ * coinInAmount: BigInt(1e9),
8432
+ * coinOutType: "0x<yourCoin>",
8433
+ * slippage: 0.01,
8434
+ * });
8435
+ * ```
8436
+ */
8437
+ declare class Pool extends Caller {
8438
+ readonly pool: PoolObject;
8439
+ readonly api?: AftermathApi | undefined;
8440
+ /**
8441
+ * Internal margin of error used in trade calculations to prevent
8442
+ * exceeding maximum allowed percentages of pool balances.
8443
+ */
8444
+ private static readonly constants;
8445
+ /**
8446
+ * An optional cached object containing statistical data about the pool
8447
+ * (volume, fees, APR, etc.).
8448
+ */
8449
+ stats: PoolStats | undefined;
8450
+ /**
8451
+ * Creates a new instance of the `Pool` class for on-chain interaction.
8452
+ *
8453
+ * @param pool - The fetched `PoolObject` from Aftermath API or on-chain query.
8454
+ * @param config - Optional caller configuration (e.g., network, access token).
8455
+ * @param api - An optional `AftermathApi` instance for advanced transaction usage.
8456
+ */
8457
+ constructor(pool: PoolObject, config?: CallerConfig, api?: AftermathApi | undefined);
8458
+ /**
8459
+ * Builds or fetches a deposit transaction to add liquidity to this pool.
8460
+ * The resulting `Transaction` can be signed and submitted by the user.
8461
+ *
8462
+ * @param inputs - The deposit parameters including coin amounts, slippage, etc.
8463
+ * @returns A `Transaction` to deposit funds into the pool.
8464
+ *
8465
+ * @example
8466
+ * ```typescript
8467
+ * const depositTx = await pool.getDepositTransaction({
8468
+ * walletAddress: "0x...",
8469
+ * amountsIn: { "0x<coin>": BigInt(1000000) },
8470
+ * slippage: 0.01,
8471
+ * });
8472
+ * ```
8298
8473
  */
8299
8474
  getDepositTransaction(inputs: ApiPoolDepositBody): Promise<Transaction>;
8300
8475
  /**
@@ -8674,7 +8849,7 @@ declare class Pool extends Caller {
8674
8849
  * @param inputs - Contains `amount` as a bigint.
8675
8850
  * @returns The post-fee amount as a bigint.
8676
8851
  */
8677
- private getAmountWithDAOFee;
8852
+ private readonly getAmountWithDAOFee;
8678
8853
  /**
8679
8854
  * The inverse operation of `getAmountWithDAOFee`, used in internal calculations
8680
8855
  * when we need to back out how much input was needed prior to the fee cut.
@@ -8682,12 +8857,12 @@ declare class Pool extends Caller {
8682
8857
  * @param inputs - Contains `amount` as a bigint.
8683
8858
  * @returns The pre-fee amount as a bigint.
8684
8859
  */
8685
- private getAmountWithoutDAOFee;
8860
+ private readonly getAmountWithoutDAOFee;
8686
8861
  /**
8687
8862
  * Provides an instance of the Pools provider from `AftermathApi`.
8688
8863
  * Throws an error if not defined.
8689
8864
  */
8690
- private useProvider;
8865
+ private readonly poolsApi;
8691
8866
  }
8692
8867
 
8693
8868
  /**
@@ -8698,8 +8873,7 @@ declare class Pool extends Caller {
8698
8873
  *
8699
8874
  * @example
8700
8875
  * ```typescript
8701
- * const afSdk = new Aftermath("MAINNET");
8702
- * await afSdk.init(); // initialize provider
8876
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
8703
8877
  *
8704
8878
  * const pools = afSdk.Pools();
8705
8879
  *
@@ -8711,7 +8885,7 @@ declare class Pool extends Caller {
8711
8885
  * ```
8712
8886
  */
8713
8887
  declare class Pools extends Caller {
8714
- readonly Provider?: AftermathApi | undefined;
8888
+ readonly api?: AftermathApi | undefined;
8715
8889
  /**
8716
8890
  * Static constants relevant to the pool logic, such as protocol fees,
8717
8891
  * referral percentages, and bounds for trading/withdrawal percentages.
@@ -8801,9 +8975,9 @@ declare class Pools extends Caller {
8801
8975
  * Creates a new `Pools` instance for querying and managing AMM pools on Aftermath.
8802
8976
  *
8803
8977
  * @param config - Optional configuration object specifying network or access token.
8804
- * @param Provider - An optional `AftermathApi` instance providing advanced transaction building.
8978
+ * @param api - An optional `AftermathApi` instance providing advanced transaction building.
8805
8979
  */
8806
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
8980
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
8807
8981
  /**
8808
8982
  * Fetches a single pool by its on-chain `objectId` and returns a new `Pool` instance.
8809
8983
  *
@@ -9088,15 +9262,14 @@ declare class Pools extends Caller {
9088
9262
  * Provides a typed reference to the `Pools` part of the `AftermathApi`,
9089
9263
  * throwing an error if not defined.
9090
9264
  */
9091
- private useProvider;
9265
+ private readonly poolsApi;
9092
9266
  }
9093
9267
 
9094
9268
  declare class NftAmmMarket extends Caller {
9095
9269
  readonly market: NftAmmMarketObject;
9096
- private readonly Provider?;
9097
- private static readonly constants;
9270
+ private readonly api?;
9098
9271
  pool: Pool;
9099
- constructor(market: NftAmmMarketObject, config?: CallerConfig, Provider?: AftermathApi | undefined);
9272
+ constructor(market: NftAmmMarketObject, config?: CallerConfig, api?: AftermathApi | undefined);
9100
9273
  getNfts(inputs: {
9101
9274
  cursor?: ObjectId;
9102
9275
  limit?: number;
@@ -9137,13 +9310,13 @@ declare class NftAmmMarket extends Caller {
9137
9310
  lpCoinAmount: Balance;
9138
9311
  referral?: boolean;
9139
9312
  }) => bigint;
9140
- private useProvider;
9313
+ private readonly nftAmmApi;
9141
9314
  }
9142
9315
 
9143
9316
  declare class NftAmm extends Caller {
9144
- readonly Provider?: AftermathApi | undefined;
9317
+ readonly api?: AftermathApi | undefined;
9145
9318
  static readonly constants: {};
9146
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
9319
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
9147
9320
  getMarket(inputs: {
9148
9321
  objectId: ObjectId;
9149
9322
  }): Promise<NftAmmMarket>;
@@ -9151,1216 +9324,1203 @@ declare class NftAmm extends Caller {
9151
9324
  objectIds: ObjectId[];
9152
9325
  }): Promise<NftAmmMarket[]>;
9153
9326
  getAllMarkets(): Promise<NftAmmMarket[]>;
9154
- private useProvider;
9155
9327
  }
9156
9328
 
9157
9329
  /**
9158
- * High-level wrapper around a single perpetuals market.
9330
+ * Note on “refreshing” account state:
9159
9331
  *
9160
- * This class provides:
9332
+ * This class is a thin wrapper around a snapshot of {@link PerpetualsAccountObject}
9333
+ * that is typically fetched via {@link Perpetuals.getAccount}. The transaction builders
9334
+ * use the current snapshot to derive fields like `hasPosition` and to construct
9335
+ * SL/TP helpers that depend on the position side.
9161
9336
  *
9162
- * - Lightweight accessors for immutable market properties:
9163
- * - `marketId`, `indexPrice`, `collateralPrice`, `collateralCoinType`
9164
- * - `marketParams`, `marketState`
9165
- * - Read endpoints for:
9166
- * - Orderbook snapshots
9167
- * - 24h stats and order history
9168
- * - Market prices and derived funding metrics
9169
- * - Helpers for:
9170
- * - Order sizing (max size, lot/tick rounding)
9171
- * - Margin and collateral calculations
9172
- * - Constructing an “empty” position for a market
9337
+ * If your app is long-lived, you may want to periodically re-fetch the account
9338
+ * (and recreate this wrapper) to avoid stale local position/order state. For example:
9339
+ * - After placing/canceling orders
9340
+ * - After fills/liquidations/funding settlements
9341
+ * - After switching markets or wallets
9342
+ */
9343
+ /**
9344
+ * High-level wrapper around a single Perpetuals account or vault account.
9173
9345
  *
9174
- * Typical usage:
9346
+ * This class encapsulates:
9347
+ *
9348
+ * - Transaction builders for:
9349
+ * - Collateral actions (deposit, withdraw, allocate, deallocate, transfer)
9350
+ * - Orders (market/limit, cancel, stop orders, SL/TP, set leverage)
9351
+ * - Read-only account helpers:
9352
+ * - Stop-order message signing
9353
+ * - Order & stop-order metadata
9354
+ * - Collateral & trade history
9355
+ * - Convenience helpers to:
9356
+ * - Fetch and categorize SL/TP stop orders
9357
+ * - Resolve account/vault identifiers and owner addresses
9358
+ *
9359
+ * You typically do not construct `PerpetualsAccount` directly. Instead, use
9360
+ * {@link Perpetuals.getAccount} or {@link Perpetuals.getAccounts}, which
9361
+ * fetch all required on-chain data and wrap it for you:
9175
9362
  *
9176
9363
  * ```ts
9177
- * const perps = new Perpetuals(config);
9178
- * const { markets } = await perps.getMarkets({ marketIds: ["0x..."] });
9179
- * const market = markets[0];
9364
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
9180
9365
  *
9181
- * const { orderbook } = await market.getOrderbook();
9182
- * const stats = await market.get24hrStats();
9183
- * const { basePrice, collateralPrice } = await market.getPrices();
9366
+ * const perps = afSdk.Perpetuals();
9367
+ * const [accountCap] = await perps.getOwnedAccountCaps({
9368
+ * walletAddress: "0x...",
9369
+ * });
9370
+ *
9371
+ * const account = await perps.getAccount({ accountCap });
9372
+ *
9373
+ * // Build a deposit transaction
9374
+ * const depositTx = await account.getDepositCollateralTx({
9375
+ * depositAmount: BigInt("1000000000"),
9376
+ * });
9184
9377
  * ```
9185
9378
  */
9186
- declare class PerpetualsMarket extends Caller {
9187
- marketData: PerpetualsMarketData;
9188
- readonly Provider?: AftermathApi | undefined;
9189
- /** Unique identifier for this perpetuals market (object ID on chain). */
9190
- readonly marketId: PerpetualsMarketId;
9379
+ declare class PerpetualsAccount extends Caller {
9380
+ readonly account: PerpetualsAccountObject;
9381
+ readonly accountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap;
9382
+ readonly api?: AftermathApi | undefined;
9191
9383
  /**
9192
- * Current oracle/index price for the market's underlying asset, quoted in
9193
- * the index unit (typically USD).
9384
+ * If this account is backed by a vault, this holds the vault object ID.
9385
+ * Otherwise, `undefined` for "direct" user accounts.
9386
+ *
9387
+ * This is used primarily to route requests to either:
9388
+ * - `/perpetuals/account/...` endpoints, or
9389
+ * - `/perpetuals/vault/...` endpoints.
9194
9390
  */
9195
- readonly indexPrice: number;
9391
+ private readonly vaultId;
9196
9392
  /**
9197
- * Current price of the collateral asset in USD (or the platform's base
9198
- * pricing unit).
9393
+ * Create a new {@link PerpetualsAccount} wrapper.
9394
+ *
9395
+ * @param account - Raw account object with positions and equity data.
9396
+ * @param accountCap - Account cap or partial vault cap object containing
9397
+ * ownership and collateral metadata.
9398
+ * @param config - Optional {@link CallerConfig} (network, auth, etc.).
9399
+ * @param api - Optional shared {@link AftermathApi} provider instance
9400
+ * used to derive serialized transaction kinds (`txKind`) from
9401
+ * {@link Transaction} objects.
9199
9402
  */
9200
- readonly collateralPrice: number;
9201
- /** Sui type of the collateral coin (e.g. `"0x2::sui::SUI"`). */
9202
- readonly collateralCoinType: CoinType;
9203
- /** Static market configuration parameters (lot size, tick size, margins, etc.). */
9204
- readonly marketParams: PerpetualsMarketParams;
9205
- /** Dynamic market state (funding rates, open interest, etc.). */
9206
- readonly marketState: PerpetualsMarketState;
9403
+ constructor(account: PerpetualsAccountObject, accountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap, config?: CallerConfig, api?: AftermathApi | undefined);
9207
9404
  /**
9208
- * Create a new {@link PerpetualsMarket} wrapper from raw market data.
9209
- *
9210
- * @param marketData - Snapshot of market configuration and state.
9211
- * @param config - Optional {@link CallerConfig} (network, base URL, etc.).
9212
- * @param Provider - Optional shared {@link AftermathApi} provider instance.
9405
+ * Build a `deposit-collateral` transaction for this account.
9213
9406
  *
9214
- * @remarks
9215
- * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
9216
- * all HTTP requests resolve under `/perpetuals/...`.
9217
- */
9218
- constructor(marketData: PerpetualsMarketData, config?: CallerConfig, Provider?: AftermathApi | undefined);
9219
- /**
9220
- * Fetch the 24-hour volume and price change statistics for this market.
9221
- *
9222
- * Under the hood, this calls {@link Perpetuals.getMarkets24hrStats} and
9223
- * returns the first (and only) entry.
9407
+ * For non-vault accounts, this endpoint constructs a transaction that:
9408
+ * - Optionally extends an existing {@link Transaction}, and
9409
+ * - Deposits collateral into the Perpetuals account.
9224
9410
  *
9225
- * @returns {@link PerpetualsMarket24hrStats}.
9411
+ * **Note:** Vault accounts are currently not supported and will throw.
9226
9412
  *
9227
- * @remarks
9228
- * This method creates a new {@link Perpetuals} instance using `this.config`.
9229
- * If you need shared Provider behavior, prefer calling `perps.getMarkets24hrStats`
9230
- * directly with the same Provider you initialized.
9231
- */
9232
- get24hrStats(): Promise<PerpetualsMarket24hrStats>;
9233
- /**
9234
- * Fetch the full orderbook snapshot for this market.
9413
+ * @param inputs.tx - Optional existing transaction to extend. If omitted,
9414
+ * a new {@link Transaction} is created under the hood.
9415
+ * @param inputs.isSponsoredTx - Optional flag indicating whether the
9416
+ * transaction is gas-sponsored.
9417
+ * @param inputs.depositAmount - Amount of collateral to deposit, if paying
9418
+ * directly from the wallet.
9419
+ * @param inputs.depositCoinArg - Transaction object argument referencing a
9420
+ * coin to deposit (mutually exclusive with `depositAmount`).
9235
9421
  *
9236
- * @returns Object containing `orderbook`.
9422
+ * @returns Transaction response containing a `tx`.
9237
9423
  *
9238
9424
  * @example
9239
9425
  * ```ts
9240
- * const { orderbook } = await market.getOrderbook();
9241
- * console.log(orderbook.bids[0], orderbook.asks[0]);
9426
+ * const { tx } = await account.getDepositCollateralTx({
9427
+ * depositAmount: BigInt("1000000000"),
9428
+ * });
9242
9429
  * ```
9243
9430
  */
9244
- getOrderbook(): Promise<{
9245
- orderbook: PerpetualsOrderbook;
9431
+ getDepositCollateralTx(inputs: {
9432
+ tx?: Transaction;
9433
+ isSponsoredTx?: boolean;
9434
+ sponsor?: PerpetualsSponsorConfig;
9435
+ } & ({
9436
+ depositAmount: Balance;
9437
+ } | {
9438
+ depositCoinArg: TransactionObjectArgument;
9439
+ })): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9440
+ tx: Transaction;
9246
9441
  }>;
9247
9442
  /**
9248
- * Compute the maximum order size that can be placed by a given account
9249
- * in this market, under optional leverage and price assumptions.
9443
+ * Build a `withdraw-collateral` transaction for this account.
9250
9444
  *
9251
- * This is a common frontend helper for:
9252
- * - "max size" buttons
9253
- * - input validation against risk limits
9445
+ * For non-vault accounts, this endpoint constructs a transaction to:
9446
+ * - Withdraw collateral from the Perpetuals account, and
9447
+ * - Optionally transfer it to a `recipientAddress` (otherwise coin is left
9448
+ * as a transaction argument).
9254
9449
  *
9255
- * **Note:** This is routed through the `account` namespace because it depends on
9256
- * the account's collateral and positions.
9450
+ * **Note:** Vault accounts are currently not supported and will throw.
9257
9451
  *
9258
- * @param inputs.accountId - Perpetuals account ID.
9259
- * @param inputs.side - Order side (Bid/Ask).
9260
- * @param inputs.leverage - Optional assumed leverage.
9261
- * @param inputs.price - Optional assumed price (e.g. for limit orders).
9452
+ * @param inputs.withdrawAmount - Amount of collateral to withdraw.
9453
+ * @param inputs.recipientAddress - Optional address to receive the withdrawn
9454
+ * coins directly.
9455
+ * @param inputs.tx - Optional transaction to extend (defaults to new `Transaction()`).
9262
9456
  *
9263
- * @returns `{ maxOrderSize }` in base units (scaled integer as `bigint`).
9457
+ * @returns A response containing `tx` and the `coinOutArg` where the
9458
+ * withdrawn coins end up if `recipientAddress` is not used.
9264
9459
  *
9265
9460
  * @example
9266
9461
  * ```ts
9267
- * const { maxOrderSize } = await market.getMaxOrderSize({
9268
- * accountId: 123n,
9269
- * side: PerpetualsOrderSide.Bid,
9270
- * leverage: 5,
9462
+ * const { tx, coinOutArg } = await account.getWithdrawCollateralTx({
9463
+ * withdrawAmount: BigInt("1000000000"),
9271
9464
  * });
9272
9465
  * ```
9273
9466
  */
9274
- getMaxOrderSize: (inputs: Omit<ApiPerpetualsMaxOrderSizeBody, "marketId">) => Promise<{
9275
- maxOrderSize: bigint;
9467
+ getWithdrawCollateralTx(inputs: {
9468
+ withdrawAmount: Balance;
9469
+ recipientAddress?: SuiAddress;
9470
+ sponsor?: PerpetualsSponsorConfig;
9471
+ tx?: Transaction;
9472
+ }): Promise<Omit<ApiPerpetualsWithdrawCollateralResponse, "txKind"> & {
9473
+ tx: Transaction;
9276
9474
  }>;
9277
9475
  /**
9278
- * Market-level preview of placing a market order.
9476
+ * Build an `allocate-collateral` transaction, moving collateral from this
9477
+ * account into a specific market (clearing house).
9279
9478
  *
9280
- * Unlike {@link PerpetualsAccount.getPlaceMarketOrderPreview}, this version:
9281
- * - Calls `account/previews/place-market-order`
9282
- * - Explicitly sets `accountId: undefined`, allowing a “generic” preview that
9283
- * doesn’t rely on a specific account’s on-chain positions/collateral.
9479
+ * Works for both account-backed and vault-backed accounts.
9284
9480
  *
9285
- * @param inputs - {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
9286
- * @param abortSignal - Optional abort signal to cancel the request.
9481
+ * @param inputs.marketId - Market to allocate collateral to.
9482
+ * @param inputs.allocateAmount - Amount of collateral to allocate.
9483
+ * @param inputs.tx - Optional transaction to extend.
9287
9484
  *
9288
- * @returns Either `{ error }` or a preview containing the simulated updated position,
9289
- * slippage, filled/posted sizes, collateral change, and execution price.
9485
+ * @returns Transaction response containing a `tx`.
9290
9486
  */
9291
- getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9487
+ getAllocateCollateralTx(inputs: {
9488
+ marketId: PerpetualsMarketId;
9489
+ allocateAmount: Balance;
9490
+ sponsor?: PerpetualsSponsorConfig;
9491
+ tx?: Transaction;
9492
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9493
+ tx: Transaction;
9494
+ }>;
9292
9495
  /**
9293
- * Market-level preview of placing a limit order.
9496
+ * Build a `deallocate-collateral` transaction, moving collateral from a
9497
+ * specific market back to this account.
9294
9498
  *
9295
- * Similar to {@link getPlaceMarketOrderPreview}, this uses:
9296
- * - `account/previews/place-limit-order`
9297
- * - `accountId: undefined`
9499
+ * Works for both account-backed and vault-backed accounts.
9298
9500
  *
9299
- * @param inputs - {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
9300
- * @param abortSignal - Optional abort signal to cancel the request.
9501
+ * @param inputs.marketId - Market to deallocate collateral from.
9502
+ * @param inputs.deallocateAmount - Amount of collateral to deallocate.
9503
+ * @param inputs.tx - Optional transaction to extend.
9301
9504
  *
9302
- * @returns Either `{ error }` or a preview describing the simulated post-order state.
9505
+ * @returns Transaction response containing a `tx`.
9303
9506
  */
9304
- getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9507
+ getDeallocateCollateralTx(inputs: {
9508
+ marketId: PerpetualsMarketId;
9509
+ deallocateAmount: Balance;
9510
+ sponsor?: PerpetualsSponsorConfig;
9511
+ tx?: Transaction;
9512
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9513
+ tx: Transaction;
9514
+ }>;
9305
9515
  /**
9306
- * Market-level preview of placing a scale order.
9516
+ * Build a `transfer-collateral` transaction between two Perpetuals accounts.
9307
9517
  *
9308
- * Similar to {@link getPlaceLimitOrderPreview}, this uses:
9309
- * - `account/previews/place-scale-order`
9310
- * - `accountId: undefined`
9518
+ * Only supported for direct accounts, **not** vault-backed accounts.
9311
9519
  *
9312
- * @param inputs - {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
9313
- * @param abortSignal - Optional abort signal to cancel the request.
9520
+ * @param inputs.transferAmount - Amount of collateral to transfer.
9521
+ * @param inputs.toAccountId - Destination account ID.
9522
+ * @param inputs.tx - Optional transaction to extend.
9314
9523
  *
9315
- * @returns Either `{ error }` or a preview describing the simulated post-order state.
9524
+ * @returns Transaction response containing a `tx`.
9316
9525
  */
9317
- getPlaceScaleOrderPreview(inputs: SdkPerpetualsPlaceScaleOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9526
+ getTransferCollateralTx(inputs: {
9527
+ transferAmount: Balance;
9528
+ toAccountId: PerpetualsAccountId;
9529
+ toAccountCapId?: ObjectId;
9530
+ sponsor?: PerpetualsSponsorConfig;
9531
+ tx?: Transaction;
9532
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9533
+ tx: Transaction;
9534
+ }>;
9318
9535
  /**
9319
- * Fetch paginated order history for this market.
9536
+ * Build a `place-market-order` transaction for this account.
9320
9537
  *
9321
- * This is market-wide (public) history, not scoped to any account.
9538
+ * This is the primary entrypoint for opening/closing positions via market orders.
9539
+ * It automatically:
9540
+ * - Injects the account/vault identity into the payload.
9541
+ * - Derives `hasPosition` based on the current account state for the given market.
9542
+ * - Optionally attaches SL/TP stop orders via the `slTp` input.
9322
9543
  *
9323
- * @param inputs.beforeTimestampCursor - Optional pagination cursor.
9324
- * @param inputs.limit - Optional page size.
9544
+ * Important behavioral notes:
9545
+ * - `hasPosition` is derived from the local {@link PerpetualsAccountObject} snapshot.
9546
+ * If the snapshot is stale, consider re-fetching the account first.
9547
+ * - For vault-backed accounts, the API routes to `/perpetuals/vault/...` and uses
9548
+ * `vaultId` as the identity discriminator. For direct accounts, it uses `accountId`.
9325
9549
  *
9326
- * @returns {@link ApiPerpetualsMarketOrderHistoryResponse} containing:
9327
- * - `orders`
9328
- * - `nextBeforeTimestampCursor`
9550
+ * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderInputs} for details.
9551
+ * Notably:
9552
+ * - `marketId`, `side`, `size`, `collateralChange`, `reduceOnly`
9553
+ * - Optional `leverage`
9554
+ * - Optional `slTp` params
9555
+ * - Optional `tx` to extend
9556
+ *
9557
+ * @returns Transaction response containing `tx`.
9558
+ *
9559
+ * @example
9560
+ * ```ts
9561
+ * const { tx } = await account.getPlaceMarketOrderTx({
9562
+ * marketId: "0x...",
9563
+ * side: PerpetualsOrderSide.Bid,
9564
+ * size: BigInt("1000000000"),
9565
+ * collateralChange: 10,
9566
+ * reduceOnly: false,
9567
+ * });
9568
+ * ```
9329
9569
  */
9330
- getOrderHistory(inputs: Omit<ApiPerpetualsMarketOrderHistoryBody, "marketId">): Promise<ApiPerpetualsMarketOrderHistoryResponse>;
9570
+ getPlaceMarketOrderTx(inputs: SdkPerpetualsPlaceMarketOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9571
+ tx: Transaction;
9572
+ }>;
9331
9573
  /**
9332
- * Fetch the current prices for this market.
9574
+ * Build a `place-limit-order` transaction for this account.
9333
9575
  *
9334
- * Internally calls {@link Perpetuals.getPrices} and returns the first result.
9576
+ * Similar to {@link getPlaceMarketOrderTx}, but uses limit order semantics:
9577
+ * - Requires `price` and `orderType`.
9578
+ * - Supports reduce-only flags, expiry, optional leverage, and SL/TP stop orders.
9335
9579
  *
9336
- * @returns `{ marketId, basePrice, collateralPrice, midPrice, markPrice }`.
9580
+ * Notes:
9581
+ * - `hasPosition` is derived from local account state; refresh the account if needed.
9582
+ * - This method does not validate tick/lot sizing locally; the API/on-chain
9583
+ * will enforce market constraints.
9337
9584
  *
9338
- * @remarks
9339
- * This method instantiates a new {@link Perpetuals} client using `this.config`.
9340
- * If you rely on a shared Provider, call `perps.getPrices(...)` directly instead.
9585
+ * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderInputs}.
9586
+ *
9587
+ * @returns Transaction response containing `tx`.
9341
9588
  */
9342
- getPrices(): Promise<{
9343
- marketId: PerpetualsMarketId;
9344
- basePrice: number;
9345
- collateralPrice: number;
9346
- midPrice: number | undefined;
9347
- markPrice: number;
9589
+ getPlaceLimitOrderTx(inputs: SdkPerpetualsPlaceLimitOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9590
+ tx: Transaction;
9348
9591
  }>;
9349
9592
  /**
9350
- * Compute the remaining time until the next funding event, in milliseconds.
9593
+ * Build a `place-scale-order` transaction for this account.
9351
9594
  *
9352
- * @returns `nextFundingTimeMs() - Date.now()`.
9595
+ * A scale order distributes a total size across multiple limit orders
9596
+ * evenly spaced between a start and end price. An optional `sizeSkew`
9597
+ * parameter controls whether the distribution is uniform or weighted.
9353
9598
  *
9354
- * @remarks
9355
- * If the next funding timestamp does not fit safely into a JS `number`,
9356
- * {@link nextFundingTimeMs} returns `Number.MAX_SAFE_INTEGER`, and the
9357
- * difference may be very large.
9599
+ * @param inputs - See {@link SdkPerpetualsPlaceScaleOrderInputs}.
9600
+ *
9601
+ * @returns Transaction response containing `tx`.
9358
9602
  */
9359
- timeUntilNextFundingMs: () => Timestamp;
9603
+ getPlaceScaleOrderTx(inputs: SdkPerpetualsPlaceScaleOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9604
+ tx: Transaction;
9605
+ }>;
9360
9606
  /**
9361
- * Get the scheduled timestamp for the next funding event, in milliseconds.
9607
+ * Build a `cancel-and-place-orders` transaction for this account.
9362
9608
  *
9363
- * Safety behavior:
9364
- * - If `marketData.nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,
9365
- * this returns `Number.MAX_SAFE_INTEGER`.
9609
+ * Atomically cancels existing orders and places new ones in a single
9610
+ * transaction. Useful for rebalancing order grids or replacing stale
9611
+ * orders without intermediate exposure.
9366
9612
  *
9367
- * @returns Next funding timestamp (ms) as a JS `number`.
9613
+ * @param inputs - See {@link SdkPerpetualsCancelAndPlaceOrdersInputs}.
9614
+ *
9615
+ * @returns Transaction response containing `tx`.
9368
9616
  */
9369
- nextFundingTimeMs: () => Timestamp;
9617
+ getCancelAndPlaceOrdersTx(inputs: SdkPerpetualsCancelAndPlaceOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9618
+ tx: Transaction;
9619
+ }>;
9370
9620
  /**
9371
- * Estimated funding rate per period for this market.
9621
+ * Build a `cancel-orders` transaction for this account.
9372
9622
  *
9373
- * This is read directly from `marketData.estimatedFundingRate`.
9374
- *
9375
- * @returns Estimated funding rate as a fraction (e.g. `0.01` = 1%).
9376
- */
9377
- estimatedFundingRate: () => Percentage;
9378
- /**
9379
- * Calculate the collateral required to support an order given leverage and prices.
9380
- *
9381
- * The computed collateral is based on the *remaining* unfilled size:
9382
- * `remaining = initialSize - filledSize`.
9623
+ * Each market in `marketIdsToData` supplies:
9624
+ * - `orderIds`: the orders to cancel in that market
9625
+ * - `collateralChange`: collateral adjustment to apply alongside cancellation
9626
+ * - `leverage`: leverage context used for estimating/validating constraints server-side
9383
9627
  *
9384
- * USD requirement:
9385
- * ```text
9386
- * remainingBase * indexPrice * initialMarginRatio
9387
- * ```
9388
- * where `initialMarginRatio = 1 / leverage` (or 1 if leverage is falsy).
9628
+ * Notes:
9629
+ * - Cancels are applied per market; some markets may succeed while others fail
9630
+ * depending on API/on-chain validation (returned as a transaction failure at execution).
9631
+ * - If you need to understand the effect prior to building a tx, use
9632
+ * {@link getCancelOrdersPreview}.
9389
9633
  *
9390
- * @param inputs.leverage - Target leverage for the order (>= 1).
9391
- * @param inputs.orderData - Order data containing `initialSize` and `filledSize`.
9392
- * @param inputs.indexPrice - Index/oracle price of the base asset.
9393
- * @param inputs.collateralPrice - Price of the collateral asset.
9634
+ * @param inputs.tx - Optional transaction to extend.
9635
+ * @param inputs.marketIdsToData - Mapping from market IDs to cancel payloads.
9394
9636
  *
9395
- * @returns Object with:
9396
- * - `collateralUsd`: required collateral in USD
9397
- * - `collateral`: required collateral in collateral coin units
9637
+ * @returns Transaction response containing `tx`.
9398
9638
  */
9399
- calcCollateralUsedForOrder: (inputs: {
9400
- leverage: number;
9401
- orderData: PerpetualsOrderData;
9402
- indexPrice: number;
9403
- collateralPrice: number;
9404
- }) => {
9405
- collateral: number;
9406
- collateralUsd: number;
9407
- };
9639
+ getCancelOrdersTx(inputs: {
9640
+ tx?: Transaction;
9641
+ sponsor?: PerpetualsSponsorConfig;
9642
+ marketIdsToData: Record<PerpetualsMarketId, {
9643
+ orderIds: PerpetualsOrderId[];
9644
+ collateralChange: number;
9645
+ }>;
9646
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9647
+ tx: Transaction;
9648
+ }>;
9408
9649
  /**
9409
- * Get the base-asset lot size for this market as a `number`.
9410
- *
9411
- * Order sizes must be multiples of this lot size.
9650
+ * Build a `cancel-stop-orders` transaction for this account.
9412
9651
  *
9413
- * @returns Lot size in base asset units.
9414
- */
9415
- lotSize(): number;
9416
- /**
9417
- * Get the minimal price tick size for this market as a `number`.
9652
+ * This cancels stop-order *objects/tickets* by their object IDs. These IDs are
9653
+ * returned by stop-order query endpoints (see {@link getStopOrderDatas}).
9418
9654
  *
9419
- * Limit prices must be multiples of this tick size.
9655
+ * @param inputs.tx - Optional transaction to extend.
9656
+ * @param inputs.stopOrderIds - Array of stop-order ticket IDs to cancel.
9420
9657
  *
9421
- * @returns Tick size in quote units (e.g. USD).
9658
+ * @returns Transaction response containing `tx`.
9422
9659
  */
9423
- tickSize(): number;
9660
+ getCancelStopOrdersTx(inputs: {
9661
+ tx?: Transaction;
9662
+ sponsor?: PerpetualsSponsorConfig;
9663
+ stopOrderIds: ObjectId[];
9664
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9665
+ tx: Transaction;
9666
+ }>;
9424
9667
  /**
9425
- * Get the maximum theoretical leverage for this market.
9668
+ * Build a `place-stop-orders` transaction for this account.
9426
9669
  *
9427
- * Computed as:
9428
- * ```ts
9429
- * 1 / marginRatioInitial
9430
- * ```
9670
+ * This allows placing one or more stop orders in a single transaction,
9671
+ * optionally with a dedicated gas coin and a sponsored gas flag.
9431
9672
  *
9432
- * @returns Maximum leverage.
9433
- */
9434
- maxLeverage(): number;
9435
- /**
9436
- * Get the initial margin ratio for this market.
9673
+ * Typical usage:
9674
+ * - Construct stop order payload(s) client-side
9675
+ * - Call this method to build a transaction kind
9676
+ * - Sign/execute the transaction via Sui
9437
9677
  *
9438
- * This is the minimum margin required when opening a position.
9678
+ * @param inputs - See {@link SdkPerpetualsPlaceStopOrdersInputs}.
9439
9679
  *
9440
- * @returns Initial margin ratio as a fraction (e.g. 0.05 = 20x).
9680
+ * @returns Transaction response containing `tx`.
9441
9681
  */
9442
- initialMarginRatio(): number;
9682
+ getPlaceStopOrdersTx(inputs: SdkPerpetualsPlaceStopOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9683
+ tx: Transaction;
9684
+ }>;
9443
9685
  /**
9444
- * Get the maintenance margin ratio for this market.
9686
+ * Build a `place-sl-tp-orders` transaction for this account.
9445
9687
  *
9446
- * Falling below this ratio may trigger liquidation.
9688
+ * This helper constructs SL/TP stop orders for an **existing** position
9689
+ * in a given market. If the account has no position for `marketId`, this
9690
+ * throws an error.
9447
9691
  *
9448
- * @returns Maintenance margin ratio as a fraction.
9449
- */
9450
- maintenanceMarginRatio(): number;
9451
- /**
9452
- * Round a price to the nearest valid tick for this market.
9692
+ * Implementation details:
9693
+ * - Determines the current position side from the account snapshot.
9694
+ * - Sets `positionSide` for the API so SL/TP orders are bound to closing logic
9695
+ * (i.e. they should trigger on the opposite side of the open position).
9453
9696
  *
9454
- * Rounding mode:
9455
- * - `floor: true` => round down
9456
- * - `ceil: true` => round up
9457
- * - neither => nearest tick (`Math.round`)
9697
+ * @param inputs - See {@link SdkPerpetualsPlaceSlTpOrdersInputs}.
9458
9698
  *
9459
- * @param inputs.price - Raw price to round.
9460
- * @param inputs.floor - Force floor rounding.
9461
- * @param inputs.ceil - Force ceil rounding.
9462
- * @returns Price snapped to the market tick size.
9699
+ * @returns Transaction response containing `tx`.
9463
9700
  */
9464
- roundToValidPrice: (inputs: {
9465
- price: number;
9466
- floor?: boolean;
9467
- ceil?: boolean;
9468
- }) => number;
9701
+ getPlaceSlTpOrdersTx(inputs: SdkPerpetualsPlaceSlTpOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9702
+ tx: Transaction;
9703
+ }>;
9469
9704
  /**
9470
- * Round a price to the nearest valid tick as a fixed-point `bigint` (1e9 precision).
9471
- *
9472
- * This is helpful when you need the on-chain representation directly
9473
- * (e.g. order price fields stored in 9-decimal fixed).
9705
+ * Build an `edit-stop-orders` transaction for this account.
9474
9706
  *
9475
- * @param inputs.price - Raw price as a JS number.
9476
- * @param inputs.floor - Force floor rounding.
9477
- * @param inputs.ceil - Force ceil rounding.
9478
- * @returns Tick-snapped price scaled by `1e9`.
9479
- */
9480
- roundToValidPriceBigInt: (inputs: {
9481
- price: number;
9482
- floor?: boolean;
9483
- ceil?: boolean;
9484
- }) => bigint;
9485
- /**
9486
- * Round a base-asset size to the nearest valid lot size for this market.
9707
+ * This endpoint lets you update existing stop orders in batch.
9487
9708
  *
9488
- * Rounding mode:
9489
- * - `floor: true` => round down
9490
- * - `ceil: true` => round up
9491
- * - neither => nearest lot (`Math.round`)
9709
+ * Notes:
9710
+ * - You must provide the full updated stop-order objects (including object IDs).
9711
+ * - This is typically used to adjust trigger prices, sizes, expiries, or the
9712
+ * embedded limit-order parameters.
9492
9713
  *
9493
- * @param inputs.size - Raw size in base asset units.
9494
- * @param inputs.floor - Force floor rounding.
9495
- * @param inputs.ceil - Force ceil rounding.
9496
- * @returns Size snapped to the market lot size.
9497
- */
9498
- roundToValidSize: (inputs: {
9499
- size: number;
9500
- floor?: boolean;
9501
- ceil?: boolean;
9502
- }) => number;
9503
- /**
9504
- * Round a base-asset size to the nearest valid lot as a fixed-point `bigint` (1e9 precision).
9714
+ * @param inputs.stopOrders - Full updated stop-order payloads to apply.
9715
+ * @param inputs.tx - Optional transaction to extend.
9505
9716
  *
9506
- * @param inputs.size - Raw base size as a JS number.
9507
- * @param inputs.floor - Force floor rounding.
9508
- * @param inputs.ceil - Force ceil rounding.
9509
- * @returns Lot-snapped size scaled by `1e9`.
9717
+ * @returns Transaction response containing `tx`.
9510
9718
  */
9511
- roundToValidSizeBigInt: (inputs: {
9512
- size: number;
9513
- floor?: boolean;
9514
- ceil?: boolean;
9515
- }) => bigint;
9719
+ getEditStopOrdersTx(inputs: Omit<ApiPerpetualsEditStopOrdersBody, "txKind" | "accountObjectId"> & {
9720
+ tx?: Transaction;
9721
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9722
+ tx: Transaction;
9723
+ }>;
9516
9724
  /**
9517
- * Construct an "empty" position object for this market.
9725
+ * Build a `set-leverage` transaction for a given market.
9518
9726
  *
9519
- * Useful when an account has no open position but downstream UI/calculations
9520
- * expect a {@link PerpetualsPosition}-shaped object.
9727
+ * This updates the effective leverage for the position (or potential position)
9728
+ * in `marketId`, and optionally adjusts collateral in tandem.
9521
9729
  *
9522
- * @returns A zeroed-out {@link PerpetualsPosition} for `this.marketId`.
9523
- */
9524
- emptyPosition: () => PerpetualsPosition;
9525
- }
9526
-
9527
- /**
9528
- * Note on “refreshing” account state:
9529
- *
9530
- * This class is a thin wrapper around a snapshot of {@link PerpetualsAccountObject}
9531
- * that is typically fetched via {@link Perpetuals.getAccount}. The transaction builders
9532
- * use the current snapshot to derive fields like `hasPosition` and to construct
9533
- * SL/TP helpers that depend on the position side.
9534
- *
9535
- * If your app is long-lived, you may want to periodically re-fetch the account
9536
- * (and recreate this wrapper) to avoid stale local position/order state. For example:
9537
- * - After placing/canceling orders
9538
- * - After fills/liquidations/funding settlements
9539
- * - After switching markets or wallets
9540
- */
9541
- /**
9542
- * High-level wrapper around a single Perpetuals account or vault account.
9543
- *
9544
- * This class encapsulates:
9545
- *
9546
- * - Transaction builders for:
9547
- * - Collateral actions (deposit, withdraw, allocate, deallocate, transfer)
9548
- * - Orders (market/limit, cancel, stop orders, SL/TP, set leverage)
9549
- * - Read-only account helpers:
9550
- * - Stop-order message signing
9551
- * - Order & stop-order metadata
9552
- * - Collateral & trade history
9553
- * - Convenience helpers to:
9554
- * - Fetch and categorize SL/TP stop orders
9555
- * - Resolve account/vault identifiers and owner addresses
9556
- *
9557
- * You typically do not construct `PerpetualsAccount` directly. Instead, use
9558
- * {@link Perpetuals.getAccount} or {@link Perpetuals.getAccounts}, which
9559
- * fetch all required on-chain data and wrap it for you:
9560
- *
9561
- * ```ts
9562
- * const afSdk = new Aftermath("MAINNET");
9563
- * await afSdk.init();
9564
- *
9565
- * const perps = afSdk.Perpetuals();
9566
- * const [accountCap] = await perps.getOwnedAccountCaps({
9567
- * walletAddress: "0x...",
9568
- * });
9569
- *
9570
- * const account = await perps.getAccount({ accountCap });
9571
- *
9572
- * // Build a deposit transaction
9573
- * const depositTx = await account.getDepositCollateralTx({
9574
- * depositAmount: BigInt("1000000000"),
9575
- * });
9576
- * ```
9577
- */
9578
- declare class PerpetualsAccount extends Caller {
9579
- readonly account: PerpetualsAccountObject;
9580
- readonly accountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap;
9581
- readonly Provider?: AftermathApi | undefined;
9582
- /**
9583
- * If this account is backed by a vault, this holds the vault object ID.
9584
- * Otherwise, `undefined` for "direct" user accounts.
9730
+ * Notes:
9731
+ * - Leverage changes may be constrained by protocol risk limits and current
9732
+ * position state.
9733
+ * - If you want to understand the effect first, use {@link getSetLeveragePreview}.
9585
9734
  *
9586
- * This is used primarily to route requests to either:
9587
- * - `/perpetuals/account/...` endpoints, or
9588
- * - `/perpetuals/vault/...` endpoints.
9589
- */
9590
- private readonly vaultId;
9591
- /**
9592
- * Create a new {@link PerpetualsAccount} wrapper.
9735
+ * @param inputs.tx - Optional transaction to extend.
9736
+ * @param inputs.leverage - Target leverage value.
9737
+ * @param inputs.collateralChange - Net collateral change to apply alongside
9738
+ * the leverage update.
9739
+ * @param inputs.marketId - Market whose leverage to adjust.
9593
9740
  *
9594
- * @param account - Raw account object with positions and equity data.
9595
- * @param accountCap - Account cap or partial vault cap object containing
9596
- * ownership and collateral metadata.
9597
- * @param config - Optional {@link CallerConfig} (network, auth, etc.).
9598
- * @param Provider - Optional shared {@link AftermathApi} provider instance
9599
- * used to derive serialized transaction kinds (`txKind`) from
9600
- * {@link Transaction} objects.
9741
+ * @returns Transaction response containing `tx`.
9601
9742
  */
9602
- constructor(account: PerpetualsAccountObject, accountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap, config?: CallerConfig, Provider?: AftermathApi | undefined);
9743
+ getSetLeverageTx(inputs: {
9744
+ tx?: Transaction;
9745
+ leverage: number;
9746
+ collateralChange: number;
9747
+ marketId: PerpetualsMarketId;
9748
+ sponsor?: PerpetualsSponsorConfig;
9749
+ }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9750
+ tx: Transaction;
9751
+ }>;
9603
9752
  /**
9604
- * Build a `deposit-collateral` transaction for this account.
9753
+ * Build a deterministic message payload to sign when querying stop orders
9754
+ * from the backend.
9605
9755
  *
9606
- * For non-vault accounts, this endpoint constructs a transaction that:
9607
- * - Optionally extends an existing {@link Transaction}, and
9608
- * - Deposits collateral into the Perpetuals account.
9756
+ * This payload is intended to be signed off-chain and then submitted to
9757
+ * `getStopOrderDatas` as a proof of account ownership.
9609
9758
  *
9610
- * **Note:** Vault accounts are currently not supported and will throw.
9759
+ * Important:
9760
+ * - The returned payload is *not* a Sui transaction; it is an off-chain
9761
+ * “authentication” message.
9762
+ * - The backend expects `account_id` to be a decimal string. This code
9763
+ * normalizes the bigint `accountId` by stripping the trailing `n`.
9611
9764
  *
9612
- * @param inputs.tx - Optional existing transaction to extend. If omitted,
9613
- * a new {@link Transaction} is created under the hood.
9614
- * @param inputs.isSponsoredTx - Optional flag indicating whether the
9615
- * transaction is gas-sponsored.
9616
- * @param inputs.depositAmount - Amount of collateral to deposit, if paying
9617
- * directly from the wallet.
9618
- * @param inputs.depositCoinArg - Transaction object argument referencing a
9619
- * coin to deposit (mutually exclusive with `depositAmount`).
9765
+ * @param inputs.marketIds - Optional list of market IDs to scope the query.
9620
9766
  *
9621
- * @returns Transaction response containing a `tx`.
9767
+ * @returns An object describing the action and account/market IDs, suitable
9768
+ * for message signing.
9622
9769
  *
9623
9770
  * @example
9624
9771
  * ```ts
9625
- * const { tx } = await account.getDepositCollateralTx({
9626
- * depositAmount: BigInt("1000000000"),
9772
+ * const message = account.getStopOrdersMessageToSign({ marketIds: ["0x..."] });
9773
+ * const { signature } = await wallet.signMessage({
9774
+ * message: new TextEncoder().encode(JSON.stringify(message)),
9627
9775
  * });
9628
9776
  * ```
9629
9777
  */
9630
- getDepositCollateralTx(inputs: {
9631
- tx?: Transaction;
9632
- isSponsoredTx?: boolean;
9633
- sponsor?: PerpetualsSponsorConfig;
9634
- } & ({
9635
- depositAmount: Balance;
9636
- } | {
9637
- depositCoinArg: TransactionObjectArgument;
9638
- })): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9639
- tx: Transaction;
9640
- }>;
9778
+ getStopOrdersMessageToSign(inputs?: {
9779
+ marketIds: PerpetualsMarketId[];
9780
+ }): {
9781
+ action: string;
9782
+ account_id: string;
9783
+ clearing_house_ids: string[];
9784
+ };
9641
9785
  /**
9642
- * Build a `withdraw-collateral` transaction for this account.
9786
+ * Preview the effects of placing a market order (without building a tx).
9643
9787
  *
9644
- * For non-vault accounts, this endpoint constructs a transaction to:
9645
- * - Withdraw collateral from the Perpetuals account, and
9646
- * - Optionally transfer it to a `recipientAddress` (otherwise coin is left
9647
- * as a transaction argument).
9788
+ * This is a read-only API call that runs the protocol’s pricing / margin /
9789
+ * slippage logic against the current market state and your account/vault context.
9790
+ *
9791
+ * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
9792
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9793
+ *
9794
+ * @returns Either an error message or a preview including:
9795
+ * - `updatedPosition`
9796
+ * - `priceSlippage`, `percentSlippage`
9797
+ * - `filledSize`, `filledSizeUsd`
9798
+ * - `postedSize`, `postedSizeUsd`
9799
+ * - `collateralChange`
9800
+ * - `executionPrice`
9801
+ */
9802
+ getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9803
+ /**
9804
+ * Preview the effects of placing a limit order (without building a tx).
9805
+ *
9806
+ * The preview simulates:
9807
+ * - How much size would execute immediately vs post to the book
9808
+ * - Expected slippage and execution price
9809
+ * - Resulting position and margin impact
9648
9810
  *
9649
- * **Note:** Vault accounts are currently not supported and will throw.
9811
+ * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
9812
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9650
9813
  *
9651
- * @param inputs.withdrawAmount - Amount of collateral to withdraw.
9652
- * @param inputs.recipientAddress - Optional address to receive the withdrawn
9653
- * coins directly.
9654
- * @param inputs.tx - Optional transaction to extend (defaults to new `Transaction()`).
9814
+ * @returns Either an error message or a preview object similar to
9815
+ * {@link getPlaceMarketOrderPreview}.
9816
+ */
9817
+ getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9818
+ /**
9819
+ * Preview the effects of placing a scale order (without building a tx).
9655
9820
  *
9656
- * @returns A response containing `tx` and the `coinOutArg` where the
9657
- * withdrawn coins end up if `recipientAddress` is not used.
9821
+ * A scale order distributes total size across multiple limit orders
9822
+ * spaced between a start and end price. The preview simulates:
9823
+ * - How much size would execute immediately vs post to the book
9824
+ * - Expected slippage and execution price
9825
+ * - Resulting position and margin impact
9658
9826
  *
9659
- * @example
9660
- * ```ts
9661
- * const { tx, coinOutArg } = await account.getWithdrawCollateralTx({
9662
- * withdrawAmount: BigInt("1000000000"),
9663
- * });
9664
- * ```
9827
+ * @param inputs - See {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
9828
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9829
+ *
9830
+ * @returns Either an error message or a preview object similar to
9831
+ * {@link getPlaceMarketOrderPreview}.
9665
9832
  */
9666
- getWithdrawCollateralTx(inputs: {
9667
- withdrawAmount: Balance;
9668
- recipientAddress?: SuiAddress;
9669
- sponsor?: PerpetualsSponsorConfig;
9670
- tx?: Transaction;
9671
- }): Promise<Omit<ApiPerpetualsWithdrawCollateralResponse, "txKind"> & {
9672
- tx: Transaction;
9673
- }>;
9833
+ getPlaceScaleOrderPreview(inputs: SdkPerpetualsPlaceScaleOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
9674
9834
  /**
9675
- * Build an `allocate-collateral` transaction, moving collateral from this
9676
- * account into a specific market (clearing house).
9835
+ * Preview the effects of canceling orders across one or more markets.
9677
9836
  *
9678
- * Works for both account-backed and vault-backed accounts.
9837
+ * This is commonly used to:
9838
+ * - Validate that cancels are allowed under current margin constraints
9839
+ * - Estimate how collateral/margin would change after canceling (and applying
9840
+ * the associated `collateralChange` values)
9679
9841
  *
9680
- * @param inputs.marketId - Market to allocate collateral to.
9681
- * @param inputs.allocateAmount - Amount of collateral to allocate.
9682
- * @param inputs.tx - Optional transaction to extend.
9842
+ * If `marketIdsToData` is empty, this returns a trivial preview with:
9843
+ * - `marketIdsToData: {}`
9683
9844
  *
9684
- * @returns Transaction response containing a `tx`.
9845
+ * @param inputs - See {@link SdkPerpetualsCancelOrdersPreviewInputs}.
9846
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9847
+ *
9848
+ * @returns Either:
9849
+ * - `{ marketIdsToData }`, or
9850
+ * - `{ error }`.
9685
9851
  */
9686
- getAllocateCollateralTx(inputs: {
9687
- marketId: PerpetualsMarketId;
9688
- allocateAmount: Balance;
9689
- sponsor?: PerpetualsSponsorConfig;
9690
- tx?: Transaction;
9691
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9692
- tx: Transaction;
9693
- }>;
9852
+ getCancelOrdersPreview(inputs: SdkPerpetualsCancelOrdersPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewCancelOrdersResponse>;
9694
9853
  /**
9695
- * Build a `deallocate-collateral` transaction, moving collateral from a
9696
- * specific market back to this account.
9854
+ * Preview the effects of setting leverage for a given market.
9697
9855
  *
9698
- * Works for both account-backed and vault-backed accounts.
9856
+ * The preview returns:
9857
+ * - The position after the leverage change (`updatedPosition`)
9858
+ * - The collateral delta required/produced (`collateralChange`)
9699
9859
  *
9700
- * @param inputs.marketId - Market to deallocate collateral from.
9701
- * @param inputs.deallocateAmount - Amount of collateral to deallocate.
9702
- * @param inputs.tx - Optional transaction to extend.
9860
+ * @param inputs.marketId - Market whose leverage you want to adjust.
9861
+ * @param inputs.leverage - Target leverage value.
9862
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9703
9863
  *
9704
- * @returns Transaction response containing a `tx`.
9864
+ * @returns Either:
9865
+ * - `{ updatedPosition, collateralChange }`, or
9866
+ * - `{ error }`.
9705
9867
  */
9706
- getDeallocateCollateralTx(inputs: {
9868
+ getSetLeveragePreview(inputs: {
9707
9869
  marketId: PerpetualsMarketId;
9708
- deallocateAmount: Balance;
9709
- sponsor?: PerpetualsSponsorConfig;
9710
- tx?: Transaction;
9711
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9712
- tx: Transaction;
9870
+ leverage: number;
9871
+ }, abortSignal?: AbortSignal): Promise<{
9872
+ updatedPosition: PerpetualsPosition;
9873
+ collateralChange: number;
9874
+ } | {
9875
+ error: string;
9713
9876
  }>;
9714
9877
  /**
9715
- * Build a `transfer-collateral` transaction between two Perpetuals accounts.
9878
+ * Preview the effects of allocating/deallocating collateral for the position in
9879
+ * a given market.
9716
9880
  *
9717
- * Only supported for direct accounts, **not** vault-backed accounts.
9881
+ * Semantics:
9882
+ * - Positive `collateralChange` previews allocation (moving collateral into the market).
9883
+ * - Negative `collateralChange` previews deallocation (moving collateral out of the market).
9718
9884
  *
9719
- * @param inputs.transferAmount - Amount of collateral to transfer.
9720
- * @param inputs.toAccountId - Destination account ID.
9721
- * @param inputs.tx - Optional transaction to extend.
9885
+ * @param inputs.marketId - Market of whose position you want to allocate/deallocate
9886
+ * collateral to/from.
9887
+ * @param inputs.collateralChange - The target collateral change (a positive number
9888
+ * for allocating collateral, negative for deallocating collateral).
9889
+ * @param abortSignal - Optional `AbortSignal` to cancel the request.
9722
9890
  *
9723
- * @returns Transaction response containing a `tx`.
9891
+ * @returns Either:
9892
+ * - `{ updatedPosition, collateralChange }`, or
9893
+ * - `{ error }`.
9724
9894
  */
9725
- getTransferCollateralTx(inputs: {
9726
- transferAmount: Balance;
9727
- toAccountId: PerpetualsAccountId;
9728
- toAccountCapId?: ObjectId;
9729
- sponsor?: PerpetualsSponsorConfig;
9730
- tx?: Transaction;
9731
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9732
- tx: Transaction;
9895
+ getEditCollateralPreview(inputs: {
9896
+ marketId: PerpetualsMarketId;
9897
+ collateralChange: Balance;
9898
+ }, abortSignal?: AbortSignal): Promise<{
9899
+ updatedPosition: PerpetualsPosition;
9900
+ collateralChange: number;
9901
+ } | {
9902
+ error: string;
9733
9903
  }>;
9734
9904
  /**
9735
- * Build a `place-market-order` transaction for this account.
9736
- *
9737
- * This is the primary entrypoint for opening/closing positions via market orders.
9738
- * It automatically:
9739
- * - Injects the account/vault identity into the payload.
9740
- * - Derives `hasPosition` based on the current account state for the given market.
9741
- * - Optionally attaches SL/TP stop orders via the `slTp` input.
9742
- *
9743
- * Important behavioral notes:
9744
- * - `hasPosition` is derived from the local {@link PerpetualsAccountObject} snapshot.
9745
- * If the snapshot is stale, consider re-fetching the account first.
9746
- * - For vault-backed accounts, the API routes to `/perpetuals/vault/...` and uses
9747
- * `vaultId` as the identity discriminator. For direct accounts, it uses `accountId`.
9905
+ * Fetch stop-order ticket data for this account, using an off-chain signed
9906
+ * payload.
9748
9907
  *
9749
- * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderInputs} for details.
9750
- * Notably:
9751
- * - `marketId`, `side`, `size`, `collateralChange`, `reduceOnly`
9752
- * - Optional `leverage`
9753
- * - Optional `slTp` params
9754
- * - Optional `tx` to extend
9908
+ * Typical flow:
9909
+ * 1) Call {@link getStopOrdersMessageToSign} to construct a deterministic payload
9910
+ * 2) Sign the payload with the wallet
9911
+ * 3) Provide the signed payload to this method to fetch stop order data
9755
9912
  *
9756
- * @returns Transaction response containing `tx`.
9913
+ * @param inputs.bytes - Serialized message that was signed (e.g. JSON string).
9914
+ * @param inputs.signature - Signature over `bytes`.
9915
+ * @param inputs.marketIds - Optional subset of markets to filter results by.
9757
9916
  *
9758
- * @example
9759
- * ```ts
9760
- * const { tx } = await account.getPlaceMarketOrderTx({
9761
- * marketId: "0x...",
9762
- * side: PerpetualsOrderSide.Bid,
9763
- * size: BigInt("1000000000"),
9764
- * collateralChange: 10,
9765
- * reduceOnly: false,
9766
- * });
9767
- * ```
9917
+ * @returns {@link ApiPerpetualsStopOrderDatasResponse} containing `stopOrderDatas`.
9768
9918
  */
9769
- getPlaceMarketOrderTx(inputs: SdkPerpetualsPlaceMarketOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9770
- tx: Transaction;
9771
- }>;
9919
+ getStopOrderDatas(inputs: {
9920
+ bytes: string;
9921
+ signature: string;
9922
+ marketIds?: PerpetualsMarketId[];
9923
+ }): Promise<ApiPerpetualsStopOrderDatasResponse>;
9772
9924
  /**
9773
- * Build a `place-limit-order` transaction for this account.
9774
- *
9775
- * Similar to {@link getPlaceMarketOrderTx}, but uses limit order semantics:
9776
- * - Requires `price` and `orderType`.
9777
- * - Supports reduce-only flags, expiry, optional leverage, and SL/TP stop orders.
9925
+ * Fetch paginated collateral-change history for this account, including
9926
+ * deposits, withdrawals, funding settlements, liquidations, etc.
9778
9927
  *
9779
- * Notes:
9780
- * - `hasPosition` is derived from local account state; refresh the account if needed.
9781
- * - This method does not validate tick/lot sizing locally; the API/on-chain
9782
- * will enforce market constraints.
9928
+ * Pagination:
9929
+ * - Use `beforeTimestampCursor` to fetch older entries.
9930
+ * - The API returns a `nextBeforeTimestampCursor` to continue pagination.
9783
9931
  *
9784
- * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderInputs}.
9932
+ * @param inputs.beforeTimestampCursor - Optional cursor for pagination.
9933
+ * @param inputs.limit - Optional limit per page.
9785
9934
  *
9786
- * @returns Transaction response containing `tx`.
9935
+ * @returns {@link ApiPerpetualsAccountCollateralHistoryResponse} containing
9936
+ * an array of changes and a `nextBeforeTimestampCursor`.
9787
9937
  */
9788
- getPlaceLimitOrderTx(inputs: SdkPerpetualsPlaceLimitOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9789
- tx: Transaction;
9790
- }>;
9938
+ getCollateralHistory(inputs: Omit<ApiPerpetualsAccountCollateralHistoryBody, "accountId">): Promise<ApiPerpetualsAccountCollateralHistoryResponse>;
9791
9939
  /**
9792
- * Build a `place-scale-order` transaction for this account.
9940
+ * Fetch paginated order history for this account.
9793
9941
  *
9794
- * A scale order distributes a total size across multiple limit orders
9795
- * evenly spaced between a start and end price. An optional `sizeSkew`
9796
- * parameter controls whether the distribution is uniform or weighted.
9942
+ * This endpoint is distinct from {@link getOrderDatas}:
9943
+ * - `getOrderDatas` resolves current/pending orders based on the snapshot.
9944
+ * - `getOrderHistory` returns historical order events (fills, cancels, etc.)
9945
+ * over time with cursor-based pagination.
9797
9946
  *
9798
- * @param inputs - See {@link SdkPerpetualsPlaceScaleOrderInputs}.
9947
+ * @param inputs.beforeTimestampCursor - Optional cursor for pagination.
9948
+ * @param inputs.limit - Optional limit per page.
9799
9949
  *
9800
- * @returns Transaction response containing `tx`.
9950
+ * @returns {@link ApiPerpetualsAccountOrderHistoryResponse} containing a list of
9951
+ * orders and a `nextBeforeTimestampCursor`.
9801
9952
  */
9802
- getPlaceScaleOrderTx(inputs: SdkPerpetualsPlaceScaleOrderInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9803
- tx: Transaction;
9804
- }>;
9953
+ getOrderHistory(inputs: Omit<ApiPerpetualsAccountOrderHistoryBody, "accountId">): Promise<ApiPerpetualsAccountOrderHistoryResponse>;
9805
9954
  /**
9806
- * Build a `cancel-and-place-orders` transaction for this account.
9955
+ * Fetch historical margin snapshots for this account over a time range.
9807
9956
  *
9808
- * Atomically cancels existing orders and places new ones in a single
9809
- * transaction. Useful for rebalancing order grids or replacing stale
9810
- * orders without intermediate exposure.
9957
+ * This endpoint returns time-series margin data suitable for charting UI
9958
+ * such as equity and available collateral over time.
9811
9959
  *
9812
- * @param inputs - See {@link SdkPerpetualsCancelAndPlaceOrdersInputs}.
9960
+ * Notes:
9961
+ * - This is an account-level view (aggregated across markets).
9813
9962
  *
9814
- * @returns Transaction response containing `tx`.
9963
+ * @param inputs - {@link ApiPerpetualsAccountMarginHistoryBody} without `accountId`.
9964
+ * @returns {@link ApiPerpetualsAccountMarginHistoryResponse} containing `marginHistoryDatas`.
9815
9965
  */
9816
- getCancelAndPlaceOrdersTx(inputs: SdkPerpetualsCancelAndPlaceOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9817
- tx: Transaction;
9818
- }>;
9966
+ getMarginHistory(inputs: Omit<ApiPerpetualsAccountMarginHistoryBody, "accountId">): Promise<ApiPerpetualsAccountMarginHistoryResponse>;
9819
9967
  /**
9820
- * Build a `cancel-orders` transaction for this account.
9821
- *
9822
- * Each market in `marketIdsToData` supplies:
9823
- * - `orderIds`: the orders to cancel in that market
9824
- * - `collateralChange`: collateral adjustment to apply alongside cancellation
9825
- * - `leverage`: leverage context used for estimating/validating constraints server-side
9968
+ * Build a transaction that grants an Agent Wallet (assistant permissions) for this perpetuals account.
9826
9969
  *
9827
- * Notes:
9828
- * - Cancels are applied per market; some markets may succeed while others fail
9829
- * depending on API/on-chain validation (returned as a transaction failure at execution).
9830
- * - If you need to understand the effect prior to building a tx, use
9831
- * {@link getCancelOrdersPreview}.
9970
+ * The returned transaction must be signed and submitted by the **account admin** wallet.
9971
+ * After execution, `recipientAddress` can execute supported trading actions on behalf of this account.
9832
9972
  *
9833
- * @param inputs.tx - Optional transaction to extend.
9834
- * @param inputs.marketIdsToData - Mapping from market IDs to cancel payloads.
9973
+ * Agent wallets can perform all supported actions **except**:
9974
+ * - withdrawing collateral, and
9975
+ * - granting or revoking other agent wallets.
9835
9976
  *
9836
- * @returns Transaction response containing `tx`.
9977
+ * @param inputs.recipientAddress Wallet address to receive agent permissions.
9978
+ * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.
9979
+ * @throws If this instance represents a vault account (agent wallets are account-only).
9837
9980
  */
9838
- getCancelOrdersTx(inputs: {
9981
+ getGrantAgentWalletTx(inputs: {
9982
+ recipientAddress: SuiAddress;
9839
9983
  tx?: Transaction;
9840
- sponsor?: PerpetualsSponsorConfig;
9841
- marketIdsToData: Record<PerpetualsMarketId, {
9842
- orderIds: PerpetualsOrderId[];
9843
- collateralChange: number;
9844
- }>;
9845
9984
  }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9846
9985
  tx: Transaction;
9847
9986
  }>;
9848
9987
  /**
9849
- * Build a `cancel-stop-orders` transaction for this account.
9850
- *
9851
- * This cancels stop-order *objects/tickets* by their object IDs. These IDs are
9852
- * returned by stop-order query endpoints (see {@link getStopOrderDatas}).
9988
+ * Build a transaction that revokes an Agent Wallet (assistant capability) from this perpetuals account.
9853
9989
  *
9854
- * @param inputs.tx - Optional transaction to extend.
9855
- * @param inputs.stopOrderIds - Array of stop-order ticket IDs to cancel.
9990
+ * The returned transaction must be signed and submitted by the **account admin** wallet.
9991
+ * After execution, the revoked wallet immediately loses its delegated permissions.
9856
9992
  *
9857
- * @returns Transaction response containing `tx`.
9993
+ * @param inputs.accountCapId Object ID of the assistant capability to revoke.
9994
+ * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.
9995
+ * @throws If this instance represents a vault account (agent wallets are account-only).
9858
9996
  */
9859
- getCancelStopOrdersTx(inputs: {
9997
+ getRevokeAgentWalletTx(inputs: {
9998
+ accountCapId: ObjectId;
9860
9999
  tx?: Transaction;
9861
- sponsor?: PerpetualsSponsorConfig;
9862
- stopOrderIds: ObjectId[];
9863
10000
  }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9864
10001
  tx: Transaction;
9865
10002
  }>;
9866
10003
  /**
9867
- * Build a `place-stop-orders` transaction for this account.
10004
+ * Find the current position for a given market ID, if any.
9868
10005
  *
9869
- * This allows placing one or more stop orders in a single transaction,
9870
- * optionally with a dedicated gas coin and a sponsored gas flag.
10006
+ * @param inputs.marketId - Market ID to search for.
10007
+ * @returns {@link PerpetualsPosition} if found, otherwise `undefined`.
10008
+ */
10009
+ positionForMarketId(inputs: {
10010
+ marketId: PerpetualsMarketId;
10011
+ }): PerpetualsPosition | undefined;
10012
+ /**
10013
+ * Filter a list of stop orders to only include non-SL/TP orders.
9871
10014
  *
9872
- * Typical usage:
9873
- * - Construct stop order payload(s) client-side
9874
- * - Call this method to build a transaction kind
9875
- * - Sign/execute the transaction via Sui
10015
+ * A stop order is considered SL/TP if it appears in the combined set of
10016
+ * SL/TP orders across **all** markets (see {@link slTpStopOrderDatas}).
9876
10017
  *
9877
- * @param inputs - See {@link SdkPerpetualsPlaceStopOrdersInputs}.
10018
+ * Note:
10019
+ * - This implementation uses JSON string equality to compare objects.
10020
+ * This is pragmatic but assumes stable field ordering and identical shapes.
9878
10021
  *
9879
- * @returns Transaction response containing `tx`.
10022
+ * @param inputs.stopOrderDatas - Full array of stop-order ticket data.
10023
+ * @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
9880
10024
  */
9881
- getPlaceStopOrdersTx(inputs: SdkPerpetualsPlaceStopOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9882
- tx: Transaction;
9883
- }>;
10025
+ nonSlTpStopOrderDatas(inputs: {
10026
+ stopOrderDatas: PerpetualsStopOrderData[];
10027
+ }): PerpetualsStopOrderData[] | undefined;
9884
10028
  /**
9885
- * Build a `place-sl-tp-orders` transaction for this account.
10029
+ * Extract all SL/TP-style stop orders across **all** markets for this
10030
+ * account.
9886
10031
  *
9887
- * This helper constructs SL/TP stop orders for an **existing** position
9888
- * in a given market. If the account has no position for `marketId`, this
9889
- * throws an error.
10032
+ * SL/TP orders are stop orders which:
10033
+ * - Have an `slTp` payload, and
10034
+ * - Target the opposite side of the current position.
9890
10035
  *
9891
- * Implementation details:
9892
- * - Determines the current position side from the account snapshot.
9893
- * - Sets `positionSide` for the API so SL/TP orders are bound to closing logic
9894
- * (i.e. they should trigger on the opposite side of the open position).
10036
+ * This combines:
10037
+ * - "Full" SL/TP orders (size >= `i64MaxBigInt`)
10038
+ * - "Partial" SL/TP orders (size < `i64MaxBigInt`)
9895
10039
  *
9896
- * @param inputs - See {@link SdkPerpetualsPlaceSlTpOrdersInputs}.
10040
+ * The "full vs partial" distinction is a protocol convention: some systems
10041
+ * encode “close entire position” using a sentinel max size.
9897
10042
  *
9898
- * @returns Transaction response containing `tx`.
10043
+ * @param inputs.stopOrderDatas - Full list of stop-order tickets.
10044
+ * @returns Array of SL/TP stop orders, or `undefined` if none exist.
9899
10045
  */
9900
- getPlaceSlTpOrdersTx(inputs: SdkPerpetualsPlaceSlTpOrdersInputs): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9901
- tx: Transaction;
9902
- }>;
10046
+ slTpStopOrderDatas(inputs: {
10047
+ stopOrderDatas: PerpetualsStopOrderData[];
10048
+ }): PerpetualsStopOrderData[] | undefined;
9903
10049
  /**
9904
- * Build an `edit-stop-orders` transaction for this account.
10050
+ * Filter stop orders for a single market to only include non-SL/TP orders.
9905
10051
  *
9906
- * This endpoint lets you update existing stop orders in batch.
10052
+ * Uses {@link slTpStopOrderDatasForPosition} under the hood.
9907
10053
  *
9908
- * Notes:
9909
- * - You must provide the full updated stop-order objects (including object IDs).
9910
- * - This is typically used to adjust trigger prices, sizes, expiries, or the
9911
- * embedded limit-order parameters.
10054
+ * @param inputs.marketId - Market ID to filter for.
10055
+ * @param inputs.stopOrderDatas - Full list of stop orders.
10056
+ * @returns Non-SL/TP stop orders for the given market, or `undefined` if none exist.
10057
+ */
10058
+ nonSlTpStopOrderDatasForPosition(inputs: {
10059
+ marketId: PerpetualsMarketId;
10060
+ stopOrderDatas: PerpetualsStopOrderData[];
10061
+ }): PerpetualsStopOrderData[] | undefined;
10062
+ /**
10063
+ * Categorize stop orders for a specific market into:
10064
+ * - A "full" SL/TP order (size >= `i64MaxBigInt`) if any.
10065
+ * - A set of "partial" SL/TP orders (size < `i64MaxBigInt`).
9912
10066
  *
9913
- * @param inputs.stopOrders - Full updated stop-order payloads to apply.
9914
- * @param inputs.tx - Optional transaction to extend.
10067
+ * SL/TP stop orders are defined as:
10068
+ * - Market ID matches the input market.
10069
+ * - `slTp` field is present.
10070
+ * - Order side is opposite of the position side.
10071
+ * - At least a `stopLossIndexPrice` or `takeProfitIndexPrice` is set.
9915
10072
  *
9916
- * @returns Transaction response containing `tx`.
10073
+ * Notes on matching:
10074
+ * - The side comparison uses the current position side derived from the account snapshot.
10075
+ * - If `baseAssetAmount === 0` (no effective position), the method returns no SL/TP orders.
10076
+ *
10077
+ * @param inputs.marketId - Market to categorize stop orders for.
10078
+ * @param inputs.stopOrderDatas - Full list of stop orders.
10079
+ *
10080
+ * @returns Object containing:
10081
+ * - `fullSlTpOrder` (if any)
10082
+ * - `partialSlTpOrders` (if any, otherwise `undefined`)
9917
10083
  */
9918
- getEditStopOrdersTx(inputs: Omit<ApiPerpetualsEditStopOrdersBody, "txKind" | "accountObjectId"> & {
9919
- tx?: Transaction;
9920
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9921
- tx: Transaction;
9922
- }>;
10084
+ slTpStopOrderDatasForPosition(inputs: {
10085
+ marketId: PerpetualsMarketId;
10086
+ stopOrderDatas: PerpetualsStopOrderData[];
10087
+ }): {
10088
+ fullSlTpOrder: PerpetualsStopOrderData | undefined;
10089
+ partialSlTpOrders: PerpetualsStopOrderData[] | undefined;
10090
+ };
10091
+ slTpStopOrderDatasForLimitOrder(inputs: {
10092
+ stopOrderDatas: PerpetualsStopOrderData[];
10093
+ limitOrderId: PerpetualsOrderId;
10094
+ }): {
10095
+ fullSlTpOrder: PerpetualsStopOrderData | undefined;
10096
+ partialSlTpOrders: PerpetualsStopOrderData[] | undefined;
10097
+ };
10098
+ orderDatas(): PerpetualsOrderData[];
9923
10099
  /**
9924
- * Build a `set-leverage` transaction for a given market.
10100
+ * Convenience accessor for the account's available collateral (in coin units).
9925
10101
  *
9926
- * This updates the effective leverage for the position (or potential position)
9927
- * in `marketId`, and optionally adjusts collateral in tandem.
10102
+ * This is the amount of collateral not currently locked/allocated across markets,
10103
+ * as represented by the backend response.
9928
10104
  *
9929
- * Notes:
9930
- * - Leverage changes may be constrained by protocol risk limits and current
9931
- * position state.
9932
- * - If you want to understand the effect first, use {@link getSetLeveragePreview}.
10105
+ * @returns Available collateral as a `number`.
10106
+ */
10107
+ collateral(): number;
10108
+ /**
10109
+ * Check whether this {@link PerpetualsAccount} is vault-backed.
9933
10110
  *
9934
- * @param inputs.tx - Optional transaction to extend.
9935
- * @param inputs.leverage - Target leverage value.
9936
- * @param inputs.collateralChange - Net collateral change to apply alongside
9937
- * the leverage update.
9938
- * @param inputs.marketId - Market whose leverage to adjust.
10111
+ * @returns `true` if the underlying `accountCap` is a vault cap; otherwise `false`.
10112
+ */
10113
+ isVault(): boolean;
10114
+ /**
10115
+ * Resolve the owner wallet address of this account or vault.
9939
10116
  *
9940
- * @returns Transaction response containing `tx`.
10117
+ * - For direct accounts, returns the cap's `walletAddress` field.
10118
+ * - For vault-backed accounts, returns the vault cap's `ownerAddress`.
10119
+ *
10120
+ * Naming note:
10121
+ * - Some types use `walletAddress` for direct ownership. For vault-backed accounts
10122
+ * the analogous field is `ownerAddress`.
10123
+ *
10124
+ * @returns Owner wallet {@link SuiAddress}.
9941
10125
  */
9942
- getSetLeverageTx(inputs: {
9943
- tx?: Transaction;
9944
- leverage: number;
9945
- collateralChange: number;
9946
- marketId: PerpetualsMarketId;
9947
- sponsor?: PerpetualsSponsorConfig;
9948
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
9949
- tx: Transaction;
9950
- }>;
10126
+ ownerAddress(): SuiAddress;
9951
10127
  /**
9952
- * Build a deterministic message payload to sign when querying stop orders
9953
- * from the backend.
10128
+ * Get the underlying account object ID.
9954
10129
  *
9955
- * This payload is intended to be signed off-chain and then submitted to
9956
- * `getStopOrderDatas` as a proof of account ownership.
10130
+ * This is the on-chain object that holds the account's state and positions.
9957
10131
  *
9958
- * Important:
9959
- * - The returned payload is *not* a Sui transaction; it is an off-chain
9960
- * “authentication” message.
9961
- * - The backend expects `account_id` to be a decimal string. This code
9962
- * normalizes the bigint `accountId` by stripping the trailing `n`.
10132
+ * @returns {@link ObjectId} of the account object.
10133
+ */
10134
+ accountObjectId(): ObjectId;
10135
+ /**
10136
+ * Get the numeric perpetuals account ID.
9963
10137
  *
9964
- * @param inputs.marketIds - Optional list of market IDs to scope the query.
10138
+ * This is the protocol-level identifier (bigint-derived) used across API calls.
9965
10139
  *
9966
- * @returns An object describing the action and account/market IDs, suitable
9967
- * for message signing.
10140
+ * @returns {@link PerpetualsAccountId} for this account.
10141
+ */
10142
+ accountId(): PerpetualsAccountId;
10143
+ /**
10144
+ * Get the account cap object ID, if this is a direct account.
9968
10145
  *
9969
- * @example
9970
- * ```ts
9971
- * const message = account.getStopOrdersMessageToSign({ marketIds: ["0x..."] });
9972
- * const { signature } = await wallet.signMessage({
9973
- * message: new TextEncoder().encode(JSON.stringify(message)),
9974
- * });
9975
- * ```
10146
+ * Direct accounts are controlled via an on-chain “cap” object. Vault-backed
10147
+ * accounts are controlled via vault caps and do not expose a direct account-cap ID.
10148
+ *
10149
+ * @throws If called for a vault-backed account.
10150
+ *
10151
+ * @returns {@link ObjectId} of the account cap.
9976
10152
  */
9977
- getStopOrdersMessageToSign(inputs?: {
9978
- marketIds: PerpetualsMarketId[];
9979
- }): {
9980
- action: string;
9981
- account_id: string;
9982
- clearing_house_ids: string[];
9983
- };
10153
+ accountCapId(): ObjectId;
10154
+ }
10155
+
10156
+ /**
10157
+ * High-level wrapper around a single perpetuals market.
10158
+ *
10159
+ * This class provides:
10160
+ *
10161
+ * - Lightweight accessors for immutable market properties:
10162
+ * - `marketId`, `indexPrice`, `collateralPrice`, `collateralCoinType`
10163
+ * - `marketParams`, `marketState`
10164
+ * - Read endpoints for:
10165
+ * - Orderbook snapshots
10166
+ * - 24h stats and order history
10167
+ * - Market prices and derived funding metrics
10168
+ * - Helpers for:
10169
+ * - Order sizing (max size, lot/tick rounding)
10170
+ * - Margin and collateral calculations
10171
+ * - Constructing an “empty” position for a market
10172
+ *
10173
+ * Typical usage:
10174
+ *
10175
+ * ```ts
10176
+ * const perps = new Perpetuals(config);
10177
+ * const { markets } = await perps.getMarkets({ marketIds: ["0x..."] });
10178
+ * const market = markets[0];
10179
+ *
10180
+ * const { orderbook } = await market.getOrderbook();
10181
+ * const stats = await market.get24hrStats();
10182
+ * const { basePrice, collateralPrice } = await market.getPrices();
10183
+ * ```
10184
+ */
10185
+ declare class PerpetualsMarket extends Caller {
10186
+ marketData: PerpetualsMarketData;
10187
+ readonly api?: AftermathApi | undefined;
10188
+ /** Unique identifier for this perpetuals market (object ID on chain). */
10189
+ readonly marketId: PerpetualsMarketId;
9984
10190
  /**
9985
- * Preview the effects of placing a market order (without building a tx).
9986
- *
9987
- * This is a read-only API call that runs the protocol’s pricing / margin /
9988
- * slippage logic against the current market state and your account/vault context.
9989
- *
9990
- * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
9991
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
9992
- *
9993
- * @returns Either an error message or a preview including:
9994
- * - `updatedPosition`
9995
- * - `priceSlippage`, `percentSlippage`
9996
- * - `filledSize`, `filledSizeUsd`
9997
- * - `postedSize`, `postedSizeUsd`
9998
- * - `collateralChange`
9999
- * - `executionPrice`
10191
+ * Current oracle/index price for the market's underlying asset, quoted in
10192
+ * the index unit (typically USD).
10000
10193
  */
10001
- getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10194
+ readonly indexPrice: number;
10002
10195
  /**
10003
- * Preview the effects of placing a limit order (without building a tx).
10004
- *
10005
- * The preview simulates:
10006
- * - How much size would execute immediately vs post to the book
10007
- * - Expected slippage and execution price
10008
- * - Resulting position and margin impact
10009
- *
10010
- * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
10011
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
10012
- *
10013
- * @returns Either an error message or a preview object similar to
10014
- * {@link getPlaceMarketOrderPreview}.
10196
+ * Current price of the collateral asset in USD (or the platform's base
10197
+ * pricing unit).
10015
10198
  */
10016
- getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10199
+ readonly collateralPrice: number;
10200
+ /** Sui type of the collateral coin (e.g. `"0x2::sui::SUI"`). */
10201
+ readonly collateralCoinType: CoinType;
10202
+ /** Static market configuration parameters (lot size, tick size, margins, etc.). */
10203
+ readonly marketParams: PerpetualsMarketParams;
10204
+ /** Dynamic market state (funding rates, open interest, etc.). */
10205
+ readonly marketState: PerpetualsMarketState;
10017
10206
  /**
10018
- * Preview the effects of placing a scale order (without building a tx).
10019
- *
10020
- * A scale order distributes total size across multiple limit orders
10021
- * spaced between a start and end price. The preview simulates:
10022
- * - How much size would execute immediately vs post to the book
10023
- * - Expected slippage and execution price
10024
- * - Resulting position and margin impact
10207
+ * Create a new {@link PerpetualsMarket} wrapper from raw market data.
10025
10208
  *
10026
- * @param inputs - See {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
10027
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
10209
+ * @param marketData - Snapshot of market configuration and state.
10210
+ * @param config - Optional {@link CallerConfig} (network, base URL, etc.).
10211
+ * @param api - Optional shared {@link AftermathApi} provider instance.
10028
10212
  *
10029
- * @returns Either an error message or a preview object similar to
10030
- * {@link getPlaceMarketOrderPreview}.
10213
+ * @remarks
10214
+ * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
10215
+ * all HTTP requests resolve under `/perpetuals/...`.
10031
10216
  */
10032
- getPlaceScaleOrderPreview(inputs: SdkPerpetualsPlaceScaleOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10217
+ constructor(marketData: PerpetualsMarketData, config?: CallerConfig, api?: AftermathApi | undefined);
10033
10218
  /**
10034
- * Preview the effects of canceling orders across one or more markets.
10035
- *
10036
- * This is commonly used to:
10037
- * - Validate that cancels are allowed under current margin constraints
10038
- * - Estimate how collateral/margin would change after canceling (and applying
10039
- * the associated `collateralChange` values)
10219
+ * Fetch the 24-hour volume and price change statistics for this market.
10040
10220
  *
10041
- * If `marketIdsToData` is empty, this returns a trivial preview with:
10042
- * - `marketIdsToData: {}`
10221
+ * Under the hood, this calls {@link Perpetuals.getMarkets24hrStats} and
10222
+ * returns the first (and only) entry.
10043
10223
  *
10044
- * @param inputs - See {@link SdkPerpetualsCancelOrdersPreviewInputs}.
10045
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
10224
+ * @returns {@link PerpetualsMarket24hrStats}.
10046
10225
  *
10047
- * @returns Either:
10048
- * - `{ marketIdsToData }`, or
10049
- * - `{ error }`.
10226
+ * @remarks
10227
+ * This method creates a new {@link Perpetuals} instance using `this.config`.
10228
+ * If you need shared api behavior, prefer calling `perps.getMarkets24hrStats`
10229
+ * directly with the same api you initialized.
10050
10230
  */
10051
- getCancelOrdersPreview(inputs: SdkPerpetualsCancelOrdersPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewCancelOrdersResponse>;
10231
+ get24hrStats(): Promise<PerpetualsMarket24hrStats>;
10052
10232
  /**
10053
- * Preview the effects of setting leverage for a given market.
10054
- *
10055
- * The preview returns:
10056
- * - The position after the leverage change (`updatedPosition`)
10057
- * - The collateral delta required/produced (`collateralChange`)
10233
+ * Fetch the full orderbook snapshot for this market.
10058
10234
  *
10059
- * @param inputs.marketId - Market whose leverage you want to adjust.
10060
- * @param inputs.leverage - Target leverage value.
10061
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
10235
+ * @returns Object containing `orderbook`.
10062
10236
  *
10063
- * @returns Either:
10064
- * - `{ updatedPosition, collateralChange }`, or
10065
- * - `{ error }`.
10237
+ * @example
10238
+ * ```ts
10239
+ * const { orderbook } = await market.getOrderbook();
10240
+ * console.log(orderbook.bids[0], orderbook.asks[0]);
10241
+ * ```
10066
10242
  */
10067
- getSetLeveragePreview(inputs: {
10068
- marketId: PerpetualsMarketId;
10069
- leverage: number;
10070
- }, abortSignal?: AbortSignal): Promise<{
10071
- updatedPosition: PerpetualsPosition;
10072
- collateralChange: number;
10073
- } | {
10074
- error: string;
10243
+ getOrderbook(): Promise<{
10244
+ orderbook: PerpetualsOrderbook;
10075
10245
  }>;
10076
10246
  /**
10077
- * Preview the effects of allocating/deallocating collateral for the position in
10078
- * a given market.
10247
+ * Compute the maximum order size that can be placed by a given account
10248
+ * in this market, under optional leverage and price assumptions.
10079
10249
  *
10080
- * Semantics:
10081
- * - Positive `collateralChange` previews allocation (moving collateral into the market).
10082
- * - Negative `collateralChange` previews deallocation (moving collateral out of the market).
10250
+ * This is a common frontend helper for:
10251
+ * - "max size" buttons
10252
+ * - input validation against risk limits
10083
10253
  *
10084
- * @param inputs.marketId - Market of whose position you want to allocate/deallocate
10085
- * collateral to/from.
10086
- * @param inputs.collateralChange - The target collateral change (a positive number
10087
- * for allocating collateral, negative for deallocating collateral).
10088
- * @param abortSignal - Optional `AbortSignal` to cancel the request.
10254
+ * **Note:** This is routed through the `account` namespace because it depends on
10255
+ * the account's collateral and positions.
10089
10256
  *
10090
- * @returns Either:
10091
- * - `{ updatedPosition, collateralChange }`, or
10092
- * - `{ error }`.
10257
+ * @param inputs.accountId - Perpetuals account ID.
10258
+ * @param inputs.side - Order side (Bid/Ask).
10259
+ * @param inputs.leverage - Optional assumed leverage.
10260
+ * @param inputs.price - Optional assumed price (e.g. for limit orders).
10261
+ *
10262
+ * @returns `{ maxOrderSize }` in base units (scaled integer as `bigint`).
10263
+ *
10264
+ * @example
10265
+ * ```ts
10266
+ * const { maxOrderSize } = await market.getMaxOrderSize({
10267
+ * accountId: 123n,
10268
+ * side: PerpetualsOrderSide.Bid,
10269
+ * leverage: 5,
10270
+ * });
10271
+ * ```
10093
10272
  */
10094
- getEditCollateralPreview(inputs: {
10095
- marketId: PerpetualsMarketId;
10096
- collateralChange: Balance;
10097
- }, abortSignal?: AbortSignal): Promise<{
10098
- updatedPosition: PerpetualsPosition;
10099
- collateralChange: number;
10100
- } | {
10101
- error: string;
10273
+ getMaxOrderSize: (inputs: Omit<ApiPerpetualsMaxOrderSizeBody, "marketId">) => Promise<{
10274
+ maxOrderSize: bigint;
10102
10275
  }>;
10103
10276
  /**
10104
- * Fetch stop-order ticket data for this account, using an off-chain signed
10105
- * payload.
10277
+ * Market-level preview of placing a market order.
10106
10278
  *
10107
- * Typical flow:
10108
- * 1) Call {@link getStopOrdersMessageToSign} to construct a deterministic payload
10109
- * 2) Sign the payload with the wallet
10110
- * 3) Provide the signed payload to this method to fetch stop order data
10279
+ * Unlike {@link PerpetualsAccount.getPlaceMarketOrderPreview}, this version:
10280
+ * - Calls `account/previews/place-market-order`
10281
+ * - Explicitly sets `accountId: undefined`, allowing a “generic” preview that
10282
+ * doesn’t rely on a specific account’s on-chain positions/collateral.
10111
10283
  *
10112
- * @param inputs.bytes - Serialized message that was signed (e.g. JSON string).
10113
- * @param inputs.signature - Signature over `bytes`.
10114
- * @param inputs.marketIds - Optional subset of markets to filter results by.
10284
+ * @param inputs - {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
10285
+ * @param abortSignal - Optional abort signal to cancel the request.
10115
10286
  *
10116
- * @returns {@link ApiPerpetualsStopOrderDatasResponse} containing `stopOrderDatas`.
10287
+ * @returns Either `{ error }` or a preview containing the simulated updated position,
10288
+ * slippage, filled/posted sizes, collateral change, and execution price.
10117
10289
  */
10118
- getStopOrderDatas(inputs: {
10119
- bytes: string;
10120
- signature: string;
10121
- marketIds?: PerpetualsMarketId[];
10122
- }): Promise<ApiPerpetualsStopOrderDatasResponse>;
10290
+ getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10123
10291
  /**
10124
- * Fetch paginated collateral-change history for this account, including
10125
- * deposits, withdrawals, funding settlements, liquidations, etc.
10292
+ * Market-level preview of placing a limit order.
10126
10293
  *
10127
- * Pagination:
10128
- * - Use `beforeTimestampCursor` to fetch older entries.
10129
- * - The API returns a `nextBeforeTimestampCursor` to continue pagination.
10294
+ * Similar to {@link getPlaceMarketOrderPreview}, this uses:
10295
+ * - `account/previews/place-limit-order`
10296
+ * - `accountId: undefined`
10130
10297
  *
10131
- * @param inputs.beforeTimestampCursor - Optional cursor for pagination.
10132
- * @param inputs.limit - Optional limit per page.
10298
+ * @param inputs - {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
10299
+ * @param abortSignal - Optional abort signal to cancel the request.
10133
10300
  *
10134
- * @returns {@link ApiPerpetualsAccountCollateralHistoryResponse} containing
10135
- * an array of changes and a `nextBeforeTimestampCursor`.
10301
+ * @returns Either `{ error }` or a preview describing the simulated post-order state.
10136
10302
  */
10137
- getCollateralHistory(inputs: Omit<ApiPerpetualsAccountCollateralHistoryBody, "accountId">): Promise<ApiPerpetualsAccountCollateralHistoryResponse>;
10303
+ getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10138
10304
  /**
10139
- * Fetch paginated order history for this account.
10305
+ * Market-level preview of placing a scale order.
10140
10306
  *
10141
- * This endpoint is distinct from {@link getOrderDatas}:
10142
- * - `getOrderDatas` resolves current/pending orders based on the snapshot.
10143
- * - `getOrderHistory` returns historical order events (fills, cancels, etc.)
10144
- * over time with cursor-based pagination.
10307
+ * Similar to {@link getPlaceLimitOrderPreview}, this uses:
10308
+ * - `account/previews/place-scale-order`
10309
+ * - `accountId: undefined`
10145
10310
  *
10146
- * @param inputs.beforeTimestampCursor - Optional cursor for pagination.
10147
- * @param inputs.limit - Optional limit per page.
10311
+ * @param inputs - {@link SdkPerpetualsPlaceScaleOrderPreviewInputs}.
10312
+ * @param abortSignal - Optional abort signal to cancel the request.
10148
10313
  *
10149
- * @returns {@link ApiPerpetualsAccountOrderHistoryResponse} containing a list of
10150
- * orders and a `nextBeforeTimestampCursor`.
10314
+ * @returns Either `{ error }` or a preview describing the simulated post-order state.
10151
10315
  */
10152
- getOrderHistory(inputs: Omit<ApiPerpetualsAccountOrderHistoryBody, "accountId">): Promise<ApiPerpetualsAccountOrderHistoryResponse>;
10316
+ getPlaceScaleOrderPreview(inputs: SdkPerpetualsPlaceScaleOrderPreviewInputs, abortSignal?: AbortSignal): Promise<ApiPerpetualsPreviewPlaceOrderResponse>;
10153
10317
  /**
10154
- * Fetch historical margin snapshots for this account over a time range.
10318
+ * Fetch paginated order history for this market.
10155
10319
  *
10156
- * This endpoint returns time-series margin data suitable for charting UI
10157
- * such as equity and available collateral over time.
10320
+ * This is market-wide (public) history, not scoped to any account.
10158
10321
  *
10159
- * Notes:
10160
- * - This is an account-level view (aggregated across markets).
10322
+ * @param inputs.beforeTimestampCursor - Optional pagination cursor.
10323
+ * @param inputs.limit - Optional page size.
10161
10324
  *
10162
- * @param inputs - {@link ApiPerpetualsAccountMarginHistoryBody} without `accountId`.
10163
- * @returns {@link ApiPerpetualsAccountMarginHistoryResponse} containing `marginHistoryDatas`.
10325
+ * @returns {@link ApiPerpetualsMarketOrderHistoryResponse} containing:
10326
+ * - `orders`
10327
+ * - `nextBeforeTimestampCursor`
10164
10328
  */
10165
- getMarginHistory(inputs: Omit<ApiPerpetualsAccountMarginHistoryBody, "accountId">): Promise<ApiPerpetualsAccountMarginHistoryResponse>;
10329
+ getOrderHistory(inputs: Omit<ApiPerpetualsMarketOrderHistoryBody, "marketId">): Promise<ApiPerpetualsMarketOrderHistoryResponse>;
10166
10330
  /**
10167
- * Build a transaction that grants an Agent Wallet (assistant permissions) for this perpetuals account.
10168
- *
10169
- * The returned transaction must be signed and submitted by the **account admin** wallet.
10170
- * After execution, `recipientAddress` can execute supported trading actions on behalf of this account.
10331
+ * Fetch the current prices for this market.
10171
10332
  *
10172
- * Agent wallets can perform all supported actions **except**:
10173
- * - withdrawing collateral, and
10174
- * - granting or revoking other agent wallets.
10333
+ * Internally calls {@link Perpetuals.getPrices} and returns the first result.
10175
10334
  *
10176
- * @param inputs.recipientAddress Wallet address to receive agent permissions.
10177
- * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.
10178
- * @throws If this instance represents a vault account (agent wallets are account-only).
10335
+ * @returns `{ marketId, basePrice, collateralPrice, midPrice, markPrice }`.
10336
+ *
10337
+ * @remarks
10338
+ * This method instantiates a new {@link Perpetuals} client using `this.config`.
10339
+ * If you rely on a shared api, call `perps.getPrices(...)` directly instead.
10179
10340
  */
10180
- getGrantAgentWalletTx(inputs: {
10181
- recipientAddress: SuiAddress;
10182
- tx?: Transaction;
10183
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
10184
- tx: Transaction;
10341
+ getPrices(): Promise<{
10342
+ marketId: PerpetualsMarketId;
10343
+ basePrice: number;
10344
+ collateralPrice: number;
10345
+ midPrice: number | undefined;
10346
+ markPrice: number;
10185
10347
  }>;
10186
10348
  /**
10187
- * Build a transaction that revokes an Agent Wallet (assistant capability) from this perpetuals account.
10349
+ * Compute the remaining time until the next funding event, in milliseconds.
10188
10350
  *
10189
- * The returned transaction must be signed and submitted by the **account admin** wallet.
10190
- * After execution, the revoked wallet immediately loses its delegated permissions.
10351
+ * @returns `nextFundingTimeMs() - Date.now()`.
10191
10352
  *
10192
- * @param inputs.accountCapId Object ID of the assistant capability to revoke.
10193
- * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.
10194
- * @throws If this instance represents a vault account (agent wallets are account-only).
10353
+ * @remarks
10354
+ * If the next funding timestamp does not fit safely into a JS `number`,
10355
+ * {@link nextFundingTimeMs} returns `Number.MAX_SAFE_INTEGER`, and the
10356
+ * difference may be very large.
10195
10357
  */
10196
- getRevokeAgentWalletTx(inputs: {
10197
- accountCapId: ObjectId;
10198
- tx?: Transaction;
10199
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
10200
- tx: Transaction;
10201
- }>;
10358
+ timeUntilNextFundingMs: () => Timestamp;
10202
10359
  /**
10203
- * Find the current position for a given market ID, if any.
10360
+ * Get the scheduled timestamp for the next funding event, in milliseconds.
10204
10361
  *
10205
- * @param inputs.marketId - Market ID to search for.
10206
- * @returns {@link PerpetualsPosition} if found, otherwise `undefined`.
10362
+ * Safety behavior:
10363
+ * - If `marketData.nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,
10364
+ * this returns `Number.MAX_SAFE_INTEGER`.
10365
+ *
10366
+ * @returns Next funding timestamp (ms) as a JS `number`.
10207
10367
  */
10208
- positionForMarketId(inputs: {
10209
- marketId: PerpetualsMarketId;
10210
- }): PerpetualsPosition | undefined;
10368
+ nextFundingTimeMs: () => Timestamp;
10211
10369
  /**
10212
- * Filter a list of stop orders to only include non-SL/TP orders.
10213
- *
10214
- * A stop order is considered SL/TP if it appears in the combined set of
10215
- * SL/TP orders across **all** markets (see {@link slTpStopOrderDatas}).
10370
+ * Estimated funding rate per period for this market.
10216
10371
  *
10217
- * Note:
10218
- * - This implementation uses JSON string equality to compare objects.
10219
- * This is pragmatic but assumes stable field ordering and identical shapes.
10372
+ * This is read directly from `marketData.estimatedFundingRate`.
10220
10373
  *
10221
- * @param inputs.stopOrderDatas - Full array of stop-order ticket data.
10222
- * @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
10374
+ * @returns Estimated funding rate as a fraction (e.g. `0.01` = 1%).
10223
10375
  */
10224
- nonSlTpStopOrderDatas(inputs: {
10225
- stopOrderDatas: PerpetualsStopOrderData[];
10226
- }): PerpetualsStopOrderData[] | undefined;
10376
+ estimatedFundingRate: () => Percentage;
10227
10377
  /**
10228
- * Extract all SL/TP-style stop orders across **all** markets for this
10229
- * account.
10378
+ * Calculate the collateral required to support an order given leverage and prices.
10230
10379
  *
10231
- * SL/TP orders are stop orders which:
10232
- * - Have an `slTp` payload, and
10233
- * - Target the opposite side of the current position.
10380
+ * The computed collateral is based on the *remaining* unfilled size:
10381
+ * `remaining = initialSize - filledSize`.
10234
10382
  *
10235
- * This combines:
10236
- * - "Full" SL/TP orders (size >= `i64MaxBigInt`)
10237
- * - "Partial" SL/TP orders (size < `i64MaxBigInt`)
10383
+ * USD requirement:
10384
+ * ```text
10385
+ * remainingBase * indexPrice * initialMarginRatio
10386
+ * ```
10387
+ * where `initialMarginRatio = 1 / leverage` (or 1 if leverage is falsy).
10238
10388
  *
10239
- * The "full vs partial" distinction is a protocol convention: some systems
10240
- * encode “close entire position” using a sentinel max size.
10389
+ * @param inputs.leverage - Target leverage for the order (>= 1).
10390
+ * @param inputs.orderData - Order data containing `initialSize` and `filledSize`.
10391
+ * @param inputs.indexPrice - Index/oracle price of the base asset.
10392
+ * @param inputs.collateralPrice - Price of the collateral asset.
10241
10393
  *
10242
- * @param inputs.stopOrderDatas - Full list of stop-order tickets.
10243
- * @returns Array of SL/TP stop orders, or `undefined` if none exist.
10394
+ * @returns Object with:
10395
+ * - `collateralUsd`: required collateral in USD
10396
+ * - `collateral`: required collateral in collateral coin units
10244
10397
  */
10245
- slTpStopOrderDatas(inputs: {
10246
- stopOrderDatas: PerpetualsStopOrderData[];
10247
- }): PerpetualsStopOrderData[] | undefined;
10398
+ calcCollateralUsedForOrder: (inputs: {
10399
+ leverage: number;
10400
+ orderData: PerpetualsOrderData;
10401
+ indexPrice: number;
10402
+ collateralPrice: number;
10403
+ }) => {
10404
+ collateral: number;
10405
+ collateralUsd: number;
10406
+ };
10248
10407
  /**
10249
- * Filter stop orders for a single market to only include non-SL/TP orders.
10408
+ * Get the base-asset lot size for this market as a `number`.
10250
10409
  *
10251
- * Uses {@link slTpStopOrderDatasForPosition} under the hood.
10410
+ * Order sizes must be multiples of this lot size.
10252
10411
  *
10253
- * @param inputs.marketId - Market ID to filter for.
10254
- * @param inputs.stopOrderDatas - Full list of stop orders.
10255
- * @returns Non-SL/TP stop orders for the given market, or `undefined` if none exist.
10412
+ * @returns Lot size in base asset units.
10256
10413
  */
10257
- nonSlTpStopOrderDatasForPosition(inputs: {
10258
- marketId: PerpetualsMarketId;
10259
- stopOrderDatas: PerpetualsStopOrderData[];
10260
- }): PerpetualsStopOrderData[] | undefined;
10414
+ lotSize(): number;
10261
10415
  /**
10262
- * Categorize stop orders for a specific market into:
10263
- * - A "full" SL/TP order (size >= `i64MaxBigInt`) if any.
10264
- * - A set of "partial" SL/TP orders (size < `i64MaxBigInt`).
10416
+ * Get the minimal price tick size for this market as a `number`.
10265
10417
  *
10266
- * SL/TP stop orders are defined as:
10267
- * - Market ID matches the input market.
10268
- * - `slTp` field is present.
10269
- * - Order side is opposite of the position side.
10270
- * - At least a `stopLossIndexPrice` or `takeProfitIndexPrice` is set.
10418
+ * Limit prices must be multiples of this tick size.
10271
10419
  *
10272
- * Notes on matching:
10273
- * - The side comparison uses the current position side derived from the account snapshot.
10274
- * - If `baseAssetAmount === 0` (no effective position), the method returns no SL/TP orders.
10420
+ * @returns Tick size in quote units (e.g. USD).
10421
+ */
10422
+ tickSize(): number;
10423
+ /**
10424
+ * Get the maximum theoretical leverage for this market.
10275
10425
  *
10276
- * @param inputs.marketId - Market to categorize stop orders for.
10277
- * @param inputs.stopOrderDatas - Full list of stop orders.
10426
+ * Computed as:
10427
+ * ```ts
10428
+ * 1 / marginRatioInitial
10429
+ * ```
10278
10430
  *
10279
- * @returns Object containing:
10280
- * - `fullSlTpOrder` (if any)
10281
- * - `partialSlTpOrders` (if any, otherwise `undefined`)
10431
+ * @returns Maximum leverage.
10282
10432
  */
10283
- slTpStopOrderDatasForPosition(inputs: {
10284
- marketId: PerpetualsMarketId;
10285
- stopOrderDatas: PerpetualsStopOrderData[];
10286
- }): {
10287
- fullSlTpOrder: PerpetualsStopOrderData | undefined;
10288
- partialSlTpOrders: PerpetualsStopOrderData[] | undefined;
10289
- };
10290
- slTpStopOrderDatasForLimitOrder(inputs: {
10291
- stopOrderDatas: PerpetualsStopOrderData[];
10292
- limitOrderId: PerpetualsOrderId;
10293
- }): {
10294
- fullSlTpOrder: PerpetualsStopOrderData | undefined;
10295
- partialSlTpOrders: PerpetualsStopOrderData[] | undefined;
10296
- };
10297
- orderDatas(): PerpetualsOrderData[];
10433
+ maxLeverage(): number;
10298
10434
  /**
10299
- * Convenience accessor for the account's available collateral (in coin units).
10435
+ * Get the initial margin ratio for this market.
10300
10436
  *
10301
- * This is the amount of collateral not currently locked/allocated across markets,
10302
- * as represented by the backend response.
10437
+ * This is the minimum margin required when opening a position.
10303
10438
  *
10304
- * @returns Available collateral as a `number`.
10439
+ * @returns Initial margin ratio as a fraction (e.g. 0.05 = 20x).
10305
10440
  */
10306
- collateral(): number;
10441
+ initialMarginRatio(): number;
10307
10442
  /**
10308
- * Check whether this {@link PerpetualsAccount} is vault-backed.
10443
+ * Get the maintenance margin ratio for this market.
10309
10444
  *
10310
- * @returns `true` if the underlying `accountCap` is a vault cap; otherwise `false`.
10445
+ * Falling below this ratio may trigger liquidation.
10446
+ *
10447
+ * @returns Maintenance margin ratio as a fraction.
10311
10448
  */
10312
- isVault(): boolean;
10449
+ maintenanceMarginRatio(): number;
10313
10450
  /**
10314
- * Resolve the owner wallet address of this account or vault.
10315
- *
10316
- * - For direct accounts, returns the cap's `walletAddress` field.
10317
- * - For vault-backed accounts, returns the vault cap's `ownerAddress`.
10451
+ * Round a price to the nearest valid tick for this market.
10318
10452
  *
10319
- * Naming note:
10320
- * - Some types use `walletAddress` for direct ownership. For vault-backed accounts
10321
- * the analogous field is `ownerAddress`.
10453
+ * Rounding mode:
10454
+ * - `floor: true` => round down
10455
+ * - `ceil: true` => round up
10456
+ * - neither => nearest tick (`Math.round`)
10322
10457
  *
10323
- * @returns Owner wallet {@link SuiAddress}.
10458
+ * @param inputs.price - Raw price to round.
10459
+ * @param inputs.floor - Force floor rounding.
10460
+ * @param inputs.ceil - Force ceil rounding.
10461
+ * @returns Price snapped to the market tick size.
10324
10462
  */
10325
- ownerAddress(): SuiAddress;
10463
+ roundToValidPrice: (inputs: {
10464
+ price: number;
10465
+ floor?: boolean;
10466
+ ceil?: boolean;
10467
+ }) => number;
10326
10468
  /**
10327
- * Get the underlying account object ID.
10469
+ * Round a price to the nearest valid tick as a fixed-point `bigint` (1e9 precision).
10328
10470
  *
10329
- * This is the on-chain object that holds the account's state and positions.
10471
+ * This is helpful when you need the on-chain representation directly
10472
+ * (e.g. order price fields stored in 9-decimal fixed).
10330
10473
  *
10331
- * @returns {@link ObjectId} of the account object.
10474
+ * @param inputs.price - Raw price as a JS number.
10475
+ * @param inputs.floor - Force floor rounding.
10476
+ * @param inputs.ceil - Force ceil rounding.
10477
+ * @returns Tick-snapped price scaled by `1e9`.
10332
10478
  */
10333
- accountObjectId(): ObjectId;
10479
+ roundToValidPriceBigInt: (inputs: {
10480
+ price: number;
10481
+ floor?: boolean;
10482
+ ceil?: boolean;
10483
+ }) => bigint;
10334
10484
  /**
10335
- * Get the numeric perpetuals account ID.
10485
+ * Round a base-asset size to the nearest valid lot size for this market.
10336
10486
  *
10337
- * This is the protocol-level identifier (bigint-derived) used across API calls.
10487
+ * Rounding mode:
10488
+ * - `floor: true` => round down
10489
+ * - `ceil: true` => round up
10490
+ * - neither => nearest lot (`Math.round`)
10338
10491
  *
10339
- * @returns {@link PerpetualsAccountId} for this account.
10492
+ * @param inputs.size - Raw size in base asset units.
10493
+ * @param inputs.floor - Force floor rounding.
10494
+ * @param inputs.ceil - Force ceil rounding.
10495
+ * @returns Size snapped to the market lot size.
10340
10496
  */
10341
- accountId(): PerpetualsAccountId;
10497
+ roundToValidSize: (inputs: {
10498
+ size: number;
10499
+ floor?: boolean;
10500
+ ceil?: boolean;
10501
+ }) => number;
10342
10502
  /**
10343
- * Get the account cap object ID, if this is a direct account.
10503
+ * Round a base-asset size to the nearest valid lot as a fixed-point `bigint` (1e9 precision).
10344
10504
  *
10345
- * Direct accounts are controlled via an on-chain “cap” object. Vault-backed
10346
- * accounts are controlled via vault caps and do not expose a direct account-cap ID.
10505
+ * @param inputs.size - Raw base size as a JS number.
10506
+ * @param inputs.floor - Force floor rounding.
10507
+ * @param inputs.ceil - Force ceil rounding.
10508
+ * @returns Lot-snapped size scaled by `1e9`.
10509
+ */
10510
+ roundToValidSizeBigInt: (inputs: {
10511
+ size: number;
10512
+ floor?: boolean;
10513
+ ceil?: boolean;
10514
+ }) => bigint;
10515
+ /**
10516
+ * Construct an "empty" position object for this market.
10347
10517
  *
10348
- * @throws If called for a vault-backed account.
10518
+ * Useful when an account has no open position but downstream UI/calculations
10519
+ * expect a {@link PerpetualsPosition}-shaped object.
10349
10520
  *
10350
- * @returns {@link ObjectId} of the account cap.
10521
+ * @returns A zeroed-out {@link PerpetualsPosition} for `this.marketId`.
10351
10522
  */
10352
- accountCapId(): ObjectId;
10353
- }
10354
-
10355
- declare class PerpetualsOrderUtils {
10356
- static orderId: (price: bigint, counter: bigint, side: PerpetualsOrderSide) => PerpetualsOrderId;
10357
- private static orderIdAsk;
10358
- private static orderIdBid;
10359
- static price: (orderId: PerpetualsOrderId) => bigint;
10360
- private static priceAsk;
10361
- private static priceBid;
10362
- static counter: (orderId: PerpetualsOrderId) => bigint;
10363
- static isAsk: (orderId: PerpetualsOrderId) => boolean;
10523
+ emptyPosition: () => PerpetualsPosition;
10364
10524
  }
10365
10525
 
10366
10526
  /**
@@ -10399,7 +10559,7 @@ declare class PerpetualsOrderUtils {
10399
10559
  */
10400
10560
  declare class PerpetualsVault extends Caller {
10401
10561
  readonly vaultObject: PerpetualsVaultObject;
10402
- readonly Provider?: AftermathApi | undefined;
10562
+ readonly api?: AftermathApi | undefined;
10403
10563
  /**
10404
10564
  * Vault-level protocol limits and UI-friendly constraints.
10405
10565
  *
@@ -10442,10 +10602,10 @@ declare class PerpetualsVault extends Caller {
10442
10602
  *
10443
10603
  * @param vaultObject - Raw on-chain vault object snapshot.
10444
10604
  * @param config - Optional {@link CallerConfig} (network, auth, base URL).
10445
- * @param Provider - Optional shared {@link AftermathApi} provider. When provided,
10605
+ * @param api - Optional shared {@link AftermathApi} provider. When provided,
10446
10606
  * transaction builders will serialize {@link Transaction}s into `txKind`.
10447
10607
  */
10448
- constructor(vaultObject: PerpetualsVaultObject, config?: CallerConfig, Provider?: AftermathApi | undefined);
10608
+ constructor(vaultObject: PerpetualsVaultObject, config?: CallerConfig, api?: AftermathApi | undefined);
10449
10609
  /**
10450
10610
  * Build a `process-force-withdraw-request` transaction.
10451
10611
  *
@@ -10843,6 +11003,17 @@ declare class PerpetualsVault extends Caller {
10843
11003
  }) => number;
10844
11004
  }
10845
11005
 
11006
+ declare class PerpetualsOrderUtils {
11007
+ static orderId: (price: bigint, counter: bigint, side: PerpetualsOrderSide) => PerpetualsOrderId;
11008
+ private static orderIdAsk;
11009
+ private static orderIdBid;
11010
+ static price: (orderId: PerpetualsOrderId) => bigint;
11011
+ private static priceAsk;
11012
+ private static priceBid;
11013
+ static counter: (orderId: PerpetualsOrderId) => bigint;
11014
+ static isAsk: (orderId: PerpetualsOrderId) => boolean;
11015
+ }
11016
+
10846
11017
  /**
10847
11018
  * High-level client for interacting with Aftermath Perpetuals.
10848
11019
  *
@@ -10863,8 +11034,7 @@ declare class PerpetualsVault extends Caller {
10863
11034
  * ```ts
10864
11035
  * import { Aftermath } from "@aftermath/sdk";
10865
11036
  *
10866
- * const afSdk = new Aftermath("MAINNET");
10867
- * await afSdk.init();
11037
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
10868
11038
  *
10869
11039
  * const perps = afSdk.Perpetuals();
10870
11040
  *
@@ -10888,7 +11058,7 @@ declare class PerpetualsVault extends Caller {
10888
11058
  * ```
10889
11059
  */
10890
11060
  declare class Perpetuals extends Caller {
10891
- readonly Provider?: AftermathApi | undefined;
11061
+ readonly api?: AftermathApi | undefined;
10892
11062
  /**
10893
11063
  * Helper namespace for order-specific utilities such as parsing order IDs,
10894
11064
  * extracting price bits, etc.
@@ -10900,16 +11070,16 @@ declare class Perpetuals extends Caller {
10900
11070
  * Creates a new Perpetuals client.
10901
11071
  *
10902
11072
  * @param config - Optional caller configuration (network, auth token, etc.).
10903
- * @param Provider - Optional shared {@link AftermathApi} provider instance. When
11073
+ * @param api - Optional shared {@link AftermathApi} provider instance. When
10904
11074
  * provided, transaction-building helpers can derive serialized `txKind`
10905
- * from a {@link Transaction} object via `Provider.Transactions().fetchBase64TxKindFromTx`.
11075
+ * from a {@link Transaction} object via `api.Transactions().fetchBase64TxKindFromTx`.
10906
11076
  *
10907
11077
  * @remarks
10908
11078
  * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning:
10909
11079
  * - HTTP calls resolve under `/perpetuals/...`
10910
11080
  * - Websocket calls resolve under `/perpetuals/ws/...`
10911
11081
  */
10912
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
11082
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
10913
11083
  /**
10914
11084
  * Fetch all perpetual markets for a given collateral coin type.
10915
11085
  *
@@ -11720,7 +11890,7 @@ declare class Perpetuals extends Caller {
11720
11890
  onClose?: (ev: CloseEvent) => void;
11721
11891
  }): {
11722
11892
  ws: WebSocket;
11723
- subscribeMarket: ({ marketId, }: {
11893
+ subscribeMarket: ({ marketId }: {
11724
11894
  marketId: PerpetualsMarketId;
11725
11895
  }) => void;
11726
11896
  unsubscribeMarket: ({ marketId, }: {
@@ -11742,7 +11912,7 @@ declare class Perpetuals extends Caller {
11742
11912
  signature: string;
11743
11913
  } | undefined;
11744
11914
  }) => void;
11745
- subscribeOracle: ({ marketId, }: {
11915
+ subscribeOracle: ({ marketId }: {
11746
11916
  marketId: PerpetualsMarketId;
11747
11917
  }) => void;
11748
11918
  unsubscribeOracle: ({ marketId, }: {
@@ -11841,7 +12011,7 @@ declare class ReferralVault extends Caller {
11841
12011
  *
11842
12012
  * @deprecated Use `Referral` class instead
11843
12013
  * @param config - Optional caller configuration, including Sui network and access token.
11844
- * @param Provider - An optional `AftermathApi` provider instance for referral-specific methods.
12014
+ * @param api - An optional `AftermathApi` provider instance for referral-specific methods.
11845
12015
  */
11846
12016
  constructor(config?: CallerConfig);
11847
12017
  /**
@@ -11853,8 +12023,7 @@ declare class ReferralVault extends Caller {
11853
12023
  *
11854
12024
  * @example
11855
12025
  * ```typescript
11856
- * const afSdk = new Aftermath("MAINNET");
11857
- * await afSdk.init(); // initialize provider
12026
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
11858
12027
  *
11859
12028
  * const referralVault = afSdk.ReferralVault();
11860
12029
  *
@@ -11876,7 +12045,7 @@ declare class ReferralVault extends Caller {
11876
12045
  * @example
11877
12046
  * ```typescript
11878
12047
  * // Create provider
11879
- * const router = (new Aftermath("MAINNET")).Router();
12048
+ * const router = (await Aftermath.create({ network: "MAINNET" })).Router();
11880
12049
  * // Retrieve 24h volume
11881
12050
  * const volume24h = await router.getVolume24hrs();
11882
12051
  * // Get supported coins
@@ -11904,8 +12073,7 @@ declare class Router extends Caller {
11904
12073
  *
11905
12074
  * @example
11906
12075
  * ```typescript
11907
- * const afSdk = new Aftermath("MAINNET");
11908
- * await afSdk.init(); // initialize provider
12076
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
11909
12077
  *
11910
12078
  * const router = afSdk.Router();
11911
12079
  * ```
@@ -12097,8 +12265,7 @@ declare class Router extends Caller {
12097
12265
  * @example
12098
12266
  * ```typescript
12099
12267
  * // Instantiate Staking
12100
- * const sdk = new Aftermath("MAINNET");
12101
- * await sdk.init();
12268
+ * const sdk = await Aftermath.create({ network: "MAINNET" });
12102
12269
  * const staking = sdk.Staking();
12103
12270
  *
12104
12271
  * // Get active validators
@@ -12113,7 +12280,7 @@ declare class Router extends Caller {
12113
12280
  * ```
12114
12281
  */
12115
12282
  declare class Staking extends Caller {
12116
- readonly Provider?: AftermathApi | undefined;
12283
+ readonly api?: AftermathApi | undefined;
12117
12284
  /**
12118
12285
  * Contains constants for staking, including protocol fees, default validator
12119
12286
  * fee, and staking/unstaking bounds. Also defines the maximum external fee
@@ -12167,9 +12334,9 @@ declare class Staking extends Caller {
12167
12334
  * staking contracts.
12168
12335
  *
12169
12336
  * @param config - Optional configuration containing the Sui network and/or access token.
12170
- * @param Provider - Optional instance of `AftermathApi` for building transactions.
12337
+ * @param api - Optional instance of `AftermathApi` for building transactions.
12171
12338
  */
12172
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
12339
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
12173
12340
  /**
12174
12341
  * Fetches the list of currently active validators on the Sui network.
12175
12342
  *
@@ -12461,151 +12628,12 @@ declare class Staking extends Caller {
12461
12628
  }): Percentage;
12462
12629
  /**
12463
12630
  * Returns a provider instance for building transactions. Throws an error
12464
- * if `Provider` is not defined.
12631
+ * if `api` is not defined.
12465
12632
  *
12466
12633
  * @returns An instance of `AftermathApi.Staking`.
12467
- * @throws Will throw if the `Provider` is undefined.
12468
- */
12469
- private useProvider;
12470
- }
12471
-
12472
- /**
12473
- * The `GasPools` class provides methods for interacting with shared gas pool
12474
- * endpoints on the Aftermath platform. This includes querying pool details
12475
- * and building transactions for creating, depositing into, withdrawing from,
12476
- * sponsoring, granting access to, and revoking access from gas pools.
12477
- *
12478
- * @example
12479
- * ```typescript
12480
- * const gasPools = new GasPools({ network: "MAINNET" });
12481
- *
12482
- * // Get gas pool details
12483
- * const pool = await gasPools.getPool({
12484
- * walletAddress: "0x..."
12485
- * });
12486
- *
12487
- * // Build a deposit transaction
12488
- * const { tx } = await gasPools.getDepositTx({
12489
- * walletAddress: "0x...",
12490
- * depositAmount: 100_000_000n
12491
- * });
12492
- * ```
12493
- */
12494
- declare class GasPools extends Caller {
12495
- readonly Provider?: AftermathApi | undefined;
12496
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
12497
- /**
12498
- * Fetches the gas pool details for a given wallet address.
12499
- *
12500
- * @param inputs - {@link ApiGasPoolBody}
12501
- * @returns {@link ApiGasPoolResponse} containing pool ID, balance, and whitelisted addresses.
12502
- */
12503
- getPool(inputs: ApiGasPoolBody): Promise<ApiGasPoolResponse>;
12504
- /**
12505
- * Builds a transaction to create a new gas pool for the given wallet.
12506
- *
12507
- * When `deferShare` is `true`, the response includes `gasPoolArg` and
12508
- * `sharePolicyArg` so you can compose additional commands (e.g. deposit,
12509
- * grant) before calling {@link getShareTx} to finalize.
12510
- *
12511
- * @param inputs.walletAddress - Wallet address to create the gas pool for.
12512
- * @param inputs.initialDepositAmount - Optional initial deposit amount in MIST.
12513
- * @param inputs.deferShare - When true, returns args without sharing yet.
12514
- * @param inputs.tx - Optional transaction to extend.
12515
- * @returns `tx` plus optional `gasPoolArg` and `sharePolicyArg` when deferred.
12516
- */
12517
- getCreateTx(inputs: Omit<ApiGasPoolCreateBody, "txKind"> & {
12518
- tx?: Transaction;
12519
- }): Promise<Omit<ApiGasPoolCreateResponse, "txKind"> & {
12520
- tx: Transaction;
12521
- }>;
12522
- /**
12523
- * Builds a transaction to deposit into the gas pool.
12524
- *
12525
- * Supports SUI and non-SUI deposits. For non-SUI deposits, the input coin
12526
- * is swapped into SUI via the Aftermath router before depositing.
12527
- *
12528
- * @param inputs.walletAddress - Wallet address submitting the deposit.
12529
- * @param inputs.isSponsoredTx - Whether to build the transaction for sponsored gas. Defaults to false.
12530
- * @param inputs.coinType - Coin type to deposit. Defaults to SUI.
12531
- * @param inputs.amount - Amount to deposit (required when sourcing from wallet or for non-SUI).
12532
- * @param inputs.coinArg - PTB coin argument to use as input (if omitted, sourced from wallet).
12533
- * @param inputs.slippage - Slippage tolerance for non-SUI swaps (defaults to 0.01).
12534
- * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
12535
- * @param inputs.tx - Optional transaction to extend.
12536
- * @returns {@link SdkTransactionResponse} with `tx`.
12537
- */
12538
- getDepositTx(inputs: Omit<ApiGasPoolDepositBody, "txKind"> & {
12539
- tx?: Transaction;
12540
- }): Promise<SdkTransactionResponse>;
12541
- /**
12542
- * Builds a transaction to withdraw SUI from the gas pool.
12543
- *
12544
- * When `deferTransfer` is `true`, the withdrawn coin is not transferred.
12545
- * Instead, `withdrawnCoinArg` is returned for further PTB composition.
12546
- *
12547
- * @param inputs.walletAddress - Wallet address submitting the withdrawal.
12548
- * @param inputs.amount - Amount of SUI to withdraw in MIST.
12549
- * @param inputs.recipientAddress - Optional recipient (defaults to `walletAddress`).
12550
- * @param inputs.deferTransfer - When true, returns the withdrawn coin arg instead of transferring.
12551
- * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
12552
- * @param inputs.tx - Optional transaction to extend.
12553
- * @returns `tx` plus optional `withdrawnCoinArg` when deferred.
12554
- */
12555
- getWithdrawTx(inputs: Omit<ApiGasPoolWithdrawBody, "txKind"> & {
12556
- tx?: Transaction;
12557
- }): Promise<Omit<ApiGasPoolWithdrawResponse, "txKind"> & {
12558
- tx: Transaction;
12559
- }>;
12560
- /**
12561
- * Builds a transaction to sponsor (rebate) the transaction sender
12562
- * using SUI from the gas pool.
12563
- *
12564
- * @param inputs.walletAddress - Wallet address submitting the sponsor transaction.
12565
- * @param inputs.amount - Amount of SUI to rebate in MIST.
12566
- * @param inputs.tx - Optional transaction to extend.
12567
- * @returns {@link SdkTransactionResponse} with `tx`.
12568
- */
12569
- getSponsorTx(inputs: Omit<ApiGasPoolSponsorBody, "txKind"> & {
12570
- tx?: Transaction;
12571
- }): Promise<SdkTransactionResponse>;
12572
- /**
12573
- * Builds a transaction to grant another wallet access to the gas pool.
12574
- *
12575
- * @param inputs.walletAddress - Owner wallet address.
12576
- * @param inputs.targetWalletAddress - Wallet address to grant access to.
12577
- * @param inputs.gasPoolArg - Optional gas pool argument from a previously-built PTB command.
12578
- * @param inputs.tx - Optional transaction to extend.
12579
- * @returns {@link SdkTransactionResponse} with `tx`.
12580
- */
12581
- getGrantTx(inputs: Omit<ApiGasPoolGrantBody, "txKind"> & {
12582
- tx?: Transaction;
12583
- }): Promise<SdkTransactionResponse>;
12584
- /**
12585
- * Builds a transaction to revoke another wallet's access to the gas pool.
12586
- *
12587
- * @param inputs.walletAddress - Owner wallet address.
12588
- * @param inputs.targetWalletAddress - Wallet address to revoke access from.
12589
- * @param inputs.tx - Optional transaction to extend.
12590
- * @returns {@link SdkTransactionResponse} with `tx`.
12591
- */
12592
- getRevokeTx(inputs: Omit<ApiGasPoolRevokeBody, "txKind"> & {
12593
- tx?: Transaction;
12594
- }): Promise<SdkTransactionResponse>;
12595
- /**
12596
- * Builds a transaction to share a gas pool that was created with `deferShare: true`.
12597
- *
12598
- * Use this after composing additional commands (deposit, grant, etc.) with
12599
- * the `gasPoolArg` returned by {@link getCreateTx}.
12600
- *
12601
- * @param inputs.gasPoolArg - Gas pool argument from a deferred create.
12602
- * @param inputs.sharePolicyArg - Share policy argument from a deferred create.
12603
- * @param inputs.tx - Optional transaction to extend.
12604
- * @returns {@link SdkTransactionResponse} with `tx`.
12634
+ * @throws Will throw if the `api` is undefined.
12605
12635
  */
12606
- getShareTx(inputs: Omit<ApiGasPoolShareBody, "txKind"> & {
12607
- tx?: Transaction;
12608
- }): Promise<SdkTransactionResponse>;
12636
+ private readonly stakingApi;
12609
12637
  }
12610
12638
 
12611
12639
  /**
@@ -12614,7 +12642,7 @@ declare class GasPools extends Caller {
12614
12642
  * related to the Sui network package IDs.
12615
12643
  */
12616
12644
  declare class Sui extends Caller {
12617
- readonly Provider?: AftermathApi | undefined;
12645
+ readonly api?: AftermathApi | undefined;
12618
12646
  /**
12619
12647
  * Static constants containing important addresses on the Sui network:
12620
12648
  * - `zero`: The zero address (commonly used as a null placeholder).
@@ -12634,9 +12662,9 @@ declare class Sui extends Caller {
12634
12662
  * Creates a new instance of the `Sui` class for fetching chain-level info.
12635
12663
  *
12636
12664
  * @param config - Optional configuration, including the Sui network and an access token.
12637
- * @param Provider - An optional `AftermathApi` instance for advanced transaction building or data fetching.
12665
+ * @param api - An optional `AftermathApi` instance for advanced transaction building or data fetching.
12638
12666
  */
12639
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
12667
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
12640
12668
  /**
12641
12669
  * Fetches the Sui system state summary object, which contains details
12642
12670
  * about the current epoch, validator set, and other protocol-level data.
@@ -12645,8 +12673,7 @@ declare class Sui extends Caller {
12645
12673
  *
12646
12674
  * @example
12647
12675
  * ```typescript
12648
- * const afSdk = new Aftermath("MAINNET");
12649
- * await afSdk.init(); // initialize provider
12676
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
12650
12677
  *
12651
12678
  * const sui = afSdk.Sui();
12652
12679
  *
@@ -12661,8 +12688,8 @@ declare class SuiFren extends Caller {
12661
12688
  readonly suiFren: SuiFrenObject;
12662
12689
  readonly isStaked: boolean;
12663
12690
  readonly isOwned: boolean;
12664
- readonly Provider?: AftermathApi | undefined;
12665
- constructor(suiFren: SuiFrenObject, config?: CallerConfig, isStaked?: boolean, isOwned?: boolean, Provider?: AftermathApi | undefined);
12691
+ readonly api?: AftermathApi | undefined;
12692
+ constructor(suiFren: SuiFrenObject, config?: CallerConfig, isStaked?: boolean, isOwned?: boolean, api?: AftermathApi | undefined);
12666
12693
  suiFrenType(): AnyObjectType;
12667
12694
  properties(): Record<string, string>;
12668
12695
  dynamicFields(): Record<string, string>;
@@ -12683,15 +12710,15 @@ declare class SuiFren extends Caller {
12683
12710
  accessoryType: SuiFrenAccessoryType;
12684
12711
  walletAddress: SuiAddress;
12685
12712
  }): Promise<_mysten_sui_transactions.Transaction>;
12686
- private useProvider;
12713
+ private suiFrensApi;
12687
12714
  }
12688
12715
 
12689
12716
  declare class StakedSuiFren extends Caller {
12690
12717
  readonly info: StakedSuiFrenInfo;
12691
12718
  readonly isOwned: boolean;
12692
- readonly Provider?: AftermathApi | undefined;
12719
+ readonly api?: AftermathApi | undefined;
12693
12720
  readonly suiFren: SuiFren;
12694
- constructor(info: StakedSuiFrenInfo, config?: CallerConfig, isOwned?: boolean, Provider?: AftermathApi | undefined);
12721
+ constructor(info: StakedSuiFrenInfo, config?: CallerConfig, isOwned?: boolean, api?: AftermathApi | undefined);
12695
12722
  mixFee(): Balance;
12696
12723
  suiFrenId(): ObjectId;
12697
12724
  clone(): StakedSuiFren;
@@ -12710,11 +12737,11 @@ declare class StakedSuiFren extends Caller {
12710
12737
  accessoryType: SuiFrenAccessoryType;
12711
12738
  walletAddress: SuiAddress;
12712
12739
  }): Promise<_mysten_sui_transactions.Transaction>;
12713
- private useProvider;
12740
+ private suiFrensApi;
12714
12741
  }
12715
12742
 
12716
12743
  declare class SuiFrens extends Caller {
12717
- readonly Provider?: AftermathApi | undefined;
12744
+ readonly api?: AftermathApi | undefined;
12718
12745
  static readonly constants: {
12719
12746
  mixingFeeCoinType: string;
12720
12747
  protocolFees: {
@@ -12727,7 +12754,7 @@ declare class SuiFrens extends Caller {
12727
12754
  mint: bigint;
12728
12755
  };
12729
12756
  };
12730
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
12757
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
12731
12758
  static calcTotalInternalMixFee(inputs: {
12732
12759
  mixFee1: Balance | undefined;
12733
12760
  mixFee2: Balance | undefined;
@@ -12761,7 +12788,7 @@ declare class SuiFrens extends Caller {
12761
12788
  static suiFrenId(suiFren: SuiFren | StakedSuiFren | undefined): ObjectId | undefined;
12762
12789
  static mixFee(suiFren: SuiFren | StakedSuiFren | undefined): Balance | undefined;
12763
12790
  private static createStakedSuiFrensQueryString;
12764
- private useProvider;
12791
+ private suiFrensApi;
12765
12792
  }
12766
12793
 
12767
12794
  /**
@@ -13078,8 +13105,7 @@ interface ApiDCAsOwnedBody {
13078
13105
  *
13079
13106
  * @example
13080
13107
  * ```typescript
13081
- * const afSdk = new Aftermath("MAINNET");
13082
- * await afSdk.init(); // initialize provider
13108
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13083
13109
  *
13084
13110
  * const dca = afSdk.Dca();
13085
13111
  * ```
@@ -13421,8 +13447,7 @@ interface ApiLimitOrdersActiveOrdersOwnedBody {
13421
13447
  *
13422
13448
  * @example
13423
13449
  * ```typescript
13424
- * const afSdk = new Aftermath("MAINNET");
13425
- * await afSdk.init(); // initialize provider
13450
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13426
13451
  *
13427
13452
  * const limitOrders = afSdk.LimitOrders();
13428
13453
  * ```
@@ -13582,14 +13607,14 @@ interface MultisigData {
13582
13607
  * such as retrieving a multisig address and associated public key for a user.
13583
13608
  */
13584
13609
  declare class Multisig extends Caller {
13585
- readonly Provider?: AftermathApi | undefined;
13610
+ readonly api?: AftermathApi | undefined;
13586
13611
  /**
13587
13612
  * Creates a new instance of `Multisig`.
13588
13613
  *
13589
13614
  * @param config - Optional configuration for the `Caller`, including network and access token.
13590
- * @param Provider - An optional instance of `AftermathApi` to build or fetch multisig data.
13615
+ * @param api - An optional instance of `AftermathApi` to build or fetch multisig data.
13591
13616
  */
13592
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
13617
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
13593
13618
  /**
13594
13619
  * Retrieves a multisig address and corresponding public key for a user based on their
13595
13620
  * provided single public key.
@@ -13600,8 +13625,7 @@ declare class Multisig extends Caller {
13600
13625
  * @example
13601
13626
  * ```typescript
13602
13627
  *
13603
- * const afSdk = new Aftermath("MAINNET");
13604
- * await afSdk.init(); // initialize provider
13628
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13605
13629
  *
13606
13630
  * const multisig = afSdk.Multisig();
13607
13631
  *
@@ -13616,7 +13640,7 @@ declare class Multisig extends Caller {
13616
13640
  * Internal helper to get the configured `Multisig` provider from `AftermathApi`.
13617
13641
  * Throws an error if the provider is not available.
13618
13642
  */
13619
- private useProvider;
13643
+ private readonly multisigApi;
13620
13644
  }
13621
13645
 
13622
13646
  declare class Referrals extends Caller {
@@ -13645,8 +13669,8 @@ declare class Referrals extends Caller {
13645
13669
  }
13646
13670
 
13647
13671
  declare class Rewards extends Caller {
13648
- readonly Provider?: AftermathApi | undefined;
13649
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
13672
+ readonly api?: AftermathApi | undefined;
13673
+ constructor(config?: CallerConfig, api?: AftermathApi | undefined);
13650
13674
  getPoints(inputs: ApiRewardsGetPointsBody): Promise<ApiRewardsGetPointsResponse>;
13651
13675
  getHistory(inputs: ApiRewardsGetHistoryBody): Promise<ApiRewardsGetHistoryResponse>;
13652
13676
  getClaimable(inputs: ApiRewardsGetClaimableBody): Promise<ApiRewardsGetClaimableResponse>;
@@ -13708,8 +13732,7 @@ declare class UserData extends Caller {
13708
13732
  *
13709
13733
  * @example
13710
13734
  * ```typescript
13711
- * const afSdk = new Aftermath("MAINNET");
13712
- * await afSdk.init(); // initialize provider
13735
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13713
13736
  *
13714
13737
  * const userData = afSdk.UserData();
13715
13738
  *
@@ -13797,8 +13820,7 @@ declare class DynamicGas extends Caller {
13797
13820
  *
13798
13821
  * @example
13799
13822
  * ```typescript
13800
- * const afSdk = new Aftermath("MAINNET");
13801
- * await afSdk.init(); // initialize provider
13823
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13802
13824
  *
13803
13825
  * const dynamicGas = afSdk.DynamicGas();
13804
13826
  *
@@ -13839,8 +13861,7 @@ declare class Prices extends Caller {
13839
13861
  * @example
13840
13862
  * ```typescript
13841
13863
  *
13842
- * const afSdk = new Aftermath("MAINNET");
13843
- * await afSdk.init(); // initialize provider
13864
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
13844
13865
  *
13845
13866
  * const prices = afSdk.Prices();
13846
13867
  *
@@ -14867,8 +14888,8 @@ declare class Casting {
14867
14888
  }
14868
14889
 
14869
14890
  declare class CoinApi {
14870
- private readonly Provider;
14871
- constructor(Provider: AftermathApi);
14891
+ private readonly api;
14892
+ constructor(api: AftermathApi);
14872
14893
  fetchCoinWithAmountTx: (inputs: {
14873
14894
  tx: Transaction;
14874
14895
  walletAddress: SuiAddress;
@@ -14896,7 +14917,7 @@ declare class CoinApi {
14896
14917
  }
14897
14918
 
14898
14919
  declare class DcaApi {
14899
- private readonly Provider;
14920
+ private readonly api;
14900
14921
  private static readonly constants;
14901
14922
  readonly addresses: DcaAddresses;
14902
14923
  readonly eventTypes: {
@@ -14905,26 +14926,21 @@ declare class DcaApi {
14905
14926
  closedOrder: AnyObjectType;
14906
14927
  executedTrade: AnyObjectType;
14907
14928
  };
14908
- constructor(Provider: AftermathApi);
14929
+ constructor(api: AftermathApi);
14909
14930
  createCloseOrderTx: (inputs: {
14910
14931
  tx: Transaction;
14911
14932
  allocateCoinType: CoinType;
14912
14933
  buyCoinType: CoinType;
14913
14934
  orderId: ObjectId | TransactionArgument;
14914
14935
  }) => _mysten_sui_transactions.TransactionResult;
14915
- private createdOrderEventType;
14916
- private createdOrderEventTypeV2;
14917
- private closedOrderEventType;
14918
- private executedOrderEventType;
14919
- }
14920
-
14921
- interface MoveErrorsInterface {
14922
- readonly moveErrors: MoveErrors;
14936
+ private readonly createdOrderEventType;
14937
+ private readonly createdOrderEventTypeV2;
14938
+ private readonly closedOrderEventType;
14939
+ private readonly executedOrderEventType;
14923
14940
  }
14924
- type MoveErrors = Record<PackageId, Record<"ANY" | ModuleName, Record<MoveErrorCode, string>>>;
14925
14941
 
14926
14942
  declare class FarmsApi implements MoveErrorsInterface {
14927
- private readonly Provider;
14943
+ private readonly api;
14928
14944
  private static readonly constants;
14929
14945
  readonly addresses: FarmsAddresses;
14930
14946
  readonly objectTypes: {
@@ -14961,10 +14977,10 @@ declare class FarmsApi implements MoveErrorsInterface {
14961
14977
  readonly moveErrors: MoveErrors;
14962
14978
  /**
14963
14979
  * Constructor for FarmsApi
14964
- * @param Provider The AftermathApi provider instance
14980
+ * @param api The AftermathApi provider instance
14965
14981
  * @throws Error if not all required addresses have been set in provider
14966
14982
  */
14967
- constructor(Provider: AftermathApi);
14983
+ constructor(api: AftermathApi);
14968
14984
  /**
14969
14985
  * @deprecated Use the new API method in Farms class instead.
14970
14986
  * Fetches the owner caps for staking pools owned by a specific wallet address
@@ -15840,67 +15856,67 @@ declare class FarmsApi implements MoveErrorsInterface {
15840
15856
  recipientAddress: SuiAddress;
15841
15857
  rewardCoinType: CoinType;
15842
15858
  }, "tx">) => Transaction;
15843
- private eventWrapperType;
15859
+ private readonly eventWrapperType;
15844
15860
  /**
15845
15861
  * Creates the event type for vault creation events
15846
15862
  * @returns Fully qualified event type string
15847
15863
  */
15848
- private createdVaultEventType;
15864
+ private readonly createdVaultEventType;
15849
15865
  /**
15850
15866
  * Creates the event type for reward initialization events
15851
15867
  * @returns Fully qualified event type string
15852
15868
  */
15853
- private initializedRewardEventType;
15869
+ private readonly initializedRewardEventType;
15854
15870
  /**
15855
15871
  * Creates the event type for reward addition events
15856
15872
  * @returns Fully qualified event type string
15857
15873
  */
15858
- private addedRewardEventType;
15874
+ private readonly addedRewardEventType;
15859
15875
  /**
15860
15876
  * Creates the event type for emission increase events
15861
15877
  * @returns Fully qualified event type string
15862
15878
  */
15863
- private increasedEmissionsEventType;
15879
+ private readonly increasedEmissionsEventType;
15864
15880
  /**
15865
15881
  * Creates the event type for emission update events
15866
15882
  * @returns Fully qualified event type string
15867
15883
  */
15868
- private updatedEmissionsEventType;
15884
+ private readonly updatedEmissionsEventType;
15869
15885
  /**
15870
15886
  * Creates the event type for strict staking events
15871
15887
  * @returns Fully qualified event type string
15872
15888
  */
15873
- private stakedEventType;
15889
+ private readonly stakedEventType;
15874
15890
  /**
15875
15891
  * Creates the event type for relaxed staking events
15876
15892
  * @returns Fully qualified event type string
15877
15893
  */
15878
- private stakedRelaxedEventType;
15894
+ private readonly stakedRelaxedEventType;
15879
15895
  /**
15880
15896
  * Creates the event type for position locking events
15881
15897
  * @returns Fully qualified event type string
15882
15898
  */
15883
- private lockedEventType;
15899
+ private readonly lockedEventType;
15884
15900
  /**
15885
15901
  * Creates the event type for position unlocking events
15886
15902
  * @returns Fully qualified event type string
15887
15903
  */
15888
- private unlockedEventType;
15904
+ private readonly unlockedEventType;
15889
15905
  /**
15890
15906
  * Creates the event type for principal deposit events
15891
15907
  * @returns Fully qualified event type string
15892
15908
  */
15893
- private depositedPrincipalEventType;
15909
+ private readonly depositedPrincipalEventType;
15894
15910
  /**
15895
15911
  * Creates the event type for principal withdrawal events
15896
15912
  * @returns Fully qualified event type string
15897
15913
  */
15898
- private withdrewPrincipalEventType;
15914
+ private readonly withdrewPrincipalEventType;
15899
15915
  /**
15900
15916
  * Creates the event type for reward harvesting events
15901
15917
  * @returns Fully qualified event type string
15902
15918
  */
15903
- private harvestedRewardsEventType;
15919
+ private readonly harvestedRewardsEventType;
15904
15920
  /**
15905
15921
  * Checks if the input contains a one-time admin cap ID
15906
15922
  * @param inputs FarmOwnerOrOneTimeAdminCap object
@@ -15916,14 +15932,14 @@ declare class FarmsApi implements MoveErrorsInterface {
15916
15932
  }
15917
15933
 
15918
15934
  declare class FaucetApi {
15919
- private readonly Provider;
15935
+ private readonly api;
15920
15936
  private static readonly constants;
15921
15937
  readonly addresses: FaucetAddresses;
15922
15938
  readonly eventTypes: {
15923
15939
  mintCoin: AnyObjectType;
15924
15940
  addCoin: AnyObjectType;
15925
15941
  };
15926
- constructor(Provider: AftermathApi);
15942
+ constructor(api: AftermathApi);
15927
15943
  fetchSupportedCoins: () => Promise<CoinType[]>;
15928
15944
  requestCoinTx: (inputs: {
15929
15945
  tx: Transaction;
@@ -15943,32 +15959,32 @@ declare class FaucetApi {
15943
15959
  fetchBuildMintSuiFrenTx: (inputs: ApiFaucetMintSuiFrenBody) => Promise<Transaction>;
15944
15960
  fetchMintCoinEvents: (inputs: EventsInputs) => Promise<EventsWithCursor<FaucetMintCoinEvent>>;
15945
15961
  fetchAddCoinEvents: (inputs: EventsInputs) => Promise<EventsWithCursor<FaucetAddCoinEvent>>;
15946
- private mintCoinEventType;
15947
- private addCoinEventType;
15962
+ private readonly mintCoinEventType;
15963
+ private readonly addCoinEventType;
15948
15964
  }
15949
15965
 
15950
15966
  declare class LimitOrdersApi {
15951
- private readonly Provider;
15967
+ private readonly api;
15952
15968
  readonly addresses: LimitAddresses;
15953
15969
  readonly eventTypes: {
15954
15970
  createdOrder: AnyObjectType;
15955
15971
  };
15956
- constructor(Provider: AftermathApi);
15957
- private createdOrderEventType;
15972
+ constructor(api: AftermathApi);
15973
+ private readonly createdOrderEventType;
15958
15974
  }
15959
15975
 
15960
15976
  declare class MultisigApi {
15977
+ private readonly api;
15961
15978
  readonly sharedCustodyAddresses: SharedCustodyAddresses;
15962
- private readonly Provider;
15963
- constructor(Provider: AftermathApi);
15979
+ constructor(api: AftermathApi);
15964
15980
  getMultisigForUser(inputs: ApiMultisigUserBody): MultisigData;
15965
15981
  }
15966
15982
 
15967
15983
  declare class NftAmmApi {
15968
- private readonly Provider;
15984
+ private readonly api;
15969
15985
  private static readonly constants;
15970
15986
  readonly addresses: NftAmmAddresses;
15971
- constructor(Provider: AftermathApi);
15987
+ constructor(api: AftermathApi);
15972
15988
  fetchNftsInMarketTable: (inputs: {
15973
15989
  marketTableObjectId: ObjectId;
15974
15990
  cursor?: ObjectId;
@@ -16053,7 +16069,7 @@ declare class NftAmmApi {
16053
16069
  }
16054
16070
 
16055
16071
  declare class PerpetualsApi implements MoveErrorsInterface {
16056
- private readonly Provider;
16072
+ private readonly api;
16057
16073
  private static readonly constants;
16058
16074
  readonly addresses: PerpetualsAddresses;
16059
16075
  readonly eventTypes: {
@@ -16086,11 +16102,11 @@ declare class PerpetualsApi implements MoveErrorsInterface {
16086
16102
  performedAdl: AnyObjectType;
16087
16103
  };
16088
16104
  readonly moveErrors: MoveErrors;
16089
- constructor(Provider: AftermathApi);
16105
+ constructor(api: AftermathApi);
16090
16106
  getAccountCapType: (inputs: {
16091
16107
  collateralCoinType: CoinType;
16092
16108
  }) => string;
16093
- private eventType;
16109
+ private readonly eventType;
16094
16110
  }
16095
16111
 
16096
16112
  /**
@@ -16101,6 +16117,7 @@ declare class PerpetualsApi implements MoveErrorsInterface {
16101
16117
  * Provides methods to interact with the Pools API.
16102
16118
  */
16103
16119
  declare class PoolsApi implements MoveErrorsInterface {
16120
+ private readonly api;
16104
16121
  /**
16105
16122
  * Constants used in the pools API.
16106
16123
  */
@@ -16127,13 +16144,12 @@ declare class PoolsApi implements MoveErrorsInterface {
16127
16144
  withdrawV2: AnyObjectType;
16128
16145
  };
16129
16146
  readonly moveErrors: MoveErrors;
16130
- private readonly Provider;
16131
16147
  /**
16132
16148
  * Creates an instance of PoolsApi.
16133
- * @param {AftermathApi} Provider - An instance of AftermathApi.
16149
+ * @param {AftermathApi} api - An instance of AftermathApi.
16134
16150
  * @throws {Error} Throws an error if not all required addresses have been set in AfSdk
16135
16151
  */
16136
- constructor(Provider: AftermathApi);
16152
+ constructor(api: AftermathApi);
16137
16153
  fetchOwnedDaoFeePoolOwnerCaps: (inputs: ApiPoolsOwnedDaoFeePoolOwnerCapsBody) => Promise<DaoFeePoolOwnerCapObject[]>;
16138
16154
  /**
16139
16155
  * Executes a trade transaction on the specified pool.
@@ -16430,10 +16446,10 @@ declare class PoolsApi implements MoveErrorsInterface {
16430
16446
  }
16431
16447
 
16432
16448
  declare class ReferralVaultApi {
16433
- private readonly Provider;
16449
+ private readonly api;
16434
16450
  private static readonly constants;
16435
16451
  readonly addresses: ReferralVaultAddresses;
16436
- constructor(Provider: AftermathApi);
16452
+ constructor(api: AftermathApi);
16437
16453
  updateReferrerTx: (inputs: {
16438
16454
  tx: Transaction;
16439
16455
  referrer: SuiAddress;
@@ -16470,7 +16486,7 @@ declare class ReferralVaultApi {
16470
16486
  * @class
16471
16487
  */
16472
16488
  declare class RouterApi implements MoveErrorsInterface {
16473
- private readonly Provider;
16489
+ private readonly api;
16474
16490
  static readonly constants: {
16475
16491
  moduleNames: {
16476
16492
  router: string;
@@ -16491,14 +16507,14 @@ declare class RouterApi implements MoveErrorsInterface {
16491
16507
  /**
16492
16508
  * Creates an instance of RouterApi.
16493
16509
  * @constructor
16494
- * @param {AftermathApi} Provider - The Aftermath API instance.
16510
+ * @param {AftermathApi} api - The Aftermath API instance.
16495
16511
  */
16496
- constructor(Provider: AftermathApi);
16497
- private routerTradeEventType;
16512
+ constructor(api: AftermathApi);
16513
+ private readonly routerTradeEventType;
16498
16514
  }
16499
16515
 
16500
16516
  declare class StakingApi implements MoveErrorsInterface {
16501
- private readonly Provider;
16517
+ private readonly api;
16502
16518
  private static readonly constants;
16503
16519
  readonly addresses: StakingAddresses;
16504
16520
  readonly eventTypes: {
@@ -16514,7 +16530,7 @@ declare class StakingApi implements MoveErrorsInterface {
16514
16530
  unverifiedValidatorOperationCap: AnyObjectType;
16515
16531
  };
16516
16532
  readonly moveErrors: MoveErrors;
16517
- constructor(Provider: AftermathApi);
16533
+ constructor(api: AftermathApi);
16518
16534
  /**
16519
16535
  * Adds move call to tx for liquid staking of SUI for afSUI.
16520
16536
  *
@@ -16609,10 +16625,10 @@ declare class StakingApi implements MoveErrorsInterface {
16609
16625
  } & Omit<{
16610
16626
  tx: Transaction;
16611
16627
  }, "tx">) => Transaction;
16612
- private stakedEventType;
16613
- private unstakeRequestedEventType;
16614
- private unstakedEventType;
16615
- private epochWasChangedEventType;
16628
+ private readonly stakedEventType;
16629
+ private readonly unstakeRequestedEventType;
16630
+ private readonly unstakedEventType;
16631
+ private readonly epochWasChangedEventType;
16616
16632
  static updateStakingPositionsFromEvent: (inputs: {
16617
16633
  stakingPositions: StakingPosition[];
16618
16634
  event: StakeEvent | UnstakeEvent;
@@ -16622,15 +16638,14 @@ declare class StakingApi implements MoveErrorsInterface {
16622
16638
  }
16623
16639
 
16624
16640
  declare class SuiApi {
16625
- private readonly Provider;
16626
- constructor(Provider: AftermathApi);
16641
+ private readonly api;
16642
+ constructor(api: AftermathApi);
16627
16643
  /**
16628
16644
  * @deprecated Use `getSystemState()` method instead.
16629
16645
  * This method will be removed in a future release.
16630
16646
  * @example
16631
16647
  * ```typescript
16632
- * const afSdk = new Aftermath("MAINNET");
16633
- * await afSdk.init(); // initialize provider
16648
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
16634
16649
  *
16635
16650
  * const sui = afSdk.Sui();
16636
16651
  *
@@ -16641,7 +16656,7 @@ declare class SuiApi {
16641
16656
  }
16642
16657
 
16643
16658
  declare class SuiFrensApi {
16644
- private readonly Provider;
16659
+ private readonly api;
16645
16660
  private static readonly constants;
16646
16661
  readonly addresses: SuiFrensAddresses;
16647
16662
  readonly objectTypes: {
@@ -16658,7 +16673,7 @@ declare class SuiFrensApi {
16658
16673
  stakeSuiFren: AnyObjectType;
16659
16674
  unstakeSuiFren: AnyObjectType;
16660
16675
  };
16661
- constructor(Provider: AftermathApi);
16676
+ constructor(api: AftermathApi);
16662
16677
  fetchMixingLimitsAndLastEpochMixeds: (inputs: {
16663
16678
  suiFrenIds: ObjectId[];
16664
16679
  suiFrenType: AnyObjectType;
@@ -16841,9 +16856,9 @@ declare class SuiFrensApi {
16841
16856
  }
16842
16857
 
16843
16858
  declare class EventsApiHelpers {
16844
- private readonly Provider;
16859
+ private readonly api;
16845
16860
  private static readonly constants;
16846
- constructor(Provider: AftermathApi);
16861
+ constructor(api: AftermathApi);
16847
16862
  /**
16848
16863
  * @deprecated `subscribeEvent` was removed from `SuiJsonRpcClient` in
16849
16864
  * `@mysten/sui` v2. Poll `queryEvents` instead or use a WebSocket transport.
@@ -16884,11 +16899,11 @@ declare class EventsApiHelpers {
16884
16899
  }
16885
16900
 
16886
16901
  declare class InspectionsApiHelpers {
16887
- private readonly Provider;
16902
+ private readonly api;
16888
16903
  static constants: {
16889
16904
  devInspectSigner: string;
16890
16905
  };
16891
- constructor(Provider: AftermathApi);
16906
+ constructor(api: AftermathApi);
16892
16907
  fetchFirstBytesFromTxOutput: (inputs: {
16893
16908
  tx: Transaction;
16894
16909
  sender?: SuiAddress;
@@ -16908,9 +16923,9 @@ declare class InspectionsApiHelpers {
16908
16923
  }
16909
16924
 
16910
16925
  declare class ObjectsApiHelpers {
16911
- private readonly Provider;
16926
+ private readonly api;
16912
16927
  private static readonly constants;
16913
- constructor(Provider: AftermathApi);
16928
+ constructor(api: AftermathApi);
16914
16929
  fetchDoesObjectExist: (objectId: ObjectId | PackageId) => Promise<boolean>;
16915
16930
  fetchIsObjectOwnedByAddress: (inputs: {
16916
16931
  objectId: ObjectId;
@@ -16980,8 +16995,8 @@ declare class ObjectsApiHelpers {
16980
16995
  }
16981
16996
 
16982
16997
  declare class TransactionsApiHelpers {
16983
- private readonly Provider;
16984
- constructor(Provider: AftermathApi);
16998
+ private readonly api;
16999
+ constructor(api: AftermathApi);
16985
17000
  fetchTransactionsWithCursor: (inputs: {
16986
17001
  query: SuiTransactionBlockResponseQuery;
16987
17002
  cursor?: TransactionDigest;
@@ -17026,12 +17041,12 @@ declare class TransactionsApiHelpers {
17026
17041
  }
17027
17042
 
17028
17043
  declare class NftsApi {
17029
- private readonly Provider;
17044
+ private readonly api;
17030
17045
  readonly addresses: NftsAddresses;
17031
17046
  readonly objectTypes: {
17032
17047
  personalKioskCap: AnyObjectType;
17033
17048
  };
17034
- constructor(Provider: AftermathApi);
17049
+ constructor(api: AftermathApi);
17035
17050
  fetchOwnedNfts: (inputs: {
17036
17051
  walletAddress: SuiAddress;
17037
17052
  }) => Promise<Nft[]>;
@@ -17059,8 +17074,8 @@ declare class NftsApi {
17059
17074
  }
17060
17075
 
17061
17076
  declare class WalletApi {
17062
- private readonly Provider;
17063
- constructor(Provider: AftermathApi);
17077
+ private readonly api;
17078
+ constructor(api: AftermathApi);
17064
17079
  fetchCoinBalance: (inputs: {
17065
17080
  walletAddress: SuiAddress;
17066
17081
  coin: CoinType;
@@ -17098,7 +17113,7 @@ declare class WalletApi {
17098
17113
  * ```
17099
17114
  */
17100
17115
  declare class AftermathApi {
17101
- readonly provider: SuiJsonRpcClient;
17116
+ readonly client: SuiJsonRpcClient;
17102
17117
  readonly addresses: ConfigAddresses;
17103
17118
  /**
17104
17119
  * Static helper references for quick usage without instantiating the class.
@@ -17125,10 +17140,10 @@ declare class AftermathApi {
17125
17140
  * Constructs a new instance of the `AftermathApi`, binding the given Sui client
17126
17141
  * to the known `addresses`.
17127
17142
  *
17128
- * @param provider - A `SuiJsonRpcClient` for on-chain queries and transactions.
17143
+ * @param client - A `SuiJsonRpcClient` for on-chain queries and transactions.
17129
17144
  * @param addresses - The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.
17130
17145
  */
17131
- constructor(provider: SuiJsonRpcClient, addresses: ConfigAddresses);
17146
+ constructor(client: SuiJsonRpcClient, addresses: ConfigAddresses);
17132
17147
  /**
17133
17148
  * Creates a new `DynamicFieldsApiHelpers` instance for complex object field queries.
17134
17149
  */
@@ -17228,20 +17243,15 @@ declare class AftermathApi {
17228
17243
  * }
17229
17244
  * ```
17230
17245
  */
17231
- translateMoveErrorMessage: <T extends MoveErrorsInterface>(inputs: {
17246
+ translateMoveErrorMessage(inputs: {
17232
17247
  errorMessage: string;
17233
- }) => {
17234
- errorCode: MoveErrorCode;
17235
- packageId: ObjectId;
17236
- module: ModuleName;
17237
- error: string;
17238
- } | undefined;
17248
+ }): TranslatedMoveError | undefined;
17239
17249
  }
17240
17250
 
17241
17251
  declare class DynamicFieldsApiHelpers {
17242
- private readonly Provider;
17252
+ private readonly api;
17243
17253
  private static readonly constants;
17244
- constructor(Provider: AftermathApi);
17254
+ constructor(api: AftermathApi);
17245
17255
  fetchCastDynamicFieldsOfTypeWithCursor: <ObjectType>(inputs: {
17246
17256
  parentObjectId: ObjectId;
17247
17257
  objectsFromObjectIds: (objectIds: ObjectId[]) => Promise<ObjectType[]>;
@@ -17640,11 +17650,7 @@ declare class Helpers {
17640
17650
  */
17641
17651
  static parseMoveErrorMessage(inputs: {
17642
17652
  errorMessage: string;
17643
- }): {
17644
- errorCode: MoveErrorCode;
17645
- packageId: ObjectId;
17646
- module: ModuleName;
17647
- } | undefined;
17653
+ }): ParsedMoveError | undefined;
17648
17654
  /**
17649
17655
  * Translates a Move abort error message into a known error string if it matches
17650
17656
  * entries in a given `moveErrors` table. This is used to map on-chain error codes
@@ -17656,12 +17662,7 @@ declare class Helpers {
17656
17662
  static translateMoveErrorMessage(inputs: {
17657
17663
  errorMessage: string;
17658
17664
  moveErrors: MoveErrors;
17659
- }): {
17660
- errorCode: MoveErrorCode;
17661
- packageId: ObjectId;
17662
- module: ModuleName;
17663
- error: string;
17664
- } | undefined;
17665
+ }): TranslatedMoveError | undefined;
17665
17666
  /**
17666
17667
  * Constructs a `Keypair` instance from a private key string. The `privateKey`
17667
17668
  * may indicate the signing scheme (ED25519, Secp256k1, or Secp256r1) via prefix,
@@ -17681,15 +17682,15 @@ declare class Helpers {
17681
17682
  */
17682
17683
  declare class Wallet extends Caller {
17683
17684
  readonly address: SuiAddress;
17684
- readonly Provider?: AftermathApi | undefined;
17685
+ readonly api?: AftermathApi | undefined;
17685
17686
  /**
17686
17687
  * Creates a new `Wallet` instance for a specific address.
17687
17688
  *
17688
17689
  * @param address - The Sui address for this wallet (e.g., "0x<address>").
17689
17690
  * @param config - An optional caller configuration including network and authentication.
17690
- * @param Provider - An optional `AftermathApi` instance for wallet-specific methods.
17691
+ * @param api - An optional `AftermathApi` instance for wallet-specific methods.
17691
17692
  */
17692
- constructor(address: SuiAddress, config?: CallerConfig, Provider?: AftermathApi | undefined);
17693
+ constructor(address: SuiAddress, config?: CallerConfig, api?: AftermathApi | undefined);
17693
17694
  /**
17694
17695
  * Fetches the balance for a single coin type in this wallet.
17695
17696
  *
@@ -17699,8 +17700,7 @@ declare class Wallet extends Caller {
17699
17700
  * @example
17700
17701
  * ```typescript
17701
17702
  *
17702
- * const afSdk = new Aftermath("MAINNET");
17703
- * await afSdk.init(); // initialize provider
17703
+ * const afSdk = await Aftermath.create({ network: "MAINNET" });
17704
17704
  *
17705
17705
  * const wallet = afSdk.Wallet("0x<address>");
17706
17706
  *
@@ -17760,181 +17760,160 @@ declare class Wallet extends Caller {
17760
17760
  }
17761
17761
 
17762
17762
  /**
17763
- * The `Aftermath` class serves as the primary entry point for interacting with
17763
+ * Options accepted by {@link Aftermath.create}. All fields are optional
17764
+ * pass `{}` for the canonical mainnet setup.
17765
+ */
17766
+ interface AftermathOptions {
17767
+ /**
17768
+ * The target Sui network. Determines the canonical API host and
17769
+ * Sui fullnode URL when no explicit overrides are supplied.
17770
+ * @default "MAINNET"
17771
+ */
17772
+ network?: SuiNetwork;
17773
+ /**
17774
+ * Explicit override for the Aftermath API host (e.g.
17775
+ * `"http://localhost:8080"`). Useful for staging or local backends.
17776
+ */
17777
+ baseUrl?: Url;
17778
+ /**
17779
+ * Explicit override for the Sui fullnode URL.
17780
+ */
17781
+ fullnodeUrl?: Url;
17782
+ /**
17783
+ * Override for the API path segment between host and package prefix.
17784
+ * Defaults to `"api"`. Override only when targeting a backend that
17785
+ * mounts the Aftermath API under a different path.
17786
+ */
17787
+ apiEndpoint?: string;
17788
+ /**
17789
+ * Preloaded on-chain addresses. When supplied, `create` skips the
17790
+ * network round-trip that normally fetches them.
17791
+ */
17792
+ addresses?: ConfigAddresses;
17793
+ /**
17794
+ * Pre-built `AftermathApi` instance. When supplied, `create` uses it
17795
+ * directly and skips address discovery and Sui client setup entirely.
17796
+ */
17797
+ api?: AftermathApi;
17798
+ }
17799
+ /**
17800
+ * The `Aftermath` class is the primary entry point for interacting with
17764
17801
  * the Aftermath Finance protocols and utilities on the Sui blockchain.
17765
- * It provides various sub-providers (e.g. `Router`, `Staking`, `Farms`)
17766
- * initialized under the specified network environment (MAINNET, TESTNET, etc).
17802
+ * It exposes sub-providers (e.g. `Router`, `Staking`, `Farms`) configured
17803
+ * for the chosen network.
17804
+ *
17805
+ * Instances are created through the async {@link Aftermath.create} factory
17806
+ * — direct construction is not supported.
17767
17807
  *
17768
17808
  * @example
17769
17809
  * ```typescript
17770
- * // Create provider
17771
- * const aftermath = new Aftermath("MAINNET");
17772
- * // Create package provider
17773
- * const router = aftermath.Router();
17774
- * // Call sdk from package provider
17775
- * const supportedCoins = await router.getSupportedCoins();
17776
- *
17777
- * // Or do it all in one go
17778
- * const supportedCoins = await (new Aftermath("MAINNET")).Router().getSupportedCoins();
17810
+ * const aftermath = await Aftermath.create({ network: "MAINNET" });
17811
+ * const supportedCoins = await aftermath.Router().getSupportedCoins();
17779
17812
  * ```
17780
17813
  */
17781
17814
  declare class Aftermath extends Caller {
17782
- private readonly network?;
17783
- private Provider?;
17784
17815
  /**
17785
- * Creates an `Aftermath` provider instance to call the Aftermath Finance APIs
17786
- * and interact with Sui-based protocols.
17816
+ * Constructs and fully initializes an `Aftermath` instance.
17787
17817
  *
17788
- * @param network - The target Sui network ("MAINNET", "TESTNET", "DEVNET", or "LOCAL").
17789
- * @param Provider - Optionally pass a custom `AftermathApi` instance if you already have one.
17818
+ * Resolves on-chain addresses, configures the Sui fullnode client, and
17819
+ * returns a ready-to-use instance. Pass `addresses` or `api` to skip
17820
+ * the corresponding bootstrap steps.
17790
17821
  */
17791
- constructor(network?: SuiNetwork | undefined, Provider?: AftermathApi | undefined);
17822
+ static create(options?: AftermathOptions): Promise<Aftermath>;
17823
+ private readonly options;
17824
+ private constructor();
17792
17825
  /**
17793
- * Initializes the Aftermath provider by fetching addresses from the backend
17794
- * and configuring the Sui fullnode client. This method must be called before
17795
- * performing many API operations.
17796
- *
17797
- * @param inputs - Optional object allowing you to override the default `fullnodeUrl`.
17798
- * @example
17799
- * ```typescript
17800
- * const afSdk = new Aftermath("MAINNET");
17801
- * await afSdk.init(); // sets up internal providers
17802
- * ```
17826
+ * Resolves addresses and wires up the internal `AftermathApi`. Called
17827
+ * exactly once by the {@link Aftermath.create} factory.
17803
17828
  */
17804
- init(inputs?: {
17805
- fullnodeUrl: Url;
17806
- }): Promise<void>;
17829
+ private bootstrap;
17807
17830
  /**
17808
- * Retrieves the Aftermath-specific on-chain addresses (object IDs, packages, etc.).
17809
- *
17810
- * @returns A `ConfigAddresses` object containing relevant addresses for the protocol.
17811
- *
17812
- * @example
17813
- * ```typescript
17814
- * const addresses = await aftermath.getAddresses();
17815
- * console.log(addresses); // { routerPackageId: "...", someOtherPackageId: "..." }
17816
- * ```
17831
+ * The fully-bootstrapped low-level API provider. Set by `bootstrap()`
17832
+ * before any accessor is callable.
17817
17833
  */
17818
- getAddresses(): Promise<ConfigAddresses>;
17834
+ private api;
17819
17835
  /**
17820
- * Returns the base URL used for Aftermath API calls.
17821
- *
17822
- * @returns The base URL for this instance's API.
17823
- *
17824
- * @example
17825
- * ```typescript
17826
- * const apiBaseUrl = aftermath.getApiBaseUrl();
17827
- * console.log(apiBaseUrl); // "https://api.after..."
17828
- * ```
17836
+ * The Sui network this provider is configured for (e.g. "MAINNET").
17829
17837
  */
17830
- getApiBaseUrl(): string | undefined;
17838
+ get network(): SuiNetwork;
17831
17839
  /**
17832
- * Returns an instance of the `Pools` class, which handles DEX pool operations
17833
- * within the Aftermath platform (if supported).
17840
+ * The resolved API base URL for this instance.
17834
17841
  */
17835
- Pools: () => Pools;
17842
+ getApiBaseUrl(): Url | undefined;
17836
17843
  /**
17837
- * Returns an instance of the `Staking` class for Aftermath's staking and unstaking features.
17844
+ * Fetches the Aftermath on-chain addresses (object IDs, packages, etc.)
17845
+ * directly from the API. Typically you don't need to call this — the
17846
+ * `create` factory handles it. Useful for cache warmers or tooling.
17838
17847
  */
17839
- Staking: () => Staking;
17848
+ getAddresses(): Promise<ConfigAddresses>;
17840
17849
  /**
17841
- * Returns an instance of `SuiFrens`, a specialized package for social or utility services.
17850
+ * Attempts to decode a raw Move abort/error string into a structured
17851
+ * error code, package ID, module name, and human-readable message.
17852
+ * Returns `undefined` when no registered package recognizes the error.
17853
+ *
17854
+ * Thin pass-through to the underlying {@link AftermathApi} so consumers
17855
+ * don't need to reach into the private `api` field.
17842
17856
  */
17857
+ translateMoveErrorMessage(inputs: {
17858
+ errorMessage: string;
17859
+ }): TranslatedMoveError | undefined;
17860
+ /** DEX pool operations. */
17861
+ Pools: () => Pools;
17862
+ /** Liquid staking and unstaking. */
17863
+ Staking: () => Staking;
17864
+ /** SuiFrens — specialized social/utility package. */
17843
17865
  SuiFrens: () => SuiFrens;
17844
- /**
17845
- * Returns an instance of `Faucet`, allowing test/dev networks to dispense tokens.
17846
- */
17866
+ /** Test-network faucet for dispensing tokens. */
17847
17867
  Faucet: () => Faucet;
17848
- /**
17849
- * Returns an instance of the `Router` class, which handles smart order routing
17850
- * across multiple DEX protocols.
17851
- */
17868
+ /** Smart order router across DEX protocols. */
17852
17869
  Router: () => Router;
17853
- /**
17854
- * Returns an instance of `NftAmm`, which supports NFT AMM (automated market maker) features.
17855
- */
17870
+ /** NFT AMM operations. */
17856
17871
  NftAmm: () => NftAmm;
17857
17872
  /**
17858
- * Returns an instance of `ReferralVault` for referral-based interactions in the protocol.
17859
- * @deprecated Use `Referrals` instead
17873
+ * Referral vault interactions.
17874
+ * @deprecated Use `Referrals` instead.
17860
17875
  */
17861
17876
  ReferralVault: () => ReferralVault;
17862
- /**
17863
- * Returns an instance of `Referrals` for referral-based interactions in the protocol.
17864
- */
17877
+ /** Referral-program interactions. */
17865
17878
  Referrals: () => Referrals;
17866
- /**
17867
- * Returns an instance of `GasPools` for shared gas pool interactions.
17868
- */
17879
+ /** Shared gas pool interactions. */
17869
17880
  GasPools: () => GasPools;
17870
- /**
17871
- * Returns an instance of `Perpetuals` for futures or perpetual contract interactions.
17872
- */
17881
+ /** Perpetual / futures contracts. */
17873
17882
  Perpetuals: () => Perpetuals;
17874
- /**
17875
- * Returns an instance of `Rewards` for querying user reward points.
17876
- */
17883
+ /** User reward-point queries. */
17877
17884
  Rewards: () => Rewards;
17878
- /**
17879
- * Returns an instance of `Farms` for yield farming or liquidity mining functionalities.
17880
- */
17885
+ /** Yield farming / liquidity mining. */
17881
17886
  Farms: () => Farms;
17882
- /**
17883
- * Returns an instance of the `Dca` class, supporting dollar-cost averaging logic.
17884
- */
17887
+ /** Dollar-cost averaging. */
17885
17888
  Dca: () => Dca;
17886
- /**
17887
- * Returns an instance of `Multisig`, enabling multi-signature address creation and management.
17888
- */
17889
+ /** Multi-signature address creation and management. */
17889
17890
  Multisig: () => Multisig;
17890
- /**
17891
- * Returns an instance of `LimitOrders`, supporting limit order placement on certain DEX protocols.
17892
- */
17891
+ /** Limit orders on supported DEX protocols. */
17893
17892
  LimitOrders: () => LimitOrders;
17894
- /**
17895
- * Returns an instance of `UserData` for creating and managing user-specific data or key storage.
17896
- */
17893
+ /** User-specific data / key storage. */
17897
17894
  UserData: () => UserData;
17898
- /**
17899
- * Returns an instance of `Sui` for low-level Sui chain information and utilities.
17900
- */
17895
+ /** Low-level Sui chain utilities. */
17901
17896
  Sui: () => Sui;
17902
- /**
17903
- * Returns an instance of `Prices`, which provides coin price data from external or internal feeds.
17904
- */
17897
+ /** Coin price feeds. */
17905
17898
  Prices: () => Prices;
17906
17899
  /**
17907
- * Creates a new `Wallet` instance for a specific user address, enabling you to fetch balances,
17908
- * transaction history, etc.
17909
- *
17910
- * @param address - The Sui address of the wallet (e.g., "0x<32_byte_hex>").
17900
+ * Creates a `Wallet` instance scoped to a specific user address.
17901
+ * @param address - The Sui address (e.g., `"0x..."`).
17911
17902
  */
17912
17903
  Wallet: (address: SuiAddress) => Wallet;
17913
17904
  /**
17914
- * Returns an instance of the `Coin` class, which handles coin metadata, decimal conversions,
17915
- * and other coin-related utilities for a specified `CoinType`.
17916
- *
17917
- * @param coinType - Optionally specify a coin type for immediate usage in coin methods.
17905
+ * Returns a `Coin` helper for the given coin type. Pass `undefined`
17906
+ * for generic coin-metadata utilities.
17918
17907
  */
17919
17908
  Coin: (coinType?: CoinType) => Coin;
17920
- /**
17921
- * Returns an instance of `DynamicGas`, enabling dynamic assignment of gas
17922
- * objects or sponsored transactions for user operations.
17923
- */
17909
+ /** Dynamic gas-object assignment for sponsored transactions. */
17924
17910
  DynamicGas: () => DynamicGas;
17925
- /**
17926
- * Returns an instance of `Auth`, handling user authentication or token-based flows (if applicable).
17927
- */
17911
+ /** Authentication / token-based flows. */
17928
17912
  Auth: () => Auth;
17929
- /**
17930
- * Exposes a set of helper functions for general-purpose usage across
17931
- * the Aftermath ecosystem. Includes utilities for math, logging, etc.
17932
- */
17913
+ /** General-purpose helpers (math, logging, etc.). */
17933
17914
  static helpers: typeof Helpers;
17934
- /**
17935
- * Exposes a set of casting utilities for data type conversions (e.g., BigInt <-> fixed).
17936
- */
17915
+ /** Casting utilities for data type conversions (BigInt <-> IFixed, etc.). */
17937
17916
  static casting: typeof Casting;
17938
17917
  }
17939
17918
 
17940
- export { type AfSuiRouterPoolObject, Aftermath, AftermathApi, type AllocatedCollateralEvent, type AmountInCoinAndUsd, type AnyObjectType, type ApiAccessoriesForSuiFrenBody, type ApiAddSuiFrenAccessoryBody, type ApiCreateAuthAccountBody, type ApiCreatePoolBody, type ApiDataWithCursorBody, type ApiDelegatedStakesBody, type ApiDynamicFieldsBody, type ApiDynamicGasBody, type ApiDynamicGasResponse, type ApiEventsBody, type ApiFarmsCreateStakingPoolBody, type ApiFarmsCreateStakingPoolBodyV1, type ApiFarmsDepositPrincipalBody, type ApiFarmsGrantOneTimeAdminCapBody, type ApiFarmsIncreaseStakingPoolRewardsEmissionsBody, type ApiFarmsInitializeStakingPoolRewardBody, type ApiFarmsLockBody, type ApiFarmsOwnedStakedPositionsBody, type ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody, type ApiFarmsOwnedStakingPoolOwnerCapsBody, type ApiFarmsRenewLockBody, type ApiFarmsStakeBody, type ApiFarmsStakeBodyV1, type ApiFarmsTopUpStakingPoolRewardsBody, type ApiFarmsUnlockBody, type ApiFarmsUnstakeBody, type ApiFaucetMintSuiFrenBody, type ApiFaucetRequestBody, type ApiGasPoolBody, type ApiGasPoolCreateBody, type ApiGasPoolCreateResponse, type ApiGasPoolDepositBody, type ApiGasPoolGrantBody, type ApiGasPoolResponse, type ApiGasPoolRevokeBody, type ApiGasPoolShareBody, type ApiGasPoolSponsorBody, type ApiGasPoolWithdrawBody, type ApiGasPoolWithdrawResponse, type ApiGetAccessTokenBody, type ApiGetAccessTokenResponse, type ApiHarvestFarmsRewardsBody, type ApiHarvestSuiFrenFeesBody, type ApiIndexerEventsBody, type ApiIndexerUserEventsBody, type ApiMixSuiFrensBody, type ApiNftAmmBuyBody, type ApiNftAmmDepositBody, type ApiNftAmmSellBody, type ApiNftAmmWithdrawBody, type ApiOwnedStakedSuiFrensBody, type ApiOwnedSuiFrenAccessoriesBody, type ApiOwnedSuiFrensBody, type ApiPerpetualsAccountCollateralHistoryBody, type ApiPerpetualsAccountCollateralHistoryResponse, type ApiPerpetualsAccountMarginHistoryBody, type ApiPerpetualsAccountMarginHistoryResponse, type ApiPerpetualsAccountOrderHistoryBody, type ApiPerpetualsAccountOrderHistoryResponse, type ApiPerpetualsAccountPositionsBody, type ApiPerpetualsAccountPositionsResponse, type ApiPerpetualsAdminAccountCapsBody, type ApiPerpetualsAdminAccountCapsResponse, type ApiPerpetualsAllMarketsBody, type ApiPerpetualsAllMarketsResponse, type ApiPerpetualsAllocateCollateralBody, type ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody, type ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse, type ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody, type ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody, type ApiPerpetualsBuilderCodesIntegratorConfigBody, type ApiPerpetualsBuilderCodesIntegratorConfigResponse, type ApiPerpetualsBuilderCodesIntegratorVaultsBody, type ApiPerpetualsBuilderCodesIntegratorVaultsResponse, type ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody, type ApiPerpetualsCancelAndPlaceOrdersBody, type ApiPerpetualsCancelOrdersBody, type ApiPerpetualsCancelStopOrdersBody, type ApiPerpetualsCreateAccountBody, type ApiPerpetualsCreateAccountResponse, type ApiPerpetualsCreateCsvRebatesBody, type ApiPerpetualsCreateCsvRebatesResponse, type ApiPerpetualsCreateReferralCsvRebatesBody, type ApiPerpetualsCreateReferralCsvRebatesResponse, type ApiPerpetualsCreateVaultBody, type ApiPerpetualsCreateVaultCapBody, type ApiPerpetualsCurrentRebateRewardsBody, type ApiPerpetualsCurrentRebateRewardsResponse, type ApiPerpetualsDeallocateCollateralBody, type ApiPerpetualsDepositCollateralBody, type ApiPerpetualsEditStopOrdersBody, type ApiPerpetualsExecutionPriceBody, type ApiPerpetualsExecutionPriceResponse, type ApiPerpetualsGrantAgentWalletTxBody, type ApiPerpetualsHistoricalDataWithCursorBody, type ApiPerpetualsHistoricalDataWithCursorResponse, type ApiPerpetualsLimitOrderBody, type ApiPerpetualsMarketCandleHistoryBody, type ApiPerpetualsMarketCandleHistoryResponse, type ApiPerpetualsMarketFundingHistoryBody, type ApiPerpetualsMarketFundingHistoryResponse, type ApiPerpetualsMarketOrderBody, type ApiPerpetualsMarketOrderHistoryBody, type ApiPerpetualsMarketOrderHistoryResponse, type ApiPerpetualsMarkets24hrStatsResponse, type ApiPerpetualsMarketsBody, type ApiPerpetualsMarketsPricesBody, type ApiPerpetualsMarketsPricesResponse, type ApiPerpetualsMarketsResponse, type ApiPerpetualsMaxOrderSizeBody, type ApiPerpetualsOrderToPlace, type ApiPerpetualsOrderbooksBody, type ApiPerpetualsOrderbooksResponse, type ApiPerpetualsOwnedAccountCapsBody, type ApiPerpetualsOwnedAccountCapsResponse, type ApiPerpetualsOwnedVaultAssistantCapsBody, type ApiPerpetualsOwnedVaultAssistantCapsResponse, type ApiPerpetualsOwnedVaultCapsBody, type ApiPerpetualsOwnedVaultCapsResponse, type ApiPerpetualsPlaceSlTpOrdersBody, type ApiPerpetualsPlaceStopOrdersBody, type ApiPerpetualsPreviewCancelOrdersBody, type ApiPerpetualsPreviewCancelOrdersResponse, type ApiPerpetualsPreviewEditCollateralBody, type ApiPerpetualsPreviewEditCollateralResponse, type ApiPerpetualsPreviewPlaceLimitOrderBody, type ApiPerpetualsPreviewPlaceMarketOrderBody, type ApiPerpetualsPreviewPlaceOrderResponse, type ApiPerpetualsPreviewPlaceScaleOrderBody, type ApiPerpetualsPreviewSetLeverageBody, type ApiPerpetualsPreviewSetLeverageResponse, type ApiPerpetualsRevokeAgentWalletTxBody, type ApiPerpetualsScaleOrderBody, type ApiPerpetualsSetLeverageTxBody, type ApiPerpetualsShareAccountBody, type ApiPerpetualsStopOrderDatasBody, type ApiPerpetualsStopOrderDatasResponse, type ApiPerpetualsTransferCapTxBody, type ApiPerpetualsTransferCollateralBody, type ApiPerpetualsVaultCancelWithdrawRequestTxBody, type ApiPerpetualsVaultCreateWithdrawRequestTxBody, type ApiPerpetualsVaultDepositTxBody, type ApiPerpetualsVaultLpCoinPricesBody, type ApiPerpetualsVaultLpCoinPricesResponse, type ApiPerpetualsVaultOwnedLpCoinsBody, type ApiPerpetualsVaultOwnedLpCoinsResponse, type ApiPerpetualsVaultOwnedWithdrawRequestsBody, type ApiPerpetualsVaultOwnedWithdrawRequestsResponse, type ApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody, type ApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody, type ApiPerpetualsVaultOwnerUpdateLockPeriodTxBody, type ApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody, type ApiPerpetualsVaultOwnerWithdrawCollateralTxBody, type ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse, type ApiPerpetualsVaultOwnerWithdrawLockedLiquidityTxBody, type ApiPerpetualsVaultOwnerWithdrawLockedLiquidityTxResponse, type ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody, type ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse, type ApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody, type ApiPerpetualsVaultPreviewCreateWithdrawRequestBody, type ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse, type ApiPerpetualsVaultPreviewDepositBody, type ApiPerpetualsVaultPreviewDepositResponse, type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody, type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody, type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawLockedLiquidityBody, type ApiPerpetualsVaultPreviewOwnerWithdrawLockedLiquidityResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody, type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse, type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody, type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse, type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody, type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse, type ApiPerpetualsVaultProcessForceWithdrawRequestTxBody, type ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse, type ApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody, type ApiPerpetualsVaultsBody, type ApiPerpetualsVaultsResponse, type ApiPerpetualsVaultsWithdrawRequestsBody, type ApiPerpetualsVaultsWithdrawRequestsResponse, type ApiPerpetualsWithdrawCollateralBody, type ApiPerpetualsWithdrawCollateralResponse, type ApiPoolAllCoinWithdrawBody, type ApiPoolDepositBody, type ApiPoolObjectIdForLpCoinTypeBody, type ApiPoolSpotPriceBody, type ApiPoolTradeBody, type ApiPoolWithdrawBody, type ApiPoolsOwnedDaoFeePoolOwnerCapsBody, type ApiPoolsStatsBody, type ApiPublishLpCoinBody, type ApiReferralsCreateReferralLinkBody, type ApiReferralsCreateReferralLinkResponse, type ApiReferralsGetLinkedRefCodeBody, type ApiReferralsGetLinkedRefCodeResponse, type ApiReferralsGetRefCodeBody, type ApiReferralsGetRefCodeResponse, type ApiReferralsGetRefereesBody, type ApiReferralsGetRefereesResponse, type ApiReferralsIsRefCodeTakenBody, type ApiReferralsIsRefCodeTakenResponse, type ApiReferralsSetReferrerBody, type ApiReferralsSetReferrerResponse, type ApiRemoveSuiFrenAccessoryBody, type ApiRewardsClaimRequestTxBody, type ApiRewardsClaimRequestTxResponse, type ApiRewardsGetClaimableBody, type ApiRewardsGetClaimableResponse, type ApiRewardsGetHistoryBody, type ApiRewardsGetHistoryResponse, type ApiRewardsGetPointsBody, type ApiRewardsGetPointsResponse, type ApiRouterAddTransactionForCompleteTradeRouteBody, type ApiRouterAddTransactionForCompleteTradeRouteResponse, type ApiRouterCompleteTradeRouteBody, type ApiRouterDynamicGasBody, type ApiRouterPartialCompleteTradeRouteBody, type ApiRouterTradeEventsBody, type ApiRouterTransactionForCompleteTradeRouteBody, type ApiStakeBody, type ApiStakeStakedSuiBody, type ApiStakeSuiFrenBody, type ApiStakingEventsBody, type ApiStakingPositionsBody, type ApiTransactionResponse, type ApiTransactionsBody, type ApiUnstakeBody, type ApiUnstakeSuiFrenBody, type ApiUpdateValidatorFeeBody, type ApiValidatorOperationCapsBody, type Apr, type Apy, Auth, type Balance, type BigIntAsString, type Byte, type CallerConfig, type CanceledOrderEvent, type CapyLabsAppObject, Casting, Coin, type CoinDecimal, type CoinGeckoChain, type CoinGeckoCoinApiId, type CoinGeckoCoinData, type CoinGeckoCoinSymbolData, type CoinGeckoHistoricalTradeData, type CoinGeckoTickerData, type CoinMetadaWithInfo, type CoinPriceInfo, type CoinSymbol, type CoinSymbolToCoinTypes, type CoinSymbolsToPriceInfo, type CoinType, type CoinWithAmount, type CoinWithAmountOrUndefined, type CoinsToBalance, type CoinsToBalanceOrUndefined, type CoinsToDecimals, type CoinsToPrice, type CoinsToPriceInfo, type CollateralEvent, type Color, type ComposedTransferArgs, type ConfigAddresses, type CreatedAccountEvent, type CreatedDaoFeePoolEvent, type CreatedStopOrderTicketEvent, type DaoFeePoolObject, type DaoFeePoolOwnerCapObject, type DaoFeePoolsAddresses, type DcaAddresses, type DeallocatedCollateralEvent, type DecimalsScalar, type DeferredAccountArgs, type DeletedStopOrderTicketEvent, type DepositedCollateralEvent, type DynamicFieldObjectsWithCursor, type DynamicFieldsInputs, type DynamicFieldsWithCursor, type DynamicGasAddresses, type EditedStopOrderTicketDetailsEvent, type EditedStopOrderTicketExecutorEvent, type EpochWasChangedEvent, type Event$1 as Event, type EventsInputs, type EventsWithCursor, type ExecutedStopOrderTicketEvent, type ExternalFee, type FarmEvent, type FarmOwnerOrOneTimeAdminCap, type FarmUserEvent, Farms, type FarmsAddedRewardEvent, type FarmsAddresses, type FarmsCreatedVaultEvent, type FarmsDepositedPrincipalEvent, type FarmsDestroyedStakedPositionEvent, type FarmsHarvestedRewardsEvent, type FarmsIncreasedEmissionsEvent, type FarmsInitializedRewardEvent, type FarmsJoinedEvent, type FarmsLockEnforcement, type FarmsLockedEvent, type FarmsMultiplier, type FarmsSplitEvent, type FarmsStakedEvent, FarmsStakedPosition, type FarmsStakedPositionObject, type FarmsStakedPositionRewardCoin, type FarmsStakedRelaxedEvent, FarmsStakingPool, type FarmsStakingPoolObject, type FarmsStakingPoolRewardCoin, type FarmsUnlockedEvent, type FarmsVersion, type FarmsWithdrewPrincipalEvent, Faucet, type FaucetAddCoinEvent, type FaucetAddresses, type FaucetMintCoinEvent, type FilePath, type FilledMakerOrderEventFields, type FilledMakerOrdersEvent, type FilledTakerOrderEvent, type FunctionName, type GasBudget, GasPools, type HarvestSuiFrenFeesEvent, Helpers, type IFixed, type IFixedAsBytes, type IFixedAsString, type IFixedAsStringBytes, type IdAsStringBytes, type IndexerDataWithCursorQueryParams, type IndexerEventsWithCursor, type KeyType, type KioskObject, type KioskOwnerCapObject, type LimitAddresses, type LiquidatedEvent, type LocalUrl, type MixSuiFrensEvent, type ModuleName, type MoveErrorCode, type Nft, NftAmm, type NftAmmAddresses, type NftAmmInterfaceGenericTypes, type NftAmmMarketObject, type NftDisplay, type NftDisplayOther, type NftDisplaySuggested, type NftInfo, type NftsAddresses, type NormalizedBalance, type NumberAsString, type Object$1 as Object, type ObjectDigest, type ObjectId, type ObjectVersion, type OrderbookFillReceiptEvent, type PackageId, type PartialFarmsStakedPositionObject, type PartialSuiFrenObject, type Percentage, Perpetuals, PerpetualsAccount, type PerpetualsAccountCap, type PerpetualsAccountCollateralChange, type PerpetualsAccountData, type PerpetualsAccountId, type PerpetualsAccountMarginHistoryData, type PerpetualsAccountMarginHistoryTimeframeKey, type PerpetualsAccountObject, type PerpetualsAccountOrderHistoryData, type PerpetualsAddresses, type PerpetualsBuilderCodeParamaters, type PerpetualsCalculationVariables, type PerpetualsCapType, type PerpetualsExecutionInfo, type PerpetualsFilledOrderData, type PerpetualsIntegratorVaultData, type PerpetualsMakerData, PerpetualsMarket, type PerpetualsMarket24hrStats, type PerpetualsMarketCandleDataPoint, type PerpetualsMarketData, type PerpetualsMarketFundingHistoryPoint, type PerpetualsMarketId, type PerpetualsMarketOrderHistoryData, type PerpetualsMarketParams, type PerpetualsMarketState, type PerpetualsOrderData, type PerpetualsOrderEvent, type PerpetualsOrderId, type PerpetualsOrderIdAsString, type PerpetualsOrderInfo, type PerpetualsOrderPrice, PerpetualsOrderSide, type PerpetualsOrderState, PerpetualsOrderType, type PerpetualsOrderbook, type PerpetualsOrderbookDeltas, type PerpetualsOrderbookItem, type PerpetualsPartialVaultCap, type PerpetualsPosition, type PerpetualsRewardData, type PerpetualsSponsorConfig, type PerpetualsStopOrderData, PerpetualsStopOrderType, type PerpetualsTakerData, type PerpetualsTopOfOrderbook, type PerpetualsTopOfOrderbookDataPoint, type PerpetualsTwapEvent, PerpetualsVault, type PerpetualsVaultCap, type PerpetualsVaultLpCoin, type PerpetualsVaultMetatada, type PerpetualsVaultObject, type PerpetualsVaultWithdrawRequest, type PerpetualsVaultsAddresses, type PerpetualsWsCandleResponseMessage, type PerpetualsWsUpdatesMarketOrdersPayload, type PerpetualsWsUpdatesMarketOrdersSubscriptionType, type PerpetualsWsUpdatesMarketSubscriptionType, type PerpetualsWsUpdatesOraclePayload, type PerpetualsWsUpdatesOracleSubscriptionType, type PerpetualsWsUpdatesOrderbookPayload, type PerpetualsWsUpdatesOrderbookSubscriptionType, type PerpetualsWsUpdatesResponseMessage, type PerpetualsWsUpdatesSubscriptionAction, type PerpetualsWsUpdatesSubscriptionMessage, type PerpetualsWsUpdatesSubscriptionType, type PerpetualsWsUpdatesTopOfOrderbookPayload, type PerpetualsWsUpdatesTopOfOrderbookSubscriptionType, type PerpetualsWsUpdatesUserCollateralChangesPayload, type PerpetualsWsUpdatesUserCollateralChangesSubscriptionType, type PerpetualsWsUpdatesUserOrdersPayload, type PerpetualsWsUpdatesUserOrdersSubscriptionType, type PerpetualsWsUpdatesUserPayload, type PerpetualsWsUpdatesUserSubscriptionType, Pool, type PoolCoin, type PoolCoins, type PoolCreationCoinInfo, type PoolCreationLpCoinMetadata, type PoolDataPoint, type PoolDepositEvent, type PoolDepositFee, type PoolFlatness, type PoolGraphDataTimeUnit, type PoolGraphDataTimeframe, type PoolGraphDataTimeframeKey, type PoolLpInfo, type PoolName, type PoolObject, type PoolStats, type PoolTradeEvent, type PoolTradeFee, type PoolWeight, type PoolWithdrawEvent, type PoolWithdrawFee, Pools, type PoolsAddresses, type PostedOrderEvent, type RateLimit, type ReceivedCollateralEvent, type ReducedOrderEvent, ReferralVault, type ReferralVaultAddresses, type ReferralsRefereeInfo, type RewardsClaimableReward, type RewardsHistoryEntry, type RewardsHistoryEventType, type RewardsPaginationInfo, Router, type RouterAddresses, type RouterCompleteTradeRoute, type RouterCompleteTradeRouteWithFee, type RouterExternalFee, type RouterProtocolName, type RouterTradeCoin, type RouterTradeEvent, type RouterTradeInfo, type RouterTradePath, type RouterTradeRoute, type RpcEndpoint, type ScallopAddresses, type SdkPerpetualsCancelAndPlaceOrdersInputs, type SdkPerpetualsCancelOrdersPreviewInputs, type SdkPerpetualsPlaceLimitOrderInputs, type SdkPerpetualsPlaceLimitOrderPreviewInputs, type SdkPerpetualsPlaceMarketOrderInputs, type SdkPerpetualsPlaceMarketOrderPreviewInputs, type SdkPerpetualsPlaceScaleOrderInputs, type SdkPerpetualsPlaceScaleOrderPreviewInputs, type SdkPerpetualsPlaceSlTpOrdersInputs, type SdkPerpetualsPlaceStopOrdersInputs, type SdkTransactionResponse, type SerializedTransaction, type ServiceCoinData, type ServiceCoinDataV2, type SetPositionInitialMarginRatioEvent, type SettledFundingEvent, type SharedCustodyAddresses, type SignMessageCallback, type Slippage, type StakeBalanceDynamicField, type StakeEvent, type StakePosition, type StakeSuiFrenEvent, type StakedEvent, StakedSuiFren, type StakedSuiFrenInfo, type StakedSuiFrenMetadataV1Object, type StakedSuiFrenPositionObject, type StakedSuiVaultStateObject, Staking, type StakingAddresses, type StakingApyDataPoint, type StakingApyTimeframeKey, type StakingPoolOneTimeAdminCapObject, type StakingPoolOwnerCapObject, type StakingPosition, type StringByte, Sui, type SuiAddress, type SuiCheckpoint, type SuiDelegatedStake, type SuiDelegatedStakeState, SuiFren, type SuiFrenAccessoryName, type SuiFrenAccessoryObject, type SuiFrenAccessoryType, type SuiFrenAttributes, type SuiFrenObject, type SuiFrenStats, type SuiFrenVaultStateV1Object, SuiFrens, type SuiFrensAddresses, SuiFrensSortOption, type SuiNetwork, type Timestamp, type TransactionDigest, type TransactionsWithCursor, type TransferredDeallocatedCollateralEvent, type TxBytes, type UniqueId, type UnstakeEvent, type UnstakePosition, type UnstakePositionState, type UnstakeRequestedEvent, type UnstakeSuiFrenEvent, type UnstakedEvent, type UpdatedFeeBpsEvent, type UpdatedFeeRecipientEvent, type UpdatedFundingEvent, type UpdatedMarketVersionEvent, type UpdatedPremiumTwapEvent, type UpdatedSpreadTwapEvent, type Url, type UserEventsInputs, type UserHistoryEventType, type ValidatorConfigObject, type ValidatorOperationCapObject, type WithdrewCollateralEvent, isAllocatedCollateralEvent, isCanceledOrderEvent, isDeallocatedCollateralEvent, isDepositedCollateralEvent, isFarmsDepositedPrincipalEvent, isFarmsHarvestedRewardsEvent, isFarmsLockedEvent, isFarmsStakedEvent, isFarmsUnlockedEvent, isFarmsWithdrewPrincipalEvent, isFilledMakerOrdersEvent, isFilledTakerOrderEvent, isLiquidatedEvent, isPostedOrderEvent, isReducedOrderEvent, isSettledFundingEvent, isStakeEvent, isStakePosition, isSuiDelegatedStake, isUnstakeEvent, isUnstakePosition, isUpdatedFundingEvent, isUpdatedMarketVersion, isUpdatedPremiumTwapEvent, isUpdatedSpreadTwapEvent, isWithdrewCollateralEvent };
17919
+ export { type AfSuiRouterPoolObject, Aftermath, AftermathApi, type AftermathOptions, type AllocatedCollateralEvent, type AmountInCoinAndUsd, type AnyObjectType, type ApiAccessoriesForSuiFrenBody, type ApiAddSuiFrenAccessoryBody, type ApiCreateAuthAccountBody, type ApiCreatePoolBody, type ApiDataWithCursorBody, type ApiDelegatedStakesBody, type ApiDynamicFieldsBody, type ApiDynamicGasBody, type ApiDynamicGasResponse, type ApiEventsBody, type ApiFarmsCreateStakingPoolBody, type ApiFarmsCreateStakingPoolBodyV1, type ApiFarmsDepositPrincipalBody, type ApiFarmsGrantOneTimeAdminCapBody, type ApiFarmsIncreaseStakingPoolRewardsEmissionsBody, type ApiFarmsInitializeStakingPoolRewardBody, type ApiFarmsLockBody, type ApiFarmsOwnedStakedPositionsBody, type ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody, type ApiFarmsOwnedStakingPoolOwnerCapsBody, type ApiFarmsRenewLockBody, type ApiFarmsStakeBody, type ApiFarmsStakeBodyV1, type ApiFarmsTopUpStakingPoolRewardsBody, type ApiFarmsUnlockBody, type ApiFarmsUnstakeBody, type ApiFaucetMintSuiFrenBody, type ApiFaucetRequestBody, type ApiGasPoolBody, type ApiGasPoolCreateBody, type ApiGasPoolCreateResponse, type ApiGasPoolDepositBody, type ApiGasPoolGrantBody, type ApiGasPoolResponse, type ApiGasPoolRevokeBody, type ApiGasPoolShareBody, type ApiGasPoolSponsorBody, type ApiGasPoolWithdrawBody, type ApiGasPoolWithdrawResponse, type ApiGetAccessTokenBody, type ApiGetAccessTokenResponse, type ApiHarvestFarmsRewardsBody, type ApiHarvestSuiFrenFeesBody, type ApiIndexerEventsBody, type ApiIndexerUserEventsBody, type ApiMixSuiFrensBody, type ApiNftAmmBuyBody, type ApiNftAmmDepositBody, type ApiNftAmmSellBody, type ApiNftAmmWithdrawBody, type ApiOwnedStakedSuiFrensBody, type ApiOwnedSuiFrenAccessoriesBody, type ApiOwnedSuiFrensBody, type ApiPerpetualsAccountCollateralHistoryBody, type ApiPerpetualsAccountCollateralHistoryResponse, type ApiPerpetualsAccountMarginHistoryBody, type ApiPerpetualsAccountMarginHistoryResponse, type ApiPerpetualsAccountOrderHistoryBody, type ApiPerpetualsAccountOrderHistoryResponse, type ApiPerpetualsAccountPositionsBody, type ApiPerpetualsAccountPositionsResponse, type ApiPerpetualsAdminAccountCapsBody, type ApiPerpetualsAdminAccountCapsResponse, type ApiPerpetualsAllMarketsBody, type ApiPerpetualsAllMarketsResponse, type ApiPerpetualsAllocateCollateralBody, type ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody, type ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse, type ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody, type ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody, type ApiPerpetualsBuilderCodesIntegratorConfigBody, type ApiPerpetualsBuilderCodesIntegratorConfigResponse, type ApiPerpetualsBuilderCodesIntegratorVaultsBody, type ApiPerpetualsBuilderCodesIntegratorVaultsResponse, type ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody, type ApiPerpetualsCancelAndPlaceOrdersBody, type ApiPerpetualsCancelOrdersBody, type ApiPerpetualsCancelStopOrdersBody, type ApiPerpetualsCreateAccountBody, type ApiPerpetualsCreateAccountResponse, type ApiPerpetualsCreateCsvRebatesBody, type ApiPerpetualsCreateCsvRebatesResponse, type ApiPerpetualsCreateReferralCsvRebatesBody, type ApiPerpetualsCreateReferralCsvRebatesResponse, type ApiPerpetualsCreateVaultBody, type ApiPerpetualsCreateVaultCapBody, type ApiPerpetualsCurrentRebateRewardsBody, type ApiPerpetualsCurrentRebateRewardsResponse, type ApiPerpetualsDeallocateCollateralBody, type ApiPerpetualsDepositCollateralBody, type ApiPerpetualsEditStopOrdersBody, type ApiPerpetualsExecutionPriceBody, type ApiPerpetualsExecutionPriceResponse, type ApiPerpetualsGrantAgentWalletTxBody, type ApiPerpetualsHistoricalDataWithCursorBody, type ApiPerpetualsHistoricalDataWithCursorResponse, type ApiPerpetualsLimitOrderBody, type ApiPerpetualsMarketCandleHistoryBody, type ApiPerpetualsMarketCandleHistoryResponse, type ApiPerpetualsMarketFundingHistoryBody, type ApiPerpetualsMarketFundingHistoryResponse, type ApiPerpetualsMarketOrderBody, type ApiPerpetualsMarketOrderHistoryBody, type ApiPerpetualsMarketOrderHistoryResponse, type ApiPerpetualsMarkets24hrStatsResponse, type ApiPerpetualsMarketsBody, type ApiPerpetualsMarketsPricesBody, type ApiPerpetualsMarketsPricesResponse, type ApiPerpetualsMarketsResponse, type ApiPerpetualsMaxOrderSizeBody, type ApiPerpetualsOrderToPlace, type ApiPerpetualsOrderbooksBody, type ApiPerpetualsOrderbooksResponse, type ApiPerpetualsOwnedAccountCapsBody, type ApiPerpetualsOwnedAccountCapsResponse, type ApiPerpetualsOwnedVaultAssistantCapsBody, type ApiPerpetualsOwnedVaultAssistantCapsResponse, type ApiPerpetualsOwnedVaultCapsBody, type ApiPerpetualsOwnedVaultCapsResponse, type ApiPerpetualsPlaceSlTpOrdersBody, type ApiPerpetualsPlaceStopOrdersBody, type ApiPerpetualsPreviewCancelOrdersBody, type ApiPerpetualsPreviewCancelOrdersResponse, type ApiPerpetualsPreviewEditCollateralBody, type ApiPerpetualsPreviewEditCollateralResponse, type ApiPerpetualsPreviewPlaceLimitOrderBody, type ApiPerpetualsPreviewPlaceMarketOrderBody, type ApiPerpetualsPreviewPlaceOrderResponse, type ApiPerpetualsPreviewPlaceScaleOrderBody, type ApiPerpetualsPreviewSetLeverageBody, type ApiPerpetualsPreviewSetLeverageResponse, type ApiPerpetualsRevokeAgentWalletTxBody, type ApiPerpetualsScaleOrderBody, type ApiPerpetualsSetLeverageTxBody, type ApiPerpetualsShareAccountBody, type ApiPerpetualsStopOrderDatasBody, type ApiPerpetualsStopOrderDatasResponse, type ApiPerpetualsTransferCapTxBody, type ApiPerpetualsTransferCollateralBody, type ApiPerpetualsVaultCancelWithdrawRequestTxBody, type ApiPerpetualsVaultCreateWithdrawRequestTxBody, type ApiPerpetualsVaultDepositTxBody, type ApiPerpetualsVaultLpCoinPricesBody, type ApiPerpetualsVaultLpCoinPricesResponse, type ApiPerpetualsVaultOwnedLpCoinsBody, type ApiPerpetualsVaultOwnedLpCoinsResponse, type ApiPerpetualsVaultOwnedWithdrawRequestsBody, type ApiPerpetualsVaultOwnedWithdrawRequestsResponse, type ApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody, type ApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody, type ApiPerpetualsVaultOwnerUpdateLockPeriodTxBody, type ApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody, type ApiPerpetualsVaultOwnerWithdrawCollateralTxBody, type ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse, type ApiPerpetualsVaultOwnerWithdrawLockedLiquidityTxBody, type ApiPerpetualsVaultOwnerWithdrawLockedLiquidityTxResponse, type ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody, type ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse, type ApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody, type ApiPerpetualsVaultPreviewCreateWithdrawRequestBody, type ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse, type ApiPerpetualsVaultPreviewDepositBody, type ApiPerpetualsVaultPreviewDepositResponse, type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody, type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody, type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawLockedLiquidityBody, type ApiPerpetualsVaultPreviewOwnerWithdrawLockedLiquidityResponse, type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody, type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse, type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody, type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse, type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody, type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse, type ApiPerpetualsVaultProcessForceWithdrawRequestTxBody, type ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse, type ApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody, type ApiPerpetualsVaultsBody, type ApiPerpetualsVaultsResponse, type ApiPerpetualsVaultsWithdrawRequestsBody, type ApiPerpetualsVaultsWithdrawRequestsResponse, type ApiPerpetualsWithdrawCollateralBody, type ApiPerpetualsWithdrawCollateralResponse, type ApiPoolAllCoinWithdrawBody, type ApiPoolDepositBody, type ApiPoolObjectIdForLpCoinTypeBody, type ApiPoolSpotPriceBody, type ApiPoolTradeBody, type ApiPoolWithdrawBody, type ApiPoolsOwnedDaoFeePoolOwnerCapsBody, type ApiPoolsStatsBody, type ApiPublishLpCoinBody, type ApiReferralsCreateReferralLinkBody, type ApiReferralsCreateReferralLinkResponse, type ApiReferralsGetLinkedRefCodeBody, type ApiReferralsGetLinkedRefCodeResponse, type ApiReferralsGetRefCodeBody, type ApiReferralsGetRefCodeResponse, type ApiReferralsGetRefereesBody, type ApiReferralsGetRefereesResponse, type ApiReferralsIsRefCodeTakenBody, type ApiReferralsIsRefCodeTakenResponse, type ApiReferralsSetReferrerBody, type ApiReferralsSetReferrerResponse, type ApiRemoveSuiFrenAccessoryBody, type ApiRewardsClaimRequestTxBody, type ApiRewardsClaimRequestTxResponse, type ApiRewardsGetClaimableBody, type ApiRewardsGetClaimableResponse, type ApiRewardsGetHistoryBody, type ApiRewardsGetHistoryResponse, type ApiRewardsGetPointsBody, type ApiRewardsGetPointsResponse, type ApiRouterAddTransactionForCompleteTradeRouteBody, type ApiRouterAddTransactionForCompleteTradeRouteResponse, type ApiRouterCompleteTradeRouteBody, type ApiRouterDynamicGasBody, type ApiRouterPartialCompleteTradeRouteBody, type ApiRouterTradeEventsBody, type ApiRouterTransactionForCompleteTradeRouteBody, type ApiStakeBody, type ApiStakeStakedSuiBody, type ApiStakeSuiFrenBody, type ApiStakingEventsBody, type ApiStakingPositionsBody, type ApiTransactionResponse, type ApiTransactionsBody, type ApiUnstakeBody, type ApiUnstakeSuiFrenBody, type ApiUpdateValidatorFeeBody, type ApiValidatorOperationCapsBody, type Apr, type Apy, Auth, type Balance, type BigIntAsString, type Byte, type CallerConfig, type CanceledOrderEvent, type CapyLabsAppObject, Casting, Coin, type CoinDecimal, type CoinGeckoChain, type CoinGeckoCoinApiId, type CoinGeckoCoinData, type CoinGeckoCoinSymbolData, type CoinGeckoHistoricalTradeData, type CoinGeckoTickerData, type CoinMetadaWithInfo, type CoinPriceInfo, type CoinSymbol, type CoinSymbolToCoinTypes, type CoinSymbolsToPriceInfo, type CoinType, type CoinWithAmount, type CoinWithAmountOrUndefined, type CoinsToBalance, type CoinsToBalanceOrUndefined, type CoinsToDecimals, type CoinsToPrice, type CoinsToPriceInfo, type CollateralEvent, type Color, type ComposedTransferArgs, type ConfigAddresses, type CreatedAccountEvent, type CreatedDaoFeePoolEvent, type CreatedStopOrderTicketEvent, type DaoFeePoolObject, type DaoFeePoolOwnerCapObject, type DaoFeePoolsAddresses, type DcaAddresses, type DeallocatedCollateralEvent, type DecimalsScalar, type DeferredAccountArgs, type DeletedStopOrderTicketEvent, type DepositedCollateralEvent, type DynamicFieldObjectsWithCursor, type DynamicFieldsInputs, type DynamicFieldsWithCursor, type DynamicGasAddresses, type EditedStopOrderTicketDetailsEvent, type EditedStopOrderTicketExecutorEvent, type EpochWasChangedEvent, type Event$1 as Event, type EventsInputs, type EventsWithCursor, type ExecutedStopOrderTicketEvent, type ExternalFee, type FarmEvent, type FarmOwnerOrOneTimeAdminCap, type FarmUserEvent, Farms, type FarmsAddedRewardEvent, type FarmsAddresses, type FarmsCreatedVaultEvent, type FarmsDepositedPrincipalEvent, type FarmsDestroyedStakedPositionEvent, type FarmsHarvestedRewardsEvent, type FarmsIncreasedEmissionsEvent, type FarmsInitializedRewardEvent, type FarmsJoinedEvent, type FarmsLockEnforcement, type FarmsLockedEvent, type FarmsMultiplier, type FarmsSplitEvent, type FarmsStakedEvent, FarmsStakedPosition, type FarmsStakedPositionObject, type FarmsStakedPositionRewardCoin, type FarmsStakedRelaxedEvent, FarmsStakingPool, type FarmsStakingPoolObject, type FarmsStakingPoolRewardCoin, type FarmsUnlockedEvent, type FarmsVersion, type FarmsWithdrewPrincipalEvent, Faucet, type FaucetAddCoinEvent, type FaucetAddresses, type FaucetMintCoinEvent, type FilePath, type FilledMakerOrderEventFields, type FilledMakerOrdersEvent, type FilledTakerOrderEvent, type FunctionName, type GasBudget, GasPools, type HarvestSuiFrenFeesEvent, Helpers, type IFixed, type IFixedAsBytes, type IFixedAsString, type IFixedAsStringBytes, type IdAsStringBytes, type IndexerDataWithCursorQueryParams, type IndexerEventsWithCursor, type KeyType, type KioskObject, type KioskOwnerCapObject, type LimitAddresses, type LiquidatedEvent, type LocalUrl, type MixSuiFrensEvent, type ModuleName, type MoveErrorCode, type MoveErrors, type MoveErrorsInterface, type Nft, NftAmm, type NftAmmAddresses, type NftAmmInterfaceGenericTypes, type NftAmmMarketObject, type NftDisplay, type NftDisplayOther, type NftDisplaySuggested, type NftInfo, type NftsAddresses, type NormalizedBalance, type NumberAsString, type Object$1 as Object, type ObjectDigest, type ObjectId, type ObjectVersion, type OrderbookFillReceiptEvent, type PackageId, type ParsedMoveError, type PartialFarmsStakedPositionObject, type PartialSuiFrenObject, type Percentage, Perpetuals, PerpetualsAccount, type PerpetualsAccountCap, type PerpetualsAccountCollateralChange, type PerpetualsAccountData, type PerpetualsAccountId, type PerpetualsAccountMarginHistoryData, type PerpetualsAccountMarginHistoryTimeframeKey, type PerpetualsAccountObject, type PerpetualsAccountOrderHistoryData, type PerpetualsAddresses, type PerpetualsBuilderCodeParamaters, type PerpetualsCalculationVariables, type PerpetualsCapType, type PerpetualsExecutionInfo, type PerpetualsFilledOrderData, type PerpetualsIntegratorVaultData, type PerpetualsMakerData, PerpetualsMarket, type PerpetualsMarket24hrStats, type PerpetualsMarketCandleDataPoint, type PerpetualsMarketData, type PerpetualsMarketFundingHistoryPoint, type PerpetualsMarketId, type PerpetualsMarketOrderHistoryData, type PerpetualsMarketParams, type PerpetualsMarketState, type PerpetualsOrderData, type PerpetualsOrderEvent, type PerpetualsOrderId, type PerpetualsOrderIdAsString, type PerpetualsOrderInfo, type PerpetualsOrderPrice, PerpetualsOrderSide, type PerpetualsOrderState, PerpetualsOrderType, type PerpetualsOrderbook, type PerpetualsOrderbookDeltas, type PerpetualsOrderbookItem, type PerpetualsPartialVaultCap, type PerpetualsPosition, type PerpetualsRewardData, type PerpetualsSponsorConfig, type PerpetualsStopOrderData, PerpetualsStopOrderType, type PerpetualsTakerData, type PerpetualsTopOfOrderbook, type PerpetualsTopOfOrderbookDataPoint, type PerpetualsTwapEvent, PerpetualsVault, type PerpetualsVaultCap, type PerpetualsVaultLpCoin, type PerpetualsVaultMetatada, type PerpetualsVaultObject, type PerpetualsVaultWithdrawRequest, type PerpetualsVaultsAddresses, type PerpetualsWsCandleResponseMessage, type PerpetualsWsUpdatesMarketOrdersPayload, type PerpetualsWsUpdatesMarketOrdersSubscriptionType, type PerpetualsWsUpdatesMarketSubscriptionType, type PerpetualsWsUpdatesOraclePayload, type PerpetualsWsUpdatesOracleSubscriptionType, type PerpetualsWsUpdatesOrderbookPayload, type PerpetualsWsUpdatesOrderbookSubscriptionType, type PerpetualsWsUpdatesResponseMessage, type PerpetualsWsUpdatesSubscriptionAction, type PerpetualsWsUpdatesSubscriptionMessage, type PerpetualsWsUpdatesSubscriptionType, type PerpetualsWsUpdatesTopOfOrderbookPayload, type PerpetualsWsUpdatesTopOfOrderbookSubscriptionType, type PerpetualsWsUpdatesUserCollateralChangesPayload, type PerpetualsWsUpdatesUserCollateralChangesSubscriptionType, type PerpetualsWsUpdatesUserOrdersPayload, type PerpetualsWsUpdatesUserOrdersSubscriptionType, type PerpetualsWsUpdatesUserPayload, type PerpetualsWsUpdatesUserSubscriptionType, Pool, type PoolCoin, type PoolCoins, type PoolCreationCoinInfo, type PoolCreationLpCoinMetadata, type PoolDataPoint, type PoolDepositEvent, type PoolDepositFee, type PoolFlatness, type PoolGraphDataTimeUnit, type PoolGraphDataTimeframe, type PoolGraphDataTimeframeKey, type PoolLpInfo, type PoolName, type PoolObject, type PoolStats, type PoolTradeEvent, type PoolTradeFee, type PoolWeight, type PoolWithdrawEvent, type PoolWithdrawFee, Pools, type PoolsAddresses, type PostedOrderEvent, type RateLimit, type ReceivedCollateralEvent, type ReducedOrderEvent, ReferralVault, type ReferralVaultAddresses, type ReferralsRefereeInfo, type RewardsClaimableReward, type RewardsHistoryEntry, type RewardsHistoryEventType, type RewardsPaginationInfo, Router, type RouterAddresses, type RouterCompleteTradeRoute, type RouterCompleteTradeRouteWithFee, type RouterExternalFee, type RouterProtocolName, type RouterTradeCoin, type RouterTradeEvent, type RouterTradeInfo, type RouterTradePath, type RouterTradeRoute, type RpcEndpoint, type ScallopAddresses, type SdkPerpetualsCancelAndPlaceOrdersInputs, type SdkPerpetualsCancelOrdersPreviewInputs, type SdkPerpetualsPlaceLimitOrderInputs, type SdkPerpetualsPlaceLimitOrderPreviewInputs, type SdkPerpetualsPlaceMarketOrderInputs, type SdkPerpetualsPlaceMarketOrderPreviewInputs, type SdkPerpetualsPlaceScaleOrderInputs, type SdkPerpetualsPlaceScaleOrderPreviewInputs, type SdkPerpetualsPlaceSlTpOrdersInputs, type SdkPerpetualsPlaceStopOrdersInputs, type SdkTransactionResponse, type SerializedTransaction, type ServiceCoinData, type ServiceCoinDataV2, type SetPositionInitialMarginRatioEvent, type SettledFundingEvent, type SharedCustodyAddresses, type SignMessageCallback, type Slippage, type StakeBalanceDynamicField, type StakeEvent, type StakePosition, type StakeSuiFrenEvent, type StakedEvent, StakedSuiFren, type StakedSuiFrenInfo, type StakedSuiFrenMetadataV1Object, type StakedSuiFrenPositionObject, type StakedSuiVaultStateObject, Staking, type StakingAddresses, type StakingApyDataPoint, type StakingApyTimeframeKey, type StakingPoolOneTimeAdminCapObject, type StakingPoolOwnerCapObject, type StakingPosition, type StringByte, Sui, type SuiAddress, type SuiCheckpoint, type SuiDelegatedStake, type SuiDelegatedStakeState, SuiFren, type SuiFrenAccessoryName, type SuiFrenAccessoryObject, type SuiFrenAccessoryType, type SuiFrenAttributes, type SuiFrenObject, type SuiFrenStats, type SuiFrenVaultStateV1Object, SuiFrens, type SuiFrensAddresses, SuiFrensSortOption, type SuiNetwork, type Timestamp, type TransactionDigest, type TransactionsWithCursor, type TransferredDeallocatedCollateralEvent, type TranslatedMoveError, type TxBytes, type UniqueId, type UnstakeEvent, type UnstakePosition, type UnstakePositionState, type UnstakeRequestedEvent, type UnstakeSuiFrenEvent, type UnstakedEvent, type UpdatedFeeBpsEvent, type UpdatedFeeRecipientEvent, type UpdatedFundingEvent, type UpdatedMarketVersionEvent, type UpdatedPremiumTwapEvent, type UpdatedSpreadTwapEvent, type Url, type UserEventsInputs, type UserHistoryEventType, type ValidatorConfigObject, type ValidatorOperationCapObject, type WithdrewCollateralEvent, isAllocatedCollateralEvent, isCanceledOrderEvent, isDeallocatedCollateralEvent, isDepositedCollateralEvent, isFarmsDepositedPrincipalEvent, isFarmsHarvestedRewardsEvent, isFarmsLockedEvent, isFarmsStakedEvent, isFarmsUnlockedEvent, isFarmsWithdrewPrincipalEvent, isFilledMakerOrdersEvent, isFilledTakerOrderEvent, isLiquidatedEvent, isPostedOrderEvent, isReducedOrderEvent, isSettledFundingEvent, isStakeEvent, isStakePosition, isSuiDelegatedStake, isUnstakeEvent, isUnstakePosition, isUpdatedFundingEvent, isUpdatedMarketVersion, isUpdatedPremiumTwapEvent, isUpdatedSpreadTwapEvent, isWithdrewCollateralEvent };