@gearbox-protocol/sdk 14.12.0-next.66 → 14.12.0-next.67

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 (225) hide show
  1. package/dist/cjs/common-utils/index.js +2 -2
  2. package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +3 -3
  3. package/dist/cjs/common-utils/utils/assets-math.js +7 -7
  4. package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +2 -2
  5. package/dist/cjs/common-utils/utils/creditAccount/debt.js +2 -2
  6. package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +5 -5
  7. package/dist/cjs/common-utils/utils/index.js +2 -2
  8. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +2 -2
  9. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +5 -5
  10. package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +2 -2
  11. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +2 -2
  12. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +4 -4
  13. package/dist/cjs/model/history.js +28 -0
  14. package/dist/cjs/model/history.schema.js +84 -0
  15. package/dist/cjs/model/index.js +64 -0
  16. package/dist/cjs/model/liquidations.js +23 -0
  17. package/dist/cjs/model/liquidations.schema.js +91 -0
  18. package/dist/cjs/model/opportunities.js +55 -0
  19. package/dist/cjs/model/opportunities.schema.js +220 -0
  20. package/dist/cjs/model/package.json +1 -0
  21. package/dist/cjs/model/positions.js +1 -0
  22. package/dist/cjs/model/primitives.js +1 -0
  23. package/dist/cjs/model/primitives.schema.js +85 -0
  24. package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
  25. package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
  26. package/dist/cjs/new-sdk/index.js +11 -0
  27. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
  28. package/dist/cjs/new-sdk/opportunities/index.js +4 -0
  29. package/dist/cjs/new-sdk/opportunities/types.js +1 -0
  30. package/dist/cjs/new-sdk/package.json +1 -0
  31. package/dist/cjs/new-sdk/types.js +22 -0
  32. package/dist/cjs/new-sdk/utils/history.js +1 -0
  33. package/dist/cjs/new-sdk/utils/index.js +2 -0
  34. package/dist/cjs/offchain/GearboxAPI.js +33 -0
  35. package/dist/cjs/offchain/index.js +8 -0
  36. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
  37. package/dist/cjs/offchain/opportunities/index.js +4 -0
  38. package/dist/cjs/offchain/package.json +1 -0
  39. package/dist/cjs/offchain/types.js +1 -0
  40. package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
  41. package/dist/cjs/rewards/rewards/api.js +2 -2
  42. package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
  43. package/dist/cjs/sdk/MultichainSDK.js +18 -2
  44. package/dist/cjs/sdk/OnchainSDK.js +8 -1
  45. package/dist/cjs/sdk/accounts/index.js +2 -0
  46. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +150 -106
  47. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  48. package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
  49. package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
  50. package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
  51. package/dist/cjs/sdk/base/TokensMeta.js +51 -0
  52. package/dist/cjs/sdk/base/index.js +2 -0
  53. package/dist/cjs/sdk/chain/chains.js +76 -0
  54. package/dist/cjs/sdk/chain/index.js +4 -0
  55. package/dist/cjs/sdk/core/errors.js +13 -0
  56. package/dist/cjs/sdk/core/index.js +2 -1
  57. package/dist/cjs/sdk/index.js +25 -1
  58. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
  59. package/dist/cjs/sdk/market/MarketSuite.js +163 -0
  60. package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  61. package/dist/cjs/sdk/market/credit/CreditSuite.js +102 -0
  62. package/dist/cjs/sdk/market/math.js +104 -0
  63. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  64. package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  65. package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  66. package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
  67. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
  68. package/dist/cjs/sdk/market/pool/math.js +44 -0
  69. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  70. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
  71. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +103 -0
  72. package/dist/cjs/sdk/opportunities/index.js +12 -0
  73. package/dist/cjs/sdk/types/multichain.js +1 -0
  74. package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
  75. package/dist/cjs/sdk/utils/index.js +3 -0
  76. package/dist/cjs/sdk/utils/zod.js +12 -0
  77. package/dist/esm/common-utils/index.js +1 -1
  78. package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
  79. package/dist/esm/common-utils/utils/assets-math.js +1 -1
  80. package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
  81. package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
  82. package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
  83. package/dist/esm/common-utils/utils/index.js +1 -1
  84. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
  85. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
  86. package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
  87. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
  88. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
  89. package/dist/esm/model/history.js +26 -0
  90. package/dist/esm/model/history.schema.js +76 -0
  91. package/dist/esm/model/index.js +9 -0
  92. package/dist/esm/model/liquidations.js +22 -0
  93. package/dist/esm/model/liquidations.schema.js +83 -0
  94. package/dist/esm/model/opportunities.js +51 -0
  95. package/dist/esm/model/opportunities.schema.js +198 -0
  96. package/dist/esm/model/package.json +1 -0
  97. package/dist/esm/model/positions.js +1 -0
  98. package/dist/esm/model/primitives.js +1 -0
  99. package/dist/esm/model/primitives.schema.js +75 -0
  100. package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
  101. package/dist/esm/new-sdk/GearboxSDK.js +121 -0
  102. package/dist/esm/new-sdk/index.js +7 -0
  103. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
  104. package/dist/esm/new-sdk/opportunities/index.js +3 -0
  105. package/dist/esm/new-sdk/opportunities/types.js +1 -0
  106. package/dist/esm/new-sdk/package.json +1 -0
  107. package/dist/esm/new-sdk/types.js +21 -0
  108. package/dist/esm/new-sdk/utils/history.js +1 -0
  109. package/dist/esm/new-sdk/utils/index.js +2 -0
  110. package/dist/esm/offchain/GearboxAPI.js +32 -0
  111. package/dist/esm/offchain/index.js +5 -0
  112. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
  113. package/dist/esm/offchain/opportunities/index.js +2 -0
  114. package/dist/esm/offchain/package.json +1 -0
  115. package/dist/esm/offchain/types.js +1 -0
  116. package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
  117. package/dist/esm/rewards/rewards/api.js +1 -1
  118. package/dist/esm/rewards/rewards/extra-apy.js +1 -1
  119. package/dist/esm/sdk/MultichainSDK.js +18 -2
  120. package/dist/esm/sdk/OnchainSDK.js +8 -1
  121. package/dist/esm/sdk/accounts/index.js +2 -2
  122. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +152 -108
  123. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  124. package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
  125. package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
  126. package/dist/esm/sdk/base/MultichainConstruct.js +79 -0
  127. package/dist/esm/sdk/base/TokensMeta.js +51 -0
  128. package/dist/esm/sdk/base/index.js +2 -1
  129. package/dist/esm/sdk/chain/chains.js +74 -2
  130. package/dist/esm/sdk/chain/index.js +2 -2
  131. package/dist/esm/sdk/core/errors.js +13 -1
  132. package/dist/esm/sdk/core/index.js +2 -2
  133. package/dist/esm/sdk/index.js +11 -5
  134. package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
  135. package/dist/esm/sdk/market/MarketSuite.js +163 -0
  136. package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  137. package/dist/esm/sdk/market/credit/CreditSuite.js +102 -0
  138. package/dist/esm/sdk/market/math.js +98 -0
  139. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  140. package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  141. package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  142. package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
  143. package/dist/esm/sdk/market/pool/PoolV310Contract.js +27 -0
  144. package/dist/esm/sdk/market/pool/math.js +41 -0
  145. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  146. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +59 -0
  147. package/dist/esm/sdk/opportunities/OpportunitiesService.js +102 -0
  148. package/dist/esm/sdk/opportunities/index.js +4 -0
  149. package/dist/esm/sdk/types/multichain.js +1 -0
  150. package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
  151. package/dist/esm/sdk/utils/index.js +3 -2
  152. package/dist/esm/sdk/utils/zod.js +13 -2
  153. package/dist/types/common-utils/index.d.ts +1 -1
  154. package/dist/types/common-utils/utils/index.d.ts +1 -1
  155. package/dist/types/model/history.d.ts +105 -0
  156. package/dist/types/model/history.schema.d.ts +66 -0
  157. package/dist/types/model/index.d.ts +9 -0
  158. package/dist/types/model/liquidations.d.ts +230 -0
  159. package/dist/types/model/liquidations.schema.d.ts +292 -0
  160. package/dist/types/model/opportunities.d.ts +543 -0
  161. package/dist/types/model/opportunities.schema.d.ts +1066 -0
  162. package/dist/types/model/positions.d.ts +11 -0
  163. package/dist/types/model/primitives.d.ts +193 -0
  164. package/dist/types/model/primitives.schema.d.ts +81 -0
  165. package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
  166. package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
  167. package/dist/types/new-sdk/index.d.ts +9 -0
  168. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
  169. package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
  170. package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
  171. package/dist/types/new-sdk/types.d.ts +149 -0
  172. package/dist/types/new-sdk/utils/history.d.ts +44 -0
  173. package/dist/types/new-sdk/utils/index.d.ts +2 -0
  174. package/dist/types/offchain/GearboxAPI.d.ts +31 -0
  175. package/dist/types/offchain/index.d.ts +5 -0
  176. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
  177. package/dist/types/offchain/opportunities/index.d.ts +2 -0
  178. package/dist/types/offchain/types.d.ts +50 -0
  179. package/dist/types/sdk/MultichainSDK.d.ts +15 -2
  180. package/dist/types/sdk/OnchainSDK.d.ts +9 -3
  181. package/dist/types/sdk/accounts/index.d.ts +3 -3
  182. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
  183. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
  184. package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
  185. package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
  186. package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
  187. package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
  188. package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
  189. package/dist/types/sdk/base/index.d.ts +2 -1
  190. package/dist/types/sdk/chain/chains.d.ts +68 -1
  191. package/dist/types/sdk/chain/index.d.ts +2 -2
  192. package/dist/types/sdk/core/errors.d.ts +10 -1
  193. package/dist/types/sdk/core/index.d.ts +2 -2
  194. package/dist/types/sdk/index.d.ts +15 -8
  195. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
  196. package/dist/types/sdk/market/MarketSuite.d.ts +109 -1
  197. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
  198. package/dist/types/sdk/market/credit/CreditSuite.d.ts +47 -0
  199. package/dist/types/sdk/market/credit/types.d.ts +22 -0
  200. package/dist/types/sdk/market/index.d.ts +2 -2
  201. package/dist/types/sdk/market/math.d.ts +74 -0
  202. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
  203. package/dist/types/sdk/market/oracle/types.d.ts +46 -0
  204. package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
  205. package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
  206. package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
  207. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
  208. package/dist/types/sdk/market/pool/math.d.ts +57 -0
  209. package/dist/types/sdk/market/pool/types.d.ts +23 -0
  210. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
  211. package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
  212. package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
  213. package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +47 -0
  214. package/dist/types/sdk/opportunities/index.d.ts +4 -0
  215. package/dist/types/sdk/types/index.d.ts +2 -1
  216. package/dist/types/sdk/types/multichain.d.ts +65 -0
  217. package/dist/types/sdk/types/state.d.ts +1 -1
  218. package/dist/types/sdk/types/transactions.d.ts +3 -0
  219. package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
  220. package/dist/types/sdk/utils/index.d.ts +3 -2
  221. package/dist/types/sdk/utils/zod.d.ts +6 -2
  222. package/package.json +16 -1
  223. package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
  224. package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
  225. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
@@ -0,0 +1,105 @@
1
+ import { Timestamp } from "./primitives.js";
2
+ import { OpportunityKey } from "./opportunities.js";
3
+ //#region src/model/history.d.ts
4
+ /**
5
+ * Historical time series of an opportunity.
6
+ *
7
+ * History is backend-only by construction: the chain serves the present, and
8
+ * reconstructing a series from it would mean archive-node reads per point.
9
+ **/
10
+ /**
11
+ * Time window a series covers, ending at the present.
12
+ *
13
+ * `"max"` is the full history the backend retains for the opportunity.
14
+ **/
15
+ type HistoryRange = "1d" | "1w" | "1m" | "1y" | "max";
16
+ /**
17
+ * Series available for a pool opportunity.
18
+ **/
19
+ type PoolHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
20
+ /**
21
+ * Every {@link PoolHistoryMetric}, for callers that enumerate them.
22
+ **/
23
+ declare const POOL_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
24
+ /**
25
+ * Series available for a strategy opportunity.
26
+ *
27
+ * `collateralPrice` is the collateral/underlying series a liquidation-price
28
+ * chart draws; the two USD series are the same prices quoted in dollars.
29
+ **/
30
+ type StrategyHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
31
+ /**
32
+ * Every {@link StrategyHistoryMetric}, for callers that enumerate them.
33
+ **/
34
+ declare const STRATEGY_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
35
+ /**
36
+ * Any series the read model can return.
37
+ **/
38
+ type HistoryMetric = PoolHistoryMetric | StrategyHistoryMetric;
39
+ /**
40
+ * One sample of a series.
41
+ **/
42
+ interface HistoryPoint {
43
+ /**
44
+ * When the sample was taken.
45
+ **/
46
+ timestamp: Timestamp;
47
+ /**
48
+ * Sampled value. The unit follows from the metric: APY metrics are in basis
49
+ * points, amount metrics are in the underlying's base units expressed as a
50
+ * float, price metrics are plain prices.
51
+ *
52
+ * @example `842` for an 8.42% APY sample
53
+ **/
54
+ value: number;
55
+ }
56
+ /**
57
+ * Annotations the backend ships alongside a series, e.g. what a chart drawn
58
+ * from it should say beyond the points themselves.
59
+ *
60
+ * TODO: the backend has not specified this payload yet. It stays empty until
61
+ * it does, so that filling it in later is additive rather than a rename.
62
+ **/
63
+ interface HistoryChartMetadata {}
64
+ /**
65
+ * A named series of samples ordered by ascending timestamp.
66
+ *
67
+ * @typeParam M - Metric the series carries.
68
+ **/
69
+ interface HistorySeries<M extends string = HistoryMetric> {
70
+ /**
71
+ * Metric the samples belong to; it also defines their unit, so no separate
72
+ * unit field ships.
73
+ **/
74
+ metric: M;
75
+ /**
76
+ * Samples, oldest first.
77
+ **/
78
+ points: HistoryPoint[];
79
+ /**
80
+ * What the backend says about the series, see {@link HistoryChartMetadata}.
81
+ **/
82
+ metadata: HistoryChartMetadata;
83
+ }
84
+ /**
85
+ * A request for one series of a single opportunity.
86
+ *
87
+ * @typeParam M - Metric requested.
88
+ **/
89
+ interface OpportunityHistoryQuery<M extends HistoryMetric = HistoryMetric> {
90
+ /**
91
+ * Opportunity the series belongs to.
92
+ **/
93
+ opportunity: OpportunityKey;
94
+ /**
95
+ * Window to cover.
96
+ **/
97
+ range: HistoryRange;
98
+ /**
99
+ * Metric to return. A metric that does not apply to the opportunity's kind
100
+ * has no series.
101
+ **/
102
+ metric: M;
103
+ }
104
+ //#endregion
105
+ export { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, PoolHistoryMetric, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric };
@@ -0,0 +1,66 @@
1
+ import { HistoryChartMetadata } from "./history.js";
2
+ import { z } from "zod/v4";
3
+ //#region src/model/history.schema.d.ts
4
+ /**
5
+ * Runtime schemas for {@link ./history.js}, see the note in
6
+ * `primitives.schema.ts` on why they are written by hand.
7
+ **/
8
+ /**
9
+ * {@link HistoryRange}
10
+ **/
11
+ declare const historyRangeSchema: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
12
+ /**
13
+ * {@link PoolHistoryMetric}
14
+ **/
15
+ declare const poolHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>;
16
+ /**
17
+ * {@link StrategyHistoryMetric}
18
+ **/
19
+ declare const strategyHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>;
20
+ /**
21
+ * {@link HistoryMetric}
22
+ **/
23
+ declare const historyMetricSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
24
+ /**
25
+ * {@link HistoryPoint}
26
+ **/
27
+ declare const historyPointSchema: z.ZodObject<{
28
+ timestamp: z.ZodNumber;
29
+ value: z.ZodNumber;
30
+ }, z.core.$strip>;
31
+ /**
32
+ * {@link HistoryChartMetadata}
33
+ *
34
+ * TODO: empty until the backend specifies the payload.
35
+ **/
36
+ declare const historyChartMetadataSchema: z.ZodType<HistoryChartMetadata>;
37
+ /**
38
+ * {@link HistorySeries}
39
+ **/
40
+ declare const historySeriesSchema: z.ZodObject<{
41
+ metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
42
+ points: z.ZodArray<z.ZodObject<{
43
+ timestamp: z.ZodNumber;
44
+ value: z.ZodNumber;
45
+ }, z.core.$strip>>;
46
+ metadata: z.ZodType<HistoryChartMetadata, unknown, z.core.$ZodTypeInternals<HistoryChartMetadata, unknown>>;
47
+ }, z.core.$strip>;
48
+ /**
49
+ * {@link OpportunityHistoryQuery}
50
+ **/
51
+ declare const opportunityHistoryQuerySchema: z.ZodObject<{
52
+ opportunity: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
+ chainId: z.ZodNumber;
54
+ pool: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
55
+ kind: z.ZodLiteral<"pool">;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ chainId: z.ZodNumber;
58
+ creditManager: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
59
+ targetCollateral: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
60
+ kind: z.ZodLiteral<"strategy">;
61
+ }, z.core.$strip>], "kind">;
62
+ range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
63
+ metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
64
+ }, z.core.$strip>;
65
+ //#endregion
66
+ export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema };
@@ -0,0 +1,9 @@
1
+ import { Amount, AssetType, Bps, ChainId, Curator, Leverage, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
2
+ 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";
3
+ import { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, PoolHistoryMetric, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric } from "./history.js";
4
+ import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema } from "./history.schema.js";
5
+ import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
6
+ import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
7
+ import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
8
+ import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
9
+ export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, DelayedReceivedAsset, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, PointRewards, PointsProgram, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, Timestamp, Token, TokenAmount, TokenRewards, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, delayedReceivedAssetSchema, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, timestampSchema, tokenAmountSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
@@ -0,0 +1,230 @@
1
+ import { AssetType, ChainId, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
2
+ import { Address } from "viem";
3
+ //#region src/model/liquidations.d.ts
4
+ /**
5
+ * Optional narrowing of a liquidatable accounts list.
6
+ *
7
+ * Every criterion is optional and an omitted one matches any value, so an empty
8
+ * filter is the same as no filter at all. Criteria combine with AND.
9
+ **/
10
+ interface LiquidatableAccountFilter {
11
+ /**
12
+ * Keep only accounts on these chains.
13
+ **/
14
+ chainIds?: ChainId[];
15
+ /**
16
+ * Keep only accounts whose underlying — the token of
17
+ * {@link LiquidatableAccount.totalValue} — is of this class.
18
+ **/
19
+ underlyingType?: AssetType;
20
+ /**
21
+ * Keep only accounts of paused credit facades, or only of unpaused ones.
22
+ **/
23
+ paused?: boolean;
24
+ /**
25
+ * Keep only accounts in markets that accept RWA collateral, or only the ones
26
+ * outside them.
27
+ **/
28
+ rwa?: boolean;
29
+ /**
30
+ * Keep only accounts with (`true`) or without (`false`) delayed
31
+ * (phantom-token) withdrawals.
32
+ **/
33
+ delayed?: boolean;
34
+ }
35
+ /**
36
+ * A credit account that can be liquidated, with amounts precomputed for
37
+ * manual liquidation.
38
+ **/
39
+ interface LiquidatableAccount {
40
+ /**
41
+ * Chain the account lives on.
42
+ **/
43
+ chainId: ChainId;
44
+ /**
45
+ * Credit account address.
46
+ **/
47
+ creditAccount: Address;
48
+ /**
49
+ * Credit manager the account is opened in.
50
+ **/
51
+ creditManager: Address;
52
+ /**
53
+ * Main asset being liquidated: the most valuable enabled non-underlying
54
+ * collateral token. For delayed-withdrawal phantom tokens, the source
55
+ * asset (e.g. ACRED) is reported instead of the phantom token. Falls back
56
+ * to the underlying when the account holds no other collateral.
57
+ **/
58
+ asset: Token;
59
+ /**
60
+ * Account total value. The token is the unwrapped asset (e.g. USDC) for
61
+ * RWA credit managers (1:1 with the wrapped underlying), the credit
62
+ * manager underlying otherwise.
63
+ **/
64
+ totalValue: TokenAmount;
65
+ /**
66
+ * Estimated amount the liquidator pays to fully liquidate the account:
67
+ * `totalValue * liquidationDiscount`. Same token as {@link totalValue}.
68
+ **/
69
+ repaymentAmount: TokenAmount;
70
+ /**
71
+ * Estimated liquidator profit: `totalValue * (1 - liquidationDiscount)`.
72
+ * Same token as {@link totalValue}.
73
+ **/
74
+ estimatedProfit: TokenAmount;
75
+ /**
76
+ * `true` when the account holds a delayed-withdrawal phantom token above
77
+ * dust, i.e. the liquidation transfers withdrawal redeemers into the
78
+ * liquidator's ownership instead of instantly receivable tokens.
79
+ **/
80
+ isDelayed: boolean;
81
+ /**
82
+ * `true` when the credit manager's facade is paused. Liquidations of such
83
+ * accounts only succeed for emergency liquidators approved in the market.
84
+ **/
85
+ paused: boolean;
86
+ /**
87
+ * Whether the account's market accepts real-world-asset collateral. Read
88
+ * from a hardcoded per-chain list rather than from the chain.
89
+ **/
90
+ rwa: boolean;
91
+ }
92
+ /**
93
+ * Whether a liquidatable account satisfies every criterion of a filter.
94
+ *
95
+ * This is the single definition of what each criterion means: every source
96
+ * builds its rows first and runs them through here, so the chain and the
97
+ * backend cannot disagree on what a filter selects.
98
+ *
99
+ * @param account - Row to test.
100
+ * @param filter - Criteria to test against. An absent filter matches anything.
101
+ **/
102
+ declare function matchesLiquidatableAccountFilter(account: LiquidatableAccount, filter?: LiquidatableAccountFilter): boolean;
103
+ /**
104
+ * A token received directly from the credit account balance upon liquidation.
105
+ **/
106
+ interface InstantReceivedAsset extends TokenAmount {
107
+ isDelayed: false;
108
+ }
109
+ /**
110
+ * A token produced by a delayed withdrawal whose redeemer is transferred to
111
+ * the liquidator upon liquidation.
112
+ *
113
+ * The amount is exact for claimable withdrawals, estimated for pending ones.
114
+ **/
115
+ interface DelayedReceivedAsset extends TokenAmount {
116
+ isDelayed: true;
117
+ /**
118
+ * Redeemer contract transferred to the liquidator, from which the token
119
+ * becomes claimable. `undefined` when the compressor does not report one.
120
+ **/
121
+ redeemerAddress?: Address;
122
+ /**
123
+ * Estimated moment a pending withdrawal becomes claimable. `undefined`
124
+ * means the withdrawal is claimable now.
125
+ **/
126
+ claimableAt?: Timestamp;
127
+ }
128
+ /**
129
+ * A single asset the liquidator receives when fully liquidating an account.
130
+ **/
131
+ type ReceivedAsset = InstantReceivedAsset | DelayedReceivedAsset;
132
+ /**
133
+ * ERC-20 approval the liquidator must grant before sending the liquidation
134
+ * transaction.
135
+ *
136
+ * The token is the one the compressor reports for the liquidation path it
137
+ * selected: the credit manager underlying for standard liquidations, the
138
+ * unwrapped stablecoin (e.g. USDC) for RWA ones. The value is what the
139
+ * transaction pulls plus 0.5% of headroom.
140
+ **/
141
+ interface LiquidationApproval extends TokenAmount {
142
+ /**
143
+ * Address to approve
144
+ **/
145
+ spender: Address;
146
+ }
147
+ /**
148
+ * A single delayed-withdrawal position owned by the liquidator.
149
+ **/
150
+ interface LiquidationPosition {
151
+ /**
152
+ * Chain the withdrawal lives on.
153
+ **/
154
+ chainId: ChainId;
155
+ /**
156
+ * Source asset spent by the delayed withdrawal (e.g. ACRED).
157
+ **/
158
+ sourceToken: Token;
159
+ /**
160
+ * Receivable asset (e.g. USDC) and its amount: exact for claimable
161
+ * withdrawals, estimated for pending ones.
162
+ **/
163
+ output: TokenAmount;
164
+ /**
165
+ * Estimated moment a pending withdrawal becomes claimable. `undefined`
166
+ * means the withdrawal is claimable now.
167
+ **/
168
+ claimableAt?: Timestamp;
169
+ /**
170
+ * Transaction that claims the withdrawal. `undefined` for pending
171
+ * withdrawals and when the compressor reports no claim call.
172
+ **/
173
+ claimTx?: TxCall;
174
+ /**
175
+ * Redeemer contract the withdrawal is claimed from, owned by the liquidator.
176
+ * `undefined` on compressor versions below 313, which do not report it.
177
+ **/
178
+ redeemer?: Address;
179
+ }
180
+ /**
181
+ * Detailed information about a liquidatable credit account, including
182
+ * the full breakdown of assets the liquidator receives.
183
+ **/
184
+ interface LiquidationDetails extends LiquidatableAccount {
185
+ /**
186
+ * Exact amount the liquidator pays for the liquidation, superseding
187
+ * the estimate of {@link LiquidatableAccount}. The token is
188
+ * {@link LiquidationApproval}'s, which for RWA markets is the
189
+ * unwrapped stablecoin rather than {@link LiquidatableAccount.totalValue}'s
190
+ * token; it falls back to the latter when nothing is pulled.
191
+ **/
192
+ repaymentAmount: TokenAmount;
193
+ /**
194
+ * Assets the liquidator receives upon full liquidation: direct credit
195
+ * account balances plus outputs of delayed withdrawals (claimable and
196
+ * pending).
197
+ **/
198
+ receivedAssets: ReceivedAsset[];
199
+ /**
200
+ * Whether the liquidator passes the KYC checks of the liquidated assets.
201
+ * When the liquidator wallet was not provided, `false` only means that the
202
+ * liquidation is KYC-gated, not that a particular wallet was rejected.
203
+ **/
204
+ isLiquidatorEligible: boolean;
205
+ /**
206
+ * `true` when the credit account is frozen by the RWA factory
207
+ * (`isFrozen`) and cannot move its RWA collateral. Always `false` for
208
+ * non-RWA liquidation paths.
209
+ **/
210
+ isCreditAccountFrozen: boolean;
211
+ /**
212
+ * Name of the KYC protocol the liquidator must be whitelisted in
213
+ * (e.g. `"securitize"`). `undefined` when the liquidation is not KYC-gated.
214
+ **/
215
+ kycProtocol?: string;
216
+ /**
217
+ * Token the liquidator must be whitelisted for in {@link kycProtocol}.
218
+ * `undefined` when the liquidation is not KYC-gated, and when the token is
219
+ * not in the SDK's token registry.
220
+ **/
221
+ kycToken?: Token;
222
+ /**
223
+ * ERC-20 approval required before sending the liquidation transaction.
224
+ * `undefined` when the selected liquidation path needs no capital from the
225
+ * liquidator, i.e. {@link repaymentAmount} is zero.
226
+ **/
227
+ approve?: LiquidationApproval;
228
+ }
229
+ //#endregion
230
+ export { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter };