@gearbox-protocol/sdk 15.1.0-next.11 → 15.1.0-next.13

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 (53) hide show
  1. package/dist/cjs/dev/mode-parity/compareOpportunities.js +105 -0
  2. package/dist/cjs/dev/{comparePositions.js → mode-parity/comparePositions.js} +23 -46
  3. package/dist/cjs/dev/mode-parity/compareRules.js +93 -0
  4. package/dist/cjs/dev/{fieldDiff.js → mode-parity/fieldDiff.js} +49 -2
  5. package/dist/cjs/dev/mode-parity/scriptUtils.js +131 -0
  6. package/dist/cjs/model/compare.schema.js +33 -0
  7. package/dist/cjs/model/curators.schema.js +2 -1
  8. package/dist/cjs/model/index.js +5 -0
  9. package/dist/cjs/model/opportunities.schema.js +13 -12
  10. package/dist/cjs/model/positions.schema.js +15 -14
  11. package/dist/cjs/model/primitives.schema.js +2 -1
  12. package/dist/cjs/new-sdk/index.js +3 -3
  13. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +8 -8
  14. package/dist/cjs/new-sdk/{simulate/SimulateApi.js → prepare/PrepareApi.js} +21 -49
  15. package/dist/cjs/new-sdk/prepare/index.js +4 -0
  16. package/dist/esm/dev/{compareOpportunities.js → mode-parity/compareOpportunities.js} +14 -46
  17. package/dist/esm/dev/{comparePositions.js → mode-parity/comparePositions.js} +16 -39
  18. package/dist/esm/dev/mode-parity/compareRules.js +91 -0
  19. package/dist/esm/dev/{fieldDiff.js → mode-parity/fieldDiff.js} +49 -3
  20. package/dist/esm/dev/mode-parity/scriptUtils.js +121 -0
  21. package/dist/esm/model/compare.schema.js +29 -0
  22. package/dist/esm/model/curators.schema.js +2 -1
  23. package/dist/esm/model/index.js +2 -1
  24. package/dist/esm/model/opportunities.schema.js +13 -12
  25. package/dist/esm/model/positions.schema.js +15 -14
  26. package/dist/esm/model/primitives.schema.js +2 -1
  27. package/dist/esm/new-sdk/index.js +3 -3
  28. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +8 -8
  29. package/dist/esm/new-sdk/{simulate/SimulateApi.js → prepare/PrepareApi.js} +21 -49
  30. package/dist/esm/new-sdk/prepare/index.js +3 -0
  31. package/dist/types/dev/{compareOpportunities.d.ts → mode-parity/compareOpportunities.d.ts} +5 -5
  32. package/dist/types/dev/{comparePositions.d.ts → mode-parity/comparePositions.d.ts} +5 -5
  33. package/dist/types/dev/mode-parity/compareRules.d.ts +33 -0
  34. package/dist/types/dev/{fieldDiff.d.ts → mode-parity/fieldDiff.d.ts} +47 -5
  35. package/dist/types/dev/mode-parity/scriptUtils.d.ts +47 -0
  36. package/dist/types/model/compare.schema.d.ts +47 -0
  37. package/dist/types/model/index.d.ts +2 -1
  38. package/dist/types/new-sdk/execute/ExecuteApi.d.ts +9 -9
  39. package/dist/types/new-sdk/index.d.ts +4 -4
  40. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +4 -4
  41. package/dist/types/new-sdk/opportunities/types.d.ts +5 -5
  42. package/dist/types/new-sdk/{simulate/SimulateApi.d.ts → prepare/PrepareApi.d.ts} +19 -19
  43. package/dist/types/new-sdk/prepare/index.d.ts +3 -0
  44. package/dist/types/new-sdk/{simulate → prepare}/types.d.ts +35 -61
  45. package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +1 -1
  46. package/dist/types/sdk/accounts/intents/types.d.ts +12 -12
  47. package/package.json +1 -1
  48. package/dist/cjs/dev/compareOpportunities.js +0 -137
  49. package/dist/cjs/new-sdk/simulate/index.js +0 -4
  50. package/dist/esm/new-sdk/simulate/index.js +0 -3
  51. package/dist/types/new-sdk/simulate/index.d.ts +0 -3
  52. /package/dist/cjs/new-sdk/{simulate → prepare}/types.js +0 -0
  53. /package/dist/esm/new-sdk/{simulate → prepare}/types.js +0 -0
@@ -1,6 +1,6 @@
1
- import { ChainId } from "../model/primitives.js";
2
- import "../model/index.js";
3
- //#region src/dev/fieldDiff.d.ts
1
+ import { ChainId } from "../../model/primitives.js";
2
+ import "../../model/index.js";
3
+ //#region src/dev/mode-parity/fieldDiff.d.ts
4
4
  /**
5
5
  * What kind of disagreement a {@link FieldDiff} describes, so that a reader can
6
6
  * bucket the report without re-deriving it from the values.
@@ -45,6 +45,33 @@ interface FieldDiff {
45
45
  expected?: true;
46
46
  reason?: ExpectedDiffReason;
47
47
  }
48
+ /**
49
+ * The largest numeric disagreement seen for one collapsed field path, on
50
+ * either the unexpected or the expected side.
51
+ **/
52
+ interface WorstDiff {
53
+ /**
54
+ * Entity id (position/opportunity id) with the biggest relative difference.
55
+ **/
56
+ id: string;
57
+ /**
58
+ * Uncollapsed path, so the exact array element is named.
59
+ **/
60
+ path: string;
61
+ /**
62
+ * Relative difference in bps.
63
+ **/
64
+ bps: number;
65
+ onchain: unknown;
66
+ offchain: unknown;
67
+ }
68
+ /**
69
+ * One field disagreement together with the matched row it belongs to.
70
+ **/
71
+ interface EntityFieldDiff {
72
+ id: string;
73
+ diff: FieldDiff;
74
+ }
48
75
  /**
49
76
  * How often one field disagreed across all matched rows, with array keys
50
77
  * collapsed, e.g. `collateralTokens[].symbol`.
@@ -55,6 +82,15 @@ interface DiffPathCount {
55
82
  count: number;
56
83
  expected: number;
57
84
  unexpected: number;
85
+ /**
86
+ * Largest unexpected numeric disagreement, when any unexpected diff of this
87
+ * path yields a relative bps value.
88
+ **/
89
+ worstUnexpected?: WorstDiff;
90
+ /**
91
+ * Largest expected numeric disagreement, see {@link worstUnexpected}.
92
+ **/
93
+ worstExpected?: WorstDiff;
58
94
  }
59
95
  /**
60
96
  * Counts of one chain, one wallet, or of the whole report when those ids are
@@ -127,7 +163,7 @@ declare function withExpected(diff: FieldDiff, reason: ExpectedDiffReason): Fiel
127
163
  * field of a hundred collateral tokens counts as one path. Sorted so the
128
164
  * unexpected disagreements come first.
129
165
  **/
130
- declare function countPaths(diffs: Iterable<FieldDiff>): DiffPathCount[];
166
+ declare function countPaths(diffs: Iterable<EntityFieldDiff>): DiffPathCount[];
131
167
  /**
132
168
  * Collapse `collateralTokens[0xa0b8...].symbol` to `collateralTokens[].symbol`.
133
169
  **/
@@ -161,7 +197,13 @@ declare function withinRelative(onchain: number | undefined, offchain: number |
161
197
  **/
162
198
  declare function withinRelativeBigint(onchain: bigint, offchain: bigint, epsilon: number): boolean;
163
199
  declare function asFiniteNumber(value: unknown): number | undefined;
200
+ /**
201
+ * Relative difference of two numbers or bigints, in bps:
202
+ * `|a − b| / max(|a|, |b|) * 10_000`. `undefined` when the values are not
203
+ * a comparable pair of finite numbers or of bigints.
204
+ **/
205
+ declare function relativeDiffBps(onchain: unknown, offchain: unknown): number | undefined;
164
206
  declare function union(left: string[], right: string[]): string[];
165
207
  declare function isRecord(value: unknown): value is Record<string, unknown>;
166
208
  //#endregion
167
- export { AMOUNT_RELATIVE_EPSILON, ArrayElementKey, BPS_ABSOLUTE_EPSILON, ChainCompareCounts, CompareCounts, DiffKind, DiffOptions, DiffPathCount, ExpectedDiffReason, FieldDiff, USD_RELATIVE_EPSILON, asFiniteNumber, collapseArrayKeys, countPaths, diffObjects, diffValue, isAmountWithinTolerance, isBpsWithinTolerance, isRecord, isUsdWithinTolerance, toCompareCounts, union, withExpected, withinRelative, withinRelativeBigint };
209
+ export { AMOUNT_RELATIVE_EPSILON, ArrayElementKey, BPS_ABSOLUTE_EPSILON, ChainCompareCounts, CompareCounts, DiffKind, DiffOptions, DiffPathCount, EntityFieldDiff, ExpectedDiffReason, FieldDiff, USD_RELATIVE_EPSILON, WorstDiff, asFiniteNumber, collapseArrayKeys, countPaths, diffObjects, diffValue, isAmountWithinTolerance, isBpsWithinTolerance, isRecord, isUsdWithinTolerance, relativeDiffBps, toCompareCounts, union, withExpected, withinRelative, withinRelativeBigint };
@@ -0,0 +1,47 @@
1
+ import { ChainMetadata } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ import { ChainCompareCounts, CompareCounts, DiffPathCount } from "./fieldDiff.js";
4
+ import { Logger } from "pino";
5
+ //#region src/dev/mode-parity/scriptUtils.d.ts
6
+ /**
7
+ * Chains the compare scripts attach to.
8
+ **/
9
+ type ComparedNetwork = "Mainnet" | "Monad" | "Plasma" | "Somnia" | "Etherlink";
10
+ declare const NETWORKS: ComparedNetwork[];
11
+ declare const BACKEND_URL: string;
12
+ declare const TIMEOUT = 480000;
13
+ /**
14
+ * Totals both compare reports print.
15
+ **/
16
+ interface PrintableCompareSummary extends CompareCounts {
17
+ byChain: ChainCompareCounts[];
18
+ diffsByPath: DiffPathCount[];
19
+ }
20
+ /**
21
+ * Per-source chain metadata both compare reports carry.
22
+ **/
23
+ interface PrintableCompareReport {
24
+ backendUrl: string;
25
+ summary: PrintableCompareSummary;
26
+ onchainChains: ChainMetadata[];
27
+ offchainChains: ChainMetadata[];
28
+ }
29
+ declare function requireEnv(name: string): string;
30
+ declare function rpcUrls(): Record<ComparedNetwork, string>;
31
+ declare function createLogger(): Logger;
32
+ declare function errorMessage(error: unknown): string;
33
+ /**
34
+ * Runs `fn` over `items` with at most `concurrency` in flight.
35
+ **/
36
+ declare function mapPool<T>(items: readonly T[], concurrency: number, fn: (item: T) => Promise<void>): Promise<void>;
37
+ /**
38
+ * Formats a relative difference in bps as a percent, e.g. 12.5 → `"0.125%"`.
39
+ **/
40
+ declare function formatBpsAsPercent(bps: number): string;
41
+ /**
42
+ * Prints the shared membership table, the fields that differed most often,
43
+ * and any chain that failed to answer.
44
+ **/
45
+ declare function printCompareSummary(noun: string, report: PrintableCompareReport, extraLines?: string[]): void;
46
+ //#endregion
47
+ export { BACKEND_URL, ComparedNetwork, NETWORKS, PrintableCompareReport, PrintableCompareSummary, TIMEOUT, createLogger, errorMessage, formatBpsAsPercent, mapPool, printCompareSummary, requireEnv, rpcUrls };
@@ -0,0 +1,47 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/model/compare.schema.d.ts
3
+ /**
4
+ * How close two numeric values may be before a disagreement counts as real.
5
+ *
6
+ * The compare scripts pick a formula from this union; the schemas only name
7
+ * which formula a field uses.
8
+ *
9
+ * - `"amount"` — accrual lag on an {@link Amount.value} / {@link TokenAmount.value}.
10
+ * - `"bps"` — truncation vs rounding on a basis-point rate, ±1.
11
+ * - `"float"` — relative float drift within 0.1% (leverage).
12
+ * - `"usd"` — price-derived {@link Amount.valueUsd} / {@link TokenAmount.valueUsd}.
13
+ **/
14
+ type CompareTolerance = "amount" | "bps" | "float" | "usd";
15
+ /**
16
+ * A numeric field whose two sources may drift within {@link tolerance}.
17
+ **/
18
+ interface ToleranceCompareTag {
19
+ tolerance: CompareTolerance;
20
+ }
21
+ /**
22
+ * Compare metadata a schema field may carry.
23
+ *
24
+ * - `"offchainOnly"` / `"onchainOnly"` — the other source typically leaves
25
+ * the field empty, so a disagreement is expected.
26
+ * - {@link ToleranceCompareTag} — a numeric disagreement within the named
27
+ * formula is expected snapshot noise.
28
+ **/
29
+ type CompareTag = "offchainOnly" | "onchainOnly" | ToleranceCompareTag;
30
+ /**
31
+ * Marks a field that only the backend fills.
32
+ **/
33
+ declare function offchainOnly<S extends z.ZodType>(schema: S): S;
34
+ /**
35
+ * Marks a field that only the chain fills.
36
+ **/
37
+ declare function onchainOnly<S extends z.ZodType>(schema: S): S;
38
+ /**
39
+ * Marks a numeric field whose two sources may drift within {@link kind}.
40
+ **/
41
+ declare function tolerance<S extends z.ZodType>(schema: S, kind: CompareTolerance): S;
42
+ /**
43
+ * The compare tag registered on a schema, if any.
44
+ **/
45
+ declare function compareTagOf(schema: z.ZodType): CompareTag | undefined;
46
+ //#endregion
47
+ export { CompareTag, CompareTolerance, ToleranceCompareTag, compareTagOf, offchainOnly, onchainOnly, tolerance };
@@ -2,6 +2,7 @@ import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmoun
2
2
  import { Curator, CuratorName } from "./curators.js";
3
3
  import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric } from "./charts.js";
4
4
  import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
5
+ import { CompareTag, CompareTolerance, ToleranceCompareTag, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
5
6
  import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
6
7
  import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
7
8
  import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
@@ -16,4 +17,4 @@ import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema,
16
17
  import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
17
18
  import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
18
19
  import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
19
- export { Amount, ApyBreakdown, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, Curator, CuratorName, DataResponse, DataSource, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionMetrics, PositionTransaction, PositionTransactionKind, PositionsTotals, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, ResponseMetadata, Rewards, RewardsPnL, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
20
+ export { Amount, ApyBreakdown, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, Curator, CuratorName, DataResponse, DataSource, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionMetrics, PositionTransaction, PositionTransactionKind, PositionsTotals, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, ResponseMetadata, Rewards, RewardsPnL, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema };
@@ -4,15 +4,15 @@ import "../../model/index.js";
4
4
  import { SecuritizeRegisterMessage } from "../../sdk/market/rwa/securitize/types.js";
5
5
  import { RawTx } from "../../sdk/types/transactions.js";
6
6
  import "../../sdk/index.js";
7
- import { LpSimulate, OpenStrategySimulate, StrategySimulate } from "../simulate/types.js";
8
- import { ChainOf } from "../simulate/SimulateApi.js";
9
- import "../simulate/index.js";
7
+ import { LpSimulate, OpenStrategySimulate, StrategySimulate } from "../prepare/types.js";
8
+ import { ChainOf } from "../prepare/PrepareApi.js";
9
+ import "../prepare/index.js";
10
10
  import { Address } from "viem";
11
11
  //#region src/new-sdk/execute/ExecuteApi.d.ts
12
12
  /**
13
13
  * A pool deposit, withdrawal or redemption, as
14
- * {@link OpportunitiesSimulate.deposit} / {@link OpportunitiesSimulate.withdraw}
15
- * / {@link OpportunitiesSimulate.redeem} priced it. The simulation carries the
14
+ * {@link OpportunitiesPrepare.deposit} / {@link OpportunitiesPrepare.withdraw}
15
+ * / {@link OpportunitiesPrepare.redeem} priced it. The simulation carries the
16
16
  * tokens on both sides and the zapper, so nothing else is needed to encode
17
17
  * the call.
18
18
  **/
@@ -28,7 +28,7 @@ interface PoolPrepareRequest {
28
28
  }
29
29
  /**
30
30
  * Opening a new position, from a viable
31
- * {@link OpportunitiesSimulate.openNewStrategy} result. The preview values
31
+ * {@link OpportunitiesPrepare.openNewStrategy} result. The preview values
32
32
  * collateral in underlying only, so the wallet's actual collateral assets and
33
33
  * the native value to attach come from the caller.
34
34
  **/
@@ -70,19 +70,19 @@ interface AccountPrepareRequest {
70
70
  }
71
71
  /**
72
72
  * What {@link OpportunitiesExecute.buildTx} turns into a transaction: a
73
- * simulate result plus the few facts about the wallet the simulation does not
73
+ * `prepare` result plus the few facts about the wallet the simulation does not
74
74
  * carry.
75
75
  **/
76
76
  type PrepareRequest = PoolPrepareRequest | OpenPrepareRequest | AccountPrepareRequest;
77
77
  /**
78
- * The write side of the opportunities namespace: turns what `simulate`
78
+ * The write side of the opportunities namespace: turns what `prepare`
79
79
  * answered into the transaction to sign. Sending, and whatever the wallet has
80
80
  * to do first (allowances, permits, RWA signatures), stays with the caller —
81
81
  * `checkPrerequisites` reports the former on the built transaction.
82
82
  **/
83
83
  interface OpportunitiesExecute {
84
84
  /**
85
- * The transaction to sign, from a simulate result. No second round of math:
85
+ * The transaction to sign, from a `prepare` result. No second round of math:
86
86
  * `account` requests submit the simulation's own multicall, `open` requests
87
87
  * hand the preview's router path and quotas to `openCA`, `pool` requests
88
88
  * encode the deposit / redeem the simulation priced.
@@ -4,9 +4,9 @@ import { filterResponse } from "./utils/filterResponse.js";
4
4
  import { DEFAULT_MAX_OFFCHAIN_LAG, mergeChainList, mergeChainOne } from "./utils/mergeChains.js";
5
5
  import "./utils/index.js";
6
6
  import { AbstractNamespace, MergedQuery } from "./AbstractNamespace.js";
7
- import { AddCollateralParams, AdjustLeverageParams, DelayedSimulate, DelayedStrategySimulate, DepositStrategyParams, FinishDelayedParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesSimulate, PoolInput, PositionInput, RepayStrategyParams, SimulateOptions, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./simulate/types.js";
8
- import { ChainOf, SimulateApi } from "./simulate/SimulateApi.js";
9
- import "./simulate/index.js";
7
+ import { AddCollateralParams, AdjustLeverageParams, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesPrepare, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
8
+ import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
9
+ import "./prepare/index.js";
10
10
  import { AccountPrepareRequest, ExecuteApi, OpenPrepareRequest, OpportunitiesExecute, PoolPrepareRequest, PrepareRequest } from "./execute/ExecuteApi.js";
11
11
  import "./execute/index.js";
12
12
  import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers } from "./opportunities/types.js";
@@ -24,4 +24,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
24
24
  import { assertSameChains } from "./errors/assertSameChains.js";
25
25
  import { everyChainFailed } from "./errors/everyChainFailed.js";
26
26
  import "./errors/index.js";
27
- export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedSimulate, DelayedStrategySimulate, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinishDelayedParams, GearboxSDK, GearboxSDKOptions, type ListMerger, LpParams, LpRedeemParams, LpSimulate, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, NoticesByMode, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategySimulate, Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesExecute, OpportunitiesMerged, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunitiesSimulate, OpportunityMergers, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly, PrepareRequest, RepayStrategyParams, SimulateApi, SimulateOptions, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
27
+ export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategySimulate, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, GearboxSDK, GearboxSDKOptions, type ListMerger, LpParams, LpRedeemParams, LpSimulate, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, NoticesByMode, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategySimulate, Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesExecute, OpportunitiesMerged, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunitiesPrepare, OpportunityMergers, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly, PrepareApi, PrepareOptions, PrepareRequest, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
@@ -10,8 +10,8 @@ import { NamespaceOptions } from "../types.js";
10
10
  import { FilterResult } from "../utils/types.js";
11
11
  import "../utils/index.js";
12
12
  import { AbstractNamespace } from "../AbstractNamespace.js";
13
- import { OpportunitiesSimulate } from "../simulate/types.js";
14
- import "../simulate/index.js";
13
+ import { OpportunitiesPrepare } from "../prepare/types.js";
14
+ import "../prepare/index.js";
15
15
  import { OpportunitiesExecute } from "../execute/ExecuteApi.js";
16
16
  import "../execute/index.js";
17
17
  import { OpportunitiesBase, OpportunitiesOffchainOnly, OpportunitiesOnchainOnly, OpportunityMergers } from "./types.js";
@@ -28,9 +28,9 @@ declare class OpportunitiesNamespace extends AbstractNamespace<MultichainSDK["op
28
28
  readonly merge: OpportunityMergers;
29
29
  constructor(onchain: MultichainSDK | undefined, offchain: GearboxAPI | undefined, options: NamespaceOptions);
30
30
  /**
31
- * {@inheritDoc OpportunitiesOnchainOnly.simulate}
31
+ * {@inheritDoc OpportunitiesOnchainOnly.prepare}
32
32
  **/
33
- get simulate(): OpportunitiesSimulate;
33
+ get prepare(): OpportunitiesPrepare;
34
34
  /**
35
35
  * {@inheritDoc OpportunitiesOnchainOnly.execute}
36
36
  **/
@@ -9,8 +9,8 @@ import "../../offchain/index.js";
9
9
  import { Mode } from "../types.js";
10
10
  import { EntityMerger, FilterResult, ListMerger } from "../utils/types.js";
11
11
  import "../utils/index.js";
12
- import { OpportunitiesSimulate } from "../simulate/types.js";
13
- import "../simulate/index.js";
12
+ import { OpportunitiesPrepare } from "../prepare/types.js";
13
+ import "../prepare/index.js";
14
14
  import { OpportunitiesExecute } from "../execute/ExecuteApi.js";
15
15
  import "../execute/index.js";
16
16
  //#region src/new-sdk/opportunities/types.d.ts
@@ -80,11 +80,11 @@ interface OpportunitiesOnchainOnly {
80
80
  * state, and the strategy flows additionally need the pathfinder for real swap
81
81
  * paths, so there is nothing the backend could answer with.
82
82
  **/
83
- readonly simulate: OpportunitiesSimulate;
83
+ readonly prepare: OpportunitiesPrepare;
84
84
  /**
85
- * The transaction a simulate result stands for, see
85
+ * The transaction a prepared operation stands for, see
86
86
  * {@link OpportunitiesExecute.buildTx}. Absent in `offchain` mode for the
87
- * same reason as {@link simulate}: it encodes against live chain state.
87
+ * same reason as {@link prepare}: it encodes against live chain state.
88
88
  **/
89
89
  execute: OpportunitiesExecute;
90
90
  }
@@ -6,8 +6,8 @@ import { MultichainSDK } from "../../sdk/MultichainSDK.js";
6
6
  import { ChainQueryOneProps, MultichainConstruct } from "../../sdk/base/MultichainConstruct.js";
7
7
  import "../../sdk/index.js";
8
8
  import { EnsureFreshChains } from "../types.js";
9
- import { AddCollateralParams, AdjustLeverageParams, DelayedSimulate, DepositStrategyParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesSimulate, PoolInput, PositionInput, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
10
- //#region src/new-sdk/simulate/SimulateApi.d.ts
9
+ import { AddCollateralParams, AdjustLeverageParams, DepositStrategyParams, FinalizeParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesPrepare, PoolInput, PositionInput, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
10
+ //#region src/new-sdk/prepare/PrepareApi.d.ts
11
11
  /**
12
12
  * The chain's SDK, resolved on the spot.
13
13
  *
@@ -17,7 +17,7 @@ import { AddCollateralParams, AdjustLeverageParams, DelayedSimulate, DepositStra
17
17
  **/
18
18
  type ChainOf = (chainId: ChainId) => OnchainSDK;
19
19
  /**
20
- * {@inheritDoc OpportunitiesSimulate}
20
+ * {@inheritDoc OpportunitiesPrepare}
21
21
  *
22
22
  * Holds no state of its own: it owns the mapping from the public,
23
23
  * read-model-shaped request to the engine's intent, and nothing else. All
@@ -29,62 +29,62 @@ type ChainOf = (chainId: ChainId) => OnchainSDK;
29
29
  * to, hence a chain the SDK does not cover, or one that fails the read, throws
30
30
  * rather than answering with empty metadata.
31
31
  **/
32
- declare class SimulateApi extends MultichainConstruct implements OpportunitiesSimulate {
32
+ declare class PrepareApi extends MultichainConstruct implements OpportunitiesPrepare {
33
33
  #private;
34
34
  constructor(sdk: MultichainSDK, ensureFresh?: EnsureFreshChains);
35
35
  protected queryChain<T>(props: ChainQueryOneProps<T>): Promise<DataResponse<T>>;
36
36
  /**
37
- * {@inheritDoc OpportunitiesSimulate.delayed}
37
+ * {@inheritDoc OpportunitiesPrepare.finalize}
38
38
  **/
39
- readonly delayed: DelayedSimulate;
39
+ finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategySimulate>>;
40
40
  /**
41
- * {@inheritDoc OpportunitiesSimulate.deposit}
41
+ * {@inheritDoc OpportunitiesPrepare.deposit}
42
42
  **/
43
43
  deposit(pool: PoolInput, params: LpParams): LpSimulate;
44
44
  /**
45
- * {@inheritDoc OpportunitiesSimulate.withdraw}
45
+ * {@inheritDoc OpportunitiesPrepare.withdraw}
46
46
  **/
47
47
  withdraw(pool: PoolInput, params: LpParams): LpSimulate;
48
48
  /**
49
- * {@inheritDoc OpportunitiesSimulate.redeem}
49
+ * {@inheritDoc OpportunitiesPrepare.redeem}
50
50
  **/
51
51
  redeem(pool: PoolInput, params: LpRedeemParams): LpSimulate;
52
52
  /**
53
- * {@inheritDoc OpportunitiesSimulate.openNewStrategy}
53
+ * {@inheritDoc OpportunitiesPrepare.openNewStrategy}
54
54
  **/
55
55
  openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategySimulate>>;
56
56
  /**
57
- * {@inheritDoc OpportunitiesSimulate.depositStrategy}
57
+ * {@inheritDoc OpportunitiesPrepare.depositStrategy}
58
58
  **/
59
59
  depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategySimulate>>;
60
60
  /**
61
- * {@inheritDoc OpportunitiesSimulate.withdrawStrategy}
61
+ * {@inheritDoc OpportunitiesPrepare.withdrawStrategy}
62
62
  **/
63
63
  withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesSimulate>>;
64
64
  /**
65
- * {@inheritDoc OpportunitiesSimulate.maxWithdraw}
65
+ * {@inheritDoc OpportunitiesPrepare.maxWithdraw}
66
66
  **/
67
67
  maxWithdraw(position: PositionInput): Promise<DataResponse<bigint>>;
68
68
  /**
69
- * {@inheritDoc OpportunitiesSimulate.repayStrategy}
69
+ * {@inheritDoc OpportunitiesPrepare.repayStrategy}
70
70
  **/
71
71
  repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategySimulate>>;
72
72
  /**
73
- * {@inheritDoc OpportunitiesSimulate.maxRepay}
73
+ * {@inheritDoc OpportunitiesPrepare.maxRepay}
74
74
  **/
75
75
  maxRepay(position: PositionInput): Promise<DataResponse<bigint>>;
76
76
  /**
77
- * {@inheritDoc OpportunitiesSimulate.adjustLeverage}
77
+ * {@inheritDoc OpportunitiesPrepare.adjustLeverage}
78
78
  **/
79
79
  adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesSimulate>>;
80
80
  /**
81
- * {@inheritDoc OpportunitiesSimulate.addCollateral}
81
+ * {@inheritDoc OpportunitiesPrepare.addCollateral}
82
82
  **/
83
83
  addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategySimulate>>;
84
84
  /**
85
- * {@inheritDoc OpportunitiesSimulate.withdrawCollateral}
85
+ * {@inheritDoc OpportunitiesPrepare.withdrawCollateral}
86
86
  **/
87
87
  withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategySimulate>>;
88
88
  }
89
89
  //#endregion
90
- export { ChainOf, SimulateApi };
90
+ export { ChainOf, PrepareApi };
@@ -0,0 +1,3 @@
1
+ import { AddCollateralParams, AdjustLeverageParams, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesPrepare, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
2
+ import { ChainOf, PrepareApi } from "./PrepareApi.js";
3
+ export { AddCollateralParams, AdjustLeverageParams, ChainOf, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesPrepare, PoolInput, PositionInput, PrepareApi, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams };