@gearbox-protocol/sdk 16.3.0-next.2 → 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/model/errors/index.js +0 -1
- package/dist/cjs/model/errors/prepare-errors.js +0 -8
- package/dist/cjs/model/index.js +0 -1
- package/dist/cjs/onchain/accounts/intents/guards.js +4 -4
- package/dist/cjs/onchain/market/credit/CreditSuite.js +7 -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/prepare/PrepareApi.js +27 -8
- package/dist/cjs/sdk/prepare/index.js +0 -1
- 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 +2 -2
- package/dist/esm/onchain/accounts/intents/guards.js +4 -4
- package/dist/esm/onchain/market/credit/CreditSuite.js +7 -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/prepare/PrepareApi.js +28 -9
- package/dist/esm/sdk/prepare/index.js +2 -2
- 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 +2 -2
- package/dist/types/onchain/index.d.ts +2 -2
- package/dist/types/onchain/market/credit/types.d.ts +2 -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/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
|
@@ -10,7 +10,6 @@ exports.creditAccountNotEmpty = require_model_errors_prepare_errors.creditAccoun
|
|
|
10
10
|
exports.creditAccountNotFound = require_model_errors_prepare_errors.creditAccountNotFound;
|
|
11
11
|
exports.creditManagerPaused = require_model_errors_operation_errors.creditManagerPaused;
|
|
12
12
|
exports.debtOutOfRange = require_model_errors_operation_errors.debtOutOfRange;
|
|
13
|
-
exports.emptyOpenTakesNothing = require_model_errors_prepare_errors.emptyOpenTakesNothing;
|
|
14
13
|
exports.forbiddenToken = require_model_errors_operation_errors.forbiddenToken;
|
|
15
14
|
exports.insufficientAllowance = require_model_errors_operation_errors.insufficientAllowance;
|
|
16
15
|
exports.insufficientBalance = require_model_errors_operation_errors.insufficientBalance;
|
|
@@ -73,13 +73,6 @@ function creditAccountNotEmpty(creditAccount) {
|
|
|
73
73
|
creditAccount
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
/** {@inheritDoc EmptyOpenTakesNothingError} */
|
|
77
|
-
function emptyOpenTakesNothing() {
|
|
78
|
-
return {
|
|
79
|
-
code: "emptyOpenTakesNothing",
|
|
80
|
-
message: "An empty opening takes no collateral, no account to reuse and no leverage."
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
76
|
/**
|
|
84
77
|
* {@inheritDoc UnexpectedFailureError}
|
|
85
78
|
*
|
|
@@ -97,7 +90,6 @@ function unexpectedFailure(thrown, action = "prepare this operation") {
|
|
|
97
90
|
//#endregion
|
|
98
91
|
exports.creditAccountNotEmpty = creditAccountNotEmpty;
|
|
99
92
|
exports.creditAccountNotFound = creditAccountNotFound;
|
|
100
|
-
exports.emptyOpenTakesNothing = emptyOpenTakesNothing;
|
|
101
93
|
exports.multipleDelayedWithdrawals = multipleDelayedWithdrawals;
|
|
102
94
|
exports.noDelayedRoute = noDelayedRoute;
|
|
103
95
|
exports.noRecordedIntent = noRecordedIntent;
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -92,7 +92,6 @@ exports.curatorSchema = require_model_curators_schema.curatorSchema;
|
|
|
92
92
|
exports.dataSourceSchema = require_model_response_schema.dataSourceSchema;
|
|
93
93
|
exports.debtOutOfRange = require_model_errors_operation_errors.debtOutOfRange;
|
|
94
94
|
exports.delayedReceivedAssetSchema = require_model_liquidations_schema.delayedReceivedAssetSchema;
|
|
95
|
-
exports.emptyOpenTakesNothing = require_model_errors_prepare_errors.emptyOpenTakesNothing;
|
|
96
95
|
exports.encodeFlag = require_model_filters_schema.encodeFlag;
|
|
97
96
|
exports.filterAllSchema = require_model_filters_schema.filterAllSchema;
|
|
98
97
|
exports.filterable = require_model_filters_schema.filterable;
|
|
@@ -44,13 +44,13 @@ function assertMarketOperable(suite) {
|
|
|
44
44
|
}
|
|
45
45
|
/** The pool has to be able to lend what the plan means to draw. */
|
|
46
46
|
function assertCanBorrow(sdk, suite, amount) {
|
|
47
|
-
const
|
|
47
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
48
48
|
require_onchain_validation_raise.raise(require_onchain_validation_checks_checkBorrowLimit.checkBorrowLimit({
|
|
49
49
|
requested: amount,
|
|
50
|
-
available: value,
|
|
51
|
-
limit,
|
|
50
|
+
available: maxBorrowAmount.amount.value,
|
|
51
|
+
limit: maxBorrowAmount.limit,
|
|
52
52
|
underlying: require_onchain_validation_helpers_token.toToken(sdk, suite.market.pool.underlying)
|
|
53
|
-
}), `borrow: ${amount} exceeds what the pool can lend now (${value})`);
|
|
53
|
+
}), `borrow: ${amount} exceeds what the pool can lend now (${maxBorrowAmount.amount.value})`);
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* What the account is allowed to end up holding more of than it started with.
|
|
@@ -279,11 +279,11 @@ var CreditSuite = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
279
279
|
const { pool } = this.market.pool;
|
|
280
280
|
const { maxDebtPerBlockMultiplier, maxDebt } = this.creditFacade;
|
|
281
281
|
if (maxDebtPerBlockMultiplier === 0) return {
|
|
282
|
-
|
|
282
|
+
amount: this.market.toUnderlyingAmount(0n),
|
|
283
283
|
limit: "debtPerBlockLimit"
|
|
284
284
|
};
|
|
285
285
|
const available = pool.creditManagerDebtParams.get(this.creditManager.address)?.available;
|
|
286
|
-
|
|
286
|
+
const { value, limit } = [
|
|
287
287
|
{
|
|
288
288
|
value: pool.availableLiquidity,
|
|
289
289
|
limit: "poolAvailableLiquidity"
|
|
@@ -297,6 +297,10 @@ var CreditSuite = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
297
297
|
limit: "maxDebt"
|
|
298
298
|
}
|
|
299
299
|
].reduce((a, b) => b.value < a.value ? b : a);
|
|
300
|
+
return {
|
|
301
|
+
amount: this.market.toUnderlyingAmount(value),
|
|
302
|
+
limit
|
|
303
|
+
};
|
|
300
304
|
}
|
|
301
305
|
/**
|
|
302
306
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -355,7 +359,7 @@ var CreditSuite = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
355
359
|
* or `undefined` when credit suite does not offer a strategy opportunity.
|
|
356
360
|
*/
|
|
357
361
|
strategyOpportunity() {
|
|
358
|
-
const maxBorrowAmount = this.maxBorrowAmount().value;
|
|
362
|
+
const maxBorrowAmount = this.maxBorrowAmount().amount.value;
|
|
359
363
|
if (maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
360
364
|
const collateral = this.strategyTargetCollateral;
|
|
361
365
|
if (!collateral) return;
|
|
@@ -33,7 +33,8 @@ async function checkCreditOperation(args) {
|
|
|
33
33
|
minDebt: suite.creditFacade.minDebt,
|
|
34
34
|
maxDebt: suite.creditFacade.maxDebt,
|
|
35
35
|
underlying,
|
|
36
|
-
allowZero: !isOpening
|
|
36
|
+
allowZero: !isOpening,
|
|
37
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
37
38
|
}),
|
|
38
39
|
...require_onchain_validation_bundles_checkDraw.checkDraw(suite, preview, underlying),
|
|
39
40
|
...require_onchain_validation_bundles_checkObtained.checkObtained(suite, preview),
|
|
@@ -16,11 +16,11 @@ require("../checks/index.js");
|
|
|
16
16
|
function checkDraw(suite, preview, underlying) {
|
|
17
17
|
const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
18
18
|
if (drawn <= 0n) return [];
|
|
19
|
-
const
|
|
19
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
20
20
|
return require_onchain_validation_checks_checkBorrowLimit.checkBorrowLimit({
|
|
21
21
|
requested: drawn,
|
|
22
|
-
available: value,
|
|
23
|
-
limit,
|
|
22
|
+
available: maxBorrowAmount.amount.value,
|
|
23
|
+
limit: maxBorrowAmount.limit,
|
|
24
24
|
underlying
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -2,11 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_onchain_validation_helpers_token = require("./helpers/token.js");
|
|
3
3
|
require("./helpers/index.js");
|
|
4
4
|
const require_onchain_validation_checks_checkDebtLimits = require("./checks/checkDebtLimits.js");
|
|
5
|
+
const require_onchain_validation_checks_checkQuotaCount = require("./checks/checkQuotaCount.js");
|
|
5
6
|
require("./checks/index.js");
|
|
6
7
|
const require_onchain_validation_bundles_checkAccountQuotas = require("./bundles/checkAccountQuotas.js");
|
|
7
8
|
const require_onchain_validation_bundles_checkHealthFactors = require("./bundles/checkHealthFactors.js");
|
|
8
9
|
const require_onchain_validation_bundles_checkMarket = require("./bundles/checkMarket.js");
|
|
9
|
-
const require_onchain_validation_bundles_checkPoolOperation = require("./bundles/checkPoolOperation.js");
|
|
10
10
|
//#region src/onchain/validation/checkSimulation.ts
|
|
11
11
|
/**
|
|
12
12
|
* Whether a simulated operation clears the caller's own thresholds.
|
|
@@ -28,19 +28,12 @@ const require_onchain_validation_bundles_checkPoolOperation = require("./bundles
|
|
|
28
28
|
* touched. The engine performed all three during the walk, so a simulation that
|
|
29
29
|
* came back `ok` has already passed them.
|
|
30
30
|
*
|
|
31
|
-
* A
|
|
32
|
-
*
|
|
31
|
+
* A credit account only, opened or adjusted: a pool operation has no account
|
|
32
|
+
* to weigh, and the three things its own state decides are read by `prepare`
|
|
33
|
+
* before it answers. An opening names its quotas `averageQuota` — the branch
|
|
34
|
+
* the planner already weighed it as.
|
|
33
35
|
*/
|
|
34
36
|
function checkSimulation(sdk, input, options = {}) {
|
|
35
|
-
if ("pool" in input) {
|
|
36
|
-
const { pool, state, isDeposit } = input;
|
|
37
|
-
return require_onchain_validation_bundles_checkPoolOperation.checkPoolOperation({
|
|
38
|
-
sdk,
|
|
39
|
-
pool,
|
|
40
|
-
isDeposit,
|
|
41
|
-
tokenOut: state.tokenOut
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
37
|
const { state } = input;
|
|
45
38
|
const suite = sdk.marketRegister.findCreditManager(state.creditManager);
|
|
46
39
|
return [
|
|
@@ -50,9 +43,13 @@ function checkSimulation(sdk, input, options = {}) {
|
|
|
50
43
|
minDebt: suite.creditFacade.minDebt,
|
|
51
44
|
maxDebt: suite.creditFacade.maxDebt,
|
|
52
45
|
underlying: require_onchain_validation_helpers_token.toToken(sdk, suite.market.pool.underlying),
|
|
53
|
-
allowZero: true
|
|
46
|
+
allowZero: true,
|
|
47
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
54
48
|
}),
|
|
55
|
-
...
|
|
49
|
+
..."averageQuota" in state ? require_onchain_validation_checks_checkQuotaCount.checkQuotaCount({
|
|
50
|
+
count: state.averageQuota.filter((q) => q.balance > 0n).length,
|
|
51
|
+
max: suite.creditManager.maxEnabledTokens
|
|
52
|
+
}) : require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas(suite, state),
|
|
56
53
|
...require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors(state, options)
|
|
57
54
|
];
|
|
58
55
|
}
|
|
@@ -6,12 +6,13 @@ require("../helpers/index.js");
|
|
|
6
6
|
//#region src/onchain/validation/checks/checkDebtLimits.ts
|
|
7
7
|
/** A debt the facade would revert on. */
|
|
8
8
|
function checkDebtLimits(args) {
|
|
9
|
-
const { debt, minDebt, maxDebt, underlying, allowZero } = args;
|
|
9
|
+
const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
|
|
10
10
|
if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
|
|
11
11
|
return [require_model_errors_operation_errors.debtOutOfRange({
|
|
12
12
|
requested: require_onchain_validation_helpers_amount.amountOf(underlying, debt),
|
|
13
13
|
minDebt: require_onchain_validation_helpers_amount.amountOf(underlying, minDebt),
|
|
14
|
-
maxDebt: require_onchain_validation_helpers_amount.amountOf(underlying, maxDebt)
|
|
14
|
+
maxDebt: require_onchain_validation_helpers_amount.amountOf(underlying, maxDebt),
|
|
15
|
+
maxBorrowAmount
|
|
15
16
|
})];
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -47,7 +47,6 @@ exports.SourceUnavailableError = require_sdk_errors_SourceUnavailableError.Sourc
|
|
|
47
47
|
exports.assertSameChains = require_sdk_errors_assertSameChains.assertSameChains;
|
|
48
48
|
exports.creditAccountNotEmpty = require_model_errors_prepare_errors.creditAccountNotEmpty;
|
|
49
49
|
exports.creditAccountNotFound = require_model_errors_prepare_errors.creditAccountNotFound;
|
|
50
|
-
exports.emptyOpenTakesNothing = require_model_errors_prepare_errors.emptyOpenTakesNothing;
|
|
51
50
|
exports.everyChainFailed = require_sdk_errors_everyChainFailed.everyChainFailed;
|
|
52
51
|
exports.filterResponse = require_sdk_utils_filterResponse.filterResponse;
|
|
53
52
|
exports.mergeChainList = require_sdk_utils_mergeChains.mergeChainList;
|
|
@@ -5,6 +5,7 @@ const require_model_errors_prepare_errors = require("../../model/errors/prepare-
|
|
|
5
5
|
const require_model_result = require("../../model/result.js");
|
|
6
6
|
require("../../model/index.js");
|
|
7
7
|
const require_onchain_validation_helpers_token = require("../../onchain/validation/helpers/token.js");
|
|
8
|
+
const require_onchain_validation_bundles_checkPoolOperation = require("../../onchain/validation/bundles/checkPoolOperation.js");
|
|
8
9
|
const require_onchain_accounts_intents_utils_credit_account_slice = require("../../onchain/accounts/intents/utils/credit-account-slice.js");
|
|
9
10
|
const require_onchain_accounts_intents_index = require("../../onchain/accounts/intents/index.js");
|
|
10
11
|
require("../../onchain/index.js");
|
|
@@ -85,6 +86,13 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
|
|
|
85
86
|
tokenIn,
|
|
86
87
|
tokenOut
|
|
87
88
|
});
|
|
89
|
+
const [refusal] = require_onchain_validation_bundles_checkPoolOperation.checkPoolOperation({
|
|
90
|
+
sdk: chain,
|
|
91
|
+
pool: pool.pool,
|
|
92
|
+
isDeposit: true,
|
|
93
|
+
tokenOut: state.tokenOut
|
|
94
|
+
});
|
|
95
|
+
if (refusal) return require_model_result.sdkErr(refusal);
|
|
88
96
|
const call = pools.addLiquidity({
|
|
89
97
|
collateral: {
|
|
90
98
|
token: state.tokenIn.token.address,
|
|
@@ -121,6 +129,13 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
|
|
|
121
129
|
tokenIn,
|
|
122
130
|
tokenOut
|
|
123
131
|
});
|
|
132
|
+
const [refusal] = require_onchain_validation_bundles_checkPoolOperation.checkPoolOperation({
|
|
133
|
+
sdk: chain,
|
|
134
|
+
pool: pool.pool,
|
|
135
|
+
isDeposit: false,
|
|
136
|
+
tokenOut: state.tokenOut
|
|
137
|
+
});
|
|
138
|
+
if (refusal) return require_model_result.sdkErr(refusal);
|
|
124
139
|
const { calls } = pools.removeLiquidity({
|
|
125
140
|
pool: pool.pool,
|
|
126
141
|
amount: params.amount,
|
|
@@ -155,6 +170,13 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
|
|
|
155
170
|
tokenIn,
|
|
156
171
|
tokenOut
|
|
157
172
|
});
|
|
173
|
+
const [refusal] = require_onchain_validation_bundles_checkPoolOperation.checkPoolOperation({
|
|
174
|
+
sdk: chain,
|
|
175
|
+
pool: pool.pool,
|
|
176
|
+
isDeposit: false,
|
|
177
|
+
tokenOut: state.tokenOut
|
|
178
|
+
});
|
|
179
|
+
if (refusal) return require_model_result.sdkErr(refusal);
|
|
158
180
|
const { calls } = pools.removeLiquidity({
|
|
159
181
|
pool: pool.pool,
|
|
160
182
|
amount: params.amount,
|
|
@@ -180,14 +202,11 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
|
|
|
180
202
|
try {
|
|
181
203
|
const sdk = await this.#chain(strategy.chainId);
|
|
182
204
|
const at = stateBlock(sdk);
|
|
183
|
-
if (params.empty) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
empty: true
|
|
189
|
-
}), at);
|
|
190
|
-
}
|
|
205
|
+
if (params.empty) return opened(await service(sdk).openStrategyIntent({
|
|
206
|
+
sdk,
|
|
207
|
+
creditManager: strategy.creditManager,
|
|
208
|
+
empty: true
|
|
209
|
+
}), at);
|
|
191
210
|
const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
|
|
192
211
|
if (!targetToken) return require_model_result.sdkErr(require_model_errors_prepare_errors.noStrategyTargetCollateral(strategy.creditManager));
|
|
193
212
|
let creditAccount;
|
|
@@ -6,6 +6,5 @@ require("./types.js");
|
|
|
6
6
|
exports.PrepareApi = require_sdk_prepare_PrepareApi.PrepareApi;
|
|
7
7
|
exports.creditAccountNotEmpty = require_model_errors_prepare_errors.creditAccountNotEmpty;
|
|
8
8
|
exports.creditAccountNotFound = require_model_errors_prepare_errors.creditAccountNotFound;
|
|
9
|
-
exports.emptyOpenTakesNothing = require_model_errors_prepare_errors.emptyOpenTakesNothing;
|
|
10
9
|
exports.noStrategyTargetCollateral = require_model_errors_prepare_errors.noStrategyTargetCollateral;
|
|
11
10
|
exports.unexpectedFailure = require_model_errors_prepare_errors.unexpectedFailure;
|
|
@@ -2,6 +2,6 @@ import "./base.js";
|
|
|
2
2
|
import { creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./liquidation-errors.js";
|
|
3
3
|
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
4
4
|
import { unpriceableTokenError } from "./oracle-errors.js";
|
|
5
|
-
import { creditAccountNotEmpty, creditAccountNotFound,
|
|
5
|
+
import { creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./prepare-errors.js";
|
|
6
6
|
import { malformedTransaction } from "./preview-errors.js";
|
|
7
|
-
export { creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange,
|
|
7
|
+
export { creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
@@ -72,13 +72,6 @@ function creditAccountNotEmpty(creditAccount) {
|
|
|
72
72
|
creditAccount
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
/** {@inheritDoc EmptyOpenTakesNothingError} */
|
|
76
|
-
function emptyOpenTakesNothing() {
|
|
77
|
-
return {
|
|
78
|
-
code: "emptyOpenTakesNothing",
|
|
79
|
-
message: "An empty opening takes no collateral, no account to reuse and no leverage."
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
75
|
/**
|
|
83
76
|
* {@inheritDoc UnexpectedFailureError}
|
|
84
77
|
*
|
|
@@ -94,4 +87,4 @@ function unexpectedFailure(thrown, action = "prepare this operation") {
|
|
|
94
87
|
};
|
|
95
88
|
}
|
|
96
89
|
//#endregion
|
|
97
|
-
export { creditAccountNotEmpty, creditAccountNotFound,
|
|
90
|
+
export { creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import "./delayed-intents.js";
|
|
|
17
17
|
import { creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./errors/liquidation-errors.js";
|
|
18
18
|
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
|
|
19
19
|
import { unpriceableTokenError } from "./errors/oracle-errors.js";
|
|
20
|
-
import { creditAccountNotEmpty, creditAccountNotFound,
|
|
20
|
+
import { creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
|
|
21
21
|
import { malformedTransaction } from "./errors/preview-errors.js";
|
|
22
22
|
import "./errors/index.js";
|
|
23
23
|
import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
@@ -32,4 +32,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
|
|
|
32
32
|
import { safeValue, sdkErr, sdkOk } from "./result.js";
|
|
33
33
|
import "./withdrawals.js";
|
|
34
34
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
35
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, 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,
|
|
35
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, 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, kycProtocolSchema, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, 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 };
|
|
@@ -43,13 +43,13 @@ function assertMarketOperable(suite) {
|
|
|
43
43
|
}
|
|
44
44
|
/** The pool has to be able to lend what the plan means to draw. */
|
|
45
45
|
function assertCanBorrow(sdk, suite, amount) {
|
|
46
|
-
const
|
|
46
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
47
47
|
raise(checkBorrowLimit({
|
|
48
48
|
requested: amount,
|
|
49
|
-
available: value,
|
|
50
|
-
limit,
|
|
49
|
+
available: maxBorrowAmount.amount.value,
|
|
50
|
+
limit: maxBorrowAmount.limit,
|
|
51
51
|
underlying: toToken(sdk, suite.market.pool.underlying)
|
|
52
|
-
}), `borrow: ${amount} exceeds what the pool can lend now (${value})`);
|
|
52
|
+
}), `borrow: ${amount} exceeds what the pool can lend now (${maxBorrowAmount.amount.value})`);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* What the account is allowed to end up holding more of than it started with.
|
|
@@ -278,11 +278,11 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
278
278
|
const { pool } = this.market.pool;
|
|
279
279
|
const { maxDebtPerBlockMultiplier, maxDebt } = this.creditFacade;
|
|
280
280
|
if (maxDebtPerBlockMultiplier === 0) return {
|
|
281
|
-
|
|
281
|
+
amount: this.market.toUnderlyingAmount(0n),
|
|
282
282
|
limit: "debtPerBlockLimit"
|
|
283
283
|
};
|
|
284
284
|
const available = pool.creditManagerDebtParams.get(this.creditManager.address)?.available;
|
|
285
|
-
|
|
285
|
+
const { value, limit } = [
|
|
286
286
|
{
|
|
287
287
|
value: pool.availableLiquidity,
|
|
288
288
|
limit: "poolAvailableLiquidity"
|
|
@@ -296,6 +296,10 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
296
296
|
limit: "maxDebt"
|
|
297
297
|
}
|
|
298
298
|
].reduce((a, b) => b.value < a.value ? b : a);
|
|
299
|
+
return {
|
|
300
|
+
amount: this.market.toUnderlyingAmount(value),
|
|
301
|
+
limit
|
|
302
|
+
};
|
|
299
303
|
}
|
|
300
304
|
/**
|
|
301
305
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -354,7 +358,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
354
358
|
* or `undefined` when credit suite does not offer a strategy opportunity.
|
|
355
359
|
*/
|
|
356
360
|
strategyOpportunity() {
|
|
357
|
-
const maxBorrowAmount = this.maxBorrowAmount().value;
|
|
361
|
+
const maxBorrowAmount = this.maxBorrowAmount().amount.value;
|
|
358
362
|
if (maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
359
363
|
const collateral = this.strategyTargetCollateral;
|
|
360
364
|
if (!collateral) return;
|
|
@@ -32,7 +32,8 @@ async function checkCreditOperation(args) {
|
|
|
32
32
|
minDebt: suite.creditFacade.minDebt,
|
|
33
33
|
maxDebt: suite.creditFacade.maxDebt,
|
|
34
34
|
underlying,
|
|
35
|
-
allowZero: !isOpening
|
|
35
|
+
allowZero: !isOpening,
|
|
36
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
36
37
|
}),
|
|
37
38
|
...checkDraw(suite, preview, underlying),
|
|
38
39
|
...checkObtained(suite, preview),
|
|
@@ -15,11 +15,11 @@ import "../checks/index.js";
|
|
|
15
15
|
function checkDraw(suite, preview, underlying) {
|
|
16
16
|
const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
17
17
|
if (drawn <= 0n) return [];
|
|
18
|
-
const
|
|
18
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
19
19
|
return checkBorrowLimit({
|
|
20
20
|
requested: drawn,
|
|
21
|
-
available: value,
|
|
22
|
-
limit,
|
|
21
|
+
available: maxBorrowAmount.amount.value,
|
|
22
|
+
limit: maxBorrowAmount.limit,
|
|
23
23
|
underlying
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toToken } from "./helpers/token.js";
|
|
2
2
|
import "./helpers/index.js";
|
|
3
3
|
import { checkDebtLimits } from "./checks/checkDebtLimits.js";
|
|
4
|
+
import { checkQuotaCount } from "./checks/checkQuotaCount.js";
|
|
4
5
|
import "./checks/index.js";
|
|
5
6
|
import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
|
|
6
7
|
import { checkHealthFactors } from "./bundles/checkHealthFactors.js";
|
|
7
8
|
import { checkMarket } from "./bundles/checkMarket.js";
|
|
8
|
-
import { checkPoolOperation } from "./bundles/checkPoolOperation.js";
|
|
9
9
|
//#region src/onchain/validation/checkSimulation.ts
|
|
10
10
|
/**
|
|
11
11
|
* Whether a simulated operation clears the caller's own thresholds.
|
|
@@ -27,19 +27,12 @@ import { checkPoolOperation } from "./bundles/checkPoolOperation.js";
|
|
|
27
27
|
* touched. The engine performed all three during the walk, so a simulation that
|
|
28
28
|
* came back `ok` has already passed them.
|
|
29
29
|
*
|
|
30
|
-
* A
|
|
31
|
-
*
|
|
30
|
+
* A credit account only, opened or adjusted: a pool operation has no account
|
|
31
|
+
* to weigh, and the three things its own state decides are read by `prepare`
|
|
32
|
+
* before it answers. An opening names its quotas `averageQuota` — the branch
|
|
33
|
+
* the planner already weighed it as.
|
|
32
34
|
*/
|
|
33
35
|
function checkSimulation(sdk, input, options = {}) {
|
|
34
|
-
if ("pool" in input) {
|
|
35
|
-
const { pool, state, isDeposit } = input;
|
|
36
|
-
return checkPoolOperation({
|
|
37
|
-
sdk,
|
|
38
|
-
pool,
|
|
39
|
-
isDeposit,
|
|
40
|
-
tokenOut: state.tokenOut
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
36
|
const { state } = input;
|
|
44
37
|
const suite = sdk.marketRegister.findCreditManager(state.creditManager);
|
|
45
38
|
return [
|
|
@@ -49,9 +42,13 @@ function checkSimulation(sdk, input, options = {}) {
|
|
|
49
42
|
minDebt: suite.creditFacade.minDebt,
|
|
50
43
|
maxDebt: suite.creditFacade.maxDebt,
|
|
51
44
|
underlying: toToken(sdk, suite.market.pool.underlying),
|
|
52
|
-
allowZero: true
|
|
45
|
+
allowZero: true,
|
|
46
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
53
47
|
}),
|
|
54
|
-
...
|
|
48
|
+
..."averageQuota" in state ? checkQuotaCount({
|
|
49
|
+
count: state.averageQuota.filter((q) => q.balance > 0n).length,
|
|
50
|
+
max: suite.creditManager.maxEnabledTokens
|
|
51
|
+
}) : checkAccountQuotas(suite, state),
|
|
55
52
|
...checkHealthFactors(state, options)
|
|
56
53
|
];
|
|
57
54
|
}
|
|
@@ -5,12 +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 } = args;
|
|
8
|
+
const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
|
|
9
9
|
if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
|
|
10
10
|
return [debtOutOfRange({
|
|
11
11
|
requested: amountOf(underlying, debt),
|
|
12
12
|
minDebt: amountOf(underlying, minDebt),
|
|
13
|
-
maxDebt: amountOf(underlying, maxDebt)
|
|
13
|
+
maxDebt: amountOf(underlying, maxDebt),
|
|
14
|
+
maxBorrowAmount
|
|
14
15
|
})];
|
|
15
16
|
}
|
|
16
17
|
//#endregion
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { creditAccountNotEmpty, creditAccountNotFound,
|
|
1
|
+
import { creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure } from "../model/errors/prepare-errors.js";
|
|
2
2
|
import { AllSourcesFailedError } from "./errors/AllSourcesFailedError.js";
|
|
3
3
|
import { SourceChainMismatchError } from "./errors/SourceChainMismatchError.js";
|
|
4
4
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
@@ -27,4 +27,4 @@ import { PreviewNamespace } from "./preview/PreviewNamespace.js";
|
|
|
27
27
|
import "./preview/index.js";
|
|
28
28
|
import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
|
|
29
29
|
import "./types.js";
|
|
30
|
-
export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound,
|
|
30
|
+
export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { hexEq } from "../../onchain/utils/hex.js";
|
|
2
2
|
import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
|
|
3
|
-
import { creditAccountNotEmpty, creditAccountNotFound,
|
|
3
|
+
import { creditAccountNotEmpty, creditAccountNotFound, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedTokenPair } from "../../model/errors/prepare-errors.js";
|
|
4
4
|
import { sdkErr, sdkOk } from "../../model/result.js";
|
|
5
5
|
import "../../model/index.js";
|
|
6
6
|
import { toToken } from "../../onchain/validation/helpers/token.js";
|
|
7
|
+
import { checkPoolOperation } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
7
8
|
import { toCreditAccountSlice } from "../../onchain/accounts/intents/utils/credit-account-slice.js";
|
|
8
9
|
import { CreditAccountOperationsService } from "../../onchain/accounts/intents/index.js";
|
|
9
10
|
import "../../onchain/index.js";
|
|
@@ -84,6 +85,13 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
84
85
|
tokenIn,
|
|
85
86
|
tokenOut
|
|
86
87
|
});
|
|
88
|
+
const [refusal] = checkPoolOperation({
|
|
89
|
+
sdk: chain,
|
|
90
|
+
pool: pool.pool,
|
|
91
|
+
isDeposit: true,
|
|
92
|
+
tokenOut: state.tokenOut
|
|
93
|
+
});
|
|
94
|
+
if (refusal) return sdkErr(refusal);
|
|
87
95
|
const call = pools.addLiquidity({
|
|
88
96
|
collateral: {
|
|
89
97
|
token: state.tokenIn.token.address,
|
|
@@ -120,6 +128,13 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
120
128
|
tokenIn,
|
|
121
129
|
tokenOut
|
|
122
130
|
});
|
|
131
|
+
const [refusal] = checkPoolOperation({
|
|
132
|
+
sdk: chain,
|
|
133
|
+
pool: pool.pool,
|
|
134
|
+
isDeposit: false,
|
|
135
|
+
tokenOut: state.tokenOut
|
|
136
|
+
});
|
|
137
|
+
if (refusal) return sdkErr(refusal);
|
|
123
138
|
const { calls } = pools.removeLiquidity({
|
|
124
139
|
pool: pool.pool,
|
|
125
140
|
amount: params.amount,
|
|
@@ -154,6 +169,13 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
154
169
|
tokenIn,
|
|
155
170
|
tokenOut
|
|
156
171
|
});
|
|
172
|
+
const [refusal] = checkPoolOperation({
|
|
173
|
+
sdk: chain,
|
|
174
|
+
pool: pool.pool,
|
|
175
|
+
isDeposit: false,
|
|
176
|
+
tokenOut: state.tokenOut
|
|
177
|
+
});
|
|
178
|
+
if (refusal) return sdkErr(refusal);
|
|
157
179
|
const { calls } = pools.removeLiquidity({
|
|
158
180
|
pool: pool.pool,
|
|
159
181
|
amount: params.amount,
|
|
@@ -179,14 +201,11 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
179
201
|
try {
|
|
180
202
|
const sdk = await this.#chain(strategy.chainId);
|
|
181
203
|
const at = stateBlock(sdk);
|
|
182
|
-
if (params.empty) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
empty: true
|
|
188
|
-
}), at);
|
|
189
|
-
}
|
|
204
|
+
if (params.empty) return opened(await service(sdk).openStrategyIntent({
|
|
205
|
+
sdk,
|
|
206
|
+
creditManager: strategy.creditManager,
|
|
207
|
+
empty: true
|
|
208
|
+
}), at);
|
|
190
209
|
const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
|
|
191
210
|
if (!targetToken) return sdkErr(noStrategyTargetCollateral(strategy.creditManager));
|
|
192
211
|
let creditAccount;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { creditAccountNotEmpty, creditAccountNotFound,
|
|
1
|
+
import { creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure } from "../../model/errors/prepare-errors.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { PrepareApi } from "./PrepareApi.js";
|
|
4
4
|
import "./types.js";
|
|
5
|
-
export { PrepareApi, creditAccountNotEmpty, creditAccountNotFound,
|
|
5
|
+
export { PrepareApi, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -2,6 +2,6 @@ import { IGearboxError } from "./base.js";
|
|
|
2
2
|
import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./liquidation-errors.js";
|
|
3
3
|
import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
4
4
|
import { UnpriceableTokenError, unpriceableTokenError } from "./oracle-errors.js";
|
|
5
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
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 { BorrowLimitCause, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, DebtOutOfRangeError,
|
|
7
|
+
export { 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, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Bps, Token, TokenAmount } from "../primitives.js";
|
|
2
2
|
import { IGearboxError } from "./base.js";
|
|
3
3
|
import { RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements } from "../rwa.js";
|
|
4
|
+
import { MaxBorrowAmount } from "../../onchain/market/credit/types.js";
|
|
5
|
+
import "../../onchain/index.js";
|
|
4
6
|
import { Address } from "viem";
|
|
5
7
|
//#region src/model/errors/operation-errors.d.ts
|
|
6
8
|
/**
|
|
@@ -82,6 +84,8 @@ interface DebtOutOfRangeError extends IGearboxError {
|
|
|
82
84
|
requested: TokenAmount;
|
|
83
85
|
minDebt: TokenAmount;
|
|
84
86
|
maxDebt: TokenAmount;
|
|
87
|
+
/** What the market will really lend; absent where the raiser only throws. */
|
|
88
|
+
maxBorrowAmount?: MaxBorrowAmount;
|
|
85
89
|
}
|
|
86
90
|
/** {@inheritDoc DebtOutOfRangeError} */
|
|
87
91
|
declare function debtOutOfRange(args: Omit<DebtOutOfRangeError, "code" | "message">): DebtOutOfRangeError;
|
|
@@ -96,15 +96,6 @@ interface CreditAccountNotEmptyError extends IGearboxError {
|
|
|
96
96
|
}
|
|
97
97
|
/** {@inheritDoc CreditAccountNotEmptyError} */
|
|
98
98
|
declare function creditAccountNotEmpty(creditAccount: Address): CreditAccountNotEmptyError;
|
|
99
|
-
/**
|
|
100
|
-
* An empty opening was asked for with something to open it with: collateral to
|
|
101
|
-
* spend, an account to reuse, or a leverage to reach.
|
|
102
|
-
**/
|
|
103
|
-
interface EmptyOpenTakesNothingError extends IGearboxError {
|
|
104
|
-
code: "emptyOpenTakesNothing";
|
|
105
|
-
}
|
|
106
|
-
/** {@inheritDoc EmptyOpenTakesNothingError} */
|
|
107
|
-
declare function emptyOpenTakesNothing(): EmptyOpenTakesNothingError;
|
|
108
99
|
/**
|
|
109
100
|
* The SDK could not answer at all: a read that failed, a chain it is not
|
|
110
101
|
* connected to, a market or token address it knows nothing about, a contract
|
|
@@ -128,4 +119,4 @@ interface UnexpectedFailureError extends IGearboxError {
|
|
|
128
119
|
**/
|
|
129
120
|
declare function unexpectedFailure(thrown: unknown, action?: string): UnexpectedFailureError;
|
|
130
121
|
//#endregion
|
|
131
|
-
export { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
122
|
+
export { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
@@ -8,7 +8,7 @@ import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiqui
|
|
|
8
8
|
import { KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature } from "./rwa.js";
|
|
9
9
|
import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
|
|
10
10
|
import { UnpriceableTokenError, unpriceableTokenError } from "./errors/oracle-errors.js";
|
|
11
|
-
import { CreditAccountNotEmptyError, CreditAccountNotFoundError,
|
|
11
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
|
|
12
12
|
import { InvalidDelayedIntentError, MalformedTransactionError, PoolOperationPreviewError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, malformedTransaction } from "./errors/preview-errors.js";
|
|
13
13
|
import "./errors/index.js";
|
|
14
14
|
import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
@@ -33,4 +33,4 @@ import { SDKError, SDKResult, SDKReturn, SafeValue, safeValue, sdkErr, sdkOk } f
|
|
|
33
33
|
import { kycProtocolSchema, kycRequirementSchema } from "./rwa.schema.js";
|
|
34
34
|
import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
|
|
35
35
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
36
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent,
|
|
36
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycProtocolSchema, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, 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 };
|
|
@@ -311,7 +311,7 @@ import { CheckWalletAllowanceInput, checkWalletAllowance } from "./validation/bu
|
|
|
311
311
|
import { CheckWalletBalanceInput, checkWalletBalance } from "./validation/bundles/checkWalletBalance.js";
|
|
312
312
|
import { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError, checkLiquidation } from "./validation/checkLiquidation.js";
|
|
313
313
|
import { CheckOperationInput, CheckOperationOptions, OperationValidationError, checkOperation } from "./validation/checkOperation.js";
|
|
314
|
-
import { CheckSimulationInput, CreditSimulationInput,
|
|
314
|
+
import { CheckSimulationInput, CreditSimulationInput, SimulationValidationError, checkSimulation } from "./validation/checkSimulation.js";
|
|
315
315
|
import { BorrowLimitArgs, checkBorrowLimit } from "./validation/checks/checkBorrowLimit.js";
|
|
316
316
|
import { CollateralisedArgs, checkCollateralised } from "./validation/checks/checkCollateralised.js";
|
|
317
317
|
import { CreditAccountFrozenArgs, checkCreditAccountFrozen } from "./validation/checks/checkCreditAccountFrozen.js";
|
|
@@ -331,4 +331,4 @@ import { amountOf } from "./validation/helpers/amount.js";
|
|
|
331
331
|
import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./validation/helpers/health-factor-limits.js";
|
|
332
332
|
import { toToken, toTokenAmount } from "./validation/helpers/token.js";
|
|
333
333
|
import "./validation/index.js";
|
|
334
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterOperation, AdapterOperationBase, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddCollateralOp, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetWithAmountInTarget, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, BorrowLimitArgs, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CallTrace, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, ClassifyInnerOperationsProps, ClientOptions, CloseCreditAccountOperation, CloseCreditAccountResult, CloseOrRepayOperation, ClosePathBalances, CollateralFundingPreview, CollateralisedArgs, CompareBalancesOp, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvertFn, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountFrozenArgs, CreditAccountOperation, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountState, CreditAccountStateProps, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerPausedArgs, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, DebtLimitsArgs, DecreaseDebtOp, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, EmergencyLiquidatorArgs, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, FacadeOperationMetadata, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, type FinishIntentResult, FluidDexAdapterContract, ForbiddenTokenArgs, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetCurrentWithdrawalsProps, GetCurrentWithdrawalsPropsBase, GetExternalAccountCurrentWithdrawalsProps, GetInvestorOptions, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetReward, GetWithdrawalRequestResultProps, HealthFactorThresholds, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IDegenNFT, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IMultichainOpportunitiesService, IMultichainPositionsService, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, IncreaseDebtOp, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InnerFacadeOperation, InnerOperation, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type IntentValidationError, type InterestRateModelStateHuman, InterestRateModelType, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, KycCheckResult, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LeverageArgs, type LeverageBand, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidateCreditAccountOperation, LiquidationEligibilityError, LiquidationFees, LiquidationValidationError, LiquidationsService, LiquidatorEligibleArgs, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketExpiredArgs, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketStateError, type MarketStateHuman, MarketSuite, MarketType, MaxBorrowAmount, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallOperation, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, OpenCreditAccountOperation, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OpenStrategyState, Operation, OperationMetadata, type OperationState, OperationValidationError, OpportunitiesService, OptimalRepaidAmountProps, OuterFacadeOperation, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationOperation, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolDepositOperation, PoolLiquidityArgs, PoolMintOperation, PoolOperation, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolRedeemOperation, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolSimulationInput, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolSunsetArgs, PoolV310Contract, PoolWithdrawOperation, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewOperationError, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, ProjectedPoolOptions, PythPriceFeed, QuotaCountArgs, QuotaKeeperState, QuotaLimitArgs, QuotaMode, type QuotaParamsHuman, QuotaSlice, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryStateHuman, RWAInvestorData, RWALiquidatorInfo, RWAMulticallOperation, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedemptionPhantomRename, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, ReplayMulticallResult, ReplayState, ReplayableOperation, RequestableWithdrawal, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteErrors, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeDegenNFT, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, SimulationValidationError, StakingRewardsAdapterContract, type StartIntent, StoreExpectedBalancesOp, StrategyCollateralProps, StrategyRateInputs, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokenTransfer, TokensMeta, TokensMetaState, TraceAdapterExt, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatePriceFeedsResult, UpdateQuotaOp, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WalletFundingError, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, WeighedFactors, type WithBlock, type WithMultichain, type WithdrawAssetIntent, type WithdrawCeilings, WithdrawCollateral, WithdrawCollateralOp, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, 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, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
334
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterOperation, AdapterOperationBase, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddCollateralOp, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetWithAmountInTarget, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, BorrowLimitArgs, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CallTrace, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, ClassifyInnerOperationsProps, ClientOptions, CloseCreditAccountOperation, CloseCreditAccountResult, CloseOrRepayOperation, ClosePathBalances, CollateralFundingPreview, CollateralisedArgs, CompareBalancesOp, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvertFn, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountFrozenArgs, CreditAccountOperation, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountState, CreditAccountStateProps, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerPausedArgs, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, DebtLimitsArgs, DecreaseDebtOp, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, EmergencyLiquidatorArgs, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, FacadeOperationMetadata, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, type FinishIntentResult, FluidDexAdapterContract, ForbiddenTokenArgs, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetCurrentWithdrawalsProps, GetCurrentWithdrawalsPropsBase, GetExternalAccountCurrentWithdrawalsProps, GetInvestorOptions, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetReward, GetWithdrawalRequestResultProps, HealthFactorThresholds, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IDegenNFT, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IMultichainOpportunitiesService, IMultichainPositionsService, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, IncreaseDebtOp, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InnerFacadeOperation, InnerOperation, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type IntentValidationError, type InterestRateModelStateHuman, InterestRateModelType, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, KycCheckResult, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LeverageArgs, type LeverageBand, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidateCreditAccountOperation, LiquidationEligibilityError, LiquidationFees, LiquidationValidationError, LiquidationsService, LiquidatorEligibleArgs, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketExpiredArgs, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketStateError, type MarketStateHuman, MarketSuite, MarketType, MaxBorrowAmount, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallOperation, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, OpenCreditAccountOperation, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OpenStrategyState, Operation, OperationMetadata, type OperationState, OperationValidationError, OpportunitiesService, OptimalRepaidAmountProps, OuterFacadeOperation, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationOperation, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolDepositOperation, PoolLiquidityArgs, PoolMintOperation, PoolOperation, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolRedeemOperation, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolSunsetArgs, PoolV310Contract, PoolWithdrawOperation, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewOperationError, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, ProjectedPoolOptions, PythPriceFeed, QuotaCountArgs, QuotaKeeperState, QuotaLimitArgs, QuotaMode, type QuotaParamsHuman, QuotaSlice, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryStateHuman, RWAInvestorData, RWALiquidatorInfo, RWAMulticallOperation, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedemptionPhantomRename, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, ReplayMulticallResult, ReplayState, ReplayableOperation, RequestableWithdrawal, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteErrors, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeDegenNFT, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, SimulationValidationError, StakingRewardsAdapterContract, type StartIntent, StoreExpectedBalancesOp, StrategyCollateralProps, StrategyRateInputs, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokenTransfer, TokensMeta, TokensMetaState, TraceAdapterExt, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatePriceFeedsResult, UpdateQuotaOp, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WalletFundingError, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, WeighedFactors, type WithBlock, type WithMultichain, type WithdrawAssetIntent, type WithdrawCeilings, WithdrawCollateral, WithdrawCollateralOp, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, 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, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bps, Leverage } from "../../../model/primitives.js";
|
|
1
|
+
import { Bps, Leverage, TokenAmount } from "../../../model/primitives.js";
|
|
2
2
|
import { BorrowLimitCause } from "../../../model/errors/operation-errors.js";
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
@@ -25,7 +25,7 @@ interface ICreditConfiguratorContract extends IBaseContract {
|
|
|
25
25
|
**/
|
|
26
26
|
interface MaxBorrowAmount {
|
|
27
27
|
/** In the pool's underlying. */
|
|
28
|
-
|
|
28
|
+
amount: TokenAmount;
|
|
29
29
|
/** The limit {@link value} ran into; see {@link BorrowLimitCause}. */
|
|
30
30
|
limit: BorrowLimitCause;
|
|
31
31
|
}
|
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
import { ChainId } from "../../model/primitives.js";
|
|
2
2
|
import { DebtOutOfRangeError, InsufficientCollateralError, QuotaCountExceededError } from "../../model/errors/operation-errors.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
|
-
import { PoolSimulation } from "../pools/types.js";
|
|
5
4
|
import { OnchainSDK } from "../OnchainSDK.js";
|
|
6
5
|
import { OperationState } from "../accounts/intents/types.js";
|
|
6
|
+
import { OpenStrategyState } from "../accounts/intents/open-strategy.js";
|
|
7
7
|
import { HealthFactorThresholds } from "./bundles/checkHealthFactors.js";
|
|
8
8
|
import { MarketStateError } from "./bundles/checkMarket.js";
|
|
9
|
-
import { PoolOperationError } from "./bundles/checkPoolOperation.js";
|
|
10
|
-
import { Address } from "viem";
|
|
11
9
|
//#region src/onchain/validation/checkSimulation.d.ts
|
|
12
10
|
/** A simulated credit operation, as the intents engine reports one. */
|
|
13
11
|
interface CreditSimulationInput {
|
|
14
12
|
chainId: ChainId;
|
|
15
|
-
state: OperationState;
|
|
13
|
+
state: OperationState | OpenStrategyState;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
* A simulated pool operation. The pool comes alongside the state, which names
|
|
19
|
-
* the tokens moving through it but not the market they belong to.
|
|
20
|
-
*/
|
|
21
|
-
interface PoolSimulationInput {
|
|
22
|
-
chainId: ChainId;
|
|
23
|
-
pool: Address;
|
|
24
|
-
state: PoolSimulation;
|
|
25
|
-
/** Whether the operation puts liquidity in rather than taking it out. */
|
|
26
|
-
isDeposit: boolean;
|
|
27
|
-
}
|
|
28
|
-
type CheckSimulationInput = CreditSimulationInput | PoolSimulationInput;
|
|
15
|
+
type CheckSimulationInput = CreditSimulationInput;
|
|
29
16
|
/** {@inheritDoc checkSimulation} */
|
|
30
|
-
type SimulationValidationError = MarketStateError | DebtOutOfRangeError | QuotaCountExceededError | InsufficientCollateralError
|
|
17
|
+
type SimulationValidationError = MarketStateError | DebtOutOfRangeError | QuotaCountExceededError | InsufficientCollateralError;
|
|
31
18
|
/**
|
|
32
19
|
* Whether a simulated operation clears the caller's own thresholds.
|
|
33
20
|
*
|
|
@@ -48,9 +35,11 @@ type SimulationValidationError = MarketStateError | DebtOutOfRangeError | QuotaC
|
|
|
48
35
|
* touched. The engine performed all three during the walk, so a simulation that
|
|
49
36
|
* came back `ok` has already passed them.
|
|
50
37
|
*
|
|
51
|
-
* A
|
|
52
|
-
*
|
|
38
|
+
* A credit account only, opened or adjusted: a pool operation has no account
|
|
39
|
+
* to weigh, and the three things its own state decides are read by `prepare`
|
|
40
|
+
* before it answers. An opening names its quotas `averageQuota` — the branch
|
|
41
|
+
* the planner already weighed it as.
|
|
53
42
|
*/
|
|
54
43
|
declare function checkSimulation(sdk: OnchainSDK, input: CheckSimulationInput, options?: HealthFactorThresholds): SimulationValidationError[];
|
|
55
44
|
//#endregion
|
|
56
|
-
export { CheckSimulationInput, CreditSimulationInput,
|
|
45
|
+
export { CheckSimulationInput, CreditSimulationInput, SimulationValidationError, checkSimulation };
|
|
@@ -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 };
|
|
@@ -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 };
|