@gearbox-protocol/sdk 17.13.0-next.6 → 17.13.0-next.7
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/analytics.schema.js +71 -7
- package/dist/cjs/model/index.js +5 -1
- package/dist/cjs/model/liquidations.schema.js +4 -3
- package/dist/cjs/model/opportunities.schema.js +1 -1
- package/dist/cjs/model/positions.schema.js +3 -0
- package/dist/cjs/offchain/analytics/OffchainAnalyticsPositions.js +8 -0
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +15 -3
- package/dist/cjs/onchain/pools/PoolService.js +1 -0
- package/dist/cjs/onchain/positions/PositionsService.js +1 -0
- package/dist/cjs/onchain/validation/bundles/checkLiquidationEligibility.js +1 -0
- package/dist/cjs/onchain/validation/checks/checkPartiallyLiquidatable.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/analytics.schema.js +69 -9
- package/dist/esm/model/index.js +3 -3
- package/dist/esm/model/liquidations.schema.js +4 -3
- package/dist/esm/model/opportunities.schema.js +1 -1
- package/dist/esm/model/positions.schema.js +3 -0
- package/dist/esm/offchain/analytics/OffchainAnalyticsPositions.js +9 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +16 -4
- 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/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/pools/PoolService.js +1 -0
- package/dist/esm/onchain/positions/PositionsService.js +1 -0
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/bundles/checkLiquidationEligibility.js +1 -0
- package/dist/esm/onchain/validation/checks/checkPartiallyLiquidatable.js +1 -1
- package/dist/types/model/analytics.d.ts +56 -2
- package/dist/types/model/analytics.schema.d.ts +169 -25
- package/dist/types/model/index.d.ts +4 -4
- package/dist/types/model/liquidations.d.ts +14 -5
- package/dist/types/model/liquidations.schema.d.ts +3 -1
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/model/positions.d.ts +5 -0
- package/dist/types/model/positions.schema.d.ts +80 -0
- package/dist/types/offchain/analytics/OffchainAnalyticsPositions.d.ts +4 -1
- package/dist/types/offchain/analytics/types.d.ts +14 -1
- package/dist/types/onchain/validation/checks/checkPartiallyLiquidatable.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
19
20
|
import "../../market/rwa/securitize/index.js";
|
|
20
21
|
import "../../market/index.js";
|
|
21
22
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
import { optimalPartialLiquidation, partialLiquidationParams } from "./partialLiquidation.js";
|
|
24
24
|
import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
|
|
25
25
|
//#region src/onchain/accounts/liquidations/LiquidationsService.ts
|
|
@@ -70,7 +70,8 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
70
70
|
isCreditAccountFrozen: data.isCreditAccountFrozen,
|
|
71
71
|
kycProtocol: data.kycProtocol || void 0,
|
|
72
72
|
kycToken: hexEq(data.kycToken, "0x0000000000000000000000000000000000000000") ? void 0 : this.sdk.tokensMeta.getToken(data.kycToken),
|
|
73
|
-
approve: this.#liquidationApproval(data, suite, priceOracle)
|
|
73
|
+
approve: this.#liquidationApproval(data, suite, priceOracle),
|
|
74
|
+
isPartial: false
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
@@ -151,7 +152,8 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
151
152
|
spender: suite.creditManager.address,
|
|
152
153
|
...priceOracle.toTokenAmount(underlying, repaidAmount * (PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / PERCENTAGE_FACTOR)
|
|
153
154
|
},
|
|
154
|
-
isPartiallyLiquidatable
|
|
155
|
+
isPartiallyLiquidatable,
|
|
156
|
+
isPartial: true
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
159
|
/**
|
|
@@ -418,9 +420,19 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
418
420
|
},
|
|
419
421
|
isDelayed: ca.tokens.some((t) => t.balance > 10n && this.#isWithdrawalPhantom(t.token)),
|
|
420
422
|
paused: suite.creditFacade.isPaused,
|
|
421
|
-
rwa: market.rwa
|
|
423
|
+
rwa: market.rwa,
|
|
424
|
+
isPartiallyLiquidatable: this.#isPartiallyLiquidatable(ca, suite)
|
|
422
425
|
};
|
|
423
426
|
}
|
|
427
|
+
#isPartiallyLiquidatable(ca, suite) {
|
|
428
|
+
if (suite.market.rwa) return false;
|
|
429
|
+
try {
|
|
430
|
+
return this.#getPartialLiquidationParams(ca, suite, {}).isPartiallyLiquidatable;
|
|
431
|
+
} catch (e) {
|
|
432
|
+
this.logger?.debug(e, `credit account ${this.labelAddress(ca.creditAccount)} cannot be partially liquidated`);
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
424
436
|
#isWithdrawalPhantom(token) {
|
|
425
437
|
return !!this.sdk.withdrawalCompressor?.getWithdrawalSourceToken(token);
|
|
426
438
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
6
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
6
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
7
7
|
//#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
8
8
|
const abi = iRedemptionLoggerV310Abi;
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
4
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
5
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
6
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
7
|
import { getAssetType } from "../chain/chains.js";
|
|
5
8
|
import { formatBN } from "../utils/formatter.js";
|
|
6
9
|
import "../utils/index.js";
|
|
7
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { SdkRWADataNotLoadedError } from "../core/errors.js";
|
|
11
11
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
12
12
|
import { decodeAbiParameters } from "viem";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
2
1
|
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
2
|
+
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
3
3
|
//#region src/onchain/market/adapters/contracts/AccountMigratorAdapterContract.ts
|
|
4
4
|
const abi = accountMigratorAbi;
|
|
5
5
|
const protocolAbi = accountMigratorAbi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
1
2
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
2
3
|
import "../../../base/index.js";
|
|
3
|
-
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
4
4
|
import { iERC4626Abi } from "../abi/targetContractAbi.js";
|
|
5
5
|
import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
|
|
6
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
@@ -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,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
4
|
import { RAY } from "../../constants/math.js";
|
|
@@ -7,7 +8,6 @@ import "../../utils/index.js";
|
|
|
7
8
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
8
9
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
9
10
|
import "../../base/index.js";
|
|
10
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
11
11
|
//#region src/onchain/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
13
13
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
1
2
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
2
3
|
import "../../utils/index.js";
|
|
3
|
-
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
4
4
|
import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
|
|
5
5
|
import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
|
|
6
6
|
import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/onchain/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/market/zapper/ZapperContract.ts
|
|
7
7
|
/**
|
|
8
8
|
* Base contract for every Gearbox zapper. Specialized zappers (e.g.
|
|
@@ -397,6 +397,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
397
397
|
return {
|
|
398
398
|
kind: "pool",
|
|
399
399
|
name: this.sdk.tokensMeta.mustGetToken(pool.address).name,
|
|
400
|
+
curator: market.curator,
|
|
400
401
|
chainId: this.chainId,
|
|
401
402
|
pool: pool.address,
|
|
402
403
|
underlyingToken: market.underlyingToken,
|
|
@@ -314,6 +314,7 @@ var PositionsService = class extends SDKConstruct {
|
|
|
314
314
|
creditAccount: ca.creditAccount,
|
|
315
315
|
underlyingToken: token,
|
|
316
316
|
name: suite.accountStrategyName(ca.creditAccount),
|
|
317
|
+
curator: market.curator,
|
|
317
318
|
targetCollateral: suite.accountTargetCollateral(ca.creditAccount),
|
|
318
319
|
leverage: calcPositionLeverage(totalValue, totalDebtValue),
|
|
319
320
|
borrowApy: calcBorrowApy(pool.baseInterestRate, suite.creditManager.feeInterest),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
1
|
import { ierc20Abi } from "../../../abi/iERC20.js";
|
|
2
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
3
|
+
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/preview/preview/previewPoolPositionOperation.ts
|
|
7
7
|
function previewRead(operation) {
|
|
8
8
|
switch (operation.operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { generateCastTraceCall } from "./cast.js";
|
|
3
2
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
import { generateCastTraceCall } from "./cast.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -18,6 +18,7 @@ function checkLiquidationEligibility(input) {
|
|
|
18
18
|
creditAccount: details.creditAccount
|
|
19
19
|
}),
|
|
20
20
|
...checkPartiallyLiquidatable({
|
|
21
|
+
isPartial: details.isPartial,
|
|
21
22
|
partiallyLiquidatable: details.isPartiallyLiquidatable,
|
|
22
23
|
creditAccount: details.creditAccount
|
|
23
24
|
}),
|
|
@@ -6,7 +6,7 @@ import "../../../model/index.js";
|
|
|
6
6
|
* leaving less than the minimum debt is refused.
|
|
7
7
|
*/
|
|
8
8
|
function checkPartiallyLiquidatable(args) {
|
|
9
|
-
return args.
|
|
9
|
+
return args.isPartial && !args.partiallyLiquidatable ? [partialLiquidationImpossible(args.creditAccount)] : [];
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
export { checkPartiallyLiquidatable };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ChainId, Token } from "./primitives.js";
|
|
1
2
|
import { ChartRange, ProtocolChartMetric } from "./charts.js";
|
|
2
|
-
import {
|
|
3
|
+
import { CuratorName } from "./curators.js";
|
|
4
|
+
import { ChainScopedFilter, Filterable } from "./filters.js";
|
|
3
5
|
import { PoolPosition, PositionFilter, StrategyPosition } from "./positions.js";
|
|
4
6
|
import { LiquidationPosition } from "./liquidations.js";
|
|
5
7
|
import { Address } from "viem";
|
|
@@ -24,17 +26,50 @@ export interface AnalyticsPositionOwner {
|
|
|
24
26
|
borrower: Address;
|
|
25
27
|
}
|
|
26
28
|
/** Fields the protocol-wide position list can order by. */
|
|
27
|
-
export type AnalyticsPositionSortField = "netValueUsd" | "totalValueUsd" | "totalDebtUsd" | "pnlUsd" | "
|
|
29
|
+
export type AnalyticsPositionSortField = "netValueUsd" | "totalValueUsd" | "totalDebtUsd" | "pnlUsd" | "healthFactor";
|
|
28
30
|
/** Direction of one analytics list ordering. */
|
|
29
31
|
export type AnalyticsSortDirection = "asc" | "desc";
|
|
32
|
+
/** A contract selected on exactly one chain by an analytics filter. */
|
|
33
|
+
export interface AnalyticsContractRef {
|
|
34
|
+
/** Chain the contract lives on. */
|
|
35
|
+
chainId: ChainId;
|
|
36
|
+
/** Address of the pool, credit manager or token contract. */
|
|
37
|
+
address: Address;
|
|
38
|
+
}
|
|
39
|
+
/** A pool or credit manager choice with a display name for a filter UI. */
|
|
40
|
+
export interface AnalyticsContractOption extends AnalyticsContractRef {
|
|
41
|
+
/** Human-readable pool or credit manager name. */
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
30
44
|
/**
|
|
31
45
|
* Filtering, ordering and offset pagination of the protocol-wide position
|
|
32
46
|
* list. Omitted position criteria have the same meaning as they do on
|
|
33
47
|
* {@link PositionFilter}.
|
|
48
|
+
*
|
|
49
|
+
* Pool, credit manager, balance asset and curator filters accept one value or
|
|
50
|
+
* a list. Values within a list combine with OR; different filters combine with
|
|
51
|
+
* AND. An empty list matches no positions.
|
|
52
|
+
*
|
|
53
|
+
* Pool, credit manager and asset references match both chain and address,
|
|
54
|
+
* within the chains this SDK covers and any further restriction from
|
|
55
|
+
* `chainIds`. Curator names match across the selected chains.
|
|
34
56
|
**/
|
|
35
57
|
export interface AnalyticsPositionListOptions extends PositionFilter {
|
|
36
58
|
/** Keep only positions owned by this wallet. */
|
|
37
59
|
borrower?: Address;
|
|
60
|
+
/** Keep only positions associated with the given pool or pools. */
|
|
61
|
+
pool?: AnalyticsContractRef | readonly AnalyticsContractRef[];
|
|
62
|
+
/** Keep only positions associated with the given credit manager or managers. */
|
|
63
|
+
creditManager?: AnalyticsContractRef | readonly AnalyticsContractRef[];
|
|
64
|
+
/**
|
|
65
|
+
* Keep only positions holding a positive balance of any selected token.
|
|
66
|
+
* For credit accounts, match the token of each
|
|
67
|
+
* {@link PositionCollateral.collateral}, including underlying balances.
|
|
68
|
+
* Phantom tokens match their own address as reported in the balance.
|
|
69
|
+
*/
|
|
70
|
+
asset?: AnalyticsContractRef | readonly AnalyticsContractRef[];
|
|
71
|
+
/** Keep only positions in markets managed by the named curator or curators. */
|
|
72
|
+
curator?: Filterable<CuratorName | readonly CuratorName[]>;
|
|
38
73
|
/**
|
|
39
74
|
* Field to order by. Values that do not apply to a position kind, and USD
|
|
40
75
|
* values that cannot be priced, are always placed after concrete values.
|
|
@@ -60,6 +95,25 @@ export interface AnalyticsPositionPage {
|
|
|
60
95
|
/** Effective maximum number of rows returned. */
|
|
61
96
|
limit: number;
|
|
62
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Every selectable filter value across current positions on the requested
|
|
100
|
+
* chains, collected before pagination. Contract and token choices are distinct
|
|
101
|
+
* by chain and address; curator names are distinct across the selected chains.
|
|
102
|
+
**/
|
|
103
|
+
export interface AnalyticsPositionFilterOptions {
|
|
104
|
+
/** Pools associated with positions, including pools their accounts borrow from. */
|
|
105
|
+
pools: AnalyticsContractOption[];
|
|
106
|
+
/** Credit managers associated with current credit-account positions. */
|
|
107
|
+
creditManagers: AnalyticsContractOption[];
|
|
108
|
+
/**
|
|
109
|
+
* Tokens held with a positive balance, using the same rule as the `asset`
|
|
110
|
+
* filter. Includes underlying balances and phantom tokens at their own
|
|
111
|
+
* reported addresses, with metadata to display each choice.
|
|
112
|
+
*/
|
|
113
|
+
assets: Token[];
|
|
114
|
+
/** Known names of the curators of the positions' markets. */
|
|
115
|
+
curators: CuratorName[];
|
|
116
|
+
}
|
|
63
117
|
/**
|
|
64
118
|
* What one protocol-wide chart read asks for.
|
|
65
119
|
*
|
|
@@ -7,12 +7,7 @@ export declare const ANALYTICS_POSITIONS_DEFAULT_LIMIT = 25;
|
|
|
7
7
|
export declare const ANALYTICS_POSITIONS_MAX_LIMIT = 100;
|
|
8
8
|
/** {@link AnalyticsPositionSortField} */
|
|
9
9
|
export declare const analyticsPositionSortFieldSchema: z.ZodEnum<{
|
|
10
|
-
apy: "apy";
|
|
11
|
-
borrower: "borrower";
|
|
12
|
-
chainId: "chainId";
|
|
13
10
|
healthFactor: "healthFactor";
|
|
14
|
-
leverage: "leverage";
|
|
15
|
-
name: "name";
|
|
16
11
|
netValueUsd: "netValueUsd";
|
|
17
12
|
pnlUsd: "pnlUsd";
|
|
18
13
|
totalDebtUsd: "totalDebtUsd";
|
|
@@ -23,22 +18,74 @@ export declare const analyticsSortDirectionSchema: z.ZodEnum<{
|
|
|
23
18
|
asc: "asc";
|
|
24
19
|
desc: "desc";
|
|
25
20
|
}>;
|
|
21
|
+
/** {@link AnalyticsContractRef} */
|
|
22
|
+
export declare const analyticsContractRefSchema: z.ZodObject<{
|
|
23
|
+
chainId: z.ZodNumber;
|
|
24
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
26
|
/** {@link AnalyticsPosition} */
|
|
27
27
|
export declare const analyticsPositionSchema: z.ZodType<AnalyticsPosition>;
|
|
28
28
|
/** {@link AnalyticsPositionListOptions} */
|
|
29
29
|
export declare const analyticsPositionListOptionsSchema: z.ZodObject<{
|
|
30
30
|
borrower: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
31
|
+
pool: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
32
|
+
chainId: z.ZodNumber;
|
|
33
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
34
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
35
|
+
chainId: z.ZodNumber;
|
|
36
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
37
|
+
}, z.core.$strip>>>]>>;
|
|
38
|
+
creditManager: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
39
|
+
chainId: z.ZodNumber;
|
|
40
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
41
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
42
|
+
chainId: z.ZodNumber;
|
|
43
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
44
|
+
}, z.core.$strip>>>]>>;
|
|
45
|
+
asset: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
46
|
+
chainId: z.ZodNumber;
|
|
47
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
48
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
49
|
+
chainId: z.ZodNumber;
|
|
50
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
51
|
+
}, z.core.$strip>>>]>>;
|
|
52
|
+
curator: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodEnum<{
|
|
53
|
+
"Chaos Labs": "Chaos Labs";
|
|
54
|
+
"Gami Labs": "Gami Labs";
|
|
55
|
+
Hyperithm: "Hyperithm";
|
|
56
|
+
"Invariant Group": "Invariant Group";
|
|
57
|
+
K3: "K3";
|
|
58
|
+
KPK: "KPK";
|
|
59
|
+
"M11 Credit": "M11 Credit";
|
|
60
|
+
Re7: "Re7";
|
|
61
|
+
Securitize: "Securitize";
|
|
62
|
+
TelosC: "TelosC";
|
|
63
|
+
"Testnet Curator": "Testnet Curator";
|
|
64
|
+
Tulipa: "Tulipa";
|
|
65
|
+
UltraYield: "UltraYield";
|
|
66
|
+
cp0x: "cp0x";
|
|
67
|
+
}>, z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
68
|
+
"Chaos Labs": "Chaos Labs";
|
|
69
|
+
"Gami Labs": "Gami Labs";
|
|
70
|
+
Hyperithm: "Hyperithm";
|
|
71
|
+
"Invariant Group": "Invariant Group";
|
|
72
|
+
K3: "K3";
|
|
73
|
+
KPK: "KPK";
|
|
74
|
+
"M11 Credit": "M11 Credit";
|
|
75
|
+
Re7: "Re7";
|
|
76
|
+
Securitize: "Securitize";
|
|
77
|
+
TelosC: "TelosC";
|
|
78
|
+
"Testnet Curator": "Testnet Curator";
|
|
79
|
+
Tulipa: "Tulipa";
|
|
80
|
+
UltraYield: "UltraYield";
|
|
81
|
+
cp0x: "cp0x";
|
|
82
|
+
}>>>]>, z.ZodLiteral<"all">]>>;
|
|
31
83
|
kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
|
|
32
84
|
isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
|
|
33
85
|
chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
34
86
|
underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
|
|
35
87
|
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
36
|
-
apy: "apy";
|
|
37
|
-
borrower: "borrower";
|
|
38
|
-
chainId: "chainId";
|
|
39
88
|
healthFactor: "healthFactor";
|
|
40
|
-
leverage: "leverage";
|
|
41
|
-
name: "name";
|
|
42
89
|
netValueUsd: "netValueUsd";
|
|
43
90
|
pnlUsd: "pnlUsd";
|
|
44
91
|
totalDebtUsd: "totalDebtUsd";
|
|
@@ -53,9 +100,16 @@ export declare const analyticsPositionListOptionsSchema: z.ZodObject<{
|
|
|
53
100
|
}, z.core.$strip>;
|
|
54
101
|
/**
|
|
55
102
|
* {@link AnalyticsPositionListOptions} as URL query parameters.
|
|
103
|
+
* Pool, credit manager and asset choices are comma-separated `chainId:address`
|
|
104
|
+
* references; curator choices are comma-separated names. An empty string
|
|
105
|
+
* carries an empty list rather than an unrestricted condition.
|
|
56
106
|
**/
|
|
57
107
|
export declare const analyticsPositionListQueryParamsSchema: z.ZodObject<{
|
|
58
108
|
borrower: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
|
|
109
|
+
pool: z.ZodOptional<z.ZodString>;
|
|
110
|
+
creditManager: z.ZodOptional<z.ZodString>;
|
|
111
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
112
|
+
curator: z.ZodOptional<z.ZodString>;
|
|
59
113
|
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
|
|
60
114
|
isZeroDebt: z.ZodOptional<z.ZodEnum<{
|
|
61
115
|
false: "false";
|
|
@@ -64,12 +118,7 @@ export declare const analyticsPositionListQueryParamsSchema: z.ZodObject<{
|
|
|
64
118
|
chainIds: z.ZodOptional<z.ZodString>;
|
|
65
119
|
underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
66
120
|
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
67
|
-
apy: "apy";
|
|
68
|
-
borrower: "borrower";
|
|
69
|
-
chainId: "chainId";
|
|
70
121
|
healthFactor: "healthFactor";
|
|
71
|
-
leverage: "leverage";
|
|
72
|
-
name: "name";
|
|
73
122
|
netValueUsd: "netValueUsd";
|
|
74
123
|
pnlUsd: "pnlUsd";
|
|
75
124
|
totalDebtUsd: "totalDebtUsd";
|
|
@@ -88,6 +137,10 @@ export declare const analyticsPositionListQueryParamsSchema: z.ZodObject<{
|
|
|
88
137
|
**/
|
|
89
138
|
export declare const analyticsPositionListQuerySchema: z.ZodCodec<z.ZodObject<{
|
|
90
139
|
borrower: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
|
|
140
|
+
pool: z.ZodOptional<z.ZodString>;
|
|
141
|
+
creditManager: z.ZodOptional<z.ZodString>;
|
|
142
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
143
|
+
curator: z.ZodOptional<z.ZodString>;
|
|
91
144
|
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
|
|
92
145
|
isZeroDebt: z.ZodOptional<z.ZodEnum<{
|
|
93
146
|
false: "false";
|
|
@@ -96,12 +149,7 @@ export declare const analyticsPositionListQuerySchema: z.ZodCodec<z.ZodObject<{
|
|
|
96
149
|
chainIds: z.ZodOptional<z.ZodString>;
|
|
97
150
|
underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
98
151
|
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
99
|
-
apy: "apy";
|
|
100
|
-
borrower: "borrower";
|
|
101
|
-
chainId: "chainId";
|
|
102
152
|
healthFactor: "healthFactor";
|
|
103
|
-
leverage: "leverage";
|
|
104
|
-
name: "name";
|
|
105
153
|
netValueUsd: "netValueUsd";
|
|
106
154
|
pnlUsd: "pnlUsd";
|
|
107
155
|
totalDebtUsd: "totalDebtUsd";
|
|
@@ -115,17 +163,64 @@ export declare const analyticsPositionListQuerySchema: z.ZodCodec<z.ZodObject<{
|
|
|
115
163
|
limit: z.ZodOptional<z.ZodString>;
|
|
116
164
|
}, z.core.$strip>, z.ZodObject<{
|
|
117
165
|
borrower: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
166
|
+
pool: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
167
|
+
chainId: z.ZodNumber;
|
|
168
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
169
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
170
|
+
chainId: z.ZodNumber;
|
|
171
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
172
|
+
}, z.core.$strip>>>]>>;
|
|
173
|
+
creditManager: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
174
|
+
chainId: z.ZodNumber;
|
|
175
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
176
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
177
|
+
chainId: z.ZodNumber;
|
|
178
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
179
|
+
}, z.core.$strip>>>]>>;
|
|
180
|
+
asset: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
181
|
+
chainId: z.ZodNumber;
|
|
182
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
183
|
+
}, z.core.$strip>, z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
184
|
+
chainId: z.ZodNumber;
|
|
185
|
+
address: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
186
|
+
}, z.core.$strip>>>]>>;
|
|
187
|
+
curator: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodEnum<{
|
|
188
|
+
"Chaos Labs": "Chaos Labs";
|
|
189
|
+
"Gami Labs": "Gami Labs";
|
|
190
|
+
Hyperithm: "Hyperithm";
|
|
191
|
+
"Invariant Group": "Invariant Group";
|
|
192
|
+
K3: "K3";
|
|
193
|
+
KPK: "KPK";
|
|
194
|
+
"M11 Credit": "M11 Credit";
|
|
195
|
+
Re7: "Re7";
|
|
196
|
+
Securitize: "Securitize";
|
|
197
|
+
TelosC: "TelosC";
|
|
198
|
+
"Testnet Curator": "Testnet Curator";
|
|
199
|
+
Tulipa: "Tulipa";
|
|
200
|
+
UltraYield: "UltraYield";
|
|
201
|
+
cp0x: "cp0x";
|
|
202
|
+
}>, z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
203
|
+
"Chaos Labs": "Chaos Labs";
|
|
204
|
+
"Gami Labs": "Gami Labs";
|
|
205
|
+
Hyperithm: "Hyperithm";
|
|
206
|
+
"Invariant Group": "Invariant Group";
|
|
207
|
+
K3: "K3";
|
|
208
|
+
KPK: "KPK";
|
|
209
|
+
"M11 Credit": "M11 Credit";
|
|
210
|
+
Re7: "Re7";
|
|
211
|
+
Securitize: "Securitize";
|
|
212
|
+
TelosC: "TelosC";
|
|
213
|
+
"Testnet Curator": "Testnet Curator";
|
|
214
|
+
Tulipa: "Tulipa";
|
|
215
|
+
UltraYield: "UltraYield";
|
|
216
|
+
cp0x: "cp0x";
|
|
217
|
+
}>>>]>, z.ZodLiteral<"all">]>>;
|
|
118
218
|
kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
|
|
119
219
|
isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
|
|
120
220
|
chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
121
221
|
underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
|
|
122
222
|
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
123
|
-
apy: "apy";
|
|
124
|
-
borrower: "borrower";
|
|
125
|
-
chainId: "chainId";
|
|
126
223
|
healthFactor: "healthFactor";
|
|
127
|
-
leverage: "leverage";
|
|
128
|
-
name: "name";
|
|
129
224
|
netValueUsd: "netValueUsd";
|
|
130
225
|
pnlUsd: "pnlUsd";
|
|
131
226
|
totalDebtUsd: "totalDebtUsd";
|
|
@@ -145,6 +240,55 @@ export declare const analyticsPositionPageSchema: z.ZodObject<{
|
|
|
145
240
|
offset: z.ZodNumber;
|
|
146
241
|
limit: z.ZodNumber;
|
|
147
242
|
}, z.core.$strip>;
|
|
243
|
+
/** {@link AnalyticsContractOption} */
|
|
244
|
+
export declare const analyticsContractOptionSchema: z.ZodObject<{
|
|
245
|
+
chainId: z.ZodNumber;
|
|
246
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
247
|
+
name: z.ZodString;
|
|
248
|
+
}, z.core.$strip>;
|
|
249
|
+
/** {@link AnalyticsPositionFilterOptions} */
|
|
250
|
+
export declare const analyticsPositionFilterOptionsSchema: z.ZodObject<{
|
|
251
|
+
pools: z.ZodArray<z.ZodObject<{
|
|
252
|
+
chainId: z.ZodNumber;
|
|
253
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
254
|
+
name: z.ZodString;
|
|
255
|
+
}, z.core.$strip>>;
|
|
256
|
+
creditManagers: z.ZodArray<z.ZodObject<{
|
|
257
|
+
chainId: z.ZodNumber;
|
|
258
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
259
|
+
name: z.ZodString;
|
|
260
|
+
}, z.core.$strip>>;
|
|
261
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
262
|
+
chainId: z.ZodNumber;
|
|
263
|
+
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
264
|
+
symbol: z.ZodString;
|
|
265
|
+
name: z.ZodString;
|
|
266
|
+
decimals: z.ZodNumber;
|
|
267
|
+
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
268
|
+
}, z.core.$strip>>;
|
|
269
|
+
curators: z.ZodArray<z.ZodEnum<{
|
|
270
|
+
"Chaos Labs": "Chaos Labs";
|
|
271
|
+
"Gami Labs": "Gami Labs";
|
|
272
|
+
Hyperithm: "Hyperithm";
|
|
273
|
+
"Invariant Group": "Invariant Group";
|
|
274
|
+
K3: "K3";
|
|
275
|
+
KPK: "KPK";
|
|
276
|
+
"M11 Credit": "M11 Credit";
|
|
277
|
+
Re7: "Re7";
|
|
278
|
+
Securitize: "Securitize";
|
|
279
|
+
TelosC: "TelosC";
|
|
280
|
+
"Testnet Curator": "Testnet Curator";
|
|
281
|
+
Tulipa: "Tulipa";
|
|
282
|
+
UltraYield: "UltraYield";
|
|
283
|
+
cp0x: "cp0x";
|
|
284
|
+
}>>;
|
|
285
|
+
}, z.core.$strip>;
|
|
286
|
+
/** Chain scope of a filter-options read, shared by the client and backend. */
|
|
287
|
+
export declare const analyticsPositionFilterOptionsQuerySchema: z.ZodCodec<z.ZodObject<{
|
|
288
|
+
chainIds: z.ZodOptional<z.ZodString>;
|
|
289
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
290
|
+
chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
291
|
+
}, z.core.$strip>>;
|
|
148
292
|
/**
|
|
149
293
|
* {@link AnalyticsChartQuery}
|
|
150
294
|
*
|