@pegaroute/sdk 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -20,7 +20,7 @@ frontend read it.
20
20
  ## Quote and swap (backend)
21
21
 
22
22
  ```ts
23
- import { type CreateSwapParams, Pegaroute } from "@pegaroute/sdk";
23
+ import { type CreateSwapParams, hasQuoteRouteFees, Pegaroute } from "@pegaroute/sdk";
24
24
 
25
25
  const pr = new Pegaroute({ apiKey: process.env.PEGAROUTE_API_KEY!, baseUrl: process.env.PEGAROUTE_BASE_URL! });
26
26
 
@@ -39,12 +39,22 @@ const quote = await pr.quotes.get(params);
39
39
  const best = quote.routes[0];
40
40
 
41
41
  if (best) {
42
+ // Show the user what the route costs. `{}` means no fee data, not a zero fee.
43
+ if (hasQuoteRouteFees(best.fees)) showCost(`$${best.fees.totalUsd} (${best.fees.totalBps} bps)`);
44
+
45
+ // Some routes add a fee in the source chain's native coin, which the wallet pays on top of `amount`.
46
+ if (best.additionalFee) showExtraFee(`${best.additionalFee.amount} ${best.additionalFee.token}`);
47
+
42
48
  const swap = await pr.swaps.create({ ...params, quoteId: quote.quoteId, routeProvider: best.provider });
43
49
 
44
50
  // Send `swap.transactionId` and `swap.execution` to the frontend for signing.
45
51
  }
46
52
  ```
47
53
 
54
+ `fees.totalUsd` is never negative. If the output is worth more than the input at reference prices, every fee is `0`,
55
+ so two routes showing `0` can still pay out different amounts: compare routes by `expectedOutput`. Only
56
+ `fees.breakdown.route` can be negative, when the provider's rate beats the reference price.
57
+
48
58
  ## Sign (frontend, EVM with viem)
49
59
 
50
60
  `swap.execution` says what the user's wallet must sign. For an EVM router call (e.g. THORChain):
@@ -171,28 +171,83 @@ interface TokenAmount {
171
171
  baseUnits: string;
172
172
  }
173
173
  /**
174
- * Fees for a route, as human-readable decimal strings.
174
+ * A fee, in two forms: USD, and basis points of the swap's input USD value (100 bps = 1%).
175
175
  *
176
- * Amounts are in destination-asset units (THORChain/Maya), or in USD when `unit` is `"USD"` (Instaswap/Squid).
177
- * Read `total` for the full fee the user pays.
176
+ * @example
177
+ * { usd: "2.5", bps: 10 } // $2.50 on a $2,500 swap
178
+ */
179
+ interface FeeAmount {
180
+ /** Amount in USD, as a decimal string, e.g. `"2.7178"`. */
181
+ usd: string;
182
+ /** The same amount in basis points of the input USD value. */
183
+ bps: number;
184
+ }
185
+ /**
186
+ * What a route costs the user, in USD and in basis points of the input USD value.
187
+ *
188
+ * Pegaroute prices the input and output tokens once per quote request, so all routes of a quote use the same
189
+ * reference prices and compare directly. Source-chain gas that the wallet pays and the route's `additionalFee` are not
190
+ * included.
191
+ *
192
+ * Never negative. If `expectedOutput` is worth more than the input (the user gains on the swap), `totalUsd`, `totalBps`
193
+ * and every part of `breakdown` are `0` instead of negative. A `0` fee therefore doesn't say how much the user gains:
194
+ * if two routes both show `0`, one can still pay out more. Compare them by `expectedOutput`, not by fee.
195
+ */
196
+ interface QuoteRouteFees {
197
+ /** `totalUsd` in basis points of the input USD value. Never negative. */
198
+ totalBps: number;
199
+ /** Cost of the swap in USD: input USD − `expectedOutput` USD. Never negative. */
200
+ totalUsd: string;
201
+ /** The total split in three parts: `affiliate` + `route` + `gas` = total, in USD and in bps. */
202
+ breakdown: {
203
+ /** The fee that Pegaroute and the integrator receive. */
204
+ affiliate: FeeAmount;
205
+ /**
206
+ * All other costs: provider fees, price impact, spread, and the difference between the provider's price and the
207
+ * reference price.
208
+ *
209
+ * Can be negative. That happens when the provider offers a better rate than the reference price: the extra the
210
+ * user gets cancels out part of the affiliate and gas fees, so the total ends up below `affiliate` + `gas`. The
211
+ * three parts still add up to the total.
212
+ *
213
+ * @example
214
+ * // $1,000 in, $999.50 out: total $0.50, affiliate $1, gas $0 → route $0.50 − $1 − $0.
215
+ * // The provider's rate is $0.50 better than the reference price.
216
+ * { usd: "-0.5", bps: -5 }
217
+ */
218
+ route: FeeAmount;
219
+ /**
220
+ * Gas the provider takes from the output (`expectedOutput` is already after it). On Instaswap private routes it
221
+ * also includes the zkproof protocol fee.
222
+ */
223
+ gas: FeeAmount;
224
+ };
225
+ }
226
+ /**
227
+ * A route's `fees` when Pegaroute has no fee data for it, sent as `{}`: there is no reference price for the input or
228
+ * output token, or the provider's quote doesn't show the fee it applies. This is not a zero fee: don't show it as one.
229
+ */
230
+ type NoQuoteRouteFees = { [K in keyof QuoteRouteFees]?: never; };
231
+ /**
232
+ * Whether Pegaroute sent fee data for a route. `false` means `{}`: no fee data, not a zero fee.
233
+ *
234
+ * @example
235
+ * if (hasQuoteRouteFees(route.fees)) {
236
+ * show(`$${route.fees.totalUsd} (${route.fees.totalBps} bps)`);
237
+ * }
178
238
  */
