@gearbox-protocol/sdk 16.3.0-next.1 → 16.3.0-next.3
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/abi/rwa/iMidasAccessControl.js +23 -0
- package/dist/cjs/abi/rwa/iMidasDegenNFT.js +92 -0
- package/dist/cjs/model/errors/index.js +0 -1
- package/dist/cjs/model/errors/prepare-errors.js +0 -8
- package/dist/cjs/model/index.js +6 -2
- package/dist/cjs/model/opportunities.schema.js +3 -1
- package/dist/cjs/model/rwa.js +13 -0
- package/dist/cjs/model/rwa.schema.js +20 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/accounts/intents/guards.js +4 -4
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/cjs/onchain/index.js +8 -2
- package/dist/cjs/onchain/market/MarketSuite.js +3 -3
- package/dist/cjs/onchain/market/credit/CreditSuite.js +37 -3
- package/dist/cjs/onchain/market/index.js +8 -2
- package/dist/cjs/onchain/market/rwa/createDegenNFT.js +53 -0
- package/dist/cjs/onchain/market/rwa/index.js +7 -1
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +56 -0
- package/dist/cjs/onchain/market/rwa/midas/constants.js +2 -0
- package/dist/cjs/onchain/market/rwa/midas/index.js +3 -0
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +22 -3
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
- package/dist/cjs/onchain/market/rwa/securitize/constants.js +2 -0
- package/dist/cjs/onchain/market/rwa/securitize/index.js +3 -0
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +2 -1
- package/dist/cjs/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/cjs/onchain/validation/checkSimulation.js +11 -14
- package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +3 -2
- package/dist/cjs/sdk/index.js +0 -1
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/cjs/sdk/prepare/PrepareApi.js +27 -8
- package/dist/cjs/sdk/prepare/index.js +0 -1
- package/dist/esm/abi/rwa/iMidasAccessControl.js +22 -0
- package/dist/esm/abi/rwa/iMidasDegenNFT.js +91 -0
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/prepare-errors.js +1 -8
- package/dist/esm/model/index.js +4 -3
- package/dist/esm/model/opportunities.schema.js +3 -1
- package/dist/esm/model/rwa.js +12 -1
- package/dist/esm/model/rwa.schema.js +18 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/accounts/intents/guards.js +4 -4
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/esm/onchain/index.js +5 -3
- package/dist/esm/onchain/market/MarketSuite.js +3 -3
- package/dist/esm/onchain/market/credit/CreditSuite.js +37 -3
- package/dist/esm/onchain/market/index.js +5 -3
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +52 -0
- package/dist/esm/onchain/market/rwa/index.js +5 -3
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +55 -0
- package/dist/esm/onchain/market/rwa/midas/constants.js +2 -1
- package/dist/esm/onchain/market/rwa/midas/index.js +3 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +20 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
- package/dist/esm/onchain/market/rwa/securitize/constants.js +2 -1
- package/dist/esm/onchain/market/rwa/securitize/index.js +3 -2
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +2 -1
- package/dist/esm/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/esm/onchain/validation/checkSimulation.js +11 -14
- package/dist/esm/onchain/validation/checks/checkDebtLimits.js +3 -2
- package/dist/esm/sdk/index.js +2 -2
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/esm/sdk/prepare/PrepareApi.js +28 -9
- package/dist/esm/sdk/prepare/index.js +2 -2
- package/dist/types/abi/rwa/iMidasAccessControl.d.ts +22 -0
- package/dist/types/abi/rwa/iMidasDegenNFT.d.ts +82 -0
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +4 -0
- package/dist/types/model/errors/prepare-errors.d.ts +1 -10
- package/dist/types/model/index.d.ts +4 -3
- package/dist/types/model/opportunities.d.ts +9 -0
- package/dist/types/model/opportunities.schema.d.ts +30 -0
- package/dist/types/model/rwa.d.ts +25 -1
- package/dist/types/model/rwa.schema.d.ts +29 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
- package/dist/types/offchain/opportunities/types.d.ts +4 -1
- package/dist/types/onchain/index.d.ts +9 -7
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +12 -2
- package/dist/types/onchain/market/credit/types.d.ts +2 -2
- package/dist/types/onchain/market/index.d.ts +8 -6
- package/dist/types/onchain/market/rwa/RWARegistry.d.ts +1 -1
- package/dist/types/onchain/market/rwa/createDegenNFT.d.ts +12 -0
- package/dist/types/onchain/market/rwa/index.d.ts +9 -7
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +98 -0
- package/dist/types/onchain/market/rwa/midas/constants.d.ts +2 -1
- package/dist/types/onchain/market/rwa/midas/index.d.ts +3 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +8 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -2
- package/dist/types/onchain/market/rwa/securitize/constants.d.ts +2 -1
- package/dist/types/onchain/market/rwa/securitize/index.d.ts +4 -3
- package/dist/types/onchain/market/rwa/types.d.ts +20 -2
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +2 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/types.d.ts +3 -2
- package/dist/types/onchain/validation/checkSimulation.d.ts +9 -20
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +4 -0
- package/dist/types/onchain/validation/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +4 -3
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +2 -1
- package/dist/types/sdk/opportunities/types.d.ts +8 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +6 -5
- package/dist/types/sdk/prepare/index.d.ts +4 -3
- package/dist/types/sdk/prepare/types.d.ts +47 -21
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Token } from "../../../model/primitives.js";
|
|
2
2
|
import { DebtOutOfRangeError } from "../../../model/errors/operation-errors.js";
|
|
3
3
|
import "../../../model/index.js";
|
|
4
|
+
import { MaxBorrowAmount } from "../../market/credit/types.js";
|
|
5
|
+
import "../../market/index.js";
|
|
4
6
|
//#region src/onchain/validation/checks/checkDebtLimits.d.ts
|
|
5
7
|
interface DebtLimitsArgs {
|
|
6
8
|
debt: bigint;
|
|
@@ -14,6 +16,8 @@ interface DebtLimitsArgs {
|
|
|
14
16
|
* rather than assumed.
|
|
15
17
|
*/
|
|
16
18
|
allowZero: boolean;
|
|
19
|
+
/** From the caller's suite; a caller that raises to throw advises nobody. */
|
|
20
|
+
maxBorrowAmount?: MaxBorrowAmount;
|
|
17
21
|
}
|
|
18
22
|
/** A debt the facade would revert on. */
|
|
19
23
|
declare function checkDebtLimits(args: DebtLimitsArgs): DebtOutOfRangeError[];
|
|
@@ -19,7 +19,7 @@ import { CheckWalletBalanceInput, checkWalletBalance } from "./bundles/checkWall
|
|
|
19
19
|
import "./bundles/index.js";
|
|
20
20
|
import { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError, checkLiquidation } from "./checkLiquidation.js";
|
|
21
21
|
import { CheckOperationInput, CheckOperationOptions, OperationValidationError, checkOperation } from "./checkOperation.js";
|
|
22
|
-
import { CheckSimulationInput, CreditSimulationInput,
|
|
22
|
+
import { CheckSimulationInput, CreditSimulationInput, SimulationValidationError, checkSimulation } from "./checkSimulation.js";
|
|
23
23
|
import { BorrowLimitArgs, checkBorrowLimit } from "./checks/checkBorrowLimit.js";
|
|
24
24
|
import { CollateralisedArgs, checkCollateralised } from "./checks/checkCollateralised.js";
|
|
25
25
|
import { CreditAccountFrozenArgs, checkCreditAccountFrozen } from "./checks/checkCreditAccountFrozen.js";
|
|
@@ -40,4 +40,4 @@ import { amountOf } from "./helpers/amount.js";
|
|
|
40
40
|
import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./helpers/health-factor-limits.js";
|
|
41
41
|
import { toToken, toTokenAmount } from "./helpers/token.js";
|
|
42
42
|
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,
|
|
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, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
1
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure } from "../model/errors/prepare-errors.js";
|
|
2
2
|
import { LeverageBand } from "../onchain/accounts/intents/leverage-band.js";
|
|
3
3
|
import { OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../onchain/accounts/intents/types.js";
|
|
4
|
+
import { PoolOperationError } from "../onchain/validation/bundles/checkPoolOperation.js";
|
|
4
5
|
import { IAnalytics, IAnalyticsByMode } from "./analytics/types.js";
|
|
5
6
|
import { ILiquidations, ILiquidationsByMode } from "./liquidations/types.js";
|
|
6
|
-
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
|
|
7
|
+
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenFlowError, OpenStrategyEmptyParams, OpenStrategyFundedParams, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
|
|
7
8
|
import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
|
|
8
9
|
import "./prepare/index.js";
|
|
9
10
|
import { AccountPrepareRequest, IOpportunitiesExecute, OpenPrepareRequest, PoolPrepareRequest, PrepareRequest } from "./execute/types.js";
|
|
@@ -37,4 +38,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
|
37
38
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
38
39
|
import { everyChainFailed } from "./errors/everyChainFailed.js";
|
|
39
40
|
import "./errors/index.js";
|
|
40
|
-
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, ChainOf, ChainRef, CheckOperationProps, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyResult, DepositStrategyParams,
|
|
41
|
+
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, ChainOf, ChainRef, CheckOperationProps, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyResult, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, FinalizeResult, GearboxSDK, GearboxSDKOptions, IAnalytics, IAnalyticsByMode, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, type MergeListResult, MergedQuery, MissingSourceError, Mode, type MultipleDelayedWithdrawalsError, NamespaceOptions, type NoDelayedRouteError, type NoRecordedIntentError, NoSourceServedError, type NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenFlowError, OpenPrepareRequest, OpenStrategyEmptyParams, OpenStrategyFundedParams, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, type PoolOperationError, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewNamespace, RepayStrategyParams, type RouteErrors, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -15,6 +15,7 @@ import "../utils/index.js";
|
|
|
15
15
|
import { IOpportunitiesBase, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunityMergers } from "./types.js";
|
|
16
16
|
import { NamespaceOptions } from "../types.js";
|
|
17
17
|
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
18
|
+
import { Address } from "viem";
|
|
18
19
|
//#region src/sdk/opportunities/OpportunitiesNamespace.d.ts
|
|
19
20
|
/**
|
|
20
21
|
* The `opportunities` namespace of a {@link GearboxSDK}, see
|
|
@@ -46,7 +47,7 @@ declare class OpportunitiesNamespace extends AbstractNamespace<MultichainSDK["op
|
|
|
46
47
|
/**
|
|
47
48
|
* {@inheritDoc IOpportunitiesBase.getStrategy}
|
|
48
49
|
**/
|
|
49
|
-
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
50
|
+
getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
50
51
|
/**
|
|
51
52
|
* {@inheritDoc IOpportunitiesBase.filter}
|
|
52
53
|
**/
|
|
@@ -13,6 +13,7 @@ import "../execute/index.js";
|
|
|
13
13
|
import { EntityMerger, FilterResult, ListMerger } from "../utils/types.js";
|
|
14
14
|
import "../utils/index.js";
|
|
15
15
|
import { Mode } from "../types.js";
|
|
16
|
+
import { Address } from "viem";
|
|
16
17
|
//#region src/sdk/opportunities/types.d.ts
|
|
17
18
|
/**
|
|
18
19
|
* What the `opportunities` namespace offers in every mode.
|
|
@@ -29,9 +30,10 @@ interface IOpportunitiesBase {
|
|
|
29
30
|
**/
|
|
30
31
|
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
31
32
|
/**
|
|
32
|
-
* Detailed view of one strategy opportunity.
|
|
33
|
+
* Detailed view of one strategy opportunity. With `wallet`, `kyc` tells whether
|
|
34
|
+
* that wallet must register with the strategy's KYC provider before opening.
|
|
33
35
|
**/
|
|
34
|
-
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
36
|
+
getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
35
37
|
/**
|
|
36
38
|
* Narrows an already-read list, rows and metadata alike. `undefined` passes
|
|
37
39
|
* through, so a read still in flight stays that way, and a list already read
|
|
@@ -108,6 +110,10 @@ interface IOpportunitiesOffchainBranch {
|
|
|
108
110
|
interface IOpportunityMergers {
|
|
109
111
|
list: ListMerger<Opportunity[]>;
|
|
110
112
|
pool: EntityMerger<PoolOpportunityDetail>;
|
|
113
|
+
/**
|
|
114
|
+
* Same freshness rule as {@link pool}, except `kyc` is taken from the chain
|
|
115
|
+
* whenever that leg succeeded — the backend does not evaluate it.
|
|
116
|
+
**/
|
|
111
117
|
strategy: EntityMerger<StrategyOpportunityDetail>;
|
|
112
118
|
}
|
|
113
119
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bps, ChainId } from "../../model/primitives.js";
|
|
2
2
|
import { DebtOutOfRangeError, InsufficientPoolLiquidityError, LeverageOutOfRangeError } from "../../model/errors/operation-errors.js";
|
|
3
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
3
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
|
|
4
4
|
import { PositionCollateral, StrategyPosition } from "../../model/positions.js";
|
|
5
5
|
import { SDKReturn } from "../../model/result.js";
|
|
6
6
|
import "../../model/index.js";
|
|
@@ -10,6 +10,7 @@ import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
|
10
10
|
import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
|
|
11
11
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
12
12
|
import { WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
13
|
+
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
13
14
|
import "../../onchain/index.js";
|
|
14
15
|
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
15
16
|
import { EnsureFreshChains } from "../types.js";
|
|
@@ -54,19 +55,19 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
|
|
|
54
55
|
/**
|
|
55
56
|
* {@inheritDoc IOpportunitiesPrepare.deposit}
|
|
56
57
|
**/
|
|
57
|
-
deposit(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
58
|
+
deposit(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
58
59
|
/**
|
|
59
60
|
* {@inheritDoc IOpportunitiesPrepare.withdraw}
|
|
60
61
|
**/
|
|
61
|
-
withdraw(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
62
|
+
withdraw(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
62
63
|
/**
|
|
63
64
|
* {@inheritDoc IOpportunitiesPrepare.redeem}
|
|
64
65
|
**/
|
|
65
|
-
redeem(pool: PoolInput, params: LpRedeemParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
66
|
+
redeem(pool: PoolInput, params: LpRedeemParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
66
67
|
/**
|
|
67
68
|
* {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
|
|
68
69
|
**/
|
|
69
|
-
openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError |
|
|
70
|
+
openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError | CreditAccountNotFoundError | CreditAccountNotEmptyError>>;
|
|
70
71
|
/**
|
|
71
72
|
* {@inheritDoc IOpportunitiesPrepare.depositStrategy}
|
|
72
73
|
**/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
1
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure } from "../../model/errors/prepare-errors.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
4
4
|
import { OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
6
|
+
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenFlowError, OpenStrategyEmptyParams, OpenStrategyFundedParams, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
6
7
|
import { ChainOf, PrepareApi } from "./PrepareApi.js";
|
|
7
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams,
|
|
8
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyEmptyParams, OpenStrategyFundedParams, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareApi, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Bps, Timestamp, TokenAmount } from "../../model/primitives.js";
|
|
2
2
|
import { Curator } from "../../model/curators.js";
|
|
3
3
|
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
|
|
4
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
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";
|
|
7
7
|
import { SDKReturn } from "../../model/result.js";
|
|
@@ -14,6 +14,7 @@ import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
|
14
14
|
import { AccountCalculatorOperation } from "../../onchain/accounts/intents/operations.js";
|
|
15
15
|
import { ClaimRemainder, DelayedStart, OperationState, PathLossRate, ResumableIntent, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
16
16
|
import { OpenStrategyState } from "../../onchain/accounts/intents/open-strategy.js";
|
|
17
|
+
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
17
18
|
import "../../onchain/index.js";
|
|
18
19
|
import { Address } from "viem";
|
|
19
20
|
//#region src/sdk/prepare/types.d.ts
|
|
@@ -337,7 +338,15 @@ interface WithdrawCollateralParams extends PrepareOptions {
|
|
|
337
338
|
/** Wallet receiving the tokens. */
|
|
338
339
|
to: Address;
|
|
339
340
|
}
|
|
340
|
-
|
|
341
|
+
/**
|
|
342
|
+
* Opening a position, in one of the two shapes an opening comes in.
|
|
343
|
+
*
|
|
344
|
+
* The union is the check: an empty opening names nothing to open with, so
|
|
345
|
+
* collateral it meant to spend or an account it meant to reuse cannot be
|
|
346
|
+
* silently dropped — those arguments do not typecheck against `empty: true`.
|
|
347
|
+
**/
|
|
348
|
+
type OpenStrategyParams = OpenStrategyFundedParams | OpenStrategyEmptyParams;
|
|
349
|
+
interface OpenStrategyFundedParams extends PrepareOptions {
|
|
341
350
|
/** Collateral coming from the wallet, in their own tokens. */
|
|
342
351
|
collateral: Asset[];
|
|
343
352
|
/**
|
|
@@ -355,25 +364,42 @@ interface OpenStrategyParams extends PrepareOptions {
|
|
|
355
364
|
* Existing credit account to open the position on, instead of creating one.
|
|
356
365
|
*
|
|
357
366
|
* Must belong to `strategy.creditManager` and carry no debt and no quotas —
|
|
358
|
-
* an account pre-opened by an {@link
|
|
367
|
+
* an account pre-opened by an {@link OpenStrategyEmptyParams} opening.
|
|
359
368
|
* The projection is identical either way; only the transaction differs, and
|
|
360
369
|
* `execute.buildTx` reads which one to build off the result's own
|
|
361
370
|
* `state.creditAccount`.
|
|
362
371
|
**/
|
|
363
372
|
creditAccount?: Address;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
empty?: false;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Opening an account that holds nothing: no collateral, no debt, no quotas, and
|
|
377
|
+
* no route quoted. A wallet holds one so a position can be put on it later, by
|
|
378
|
+
* an opening that names it as
|
|
379
|
+
* {@link OpenStrategyFundedParams.creditAccount}.
|
|
380
|
+
*
|
|
381
|
+
* The market is the whole request. There is nothing else to say: with no
|
|
382
|
+
* collateral the debt is zero at any leverage, and there is nothing to route
|
|
383
|
+
* anywhere — so leverage and a target token are not merely ignored here, they
|
|
384
|
+
* cannot be named.
|
|
385
|
+
**/
|
|
386
|
+
interface OpenStrategyEmptyParams {
|
|
387
|
+
empty: true;
|
|
388
|
+
/**
|
|
389
|
+
* The three an empty opening would otherwise have to drop, spelled out as
|
|
390
|
+
* `never` rather than merely left out.
|
|
391
|
+
*
|
|
392
|
+
* A bare `{ empty: true }` is a structural type, and excess-property checking
|
|
393
|
+
* only fires on a fresh object literal — so params built up in a variable, as
|
|
394
|
+
* a form builds them, would pass on the extra members and have them silently
|
|
395
|
+
* dropped. Naming them closes that: the shape is refused wherever it is
|
|
396
|
+
* written, and `empty` typed as a plain `boolean` is refused by both branches.
|
|
397
|
+
**/
|
|
398
|
+
collateral?: never;
|
|
399
|
+
leverage?: never;
|
|
400
|
+
creditAccount?: never;
|
|
401
|
+
targetToken?: never;
|
|
402
|
+
leftoverBalances?: never;
|
|
377
403
|
}
|
|
378
404
|
interface LpParams {
|
|
379
405
|
/**
|
|
@@ -460,7 +486,7 @@ interface IOpportunitiesPrepare {
|
|
|
460
486
|
* loaded already; the wait is for the one thing that is not, the shares the
|
|
461
487
|
* wallet holds, without which {@link LpState.netValue} cannot be said.
|
|
462
488
|
**/
|
|
463
|
-
deposit(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
489
|
+
deposit(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
464
490
|
/**
|
|
465
491
|
* Taking underlying out of a pool: `amount` is the `tokenOut` the wallet
|
|
466
492
|
* wants back, and the pool burns whatever shares that costs.
|
|
@@ -468,19 +494,19 @@ interface IOpportunitiesPrepare {
|
|
|
468
494
|
* The LP counterpart of {@link withdrawStrategy} / {@link withdrawCollateral},
|
|
469
495
|
* which act on credit accounts.
|
|
470
496
|
**/
|
|
471
|
-
withdraw(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
497
|
+
withdraw(pool: PoolInput, params: LpParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
472
498
|
/**
|
|
473
499
|
* Redeeming pool shares: `amount` is the `tokenIn` the wallet parts with,
|
|
474
500
|
* and the reported state is the underlying it converts to.
|
|
475
501
|
**/
|
|
476
|
-
redeem(pool: PoolInput, params: LpRedeemParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError>>;
|
|
502
|
+
redeem(pool: PoolInput, params: LpRedeemParams): Promise<SDKReturn<LpResult, UnsupportedTokenPairError | UnexpectedFailureError | PoolOperationError>>;
|
|
477
503
|
/**
|
|
478
504
|
* Opening a leveraged position from wallet collateral.
|
|
479
505
|
*
|
|
480
506
|
* The one flow with no account yet, so the result carries no operation list —
|
|
481
507
|
* it feeds `sdk.accounts.openCA` instead.
|
|
482
508
|
**/
|
|
483
|
-
openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError |
|
|
509
|
+
openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError | CreditAccountNotFoundError | CreditAccountNotEmptyError>>;
|
|
484
510
|
/**
|
|
485
511
|
* Growing a position: collateral in, debt drawn on top, both converted into
|
|
486
512
|
* the position token.
|
|
@@ -662,4 +688,4 @@ interface IOpportunitiesPrepare {
|
|
|
662
688
|
finalize(position: PositionInput, params: FinalizeParams): Promise<SDKReturn<FinalizeResult, AccountFlowError | NoRecordedIntentError | NoDelayedRouteError | WithdrawalInProgressError | UnsupportedTokenPairError>>;
|
|
663
689
|
}
|
|
664
690
|
//#endregion
|
|
665
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams,
|
|
691
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyEmptyParams, OpenStrategyFundedParams, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError };
|