@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,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 };
@@ -0,0 +1,292 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/model/liquidations.schema.d.ts
3
+ /**
4
+ * Runtime schemas for {@link ./liquidations.js}, see the note in
5
+ * `primitives.schema.ts` on why they are written by hand.
6
+ **/
7
+ /**
8
+ * {@link LiquidatableAccountFilter}
9
+ **/
10
+ declare const liquidatableAccountFilterSchema: z.ZodObject<{
11
+ chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
12
+ underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
13
+ paused: z.ZodOptional<z.ZodBoolean>;
14
+ rwa: z.ZodOptional<z.ZodBoolean>;
15
+ delayed: z.ZodOptional<z.ZodBoolean>;
16
+ }, z.core.$strip>;
17
+ /**
18
+ * {@link LiquidatableAccount}
19
+ **/
20
+ declare const liquidatableAccountSchema: z.ZodObject<{
21
+ chainId: z.ZodNumber;
22
+ creditAccount: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
23
+ creditManager: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
24
+ asset: z.ZodObject<{
25
+ chainId: z.ZodNumber;
26
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
27
+ symbol: z.ZodString;
28
+ name: z.ZodString;
29
+ decimals: z.ZodNumber;
30
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
31
+ }, z.core.$strip>;
32
+ totalValue: z.ZodObject<{
33
+ value: z.ZodBigInt;
34
+ valueUsd: z.ZodNullable<z.ZodNumber>;
35
+ token: z.ZodObject<{
36
+ chainId: z.ZodNumber;
37
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
38
+ symbol: z.ZodString;
39
+ name: z.ZodString;
40
+ decimals: z.ZodNumber;
41
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
42
+ }, z.core.$strip>;
43
+ }, z.core.$strip>;
44
+ repaymentAmount: z.ZodObject<{
45
+ value: z.ZodBigInt;
46
+ valueUsd: z.ZodNullable<z.ZodNumber>;
47
+ token: z.ZodObject<{
48
+ chainId: z.ZodNumber;
49
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
50
+ symbol: z.ZodString;
51
+ name: z.ZodString;
52
+ decimals: z.ZodNumber;
53
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
54
+ }, z.core.$strip>;
55
+ }, z.core.$strip>;
56
+ estimatedProfit: z.ZodObject<{
57
+ value: z.ZodBigInt;
58
+ valueUsd: z.ZodNullable<z.ZodNumber>;
59
+ token: z.ZodObject<{
60
+ chainId: z.ZodNumber;
61
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
62
+ symbol: z.ZodString;
63
+ name: z.ZodString;
64
+ decimals: z.ZodNumber;
65
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
66
+ }, z.core.$strip>;
67
+ }, z.core.$strip>;
68
+ isDelayed: z.ZodBoolean;
69
+ paused: z.ZodBoolean;
70
+ rwa: z.ZodBoolean;
71
+ }, z.core.$strip>;
72
+ /**
73
+ * {@link InstantReceivedAsset}
74
+ **/
75
+ declare const instantReceivedAssetSchema: z.ZodObject<{
76
+ value: z.ZodBigInt;
77
+ valueUsd: z.ZodNullable<z.ZodNumber>;
78
+ token: z.ZodObject<{
79
+ chainId: z.ZodNumber;
80
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
81
+ symbol: z.ZodString;
82
+ name: z.ZodString;
83
+ decimals: z.ZodNumber;
84
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
85
+ }, z.core.$strip>;
86
+ isDelayed: z.ZodLiteral<false>;
87
+ }, z.core.$strip>;
88
+ /**
89
+ * {@link DelayedReceivedAsset}
90
+ **/
91
+ declare const delayedReceivedAssetSchema: z.ZodObject<{
92
+ value: z.ZodBigInt;
93
+ valueUsd: z.ZodNullable<z.ZodNumber>;
94
+ token: z.ZodObject<{
95
+ chainId: z.ZodNumber;
96
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
97
+ symbol: z.ZodString;
98
+ name: z.ZodString;
99
+ decimals: z.ZodNumber;
100
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
101
+ }, z.core.$strip>;
102
+ isDelayed: z.ZodLiteral<true>;
103
+ redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
104
+ claimableAt: z.ZodOptional<z.ZodNumber>;
105
+ }, z.core.$strip>;
106
+ /**
107
+ * {@link ReceivedAsset}
108
+ **/
109
+ declare const receivedAssetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ value: z.ZodBigInt;
111
+ valueUsd: z.ZodNullable<z.ZodNumber>;
112
+ token: z.ZodObject<{
113
+ chainId: z.ZodNumber;
114
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
115
+ symbol: z.ZodString;
116
+ name: z.ZodString;
117
+ decimals: z.ZodNumber;
118
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
119
+ }, z.core.$strip>;
120
+ isDelayed: z.ZodLiteral<false>;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ value: z.ZodBigInt;
123
+ valueUsd: z.ZodNullable<z.ZodNumber>;
124
+ token: z.ZodObject<{
125
+ chainId: z.ZodNumber;
126
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
127
+ symbol: z.ZodString;
128
+ name: z.ZodString;
129
+ decimals: z.ZodNumber;
130
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
131
+ }, z.core.$strip>;
132
+ isDelayed: z.ZodLiteral<true>;
133
+ redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
134
+ claimableAt: z.ZodOptional<z.ZodNumber>;
135
+ }, z.core.$strip>], "isDelayed">;
136
+ /**
137
+ * {@link LiquidationApproval}
138
+ **/
139
+ declare const liquidationApprovalSchema: z.ZodObject<{
140
+ value: z.ZodBigInt;
141
+ valueUsd: z.ZodNullable<z.ZodNumber>;
142
+ token: z.ZodObject<{
143
+ chainId: z.ZodNumber;
144
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
145
+ symbol: z.ZodString;
146
+ name: z.ZodString;
147
+ decimals: z.ZodNumber;
148
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
149
+ }, z.core.$strip>;
150
+ spender: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
151
+ }, z.core.$strip>;
152
+ /**
153
+ * {@link LiquidationPosition}
154
+ **/
155
+ declare const liquidationPositionSchema: z.ZodObject<{
156
+ chainId: z.ZodNumber;
157
+ sourceToken: z.ZodObject<{
158
+ chainId: z.ZodNumber;
159
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
160
+ symbol: z.ZodString;
161
+ name: z.ZodString;
162
+ decimals: z.ZodNumber;
163
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
164
+ }, z.core.$strip>;
165
+ output: z.ZodObject<{
166
+ value: z.ZodBigInt;
167
+ valueUsd: z.ZodNullable<z.ZodNumber>;
168
+ token: z.ZodObject<{
169
+ chainId: z.ZodNumber;
170
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
171
+ symbol: z.ZodString;
172
+ name: z.ZodString;
173
+ decimals: z.ZodNumber;
174
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
175
+ }, z.core.$strip>;
176
+ }, z.core.$strip>;
177
+ claimableAt: z.ZodOptional<z.ZodNumber>;
178
+ claimTx: z.ZodOptional<z.ZodObject<{
179
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
180
+ callData: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
181
+ value: z.ZodOptional<z.ZodBigInt>;
182
+ }, z.core.$strip>>;
183
+ redeemer: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
184
+ }, z.core.$strip>;
185
+ /**
186
+ * {@link LiquidationDetails}
187
+ **/
188
+ declare const liquidationDetailsSchema: z.ZodObject<{
189
+ chainId: z.ZodNumber;
190
+ creditAccount: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
191
+ creditManager: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
192
+ asset: z.ZodObject<{
193
+ chainId: z.ZodNumber;
194
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
195
+ symbol: z.ZodString;
196
+ name: z.ZodString;
197
+ decimals: z.ZodNumber;
198
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
199
+ }, z.core.$strip>;
200
+ totalValue: z.ZodObject<{
201
+ value: z.ZodBigInt;
202
+ valueUsd: z.ZodNullable<z.ZodNumber>;
203
+ token: z.ZodObject<{
204
+ chainId: z.ZodNumber;
205
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
206
+ symbol: z.ZodString;
207
+ name: z.ZodString;
208
+ decimals: z.ZodNumber;
209
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
210
+ }, z.core.$strip>;
211
+ }, z.core.$strip>;
212
+ estimatedProfit: z.ZodObject<{
213
+ value: z.ZodBigInt;
214
+ valueUsd: z.ZodNullable<z.ZodNumber>;
215
+ token: z.ZodObject<{
216
+ chainId: z.ZodNumber;
217
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
218
+ symbol: z.ZodString;
219
+ name: z.ZodString;
220
+ decimals: z.ZodNumber;
221
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
222
+ }, z.core.$strip>;
223
+ }, z.core.$strip>;
224
+ isDelayed: z.ZodBoolean;
225
+ paused: z.ZodBoolean;
226
+ rwa: z.ZodBoolean;
227
+ repaymentAmount: z.ZodObject<{
228
+ value: z.ZodBigInt;
229
+ valueUsd: z.ZodNullable<z.ZodNumber>;
230
+ token: z.ZodObject<{
231
+ chainId: z.ZodNumber;
232
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
233
+ symbol: z.ZodString;
234
+ name: z.ZodString;
235
+ decimals: z.ZodNumber;
236
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
237
+ }, z.core.$strip>;
238
+ }, z.core.$strip>;
239
+ receivedAssets: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
240
+ value: z.ZodBigInt;
241
+ valueUsd: z.ZodNullable<z.ZodNumber>;
242
+ token: z.ZodObject<{
243
+ chainId: z.ZodNumber;
244
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
245
+ symbol: z.ZodString;
246
+ name: z.ZodString;
247
+ decimals: z.ZodNumber;
248
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
249
+ }, z.core.$strip>;
250
+ isDelayed: z.ZodLiteral<false>;
251
+ }, z.core.$strip>, z.ZodObject<{
252
+ value: z.ZodBigInt;
253
+ valueUsd: z.ZodNullable<z.ZodNumber>;
254
+ token: z.ZodObject<{
255
+ chainId: z.ZodNumber;
256
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
257
+ symbol: z.ZodString;
258
+ name: z.ZodString;
259
+ decimals: z.ZodNumber;
260
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
261
+ }, z.core.$strip>;
262
+ isDelayed: z.ZodLiteral<true>;
263
+ redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
264
+ claimableAt: z.ZodOptional<z.ZodNumber>;
265
+ }, z.core.$strip>], "isDelayed">>;
266
+ isLiquidatorEligible: z.ZodBoolean;
267
+ isCreditAccountFrozen: z.ZodBoolean;
268
+ kycProtocol: z.ZodOptional<z.ZodString>;
269
+ kycToken: z.ZodOptional<z.ZodObject<{
270
+ chainId: z.ZodNumber;
271
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
272
+ symbol: z.ZodString;
273
+ name: z.ZodString;
274
+ decimals: z.ZodNumber;
275
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
276
+ }, z.core.$strip>>;
277
+ approve: z.ZodOptional<z.ZodObject<{
278
+ value: z.ZodBigInt;
279
+ valueUsd: z.ZodNullable<z.ZodNumber>;
280
+ token: z.ZodObject<{
281
+ chainId: z.ZodNumber;
282
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
283
+ symbol: z.ZodString;
284
+ name: z.ZodString;
285
+ decimals: z.ZodNumber;
286
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
287
+ }, z.core.$strip>;
288
+ spender: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
289
+ }, z.core.$strip>>;
290
+ }, z.core.$strip>;
291
+ //#endregion
292
+ export { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema };