@gearbox-protocol/sdk 16.0.0-next.22 → 16.0.0-next.23

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 (82) hide show
  1. package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +2 -2
  2. package/dist/cjs/onchain/accounts/intents/open-strategy.js +7 -4
  3. package/dist/cjs/onchain/accounts/intents/realize.js +10 -6
  4. package/dist/cjs/onchain/accounts/intents/tail.js +3 -2
  5. package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -1
  6. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +18 -1
  7. package/dist/cjs/onchain/accounts/intents/tests/add-collateral.fixtures.js +4 -4
  8. package/dist/cjs/onchain/accounts/intents/tests/adjust-leverage.fixtures.js +15 -15
  9. package/dist/cjs/onchain/accounts/intents/tests/deposit.fixtures.js +13 -13
  10. package/dist/cjs/onchain/accounts/intents/tests/finish-decrease-leverage.fixtures.js +2 -2
  11. package/dist/cjs/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +2 -2
  12. package/dist/cjs/onchain/accounts/intents/tests/withdraw-asset.fixtures.js +4 -4
  13. package/dist/cjs/onchain/accounts/intents/tests/withdraw.fixtures.js +7 -7
  14. package/dist/cjs/onchain/accounts/intents/utils/adjust-state-to-snapshot.js +8 -5
  15. package/dist/cjs/onchain/accounts/intents/utils/common.js +2 -2
  16. package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +4 -4
  17. package/dist/cjs/onchain/accounts/intents/view.js +2 -2
  18. package/dist/cjs/onchain/market/MarketSuite.js +15 -0
  19. package/dist/cjs/onchain/market/math.js +6 -2
  20. package/dist/cjs/onchain/pools/PoolService.js +25 -29
  21. package/dist/cjs/preview/index.js +3 -1
  22. package/dist/cjs/preview/preview/buildDelayedPreview.js +4 -4
  23. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +3 -3
  24. package/dist/cjs/preview/preview/previewCloseOrRepayCreditAccount.js +1 -1
  25. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +7 -7
  26. package/dist/cjs/preview/validate/checkOperation.js +47 -37
  27. package/dist/cjs/preview/validate/checkSimulation.js +3 -16
  28. package/dist/cjs/preview/validate/index.js +3 -1
  29. package/dist/cjs/sdk/execute/ExecuteApi.js +9 -6
  30. package/dist/cjs/sdk/prepare/PrepareApi.js +4 -1
  31. package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +2 -2
  32. package/dist/esm/onchain/accounts/intents/open-strategy.js +7 -4
  33. package/dist/esm/onchain/accounts/intents/realize.js +10 -6
  34. package/dist/esm/onchain/accounts/intents/tail.js +3 -2
  35. package/dist/esm/onchain/accounts/intents/testing/market.js +1 -1
  36. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +18 -1
  37. package/dist/esm/onchain/accounts/intents/tests/add-collateral.fixtures.js +4 -4
  38. package/dist/esm/onchain/accounts/intents/tests/adjust-leverage.fixtures.js +15 -15
  39. package/dist/esm/onchain/accounts/intents/tests/deposit.fixtures.js +13 -13
  40. package/dist/esm/onchain/accounts/intents/tests/finish-decrease-leverage.fixtures.js +2 -2
  41. package/dist/esm/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +2 -2
  42. package/dist/esm/onchain/accounts/intents/tests/withdraw-asset.fixtures.js +4 -4
  43. package/dist/esm/onchain/accounts/intents/tests/withdraw.fixtures.js +7 -7
  44. package/dist/esm/onchain/accounts/intents/utils/adjust-state-to-snapshot.js +8 -5
  45. package/dist/esm/onchain/accounts/intents/utils/common.js +2 -2
  46. package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +4 -4
  47. package/dist/esm/onchain/accounts/intents/view.js +2 -2
  48. package/dist/esm/onchain/market/MarketSuite.js +15 -0
  49. package/dist/esm/onchain/market/math.js +6 -2
  50. package/dist/esm/onchain/pools/PoolService.js +25 -29
  51. package/dist/esm/preview/index.js +2 -2
  52. package/dist/esm/preview/preview/buildDelayedPreview.js +4 -4
  53. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +3 -3
  54. package/dist/esm/preview/preview/previewCloseOrRepayCreditAccount.js +1 -1
  55. package/dist/esm/preview/preview/previewOpenCreditAccount.js +7 -7
  56. package/dist/esm/preview/validate/checkOperation.js +45 -37
  57. package/dist/esm/preview/validate/checkSimulation.js +5 -18
  58. package/dist/esm/preview/validate/index.js +2 -2
  59. package/dist/esm/sdk/execute/ExecuteApi.js +9 -6
  60. package/dist/esm/sdk/prepare/PrepareApi.js +4 -1
  61. package/dist/types/model/index.d.ts +2 -2
  62. package/dist/types/model/previews.d.ts +59 -109
  63. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +15 -29
  64. package/dist/types/onchain/accounts/intents/testing/expect.d.ts +6 -2
  65. package/dist/types/onchain/accounts/intents/testing/market.d.ts +1 -1
  66. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +1 -1
  67. package/dist/types/onchain/accounts/intents/tests/add-collateral.fixtures.d.ts +1 -1
  68. package/dist/types/onchain/accounts/intents/tests/adjust-leverage.fixtures.d.ts +2 -2
  69. package/dist/types/onchain/accounts/intents/tests/deposit.fixtures.d.ts +2 -2
  70. package/dist/types/onchain/accounts/intents/tests/withdraw-asset.fixtures.d.ts +1 -1
  71. package/dist/types/onchain/accounts/intents/tests/withdraw.fixtures.d.ts +2 -2
  72. package/dist/types/onchain/accounts/intents/types.d.ts +8 -59
  73. package/dist/types/onchain/accounts/intents/utils/adjust-state-to-snapshot.d.ts +2 -2
  74. package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +3 -3
  75. package/dist/types/onchain/market/MarketSuite.d.ts +13 -1
  76. package/dist/types/onchain/market/math.d.ts +5 -1
  77. package/dist/types/onchain/pools/types.d.ts +6 -4
  78. package/dist/types/preview/index.d.ts +2 -2
  79. package/dist/types/preview/preview/buildDelayedPreview.d.ts +1 -1
  80. package/dist/types/preview/validate/checkOperation.d.ts +24 -7
  81. package/dist/types/preview/validate/index.d.ts +2 -2
  82. package/package.json +1 -1
