@gearbox-protocol/sdk 14.12.0-next.65 → 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 (249) 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/dev/index.js +2 -1
  14. package/dist/cjs/dev/kycUtils.js +1 -1
  15. package/dist/cjs/dev/midasUtils.js +104 -0
  16. package/dist/cjs/model/history.js +28 -0
  17. package/dist/cjs/model/history.schema.js +84 -0
  18. package/dist/cjs/model/index.js +64 -0
  19. package/dist/cjs/model/liquidations.js +23 -0
  20. package/dist/cjs/model/liquidations.schema.js +91 -0
  21. package/dist/cjs/model/opportunities.js +55 -0
  22. package/dist/cjs/model/opportunities.schema.js +220 -0
  23. package/dist/cjs/model/package.json +1 -0
  24. package/dist/cjs/model/positions.js +1 -0
  25. package/dist/cjs/model/primitives.js +1 -0
  26. package/dist/cjs/model/primitives.schema.js +85 -0
  27. package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
  28. package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
  29. package/dist/cjs/new-sdk/index.js +11 -0
  30. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
  31. package/dist/cjs/new-sdk/opportunities/index.js +4 -0
  32. package/dist/cjs/new-sdk/opportunities/types.js +1 -0
  33. package/dist/cjs/new-sdk/package.json +1 -0
  34. package/dist/cjs/new-sdk/types.js +22 -0
  35. package/dist/cjs/new-sdk/utils/history.js +1 -0
  36. package/dist/cjs/new-sdk/utils/index.js +2 -0
  37. package/dist/cjs/offchain/GearboxAPI.js +33 -0
  38. package/dist/cjs/offchain/index.js +8 -0
  39. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
  40. package/dist/cjs/offchain/opportunities/index.js +4 -0
  41. package/dist/cjs/offchain/package.json +1 -0
  42. package/dist/cjs/offchain/types.js +1 -0
  43. package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
  44. package/dist/cjs/rewards/rewards/api.js +2 -2
  45. package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
  46. package/dist/cjs/sdk/MultichainSDK.js +18 -2
  47. package/dist/cjs/sdk/OnchainSDK.js +8 -1
  48. package/dist/cjs/sdk/accounts/index.js +2 -0
  49. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +150 -106
  50. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  51. package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
  52. package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
  53. package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
  54. package/dist/cjs/sdk/base/TokensMeta.js +51 -0
  55. package/dist/cjs/sdk/base/index.js +2 -0
  56. package/dist/cjs/sdk/chain/chains.js +76 -0
  57. package/dist/cjs/sdk/chain/index.js +4 -0
  58. package/dist/cjs/sdk/core/errors.js +13 -0
  59. package/dist/cjs/sdk/core/index.js +2 -1
  60. package/dist/cjs/sdk/index.js +25 -1
  61. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
  62. package/dist/cjs/sdk/market/MarketSuite.js +163 -0
  63. package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  64. package/dist/cjs/sdk/market/credit/CreditSuite.js +102 -0
  65. package/dist/cjs/sdk/market/math.js +104 -0
  66. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  67. package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  68. package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  69. package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
  70. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
  71. package/dist/cjs/sdk/market/pool/math.js +44 -0
  72. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  73. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
  74. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +103 -0
  75. package/dist/cjs/sdk/opportunities/index.js +12 -0
  76. package/dist/cjs/sdk/types/multichain.js +1 -0
  77. package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
  78. package/dist/cjs/sdk/utils/index.js +3 -0
  79. package/dist/cjs/sdk/utils/zod.js +12 -0
  80. package/dist/esm/common-utils/index.js +1 -1
  81. package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
  82. package/dist/esm/common-utils/utils/assets-math.js +1 -1
  83. package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
  84. package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
  85. package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
  86. package/dist/esm/common-utils/utils/index.js +1 -1
  87. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
  88. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
  89. package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
  90. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
  91. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
  92. package/dist/esm/dev/AccountOpener.js +1 -1
  93. package/dist/esm/dev/index.js +3 -3
  94. package/dist/esm/dev/kycUtils.js +1 -1
  95. package/dist/esm/dev/midasUtils.js +105 -2
  96. package/dist/esm/dev/withdrawalUtils.js +1 -1
  97. package/dist/esm/model/history.js +26 -0
  98. package/dist/esm/model/history.schema.js +76 -0
  99. package/dist/esm/model/index.js +9 -0
  100. package/dist/esm/model/liquidations.js +22 -0
  101. package/dist/esm/model/liquidations.schema.js +83 -0
  102. package/dist/esm/model/opportunities.js +51 -0
  103. package/dist/esm/model/opportunities.schema.js +198 -0
  104. package/dist/esm/model/package.json +1 -0
  105. package/dist/esm/model/positions.js +1 -0
  106. package/dist/esm/model/primitives.js +1 -0
  107. package/dist/esm/model/primitives.schema.js +75 -0
  108. package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
  109. package/dist/esm/new-sdk/GearboxSDK.js +121 -0
  110. package/dist/esm/new-sdk/index.js +7 -0
  111. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
  112. package/dist/esm/new-sdk/opportunities/index.js +3 -0
  113. package/dist/esm/new-sdk/opportunities/types.js +1 -0
  114. package/dist/esm/new-sdk/package.json +1 -0
  115. package/dist/esm/new-sdk/types.js +21 -0
  116. package/dist/esm/new-sdk/utils/history.js +1 -0
  117. package/dist/esm/new-sdk/utils/index.js +2 -0
  118. package/dist/esm/offchain/GearboxAPI.js +32 -0
  119. package/dist/esm/offchain/index.js +5 -0
  120. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
  121. package/dist/esm/offchain/opportunities/index.js +2 -0
  122. package/dist/esm/offchain/package.json +1 -0
  123. package/dist/esm/offchain/types.js +1 -0
  124. package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
  125. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  126. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  127. package/dist/esm/rewards/rewards/api.js +1 -1
  128. package/dist/esm/rewards/rewards/extra-apy.js +1 -1
  129. package/dist/esm/sdk/MultichainSDK.js +18 -2
  130. package/dist/esm/sdk/OnchainSDK.js +8 -1
  131. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  132. package/dist/esm/sdk/accounts/index.js +2 -2
  133. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +153 -109
  134. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  135. package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
  136. package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
  137. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  138. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  139. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  140. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  141. package/dist/esm/sdk/base/MultichainConstruct.js +79 -0
  142. package/dist/esm/sdk/base/TokensMeta.js +53 -2
  143. package/dist/esm/sdk/base/index.js +2 -1
  144. package/dist/esm/sdk/chain/chains.js +74 -2
  145. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  146. package/dist/esm/sdk/chain/index.js +2 -2
  147. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  148. package/dist/esm/sdk/core/errors.js +13 -1
  149. package/dist/esm/sdk/core/index.js +2 -2
  150. package/dist/esm/sdk/index.js +11 -5
  151. package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
  152. package/dist/esm/sdk/market/MarketSuite.js +163 -0
  153. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  154. package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  155. package/dist/esm/sdk/market/credit/CreditSuite.js +102 -0
  156. package/dist/esm/sdk/market/math.js +98 -0
  157. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  158. package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  159. package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  160. package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
  161. package/dist/esm/sdk/market/pool/PoolV310Contract.js +28 -1
  162. package/dist/esm/sdk/market/pool/math.js +41 -0
  163. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  164. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  165. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  166. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +59 -0
  167. package/dist/esm/sdk/opportunities/OpportunitiesService.js +102 -0
  168. package/dist/esm/sdk/opportunities/index.js +4 -0
  169. package/dist/esm/sdk/pools/PoolService.js +1 -1
  170. package/dist/esm/sdk/types/multichain.js +1 -0
  171. package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
  172. package/dist/esm/sdk/utils/index.js +3 -2
  173. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  174. package/dist/esm/sdk/utils/zod.js +13 -2
  175. package/dist/types/common-utils/index.d.ts +1 -1
  176. package/dist/types/common-utils/utils/index.d.ts +1 -1
  177. package/dist/types/dev/index.d.ts +2 -2
  178. package/dist/types/dev/midasUtils.d.ts +31 -2
  179. package/dist/types/model/history.d.ts +105 -0
  180. package/dist/types/model/history.schema.d.ts +66 -0
  181. package/dist/types/model/index.d.ts +9 -0
  182. package/dist/types/model/liquidations.d.ts +230 -0
  183. package/dist/types/model/liquidations.schema.d.ts +292 -0
  184. package/dist/types/model/opportunities.d.ts +543 -0
  185. package/dist/types/model/opportunities.schema.d.ts +1066 -0
  186. package/dist/types/model/positions.d.ts +11 -0
  187. package/dist/types/model/primitives.d.ts +193 -0
  188. package/dist/types/model/primitives.schema.d.ts +81 -0
  189. package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
  190. package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
  191. package/dist/types/new-sdk/index.d.ts +9 -0
  192. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
  193. package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
  194. package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
  195. package/dist/types/new-sdk/types.d.ts +149 -0
  196. package/dist/types/new-sdk/utils/history.d.ts +44 -0
  197. package/dist/types/new-sdk/utils/index.d.ts +2 -0
  198. package/dist/types/offchain/GearboxAPI.d.ts +31 -0
  199. package/dist/types/offchain/index.d.ts +5 -0
  200. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
  201. package/dist/types/offchain/opportunities/index.d.ts +2 -0
  202. package/dist/types/offchain/types.d.ts +50 -0
  203. package/dist/types/sdk/MultichainSDK.d.ts +15 -2
  204. package/dist/types/sdk/OnchainSDK.d.ts +9 -3
  205. package/dist/types/sdk/accounts/index.d.ts +3 -3
  206. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
  207. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
  208. package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
  209. package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
  210. package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
  211. package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
  212. package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
  213. package/dist/types/sdk/base/index.d.ts +2 -1
  214. package/dist/types/sdk/chain/chains.d.ts +68 -1
  215. package/dist/types/sdk/chain/index.d.ts +2 -2
  216. package/dist/types/sdk/core/errors.d.ts +10 -1
  217. package/dist/types/sdk/core/index.d.ts +2 -2
  218. package/dist/types/sdk/index.d.ts +15 -8
  219. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
  220. package/dist/types/sdk/market/MarketSuite.d.ts +109 -1
  221. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
  222. package/dist/types/sdk/market/credit/CreditSuite.d.ts +47 -0
  223. package/dist/types/sdk/market/credit/types.d.ts +22 -0
  224. package/dist/types/sdk/market/index.d.ts +2 -2
  225. package/dist/types/sdk/market/math.d.ts +74 -0
  226. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
  227. package/dist/types/sdk/market/oracle/types.d.ts +46 -0
  228. package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
  229. package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
  230. package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
  231. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
  232. package/dist/types/sdk/market/pool/math.d.ts +57 -0
  233. package/dist/types/sdk/market/pool/types.d.ts +23 -0
  234. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
  235. package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
  236. package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
  237. package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +47 -0
  238. package/dist/types/sdk/opportunities/index.d.ts +4 -0
  239. package/dist/types/sdk/types/index.d.ts +2 -1
  240. package/dist/types/sdk/types/multichain.d.ts +65 -0
  241. package/dist/types/sdk/types/state.d.ts +1 -1
  242. package/dist/types/sdk/types/transactions.d.ts +3 -0
  243. package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
  244. package/dist/types/sdk/utils/index.d.ts +3 -2
  245. package/dist/types/sdk/utils/zod.d.ts +6 -2
  246. package/package.json +16 -1
  247. package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
  248. package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
  249. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
@@ -0,0 +1,543 @@
1
+ import { Amount, AssetType, Bps, ChainId, Curator, Leverage, Timestamp, Token } from "./primitives.js";
2
+ import { Address } from "viem";
3
+ //#region src/model/opportunities.d.ts
4
+ /**
5
+ * Discriminator of the two opportunity kinds.
6
+ *
7
+ * - `"pool"` — passive lending: deposit the underlying, earn the supply rate.
8
+ * - `"strategy"` — leveraged position: deposit collateral, borrow the
9
+ * underlying against it inside a credit account.
10
+ **/
11
+ type OpportunityKind = "pool" | "strategy";
12
+ /**
13
+ * An off-chain points program a position accrues towards, e.g. a partner
14
+ * protocol's season points. Points have no APY, so they are listed separately
15
+ * from token rewards.
16
+ **/
17
+ interface PointsProgram {
18
+ /**
19
+ * Stable slug of the program.
20
+ *
21
+ * @example `"ethena-sats-s3"`
22
+ **/
23
+ id: string;
24
+ /**
25
+ * Display name of the program.
26
+ *
27
+ * @example `"Ethena Sats Season 3"`
28
+ **/
29
+ name: string;
30
+ /**
31
+ * Points earned per unit of position relative to the program's base rate, or
32
+ * `null` when the program does not publish one.
33
+ *
34
+ * @example `2` for a 2x boost
35
+ **/
36
+ multiplier: number | null;
37
+ }
38
+ /**
39
+ * Rewards paid out in a token, e.g. a liquidity mining program.
40
+ **/
41
+ interface TokenRewards {
42
+ kind: "token";
43
+ /**
44
+ * Token the rewards are paid in.
45
+ **/
46
+ token: Token;
47
+ /**
48
+ * Extra APR earned by supplying, in basis points.
49
+ *
50
+ * @example `120` for +1.2% APR
51
+ **/
52
+ supplyApr?: Bps;
53
+ /**
54
+ * Extra APR earned on the borrowed side, in basis points. Present when a
55
+ * program rebates part of the borrow cost.
56
+ *
57
+ * @example `45` for +0.45% APR
58
+ **/
59
+ borrowApr?: Bps;
60
+ }
61
+ /**
62
+ * Rewards accrued as points rather than tokens.
63
+ **/
64
+ interface PointRewards {
65
+ kind: "point";
66
+ /**
67
+ * Programs the position accrues points in.
68
+ **/
69
+ points: PointsProgram[];
70
+ }
71
+ /**
72
+ * Any reward stream attached to an opportunity.
73
+ **/
74
+ type Rewards = TokenRewards | PointRewards;
75
+ /**
76
+ * A yield figure split into the part the protocol itself generates and the
77
+ * incentives layered on top.
78
+ **/
79
+ interface ApyBreakdown {
80
+ /**
81
+ * Everything combined, in basis points: the number a UI shows as "APY".
82
+ *
83
+ * @example `842` for 8.42% APY
84
+ **/
85
+ totalApy: Bps;
86
+ /**
87
+ * The part generated by the underlying protocol alone, without incentives,
88
+ * in basis points.
89
+ *
90
+ * @example `610` for 6.10% APY
91
+ **/
92
+ organicApy: Bps;
93
+ /**
94
+ * Incentives that make up the difference between {@link organicApy} and
95
+ * {@link totalApy}, plus any points programs that carry no APY at all.
96
+ **/
97
+ rewards: Rewards[];
98
+ }
99
+ /**
100
+ * Fields both opportunity kinds share.
101
+ **/
102
+ interface OpportunityBase {
103
+ /**
104
+ * Chain the opportunity lives on.
105
+ **/
106
+ chainId: ChainId;
107
+ /**
108
+ * Human-readable name for the row.
109
+ *
110
+ * @example `"USDC Pool"`, `"wstETH / WETH"`
111
+ **/
112
+ title: string;
113
+ /**
114
+ * Curator of the market this opportunity belongs to.
115
+ **/
116
+ curator: Curator;
117
+ /**
118
+ * Token that is supplied to the pool and borrowed by credit accounts. All
119
+ * amounts of the opportunity are denominated in it.
120
+ *
121
+ * For RWA markets it's an unwrapped, e.g. — `USDC`, not `dcUSDC` (pool underlying according to contract).
122
+ * The wrapper converts one-for-one, so every amount stays exact.
123
+ **/
124
+ underlyingToken: Token;
125
+ /**
126
+ * Size of the opportunity.
127
+ *
128
+ * For a pool this is the supply of pool shares; for a strategy it is the
129
+ * summed total value of the credit accounts holding the target collateral.
130
+ **/
131
+ totalSupply: Amount;
132
+ /**
133
+ * Debt principal drawn against the opportunity.
134
+ **/
135
+ totalBorrow: Amount;
136
+ /**
137
+ * How much of the available capital is currently borrowed, in basis points.
138
+ *
139
+ * @example `7500` for 75% utilization
140
+ **/
141
+ utilization: Bps;
142
+ /**
143
+ * Yield earned by supplying. For a strategy it is the net yield at
144
+ * {@link StrategyOpportunity.maxLeverage}.
145
+ *
146
+ * Absent in `onchain` mode: every yield figure that folds in incentives,
147
+ * points or smoothing is computed by the backend.
148
+ *
149
+ * @mode offchain
150
+ **/
151
+ supplyApy?: ApyBreakdown;
152
+ /**
153
+ * Tokens accepted as collateral, i.e. the tokens that have both a non-zero
154
+ * liquidation threshold and a non-zero quota limit.
155
+ **/
156
+ collateralTokens: Token[];
157
+ /**
158
+ * The contract's own pause flag: the pool for a {@link PoolOpportunity}, the
159
+ * credit facade or the pool it borrows from for a
160
+ * {@link StrategyOpportunity}.
161
+ **/
162
+ paused: boolean;
163
+ /**
164
+ * Whether at least one of {@link collateralTokens} is a real-world-asset
165
+ * token. Read from a hardcoded per-chain list rather than from the chain.
166
+ **/
167
+ rwa: boolean;
168
+ /**
169
+ * Whether the opportunity is being wound down and should no longer be
170
+ * entered. Read from a hardcoded per-chain list, kept separately for pools
171
+ * and for strategies, and unrelated to
172
+ * {@link StrategyOpportunity.expirationDate}.
173
+ **/
174
+ sunset: boolean;
175
+ }
176
+ /**
177
+ * Passive lending into a Gearbox pool.
178
+ *
179
+ * Identified by `(chainId, pool)`, see {@link poolOpportunityId}.
180
+ **/
181
+ interface PoolOpportunity extends OpportunityBase {
182
+ kind: "pool";
183
+ /**
184
+ * Address of the ERC-4626 pool contract.
185
+ **/
186
+ pool: Address;
187
+ }
188
+ /**
189
+ * A leveraged position: one credit manager plus one target collateral token.
190
+ * A credit manager that accepts five collateral tokens therefore produces five
191
+ * strategies.
192
+ *
193
+ * Identified by `(chainId, creditManager, targetCollateral.address)`,
194
+ * see {@link strategyOpportunityId}.
195
+ **/
196
+ interface StrategyOpportunity extends OpportunityBase {
197
+ kind: "strategy";
198
+ /**
199
+ * Address of the credit manager the position is opened in.
200
+ **/
201
+ creditManager: Address;
202
+ /**
203
+ * Collateral token the position is built around.
204
+ **/
205
+ targetCollateral: Token;
206
+ /**
207
+ * Liquidation threshold of {@link targetCollateral} in this credit manager,
208
+ * in basis points: the share of the collateral value that counts towards
209
+ * covering debt.
210
+ *
211
+ * @example `9000` for an 86% threshold
212
+ **/
213
+ liquidationThreshold: Bps;
214
+ /**
215
+ * Share of a liquidated account's value paid to the liquidator, in basis
216
+ * points.
217
+ *
218
+ * @example `400` for a 4% premium
219
+ **/
220
+ liquidationPremium: Bps;
221
+ /**
222
+ * Share of a liquidated account's value taken by the protocol, in basis
223
+ * points.
224
+ *
225
+ * @example `150` for a 1.5% fee
226
+ **/
227
+ liquidationFee: Bps;
228
+ /**
229
+ * Moment the credit facade expires, after which positions can no longer be
230
+ * opened and open ones become liquidatable, or `null` when the facade is not
231
+ * expirable. A timestamp in the past means it has already expired.
232
+ **/
233
+ expirationDate: Timestamp | null;
234
+ /**
235
+ * Yield the collateral itself earns while it sits in the credit account,
236
+ * before leverage.
237
+ *
238
+ * @mode offchain
239
+ **/
240
+ collateralApy?: ApyBreakdown;
241
+ /**
242
+ * Annual cost of the borrowed underlying, in basis points, including the
243
+ * protocol's interest fee.
244
+ *
245
+ * @example `520` for 5.2% APY
246
+ **/
247
+ borrowApy?: Bps;
248
+ /**
249
+ * Annual cost of the quota on {@link targetCollateral}, scaled to the debt a
250
+ * maximally leveraged position carries, in basis points. Comes on top of
251
+ * {@link borrowApy}.
252
+ *
253
+ * @example `90` for +0.9% APY
254
+ **/
255
+ additionalBorrowApy?: Bps;
256
+ /**
257
+ * Largest debt a single new position can take on right now: the tightest of
258
+ * the credit manager's remaining debt limit, the pool's free liquidity and
259
+ * the facade's per-account maximum.
260
+ **/
261
+ maxBorrowAmount: Amount;
262
+ /**
263
+ * Highest leverage the liquidation threshold allows,
264
+ * `1 / (1 - liquidationThreshold)`.
265
+ *
266
+ * @example `10` at a 90% threshold
267
+ **/
268
+ maxLeverage: Leverage;
269
+ }
270
+ /**
271
+ * A row of the opportunities list.
272
+ **/
273
+ type Opportunity = PoolOpportunity | StrategyOpportunity;
274
+ /**
275
+ * Canonical id of an opportunity: the string used to match a row read from the
276
+ * chain with the same row served by the backend.
277
+ **/
278
+ type OpportunityId = string;
279
+ /**
280
+ * Builds the canonical id of a pool opportunity.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * poolOpportunityId(1, "0xda00...") // "1:0xda00..."
285
+ * ```
286
+ **/
287
+ declare function poolOpportunityId(chainId: ChainId, pool: Address): OpportunityId;
288
+ /**
289
+ * Builds the canonical id of a strategy opportunity.
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * strategyOpportunityId(1, "0x3eb9...", "0x7f39...") // "1:0x3eb9...:0x7f39..."
294
+ * ```
295
+ **/
296
+ declare function strategyOpportunityId(chainId: ChainId, creditManager: Address, targetCollateral: Address): OpportunityId;
297
+ /**
298
+ * Canonical id of any opportunity, dispatching on {@link Opportunity.kind}.
299
+ **/
300
+ declare function opportunityId(opportunity: Opportunity): OpportunityId;
301
+ /**
302
+ * Optional narrowing of an opportunities list.
303
+ *
304
+ * The list is filtered in memory over final values, so there is no paging and
305
+ * no sorting: a screen sorts what it got.
306
+ *
307
+ * Every criterion is optional and an omitted one matches any value, so an empty
308
+ * filter is the same as no filter at all. Criteria combine with AND.
309
+ **/
310
+ interface OpportunityFilter {
311
+ /**
312
+ * Keep only pools or only strategies.
313
+ **/
314
+ kind?: OpportunityKind;
315
+ /**
316
+ * Keep only opportunities on these chains.
317
+ **/
318
+ chainIds?: ChainId[];
319
+ /**
320
+ * Keep only opportunities whose {@link OpportunityBase.underlyingToken} is of
321
+ * this class, which for an RWA market means the class of the token its
322
+ * wrapper holds. An underlying that is not in the hardcoded table never
323
+ * matches, so a set filter also drops unclassified rows.
324
+ **/
325
+ underlyingType?: AssetType;
326
+ /**
327
+ * Keep only paused opportunities, or only unpaused ones.
328
+ **/
329
+ paused?: boolean;
330
+ /**
331
+ * Keep only opportunities being wound down, or only the ones that are not.
332
+ **/
333
+ sunset?: boolean;
334
+ /**
335
+ * Keep only opportunities that accept RWA collateral, or only the ones that
336
+ * do not.
337
+ **/
338
+ rwa?: boolean;
339
+ }
340
+ /**
341
+ * Whether an opportunity satisfies every criterion of a filter.
342
+ *
343
+ * This is the single definition of what each criterion means: every source
344
+ * builds its rows first and runs them through here, so the chain and the
345
+ * backend cannot disagree on what a filter selects.
346
+ *
347
+ * @param opportunity - Row to test.
348
+ * @param filter - Criteria to test against. An absent filter matches anything.
349
+ **/
350
+ declare function matchesOpportunityFilter(opportunity: Opportunity, filter?: OpportunityFilter): boolean;
351
+ /**
352
+ * One point of an interest rate curve.
353
+ **/
354
+ interface RateCurvePoint {
355
+ /**
356
+ * Utilization this point is sampled at, in basis points.
357
+ *
358
+ * @example `9000` for 90% utilization
359
+ **/
360
+ utilization: Bps;
361
+ /**
362
+ * Rate depositors earn at this utilization, in basis points.
363
+ *
364
+ * @example `430` for 4.3%
365
+ **/
366
+ supplyApy: Bps;
367
+ /**
368
+ * Base rate borrowers pay at this utilization, in basis points. Excludes the
369
+ * per-credit-manager interest fee, because the curve belongs to the pool and
370
+ * every credit manager of a market can charge a different one.
371
+ *
372
+ * @example `620` for 6.2%
373
+ **/
374
+ borrowApy: Bps;
375
+ }
376
+ /**
377
+ * The pool's interest rate model, evaluated into chart-ready points so that no
378
+ * consumer has to reimplement the model.
379
+ **/
380
+ interface RateCurve {
381
+ /**
382
+ * Points ordered by ascending utilization, always including the kinks of the
383
+ * model so the polyline is exact rather than approximated.
384
+ **/
385
+ points: RateCurvePoint[];
386
+ /**
387
+ * Utilization above which borrowing is forbidden, in basis points, or `null`
388
+ * when the model has no such cutoff.
389
+ *
390
+ * @example `9000` for a cutoff at 90% utilization
391
+ **/
392
+ borrowingLimitUtilization: Bps | null;
393
+ }
394
+ /**
395
+ * Quota configuration of one collateral token: how much of it the market
396
+ * accepts in total, and what holding it costs.
397
+ **/
398
+ interface QuotaAsset {
399
+ /**
400
+ * Token the quota applies to.
401
+ **/
402
+ token: Token;
403
+ /**
404
+ * Annual quota rate paid on the quoted amount, in basis points.
405
+ *
406
+ * @example `250` for 2.5% per year
407
+ **/
408
+ quotaRate: Bps;
409
+ /**
410
+ * Maximum amount that can be quoted across all credit accounts, denominated
411
+ * in the market's underlying.
412
+ **/
413
+ limit: Amount;
414
+ /**
415
+ * Amount currently quoted, denominated in the market's underlying.
416
+ **/
417
+ used: Amount;
418
+ }
419
+ /**
420
+ * A price feed and the feeds it is composed of.
421
+ **/
422
+ interface PriceFeedData {
423
+ /**
424
+ * Display name of the feed.
425
+ *
426
+ * @example `"CompositePriceFeed wstETH / USD"`
427
+ **/
428
+ name: string;
429
+ /**
430
+ * Gearbox price feed contract type.
431
+ *
432
+ * @example `"PRICE_FEED::COMPOSITE"`, `"PRICE_FEED::REDSTONE"`
433
+ **/
434
+ type: string;
435
+ /**
436
+ * Address of the feed contract.
437
+ **/
438
+ feedAddress: Address;
439
+ /**
440
+ * Feeds this feed reads from. Empty for a leaf feed.
441
+ **/
442
+ dependencies: PriceFeedData[];
443
+ }
444
+ /**
445
+ * Prices and feeds behind a strategy, i.e. everything a liquidation-price chart
446
+ * needs.
447
+ **/
448
+ interface PriceFeedSummary {
449
+ /**
450
+ * Price of one whole underlying token in USD.
451
+ *
452
+ * @example `1.0001` for USDC
453
+ **/
454
+ underlyingPriceInUsd: number;
455
+ /**
456
+ * Price of one whole collateral token in USD.
457
+ *
458
+ * @example `4210.55` for wstETH
459
+ **/
460
+ collateralPriceInUsd: number;
461
+ /**
462
+ * Price of one whole collateral token expressed in the underlying.
463
+ *
464
+ * @example `4210.13` for wstETH priced in USDC
465
+ **/
466
+ collateralPriceInUnderlying: number;
467
+ /**
468
+ * Main feed of the underlying token.
469
+ **/
470
+ underlyingFeed: PriceFeedData;
471
+ /**
472
+ * Main feed of the collateral token. Reserve feeds are not included.
473
+ **/
474
+ collateralFeed: PriceFeedData;
475
+ }
476
+ /**
477
+ * A pool opportunity plus the data only its detail screen needs.
478
+ **/
479
+ interface PoolOpportunityDetail extends PoolOpportunity {
480
+ /**
481
+ * Interest rate curve of the pool.
482
+ **/
483
+ rateCurve: RateCurve;
484
+ /**
485
+ * Quota configuration of every collateral token of the market.
486
+ **/
487
+ quotaAssets: QuotaAsset[];
488
+ }
489
+ /**
490
+ * A strategy opportunity plus the data only its detail screen needs.
491
+ **/
492
+ interface StrategyOpportunityDetail extends StrategyOpportunity {
493
+ /**
494
+ * Interest rate curve of the pool the strategy borrows from.
495
+ **/
496
+ rateCurve: RateCurve;
497
+ /**
498
+ * Prices and feeds of the underlying and the target collateral.
499
+ **/
500
+ priceFeeds: PriceFeedSummary;
501
+ }
502
+ /**
503
+ * Detailed view of any opportunity.
504
+ **/
505
+ type OpportunityDetail = PoolOpportunityDetail | StrategyOpportunityDetail;
506
+ /**
507
+ * Identifies a pool opportunity in a detail request.
508
+ **/
509
+ interface PoolOpportunityKey {
510
+ chainId: ChainId;
511
+ pool: Address;
512
+ }
513
+ /**
514
+ * Identifies a strategy opportunity in a detail request.
515
+ **/
516
+ interface StrategyOpportunityKey {
517
+ chainId: ChainId;
518
+ creditManager: Address;
519
+ /**
520
+ * Address of the target collateral token.
521
+ **/
522
+ targetCollateral: Address;
523
+ }
524
+ /**
525
+ * {@link PoolOpportunityKey} tagged with its kind, for requests that accept
526
+ * both kinds.
527
+ **/
528
+ interface PoolOpportunityRef extends PoolOpportunityKey {
529
+ kind: "pool";
530
+ }
531
+ /**
532
+ * {@link StrategyOpportunityKey} tagged with its kind, for requests that accept
533
+ * both kinds.
534
+ **/
535
+ interface StrategyOpportunityRef extends StrategyOpportunityKey {
536
+ kind: "strategy";
537
+ }
538
+ /**
539
+ * Identifies any opportunity, for requests that accept both kinds.
540
+ **/
541
+ type OpportunityKey = PoolOpportunityRef | StrategyOpportunityRef;
542
+ //#endregion
543
+ 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 };