@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.
- package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +1 -1
- package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +1 -1
- package/dist/cjs/preview/index.js +6 -6
- package/dist/cjs/preview/preview/{buildDelayedStrategyVerify.js → buildDelayedStrategyPositionOperationPreview.js} +3 -3
- package/dist/cjs/preview/preview/index.js +6 -6
- package/dist/cjs/preview/preview/{previewAdjustStrategyVerify.js → previewAdjustStrategyPosition.js} +3 -3
- package/dist/cjs/preview/preview/{previewExitOrRepayStrategyVerify.js → previewExitOrRepayStrategyPosition.js} +3 -3
- package/dist/cjs/preview/preview/{previewOpenStrategyVerify.js → previewOpenStrategyPosition.js} +3 -3
- package/dist/cjs/preview/preview/previewOperation.js +10 -10
- package/dist/cjs/preview/preview/{previewLpVerify.js → previewPoolPositionOperation.js} +3 -3
- package/dist/cjs/sdk/execute/ExecuteApi.js +3 -3
- package/dist/cjs/sdk/prepare/PrepareApi.js +1 -1
- package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +1 -1
- package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +1 -1
- package/dist/esm/preview/index.js +4 -4
- package/dist/esm/preview/preview/{buildDelayedStrategyVerify.js → buildDelayedStrategyPositionOperationPreview.js} +3 -3
- package/dist/esm/preview/preview/index.js +4 -4
- package/dist/esm/preview/preview/{previewAdjustStrategyVerify.js → previewAdjustStrategyPosition.js} +3 -3
- package/dist/esm/preview/preview/{previewExitOrRepayStrategyVerify.js → previewExitOrRepayStrategyPosition.js} +3 -3
- package/dist/esm/preview/preview/{previewOpenStrategyVerify.js → previewOpenStrategyPosition.js} +3 -3
- package/dist/esm/preview/preview/previewOperation.js +10 -10
- package/dist/esm/preview/preview/{previewLpVerify.js → previewPoolPositionOperation.js} +3 -3
- package/dist/esm/sdk/execute/ExecuteApi.js +3 -3
- package/dist/esm/sdk/prepare/PrepareApi.js +1 -1
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/model/previews.d.ts +13 -13
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +4 -4
- package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +1 -1
- package/dist/types/preview/index.d.ts +4 -4
- package/dist/types/preview/preview/{buildDelayedStrategyVerify.d.ts → buildDelayedStrategyPositionOperationPreview.d.ts} +4 -4
- package/dist/types/preview/preview/index.d.ts +4 -4
- package/dist/types/preview/preview/{previewAdjustStrategyVerify.d.ts → previewAdjustStrategyPosition.d.ts} +4 -4
- package/dist/types/preview/preview/{previewExitOrRepayStrategyVerify.d.ts → previewExitOrRepayStrategyPosition.d.ts} +4 -4
- package/dist/types/preview/preview/previewOpenStrategyPosition.d.ts +12 -0
- package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +11 -0
- package/dist/types/sdk/execute/types.d.ts +13 -13
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/opportunities/types.d.ts +2 -1
- package/dist/types/sdk/prepare/PrepareApi.d.ts +14 -14
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +41 -41
- package/package.json +1 -1
- package/dist/types/preview/preview/previewLpVerify.d.ts +0 -11
- 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
|
|
22
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
80
|
+
type DelayedStrategyPrepare = {
|
|
81
81
|
ok: true;
|
|
82
82
|
/**
|
|
83
|
-
* {@inheritDoc
|
|
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
|
|
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
|
|
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<
|
|
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<
|
|
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
|
|
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
|
|
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
|
|
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
|
|
170
|
+
* the preparation and execution.
|
|
171
171
|
**/
|
|
172
172
|
quotaReserve?: number;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
* Position to
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
|
347
|
-
*
|
|
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
|
|
354
|
-
*
|
|
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):
|
|
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):
|
|
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):
|
|
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<
|
|
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<
|
|
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
|
|
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<
|
|
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
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
|
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<
|
|
534
|
+
finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategyPrepare>>;
|
|
535
535
|
}
|
|
536
536
|
//#endregion
|
|
537
|
-
export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding,
|
|
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,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 };
|