@gearbox-protocol/sdk 16.0.0-next.26 → 16.0.0-next.28
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/model/index.js +1 -0
- package/dist/cjs/model/previews.js +23 -0
- package/dist/cjs/onchain/accounts/index.js +2 -0
- package/dist/cjs/onchain/accounts/intents/index.js +2 -0
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +4 -18
- package/dist/cjs/onchain/accounts/intents/realize.js +77 -50
- package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -0
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +13 -5
- package/dist/cjs/onchain/index.js +2 -0
- package/dist/cjs/onchain/positions/PositionsService.js +79 -0
- package/dist/cjs/preview/index.js +6 -6
- package/dist/cjs/preview/preview/{buildDelayedPreview.js → buildDelayedStrategyVerify.js} +6 -25
- package/dist/cjs/preview/preview/index.js +6 -6
- package/dist/cjs/preview/preview/{previewAdjustCreditAccount.js → previewAdjustStrategyVerify.js} +6 -24
- package/dist/cjs/preview/preview/{previewCloseOrRepayCreditAccount.js → previewExitOrRepayStrategyVerify.js} +3 -3
- package/dist/cjs/preview/preview/{previewPoolOperation.js → previewLpVerify.js} +3 -3
- package/dist/cjs/preview/preview/{previewOpenCreditAccount.js → previewOpenStrategyVerify.js} +6 -26
- package/dist/cjs/preview/preview/previewOperation.js +10 -10
- package/dist/cjs/preview/validate/checkOperation.js +13 -9
- package/dist/cjs/rewards/rewards/api.js +15 -7
- package/dist/cjs/sdk/prepare/PrepareApi.js +7 -0
- package/dist/cjs/sdk/prepare/withdrawable-collaterals.js +23 -0
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/model/previews.js +23 -1
- package/dist/esm/onchain/accounts/index.js +2 -1
- package/dist/esm/onchain/accounts/intents/index.js +2 -1
- package/dist/esm/onchain/accounts/intents/open-strategy.js +4 -18
- package/dist/esm/onchain/accounts/intents/realize.js +77 -50
- package/dist/esm/onchain/accounts/intents/testing/market.js +1 -0
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +13 -5
- package/dist/esm/onchain/index.js +2 -1
- package/dist/esm/onchain/positions/PositionsService.js +79 -0
- package/dist/esm/preview/index.js +4 -4
- package/dist/esm/preview/preview/{buildDelayedPreview.js → buildDelayedStrategyVerify.js} +7 -26
- package/dist/esm/preview/preview/index.js +4 -4
- package/dist/esm/preview/preview/{previewAdjustCreditAccount.js → previewAdjustStrategyVerify.js} +7 -25
- package/dist/esm/preview/preview/{previewCloseOrRepayCreditAccount.js → previewExitOrRepayStrategyVerify.js} +3 -3
- package/dist/esm/preview/preview/{previewPoolOperation.js → previewLpVerify.js} +3 -3
- package/dist/esm/preview/preview/{previewOpenCreditAccount.js → previewOpenStrategyVerify.js} +7 -27
- package/dist/esm/preview/preview/previewOperation.js +10 -10
- package/dist/esm/preview/validate/checkOperation.js +13 -9
- package/dist/esm/rewards/rewards/api.js +16 -8
- package/dist/esm/sdk/prepare/PrepareApi.js +7 -0
- package/dist/esm/sdk/prepare/withdrawable-collaterals.js +22 -0
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/model/previews.d.ts +202 -76
- package/dist/types/onchain/accounts/index.d.ts +2 -1
- package/dist/types/onchain/accounts/intents/index.d.ts +2 -1
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +1 -7
- package/dist/types/onchain/accounts/intents/testing/market.d.ts +1 -0
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +7 -0
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +1 -1
- package/dist/types/onchain/index.d.ts +2 -1
- package/dist/types/onchain/positions/PositionsService.d.ts +30 -0
- package/dist/types/preview/index.d.ts +5 -5
- package/dist/types/preview/preview/{buildDelayedPreview.d.ts → buildDelayedStrategyVerify.d.ts} +4 -4
- package/dist/types/preview/preview/index.d.ts +4 -4
- package/dist/types/preview/preview/{previewAdjustCreditAccount.d.ts → previewAdjustStrategyVerify.d.ts} +4 -4
- package/dist/types/preview/preview/{previewCloseOrRepayCreditAccount.d.ts → previewExitOrRepayStrategyVerify.d.ts} +4 -4
- package/dist/types/preview/preview/previewLpVerify.d.ts +11 -0
- package/dist/types/preview/preview/previewOpenStrategyVerify.d.ts +12 -0
- package/dist/types/preview/validate/checkOperation.d.ts +12 -4
- package/dist/types/preview/validate/index.d.ts +2 -2
- package/dist/types/rewards/rewards/api.d.ts +12 -6
- package/dist/types/rewards/rewards/merkl-api.d.ts +6 -0
- package/dist/types/sdk/prepare/PrepareApi.d.ts +5 -0
- package/dist/types/sdk/prepare/types.d.ts +18 -1
- package/dist/types/sdk/prepare/withdrawable-collaterals.d.ts +11 -0
- package/package.json +1 -1
- package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +0 -12
- package/dist/types/preview/preview/previewPoolOperation.d.ts +0 -11
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Bps } from "../../model/primitives.js";
|
|
2
2
|
import { BorrowRateBreakdown, Position, StrategyPosition } from "../../model/positions.js";
|
|
3
|
+
import { AccountMetrics, AccountProjection } from "../../model/previews.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
5
|
import { AccountSnapshot, ListPositionsProps, ListStrategyPositionsProps } from "./types.js";
|
|
5
6
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
@@ -67,6 +68,35 @@ declare class PositionsService extends SDKConstruct {
|
|
|
67
68
|
* non-underlying assets.
|
|
68
69
|
**/
|
|
69
70
|
liquidationPrice(snapshot: AccountSnapshot): bigint | null;
|
|
71
|
+
/**
|
|
72
|
+
* Every derived number of an account state at once — the whole
|
|
73
|
+
* {@link AccountMetrics} half of a projection.
|
|
74
|
+
*
|
|
75
|
+
* This is what both halves of the SDK fill their answers from: `prepare`, for
|
|
76
|
+
* a state it walked an intent into, and `preview`, for one it replayed out of
|
|
77
|
+
* calldata. One snapshot in, one set of metrics out, so the two descriptions
|
|
78
|
+
* of the same operation cannot disagree because one of them grew its own
|
|
79
|
+
* formula.
|
|
80
|
+
*
|
|
81
|
+
* Identical to the four methods above field for field, and cheaper than
|
|
82
|
+
* calling them one by one: the market data is collected once, and the health
|
|
83
|
+
* factor and borrow rate the time to liquidation decays at are the very ones
|
|
84
|
+
* reported beside it.
|
|
85
|
+
**/
|
|
86
|
+
metrics(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): AccountMetrics;
|
|
87
|
+
/**
|
|
88
|
+
* A projected account state as both halves of the SDK report it: the holdings
|
|
89
|
+
* priced and named, and the metrics of {@link PositionsService.metrics}.
|
|
90
|
+
*
|
|
91
|
+
* The snapshot is taken at its word — what it lists is what comes back, so a
|
|
92
|
+
* caller that drops dust before the walk reports an account without it, and
|
|
93
|
+
* one that keeps wei reports them. That is the whole of the policy left to
|
|
94
|
+
* the caller; everything downstream of the balances is decided here.
|
|
95
|
+
*
|
|
96
|
+
* @param options - The operation's effect on the pool, for the rate the
|
|
97
|
+
* metrics are quoted at, see {@link ProjectedPoolOptions}.
|
|
98
|
+
**/
|
|
99
|
+
projection(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): AccountProjection;
|
|
70
100
|
}
|
|
71
101
|
//#endregion
|
|
72
102
|
export { PositionsService, ProjectedPoolOptions };
|
|
@@ -28,17 +28,17 @@ import { checkPrerequisites } from "./prerequisites/checkPrerequisites.js";
|
|
|
28
28
|
import "./prerequisites/index.js";
|
|
29
29
|
import { CreditAccountState, CreditAccountStateProps } from "./preview/CreditAccountState.js";
|
|
30
30
|
import { DetectedDelayedOperation, detectDelayedOperation } from "./preview/detectDelayedOperation.js";
|
|
31
|
-
import {
|
|
31
|
+
import { buildDelayedStrategyVerify } from "./preview/buildDelayedStrategyVerify.js";
|
|
32
32
|
import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/detectCloseOrRepay.js";
|
|
33
33
|
import { DetectedDelayedClaim, detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/detectDelayedClaim.js";
|
|
34
34
|
import { UnsupportedOperationError } from "./preview/errors.js";
|
|
35
|
-
import {
|
|
36
|
-
import { CloseOrRepayOperation,
|
|
35
|
+
import { previewAdjustStrategyVerify } from "./preview/previewAdjustStrategyVerify.js";
|
|
36
|
+
import { CloseOrRepayOperation, previewExitOrRepayStrategyVerify } from "./preview/previewExitOrRepayStrategyVerify.js";
|
|
37
37
|
import { previewOperation } from "./preview/previewOperation.js";
|
|
38
38
|
import { ReplayState, makeReplayState, replayInnerOperations } from "./preview/replayInnerOperations.js";
|
|
39
39
|
import { ReplayMulticallResult, ReplayableOperation, replayMulticall } from "./preview/replayMulticall.js";
|
|
40
40
|
import "./preview/index.js";
|
|
41
|
-
import { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./validate/checkOperation.js";
|
|
41
|
+
import { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./validate/checkOperation.js";
|
|
42
42
|
import { checkSimulation } from "./validate/checkSimulation.js";
|
|
43
43
|
import "./validate/index.js";
|
|
44
|
-
export { AdapterOperation, AdapterOperationBase, AddCollateralOp, AllowanceDetail, AllowancePrerequisite, AllowanceResult, BalanceDetail, BalancePrerequisite, BalanceResult, BorrowLimitBinding, CheckOperationOptions, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CloseOrRepayOperation, CompareBalancesOp, CreditAccountOperation, CreditAccountState, CreditAccountStateProps, DecreaseDebtOp, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ExtractTransfersResult, FacadeCallType, FacadeOperationMetadata, FacadeParsedCall, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, IntentPreviewError, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, Prerequisite, PrerequisiteContext, PrerequisiteError, PrerequisiteKind, PrerequisiteOutcome, PrerequisiteResult, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewOperationInput, PreviewOperationOptions, PreviewRefusal, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOpenRequirementsDetail, RWAOpenRequirementsPrerequisite, RWAOpenRequirementsResult, RWAOperation, RWAOperationMetadata, ReplayMulticallResult, ReplayState, ReplayableOperation, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, UpdateQuotaOp, WithdrawCollateralAlignmentError, WithdrawCollateralEventInfo, WithdrawCollateralOp,
|
|
44
|
+
export { AdapterOperation, AdapterOperationBase, AddCollateralOp, AllowanceDetail, AllowancePrerequisite, AllowanceResult, BalanceDetail, BalancePrerequisite, BalanceResult, BorrowLimitBinding, CheckOperationOptions, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CloseOrRepayOperation, CompareBalancesOp, CreditAccountOperation, CreditAccountState, CreditAccountStateProps, DecreaseDebtOp, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ExtractTransfersResult, FacadeCallType, FacadeOperationMetadata, FacadeParsedCall, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, IntentPreviewError, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, Prerequisite, PrerequisiteContext, PrerequisiteError, PrerequisiteKind, PrerequisiteOutcome, PrerequisiteResult, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewOperationInput, PreviewOperationOptions, PreviewRefusal, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOpenRequirementsDetail, RWAOpenRequirementsPrerequisite, RWAOpenRequirementsResult, RWAOperation, RWAOperationMetadata, ReplayMulticallResult, ReplayState, ReplayableOperation, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, UpdateQuotaOp, WeighedFactors, WithdrawCollateralAlignmentError, WithdrawCollateralEventInfo, WithdrawCollateralOp, buildDelayedStrategyVerify, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssue, detectDelayedClaim, detectDelayedOperation, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, marketIssues, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyVerify, previewExitOrRepayStrategyVerify, previewOperation, quotaCountIssue, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
package/dist/types/preview/preview/{buildDelayedPreview.d.ts → buildDelayedStrategyVerify.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewInstantStrategyVerify } from "../../model/previews.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { ConvertFn } from "../../onchain/market/oracle/types.js";
|
|
4
4
|
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
@@ -6,7 +6,7 @@ import "../../onchain/index.js";
|
|
|
6
6
|
import { CreditAccountState } from "./CreditAccountState.js";
|
|
7
7
|
import { DetectedDelayedOperation } from "./detectDelayedOperation.js";
|
|
8
8
|
import { Address } from "viem";
|
|
9
|
-
//#region src/preview/preview/
|
|
9
|
+
//#region src/preview/preview/buildDelayedStrategyVerify.d.ts
|
|
10
10
|
/**
|
|
11
11
|
* Builds the best-effort preview of the account state after the detected
|
|
12
12
|
* delayed withdrawal is claimed and its intent (if any) is resumed:
|
|
@@ -29,6 +29,6 @@ import { Address } from "viem";
|
|
|
29
29
|
* @param sdk - Market data source for the position metrics of the resulting
|
|
30
30
|
* state; read synchronously, no network access.
|
|
31
31
|
*/
|
|
32
|
-
declare function
|
|
32
|
+
declare function buildDelayedStrategyVerify(afterInstant: CreditAccountState, before: CreditAccountState, detected: DetectedDelayedOperation, convert: ConvertFn, receivedToken: Address, sdk: OnchainSDK): PreviewInstantStrategyVerify;
|
|
33
33
|
//#endregion
|
|
34
|
-
export {
|
|
34
|
+
export { buildDelayedStrategyVerify };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CreditAccountState, CreditAccountStateProps } from "./CreditAccountState.js";
|
|
2
2
|
import { DetectedDelayedOperation, detectDelayedOperation } from "./detectDelayedOperation.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buildDelayedStrategyVerify } from "./buildDelayedStrategyVerify.js";
|
|
4
4
|
import { classifyCloseOrRepay, isCloseOrRepay } from "./detectCloseOrRepay.js";
|
|
5
5
|
import { DetectedDelayedClaim, detectDelayedClaim, resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
|
|
6
6
|
import { UnsupportedOperationError } from "./errors.js";
|
|
7
|
-
import {
|
|
8
|
-
import { CloseOrRepayOperation,
|
|
7
|
+
import { previewAdjustStrategyVerify } from "./previewAdjustStrategyVerify.js";
|
|
8
|
+
import { CloseOrRepayOperation, previewExitOrRepayStrategyVerify } from "./previewExitOrRepayStrategyVerify.js";
|
|
9
9
|
import { previewOperation } from "./previewOperation.js";
|
|
10
10
|
import { ReplayState, makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
|
|
11
11
|
import { ReplayMulticallResult, ReplayableOperation, replayMulticall } from "./replayMulticall.js";
|
|
12
|
-
export { CloseOrRepayOperation, CreditAccountState, CreditAccountStateProps, DetectedDelayedClaim, DetectedDelayedOperation, ReplayMulticallResult, ReplayState, ReplayableOperation, UnsupportedOperationError,
|
|
12
|
+
export { CloseOrRepayOperation, CreditAccountState, CreditAccountStateProps, DetectedDelayedClaim, DetectedDelayedOperation, ReplayMulticallResult, ReplayState, ReplayableOperation, UnsupportedOperationError, buildDelayedStrategyVerify, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, isCloseOrRepay, makeReplayState, previewAdjustStrategyVerify, previewExitOrRepayStrategyVerify, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewAdjustStrategyVerify } from "../../model/previews.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
@@ -6,7 +6,7 @@ import { MulticallOperation } from "../parse/types-facades.js";
|
|
|
6
6
|
import { RWAMulticallOperation } from "../parse/types-rwa.js";
|
|
7
7
|
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
8
8
|
import "../parse/index.js";
|
|
9
|
-
//#region src/preview/preview/
|
|
9
|
+
//#region src/preview/preview/previewAdjustStrategyVerify.d.ts
|
|
10
10
|
/**
|
|
11
11
|
* Previews a `multicall`/`botMulticall` operation on an existing credit
|
|
12
12
|
* account: threads the multicall through {@link replayMulticall} over the
|
|
@@ -14,6 +14,6 @@ import "../parse/index.js";
|
|
|
14
14
|
* minimal guaranteed post-state alongside the changes relative to the
|
|
15
15
|
* pre-state.
|
|
16
16
|
*/
|
|
17
|
-
declare function
|
|
17
|
+
declare function previewAdjustStrategyVerify<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | RWAMulticallOperation, options: PreviewOperationOptions<true>): Promise<PreviewAdjustStrategyVerify>;
|
|
18
18
|
//#endregion
|
|
19
|
-
export {
|
|
19
|
+
export { previewAdjustStrategyVerify };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewExitStrategyVerify, PreviewRepayStrategyVerify } from "../../model/previews.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
@@ -6,13 +6,13 @@ import { CloseCreditAccountOperation, MulticallOperation } from "../parse/types-
|
|
|
6
6
|
import { RWAMulticallOperation } from "../parse/types-rwa.js";
|
|
7
7
|
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
8
8
|
import "../parse/index.js";
|
|
9
|
-
//#region src/preview/preview/
|
|
9
|
+
//#region src/preview/preview/previewExitOrRepayStrategyVerify.d.ts
|
|
10
10
|
/**
|
|
11
11
|
* Any parsed operation that fully closes or repays a credit account: the
|
|
12
12
|
* facade `closeCreditAccount` entry point (permanent closure) or a plain
|
|
13
13
|
* multicall detected by `isCloseOrRepay` (`decreaseDebt(MAX)`).
|
|
14
14
|
*/
|
|
15
15
|
type CloseOrRepayOperation = CloseCreditAccountOperation | MulticallOperation | RWAMulticallOperation;
|
|
16
|
-
declare function
|
|
16
|
+
declare function previewExitOrRepayStrategyVerify<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: CloseOrRepayOperation, permanent: boolean, options: PreviewOperationOptions<true>): Promise<PreviewExitStrategyVerify | PreviewRepayStrategyVerify>;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { CloseOrRepayOperation,
|
|
18
|
+
export { CloseOrRepayOperation, previewExitOrRepayStrategyVerify };
|
|
@@ -0,0 +1,11 @@
|
|
|
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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bps } from "../../model/primitives.js";
|
|
2
|
-
import { AccountProjection, OperationPreview } from "../../model/previews.js";
|
|
2
|
+
import { AccountHoldings, AccountMetrics, AccountProjection, OperationPreview } from "../../model/previews.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
4
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
5
5
|
import { CreditSuite } from "../../onchain/market/credit/CreditSuite.js";
|
|
@@ -49,7 +49,15 @@ declare function marketIssues(suite: CreditSuite): PreviewIssue | null;
|
|
|
49
49
|
* need an operation's *delta* between them, and the caller acts on the first
|
|
50
50
|
* issue reported.
|
|
51
51
|
*/
|
|
52
|
-
declare function quotaCountIssue(suite: CreditSuite,
|
|
52
|
+
declare function quotaCountIssue(suite: CreditSuite, account: Pick<AccountProjection, "quotas">): PreviewIssue | null;
|
|
53
|
+
/**
|
|
54
|
+
* An account's factors, in whichever branch of a routed leg the caller means to
|
|
55
|
+
* be held to: `prepare` reports the outcome the router expects, `preview` the
|
|
56
|
+
* floor its calldata guarantees. The bar is indifferent — it weighs the numbers
|
|
57
|
+
* it is handed — and passing them one by one is what makes the choice visible
|
|
58
|
+
* where it is made.
|
|
59
|
+
*/
|
|
60
|
+
interface WeighedFactors extends Pick<AccountHoldings, "totalDebt">, Pick<AccountMetrics, "healthFactor" | "safeHealthFactor"> {}
|
|
53
61
|
/**
|
|
54
62
|
* The account against whichever bars the caller holds it to.
|
|
55
63
|
*
|
|
@@ -58,6 +66,6 @@ declare function quotaCountIssue(suite: CreditSuite, projection: AccountProjecti
|
|
|
58
66
|
*
|
|
59
67
|
* {@inheritDoc quotaCountIssue}
|
|
60
68
|
*/
|
|
61
|
-
declare function collateralIssue(
|
|
69
|
+
declare function collateralIssue(account: WeighedFactors, options: CheckOperationOptions): PreviewIssue | null;
|
|
62
70
|
//#endregion
|
|
63
|
-
export { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue };
|
|
71
|
+
export { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./checkOperation.js";
|
|
1
|
+
import { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./checkOperation.js";
|
|
2
2
|
import { checkSimulation } from "./checkSimulation.js";
|
|
3
|
-
export { CheckOperationOptions, checkOperation, checkSimulation, collateralIssue, marketIssues, quotaCountIssue };
|
|
3
|
+
export { CheckOperationOptions, WeighedFactors, checkOperation, checkSimulation, collateralIssue, marketIssues, quotaCountIssue };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ChainId, Token } from "../../model/primitives.js";
|
|
1
|
+
import { ChainId, Token, TokenAmount } from "../../model/primitives.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { Address } from "viem";
|
|
6
6
|
//#region src/rewards/rewards/api.d.ts
|
|
7
7
|
/**
|
|
8
|
-
* One claimable Merkl liquidity-mining reward, denominated.
|
|
8
|
+
* One claimable Merkl liquidity-mining reward, denominated and priced.
|
|
9
9
|
*
|
|
10
10
|
* Both tokens arrive resolved, so a consumer neither looks one up nor
|
|
11
11
|
* reassembles one out of the loose fields Merkl sends.
|
|
@@ -16,10 +16,16 @@ interface MerklReward {
|
|
|
16
16
|
readonly pool: Address;
|
|
17
17
|
/** That pool's share token — what the campaign is keyed on. */
|
|
18
18
|
readonly poolToken: Token;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The incentive token being handed out, how much of it is claimable
|
|
21
|
+
* (distributed minus already claimed, always > 0) and what that is worth.
|
|
22
|
+
*
|
|
23
|
+
* Priced by Merkl, not by the market oracles: a campaign's incentive token
|
|
24
|
+
* is rarely collateral in the pool it incentivises, so the oracles usually
|
|
25
|
+
* do not know it — GEAR, which most Gearbox campaigns pay in, among them.
|
|
26
|
+
* `valueUsd` is `null` for a token Merkl does not price either.
|
|
27
|
+
*/
|
|
28
|
+
readonly amount: TokenAmount;
|
|
23
29
|
}
|
|
24
30
|
type ReportHandler = (e: unknown, description?: string) => void;
|
|
25
31
|
/**
|
|
@@ -20,6 +20,12 @@ interface MerkleXYZUserRewardsV4 {
|
|
|
20
20
|
chainId: number;
|
|
21
21
|
symbol: string;
|
|
22
22
|
decimals: number;
|
|
23
|
+
/**
|
|
24
|
+
* USD price of one whole token. Optional because Merkl omits the key
|
|
25
|
+
* outright for the tokens it does not price — points and the like —
|
|
26
|
+
* rather than sending a null.
|
|
27
|
+
*/
|
|
28
|
+
price?: number;
|
|
23
29
|
};
|
|
24
30
|
breakdowns: Array<{
|
|
25
31
|
reason: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bps, ChainId } from "../../model/primitives.js";
|
|
2
|
+
import { PositionCollateral, StrategyPosition } from "../../model/positions.js";
|
|
2
3
|
import { DataResponse } from "../../model/response.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
5
|
import { Asset } from "../../onchain/base/types.js";
|
|
@@ -92,6 +93,10 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
|
|
|
92
93
|
* {@inheritDoc IOpportunitiesPrepare.leverageBand}
|
|
93
94
|
**/
|
|
94
95
|
leverageBand(strategy: StrategyInput, collateral: readonly Asset[], targetHF?: Bps): LeverageBand | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* {@inheritDoc IOpportunitiesPrepare.withdrawableCollaterals}
|
|
98
|
+
**/
|
|
99
|
+
withdrawableCollaterals(position: StrategyPosition): PositionCollateral[];
|
|
95
100
|
/**
|
|
96
101
|
* {@inheritDoc IOpportunitiesPrepare.maxWithdrawCollateral}
|
|
97
102
|
**/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bps } from "../../model/primitives.js";
|
|
2
2
|
import { PoolOpportunityKey, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
|
-
import { StrategyPositionKey } from "../../model/positions.js";
|
|
3
|
+
import { PositionCollateral, StrategyPosition, StrategyPositionKey } from "../../model/positions.js";
|
|
4
4
|
import { DataResponse } from "../../model/response.js";
|
|
5
5
|
import "../../model/index.js";
|
|
6
6
|
import { ClaimableWithdrawal } from "../../onchain/accounts/withdrawal-compressor/types.js";
|
|
@@ -485,6 +485,23 @@ interface IOpportunitiesPrepare {
|
|
|
485
485
|
* a caller must not mark a range for it.
|
|
486
486
|
**/
|
|
487
487
|
leverageBand(strategy: StrategyInput, collateral: readonly Asset[], targetHF?: Bps): LeverageBand | undefined;
|
|
488
|
+
/**
|
|
489
|
+
* The collaterals an account can actually take out, most valuable first —
|
|
490
|
+
* what a withdraw-collateral picker offers.
|
|
491
|
+
*
|
|
492
|
+
* `StrategyPosition.collaterals` is everything the account holds, in the
|
|
493
|
+
* order the manager keeps its tokens. Phantoms are in there: the position
|
|
494
|
+
* reports one as itself and puts the asset it redeems into under
|
|
495
|
+
* `withdrawals`, and {@link withdrawCollateral} cannot move a balance that
|
|
496
|
+
* is not transferable. Balances below dust are already gone — the position
|
|
497
|
+
* drops them as it is built.
|
|
498
|
+
*
|
|
499
|
+
* Synchronous, like {@link leverageBand}: it reads loaded token metadata and
|
|
500
|
+
* the position it was handed, so a form can ask on every render. Nothing is
|
|
501
|
+
* quoted here — which of these the router can sell is a different question,
|
|
502
|
+
* and the answer to it is a simulation.
|
|
503
|
+
**/
|
|
504
|
+
withdrawableCollaterals(position: StrategyPosition): PositionCollateral[];
|
|
488
505
|
/**
|
|
489
506
|
* Largest amount of one collateral {@link withdrawCollateral} can move out
|
|
490
507
|
* while the account stays safely collateralised, in the token's units: the
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PositionCollateral, StrategyPosition } from "../../model/positions.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
4
|
+
import "../../onchain/index.js";
|
|
5
|
+
//#region src/sdk/prepare/withdrawable-collaterals.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* {@inheritDoc IOpportunitiesPrepare.withdrawableCollaterals}
|
|
8
|
+
**/
|
|
9
|
+
declare function withdrawableCollaterals(sdk: OnchainSDK, position: StrategyPosition): PositionCollateral[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { withdrawableCollaterals };
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OpenCreditAccountPreview } 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/previewOpenCreditAccount.d.ts
|
|
10
|
-
declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): Promise<OpenCreditAccountPreview>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { previewOpenCreditAccount };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PoolOperationPreview } 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/previewPoolOperation.d.ts
|
|
9
|
-
declare function previewPoolOperation<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: PreviewOperationOptions): Promise<PoolOperationPreview>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { previewPoolOperation };
|