@gearbox-protocol/sdk 18.2.0-next.1 → 18.2.0-next.11

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 (135) hide show
  1. package/dist/cjs/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +179 -0
  2. package/dist/cjs/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +534 -0
  3. package/dist/cjs/abi/router/treehouseWorker.js +885 -0
  4. package/dist/cjs/dev/AccountOpener.js +1 -1
  5. package/dist/cjs/dev/withdrawalUtils.js +1 -1
  6. package/dist/cjs/history/trace/extractTransfers.js +1 -1
  7. package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  8. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  9. package/dist/cjs/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -2
  10. package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -2
  11. package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -2
  12. package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  13. package/dist/cjs/onchain/base/TokensMeta.js +3 -3
  14. package/dist/cjs/onchain/core/createAddressProvider.js +1 -1
  15. package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
  16. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  17. package/dist/cjs/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  18. package/dist/cjs/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  19. package/dist/cjs/onchain/market/adapters/types.js +3 -0
  20. package/dist/cjs/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  21. package/dist/cjs/onchain/market/pool/PoolV310Contract.js +1 -1
  22. package/dist/cjs/onchain/market/rwa/createDegenNFT.js +1 -1
  23. package/dist/cjs/onchain/market/zapper/IETHZapperContract.js +1 -2
  24. package/dist/cjs/onchain/market/zapper/ZapperContract.js +1 -1
  25. package/dist/cjs/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  26. package/dist/cjs/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  27. package/dist/cjs/permissionless/api/index.js +26 -0
  28. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +585 -47
  29. package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
  30. package/dist/cjs/permissionless/api/oracles/index.js +28 -0
  31. package/dist/cjs/permissionless/api/oracles/schemas.js +102 -35
  32. package/dist/cjs/permissionless/api/oracles/score/formula.js +99 -0
  33. package/dist/cjs/permissionless/api/oracles/score/index.js +8 -0
  34. package/dist/cjs/permissionless/api/oracles/score/run.js +88 -0
  35. package/dist/cjs/permissionless/api/oracles/score/types.js +1 -0
  36. package/dist/cjs/permissionless/api/oracles/stress/classify.js +258 -0
  37. package/dist/cjs/permissionless/api/oracles/stress/index.js +22 -0
  38. package/dist/cjs/permissionless/api/oracles/stress/override.js +125 -0
  39. package/dist/cjs/permissionless/api/oracles/stress/run.js +432 -0
  40. package/dist/cjs/permissionless/api/oracles/stress/score.js +98 -0
  41. package/dist/cjs/permissionless/api/oracles/stress/types.js +1 -0
  42. package/dist/cjs/permissionless/api/schemas.js +0 -3
  43. package/dist/cjs/permissionless/bindings/index.js +1 -1
  44. package/dist/cjs/permissionless/index.js +29 -1
  45. package/dist/cjs/permissionless/utils/index.js +2 -0
  46. package/dist/cjs/permissionless/utils/price-update/get-prices.js +64 -0
  47. package/dist/cjs/permissionless/utils/price-update/index.js +2 -0
  48. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  49. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  50. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  51. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  52. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  53. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  54. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  55. package/dist/cjs/testnets/errors/index.js +13 -0
  56. package/dist/cjs/testnets/index.js +32 -0
  57. package/dist/cjs/testnets/package.json +1 -0
  58. package/dist/cjs/testnets/schemas.js +242 -0
  59. package/dist/cjs/testnets/types.js +1 -0
  60. package/dist/esm/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +178 -0
  61. package/dist/esm/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +533 -0
  62. package/dist/esm/abi/router/treehouseWorker.js +884 -0
  63. package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
  64. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  65. package/dist/esm/onchain/market/adapters/types.js +3 -0
  66. package/dist/esm/permissionless/api/index.js +7 -1
  67. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +587 -49
  68. package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
  69. package/dist/esm/permissionless/api/oracles/index.js +10 -1
  70. package/dist/esm/permissionless/api/oracles/schemas.js +95 -35
  71. package/dist/esm/permissionless/api/oracles/score/formula.js +96 -0
  72. package/dist/esm/permissionless/api/oracles/score/index.js +4 -0
  73. package/dist/esm/permissionless/api/oracles/score/run.js +87 -0
  74. package/dist/esm/permissionless/api/oracles/score/types.js +1 -0
  75. package/dist/esm/permissionless/api/oracles/stress/classify.js +256 -0
  76. package/dist/esm/permissionless/api/oracles/stress/index.js +6 -0
  77. package/dist/esm/permissionless/api/oracles/stress/override.js +119 -0
  78. package/dist/esm/permissionless/api/oracles/stress/run.js +427 -0
  79. package/dist/esm/permissionless/api/oracles/stress/score.js +95 -0
  80. package/dist/esm/permissionless/api/oracles/stress/types.js +1 -0
  81. package/dist/esm/permissionless/api/schemas.js +2 -4
  82. package/dist/esm/permissionless/bindings/index.js +1 -1
  83. package/dist/esm/permissionless/index.js +9 -3
  84. package/dist/esm/permissionless/utils/index.js +2 -2
  85. package/dist/esm/permissionless/utils/price-update/get-prices.js +63 -1
  86. package/dist/esm/permissionless/utils/price-update/index.js +2 -2
  87. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  88. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  89. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  90. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  91. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  92. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  93. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  94. package/dist/esm/testnets/errors/index.js +7 -0
  95. package/dist/esm/testnets/index.js +11 -0
  96. package/dist/esm/testnets/package.json +1 -0
  97. package/dist/esm/testnets/schemas.js +228 -0
  98. package/dist/esm/testnets/types.js +1 -0
  99. package/dist/types/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.d.ts +148 -0
  100. package/dist/types/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.d.ts +440 -0
  101. package/dist/types/abi/router/treehouseWorker.d.ts +728 -0
  102. package/dist/types/onchain/market/adapters/types.d.ts +4 -1
  103. package/dist/types/permissionless/api/index.d.ts +10 -2
  104. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +232 -35
  105. package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
  106. package/dist/types/permissionless/api/oracles/index.d.ts +12 -2
  107. package/dist/types/permissionless/api/oracles/schemas.d.ts +209 -22
  108. package/dist/types/permissionless/api/oracles/score/formula.d.ts +46 -0
  109. package/dist/types/permissionless/api/oracles/score/index.d.ts +4 -0
  110. package/dist/types/permissionless/api/oracles/score/run.d.ts +21 -0
  111. package/dist/types/permissionless/api/oracles/score/types.d.ts +85 -0
  112. package/dist/types/permissionless/api/oracles/stress/classify.d.ts +57 -0
  113. package/dist/types/permissionless/api/oracles/stress/index.d.ts +6 -0
  114. package/dist/types/permissionless/api/oracles/stress/override.d.ts +59 -0
  115. package/dist/types/permissionless/api/oracles/stress/run.d.ts +73 -0
  116. package/dist/types/permissionless/api/oracles/stress/score.d.ts +57 -0
  117. package/dist/types/permissionless/api/oracles/stress/types.d.ts +272 -0
  118. package/dist/types/permissionless/api/oracles/types.d.ts +408 -63
  119. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  120. package/dist/types/permissionless/index.d.ts +11 -3
  121. package/dist/types/permissionless/utils/index.d.ts +2 -2
  122. package/dist/types/permissionless/utils/price-update/get-prices.d.ts +33 -0
  123. package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
  124. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  125. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  126. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  127. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  128. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  129. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  130. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  131. package/dist/types/testnets/errors/index.d.ts +7 -0
  132. package/dist/types/testnets/index.d.ts +11 -0
  133. package/dist/types/testnets/schemas.d.ts +554 -0
  134. package/dist/types/testnets/types.d.ts +717 -0
  135. package/package.json +9 -3
@@ -17,7 +17,18 @@ export declare const priceFeedSchema: z.ZodObject<{
17
17
  stalenessPeriod: z.ZodNumber;
18
18
  name: z.ZodString;
19
19
  }, z.core.$loose>;
20
- /** {@link PermissionlessAsset} */
20
+ /**
21
+ * {@link PermissionlessPriceFeedAsset}
22
+ *
23
+ * What identifies an asset, which is all a feed's own listing of one says.
24
+ **/
25
+ export declare const priceFeedAssetSchema: z.ZodObject<{
26
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
27
+ symbol: z.ZodString;
28
+ name: z.ZodString;
29
+ decimals: z.ZodNumber;
30
+ }, z.core.$loose>;
31
+ /** {@link PermissionlessAsset} — identified as above, plus what prices it. */
21
32
  export declare const assetSchema: z.ZodObject<{
22
33
  address: z.ZodCustom<`0x${string}`, `0x${string}`>;
23
34
  symbol: z.ZodString;
@@ -33,7 +44,12 @@ export declare const assetSchema: z.ZodObject<{
33
44
  name: z.ZodString;
34
45
  }, z.core.$loose>>;
35
46
  }, z.core.$loose>;
36
- /** {@link PermissionlessPriceFeedStore} */
47
+ /**
48
+ * {@link PermissionlessPriceFeedStore}
49
+ *
50
+ * A store is a chain's, and is described by the same five fields the chain
51
+ * list answers with, so those are extended rather than restated.
52
+ **/
37
53
  export declare const priceFeedStoreSchema: z.ZodObject<{
38
54
  chainId: z.ZodNumber;
39
55
  name: z.ZodString;
@@ -64,33 +80,103 @@ export declare const priceFeedStoreSchema: z.ZodObject<{
64
80
  name: z.ZodString;
65
81
  }, z.core.$loose>>;
66
82
  }, z.core.$loose>;
67
- /** {@link PermissionlessPrices} */
68
- export declare const pricesSchema: z.ZodObject<{
69
- prices: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
70
- marketCaps: z.ZodType<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown>>;
71
- time: z.ZodNumber;
72
- }, z.core.$loose>;
73
- /** {@link PermissionlessPriceFeedAsset} */
74
- export declare const priceFeedAssetSchema: z.ZodObject<{
75
- address: z.ZodCustom<`0x${string}`, `0x${string}`>;
76
- symbol: z.ZodString;
83
+ /** Every chain's {@link PermissionlessPriceFeedStore}, one per chain. */
84
+ export declare const priceFeedStoresSchema: z.ZodArray<z.ZodObject<{
85
+ chainId: z.ZodNumber;
77
86
  name: z.ZodString;
78
- decimals: z.ZodNumber;
79
- }, z.core.$loose>;
80
- /** {@link PermissionlessPriceFeedMarket} */
87
+ isPublic: z.ZodBoolean;
88
+ isActivated: z.ZodBoolean;
89
+ explorerUrl: z.ZodString;
90
+ assets: z.ZodArray<z.ZodObject<{
91
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
92
+ symbol: z.ZodString;
93
+ name: z.ZodString;
94
+ decimals: z.ZodNumber;
95
+ owner: z.ZodCustom<`0x${string}`, `0x${string}`>;
96
+ priceFeeds: z.ZodArray<z.ZodObject<{
97
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
98
+ contractType: z.ZodString;
99
+ version: z.ZodNumber;
100
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
101
+ stalenessPeriod: z.ZodNumber;
102
+ name: z.ZodString;
103
+ }, z.core.$loose>>;
104
+ }, z.core.$loose>>;
105
+ priceFeeds: z.ZodArray<z.ZodObject<{
106
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
107
+ contractType: z.ZodString;
108
+ version: z.ZodNumber;
109
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
110
+ stalenessPeriod: z.ZodNumber;
111
+ name: z.ZodString;
112
+ }, z.core.$loose>>;
113
+ }, z.core.$loose>>;
114
+ /**
115
+ * {@link PermissionlessIndexedPriceFeedMarket} — the market as the feed's slot
116
+ * in it, before the oracle is asked what period it holds for the slot.
117
+ **/
81
118
  export declare const priceFeedMarketSchema: z.ZodObject<{
82
119
  market: z.ZodCustom<`0x${string}`, `0x${string}`>;
83
120
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
84
121
  curatorName: z.ZodNullable<z.ZodString>;
85
122
  marketName: z.ZodNullable<z.ZodString>;
123
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
124
+ isUnderlying: z.ZodBoolean;
125
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
126
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
86
127
  token: z.ZodCustom<`0x${string}`, `0x${string}`>;
87
128
  tokenSymbol: z.ZodNullable<z.ZodString>;
88
- underlyingSymbol: z.ZodNullable<z.ZodString>;
89
129
  reserve: z.ZodBoolean;
130
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
131
+ }, z.core.$loose>;
132
+ /**
133
+ * {@link PermissionlessMarketSlot} — the same slot read from the chain's end,
134
+ * so the feed is a column rather than what was asked for.
135
+ **/
136
+ export declare const marketSlotSchema: z.ZodObject<{
137
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
138
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
139
+ curatorName: z.ZodNullable<z.ZodString>;
140
+ marketName: z.ZodNullable<z.ZodString>;
141
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
90
142
  isUnderlying: z.ZodBoolean;
91
143
  quotaLimit: z.ZodNullable<z.ZodNumber>;
144
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
145
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
146
+ tokenSymbol: z.ZodNullable<z.ZodString>;
147
+ reserve: z.ZodBoolean;
148
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
149
+ chainId: z.ZodNumber;
150
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
151
+ isShutdown: z.ZodBoolean;
152
+ priceFeed: z.ZodCustom<`0x${string}`, `0x${string}`>;
153
+ priceFeedName: z.ZodNullable<z.ZodString>;
154
+ priceFeedInStore: z.ZodBoolean;
155
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
92
156
  }, z.core.$loose>;
93
- /** {@link PermissionlessPriceFeedDetails} */
157
+ /** Every slot in scope, across whichever chains the read covered. */
158
+ export declare const marketSlotsSchema: z.ZodArray<z.ZodObject<{
159
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
160
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
161
+ curatorName: z.ZodNullable<z.ZodString>;
162
+ marketName: z.ZodNullable<z.ZodString>;
163
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
164
+ isUnderlying: z.ZodBoolean;
165
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
166
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
167
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
168
+ tokenSymbol: z.ZodNullable<z.ZodString>;
169
+ reserve: z.ZodBoolean;
170
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
171
+ chainId: z.ZodNumber;
172
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
173
+ isShutdown: z.ZodBoolean;
174
+ priceFeed: z.ZodCustom<`0x${string}`, `0x${string}`>;
175
+ priceFeedName: z.ZodNullable<z.ZodString>;
176
+ priceFeedInStore: z.ZodBoolean;
177
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
178
+ }, z.core.$loose>>;
179
+ /** {@link PermissionlessIndexedPriceFeedDetails} */
94
180
  export declare const priceFeedDetailsSchema: z.ZodObject<{
95
181
  chainId: z.ZodNumber;
96
182
  priceFeed: z.ZodObject<{
@@ -112,17 +198,118 @@ export declare const priceFeedDetailsSchema: z.ZodObject<{
112
198
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
113
199
  curatorName: z.ZodNullable<z.ZodString>;
114
200
  marketName: z.ZodNullable<z.ZodString>;
201
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
202
+ isUnderlying: z.ZodBoolean;
203
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
204
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
115
205
  token: z.ZodCustom<`0x${string}`, `0x${string}`>;
116
206
  tokenSymbol: z.ZodNullable<z.ZodString>;
117
- underlyingSymbol: z.ZodNullable<z.ZodString>;
118
207
  reserve: z.ZodBoolean;
208
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
209
+ }, z.core.$loose>>;
210
+ }, z.core.$loose>;
211
+ /** {@link PermissionlessAssetMarketFeed} */
212
+ export declare const assetMarketFeedSchema: z.ZodObject<{
213
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
214
+ name: z.ZodNullable<z.ZodString>;
215
+ inStore: z.ZodBoolean;
216
+ }, z.core.$loose>;
217
+ /** {@link PermissionlessAssetMarket} — the market as what prices the asset in it. */
218
+ export declare const assetMarketSchema: z.ZodObject<{
219
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
220
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
221
+ curatorName: z.ZodNullable<z.ZodString>;
222
+ marketName: z.ZodNullable<z.ZodString>;
223
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
224
+ isUnderlying: z.ZodBoolean;
225
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
226
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
227
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
228
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
229
+ isShutdown: z.ZodBoolean;
230
+ mainFeed: z.ZodNullable<z.ZodObject<{
231
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
232
+ name: z.ZodNullable<z.ZodString>;
233
+ inStore: z.ZodBoolean;
234
+ }, z.core.$loose>>;
235
+ reserveFeed: z.ZodNullable<z.ZodObject<{
236
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
237
+ name: z.ZodNullable<z.ZodString>;
238
+ inStore: z.ZodBoolean;
239
+ }, z.core.$loose>>;
240
+ }, z.core.$loose>;
241
+ /** {@link PermissionlessIndexedAssetDetails} */
242
+ export declare const assetDetailsSchema: z.ZodObject<{
243
+ chainId: z.ZodNumber;
244
+ asset: z.ZodObject<{
245
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
246
+ symbol: z.ZodString;
247
+ name: z.ZodString;
248
+ decimals: z.ZodNumber;
249
+ }, z.core.$loose>;
250
+ priceFeeds: z.ZodArray<z.ZodObject<{
251
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
252
+ contractType: z.ZodString;
253
+ version: z.ZodNumber;
254
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
255
+ stalenessPeriod: z.ZodNumber;
256
+ name: z.ZodString;
257
+ }, z.core.$loose>>;
258
+ markets: z.ZodArray<z.ZodObject<{
259
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
260
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
261
+ curatorName: z.ZodNullable<z.ZodString>;
262
+ marketName: z.ZodNullable<z.ZodString>;
263
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
119
264
  isUnderlying: z.ZodBoolean;
120
265
  quotaLimit: z.ZodNullable<z.ZodNumber>;
266
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
267
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
268
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
269
+ isShutdown: z.ZodBoolean;
270
+ mainFeed: z.ZodNullable<z.ZodObject<{
271
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
272
+ name: z.ZodNullable<z.ZodString>;
273
+ inStore: z.ZodBoolean;
274
+ }, z.core.$loose>>;
275
+ reserveFeed: z.ZodNullable<z.ZodObject<{
276
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
277
+ name: z.ZodNullable<z.ZodString>;
278
+ inStore: z.ZodBoolean;
279
+ }, z.core.$loose>>;
121
280
  }, z.core.$loose>>;
122
281
  }, z.core.$loose>;
123
- /** {@link PermissionlessPriceFeedMarketCaps} */
124
- export declare const priceFeedMarketCapsSchema: z.ZodObject<{
125
- marketCaps: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
126
- time: z.ZodNumber;
282
+ /** {@link PermissionlessAssetQuota} */
283
+ export declare const assetQuotaSchema: z.ZodObject<{
284
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
285
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
286
+ isShutdown: z.ZodBoolean;
287
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
288
+ }, z.core.$loose>;
289
+ /** {@link PermissionlessIndexedAssetSummary} */
290
+ export declare const assetSummarySchema: z.ZodObject<{
291
+ chainId: z.ZodNumber;
292
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
293
+ symbol: z.ZodString;
294
+ underlyingMarketCount: z.ZodNumber;
295
+ marketQuotas: z.ZodArray<z.ZodObject<{
296
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
297
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
298
+ isShutdown: z.ZodBoolean;
299
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
300
+ }, z.core.$loose>>;
127
301
  }, z.core.$loose>;
302
+ /** The list of {@link PermissionlessAssetSummary}, already ordered. */
303
+ export declare const assetSummariesSchema: z.ZodArray<z.ZodObject<{
304
+ chainId: z.ZodNumber;
305
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
306
+ symbol: z.ZodString;
307
+ underlyingMarketCount: z.ZodNumber;
308
+ marketQuotas: z.ZodArray<z.ZodObject<{
309
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
310
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
311
+ isShutdown: z.ZodBoolean;
312
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
313
+ }, z.core.$loose>>;
314
+ }, z.core.$loose>>;
128
315
  //#endregion
@@ -0,0 +1,46 @@
1
+ import { MarketScore, ScoredFeed } from "./types.js";
2
+ //#region src/permissionless/api/oracles/score/formula.d.ts
3
+ /**
4
+ * How well a market guards an asset's price, from its two feeds alone.
5
+ *
6
+ * Two questions, and the points are lost for each separately:
7
+ *
8
+ * - Would the reserve disagree with a main feed that has gone wrong? Only if
9
+ * it is a second feed on other sources. A missing reserve, a
10
+ * `ZeroPriceFeed`, the main feed again, and a different feed on the same
11
+ * sources all answer no.
12
+ * - Is either feed bounded? A `BoundedPriceFeed` caps the answer from above,
13
+ * and a Gearbox LP feed clamps its exchange rate to a window.
14
+ *
15
+ * Independence costs more than the bound, 6 points against 5, because it is
16
+ * the broader protection: a bounded feed caps only from above, and an LP
17
+ * feed's window holds only its rate, not the price of what the rate is in.
18
+ * Either failure alone lands a market at 4 or 5; both together at 0.
19
+ */
20
+ export declare const INDEPENDENCE_WEIGHT = 6;
21
+ export declare const BOUND_WEIGHT = 5;
22
+ /** A source, as the overlap between two feeds is counted. */
23
+ export interface ScoreSource {
24
+ /** What two feeds have to share to be on the same source. */
25
+ key: string;
26
+ /** What a reader is told. */
27
+ name: string;
28
+ /** A source the classifier named, rather than one grouped alone. */
29
+ identified: boolean;
30
+ }
31
+ /**
32
+ * One market's score for one asset.
33
+ *
34
+ * `reserve` is `null` where the market holds no reserve for the asset at all.
35
+ * A source is passed per side and keyed by the caller, which is where it is
36
+ * decided that an unnamed source is its own contract and a named one is its
37
+ * group.
38
+ */
39
+ export declare function scoreMarket(market: Omit<MarketScore, "main" | "reserve" | "hasReserve" | "independence" | "bounded" | "sharedSources" | "unverified" | "score" | "reasons">, main: {
40
+ feed: Omit<ScoredFeed, "sources">;
41
+ sources: ScoreSource[];
42
+ }, reserve: {
43
+ feed: Omit<ScoredFeed, "sources">;
44
+ sources: ScoreSource[];
45
+ } | null): MarketScore;
46
+ //#endregion
@@ -0,0 +1,4 @@
1
+ import { AssetScore, AssetScoresArgs, MarketScore, ScoredFeed } from "./types.js";
2
+ import { BOUND_WEIGHT, INDEPENDENCE_WEIGHT, ScoreSource, scoreMarket } from "./formula.js";
3
+ import { runAssetScores } from "./run.js";
4
+ export { AssetScore, AssetScoresArgs, BOUND_WEIGHT, INDEPENDENCE_WEIGHT, MarketScore, ScoreSource, ScoredFeed, runAssetScores, scoreMarket };
@@ -0,0 +1,21 @@
1
+ import { AssetScore } from "./types.js";
2
+ import { PermissionlessMarketSlot } from "../types.js";
3
+ import { Address, Chain, PublicClient, Transport } from "viem";
4
+ //#region src/permissionless/api/oracles/score/run.d.ts
5
+ /**
6
+ * Every asset of one chain, scored by how its running markets price it.
7
+ *
8
+ * One read of every oracle's feed tree and one of the LP feeds' rate
9
+ * contracts, both multicalls: the score is a reading of the trees and needs
10
+ * no simulation.
11
+ **/
12
+ export declare function runAssetScores({ client, chainId, slots, compressor, logger }: {
13
+ client: PublicClient<Transport, Chain>;
14
+ chainId: number;
15
+ slots: PermissionlessMarketSlot[];
16
+ compressor: Address;
17
+ logger?: {
18
+ warn(message: string): void;
19
+ };
20
+ }): Promise<AssetScore[]>;
21
+ //#endregion
@@ -0,0 +1,85 @@
1
+ import { Address } from "viem";
2
+ //#region src/permissionless/api/oracles/score/types.d.ts
3
+ /**
4
+ * One of a market's two feeds for a token, as the score reads it.
5
+ **/
6
+ export interface ScoredFeed {
7
+ feed: Address;
8
+ /** The store's name for the feed, `null` where it has none. */
9
+ name: string | null;
10
+ /** Gearbox contract type of the feed itself, `""` for one it never deployed. */
11
+ contractType: string;
12
+ /**
13
+ * Every price source beneath the feed, by name: `"Chainlink"`, `"Lido"`, or
14
+ * the description of a source nothing could name.
15
+ */
16
+ sources: string[];
17
+ }
18
+ /**
19
+ * How well one market guards one asset's price, out of 10.
20
+ *
21
+ * `score = max(0, 10 − 6·(1 − independence) − 5·(1 − bounded))`, rounded down
22
+ * to a half point.
23
+ **/
24
+ export interface MarketScore {
25
+ market: Address;
26
+ marketName: string | null;
27
+ marketConfigurator: Address;
28
+ curatorName: string | null;
29
+ main: ScoredFeed;
30
+ /** `null` where the market holds no reserve for the asset at all. */
31
+ reserve: ScoredFeed | null;
32
+ /**
33
+ * The reserve is a second feed: present, not a `ZeroPriceFeed`, and not
34
+ * the main feed again.
35
+ */
36
+ hasReserve: boolean;
37
+ /**
38
+ * The share of the two feeds' sources they do not have in common:
39
+ * `1 − |shared| / |all|`. 1 for feeds with nothing in common, 0 for feeds
40
+ * on the same sources — and 0 where {@link hasReserve} is false.
41
+ */
42
+ independence: number;
43
+ /** Main or reserve is a `BoundedPriceFeed` or a Gearbox LP feed. */
44
+ bounded: boolean;
45
+ /** The sources the two feeds have in common, by name. */
46
+ sharedSources: string[];
47
+ /**
48
+ * The independence counted here rests on a source nothing could name.
49
+ *
50
+ * Such a source counts as its own, so two of them look independent even
51
+ * if one operator stands behind both. The same unnamed source on both
52
+ * sides — the same contract — is still counted as shared.
53
+ */
54
+ unverified: boolean;
55
+ score: number;
56
+ /** What cost the market its points, for a reader to act on. Empty at 10. */
57
+ reasons: string[];
58
+ }
59
+ /**
60
+ * One asset's score: its worst market's.
61
+ *
62
+ * The minimum, not an average, because the asset is only as well guarded as
63
+ * the most exposed market that accepts it.
64
+ **/
65
+ export interface AssetScore {
66
+ chainId: number;
67
+ asset: Address;
68
+ symbol: string | null;
69
+ /**
70
+ * `null` for an asset no running market accepts as collateral: every
71
+ * market has it switched off, or it is only ever a market's underlying.
72
+ */
73
+ score: number | null;
74
+ /** Some market's score rests on a source nothing could name. */
75
+ unverified: boolean;
76
+ /** The market the score comes from. */
77
+ worst: MarketScore | null;
78
+ /** Every running market pricing the asset, worst first. */
79
+ markets: MarketScore[];
80
+ }
81
+ export interface AssetScoresArgs {
82
+ /** Omitted scores every chain the backend serves markets for. */
83
+ chainId?: number;
84
+ }
85
+ //#endregion
@@ -0,0 +1,57 @@
1
+ import { StressSource } from "./types.js";
2
+ import { Address } from "viem";
3
+ //#region src/permissionless/api/oracles/stress/classify.d.ts
4
+ /**
5
+ * Who a price ultimately comes from, worked out from what the chain says
6
+ * about the feed reporting it.
7
+ *
8
+ * There is no registry on chain of which aggregator belongs to whom, so this
9
+ * is a reading of three things the chain does carry: the Gearbox contract
10
+ * type, which names the provider outright for the feeds Gearbox deploys; the
11
+ * `description()` every Chainlink-shaped feed returns; and the interface
12
+ * version, which separates Chainlink's own proxies from the many contracts
13
+ * that imitate them.
14
+ *
15
+ * Every rule is open to inspection and every unmatched feed is reported as
16
+ * unmatched, because the alternative — guessing from a symbol, or sweeping
17
+ * the remainder into one bucket — would understate exactly the part of the
18
+ * answer a reader should distrust.
19
+ **/
20
+ /** One node of an oracle's feed tree, as the compressor reports it. */
21
+ export interface TreeNode {
22
+ address: Address;
23
+ /** Gearbox contract type, `""` for a contract it never deployed. */
24
+ contractType: string;
25
+ /** `AggregatorV3Interface.version()`, or 0 where there is none. */
26
+ version: number;
27
+ description: string;
28
+ /** The feeds it reads, lowercased. Empty makes it a leaf. */
29
+ underlyingFeeds: Address[];
30
+ }
31
+ /**
32
+ * Every source behind a chain's feed trees.
33
+ *
34
+ * A source per contract, not per feed: two of an oracle's trees carrying the
35
+ * same aggregator is one source read twice, and the test varies it once.
36
+ *
37
+ * `rateTargets` says which contract each rate-bearing feed reads its rate
38
+ * from — the feed's own `lpContract`, read separately because the compressor
39
+ * does not report it. A feed missing from it is left out with a reason, since
40
+ * perturbing the whole feed instead would charge its protocol with a failure
41
+ * of whatever prices the thing the rate is denominated in.
42
+ **/
43
+ export declare function classifySources(chainId: number, nodes: TreeNode[], rateTargets: Map<Address, Address>, baselineOf: (target: Address) => bigint | null): {
44
+ sources: StressSource[];
45
+ unresolved: TreeNode[];
46
+ };
47
+ /**
48
+ * The sources each of the given feeds is priced through, following the trees
49
+ * down from every one of them.
50
+ *
51
+ * A feed is reached by a source when the source sits anywhere beneath it, at
52
+ * any depth: a market reading a composite of a composite of a Chainlink
53
+ * aggregator is a market Chainlink can move. Memoised over the whole forest,
54
+ * so a node shared by twenty trees is walked once.
55
+ **/
56
+ export declare function sourcesByFeed(roots: Address[], nodes: Map<Address, TreeNode>, sources: StressSource[]): Map<Address, Set<Address>>;
57
+ //#endregion
@@ -0,0 +1,6 @@
1
+ import { BreakingPoint, FeedOutcome, GroupReport, GroupScenarioOutcome, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs } from "./types.js";
2
+ import { TreeNode, classifySources, sourcesByFeed } from "./classify.js";
3
+ import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./override.js";
4
+ import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, runStressTest } from "./run.js";
5
+ import { scoreGroup, slotHarm, verdictOf } from "./score.js";
6
+ export { BreakingPoint, DEFAULT_SCENARIOS, FeedOutcome, GroupReport, GroupScenarioOutcome, RATE_FEED_TYPE, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs, TreeNode, UNBOUNDED_DOWN, UNBOUNDED_UP, classifySources, groupOverride, perturb, rateStub, readForest, readRateTargets, roundDataStub, runStressTest, scoreGroup, slotHarm, sourcesByFeed, verdictOf };
@@ -0,0 +1,59 @@
1
+ import { StressSource } from "./types.js";
2
+ import { Hex, StateOverride } from "viem";
3
+ //#region src/permissionless/api/oracles/stress/override.d.ts
4
+ /**
5
+ * Runtime code answering every call with the same five words.
6
+ *
7
+ * Deliberately selector-blind. A price feed is read through more than
8
+ * `latestRoundData` — `decimals`, `version`, sometimes `latestAnswer` — and
9
+ * dispatching on each would mean knowing which of them every caller in a tree
10
+ * reaches for. Five words decode as the round data; a caller expecting one
11
+ * word reads the first, which is why `roundId` is set to the 8 decimals every
12
+ * Gearbox feed reports rather than to a round number.
13
+ *
14
+ * `answeredInRound` is the same 8, so the `answeredInRound >= roundId` check
15
+ * the older consumers make passes.
16
+ **/
17
+ export declare function roundDataStub(answer: bigint, updatedAt: bigint): Hex;
18
+ /**
19
+ * Runtime code answering every call with one word.
20
+ *
21
+ * What an exchange rate getter returns, whichever of them the feed calls:
22
+ * `stEthPerToken`, `convertToAssets`, `get_virtual_price`, `pricePerShare`
23
+ * and `getRate` all answer a single `uint256`, so the stub does not need to
24
+ * know which.
25
+ **/
26
+ export declare function rateStub(rate: bigint): Hex;
27
+ /**
28
+ * The two unbounded ends, as far as the types involved can carry them.
29
+ *
30
+ * "Infinitely large" has to stop somewhere: a price is an `int256` and the
31
+ * arithmetic above it multiplies, so a genuinely enormous answer overflows
32
+ * inside the composite feed and reverts — which would be scored as the
33
+ * oracle resisting, when all that happened is that the test asked something
34
+ * the type cannot hold. `1e12` times the current answer is past any bound,
35
+ * any sanity check and any collateral ratio, and still multiplies.
36
+ */
37
+ export declare const UNBOUNDED_UP = 1000000000000;
38
+ /** The other end: a thousandth of a trillionth, which is as near zero. */
39
+ export declare const UNBOUNDED_DOWN = 1e-12;
40
+ /**
41
+ * What a source should answer under a multiplier, given what it answers now.
42
+ *
43
+ * Floored at one rather than at zero: a multiplier small enough to round the
44
+ * baseline away would be testing a feed reporting nothing, which is the revert
45
+ * case and is a different scenario with a different meaning.
46
+ */
47
+ export declare function perturb(baseline: bigint, multiplier: number): bigint;
48
+ /**
49
+ * The state override that makes every source of a group answer a multiple of
50
+ * what it answers now.
51
+ *
52
+ * One override per contract, so a group whose sources share an aggregator
53
+ * perturbs it once. Sources with nothing behind them and sources that are not
54
+ * answering are both left out, for the reasons on
55
+ * {@link StressSource.perturbable} and {@link StressSource.baseline} — an
56
+ * empty result is a group there is nothing to simulate about.
57
+ **/
58
+ export declare function groupOverride(sources: StressSource[], multiplier: number, updatedAt: bigint): StateOverride;
59
+ //#endregion
@@ -0,0 +1,73 @@
1
+ import { StressReport, StressScenario } from "./types.js";
2
+ import { PermissionlessMarketSlot } from "../types.js";
3
+ import { TreeNode } from "./classify.js";
4
+ import { Address, Chain, PublicClient, Transport } from "viem";
5
+ //#region src/permissionless/api/oracles/stress/run.d.ts
6
+ /**
7
+ * The two ends the question is asked at, which is what "infinitely large and
8
+ * infinitely small" comes to once a type has to hold it.
9
+ */
10
+ export declare const DEFAULT_SCENARIOS: StressScenario[];
11
+ /**
12
+ * The Gearbox LP feeds: a protocol's exchange rate, clamped to a window the
13
+ * feed holds, times the price of what the rate is denominated in.
14
+ */
15
+ export declare const RATE_FEED_TYPE: RegExp;
16
+ /**
17
+ * The feed trees of every oracle the chain's markets use, flattened.
18
+ *
19
+ * One call per oracle and not per feed: the compressor answers an oracle's
20
+ * entire tree at once, with every node's type, description, children and
21
+ * current answer, which is the whole of what this test needs off the chain.
22
+ * A node carried by several oracles is one node — the trees overlap heavily,
23
+ * since the aggregators under them are the same handful.
24
+ */
25
+ export declare function readForest(client: PublicClient<Transport, Chain>, compressor: Address, oracles: Address[]): Promise<{
26
+ nodes: Map<Address, TreeNode>;
27
+ answers: Map<Address, bigint | null>;
28
+ unreadableOracles: Address[];
29
+ }>;
30
+ /**
31
+ * Where each rate-bearing feed reads its rate, and what it will accept.
32
+ *
33
+ * The baseline a rate source is perturbed from is the feed's own `lowerBound`
34
+ * and not the rate itself. Reading the rate would mean knowing which getter
35
+ * each protocol publishes it under — `stEthPerToken`, `convertToAssets`,
36
+ * `get_virtual_price`, `pricePerShare` — and in exactly which units, which is
37
+ * a table that goes stale. The bound is within the feed's own accepted window
38
+ * of the live rate by construction, so it is the same figure to within that
39
+ * window, which is two percent or so. That is immaterial against the
40
+ * multipliers the ends of the sweep use, and at the fine end of the threshold
41
+ * search the bound *is* the answer: an LP feed clamps the rate it accepts, so
42
+ * where it breaks is where its bound is.
43
+ */
44
+ export declare function readRateTargets(client: PublicClient<Transport, Chain>, feeds: Address[]): Promise<{
45
+ targets: Map<Address, Address>;
46
+ baselines: Map<Address, bigint>;
47
+ bounds: Map<Address, {
48
+ lower: bigint;
49
+ upper: bigint;
50
+ }>;
51
+ }>;
52
+ /**
53
+ * Every source behind one chain's markets, put through the sweep a group at a
54
+ * time.
55
+ *
56
+ * Takes the slots as read, so the caller decides whether that read came from
57
+ * the backend or from somewhere else, and takes a client rather than making
58
+ * one, so the whole thing is testable against a stub.
59
+ **/
60
+ export declare function runStressTest({ client, chainId, slots, compressor, scenarios, thresholds, groups: only, logger }: {
61
+ client: PublicClient<Transport, Chain>;
62
+ chainId: number;
63
+ slots: PermissionlessMarketSlot[];
64
+ compressor: Address;
65
+ scenarios?: StressScenario[];
66
+ thresholds?: boolean;
67
+ groups?: string[];
68
+ logger?: {
69
+ warn(message: string): void;
70
+ debug?(message: string): void;
71
+ };
72
+ }): Promise<StressReport>;
73
+ //#endregion