@gearbox-protocol/sdk 16.0.0-next.12 → 16.0.0-next.14

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.
Files changed (51) hide show
  1. package/dist/cjs/model/charts.js +5 -1
  2. package/dist/cjs/model/index.js +3 -1
  3. package/dist/cjs/model/opportunities.schema.js +9 -0
  4. package/dist/cjs/model/positions.js +6 -0
  5. package/dist/cjs/model/positions.schema.js +2 -1
  6. package/dist/cjs/model/previews.js +4 -3
  7. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +9 -0
  8. package/dist/cjs/offchain/positions/OffchainPositions.js +9 -0
  9. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +14 -0
  10. package/dist/cjs/onchain/market/adapters/contracts/ERC4626AdapterContract.js +54 -0
  11. package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +13 -0
  12. package/dist/cjs/onchain/positions/PositionsService.js +20 -17
  13. package/dist/cjs/preview/preview/replayInnerOperations.js +10 -25
  14. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +6 -0
  15. package/dist/cjs/sdk/positions/PositionsNamespace.js +6 -0
  16. package/dist/esm/model/charts.js +5 -1
  17. package/dist/esm/model/index.js +4 -4
  18. package/dist/esm/model/opportunities.schema.js +9 -1
  19. package/dist/esm/model/positions.js +6 -1
  20. package/dist/esm/model/positions.schema.js +2 -1
  21. package/dist/esm/model/previews.js +4 -3
  22. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +10 -1
  23. package/dist/esm/offchain/positions/OffchainPositions.js +10 -1
  24. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +14 -0
  25. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +55 -1
  26. package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +14 -1
  27. package/dist/esm/onchain/positions/PositionsService.js +21 -18
  28. package/dist/esm/preview/preview/replayInnerOperations.js +11 -26
  29. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +6 -0
  30. package/dist/esm/sdk/positions/PositionsNamespace.js +6 -0
  31. package/dist/types/model/charts.d.ts +4 -2
  32. package/dist/types/model/charts.schema.d.ts +8 -0
  33. package/dist/types/model/index.d.ts +5 -5
  34. package/dist/types/model/opportunities.d.ts +19 -1
  35. package/dist/types/model/opportunities.schema.d.ts +9 -1
  36. package/dist/types/model/positions.d.ts +13 -1
  37. package/dist/types/model/positions.schema.d.ts +2 -0
  38. package/dist/types/model/previews.d.ts +4 -3
  39. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +5 -1
  40. package/dist/types/offchain/positions/OffchainPositions.d.ts +6 -1
  41. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +12 -0
  42. package/dist/types/onchain/market/adapters/contracts/ERC4626AdapterContract.d.ts +8 -1
  43. package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +7 -0
  44. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
  45. package/dist/types/sdk/opportunities/types.d.ts +9 -1
  46. package/dist/types/sdk/positions/PositionsNamespace.d.ts +5 -1
  47. package/dist/types/sdk/positions/types.d.ts +9 -1
  48. package/package.json +1 -1
  49. package/dist/cjs/preview/preview/applyRWAWrapUnwrap.js +0 -67
  50. package/dist/esm/preview/preview/applyRWAWrapUnwrap.js +0 -66
  51. package/dist/types/preview/preview/applyRWAWrapUnwrap.d.ts +0 -17
@@ -4,7 +4,7 @@ import "../../../base/index.js";
4
4
  import { iERC4626Abi } from "../abi/targetContractAbi.js";
5
5
  import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
6
6
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
7
- import { decodeAbiParameters, zeroAddress } from "viem";
7
+ import { decodeAbiParameters, decodeFunctionData, zeroAddress } from "viem";
8
8
  //#region src/onchain/market/adapters/contracts/ERC4626AdapterContract.ts
9
9
  const abi = ierc4626AdapterAbi;
10
10
  const protocolAbi = iERC4626Abi;
@@ -97,6 +97,60 @@ var ERC4626AdapterContract = class extends AbstractAdapterContract {
97
97
  };
98
98
  return super.classifyLegacyOperation(parsed, transfers);
99
99
  }
100
+ /**
101
+ * Out-of-bracket calls are legal only on the RWA wrap/unwrap adapter (the
102
+ * share converts 1:1 with the vault asset, so no on-chain preview or
103
+ * slippage bracket is needed); a regular vault-strategy ERC4626 adapter
104
+ * keeps the base behavior and returns false.
105
+ */
106
+ replayOutOfBracketCall(balances, calldata) {
107
+ const meta = this.sdk.tokensMeta.get(this.share);
108
+ if (!meta || !this.sdk.tokensMeta.isRWAUnderlying(meta)) return false;
109
+ const resolved = this.#resolveWrapUnwrap(calldata, balances);
110
+ if (resolved && resolved.amountIn > 0n) {
111
+ balances.dec(resolved.tokenIn, resolved.amountIn);
112
+ balances.inc(resolved.tokenOut, resolved.amountIn);
113
+ }
114
+ return true;
115
+ }
116
+ #resolveWrapUnwrap(calldata, balances) {
117
+ const decoded = decodeFunctionData({
118
+ abi,
119
+ data: calldata
120
+ });
121
+ const { asset, share } = this;
122
+ switch (decoded.functionName) {
123
+ case "deposit": return {
124
+ tokenIn: asset,
125
+ tokenOut: share,
126
+ amountIn: decoded.args[0]
127
+ };
128
+ case "depositDiff": {
129
+ const [leftoverAmount] = decoded.args;
130
+ const running = balances.getOrZero(asset);
131
+ return {
132
+ tokenIn: asset,
133
+ tokenOut: share,
134
+ amountIn: running > leftoverAmount ? running - leftoverAmount : 0n
135
+ };
136
+ }
137
+ case "redeem": return {
138
+ tokenIn: share,
139
+ tokenOut: asset,
140
+ amountIn: decoded.args[0]
141
+ };
142
+ case "redeemDiff": {
143
+ const [leftoverAmount] = decoded.args;
144
+ const running = balances.getOrZero(share);
145
+ return {
146
+ tokenIn: share,
147
+ tokenOut: asset,
148
+ amountIn: running > leftoverAmount ? running - leftoverAmount : 0n
149
+ };
150
+ }
151
+ default: return;
152
+ }
153
+ }
100
154
  async applyBalanceChanges(balances, decoded) {
101
155
  switch (decoded.functionName) {
102
156
  case "depositDiff": {
@@ -5,10 +5,14 @@ import "../abi/adapters/index.js";
5
5
  import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
6
6
  import "../abi/index.js";
7
7
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
8
- import { decodeAbiParameters, decodeFunctionData, isAddressEqual, zeroAddress } from "viem";
8
+ import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, isAddressEqual, zeroAddress } from "viem";
9
9
  //#region src/onchain/market/adapters/contracts/MidasGatewayAdapterContract.ts
10
10
  const abi = iMidasGatewayAdapterV311Abi;
11
11
  const protocolAbi = iMidasGatewayV311Abi;
12
+ const receiveGreenlistCalldata = encodeFunctionData({
13
+ abi,
14
+ functionName: "receiveGreenlist"
15
+ });
12
16
  var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
13
17
  #version;
14
18
  #gateway;
@@ -164,6 +168,15 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
164
168
  const [redeemer] = decoded.args;
165
169
  return { redeemer };
166
170
  }
171
+ /**
172
+ * `receiveGreenlist()` is prepended by `prependMidasReceiveGreenlist`
173
+ * before the balance bracket when the multicall mints a permissioned
174
+ * mToken: it only greenlists the credit account and is balance-neutral,
175
+ * so it is legal outside a bracket and leaves balances untouched.
176
+ */
177
+ replayOutOfBracketCall(_balances, calldata) {
178
+ return calldata === receiveGreenlistCalldata;
179
+ }
167
180
  async applyBalanceChanges(balances, decoded) {
168
181
  switch (decoded.functionName) {
169
182
  case "depositInstantDiff": {
@@ -8,7 +8,7 @@ import "../base/index.js";
8
8
  import { bpsToRay, calcBorrowApy, calcPositionLeverage, healthFactorBps, usdToNumber } from "../market/math.js";
9
9
  import { strategyName } from "../market/strategyName.js";
10
10
  import { isFilterSet } from "../../model/filters.js";
11
- import { matchesPositionFilter } from "../../model/positions.js";
11
+ import { STRATEGY_POSITION_COLLATERAL_ERROR, matchesPositionFilter } from "../../model/positions.js";
12
12
  import "../../model/index.js";
13
13
  import { borrowRateAtUtilization, utilizationAfterLiquidityChange } from "../market/pool/math.js";
14
14
  import { calcBorrowRate } from "./calcBorrowRate.js";
@@ -63,12 +63,9 @@ var PositionsService = class extends SDKConstruct {
63
63
  **/
64
64
  async listStrategyPositions(props) {
65
65
  const { owner, includeZeroDebt, blockNumber } = props;
66
- const describable = (await this.sdk.accounts.getBorrowerCreditAccounts(owner, { includeZeroDebt }, blockNumber)).filter((ca) => {
67
- if (!ca.success) this.logger?.warn(`cannot describe position of ${this.labelAddress(ca.creditAccount)}: collateral computation failed`);
68
- return ca.success;
69
- });
70
- const withdrawals = await Promise.all(describable.map((ca) => this.#accountWithdrawals(ca, blockNumber)));
71
- return describable.map((ca, i) => this.#toStrategyPosition(ca, withdrawals[i] ?? new AddressMap()));
66
+ const accounts = await this.sdk.accounts.getBorrowerCreditAccounts(owner, { includeZeroDebt }, blockNumber);
67
+ const withdrawals = await Promise.all(accounts.map((ca) => this.#accountWithdrawals(ca, blockNumber)));
68
+ return accounts.map((ca, i) => this.#toStrategyPosition(ca, withdrawals[i] ?? new AddressMap()));
72
69
  }
73
70
  /**
74
71
  * Health factor of an account state, in basis points (`10000` = 1.0).
@@ -179,14 +176,11 @@ var PositionsService = class extends SDKConstruct {
179
176
  const token = market.underlyingToken;
180
177
  const totalDebtValue = ca.debt + ca.accruedInterest + ca.accruedFees;
181
178
  const target = getAccountTargetCollateral(ca.creditAccount, this.sdk.chainId) ?? suite.strategyTargetCollateral;
182
- const snapshot = accountSnapshotFromCreditAccountData(ca);
183
- const borrowRate = this.borrowRate(snapshot);
184
- const timeToLiquidation = this.timeToLiquidation(snapshot);
185
- const liquidationPrice = this.liquidationPrice(snapshot);
186
- const zeroDebt = ca.debt === 0n;
179
+ const priceFailed = !ca.success;
180
+ const recomputeTotals = ca.debt === 0n || priceFailed;
187
181
  const collaterals = [];
188
- let totalValue = zeroDebt ? 0n : ca.totalValue;
189
- let totalValueUSD = zeroDebt ? 0n : ca.totalValueUSD;
182
+ let totalValue = recomputeTotals ? 0n : ca.totalValue;
183
+ let totalValueUSD = recomputeTotals ? 0n : ca.totalValueUSD;
190
184
  for (const t of ca.tokens) {
191
185
  if (t.balance <= 10n) continue;
192
186
  collaterals.push({
@@ -194,13 +188,21 @@ var PositionsService = class extends SDKConstruct {
194
188
  quota: priceOracle.toTokenAmount(market.underlying, t.quota),
195
189
  withdrawals: withdrawals.get(t.token) ?? []
196
190
  });
197
- if (zeroDebt) {
191
+ if (recomputeTotals) {
198
192
  const value = priceOracle.safeConvert(t.token, market.underlying, t.balance) || 0n;
199
193
  totalValue += value;
200
194
  const usd = priceOracle.safeConvertToUSD(t.token, t.balance) || 0n;
201
195
  totalValueUSD += usd;
202
196
  }
203
197
  }
198
+ const snapshot = {
199
+ ...accountSnapshotFromCreditAccountData(ca),
200
+ totalValue
201
+ };
202
+ const borrowRate = this.borrowRate(snapshot);
203
+ const timeToLiquidation = this.timeToLiquidation(snapshot);
204
+ const liquidationPrice = this.liquidationPrice(snapshot);
205
+ const totalDebtUSD = priceFailed ? priceOracle.safeConvertToUSD(market.underlying, totalDebtValue) ?? 0n : ca.totalDebtUSD;
204
206
  return {
205
207
  kind: "strategy",
206
208
  chainId: this.sdk.chainId,
@@ -214,18 +216,19 @@ var PositionsService = class extends SDKConstruct {
214
216
  totalDebt: {
215
217
  token,
216
218
  value: totalDebtValue,
217
- valueUsd: usdToNumber(ca.totalDebtUSD)
219
+ valueUsd: usdToNumber(totalDebtUSD)
218
220
  },
219
221
  totalValue: {
220
222
  token,
221
223
  value: totalValue,
222
224
  valueUsd: usdToNumber(totalValueUSD)
223
225
  },
224
- healthFactor: healthFactorBps(ca.healthFactor),
226
+ healthFactor: priceFailed ? this.healthFactor(snapshot) : healthFactorBps(ca.healthFactor),
225
227
  borrowRate,
226
228
  timeToLiquidation,
227
229
  liquidationPrice,
228
- collaterals
230
+ collaterals,
231
+ ...priceFailed ? { error: STRATEGY_POSITION_COLLATERAL_ERROR } : {}
229
232
  };
230
233
  }
231
234
  /**
@@ -1,11 +1,9 @@
1
1
  import { AssetsMap } from "../../onchain/utils/AssetsMap.js";
2
2
  import "../../onchain/constants/math.js";
3
3
  import { AbstractAdapterContract } from "../../onchain/market/adapters/contracts/AbstractAdapter.js";
4
- import { ERC4626AdapterContract } from "../../onchain/market/adapters/contracts/ERC4626AdapterContract.js";
5
- import { ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP } from "../../model/previews.js";
4
+ import { ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL } from "../../model/previews.js";
6
5
  import "../../model/index.js";
7
6
  import "../../onchain/index.js";
8
- import { applyRWAWrapUnwrap } from "./applyRWAWrapUnwrap.js";
9
7
  //#region src/preview/preview/replayInnerOperations.ts
10
8
  /**
11
9
  * Creates a {@link ReplayState} around the given account seed, with empty
@@ -93,26 +91,25 @@ function applyWithdrawCollateral(state, op) {
93
91
  *
94
92
  * Inside a bracket, the adapter's balance changes are previewed via
95
93
  * {@link AbstractAdapterContract.previewBalanceChanges}. Outside a bracket,
96
- * only RWA wrap/unwrap calls are allowed (see {@link applyRWAWrapUnwrap});
97
- * nothing enforces the outcome of any other out-of-bracket adapter call
98
- * on-chain, so its effect on balances cannot be previewed.
94
+ * only calls that {@link AbstractAdapterContract.replayOutOfBracketCall}
95
+ * accepts are allowed; nothing enforces the outcome of any other out-of-bracket
96
+ * adapter call on-chain, so its effect on balances cannot be previewed.
99
97
  */
100
98
  async function applyExecute(sdk, op, inBracket, balances) {
101
99
  const adapter = sdk.getContract(op.adapter);
102
100
  if (!inBracket) {
103
- if (!isRWAShare(sdk, adapter)) return {
104
- code: ERROR_ADAPTER_CALL_OUTSIDE_BRACKET,
105
- message: `call to ${op.adapter} outside of a storeExpectedBalances/compareBalances bracket`
106
- };
107
- try {
108
- applyRWAWrapUnwrap(adapter, op.calldata, balances);
109
- return;
101
+ if (adapter instanceof AbstractAdapterContract) try {
102
+ if (adapter.replayOutOfBracketCall(balances, op.calldata)) return;
110
103
  } catch (e) {
111
104
  return {
112
- code: ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP,
105
+ code: ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL,
113
106
  message: e instanceof Error ? e.message : String(e)
114
107
  };
115
108
  }
109
+ return {
110
+ code: ERROR_ADAPTER_CALL_OUTSIDE_BRACKET,
111
+ message: `call to ${op.adapter} outside of a storeExpectedBalances/compareBalances bracket`
112
+ };
116
113
  }
117
114
  if (!(adapter instanceof AbstractAdapterContract)) return {
118
115
  code: ERROR_NON_ADAPTER_CALL_IN_BRACKET,
@@ -128,17 +125,5 @@ async function applyExecute(sdk, op, inBracket, balances) {
128
125
  };
129
126
  }
130
127
  }
131
- /**
132
- * True when the ERC4626 adapter converts an RWA underlying, i.e. it is the
133
- * wrap/unwrap adapter of an RWA market rather than a regular vault strategy
134
- * adapter.
135
- */
136
- function isRWAShare(sdk, adapter) {
137
- if (adapter instanceof ERC4626AdapterContract) {
138
- const meta = sdk.tokensMeta.get(adapter.share);
139
- return !!meta && sdk.tokensMeta.isRWAUnderlying(meta);
140
- }
141
- return false;
142
- }
143
128
  //#endregion
144
129
  export { makeReplayState, replayInnerOperations };
@@ -84,6 +84,12 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
84
84
  filter(response, filter) {
85
85
  return filterResponse(response, filter, matchesOpportunityFilter);
86
86
  }
87
+ /**
88
+ * {@inheritDoc OpportunitiesOffchainOnly.totals}
89
+ **/
90
+ async totals() {
91
+ return this.offchain.getTotals();
92
+ }
87
93
  async charts(key, metrics, range) {
88
94
  return this.offchain.getCharts(key, metrics, range);
89
95
  }
@@ -40,6 +40,12 @@ var PositionsNamespace = class extends AbstractNamespace {
40
40
  filter(response, filter) {
41
41
  return filterResponse(response, filter, matchesPositionFilter);
42
42
  }
43
+ /**
44
+ * {@inheritDoc PositionsOffchainOnly.totals}
45
+ **/
46
+ async totals(wallet) {
47
+ return this.offchain.getTotals(wallet);
48
+ }
43
49
  async charts(key, metrics, range) {
44
50
  return this.offchain.getCharts(key, metrics, range);
45
51
  }
@@ -22,7 +22,7 @@ type ChartRange = (typeof CHART_RANGES)[number];
22
22
  /**
23
23
  * Every metric a pool opportunity can chart.
24
24
  **/
25
- declare const POOL_OPPORTUNITY_CHART_METRICS: readonly ["depositApy", "depositApyAvg7d", "dieselRate", "supplied", "borrowed"];
25
+ declare const POOL_OPPORTUNITY_CHART_METRICS: readonly ["depositApy", "depositApyAvg7d", "dieselRate", "supplied", "borrowed", "utilization"];
26
26
  /**
27
27
  * Metric a pool opportunity can chart. Derived from the runtime list that also
28
28
  * builds the backend's route enum, so the two cannot drift.
@@ -49,7 +49,7 @@ type StrategyOpportunityChartMetric = (typeof STRATEGY_OPPORTUNITY_CHART_METRICS
49
49
  * deposits and withdrawals landed. It is anchored at inception, so a narrow
50
50
  * `range` only zooms the visible slice and its first point is rarely zero.
51
51
  **/
52
- declare const POOL_POSITION_CHART_METRICS: readonly ["apy", "pnl", "mwr"];
52
+ declare const POOL_POSITION_CHART_METRICS: readonly ["apy", "apyAvg7d", "pnl", "mwr"];
53
53
  /**
54
54
  * Metric a pool position can chart, derived from
55
55
  * {@link POOL_POSITION_CHART_METRICS}.
@@ -168,11 +168,13 @@ declare const CHART_METRIC_UNITS: {
168
168
  readonly supplied: "token";
169
169
  readonly borrowed: "token";
170
170
  readonly tvl: "token";
171
+ readonly utilization: "bps";
171
172
  readonly dieselRate: "ratio";
172
173
  readonly collateralPrice: "ratio";
173
174
  readonly collateralUsdPrice: "usd";
174
175
  readonly underlyingUsdPrice: "usd";
175
176
  readonly apy: "bps";
177
+ readonly apyAvg7d: "bps";
176
178
  readonly pnl: "token";
177
179
  readonly mwr: "bps";
178
180
  readonly totalValueUnderlying: "token";
@@ -29,6 +29,7 @@ declare const poolOpportunityChartMetricSchema: z.ZodEnum<{
29
29
  depositApyAvg7d: "depositApyAvg7d";
30
30
  dieselRate: "dieselRate";
31
31
  supplied: "supplied";
32
+ utilization: "utilization";
32
33
  }>;
33
34
  /**
34
35
  * {@link StrategyOpportunityChartMetric}
@@ -49,6 +50,7 @@ declare const strategyOpportunityChartMetricSchema: z.ZodEnum<{
49
50
  **/
50
51
  declare const poolPositionChartMetricSchema: z.ZodEnum<{
51
52
  apy: "apy";
53
+ apyAvg7d: "apyAvg7d";
52
54
  mwr: "mwr";
53
55
  pnl: "pnl";
54
56
  }>;
@@ -74,6 +76,7 @@ declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
74
76
  depositApyAvg7d: "depositApyAvg7d";
75
77
  dieselRate: "dieselRate";
76
78
  supplied: "supplied";
79
+ utilization: "utilization";
77
80
  }>, z.ZodEnum<{
78
81
  borrowApy: "borrowApy";
79
82
  borrowApyAvg7d: "borrowApyAvg7d";
@@ -86,6 +89,7 @@ declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
86
89
  underlyingUsdPrice: "underlyingUsdPrice";
87
90
  }>, z.ZodEnum<{
88
91
  apy: "apy";
92
+ apyAvg7d: "apyAvg7d";
89
93
  mwr: "mwr";
90
94
  pnl: "pnl";
91
95
  }>, z.ZodEnum<{
@@ -108,6 +112,7 @@ declare const chartQuerySchema: z.ZodObject<{
108
112
  depositApyAvg7d: "depositApyAvg7d";
109
113
  dieselRate: "dieselRate";
110
114
  supplied: "supplied";
115
+ utilization: "utilization";
111
116
  }>, z.ZodEnum<{
112
117
  borrowApy: "borrowApy";
113
118
  borrowApyAvg7d: "borrowApyAvg7d";
@@ -120,6 +125,7 @@ declare const chartQuerySchema: z.ZodObject<{
120
125
  underlyingUsdPrice: "underlyingUsdPrice";
121
126
  }>, z.ZodEnum<{
122
127
  apy: "apy";
128
+ apyAvg7d: "apyAvg7d";
123
129
  mwr: "mwr";
124
130
  pnl: "pnl";
125
131
  }>, z.ZodEnum<{
@@ -179,6 +185,7 @@ declare const chartQueryCodec: z.ZodCodec<z.ZodObject<{
179
185
  depositApyAvg7d: "depositApyAvg7d";
180
186
  dieselRate: "dieselRate";
181
187
  supplied: "supplied";
188
+ utilization: "utilization";
182
189
  }>, z.ZodEnum<{
183
190
  borrowApy: "borrowApy";
184
191
  borrowApyAvg7d: "borrowApyAvg7d";
@@ -191,6 +198,7 @@ declare const chartQueryCodec: z.ZodCodec<z.ZodObject<{
191
198
  underlyingUsdPrice: "underlyingUsdPrice";
192
199
  }>, z.ZodEnum<{
193
200
  apy: "apy";
201
+ apyAvg7d: "apyAvg7d";
194
202
  mwr: "mwr";
195
203
  pnl: "pnl";
196
204
  }>, z.ZodEnum<{
@@ -9,14 +9,14 @@ import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } fro
9
9
  import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
10
10
  import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
11
11
  import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
12
- import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, 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
- import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
12
+ 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
+ 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";
14
14
  import { Notice, NoticeKind, NoticeSubject } from "./notices.js";
15
15
  import { noticeKindSchema, noticeSchema } from "./notices.schema.js";
16
- 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";
16
+ 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
17
  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 { AdjustCreditAccountPreview, CloseCreditAccountPreview, DelayedCreditAccountOperationPreview, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP, ERROR_UNPRICEABLE_TOKEN, InstantOperationPreview, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, PoolOperationPreview, PoolOperationType, PreviewOperationInput, PreviewOperationOptions, RepayCreditAccountPreview } from "./previews.js";
18
+ import { AdjustCreditAccountPreview, CloseCreditAccountPreview, DelayedCreditAccountOperationPreview, 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, InstantOperationPreview, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, PoolOperationPreview, PoolOperationType, PreviewOperationInput, PreviewOperationOptions, RepayCreditAccountPreview } 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";
22
- export { AdjustCreditAccountPreview, Amount, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CloseCreditAccountPreview, CompareTag, CompareTolerance, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedCreditAccountOperationPreview, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedWithdrawCollateralIntent, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP, ERROR_UNPRICEABLE_TOKEN, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantOperationPreview, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreview, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayCreditAccountPreview, ResponseMetadata, Rewards, RewardsPnL, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, amountSchema, apyBreakdownSchema, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema };
22
+ export { AdjustCreditAccountPreview, Amount, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CloseCreditAccountPreview, CompareTag, CompareTolerance, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedCreditAccountOperationPreview, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedWithdrawCollateralIntent, 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, FILTER_ALL, FilterAll, Filterable, GridSampling, InstantOperationPreview, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Notice, NoticeKind, NoticeSubject, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreview, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionRef, Position, PositionChartMetric, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayCreditAccountPreview, ResponseMetadata, Rewards, RewardsPnL, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, amountSchema, apyBreakdownSchema, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema };
@@ -626,5 +626,23 @@ interface StrategyOpportunityRef extends StrategyOpportunityKey {
626
626
  * Identifies any opportunity, for requests that accept both kinds.
627
627
  **/
628
628
  type OpportunityKey = PoolOpportunityRef | StrategyOpportunityRef;
629
+ /**
630
+ * Protocol-wide aggregate over every opportunity, served by the backend rather
631
+ * than summed by a consumer: the landing page's headline figures.
632
+ **/
633
+ interface OpportunityTotals {
634
+ /**
635
+ * Total value locked in Gearbox Protocol
636
+ **/
637
+ tvl: number;
638
+ /**
639
+ * Total borrowed from pools in Gearbox Protocol
640
+ **/
641
+ totalBorrowed: number;
642
+ /**
643
+ * Total supplied to pools in Gearbox Protocol
644
+ **/
645
+ totalSupply: number;
646
+ }
629
647
  //#endregion
630
- export { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId };
648
+ export { 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 };
@@ -1446,5 +1446,13 @@ declare const opportunityKeySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1446
1446
  creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
1447
1447
  kind: z.ZodLiteral<"strategy">;
1448
1448
  }, z.core.$strip>], "kind">;
1449
+ /**
1450
+ * {@link OpportunityTotals}
1451
+ **/
1452
+ declare const opportunityTotalsSchema: z.ZodObject<{
1453
+ tvl: z.ZodNumber;
1454
+ totalBorrowed: z.ZodNumber;
1455
+ totalSupply: z.ZodNumber;
1456
+ }, z.core.$strip>;
1449
1457
  //#endregion
1450
- export { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema };
1458
+ export { 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 };
@@ -181,6 +181,11 @@ interface BorrowRateBreakdown {
181
181
  **/
182
182
  quotas: TokenQuotaRate[];
183
183
  }
184
+ /**
185
+ * Set on {@link StrategyPosition.error} when the account could not be fully
186
+ * valued (e.g. a dead price feed).
187
+ **/
188
+ declare const STRATEGY_POSITION_COLLATERAL_ERROR = "collateral computation failed";
184
189
  /**
185
190
  * An open credit account of a wallet.
186
191
  **/
@@ -316,6 +321,13 @@ interface StrategyPosition {
316
321
  * withdrawals.
317
322
  **/
318
323
  collaterals: PositionCollateral[];
324
+ /**
325
+ * Present when the account could not be fully valued (e.g. a dead price
326
+ * feed). Identity, balances, and debt principal are still filled; valued
327
+ * fields are best-effort. Set by either the chain compressor path or the
328
+ * backend.
329
+ **/
330
+ error?: string;
319
331
  }
320
332
  /**
321
333
  * A row of the positions list: anything a wallet holds in the protocol.
@@ -491,4 +503,4 @@ interface PositionTransaction {
491
503
  assets: TokenAmount[];
492
504
  }
493
505
  //#endregion
494
- export { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId };
506
+ export { 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 };
@@ -545,6 +545,7 @@ declare const strategyPositionSchema: z.ZodObject<{
545
545
  claimableAt: z.ZodOptional<z.ZodNumber>;
546
546
  }, z.core.$strip>>;
547
547
  }, z.core.$strip>>;
548
+ error: z.ZodOptional<z.ZodString>;
548
549
  }, z.core.$strip>;
549
550
  /**
550
551
  * {@link Position}
@@ -891,6 +892,7 @@ declare const positionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
891
892
  claimableAt: z.ZodOptional<z.ZodNumber>;
892
893
  }, z.core.$strip>>;
893
894
  }, z.core.$strip>>;
895
+ error: z.ZodOptional<z.ZodString>;
894
896
  }, z.core.$strip>, z.ZodObject<{
895
897
  kind: z.ZodLiteral<"liquidation">;
896
898
  name: z.ZodString;
@@ -64,9 +64,10 @@ declare const ERROR_NON_ADAPTER_CALL_IN_BRACKET = 1003;
64
64
  **/
65
65
  declare const ERROR_UNPREVIEWABLE_ADAPTER_CALL = 1004;
66
66
  /**
67
- * Out-of-bracket RWA wrap/unwrap calldata cannot be decoded
67
+ * An out-of-bracket adapter call that is allowed there (e.g. RWA wrap/unwrap)
68
+ * could not be decoded or replayed
68
69
  **/
69
- declare const ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP = 1005;
70
+ declare const ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL = 1005;
70
71
  /**
71
72
  * `msg.value` does not fit into the declared WETH collateral
72
73
  * Transactions can have arbitrary value, but the ones that we create
@@ -467,4 +468,4 @@ interface DelayedCreditAccountOperationPreview {
467
468
  */
468
469
  type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview | CloseCreditAccountPreview | RepayCreditAccountPreview | DelayedCreditAccountOperationPreview;
469
470
  //#endregion
470
- export { AdjustCreditAccountPreview, CloseCreditAccountPreview, DelayedCreditAccountOperationPreview, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP, ERROR_UNPRICEABLE_TOKEN, InstantOperationPreview, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, PoolOperationPreview, PoolOperationType, PreviewOperationInput, PreviewOperationOptions, RepayCreditAccountPreview };
471
+ export { AdjustCreditAccountPreview, CloseCreditAccountPreview, DelayedCreditAccountOperationPreview, 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, InstantOperationPreview, OpenCreditAccountPreview, OperationPreview, OperationPreviewError, PoolOperationPreview, PoolOperationType, PreviewOperationInput, PreviewOperationOptions, RepayCreditAccountPreview };
@@ -1,5 +1,5 @@
1
1
  import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
2
- import { Opportunity, OpportunityFilter, OpportunityKey, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
2
+ import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { GearboxAPIOptions } from "../types.js";
5
5
  import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
@@ -27,6 +27,10 @@ declare class OffchainOpportunities extends AbstractOffchainNamespace {
27
27
  * Detailed view of one strategy opportunity.
28
28
  **/
29
29
  getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
30
+ /**
31
+ * Protocol-wide totals across every opportunity the backend serves.
32
+ **/
33
+ getTotals(): Promise<DataResponse<OpportunityTotals>>;
30
34
  /**
31
35
  * Charts of one opportunity: one series per metric, on a shared grid.
32
36
  **/
@@ -1,9 +1,10 @@
1
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
- import { Position, PositionKey } from "../../model/positions.js";
2
+ import { Position, PositionKey, PositionsTotals } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
5
5
  import { GearboxAPIOptions } from "../types.js";
6
6
  import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
7
+ import { Address } from "viem";
7
8
  //#region src/offchain/positions/OffchainPositions.d.ts
8
9
  type PositionChartMetricFor<K extends PositionKey> = {
9
10
  pool: PoolPositionChartMetric;
@@ -19,6 +20,10 @@ declare class OffchainPositions extends AbstractOffchainNamespace {
19
20
  * Everything a wallet holds, optionally narrowed by {@link PositionFilter}.
20
21
  **/
21
22
  list(props: ListPositionsPropsBase): Promise<DataResponse<Position[]>>;
23
+ /**
24
+ * Aggregate over everything a wallet holds, see {@link PositionsTotals}.
25
+ **/
26
+ getTotals(wallet: Address): Promise<DataResponse<PositionsTotals>>;
22
27
  /**
23
28
  * Charts of one position: one series per metric, on a shared grid.
24
29
  **/
@@ -57,6 +57,18 @@ declare class AbstractAdapterContract<const abi extends Abi | readonly unknown[]
57
57
  * specific function) has no balance-changes support.
58
58
  */
59
59
  previewBalanceChanges(balances: AssetsMap, calldata: Hex): Promise<void>;
60
+ /**
61
+ * Replays this adapter call when it appears outside a
62
+ * storeExpectedBalances/compareBalances bracket, mutating `balances` in
63
+ * place, and returns `true` when the call is legal there.
64
+ *
65
+ * Base implementation returns `false`: nothing enforces the outcome of an
66
+ * out-of-bracket adapter call on-chain, so it cannot be previewed.
67
+ *
68
+ * @throws when the call is allowed outside a bracket but its calldata
69
+ * cannot be decoded
70
+ */
71
+ replayOutOfBracketCall(_balances: AssetsMap, _calldata: Hex): boolean;
60
72
  /**
61
73
  * Applies the balance changes of a decoded adapter call to the running
62
74
  * balances, mutating them in place. Overrides should express changes via
@@ -5,7 +5,7 @@ import { AbstractAdapterContract, ConcreteAdapterContractOptions } from "./Abstr
5
5
  import { OnchainSDK } from "../../../OnchainSDK.js";
6
6
  import "../../../utils/index.js";
7
7
  import "../../../base/index.js";
8
- import { Address, DecodeFunctionDataReturnType } from "viem";
8
+ import { Address, DecodeFunctionDataReturnType, Hex } from "viem";
9
9
  //#region src/onchain/market/adapters/contracts/ERC4626AdapterContract.d.ts
10
10
  declare const abi: readonly [{
11
11
  readonly type: "function";
@@ -682,6 +682,13 @@ declare class ERC4626AdapterContract extends AbstractAdapterContract<abi, protoc
682
682
  * @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
683
683
  */
684
684
  classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
685
+ /**
686
+ * Out-of-bracket calls are legal only on the RWA wrap/unwrap adapter (the
687
+ * share converts 1:1 with the vault asset, so no on-chain preview or
688
+ * slippage bracket is needed); a regular vault-strategy ERC4626 adapter
689
+ * keeps the base behavior and returns false.
690
+ */
691
+ replayOutOfBracketCall(balances: AssetsMap, calldata: Hex): boolean;
685
692
  protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
686
693
  }
687
694
  //#endregion