aftermath-ts-sdk 5.1.1 → 6.0.0-dev.abf3dae
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 +296 -240
- package/dist/index.js +68 -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);
|
|
@@ -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
|
// =========================================================================
|
|
@@ -15134,6 +15154,34 @@ var init_perpetuals = __esm({
|
|
|
15134
15154
|
getMarkets24hrStats(inputs) {
|
|
15135
15155
|
return this.fetchApi("markets/24hr-stats", inputs);
|
|
15136
15156
|
}
|
|
15157
|
+
/**
|
|
15158
|
+
* Fetch the category and tag labels that group markets in a picker UI.
|
|
15159
|
+
*
|
|
15160
|
+
* The response is the vocabulary behind `PerpetualsMarketMetadata.category`
|
|
15161
|
+
* and `PerpetualsMarketMetadata.tags`: every market names exactly one of
|
|
15162
|
+
* these categories, and each of its tags is declared under that category.
|
|
15163
|
+
* Both lists come back in display order.
|
|
15164
|
+
*
|
|
15165
|
+
* The labels are configuration rather than a fixed enum, so resolve a
|
|
15166
|
+
* market's metadata against this response instead of hard-coding them.
|
|
15167
|
+
*
|
|
15168
|
+
* @param abortSignal - Optional cancellation signal.
|
|
15169
|
+
* @returns `ApiPerpetualsMarketsCategoriesResponse` containing `categories`.
|
|
15170
|
+
*
|
|
15171
|
+
* @remarks
|
|
15172
|
+
* `categories` is empty when the backing static configuration is unavailable.
|
|
15173
|
+
* Treat that as "no grouping" and show every market rather than rendering an
|
|
15174
|
+
* empty picker.
|
|
15175
|
+
*
|
|
15176
|
+
* @example
|
|
15177
|
+
* ```ts
|
|
15178
|
+
* const { categories } = await perps.getMarketsCategories();
|
|
15179
|
+
* // [{ name: "Crypto", tags: ["Layer 1", "DeFi", ...] }, ...]
|
|
15180
|
+
* ```
|
|
15181
|
+
*/
|
|
15182
|
+
getMarketsCategories(abortSignal) {
|
|
15183
|
+
return this.fetchApi("markets/categories", {}, abortSignal);
|
|
15184
|
+
}
|
|
15137
15185
|
// =========================================================================
|
|
15138
15186
|
// Prices
|
|
15139
15187
|
// =========================================================================
|
|
@@ -15468,7 +15516,7 @@ var init_perpetuals = __esm({
|
|
|
15468
15516
|
* collect fees on orders placed on behalf of the user. Once revoked, the integrator
|
|
15469
15517
|
* will no longer be able to submit orders with integrator fees for this account.
|
|
15470
15518
|
* The user can re-approve the integrator at any time by calling
|
|
15471
|
-
* `
|
|
15519
|
+
* `getCreateBuilderCodeIntegratorConfigTx` again.
|
|
15472
15520
|
*
|
|
15473
15521
|
* The resulting transaction must be signed by the account owner and executed on-chain.
|
|
15474
15522
|
*
|
|
@@ -15497,86 +15545,6 @@ var init_perpetuals = __esm({
|
|
|
15497
15545
|
}
|
|
15498
15546
|
);
|
|
15499
15547
|
}
|
|
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
15548
|
// =========================================================================
|
|
15581
15549
|
// Builder Codes Inspections
|
|
15582
15550
|
// =========================================================================
|
|
@@ -15611,41 +15579,6 @@ var init_perpetuals = __esm({
|
|
|
15611
15579
|
async getBuilderCodeIntegratorConfig(inputs) {
|
|
15612
15580
|
return this.fetchApi("builder-codes/integrator-config", inputs);
|
|
15613
15581
|
}
|
|
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
15582
|
// =========================================================================
|
|
15650
15583
|
// Public Static Helpers
|
|
15651
15584
|
// =========================================================================
|
|
@@ -15892,14 +15825,14 @@ var init_perpetuals = __esm({
|
|
|
15892
15825
|
};
|
|
15893
15826
|
}
|
|
15894
15827
|
/**
|
|
15895
|
-
* Open a market-candles
|
|
15896
|
-
* `/perpetuals/ws/
|
|
15828
|
+
* Open a market-candles subscription for a single market/interval on
|
|
15829
|
+
* `/perpetuals/ws/updates`.
|
|
15897
15830
|
*
|
|
15898
15831
|
* The stream emits {@link PerpetualsWsCandleResponseMessage} messages,
|
|
15899
15832
|
* typically containing the latest candle for the specified interval.
|
|
15900
15833
|
*
|
|
15901
15834
|
* @param args.marketId - Market ID to subscribe to.
|
|
15902
|
-
*
|
|
15835
|
+
* @param args.interval - Timeframe label such as `"1m"` or `"1h"`.
|
|
15903
15836
|
* @param args.onMessage - Handler for incoming candle updates.
|
|
15904
15837
|
* @param args.onOpen - Optional hook called when the websocket opens.
|
|
15905
15838
|
* @param args.onError - Optional hook called on websocket error.
|
|
@@ -15911,7 +15844,7 @@ var init_perpetuals = __esm({
|
|
|
15911
15844
|
* ```ts
|
|
15912
15845
|
* const stream = perps.openMarketCandlesWebsocketStream({
|
|
15913
15846
|
* marketId: "0x...",
|
|
15914
|
-
*
|
|
15847
|
+
* interval: "1m",
|
|
15915
15848
|
* onMessage: ({ lastCandle }) => console.log(lastCandle),
|
|
15916
15849
|
* });
|
|
15917
15850
|
* ```
|
|
@@ -17840,7 +17773,6 @@ var init_packages = __esm({
|
|
|
17840
17773
|
"src/packages/index.ts"() {
|
|
17841
17774
|
"use strict";
|
|
17842
17775
|
init_auth2();
|
|
17843
|
-
init_auth2();
|
|
17844
17776
|
init_coin2();
|
|
17845
17777
|
init_farms2();
|
|
17846
17778
|
init_faucet2();
|