aftermath-ts-sdk 5.1.1-dev.d87511f → 5.1.1-dev.f287104
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/LICENSE +202 -0
- package/dist/index.d.ts +106 -235
- package/dist/index.js +39 -136
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
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
|
|
2820
|
-
const
|
|
2821
|
-
return `${
|
|
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
|
-
|
|
3068
|
-
_Caller.
|
|
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);
|
|
@@ -15134,6 +15125,34 @@ var init_perpetuals = __esm({
|
|
|
15134
15125
|
getMarkets24hrStats(inputs) {
|
|
15135
15126
|
return this.fetchApi("markets/24hr-stats", inputs);
|
|
15136
15127
|
}
|
|
15128
|
+
/**
|
|
15129
|
+
* Fetch the category and tag labels that group markets in a picker UI.
|
|
15130
|
+
*
|
|
15131
|
+
* The response is the vocabulary behind `PerpetualsMarketMetadata.category`
|
|
15132
|
+
* and `PerpetualsMarketMetadata.tags`: every market names exactly one of
|
|
15133
|
+
* these categories, and each of its tags is declared under that category.
|
|
15134
|
+
* Both lists come back in display order.
|
|
15135
|
+
*
|
|
15136
|
+
* The labels are configuration rather than a fixed enum, so resolve a
|
|
15137
|
+
* market's metadata against this response instead of hard-coding them.
|
|
15138
|
+
*
|
|
15139
|
+
* @param abortSignal - Optional cancellation signal.
|
|
15140
|
+
* @returns `ApiPerpetualsMarketsCategoriesResponse` containing `categories`.
|
|
15141
|
+
*
|
|
15142
|
+
* @remarks
|
|
15143
|
+
* `categories` is empty when the backing static configuration is unavailable.
|
|
15144
|
+
* Treat that as "no grouping" and show every market rather than rendering an
|
|
15145
|
+
* empty picker.
|
|
15146
|
+
*
|
|
15147
|
+
* @example
|
|
15148
|
+
* ```ts
|
|
15149
|
+
* const { categories } = await perps.getMarketsCategories();
|
|
15150
|
+
* // [{ name: "Crypto", tags: ["Layer 1", "DeFi", ...] }, ...]
|
|
15151
|
+
* ```
|
|
15152
|
+
*/
|
|
15153
|
+
getMarketsCategories(abortSignal) {
|
|
15154
|
+
return this.fetchApi("markets/categories", {}, abortSignal);
|
|
15155
|
+
}
|
|
15137
15156
|
// =========================================================================
|
|
15138
15157
|
// Prices
|
|
15139
15158
|
// =========================================================================
|
|
@@ -15468,7 +15487,7 @@ var init_perpetuals = __esm({
|
|
|
15468
15487
|
* collect fees on orders placed on behalf of the user. Once revoked, the integrator
|
|
15469
15488
|
* will no longer be able to submit orders with integrator fees for this account.
|
|
15470
15489
|
* The user can re-approve the integrator at any time by calling
|
|
15471
|
-
* `
|
|
15490
|
+
* `getCreateBuilderCodeIntegratorConfigTx` again.
|
|
15472
15491
|
*
|
|
15473
15492
|
* The resulting transaction must be signed by the account owner and executed on-chain.
|
|
15474
15493
|
*
|
|
@@ -15497,86 +15516,6 @@ var init_perpetuals = __esm({
|
|
|
15497
15516
|
}
|
|
15498
15517
|
);
|
|
15499
15518
|
}
|
|
15500
|
-
/**
|
|
15501
|
-
* Build a transaction to initialize an integrator's global fee vault.
|
|
15502
|
-
*
|
|
15503
|
-
* This endpoint creates a transaction that initializes the global vault where an
|
|
15504
|
-
* integrator's fees accumulate across all markets. This is a one-time setup that
|
|
15505
|
-
* must be performed before the integrator can claim fees. The integrator's identity
|
|
15506
|
-
* is taken from the transaction sender on-chain.
|
|
15507
|
-
*
|
|
15508
|
-
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
15509
|
-
*
|
|
15510
|
-
* @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody}.
|
|
15511
|
-
* @returns `SdkTransactionResponse` with `tx`.
|
|
15512
|
-
*
|
|
15513
|
-
* @example
|
|
15514
|
-
* ```ts
|
|
15515
|
-
* const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({});
|
|
15516
|
-
* ```
|
|
15517
|
-
*/
|
|
15518
|
-
async getCreateBuilderCodeIntegratorVaultTx(inputs) {
|
|
15519
|
-
const { tx, ...otherInputs } = inputs;
|
|
15520
|
-
return this.fetchApiTxObject(
|
|
15521
|
-
"builder-codes/transactions/create-integrator-vault",
|
|
15522
|
-
{
|
|
15523
|
-
...otherInputs,
|
|
15524
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
|
|
15525
|
-
},
|
|
15526
|
-
void 0,
|
|
15527
|
-
{
|
|
15528
|
-
txKind: true
|
|
15529
|
-
}
|
|
15530
|
-
);
|
|
15531
|
-
}
|
|
15532
|
-
/**
|
|
15533
|
-
* Build a transaction to claim accumulated integrator fees from a vault.
|
|
15534
|
-
*
|
|
15535
|
-
* This endpoint creates a transaction that allows an integrator to claim the fees
|
|
15536
|
-
* they have earned from orders placed on behalf of users. Fees accumulate in the
|
|
15537
|
-
* integrator's global vault (across all markets) and can be claimed at any moment.
|
|
15538
|
-
* The fees are proportional to the taker volume generated by the users' orders that
|
|
15539
|
-
* the integrator submitted.
|
|
15540
|
-
*
|
|
15541
|
-
* If a `recipientAddress` is provided, the claimed fees will be automatically
|
|
15542
|
-
* transferred to that address. Otherwise, the coin outputs are exposed as transaction
|
|
15543
|
-
* arguments for further use in the transaction (one per non-zero collateral balance).
|
|
15544
|
-
*
|
|
15545
|
-
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
15546
|
-
*
|
|
15547
|
-
* @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
|
|
15548
|
-
* @returns `ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse` containing
|
|
15549
|
-
* `txKind` and optionally `coinOutArgs`.
|
|
15550
|
-
*
|
|
15551
|
-
* @example
|
|
15552
|
-
* ```ts
|
|
15553
|
-
* // Claim with automatic transfer to recipient
|
|
15554
|
-
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
15555
|
-
* integratorId: 7,
|
|
15556
|
-
* recipientAddress: "0x...",
|
|
15557
|
-
* });
|
|
15558
|
-
*
|
|
15559
|
-
* // Claim with coin outputs for further use
|
|
15560
|
-
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
15561
|
-
* integratorId: 7,
|
|
15562
|
-
* });
|
|
15563
|
-
* // response.coinOutArgs can be used in subsequent transaction commands
|
|
15564
|
-
* ```
|
|
15565
|
-
*/
|
|
15566
|
-
async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
|
|
15567
|
-
const { tx, ...otherInputs } = inputs;
|
|
15568
|
-
return this.fetchApiTxObject(
|
|
15569
|
-
"builder-codes/transactions/claim-integrator-vault-fees",
|
|
15570
|
-
{
|
|
15571
|
-
...otherInputs,
|
|
15572
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
|
|
15573
|
-
},
|
|
15574
|
-
void 0,
|
|
15575
|
-
{
|
|
15576
|
-
txKind: true
|
|
15577
|
-
}
|
|
15578
|
-
);
|
|
15579
|
-
}
|
|
15580
15519
|
// =========================================================================
|
|
15581
15520
|
// Builder Codes Inspections
|
|
15582
15521
|
// =========================================================================
|
|
@@ -15611,41 +15550,6 @@ var init_perpetuals = __esm({
|
|
|
15611
15550
|
async getBuilderCodeIntegratorConfig(inputs) {
|
|
15612
15551
|
return this.fetchApi("builder-codes/integrator-config", inputs);
|
|
15613
15552
|
}
|
|
15614
|
-
/**
|
|
15615
|
-
* Fetch accumulated integrator vault fees.
|
|
15616
|
-
*
|
|
15617
|
-
* This endpoint queries the total fees an integrator has earned and accumulated in
|
|
15618
|
-
* their global vault, grouped by collateral coin type. Integrators earn fees
|
|
15619
|
-
* proportional to the taker volume generated by orders they submit on behalf of
|
|
15620
|
-
* users. These fees can be claimed at any time using
|
|
15621
|
-
* {@link getClaimBuilderCodeIntegratorVaultFeesTx}.
|
|
15622
|
-
*
|
|
15623
|
-
* This information is useful for:
|
|
15624
|
-
* - Displaying total claimable fees to integrators in dashboards
|
|
15625
|
-
* - Monitoring fee accrual across collateral types
|
|
15626
|
-
* - Determining whether fees are ready to be claimed
|
|
15627
|
-
*
|
|
15628
|
-
* @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
|
|
15629
|
-
* @returns `ApiPerpetualsBuilderCodesIntegratorVaultsResponse` containing
|
|
15630
|
-
* a vector of per-collateral vault data with accumulated fees.
|
|
15631
|
-
*
|
|
15632
|
-
* @example
|
|
15633
|
-
* ```ts
|
|
15634
|
-
* const vaultFees = await perps.getBuilderCodeIntegratorVaults({
|
|
15635
|
-
* integratorId: 7,
|
|
15636
|
-
* });
|
|
15637
|
-
*
|
|
15638
|
-
* for (const vault of vaultFees.integratorVaults) {
|
|
15639
|
-
* console.log(`${vault.collateralCoinType}: ${vault.fees} collateral units claimable`);
|
|
15640
|
-
* }
|
|
15641
|
-
*
|
|
15642
|
-
* const totalFeesUsd = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.feesUsd, 0);
|
|
15643
|
-
* console.log(`Total claimable (USD): ${totalFeesUsd}`);
|
|
15644
|
-
* ```
|
|
15645
|
-
*/
|
|
15646
|
-
async getBuilderCodeIntegratorVaults(inputs) {
|
|
15647
|
-
return this.fetchApi("builder-codes/integrator-vaults", inputs);
|
|
15648
|
-
}
|
|
15649
15553
|
// =========================================================================
|
|
15650
15554
|
// Public Static Helpers
|
|
15651
15555
|
// =========================================================================
|
|
@@ -15892,14 +15796,14 @@ var init_perpetuals = __esm({
|
|
|
15892
15796
|
};
|
|
15893
15797
|
}
|
|
15894
15798
|
/**
|
|
15895
|
-
* Open a market-candles
|
|
15896
|
-
* `/perpetuals/ws/
|
|
15799
|
+
* Open a market-candles subscription for a single market/interval on
|
|
15800
|
+
* `/perpetuals/ws/updates`.
|
|
15897
15801
|
*
|
|
15898
15802
|
* The stream emits {@link PerpetualsWsCandleResponseMessage} messages,
|
|
15899
15803
|
* typically containing the latest candle for the specified interval.
|
|
15900
15804
|
*
|
|
15901
15805
|
* @param args.marketId - Market ID to subscribe to.
|
|
15902
|
-
*
|
|
15806
|
+
* @param args.interval - Timeframe label such as `"1m"` or `"1h"`.
|
|
15903
15807
|
* @param args.onMessage - Handler for incoming candle updates.
|
|
15904
15808
|
* @param args.onOpen - Optional hook called when the websocket opens.
|
|
15905
15809
|
* @param args.onError - Optional hook called on websocket error.
|
|
@@ -15911,7 +15815,7 @@ var init_perpetuals = __esm({
|
|
|
15911
15815
|
* ```ts
|
|
15912
15816
|
* const stream = perps.openMarketCandlesWebsocketStream({
|
|
15913
15817
|
* marketId: "0x...",
|
|
15914
|
-
*
|
|
15818
|
+
* interval: "1m",
|
|
15915
15819
|
* onMessage: ({ lastCandle }) => console.log(lastCandle),
|
|
15916
15820
|
* });
|
|
15917
15821
|
* ```
|
|
@@ -17840,7 +17744,6 @@ var init_packages = __esm({
|
|
|
17840
17744
|
"src/packages/index.ts"() {
|
|
17841
17745
|
"use strict";
|
|
17842
17746
|
init_auth2();
|
|
17843
|
-
init_auth2();
|
|
17844
17747
|
init_coin2();
|
|
17845
17748
|
init_farms2();
|
|
17846
17749
|
init_faucet2();
|