179
- interface QuoteFees {
180
- /** Pegaroute's affiliate fee. For Instaswap and Squid this excludes the integrator's share (see `subAffiliate`). */
181
- affiliate: string;
182
- /** Liquidity and other route fees. On Squid this includes Squid's own platform share. */
183
- liquidity: string;
184
- /** Outbound gas fee on the destination chain (`"0"` when not applicable). */
185
- outbound: string;
186
- /** Sum of `affiliate`, `liquidity`, `outbound` and `subAffiliate` (when present). */
187
- total: string;
188
- /** Present when all fee amounts are in USD instead of asset units. */
189
- unit?: "USD";
190
- /** The integrator's USD share, excluded from `affiliate` (Instaswap/Squid only). */
191
- subAffiliate?: string;
192
- /** Total provider-facing fee in basis points, when the provider reports it. */
193
- totalBps?: number;
194
- /** Slippage in basis points, when the provider reports it. */
195
- slippageBps?: number;
239
+ declare function hasQuoteRouteFees(fees: QuoteRouteFees | NoQuoteRouteFees): fees is QuoteRouteFees;
240
+ /**
241
+ * A fee the wallet pays in the source chain's native coin, on top of the quoted amount and the source network gas.
242
+ *
243
+ * @example
244
+ * { token: "ETH", amount: "0.0004" } // a 0.1 ETH swap needs to send 0.1004 ETH
245
+ */
246
+ interface AdditionalFee {
247
+ /** Token ID of the source chain's native coin, as in `tokens.list(fromChain)`, e.g. `"ETH"`. */
248
+ token: string;
249
+ /** Fee amount, as a human-readable decimal, e.g. `"0.0004"`. */
250
+ amount: string;
196
251
  }
197
252
  /** How the affiliate fee on a swap was split between Pegaroute and the integrator, in basis points. */
198
253
  interface AffiliateFeeBreakdown {
@@ -239,8 +294,6 @@ interface RouteInfo {
239
294
  private?: PrivateSwapMode;
240
295
  /** Expected output amount in the destination token, as a human-readable decimal. */
241
296
  expectedOutput: string;
242
- /** Fees for this route. */
243
- fees: QuoteFees;
244
297
  /** Estimated time to complete, in seconds. */
245
298
  estimatedTimeSeconds: number;
246
299
  /** OpenOcean aggregator behind the route (Solana/Sui only). */
@@ -345,12 +398,31 @@ interface QuoteRoute {
345
398
  private?: PrivateSwapMode;
346
399
  /** The provider's integration type. */
347
400
  providerType: ProviderType;
348
- /** Expected output in the destination token, as a human-readable decimal, after fees. */
401
+ /**
402
+ * Expected output in the destination token, as a human-readable decimal: after all fees, including
403
+ * `fees.breakdown.gas`. `additionalFee` is not taken from it, since the wallet pays that fee on top.
404
+ */
349
405
  expectedOutput: string;
350
406
  /** Estimated time to complete, in seconds. */
351
407
  estimatedTimeSeconds: number;
352
- /** Fees for this route. */
353
- fees: QuoteFees;
408
+ /**
409
+ * What this route costs, or `{}` when Pegaroute has no fee data for it (not a zero fee). Tell them apart with
410
+ * `hasQuoteRouteFees`.
411
+ *
412
+ * @example
413
+ * if (hasQuoteRouteFees(route.fees)) {
414
+ * show(`$${route.fees.totalUsd} (${route.fees.totalBps} bps)`);
415
+ * }
416
+ */
417
+ fees: QuoteRouteFees | NoQuoteRouteFees;
418
+ /**
419
+ * A fee the wallet pays in the source chain's native coin, on top of the quoted amount and the source network gas, or
420
+ * `null` when there is none. Show it to the user next to the route's cost.
421
+ *
422
+ * On Squid routes this is the Axelar gas receiver fee; on an EVM chain the transaction `value` from `swaps.create`
423
+ * already includes it. Neither `expectedOutput` nor `fees` include it, but the route order does.
424
+ */
425
+ additionalFee: AdditionalFee | null;
354
426
  /** The provider's own quote expiry (ISO 8601 or Unix seconds), if it has one. Use the quote's `expiresAt` instead. */
355
427
  expiry: string | null;
356
428
  /** Transaction memo (THORChain/Maya), if any. */
@@ -363,11 +435,6 @@ interface QuoteRoute {
363
435
  gasRate: string | null;
364
436
  /** Minimum swap amount in the source token, as a human-readable decimal, if the provider has one. */
365
437
  minAmount: string | null;
366
- /** The fee applied to this route after provider caps. */
367
- resolvedFee: {
368
- /** Effective fee in basis points. */
369
- feeBps: number;
370
- };
371
438
  /** OpenOcean aggregator behind the route (Solana/Sui only). */
372
439
  openOceanRoute?: OpenOceanRouteMeta;
373
440
  }
@@ -392,7 +459,11 @@ interface QuoteResponse {
392
459
  quoteId: string;
393
460
  /** When the quote expires (ISO 8601). After that, `swaps.create` throws `QuoteExpiredError`. */
394
461
  expiresAt: string;
395
- /** Available routes, best first: highest output, then fastest, then lowest slippage. */
462
+ /**
463
+ * Available routes, best first. Routes are ranked by `expectedOutput` minus `additionalFee`, then by speed. To
464
+ * subtract the fee, Pegaroute converts it to the output token at reference prices. If it has no reference price for
465
+ * either token, it ranks that route by `expectedOutput` alone.
466
+ */
396
467
  routes: QuoteRoute[];
397
468
  /** One entry per provider that was tried but didn't return a route. */
398
469
  warnings: RouteWarning[];
@@ -828,8 +899,6 @@ interface GetSwapResponse {
828
899
  input: SwapInput;
829
900
  /** The destination side of the swap. */
830
901
  output: SwapOutput;
831
- /** Fees for the swap. */
832
- fees: QuoteFees;
833
902
  /** How the affiliate fee was split, when recorded. */
834
903
  affiliateFeeBreakdown?: AffiliateFeeBreakdown;
835
904
  /** When the swap reached each stage. */
@@ -925,8 +994,6 @@ interface Transaction {
925
994
  destination: SwapOutput;
926
995
  /** The route the swap executes on. */
927
996
  route: RouteInfo;
928
- /** Fees for the swap. */
929
- fees: QuoteFees;
930
997
  /** How the affiliate fee was split, when recorded. */
931
998
  affiliateFeeBreakdown?: AffiliateFeeBreakdown;
932
999
  /** Why the swap failed, if it did. */
@@ -1015,8 +1082,6 @@ interface TransactionWebhookData {
1015
1082
  input: Pick<SwapInput, "chain" | "token" | "amount" | "address" | "refundAddress" | "txHash">;
1016
1083
  /** The destination side of the swap. */
1017
1084
  output: SwapOutput;
1018
- /** Fees for the swap. */
1019
- fees: QuoteFees;
1020
1085
  /** When the swap reached each stage. */
1021
1086
  timestamps: SwapTimestamps;
1022
1087
  /** Why the swap failed, or `null`. */
@@ -1067,4 +1132,4 @@ interface TestWebhookEvent {
1067
1132
  */
1068
1133
  type WebhookEvent = TransactionWebhookEvent | TestWebhookEvent;
1069
1134
  //#endregion
1070
- export { KnownErrorCode as $, toExternalStatus as A, JsonSwapExecution as B, SwapInput as C, Token as Ct, InternalSwapStatus as D, SwapTimestamps as E, EvmSwapExecution as F, UtxoSwapExecution as G, OtherDepositSwapExecution as H, ExecutionFamily as I, GetQuoteParams as J, isExecutionFamily as K, ExecutionMode as L, CosmosMsgDepositSwapExecution as M, CosmosMsgExecuteSwapExecution as N, SwapStatus as O, EvmApproval as P, ErrorCode as Q, ExecutionOfFamily as R, SwapFailure as S, ProvidersResponse as St, SwapProviderInfo as T, SerializedSwapExecution as U, NamedDepositSwapExecution as V, SwapExecution as W, QuoteRoute as X, QuoteResponse as Y, RouteWarning as Z, ProviderStatusInfo as _, ProviderFeeStructure as _t, WebhookEvent as a, QuoteFees as at, SwapEvent as b, ProviderTakeStructure as bt, ExpectedAffiliateEntry as c, StreamingProgress as ct, TransactionsResponse as d, ChainsResponse as dt, AffiliateFeeBreakdown as et, CreateSwapParams as f, HealthResponse as ft, InstaswapSwapLiteSnapshot as g, ProviderAffiliateFeeStructure as gt, InstaswapFeeLine as h, PingResponse as ht, TransactionWebhookEventType as i, Provider as it, CosmosBankSendSwapExecution as j, isTerminalStatus as k, ListTransactionsParams as l, TokenAmount as lt, GetSwapResponse as m, ListProvidersParams as mt, TransactionWebhookData as n, OpenOceanRouteMeta as nt, WebhookStreamingProgress as o, RefundInfo as ot, CreateSwapResponse as p, KnownProviderType as pt, isExecutionMode as q, TransactionWebhookEvent as r, PrivateSwapMode as rt, CursorPagination as s, RouteInfo as st, TestWebhookEvent as t, KnownProvider as tt, Transaction as u, Chain as ut, SubmitTxHashParams as v, ProviderHealth as vt, SwapOutput as w, TokensResponse as wt, SwapEventsResponse as x, ProviderType as xt, SubmitTxHashResponse as y, ProviderInfo as yt, ExecutionOfMode as z };
1135
+ export { KnownErrorCode as $, toExternalStatus as A, JsonSwapExecution as B, SwapInput as C, ProviderInfo as Ct, InternalSwapStatus as D, Token as Dt, SwapTimestamps as E, ProvidersResponse as Et, EvmSwapExecution as F, UtxoSwapExecution as G, OtherDepositSwapExecution as H, ExecutionFamily as I, GetQuoteParams as J, isExecutionFamily as K, ExecutionMode as L, CosmosMsgDepositSwapExecution as M, CosmosMsgExecuteSwapExecution as N, SwapStatus as O, TokensResponse as Ot, EvmApproval as P, ErrorCode as Q, ExecutionOfFamily as R, SwapFailure as S, ProviderHealth as St, SwapProviderInfo as T, ProviderType as Tt, SerializedSwapExecution as U, NamedDepositSwapExecution as V, SwapExecution as W, QuoteRoute as X, QuoteResponse as Y, RouteWarning as Z, ProviderStatusInfo as _, KnownProviderType as _t, WebhookEvent as a, OpenOceanRouteMeta as at, SwapEvent as b, ProviderAffiliateFeeStructure as bt, ExpectedAffiliateEntry as c, QuoteRouteFees as ct, TransactionsResponse as d, StreamingProgress as dt, AdditionalFee as et, CreateSwapParams as f, TokenAmount as ft, InstaswapSwapLiteSnapshot as g, HealthResponse as gt, InstaswapFeeLine as h, ChainsResponse as ht, TransactionWebhookEventType as i, NoQuoteRouteFees as it, CosmosBankSendSwapExecution as j, isTerminalStatus as k, ListTransactionsParams as l, RefundInfo as lt, GetSwapResponse as m, Chain as mt, TransactionWebhookData as n, FeeAmount as nt, WebhookStreamingProgress as o, PrivateSwapMode as ot, CreateSwapResponse as p, hasQuoteRouteFees as pt, isExecutionMode as q, TransactionWebhookEvent as r, KnownProvider as rt, CursorPagination as s, Provider as st, TestWebhookEvent as t, AffiliateFeeBreakdown as tt, Transaction as u, RouteInfo as ut, SubmitTxHashParams as v, ListProvidersParams as vt, SwapOutput as w, ProviderTakeStructure as wt, SwapEventsResponse as x, ProviderFeeStructure as xt, SubmitTxHashResponse as y, PingResponse as yt, ExecutionOfMode as z };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as KnownErrorCode, A as toExternalStatus, B as JsonSwapExecution, C as SwapInput, Ct as Token, D as InternalSwapStatus, E as SwapTimestamps, F as EvmSwapExecution, G as UtxoSwapExecution, H as OtherDepositSwapExecution, I as ExecutionFamily, J as GetQuoteParams, K as isExecutionFamily, L as ExecutionMode, M as CosmosMsgDepositSwapExecution, N as CosmosMsgExecuteSwapExecution, O as SwapStatus, P as EvmApproval, Q as ErrorCode, R as ExecutionOfFamily, S as SwapFailure, St as ProvidersResponse, T as SwapProviderInfo, U as SerializedSwapExecution, V as NamedDepositSwapExecution, W as SwapExecution, X as QuoteRoute, Y as QuoteResponse, Z as RouteWarning, _ as ProviderStatusInfo, _t as ProviderFeeStructure, a as WebhookEvent, at as QuoteFees, b as SwapEvent, bt as ProviderTakeStructure, c as ExpectedAffiliateEntry, ct as StreamingProgress, d as TransactionsResponse, dt as ChainsResponse, et as AffiliateFeeBreakdown, f as CreateSwapParams, ft as HealthResponse, g as InstaswapSwapLiteSnapshot, gt as ProviderAffiliateFeeStructure, h as InstaswapFeeLine, ht as PingResponse, i as TransactionWebhookEventType, it as Provider, j as CosmosBankSendSwapExecution, k as isTerminalStatus, l as ListTransactionsParams, lt as TokenAmount, m as GetSwapResponse, mt as ListProvidersParams, n as TransactionWebhookData, nt as OpenOceanRouteMeta, o as WebhookStreamingProgress, ot as RefundInfo, p as CreateSwapResponse, pt as KnownProviderType, q as isExecutionMode, r as TransactionWebhookEvent, rt as PrivateSwapMode, s as CursorPagination, st as RouteInfo, t as TestWebhookEvent, tt as KnownProvider, u as Transaction, ut as Chain, v as SubmitTxHashParams, vt as ProviderHealth, w as SwapOutput, wt as TokensResponse, x as SwapEventsResponse, xt as ProviderType, y as SubmitTxHashResponse, yt as ProviderInfo, z as ExecutionOfMode } from "./index-CeY_5Z4u.js";
1
+ import { $ as KnownErrorCode, A as toExternalStatus, B as JsonSwapExecution, C as SwapInput, Ct as ProviderInfo, D as InternalSwapStatus, Dt as Token, E as SwapTimestamps, Et as ProvidersResponse, F as EvmSwapExecution, G as UtxoSwapExecution, H as OtherDepositSwapExecution, I as ExecutionFamily, J as GetQuoteParams, K as isExecutionFamily, L as ExecutionMode, M as CosmosMsgDepositSwapExecution, N as CosmosMsgExecuteSwapExecution, O as SwapStatus, Ot as TokensResponse, P as EvmApproval, Q as ErrorCode, R as ExecutionOfFamily, S as SwapFailure, St as ProviderHealth, T as SwapProviderInfo, Tt as ProviderType, U as SerializedSwapExecution, V as NamedDepositSwapExecution, W as SwapExecution, X as QuoteRoute, Y as QuoteResponse, Z as RouteWarning, _ as ProviderStatusInfo, _t as KnownProviderType, a as WebhookEvent, at as OpenOceanRouteMeta, b as SwapEvent, bt as ProviderAffiliateFeeStructure, c as ExpectedAffiliateEntry, ct as QuoteRouteFees, d as TransactionsResponse, dt as StreamingProgress, et as AdditionalFee, f as CreateSwapParams, ft as TokenAmount, g as InstaswapSwapLiteSnapshot, gt as HealthResponse, h as InstaswapFeeLine, ht as ChainsResponse, i as TransactionWebhookEventType, it as NoQuoteRouteFees, j as CosmosBankSendSwapExecution, k as isTerminalStatus, l as ListTransactionsParams, lt as RefundInfo, m as GetSwapResponse, mt as Chain, n as TransactionWebhookData, nt as FeeAmount, o as WebhookStreamingProgress, ot as PrivateSwapMode, p as CreateSwapResponse, pt as hasQuoteRouteFees, q as isExecutionMode, r as TransactionWebhookEvent, rt as KnownProvider, s as CursorPagination, st as Provider, t as TestWebhookEvent, tt as AffiliateFeeBreakdown, u as Transaction, ut as RouteInfo, v as SubmitTxHashParams, vt as ListProvidersParams, w as SwapOutput, wt as ProviderTakeStructure, x as SwapEventsResponse, xt as ProviderFeeStructure, y as SubmitTxHashResponse, yt as PingResponse, z as ExecutionOfMode } from "./index-ClDOR6-k.js";
2
2
  //#region src/core/http.d.ts
3
3
  /** Per-call options accepted by every SDK method. */
4
4
  interface RequestOptions {
@@ -496,4 +496,4 @@ interface VerifyWebhookParams {
496
496
  */
497
497
  export declare function verifyWebhook(params: VerifyWebhookParams): Promise<WebhookEvent>;
498
498
  //#endregion
499
- export { type AffiliateFeeBreakdown, type Chain, type ChainsResponse, type CosmosBankSendSwapExecution, type CosmosMsgDepositSwapExecution, type CosmosMsgExecuteSwapExecution, type CreateSwapParams, type CreateSwapResponse, type CursorPagination, type ErrorCode, type EvmApproval, type EvmSwapExecution, type ExecutionFamily, type ExecutionMode, type ExecutionOfFamily, type ExecutionOfMode, type ExpectedAffiliateEntry, type Fetch, type GetQuoteParams, type GetSwapResponse, type HealthResponse, type InstaswapFeeLine, type InstaswapSwapLiteSnapshot, type InternalSwapStatus, type JsonSwapExecution, type KnownErrorCode, type KnownProvider, type KnownProviderType, type ListProvidersParams, type ListTransactionsParams, type NamedDepositSwapExecution, type OpenOceanRouteMeta, type OtherDepositSwapExecution, type PagePromise, type PegarouteOptions, type PingResponse, type PrivateSwapMode, type Provider, type ProviderAffiliateFeeStructure, type ProviderFeeStructure, type ProviderHealth, type ProviderInfo, type ProviderStatusInfo, type ProviderTakeStructure, type ProviderType, type ProvidersResponse, type QuoteFees, type QuoteResponse, type QuoteRoute, type RefundInfo, type RequestOptions, type RouteInfo, type RouteWarning, type SerializedSwapExecution, type StreamingProgress, type SubmitTxHashParams, type SubmitTxHashResponse, type SwapEvent, type SwapEventsResponse, type SwapExecution, type SwapFailure, type SwapInput, type SwapOutput, type SwapProviderInfo, type SwapStatus, type SwapTimestamps, type TestWebhookEvent, type Token, type TokenAmount, type TokensResponse, type Transaction, type TransactionWebhookData, type TransactionWebhookEvent, type TransactionWebhookEventType, type TransactionsResponse, type UtxoSwapExecution, type VerifyWebhookParams, type WaitForCompletionOptions, type WebhookEvent, type WebhookStreamingProgress, type WebhookVerificationFailure, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
499
+ export { type AdditionalFee, type AffiliateFeeBreakdown, type Chain, type ChainsResponse, type CosmosBankSendSwapExecution, type CosmosMsgDepositSwapExecution, type CosmosMsgExecuteSwapExecution, type CreateSwapParams, type CreateSwapResponse, type CursorPagination, type ErrorCode, type EvmApproval, type EvmSwapExecution, type ExecutionFamily, type ExecutionMode, type ExecutionOfFamily, type ExecutionOfMode, type ExpectedAffiliateEntry, type FeeAmount, type Fetch, type GetQuoteParams, type GetSwapResponse, type HealthResponse, type InstaswapFeeLine, type InstaswapSwapLiteSnapshot, type InternalSwapStatus, type JsonSwapExecution, type KnownErrorCode, type KnownProvider, type KnownProviderType, type ListProvidersParams, type ListTransactionsParams, type NamedDepositSwapExecution, type NoQuoteRouteFees, type OpenOceanRouteMeta, type OtherDepositSwapExecution, type PagePromise, type PegarouteOptions, type PingResponse, type PrivateSwapMode, type Provider, type ProviderAffiliateFeeStructure, type ProviderFeeStructure, type ProviderHealth, type ProviderInfo, type ProviderStatusInfo, type ProviderTakeStructure, type ProviderType, type ProvidersResponse, type QuoteResponse, type QuoteRoute, type QuoteRouteFees, type RefundInfo, type RequestOptions, type RouteInfo, type RouteWarning, type SerializedSwapExecution, type StreamingProgress, type SubmitTxHashParams, type SubmitTxHashResponse, type SwapEvent, type SwapEventsResponse, type SwapExecution, type SwapFailure, type SwapInput, type SwapOutput, type SwapProviderInfo, type SwapStatus, type SwapTimestamps, type TestWebhookEvent, type Token, type TokenAmount, type TokensResponse, type Transaction, type TransactionWebhookData, type TransactionWebhookEvent, type TransactionWebhookEventType, type TransactionsResponse, type UtxoSwapExecution, type VerifyWebhookParams, type WaitForCompletionOptions, type WebhookEvent, type WebhookStreamingProgress, type WebhookVerificationFailure, hasQuoteRouteFees, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as toExternalStatus, n as isExecutionMode, r as isTerminalStatus, t as isExecutionFamily } from "./types-Cz8gDMIR.js";
1
+ import { a as toExternalStatus, i as isTerminalStatus, n as isExecutionMode, r as hasQuoteRouteFees, t as isExecutionFamily } from "./types-Dt7OyLsD.js";
2
2
  //#region src/core/errors.ts
3
3
  /** Base class for every error the SDK throws after a request is made. */
4
4
  var PegarouteError = class extends Error {
@@ -898,4 +898,4 @@ function hexToBytes(hex) {
898
898
  return bytes;
899
899
  }
900
900
  //#endregion
901
- export { AuthenticationError, BadRequestError, ConflictError, ConnectionError, InternalServerError, NotFoundError, Pegaroute, PegarouteError, PermissionDeniedError, ProviderChangedError, QuoteExpiredError, RateLimitError, ServiceUnavailableError, TimeoutError, UnprocessableEntityError, WaitTimeoutError, WebhookVerificationError, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus, verifyWebhook };
901
+ export { AuthenticationError, BadRequestError, ConflictError, ConnectionError, InternalServerError, NotFoundError, Pegaroute, PegarouteError, PermissionDeniedError, ProviderChangedError, QuoteExpiredError, RateLimitError, ServiceUnavailableError, TimeoutError, UnprocessableEntityError, WaitTimeoutError, WebhookVerificationError, hasQuoteRouteFees, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus, verifyWebhook };
@@ -36,6 +36,19 @@ function isTerminalStatus(status) {
36
36
  return TERMINAL_STATUSES.has(status);
37
37
  }
38
38
  //#endregion
39
+ //#region src/types/common.ts
40
+ /**
41
+ * Whether Pegaroute sent fee data for a route. `false` means `{}`: no fee data, not a zero fee.
42
+ *
43
+ * @example
44
+ * if (hasQuoteRouteFees(route.fees)) {
45
+ * show(`$${route.fees.totalUsd} (${route.fees.totalBps} bps)`);
46
+ * }
47
+ */
48
+ function hasQuoteRouteFees(fees) {
49
+ return fees.totalUsd !== void 0;
50
+ }
51
+ //#endregion
39
52
  //#region src/types/execution.ts
40
53
  /**
41
54
  * Narrows an execution to the variants of one mode, whatever the family.
@@ -61,4 +74,4 @@ function isExecutionFamily(execution, family) {
61
74
  return execution.family === family;
62
75
  }
63
76
  //#endregion
64
- export { toExternalStatus as i, isExecutionMode as n, isTerminalStatus as r, isExecutionFamily as t };
77
+ export { toExternalStatus as a, isTerminalStatus as i, isExecutionMode as n, hasQuoteRouteFees as r, isExecutionFamily as t };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as KnownErrorCode, A as toExternalStatus, B as JsonSwapExecution, C as SwapInput, Ct as Token, D as InternalSwapStatus, E as SwapTimestamps, F as EvmSwapExecution, G as UtxoSwapExecution, H as OtherDepositSwapExecution, I as ExecutionFamily, J as GetQuoteParams, K as isExecutionFamily, L as ExecutionMode, M as CosmosMsgDepositSwapExecution, N as CosmosMsgExecuteSwapExecution, O as SwapStatus, P as EvmApproval, Q as ErrorCode, R as ExecutionOfFamily, S as SwapFailure, St as ProvidersResponse, T as SwapProviderInfo, U as SerializedSwapExecution, V as NamedDepositSwapExecution, W as SwapExecution, X as QuoteRoute, Y as QuoteResponse, Z as RouteWarning, _ as ProviderStatusInfo, _t as ProviderFeeStructure, a as WebhookEvent, at as QuoteFees, b as SwapEvent, bt as ProviderTakeStructure, c as ExpectedAffiliateEntry, ct as StreamingProgress, d as TransactionsResponse, dt as ChainsResponse, et as AffiliateFeeBreakdown, f as CreateSwapParams, ft as HealthResponse, g as InstaswapSwapLiteSnapshot, gt as ProviderAffiliateFeeStructure, h as InstaswapFeeLine, ht as PingResponse, i as TransactionWebhookEventType, it as Provider, j as CosmosBankSendSwapExecution, k as isTerminalStatus, l as ListTransactionsParams, lt as TokenAmount, m as GetSwapResponse, mt as ListProvidersParams, n as TransactionWebhookData, nt as OpenOceanRouteMeta, o as WebhookStreamingProgress, ot as RefundInfo, p as CreateSwapResponse, pt as KnownProviderType, q as isExecutionMode, r as TransactionWebhookEvent, rt as PrivateSwapMode, s as CursorPagination, st as RouteInfo, t as TestWebhookEvent, tt as KnownProvider, u as Transaction, ut as Chain, v as SubmitTxHashParams, vt as ProviderHealth, w as SwapOutput, wt as TokensResponse, x as SwapEventsResponse, xt as ProviderType, y as SubmitTxHashResponse, yt as ProviderInfo, z as ExecutionOfMode } from "./index-CeY_5Z4u.js";
2
- export { type AffiliateFeeBreakdown, type Chain, type ChainsResponse, type CosmosBankSendSwapExecution, type CosmosMsgDepositSwapExecution, type CosmosMsgExecuteSwapExecution, type CreateSwapParams, type CreateSwapResponse, type CursorPagination, type ErrorCode, type EvmApproval, type EvmSwapExecution, type ExecutionFamily, type ExecutionMode, type ExecutionOfFamily, type ExecutionOfMode, type ExpectedAffiliateEntry, type GetQuoteParams, type GetSwapResponse, type HealthResponse, type InstaswapFeeLine, type InstaswapSwapLiteSnapshot, type InternalSwapStatus, type JsonSwapExecution, type KnownErrorCode, type KnownProvider, type KnownProviderType, type ListProvidersParams, type ListTransactionsParams, type NamedDepositSwapExecution, type OpenOceanRouteMeta, type OtherDepositSwapExecution, type PingResponse, type PrivateSwapMode, type Provider, type ProviderAffiliateFeeStructure, type ProviderFeeStructure, type ProviderHealth, type ProviderInfo, type ProviderStatusInfo, type ProviderTakeStructure, type ProviderType, type ProvidersResponse, type QuoteFees, type QuoteResponse, type QuoteRoute, type RefundInfo, type RouteInfo, type RouteWarning, type SerializedSwapExecution, type StreamingProgress, type SubmitTxHashParams, type SubmitTxHashResponse, type SwapEvent, type SwapEventsResponse, type SwapExecution, type SwapFailure, type SwapInput, type SwapOutput, type SwapProviderInfo, type SwapStatus, type SwapTimestamps, type TestWebhookEvent, type Token, type TokenAmount, type TokensResponse, type Transaction, type TransactionWebhookData, type TransactionWebhookEvent, type TransactionWebhookEventType, type TransactionsResponse, type UtxoSwapExecution, type WebhookEvent, type WebhookStreamingProgress, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
1
+ import { $ as KnownErrorCode, A as toExternalStatus, B as JsonSwapExecution, C as SwapInput, Ct as ProviderInfo, D as InternalSwapStatus, Dt as Token, E as SwapTimestamps, Et as ProvidersResponse, F as EvmSwapExecution, G as UtxoSwapExecution, H as OtherDepositSwapExecution, I as ExecutionFamily, J as GetQuoteParams, K as isExecutionFamily, L as ExecutionMode, M as CosmosMsgDepositSwapExecution, N as CosmosMsgExecuteSwapExecution, O as SwapStatus, Ot as TokensResponse, P as EvmApproval, Q as ErrorCode, R as ExecutionOfFamily, S as SwapFailure, St as ProviderHealth, T as SwapProviderInfo, Tt as ProviderType, U as SerializedSwapExecution, V as NamedDepositSwapExecution, W as SwapExecution, X as QuoteRoute, Y as QuoteResponse, Z as RouteWarning, _ as ProviderStatusInfo, _t as KnownProviderType, a as WebhookEvent, at as OpenOceanRouteMeta, b as SwapEvent, bt as ProviderAffiliateFeeStructure, c as ExpectedAffiliateEntry, ct as QuoteRouteFees, d as TransactionsResponse, dt as StreamingProgress, et as AdditionalFee, f as CreateSwapParams, ft as TokenAmount, g as InstaswapSwapLiteSnapshot, gt as HealthResponse, h as InstaswapFeeLine, ht as ChainsResponse, i as TransactionWebhookEventType, it as NoQuoteRouteFees, j as CosmosBankSendSwapExecution, k as isTerminalStatus, l as ListTransactionsParams, lt as RefundInfo, m as GetSwapResponse, mt as Chain, n as TransactionWebhookData, nt as FeeAmount, o as WebhookStreamingProgress, ot as PrivateSwapMode, p as CreateSwapResponse, pt as hasQuoteRouteFees, q as isExecutionMode, r as TransactionWebhookEvent, rt as KnownProvider, s as CursorPagination, st as Provider, t as TestWebhookEvent, tt as AffiliateFeeBreakdown, u as Transaction, ut as RouteInfo, v as SubmitTxHashParams, vt as ListProvidersParams, w as SwapOutput, wt as ProviderTakeStructure, x as SwapEventsResponse, xt as ProviderFeeStructure, y as SubmitTxHashResponse, yt as PingResponse, z as ExecutionOfMode } from "./index-ClDOR6-k.js";
2
+ export { type AdditionalFee, type AffiliateFeeBreakdown, type Chain, type ChainsResponse, type CosmosBankSendSwapExecution, type CosmosMsgDepositSwapExecution, type CosmosMsgExecuteSwapExecution, type CreateSwapParams, type CreateSwapResponse, type CursorPagination, type ErrorCode, type EvmApproval, type EvmSwapExecution, type ExecutionFamily, type ExecutionMode, type ExecutionOfFamily, type ExecutionOfMode, type ExpectedAffiliateEntry, type FeeAmount, type GetQuoteParams, type GetSwapResponse, type HealthResponse, type InstaswapFeeLine, type InstaswapSwapLiteSnapshot, type InternalSwapStatus, type JsonSwapExecution, type KnownErrorCode, type KnownProvider, type KnownProviderType, type ListProvidersParams, type ListTransactionsParams, type NamedDepositSwapExecution, type NoQuoteRouteFees, type OpenOceanRouteMeta, type OtherDepositSwapExecution, type PingResponse, type PrivateSwapMode, type Provider, type ProviderAffiliateFeeStructure, type ProviderFeeStructure, type ProviderHealth, type ProviderInfo, type ProviderStatusInfo, type ProviderTakeStructure, type ProviderType, type ProvidersResponse, type QuoteResponse, type QuoteRoute, type QuoteRouteFees, type RefundInfo, type RouteInfo, type RouteWarning, type SerializedSwapExecution, type StreamingProgress, type SubmitTxHashParams, type SubmitTxHashResponse, type SwapEvent, type SwapEventsResponse, type SwapExecution, type SwapFailure, type SwapInput, type SwapOutput, type SwapProviderInfo, type SwapStatus, type SwapTimestamps, type TestWebhookEvent, type Token, type TokenAmount, type TokensResponse, type Transaction, type TransactionWebhookData, type TransactionWebhookEvent, type TransactionWebhookEventType, type TransactionsResponse, type UtxoSwapExecution, type WebhookEvent, type WebhookStreamingProgress, hasQuoteRouteFees, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
package/dist/types.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as toExternalStatus, n as isExecutionMode, r as isTerminalStatus, t as isExecutionFamily } from "./types-Cz8gDMIR.js";
2
- export { isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
1
+ import { a as toExternalStatus, i as isTerminalStatus, n as isExecutionMode, r as hasQuoteRouteFees, t as isExecutionFamily } from "./types-Dt7OyLsD.js";
2
+ export { hasQuoteRouteFees, isExecutionFamily, isExecutionMode, isTerminalStatus, toExternalStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pegaroute/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript SDK for the Pegaroute cross-chain swap API",
5
5
  "license": "MIT",
6
6
  "type": "module",