@pendle/sdk-boros 1.7.0 → 1.8.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/entities/Calculator/marginCalculator.d.ts +6 -3
  3. package/dist/entities/Calculator/marginCalculator.js +17 -14
  4. package/dist/entities/Calculator/marginCalculator.js.map +1 -1
  5. package/dist/entities/aggregatorHelpers/AggregatorHelperErrors.d.ts +45 -48
  6. package/dist/entities/aggregatorHelpers/AggregatorHelperErrors.js +107 -90
  7. package/dist/entities/aggregatorHelpers/AggregatorHelperErrors.js.map +1 -1
  8. package/dist/entities/aggregatorHelpers/PendleSwap/PendleSwapAggregatorHelper.d.ts +1 -1
  9. package/dist/entities/aggregatorHelpers/PendleSwap/PendleSwapAggregatorHelper.js +3 -3
  10. package/dist/entities/aggregatorHelpers/PendleSwap/PendleSwapAggregatorHelper.js.map +1 -1
  11. package/dist/entities/aggregatorHelpers/index.d.ts +1 -0
  12. package/dist/entities/aggregatorHelpers/index.js +1 -0
  13. package/dist/entities/aggregatorHelpers/index.js.map +1 -1
  14. package/dist/entities/collateralSwapper/CollateralSwapper.js +9 -9
  15. package/dist/entities/collateralSwapper/CollateralSwapper.js.map +1 -1
  16. package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.d.ts +1 -1
  17. package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.js +3 -3
  18. package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.js.map +1 -1
  19. package/dist/entities/crossChainDeposit/aggregators/Bungee/index.d.ts +1 -0
  20. package/dist/entities/crossChainDeposit/aggregators/Bungee/index.js +28 -9
  21. package/dist/entities/crossChainDeposit/aggregators/Bungee/index.js.map +1 -1
  22. package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js +4 -4
  23. package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js.map +1 -1
  24. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.d.ts +1 -1
  25. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js +4 -4
  26. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js.map +1 -1
  27. package/dist/errors/AggregatorErrorCodes.d.ts +9 -0
  28. package/dist/errors/AggregatorErrorCodes.js +12 -0
  29. package/dist/errors/AggregatorErrorCodes.js.map +1 -0
  30. package/dist/errors/ErrorCodes.d.ts +28 -16
  31. package/dist/errors/ErrorCodes.js +2 -0
  32. package/dist/errors/ErrorCodes.js.map +1 -1
  33. package/dist/errors/index.d.ts +1 -0
  34. package/dist/errors/index.js +1 -0
  35. package/dist/errors/index.js.map +1 -1
  36. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @pendle/sdk-boros
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 39fcae2: Aggregator failures now throw a single displayable `AggregatorHelperError` carrying a stable `code`, user-facing `shortMessage`, and structured fields — and it is exported, so consumers can finally catch it.
8
+
9
+ - `AggregatorHelperError` — `code`, `shortMessage`, `retryable`, `aggregator`, `requestType`, `requestData`, `status`, `providerMessage`, `providerCode`, `responseData`, plus `.is(err, code?)` and `.isFrom(err, aggregator, requestType?)` narrowing helpers.
10
+ - `AggregatorErrorCodes` — `AGGREGATOR_TIMEOUT`, `AGGREGATOR_NETWORK_ERROR`, `AGGREGATOR_RATE_LIMITED`, `AGGREGATOR_SERVER_ERROR`, `AGGREGATOR_REQUEST_REJECTED`, `AGGREGATOR_UNKNOWN_ERROR`. Merged into `ErrorCodes`, so `ErrorCodes.AGGREGATOR_TIMEOUT` is the same value.
11
+ - `defaultAggregatorErrorMessageHandler` — the copy table, keyed by code, exported so a caller can render the default text for a code itself. The copy is fixed for now: there is deliberately no way to install a replacement handler.
12
+ - `PendleSdkError` is now exported too — it was the base class of every aggregator error and unreachable.
13
+
14
+ Nothing was removed from the public surface. `AggregatorHelperRequestError`, `AggregatorHelperServerError`, `UnknownAggregatorHelperError`, `WrappedAxiosError` and `AggregatorHelperAxiosError` are gone, but none of them were exported — a consumer could not name or `instanceof` them, only read their `.message`. That message is the thing this changes.
15
+
16
+ A 503 from Bungee used to surface as `BUNGEE: BUNGEE server error, error code unknown` on `.message`, and `BUNGEE: BUNGEE: BUNGEE server error, error code unknown` from `String(err)` and the stack header. The class set `name` to the `AggregatorName`, so `Error.prototype.toString()` (`${name}: ${message}`) stacked the provider on top of a message that already self-prefixed twice. `name` is now the class name, which also stops every aggregator failure collapsing into one `BUNGEE` group in log aggregators. The same error now reads `Bungee is temporarily unavailable. Please try again or pick another route.` on `shortMessage`, with `[AGGREGATOR_SERVER_ERROR aggregator=BUNGEE requestType=quote status=503]` appended on `message` for logs.
17
+
18
+ Errors are classified by failure mode rather than by the shape of the underlying axios object, because that is what a caller has to act on — retry, fall back to another route, or fix the request. `classifyAggregatorError` drops its `errorStatuses` and `errorDataCheckingFn` parameters: `classifyAggregatorError(aggregator, error, requestType, requestData)`. Every call site passed the same hardcoded `[500, 502, 503, 504]`, which quietly classified 501/507/599 as unknown, and all 15 passed `() => undefined` as the data checker — which made `AggregatorHelperRequestError` unreachable and threw away every 4xx body the provider sent. A default extractor now reads the provider's own reason off `message`/`error` and its code off `code`/`errorCode`/`statusCode`, the shapes Socket, LI.FI and the Boros API actually return.
19
+
20
+ The provider's reason becomes the display copy for `AGGREGATOR_REQUEST_REJECTED` — it is specific and the user can act on it — but is deliberately kept off `shortMessage` for `AGGREGATOR_SERVER_ERROR`, where a 5xx body is an internal detail (`upstream pod OOMKilled` is not for users). It is always available on `providerMessage`. Response bodies live on `responseData` instead of being `JSON.stringify`'d into the message, which previously inlined an unbounded blob into every log line.
21
+
22
+ The codes live in `src/errors/AggregatorErrorCodes.ts`, a leaf module with no imports, spread into `ApiErrorCodes`. Handling a swap error should not pull the contract error ABI into the bundle, which is what importing them from `ErrorCodes` would have done.
23
+
24
+ ### Patch Changes
25
+
26
+ - b09c3c5: Bungee quotes round the slippage they send to 3 decimal places. Socket's backend started rejecting anything longer (`400 Validation Error : slippage must have at most 3 decimal places`), which broke every quote whose slippage came out of the dynamic auto-slippage formulas — `8 / inputValueUsd` on a $999 deposit produces `0.8008006885764801%`.
27
+
28
+ Both `quoteDeposit` and `quoteWithdraw` now go through `toBungeeSlippage`, which converts the SDK's decimal (`0.005`) to Socket's percentage (`0.5`) and rounds to nearest 3 dp.
29
+
30
+ Rounding is decimal (`toFixed`), not `Math.ceil(x * 1000) / 1000` — the latter bumps 648 of the first 5000 already-valid 3 dp values a full step up on a float ULP, so a caller asking for `0.009%` would have been quoted at `0.01%`.
31
+
32
+ A nonzero tolerance that rounds to `0` is floored at `0.001%`, since a zero tolerance makes every route revert. An explicitly requested `0` is passed through unchanged.
33
+
34
+ ## 1.7.1
35
+
36
+ ### Patch Changes
37
+
38
+ - 6efb777: The leverage-free V2 margin helpers accept an optional `kIM` override, so a caller can price a position at an account's **personal kIM** instead of the market-global one.
39
+
40
+ - `getMarginRequiredFor1YUV2(market, kIM?: bigint)`
41
+ - `getMarginRequiredFor1YUFixedX18V2(market, kIM?: bigint)`
42
+ - `getStrategyMarginRequirementsV2(long, short, kIM?: { long?: bigint; short?: bigint })`
43
+
44
+ `kIM` is a raw FixedX18 value, the same domain as `market.config.kIM` — feed it straight from `GET /apis/v1/accounts/margin-config`, which returns one entry per market where a personal override is set. Omit it (or omit a leg) for the market-global figure; every existing call site is unaffected.
45
+
46
+ Without this, the only way to reach the margin factor was to hand the SDK a `MarketResponse` whose `config.kIM` had been swapped out — an object that then lies about the market to everything else reading it (`getStrategyFees`, `calculateAprTimesMaxLeverage`, and any UI rendering the market's published risk params).
47
+
48
+ A non-positive override falls back to the market value: a personal kIM only ever ratchets the global one up, so `0n` is a caller bug, not a request to price at zero margin.
49
+
50
+ The deprecated V1 helpers are deliberately left alone — they carry a `leverage` knob that V2 dropped, and leverage on Boros is a cosmetic `1/kIM` echo, not a contract input.
51
+
3
52
  ## 1.7.0
4
53
 
5
54
  ### Minor Changes
@@ -1,9 +1,9 @@
1
1
  import { FixedX18 } from '@pendle/boros-offchain-math';
2
2
  import type { MarketResponse } from '../../backend/secrettune/BorosCoreSDK';
3
3
  export declare function getMarginRequiredFor1YU(market: MarketResponse, leverage?: number): number;
4
- export declare function getMarginRequiredFor1YUV2(market: MarketResponse): number;
4
+ export declare function getMarginRequiredFor1YUV2(market: MarketResponse, kIM?: bigint): number;
5
5
  export declare function getMarginRequiredFor1YUFixedX18(market: MarketResponse, leverage?: number): FixedX18;
6
- export declare function getMarginRequiredFor1YUFixedX18V2(market: MarketResponse): FixedX18;
6
+ export declare function getMarginRequiredFor1YUFixedX18V2(market: MarketResponse, kIM?: bigint): FixedX18;
7
7
  export declare function getStrategyBorosMargin(longMarket: MarketResponse, shortMarket: MarketResponse, leverage?: number): number;
8
8
  export declare function getStrategyMarginRequirements(longMarket: MarketResponse, shortMarket: MarketResponse, leverage?: {
9
9
  longLeverage?: number;
@@ -13,7 +13,10 @@ export declare function getStrategyMarginRequirements(longMarket: MarketResponse
13
13
  marginRequired2: number;
14
14
  totalBorosMargin: number;
15
15
  };
16
- export declare function getStrategyMarginRequirementsV2(longMarket: MarketResponse, shortMarket: MarketResponse): {
16
+ export declare function getStrategyMarginRequirementsV2(longMarket: MarketResponse, shortMarket: MarketResponse, kIM?: {
17
+ long?: bigint;
18
+ short?: bigint;
19
+ }): {
17
20
  marginRequired1: number;
18
21
  marginRequired2: number;
19
22
  totalBorosMargin: number;
@@ -12,11 +12,16 @@ const market_1 = require("../market/market");
12
12
  const DEFAULT_MIN_MARGIN_INDEX_RATE = boros_offchain_math_1.FixedX18.fromNumber(0.1);
13
13
  const DEFAULT_MIN_MARGIN_INDEX_DURATION_S = 604800;
14
14
  const ONE_YU = 10n ** 18n;
15
- function extractMarketParams(market, leverage) {
16
- const effectiveLeverage = leverage ?? market.metadata?.maxLeverage ?? 1;
17
- const marginFactor = market.config.kIM
15
+ function resolveMarginFactor(market, kIM) {
16
+ if (kIM !== undefined && kIM > 0n)
17
+ return boros_offchain_math_1.FixedX18.fromRawValue(kIM);
18
+ return market.config.kIM
18
19
  ? boros_offchain_math_1.FixedX18.fromRawValue(BigInt(market.config.kIM))
19
20
  : boros_offchain_math_1.FixedX18.fromNumber(0.5);
21
+ }
22
+ function extractMarketParams(market, leverage) {
23
+ const effectiveLeverage = leverage ?? market.metadata?.maxLeverage ?? 1;
24
+ const marginFactor = resolveMarginFactor(market);
20
25
  const minMarginIndexDuration_s = market.config.tThresh ?? DEFAULT_MIN_MARGIN_INDEX_DURATION_S;
21
26
  const timeToMaturity = market.data?.timeToMaturity ??
22
27
  Math.max(0, market.imData.maturity - Math.floor(Date.now() / 1000));
@@ -34,10 +39,8 @@ function extractMarketParams(market, leverage) {
34
39
  isMarketOrder: true,
35
40
  };
36
41
  }
37
- function extractMarketParamsV2(market) {
38
- const marginFactor = market.config.kIM
39
- ? boros_offchain_math_1.FixedX18.fromRawValue(BigInt(market.config.kIM))
40
- : boros_offchain_math_1.FixedX18.fromNumber(0.5);
42
+ function extractMarketParamsV2(market, kIM) {
43
+ const marginFactor = resolveMarginFactor(market, kIM);
41
44
  const minMarginIndexDuration_s = market.config.tThresh ?? DEFAULT_MIN_MARGIN_INDEX_DURATION_S;
42
45
  const timeToMaturity = market.data?.timeToMaturity ??
43
46
  Math.max(0, market.imData.maturity - Math.floor(Date.now() / 1000));
@@ -62,9 +65,9 @@ function getMarginRequiredFor1YU(market, leverage) {
62
65
  }, false);
63
66
  return Number(marginBigInt) / 1e18;
64
67
  }
65
- function getMarginRequiredFor1YUV2(market) {
68
+ function getMarginRequiredFor1YUV2(market, kIM) {
66
69
  const marginBigInt = market_1.Market.getInitialMarginByOrderSizeV2({
67
- ...extractMarketParamsV2(market),
70
+ ...extractMarketParamsV2(market, kIM),
68
71
  orderSize: ONE_YU,
69
72
  });
70
73
  return Number(marginBigInt) / 1e18;
@@ -77,9 +80,9 @@ function getMarginRequiredFor1YUFixedX18(market, leverage) {
77
80
  }, false);
78
81
  return boros_offchain_math_1.FixedX18.fromRawValue(marginBigInt);
79
82
  }
80
- function getMarginRequiredFor1YUFixedX18V2(market) {
83
+ function getMarginRequiredFor1YUFixedX18V2(market, kIM) {
81
84
  const marginBigInt = market_1.Market.getInitialMarginByOrderSizeV2({
82
- ...extractMarketParamsV2(market),
85
+ ...extractMarketParamsV2(market, kIM),
83
86
  orderSize: ONE_YU,
84
87
  });
85
88
  return boros_offchain_math_1.FixedX18.fromRawValue(marginBigInt);
@@ -98,9 +101,9 @@ function getStrategyMarginRequirements(longMarket, shortMarket, leverage) {
98
101
  totalBorosMargin: marginRequired1 + marginRequired2,
99
102
  };
100
103
  }
101
- function getStrategyMarginRequirementsV2(longMarket, shortMarket) {
102
- const marginRequired1 = getMarginRequiredFor1YUV2(longMarket);
103
- const marginRequired2 = getMarginRequiredFor1YUV2(shortMarket);
104
+ function getStrategyMarginRequirementsV2(longMarket, shortMarket, kIM) {
105
+ const marginRequired1 = getMarginRequiredFor1YUV2(longMarket, kIM?.long);
106
+ const marginRequired2 = getMarginRequiredFor1YUV2(shortMarket, kIM?.short);
104
107
  return {
105
108
  marginRequired1,
106
109
  marginRequired2,
@@ -1 +1 @@
1
- {"version":3,"file":"marginCalculator.js","sourceRoot":"","sources":["../../../src/entities/Calculator/marginCalculator.ts"],"names":[],"mappings":";;AA6FA,0DAiBC;AAKD,8DAMC;AAOD,0EAeC;AAYD,8EAMC;AAUD,wDAQC;AAOD,sEAmBC;AAKD,0EAeC;AAjOD,qEAAsE;AAEtE,6CAA0C;AAM1C,MAAM,6BAA6B,GAAG,8BAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAK/D,MAAM,mCAAmC,GAAG,MAAM,CAAC;AAKnD,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;AAK1B,SAAS,mBAAmB,CAAC,MAAsB,EAAE,QAAiB;IACpE,MAAM,iBAAiB,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,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B,+BAA+B,CAC7C,UAA0B,EAC1B,WAA2B,EAC3B,GAGC;IAMD,MAAM,eAAe,GAAG,yBAAyB,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACzE,MAAM,eAAe,GAAG,yBAAyB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3E,OAAO;QACL,eAAe;QACf,eAAe;QACf,gBAAgB,EAAE,eAAe,GAAG,eAAe;KACpD,CAAC;AACJ,CAAC"}
@@ -1,18 +1,12 @@
1
- import { AxiosError } from 'axios';
2
1
  import { Hex } from 'viem';
3
2
  import { PrepareCollateralSwapDto, QuoteBridgeDto, QuoteWithdrawDto } from '../../backend/secrettune/BorosCoreSDK';
4
3
  import { PendleSwapDtoV2 } from '../../backend/secrettune/PendleV2SDK';
5
- import { PendleSdkError, PendleSdkErrorParams } from '../../errors/PendleSdkError';
6
- import { AggregatorName, QuoteDepositParams, QuoteWithdrawParams } from '../crossChainDeposit';
4
+ import { AggregatorErrorCode, AggregatorErrorCodes } from '../../errors/AggregatorErrorCodes';
5
+ import { PendleSdkError } from '../../errors/PendleSdkError';
6
+ import { AggregatorName, QuoteDepositParams, QuoteWithdrawParams } from '../crossChainDeposit/AggregatorHelper';
7
7
  import { BungeeQuoteRequest, BungeeStatusRequest } from '../crossChainDeposit/aggregators/Bungee/types';
8
8
  import { GetTokensRequest, LifiGetRouteStatusRequest, LifiGetRoutesRequest, LifiGetRoutesStep } from '../crossChainDeposit/aggregators/Lifi/types';
9
9
  export type AggregatorRequestType = 'getTokens' | 'quote' | 'quoteWithdraw' | 'assemble' | 'getRouteStatus' | 'getIntentStatus' | 'prepareTransferCall';
10
- export type AggregatorErrorCodeType = {
11
- [AggregatorName.LIFI]: number;
12
- [AggregatorName.PENDLE]: number;
13
- [AggregatorName.BOROS]: number;
14
- [AggregatorName.BUNGEE]: number;
15
- };
16
10
  export type AggregatorRequestData = {
17
11
  [AggregatorName.LIFI]: {
18
12
  getTokens: GetTokensRequest;
@@ -51,44 +45,47 @@ export type AggregatorRequestData = {
51
45
  prepareTransferCall: undefined;
52
46
  };
53
47
  };
54
- export type ErrorDataCheckingFnReturnType<T extends AggregatorName> = {
55
- errorCode?: AggregatorErrorCodeType[T];
56
- message: string;
57
- extraData?: any;
58
- } | undefined;
59
- export declare class AggregatorHelperError extends PendleSdkError {
60
- readonly name: AggregatorName;
61
- readonly message: string;
62
- constructor(name: AggregatorName, message: string, params?: PendleSdkErrorParams);
63
- }
64
- export declare class AggregatorHelperRequestError<T extends AggregatorName, RT extends AggregatorRequestType> extends AggregatorHelperError {
65
- readonly name: T;
48
+ export { AggregatorErrorCodes, type AggregatorErrorCode };
49
+ export declare const AGGREGATOR_LABEL: Record<AggregatorName, string>;
50
+ export type AggregatorErrorContext = {
51
+ aggregator: AggregatorName;
52
+ label: string;
53
+ requestType: AggregatorRequestType;
54
+ status?: number;
55
+ providerMessage?: string;
56
+ providerCode?: string | number;
57
+ };
58
+ export type AggregatorErrorMessageHandler = Record<AggregatorErrorCode, (ctx: AggregatorErrorContext) => string>;
59
+ export declare const defaultAggregatorErrorMessageHandler: AggregatorErrorMessageHandler;
60
+ export type AggregatorHelperErrorParams<T extends AggregatorName = AggregatorName, RT extends AggregatorRequestType = AggregatorRequestType> = {
61
+ code: AggregatorErrorCode;
62
+ aggregator: T;
63
+ requestType: RT;
64
+ requestData?: AggregatorRequestData[T][RT];
65
+ status?: number;
66
+ providerMessage?: string;
67
+ providerCode?: string | number;
68
+ responseData?: unknown;
69
+ cause?: unknown;
70
+ };
71
+ export declare class AggregatorHelperError<T extends AggregatorName = AggregatorName, RT extends AggregatorRequestType = AggregatorRequestType> extends PendleSdkError {
72
+ readonly code: AggregatorErrorCode;
73
+ readonly aggregator: T;
66
74
  readonly requestType: RT;
67
- readonly requestErrorMessage: string;
68
- readonly requestData: AggregatorRequestData[T][RT];
69
- readonly errorCode?: AggregatorErrorCodeType[T] | undefined;
70
- constructor(name: T, requestType: RT, requestErrorMessage: string, requestData: AggregatorRequestData[T][RT], errorCode?: AggregatorErrorCodeType[T] | undefined, params?: PendleSdkErrorParams);
71
- static isErrorOfType<T extends AggregatorName>(error: unknown, name: T): error is AggregatorHelperRequestError<T, AggregatorRequestType>;
72
- static isErrorOfType<T extends AggregatorName, RT extends AggregatorRequestType>(error: unknown, name: T, requestType: RT): error is AggregatorHelperRequestError<T, RT>;
73
- }
74
- export declare class AggregatorHelperServerError<T extends AggregatorName> extends AggregatorHelperError {
75
- readonly name: T;
76
- readonly status: number;
77
- readonly errorCode?: AggregatorErrorCodeType[T] | undefined;
78
- constructor(name: T, status: number, errorCode?: AggregatorErrorCodeType[T] | undefined, params?: PendleSdkErrorParams);
79
- static create<T extends AggregatorName>(name: T, err: AxiosError, errorDataCheckingFn: (errorData: unknown) => ErrorDataCheckingFnReturnType<T>): AggregatorHelperServerError<T> | undefined;
80
- static isErrorOfType<T extends AggregatorName>(error: unknown, name: T): error is AggregatorHelperServerError<T>;
75
+ readonly requestData?: AggregatorRequestData[T][RT];
76
+ readonly status?: number;
77
+ readonly providerMessage?: string;
78
+ readonly providerCode?: string | number;
79
+ readonly responseData?: unknown;
80
+ readonly shortMessage: string;
81
+ readonly retryable: boolean;
82
+ constructor(params: AggregatorHelperErrorParams<T, RT>);
83
+ static is(error: unknown, code?: AggregatorErrorCode): error is AggregatorHelperError;
84
+ static isFrom<T extends AggregatorName, RT extends AggregatorRequestType = AggregatorRequestType>(error: unknown, aggregator: T, requestType?: RT): error is AggregatorHelperError<T, RT>;
81
85
  }
82
- export declare class UnknownAggregatorHelperError extends AggregatorHelperError {
83
- constructor(name: AggregatorName, params?: PendleSdkErrorParams);
84
- }
85
- export declare class WrappedAxiosError extends PendleSdkError {
86
- readonly cause: AxiosError;
87
- constructor(message: string, cause: AxiosError);
88
- }
89
- export declare class AggregatorHelperAxiosError extends WrappedAxiosError {
90
- readonly name: AggregatorName;
91
- readonly cause: AxiosError;
92
- constructor(name: AggregatorName, cause: AxiosError);
93
- }
94
- export declare function classifyAggregatorError<T extends AggregatorName, RT extends AggregatorRequestType>(name: T, error: any, errorStatuses: number[], requestType: RT, requestData: AggregatorRequestData[T][RT], errorDataCheckingFn: (errorData: unknown) => ErrorDataCheckingFnReturnType<T>): AggregatorHelperRequestError<T, RT> | AggregatorHelperServerError<T> | UnknownAggregatorHelperError | AggregatorHelperAxiosError;
86
+ export type ProviderErrorDetails = {
87
+ message?: string;
88
+ code?: string | number;
89
+ };
90
+ export declare function defaultProviderErrorDetails(data: unknown): ProviderErrorDetails | undefined;
91
+ export declare function classifyAggregatorError<T extends AggregatorName, RT extends AggregatorRequestType>(aggregator: T, error: unknown, requestType: RT, requestData?: AggregatorRequestData[T][RT], extractProviderDetails?: (data: unknown) => ProviderErrorDetails | undefined): AggregatorHelperError<T, RT>;
@@ -3,114 +3,131 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AggregatorHelperAxiosError = exports.WrappedAxiosError = exports.UnknownAggregatorHelperError = exports.AggregatorHelperServerError = exports.AggregatorHelperRequestError = exports.AggregatorHelperError = void 0;
6
+ exports.AggregatorHelperError = exports.defaultAggregatorErrorMessageHandler = exports.AGGREGATOR_LABEL = exports.AggregatorErrorCodes = void 0;
7
+ exports.defaultProviderErrorDetails = defaultProviderErrorDetails;
7
8
  exports.classifyAggregatorError = classifyAggregatorError;
8
9
  const axios_1 = __importDefault(require("axios"));
10
+ const AggregatorErrorCodes_1 = require("../../errors/AggregatorErrorCodes");
11
+ Object.defineProperty(exports, "AggregatorErrorCodes", { enumerable: true, get: function () { return AggregatorErrorCodes_1.AggregatorErrorCodes; } });
9
12
  const PendleSdkError_1 = require("../../errors/PendleSdkError");
10
- const crossChainDeposit_1 = require("../crossChainDeposit");
11
- class AggregatorHelperError extends PendleSdkError_1.PendleSdkError {
12
- name;
13
- message;
14
- constructor(name, message, params) {
15
- super(`${name}: ${message}`, params);
16
- this.name = name;
17
- this.message = message;
18
- }
13
+ const AggregatorHelper_1 = require("../crossChainDeposit/AggregatorHelper");
14
+ exports.AGGREGATOR_LABEL = {
15
+ [AggregatorHelper_1.AggregatorName.LIFI]: 'LI.FI',
16
+ [AggregatorHelper_1.AggregatorName.PENDLE]: 'Pendle',
17
+ [AggregatorHelper_1.AggregatorName.BOROS]: 'Boros',
18
+ [AggregatorHelper_1.AggregatorName.BUNGEE]: 'Bungee',
19
+ };
20
+ exports.defaultAggregatorErrorMessageHandler = {
21
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_TIMEOUT]: ({ label }) => `${label} took too long to respond. Please try again.`,
22
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_NETWORK_ERROR]: ({ label }) => `Could not reach ${label}. Check your connection and try again.`,
23
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_RATE_LIMITED]: ({ label }) => `Too many requests to ${label}. Please wait a moment and try again.`,
24
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_SERVER_ERROR]: ({ label }) => `${label} is temporarily unavailable. Please try again or pick another route.`,
25
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_REQUEST_REJECTED]: ({ label, providerMessage }) => providerMessage ?? `${label} could not process this request.`,
26
+ [AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_UNKNOWN_ERROR]: ({ label }) => `Something went wrong while contacting ${label}.`,
27
+ };
28
+ function resolveMessageHandler(code) {
29
+ const handler = exports.defaultAggregatorErrorMessageHandler[code];
30
+ return typeof handler === 'function'
31
+ ? handler
32
+ : exports.defaultAggregatorErrorMessageHandler[AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_UNKNOWN_ERROR];
19
33
  }
20
- exports.AggregatorHelperError = AggregatorHelperError;
21
- class AggregatorHelperRequestError extends AggregatorHelperError {
22
- name;
34
+ class AggregatorHelperError extends PendleSdkError_1.PendleSdkError {
35
+ code;
36
+ aggregator;
23
37
  requestType;
24
- requestErrorMessage;
25
38
  requestData;
26
- errorCode;
27
- constructor(name, requestType, requestErrorMessage, requestData, errorCode, params) {
28
- super(name, `${name} ${requestType} request error, error code ${errorCode ?? 'unknown'}: ${requestErrorMessage}`, params);
29
- this.name = name;
30
- this.requestType = requestType;
31
- this.requestErrorMessage = requestErrorMessage;
32
- this.requestData = requestData;
33
- this.errorCode = errorCode;
39
+ status;
40
+ providerMessage;
41
+ providerCode;
42
+ responseData;
43
+ shortMessage;
44
+ retryable;
45
+ constructor(params) {
46
+ const label = exports.AGGREGATOR_LABEL[params.aggregator];
47
+ const shortMessage = resolveMessageHandler(params.code)({
48
+ aggregator: params.aggregator,
49
+ label,
50
+ requestType: params.requestType,
51
+ status: params.status,
52
+ providerMessage: params.providerMessage,
53
+ providerCode: params.providerCode,
54
+ });
55
+ const detail = [
56
+ `aggregator=${params.aggregator}`,
57
+ `requestType=${params.requestType}`,
58
+ params.status !== undefined ? `status=${params.status}` : undefined,
59
+ params.providerCode !== undefined ? `providerCode=${params.providerCode}` : undefined,
60
+ ]
61
+ .filter((part) => part !== undefined)
62
+ .join(' ');
63
+ super(`${shortMessage} [${params.code} ${detail}]`, { cause: params.cause });
64
+ this.name = 'AggregatorHelperError';
65
+ this.code = params.code;
66
+ this.aggregator = params.aggregator;
67
+ this.requestType = params.requestType;
68
+ this.requestData = params.requestData;
69
+ this.status = params.status;
70
+ this.providerMessage = params.providerMessage;
71
+ this.providerCode = params.providerCode;
72
+ this.responseData = params.responseData;
73
+ this.shortMessage = shortMessage;
74
+ this.retryable = params.code !== AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_REQUEST_REJECTED;
34
75
  }
35
- static isErrorOfType(error, name, requestType) {
36
- return (error instanceof AggregatorHelperRequestError &&
37
- error.name === name &&
76
+ static is(error, code) {
77
+ return error instanceof AggregatorHelperError && (code === undefined || error.code === code);
78
+ }
79
+ static isFrom(error, aggregator, requestType) {
80
+ return (error instanceof AggregatorHelperError &&
81
+ error.aggregator === aggregator &&
38
82
  (requestType === undefined || error.requestType === requestType));
39
83
  }
40
84
  }
41
- exports.AggregatorHelperRequestError = AggregatorHelperRequestError;
42
- class AggregatorHelperServerError extends AggregatorHelperError {
43
- name;
44
- status;
45
- errorCode;
46
- constructor(name, status, errorCode, params) {
47
- super(name, `${name} server error, error code ${errorCode ?? 'unknown'}`, params);
48
- this.name = name;
49
- this.status = status;
50
- this.errorCode = errorCode;
51
- }
52
- static create(name, err, errorDataCheckingFn) {
53
- const status = err.status || err.response?.status;
54
- const isServerError = status && status >= 500 && status < 600;
55
- if (isServerError) {
56
- const data = err.response?.data;
57
- const dataCheckResult = errorDataCheckingFn(data);
58
- const errorCode = dataCheckResult?.errorCode;
59
- return new AggregatorHelperServerError(name, status, errorCode, { cause: err });
60
- }
85
+ exports.AggregatorHelperError = AggregatorHelperError;
86
+ function defaultProviderErrorDetails(data) {
87
+ if (typeof data !== 'object' || data === null) {
88
+ return undefined;
61
89
  }
62
- static isErrorOfType(error, name) {
63
- return error instanceof AggregatorHelperServerError && error.name === name;
90
+ const body = data;
91
+ const message = [body.message, body.error].find((value) => typeof value === 'string');
92
+ const code = [body.code, body.errorCode, body.statusCode].find((value) => typeof value === 'string' || typeof value === 'number');
93
+ if (message === undefined && code === undefined) {
94
+ return undefined;
64
95
  }
96
+ return { message, code };
65
97
  }
66
- exports.AggregatorHelperServerError = AggregatorHelperServerError;
67
- class UnknownAggregatorHelperError extends AggregatorHelperError {
68
- constructor(name, params) {
69
- const cause = params?.cause;
70
- super(name, `${name}: ${cause instanceof Error ? cause.message : 'unknown error'}`, params);
98
+ function classifyAggregatorError(aggregator, error, requestType, requestData, extractProviderDetails = defaultProviderErrorDetails) {
99
+ if (error instanceof AggregatorHelperError) {
100
+ return error;
71
101
  }
72
- }
73
- exports.UnknownAggregatorHelperError = UnknownAggregatorHelperError;
74
- class WrappedAxiosError extends PendleSdkError_1.PendleSdkError {
75
- cause;
76
- constructor(message, cause) {
77
- const prefix = `Wrapped axios error: ${message}: ${cause.message}.`;
78
- const errorMessage = cause.response ? `${prefix}\nResponse: ${JSON.stringify(cause.response.data)}.` : prefix;
79
- super(errorMessage, { cause });
80
- this.cause = cause;
102
+ const base = { aggregator, requestType, requestData, cause: error };
103
+ if (!axios_1.default.isAxiosError(error)) {
104
+ return new AggregatorHelperError({ ...base, code: AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_UNKNOWN_ERROR });
81
105
  }
82
- }
83
- exports.WrappedAxiosError = WrappedAxiosError;
84
- class AggregatorHelperAxiosError extends WrappedAxiosError {
85
- name;
86
- cause;
87
- constructor(name, cause) {
88
- super(`${name} helper axios error`, cause);
89
- this.name = name;
90
- this.cause = cause;
106
+ if (!error.response) {
107
+ const timedOut = error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT';
108
+ return new AggregatorHelperError({
109
+ ...base,
110
+ code: timedOut ? AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_TIMEOUT : AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_NETWORK_ERROR,
111
+ });
91
112
  }
92
- }
93
- exports.AggregatorHelperAxiosError = AggregatorHelperAxiosError;
94
- function classifyAggregatorError(name, error, errorStatuses, requestType, requestData, errorDataCheckingFn) {
95
- if (axios_1.default.isAxiosError(error)) {
96
- const serverErr = AggregatorHelperServerError.create(name, error, errorDataCheckingFn);
97
- if (serverErr) {
98
- return serverErr;
99
- }
113
+ const { status, data } = error.response;
114
+ const providerDetails = extractProviderDetails(data);
115
+ const withResponse = {
116
+ ...base,
117
+ status,
118
+ responseData: data,
119
+ providerMessage: providerDetails?.message,
120
+ providerCode: providerDetails?.code,
121
+ };
122
+ if (status === 429) {
123
+ return new AggregatorHelperError({ ...withResponse, code: AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_RATE_LIMITED });
100
124
  }
101
- if (!axios_1.default.isAxiosError(error) || error.response === undefined || !errorStatuses.includes(error.response.status)) {
102
- if (axios_1.default.isAxiosError(error)) {
103
- return new AggregatorHelperAxiosError(name, error);
104
- }
105
- return new UnknownAggregatorHelperError(name, { cause: error });
125
+ if (status >= 500) {
126
+ return new AggregatorHelperError({ ...withResponse, code: AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_SERVER_ERROR });
106
127
  }
107
- const data = error.response.data;
108
- const dataCheckResult = errorDataCheckingFn(data);
109
- if (!dataCheckResult) {
110
- return new UnknownAggregatorHelperError(name, { cause: error });
128
+ if (status >= 400) {
129
+ return new AggregatorHelperError({ ...withResponse, code: AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_REQUEST_REJECTED });
111
130
  }
112
- return new AggregatorHelperRequestError(name, requestType, dataCheckResult.message, requestData, dataCheckResult.errorCode, {
113
- cause: error,
114
- });
131
+ return new AggregatorHelperError({ ...withResponse, code: AggregatorErrorCodes_1.AggregatorErrorCodes.AGGREGATOR_UNKNOWN_ERROR });
115
132
  }
116
133
  //# sourceMappingURL=AggregatorHelperErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AggregatorHelperErrors.js","sourceRoot":"","sources":["../../../src/entities/aggregatorHelpers/AggregatorHelperErrors.ts"],"names":[],"mappings":";;;;;;AAgLA,0DA0CC;AA1ND,kDAA0C;AAI1C,gEAAmF;AACnF,4DAA+F;AA+D/F,MAAa,qBAAsB,SAAQ,+BAAc;IAEnC;IACA;IAFpB,YACoB,IAAoB,EACpB,OAAe,EACjC,MAA6B;QAE7B,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;QAJnB,SAAI,GAAJ,IAAI,CAAgB;QACpB,YAAO,GAAP,OAAO,CAAQ;IAInC,CAAC;CACF;AARD,sDAQC;AAED,MAAa,4BAGX,SAAQ,qBAAqB;IAET;IACT;IACA;IACA;IACA;IALX,YACoB,IAAO,EAChB,WAAe,EACf,mBAA2B,EAC3B,WAAyC,EACz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from '../../../backend/secrettune/module';
2
1
  import { PendleSwapDtoV2, PendleSwapResponse } from '../../../backend/secrettune/PendleV2SDK';
2
+ import { PendleV2Sdk } from '../../../backend/secrettune/module';
3
3
  export type PendleSwapQuoteParams = Omit<PendleSwapDtoV2, 'slippage'> & {
4
4
  slippage?: number;
5
5
  };
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PendleSwapAggregatorHelper = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const module_1 = require("../../../backend/secrettune/module");
6
+ const slippage_1 = require("../../../utils/slippage");
6
7
  const crossChainDeposit_1 = require("../../crossChainDeposit");
7
- const TokenHelper_1 = require("../TokenHelper");
8
8
  const autoSlippage_1 = require("../../crossChainDeposit/helpers/autoSlippage");
9
9
  const AggregatorHelperErrors_1 = require("../AggregatorHelperErrors");
10
- const slippage_1 = require("../../../utils/slippage");
10
+ const TokenHelper_1 = require("../TokenHelper");
11
11
  class PendleSwapAggregatorHelper {
12
12
  pendleV2Sdk;
13
13
  tokenHelper;
@@ -25,7 +25,7 @@ class PendleSwapAggregatorHelper {
25
25
  return { ...data, slippage, minAmountOut };
26
26
  }
27
27
  catch (error) {
28
- throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(crossChainDeposit_1.AggregatorName.PENDLE, error, [500, 502, 503, 504], 'quote', fullReq, () => undefined);
28
+ throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(crossChainDeposit_1.AggregatorName.PENDLE, error, 'quote', fullReq);
29
29
  }
30
30
  }
31
31
  async resolveAutoSlippage(chainId, req) {
@@ -1 +1 @@
1
- {"version":3,"file":"PendleSwapAggregatorHelper.js","sourceRoot":"","sources":["../../../../src/entities/aggregatorHelpers/PendleSwap/PendleSwapAggregatorHelper.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AACnC,+DAA6F;AAG7F,+DAAyD;AACzD,gDAA6C;AAC7C,+EAAqF;AACrF,sEAAoE;AACpE,sDAAwD;AASxD,MAAa,0B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CAAC;QAChC,IAAI,SAAS,IAAI,IAAI;YAAE,OAAO,KAAK,CAAC;QAEpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,OAAkB,EAAE,CAAC,CAAC;QACpF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAE5F,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,KAAK,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC5B,aAAa,GAAG,MAAM,CAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QACjG,CAAC;QAED,OAAO,IAAA,oCAAqB,EAAC;YAC3B,WAAW,EAAE,OAAO;YACpB,SAAS,EAAE,SAAS,CAAC,KAAsB;YAC3C,OAAO,EAAE,GAAG,CAAC,QAAyB;YACtC,aAAa;SACd,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,gEAwCC"}
1
+ {"version":3,"file":"PendleSwapAggregatorHelper.js","sourceRoot":"","sources":["../../../../src/entities/aggregatorHelpers/PendleSwap/PendleSwapAggregatorHelper.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAEnC,+DAA6F;AAE7F,sDAAwD;AACxD,+DAAyD;AACzD,+EAAqF;AACrF,sEAAoE;AACpE,gDAA6C;AAS7C,MAAa,0BAA0B;IAGR;IAFZ,WAAW,CAAc;IAE1C,YAA6B,cAA2B,IAAA,uBAAc,GAAE;QAA3C,gBAAW,GAAX,WAAW,CAAgC;QACtE,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;IACnD,CAA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AAK,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAE5F,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,KAAK,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC5B,aAAa,GAAG,MAAM,CAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QACjG,CAAC;QAED,OAAO,IAAA,oCAAqB,EAAC;YAC3B,WAAW,EAAE,OAAO;YACpB,SAAS,EAAE,SAAS,CAAC,KAAsB;YAC3C,OAAO,EAAE,GAAG,CAAC,QAAyB;YACtC,aAAa;SACd,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,gEAwCC"}
@@ -1 +1,2 @@
1
1
  export * from './PendleSwap/PendleSwapAggregatorHelper';
2
+ export * from './AggregatorHelperErrors';
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./PendleSwap/PendleSwapAggregatorHelper"), exports);
18
+ __exportStar(require("./AggregatorHelperErrors"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/aggregatorHelpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/aggregatorHelpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD;AACxD,2DAAyC"}