@gearbox-protocol/sdk 16.0.0-next.30 → 16.0.0-next.32

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 (45) hide show
  1. package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +1 -1
  2. package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +1 -1
  3. package/dist/cjs/preview/index.js +6 -6
  4. package/dist/cjs/preview/preview/{buildDelayedStrategyVerify.js → buildDelayedStrategyPositionOperationPreview.js} +3 -3
  5. package/dist/cjs/preview/preview/index.js +6 -6
  6. package/dist/cjs/preview/preview/{previewAdjustStrategyVerify.js → previewAdjustStrategyPosition.js} +3 -3
  7. package/dist/cjs/preview/preview/{previewExitOrRepayStrategyVerify.js → previewExitOrRepayStrategyPosition.js} +3 -3
  8. package/dist/cjs/preview/preview/{previewOpenStrategyVerify.js → previewOpenStrategyPosition.js} +3 -3
  9. package/dist/cjs/preview/preview/previewOperation.js +10 -10
  10. package/dist/cjs/preview/preview/{previewLpVerify.js → previewPoolPositionOperation.js} +3 -3
  11. package/dist/cjs/sdk/execute/ExecuteApi.js +3 -3
  12. package/dist/cjs/sdk/prepare/PrepareApi.js +1 -1
  13. package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +1 -1
  14. package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +1 -1
  15. package/dist/esm/preview/index.js +4 -4
  16. package/dist/esm/preview/preview/{buildDelayedStrategyVerify.js → buildDelayedStrategyPositionOperationPreview.js} +3 -3
  17. package/dist/esm/preview/preview/index.js +4 -4
  18. package/dist/esm/preview/preview/{previewAdjustStrategyVerify.js → previewAdjustStrategyPosition.js} +3 -3
  19. package/dist/esm/preview/preview/{previewExitOrRepayStrategyVerify.js → previewExitOrRepayStrategyPosition.js} +3 -3
  20. package/dist/esm/preview/preview/{previewOpenStrategyVerify.js → previewOpenStrategyPosition.js} +3 -3
  21. package/dist/esm/preview/preview/previewOperation.js +10 -10
  22. package/dist/esm/preview/preview/{previewLpVerify.js → previewPoolPositionOperation.js} +3 -3
  23. package/dist/esm/sdk/execute/ExecuteApi.js +3 -3
  24. package/dist/esm/sdk/prepare/PrepareApi.js +1 -1
  25. package/dist/types/model/index.d.ts +2 -2
  26. package/dist/types/model/previews.d.ts +13 -13
  27. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +2 -2
  28. package/dist/types/onchain/accounts/intents/types.d.ts +4 -4
  29. package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +1 -1
  30. package/dist/types/preview/index.d.ts +4 -4
  31. package/dist/types/preview/preview/{buildDelayedStrategyVerify.d.ts → buildDelayedStrategyPositionOperationPreview.d.ts} +4 -4
  32. package/dist/types/preview/preview/index.d.ts +4 -4
  33. package/dist/types/preview/preview/{previewAdjustStrategyVerify.d.ts → previewAdjustStrategyPosition.d.ts} +4 -4
  34. package/dist/types/preview/preview/{previewExitOrRepayStrategyVerify.d.ts → previewExitOrRepayStrategyPosition.d.ts} +4 -4
  35. package/dist/types/preview/preview/previewOpenStrategyPosition.d.ts +12 -0
  36. package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +11 -0
  37. package/dist/types/sdk/execute/types.d.ts +13 -13
  38. package/dist/types/sdk/index.d.ts +2 -2
  39. package/dist/types/sdk/opportunities/types.d.ts +2 -1
  40. package/dist/types/sdk/prepare/PrepareApi.d.ts +14 -14
  41. package/dist/types/sdk/prepare/index.d.ts +2 -2
  42. package/dist/types/sdk/prepare/types.d.ts +41 -41
  43. package/package.json +1 -1
  44. package/dist/types/preview/preview/previewLpVerify.d.ts +0 -11
  45. package/dist/types/preview/preview/previewOpenStrategyVerify.d.ts +0 -12
@@ -18,17 +18,17 @@ import { Address } from "viem";
18
18
  /**
19
19
  * What a pool deposit or withdrawal would yield.
20
20
  *
21
- * Shaped like {@link StrategySimulate} so both kinds of simulation are consumed
22
- * the same way, with the pool's own numbers as the state: the ERC-4626
21
+ * Shaped like {@link StrategyPrepare} so both kinds of result are consumed the
22
+ * same way, with the pool's own numbers as the state: the ERC-4626
23
23
  * conversion applied to the amount, at the rate of the block the market was
24
24
  * loaded at.
25
25
  **/
