aftermath-ts-sdk 5.0.1 → 5.0.2-dev.199e2ab

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
@@ -691,8 +691,8 @@ interface PoolsAddresses {
691
691
  };
692
692
  /** Optional data required to publish LP-coin packages. */
693
693
  other?: {
694
- /** JSON-serialized Move modules and dependencies keyed by LP-coin decimals. */
695
- createLpCoinPackageCompilations: Record<CoinDecimal, string>;
694
+ /** Serialized Move package compilation templated per pool for LP-coin publishing. */
695
+ createLpCoinPackageCompilation: string;
696
696
  };
697
697
  }
698
698
  /** Package and object addresses used by DAO fee-pool operations. */
@@ -3047,8 +3047,13 @@ interface PerpetualsVaultObject {
3047
3047
  /** Minimum position margin (USD) to trigger full close during force withdraw. */
3048
3048
  minForceWithdrawValueUsd: number;
3049
3049
  };
3050
- /** Owner address of the vault. */
3051
- ownerAddress: SuiAddress;
3050
+ /**
3051
+ * Owner address of the vault.
3052
+ *
3053
+ * `null` when the vault's owner cap, or its owner address, cannot be
3054
+ * resolved. The field is always present; only its value may be null.
3055
+ */
3056
+ ownerAddress: SuiAddress | null;
3052
3057
  /** Creation timestamp of the vault. */
3053
3058
  creationTimestamp: Timestamp | undefined;
3054
3059
  /** Underlying perpetuals account ID that the vault uses. */
@@ -7584,6 +7589,8 @@ interface PoolCreationLpCoinMetadata {
7584
7589
  symbol: string;
7585
7590
  /** An optional URL for the LP coin icon. */
7586
7591
  iconUrl?: Url;
7592
+ /** An optional description templated into the LP coin package. */
7593
+ description?: string;
7587
7594
  }
7588
7595
  /**
7589
7596
  * A data structure used for integration with CoinGecko, representing
@@ -7694,10 +7701,23 @@ interface ApiPoolAllCoinWithdrawBody {
7694
7701
  * typically specifying the coin's decimals.
7695
7702
  */
7696
7703
  interface ApiPublishLpCoinBody {
7697
- /** The wallet that publishes and receives the LP coin package upgrade cap. */
7704
+ /** The wallet that publishes the LP coin package and receives the pool-creation cap. */
7698
7705
  walletAddress: SuiAddress;
7699
- /** The decimal precision compiled into the LP coin package. */
7700
- lpCoinDecimals: number;
7706
+ /** Name, symbol, optional icon, and optional description templated into the LP coin. */
7707
+ lpCoinMetadata: PoolCreationLpCoinMetadata;
7708
+ /** Per-coin type, weight, and decimals templated into the LP coin package. */
7709
+ coinsInfo: {
7710
+ /** The fully qualified coin type deposited into the pool. */
7711
+ coinType: CoinType;
7712
+ /** The decimal weight for this coin. Weights must sum to `1`. */
7713
+ weight: Percentage;
7714
+ /** Optional display precision stored for this coin. */
7715
+ decimals?: number;
7716
+ }[];
7717
+ /** The pool curve mode passed to Move as a flatness value. */
7718
+ poolFlatness: 0 | 1;
7719
+ /** Whether the supplied coin decimals are preserved for the LP coin. */
7720
+ respectDecimals: boolean;
7701
7721
  }
7702
7722
  /**
7703
7723
  * Request body for creating a new pool, specifying coin information,
@@ -7708,8 +7728,6 @@ interface ApiCreatePoolBody {
7708
7728
  walletAddress: SuiAddress;
7709
7729
  /** The fully qualified LP coin type used by the new pool. */
7710
7730
  lpCoinType: CoinType;
7711
- /** Metadata for the LP coin published for the pool. */
7712
- lpCoinMetadata: PoolCreationLpCoinMetadata;
7713
7731
  /** Per-coin weights, fees, decimal metadata, and initial deposits. */
7714
7732
  coinsInfo: {
7715
7733
  /** The fully qualified coin type deposited into the pool. */
@@ -7731,8 +7749,6 @@ interface ApiCreatePoolBody {
7731
7749
  createPoolCapId: ObjectId;
7732
7750
  /** Whether the transaction should preserve the supplied coin decimals. */
7733
7751
  respectDecimals: boolean;
7734
- /** Optional decimal precision forced for the LP coin. */
7735
- forceLpDecimals?: CoinDecimal;
7736
7752
  /** Whether coin selection is prepared for a sponsored transaction. */
7737
7753
  isSponsoredTx?: boolean;
7738
7754
  /** Whether the LP coin is burned as part of the creation flow. */
@@ -11288,20 +11304,29 @@ declare class Pools extends Caller {
11288
11304
  walletAddress: SuiAddress;
11289
11305
  }): Promise<PoolLpInfo[]>;
11290
11306
  /**
11291
- * Builds an unsigned transaction that publishes the compiled LP coin package.
11307
+ * Builds an unsigned transaction that publishes an LP coin package templated
11308
+ * for this pool and mints its `CreatePoolCapV2`.
11292
11309
  *
11293
- * The transaction transfers the resulting upgrade capability to
11294
- * `walletAddress`. It is not signed, submitted, or serialized by this method.
11310
+ * The API templates the LP coin package with the pool's metadata, weights,
11311
+ * decimals, and flatness, publishes it, and transfers the resulting cap and
11312
+ * upgrade capability to `walletAddress`. This method does not sign, submit, or
11313
+ * serialize the returned `Transaction`.
11295
11314
  *
11296
- * @param inputs - Publisher address and compiled LP coin decimal precision.
11315
+ * @param inputs - Publisher address, LP coin metadata, and pool configuration.
11297
11316
  * @returns A promise for the unsigned publish `Transaction`.
11298
- * @throws `Error` when the provider lacks the compiled package for the requested decimals.
11317
+ * @throws `AftermathTransportError` when the API cannot build or decode the transaction.
11299
11318
  *
11300
11319
  * @example
11301
11320
  * ```typescript
11302
11321
  * const publishTx = await pools.getPublishLpCoinTransaction({
11303
11322
  * walletAddress: "0x<address>",
11304
- * lpCoinDecimals: 9
11323
+ * lpCoinMetadata: { name: "MyPool LP", symbol: "MYPLP" },
11324
+ * coinsInfo: [
11325
+ * { weight: 0.5, decimals: 9 },
11326
+ * { weight: 0.5, decimals: 6 },
11327
+ * ],
11328
+ * poolFlatness: 0,
11329
+ * respectDecimals: true,
11305
11330
  * });
11306
11331
  * ```
11307
11332
  */
@@ -19591,15 +19616,6 @@ declare class PoolsApi implements MoveErrorsInterface {
19591
19616
  coinTypes: CoinType[];
19592
19617
  withTransfer?: boolean;
19593
19618
  }) => TransactionObjectArgument[];
19594
- /**
19595
- * Publishes a transaction block for creating a liquidity pool coin.
19596
- * @param inputs An object containing the transaction block and the decimal value of the liquidity pool coin.
19597
- * @returns A promise that resolves to the result of the transaction publishing.
19598
- */
19599
- publishLpCoinTx: (inputs: {
19600
- tx: Transaction;
19601
- lpCoinDecimals: CoinDecimal;
19602
- }) => _mysten_sui_transactions.TransactionResult;
19603
19619
  /**
19604
19620
  * Creates a transaction to create a new pool.
19605
19621
  * @param inputs - An object containing the necessary inputs to create the pool.
@@ -19618,14 +19634,10 @@ declare class PoolsApi implements MoveErrorsInterface {
19618
19634
  depositFee: PoolDepositFee;
19619
19635
  withdrawFee: PoolWithdrawFee;
19620
19636
  }[];
19621
- lpCoinMetadata: PoolCreationLpCoinMetadata;
19622
- lpCoinIconUrl: Url;
19623
19637
  createPoolCapId: ObjectId | TransactionObjectArgument;
19624
19638
  poolName: PoolName;
19625
19639
  poolFlatness: PoolFlatness;
19626
- lpCoinDescription: string;
19627
19640
  respectDecimals: boolean;
19628
- forceLpDecimals?: CoinDecimal;
19629
19641
  withTransfer?: boolean;
19630
19642
  }) => TransactionObjectArgument[];
19631
19643
  /**
@@ -19826,12 +19838,6 @@ declare class PoolsApi implements MoveErrorsInterface {
19826
19838
  lpCoinAmount: Balance;
19827
19839
  referrer?: SuiAddress;
19828
19840
  }) => Promise<Transaction>;
19829
- /**
19830
- * Builds a transaction block for publishing an LP coin.
19831
- * @param inputs - The input parameters for the transaction.
19832
- * @returns The built transaction block.
19833
- */
19834
- buildPublishLpCoinTx: (inputs: ApiPublishLpCoinBody) => Transaction;
19835
19841
  /**
19836
19842
  * Builds a standalone transaction that updates a DAO fee in basis points.
19837
19843
  *
package/dist/index.js CHANGED
@@ -10810,25 +10810,35 @@ var init_pools = __esm({
10810
10810
  // Transactions
10811
10811
  // =========================================================================
10812
10812
  /**
10813
- * Builds an unsigned transaction that publishes the compiled LP coin package.
10813
+ * Builds an unsigned transaction that publishes an LP coin package templated
10814
+ * for this pool and mints its `CreatePoolCapV2`.
10814
10815
  *
10815
- * The transaction transfers the resulting upgrade capability to
10816
- * `walletAddress`. It is not signed, submitted, or serialized by this method.
10816
+ * The API templates the LP coin package with the pool's metadata, weights,
10817
+ * decimals, and flatness, publishes it, and transfers the resulting cap and
10818
+ * upgrade capability to `walletAddress`. This method does not sign, submit, or
10819
+ * serialize the returned `Transaction`.
10817
10820
  *
10818
- * @param inputs - Publisher address and compiled LP coin decimal precision.
10821
+ * @param inputs - Publisher address, LP coin metadata, and pool configuration.
10819
10822
  * @returns A promise for the unsigned publish `Transaction`.
10820
- * @throws `Error` when the provider lacks the compiled package for the requested decimals.
10823
+ * @throws `AftermathTransportError` when the API cannot build or decode the transaction.
10821
10824
  *
10822
10825
  * @example
10823
10826
  * ```typescript
10824
10827
  * const publishTx = await pools.getPublishLpCoinTransaction({
10825
10828
  * walletAddress: "0x<address>",
10826
- * lpCoinDecimals: 9
10829
+ * lpCoinMetadata: { name: "MyPool LP", symbol: "MYPLP" },
10830
+ * coinsInfo: [
10831
+ * { weight: 0.5, decimals: 9 },
10832
+ * { weight: 0.5, decimals: 6 },
10833
+ * ],
10834
+ * poolFlatness: 0,
10835
+ * respectDecimals: true,
10827
10836
  * });
10828
10837
  * ```
10829
10838
  */
10830
10839
  async getPublishLpCoinTransaction(inputs) {
10831
- return this.poolsApi().buildPublishLpCoinTx(inputs);
10840
+ const { tx } = await this.fetchApiTxObject("transactions/publish-lp-coin", inputs);
10841
+ return tx;
10832
10842
  }
10833
10843
  /**
10834
10844
  * Builds an unsigned transaction that creates a new pool on chain.
@@ -10867,7 +10877,8 @@ var init_pools = __esm({
10867
10877
  * ```
10868
10878
  */
10869
10879
  async getCreatePoolTransaction(inputs) {
10870
- return this.fetchApiTransaction("transactions/create-pool", inputs);
10880
+ const { tx } = await this.fetchApiTxObject("transactions/create-pool", inputs);
10881
+ return tx;
10871
10882
  }
10872
10883
  /**
10873
10884
  * Resolves LP coin types to pool object IDs.
@@ -14516,7 +14527,7 @@ var init_perpetualsVault = __esm({
14516
14527
  partialVaultCap() {
14517
14528
  return {
14518
14529
  vaultId: this.vaultObject.objectId,
14519
- ownerAddress: this.vaultObject.ownerAddress,
14530
+ ownerAddress: this.vaultObject.ownerAddress ?? "",
14520
14531
  accountId: this.vaultObject.accountId,
14521
14532
  accountObjectId: this.vaultObject.accountObjectId,
14522
14533
  collateralCoinType: this.vaultObject.collateralCoinType
@@ -23818,7 +23829,6 @@ import { bcs as bcs2 } from "@mysten/sui/bcs";
23818
23829
  import {
23819
23830
  Transaction as Transaction12
23820
23831
  } from "@mysten/sui/transactions";
23821
- import { fromBase64 as fromBase642, normalizeSuiObjectId } from "@mysten/sui/utils";
23822
23832
  var _PoolsApi, PoolsApi;
23823
23833
  var init_poolsApi = __esm({
23824
23834
  "src/packages/pools/api/poolsApi.ts"() {
@@ -24022,29 +24032,6 @@ var init_poolsApi = __esm({
24022
24032
  ]
24023
24033
  });
24024
24034
  };
24025
- /**
24026
- * Publishes a transaction block for creating a liquidity pool coin.
24027
- * @param inputs An object containing the transaction block and the decimal value of the liquidity pool coin.
24028
- * @returns A promise that resolves to the result of the transaction publishing.
24029
- */
24030
- this.publishLpCoinTx = (inputs) => {
24031
- const compilations = this.addresses.pools.other?.createLpCoinPackageCompilations;
24032
- if (!compilations) {
24033
- throw new Error(
24034
- "not all required addresses have been set in provider for lp coin publishing (requires package compilations)"
24035
- );
24036
- }
24037
- const { tx, lpCoinDecimals } = inputs;
24038
- const compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);
24039
- return tx.publish({
24040
- modules: compiledModulesAndDeps.modules.map(
24041
- (m) => Array.from(fromBase642(m))
24042
- ),
24043
- dependencies: compiledModulesAndDeps.dependencies.map(
24044
- (addr) => normalizeSuiObjectId(addr)
24045
- )
24046
- });
24047
- };
24048
24035
  // TODO: handle bounds checks here instead of just on-chain ?
24049
24036
  /**
24050
24037
  * Creates a transaction to create a new pool.
@@ -24052,16 +24039,7 @@ var init_poolsApi = __esm({
24052
24039
  * @returns A transaction block to create the pool.
24053
24040
  */
24054
24041
  this.createPoolTx = (inputs) => {
24055
- const {
24056
- tx,
24057
- lpCoinType,
24058
- createPoolCapId,
24059
- coinsInfo,
24060
- lpCoinMetadata,
24061
- lpCoinDescription,
24062
- lpCoinIconUrl,
24063
- withTransfer
24064
- } = inputs;
24042
+ const { tx, lpCoinType, createPoolCapId, coinsInfo, withTransfer } = inputs;
24065
24043
  const poolSize = coinsInfo.length;
24066
24044
  const coinTypes = coinsInfo.map((coin) => coin.coinType);
24067
24045
  const decimals = coinsInfo.map((coin) => coin.decimals);
@@ -24069,7 +24047,7 @@ var init_poolsApi = __esm({
24069
24047
  target: Helpers.transactions.createTxTarget(
24070
24048
  withTransfer ? this.addresses.pools.packages.ammInterface : this.addresses.pools.packages.amm,
24071
24049
  withTransfer ? _PoolsApi.constants.moduleNames.interface : _PoolsApi.constants.moduleNames.poolFactory,
24072
- `create_pool_${poolSize}_coins`
24050
+ `create_pool_${poolSize}_coins_v2`
24073
24051
  ),
24074
24052
  typeArguments: [lpCoinType, ...coinTypes],
24075
24053
  arguments: [
@@ -24078,25 +24056,6 @@ var init_poolsApi = __esm({
24078
24056
  tx.pure(
24079
24057
  bcs2.vector(bcs2.u8()).serialize(Casting.u8VectorFromString(inputs.poolName))
24080
24058
  ),
24081
- tx.pure(
24082
- bcs2.vector(bcs2.u8()).serialize(
24083
- Casting.u8VectorFromString(lpCoinMetadata.name.toString())
24084
- )
24085
- ),
24086
- tx.pure(
24087
- bcs2.vector(bcs2.u8()).serialize(
24088
- Casting.u8VectorFromString(
24089
- lpCoinMetadata.symbol.toString().toUpperCase()
24090
- )
24091
- )
24092
- ),
24093
- tx.pure(
24094
- bcs2.vector(bcs2.u8()).serialize(Casting.u8VectorFromString(lpCoinDescription))
24095
- ),
24096
- tx.pure(
24097
- bcs2.vector(bcs2.u8()).serialize(Casting.u8VectorFromString(lpCoinIconUrl))
24098
- ),
24099
- // lp_icon_url
24100
24059
  tx.pure(
24101
24060
  bcs2.vector(bcs2.u64()).serialize(coinsInfo.map((coin) => coin.weight))
24102
24061
  ),
@@ -24121,11 +24080,7 @@ var init_poolsApi = __esm({
24121
24080
  decimals.includes(void 0) ? void 0 : decimals
24122
24081
  )
24123
24082
  ),
24124
- // decimals
24125
- tx.pure.bool(inputs.respectDecimals),
24126
- // respect_decimals
24127
- tx.pure(bcs2.option(bcs2.u8()).serialize(inputs.forceLpDecimals))
24128
- // force_lp_decimals
24083
+ tx.pure.bool(inputs.respectDecimals)
24129
24084
  ]
24130
24085
  });
24131
24086
  };
@@ -24641,19 +24596,6 @@ var init_poolsApi = __esm({
24641
24596
  }
24642
24597
  return tx;
24643
24598
  };
24644
- /**
24645
- * Builds a transaction block for publishing an LP coin.
24646
- * @param inputs - The input parameters for the transaction.
24647
- * @returns The built transaction block.
24648
- */
24649
- this.buildPublishLpCoinTx = (inputs) => {
24650
- const { lpCoinDecimals } = inputs;
24651
- const tx = new Transaction12();
24652
- tx.setSender(inputs.walletAddress);
24653
- const upgradeCap = this.publishLpCoinTx({ tx, lpCoinDecimals });
24654
- tx.transferObjects([upgradeCap], inputs.walletAddress);
24655
- return tx;
24656
- };
24657
24599
  /**
24658
24600
  * Builds a standalone transaction that updates a DAO fee in basis points.
24659
24601
  *