aftermath-ts-sdk 5.1.1-dev.5176abd → 5.1.1-dev.7aecc77

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.js CHANGED
@@ -2816,9 +2816,9 @@ var init_caller = __esm({
2816
2816
  if (this.apiBaseUrl === void 0) {
2817
2817
  throw new Error("no apiBaseUrl: unable to fetch data");
2818
2818
  }
2819
- const safeUrl = this.apiBaseUrl.slice(-1) === "/" ? this.apiBaseUrl.slice(0, -1) : this.apiBaseUrl;
2820
- const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
2821
- return `${safeUrl}/${endpointSegment}${this.apiUrlPrefix + (url === "" ? "" : "/")}${url}`;
2819
+ const baseUrl = this.apiBaseUrl.replace(_Caller.TRAILING_SLASHES_REGEX, "");
2820
+ const path = [this.apiEndpoint, this.apiUrlPrefix, url].map((segment) => segment.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
2821
+ return `${baseUrl}/${path}`;
2822
2822
  };
2823
2823
  /**
2824
2824
  * Stores an access token on this caller for later requests.
@@ -3064,19 +3064,10 @@ var init_caller = __esm({
3064
3064
  if (this.apiBaseUrl === void 0) {
3065
3065
  throw new Error("no apiBaseUrl: unable to open websocket");
3066
3066
  }
3067
- const baseHttp = this.apiBaseUrl.replace(
3068
- _Caller.TRAILING_SLASHES_REGEX,
3069
- ""
3067
+ return this.urlForApiCall(path2).replace(
3068
+ _Caller.HTTP_PROTOCOL_REGEX,
3069
+ "ws$1://"
3070
3070
  );
3071
- const baseWs = baseHttp.replace(_Caller.HTTP_PROTOCOL_REGEX, "ws$1://");
3072
- const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
3073
- const prefix = `${endpointSegment}${this.apiUrlPrefix}`;
3074
- const normalizedPrefix = prefix.replace(
3075
- _Caller.TRAILING_SLASHES_REGEX,
3076
- ""
3077
- );
3078
- const normalizedPath = path2.startsWith("/") ? path2.slice(1) : path2;
3079
- return `${baseWs}/${normalizedPrefix}${normalizedPath ? `/${normalizedPath}` : ""}`;
3080
3071
  };
3081
3072
  const url = buildWsUrl(path);
3082
3073
  const ws = new WebSocket(url);
@@ -14989,6 +14980,35 @@ var init_perpetuals = __esm({
14989
14980
  marketIds
14990
14981
  });
14991
14982
  }
14983
+ /**
14984
+ * Fetch daily realized PnL and funding for one or more accounts, bucketed
14985
+ * by UTC calendar day from account creation through today.
14986
+ *
14987
+ * @param inputs.accountIds - 1 to 50 account IDs to query.
14988
+ *
14989
+ * @returns `ApiPerpetualsAccountsPnlCalendarResponse` containing one
14990
+ * calendar per distinct account.
14991
+ *
14992
+ * @remarks
14993
+ * If `accountIds` is empty, this returns `{ accounts: [] }` without making an API call.
14994
+ *
14995
+ * @example
14996
+ * ```ts
14997
+ * const { accounts } = await perps.getAccountsPnlCalendar({
14998
+ * accountIds: [123n],
14999
+ * });
15000
+ * ```
15001
+ */
15002
+ async getAccountsPnlCalendar(inputs) {
15003
+ if (inputs.accountIds.length <= 0) {
15004
+ return {
15005
+ accounts: []
15006
+ };
15007
+ }
15008
+ return this.fetchApi("accounts/pnl-calendar", {
15009
+ accountIds: inputs.accountIds
15010
+ });
15011
+ }
14992
15012
  // =========================================================================
14993
15013
  // Ownership Queries
14994
15014
  // =========================================================================
@@ -15496,7 +15516,7 @@ var init_perpetuals = __esm({
15496
15516
  * collect fees on orders placed on behalf of the user. Once revoked, the integrator
15497
15517
  * will no longer be able to submit orders with integrator fees for this account.
15498
15518
  * The user can re-approve the integrator at any time by calling
15499
- * `getCreateIntegratorConfigTx` again.
15519
+ * `getCreateBuilderCodeIntegratorConfigTx` again.
15500
15520
  *
15501
15521
  * The resulting transaction must be signed by the account owner and executed on-chain.
15502
15522
  *
@@ -15525,86 +15545,6 @@ var init_perpetuals = __esm({
15525
15545
  }
15526
15546
  );
15527
15547
  }
15528
- /**
15529
- * Build a transaction to initialize an integrator's global fee vault.
15530
- *
15531
- * This endpoint creates a transaction that initializes the global vault where an
15532
- * integrator's fees accumulate across all markets. This is a one-time setup that
15533
- * must be performed before the integrator can claim fees. The integrator's identity
15534
- * is taken from the transaction sender on-chain.
15535
- *
15536
- * The resulting transaction must be signed by the integrator and executed on-chain.
15537
- *
15538
- * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody}.
15539
- * @returns `SdkTransactionResponse` with `tx`.
15540
- *
15541
- * @example
15542
- * ```ts
15543
- * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({});
15544
- * ```
15545
- */
15546
- async getCreateBuilderCodeIntegratorVaultTx(inputs) {
15547
- const { tx, ...otherInputs } = inputs;
15548
- return this.fetchApiTxObject(
15549
- "builder-codes/transactions/create-integrator-vault",
15550
- {
15551
- ...otherInputs,
15552
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
15553
- },
15554
- void 0,
15555
- {
15556
- txKind: true
15557
- }
15558
- );
15559
- }
15560
- /**
15561
- * Build a transaction to claim accumulated integrator fees from a vault.
15562
- *
15563
- * This endpoint creates a transaction that allows an integrator to claim the fees
15564
- * they have earned from orders placed on behalf of users. Fees accumulate in the
15565
- * integrator's global vault (across all markets) and can be claimed at any moment.
15566
- * The fees are proportional to the taker volume generated by the users' orders that
15567
- * the integrator submitted.
15568
- *
15569
- * If a `recipientAddress` is provided, the claimed fees will be automatically
15570
- * transferred to that address. Otherwise, the coin outputs are exposed as transaction
15571
- * arguments for further use in the transaction (one per non-zero collateral balance).
15572
- *
15573
- * The resulting transaction must be signed by the integrator and executed on-chain.
15574
- *
15575
- * @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
15576
- * @returns `ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse` containing
15577
- * `txKind` and optionally `coinOutArgs`.
15578
- *
15579
- * @example
15580
- * ```ts
15581
- * // Claim with automatic transfer to recipient
15582
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
15583
- * integratorId: 7,
15584
- * recipientAddress: "0x...",
15585
- * });
15586
- *
15587
- * // Claim with coin outputs for further use
15588
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
15589
- * integratorId: 7,
15590
- * });
15591
- * // response.coinOutArgs can be used in subsequent transaction commands
15592
- * ```
15593
- */
15594
- async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
15595
- const { tx, ...otherInputs } = inputs;
15596
- return this.fetchApiTxObject(
15597
- "builder-codes/transactions/claim-integrator-vault-fees",
15598
- {
15599
- ...otherInputs,
15600
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
15601
- },
15602
- void 0,
15603
- {
15604
- txKind: true
15605
- }
15606
- );
15607
- }
15608
15548
  // =========================================================================
15609
15549
  // Builder Codes Inspections
15610
15550
  // =========================================================================
@@ -15639,41 +15579,6 @@ var init_perpetuals = __esm({
15639
15579
  async getBuilderCodeIntegratorConfig(inputs) {
15640
15580
  return this.fetchApi("builder-codes/integrator-config", inputs);
15641
15581
  }
15642
- /**
15643
- * Fetch accumulated integrator vault fees.
15644
- *
15645
- * This endpoint queries the total fees an integrator has earned and accumulated in
15646
- * their global vault, grouped by collateral coin type. Integrators earn fees
15647
- * proportional to the taker volume generated by orders they submit on behalf of
15648
- * users. These fees can be claimed at any time using
15649
- * {@link getClaimBuilderCodeIntegratorVaultFeesTx}.
15650
- *
15651
- * This information is useful for:
15652
- * - Displaying total claimable fees to integrators in dashboards
15653
- * - Monitoring fee accrual across collateral types
15654
- * - Determining whether fees are ready to be claimed
15655
- *
15656
- * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
15657
- * @returns `ApiPerpetualsBuilderCodesIntegratorVaultsResponse` containing
15658
- * a vector of per-collateral vault data with accumulated fees.
15659
- *
15660
- * @example
15661
- * ```ts
15662
- * const vaultFees = await perps.getBuilderCodeIntegratorVaults({
15663
- * integratorId: 7,
15664
- * });
15665
- *
15666
- * for (const vault of vaultFees.integratorVaults) {
15667
- * console.log(`${vault.collateralCoinType}: ${vault.fees} collateral units claimable`);
15668
- * }
15669
- *
15670
- * const totalFeesUsd = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.feesUsd, 0);
15671
- * console.log(`Total claimable (USD): ${totalFeesUsd}`);
15672
- * ```
15673
- */
15674
- async getBuilderCodeIntegratorVaults(inputs) {
15675
- return this.fetchApi("builder-codes/integrator-vaults", inputs);
15676
- }
15677
15582
  // =========================================================================
15678
15583
  // Public Static Helpers
15679
15584
  // =========================================================================
@@ -15920,14 +15825,14 @@ var init_perpetuals = __esm({
15920
15825
  };
15921
15826
  }
15922
15827
  /**
15923
- * Open a market-candles websocket stream for a single market/interval:
15924
- * `/perpetuals/ws/market-candles/{market_id}/{interval_ms}`.
15828
+ * Open a market-candles subscription for a single market/interval on
15829
+ * `/perpetuals/ws/updates`.
15925
15830
  *
15926
15831
  * The stream emits {@link PerpetualsWsCandleResponseMessage} messages,
15927
15832
  * typically containing the latest candle for the specified interval.
15928
15833
  *
15929
15834
  * @param args.marketId - Market ID to subscribe to.
15930
- * The input contains the candle interval in milliseconds.
15835
+ * @param args.interval - Timeframe label such as `"1m"` or `"1h"`.
15931
15836
  * @param args.onMessage - Handler for incoming candle updates.
15932
15837
  * @param args.onOpen - Optional hook called when the websocket opens.
15933
15838
  * @param args.onError - Optional hook called on websocket error.
@@ -15939,7 +15844,7 @@ var init_perpetuals = __esm({
15939
15844
  * ```ts
15940
15845
  * const stream = perps.openMarketCandlesWebsocketStream({
15941
15846
  * marketId: "0x...",
15942
- * intervalMs: 60_000,
15847
+ * interval: "1m",
15943
15848
  * onMessage: ({ lastCandle }) => console.log(lastCandle),
15944
15849
  * });
15945
15850
  * ```
@@ -17868,7 +17773,6 @@ var init_packages = __esm({
17868
17773
  "src/packages/index.ts"() {
17869
17774
  "use strict";
17870
17775
  init_auth2();
17871
- init_auth2();
17872
17776
  init_coin2();
17873
17777
  init_farms2();
17874
17778
  init_faucet2();