@@ -34,7 +34,7 @@ declare const QUOTA_ANY_DELTA: bigint;
34
34
  interface WithdrawAssetCase {
35
35
  intent: WithdrawAssetIntent;
36
36
  tokens: ReturnType<typeof caToken>[];
37
- accountDebt: bigint;
37
+ totalDebt: bigint;
38
38
  totalValue: bigint;
39
39
  ops: ExpectedFlowOp[];
40
40
  rwaAssets?: Record<Address, Address>;
@@ -20,9 +20,9 @@ declare const QUOTA_DELTA: bigint;
20
20
  interface WithdrawCase {
21
21
  intent: WithdrawStrategyIntent;
22
22
  tokens: ReturnType<typeof caToken>[];
23
- accountDebt: bigint;
23
+ totalDebt: bigint;
24
24
  totalValue: bigint;
25
- accountDebtAfter: bigint;
25
+ totalDebtAfter: bigint;
26
26
  ops: ExpectedFlowOp[];
27
27
  rwaAssets?: Record<Address, Address>;
28
28
  }
@@ -1,9 +1,7 @@
1
- import { Bps, Leverage, TokenAmount } from "../../../model/primitives.js";
2
1
  import { DelayedIntent } from "../../../model/delayed-intents.js";
3
- import { BorrowRateBreakdown } from "../../../model/positions.js";
2
+ import { AccountProjection } from "../../../model/previews.js";
4
3
  import "../../../model/index.js";
5
4
  import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
6
- import { Asset } from "../../base/types.js";
7
5
  import { RouterCASlice } from "../../router/types.js";
8
6
  import { MultiCall } from "../../types/transactions.js";
9
7
  import { OnchainSDK } from "../../OnchainSDK.js";
@@ -19,7 +17,7 @@ import { Address } from "viem";
19
17
  */
20
18
  type CreditAccountSlice = Omit<RouterCASlice, "debt"> & {
21
19
  /** either base debt or debt plus interest and fees */
22
- accountDebt: bigint;
20
+ totalDebt: bigint;
23
21
  };
24
22
  /**
25
23
  * Price impact against three bases: the routed output, net value, total value.
@@ -32,61 +30,12 @@ interface PathLossRate {
32
30
  netValuePriceImpact: bigint;
33
31
  totalValuePriceImpact: bigint;
34
32
  }
35
- /** Projected account metrics once the operations execute. */
36
- interface OperationState {
37
- /**
38
- * Health factor in basis points: below `10000` the account is liquidatable.
39
- *
40
- * @example `12500` for a health factor of 1.25
41
- **/
42
- healthFactor: Bps;
43
- /**
44
- * The same factor with collateral valued at safe prices, present only where
45
- * the walk had reason to compute it — a call that hands funds over, which is
46
- * the one the credit manager weighs at safe prices on-chain.
47
- **/
48
- safeHealthFactor?: Bps;
49
- /**
50
- * Cost of the debt, broken down by source.
51
- **/
52
- borrowRate: BorrowRateBreakdown;
53
- /**
54
- * Estimated milliseconds until the health factor decays to `10000` under
55
- * the current borrow rate, or `null` when the debt carries no rate (or the
56
- * account is already liquidatable).
57
- **/
58
- timeToLiquidation: bigint | null;
59
- /**
60
- * Price of the single non-underlying collateral at which the account
61
- * becomes liquidatable, in the oracle's 8-decimal fixed point, or `null`
62
- * when the account holds zero or several non-underlying assets.
63
- **/
64
- liquidationPrice: bigint | null;
65
- /** Account TVL after operation */
66
- totalValue: bigint;
67
- /**
68
- * Account debt after operation: principal plus accrued interest and fees,
69
- * the amount it would take to settle the loan — the same quantity the
70
- * preview module reports as `debt`.
71
- */
72
- accountDebt: bigint;
73
- /**
74
- * Leverage after operation in the read model's convention — `debt / equity`,
75
- * as `Position.leverage` reports it — not the calculator's `TVL / collateral`.
76
- */
77
- leverage: Leverage;
78
- /**
79
- * What the account holds after the operation, priced: the same shape the
80
- * read model and the transaction previews report holdings in, so a caller
81
- * showing them needs no registry or oracle of its own.
82
- */
83
- assets: TokenAmount[];
84
- /**
85
- * Every quota the account stands at after the operation: the ones the plan
86
- * resized as well as the ones it left alone. Tokens it leaves unquoted are
87
- * absent rather than present at zero.
88
- */
89
- quotas: Record<Address, Asset>;
33
+ /**
34
+ * What the operations leave the account at, in the shared
35
+ * {@link AccountProjection} vocabulary, plus the one thing only a routed walk
36
+ * can report.
37
+ */
38
+ interface OperationState extends AccountProjection {
90
39
  /**
91
40
  * What the routed legs lost to market depth. `undefined` where nothing was
92
41
  * routed or nothing could be measured — never a manufactured zero.
@@ -5,8 +5,8 @@ import { Address } from "viem";
5
5
  //#region src/onchain/accounts/intents/utils/adjust-state-to-snapshot.d.ts
6
6
  /**
7
7
  * Maps an intents {@link OperationState} onto the {@link AccountSnapshot} that
8
- * position-metric functions take. `accountDebt` is treated as total debt
9
- * (principal plus accrued interest and fees).
8
+ * position-metric functions take: the state prices what it reports, a snapshot
9
+ * only names it.
10
10
  **/
11
11
  declare function adjustStateToSnapshot(creditManager: Address, state: OperationState): AccountSnapshot;
12
12
  //#endregion
@@ -7,9 +7,9 @@ import { Address } from "viem";
7
7
  /**
8
8
  * Narrows full account data down to the slice the intent engine operates on.
9
9
  *
10
- * `accountDebt` is the total repayable debt (principal + accrued interest +
11
- * accrued fees) rather than the principal, because every debt-touching intent
12
- * settles the full outstanding amount.
10
+ * `totalDebt` is the total repayable debt (principal + accrued interest +
11
+ * accrued fees) rather than `CreditAccountData.debt`'s principal, because every
12
+ * debt-touching intent settles the full outstanding amount.
13
13
  *
14
14
  * Addresses are lowercased so that `eq` comparisons and `AddressMap` lookups
15
15
  * behave consistently everywhere downstream.
@@ -1,4 +1,4 @@
1
- import { Token, UnderlyingToken } from "../../model/primitives.js";
1
+ import { Token, TokenAmount, UnderlyingToken } from "../../model/primitives.js";
2
2
  import { Curator } from "../../model/curators.js";
3
3
  import { Opportunity, OpportunityFilter, PoolOpportunity, PoolOpportunityDetail, PriceFeedSummary, QuotaAsset } from "../../model/opportunities.js";
4
4
  import "../../model/index.js";
@@ -101,6 +101,18 @@ declare class MarketSuite extends SDKConstruct {
101
101
  * wrapper itself, e.g. USDC rather than dcUSDC (which will be "wrappedAddress" in this case)
102
102
  */
103
103
  get underlyingToken(): UnderlyingToken;
104
+ /**
105
+ * Prices a figure already denominated in this market's underlying — a debt,
106
+ * a TVL, a payout — as the read model reports one.
107
+ *
108
+ * The token it names is {@link underlyingToken}, so an amount coming out of a
109
+ * preview or a simulation carries the same identity as the one on a
110
+ * `StrategyPosition`: USDC on an RWA market, not the dcUSDC wrapper the pool
111
+ * actually holds. The two convert one-for-one, so the figure is exact either
112
+ * way; only the label differs, and a caller showing both side by side must
113
+ * not see two.
114
+ **/
115
+ toUnderlyingAmount: (value: bigint) => TokenAmount;
104
116
  /**
105
117
  * Display name of this market's pool, e.g. `"USDC Pool"`.
106
118
  */
@@ -26,12 +26,16 @@ declare function bpsToRay(bps: Bps): bigint;
26
26
  /**
27
27
  * Converts a USD value in the oracle's 8-decimal fixed point to a float.
28
28
  *
29
- * Values below {@link USD_DUST_THRESHOLD} report as `0`.
29
+ * Values whose magnitude is below {@link USD_DUST_THRESHOLD} report as `0`.
30
+ * The threshold is weighed on the magnitude because the deltas the model
31
+ * carries — a debt repaid, a balance sold — are negative, and dust is dust in
32
+ * either direction.
30
33
  *
31
34
  * @example
32
35
  * ```ts
33
36
  * // usd: $1500.50 in 8-decimal fixed point
34
37
  * usdToNumber(150_050_000_000n) // 1500.5
38
+ * usdToNumber(-150_050_000_000n) // -1500.5
35
39
  * ```
36
40
  **/
37
41
  declare function usdToNumber(usd: bigint): number;
@@ -1,3 +1,4 @@
1
+ import { Amount, TokenAmount } from "../../model/primitives.js";
1
2
  import { PoolPosition } from "../../model/positions.js";
2
3
  import "../../model/index.js";
3
4
  import { Asset, PermitResult } from "../base/types.js";
@@ -135,11 +136,11 @@ interface PoolSimulation {
135
136
  /**
136
137
  * Token and amount leaving the wallet — exactly what was asked for.
137
138
  **/
138
- tokenIn: Asset;
139
+ tokenIn: TokenAmount;
139
140
  /**
140
141
  * Token and amount arriving in the wallet at the rate the pool state implies.
141
142
  **/
142
- tokenOut: Asset;
143
+ tokenOut: TokenAmount;
143
144
  /**
144
145
  * Zapper the operation would be routed through; unset for direct pool
145
146
  * operations.
@@ -150,9 +151,10 @@ interface PoolSimulation {
150
151
  * shaved by a hair so a withdrawal sized against it does not fail on rounding.
151
152
  *
152
153
  * The conversion is a rate, not a promise that the pool is liquid enough, so
153
- * compare `tokenOut.balance` against this to see if the withdrawal fits.
154
+ * compare `tokenOut.value` against `availableLiquidity.value` to see if the
155
+ * withdrawal fits.
154
156
  **/
155
- availableLiquidity?: bigint;
157
+ availableLiquidity?: Amount;
156
158
  }
157
159
  /**
158
160
  * Props for {@link IPoolsService.listPositions}.
@@ -38,7 +38,7 @@ 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, collateralIssuesOf } from "./validate/checkOperation.js";
41
+ import { CheckOperationOptions, 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, buildDelayedPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssuesOf, detectDelayedClaim, detectDelayedOperation, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustCreditAccount, previewCloseOrRepayCreditAccount, previewOperation, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
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, buildDelayedPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssue, detectDelayedClaim, detectDelayedOperation, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, marketIssues, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustCreditAccount, previewCloseOrRepayCreditAccount, previewOperation, quotaCountIssue, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
@@ -17,7 +17,7 @@ import { Address } from "viem";
17
17
  * nothing and set a non-fatal `ERROR_UNPRICEABLE_TOKEN` error on the
18
18
  * preview.
19
19
  *
20
- * The changes (e.g. `debtChange`) are reported relative to the account
20
+ * The changes (e.g. `totalDebtChange`) are reported relative to the account
21
21
  * state before the whole transaction.
22
22
  *
23
23
  * @param afterInstant - Account state after the instant part of the
@@ -1,7 +1,8 @@
1
1
  import { Bps } from "../../model/primitives.js";
2
- import { OperationPreview } from "../../model/previews.js";
2
+ import { AccountProjection, OperationPreview } from "../../model/previews.js";
3
3
  import "../../model/index.js";
4
4
  import { AddressMap } from "../../onchain/utils/AddressMap.js";
5
+ import { CreditSuite } from "../../onchain/market/credit/CreditSuite.js";
5
6
  import { OnchainSDK } from "../../onchain/OnchainSDK.js";
6
7
  import { PreviewIssue } from "../../onchain/validation/refusal.js";
7
8
  import "../../onchain/index.js";
@@ -37,10 +38,26 @@ declare function checkOperation(input: {
37
38
  sdk: OnchainSDK;
38
39
  preview: OperationPreview;
39
40
  }, options?: CheckOperationOptions): PreviewIssue | null;
40
- /** The two collateral bars, shared by the preview and the simulation paths. */
41
- declare function collateralIssuesOf(factors: {
42
- healthFactor: Bps | undefined;
43
- safeHealthFactor: Bps | undefined;
44
- }, options: CheckOperationOptions): PreviewIssue | null;
41
+ /** What the market itself refuses, whatever the operation does. */
42
+ declare function marketIssues(suite: CreditSuite): PreviewIssue | null;
43
+ /**
44
+ * A bar that reads nothing but the projected account, so a parsed transaction
45
+ * and a simulated one are held to it by the same code.
46
+ *
47
+ * These stay separate functions rather than one block because the order the
48
+ * checks run in is the answer: `checkOperation` interleaves the checks that
49
+ * need an operation's *delta* between them, and the caller acts on the first
50
+ * issue reported.
51
+ */
52
+ declare function quotaCountIssue(suite: CreditSuite, projection: AccountProjection): PreviewIssue | null;
53
+ /**
54
+ * The account against whichever bars the caller holds it to.
55
+ *
56
+ * A loan-free account is nothing to weigh: the health factor reports its
57
+ * zero-debt sentinel and no bar applies.
58
+ *
59
+ * {@inheritDoc quotaCountIssue}
60
+ */
61
+ declare function collateralIssue(projection: AccountProjection, options: CheckOperationOptions): PreviewIssue | null;
45
62
  //#endregion
46
- export { CheckOperationOptions, checkOperation, collateralIssuesOf };
63
+ export { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue };
@@ -1,3 +1,3 @@
1
- import { CheckOperationOptions, checkOperation, collateralIssuesOf } from "./checkOperation.js";
1
+ import { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./checkOperation.js";
2
2
  import { checkSimulation } from "./checkSimulation.js";
3
- export { CheckOperationOptions, checkOperation, checkSimulation, collateralIssuesOf };
3
+ export { CheckOperationOptions, checkOperation, checkSimulation, collateralIssue, marketIssues, quotaCountIssue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.0.0-next.22",
3
+ "version": "16.0.0-next.23",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {