@gearbox-protocol/sdk 14.12.0-next.80 → 14.12.0-next.81
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/index.js +8 -0
- package/dist/cjs/model/response.js +1 -0
- package/dist/cjs/model/response.schema.js +61 -0
- package/dist/cjs/offchain/AbstractOffchainNamespace.js +3 -3
- package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +6 -6
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +26 -20
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +3 -2
- package/dist/cjs/sdk/market/rwa/RWARegistry.js +4 -2
- package/dist/cjs/sdk/pools/PoolService.js +2 -1
- package/dist/cjs/sdk/positions/PositionsService.js +11 -4
- package/dist/esm/model/index.js +3 -1
- package/dist/esm/model/response.js +1 -0
- package/dist/esm/model/response.schema.js +55 -0
- package/dist/esm/offchain/AbstractOffchainNamespace.js +3 -3
- package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +6 -6
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +26 -20
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +3 -2
- package/dist/esm/sdk/market/rwa/RWARegistry.js +4 -2
- package/dist/esm/sdk/pools/PoolService.js +2 -1
- package/dist/esm/sdk/positions/PositionsService.js +11 -4
- package/dist/types/model/index.d.ts +3 -1
- package/dist/types/model/response.d.ts +104 -0
- package/dist/types/model/response.schema.d.ts +89 -0
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +3 -3
- package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +4 -0
- package/dist/types/sdk/accounts/index.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/types.d.ts +28 -6
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +4 -4
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +2 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +2 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +26 -4
- package/dist/types/sdk/index.d.ts +4 -4
- package/dist/types/sdk/market/rwa/RWARegistry.d.ts +2 -1
- package/dist/types/sdk/pools/types.d.ts +4 -0
- package/dist/types/sdk/positions/MultichainPositionsService.d.ts +1 -1
- package/dist/types/sdk/positions/index.d.ts +2 -2
- package/dist/types/sdk/positions/types.d.ts +14 -5
- package/dist/types/sdk/types/index.d.ts +2 -2
- package/dist/types/sdk/types/multichain.d.ts +16 -1
- package/package.json +1 -1
|
@@ -32,13 +32,13 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
32
32
|
* Accounts whose collateral computation failed are excluded.
|
|
33
33
|
**/
|
|
34
34
|
async getLiquidatableAccounts(props) {
|
|
35
|
-
await this.sdk.withdrawalCompressor?.loadWithdrawableAssets();
|
|
35
|
+
await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(void 0, props?.blockNumber);
|
|
36
36
|
const unhealthy = await this.sdk.accounts.getCreditAccounts({
|
|
37
37
|
maxHealthFactor: WAD - 1n,
|
|
38
38
|
includeZeroDebt: false
|
|
39
|
-
});
|
|
39
|
+
}, props?.blockNumber);
|
|
40
40
|
const seen = new AddressSet(unhealthy.map((ca) => ca.creditAccount));
|
|
41
|
-
let expired = await this.#getExpiredCreditAccounts();
|
|
41
|
+
let expired = await this.#getExpiredCreditAccounts(props?.blockNumber);
|
|
42
42
|
expired = expired.filter((ca) => !seen.has(ca.creditAccount));
|
|
43
43
|
return [...unhealthy, ...expired].flatMap((ca) => {
|
|
44
44
|
if (!ca.success) {
|
|
@@ -55,13 +55,13 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
55
55
|
* @throws When the account is not found or its collateral computation fails.
|
|
56
56
|
**/
|
|
57
57
|
async getLiquidationDetails(props) {
|
|
58
|
-
const { creditAccount, liquidator, ignoreReservePrices } = props;
|
|
59
|
-
const ca = await this.#getCreditAccountData(creditAccount);
|
|
58
|
+
const { creditAccount, liquidator, ignoreReservePrices, blockNumber } = props;
|
|
59
|
+
const ca = await this.#getCreditAccountData(creditAccount, blockNumber);
|
|
60
60
|
const suite = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
61
61
|
const { priceOracle } = suite.market;
|
|
62
|
-
await this.sdk.withdrawalCompressor?.loadWithdrawableAssets();
|
|
62
|
+
await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(void 0, blockNumber);
|
|
63
63
|
const account = this.#buildAccount(ca, suite);
|
|
64
|
-
const data = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices);
|
|
64
|
+
const data = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices, blockNumber);
|
|
65
65
|
return {
|
|
66
66
|
...account,
|
|
67
67
|
repaymentAmount: priceOracle.toTokenAmount(hexEq(data.requiredToken, "0x0000000000000000000000000000000000000000") ? account.totalValue.token.address : data.requiredToken, data.requiredAmount),
|
|
@@ -79,9 +79,9 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
79
79
|
* the debt from own funds and receiving the collateral from the credit account.
|
|
80
80
|
**/
|
|
81
81
|
async buildLiquidationTx(props) {
|
|
82
|
-
const { creditAccount, liquidator, ignoreReservePrices } = props;
|
|
83
|
-
const ca = await this.#getCreditAccountData(creditAccount);
|
|
84
|
-
const { liquidationCall } = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices);
|
|
82
|
+
const { creditAccount, liquidator, ignoreReservePrices, blockNumber } = props;
|
|
83
|
+
const ca = await this.#getCreditAccountData(creditAccount, blockNumber);
|
|
84
|
+
const { liquidationCall } = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices, blockNumber);
|
|
85
85
|
this.logger?.debug(`built tx to liquidate credit account ${this.labelAddress(creditAccount)} to ${this.labelAddress(liquidator)}`);
|
|
86
86
|
return {
|
|
87
87
|
to: liquidationCall.target,
|
|
@@ -96,9 +96,13 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
96
96
|
async getLiquidationPositions(props) {
|
|
97
97
|
const compressor = this.sdk.withdrawalCompressor;
|
|
98
98
|
if (!compressor) return [];
|
|
99
|
-
await compressor.loadWithdrawableAssets();
|
|
99
|
+
await compressor.loadWithdrawableAssets(void 0, props.blockNumber);
|
|
100
100
|
const phantomTokens = new AddressSet(compressor.getWithdrawableAssets().map((a) => a.withdrawalPhantomToken));
|
|
101
|
-
const { claimable, pending } = await compressor.getExternalAccountCurrentWithdrawals(
|
|
101
|
+
const { claimable, pending } = await compressor.getExternalAccountCurrentWithdrawals({
|
|
102
|
+
account: props.liquidator,
|
|
103
|
+
withdrawalTokens: phantomTokens.asArray(),
|
|
104
|
+
blockNumber: props.blockNumber
|
|
105
|
+
});
|
|
102
106
|
return [...claimable.map((w) => ({
|
|
103
107
|
...this.#liquidationPosition(w.token, w.outputs),
|
|
104
108
|
claimTx: this.#claimTx(w.claimCalls, w.token),
|
|
@@ -114,7 +118,7 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
114
118
|
* deployed for the markets of the chain and registers them in the SDK
|
|
115
119
|
* contracts register.
|
|
116
120
|
**/
|
|
117
|
-
async loadRWALiquidators() {
|
|
121
|
+
async loadRWALiquidators(props) {
|
|
118
122
|
const configurators = this.sdk.marketRegister.marketConfigurators;
|
|
119
123
|
if (configurators.length === 0) return;
|
|
120
124
|
const resp = await this.client.multicall({
|
|
@@ -125,7 +129,8 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
125
129
|
args: [mc.address]
|
|
126
130
|
})),
|
|
127
131
|
allowFailure: false,
|
|
128
|
-
batchSize: 0
|
|
132
|
+
batchSize: 0,
|
|
133
|
+
blockNumber: props?.blockNumber
|
|
129
134
|
});
|
|
130
135
|
for (const info of resp.flat()) this.#createRWALiquidator(info);
|
|
131
136
|
}
|
|
@@ -211,13 +216,13 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
211
216
|
...priceOracle.toTokenAmount(requiredToken, requiredAmount * (PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / PERCENTAGE_FACTOR)
|
|
212
217
|
};
|
|
213
218
|
}
|
|
214
|
-
async #getCreditAccountData(creditAccount) {
|
|
215
|
-
const ca = await this.sdk.accounts.getCreditAccountData(creditAccount);
|
|
219
|
+
async #getCreditAccountData(creditAccount, blockNumber) {
|
|
220
|
+
const ca = await this.sdk.accounts.getCreditAccountData(creditAccount, blockNumber);
|
|
216
221
|
if (!ca) throw new Error(`credit account ${creditAccount} not found`);
|
|
217
222
|
if (!ca.success) throw new Error(`cannot compute liquidation details for ${creditAccount}: collateral computation failed`);
|
|
218
223
|
return ca;
|
|
219
224
|
}
|
|
220
|
-
async #getLiquidationData(ca, liquidator = ADDRESS_0X0, ignoreReservePrices) {
|
|
225
|
+
async #getLiquidationData(ca, liquidator = ADDRESS_0X0, ignoreReservePrices, blockNumber) {
|
|
221
226
|
const priceUpdates = await this.sdk.accounts.getOnDemandPriceUpdates(ca, ignoreReservePrices);
|
|
222
227
|
const { result } = await this.client.simulateContract({
|
|
223
228
|
address: LIQUIDATION_COMPRESSOR_V313_ADDRESS,
|
|
@@ -227,11 +232,12 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
227
232
|
liquidator,
|
|
228
233
|
ca.creditAccount,
|
|
229
234
|
priceUpdates
|
|
230
|
-
]
|
|
235
|
+
],
|
|
236
|
+
blockNumber
|
|
231
237
|
});
|
|
232
238
|
return result;
|
|
233
239
|
}
|
|
234
|
-
async #getExpiredCreditAccounts() {
|
|
240
|
+
async #getExpiredCreditAccounts(blockNumber) {
|
|
235
241
|
const expiredCMs = [];
|
|
236
242
|
for (const market of this.sdk.marketRegister.markets) {
|
|
237
243
|
if (market.pool.pool.totalBorrowed === 0n) continue;
|
|
@@ -245,7 +251,7 @@ var LiquidationsService = class extends SDKConstruct {
|
|
|
245
251
|
return (await Promise.all(expiredCMs.map((creditManager) => this.sdk.accounts.getCreditAccounts({
|
|
246
252
|
creditManager,
|
|
247
253
|
includeZeroDebt: false
|
|
248
|
-
})))).flat();
|
|
254
|
+
}, blockNumber)))).flat();
|
|
249
255
|
}
|
|
250
256
|
#buildAccount(ca, suite = this.sdk.marketRegister.findCreditManager(ca.creditManager)) {
|
|
251
257
|
const market = suite.market;
|
|
@@ -64,7 +64,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
64
64
|
/**
|
|
65
65
|
* {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
|
|
66
66
|
**/
|
|
67
|
-
async loadWithdrawableAssets(force) {
|
|
67
|
+
async loadWithdrawableAssets(force, blockNumber) {
|
|
68
68
|
if (this.#withdrawableAssets && !force) return this.getWithdrawableAssets();
|
|
69
69
|
const cms = this.#sdk.marketRegister.creditManagers.map((cm) => cm.creditManager.address);
|
|
70
70
|
const resp = await this.client.multicall({
|
|
@@ -75,7 +75,8 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
75
75
|
args: [cm]
|
|
76
76
|
})),
|
|
77
77
|
allowFailure: true,
|
|
78
|
-
batchSize: 0
|
|
78
|
+
batchSize: 0,
|
|
79
|
+
blockNumber
|
|
79
80
|
});
|
|
80
81
|
const cache = new AddressMap(void 0, MAP_LABEL);
|
|
81
82
|
for (let i = 0; i < resp.length; i++) {
|
|
@@ -120,7 +121,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
120
121
|
/**
|
|
121
122
|
* {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
|
|
122
123
|
**/
|
|
123
|
-
async getCurrentWithdrawals(creditAccount) {
|
|
124
|
+
async getCurrentWithdrawals(creditAccount, blockNumber) {
|
|
124
125
|
const [[claimable, pending], creditManager] = await this.client.multicall({
|
|
125
126
|
contracts: [{
|
|
126
127
|
address: this.address,
|
|
@@ -133,7 +134,8 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
133
134
|
functionName: "creditManager"
|
|
134
135
|
}],
|
|
135
136
|
allowFailure: false,
|
|
136
|
-
batchSize: 0
|
|
137
|
+
batchSize: 0,
|
|
138
|
+
blockNumber
|
|
137
139
|
});
|
|
138
140
|
return {
|
|
139
141
|
claimable: claimable.map((w) => toClaimableWithdrawal(w, creditManager)),
|
|
@@ -143,7 +145,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
143
145
|
/**
|
|
144
146
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
145
147
|
**/
|
|
146
|
-
async getExternalAccountCurrentWithdrawals(
|
|
148
|
+
async getExternalAccountCurrentWithdrawals(_props) {
|
|
147
149
|
this.#reportUnsupported("external account withdrawals");
|
|
148
150
|
return {
|
|
149
151
|
claimable: [],
|
|
@@ -183,7 +183,7 @@ var WithdrawalCompressorV313Contract = class extends AbstractWithdrawalCompresso
|
|
|
183
183
|
/**
|
|
184
184
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
185
185
|
**/
|
|
186
|
-
async getExternalAccountCurrentWithdrawals(account,
|
|
186
|
+
async getExternalAccountCurrentWithdrawals({ account, withdrawalTokens = [], blockNumber }) {
|
|
187
187
|
if (withdrawalTokens.length === 0) return {
|
|
188
188
|
claimable: [],
|
|
189
189
|
pending: []
|
|
@@ -192,7 +192,8 @@ var WithdrawalCompressorV313Contract = class extends AbstractWithdrawalCompresso
|
|
|
192
192
|
address: this.address,
|
|
193
193
|
abi: iExternalWithdrawalsBatchAbi,
|
|
194
194
|
functionName: "getExternalAccountCurrentWithdrawals",
|
|
195
|
-
args: [withdrawalTokens, account]
|
|
195
|
+
args: [withdrawalTokens, account],
|
|
196
|
+
blockNumber
|
|
196
197
|
});
|
|
197
198
|
return {
|
|
198
199
|
claimable: claimable.map((w) => toClaimableWithdrawal(w, void 0)),
|
|
@@ -54,8 +54,9 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
54
54
|
* @param investor - Investor EOA address.
|
|
55
55
|
* @param factories_ - Optional subset of factory addresses to query.
|
|
56
56
|
* When omitted, all loaded factories are used.
|
|
57
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
57
58
|
*/
|
|
58
|
-
async getInvestorData(investor, factories_) {
|
|
59
|
+
async getInvestorData(investor, factories_, blockNumber) {
|
|
59
60
|
let factories = this.#factories.values();
|
|
60
61
|
if (factories_?.length) factories = factories_.map((f) => this.#factories.mustGet(f));
|
|
61
62
|
if (!factories.length) return [];
|
|
@@ -64,7 +65,8 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
64
65
|
abi: iRWACompressorAbi,
|
|
65
66
|
address: rwaCompressorAddress,
|
|
66
67
|
functionName: "getRWAInvestorData",
|
|
67
|
-
args: [investor, factories.map((f) => f.address)]
|
|
68
|
+
args: [investor, factories.map((f) => f.address)],
|
|
69
|
+
blockNumber
|
|
68
70
|
});
|
|
69
71
|
const result = [];
|
|
70
72
|
for (let i = 0; i < factories.length; i++) {
|
|
@@ -188,7 +188,8 @@ var PoolService = class extends SDKConstruct {
|
|
|
188
188
|
args: [props.wallet]
|
|
189
189
|
})),
|
|
190
190
|
allowFailure: false,
|
|
191
|
-
batchSize: 0
|
|
191
|
+
batchSize: 0,
|
|
192
|
+
blockNumber: props.blockNumber
|
|
192
193
|
});
|
|
193
194
|
return markets.flatMap((market, i) => {
|
|
194
195
|
const shares = balances[i] ?? 0n;
|
|
@@ -17,19 +17,26 @@ var PositionsService = class extends SDKConstruct {
|
|
|
17
17
|
* the call rather than the SDK's loaded snapshot.
|
|
18
18
|
**/
|
|
19
19
|
async list(props) {
|
|
20
|
-
const { wallet, filter } = props;
|
|
20
|
+
const { wallet, filter, blockNumber } = props;
|
|
21
21
|
const chainIds = filter?.chainIds;
|
|
22
22
|
if (isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
23
23
|
const wantedKind = filter?.kind;
|
|
24
24
|
const wanted = (kind) => !isFilterSet(wantedKind) || wantedKind === kind;
|
|
25
25
|
const isZeroDebt = filter?.isZeroDebt;
|
|
26
26
|
const [pool, strategy, liquidation] = await Promise.all([
|
|
27
|
-
wanted("pool") ? this.sdk.pools.listPositions({
|
|
27
|
+
wanted("pool") ? this.sdk.pools.listPositions({
|
|
28
|
+
wallet,
|
|
29
|
+
blockNumber
|
|
30
|
+
}) : Promise.resolve([]),
|
|
28
31
|
wanted("strategy") ? this.sdk.accounts.listPositions({
|
|
29
32
|
owner: wallet,
|
|
30
|
-
includeZeroDebt: !isFilterSet(isZeroDebt) || isZeroDebt
|
|
33
|
+
includeZeroDebt: !isFilterSet(isZeroDebt) || isZeroDebt,
|
|
34
|
+
blockNumber
|
|
31
35
|
}) : Promise.resolve([]),
|
|
32
|
-
wanted("liquidation") ? this.sdk.liquidations.getLiquidationPositions({
|
|
36
|
+
wanted("liquidation") ? this.sdk.liquidations.getLiquidationPositions({
|
|
37
|
+
liquidator: wallet,
|
|
38
|
+
blockNumber
|
|
39
|
+
}) : Promise.resolve([])
|
|
33
40
|
]);
|
|
34
41
|
return [
|
|
35
42
|
...pool,
|
|
@@ -12,4 +12,6 @@ import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAcc
|
|
|
12
12
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
13
13
|
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
14
14
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
15
|
-
|
|
15
|
+
import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
|
|
16
|
+
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
17
|
+
export { Amount, ApyBreakdown, AssetType, Bps, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainSucceeded, Curator, CuratorName, DataResponse, DataSource, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionHistoryMetric, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionHistoryMetric, PositionHistoryQuery, PositionId, PositionKey, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, ResponseMetadata, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionHistoryMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ChainId, Timestamp } from "./primitives.js";
|
|
2
|
+
//#region src/model/response.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared response envelope: the payload plus per-chain metadata naming which
|
|
5
|
+
* source served each chain.
|
|
6
|
+
*
|
|
7
|
+
* The backend sends this on HTTP success only. Transport failures, timeouts,
|
|
8
|
+
* and backend error bodies are not an envelope — the offchain client wraps
|
|
9
|
+
* those, because the request may never have reached the backend.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam T - Payload type
|
|
12
|
+
**/
|
|
13
|
+
interface DataResponse<T> {
|
|
14
|
+
/**
|
|
15
|
+
* Response payload.
|
|
16
|
+
**/
|
|
17
|
+
data: T;
|
|
18
|
+
/**
|
|
19
|
+
* Per-chain outcome of the read, see {@link ResponseMetadata}.
|
|
20
|
+
**/
|
|
21
|
+
meta: ResponseMetadata;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Per-chain outcomes attached to every {@link DataResponse}.
|
|
25
|
+
**/
|
|
26
|
+
interface ResponseMetadata {
|
|
27
|
+
/**
|
|
28
|
+
* One entry per chain the read asked. After a merge, each success names the
|
|
29
|
+
* side that won it in {@link ChainSucceeded.source}, so a consumer can tell
|
|
30
|
+
* a chain served live from a chain served by the backend without per-row
|
|
31
|
+
* provenance.
|
|
32
|
+
**/
|
|
33
|
+
chains: ChainMetadata[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Which side produced a chain's data.
|
|
37
|
+
**/
|
|
38
|
+
type DataSource = "onchain" | "offchain";
|
|
39
|
+
/**
|
|
40
|
+
* Chain that answered, and which source served it.
|
|
41
|
+
*
|
|
42
|
+
* Discriminated from {@link ChainFailed} on {@link status}, so a success
|
|
43
|
+
* without a source is unrepresentable.
|
|
44
|
+
**/
|
|
45
|
+
interface ChainSucceeded {
|
|
46
|
+
/**
|
|
47
|
+
* Chain the entry describes.
|
|
48
|
+
**/
|
|
49
|
+
chainId: ChainId;
|
|
50
|
+
status: "success";
|
|
51
|
+
/**
|
|
52
|
+
* Source that produced this chain's data. Never absent on success: some
|
|
53
|
+
* source produced it.
|
|
54
|
+
**/
|
|
55
|
+
source: DataSource;
|
|
56
|
+
/**
|
|
57
|
+
* Block the data reflects. A `number` here (model convention), converted
|
|
58
|
+
* from `bigint` at the onchain boundary.
|
|
59
|
+
**/
|
|
60
|
+
blockNumber?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Unix seconds of {@link blockNumber}.
|
|
63
|
+
**/
|
|
64
|
+
timestamp?: Timestamp;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Chain that did not answer.
|
|
68
|
+
**/
|
|
69
|
+
interface ChainFailed {
|
|
70
|
+
/**
|
|
71
|
+
* Chain the entry describes.
|
|
72
|
+
**/
|
|
73
|
+
chainId: ChainId;
|
|
74
|
+
status: "error";
|
|
75
|
+
/**
|
|
76
|
+
* Source that failed this chain. Absent when every source failed for it, so
|
|
77
|
+
* no side won it.
|
|
78
|
+
**/
|
|
79
|
+
source?: DataSource;
|
|
80
|
+
/**
|
|
81
|
+
* Rejection reason. A `string` in JSON responses, an `Error` (or an
|
|
82
|
+
* `AggregateError` when both sources failed) when produced locally.
|
|
83
|
+
*
|
|
84
|
+
* Serialises to `{}` if an envelope carrying a real `Error` is put into
|
|
85
|
+
* Redux or a log as-is.
|
|
86
|
+
**/
|
|
87
|
+
error?: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Per-chain outcome, discriminated on {@link ChainSucceeded.status} /
|
|
91
|
+
* {@link ChainFailed.status}.
|
|
92
|
+
**/
|
|
93
|
+
type ChainMetadata = ChainSucceeded | ChainFailed;
|
|
94
|
+
/**
|
|
95
|
+
* Anything the read model scopes to one chain, i.e. every list row.
|
|
96
|
+
**/
|
|
97
|
+
interface ChainScoped {
|
|
98
|
+
/**
|
|
99
|
+
* Chain the row lives on.
|
|
100
|
+
**/
|
|
101
|
+
chainId: ChainId;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
//#region src/model/response.schema.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Runtime schemas for {@link ./response.js}, see the note in
|
|
5
|
+
* `primitives.schema.ts` on why they are written by hand.
|
|
6
|
+
*
|
|
7
|
+
* `responseSchema(payloadSchema)` validates a successful backend 2xx body.
|
|
8
|
+
* HTTP and transport errors never pass through it.
|
|
9
|
+
**/
|
|
10
|
+
/**
|
|
11
|
+
* {@link DataSource}
|
|
12
|
+
**/
|
|
13
|
+
declare const dataSourceSchema: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
|
|
14
|
+
/**
|
|
15
|
+
* {@link ChainSucceeded}
|
|
16
|
+
**/
|
|
17
|
+
declare const chainSucceededSchema: z.ZodObject<{
|
|
18
|
+
chainId: z.ZodNumber;
|
|
19
|
+
status: z.ZodLiteral<"success">;
|
|
20
|
+
source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
|
|
21
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
/**
|
|
25
|
+
* {@link ChainFailed}
|
|
26
|
+
*
|
|
27
|
+
* `error` is a `string` on the wire. The schema accepts `unknown` so the same
|
|
28
|
+
* codec also validates a locally produced envelope that carries an `Error`.
|
|
29
|
+
**/
|
|
30
|
+
declare const chainFailedSchema: z.ZodObject<{
|
|
31
|
+
chainId: z.ZodNumber;
|
|
32
|
+
status: z.ZodLiteral<"error">;
|
|
33
|
+
source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
|
|
34
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/**
|
|
37
|
+
* {@link ChainMetadata}
|
|
38
|
+
**/
|
|
39
|
+
declare const chainMetadataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
40
|
+
chainId: z.ZodNumber;
|
|
41
|
+
status: z.ZodLiteral<"success">;
|
|
42
|
+
source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
|
|
43
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
+
chainId: z.ZodNumber;
|
|
47
|
+
status: z.ZodLiteral<"error">;
|
|
48
|
+
source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
|
|
49
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
50
|
+
}, z.core.$strip>], "status">;
|
|
51
|
+
/**
|
|
52
|
+
* {@link ResponseMetadata}
|
|
53
|
+
**/
|
|
54
|
+
declare const responseMetadataSchema: z.ZodObject<{
|
|
55
|
+
chains: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
56
|
+
chainId: z.ZodNumber;
|
|
57
|
+
status: z.ZodLiteral<"success">;
|
|
58
|
+
source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
|
|
59
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
chainId: z.ZodNumber;
|
|
63
|
+
status: z.ZodLiteral<"error">;
|
|
64
|
+
source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
|
|
65
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
66
|
+
}, z.core.$strip>], "status">>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/**
|
|
69
|
+
* {@link DataResponse} parameterized by the payload schema.
|
|
70
|
+
**/
|
|
71
|
+
declare function responseSchema<S extends z.ZodType>(payloadSchema: S): z.ZodObject<{
|
|
72
|
+
data: S;
|
|
73
|
+
meta: z.ZodObject<{
|
|
74
|
+
chains: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
75
|
+
chainId: z.ZodNumber;
|
|
76
|
+
status: z.ZodLiteral<"success">;
|
|
77
|
+
source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
|
|
78
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
81
|
+
chainId: z.ZodNumber;
|
|
82
|
+
status: z.ZodLiteral<"error">;
|
|
83
|
+
source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
|
|
84
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
85
|
+
}, z.core.$strip>], "status">>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema };
|
|
@@ -68,9 +68,9 @@ declare abstract class AbstractOffchainNamespace {
|
|
|
68
68
|
/**
|
|
69
69
|
* Reads one endpoint and decodes its payload.
|
|
70
70
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
71
|
+
* A 2xx body is a {@link DataResponse}. Timeouts, non-2xx, and schema skew
|
|
72
|
+
* throw — they are not a backend envelope, and this layer is what wraps
|
|
73
|
+
* them, because the request may never have reached the backend.
|
|
74
74
|
**/
|
|
75
75
|
protected get<S extends z.ZodType>(request: OffchainGetRequest<S>): Promise<OffchainResult<z.output<S>>>;
|
|
76
76
|
/**
|
|
@@ -159,6 +159,10 @@ interface ListStrategyPositionsProps {
|
|
|
159
159
|
* Whether to include accounts that carry no debt.
|
|
160
160
|
**/
|
|
161
161
|
includeZeroDebt: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Block to read at. Defaults to the latest block.
|
|
164
|
+
**/
|
|
165
|
+
blockNumber?: bigint;
|
|
162
166
|
}
|
|
163
167
|
//#endregion
|
|
164
168
|
export { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions, ListStrategyPositionsProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClaimableWithdrawal, CurrentWithdrawals, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
1
|
+
import { ClaimableWithdrawal, CurrentWithdrawals, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
2
2
|
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions, ListStrategyPositionsProps } from "./credit-account-compressor/types.js";
|
|
3
3
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
4
4
|
import { CreditAccountCompressorV310Contract } from "./credit-account-compressor/CreditAccountCompressorV310Contract.js";
|
|
@@ -28,4 +28,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
|
|
|
28
28
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
29
29
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
30
30
|
import "./liquidations/index.js";
|
|
31
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, AccountToCheck, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, 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, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, EncodableCreditAccountOperation, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type IntentPreviewResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, ListStrategyPositionsProps, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, PartiallyLiquidateProps, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, RequestableWithdrawal, Rewards, SetBotProps, SetBotResult, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, primaryInstantOutput, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
31
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, AccountToCheck, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, 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, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, EncodableCreditAccountOperation, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type IntentPreviewResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, ListStrategyPositionsProps, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, PartiallyLiquidateProps, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, RequestableWithdrawal, Rewards, SetBotProps, SetBotResult, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, primaryInstantOutput, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -3,7 +3,7 @@ import { LiquidatableAccount, LiquidationDetails, LiquidationPosition } from "..
|
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
5
5
|
import "../../base/index.js";
|
|
6
|
-
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps } from "./types.js";
|
|
6
|
+
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps, LoadRWALiquidatorsProps } from "./types.js";
|
|
7
7
|
//#region src/sdk/accounts/liquidations/LiquidationsService.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -40,7 +40,7 @@ declare class LiquidationsService extends SDKConstruct {
|
|
|
40
40
|
* deployed for the markets of the chain and registers them in the SDK
|
|
41
41
|
* contracts register.
|
|
42
42
|
**/
|
|
43
|
-
loadRWALiquidators(): Promise<void>;
|
|
43
|
+
loadRWALiquidators(props?: LoadRWALiquidatorsProps): Promise<void>;
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
46
|
export { LiquidationsService };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
2
|
-
import { MultichainNetworkProps, MultichainNetworksProps, WithMultichain } from "../../types/multichain.js";
|
|
2
|
+
import { MultichainNetworkProps, MultichainNetworksProps, WithBlock, WithMultichain } from "../../types/multichain.js";
|
|
3
3
|
import { LiquidatableAccountFilter } from "../../../model/liquidations.js";
|
|
4
4
|
import "../../../model/index.js";
|
|
5
5
|
import "../../types/index.js";
|
|
@@ -35,8 +35,11 @@ type RWALiquidatorInfo = ContractFunctionReturnType<typeof iLiquidationCompresso
|
|
|
35
35
|
type GetLiquidatableAccountsPropsBase = Omit<LiquidatableAccountFilter, "chainIds">;
|
|
36
36
|
/**
|
|
37
37
|
* Props for {@link LiquidationsService.getLiquidatableAccounts}.
|
|
38
|
+
*
|
|
39
|
+
* {@link BlockNumberProps.blockNumber} is only on the single-chain form: a
|
|
40
|
+
* height is not shared across the networks of the fan-out.
|
|
38
41
|
**/
|
|
39
|
-
type GetLiquidatableAccountsProps<Multichain extends boolean = false> = GetLiquidatableAccountsPropsBase & WithMultichain<Multichain, MultichainNetworksProps>;
|
|
42
|
+
type GetLiquidatableAccountsProps<Multichain extends boolean = false> = GetLiquidatableAccountsPropsBase & WithBlock<Multichain> & WithMultichain<Multichain, MultichainNetworksProps>;
|
|
40
43
|
/**
|
|
41
44
|
* Chain-independent part of {@link GetLiquidationDetailsProps}.
|
|
42
45
|
**/
|
|
@@ -58,9 +61,16 @@ interface GetLiquidationDetailsPropsBase {
|
|
|
58
61
|
* applied by the compressor before computing amounts.
|
|
59
62
|
**/
|
|
60
63
|
ignoreReservePrices?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Block to read at. Defaults to the latest block.
|
|
66
|
+
**/
|
|
67
|
+
blockNumber?: bigint;
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Props for {@link LiquidationsService.getLiquidationDetails}.
|
|
71
|
+
*
|
|
72
|
+
* {@link BlockNumberProps.blockNumber} is kept on the multichain form because
|
|
73
|
+
* the method already targets a single {@link MultichainNetworkProps.network}.
|
|
64
74
|
**/
|
|
65
75
|
type GetLiquidationDetailsProps<Multichain extends boolean = false> = GetLiquidationDetailsPropsBase & WithMultichain<Multichain, MultichainNetworkProps>;
|
|
66
76
|
/**
|
|
@@ -81,9 +91,16 @@ interface BuildLiquidationTxPropsBase {
|
|
|
81
91
|
* applied by the compressor before building the transaction.
|
|
82
92
|
**/
|
|
83
93
|
ignoreReservePrices?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Block to read at. Defaults to the latest block.
|
|
96
|
+
**/
|
|
97
|
+
blockNumber?: bigint;
|
|
84
98
|
}
|
|
85
99
|
/**
|
|
86
100
|
* Props for {@link LiquidationsService.buildLiquidationTx}.
|
|
101
|
+
*
|
|
102
|
+
* {@link BlockNumberProps.blockNumber} is kept on the multichain form because
|
|
103
|
+
* the method already targets a single {@link MultichainNetworkProps.network}.
|
|
87
104
|
**/
|
|
88
105
|
type BuildLiquidationTxProps<Multichain extends boolean = false> = BuildLiquidationTxPropsBase & WithMultichain<Multichain, MultichainNetworkProps>;
|
|
89
106
|
/**
|
|
@@ -98,12 +115,17 @@ interface GetLiquidationPositionsPropsBase {
|
|
|
98
115
|
}
|
|
99
116
|
/**
|
|
100
117
|
* Props for {@link LiquidationsService.getLiquidationPositions}.
|
|
118
|
+
*
|
|
119
|
+
* {@link BlockNumberProps.blockNumber} is only on the single-chain form: a
|
|
120
|
+
* height is not shared across the networks of the fan-out.
|
|
101
121
|
**/
|
|
102
|
-
type GetLiquidationPositionsProps<Multichain extends boolean = false> = GetLiquidationPositionsPropsBase & WithMultichain<Multichain, MultichainNetworksProps>;
|
|
122
|
+
type GetLiquidationPositionsProps<Multichain extends boolean = false> = GetLiquidationPositionsPropsBase & WithBlock<Multichain> & WithMultichain<Multichain, MultichainNetworksProps>;
|
|
103
123
|
/**
|
|
104
|
-
* Props for {@link
|
|
105
|
-
*
|
|
124
|
+
* Props for {@link LiquidationsService.loadRWALiquidators}.
|
|
125
|
+
*
|
|
126
|
+
* {@link BlockNumberProps.blockNumber} is only on the single-chain form: a
|
|
127
|
+
* height is not shared across the networks of the fan-out.
|
|
106
128
|
**/
|
|
107
|
-
type LoadRWALiquidatorsProps<Multichain extends boolean = false> = WithMultichain<Multichain, MultichainNetworksProps>;
|
|
129
|
+
type LoadRWALiquidatorsProps<Multichain extends boolean = false> = WithBlock<Multichain> & WithMultichain<Multichain, MultichainNetworksProps>;
|
|
108
130
|
//#endregion
|
|
109
131
|
export { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo };
|
package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
2
|
-
import { ClaimableWithdrawal, CurrentWithdrawals, GetWithdrawalRequestResultProps, IWithdrawalCompressorContract, PendingWithdrawal, RequestableWithdrawal, WithdrawableAsset, WithdrawalStatus, WithdrawalsState } from "./types.js";
|
|
2
|
+
import { ClaimableWithdrawal, CurrentWithdrawals, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IWithdrawalCompressorContract, PendingWithdrawal, RequestableWithdrawal, WithdrawableAsset, WithdrawalStatus, WithdrawalsState } from "./types.js";
|
|
3
3
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
4
4
|
import { BaseContract, BaseContractArgs } from "../../base/BaseContract.js";
|
|
5
5
|
import "../../base/index.js";
|
|
@@ -55,7 +55,7 @@ declare abstract class AbstractWithdrawalCompressorContract<abi extends Abi> ext
|
|
|
55
55
|
/**
|
|
56
56
|
* {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
|
|
57
57
|
**/
|
|
58
|
-
loadWithdrawableAssets(force?: boolean): Promise<WithdrawableAsset[]>;
|
|
58
|
+
loadWithdrawableAssets(force?: boolean, blockNumber?: bigint): Promise<WithdrawableAsset[]>;
|
|
59
59
|
/**
|
|
60
60
|
* {@inheritDoc IWithdrawalCompressorContract.findWithdrawableAssets}
|
|
61
61
|
**/
|
|
@@ -75,11 +75,11 @@ declare abstract class AbstractWithdrawalCompressorContract<abi extends Abi> ext
|
|
|
75
75
|
/**
|
|
76
76
|
* {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
|
|
77
77
|
**/
|
|
78
|
-
getCurrentWithdrawals(creditAccount: Address): Promise<CurrentWithdrawals>;
|
|
78
|
+
getCurrentWithdrawals(creditAccount: Address, blockNumber?: bigint): Promise<CurrentWithdrawals>;
|
|
79
79
|
/**
|
|
80
80
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
81
81
|
**/
|
|
82
|
-
getExternalAccountCurrentWithdrawals(
|
|
82
|
+
getExternalAccountCurrentWithdrawals(_props: GetExternalAccountCurrentWithdrawalsProps): Promise<CurrentWithdrawals>;
|
|
83
83
|
/**
|
|
84
84
|
* {@inheritDoc IWithdrawalCompressorContract.getWithdrawalStatus}
|
|
85
85
|
**/
|