@gearbox-protocol/sdk 17.10.0 → 17.10.1-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 (88) hide show
  1. package/dist/cjs/onchain/accounts/index.js +1 -0
  2. package/dist/cjs/onchain/accounts/intents/guards.js +4 -2
  3. package/dist/cjs/onchain/accounts/intents/index.js +44 -11
  4. package/dist/cjs/onchain/accounts/intents/leverage-band.js +49 -8
  5. package/dist/cjs/onchain/accounts/intents/math.js +3 -44
  6. package/dist/cjs/onchain/accounts/intents/maxBorrow.js +7 -1
  7. package/dist/cjs/onchain/accounts/intents/open-strategy.js +12 -7
  8. package/dist/cjs/onchain/accounts/intents/plan.js +4 -4
  9. package/dist/cjs/onchain/accounts/intents/realize.js +4 -3
  10. package/dist/cjs/onchain/accounts/intents/strategyLimits.js +159 -0
  11. package/dist/cjs/onchain/accounts/intents/tail.js +6 -2
  12. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +4 -0
  13. package/dist/cjs/onchain/accounts/intents/utils/index.js +1 -0
  14. package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +39 -0
  15. package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +1 -1
  16. package/dist/cjs/onchain/accounts/quota-utils.js +9 -0
  17. package/dist/cjs/onchain/index.js +1 -0
  18. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +8 -6
  19. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +2 -3
  20. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +3 -4
  21. package/dist/cjs/onchain/validation/checks/checkQuotaLimit.js +2 -1
  22. package/dist/cjs/sdk/prepare/PrepareApi.js +3 -2
  23. package/dist/esm/dev/AccountOpener.js +1 -1
  24. package/dist/esm/dev/withdrawalUtils.js +1 -1
  25. package/dist/esm/history/trace/extractTransfers.js +1 -1
  26. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  27. package/dist/esm/onchain/accounts/index.js +2 -2
  28. package/dist/esm/onchain/accounts/intents/guards.js +4 -2
  29. package/dist/esm/onchain/accounts/intents/index.js +44 -11
  30. package/dist/esm/onchain/accounts/intents/leverage-band.js +50 -9
  31. package/dist/esm/onchain/accounts/intents/math.js +5 -45
  32. package/dist/esm/onchain/accounts/intents/maxBorrow.js +7 -1
  33. package/dist/esm/onchain/accounts/intents/open-strategy.js +13 -8
  34. package/dist/esm/onchain/accounts/intents/plan.js +4 -4
  35. package/dist/esm/onchain/accounts/intents/realize.js +4 -3
  36. package/dist/esm/onchain/accounts/intents/strategyLimits.js +158 -0
  37. package/dist/esm/onchain/accounts/intents/tail.js +6 -2
  38. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +4 -0
  39. package/dist/esm/onchain/accounts/intents/utils/index.js +2 -2
  40. package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +41 -3
  41. package/dist/esm/onchain/accounts/intents/withdraw-limits.js +1 -1
  42. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  43. package/dist/esm/onchain/accounts/quota-utils.js +9 -1
  44. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  45. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  46. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  47. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  48. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  49. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  50. package/dist/esm/onchain/index.js +2 -2
  51. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  52. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  53. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  54. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +8 -6
  55. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  56. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  57. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  58. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  59. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  60. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  61. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +2 -3
  62. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +3 -4
  63. package/dist/esm/onchain/validation/checks/checkQuotaLimit.js +2 -1
  64. package/dist/esm/sdk/prepare/PrepareApi.js +3 -2
  65. package/dist/types/model/errors/index.d.ts +2 -2
  66. package/dist/types/model/errors/operation-errors.d.ts +28 -14
  67. package/dist/types/model/index.d.ts +2 -2
  68. package/dist/types/onchain/accounts/index.d.ts +2 -2
  69. package/dist/types/onchain/accounts/intents/guards.d.ts +12 -12
  70. package/dist/types/onchain/accounts/intents/index.d.ts +2 -3
  71. package/dist/types/onchain/accounts/intents/leverage-band.d.ts +8 -6
  72. package/dist/types/onchain/accounts/intents/math.d.ts +7 -16
  73. package/dist/types/onchain/accounts/intents/plan.d.ts +2 -0
  74. package/dist/types/onchain/accounts/intents/realize.d.ts +3 -0
  75. package/dist/types/onchain/accounts/intents/strategyLimits.d.ts +33 -0
  76. package/dist/types/onchain/accounts/intents/tail.d.ts +13 -9
  77. package/dist/types/onchain/accounts/intents/utils/index.d.ts +2 -2
  78. package/dist/types/onchain/accounts/intents/utils/quotas-for-update.d.ts +15 -1
  79. package/dist/types/onchain/accounts/quota-utils.d.ts +11 -1
  80. package/dist/types/onchain/index.d.ts +2 -2
  81. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +0 -3
  82. package/dist/types/onchain/market/oracle/types.d.ts +4 -3
  83. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +2 -3
  84. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -3
  85. package/dist/types/onchain/validation/checks/checkQuotaLimit.d.ts +2 -2
  86. package/dist/types/sdk/prepare/PrepareApi.d.ts +1 -1
  87. package/dist/types/sdk/prepare/types.d.ts +3 -4
  88. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { iPausableAbi } from "../../../abi/iPausable.js";
