@gearbox-protocol/sdk 16.0.0-next.27 → 16.0.0-next.29

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 (75) hide show
  1. package/dist/cjs/model/index.js +1 -0
  2. package/dist/cjs/model/previews.js +23 -0
  3. package/dist/cjs/onchain/accounts/intents/open-strategy.js +5 -18
  4. package/dist/cjs/onchain/accounts/intents/realize.js +77 -49
  5. package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -0
  6. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +28 -5
  7. package/dist/cjs/onchain/index.js +6 -0
  8. package/dist/cjs/onchain/market/credit/creditOperationMarket.js +32 -0
  9. package/dist/cjs/onchain/market/credit/index.js +3 -0
  10. package/dist/cjs/onchain/market/index.js +5 -0
  11. package/dist/cjs/onchain/market/oracle/collateralPriceInUnderlying.js +27 -0
  12. package/dist/cjs/onchain/market/oracle/index.js +2 -0
  13. package/dist/cjs/onchain/positions/PositionsService.js +94 -0
  14. package/dist/cjs/onchain/positions/calcLiquidationPrice.js +14 -4
  15. package/dist/cjs/onchain/positions/index.js +1 -0
  16. package/dist/cjs/preview/index.js +6 -6
  17. package/dist/cjs/preview/preview/{buildDelayedPreview.js → buildDelayedStrategyVerify.js} +8 -27
  18. package/dist/cjs/preview/preview/index.js +6 -6
  19. package/dist/cjs/preview/preview/{previewAdjustCreditAccount.js → previewAdjustStrategyVerify.js} +6 -24
  20. package/dist/cjs/preview/preview/{previewCloseOrRepayCreditAccount.js → previewExitOrRepayStrategyVerify.js} +6 -7
  21. package/dist/cjs/preview/preview/{previewPoolOperation.js → previewLpVerify.js} +3 -3
  22. package/dist/cjs/preview/preview/{previewOpenCreditAccount.js → previewOpenStrategyVerify.js} +6 -26
  23. package/dist/cjs/preview/preview/previewOperation.js +13 -12
  24. package/dist/cjs/preview/validate/checkOperation.js +13 -9
  25. package/dist/esm/model/index.js +2 -2
  26. package/dist/esm/model/previews.js +23 -1
  27. package/dist/esm/onchain/accounts/intents/open-strategy.js +5 -18
  28. package/dist/esm/onchain/accounts/intents/realize.js +77 -49
  29. package/dist/esm/onchain/accounts/intents/testing/market.js +1 -0
  30. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +27 -6
  31. package/dist/esm/onchain/index.js +4 -2
  32. package/dist/esm/onchain/market/credit/creditOperationMarket.js +30 -0
  33. package/dist/esm/onchain/market/credit/index.js +2 -1
  34. package/dist/esm/onchain/market/index.js +3 -1
  35. package/dist/esm/onchain/market/oracle/collateralPriceInUnderlying.js +26 -0
  36. package/dist/esm/onchain/market/oracle/index.js +2 -1
  37. package/dist/esm/onchain/positions/PositionsService.js +95 -1
  38. package/dist/esm/onchain/positions/calcLiquidationPrice.js +14 -5
  39. package/dist/esm/onchain/positions/index.js +2 -2
  40. package/dist/esm/preview/index.js +4 -4
  41. package/dist/esm/preview/preview/{buildDelayedPreview.js → buildDelayedStrategyVerify.js} +9 -28
  42. package/dist/esm/preview/preview/index.js +4 -4
  43. package/dist/esm/preview/preview/{previewAdjustCreditAccount.js → previewAdjustStrategyVerify.js} +7 -25
  44. package/dist/esm/preview/preview/{previewCloseOrRepayCreditAccount.js → previewExitOrRepayStrategyVerify.js} +6 -7
  45. package/dist/esm/preview/preview/{previewPoolOperation.js → previewLpVerify.js} +3 -3
  46. package/dist/esm/preview/preview/{previewOpenCreditAccount.js → previewOpenStrategyVerify.js} +7 -27
  47. package/dist/esm/preview/preview/previewOperation.js +13 -12
  48. package/dist/esm/preview/validate/checkOperation.js +13 -9
  49. package/dist/types/model/index.d.ts +2 -2
  50. package/dist/types/model/previews.d.ts +222 -97
  51. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +13 -7
  52. package/dist/types/onchain/accounts/intents/testing/market.d.ts +1 -0
  53. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +18 -0
  54. package/dist/types/onchain/accounts/intents/types.d.ts +12 -0
  55. package/dist/types/onchain/index.d.ts +4 -2
  56. package/dist/types/onchain/market/credit/creditOperationMarket.d.ts +23 -0
  57. package/dist/types/onchain/market/credit/index.d.ts +2 -1
  58. package/dist/types/onchain/market/index.d.ts +3 -1
  59. package/dist/types/onchain/market/oracle/collateralPriceInUnderlying.d.ts +19 -0
  60. package/dist/types/onchain/market/oracle/index.d.ts +2 -1
  61. package/dist/types/onchain/positions/PositionsService.d.ts +38 -0
  62. package/dist/types/onchain/positions/calcLiquidationPrice.d.ts +10 -1
  63. package/dist/types/onchain/positions/index.d.ts +2 -2
  64. package/dist/types/preview/index.d.ts +5 -5
  65. package/dist/types/preview/preview/{buildDelayedPreview.d.ts → buildDelayedStrategyVerify.d.ts} +4 -4
  66. package/dist/types/preview/preview/index.d.ts +4 -4
  67. package/dist/types/preview/preview/{previewAdjustCreditAccount.d.ts → previewAdjustStrategyVerify.d.ts} +4 -4
  68. package/dist/types/preview/preview/{previewCloseOrRepayCreditAccount.d.ts → previewExitOrRepayStrategyVerify.d.ts} +4 -4
  69. package/dist/types/preview/preview/previewLpVerify.d.ts +11 -0
  70. package/dist/types/preview/preview/previewOpenStrategyVerify.d.ts +12 -0
  71. package/dist/types/preview/validate/checkOperation.d.ts +12 -4
  72. package/dist/types/preview/validate/index.d.ts +2 -2
  73. package/package.json +1 -1
  74. package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +0 -12
  75. package/dist/types/preview/preview/previewPoolOperation.d.ts +0 -11
