@gearbox-protocol/sdk 16.0.0-next.22 → 16.0.0-next.24
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/maxWithdrawCollateral.js +2 -2
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +9 -4
- package/dist/cjs/onchain/accounts/intents/realize.js +13 -6
- package/dist/cjs/onchain/accounts/intents/tail.js +3 -2
- package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +19 -1
- package/dist/cjs/onchain/accounts/intents/tests/add-collateral.fixtures.js +4 -4
- package/dist/cjs/onchain/accounts/intents/tests/adjust-leverage.fixtures.js +15 -15
- package/dist/cjs/onchain/accounts/intents/tests/deposit.fixtures.js +13 -13
- package/dist/cjs/onchain/accounts/intents/tests/finish-decrease-leverage.fixtures.js +2 -2
- package/dist/cjs/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +2 -2
- package/dist/cjs/onchain/accounts/intents/tests/withdraw-asset.fixtures.js +4 -4
- package/dist/cjs/onchain/accounts/intents/tests/withdraw.fixtures.js +7 -7
- package/dist/cjs/onchain/accounts/intents/utils/adjust-state-to-snapshot.js +8 -5
- package/dist/cjs/onchain/accounts/intents/utils/common.js +2 -2
- package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +4 -4
- package/dist/cjs/onchain/accounts/intents/view.js +2 -2
- package/dist/cjs/onchain/market/MarketSuite.js +15 -0
- package/dist/cjs/onchain/market/math.js +6 -2
- package/dist/cjs/onchain/pools/PoolService.js +25 -29
- package/dist/cjs/preview/index.js +3 -1
- package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -4
- package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +4 -3
- package/dist/cjs/preview/preview/previewCloseOrRepayCreditAccount.js +1 -1
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +7 -7
- package/dist/cjs/preview/validate/checkOperation.js +47 -37
- package/dist/cjs/preview/validate/checkSimulation.js +5 -18
- package/dist/cjs/preview/validate/index.js +3 -1
- package/dist/cjs/sdk/execute/ExecuteApi.js +9 -6
- package/dist/cjs/sdk/prepare/PrepareApi.js +4 -1
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +2 -2
- package/dist/esm/onchain/accounts/intents/open-strategy.js +9 -4
- package/dist/esm/onchain/accounts/intents/realize.js +13 -6
- package/dist/esm/onchain/accounts/intents/tail.js +3 -2
- package/dist/esm/onchain/accounts/intents/testing/market.js +1 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +19 -1
- package/dist/esm/onchain/accounts/intents/tests/add-collateral.fixtures.js +4 -4
- package/dist/esm/onchain/accounts/intents/tests/adjust-leverage.fixtures.js +15 -15
- package/dist/esm/onchain/accounts/intents/tests/deposit.fixtures.js +13 -13
- package/dist/esm/onchain/accounts/intents/tests/finish-decrease-leverage.fixtures.js +2 -2
- package/dist/esm/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +2 -2
- package/dist/esm/onchain/accounts/intents/tests/withdraw-asset.fixtures.js +4 -4
- package/dist/esm/onchain/accounts/intents/tests/withdraw.fixtures.js +7 -7
- package/dist/esm/onchain/accounts/intents/utils/adjust-state-to-snapshot.js +8 -5
- package/dist/esm/onchain/accounts/intents/utils/common.js +2 -2
- package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +4 -4
- package/dist/esm/onchain/accounts/intents/view.js +2 -2
- package/dist/esm/onchain/market/MarketSuite.js +15 -0
- package/dist/esm/onchain/market/math.js +6 -2
- package/dist/esm/onchain/pools/PoolService.js +25 -29
- package/dist/esm/preview/index.js +2 -2
- package/dist/esm/preview/preview/buildDelayedPreview.js +5 -4
- package/dist/esm/preview/preview/previewAdjustCreditAccount.js +4 -3
- package/dist/esm/preview/preview/previewCloseOrRepayCreditAccount.js +1 -1
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +7 -7
- package/dist/esm/preview/validate/checkOperation.js +45 -37
- package/dist/esm/preview/validate/checkSimulation.js +7 -20
- package/dist/esm/preview/validate/index.js +2 -2
- package/dist/esm/sdk/execute/ExecuteApi.js +9 -6
- package/dist/esm/sdk/prepare/PrepareApi.js +4 -1
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/model/previews.d.ts +71 -125
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +13 -29
- package/dist/types/onchain/accounts/intents/testing/expect.d.ts +6 -2
- package/dist/types/onchain/accounts/intents/testing/market.d.ts +1 -1
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +1 -1
- package/dist/types/onchain/accounts/intents/tests/add-collateral.fixtures.d.ts +1 -1
- package/dist/types/onchain/accounts/intents/tests/adjust-leverage.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/tests/deposit.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/tests/withdraw-asset.fixtures.d.ts +1 -1
- package/dist/types/onchain/accounts/intents/tests/withdraw.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +8 -59
- package/dist/types/onchain/accounts/intents/utils/adjust-state-to-snapshot.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +3 -3
- package/dist/types/onchain/market/MarketSuite.d.ts +13 -1
- package/dist/types/onchain/market/math.d.ts +5 -1
- package/dist/types/onchain/pools/types.d.ts +6 -4
- package/dist/types/preview/index.d.ts +2 -2
- package/dist/types/preview/preview/buildDelayedPreview.d.ts +1 -1
- package/dist/types/preview/validate/checkOperation.d.ts +24 -7
- package/dist/types/preview/validate/checkSimulation.d.ts +0 -2
- package/dist/types/preview/validate/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -24,9 +24,9 @@ declare const QUOTA_DOWN: bigint;
|
|
|
24
24
|
interface AdjustLeverageCase {
|
|
25
25
|
intent: AdjustLeverageIntent;
|
|
26
26
|
tokens: ReturnType<typeof caToken>[];
|
|
27
|
-
|
|
27
|
+
totalDebt: bigint;
|
|
28
28
|
totalValue: bigint;
|
|
29
|
-
|
|
29
|
+
totalDebtAfter: bigint;
|
|
30
30
|
ops: ExpectedFlowOp[];
|
|
31
31
|
rwaAssets?: Record<Address, Address>;
|
|
32
32
|
}
|
|
@@ -18,9 +18,9 @@ declare const LEV_3X = 300n;
|
|
|
18
18
|
interface DepositCase {
|
|
19
19
|
intent: DepositStrategyIntent;
|
|
20
20
|
tokens: ReturnType<typeof caToken>[];
|
|
21
|
-
|
|
21
|
+
totalDebt: bigint;
|
|
22
22
|
totalValue: bigint;
|
|
23
|
-
|
|
23
|
+
totalDebtAfter: bigint;
|
|
24
24
|
ops: ExpectedFlowOp[];
|
|
25
25
|
rwaAssets?: Record<Address, Address>;
|
|
26
26
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
23
|
+
totalDebt: bigint;
|
|
24
24
|
totalValue: bigint;
|
|
25
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
9
|
-
*
|
|
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
|
-
* `
|
|
11
|
-
* accrued fees) rather than
|
|
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:
|
|
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:
|
|
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.
|
|
154
|
+
* compare `tokenOut.value` against `availableLiquidity.value` to see if the
|
|
155
|
+
* withdrawal fits.
|
|
154
156
|
**/
|
|
155
|
-
availableLiquidity?:
|
|
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,
|
|
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,
|
|
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. `
|
|
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
|
-
/**
|
|
41
|
-
declare function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
63
|
+
export { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue };
|
|
@@ -3,7 +3,6 @@ import { PreviewIssue } from "../../onchain/validation/refusal.js";
|
|
|
3
3
|
import { OperationState } from "../../onchain/accounts/intents/types.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { CheckOperationOptions } from "./checkOperation.js";
|
|
6
|
-
import { Address } from "viem";
|
|
7
6
|
//#region src/preview/validate/checkSimulation.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Whether a simulated operation clears the caller's own bars.
|
|
@@ -28,7 +27,6 @@ import { Address } from "viem";
|
|
|
28
27
|
declare function checkSimulation(input: {
|
|
29
28
|
sdk: OnchainSDK;
|
|
30
29
|
state: OperationState;
|
|
31
|
-
creditManager: Address;
|
|
32
30
|
}, options?: CheckOperationOptions): PreviewIssue | null;
|
|
33
31
|
//#endregion
|
|
34
32
|
export { checkSimulation };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CheckOperationOptions, checkOperation,
|
|
1
|
+
import { CheckOperationOptions, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./checkOperation.js";
|
|
2
2
|
import { checkSimulation } from "./checkSimulation.js";
|
|
3
|
-
export { CheckOperationOptions, checkOperation, checkSimulation,
|
|
3
|
+
export { CheckOperationOptions, checkOperation, checkSimulation, collateralIssue, marketIssues, quotaCountIssue };
|