@gearbox-protocol/sdk 16.0.0-next.29 → 16.0.0-next.30
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/liquidations.schema.js +5 -1
- package/dist/cjs/onchain/accounts/intents/index.js +5 -5
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +4 -3
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +13 -4
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +6 -5
- package/dist/cjs/onchain/accounts/liquidations/skipLiquidatableAccount.js +12 -0
- package/dist/cjs/onchain/market/credit/creditOperationMarket.js +7 -3
- package/dist/cjs/sdk/execute/ExecuteApi.js +6 -6
- package/dist/cjs/sdk/prepare/PrepareApi.js +8 -8
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/liquidations.schema.js +6 -2
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/intents/index.js +6 -6
- package/dist/esm/onchain/accounts/intents/open-strategy.js +4 -3
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +13 -4
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +7 -6
- package/dist/esm/onchain/accounts/liquidations/skipLiquidatableAccount.js +11 -0
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/credit/creditOperationMarket.js +7 -3
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +6 -6
- package/dist/esm/sdk/prepare/PrepareApi.js +8 -8
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/liquidations.d.ts +14 -8
- package/dist/types/model/liquidations.schema.d.ts +46 -2
- package/dist/types/model/positions.d.ts +1 -1
- package/dist/types/model/previews.d.ts +9 -7
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +6 -19
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +8 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +24 -17
- package/dist/types/onchain/accounts/liquidations/LiquidationsService.d.ts +0 -1
- package/dist/types/onchain/accounts/liquidations/skipLiquidatableAccount.d.ts +11 -0
- package/dist/types/onchain/index.d.ts +2 -2
- package/dist/types/onchain/market/credit/creditOperationMarket.d.ts +6 -2
- package/dist/types/sdk/execute/types.d.ts +4 -4
- package/dist/types/sdk/prepare/types.d.ts +8 -8
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
4
|
import "../../base/index.js";
|
|
4
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -15,14 +15,18 @@ function totalLiquidationDiscount(suite) {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* The market half of every credit operation result, read off the suite that
|
|
18
|
-
* serves it
|
|
19
|
-
*
|
|
18
|
+
* serves it: a preview, a projection, the open-strategy walk and a
|
|
19
|
+
* liquidatable-account row all spread it, so the four fields are filled in one
|
|
20
|
+
* place and cannot drift apart between the halves of the SDK.
|
|
21
|
+
*
|
|
22
|
+
* The curator comes from the same getter {@link CreditSuite.strategyOpportunity}
|
|
23
|
+
* reads, so a result and the opportunity beside it name one entity.
|
|
20
24
|
**/
|
|
21
25
|
function creditOperationMarket(suite) {
|
|
22
26
|
return {
|
|
23
27
|
creditManager: suite.creditManager.address,
|
|
24
28
|
name: suite.name,
|
|
25
|
-
curator: suite.
|
|
29
|
+
curator: suite.market.curator,
|
|
26
30
|
liquidationDiscount: totalLiquidationDiscount(suite)
|
|
27
31
|
};
|
|
28
32
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
4
|
import { RAY } from "../../constants/math.js";
|
|
@@ -7,7 +8,6 @@ import "../../utils/index.js";
|
|
|
7
8
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
8
9
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
9
10
|
import "../../base/index.js";
|
|
10
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
11
11
|
//#region src/onchain/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
13
13
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/onchain/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/onchain/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { generateCastTraceCall } from "./cast.js";
|
|
3
2
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
import { generateCastTraceCall } from "./cast.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { asPreviewSimulationError } from "./errors.js";
|
|
4
4
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
5
5
|
function previewRead(operation) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
@@ -22,7 +22,7 @@ var ExecuteApi = class {
|
|
|
22
22
|
};
|
|
23
23
|
function poolTx(sdk, request) {
|
|
24
24
|
const { pool, wallet, sim } = request;
|
|
25
|
-
const { tokenIn, tokenOut } = sim.
|
|
25
|
+
const { tokenIn, tokenOut } = sim.state;
|
|
26
26
|
if (request.op === "deposit") {
|
|
27
27
|
const meta = sdk.pools.getDepositMetadata(pool, tokenIn.token.address, tokenOut.token.address);
|
|
28
28
|
const result = sdk.pools.addLiquidity({
|
|
@@ -49,16 +49,16 @@ function poolTx(sdk, request) {
|
|
|
49
49
|
}
|
|
50
50
|
async function openTx(sdk, request) {
|
|
51
51
|
const { creditManager, wallet, collateral, ethAmount, sim } = request;
|
|
52
|
-
const {
|
|
52
|
+
const { state } = sim;
|
|
53
53
|
return sdk.accounts.openCA({
|
|
54
54
|
creditManager,
|
|
55
55
|
to: wallet,
|
|
56
56
|
collateral,
|
|
57
57
|
ethAmount,
|
|
58
|
-
debt:
|
|
59
|
-
calls:
|
|
60
|
-
averageQuota:
|
|
61
|
-
minQuota:
|
|
58
|
+
debt: state.totalDebt.value,
|
|
59
|
+
calls: state.calls,
|
|
60
|
+
averageQuota: state.averageQuota,
|
|
61
|
+
minQuota: state.minQuota,
|
|
62
62
|
permits: {},
|
|
63
63
|
referralCode: 0n,
|
|
64
64
|
rwaOptions: await openRwaOptions(sdk, request)
|
|
@@ -59,7 +59,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
59
59
|
const tokenIn = params.tokenIn ?? marketRegister.findByPool(pool.pool).pool.underlying;
|
|
60
60
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getDepositTokensOut(pool.pool, tokenIn));
|
|
61
61
|
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
62
|
-
const
|
|
62
|
+
const state = pools.simulateDeposit({
|
|
63
63
|
pool: pool.pool,
|
|
64
64
|
amount: params.amount,
|
|
65
65
|
tokenIn,
|
|
@@ -67,8 +67,8 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
67
67
|
});
|
|
68
68
|
const call = pools.addLiquidity({
|
|
69
69
|
collateral: {
|
|
70
|
-
token:
|
|
71
|
-
balance:
|
|
70
|
+
token: state.tokenIn.token.address,
|
|
71
|
+
balance: state.tokenIn.value
|
|
72
72
|
},
|
|
73
73
|
pool: pool.pool,
|
|
74
74
|
wallet: params.wallet,
|
|
@@ -78,7 +78,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
78
78
|
return {
|
|
79
79
|
ok: true,
|
|
80
80
|
operations: [],
|
|
81
|
-
|
|
81
|
+
state,
|
|
82
82
|
calls: call.calls
|
|
83
83
|
};
|
|
84
84
|
}
|
|
@@ -91,7 +91,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
91
91
|
const tokenIn = params.tokenIn ?? pool.pool;
|
|
92
92
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
|
|
93
93
|
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
94
|
-
const
|
|
94
|
+
const state = pools.simulateWithdraw({
|
|
95
95
|
pool: pool.pool,
|
|
96
96
|
amount: params.amount,
|
|
97
97
|
tokenIn,
|
|
@@ -108,7 +108,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
108
108
|
return {
|
|
109
109
|
ok: true,
|
|
110
110
|
operations: [],
|
|
111
|
-
|
|
111
|
+
state,
|
|
112
112
|
calls
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -121,7 +121,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
121
121
|
const tokenIn = params.tokenIn ?? pool.pool;
|
|
122
122
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
|
|
123
123
|
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
124
|
-
const
|
|
124
|
+
const state = pools.simulateRedeem({
|
|
125
125
|
pool: pool.pool,
|
|
126
126
|
amount: params.amount,
|
|
127
127
|
tokenIn,
|
|
@@ -138,7 +138,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
138
138
|
return {
|
|
139
139
|
ok: true,
|
|
140
140
|
operations: [],
|
|
141
|
-
|
|
141
|
+
state,
|
|
142
142
|
calls
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -7,15 +7,15 @@ import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
|
7
7
|
import { DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedWithdrawCollateralIntent } from "./delayed-intents.js";
|
|
8
8
|
import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
|
|
9
9
|
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
10
|
-
import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
11
|
-
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
12
10
|
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";
|
|
13
11
|
import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
|
|
12
|
+
import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, CreditOperationMarket, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, Estimated, EstimatedProjection, OperationPreview, OperationPreviewError, PoolOperationType, PreviewAdjustStrategyVerify, PreviewDelayedStrategyVerify, PreviewExitStrategyVerify, PreviewInstantStrategyVerify, PreviewLpVerify, PreviewOpenStrategyVerify, PreviewOperationInput, PreviewOperationOptions, PreviewRepayStrategyVerify, RoutedField, asEstimated } from "./previews.js";
|
|
13
|
+
import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
14
|
+
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
14
15
|
import { Notice, NoticeKind, NoticeSubject } from "./notices.js";
|
|
15
16
|
import { noticeKindSchema, noticeSchema } from "./notices.schema.js";
|
|
16
17
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
17
18
|
import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
18
|
-
import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, CreditOperationMarket, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, Estimated, EstimatedProjection, OperationPreview, OperationPreviewError, PoolOperationType, PreviewAdjustStrategyVerify, PreviewDelayedStrategyVerify, PreviewExitStrategyVerify, PreviewInstantStrategyVerify, PreviewLpVerify, PreviewOpenStrategyVerify, PreviewOperationInput, PreviewOperationOptions, PreviewRepayStrategyVerify, RoutedField, asEstimated } from "./previews.js";
|
|
19
19
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
20
20
|
import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
|
|
21
21
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AssetType, ChainId, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
|
|
2
2
|
import { ChainScopedFilter, Filterable } from "./filters.js";
|
|
3
|
+
import { CreditOperationMarket } from "./previews.js";
|
|
3
4
|
import { Address } from "viem";
|
|
4
5
|
//#region src/model/liquidations.d.ts
|
|
5
6
|
/**
|
|
@@ -34,8 +35,12 @@ interface LiquidatableAccountFilter extends ChainScopedFilter {
|
|
|
34
35
|
/**
|
|
35
36
|
* A credit account that can be liquidated, with amounts precomputed for
|
|
36
37
|
* manual liquidation.
|
|
38
|
+
*
|
|
39
|
+
* The market it lives in is named the same way every other credit result names
|
|
40
|
+
* it — through {@link CreditOperationMarket} — so a liquidation screen labels
|
|
41
|
+
* the manager, its curator and the discount from the row it already holds.
|
|
37
42
|
**/
|
|
38
|
-
interface LiquidatableAccount {
|
|
43
|
+
interface LiquidatableAccount extends CreditOperationMarket {
|
|
39
44
|
/**
|
|
40
45
|
* Chain the account lives on.
|
|
41
46
|
**/
|
|
@@ -44,10 +49,6 @@ interface LiquidatableAccount {
|
|
|
44
49
|
* Credit account address.
|
|
45
50
|
**/
|
|
46
51
|
creditAccount: Address;
|
|
47
|
-
/**
|
|
48
|
-
* Credit manager the account is opened in.
|
|
49
|
-
**/
|
|
50
|
-
creditManager: Address;
|
|
51
52
|
/**
|
|
52
53
|
* Main asset being liquidated: the most valuable enabled non-underlying
|
|
53
54
|
* collateral token. For delayed-withdrawal phantom tokens, the source
|
|
@@ -63,12 +64,17 @@ interface LiquidatableAccount {
|
|
|
63
64
|
totalValue: TokenAmount;
|
|
64
65
|
/**
|
|
65
66
|
* Estimated amount the liquidator pays to fully liquidate the account:
|
|
66
|
-
*
|
|
67
|
+
* {@link totalValue} less the premium the liquidator keeps, in the same
|
|
68
|
+
* token.
|
|
69
|
+
*
|
|
70
|
+
* Not `totalValue * (1 - liquidationDiscount)`: {@link liquidationDiscount}
|
|
71
|
+
* also carries the protocol's own liquidation fee, which comes out of what
|
|
72
|
+
* the repayment covers rather than off what the liquidator pays.
|
|
67
73
|
**/
|
|
68
74
|
repaymentAmount: TokenAmount;
|
|
69
75
|
/**
|
|
70
|
-
* Estimated liquidator profit:
|
|
71
|
-
*
|
|
76
|
+
* Estimated liquidator profit: the premium on {@link totalValue}, i.e.
|
|
77
|
+
* `totalValue - repaymentAmount`, in the same token.
|
|
72
78
|
**/
|
|
73
79
|
estimatedProfit: TokenAmount;
|
|
74
80
|
/**
|
|
@@ -18,9 +18,31 @@ declare const liquidatableAccountFilterSchema: z.ZodObject<{
|
|
|
18
18
|
* {@link LiquidatableAccount}
|
|
19
19
|
**/
|
|
20
20
|
declare const liquidatableAccountSchema: z.ZodObject<{
|
|
21
|
+
creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
curator: z.ZodObject<{
|
|
24
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
25
|
+
name: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
"Chaos Labs": "Chaos Labs";
|
|
27
|
+
"Gami Labs": "Gami Labs";
|
|
28
|
+
Hyperithm: "Hyperithm";
|
|
29
|
+
"Invariant Group": "Invariant Group";
|
|
30
|
+
K3: "K3";
|
|
31
|
+
KPK: "KPK";
|
|
32
|
+
"M11 Credit": "M11 Credit";
|
|
33
|
+
Re7: "Re7";
|
|
34
|
+
Securitize: "Securitize";
|
|
35
|
+
TelosC: "TelosC";
|
|
36
|
+
"Testnet Curator": "Testnet Curator";
|
|
37
|
+
Tulipa: "Tulipa";
|
|
38
|
+
UltraYield: "UltraYield";
|
|
39
|
+
cp0x: "cp0x";
|
|
40
|
+
}>>;
|
|
41
|
+
url: z.ZodNullable<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
liquidationDiscount: z.ZodNumber;
|
|
21
44
|
chainId: z.ZodNumber;
|
|
22
45
|
creditAccount: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
23
|
-
creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
24
46
|
asset: z.ZodObject<{
|
|
25
47
|
chainId: z.ZodNumber;
|
|
26
48
|
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
@@ -188,9 +210,31 @@ declare const liquidationPositionSchema: z.ZodObject<{
|
|
|
188
210
|
* {@link LiquidationDetails}
|
|
189
211
|
**/
|
|
190
212
|
declare const liquidationDetailsSchema: z.ZodObject<{
|
|
213
|
+
creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
214
|
+
name: z.ZodString;
|
|
215
|
+
curator: z.ZodObject<{
|
|
216
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
217
|
+
name: z.ZodOptional<z.ZodEnum<{
|
|
218
|
+
"Chaos Labs": "Chaos Labs";
|
|
219
|
+
"Gami Labs": "Gami Labs";
|
|
220
|
+
Hyperithm: "Hyperithm";
|
|
221
|
+
"Invariant Group": "Invariant Group";
|
|
222
|
+
K3: "K3";
|
|
223
|
+
KPK: "KPK";
|
|
224
|
+
"M11 Credit": "M11 Credit";
|
|
225
|
+
Re7: "Re7";
|
|
226
|
+
Securitize: "Securitize";
|
|
227
|
+
TelosC: "TelosC";
|
|
228
|
+
"Testnet Curator": "Testnet Curator";
|
|
229
|
+
Tulipa: "Tulipa";
|
|
230
|
+
UltraYield: "UltraYield";
|
|
231
|
+
cp0x: "cp0x";
|
|
232
|
+
}>>;
|
|
233
|
+
url: z.ZodNullable<z.ZodString>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
liquidationDiscount: z.ZodNumber;
|
|
191
236
|
chainId: z.ZodNumber;
|
|
192
237
|
creditAccount: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
193
|
-
creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
194
238
|
asset: z.ZodObject<{
|
|
195
239
|
chainId: z.ZodNumber;
|
|
196
240
|
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, UnderlyingToken } from "./primitives.js";
|
|
2
2
|
import { ChainScopedFilter, Filterable } from "./filters.js";
|
|
3
|
-
import { DelayedReceivedAsset, LiquidationPosition } from "./liquidations.js";
|
|
4
3
|
import { ApyBreakdown, PointsProgram } from "./opportunities.js";
|
|
4
|
+
import { DelayedReceivedAsset, LiquidationPosition } from "./liquidations.js";
|
|
5
5
|
import { Address, Hex } from "viem";
|
|
6
6
|
//#region src/model/positions.d.ts
|
|
7
7
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bps, ChainId, Leverage, TokenAmount } from "./primitives.js";
|
|
2
|
+
import { Curator } from "./curators.js";
|
|
2
3
|
import { DelayedIntent } from "./delayed-intents.js";
|
|
3
4
|
import { BorrowRateBreakdown } from "./positions.js";
|
|
4
5
|
import { Address, Hex } from "viem";
|
|
@@ -144,9 +145,9 @@ interface PreviewLpVerify {
|
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
146
147
|
* The market a credit operation acts on, reported the same way by every half of
|
|
147
|
-
* the SDK: the calldata previews, the intents engine's projections
|
|
148
|
-
* open-strategy walk all carry it, so a screen
|
|
149
|
-
* beside the result it already holds.
|
|
148
|
+
* the SDK: the calldata previews, the intents engine's projections, the
|
|
149
|
+
* open-strategy walk and the liquidatable-account rows all carry it, so a screen
|
|
150
|
+
* naming the market needs nothing beside the result it already holds.
|
|
150
151
|
**/
|
|
151
152
|
interface CreditOperationMarket {
|
|
152
153
|
/**
|
|
@@ -160,11 +161,12 @@ interface CreditOperationMarket {
|
|
|
160
161
|
*/
|
|
161
162
|
name: string;
|
|
162
163
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
164
|
+
* Curator of the market {@link creditManager} belongs to, in the same shape
|
|
165
|
+
* {@link StrategyOpportunity} reports it: the market configurator's address,
|
|
166
|
+
* plus the display name and the page a screen labels it with when the
|
|
167
|
+
* configurator is a known one.
|
|
166
168
|
*/
|
|
167
|
-
curator:
|
|
169
|
+
curator: Curator;
|
|
168
170
|
/**
|
|
169
171
|
* What a liquidation takes off the account, in basis points: the premium the
|
|
170
172
|
* liquidator keeps plus the protocol's own fee.
|
|
@@ -25,7 +25,7 @@ import { LeverageBand } from "./intents/leverage-band.js";
|
|
|
25
25
|
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
26
26
|
import { AccountCalculatorOperation } from "./intents/operations.js";
|
|
27
27
|
import { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./intents/types.js";
|
|
28
|
-
import {
|
|
28
|
+
import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js";
|
|
29
29
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
|
|
30
30
|
import { isPhantomToken } from "./intents/utils/pick-token.js";
|
|
31
31
|
import { CreditAccountOperationsService, OpenStrategyPreviewResult } from "./intents/index.js";
|
|
@@ -34,4 +34,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
|
|
|
34
34
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
35
35
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
36
36
|
import "./liquidations/index.js";
|
|
37
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps,
|
|
37
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteRefusals, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, borrowable, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -4,7 +4,7 @@ import { borrowable } from "./guards.js";
|
|
|
4
4
|
import { LeverageBand, LeverageBandProps } from "./leverage-band.js";
|
|
5
5
|
import { AccountCalculatorOperation } from "./operations.js";
|
|
6
6
|
import { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent } from "./types.js";
|
|
7
|
-
import {
|
|
7
|
+
import { OpenStrategyProps, OpenStrategyState } from "./open-strategy.js";
|
|
8
8
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./utils/credit-account-slice.js";
|
|
9
9
|
import { isPhantomToken } from "./utils/pick-token.js";
|
|
10
10
|
import { Address } from "viem";
|
|
@@ -18,7 +18,7 @@ import { Address } from "viem";
|
|
|
18
18
|
*/
|
|
19
19
|
type OpenStrategyPreviewResult = {
|
|
20
20
|
ok: true;
|
|
21
|
-
|
|
21
|
+
state: OpenStrategyState;
|
|
22
22
|
} | PreviewRefusal;
|
|
23
23
|
/** An intent plus everything previewing it needs. */
|
|
24
24
|
type StartProps = StartIntentProps & {
|
|
@@ -183,4 +183,4 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
183
183
|
openStrategyIntent(props: OpenStrategyProps): Promise<OpenStrategyPreviewResult>;
|
|
184
184
|
}
|
|
185
185
|
//#endregion
|
|
186
|
-
export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand,
|
|
186
|
+
export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type RouteRefusals, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, borrowable, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };
|
|
@@ -4,7 +4,7 @@ import "../../../model/index.js";
|
|
|
4
4
|
import { Asset } from "../../base/types.js";
|
|
5
5
|
import { MultiCall } from "../../types/transactions.js";
|
|
6
6
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
7
|
-
import {
|
|
7
|
+
import { SimulationPrices } from "./types.js";
|
|
8
8
|
import "../../index.js";
|
|
9
9
|
import { Address } from "viem";
|
|
10
10
|
//#region src/onchain/accounts/intents/open-strategy.d.ts
|
|
@@ -32,21 +32,7 @@ interface OpenStrategyProps {
|
|
|
32
32
|
* hands back expected and floor balances from a single call, and `openCA` wants
|
|
33
33
|
* both `minQuota` and `averageQuota`, so there is nothing to gain by dropping one.
|
|
34
34
|
*/
|
|
35
|
-
interface
|
|
36
|
-
/** What the routed leg lost to market depth; `undefined` if not measured. */
|
|
37
|
-
priceImpact: PathLossRate | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* What the position's collateral costs in the market underlying right now, in
|
|
40
|
-
* the oracle's 8-decimal fixed point — the same scale and the same pair as
|
|
41
|
-
* {@link liquidationPrice}, so a screen showing both reads them as one pair.
|
|
42
|
-
*
|
|
43
|
-
* `null` where there is no pair to quote: an account holding zero or several
|
|
44
|
-
* non-underlying assets, or one whose collateral the oracle cannot price.
|
|
45
|
-
*
|
|
46
|
-
* Simulations only. A calldata preview is not asked for it: it reports what a
|
|
47
|
-
* transaction does, not what the market costs while a form is open.
|
|
48
|
-
*/
|
|
49
|
-
currentPrice: bigint | null;
|
|
35
|
+
interface OpenStrategyState extends Omit<AccountProjection, "assets" | "quotas">, SimulationPrices {
|
|
50
36
|
/** Expected post-open balances. */
|
|
51
37
|
averageAssets: TokenAmount[];
|
|
52
38
|
/** Floor post-open balances after slippage. */
|
|
@@ -65,7 +51,8 @@ interface OpenStrategyPreview extends Omit<AccountProjection, "assets" | "quotas
|
|
|
65
51
|
calls: MultiCall[];
|
|
66
52
|
}
|
|
67
53
|
/**
|
|
68
|
-
*
|
|
54
|
+
* Builds the state opening a leveraged position out of wallet collateral would
|
|
55
|
+
* land in.
|
|
69
56
|
*
|
|
70
57
|
* Debt follows from the target leverage against the supplied margin
|
|
71
58
|
* (`debt = margin * (L - 1)`, `totalValue = margin * L`); the collateral and the
|
|
@@ -75,6 +62,6 @@ interface OpenStrategyPreview extends Omit<AccountProjection, "assets" | "quotas
|
|
|
75
62
|
* no operation list — the caller passes the numbers and calls straight to
|
|
76
63
|
* `sdk.accounts.openCA`.
|
|
77
64
|
*/
|
|
78
|
-
declare function
|
|
65
|
+
declare function buildOpenStrategyState(props: OpenStrategyProps): Promise<OpenStrategyState>;
|
|
79
66
|
//#endregion
|
|
80
|
-
export {
|
|
67
|
+
export { OpenStrategyProps, OpenStrategyState, buildOpenStrategyState };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Curator } from "../../../../model/curators.js";
|
|
2
|
+
import "../../../../model/index.js";
|
|
1
3
|
import { MultiCall } from "../../../types/transactions.js";
|
|
2
4
|
import { OnchainSDK } from "../../../OnchainSDK.js";
|
|
3
5
|
import { CreditAccountSlice } from "../types.js";
|
|
@@ -13,8 +15,12 @@ import { Address } from "viem";
|
|
|
13
15
|
* from their inputs, so `result.calls` pins down which ops reached the
|
|
14
16
|
* assembler and in which order.
|
|
15
17
|
*/
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Curator of the mock market: an unknown market configurator, so it carries no
|
|
20
|
+
* display name and no page — what the on-chain source answers for a
|
|
21
|
+
* configurator outside the curated table.
|
|
22
|
+
*/
|
|
23
|
+
declare const MOCK_CURATOR: Curator;
|
|
18
24
|
/**
|
|
19
25
|
* Liquidation fees of the mock suite: a 3% premium (the manager reports its
|
|
20
26
|
* complement) on top of a 1.5% protocol fee, so the discount a screen shows is
|
|
@@ -31,11 +31,14 @@ interface PathLossRate {
|
|
|
31
31
|
totalValuePriceImpact: bigint;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* The two prices only a planned walk can quote, carried by every simulation
|
|
35
|
+
* result beside its projection.
|
|
36
|
+
*
|
|
37
|
+
* A calldata preview is asked for neither: it reads a transaction that already
|
|
38
|
+
* names its amounts, and it reports what that transaction does rather than what
|
|
39
|
+
* the market charges while a form is open.
|
|
37
40
|
*/
|
|
38
|
-
interface
|
|
41
|
+
interface SimulationPrices {
|
|
39
42
|
/**
|
|
40
43
|
* What the routed legs lost to market depth. `undefined` where nothing was
|
|
41
44
|
* routed or nothing could be measured — never a manufactured zero.
|
|
@@ -44,16 +47,20 @@ interface OperationState extends AccountProjection {
|
|
|
44
47
|
/**
|
|
45
48
|
* What the position's collateral costs in the market underlying right now, in
|
|
46
49
|
* the oracle's 8-decimal fixed point — the same scale and the same pair as
|
|
47
|
-
* {@link liquidationPrice}, so a screen showing both reads
|
|
50
|
+
* {@link AccountMetrics.liquidationPrice}, so a screen showing both reads
|
|
51
|
+
* them as one pair.
|
|
48
52
|
*
|
|
49
53
|
* `null` where there is no pair to quote: an account holding zero or several
|
|
50
54
|
* non-underlying assets, or one whose collateral the oracle cannot price.
|
|
51
|
-
*
|
|
52
|
-
* Simulations only. A calldata preview is not asked for it: it reports what a
|
|
53
|
-
* transaction does, not what the market costs while a form is open.
|
|
54
55
|
*/
|
|
55
56
|
currentPrice: bigint | null;
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* What the operations leave the account at, in the shared
|
|
60
|
+
* {@link AccountProjection} vocabulary, plus the prices only a routed walk can
|
|
61
|
+
* report.
|
|
62
|
+
*/
|
|
63
|
+
interface OperationState extends AccountProjection, SimulationPrices {}
|
|
57
64
|
/**
|
|
58
65
|
* What a preview yields: the operation chain, the state it projects, and the
|
|
59
66
|
* calldata that realises it — or the reason the request is not viable.
|
|
@@ -61,7 +68,7 @@ interface OperationState extends AccountProjection {
|
|
|
61
68
|
type IntentPreviewResult = {
|
|
62
69
|
ok: true;
|
|
63
70
|
operations: AccountCalculatorOperation[];
|
|
64
|
-
|
|
71
|
+
state: OperationState;
|
|
65
72
|
calls: MultiCall[];
|
|
66
73
|
} | PreviewRefusal;
|
|
67
74
|
/** What the request recorded, and when the tail can be run. */
|
|
@@ -98,8 +105,8 @@ interface DelayedStart {
|
|
|
98
105
|
* the phantom of the in-flight redemption in its place, the debt untouched.
|
|
99
106
|
*
|
|
100
107
|
* This is the state the facade judges when the transaction lands, so it is
|
|
101
|
-
* the one the engine's guards are applied to — while the `
|
|
102
|
-
*
|
|
108
|
+
* the one the engine's guards are applied to — while the `state` beside it is
|
|
109
|
+
* where the intent ends up, tail included, which is what a caller asking
|
|
103
110
|
* "what does this do to my position" means.
|
|
104
111
|
*/
|
|
105
112
|
afterRequest: OperationState;
|
|
@@ -109,10 +116,10 @@ interface DelayedStart {
|
|
|
109
116
|
* plus what it recorded for the tail.
|
|
110
117
|
*
|
|
111
118
|
* `operations` and `calls` are the request and nothing else — that is the only
|
|
112
|
-
* transaction there is to send now. `
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
119
|
+
* transaction there is to send now. `state`, though, is where the intent ends:
|
|
120
|
+
* the account once the redemption matures, is claimed and the tail runs, since
|
|
121
|
+
* that is what the caller asked for when they asked to withdraw. The half-way
|
|
122
|
+
* state the request itself lands in is
|
|
116
123
|
* {@link DelayedStart.afterRequest}, and both are validated before either is
|
|
117
124
|
* reported.
|
|
118
125
|
*
|
|
@@ -123,7 +130,7 @@ interface DelayedStart {
|
|
|
123
130
|
type DelayedStartResult = {
|
|
124
131
|
ok: true;
|
|
125
132
|
operations: AccountCalculatorOperation[];
|
|
126
|
-
|
|
133
|
+
state: OperationState;
|
|
127
134
|
calls: MultiCall[];
|
|
128
135
|
delayed: DelayedStart;
|
|
129
136
|
} | PreviewRefusal;
|
|
@@ -388,4 +395,4 @@ type FinishIntentProps = StartIntentProps & {
|
|
|
388
395
|
claimable: ClaimableWithdrawal;
|
|
389
396
|
};
|
|
390
397
|
//#endregion
|
|
391
|
-
export { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent };
|
|
398
|
+
export { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, SimulationPrices, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent };
|
|
@@ -14,7 +14,6 @@ declare class LiquidationsService extends SDKConstruct {
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns all liquidatable credit accounts: accounts with health factor
|
|
16
16
|
* below 1 plus accounts of expired credit managers with outstanding debt.
|
|
17
|
-
* Accounts whose collateral computation failed are excluded.
|
|
18
17
|
**/
|
|
19
18
|
getLiquidatableAccounts(props?: GetLiquidatableAccountsProps): Promise<LiquidatableAccount[]>;
|
|
20
19
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CreditAccountData } from "../../base/types.js";
|
|
2
|
+
import { Address } from "viem";
|
|
3
|
+
//#region src/onchain/accounts/liquidations/skipLiquidatableAccount.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether a credit account should be dropped from the liquidatable list:
|
|
6
|
+
* collateral computation failed, or it holds a Mellow withdrawal phantom
|
|
7
|
+
* token above dust (no liquidation subcompressor for that type).
|
|
8
|
+
**/
|
|
9
|
+
declare function skipLiquidatableAccount(account: Pick<CreditAccountData, "success" | "tokens">, getContractType: (token: Address) => string | undefined): boolean;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { skipLiquidatableAccount };
|