@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
@@ -11,7 +11,7 @@ import { DelayedStart, OperationState, PreviewErrorReason, ResumableIntent, Rout
11
11
  import { AccountCalculatorOperation } from "../../sdk/accounts/intents/operations.js";
12
12
  import "../../sdk/index.js";
13
13
  import { Address } from "viem";
14
- //#region src/new-sdk/simulate/types.d.ts
14
+ //#region src/new-sdk/prepare/types.d.ts
15
15
  /**
16
16
  * What a pool deposit or withdrawal would yield.
17
17
  *
@@ -105,8 +105,8 @@ type DelayedStrategySimulate = {
105
105
  };
106
106
  /**
107
107
  * What one of the two flows that sell a position asset —
108
- * {@link OpportunitiesSimulate.withdrawStrategy} and
109
- * {@link OpportunitiesSimulate.adjustLeverage} — would yield each way it can be
108
+ * {@link OpportunitiesPrepare.withdrawStrategy} and
109
+ * {@link OpportunitiesPrepare.adjustLeverage} — would yield each way it can be
110
110
  * served.
111
111
  *
112
112
  * Whether the account can sell that asset on the router, redeem it through its
@@ -126,9 +126,9 @@ type StrategyRoutesSimulate = {
126
126
  }> | undefined;
127
127
  /**
128
128
  * The request half of the redemption route, which
129
- * {@link DelayedSimulate.finish} completes once it matures. `undefined`
130
- * when the route does not exist — no redemption venue for the asset, or a
131
- * request that settles at once anyway — see `refused.delayed`.
129
+ * {@link OpportunitiesPrepare.finalize} completes once it matures.
130
+ * `undefined` when the route does not exist — no redemption venue for the
131
+ * asset, or a request that settles at once anyway — see `refused.delayed`.
132
132
  **/
133
133
  delayed: Extract<DelayedStrategySimulate, {
134
134
  ok: true;
@@ -165,7 +165,7 @@ type OpenStrategySimulate = {
165
165
  /**
166
166
  * Shared knobs. Both default to the SDK's own defaults when omitted.
167
167
  **/
168
- interface SimulateOptions {
168
+ interface PrepareOptions {
169
169
  /** Router slippage in PERCENTAGE_FORMAT (100% = 10_000). */
170
170
  slippage?: number;
171
171
  /**
@@ -189,7 +189,7 @@ type PoolInput = PoolOpportunityKey;
189
189
  * `sdk.opportunities.list()` satisfies this, as does a bare key.
190
190
  **/
191
191
  type StrategyInput = StrategyOpportunityKey;
192
- interface DepositStrategyParams extends SimulateOptions {
192
+ interface DepositStrategyParams extends PrepareOptions {
193
193
  /**
194
194
  * Collateral to add: the market underlying, or its unwrapped asset on an RWA
195
195
  * market (USDC rather than dcUSDC).
@@ -209,11 +209,11 @@ interface DepositStrategyParams extends SimulateOptions {
209
209
  **/
210
210
  targetLeverage?: bigint;
211
211
  }
212
- interface WithdrawStrategyParams extends SimulateOptions {
212
+ interface WithdrawStrategyParams extends PrepareOptions {
213
213
  /**
214
214
  * Amount the wallet receives, denominated in `tokenOut`. `MAX_UINT256`, or
215
215
  * anything at or above the account's net value, turns the flow into an exit,
216
- * see {@link OpportunitiesSimulate.withdrawStrategy}.
216
+ * see {@link OpportunitiesPrepare.withdrawStrategy}.
217
217
  **/
218
218
  amount: bigint;
219
219
  /** Wallet receiving the payout. */
@@ -229,7 +229,7 @@ interface WithdrawStrategyParams extends SimulateOptions {
229
229
  **/
230
230
  sourceToken?: Address;
231
231
  }
232
- interface RepayStrategyParams extends SimulateOptions {
232
+ interface RepayStrategyParams extends PrepareOptions {
233
233
  /**
234
234
  * Funding token: the market underlying, which needs no conversion and is
235
235
  * repaid where it lands, or — on an RWA market — the unwrapped asset behind
@@ -240,14 +240,14 @@ interface RepayStrategyParams extends SimulateOptions {
240
240
  * Amount taken from the wallet. Anything above the outstanding debt settles
241
241
  * it in full and stays on the account as collateral, so a caller clearing the
242
242
  * account can add a buffer for the interest that accrues before the
243
- * transaction lands, see {@link OpportunitiesSimulate.maxRepay}.
243
+ * transaction lands, see {@link OpportunitiesPrepare.maxRepay}.
244
244
  * `MAX_UINT256` settles the debt and sizes that buffer itself.
245
245
  **/
246
246
  amount: bigint;
247
247
  /** Native value to attach when paying a wrapped-native market in the coin. */
248
248
  value?: bigint;
249
249
  }
250
- interface AdjustLeverageParams extends SimulateOptions {
250
+ interface AdjustLeverageParams extends PrepareOptions {
251
251
  /**
252
252
  * Target total leverage scaled by `LEVERAGE_DECIMALS` (300n = 3x); 100n means
253
253
  * no debt.
@@ -259,21 +259,21 @@ interface AdjustLeverageParams extends SimulateOptions {
259
259
  **/
260
260
  token?: Address;
261
261
  }
262
- interface AddCollateralParams extends SimulateOptions {
262
+ interface AddCollateralParams extends PrepareOptions {
263
263
  /** Position token to deposit; nothing else is accepted. */
264
264
  token: Address;
265
265
  amount: bigint;
266
266
  /** Native value to attach when paying a wrapped-native market in the coin. */
267
267
  value?: bigint;
268
268
  }
269
- interface WithdrawCollateralParams extends SimulateOptions {
269
+ interface WithdrawCollateralParams extends PrepareOptions {
270
270
  /** Token to move out; must already sit on the account. */
271
271
  token: Address;
272
272
  amount: bigint;
273
273
  /** Wallet receiving the tokens. */
274
274
  to: Address;
275
275
  }
276
- interface OpenStrategyParams extends SimulateOptions {
276
+ interface OpenStrategyParams extends PrepareOptions {
277
277
  /** Collateral coming from the wallet, in their own tokens. */
278
278
  collateral: Asset[];
279
279
  /**
@@ -312,7 +312,7 @@ interface LpParams {
312
312
  tokenOut?: Address;
313
313
  }
314
314
  /**
315
- * Same shape as {@link LpParams}, but {@link OpportunitiesSimulate.redeem}
315
+ * Same shape as {@link LpParams}, but {@link OpportunitiesPrepare.redeem}
316
316
  * treats `amount` as the pool shares to burn rather than the underlying to
317
317
  * receive.
318
318
  **/
@@ -326,7 +326,7 @@ interface LpRedeemParams {
326
326
  tokenIn?: Address;
327
327
  tokenOut?: Address;
328
328
  }
329
- interface FinishDelayedParams extends SimulateOptions {
329
+ interface FinalizeParams extends PrepareOptions {
330
330
  /**
331
331
  * The matured withdrawal to claim, from
332
332
  * `sdk.onchain.chain(chainId).withdrawalCompressor.getCurrentWithdrawals()`.
@@ -339,44 +339,6 @@ interface FinishDelayedParams extends SimulateOptions {
339
339
  **/
340
340
  intent?: ResumableIntent;
341
341
  }
342
- /**
343
- * The delayed route of the two operations that can take it: a source that only
344
- * redeems through its issuer — a Securitize dsToken, a Mellow share — instead of
345
- * through the router.
346
- *
347
- * Two transactions rather than one: the request, then the tail once the
348
- * redemption matures, which is days later. In between, nothing has to be kept on
349
- * the client — the request writes the operation into the withdrawal's
350
- * `extraData`, and reading the claimable decodes it back.
351
- **/
352
- interface DelayedSimulate {
353
- /**
354
- * The delayed counterpart of {@link OpportunitiesSimulate.withdrawStrategy},
355
- * on its own: that flow already quotes this route alongside the instant one,
356
- * so reach for this when the delayed route is the only one of interest.
357
- *
358
- * Reports `noDelayedRoute` when the account has no redemption venue for the
359
- * source at all.
360
- **/
361
- withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<DelayedStrategySimulate>>;
362
- /**
363
- * The delayed counterpart of {@link OpportunitiesSimulate.adjustLeverage} on
364
- * its own, which only deleveraging reaches: raising leverage buys the position
365
- * token and never redeems it. That flow already quotes this route alongside
366
- * the instant one, so reach for this when it is the only one of interest.
367
- **/
368
- adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<DelayedStrategySimulate>>;
369
- /**
370
- * The tail: claim the matured withdrawal, then whatever the recorded
371
- * operation still owes — repaying debt and paying the wallet out for a
372
- * withdrawal, repaying alone for a deleveraging, nothing beyond the claim for
373
- * the rest.
374
- *
375
- * Answers like the instant flows, so both halves are consumed the same way.
376
- * Reports `noRecordedIntent` when the claim names no operation to resume.
377
- **/
378
- finish(position: PositionInput, params: FinishDelayedParams): Promise<DataResponse<StrategySimulate>>;
379
- }
380
342
  /**
381
343
  * Simulations of everything a wallet can do to a pool or a credit account.
382
344
  *
@@ -387,7 +349,7 @@ interface DelayedSimulate {
387
349
  * Not to be confused with `src/preview/simulate`, which goes the other way: it
388
350
  * takes calldata that already exists and reports what it would do.
389
351
  **/
390
- interface OpportunitiesSimulate {
352
+ interface OpportunitiesPrepare {
391
353
  /**
392
354
  * Depositing into a pool: underlying in, shares out.
393
355
  *
@@ -499,10 +461,22 @@ interface OpportunitiesSimulate {
499
461
  **/
500
462
  withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategySimulate>>;
501
463
  /**
502
- * The same requests routed through a delayed redemption instead of the
503
- * router, and the tail that finishes them, see {@link DelayedSimulate}.
464
+ * The tail of a delayed route: claim the matured withdrawal, then whatever the
465
+ * operation that requested it still owes repaying debt and paying the wallet
466
+ * out for a withdrawal, repaying alone for a deleveraging, nothing beyond the
467
+ * claim for the rest.
468
+ *
469
+ * The route is requested by {@link withdrawStrategy} or
470
+ * {@link adjustLeverage}, whose `delayed` branch is the transaction that
471
+ * starts it; days later the redemption matures and this finishes it. Nothing
472
+ * has to be kept on the client in between: the request writes the operation
473
+ * into the withdrawal's `extraData`, and reading the claimable decodes it
474
+ * back.
475
+ *
476
+ * Answers like the instant flows, so both halves are consumed the same way.
477
+ * Reports `noRecordedIntent` when the claim names no operation to resume.
504
478
  **/
505
- readonly delayed: DelayedSimulate;
479
+ finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategySimulate>>;
506
480
  }
507
481
  //#endregion
508
- export { AddCollateralParams, AdjustLeverageParams, DelayedSimulate, DelayedStrategySimulate, DepositStrategyParams, FinishDelayedParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesSimulate, PoolInput, PositionInput, RepayStrategyParams, SimulateOptions, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams };
482
+ export { AddCollateralParams, AdjustLeverageParams, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesPrepare, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams };
@@ -105,7 +105,7 @@ interface BuildMockSdkArgs {
105
105
  delayed?: Record<Address, MockDelayedVenue[]>;
106
106
  /**
107
107
  * Accounts `accounts.getCreditAccountData` knows, keyed by address. What the
108
- * simulate layer reads on its own instead of taking a slice from the caller;
108
+ * prepare layer reads on its own instead of taking a slice from the caller;
109
109
  * `accountDebt` lands as the principal with no interest or fees accrued.
110
110
  */
111
111
  creditAccounts?: CreditAccountSlice[];
@@ -40,7 +40,7 @@ interface OperationState extends PositionMetrics {
40
40
  *
41
41
  * Every member is thrown by the engine as an {@link IntentPreviewError}, with
42
42
  * the exception of `unsupportedTokenPair` and `noRecordedIntent`, which the
43
- * simulate namespace reports for a request it can refuse before planning: a
43
+ * prepare namespace reports for a request it can refuse before planning: a
44
44
  * route the market does not offer, a claim naming no operation.
45
45
  */
46
46
  type PreviewErrorReason = "debtOutOfRange" | "leverageOutOfRange" | "insufficientSourceBalance" |
@@ -98,8 +98,8 @@ type IntentPreviewResult = {
98
98
  interface DelayedStart {
99
99
  /**
100
100
  * The intent written into the request, and decoded back from the claimable
101
- * withdrawal at claim time. Feed it to
102
- * `CreditAccountOperationsService.finishIntent`.
101
+ * withdrawal at claim time. `prepare.finalize` picks it up from there, and
102
+ * `CreditAccountOperationsService.finishIntent` is what it feeds.
103
103
  */
104
104
  record: DelayedIntent;
105
105
  /** Unix seconds after which the delayed outputs can be claimed. */
@@ -172,16 +172,16 @@ type IntentRoutesResult = {
172
172
  * The intents the engine previews.
173
173
  *
174
174
  * Naming avoids the `withdrawCollateral` collision that exists elsewhere in the
175
- * repo. Mapping to the public simulate API:
175
+ * repo. Mapping to the public prepare API:
176
176
  *
177
- * | Intent type | Public name | Debt |
178
- * | ------------------ | -------------------------- | ------- |
179
- * | `ADD_COLLATERAL` | `simulate.addCollateral` | fixed |
180
- * | `WITHDRAW_ASSET` | `simulate.withdrawCollateral` | fixed |
181
- * | `ADJUST_LEVERAGE` | `simulate.adjustLeverage` | changes |
182
- * | `DEPOSIT` | `simulate.depositStrategy` | grows |
183
- * | `WITHDRAW` | `simulate.withdrawStrategy` | shrinks |
184
- * | `REPAY` | `simulate.repayStrategy` | shrinks |
177
+ * | Intent type | Public name | Debt |
178
+ * | ------------------ | ---------------------------- | ------- |
179
+ * | `ADD_COLLATERAL` | `prepare.addCollateral` | fixed |
180
+ * | `WITHDRAW_ASSET` | `prepare.withdrawCollateral` | fixed |
181
+ * | `ADJUST_LEVERAGE` | `prepare.adjustLeverage` | changes |
182
+ * | `DEPOSIT` | `prepare.depositStrategy` | grows |
183
+ * | `WITHDRAW` | `prepare.withdrawStrategy` | shrinks |
184
+ * | `REPAY` | `prepare.repayStrategy` | shrinks |
185
185
  */
186
186
  /** Shared inputs for every start intent. */
187
187
  type StartIntentProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "15.1.0-next.11",
3
+ "version": "15.1.0-next.13",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,137 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model_opportunities = require("../model/opportunities.js");
3
- require("../model/index.js");
4
- const require_dev_fieldDiff = require("./fieldDiff.js");
5
- //#region src/dev/compareOpportunities.ts
6
- /**
7
- * Matches two opportunity listings by {@link opportunityId} and reports every
8
- * field the two sources disagree on.
9
- *
10
- * Nothing is filtered out. A field only the backend can fill, or a USD value
11
- * that drifted within snapshot-lag noise, is still reported — tagged
12
- * {@link FieldDiff.expected} so that {@link CompareCounts.clean} can ignore it
13
- * while {@link CompareCounts.identical} stays strict.
14
- **/
15
- function compareOpportunities(input) {
16
- const onchainRows = indexById(input.onchain.data);
17
- const offchainRows = indexById(input.offchain.data);
18
- const onlyOnchain = [];
19
- const onlyOffchain = [];
20
- const matched = [];
21
- for (const [id, row] of onchainRows) {
22
- const counterpart = offchainRows.get(id);
23
- if (!counterpart) {
24
- onlyOnchain.push(toRef(row));
25
- continue;
26
- }
27
- const diffs = diffOpportunity(row, counterpart);
28
- matched.push({
29
- id,
30
- kind: row.kind,
31
- chainId: row.chainId,
32
- onchainName: row.name,
33
- offchainName: counterpart.name,
34
- identical: diffs.length === 0,
35
- clean: diffs.every((diff) => diff.expected),
36
- diffs
37
- });
38
- }
39
- for (const [id, row] of offchainRows) if (!onchainRows.has(id)) onlyOffchain.push(toRef(row));
40
- byId(onlyOnchain);
41
- byId(onlyOffchain);
42
- matched.sort((a, b) => a.id.localeCompare(b.id));
43
- return {
44
- generatedAt: input.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
45
- backendUrl: input.backendUrl,
46
- networks: [...input.networks],
47
- onchainChains: input.onchain.meta.chains,
48
- offchainChains: input.offchain.meta.chains,
49
- summary: summarize(input.onchain.data, input.offchain.data, onlyOnchain, onlyOffchain, matched),
50
- onlyOnchain,
51
- onlyOffchain,
52
- matched
53
- };
54
- }
55
- function indexById(rows) {
56
- return new Map(rows.map((row) => [require_model_opportunities.opportunityId(row), row]));
57
- }
58
- function byId(refs) {
59
- refs.sort((a, b) => a.id.localeCompare(b.id));
60
- }
61
- function toRef(row) {
62
- const base = {
63
- id: require_model_opportunities.opportunityId(row),
64
- kind: row.kind,
65
- chainId: row.chainId,
66
- name: row.name
67
- };
68
- return row.kind === "pool" ? {
69
- ...base,
70
- pool: row.pool
71
- } : {
72
- ...base,
73
- creditManager: row.creditManager,
74
- targetCollateral: row.targetCollateral.address
75
- };
76
- }
77
- /**
78
- * Every field two versions of one opportunity disagree on.
79
- **/
80
- function diffOpportunity(onchain, offchain) {
81
- return require_dev_fieldDiff.diffObjects(onchain, offchain).map((diff) => tagDiff(diff, onchain.kind));
82
- }
83
- /**
84
- * Paths whose values are basis-point rates that routinely differ by ±1 from
85
- * truncation vs rounding, plus pool `utilization` for the same reason.
86
- **/
87
- const BPS_RATE_PATHS = /* @__PURE__ */ new Set([
88
- "borrowApy",
89
- "supplyApy.organicApy",
90
- "additionalBorrowApy",
91
- "utilization"
92
- ]);
93
- /**
94
- * Amount fields whose bigint `value` moves with expected-liquidity accrual
95
- * between the backend's last sync and the current block. Strategy
96
- * `totalBorrow.value` and `maxBorrowAmount.value` are not in this set: those
97
- * disagreements are formula bugs, not lag.
98
- **/
99
- const LAG_AMOUNT_PATHS = /* @__PURE__ */ new Set(["totalSupply.value", "availableLiquidity.value"]);
100
- /**
101
- * Fields documented `@mode offchain` in the model: the chain has nothing to
102
- * put there, so a presence (or nested) mismatch is expected. Strategy
103
- * `utilization` is in this set; pool `utilization` is not.
104
- **/
105
- function isModeScoped(path, kind) {
106
- if (path === "curator.url") return true;
107
- if (path === "totalApy" || path.endsWith(".totalApy")) return true;
108
- if (path === "rewards" || path.startsWith("rewards[") || path.includes(".rewards[") || path.endsWith(".rewards")) return true;
109
- if (kind !== "strategy") return false;
110
- return path === "utilization" || path === "collateralApy" || path.startsWith("collateralApy.") || path === "maxLeverageApy" || path.startsWith("maxLeverageApy.") || path === "totalValue" || path.startsWith("totalValue.");
111
- }
112
- function tagDiff(diff, kind) {
113
- if (isModeScoped(diff.path, kind)) return require_dev_fieldDiff.withExpected(diff, "mode-scoped");
114
- if (withinTolerance(diff)) return require_dev_fieldDiff.withExpected(diff, "tolerance");
115
- return diff;
116
- }
117
- function withinTolerance(diff) {
118
- if (diff.kind === "usd") return require_dev_fieldDiff.isUsdWithinTolerance(diff.onchain, diff.offchain);
119
- if (diff.kind !== "numeric") return false;
120
- if (BPS_RATE_PATHS.has(diff.path)) return require_dev_fieldDiff.isBpsWithinTolerance(diff.onchain, diff.offchain);
121
- if (LAG_AMOUNT_PATHS.has(diff.path)) return require_dev_fieldDiff.isAmountWithinTolerance(diff.onchain, diff.offchain);
122
- return false;
123
- }
124
- function summarize(onchain, offchain, onlyOnchain, onlyOffchain, matched) {
125
- const byChain = require_dev_fieldDiff.union(onchain.map((row) => String(row.chainId)), offchain.map((row) => String(row.chainId))).map((chainId) => ({
126
- chainId: Number(chainId),
127
- ...require_dev_fieldDiff.toCompareCounts(onchain.filter((row) => String(row.chainId) === chainId).length, offchain.filter((row) => String(row.chainId) === chainId).length, onlyOnchain.filter((ref) => String(ref.chainId) === chainId).length, onlyOffchain.filter((ref) => String(ref.chainId) === chainId).length, matched.filter((match) => String(match.chainId) === chainId))
128
- })).sort((a, b) => a.chainId - b.chainId);
129
- return {
130
- ...require_dev_fieldDiff.toCompareCounts(onchain.length, offchain.length, onlyOnchain.length, onlyOffchain.length, matched),
131
- byChain,
132
- diffsByPath: require_dev_fieldDiff.countPaths(matched.flatMap((match) => match.diffs))
133
- };
134
- }
135
- //#endregion
136
- exports.compareOpportunities = compareOpportunities;
137
- exports.diffOpportunity = diffOpportunity;
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_new_sdk_simulate_SimulateApi = require("./SimulateApi.js");
3
- require("./types.js");
4
- exports.SimulateApi = require_new_sdk_simulate_SimulateApi.SimulateApi;
@@ -1,3 +0,0 @@
1
- import { SimulateApi } from "./SimulateApi.js";
2
- import "./types.js";
3
- export { SimulateApi };
@@ -1,3 +0,0 @@
1
- import { AddCollateralParams, AdjustLeverageParams, DelayedSimulate, DelayedStrategySimulate, DepositStrategyParams, FinishDelayedParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesSimulate, PoolInput, PositionInput, RepayStrategyParams, SimulateOptions, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
2
- import { ChainOf, SimulateApi } from "./SimulateApi.js";
3
- export { AddCollateralParams, AdjustLeverageParams, ChainOf, DelayedSimulate, DelayedStrategySimulate, DepositStrategyParams, FinishDelayedParams, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, OpportunitiesSimulate, PoolInput, PositionInput, RepayStrategyParams, SimulateApi, SimulateOptions, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams };
File without changes
File without changes