aftermath-ts-sdk 3.3.3-dev.ff8f0b0 → 4.0.0-dev.0d478c0
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 +223 -199
- package/dist/index.js +120 -58
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -15381,58 +15381,6 @@ var init_perpetuals = __esm({
|
|
|
15381
15381
|
// =========================================================================
|
|
15382
15382
|
// Rebates
|
|
15383
15383
|
// =========================================================================
|
|
15384
|
-
/**
|
|
15385
|
-
* Calculate rewards and rebates for one or more perpetuals accounts.
|
|
15386
|
-
*
|
|
15387
|
-
* Computes per-account maker and taker reward allocations, fee-tier rebates,
|
|
15388
|
-
* and volume-based metrics. When `accountIds` is omitted or empty, all eligible
|
|
15389
|
-
* accounts are included.
|
|
15390
|
-
*
|
|
15391
|
-
* **Note:** All data returned is for the current epoch only.
|
|
15392
|
-
*
|
|
15393
|
-
* @param inputs.totalMakerRewards - Total maker reward pool to distribute.
|
|
15394
|
-
* @param inputs.totalTakerRewards - Total taker reward pool to distribute.
|
|
15395
|
-
* @param inputs.accountIds - Optional list of account IDs.
|
|
15396
|
-
* @returns `ApiPerpetualsCurrentRebateRewardsResponse` with per-account reward and rebate data.
|
|
15397
|
-
*
|
|
15398
|
-
* @example
|
|
15399
|
-
* ```ts
|
|
15400
|
-
* const { totalQScoreFinal, rewards } = await perps.getCurrentRebateRewards({
|
|
15401
|
-
* totalMakerRewards: 10000,
|
|
15402
|
-
* totalTakerRewards: 5000,
|
|
15403
|
-
* });
|
|
15404
|
-
* ```
|
|
15405
|
-
*/
|
|
15406
|
-
async getCurrentRebateRewards(inputs) {
|
|
15407
|
-
return this.fetchApi("rebates/rewards", inputs);
|
|
15408
|
-
}
|
|
15409
|
-
/**
|
|
15410
|
-
* Generate a CSV-formatted rebate report for perpetuals market makers.
|
|
15411
|
-
*
|
|
15412
|
-
* Computes per-account reward allocations and fee-tier rebate adjustments,
|
|
15413
|
-
* returning the result as a CSV string. When `aggregated` is true, the CSV
|
|
15414
|
-
* groups rewards by owner address instead of per-account.
|
|
15415
|
-
*
|
|
15416
|
-
* **Note:** All data returned is for the current epoch only.
|
|
15417
|
-
*
|
|
15418
|
-
* @param inputs - {@link ApiPerpetualsCreateCsvRebatesBody}.
|
|
15419
|
-
* @returns `ApiPerpetualsCreateCsvRebatesResponse` containing the CSV string.
|
|
15420
|
-
*/
|
|
15421
|
-
async getCsvRebates(inputs) {
|
|
15422
|
-
return this.fetchApi("rebates/create-csv-rebates", inputs);
|
|
15423
|
-
}
|
|
15424
|
-
/**
|
|
15425
|
-
* Generate a CSV-formatted referral rebate report.
|
|
15426
|
-
*
|
|
15427
|
-
* Calculates referrer commissions and referee discounts based on trading
|
|
15428
|
-
* fees within the specified epoch, returning the result as a CSV string.
|
|
15429
|
-
*
|
|
15430
|
-
* @param inputs - {@link ApiPerpetualsCreateReferralCsvRebatesBody}.
|
|
15431
|
-
* @returns `ApiPerpetualsCreateReferralCsvRebatesResponse` containing the CSV string.
|
|
15432
|
-
*/
|
|
15433
|
-
async getReferralCsvRebates(inputs) {
|
|
15434
|
-
return this.fetchApi("rebates/create-referral-csv-rebates", inputs);
|
|
15435
|
-
}
|
|
15436
15384
|
// =========================================================================
|
|
15437
15385
|
// Builder Codes Transactions
|
|
15438
15386
|
// =========================================================================
|
|
@@ -16112,8 +16060,9 @@ var init_router = __esm({
|
|
|
16112
16060
|
* const router = afSdk.Router();
|
|
16113
16061
|
* ```
|
|
16114
16062
|
*/
|
|
16115
|
-
constructor(config) {
|
|
16063
|
+
constructor(config, api) {
|
|
16116
16064
|
super(config, "router");
|
|
16065
|
+
this.api = api;
|
|
16117
16066
|
// =========================================================================
|
|
16118
16067
|
// Public Methods
|
|
16119
16068
|
// =========================================================================
|
|
@@ -16260,10 +16209,9 @@ var init_router = __esm({
|
|
|
16260
16209
|
* ```
|
|
16261
16210
|
*/
|
|
16262
16211
|
async getTransactionForCompleteTradeRoute(inputs) {
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
);
|
|
16212
|
+
const { tx } = await this.fetchApiTxObject("v1/transactions/trade", inputs, void 0, { txKind: true });
|
|
16213
|
+
tx.setSenderIfNotSet(inputs.walletAddress);
|
|
16214
|
+
return tx;
|
|
16267
16215
|
}
|
|
16268
16216
|
/**
|
|
16269
16217
|
* Appends a complete route to an existing transaction.
|
|
@@ -16299,6 +16247,58 @@ var init_router = __esm({
|
|
|
16299
16247
|
* ```
|
|
16300
16248
|
*/
|
|
16301
16249
|
async addTransactionForCompleteTradeRoute(inputs) {
|
|
16250
|
+
const { tx, ...otherInputs } = inputs;
|
|
16251
|
+
const txKind = await this.api?.Transactions().fetchBase64TxKindFromTx({ tx });
|
|
16252
|
+
if (txKind === void 0) {
|
|
16253
|
+
throw new Error(
|
|
16254
|
+
"`Router` requires an `AftermathApi` provider to serialize the supplied transaction. Construct it via `Aftermath.create()`."
|
|
16255
|
+
);
|
|
16256
|
+
}
|
|
16257
|
+
const { tx: newTx, coinOutId } = await this.fetchApiTxObject(
|
|
16258
|
+
"v1/transactions/add-trade",
|
|
16259
|
+
{ ...otherInputs, txKind },
|
|
16260
|
+
void 0,
|
|
16261
|
+
{ txKind: true }
|
|
16262
|
+
);
|
|
16263
|
+
newTx.setSenderIfNotSet(inputs.walletAddress);
|
|
16264
|
+
return { tx: newTx, coinOutId };
|
|
16265
|
+
}
|
|
16266
|
+
/**
|
|
16267
|
+
* Builds a trade transaction using the unversioned endpoint.
|
|
16268
|
+
*
|
|
16269
|
+
* Returns a gas-resolved transaction, as this method did before the v1
|
|
16270
|
+
* endpoints. Kept for callers that depend on that shape.
|
|
16271
|
+
*
|
|
16272
|
+
* @deprecated Use {@link Router.getTransactionForCompleteTradeRoute}. The
|
|
16273
|
+
* unversioned endpoint fails for wallets whose input coin is sourced from an
|
|
16274
|
+
* address balance: the API cannot serialize the resulting `FundsWithdrawal`
|
|
16275
|
+
* input to its legacy JSON format.
|
|
16276
|
+
*
|
|
16277
|
+
* @param inputs - Wallet address, complete route, slippage, and optional sponsorship settings.
|
|
16278
|
+
* @returns The unsigned transaction, with gas resolved by the API.
|
|
16279
|
+
*/
|
|
16280
|
+
async getTransactionForCompleteTradeRouteDeprecated(inputs) {
|
|
16281
|
+
return this.fetchApiTransaction(
|
|
16282
|
+
"transactions/trade",
|
|
16283
|
+
inputs
|
|
16284
|
+
);
|
|
16285
|
+
}
|
|
16286
|
+
/**
|
|
16287
|
+
* Appends a complete route to an existing transaction using the unversioned
|
|
16288
|
+
* endpoint.
|
|
16289
|
+
*
|
|
16290
|
+
* Sends the transaction as v1 JSON and needs no `AftermathApi`, as this
|
|
16291
|
+
* method did before the v1 endpoints.
|
|
16292
|
+
*
|
|
16293
|
+
* @deprecated Use {@link Router.addTransactionForCompleteTradeRoute}. The
|
|
16294
|
+
* unversioned endpoint fails for wallets whose input coin is sourced from an
|
|
16295
|
+
* address balance, and `Transaction.serialize()` throws on any transaction
|
|
16296
|
+
* already carrying a `FundsWithdrawal` input.
|
|
16297
|
+
*
|
|
16298
|
+
* @param inputs - Existing transaction, sender, complete route, slippage, and optional input coin argument.
|
|
16299
|
+
* @returns A new transaction and the optional output coin argument.
|
|
16300
|
+
*/
|
|
16301
|
+
async addTransactionForCompleteTradeRouteDeprecated(inputs) {
|
|
16302
16302
|
const { tx, ...otherInputs } = inputs;
|
|
16303
16303
|
const { tx: newTx, coinOutId } = await this.fetchApi("transactions/add-trade", {
|
|
16304
16304
|
...otherInputs,
|
|
@@ -17917,6 +17917,24 @@ var init_dca = __esm({
|
|
|
17917
17917
|
* ```
|
|
17918
17918
|
*/
|
|
17919
17919
|
async getCreateDcaOrderTx(inputs) {
|
|
17920
|
+
const { tx } = await this.fetchApiTxObject("v1/transactions/create-order", inputs, void 0, { txKind: true });
|
|
17921
|
+
tx.setSenderIfNotSet(inputs.walletAddress);
|
|
17922
|
+
return tx;
|
|
17923
|
+
}
|
|
17924
|
+
/**
|
|
17925
|
+
* Builds a transaction creating a new DCA order using the unversioned endpoint.
|
|
17926
|
+
*
|
|
17927
|
+
* Returns a gas-resolved transaction, as this method did before the v1
|
|
17928
|
+
* endpoints. Kept for callers that depend on that shape.
|
|
17929
|
+
*
|
|
17930
|
+
* @deprecated Use {@link getCreateDcaOrderTx}. The unversioned endpoint fails for wallets
|
|
17931
|
+
* whose allocate coin is sourced from an address balance: the API cannot
|
|
17932
|
+
* serialize the resulting `FundsWithdrawal` input to its legacy JSON format.
|
|
17933
|
+
*
|
|
17934
|
+
* @param inputs - Order parameters, identical to the versioned endpoint.
|
|
17935
|
+
* @returns The unsigned transaction, with gas resolved by the API.
|
|
17936
|
+
*/
|
|
17937
|
+
async getCreateDcaOrderTxDeprecated(inputs) {
|
|
17920
17938
|
return this.fetchApiTransaction(
|
|
17921
17939
|
"transactions/create-order",
|
|
17922
17940
|
inputs
|
|
@@ -18127,6 +18145,24 @@ var init_limitOrders = __esm({
|
|
|
18127
18145
|
* ```
|
|
18128
18146
|
*/
|
|
18129
18147
|
async getCreateLimitOrderTx(inputs) {
|
|
18148
|
+
const { tx } = await this.fetchApiTxObject("v1/transactions/create-order", inputs, void 0, { txKind: true });
|
|
18149
|
+
tx.setSenderIfNotSet(inputs.walletAddress);
|
|
18150
|
+
return tx;
|
|
18151
|
+
}
|
|
18152
|
+
/**
|
|
18153
|
+
* Builds a transaction creating a new limit order using the unversioned endpoint.
|
|
18154
|
+
*
|
|
18155
|
+
* Returns a gas-resolved transaction, as this method did before the v1
|
|
18156
|
+
* endpoints. Kept for callers that depend on that shape.
|
|
18157
|
+
*
|
|
18158
|
+
* @deprecated Use {@link getCreateLimitOrderTx}. The unversioned endpoint fails for wallets
|
|
18159
|
+
* whose allocate coin is sourced from an address balance: the API cannot
|
|
18160
|
+
* serialize the resulting `FundsWithdrawal` input to its legacy JSON format.
|
|
18161
|
+
*
|
|
18162
|
+
* @param inputs - Order parameters, identical to the versioned endpoint.
|
|
18163
|
+
* @returns The unsigned transaction, with gas resolved by the API.
|
|
18164
|
+
*/
|
|
18165
|
+
async getCreateLimitOrderTxDeprecated(inputs) {
|
|
18130
18166
|
return this.fetchApiTransaction(
|
|
18131
18167
|
"transactions/create-order",
|
|
18132
18168
|
inputs
|
|
@@ -18501,6 +18537,32 @@ var init_rewards = __esm({
|
|
|
18501
18537
|
* @returns The total points across all reward epochs and domains.
|
|
18502
18538
|
* @throws `AftermathTransportError` when the API request or response fails.
|
|
18503
18539
|
*/
|
|
18540
|
+
/**
|
|
18541
|
+
* Computes the distribution of the maker and taker reward pools across
|
|
18542
|
+
* perpetuals accounts.
|
|
18543
|
+
*
|
|
18544
|
+
* Returns per-account maker and taker reward allocations, fee-tier rebates
|
|
18545
|
+
* and volume metrics. When `accountIds` is omitted or empty the API includes
|
|
18546
|
+
* every eligible account, so pass an explicit list to scope the result.
|
|
18547
|
+
*
|
|
18548
|
+
* **Note:** All data returned is for the current epoch only.
|
|
18549
|
+
*
|
|
18550
|
+
* @param inputs - {@link ApiRewardsDistributionBody}.
|
|
18551
|
+
* @returns Per-account reward and rebate breakdown for the current epoch.
|
|
18552
|
+
* @throws `AftermathTransportError` when the API request or response fails.
|
|
18553
|
+
*
|
|
18554
|
+
* @example
|
|
18555
|
+
* ```ts
|
|
18556
|
+
* const { totalQScoreFinal, rewards } = await rewards.getDistribution({
|
|
18557
|
+
* totalMakerRewards: 10000,
|
|
18558
|
+
* totalTakerRewards: 5000,
|
|
18559
|
+
* calculationVariables: { ... },
|
|
18560
|
+
* });
|
|
18561
|
+
* ```
|
|
18562
|
+
*/
|
|
18563
|
+
async getDistribution(inputs) {
|
|
18564
|
+
return this.fetchApi("distribution", inputs);
|
|
18565
|
+
}
|
|
18504
18566
|
async getPoints(inputs) {
|
|
18505
18567
|
return this.fetchApi(
|
|
18506
18568
|
"points",
|
|
@@ -28039,7 +28101,7 @@ var init_aftermath = __esm({
|
|
|
28039
28101
|
* Creates the smart order router provider.
|
|
28040
28102
|
* @returns A new `Router` provider configured with this instance's caller settings.
|
|
28041
28103
|
*/
|
|
28042
|
-
this.Router = () => new Router(this.config);
|
|
28104
|
+
this.Router = () => new Router(this.config, this.api);
|
|
28043
28105
|
/**
|
|
28044
28106
|
* Creates the NFT AMM provider.
|
|
28045
28107
|
* @returns A new `NftAmm` provider configured with this instance's network and addresses.
|