@gearbox-protocol/sdk 16.0.0-next.27 → 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/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/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/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/model/previews.js +23 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- 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/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/positions/PositionsService.js +79 -0
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- 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/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/preview/validate/checkOperation.js +13 -9
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/model/previews.d.ts +202 -76
- 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/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/package.json +1 -1
- package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +0 -12
- package/dist/types/preview/preview/previewPoolOperation.d.ts +0 -11
|
@@ -15,8 +15,8 @@ import { Notice, NoticeKind, NoticeSubject } from "./notices.js";
|
|
|
15
15
|
import { noticeKindSchema, noticeSchema } from "./notices.schema.js";
|
|
16
16
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
17
17
|
import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
18
|
-
import {
|
|
18
|
+
import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, Estimated, EstimatedProjection, OperationPreview, OperationPreviewError, PoolOperationType, PreviewAdjustStrategyVerify, PreviewDelayedStrategyVerify, PreviewExitStrategyVerify, PreviewInstantStrategyVerify, PreviewLpVerify, PreviewOpenStrategyVerify, PreviewOperationInput, PreviewOperationOptions, PreviewRepayStrategyVerify, RoutedField, asEstimated } from "./previews.js";
|
|
19
19
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
20
20
|
import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
|
|
21
21
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
22
|
-
export { AccountProjection,
|
|
22
|
+
export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, Amount, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedWithdrawCollateralIntent, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, Estimated, EstimatedProjection, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, PreviewAdjustStrategyVerify, PreviewDelayedStrategyVerify, PreviewExitStrategyVerify, PreviewInstantStrategyVerify, PreviewLpVerify, PreviewOpenStrategyVerify, PreviewOperationInput, PreviewOperationOptions, PreviewRepayStrategyVerify, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, ResponseMetadata, Rewards, RewardsPnL, RoutedField, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, amountSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema };
|
|
@@ -4,7 +4,7 @@ import { BorrowRateBreakdown } from "./positions.js";
|
|
|
4
4
|
import { Address, Hex } from "viem";
|
|
5
5
|
//#region src/model/previews.d.ts
|
|
6
6
|
/**
|
|
7
|
-
* ERC4626 pool operation kind, as surfaced on a {@link
|
|
7
|
+
* ERC4626 pool operation kind, as surfaced on a {@link PreviewLpVerify}.
|
|
8
8
|
**/
|
|
9
9
|
type PoolOperationType = "Deposit" | "Mint" | "Withdraw" | "Redeem";
|
|
10
10
|
/**
|
|
@@ -96,7 +96,12 @@ interface OperationPreviewError {
|
|
|
96
96
|
*/
|
|
97
97
|
message: string;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
/**
|
|
100
|
+
* What a pool transaction that already exists would do — the counterpart of
|
|
101
|
+
* `prepare.deposit`, `prepare.withdraw` and `prepare.redeem`, read off calldata
|
|
102
|
+
* rather than planned into it.
|
|
103
|
+
**/
|
|
104
|
+
interface PreviewLpVerify {
|
|
100
105
|
operation: PoolOperationType;
|
|
101
106
|
/**
|
|
102
107
|
* Pool address
|
|
@@ -138,25 +143,49 @@ interface PoolOperationPreview {
|
|
|
138
143
|
error?: OperationPreviewError;
|
|
139
144
|
}
|
|
140
145
|
/**
|
|
141
|
-
*
|
|
142
|
-
* SDK: `prepare`, which walks a request forward into the calls that realise it,
|
|
143
|
-
* and `preview`, which decodes calls that already exist and replays them back.
|
|
146
|
+
* What an account is worth and what it is made of, once an operation has run.
|
|
144
147
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* names — an RWA market reports USDC, not the dcUSDC wrapper the pool holds.
|
|
148
|
+
* The measured half of a {@link AccountProjection}: read off the balances the
|
|
149
|
+
* walk arrived at, without a formula between them and the answer.
|
|
148
150
|
**/
|
|
149
|
-
interface
|
|
151
|
+
interface AccountHoldings {
|
|
150
152
|
/**
|
|
151
|
-
*
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*/
|
|
155
|
-
creditManager: Address;
|
|
153
|
+
* Everything the account holds, denominated in the market's underlying.
|
|
154
|
+
**/
|
|
155
|
+
totalValue: TokenAmount;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
* What it would take to settle the loan: principal plus accrued interest and
|
|
158
|
+
* fees, in the market's underlying.
|
|
159
|
+
**/
|
|
160
|
+
totalDebt: TokenAmount;
|
|
161
|
+
/**
|
|
162
|
+
* Own funds in the position: `totalValue` less `totalDebt`, in the market's
|
|
163
|
+
* underlying. The read model leaves a strategy caller to subtract these two
|
|
164
|
+
* itself; a projection reports the figure so an "own funds" row reads the
|
|
165
|
+
* same on every screen that shows one.
|
|
166
|
+
**/
|
|
167
|
+
netValue: TokenAmount;
|
|
168
|
+
/**
|
|
169
|
+
* What the account holds, token by token.
|
|
170
|
+
**/
|
|
171
|
+
assets: TokenAmount[];
|
|
172
|
+
/**
|
|
173
|
+
* Quota bought for each collateral, denominated in the market's underlying
|
|
174
|
+
* rather than in the collateral token — the same convention as
|
|
175
|
+
* {@link PositionCollateral.quota}. A token the account leaves unquoted is
|
|
176
|
+
* absent rather than present at zero.
|
|
177
|
+
**/
|
|
178
|
+
quotas: TokenAmount[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The risk and cost of an account, derived from what it holds.
|
|
182
|
+
*
|
|
183
|
+
* The computed half of a {@link AccountProjection}, and the reason it is a type
|
|
184
|
+
* of its own: every one of these is a formula over the same
|
|
185
|
+
* {@link AccountSnapshot}, so both halves of the SDK get them from one place —
|
|
186
|
+
* `sdk.positions.metrics` — and cannot drift into two answers for one account.
|
|
187
|
+
**/
|
|
188
|
+
interface AccountMetrics {
|
|
160
189
|
/**
|
|
161
190
|
* Health factor in basis points: below `10000` the account is liquidatable.
|
|
162
191
|
*
|
|
@@ -168,16 +197,20 @@ interface AccountProjection {
|
|
|
168
197
|
* token's main and reserve oracle feeds, which is what the credit manager
|
|
169
198
|
* switches to for a call that hands funds over.
|
|
170
199
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
200
|
+
* Always reported, whether or not the operation in question hands anything
|
|
201
|
+
* over: which of the two factors decides a transaction is a property of the
|
|
202
|
+
* call the caller ends up sending, and a screen showing the account is
|
|
203
|
+
* entitled to both.
|
|
175
204
|
*
|
|
176
205
|
* @example `11800` where `healthFactor` is `12500`
|
|
177
206
|
**/
|
|
178
|
-
safeHealthFactor
|
|
207
|
+
safeHealthFactor: Bps;
|
|
179
208
|
/**
|
|
180
209
|
* Cost of the debt, broken down by source.
|
|
210
|
+
*
|
|
211
|
+
* Half of the breakdown rests on the debt and the quotas alone (`base`,
|
|
212
|
+
* `totalOnDebt`) and half on the position's value (`total`, `quotas[].rate`),
|
|
213
|
+
* which is why it counts as a {@link RoutedField}.
|
|
181
214
|
**/
|
|
182
215
|
borrowRate: BorrowRateBreakdown;
|
|
183
216
|
/**
|
|
@@ -197,39 +230,125 @@ interface AccountProjection {
|
|
|
197
230
|
* unleveraged; `0` if underwater.
|
|
198
231
|
**/
|
|
199
232
|
leverage: Leverage;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* A credit account as an operation leaves it, answered by both halves of the
|
|
236
|
+
* SDK: `prepare`, which walks a request forward into the calls that realise it,
|
|
237
|
+
* and `preview`, which decodes calls that already exist and replays them back.
|
|
238
|
+
*
|
|
239
|
+
* Both answer in this same vocabulary, and from the same builder
|
|
240
|
+
* (`sdk.positions.projection`), so the two descriptions of one operation can be
|
|
241
|
+
* compared field by field — which is what
|
|
242
|
+
* `previewMatchesPrepare.test.ts` does.
|
|
243
|
+
*
|
|
244
|
+
* This shape is the expected branch of a routed leg, which is what `prepare`
|
|
245
|
+
* reports; `preview` sees only the floor and answers with an
|
|
246
|
+
* {@link EstimatedProjection}, the same fields with the routed ones marked
|
|
247
|
+
* `est`. Where nothing routes the two coincide exactly.
|
|
248
|
+
*
|
|
249
|
+
* `totalDebt`, `totalValue`, `leverage` and `healthFactor` mean here exactly
|
|
250
|
+
* what they mean on a {@link StrategyPosition}, down to the token an amount
|
|
251
|
+
* names — an RWA market reports USDC, not the dcUSDC wrapper the pool holds.
|
|
252
|
+
**/
|
|
253
|
+
interface AccountProjection extends AccountHoldings, AccountMetrics {
|
|
200
254
|
/**
|
|
201
|
-
*
|
|
202
|
-
|
|
203
|
-
|
|
255
|
+
* Credit manager the account belongs to. Carried on the projection itself so
|
|
256
|
+
* a caller weighing one — `checkSimulation` among them — needs nothing beside
|
|
257
|
+
* it to find the market.
|
|
258
|
+
*/
|
|
259
|
+
creditManager: Address;
|
|
204
260
|
/**
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
261
|
+
* Human-readable credit manager name.
|
|
262
|
+
*/
|
|
263
|
+
name: string;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The fields of an {@link AccountProjection} a routed leg's outcome decides.
|
|
267
|
+
*
|
|
268
|
+
* A swap is quoted twice: the amount the pathfinder expects to return, and the
|
|
269
|
+
* floor it is willing to guarantee once slippage is allowed for. `prepare` has
|
|
270
|
+
* both and reports the expected one — that is where the position lands.
|
|
271
|
+
* `preview` reads a transaction that already exists, and calldata carries only
|
|
272
|
+
* the floor, so its answer is the worst case the same operation can settle at.
|
|
273
|
+
*
|
|
274
|
+
* Everything not listed here is the same number on either branch: the debt and
|
|
275
|
+
* the quotas are named by the calls themselves.
|
|
276
|
+
*
|
|
277
|
+
* The borrow rate is listed despite being half made of those two. `base` and
|
|
278
|
+
* `totalOnDebt` are branch-independent — the pool's rate at the projected
|
|
279
|
+
* utilization, and the quota rates over the debt — but `total` and the per-token
|
|
280
|
+
* `quotas[].rate` normalize against `totalValue`, so a floor-branch breakdown
|
|
281
|
+
* quotes the same cost against a smaller position and comes out higher. One
|
|
282
|
+
* field cannot be half prefixed, and the half that moves is the half a screen
|
|
283
|
+
* shows, so the whole breakdown carries the marker.
|
|
284
|
+
**/
|
|
285
|
+
type RoutedField = "totalValue" | "netValue" | "assets" | "healthFactor" | "safeHealthFactor" | "borrowRate" | "timeToLiquidation" | "liquidationPrice" | "leverage";
|
|
286
|
+
/**
|
|
287
|
+
* `x` becomes `estX`, for a projection assembled from the guaranteed floor.
|
|
288
|
+
*
|
|
289
|
+
* The prefix is not decoration: an `estHealthFactor` and a `healthFactor` are
|
|
290
|
+
* answers to different questions, and naming them alike would invite a screen
|
|
291
|
+
* to show one as the other or a test to hold them equal.
|
|
292
|
+
**/
|
|
293
|
+
type Estimated<T> = { [K in keyof T as `est${Capitalize<string & K>}`]: T[K]; };
|
|
294
|
+
/**
|
|
295
|
+
* A projection as `preview` can answer it: the branch-independent half under the
|
|
296
|
+
* shared names, and everything a route decides marked `est`.
|
|
297
|
+
*
|
|
298
|
+
* Same builder, same formulas, same units as an {@link AccountProjection} — only
|
|
299
|
+
* the snapshot underneath is the floor rather than the expected outcome.
|
|
300
|
+
**/
|
|
301
|
+
type EstimatedProjection = Omit<AccountProjection, RoutedField> & Estimated<Pick<AccountProjection, RoutedField>>;
|
|
302
|
+
/**
|
|
303
|
+
* Renames a projection's routed fields, for a caller that built one from floor
|
|
304
|
+
* balances.
|
|
305
|
+
*
|
|
306
|
+
* Lives beside the type so the two cannot drift: a field added to
|
|
307
|
+
* {@link RoutedField} fails to compile until it is renamed here too.
|
|
308
|
+
**/
|
|
309
|
+
declare function asEstimated(p: AccountProjection): EstimatedProjection;
|
|
310
|
+
/**
|
|
311
|
+
* What an operation moved, as opposed to where it left the account.
|
|
312
|
+
*
|
|
313
|
+
* Only `preview` reports these: it is handed both sides of the transaction and
|
|
314
|
+
* diffs them, while `prepare` is asked to reach a state and answers with the
|
|
315
|
+
* calls that get there. Split out so the two halves agree on the names for the
|
|
316
|
+
* day prepare reports deltas too.
|
|
317
|
+
**/
|
|
318
|
+
interface AccountStateChange {
|
|
209
319
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
netValue: TokenAmount;
|
|
320
|
+
* Debt after minus debt before. A repayment settles interest and fees
|
|
321
|
+
* before principal, so this is the payment itself rather than the part of
|
|
322
|
+
* it the principal happened to absorb.
|
|
323
|
+
*/
|
|
324
|
+
totalDebtChange: TokenAmount;
|
|
216
325
|
/**
|
|
217
|
-
*
|
|
218
|
-
|
|
219
|
-
|
|
326
|
+
* Quotas after minus quotas before. Denominated in the market's underlying
|
|
327
|
+
* like {@link AccountHoldings.quotas}, so `token` names the collateral the
|
|
328
|
+
* quota applies to rather than the amount's own unit.
|
|
329
|
+
*/
|
|
330
|
+
quotasChange: TokenAmount[];
|
|
220
331
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
|
|
226
|
-
|
|
332
|
+
* Assets after minus assets before.
|
|
333
|
+
*
|
|
334
|
+
* Unprefixed despite resting on the same floor balances as
|
|
335
|
+
* {@link EstimatedProjection.estAssets}: `prepare` reports no deltas at all,
|
|
336
|
+
* so there is no expected-branch figure of this name to be mistaken for.
|
|
337
|
+
*/
|
|
338
|
+
assetsChange: TokenAmount[];
|
|
227
339
|
}
|
|
228
|
-
|
|
340
|
+
/**
|
|
341
|
+
* What an account-opening transaction that already exists would do — the
|
|
342
|
+
* counterpart of `prepare.openNewStrategy`, read off calldata rather than
|
|
343
|
+
* planned into it.
|
|
344
|
+
**/
|
|
345
|
+
interface PreviewOpenStrategyVerify extends EstimatedProjection {
|
|
229
346
|
operation: "OpenCreditAccount" | "RWAOpenCreditAccount";
|
|
230
347
|
/**
|
|
231
348
|
* Collateral token this position is a strategy in: the first quoted token,
|
|
232
|
-
* with its balance taken from `
|
|
349
|
+
* with its balance taken from `estAssets` — so, like them, the floor the
|
|
350
|
+
* route guarantees rather than what it expects to return.
|
|
351
|
+
* Undefined when nothing is quoted.
|
|
233
352
|
*/
|
|
234
353
|
targetCollateral?: TokenAmount;
|
|
235
354
|
/**
|
|
@@ -242,12 +361,18 @@ interface OpenCreditAccountPreview extends AccountProjection {
|
|
|
242
361
|
collateralAdded: TokenAmount[];
|
|
243
362
|
/**
|
|
244
363
|
* Set when preview encountered non-fatal errors, all fields are
|
|
245
|
-
* still computed best-effort, but derived fields (`
|
|
246
|
-
* `targetCollateral`, `
|
|
364
|
+
* still computed best-effort, but derived fields (`estAssets`,
|
|
365
|
+
* `targetCollateral`, `estNetValue`) may be unreliable in that case.
|
|
247
366
|
*/
|
|
248
367
|
error?: OperationPreviewError;
|
|
249
368
|
}
|
|
250
|
-
|
|
369
|
+
/**
|
|
370
|
+
* What a transaction on an existing account would do — the counterpart of the
|
|
371
|
+
* `prepare` flows that adjust one (`depositStrategy`, `withdrawStrategy`,
|
|
372
|
+
* `addCollateral`, `withdrawCollateral`, `adjustLeverage`), read off calldata
|
|
373
|
+
* rather than planned into it.
|
|
374
|
+
**/
|
|
375
|
+
interface PreviewAdjustStrategyVerify extends EstimatedProjection, AccountStateChange {
|
|
251
376
|
operation: "AdjustCreditAccount";
|
|
252
377
|
/**
|
|
253
378
|
* Credit account that is being adjusted
|
|
@@ -265,22 +390,6 @@ interface AdjustCreditAccountPreview extends AccountProjection {
|
|
|
265
390
|
* Tokens that were withdrawn as collateral during account adjustment.
|
|
266
391
|
*/
|
|
267
392
|
collateralWithdrawn: TokenAmount[];
|
|
268
|
-
/**
|
|
269
|
-
* Debt after minus debt before. A repayment settles interest and fees
|
|
270
|
-
* before principal, so this is the payment itself rather than the part of
|
|
271
|
-
* it the principal happened to absorb.
|
|
272
|
-
*/
|
|
273
|
-
totalDebtChange: TokenAmount;
|
|
274
|
-
/**
|
|
275
|
-
* Quotas after minus quotas before. Denominated in the market's underlying
|
|
276
|
-
* like {@link AccountProjection.quotas}, so `token` names the collateral the
|
|
277
|
-
* quota applies to rather than the amount's own unit.
|
|
278
|
-
*/
|
|
279
|
-
quotasChange: TokenAmount[];
|
|
280
|
-
/**
|
|
281
|
-
* Assets after minus assets before
|
|
282
|
-
*/
|
|
283
|
-
assetsChange: TokenAmount[];
|
|
284
393
|
/**
|
|
285
394
|
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
286
395
|
* multicall claims a delayed withdrawal
|
|
@@ -288,12 +397,21 @@ interface AdjustCreditAccountPreview extends AccountProjection {
|
|
|
288
397
|
intent?: DelayedIntent;
|
|
289
398
|
/**
|
|
290
399
|
* Set when preview encountered non-fatal errors, all fields are
|
|
291
|
-
* still computed best-effort, but derived fields (`
|
|
292
|
-
* `
|
|
400
|
+
* still computed best-effort, but derived fields (`estAssets`, `assetsChange`,
|
|
401
|
+
* `estTotalValue`) may be unreliable in that case.
|
|
293
402
|
*/
|
|
294
403
|
error?: OperationPreviewError;
|
|
295
404
|
}
|
|
296
|
-
|
|
405
|
+
/**
|
|
406
|
+
* What an exit transaction that already exists would do — the counterpart of
|
|
407
|
+
* `prepare.withdrawStrategy` asked for everything, read off calldata rather
|
|
408
|
+
* than planned into it.
|
|
409
|
+
*
|
|
410
|
+
* Carries no {@link AccountProjection}: the account it describes ends up empty,
|
|
411
|
+
* so there is no position left to weigh — what a caller wants to know is the
|
|
412
|
+
* payout.
|
|
413
|
+
**/
|
|
414
|
+
interface PreviewExitStrategyVerify {
|
|
297
415
|
operation: "CloseCreditAccount";
|
|
298
416
|
/**
|
|
299
417
|
* True when the account is closed permanently (facade `closeCreditAccount`
|
|
@@ -333,7 +451,15 @@ interface CloseCreditAccountPreview {
|
|
|
333
451
|
*/
|
|
334
452
|
error?: OperationPreviewError;
|
|
335
453
|
}
|
|
336
|
-
|
|
454
|
+
/**
|
|
455
|
+
* What a settling repayment that already exists would do — the counterpart of
|
|
456
|
+
* `prepare.repayStrategy` asked for the whole debt, read off calldata rather
|
|
457
|
+
* than planned into it.
|
|
458
|
+
*
|
|
459
|
+
* Carries no {@link AccountProjection} for the same reason the exit does not:
|
|
460
|
+
* the loan ends here, so the risk metrics have nothing left to describe.
|
|
461
|
+
**/
|
|
462
|
+
interface PreviewRepayStrategyVerify {
|
|
337
463
|
operation: "RepayCreditAccount";
|
|
338
464
|
/**
|
|
339
465
|
* True when the account is closed permanently (facade `closeCreditAccount`
|
|
@@ -369,7 +495,7 @@ interface RepayCreditAccountPreview {
|
|
|
369
495
|
/**
|
|
370
496
|
* Total debt repaid: principal + accrued interest + fees, in underlying.
|
|
371
497
|
*
|
|
372
|
-
* The same quantity
|
|
498
|
+
* The same quantity a {@link PreviewAdjustStrategyVerify} reports as
|
|
373
499
|
* `totalDebtChange`, with the sign a repayment screen reads: positive for
|
|
374
500
|
* what the wallet parted with.
|
|
375
501
|
*/
|
|
@@ -391,14 +517,14 @@ interface RepayCreditAccountPreview {
|
|
|
391
517
|
* account: what the transaction does in the same block, before any delayed
|
|
392
518
|
* withdrawal is claimed.
|
|
393
519
|
*/
|
|
394
|
-
type
|
|
520
|
+
type PreviewInstantStrategyVerify = PreviewAdjustStrategyVerify | PreviewExitStrategyVerify | PreviewRepayStrategyVerify;
|
|
395
521
|
/**
|
|
396
522
|
* Preview of a multicall that requests a delayed withdrawal (e.g. Securitize
|
|
397
523
|
* redemption): the source token is spent now and a withdrawal phantom token is received;
|
|
398
524
|
* the actual claim token materializes later, when the withdrawal is claimed and
|
|
399
525
|
* the recorded (if any) is resumed
|
|
400
526
|
*/
|
|
401
|
-
interface
|
|
527
|
+
interface PreviewDelayedStrategyVerify {
|
|
402
528
|
operation: "DelayedCreditAccountOperation";
|
|
403
529
|
/**
|
|
404
530
|
* Credit account the operation is performed on
|
|
@@ -421,19 +547,19 @@ interface DelayedCreditAccountOperationPreview {
|
|
|
421
547
|
* What this transaction does right now: the delayed withdrawal is
|
|
422
548
|
* represented by the phantom token among the account's assets
|
|
423
549
|
*/
|
|
424
|
-
instantPreview:
|
|
550
|
+
instantPreview: PreviewInstantStrategyVerify;
|
|
425
551
|
/**
|
|
426
552
|
* Best-effort state after the withdrawal is claimed and the intent is
|
|
427
553
|
* resumed; claim-only (phantom burned, claim token received) when
|
|
428
554
|
* `intent` is undefined
|
|
429
555
|
*/
|
|
430
|
-
delayedPreview:
|
|
556
|
+
delayedPreview: PreviewInstantStrategyVerify;
|
|
431
557
|
}
|
|
432
558
|
/**
|
|
433
559
|
* Result of previewing a raw operation calldata: currently pool operations and
|
|
434
560
|
* credit account opening, adjustment, closure, repayment and delayed
|
|
435
561
|
* withdrawal operations are supported.
|
|
436
562
|
*/
|
|
437
|
-
type OperationPreview =
|
|
563
|
+
type OperationPreview = PreviewLpVerify | PreviewOpenStrategyVerify | PreviewAdjustStrategyVerify | PreviewExitStrategyVerify | PreviewRepayStrategyVerify | PreviewDelayedStrategyVerify;
|
|
438
564
|
//#endregion
|
|
439
|
-
export {
|
|
565
|
+
export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, Estimated, EstimatedProjection, OperationPreview, OperationPreviewError, PoolOperationType, PreviewAdjustStrategyVerify, PreviewDelayedStrategyVerify, PreviewExitStrategyVerify, PreviewInstantStrategyVerify, PreviewLpVerify, PreviewOpenStrategyVerify, PreviewOperationInput, PreviewOperationOptions, PreviewRepayStrategyVerify, RoutedField, asEstimated };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokenAmount } from "../../../model/primitives.js";
|
|
2
2
|
import { AccountProjection } from "../../../model/previews.js";
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { Asset } from "../../base/types.js";
|
|
@@ -33,12 +33,6 @@ interface OpenStrategyProps {
|
|
|
33
33
|
* both `minQuota` and `averageQuota`, so there is nothing to gain by dropping one.
|
|
34
34
|
*/
|
|
35
35
|
interface OpenStrategyPreview extends Omit<AccountProjection, "assets" | "quotas"> {
|
|
36
|
-
/**
|
|
37
|
-
* The same factor with collateral valued at safe prices, which is what the
|
|
38
|
-
* credit manager weighs an opening at on-chain. Always reported here: an
|
|
39
|
-
* opening always hands the pool's funds over.
|
|
40
|
-
**/
|
|
41
|
-
safeHealthFactor: Bps;
|
|
42
36
|
/** What the routed leg lost to market depth; `undefined` if not measured. */
|
|
43
37
|
priceImpact: PathLossRate | undefined;
|
|
44
38
|
/** Expected post-open balances. */
|
|
@@ -74,6 +74,7 @@ interface MarketSdkExtras {
|
|
|
74
74
|
forbiddenTokens?: Address[];
|
|
75
75
|
/** What a routed swap returns; linear when omitted. */
|
|
76
76
|
routeQuote?: (amount: bigint) => bigint;
|
|
77
|
+
routeFloor?: (amount: bigint) => bigint;
|
|
77
78
|
}
|
|
78
79
|
/** Mock SDK on the shared fixture market. */
|
|
79
80
|
declare function buildMarketSdk(extras?: MarketSdkExtras): OnchainSDK;
|
|
@@ -121,6 +121,13 @@ interface BuildMockSdkArgs {
|
|
|
121
121
|
* same proportion.
|
|
122
122
|
*/
|
|
123
123
|
routeQuote?: (amount: bigint) => bigint;
|
|
124
|
+
/**
|
|
125
|
+
* The floor a route guarantees, from what it expects to return. The default
|
|
126
|
+
* quotes no slippage at all — floor and expectation coincide — which is what
|
|
127
|
+
* every case that is not about the difference between the two wants, since it
|
|
128
|
+
* keeps the projected state and the amounts in the calls one number.
|
|
129
|
+
*/
|
|
130
|
+
routeFloor?: (amount: bigint) => bigint;
|
|
124
131
|
}
|
|
125
132
|
/** One redemption venue of the mock compressor. */
|
|
126
133
|
interface MockDelayedVenue {
|
|
@@ -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 };
|