26
- type LpSimulate = {
26
+ type LpPrepare = {
27
27
  ok: true;
28
28
  /**
29
29
  * Always empty: a pool operation is a single transaction, so there is no
30
- * chain of steps to show. Present so callers can treat both simulations
31
- * alike.
30
+ * chain of steps to show. Present so callers can treat both kinds of
31
+ * result alike.
32
32
  **/
33
33
  operations: [];
34
34
  /**
@@ -49,7 +49,7 @@ type LpSimulate = {
49
49
  * so the reason is a value rather than an exception: too much leverage, too
50
50
  * little of the source token, a token the flow does not accept.
51
51
  **/
52
- type StrategySimulate = {
52
+ type StrategyPrepare = {
53
53
  ok: true;
54
54
  /**
55
55
  * The logical steps, each carrying the amounts it was computed from.
@@ -72,15 +72,15 @@ type StrategySimulate = {
72
72
  * What the leading half of a delayed operation would yield: the request
73
73
  * transaction, plus what it recorded for the tail and where that tail leads.
74
74
  *
75
- * Shaped like {@link StrategySimulate} with one field more, so the instant and
75
+ * Shaped like {@link StrategyPrepare} with one field more, so the instant and
76
76
  * the delayed route of the same request are compared side by side — and they
77
77
  * are meant to be compared on the same footing, so `state` is the end of the
78
78
  * operation in both, not the end of the transaction.
79
79
  **/
80
- type DelayedStrategySimulate = {
80
+ type DelayedStrategyPrepare = {
81
81
  ok: true;
82
82
  /**
83
- * {@inheritDoc StrategySimulate.operations}
83
+ * {@inheritDoc StrategyPrepare.operations}
84
84
  **/
85
85
  operations: AccountCalculatorOperation[];
86
86
  /**
@@ -95,7 +95,7 @@ type DelayedStrategySimulate = {
95
95
  **/
96
96
  state: OperationState;
97
97
  /**
98
- * {@inheritDoc StrategySimulate.calls}
98
+ * {@inheritDoc StrategyPrepare.calls}
99
99
  **/
100
100
  calls: MultiCall[];
101
101
  /**
@@ -116,13 +116,13 @@ type DelayedStrategySimulate = {
116
116
  * with its refusal in `refused`, which is what lets a form offer exactly the
117
117
  * routes that exist; `ok: false` means neither does.
118
118
  **/
119
- type StrategyRoutesSimulate = {
119
+ type StrategyRoutesPrepare = {
120
120
  ok: true;
121
121
  /**
122
122
  * The router route: one transaction, settled on the spot. `undefined`
123
123
  * when the asset cannot be sold, see `refused.instant`.
124
124
  **/
125
- instant: Extract<StrategySimulate, {
125
+ instant: Extract<StrategyPrepare, {
126
126
  ok: true;
127
127
  }> | undefined;
128
128
  /**
@@ -131,7 +131,7 @@ type StrategyRoutesSimulate = {
131
131
  * `undefined` when the route does not exist — no redemption venue for the
132
132
  * asset, or a request that settles at once anyway — see `refused.delayed`.
133
133
  **/
134
- delayed: Extract<DelayedStrategySimulate, {
134
+ delayed: Extract<DelayedStrategyPrepare, {
135
135
  ok: true;
136
136
  }> | undefined;
137
137
  /**
@@ -145,17 +145,17 @@ type StrategyRoutesSimulate = {
145
145
  **/
146
146
  (PreviewRefusal & {
147
147
  /**
148
- * {@inheritDoc StrategyRoutesSimulate.refused}
148
+ * {@inheritDoc StrategyRoutesPrepare.refused}
149
149
  **/
150
150
  refused: RouteRefusals;
151
151
  });
152
152
  /**
153
153
  * What opening a new leveraged position would yield.
154
154
  *
155
- * The only simulation that reports both an expected and a floor branch: opening
155
+ * The only result that reports both an expected and a floor branch: opening
156
156
  * takes both from a single pathfinder call, and `openCA` consumes both.
157
157
  **/
158
- type OpenStrategySimulate = {
158
+ type OpenStrategyPrepare = {
159
159
  ok: true;
160
160
  state: OpenStrategyState;
161
161
  } | PreviewRefusal;
@@ -167,17 +167,17 @@ interface PrepareOptions {
167
167
  slippage?: number;
168
168
  /**
169
169
  * Extra quota headroom in PERCENTAGE_FORMAT, to survive price drift between
170
- * the simulation and execution.
170
+ * the preparation and execution.
171
171
  **/
172
172
  quotaReserve?: number;
173
173
  }
174
174
  /**
175
- * Position to simulate against. A `StrategyPosition` from
175
+ * Position to prepare against. A `StrategyPosition` from
176
176
  * `sdk.positions.list()` satisfies this, as does a bare key.
177
177
  **/
178
178
  type PositionInput = StrategyPositionKey;
179
179
  /**
180
- * Pool to simulate against. A `PoolOpportunity` from
180
+ * Pool to prepare against. A `PoolOpportunity` from
181
181
  * `sdk.opportunities.list()` satisfies this, as does a bare key.
182
182
  **/
183
183
  type PoolInput = PoolOpportunityKey;
@@ -303,8 +303,8 @@ interface LpParams {
303
303
  tokenIn?: Address;
304
304
  /**
305
305
  * Token the user receives. Defaults to the only route available for `tokenIn`;
306
- * required when the pool offers several, otherwise the simulation reports
307
- * `unsupportedTokenPair`.
306
+ * required when the pool offers several, otherwise the preparation is refused
307
+ * with `unsupportedTokenPair`.
308
308
  **/
309
309
  tokenOut?: Address;
310
310
  }
@@ -337,23 +337,23 @@ interface FinalizeParams extends PrepareOptions {
337
337
  intent?: ResumableIntent;
338
338
  }
339
339
  /**
340
- * Simulations of everything a wallet can do to a pool or a credit account.
340
+ * Everything a wallet can do to a pool or a credit account, prepared.
341
341
  *
342
342
  * On-chain only: every method reads live state and, for strategies, asks the
343
343
  * pathfinder for real swap paths. Nothing is executed and nothing is signed —
344
344
  * the result is the numbers plus the calldata that would produce them.
345
345
  *
346
- * Not to be confused with `src/preview/simulate`, which goes the other way: it
347
- * takes calldata that already exists and reports what it would do.
346
+ * Not to be confused with `src/preview`, which goes the other way: it takes
347
+ * calldata that already exists and reports what it would do.
348
348
  **/
349
349
  interface IOpportunitiesPrepare {
350
350
  /**
351
351
  * Depositing into a pool: underlying in, shares out.
352
352
  *
353
- * Synchronous, unlike every strategy simulation below: the answer is the
354
- * pool's share rate applied to the amount, and that rate is already loaded.
353
+ * Synchronous, unlike every strategy method below: the answer is the pool's
354
+ * share rate applied to the amount, and that rate is already loaded.
355
355
  **/
356
- deposit(pool: PoolInput, params: LpParams): LpSimulate;
356
+ deposit(pool: PoolInput, params: LpParams): LpPrepare;
357
357
  /**
358
358
  * Taking underlying out of a pool: `amount` is the `tokenOut` the wallet
359
359
  * wants back, and the pool burns whatever shares that costs.
@@ -361,26 +361,26 @@ interface IOpportunitiesPrepare {
361
361
  * The LP counterpart of {@link withdrawStrategy} / {@link withdrawCollateral},
362
362
  * which act on credit accounts.
363
363
  **/
364
- withdraw(pool: PoolInput, params: LpParams): LpSimulate;
364
+ withdraw(pool: PoolInput, params: LpParams): LpPrepare;
365
365
  /**
366
366
  * Redeeming pool shares: `amount` is the `tokenIn` the wallet parts with,
367
367
  * and the reported state is the underlying it converts to.
368
368
  **/
369
- redeem(pool: PoolInput, params: LpRedeemParams): LpSimulate;
369
+ redeem(pool: PoolInput, params: LpRedeemParams): LpPrepare;
370
370
  /**
371
371
  * Opening a leveraged position from wallet collateral.
372
372
  *
373
373
  * The one flow with no account yet, so the result carries no operation list —
374
374
  * it feeds `sdk.accounts.openCA` instead.
375
375
  **/
376
- openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategySimulate>>;
376
+ openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategyPrepare>>;
377
377
  /**
378
378
  * Growing a position: collateral in, debt drawn on top, both converted into
379
379
  * the position token.
380
380
  *
381
381
  * Leverage stays put unless `targetLeverage` asks for more.
382
382
  **/
383
- depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategySimulate>>;
383
+ depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategyPrepare>>;
384
384
  /**
385
385
  * Shrinking a position: part of its net value goes to the wallet and debt is
386
386
  * repaid in the same proportion, so leverage is unchanged.
@@ -388,7 +388,7 @@ interface IOpportunitiesPrepare {
388
388
  * Answers with both routes the withdrawal can take — sold through the router
389
389
  * now, or redeemed through the source's issuer and finished days later — since
390
390
  * the source token decides which of them exist, see
391
- * {@link StrategyRoutesSimulate}.
391
+ * {@link StrategyRoutesPrepare}.
392
392
  *
393
393
  * `MAX_UINT256` — or any amount at or above the account's net value — is an
394
394
  * exit instead: the quotas are dropped, the position is sold whole in one
@@ -406,7 +406,7 @@ interface IOpportunitiesPrepare {
406
406
  * @see withdrawCollateral to move an asset out without touching debt, which
407
407
  * raises leverage instead.
408
408
  **/
409
- withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesSimulate>>;
409
+ withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesPrepare>>;
410
410
  /**
411
411
  * Largest partial withdrawal {@link withdrawStrategy} accepts, in underlying
412
412
  * units: the amount whose proportional repayment leaves the debt at the
@@ -429,12 +429,12 @@ interface IOpportunitiesPrepare {
429
429
  * A repayment that covers the whole debt clears the account's quotas with it,
430
430
  * which the facade requires of a loan going to zero, and asks for the full
431
431
  * outstanding amount, so nothing is left owing because interest moved between
432
- * this simulation and the transaction. `MAX_UINT256` is how to ask for that
432
+ * this preparation and the transaction. `MAX_UINT256` is how to ask for that
433
433
  * settlement without naming a figure: the wallet is charged the debt plus a
434
434
  * 10bps margin for the interest still to come, and whatever the facade does
435
435
  * not take stays on the account.
436
436
  **/
437
- repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategySimulate>>;
437
+ repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategyPrepare>>;
438
438
  /**
439
439
  * Debt {@link repayStrategy} would have to cover to clear the account, in
440
440
  * underlying units: principal, interest and fees as of this read. Interest
@@ -449,12 +449,12 @@ interface IOpportunitiesPrepare {
449
449
  * buys instead, so there the delayed route is always absent with
450
450
  * `refused.delayed: "noDelayedRoute"`.
451
451
  **/
452
- adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesSimulate>>;
452
+ adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesPrepare>>;
453
453
  /**
454
454
  * Putting the position token onto the account at fixed debt, which lowers
455
455
  * leverage and raises the health factor.
456
456
  **/
457
- addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategySimulate>>;
457
+ addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategyPrepare>>;
458
458
  /**
459
459
  * Moving one asset that already sits on the account out to the wallet, at
460
460
  * fixed debt — so TVL falls and leverage rises.
@@ -462,7 +462,7 @@ interface IOpportunitiesPrepare {
462
462
  * @see withdrawStrategy for the deleveraging withdrawal, which repays debt in
463
463
  * proportion and leaves leverage unchanged.
464
464
  **/
465
- withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategySimulate>>;
465
+ withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategyPrepare>>;
466
466
  /**
467
467
  * The leverages a deposit of a given size can reach in this market: the
468
468
  * range a leverage slider should mark as available.
@@ -499,7 +499,7 @@ interface IOpportunitiesPrepare {
499
499
  * Synchronous, like {@link leverageBand}: it reads loaded token metadata and
500
500
  * the position it was handed, so a form can ask on every render. Nothing is
501
501
  * quoted here — which of these the router can sell is a different question,
502
- * and the answer to it is a simulation.
502
+ * and the answer to it is a prepared operation.
503
503
  **/
504
504
  withdrawableCollaterals(position: StrategyPosition): PositionCollateral[];
505
505
  /**
@@ -531,7 +531,7 @@ interface IOpportunitiesPrepare {
531
531
  * Answers like the instant flows, so both halves are consumed the same way.
532
532
  * Reports `noRecordedIntent` when the claim names no operation to resume.
533
533
  **/
534
- finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategySimulate>>;
534
+ finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategyPrepare>>;
535
535
  }
536
536
  //#endregion
537
- export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
537
+ export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, DelayedStrategyPrepare, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.0.0-next.30",
3
+ "version": "16.0.0-next.32",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,11 +0,0 @@
1
- import { PreviewLpVerify } from "../../model/previews.js";
2
- import "../../model/index.js";
3
- import { PluginsMap } from "../../onchain/plugins/types.js";
4
- import "../../onchain/index.js";
5
- import { PoolOperation } from "../parse/types-pools.js";
6
- import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
7
- import "../parse/index.js";
8
- //#region src/preview/preview/previewLpVerify.d.ts
9
- declare function previewLpVerify<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: PreviewOperationOptions): Promise<PreviewLpVerify>;
10
- //#endregion
11
- export { previewLpVerify };
@@ -1,12 +0,0 @@
1
- import { PreviewOpenStrategyVerify } from "../../model/previews.js";
2
- import "../../model/index.js";
3
- import { PluginsMap } from "../../onchain/plugins/types.js";
4
- import "../../onchain/index.js";
5
- import { OpenCreditAccountOperation } from "../parse/types-facades.js";
6
- import { RWAOpenCreditAccountOperation } from "../parse/types-rwa.js";
7
- import { PreviewOperationInput } from "../types.js";
8
- import "../parse/index.js";
9
- //#region src/preview/preview/previewOpenStrategyVerify.d.ts
10
- declare function previewOpenStrategyVerify<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): Promise<PreviewOpenStrategyVerify>;
11
- //#endregion
12
- export { previewOpenStrategyVerify };