@gearbox-protocol/sdk 16.3.2 → 16.4.0-next.2

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 (70) hide show
  1. package/dist/cjs/dev/midasUtils.js +11 -46
  2. package/dist/cjs/model/errors/index.js +1 -0
  3. package/dist/cjs/model/errors/operation-errors.js +9 -0
  4. package/dist/cjs/model/index.js +1 -0
  5. package/dist/cjs/onchain/accounts/intents/collateral-money.js +41 -0
  6. package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
  7. package/dist/cjs/onchain/accounts/intents/index.js +21 -18
  8. package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
  9. package/dist/cjs/onchain/accounts/intents/realize.js +10 -2
  10. package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
  11. package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
  12. package/dist/cjs/onchain/index.js +2 -0
  13. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +1 -1
  14. package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +10 -16
  15. package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
  16. package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
  17. package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  18. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +4 -3
  19. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +1 -2
  20. package/dist/cjs/onchain/validation/checkOperation.js +0 -1
  21. package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
  22. package/dist/cjs/onchain/validation/checks/index.js +2 -0
  23. package/dist/cjs/onchain/validation/index.js +2 -0
  24. package/dist/cjs/sdk/prepare/PrepareApi.js +3 -2
  25. package/dist/esm/dev/midasUtils.js +12 -47
  26. package/dist/esm/model/errors/index.js +2 -2
  27. package/dist/esm/model/errors/operation-errors.js +9 -1
  28. package/dist/esm/model/index.js +2 -2
  29. package/dist/esm/onchain/accounts/intents/collateral-money.js +40 -0
  30. package/dist/esm/onchain/accounts/intents/guards.js +15 -3
  31. package/dist/esm/onchain/accounts/intents/index.js +21 -18
  32. package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
  33. package/dist/esm/onchain/accounts/intents/realize.js +10 -2
  34. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  35. package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
  36. package/dist/esm/onchain/index.js +2 -1
  37. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +1 -1
  38. package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +11 -17
  39. package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
  40. package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
  41. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  42. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +4 -3
  43. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +1 -2
  44. package/dist/esm/onchain/validation/checkOperation.js +0 -1
  45. package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
  46. package/dist/esm/onchain/validation/checks/index.js +2 -1
  47. package/dist/esm/onchain/validation/index.js +2 -1
  48. package/dist/esm/sdk/prepare/PrepareApi.js +3 -2
  49. package/dist/types/dev/midasUtils.d.ts +3 -4
  50. package/dist/types/model/errors/index.d.ts +2 -2
  51. package/dist/types/model/errors/operation-errors.d.ts +41 -1
  52. package/dist/types/model/index.d.ts +3 -3
  53. package/dist/types/model/previews.d.ts +11 -20
  54. package/dist/types/onchain/accounts/intents/collateral-money.d.ts +42 -0
  55. package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
  56. package/dist/types/onchain/accounts/intents/index.d.ts +23 -14
  57. package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
  58. package/dist/types/onchain/accounts/intents/types.d.ts +26 -4
  59. package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
  60. package/dist/types/onchain/index.d.ts +2 -1
  61. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
  62. package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
  63. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
  64. package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
  65. package/dist/types/onchain/validation/checks/index.d.ts +2 -1
  66. package/dist/types/onchain/validation/index.d.ts +2 -1
  67. package/dist/types/onchain/validation/raise.d.ts +2 -2
  68. package/dist/types/sdk/prepare/PrepareApi.d.ts +1 -1
  69. package/dist/types/sdk/prepare/types.d.ts +23 -16
  70. package/package.json +1 -1
@@ -126,6 +126,46 @@ interface InsufficientCollateralError extends IGearboxError {
126
126
  }
127
127
  /** {@inheritDoc InsufficientCollateralError} */
128
128
  declare function insufficientCollateral(args: Omit<InsufficientCollateralError, "code" | "message">): InsufficientCollateralError;
129
+ /**
130
+ * The same failure as {@link InsufficientCollateralError}, traced to the
131
+ * reserve price feed rather than to the size of the position.
132
+ *
133
+ * A call that hands funds over is weighed at safe prices — `min` of a token's
134
+ * two feeds, and nothing at all for collateral governance registered no
135
+ * reserve feed for — so an account that covers its debt at the main feed can
136
+ * still be refused. Worth its own code because the two call for opposite
137
+ * words: an under-collateralised position is fixed by adding collateral or
138
+ * requesting less, while this is a valuation the account does not control, and
139
+ * requesting less only helps as far as {@link withdrawable} says it does.
140
+ **/
141
+ interface ReservePriceLimitedError extends IGearboxError {
142
+ code: "reservePriceLimited";
143
+ /** The safe-price factor the operation would have ended at. */
144
+ healthFactor: Bps;
145
+ /**
146
+ * The same account at the main feed. Above {@link healthFactorThreshold} by
147
+ * definition — that is what makes the reserve feed the thing in the way, and
148
+ * the gap between the two is how far it marks the collateral down.
149
+ **/
150
+ atMainPrices: Bps;
151
+ /** The threshold both were weighed against, the facade's own `1.0`. */
152
+ healthFactorThreshold: Bps;
153
+ /**
154
+ * What the account can still take out under the same check, in the market's
155
+ * underlying — the request to offer instead of the refused one. It is the
156
+ * `safePartial` of `WithdrawCeilings`, from the same code that answers
157
+ * `maxWithdraw`, so the two never disagree.
158
+ *
159
+ * `0n` says no partial withdrawal clears the threshold at all, and a smaller
160
+ * request will not help: holding leverage flat scales collateral and debt
161
+ * together, which leaves the safe-price factor exactly where it found it.
162
+ * Such a position can still leave entirely — an exit settles the debt rather
163
+ * than shrinking it, and a check with no debt to divide by refuses nothing.
164
+ **/
165
+ withdrawable: TokenAmount;
166
+ }
167
+ /** {@inheritDoc ReservePriceLimitedError} */
168
+ declare function reservePriceLimited(args: Omit<ReservePriceLimitedError, "code" | "message">): ReservePriceLimitedError;
129
169
  /**
130
170
  * The operation would increase the balance of a token the market forbids.
131
171
  **/
@@ -219,4 +259,4 @@ interface RWAOpenRequirementsError extends IGearboxError {
219
259
  /** {@inheritDoc RWAOpenRequirementsError} */
220
260
  declare function rwaOpenRequirementsNotMet(args: Omit<RWAOpenRequirementsError, "code" | "message">): RWAOpenRequirementsError;
221
261
  //#endregion
222
- export { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet };
262
+ export { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet };
@@ -6,14 +6,14 @@ import { DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseL
6
6
  import { IGearboxError } from "./errors/base.js";
7
7
  import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./errors/liquidation-errors.js";
8
8
  import { KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, MidasOpenAccountRequirements, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature } from "./rwa.js";
9
- import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
9
+ import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
10
10
  import { UnpriceableTokenError, unpriceableTokenError } from "./errors/oracle-errors.js";
11
11
  import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
12
12
  import { InvalidDelayedIntentError, MalformedTransactionError, PoolOperationPreviewError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, malformedTransaction } from "./errors/preview-errors.js";
13
13
  import "./errors/index.js";
14
14
  import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
15
15
  import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
16
- import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated } from "./previews.js";
16
+ import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated } from "./previews.js";
17
17
  import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
18
18
  import { AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition } from "./analytics.js";
19
19
  import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
@@ -33,4 +33,4 @@ import { SDKError, SDKResult, SDKReturn, SafeValue, safeValue, sdkErr, sdkOk } f
33
33
  import { kycRequirementSchema, rwaProtocolSchema } from "./rwa.schema.js";
34
34
  import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
35
35
  import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
36
- export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, 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, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
36
+ export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, 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, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
@@ -375,31 +375,22 @@ interface OpenStrategyPositionProjection extends EstimatedProjection {
375
375
  warning?: UnpriceableTokenError;
376
376
  }
377
377
  /**
378
- * What a facade account-opening transaction that already exists would do —
379
- * the counterpart of `prepare.openNewStrategy` on a non-RWA market, read off
380
- * calldata rather than planned into it.
378
+ * What an account-opening transaction that already exists would do — the
379
+ * counterpart of `prepare.openNewStrategy`, read off calldata rather than
380
+ * planned into it.
381
381
  **/
382
- interface OpenNonRWAStrategyPositionPreview extends OpenStrategyPositionProjection {
382
+ interface OpenStrategyPositionPreview extends OpenStrategyPositionProjection {
383
383
  operation: "OpenCreditAccount";
384
- }
385
- /**
386
- * What an RWA-factory account-opening transaction that already exists would
387
- * do — the counterpart of `prepare.openNewStrategy` on an RWA market.
388
- **/
389
- interface OpenRWAStrategyPositionPreview extends OpenStrategyPositionProjection {
390
- operation: "RWAOpenCreditAccount";
384
+ /**
385
+ * Existing zero-debt, zero-quota account this operation reopens.
386
+ */
387
+ creditAccount?: Address;
391
388
  /**
392
389
  * Registration args the factory received (Securitize: `tokensToRegister`,
393
- * `signaturesToCache`).
390
+ * `signaturesToCache`). Present on RWA-factory accounts only.
394
391
  */
395
- rwaArgs: RWAOperationArgs;
392
+ rwaArgs?: RWAOperationArgs;
396
393
  }
397
- /**
398
- * What an account-opening transaction that already exists would do — the
399
- * counterpart of `prepare.openNewStrategy`, read off calldata rather than
400
- * planned into it.
401
- **/
402
- type OpenStrategyPositionPreview = OpenNonRWAStrategyPositionPreview | OpenRWAStrategyPositionPreview;
403
394
  /**
404
395
  * What a transaction on an existing account would do — the counterpart of the
405
396
  * `prepare` flows that adjust one (`depositStrategy`, `withdrawStrategy`,
@@ -585,4 +576,4 @@ interface DelayedStrategyPositionOperationPreview extends CreditOperationMarket
585
576
  */
586
577
  type OperationPreview = PoolPositionOperationPreview | OpenStrategyPositionPreview | AdjustStrategyPositionPreview | ExitStrategyPositionPreview | RepayStrategyPositionPreview | DelayedStrategyPositionOperationPreview;
587
578
  //#endregion
588
- export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated };
579
+ export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated };
@@ -0,0 +1,42 @@
1
+ import { OnchainSDK } from "../../OnchainSDK.js";
2
+ import { CreditAccountSlice } from "./types.js";
3
+ import "../../index.js";
4
+ import { Address } from "viem";
5
+ //#region src/onchain/accounts/intents/collateral-money.d.ts
6
+ /** One balance on the account, as the slice carries it. */
7
+ type Holding = CreditAccountSlice["tokens"][number];
8
+ /**
9
+ * The collateral check's own valuation of an account, as a handful of lookups.
10
+ *
11
+ * Shared by everything that solves that check for an amount, so the rules it
12
+ * encodes are written once: a holding backed by a quota counts the lesser of the
13
+ * quota and its threshold-weighted value, an unquoted one its weighted value
14
+ * alone, and dust or a disabled balance nothing at all. Collateral is valued at
15
+ * the protocol safe price — `min` of the two feeds, 0 where there is no reserve
16
+ * — the way the facade values a call that hands funds over; the underlying is
17
+ * exempt and stays on the main feed, as `CreditManagerV3._safeConvertToUSD`
18
+ * does.
19
+ *
20
+ * Money is carried in USD × `PERCENTAGE_FACTOR`, the units the check compares
21
+ * in, so a threshold never has to be divided back out.
22
+ */
23
+ interface CollateralMoney {
24
+ /** Market underlying, the one token safe pricing does not touch. */
25
+ underlying: Address;
26
+ /** Whether the holding is weighed at all. */
27
+ counts(holding: Holding): boolean;
28
+ /** What the holding backs, in USD × `PERCENTAGE_FACTOR`. */
29
+ weigh(holding: Holding): bigint;
30
+ /** What the holding's quota backs, in the same units; 0 on a closed market. */
31
+ quotaMoney(holding: Holding): bigint;
32
+ /** USD at the main feed; `undefined` when the token has no price at all. */
33
+ mainUsd(token: Address, amount: bigint): bigint | undefined;
34
+ /** USD the check counts the holding at, before its threshold. */
35
+ checkedUsd(holding: Holding): bigint;
36
+ /** Liquidation threshold in basis points; 0 for a token the manager refuses. */
37
+ lt(token: Address): bigint;
38
+ }
39
+ /** {@inheritDoc CollateralMoney} */
40
+ declare function collateralMoney(creditAccount: CreditAccountSlice, sdk: OnchainSDK): CollateralMoney;
41
+ //#endregion
42
+ export { CollateralMoney, Holding, collateralMoney };
@@ -1,3 +1,5 @@
1
+ import { Bps, TokenAmount } from "../../../model/primitives.js";
2
+ import "../../../model/index.js";
1
3
  import { Asset } from "../../base/types.js";
2
4
  import { MarketSuite } from "../../market/MarketSuite.js";
3
5
  import { CreditSuite } from "../../market/credit/CreditSuite.js";
@@ -74,11 +76,25 @@ declare function assertGrowthAllowed(args: {
74
76
  * whose reserve feed the SDK cannot read keeps its main price, so a plan can
75
77
  * still be refused on-chain after passing here.
76
78
  */
77
- declare function assertCollateralised(healthFactorBps: number, safePrices: boolean): void;
79
+ declare function assertCollateralised(healthFactorBps: number, safePrices: boolean, atSafePrices?: SafePriceEvidence): void;
80
+ /**
81
+ * What tells a reserve feed marking collateral down apart from a position that
82
+ * is simply too small, read only when the collateral check has already failed.
83
+ *
84
+ * A thunk because both halves are expensive: the account has to be valued a
85
+ * second time at the main feed, and the check solved for the amount that would
86
+ * still clear it.
87
+ */
88
+ type SafePriceEvidence = () => {
89
+ /** The plan's end state weighed at the main feed. */
90
+ atMainPrices: Bps;
91
+ /** What the account can still take out, in the market's underlying. */
92
+ withdrawable: TokenAmount;
93
+ };
78
94
  /**
79
95
  * A quota can only be raised as far as the market still has room for: past the
80
96
  * token's limit the keeper takes nothing more, whoever is asking.
81
97
  */
82
98
  declare function assertQuotaAvailable(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
83
99
  //#endregion
84
- export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable };
100
+ export { SafePriceEvidence, assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable };
@@ -45,21 +45,30 @@ declare class CreditAccountOperationsService extends SDKConstruct {
45
45
  startIntent(props: StartProps): Promise<IntentPreviewResult>;
46
46
  /**
47
47
  * Both ends of what a `WITHDRAW` can take out, in underlying: the largest
48
- * partial withdrawal that keeps leverage and stays inside the facade's
49
- * `debtLimits`, and the net value an exit hands over. They are reported together
50
- * because a withdraw form needs both — the range it may offer, and the one
51
- * amount past it that is allowed — and because the distance between them is
52
- * the account's own, not a constant a caller could assume.
53
- *
54
- * Takes no target health factor, unlike {@link maxWithdrawCollateral}: a
55
- * proportional withdrawal leaves the factor where it found it, and the
56
- * facade's `minDebt` is what bounds it.
57
- *
58
- * @param props - Account slice and the SDK holding its market
59
- * @returns The two ceilings, see {@link WithdrawCeilings} for the gap between
60
- * them
48
+ * partial withdrawal that keeps leverage, and the net value an exit hands
49
+ * over. They are reported together because a withdraw form needs both — the
50
+ * range it may offer, and the one amount past it that is allowed — and
51
+ * because the distance between them is the account's own, not a constant a
52
+ * caller could assume.
53
+ *
54
+ * Two rules bound the partial end and both are reported: the facade's
55
+ * `debtLimits` as `partial`, and the safe-price collateral check on top of
56
+ * it as `safePartial`. The second is the one to offer — see
57
+ * {@link WithdrawCeilings}.
58
+ *
59
+ * Takes no target health factor, unlike {@link maxWithdrawCollateral}. A
60
+ * proportional withdrawal leaves the factor where it found it, so there is
61
+ * no room to choose: what these answer to is the facade's own threshold,
62
+ * which is also what {@link startIntent} refuses against.
63
+ *
64
+ * @param props - Account slice, the SDK holding its market, and optionally
65
+ * the collateral the withdrawal would be funded from
66
+ * @returns The three limits, see {@link WithdrawCeilings} for the gap
67
+ * between them
61
68
  */
62
- maxWithdraw(props: Pick<StartIntentProps, "creditAccount" | "sdk">): WithdrawCeilings;
69
+ maxWithdraw(props: Pick<StartIntentProps, "creditAccount" | "sdk"> & {
70
+ sourceToken?: Address;
71
+ }): WithdrawCeilings;
63
72
  /**
64
73
  * Debt a `REPAY` would have to cover to settle the account, in underlying
65
74
  * units: principal plus the interest and fees accrued as of the read.
@@ -16,14 +16,9 @@ interface MaxWithdrawCollateralProps {
16
16
  * factor stays at or above `targetHF`.
17
17
  *
18
18
  * This is the collateral check solved for one balance, and it counts what that
19
- * check counts: a holding backed by a quota contributes the lesser of the
20
- * quota and its threshold-weighted value, an unquoted one — the underlying —
21
- * its weighted value alone, and dust or a disabled balance nothing at all.
22
- * Collateral is valued at the protocol safe price (`min` of the two feeds,
23
- * 0 when there is no reserve), the way the facade values a call that hands
24
- * funds over; the underlying is exempt and is valued at the main feed, as
25
- * `CreditManagerV3._safeConvertToUSD` does. The debt is valued at the main
26
- * feed, as the check does. Zero debt frees the whole balance.
19
+ * check counts — see {@link collateralMoney} for the valuation, safe prices
20
+ * included. The debt is valued at the main feed, as the check does. Zero debt
21
+ * frees the whole balance.
27
22
  *
28
23
  * Rounding always favours the account, so the answer clears the check rather
29
24
  * than landing a wei short of it.
@@ -429,12 +429,34 @@ interface WithdrawStrategyIntent {
429
429
  */
430
430
  interface WithdrawCeilings {
431
431
  /**
432
- * Largest partial withdrawal {@link WithdrawStrategyIntent} accepts: the one
433
- * whose proportional repayment leaves the debt at `minDebt`. `0n` when the
434
- * debt already sits below the floor, and always at least one unit under
435
- * `exit` — the last unit closes the account rather than shrinking it.
432
+ * Largest partial withdrawal the facade's `debtLimits` accept: the one whose
433
+ * proportional repayment leaves the debt at `minDebt`. `0n` when the debt
434
+ * already sits below the floor, and always at least one unit under `exit` —
435
+ * the last unit closes the account rather than shrinking it.
436
+ *
437
+ * `debtLimits` are not the only rule a withdrawal answers to, so this is a
438
+ * limit rather than the limit: {@link safePartial} is the one to offer.
436
439
  */
437
440
  partial: bigint;
441
+ /**
442
+ * Largest partial withdrawal {@link WithdrawStrategyIntent} actually accepts
443
+ * — {@link partial} once the safe-price collateral check has had its say,
444
+ * and never above it.
445
+ *
446
+ * A withdrawal hands funds over, and the facade weighs what it leaves behind
447
+ * at safe prices: `min` of a token's two feeds, or nothing at all where
448
+ * governance registered no reserve feed. Collateral the reserve feed marks
449
+ * down therefore backs less than a projection at main prices suggests, and
450
+ * the withdrawal stops earlier than `debtLimits` alone would say. This is
451
+ * the figure a slider and a Max button belong on.
452
+ *
453
+ * `0n` on an account already under the threshold at safe prices. That is not
454
+ * a rounding artefact and a smaller request does not help: a proportional
455
+ * withdrawal leaves the safe-price factor exactly where it found it, so no
456
+ * amount clears a threshold the account is already under. Such a position
457
+ * can still leave — see {@link exit}, which the check never refuses.
458
+ */
459
+ safePartial: bigint;
438
460
  /**
439
461
  * What leaving hands over: the account's net value, which is also the amount
440
462
  * at which a withdrawal turns into an exit. `0n` on an account whose debt
@@ -0,0 +1,80 @@
1
+ import { OnchainSDK } from "../../OnchainSDK.js";
2
+ import { CreditAccountSlice, WithdrawCeilings } from "./types.js";
3
+ import "../../index.js";
4
+ import { Address } from "viem";
5
+ //#region src/onchain/accounts/intents/withdraw-limits.d.ts
6
+ interface WithdrawLimitsProps {
7
+ creditAccount: CreditAccountSlice;
8
+ sdk: OnchainSDK;
9
+ /**
10
+ * Token the withdrawal liquidates. Defaults to the account's largest
11
+ * non-phantom balance, which is what the planner reaches for when the intent
12
+ * names none.
13
+ */
14
+ sourceToken?: Address;
15
+ }
16
+ /**
17
+ * Every limit a `WITHDRAW` answers to, in underlying units.
18
+ *
19
+ * The one place they are assembled, so the figure a form is offered and the
20
+ * figure the collateral guard names when it turns a withdrawal down cannot
21
+ * drift apart: `CreditAccountOperationsService` reports this, and the guard
22
+ * quotes it back.
23
+ *
24
+ * @param props - Account slice, the SDK holding its market, and optionally the
25
+ * collateral the withdrawal would be funded from
26
+ * @returns The three limits, see {@link WithdrawCeilings}
27
+ **/
28
+ declare function withdrawLimits(props: WithdrawLimitsProps): WithdrawCeilings;
29
+ interface MaxSafeWithdrawalProps {
30
+ creditAccount: CreditAccountSlice;
31
+ sdk: OnchainSDK;
32
+ /**
33
+ * Token the withdrawal liquidates. Defaults to the account's largest
34
+ * non-phantom balance, which is what the planner reaches for when the intent
35
+ * names none.
36
+ */
37
+ sourceToken?: Address;
38
+ /**
39
+ * Health factor the withdrawal has to leave behind, in basis points. The
40
+ * facade's own threshold answers "would this land"; a form holding the
41
+ * account to something stricter passes its own.
42
+ */
43
+ targetHF: bigint;
44
+ }
45
+ /**
46
+ * Largest proportional withdrawal the safe-price collateral check still clears,
47
+ * in underlying units.
48
+ *
49
+ * A withdrawal hands funds over, so the facade weighs the account it leaves
50
+ * behind at safe prices rather than main ones — see {@link collateralMoney}.
51
+ * That is a second limit on top of the facade's `debtLimits`, and the two are
52
+ * independent: a caller wanting the amount a form may actually offer takes the
53
+ * lesser of this and `maxProportionalWithdrawal`.
54
+ *
55
+ * The arithmetic is the check solved for the amount. Taking `W` out at fixed
56
+ * leverage repays `dD = D·W/C`, so `W·TVL/C` of value is sold out of the source
57
+ * token; each dollar of that sale costs the check the source's threshold times
58
+ * its safe-to-main price ratio, while the repayment relieves `targetHF` per
59
+ * dollar of debt. Both terms are linear in `W`, which is why one division
60
+ * answers instead of a search — and why the answer is exact rather than a
61
+ * bound, as long as the plan really does fund itself from `sourceToken`.
62
+ *
63
+ * Two consequences worth stating, because they surprise:
64
+ *
65
+ * - An account whose collateral is entirely a token the reserve feed marks
66
+ * down cannot withdraw at all once it is under the threshold. A proportional
67
+ * withdrawal scales collateral and debt together, so it leaves the safe-price
68
+ * factor exactly where it found it — no amount climbs back over.
69
+ * - Leaving entirely is never refused for this reason: the exit settles the
70
+ * debt instead of shrinking it, and a check with no debt to divide by has
71
+ * nothing to refuse.
72
+ *
73
+ * @returns Amount in underlying units. The account's net value when safe prices
74
+ * do not limit the withdrawal at all, so the caller's `min` is a no-op; `0n`
75
+ * when the account already sits below `targetHF` at safe prices, and only the
76
+ * exit is left
77
+ **/
78
+ declare function maxSafeWithdrawal(props: MaxSafeWithdrawalProps): bigint;
79
+ //#endregion
80
+ export { MaxSafeWithdrawalProps, WithdrawLimitsProps, maxSafeWithdrawal, withdrawLimits };
@@ -327,8 +327,9 @@ import { PoolPausedArgs, checkPoolPaused } from "./validation/checks/checkPoolPa
327
327
  import { PoolSunsetArgs, checkPoolSunset } from "./validation/checks/checkPoolSunset.js";
328
328
  import { QuotaCountArgs, checkQuotaCount } from "./validation/checks/checkQuotaCount.js";
329
329
  import { QuotaLimitArgs, checkQuotaLimit } from "./validation/checks/checkQuotaLimit.js";
330
+ import { ReservePriceLimitedArgs, checkReservePriceLimited } from "./validation/checks/checkReservePriceLimited.js";
330
331
  import { amountOf } from "./validation/helpers/amount.js";
331
332
  import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./validation/helpers/health-factor-limits.js";
332
333
  import { toToken, toTokenAmount } from "./validation/helpers/token.js";
333
334
  import "./validation/index.js";
334
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterOperation, AdapterOperationBase, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddCollateralOp, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetWithAmountInTarget, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, BorrowLimitArgs, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CallTrace, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, ClassifyInnerOperationsProps, ClientOptions, CloseCreditAccountOperation, CloseCreditAccountResult, CloseOrRepayOperation, ClosePathBalances, CollateralFundingPreview, CollateralisedArgs, CompareBalancesOp, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvertFn, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountFrozenArgs, CreditAccountOperation, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountState, CreditAccountStateProps, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerPausedArgs, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, DebtLimitsArgs, DecreaseDebtOp, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, EmergencyLiquidatorArgs, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, FacadeOperationMetadata, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, type FinishIntentResult, FluidDexAdapterContract, ForbiddenTokenArgs, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetCurrentWithdrawalsProps, GetCurrentWithdrawalsPropsBase, GetExternalAccountCurrentWithdrawalsProps, GetInvestorOptions, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetReward, GetWithdrawalRequestResultProps, HealthFactorThresholds, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IDegenNFT, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IMultichainOpportunitiesService, IMultichainPositionsService, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, IncreaseDebtOp, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InnerFacadeOperation, InnerOperation, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type IntentValidationError, type InterestRateModelStateHuman, InterestRateModelType, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LeverageArgs, type LeverageBand, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidateCreditAccountOperation, LiquidationEligibilityError, LiquidationFees, LiquidationValidationError, LiquidationsService, LiquidatorEligibleArgs, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketExpiredArgs, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketStateError, type MarketStateHuman, MarketSuite, MarketType, MaxBorrowAmount, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallOperation, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, OpenCreditAccountOperation, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OpenStrategyState, Operation, OperationMetadata, type OperationState, OperationValidationError, OpportunitiesService, OptimalRepaidAmountProps, OuterFacadeOperation, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationOperation, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolDepositOperation, PoolLiquidityArgs, PoolMintOperation, PoolOperation, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolRedeemOperation, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolSunsetArgs, PoolV310Contract, PoolWithdrawOperation, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewOperationError, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, ProjectedPoolOptions, PythPriceFeed, QuotaCountArgs, QuotaKeeperState, QuotaLimitArgs, QuotaMode, type QuotaParamsHuman, QuotaSlice, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryProtocol, RWAFactoryStateHuman, RWAInvestorData, RWALiquidatorInfo, RWAMulticallOperation, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedemptionPhantomRename, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, ReplayMulticallResult, ReplayState, ReplayableOperation, RequestableWithdrawal, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteErrors, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeDegenNFT, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, SimulationValidationError, StakingRewardsAdapterContract, type StartIntent, StoreExpectedBalancesOp, StrategyCollateralProps, StrategyRateInputs, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokenTransfer, TokensMeta, TokensMetaState, TraceAdapterExt, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatePriceFeedsResult, UpdateQuotaOp, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WalletFundingError, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, WeighedFactors, type WithBlock, type WithMultichain, type WithdrawAssetIntent, type WithdrawCeilings, WithdrawCollateral, WithdrawCollateralOp, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
335
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterOperation, AdapterOperationBase, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddCollateralOp, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetWithAmountInTarget, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, BorrowLimitArgs, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CallTrace, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, ClassifyInnerOperationsProps, ClientOptions, CloseCreditAccountOperation, CloseCreditAccountResult, CloseOrRepayOperation, ClosePathBalances, CollateralFundingPreview, CollateralisedArgs, CompareBalancesOp, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvertFn, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountFrozenArgs, CreditAccountOperation, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountState, CreditAccountStateProps, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerPausedArgs, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, DebtLimitsArgs, DecreaseDebtOp, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, EmergencyLiquidatorArgs, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, FacadeOperationMetadata, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, type FinishIntentResult, FluidDexAdapterContract, ForbiddenTokenArgs, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetCurrentWithdrawalsProps, GetCurrentWithdrawalsPropsBase, GetExternalAccountCurrentWithdrawalsProps, GetInvestorOptions, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetReward, GetWithdrawalRequestResultProps, HealthFactorThresholds, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IDegenNFT, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IMultichainOpportunitiesService, IMultichainPositionsService, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, IncreaseDebtOp, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InnerFacadeOperation, InnerOperation, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type IntentValidationError, type InterestRateModelStateHuman, InterestRateModelType, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LeverageArgs, type LeverageBand, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidateCreditAccountOperation, LiquidationEligibilityError, LiquidationFees, LiquidationValidationError, LiquidationsService, LiquidatorEligibleArgs, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketExpiredArgs, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketStateError, type MarketStateHuman, MarketSuite, MarketType, MaxBorrowAmount, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallOperation, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, OpenCreditAccountOperation, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OpenStrategyState, Operation, OperationMetadata, type OperationState, OperationValidationError, OpportunitiesService, OptimalRepaidAmountProps, OuterFacadeOperation, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationOperation, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolDepositOperation, PoolLiquidityArgs, PoolMintOperation, PoolOperation, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolRedeemOperation, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolSunsetArgs, PoolV310Contract, PoolWithdrawOperation, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewOperationError, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, ProjectedPoolOptions, PythPriceFeed, QuotaCountArgs, QuotaKeeperState, QuotaLimitArgs, QuotaMode, type QuotaParamsHuman, QuotaSlice, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryProtocol, RWAFactoryStateHuman, RWAInvestorData, RWALiquidatorInfo, RWAMulticallOperation, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedemptionPhantomRename, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, ReplayMulticallResult, ReplayState, ReplayableOperation, RequestableWithdrawal, ReservePriceLimitedArgs, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteErrors, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeDegenNFT, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, SimulationValidationError, StakingRewardsAdapterContract, type StartIntent, StoreExpectedBalancesOp, StrategyCollateralProps, StrategyRateInputs, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokenTransfer, TokensMeta, TokensMetaState, TraceAdapterExt, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatePriceFeedsResult, UpdateQuotaOp, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WalletFundingError, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, WeighedFactors, type WithBlock, type WithMultichain, type WithdrawAssetIntent, type WithdrawCeilings, WithdrawCollateral, WithdrawCollateralOp, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
@@ -4,11 +4,13 @@ import { SDKReturn } from "../../../model/result.js";
4
4
  import "../../../model/index.js";
5
5
  import { PluginsMap } from "../../plugins/types.js";
6
6
  import { OnchainSDK } from "../../OnchainSDK.js";
7
- import { OpenCreditAccountOperation } from "../parse/types-facades.js";
8
- import { RWAOpenCreditAccountOperation } from "../parse/types-rwa.js";
7
+ import { MulticallOperation, OpenCreditAccountOperation } from "../parse/types-facades.js";
8
+ import { RWAMulticallOperation, RWAOpenCreditAccountOperation } from "../parse/types-rwa.js";
9
9
  import "../parse/index.js";
10
+ import { ReplayMulticallResult } from "./replayMulticall.js";
10
11
  import "../../index.js";
11
12
  //#region src/onchain/preview/preview/previewOpenStrategyPosition.d.ts
12
- declare function previewOpenStrategyPosition<P extends PluginsMap>(sdk: OnchainSDK<P>, input: PreviewOperationInput, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): SDKReturn<OpenStrategyPositionPreview, MalformedTransactionError>;
13
+ type OpenPreviewOperation = OpenCreditAccountOperation | RWAOpenCreditAccountOperation | MulticallOperation | RWAMulticallOperation;
14
+ declare function previewOpenStrategyPosition<P extends PluginsMap>(sdk: OnchainSDK<P>, input: PreviewOperationInput, operation: OpenPreviewOperation, replay: ReplayMulticallResult): SDKReturn<OpenStrategyPositionPreview, MalformedTransactionError>;
13
15
  //#endregion
14
16
  export { previewOpenStrategyPosition };
@@ -12,12 +12,12 @@ import "../../index.js";
12
12
  import { Address } from "viem";
13
13
  //#region src/onchain/preview/preview/replayMulticall.d.ts
14
14
  /**
15
- * Parsed operation on an existing credit account whose multicall can be
16
- * replayed: the facade `closeCreditAccount` entry point and
17
- * plain/bot/RWA multicalls all fit structurally.
15
+ * Parsed operation whose multicall can be replayed: a facade or RWA
16
+ * opening (empty seed) and close/plain/bot/RWA multicalls on an existing
17
+ * account all fit structurally.
18
18
  */
19
19
  interface ReplayableOperation {
20
- creditAccount: Address;
20
+ creditManager: Address;
21
21
  multicall: InnerOperation[];
22
22
  }
23
23
  /**
@@ -36,9 +36,10 @@ interface ReplayMulticallResult {
36
36
  after: ReplayState;
37
37
  }
38
38
  /**
39
- * Replays the operation's multicall over the account's pre-resolved
40
- * pre-state via {@link replayInnerOperations}.
39
+ * Replays the operation's multicall via {@link replayInnerOperations}.
40
+ * When `creditAccount` is omitted, the seed is
41
+ * {@link CreditAccountState.beforeOpen} (a fresh opening).
41
42
  */
42
- declare function replayMulticall<P extends PluginsMap>(sdk: OnchainSDK<P>, operation: ReplayableOperation, creditAccount: CreditAccountData): SDKReturn<ReplayMulticallResult, MalformedTransactionError>;
43
+ declare function replayMulticall<P extends PluginsMap>(sdk: OnchainSDK<P>, operation: ReplayableOperation, creditAccount?: CreditAccountData): SDKReturn<ReplayMulticallResult, MalformedTransactionError>;
43
44
  //#endregion
44
45
  export { ReplayMulticallResult, ReplayableOperation, replayMulticall };
@@ -12,8 +12,8 @@ interface DebtLimitsArgs {
12
12
  /**
13
13
  * Whether ending with no loan at all is acceptable. The one place the two
14
14
  * callers genuinely disagree: an account being adjusted may end owing
15
- * nothing, while one being opened may not — so the exemption is stated
16
- * rather than assumed.
15
+ * nothing, while one being opened may not unless it is opened empty — so the
16
+ * exemption is stated rather than assumed.
17
17
  */
18
18
  allowZero: boolean;
19
19
  /** From the caller's suite; a caller that raises to throw advises nobody. */