1
2
  import { iPoolV310Abi } from "../../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../utils/AddressMap.js";
3
4
  import { RAY } from "../../constants/math.js";
@@ -7,7 +8,6 @@ import "../../utils/index.js";
7
8
  import { SdkRWADataNotLoadedError } from "../../core/errors.js";
8
9
  import { BaseContract } from "../../base/BaseContract.js";
9
10
  import "../../base/index.js";
10
- import { iPausableAbi } from "../../../abi/iPausable.js";
11
11
  //#region src/onchain/market/pool/PoolV310Contract.ts
12
12
  const abi = [...iPoolV310Abi, ...iPausableAbi];
13
13
  var PoolV310Contract = class extends BaseContract {
@@ -1,6 +1,6 @@
1
+ import { iVersionAbi } from "../../../abi/iVersion.js";
1
2
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
2
3
  import "../../utils/index.js";
3
- import { iVersionAbi } from "../../../abi/iVersion.js";
4
4
  import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
5
5
  import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
6
6
  import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
@@ -1,5 +1,5 @@
1
- import { ZapperContract } from "./ZapperContract.js";
2
1
  import { iethZapperAbi } from "../../../abi/iETHZapper.js";
2
+ import { ZapperContract } from "./ZapperContract.js";
3
3
  //#region src/onchain/market/zapper/IETHZapperContract.ts
4
4
  const abi = iethZapperAbi;
5
5
  var IETHZapperContract = class extends ZapperContract {
@@ -1,8 +1,8 @@
1
+ import { iZapperAbi } from "../../../abi/iZapper.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
- import { iZapperAbi } from "../../../abi/iZapper.js";
6
6
  //#region src/onchain/market/zapper/ZapperContract.ts
7
7
  /**
8
8
  * Base contract for every Gearbox zapper. Specialized zappers (e.g.
@@ -1,8 +1,8 @@
1
- import { iPoolV310Abi } from "../../../abi/310/generated.js";
2
1
  import { ierc20Abi } from "../../../abi/iERC20.js";
2
+ import { iZapperAbi } from "../../../abi/iZapper.js";
3
+ import { iPoolV310Abi } from "../../../abi/310/generated.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
- import { iZapperAbi } from "../../../abi/iZapper.js";
6
6
  //#region src/onchain/preview/preview/previewPoolPositionOperation.ts
7
7
  function previewRead(operation) {
8
8
  switch (operation.operation) {
@@ -1,6 +1,6 @@
1
1
  import { errorAbis } from "../../../abi/errors.js";
2
- import { generateCastTraceCall } from "./cast.js";
3
2
  import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
3
+ import { generateCastTraceCall } from "./cast.js";
4
4
  import { simulateMulticall } from "./simulateMulticall.js";
5
5
  import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
6
6
  import { getAction, parseAccount } from "viem/utils";
@@ -11,13 +11,12 @@ import "../helpers/index.js";
11
11
  * takeable, left out when none is.
12
12
  */
13
13
  function checkBorrowLimit(args) {
14
- const { requested, available, limit, underlying, maxBorrowAmount } = args;
14
+ const { requested, available, underlying, maxBorrowAmount, ...rest } = args;
15
15
  if (requested <= available) return [];
16
16
  return [insufficientPoolLiquidity({
17
- collateralLimits: args.getCollateralLimits?.(),
17
+ ...rest,
18
18
  requested: amountOf(underlying, requested),
19
19
  available: amountOf(underlying, available),
20
- limit,
21
20
  ...maxBorrowAmount === void 0 ? {} : { maxBorrowAmount: amountOf(underlying, maxBorrowAmount) }
22
21
  })];
23
22
  }
@@ -5,14 +5,13 @@ import "../helpers/index.js";
5
5
  //#region src/onchain/validation/checks/checkDebtLimits.ts
6
6
  /** A debt the facade would revert on. */
7
7
  function checkDebtLimits(args) {
8
- const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
8
+ const { debt, minDebt, maxDebt, underlying, allowZero, ...rest } = args;
9
9
  if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
10
10
  return [debtOutOfRange({
11
- collateralLimits: args.getCollateralLimits?.(),
11
+ ...rest,
12
12
  requested: amountOf(underlying, debt),
13
13
  minDebt: amountOf(underlying, minDebt),
14
- maxDebt: amountOf(underlying, maxDebt),
15
- maxBorrowAmount
14
+ maxDebt: amountOf(underlying, maxDebt)
16
15
  })];
17
16
  }
18
17
  //#endregion
@@ -5,9 +5,10 @@ import "../helpers/index.js";
5
5
  //#region src/onchain/validation/checks/checkQuotaLimit.ts
6
6
  /** The room the keeper still has for a token's quota, in the underlying. */
7
7
  function checkQuotaLimit(args) {
8
- const { token, requested, available, underlying } = args;
8
+ const { token, requested, available, underlying, ...rest } = args;
9
9
  if (requested !== void 0 && requested <= available) return [];
10
10
  return [quotaLimitReached({
11
+ ...rest,
11
12
  token,
12
13
  requested: requested === void 0 ? void 0 : amountOf(underlying, requested),
13
14
  available: amountOf(underlying, available)
@@ -373,13 +373,14 @@ var PrepareApi = class extends MultichainConstruct {
373
373
  /**
374
374
  * {@inheritDoc IOpportunitiesPrepare.leverageBand}
375
375
  **/
376
- leverageBand(strategy, collateral, targetHF) {
376
+ leverageBand(strategy, collateral, targetHF, position) {
377
377
  const sdk = this.sdk.chain(strategy.chainId);
378
378
  return service(sdk).leverageBand({
379
379
  sdk,
380
380
  creditManager: strategy.creditManager,
381
381
  collateral,
382
- targetHF
382
+ targetHF,
383
+ position
383
384
  });
384
385
  }
385
386
  /**
@@ -1,7 +1,7 @@
1
1
  import { IGearboxError } from "./base.js";
2
2
  import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./liquidation-errors.js";
3
- import { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./operation-errors.js";
3
+ import { AccountNotMidasGreenlistedError, BorrowLimitCause, CollateralLimits, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageLimits, LeverageOutOfRangeError, MarketExpiredError, OperationLimitOptions, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaInputLimits, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./operation-errors.js";
4
4
  import { UnpriceableTokenError, unpriceableTokenError } from "./oracle-errors.js";
5
5
  import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./prepare-errors.js";
6
6
  import { InvalidDelayedIntentError, MalformedTransactionError, PoolOperationPreviewError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, malformedTransaction } from "./preview-errors.js";
7
- export { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, IGearboxError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, LeverageOutOfRangeError, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, PoolOperationPreviewError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, accountNotMidasGreenlisted, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
7
+ export { AccountNotMidasGreenlistedError, BorrowLimitCause, CollateralLimits, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, IGearboxError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, LeverageLimits, LeverageOutOfRangeError, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, OperationLimitOptions, PoolOperationPreviewError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaInputLimits, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, accountNotMidasGreenlisted, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
@@ -5,6 +5,30 @@ import { MaxBorrowAmount } from "../../onchain/market/credit/types.js";
5
5
  import "../../onchain/index.js";
6
6
  import { Address } from "viem";
7
7
  //#region src/model/errors/operation-errors.d.ts
8
+ /** Input amounts bounded by debt and borrowing capacity; quota is separate. */
9
+ interface CollateralLimits {
10
+ min: TokenAmount;
11
+ max: TokenAmount;
12
+ }
13
+ /** Target leverage in LEVERAGE_DECIMALS units. */
14
+ interface LeverageLimits {
15
+ min: bigint;
16
+ max: bigint;
17
+ }
18
+ /** Independent operation inputs imposed by the quota keeper. */
19
+ type QuotaInputLimits = {
20
+ collateralMax: TokenAmount;
21
+ leverageMax?: bigint;
22
+ } | {
23
+ collateralMax?: TokenAmount;
24
+ leverageMax: bigint;
25
+ };
26
+ /** Prepared operation-specific bounds passed to validation errors. */
27
+ interface OperationLimitOptions {
28
+ collateralLimits?: CollateralLimits;
29
+ leverageLimits?: LeverageLimits;
30
+ quotaLimits?: QuotaInputLimits;
31
+ }
8
32
  /**
9
33
  * Which limit stopped a borrow.
10
34
  *
@@ -68,13 +92,8 @@ declare function poolSunset(pool: Address): PoolSunsetError;
68
92
  /**
69
93
  * The pool cannot lend what the operation wants to borrow.
70
94
  **/
71
- interface InsufficientPoolLiquidityError extends IGearboxError {
95
+ interface InsufficientPoolLiquidityError extends IGearboxError, OperationLimitOptions {
72
96
  code: "insufficientPoolLiquidity";
73
- /** Single-token Open amounts whose projected debt fits the current debt limits. */
74
- collateralLimits?: {
75
- min: TokenAmount;
76
- max: TokenAmount;
77
- };
78
97
  /** Both in the market's underlying. */
79
98
  requested: TokenAmount;
80
99
  available: TokenAmount;
@@ -94,13 +113,8 @@ declare function insufficientPoolLiquidity(args: Omit<InsufficientPoolLiquidityE
94
113
  * The debt the operation implies falls outside the facade's `debtLimits`
95
114
  * (`minDebt`/`maxDebt`).
96
115
  **/
97
- interface DebtOutOfRangeError extends IGearboxError {
116
+ interface DebtOutOfRangeError extends IGearboxError, OperationLimitOptions {
98
117
  code: "debtOutOfRange";
99
- /** Single-token Open amounts whose projected debt fits the current debt limits. */
100
- collateralLimits?: {
101
- min: TokenAmount;
102
- max: TokenAmount;
103
- };
104
118
  /** All three in the market's underlying. */
105
119
  requested: TokenAmount;
106
120
  minDebt: TokenAmount;
@@ -201,7 +215,7 @@ declare function forbiddenToken(token: Token): ForbiddenTokenError;
201
215
  /**
202
216
  * The market takes no more quota for a token the operation wants to hold.
203
217
  **/
204
- interface QuotaLimitReachedError extends IGearboxError {
218
+ interface QuotaLimitReachedError extends IGearboxError, OperationLimitOptions {
205
219
  code: "quotaLimitReached";
206
220
  /** The token whose quota is increased. */
207
221
  token: Token;
@@ -297,4 +311,4 @@ interface AccountNotMidasGreenlistedError extends IGearboxError {
297
311
  /** {@inheritDoc AccountNotMidasGreenlistedError} */
298
312
  declare function accountNotMidasGreenlisted(args: Omit<AccountNotMidasGreenlistedError, "code" | "message">): AccountNotMidasGreenlistedError;
299
313
  //#endregion
300
- export { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet };
314
+ export { AccountNotMidasGreenlistedError, BorrowLimitCause, CollateralLimits, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageLimits, LeverageOutOfRangeError, MarketExpiredError, OperationLimitOptions, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaInputLimits, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet };
@@ -6,7 +6,7 @@ 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 { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
9
+ import { AccountNotMidasGreenlistedError, BorrowLimitCause, CollateralLimits, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageLimits, LeverageOutOfRangeError, MarketExpiredError, OperationLimitOptions, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaInputLimits, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, 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";
@@ -34,4 +34,4 @@ import { MerklReward, PointsReward, Reward } from "./rewards.js";
34
34
  import { kycRequirementSchema, rwaProtocolSchema } from "./rwa.schema.js";
35
35
  import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
36
36
  import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
37
- export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, 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, MerklReward, 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, PointsReward, 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, Reward, 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, accountNotMidasGreenlisted, 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 };
37
+ export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, 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, CollateralLimits, 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, LeverageLimits, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MerklReward, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationLimitOptions, 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, PointsReward, 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, QuotaInputLimits, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Reward, 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, accountNotMidasGreenlisted, 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 };
@@ -19,7 +19,7 @@ import { AccountBotsService } from "./bots/AccountBotsService.js";
19
19
  import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
20
20
  import "./bots/index.js";
21
21
  import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
22
- import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
22
+ import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, DIRECT_TRANSFERS_QUOTA, MaxAmountForQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, maxAmountForQuota, roundUpQuota } from "./quota-utils.js";
23
23
  import { AccountCalculatorOperation } from "./intents/operations.js";
24
24
  import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
25
25
  import { BorrowProps, BorrowState } from "./intents/borrow.js";
@@ -33,4 +33,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
33
33
  import { LiquidationsService } from "./liquidations/LiquidationsService.js";
34
34
  import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
35
35
  import "./liquidations/index.js";
36
- export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
36
+ export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MaxAmountForQuotaProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, maxAmountForQuota, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
@@ -1,5 +1,5 @@
1
1
  import { Bps, TokenAmount } from "../../../model/primitives.js";
2
- import { InsufficientPoolLiquidityError } from "../../../model/errors/operation-errors.js";
2
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
3
3
  import "../../../model/index.js";
4
4
  import { Asset } from "../../base/types.js";
5
5
  import { MarketSuite } from "../../market/MarketSuite.js";
@@ -29,9 +29,15 @@ import "../../index.js";
29
29
  */
30
30
  declare function assertMarketOperable(suite: CreditSuite): void;
31
31
  /** The pool has to be able to lend what the plan means to draw. */
32
- declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bigint, options?: {
33
- getCollateralLimits?: () => InsufficientPoolLiquidityError["collateralLimits"];
34
- }): void;
32
+ declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bigint, options?: OperationLimitOptions): void;
33
+ interface GrowthAllowedProps {
34
+ sdk: OnchainSDK;
35
+ suite: CreditSuite;
36
+ market: MarketSuite;
37
+ before: readonly Asset[];
38
+ after: readonly Asset[];
39
+ limits?: OperationLimitOptions;
40
+ }
35
41
  /**
36
42
  * What the account is allowed to end up holding more of than it started with.
37
43
  *
@@ -44,13 +50,7 @@ declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bi
44
50
  * The underlying answers to neither rule, and a phantom token is a redemption
45
51
  * in flight rather than a holding.
46
52
  */
47
- declare function assertGrowthAllowed(args: {
48
- sdk: OnchainSDK;
49
- suite: CreditSuite;
50
- market: MarketSuite;
51
- before: readonly Asset[];
52
- after: readonly Asset[];
53
- }): void;
53
+ declare function assertGrowthAllowed(args: GrowthAllowedProps): void;
54
54
  /**
55
55
  * The facade weighs the account against its debt at the end of every multicall
56
56
  * and reverts if the collateral does not cover it, so a plan that lands the
@@ -100,6 +100,6 @@ type SafePriceEvidence = () => {
100
100
  * A quota can only be raised as far as the market still has room for: past the
101
101
  * token's limit the keeper takes nothing more, whoever is asking.
102
102
  */
103
- declare function assertQuotaAvailable(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
103
+ declare function assertQuotaAvailable(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[], options?: OperationLimitOptions): void;
104
104
  //#endregion
105
105
  export { SafePriceEvidence, assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable };
@@ -111,9 +111,8 @@ declare class CreditAccountOperationsService extends SDKConstruct {
111
111
  * given deposit reaches is decided by the debt it implies and by the
112
112
  * `debtLimits` the market puts that debt in — the range a leverage slider should offer.
113
113
  *
114
- * Unlike the other ceilings here this one reads no account: opening has none
115
- * yet, and adjusting measures against the net value the caller already
116
- * holds. Nothing is fetched, so a form can ask on every keystroke.
114
+ * Nothing is fetched: opening uses the supplied collateral, while adjust
115
+ * uses a supplied account slice, so a form can ask on every keystroke.
117
116
  *
118
117
  * @param props - The manager, the SDK holding its market, what stands
119
118
  * behind the position, and optionally the health factor the ceiling should
@@ -1,4 +1,5 @@
1
1
  import { Bps, Leverage } from "../../../model/primitives.js";
2
+ import { StrategyPosition } from "../../../model/positions.js";
2
3
  import "../../../model/index.js";
3
4
  import { Asset } from "../../base/types.js";
4
5
  import { OnchainSDK } from "../../OnchainSDK.js";
@@ -15,9 +16,8 @@ interface LeverageBandProps {
15
16
  /** Credit manager the position lives in; every limit is read off it. */
16
17
  readonly creditManager: Address;
17
18
  /**
18
- * What stands behind the position: the tokens being deposited when opening
19
- * one, or its own net value when adjusting one. Priced into the market's
20
- * underlying here, so a caller hands over amounts and no exchange rates.
19
+ * Tokens deposited when opening a position. Ignored when `account` selects
20
+ * adjust mode, because that mode derives own funds from the account slice.
21
21
  **/
22
22
  readonly collateral: readonly Asset[];
23
23
  /**
@@ -25,6 +25,8 @@ interface LeverageBandProps {
25
25
  * points. Omitted keeps `calcMaxLeverage` on its flat buffer.
26
26
  **/
27
27
  readonly targetHF?: Bps;
28
+ /** Existing position; when present, its debt and quotas define an adjust band. */
29
+ readonly position?: StrategyPosition;
28
30
  }
29
31
  /**
30
32
  * The leverages this market will actually fund for a position of this size.
@@ -39,8 +41,8 @@ interface LeverageBandProps {
39
41
  * rounds **up** so the leverage it names really does clear `minDebt`, and the
40
42
  * ceiling rounds **down** so it really does stay under the borrow limit.
41
43
  *
42
- * Nothing here is fetched or simulated — every input is loaded market state,
43
- * so a form can call this on each keystroke.
44
+ * Nothing here is fetched or simulated — adjust state comes from the supplied
45
+ * position and the attached market, so a form can call this on each keystroke.
44
46
  *
45
47
  * @param props - {@link LeverageBandProps}
46
48
  * @returns The band, or `undefined` when there is nothing to offer: an
@@ -53,6 +55,6 @@ interface LeverageBandProps {
53
55
  * calcLeverageBand({ sdk, creditManager, collateral }) // { min: 1.1, max: 9 }
54
56
  * ```
55
57
  **/
56
- declare function calcLeverageBand({ sdk, creditManager, collateral, targetHF }: LeverageBandProps): LeverageBand | undefined;
58
+ declare function calcLeverageBand({ sdk, creditManager, collateral, targetHF, position }: LeverageBandProps): LeverageBand | undefined;
57
59
  //#endregion
58
60
  export { LeverageBand, LeverageBandProps, calcLeverageBand };
@@ -1,11 +1,8 @@
1
- import { DebtOutOfRangeError } from "../../../model/errors/operation-errors.js";
1
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
2
2
  import "../../../model/index.js";
3
- import { Asset } from "../../base/types.js";
4
3
  import { MaxBorrowAmount } from "../../market/credit/types.js";
5
- import { CreditSuite } from "../../market/credit/CreditSuite.js";
6
4
  import "../../market/index.js";
7
5
  import { OnchainSDK } from "../../OnchainSDK.js";
8
- import "../../base/index.js";
9
6
  import { Address } from "viem";
10
7
  //#region src/onchain/accounts/intents/math.d.ts
11
8
  /**
@@ -47,21 +44,15 @@ declare function proportionalDebt(position: Position, collateralDelta: bigint):
47
44
  declare function maxProportionalWithdrawal(position: Position, debtLimits: DebtLimits): bigint;
48
45
  /** Total leverage cannot drop below 1x — that would be negative debt. */
49
46
  declare function assertLeverageAtLeastOne(leverage: bigint): void;
47
+ interface AssertDebtLimitsOptions extends OperationLimitOptions {
48
+ allowZero?: boolean;
49
+ maxBorrowAmount?: MaxBorrowAmount;
50
+ }
50
51
  /**
51
52
  * Rejects a debt the facade would revert on: anything else has to sit inside
52
53
  * `[minDebt, maxDebt]`. Zero is fine only `allowZero`-ing it: an adjustment
53
54
  * may end owing nothing, an opening may not.
54
55
  */
55
- declare function assertDebtLimits(sdk: OnchainSDK, debt: bigint, debtLimits: DebtLimits, underlying: Address, options?: {
56
- allowZero?: boolean;
57
- maxBorrowAmount?: MaxBorrowAmount;
58
- getCollateralLimits?: () => DebtOutOfRangeError["collateralLimits"];
59
- }): void;
60
- /** Finds single-token Open amounts whose projected debt fits the market limits. */
61
- declare function openCollateralForDebtLimits({ suite, collateral, leverage }: {
62
- suite: CreditSuite;
63
- collateral: readonly Asset[];
64
- leverage: bigint;
65
- }): DebtOutOfRangeError["collateralLimits"];
56
+ declare function assertDebtLimits(sdk: OnchainSDK, debt: bigint, debtLimits: DebtLimits, underlying: Address, options?: AssertDebtLimitsOptions): void;
66
57
  //#endregion
67
- export { DebtLimits, Position, assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage, maxProportionalWithdrawal, openCollateralForDebtLimits, proportionalDebt };
58
+ export { DebtLimits, Position, assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage, maxProportionalWithdrawal, proportionalDebt };
@@ -1,4 +1,5 @@
1
1
  import { DelayedIntent } from "../../../model/delayed-intents.js";
2
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
2
3
  import "../../../model/index.js";
3
4
  import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
4
5
  import { OnchainSDK } from "../../OnchainSDK.js";
@@ -100,6 +101,7 @@ type Step = {
100
101
  };
101
102
  /** What a planner is allowed to know about the account. */
102
103
  interface AccountView {
104
+ limits?: OperationLimitOptions;
103
105
  underlying: Address;
104
106
  /** The attached SDK, for the guards that inline a token into a refusal. */
105
107
  sdk: OnchainSDK;
@@ -1,3 +1,5 @@
1
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
1
3
  import { MultiCall } from "../../types/transactions.js";
2
4
  import { OnchainSDK } from "../../OnchainSDK.js";
3
5
  import { AccountCalculatorOperation } from "./operations.js";
@@ -7,6 +9,7 @@ import { Step } from "./plan.js";
7
9
  import { RouterPaths } from "./utils/router-path.js";
8
10
  //#region src/onchain/accounts/intents/realize.d.ts
9
11
  interface RealizeProps {
12
+ limits?: OperationLimitOptions;
10
13
  creditAccount: CreditAccountSlice;
11
14
  sdk: OnchainSDK;
12
15
  /** Router slippage in PERCENTAGE_FORMAT (100% = 10_000). */
@@ -0,0 +1,33 @@
1
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Asset } from "../../base/types.js";
4
+ import { CreditSuite } from "../../market/credit/CreditSuite.js";
5
+ import "../../base/index.js";
6
+ import { AdjustLeverageIntent, CreditAccountSlice, DepositStrategyIntent } from "./types.js";
7
+ import { AccountView } from "./plan.js";
8
+ import { Address } from "viem";
9
+ //#region src/onchain/accounts/intents/strategyLimits.d.ts
10
+ interface BaseLimitsProps {
11
+ suite: CreditSuite;
12
+ quotaReserve: number | undefined;
13
+ }
14
+ interface OpenLimitsProps extends BaseLimitsProps {
15
+ type: "OPEN";
16
+ collateral: readonly Asset[];
17
+ leverage: bigint;
18
+ targetToken: Address;
19
+ }
20
+ interface AccountLimitsProps extends BaseLimitsProps {
21
+ view: AccountView;
22
+ initialQuotas: CreditAccountSlice["tokens"];
23
+ }
24
+ interface DepositLimitsProps extends AccountLimitsProps, DepositStrategyIntent {}
25
+ interface LeverageLimitsProps extends AccountLimitsProps, AdjustLeverageIntent {
26
+ /** Additional ceiling imposed by the selected delayed route. */
27
+ maxLeverage?: bigint;
28
+ }
29
+ type StrategyLimitsProps = OpenLimitsProps | DepositLimitsProps | LeverageLimitsProps;
30
+ /** Independent input bounds supplied to debt, liquidity and quota errors. */
31
+ declare function strategyLimits(props: StrategyLimitsProps): OperationLimitOptions;
32
+ //#endregion
33
+ export { strategyLimits };
@@ -1,3 +1,5 @@
1
+ import { OperationLimitOptions } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
1
3
  import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
2
4
  import { OnchainSDK } from "../../OnchainSDK.js";
3
5
  import { AccountCalculatorOperation, StartDelayedWithdrawalOperation } from "./operations.js";
@@ -28,6 +30,16 @@ declare function planTail(args: {
28
30
  claimable: ClaimableWithdrawal;
29
31
  view: AccountView;
30
32
  }): TailPlan;
33
+ interface ProjectTailProps {
34
+ /** The request as realised: the source spent, the phantom it produced. */
35
+ request: StartDelayedWithdrawalOperation;
36
+ delayed: DelayedStart;
37
+ /** The account the request was previewed against, for masks and market. */
38
+ creditAccount: CreditAccountSlice;
39
+ sdk: OnchainSDK;
40
+ quotaReserve: number | undefined;
41
+ limits?: OperationLimitOptions;
42
+ }
31
43
  /**
32
44
  * Where a delayed intent ends up, worked out at the moment it is started.
33
45
  *
@@ -46,15 +58,7 @@ declare function planTail(args: {
46
58
  * that would strand the account is refused before it is sent rather than
47
59
  * discovered days later.
48
60
  */
49
- declare function projectTail(args: {
50
- /** The request as realised: the source spent, the phantom it produced. */
51
- request: StartDelayedWithdrawalOperation;
52
- delayed: DelayedStart;
53
- /** The account the request was previewed against, for masks and market. */
54
- creditAccount: CreditAccountSlice;
55
- sdk: OnchainSDK;
56
- quotaReserve: number | undefined;
57
- }): Promise<{
61
+ declare function projectTail(args: ProjectTailProps): Promise<{
58
62
  state: OperationState;
59
63
  operations: AccountCalculatorOperation[];
60
64
  }>;
@@ -7,5 +7,5 @@ import { assembleOperationCalls } from "./assemble-operation-calls.js";
7
7
  import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-interest-and-fees.js";
8
8
  import { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals } from "./common.js";
9
9
  import { LedgerSnapshot, OperationLedger } from "./ledger.js";
10
- import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota } from "./quotas-for-update.js";
11
- export { CandidateToken, LedgerSnapshot, LegProbe, OpenStrategyLeg, OperationLedger, RouterPaths, SwapLeg, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice, withDirectTransferQuota };
10
+ import { clearedQuotas, getQuotasForUpdate, quotaIncreaseLimit, quotasAfterUpdate, withDirectTransferQuota } from "./quotas-for-update.js";
11
+ export { CandidateToken, LedgerSnapshot, LegProbe, OpenStrategyLeg, OperationLedger, RouterPaths, SwapLeg, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotaIncreaseLimit, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice, withDirectTransferQuota };
@@ -1,6 +1,10 @@
1
+ import { UnpriceableTokenError } from "../../../../model/errors/oracle-errors.js";
2
+ import { SafeValue } from "../../../../model/result.js";
3
+ import "../../../../model/index.js";
1
4
  import { AddressMap } from "../../../utils/AddressMap.js";
2
5
  import { Asset } from "../../../base/types.js";
3
6
  import { ConvertFn } from "../../../market/oracle/types.js";
7
+ import { CreditSuite } from "../../../market/credit/CreditSuite.js";
4
8
  import { QuotaUpdateState } from "../operations.js";
5
9
  import "../../../index.js";
6
10
  import { Address } from "viem";
@@ -29,6 +33,14 @@ interface GetQuotasForUpdateProps {
29
33
  maxDebt: bigint;
30
34
  convert: ConvertFn;
31
35
  }
36
+ interface QuotaIncreaseLimitProps {
37
+ suite: CreditSuite;
38
+ token: Address;
39
+ balance: bigint;
40
+ initialQuotas: readonly InitialQuota[];
41
+ quotaReserve?: number;
42
+ rwaAsset?: Address;
43
+ }
32
44
  declare function getQuotasForUpdate({ assetsBefore, assetsAfter, initialQuotas, quotaReserve, liquidationThresholds: liquidationThresholdsMap, quotas: quotasMap, maxDebt, underlyingToken, convert }: GetQuotasForUpdateProps): QuotaUpdateState;
33
45
  /**
34
46
  * The update that leaves the account holding no quota at all.
@@ -58,5 +70,7 @@ declare function withDirectTransferQuota(update: QuotaUpdateState, directTransfe
58
70
  * are dropped: a token with no quota is a token the account is not quoted for.
59
71
  */
60
72
  declare function quotasAfterUpdate(initialQuotas: Array<InitialQuota> | readonly InitialQuota[], desiredQuota: Record<Address, Asset>): Record<Address, Asset>;
73
+ /** Largest additional underlying amount whose purchase fits this token's quota. */
74
+ declare function quotaIncreaseLimit({ suite, token, balance, initialQuotas, quotaReserve, rwaAsset }: QuotaIncreaseLimitProps): SafeValue<bigint | undefined, UnpriceableTokenError>;
61
75
  //#endregion
62
- export { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota };
76
+ export { clearedQuotas, getQuotasForUpdate, quotaIncreaseLimit, quotasAfterUpdate, withDirectTransferQuota };