@gearbox-protocol/sdk 16.3.1 → 16.3.2-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/errors/index.js +1 -0
- package/dist/cjs/model/errors/operation-errors.js +9 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/collateral-money.js +41 -0
- package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
- package/dist/cjs/onchain/accounts/intents/index.js +21 -18
- package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
- package/dist/cjs/onchain/accounts/intents/realize.js +10 -2
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
- package/dist/cjs/onchain/index.js +2 -0
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
- package/dist/cjs/onchain/validation/checks/index.js +2 -0
- package/dist/cjs/onchain/validation/index.js +2 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +3 -2
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +9 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/intents/collateral-money.js +40 -0
- package/dist/esm/onchain/accounts/intents/guards.js +15 -3
- package/dist/esm/onchain/accounts/intents/index.js +21 -18
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
- package/dist/esm/onchain/accounts/intents/realize.js +10 -2
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +2 -1
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
- package/dist/esm/onchain/validation/checks/index.js +2 -1
- package/dist/esm/onchain/validation/index.js +2 -1
- package/dist/esm/sdk/prepare/PrepareApi.js +3 -2
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +41 -1
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/collateral-money.d.ts +42 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +23 -14
- package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
- package/dist/types/onchain/accounts/intents/types.d.ts +26 -4
- package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
- package/dist/types/onchain/index.d.ts +2 -1
- package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
- package/dist/types/onchain/validation/checks/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +2 -1
- package/dist/types/onchain/validation/raise.d.ts +2 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +1 -1
- package/dist/types/sdk/prepare/types.d.ts +23 -16
- package/package.json +1 -1
|
@@ -13,4 +13,5 @@ import { PoolPausedArgs, checkPoolPaused } from "./checkPoolPaused.js";
|
|
|
13
13
|
import { PoolSunsetArgs, checkPoolSunset } from "./checkPoolSunset.js";
|
|
14
14
|
import { QuotaCountArgs, checkQuotaCount } from "./checkQuotaCount.js";
|
|
15
15
|
import { QuotaLimitArgs, checkQuotaLimit } from "./checkQuotaLimit.js";
|
|
16
|
-
|
|
16
|
+
import { ReservePriceLimitedArgs, checkReservePriceLimited } from "./checkReservePriceLimited.js";
|
|
17
|
+
export { BorrowLimitArgs, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, LeverageArgs, LiquidatorEligibleArgs, MarketExpiredArgs, PoolLiquidityArgs, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, ReservePriceLimitedArgs, checkBorrowLimit, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkLeverage, checkLiquidatorEligible, checkMarketExpired, checkPoolLiquidity, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkReservePriceLimited };
|
|
@@ -35,9 +35,10 @@ import { PoolPausedArgs, checkPoolPaused } from "./checks/checkPoolPaused.js";
|
|
|
35
35
|
import { PoolSunsetArgs, checkPoolSunset } from "./checks/checkPoolSunset.js";
|
|
36
36
|
import { QuotaCountArgs, checkQuotaCount } from "./checks/checkQuotaCount.js";
|
|
37
37
|
import { QuotaLimitArgs, checkQuotaLimit } from "./checks/checkQuotaLimit.js";
|
|
38
|
+
import { ReservePriceLimitedArgs, checkReservePriceLimited } from "./checks/checkReservePriceLimited.js";
|
|
38
39
|
import "./checks/index.js";
|
|
39
40
|
import { amountOf } from "./helpers/amount.js";
|
|
40
41
|
import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./helpers/health-factor-limits.js";
|
|
41
42
|
import { toToken, toTokenAmount } from "./helpers/token.js";
|
|
42
43
|
import "./helpers/index.js";
|
|
43
|
-
export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, OperationValidationError, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, 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, raise, toToken, toTokenAmount };
|
|
44
|
+
export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, OperationValidationError, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, ReservePriceLimitedArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, 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, raise, toToken, toTokenAmount };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
|
|
1
|
+
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError, ReservePriceLimitedError } from "../../model/errors/operation-errors.js";
|
|
2
2
|
import { MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
4
|
//#region src/onchain/validation/raise.d.ts
|
|
@@ -9,7 +9,7 @@ import "../../model/index.js";
|
|
|
9
9
|
* Not a catch-all of every SDK error — pool paused/sunset is `checkOperation`'s,
|
|
10
10
|
* a malformed transaction is `previewOperation`'s, not the engine's.
|
|
11
11
|
**/
|
|
12
|
-
type IntentValidationError = CreditManagerPausedError | MarketExpiredError | InsufficientPoolLiquidityError | DebtOutOfRangeError | LeverageOutOfRangeError | InsufficientCollateralError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientBalanceError | UnsupportedCollateralTokenError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError | NoRecordedIntentError;
|
|
12
|
+
type IntentValidationError = CreditManagerPausedError | MarketExpiredError | InsufficientPoolLiquidityError | DebtOutOfRangeError | LeverageOutOfRangeError | InsufficientCollateralError | ReservePriceLimitedError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientBalanceError | UnsupportedCollateralTokenError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError | NoRecordedIntentError;
|
|
13
13
|
/**
|
|
14
14
|
* Engine-internal throw: planners and guards raise one error object, and the
|
|
15
15
|
* service boundary turns it into {@link SDKError}.
|
|
@@ -79,7 +79,7 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
|
|
|
79
79
|
/**
|
|
80
80
|
* {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
|
|
81
81
|
**/
|
|
82
|
-
maxWithdraw(position: PositionInput): Promise<WithdrawCeilings>;
|
|
82
|
+
maxWithdraw(position: PositionInput, sourceToken?: Address): Promise<WithdrawCeilings>;
|
|
83
83
|
/**
|
|
84
84
|
* {@inheritDoc IOpportunitiesPrepare.repayStrategy}
|
|
85
85
|
**/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bps, Timestamp, TokenAmount } from "../../model/primitives.js";
|
|
2
2
|
import { Curator } from "../../model/curators.js";
|
|
3
|
-
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
|
|
3
|
+
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError, ReservePriceLimitedError } from "../../model/errors/operation-errors.js";
|
|
4
4
|
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
|
|
5
5
|
import { PoolOpportunityKey, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
6
6
|
import { PositionCollateral, StrategyPosition, StrategyPositionKey } from "../../model/positions.js";
|
|
@@ -22,7 +22,7 @@ import { Address } from "viem";
|
|
|
22
22
|
* What any operation on an existing account can answer with: the engine's
|
|
23
23
|
* shared guards, the missing account, and a wrapped crash.
|
|
24
24
|
**/
|
|
25
|
-
type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
|
|
25
|
+
type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | ReservePriceLimitedError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
|
|
26
26
|
/** Same guards for the account-less open flow. */
|
|
27
27
|
type OpenFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | UnexpectedFailureError;
|
|
28
28
|
/**
|
|
@@ -541,26 +541,33 @@ interface IOpportunitiesPrepare {
|
|
|
541
541
|
**/
|
|
542
542
|
withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError) & WithRouteErrors>>;
|
|
543
543
|
/**
|
|
544
|
-
* How much {@link withdrawStrategy} can take out,
|
|
545
|
-
* underlying units: `
|
|
546
|
-
*
|
|
547
|
-
* value leaving entirely hands over.
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* sit below the floor. A form driving a slider off
|
|
552
|
-
* button off `exit` describes what the account can
|
|
553
|
-
* either alone will misstate one of them — see
|
|
554
|
-
* which spells out how far apart they can be
|
|
555
|
-
*
|
|
556
|
-
*
|
|
544
|
+
* How much {@link withdrawStrategy} can take out, every end of it, in
|
|
545
|
+
* underlying units: `safePartial` is the largest partial withdrawal the flow
|
|
546
|
+
* accepts, `partial` the same figure before the safe-price collateral check
|
|
547
|
+
* has had its say, and `exit` the net value leaving entirely hands over.
|
|
548
|
+
*
|
|
549
|
+
* More than one number because the range has a hole in it: between the
|
|
550
|
+
* largest partial and `exit` the flow refuses with `debtOutOfRange`, since
|
|
551
|
+
* the leftover loan would sit below the floor. A form driving a slider off
|
|
552
|
+
* `safePartial` and a Max button off `exit` describes what the account can
|
|
553
|
+
* actually do; a form using either alone will misstate one of them — see
|
|
554
|
+
* {@link WithdrawCeilings}, which spells out how far apart they can be and
|
|
555
|
+
* why the two partial figures differ.
|
|
556
|
+
*
|
|
557
|
+
* `sourceToken` is the collateral the withdrawal would be funded from, the
|
|
558
|
+
* same argument {@link withdrawStrategy} takes. It matters because selling
|
|
559
|
+
* one collateral and selling another cost the safe-price check different
|
|
560
|
+
* amounts; omitted, both this and the flow itself reach for the account's
|
|
561
|
+
* largest non-phantom balance.
|
|
562
|
+
*
|
|
563
|
+
* Taking everything out needs none of the figures: send `MAX_UINT256` to
|
|
557
564
|
* {@link withdrawStrategy} and the exit is what runs, named rather than
|
|
558
565
|
* priced.
|
|
559
566
|
*
|
|
560
567
|
* A bare read: it answers its numbers, and throws on an account or a chain
|
|
561
568
|
* the SDK does not hold.
|
|
562
569
|
**/
|
|
563
|
-
maxWithdraw(position: PositionInput): Promise<WithdrawCeilings>;
|
|
570
|
+
maxWithdraw(position: PositionInput, sourceToken?: Address): Promise<WithdrawCeilings>;
|
|
564
571
|
/**
|
|
565
572
|
* Paying debt down with funds from the wallet: collateral stays where it is,
|
|
566
573
|
* so net value grows by what was repaid, leverage falls and the health factor
|