@@ -7,13 +7,15 @@ import { SDKConstruct } from "../base/SDKConstruct.js";
7
7
  import "../base/index.js";
8
8
  import { bpsToRay, calcBorrowApy, calcPositionLeverage, healthFactorBps, usdToNumber } from "../market/math.js";
9
9
  import { strategyName } from "../market/strategyName.js";
10
+ import { creditOperationMarket } from "../market/credit/creditOperationMarket.js";
10
11
  import { isFilterSet } from "../../model/filters.js";
11
12
  import { STRATEGY_POSITION_COLLATERAL_ERROR, matchesPositionFilter } from "../../model/positions.js";
12
13
  import "../../model/index.js";
14
+ import { collateralPriceInUnderlying } from "../market/oracle/collateralPriceInUnderlying.js";
13
15
  import { borrowRateAtUtilization, utilizationAfterLiquidityChange } from "../market/pool/math.js";
14
16
  import { calcBorrowRate } from "./calcBorrowRate.js";
15
17
  import { calcHealthFactor } from "./calcHealthFactor.js";
16
- import { calcLiquidationPrice } from "./calcLiquidationPrice.js";
18
+ import { calcLiquidationPrice, soleNonUnderlyingCollateral } from "./calcLiquidationPrice.js";
17
19
  import { calcTimeToLiquidationMs } from "./calcTimeToLiquidationMs.js";
18
20
  import { accountSnapshotFromCreditAccountData } from "./types.js";
19
21
  //#region src/onchain/positions/PositionsService.ts
@@ -163,6 +165,98 @@ var PositionsService = class extends SDKConstruct {
163
165
  });
164
166
  }
165
167
  /**
168
+ * What the collateral {@link liquidationPrice} is quoted for costs in the
169
+ * market underlying right now, in the same `PRICE_DECIMALS` fixed point —
170
+ * the pair a form shows beside the liquidation price. `null` under exactly
171
+ * the conditions that leave the liquidation price `null`, plus an oracle
172
+ * that cannot answer for either side.
173
+ **/
174
+ currentPrice(snapshot) {
175
+ const market = this.sdk.marketRegister.findByCreditManager(snapshot.creditManager);
176
+ const underlying = market.pool.underlying;
177
+ const collateral = soleNonUnderlyingCollateral(snapshot, underlying);
178
+ if (!collateral) return null;
179
+ return collateralPriceInUnderlying(market.priceOracle, collateral, underlying);
180
+ }
181
+ /**
182
+ * Every derived number of an account state at once — the whole
183
+ * {@link AccountMetrics} half of a projection.
184
+ *
185
+ * This is what both halves of the SDK fill their answers from: `prepare`, for
186
+ * a state it walked an intent into, and `preview`, for one it replayed out of
187
+ * calldata. One snapshot in, one set of metrics out, so the two descriptions
188
+ * of the same operation cannot disagree because one of them grew its own
189
+ * formula.
190
+ *
191
+ * Identical to the four methods above field for field, and cheaper than
192
+ * calling them one by one: the market data is collected once, and the health
193
+ * factor and borrow rate the time to liquidation decays at are the very ones
194
+ * reported beside it.
195
+ **/
196
+ metrics(snapshot, options) {
197
+ const data = this.#marketData(snapshot);
198
+ const factor = (safePrices) => calcHealthFactor({
199
+ snapshot,
200
+ underlying: data.underlying,
201
+ decimals: data.decimals,
202
+ prices: data.prices,
203
+ reservePrices: data.reservePrices,
204
+ safePrices,
205
+ liquidationThresholds: data.liquidationThresholds,
206
+ activeQuotas: data.activeQuotas
207
+ });
208
+ const healthFactor = factor(false);
209
+ const borrowRate = calcBorrowRate({
210
+ snapshot,
211
+ baseInterestRate: this.#baseInterestRate(snapshot, data, options),
212
+ feeInterest: data.feeInterest,
213
+ quotaRates: data.quotaRates,
214
+ resolveToken: (address) => this.sdk.tokensMeta.mustGetToken(address)
215
+ });
216
+ return {
217
+ healthFactor,
218
+ safeHealthFactor: factor(true),
219
+ borrowRate,
220
+ timeToLiquidation: calcTimeToLiquidationMs(healthFactor, BigInt(borrowRate.totalOnDebt)),
221
+ liquidationPrice: calcLiquidationPrice({
222
+ snapshot,
223
+ underlying: data.underlying,
224
+ decimals: data.decimals,
225
+ liquidationThresholds: data.liquidationThresholds
226
+ }),
227
+ leverage: calcPositionLeverage(snapshot.totalValue, snapshot.totalDebt)
228
+ };
229
+ }
230
+ /**
231
+ * A projected account state as both halves of the SDK report it: the holdings
232
+ * priced and named, and the metrics of {@link PositionsService.metrics}.
233
+ *
234
+ * The snapshot is taken at its word — what it lists is what comes back, so a
235
+ * caller that drops dust before the walk reports an account without it, and
236
+ * one that keeps wei reports them. That is the whole of the policy left to
237
+ * the caller; everything downstream of the balances is decided here.
238
+ *
239
+ * @param options - The operation's effect on the pool, for the rate the
240
+ * metrics are quoted at, see {@link ProjectedPoolOptions}.
241
+ **/
242
+ projection(snapshot, options) {
243
+ const { creditManager, totalValue, totalDebt } = snapshot;
244
+ const market = this.sdk.marketRegister.findByCreditManager(creditManager);
245
+ const { priceOracle } = market;
246
+ return {
247
+ ...creditOperationMarket(this.sdk.marketRegister.findCreditManager(creditManager)),
248
+ totalValue: market.toUnderlyingAmount(totalValue),
249
+ totalDebt: market.toUnderlyingAmount(totalDebt),
250
+ netValue: market.toUnderlyingAmount(totalValue - totalDebt),
251
+ assets: snapshot.assets.map((a) => priceOracle.toTokenAmount(a.token, a.balance)),
252
+ quotas: snapshot.quotas.map((q) => ({
253
+ token: this.sdk.tokensMeta.mustGetToken(q.token),
254
+ ...priceOracle.toAmount(market.underlying, q.balance)
255
+ })),
256
+ ...this.metrics(snapshot, options)
257
+ };
258
+ }
259
+ /**
166
260
  * Builds one strategy position from an account snapshot.
167
261
  *
168
262
  * @param withdrawals - Delayed withdrawals of the account, keyed by the
@@ -10,13 +10,22 @@ import { isAddressEqual } from "viem";
10
10
  * holds exactly one non-dust non-underlying asset; otherwise `null`.
11
11
  **/
12
12
  function calcLiquidationPrice(props) {
13
- const { snapshot, underlying } = props;
14
- const targets = snapshot.assets.filter((a) => a.balance > 10n && !isAddressEqual(a.token, underlying));
15
- if (targets.length !== 1) return null;
13
+ const targetToken = soleNonUnderlyingCollateral(props.snapshot, props.underlying);
14
+ if (!targetToken) return null;
16
15
  return calcLiquidationPriceForTarget({
17
16
  ...props,
18
- targetToken: targets[0].token
17
+ targetToken
19
18
  });
20
19
  }
20
+ /**
21
+ * The one collateral a liquidation price — and the current price beside it —
22
+ * can be quoted for: the account's single non-dust, non-underlying asset.
23
+ * `null` when it holds none or several, which is the case neither figure
24
+ * exists for.
25
+ **/
26
+ function soleNonUnderlyingCollateral(snapshot, underlying) {
27
+ const targets = snapshot.assets.filter((a) => a.balance > 10n && !isAddressEqual(a.token, underlying));
28
+ return targets.length === 1 ? targets[0].token : null;
29
+ }
21
30
  //#endregion
22
- export { calcLiquidationPrice };
31
+ export { calcLiquidationPrice, soleNonUnderlyingCollateral };
@@ -1,9 +1,9 @@
1
1
  import { calcBorrowRate } from "./calcBorrowRate.js";
2
2
  import { calcHealthFactor } from "./calcHealthFactor.js";
3
3
  import { calcLiquidationPriceForTarget } from "./calcLiquidationPriceForTarget.js";
4
- import { calcLiquidationPrice } from "./calcLiquidationPrice.js";
4
+ import { calcLiquidationPrice, soleNonUnderlyingCollateral } from "./calcLiquidationPrice.js";
5
5
  import { calcTimeToLiquidationMs } from "./calcTimeToLiquidationMs.js";
6
6
  import { MultichainPositionsService } from "./MultichainPositionsService.js";
7
7
  import { accountSnapshotFromCreditAccountData } from "./types.js";
8
8
  import { PositionsService } from "./PositionsService.js";
9
- export { MultichainPositionsService, PositionsService, accountSnapshotFromCreditAccountData, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcTimeToLiquidationMs };
9
+ export { MultichainPositionsService, PositionsService, accountSnapshotFromCreditAccountData, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcTimeToLiquidationMs, soleNonUnderlyingCollateral };
@@ -19,7 +19,7 @@ import { BalancePrerequisite } from "./prerequisites/BalancePrerequisite.js";
19
19
  import { RWAOpenRequirementsPrerequisite } from "./prerequisites/RWAOpenRequirementsPrerequisite.js";
20
20
  import { checkPrerequisites } from "./prerequisites/checkPrerequisites.js";
21
21
  import "./prerequisites/index.js";
22
- import { buildDelayedPreview } from "./preview/buildDelayedPreview.js";
22
+ import { buildDelayedStrategyVerify } from "./preview/buildDelayedStrategyVerify.js";
23
23
  import { CreditAccountState } from "./preview/CreditAccountState.js";
24
24
  import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/detectCloseOrRepay.js";
25
25
  import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/detectDelayedClaim.js";
@@ -27,12 +27,12 @@ import { detectDelayedOperation } from "./preview/detectDelayedOperation.js";
27
27
  import { UnsupportedOperationError } from "./preview/errors.js";
28
28
  import { makeReplayState, replayInnerOperations } from "./preview/replayInnerOperations.js";
29
29
  import { replayMulticall } from "./preview/replayMulticall.js";
30
- import { previewAdjustCreditAccount } from "./preview/previewAdjustCreditAccount.js";
31
- import { previewCloseOrRepayCreditAccount } from "./preview/previewCloseOrRepayCreditAccount.js";
30
+ import { previewAdjustStrategyVerify } from "./preview/previewAdjustStrategyVerify.js";
31
+ import { previewExitOrRepayStrategyVerify } from "./preview/previewExitOrRepayStrategyVerify.js";
32
32
  import { previewOperation } from "./preview/previewOperation.js";
33
33
  import "./preview/index.js";
34
34
  import "./types.js";
35
35
  import { checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./validate/checkOperation.js";
36
36
  import { checkSimulation } from "./validate/checkSimulation.js";
37
37
  import "./validate/index.js";
38
- export { AllowancePrerequisite, BalancePrerequisite, CreditAccountState, IntentPreviewError, Prerequisite, RWAOpenRequirementsPrerequisite, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, WithdrawCollateralAlignmentError, 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 };
38
+ export { AllowancePrerequisite, BalancePrerequisite, CreditAccountState, IntentPreviewError, Prerequisite, RWAOpenRequirementsPrerequisite, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, WithdrawCollateralAlignmentError, 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 };
@@ -1,12 +1,12 @@
1
1
  import { AssetsMap } from "../../onchain/utils/AssetsMap.js";
2
2
  import { BigIntMath } from "../../onchain/utils/bigint-math.js";
3
3
  import { DUST_THRESHOLD } from "../../onchain/constants/math.js";
4
- import { calcPositionLeverage } from "../../onchain/market/math.js";
5
- import { ERROR_UNPRICEABLE_TOKEN } from "../../model/previews.js";
4
+ import { creditOperationMarket } from "../../onchain/market/credit/creditOperationMarket.js";
5
+ import { ERROR_UNPRICEABLE_TOKEN, asEstimated } from "../../model/previews.js";
6
6
  import "../../model/index.js";
7
7
  import "../../onchain/index.js";
8
8
  import { isAddressEqual } from "viem";
9
- //#region src/preview/preview/buildDelayedPreview.ts
9
+ //#region src/preview/preview/buildDelayedStrategyVerify.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,7 +29,7 @@ import { isAddressEqual } 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
- function buildDelayedPreview(afterInstant, before, detected, convert, receivedToken, sdk) {
32
+ function buildDelayedStrategyVerify(afterInstant, before, detected, convert, receivedToken, sdk) {
33
33
  const { request, intent } = detected;
34
34
  const post = afterInstant.clone();
35
35
  const converter = makeSafeConverter(convert);
@@ -166,49 +166,30 @@ function buildClosePreview(post, converter, receivedToken, sdk) {
166
166
  return {
167
167
  operation: "CloseCreditAccount",
168
168
  permanent: false,
169
- creditManager: post.creditManager,
170
- name: sdk.marketRegister.findCreditManager(post.creditManager).name,
169
+ ...creditOperationMarket(sdk.marketRegister.findCreditManager(post.creditManager)),
171
170
  creditAccount: post.creditAccount,
172
171
  receivedAmount: oracle.toTokenAmount(receivedToken, BigIntMath.max(totalValue - post.totalDebt, 0n)),
173
172
  error: converter.error
174
173
  };
175
174
  }
176
175
  function buildAdjustPreview(post, before, collateralWithdrawn, converter, sdk) {
177
- const totalValue = totalValueInUnderlying(post, converter.convert, DUST_THRESHOLD);
178
- const assets = post.balances.toAssets(DUST_THRESHOLD);
179
- const quotas = post.quotas.toAssets(0n);
180
- const snap = post.toSnapshot(totalValue);
176
+ const snap = post.toSnapshot(totalValueInUnderlying(post, converter.convert, DUST_THRESHOLD));
181
177
  const market = sdk.marketRegister.findByCreditManager(post.creditManager);
182
178
  const oracle = market.priceOracle;
183
179
  return {
184
180
  operation: "AdjustCreditAccount",
185
- creditManager: post.creditManager,
186
- name: sdk.marketRegister.findCreditManager(post.creditManager).name,
181
+ ...asEstimated(sdk.positions.projection(snap, { availableLiquidityChange: before.totalDebt - post.totalDebt })),
187
182
  creditAccount: post.creditAccount,
188
183
  collateralAdded: [],
189
184
  collateralWithdrawn: collateralWithdrawn.toAssets().map((a) => oracle.toTokenAmount(a.token, a.balance)),
190
- totalValue: market.toUnderlyingAmount(totalValue),
191
- totalDebt: market.toUnderlyingAmount(post.totalDebt),
192
- netValue: market.toUnderlyingAmount(totalValue - post.totalDebt),
193
185
  totalDebtChange: market.toUnderlyingAmount(post.totalDebt - before.totalDebt),
194
- quotas: quotas.map((q) => ({
195
- token: sdk.tokensMeta.mustGetToken(q.token),
196
- ...oracle.toAmount(market.underlying, q.balance)
197
- })),
198
186
  quotasChange: post.quotas.difference(before.quotas).toAssets().map((q) => ({
199
187
  token: sdk.tokensMeta.mustGetToken(q.token),
200
188
  ...oracle.toAmount(market.underlying, q.balance)
201
189
  })),
202
- assets: assets.map((a) => oracle.toTokenAmount(a.token, a.balance)),
203
190
  assetsChange: post.balances.difference(before.balances).toAssets(DUST_THRESHOLD).map((a) => oracle.toTokenAmount(a.token, a.balance)),
204
- error: converter.error,
205
- healthFactor: sdk.positions.healthFactor(snap),
206
- safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
207
- borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: before.totalDebt - post.totalDebt }),
208
- timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: before.totalDebt - post.totalDebt }),
209
- liquidationPrice: sdk.positions.liquidationPrice(snap),
210
- leverage: calcPositionLeverage(totalValue, post.totalDebt)
191
+ error: converter.error
211
192
  };
212
193
  }
213
194
  //#endregion
214
- export { buildDelayedPreview };
195
+ export { buildDelayedStrategyVerify };
@@ -1,4 +1,4 @@
1
- import { buildDelayedPreview } from "./buildDelayedPreview.js";
1
+ import { buildDelayedStrategyVerify } from "./buildDelayedStrategyVerify.js";
2
2
  import { CreditAccountState } from "./CreditAccountState.js";
3
3
  import { classifyCloseOrRepay, isCloseOrRepay } from "./detectCloseOrRepay.js";
4
4
  import { detectDelayedClaim, resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
@@ -6,7 +6,7 @@ import { detectDelayedOperation } from "./detectDelayedOperation.js";
6
6
  import { UnsupportedOperationError } from "./errors.js";
7
7
  import { makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
8
8
  import { replayMulticall } from "./replayMulticall.js";
9
- import { previewAdjustCreditAccount } from "./previewAdjustCreditAccount.js";
10
- import { previewCloseOrRepayCreditAccount } from "./previewCloseOrRepayCreditAccount.js";
9
+ import { previewAdjustStrategyVerify } from "./previewAdjustStrategyVerify.js";
10
+ import { previewExitOrRepayStrategyVerify } from "./previewExitOrRepayStrategyVerify.js";
11
11
  import { previewOperation } from "./previewOperation.js";
12
- export { CreditAccountState, UnsupportedOperationError, buildDelayedPreview, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, isCloseOrRepay, makeReplayState, previewAdjustCreditAccount, previewCloseOrRepayCreditAccount, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
12
+ export { CreditAccountState, UnsupportedOperationError, buildDelayedStrategyVerify, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, isCloseOrRepay, makeReplayState, previewAdjustStrategyVerify, previewExitOrRepayStrategyVerify, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
@@ -1,12 +1,11 @@
1
1
  import { AP_WETH_TOKEN } from "../../onchain/constants/address-provider.js";
2
2
  import { DUST_THRESHOLD } from "../../onchain/constants/math.js";
3
- import { calcPositionLeverage } from "../../onchain/market/math.js";
4
- import { ERROR_UNPRICEABLE_TOKEN } from "../../model/previews.js";
3
+ import { ERROR_UNPRICEABLE_TOKEN, asEstimated } from "../../model/previews.js";
5
4
  import "../../model/index.js";
6
5
  import "../../onchain/index.js";
7
6
  import { replayMulticall } from "./replayMulticall.js";
8
7
  import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
9
- //#region src/preview/preview/previewAdjustCreditAccount.ts
8
+ //#region src/preview/preview/previewAdjustStrategyVerify.ts
10
9
  /**
11
10
  * Previews a `multicall`/`botMulticall` operation on an existing credit
12
11
  * account: threads the multicall through {@link replayMulticall} over the
@@ -14,7 +13,7 @@ import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
14
13
  * minimal guaranteed post-state alongside the changes relative to the
15
14
  * pre-state.
16
15
  */
17
- async function previewAdjustCreditAccount(input, operation, options) {
16
+ async function previewAdjustStrategyVerify(input, operation, options) {
18
17
  const { sdk, value = 0n } = input;
19
18
  const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
20
19
  const oracle = market.priceOracle;
@@ -23,10 +22,8 @@ async function previewAdjustCreditAccount(input, operation, options) {
23
22
  let error = replayError;
24
23
  const { assets: collateralAdded, error: unwrapError } = unwrapNativeCollateral(after.collateralAdded.toAssets(), value, sdk.addressProvider.getAddress(AP_WETH_TOKEN, 0));
25
24
  error ??= unwrapError;
26
- const assets = account.balances.toAssets(DUST_THRESHOLD);
27
- const quotas = account.quotas.toAssets(0n);
28
25
  const assetsChange = account.balances.difference(before.balances).toAssets(DUST_THRESHOLD);
29
- const totalValue = assets.reduce((acc, { token, balance }) => {
26
+ const totalValue = account.balances.toAssets(DUST_THRESHOLD).reduce((acc, { token, balance }) => {
30
27
  try {
31
28
  return acc + oracle.convert(token, market.underlying, balance);
32
29
  } catch {
@@ -40,33 +37,18 @@ async function previewAdjustCreditAccount(input, operation, options) {
40
37
  const snap = account.toSnapshot(totalValue);
41
38
  return {
42
39
  operation: "AdjustCreditAccount",
43
- creditManager: operation.creditManager,
44
- name: sdk.marketRegister.findCreditManager(operation.creditManager).name,
40
+ ...asEstimated(sdk.positions.projection(snap, { availableLiquidityChange: before.totalDebt - account.totalDebt })),
45
41
  creditAccount: operation.creditAccount,
46
42
  collateralAdded: collateralAdded.map((a) => oracle.toTokenAmount(a.token, a.balance)),
47
43
  collateralWithdrawn: after.collateralWithdrawn.toAssets().map((a) => oracle.toTokenAmount(a.token, a.balance)),
48
- totalValue: market.toUnderlyingAmount(totalValue),
49
- totalDebt: market.toUnderlyingAmount(account.totalDebt),
50
- netValue: market.toUnderlyingAmount(totalValue - account.totalDebt),
51
44
  totalDebtChange: market.toUnderlyingAmount(account.totalDebt - before.totalDebt),
52
- quotas: quotas.map((q) => ({
53
- token: sdk.tokensMeta.mustGetToken(q.token),
54
- ...oracle.toAmount(market.underlying, q.balance)
55
- })),
56
45
  quotasChange: account.quotas.difference(before.quotas).toAssets().map((q) => ({
57
46
  token: sdk.tokensMeta.mustGetToken(q.token),
58
47
  ...oracle.toAmount(market.underlying, q.balance)
59
48
  })),
60
- assets: assets.map((a) => oracle.toTokenAmount(a.token, a.balance)),
61
49
  assetsChange: assetsChange.map((a) => oracle.toTokenAmount(a.token, a.balance)),
62
- error,
63
- healthFactor: sdk.positions.healthFactor(snap),
64
- safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
65
- borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: before.totalDebt - account.totalDebt }),
66
- timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: before.totalDebt - account.totalDebt }),
67
- liquidationPrice: sdk.positions.liquidationPrice(snap),
68
- leverage: calcPositionLeverage(totalValue, account.totalDebt)
50
+ error
69
51
  };
70
52
  }
71
53
  //#endregion
72
- export { previewAdjustCreditAccount };
54
+ export { previewAdjustStrategyVerify };
@@ -1,11 +1,12 @@
1
1
  import { AP_WETH_TOKEN } from "../../onchain/constants/address-provider.js";
2
2
  import "../../onchain/constants/math.js";
3
+ import { creditOperationMarket } from "../../onchain/market/credit/creditOperationMarket.js";
3
4
  import "../../onchain/index.js";
4
5
  import { classifyCloseOrRepay } from "./detectCloseOrRepay.js";
5
6
  import { replayMulticall } from "./replayMulticall.js";
6
7
  import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
7
- //#region src/preview/preview/previewCloseOrRepayCreditAccount.ts
8
- async function previewCloseOrRepayCreditAccount(input, operation, permanent, options) {
8
+ //#region src/preview/preview/previewExitOrRepayStrategyVerify.ts
9
+ async function previewExitOrRepayStrategyVerify(input, operation, permanent, options) {
9
10
  const { sdk } = input;
10
11
  const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
11
12
  const exitTokens = [market.underlying];
@@ -31,8 +32,7 @@ function previewCloseCreditAccount(input, operation, permanent, replay) {
31
32
  return {
32
33
  operation: "CloseCreditAccount",
33
34
  permanent,
34
- creditManager: operation.creditManager,
35
- name: sdk.marketRegister.findCreditManager(operation.creditManager).name,
35
+ ...creditOperationMarket(sdk.marketRegister.findCreditManager(operation.creditManager)),
36
36
  creditAccount: operation.creditAccount,
37
37
  receivedAmount: market.priceOracle.toTokenAmount(receivedToken, after.collateralWithdrawn.getOrZero(receivedToken)),
38
38
  error
@@ -52,8 +52,7 @@ function previewRepayCreditAccount(input, operation, permanent, replay) {
52
52
  return {
53
53
  operation: "RepayCreditAccount",
54
54
  permanent,
55
- creditManager: operation.creditManager,
56
- name: sdk.marketRegister.findCreditManager(operation.creditManager).name,
55
+ ...creditOperationMarket(sdk.marketRegister.findCreditManager(operation.creditManager)),
57
56
  creditAccount: operation.creditAccount,
58
57
  collateralAdded: collateralAdded.map((a) => market.priceOracle.toTokenAmount(a.token, a.balance)),
59
58
  debtRepaid: market.toUnderlyingAmount(before.totalDebt - after.account.totalDebt),
@@ -62,4 +61,4 @@ function previewRepayCreditAccount(input, operation, permanent, replay) {
62
61
  };
63
62
  }
64
63
  //#endregion
65
- export { previewCloseOrRepayCreditAccount };
64
+ export { previewExitOrRepayStrategyVerify };
@@ -1,7 +1,7 @@
1
1
  import { simulatePoolOperation } from "../simulate/simulatePoolOperation.js";
2
2
  import "../simulate/index.js";
3
- //#region src/preview/preview/previewPoolOperation.ts
4
- async function previewPoolOperation(input, operation, options) {
3
+ //#region src/preview/preview/previewLpVerify.ts
4
+ async function previewLpVerify(input, operation, options) {
5
5
  const { sdk, to, calldata } = input;
6
6
  const { tokenIn, tokenOut } = operation;
7
7
  const market = sdk.marketRegister.findByPool(operation.pool);
@@ -21,4 +21,4 @@ async function previewPoolOperation(input, operation, options) {
21
21
  };
22
22
  }
23
23
  //#endregion
24
- export { previewPoolOperation };
24
+ export { previewLpVerify };
@@ -1,14 +1,12 @@
1
1
  import { AP_WETH_TOKEN } from "../../onchain/constants/address-provider.js";
2
- import { DUST_THRESHOLD } from "../../onchain/constants/math.js";
3
- import { calcPositionLeverage } from "../../onchain/market/math.js";
4
- import { ERROR_UNPRICEABLE_TOKEN } from "../../model/previews.js";
2
+ import { ERROR_UNPRICEABLE_TOKEN, asEstimated } from "../../model/previews.js";
5
3
  import "../../model/index.js";
6
4
  import "../../onchain/index.js";
7
5
  import { CreditAccountState } from "./CreditAccountState.js";
8
6
  import { makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
9
7
  import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
10
- //#region src/preview/preview/previewOpenCreditAccount.ts
11
- async function previewOpenCreditAccount(input, operation) {
8
+ //#region src/preview/preview/previewOpenStrategyVerify.ts
9
+ async function previewOpenStrategyVerify(input, operation) {
12
10
  const { sdk, value = 0n } = input;
13
11
  const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
14
12
  const oracle = market.priceOracle;
@@ -29,32 +27,14 @@ async function previewOpenCreditAccount(input, operation) {
29
27
  });
30
28
  const { assets: collateral, error: unwrapError } = unwrapNativeCollateral(state.collateralAdded.toAssets(), value, sdk.addressProvider.getAddress(AP_WETH_TOKEN, 0));
31
29
  error ??= unwrapError ?? priceError;
32
- const assets = account.balances.toAssets(DUST_THRESHOLD);
33
- const quotas = account.quotas.toAssets(0n);
34
- const totalValue = netValue + account.totalDebt;
35
- const snap = account.toSnapshot(totalValue);
30
+ const snap = account.toSnapshot(netValue + account.totalDebt);
36
31
  const targetAsset = inferTargetAsset(operation.multicall, account.balances);
37
32
  return {
38
33
  operation: operation.operation,
39
- creditManager: operation.creditManager,
40
- name: sdk.marketRegister.findCreditManager(operation.creditManager).name,
34
+ ...asEstimated(sdk.positions.projection(snap, { availableLiquidityChange: -account.totalDebt })),
41
35
  targetCollateral: targetAsset ? oracle.toTokenAmount(targetAsset.token, targetAsset.balance) : void 0,
42
36
  collateralAdded: collateral.map((a) => oracle.toTokenAmount(a.token, a.balance)),
43
- netValue: market.toUnderlyingAmount(netValue),
44
- totalValue: market.toUnderlyingAmount(totalValue),
45
- totalDebt: market.toUnderlyingAmount(account.totalDebt),
46
- quotas: quotas.map((q) => ({
47
- token: sdk.tokensMeta.mustGetToken(q.token),
48
- ...oracle.toAmount(market.underlying, q.balance)
49
- })),
50
- assets: assets.map((a) => oracle.toTokenAmount(a.token, a.balance)),
51
- error,
52
- healthFactor: sdk.positions.healthFactor(snap),
53
- safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
54
- borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: -account.totalDebt }),
55
- timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: -account.totalDebt }),
56
- liquidationPrice: sdk.positions.liquidationPrice(snap),
57
- leverage: calcPositionLeverage(totalValue, account.totalDebt)
37
+ error
58
38
  };
59
39
  }
60
40
  /**
@@ -72,4 +52,4 @@ function inferTargetAsset(multicall, balances) {
72
52
  }
73
53
  }
74
54
  //#endregion
75
- export { previewOpenCreditAccount };
55
+ export { previewOpenStrategyVerify };
@@ -1,16 +1,18 @@
1
+ import { creditOperationMarket } from "../../onchain/market/credit/creditOperationMarket.js";
2
+ import "../../onchain/index.js";
1
3
  import { parseOperationCalldata } from "../parse/parseOperationCalldata.js";
2
4
  import { isPoolOperation } from "../parse/types.js";
3
5
  import "../parse/index.js";
4
- import { buildDelayedPreview } from "./buildDelayedPreview.js";
6
+ import { buildDelayedStrategyVerify } from "./buildDelayedStrategyVerify.js";
5
7
  import { isCloseOrRepay } from "./detectCloseOrRepay.js";
6
8
  import { resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
7
9
  import { detectDelayedOperation } from "./detectDelayedOperation.js";
8
10
  import { UnsupportedOperationError } from "./errors.js";
9
11
  import { replayMulticall } from "./replayMulticall.js";
10
- import { previewAdjustCreditAccount } from "./previewAdjustCreditAccount.js";
11
- import { previewCloseOrRepayCreditAccount } from "./previewCloseOrRepayCreditAccount.js";
12
- import { previewOpenCreditAccount } from "./previewOpenCreditAccount.js";
13
- import { previewPoolOperation } from "./previewPoolOperation.js";
12
+ import { previewAdjustStrategyVerify } from "./previewAdjustStrategyVerify.js";
13
+ import { previewExitOrRepayStrategyVerify } from "./previewExitOrRepayStrategyVerify.js";
14
+ import { previewLpVerify } from "./previewLpVerify.js";
15
+ import { previewOpenStrategyVerify } from "./previewOpenStrategyVerify.js";
14
16
  //#region src/preview/preview/previewOperation.ts
15
17
  /**
16
18
  * Previews a raw operation calldata: decodes it into a typed operation and
@@ -18,11 +20,11 @@ import { previewPoolOperation } from "./previewPoolOperation.js";
18
20
  */
19
21
  async function previewOperation(input, options) {
20
22
  const operation = parseOperationCalldata(input);
21
- if (isPoolOperation(operation)) return previewPoolOperation(input, operation, options);
22
- if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount") return previewOpenCreditAccount(input, operation);
23
+ if (isPoolOperation(operation)) return previewLpVerify(input, operation, options);
24
+ if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount") return previewOpenStrategyVerify(input, operation);
23
25
  if (operation.operation === "CloseCreditAccount") {
24
26
  const resolved = await resolveCreditAccount(input, operation, options);
25
- const preview = await previewCloseOrRepayCreditAccount(input, operation, true, resolved);
27
+ const preview = await previewExitOrRepayStrategyVerify(input, operation, true, resolved);
26
28
  preview.intent = await resolveDelayedClaimIntent(input.sdk, operation.multicall, options?.blockNumber);
27
29
  return preview;
28
30
  }
@@ -52,7 +54,7 @@ async function resolveCreditAccount(input, operation, options) {
52
54
  */
53
55
  async function previewMulticallOperation(input, operation, options) {
54
56
  const { sdk } = input;
55
- const instantPreview = isCloseOrRepay(operation.multicall) ? await previewCloseOrRepayCreditAccount(input, operation, false, options) : await previewAdjustCreditAccount(input, operation, options);
57
+ const instantPreview = isCloseOrRepay(operation.multicall) ? await previewExitOrRepayStrategyVerify(input, operation, false, options) : await previewAdjustStrategyVerify(input, operation, options);
56
58
  const delayed = detectDelayedOperation(sdk, operation.multicall);
57
59
  if (!delayed) {
58
60
  instantPreview.intent = await resolveDelayedClaimIntent(sdk, operation.multicall, options?.blockNumber);
@@ -66,11 +68,10 @@ async function previewMulticallOperation(input, operation, options) {
66
68
  return {
67
69
  operation: "DelayedCreditAccountOperation",
68
70
  creditAccount: operation.creditAccount,
69
- creditManager: operation.creditManager,
70
- name: sdk.marketRegister.findCreditManager(operation.creditManager).name,
71
+ ...creditOperationMarket(sdk.marketRegister.findCreditManager(operation.creditManager)),
71
72
  intent: delayed.intent,
72
73
  instantPreview,
73
- delayedPreview: buildDelayedPreview(after.account, before, delayed, convert, receivedToken, sdk)
74
+ delayedPreview: buildDelayedStrategyVerify(after.account, before, delayed, convert, receivedToken, sdk)
74
75
  };
75
76
  }
76
77
  //#endregion
@@ -71,7 +71,11 @@ function creditIssues(sdk, preview, options) {
71
71
  maxDebt: suite.creditFacade.maxDebt,
72
72
  underlying,
73
73
  allowZero: !isOpening
74
- }) || borrowIssue(suite, preview, underlying) || forbiddenIssue(suite, preview) || quotaCountIssue(suite, preview) || quotaIssue(market, preview, underlying) || collateralIssue(preview, options) || fundingIssue(options, preview.collateralAdded);
74
+ }) || borrowIssue(suite, preview, underlying) || forbiddenIssue(suite, preview) || quotaCountIssue(suite, preview) || quotaIssue(market, preview, underlying) || collateralIssue({
75
+ totalDebt: preview.totalDebt,
76
+ healthFactor: preview.estHealthFactor,
77
+ safeHealthFactor: preview.estSafeHealthFactor
78
+ }, options) || fundingIssue(options, preview.collateralAdded);
75
79
  }
76
80
  /**
77
81
  * A bar that reads nothing but the projected account, so a parsed transaction
@@ -82,9 +86,9 @@ function creditIssues(sdk, preview, options) {
82
86
  * need an operation's *delta* between them, and the caller acts on the first
83
87
  * issue reported.
84
88
  */
85
- function quotaCountIssue(suite, projection) {
89
+ function quotaCountIssue(suite, account) {
86
90
  return checkQuotaCount({
87
- count: projection.quotas.filter((q) => q.value > 0n).length,
91
+ count: account.quotas.filter((q) => q.value > 0n).length,
88
92
  max: suite.creditManager.maxEnabledTokens
89
93
  });
90
94
  }
@@ -118,16 +122,16 @@ function borrowIssue(suite, preview, underlying) {
118
122
  *
119
123
  * {@inheritDoc quotaCountIssue}
120
124
  */
121
- function collateralIssue(projection, options) {
125
+ function collateralIssue(account, options) {
122
126
  const { minHealthFactor, minSafeHealthFactor, currentHealthFactor } = options;
123
- if (projection.totalDebt.value === 0n) return null;
127
+ if (account.totalDebt.value === 0n) return null;
124
128
  return (minHealthFactor === void 0 ? null : checkCollateralised({
125
- healthFactor: projection.healthFactor,
129
+ healthFactor: account.healthFactor,
126
130
  required: minHealthFactor,
127
131
  safePrices: false,
128
132
  improvesFrom: currentHealthFactor
129
- })) || (minSafeHealthFactor === void 0 || projection.safeHealthFactor === void 0 ? null : checkCollateralised({
130
- healthFactor: projection.safeHealthFactor,
133
+ })) || (minSafeHealthFactor === void 0 ? null : checkCollateralised({
134
+ healthFactor: account.safeHealthFactor,
131
135
  required: minSafeHealthFactor,
132
136
  safePrices: true
133
137
  }));
@@ -147,7 +151,7 @@ function fundingIssue(options, puts) {
147
151
  return null;
148
152
  }
149
153
  function forbiddenIssue(suite, preview) {
150
- const obtained = preview.operation === "AdjustCreditAccount" ? preview.assetsChange : preview.assets;
154
+ const obtained = preview.operation === "AdjustCreditAccount" ? preview.assetsChange : preview.estAssets;
151
155
  const forbidden = suite.forbiddenTokens;
152
156
  for (const asset of obtained) {
153
157
  if (asset.value <= 0n) continue;
@@ -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 { AccountProjection, AdjustCreditAccountPreview, CloseCreditAccountPreview, DelayedCreditAccountOperationPreview, 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, InstantOperationPreview, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, PoolOperationPreview, PoolOperationType, PreviewOperationInput, PreviewOperationOptions, RepayCreditAccountPreview } from "./previews.js";
18
+ import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, CreditOperationMarket, 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, AdjustCreditAccountPreview, 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, CloseCreditAccountPreview, CompareTag, CompareTolerance, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedCreditAccountOperationPreview, 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, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantOperationPreview, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreview, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayCreditAccountPreview, ResponseMetadata, Rewards, RewardsPnL, 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, 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 };
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, CreditOperationMarket, 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 };