@gearbox-protocol/sdk 18.3.0 → 18.4.0

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 (181) hide show
  1. package/dist/cjs/abi/310/iKillSwitchProxy.js +130 -0
  2. package/dist/cjs/onchain/accounts/intents/maxBorrowAndWithdraw.js +3 -1
  3. package/dist/cjs/onchain/index.js +18 -0
  4. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +113 -0
  5. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +258 -0
  6. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +161 -0
  7. package/dist/cjs/onchain/market/adapters/abi/adapters/index.js +6 -0
  8. package/dist/cjs/onchain/market/adapters/abi/index.js +13 -0
  9. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +39 -0
  10. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +230 -0
  11. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +29 -0
  12. package/dist/cjs/onchain/market/adapters/abi/treehouse/index.js +7 -0
  13. package/dist/cjs/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +72 -0
  14. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +117 -0
  15. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +61 -0
  16. package/dist/cjs/onchain/market/adapters/contracts/index.js +6 -0
  17. package/dist/cjs/onchain/market/adapters/createAdapter.js +6 -0
  18. package/dist/cjs/onchain/market/adapters/index.js +18 -0
  19. package/dist/cjs/onchain/market/index.js +18 -0
  20. package/dist/cjs/permissionless/api/index.js +31 -0
  21. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +637 -65
  22. package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
  23. package/dist/cjs/permissionless/api/oracles/index.js +33 -0
  24. package/dist/cjs/permissionless/api/oracles/onchain-feed.js +25 -0
  25. package/dist/cjs/permissionless/api/oracles/schemas.js +84 -59
  26. package/dist/cjs/permissionless/api/oracles/score/formula.js +56 -0
  27. package/dist/cjs/permissionless/api/oracles/score/index.js +11 -0
  28. package/dist/cjs/permissionless/api/oracles/score/run.js +252 -0
  29. package/dist/cjs/permissionless/api/oracles/score/types.js +1 -0
  30. package/dist/cjs/permissionless/api/oracles/stress/classify.js +258 -0
  31. package/dist/cjs/permissionless/api/oracles/stress/index.js +24 -0
  32. package/dist/cjs/permissionless/api/oracles/stress/override.js +125 -0
  33. package/dist/cjs/permissionless/api/oracles/stress/run.js +485 -0
  34. package/dist/cjs/permissionless/api/oracles/stress/score.js +98 -0
  35. package/dist/cjs/permissionless/api/oracles/stress/types.js +1 -0
  36. package/dist/cjs/permissionless/api/schemas.js +0 -3
  37. package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  38. package/dist/cjs/permissionless/api/transactions/lp-price-feeds.js +10 -4
  39. package/dist/cjs/permissionless/bindings/bytecode-repository.js +8 -0
  40. package/dist/cjs/permissionless/bindings/governance/governor.js +1 -1
  41. package/dist/cjs/permissionless/bindings/index.js +8 -3
  42. package/dist/cjs/permissionless/bindings/kill-switch-proxy.js +188 -0
  43. package/dist/cjs/permissionless/bindings/market-configurator-factory.js +39 -1
  44. package/dist/cjs/permissionless/bindings/market-configurator.js +142 -0
  45. package/dist/cjs/permissionless/index.js +42 -3
  46. package/dist/cjs/permissionless/utils/index.js +3 -0
  47. package/dist/cjs/permissionless/utils/literals.js +2 -0
  48. package/dist/cjs/permissionless/utils/price-update/get-prices.js +64 -0
  49. package/dist/cjs/permissionless/utils/price-update/index.js +2 -0
  50. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  51. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  52. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  53. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  54. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  55. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  56. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  57. package/dist/cjs/testnets/errors/index.js +13 -0
  58. package/dist/cjs/testnets/index.js +32 -0
  59. package/dist/cjs/testnets/package.json +1 -0
  60. package/dist/cjs/testnets/schemas.js +242 -0
  61. package/dist/cjs/testnets/types.js +1 -0
  62. package/dist/esm/abi/310/iKillSwitchProxy.js +129 -0
  63. package/dist/esm/onchain/accounts/intents/maxBorrowAndWithdraw.js +3 -1
  64. package/dist/esm/onchain/index.js +10 -1
  65. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +112 -0
  66. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +257 -0
  67. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +160 -0
  68. package/dist/esm/onchain/market/adapters/abi/adapters/index.js +4 -1
  69. package/dist/esm/onchain/market/adapters/abi/index.js +8 -1
  70. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +38 -0
  71. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +229 -0
  72. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +28 -0
  73. package/dist/esm/onchain/market/adapters/abi/treehouse/index.js +4 -0
  74. package/dist/esm/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +71 -0
  75. package/dist/esm/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +116 -0
  76. package/dist/esm/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +60 -0
  77. package/dist/esm/onchain/market/adapters/contracts/index.js +4 -1
  78. package/dist/esm/onchain/market/adapters/createAdapter.js +6 -0
  79. package/dist/esm/onchain/market/adapters/index.js +10 -1
  80. package/dist/esm/onchain/market/index.js +10 -1
  81. package/dist/esm/permissionless/api/index.js +7 -1
  82. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +639 -67
  83. package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
  84. package/dist/esm/permissionless/api/oracles/index.js +10 -1
  85. package/dist/esm/permissionless/api/oracles/onchain-feed.js +24 -0
  86. package/dist/esm/permissionless/api/oracles/schemas.js +80 -58
  87. package/dist/esm/permissionless/api/oracles/score/formula.js +51 -0
  88. package/dist/esm/permissionless/api/oracles/score/index.js +4 -0
  89. package/dist/esm/permissionless/api/oracles/score/run.js +250 -0
  90. package/dist/esm/permissionless/api/oracles/score/types.js +1 -0
  91. package/dist/esm/permissionless/api/oracles/stress/classify.js +256 -0
  92. package/dist/esm/permissionless/api/oracles/stress/index.js +6 -0
  93. package/dist/esm/permissionless/api/oracles/stress/override.js +119 -0
  94. package/dist/esm/permissionless/api/oracles/stress/run.js +478 -0
  95. package/dist/esm/permissionless/api/oracles/stress/score.js +95 -0
  96. package/dist/esm/permissionless/api/oracles/stress/types.js +1 -0
  97. package/dist/esm/permissionless/api/schemas.js +2 -4
  98. package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  99. package/dist/esm/permissionless/api/transactions/lp-price-feeds.js +10 -4
  100. package/dist/esm/permissionless/bindings/bytecode-repository.js +8 -0
  101. package/dist/esm/permissionless/bindings/governance/governor.js +1 -1
  102. package/dist/esm/permissionless/bindings/index.js +5 -4
  103. package/dist/esm/permissionless/bindings/kill-switch-proxy.js +184 -0
  104. package/dist/esm/permissionless/bindings/market-configurator-factory.js +37 -0
  105. package/dist/esm/permissionless/bindings/market-configurator.js +143 -1
  106. package/dist/esm/permissionless/index.js +13 -6
  107. package/dist/esm/permissionless/utils/index.js +3 -3
  108. package/dist/esm/permissionless/utils/literals.js +2 -1
  109. package/dist/esm/permissionless/utils/price-update/get-prices.js +63 -1
  110. package/dist/esm/permissionless/utils/price-update/index.js +2 -2
  111. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  112. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  113. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  114. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  115. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  116. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  117. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  118. package/dist/esm/testnets/errors/index.js +7 -0
  119. package/dist/esm/testnets/index.js +11 -0
  120. package/dist/esm/testnets/package.json +1 -0
  121. package/dist/esm/testnets/schemas.js +228 -0
  122. package/dist/esm/testnets/types.js +1 -0
  123. package/dist/types/abi/310/iKillSwitchProxy.d.ts +114 -0
  124. package/dist/types/onchain/index.d.ts +10 -1
  125. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.d.ts +101 -0
  126. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.d.ts +237 -0
  127. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.d.ts +146 -0
  128. package/dist/types/onchain/market/adapters/abi/adapters/index.d.ts +4 -1
  129. package/dist/types/onchain/market/adapters/abi/index.d.ts +8 -1
  130. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.d.ts +33 -0
  131. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.d.ts +207 -0
  132. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRouter.d.ts +27 -0
  133. package/dist/types/onchain/market/adapters/abi/treehouse/index.d.ts +4 -0
  134. package/dist/types/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.d.ts +156 -0
  135. package/dist/types/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.d.ts +481 -0
  136. package/dist/types/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.d.ts +193 -0
  137. package/dist/types/onchain/market/adapters/contracts/index.d.ts +4 -1
  138. package/dist/types/onchain/market/adapters/index.d.ts +10 -1
  139. package/dist/types/onchain/market/index.d.ts +10 -1
  140. package/dist/types/permissionless/api/index.d.ts +10 -2
  141. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +237 -47
  142. package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
  143. package/dist/types/permissionless/api/oracles/index.d.ts +12 -2
  144. package/dist/types/permissionless/api/oracles/onchain-feed.d.ts +15 -0
  145. package/dist/types/permissionless/api/oracles/schemas.d.ts +147 -41
  146. package/dist/types/permissionless/api/oracles/score/formula.d.ts +36 -0
  147. package/dist/types/permissionless/api/oracles/score/index.d.ts +4 -0
  148. package/dist/types/permissionless/api/oracles/score/run.d.ts +42 -0
  149. package/dist/types/permissionless/api/oracles/score/types.d.ts +118 -0
  150. package/dist/types/permissionless/api/oracles/stress/classify.d.ts +57 -0
  151. package/dist/types/permissionless/api/oracles/stress/index.d.ts +6 -0
  152. package/dist/types/permissionless/api/oracles/stress/override.d.ts +59 -0
  153. package/dist/types/permissionless/api/oracles/stress/run.d.ts +100 -0
  154. package/dist/types/permissionless/api/oracles/stress/score.d.ts +57 -0
  155. package/dist/types/permissionless/api/oracles/stress/types.d.ts +272 -0
  156. package/dist/types/permissionless/api/oracles/types.d.ts +320 -125
  157. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  158. package/dist/types/permissionless/api/transactions/lp-price-feeds.d.ts +9 -1
  159. package/dist/types/permissionless/bindings/bytecode-repository.d.ts +10 -1
  160. package/dist/types/permissionless/bindings/index.d.ts +4 -3
  161. package/dist/types/permissionless/bindings/kill-switch-proxy.d.ts +205 -0
  162. package/dist/types/permissionless/bindings/market-configurator-factory.d.ts +30 -0
  163. package/dist/types/permissionless/bindings/market-configurator.d.ts +30 -1
  164. package/dist/types/permissionless/bindings/types.d.ts +27 -0
  165. package/dist/types/permissionless/index.d.ts +15 -6
  166. package/dist/types/permissionless/utils/index.d.ts +3 -3
  167. package/dist/types/permissionless/utils/literals.d.ts +1 -0
  168. package/dist/types/permissionless/utils/price-update/get-prices.d.ts +33 -0
  169. package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
  170. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  171. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  172. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  173. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  174. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  175. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  176. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  177. package/dist/types/testnets/errors/index.d.ts +7 -0
  178. package/dist/types/testnets/index.d.ts +11 -0
  179. package/dist/types/testnets/schemas.d.ts +554 -0
  180. package/dist/types/testnets/types.d.ts +717 -0
  181. package/package.json +6 -1
@@ -1,62 +1,53 @@
1
+ import { AssetType } from "../../../model/primitives.js";
2
+ import { PermissionlessChain } from "../chains/types.js";
1
3
  import { PriceFeed } from "../../core/pricefeed.js";
2
4
  import "../../core/index.js";
3
5
  import { Address } from "viem";
4
6
  //#region src/permissionless/api/oracles/types.d.ts
5
7
  /**
6
- * One asset of a chain, with the feeds allowed for it. The backend indexes
7
- * the chain, so every feed listed here is one the PriceFeedStore carries and
8
- * allows for the asset.
8
+ * What identifies an asset, which is all a feed's own listing of one says.
9
+ *
10
+ * Used on its own where the asset hangs off something else — a feed's assets,
11
+ * say, where listing the feeds allowed for each would only name the feed back.
9
12
  **/
10
- export interface PermissionlessAsset {
13
+ export interface PermissionlessPriceFeedAsset {
11
14
  address: Address;
12
15
  symbol: string;
13
16
  name: string;
14
17
  decimals: number;
18
+ }
19
+ /**
20
+ * One asset of a chain, with the feeds allowed for it. The backend indexes
21
+ * the chain, so every feed listed here is one the PriceFeedStore carries and
22
+ * allows for the asset.
23
+ **/
24
+ export interface PermissionlessAsset extends PermissionlessPriceFeedAsset {
15
25
  owner: Address;
16
26
  priceFeeds: PriceFeed[];
17
27
  }
18
28
  /**
19
29
  * The PriceFeedStore of one chain as the backend has indexed it: the assets
20
30
  * it prices, the feeds it carries, and which feed is allowed on which asset.
31
+ *
32
+ * A store is a chain's, so it is described by the same fields the chain list
33
+ * answers with, plus what it holds.
21
34
  **/
22
- export interface PermissionlessPriceFeedStore {
23
- chainId: number;
24
- name: string;
25
- isPublic: boolean;
26
- isActivated: boolean;
27
- explorerUrl: string;
35
+ export interface PermissionlessPriceFeedStore extends PermissionlessChain {
28
36
  assets: PermissionlessAsset[];
29
37
  priceFeeds: PriceFeed[];
30
38
  }
31
39
  /**
32
- * A price per feed, and a market cap per feed and the asset it prices.
33
- * `null` is a price the backend could not read, not a zero.
34
- **/
35
- export interface PermissionlessPrices {
36
- prices: Record<Address, string | null>;
37
- marketCaps: Record<Address, Record<Address, string | null>>;
38
- time: number;
39
- }
40
- /**
41
- * An asset the PriceFeedStore currently allows one feed to price.
40
+ * What names a market, whichever side it is being listed from.
42
41
  *
43
- * Narrower than {@link PermissionlessAsset} on purpose: this hangs off the
44
- * feed, so listing the feeds allowed for it would just name the feed back.
45
- **/
46
- export interface PermissionlessPriceFeedAsset {
47
- address: Address;
48
- symbol: string;
49
- name: string;
50
- decimals: number;
51
- }
52
- /**
53
- * One token a market prices with the feed.
42
+ * A feed's markets and an asset's markets are different reads, but what they
43
+ * say about the market is the same: who curates it, what it is denominated in
44
+ * and how much of its quota is taken. Only the thing the row is about differs,
45
+ * which is what each of the two below adds.
54
46
  *
55
- * A row per `(market, token, role)` rather than per market: the same feed can
56
- * be the main feed of one token and the reserve feed of another in the very
57
- * same market, and both are reported.
47
+ * "This token" throughout means whatever the extending row is about — the
48
+ * token the feed prices, or the asset the market holds as collateral.
58
49
  **/
59
- export interface PermissionlessPriceFeedMarket {
50
+ export interface PermissionlessMarket {
60
51
  market: Address;
61
52
  marketConfigurator: Address;
62
53
  /** The configurator's own name, as the backend's sync recorded it. */
@@ -66,17 +57,12 @@ export interface PermissionlessPriceFeedMarket {
66
57
  * of the backend calls a market by as well.
67
58
  */
68
59
  marketName: string | null;
69
- token: Address;
70
- /** `null` for a token the backend has no metadata row for. */
71
- tokenSymbol: string | null;
72
60
  /**
73
61
  * Symbol of the market's underlying, which is both what the market is
74
- * pictured by and what its quota limit is denominated in.
62
+ * pictured by and what its quota figures are denominated in.
75
63
  */
76
64
  underlyingSymbol: string | null;
77
- /** The feed is the market's reserve feed for this token, not its main one. */
78
- reserve: boolean;
79
- /** The token is the market's underlying. */
65
+ /** This token is the market's own underlying, so it is not quota-managed. */
80
66
  isUnderlying: boolean;
81
67
  /**
82
68
  * What the pool will take of this token, in units of the market's
@@ -101,29 +87,95 @@ export interface PermissionlessPriceFeedMarket {
101
87
  * holds no entry for at all.
102
88
  */
103
89
  quotaUsed: number | null;
90
+ }
91
+ /**
92
+ * One token a market prices with the feed.
93
+ *
94
+ * A row per `(market, token, role)` rather than per market: the same feed can
95
+ * be the main feed of one token and the reserve feed of another in the very
96
+ * same market, and both are reported.
97
+ **/
98
+ export interface PermissionlessIndexedPriceFeedMarket extends PermissionlessMarket {
99
+ token: Address;
100
+ /** `null` for a token the backend has no metadata row for. */
101
+ tokenSymbol: string | null;
102
+ /** The feed is the market's reserve feed for this token, not its main one. */
103
+ reserve: boolean;
104
+ /**
105
+ * The price oracle holding the slot, which is what the period is read from.
106
+ *
107
+ * The oracle and not the market: a market that has switched oracles has
108
+ * rows under each, and the period lives on whichever one holds the slot now.
109
+ */
110
+ priceOracle: Address;
111
+ }
112
+ /**
113
+ * The same slot with the period its oracle holds for it.
114
+ *
115
+ * Read off the chain rather than served, because it is not indexed: a
116
+ * curator sets one per slot in their price oracle, and nothing obliges it to
117
+ * agree with the period the PriceFeedStore carries for the feed. A reader
118
+ * comparing the two is comparing two contracts, which is why both are
119
+ * reported.
120
+ **/
121
+ export interface PermissionlessPriceFeedMarket extends PermissionlessIndexedPriceFeedMarket {
104
122
  /**
105
123
  * Staleness period this market's own price oracle holds for the slot, in
106
124
  * seconds.
107
125
  *
108
- * The market's figure rather than the store's: a curator sets one per slot
109
- * in their price oracle, and nothing obliges it to agree with the period the
110
- * PriceFeedStore carries for the feed. A reader comparing the two is
111
- * comparing two contracts, which is why both are reported.
112
- *
113
- * Read off the oracle when the route is answered rather than taken from the
114
- * index — the slot's period is not indexed — so `null` means the oracle
115
- * would not answer, not that it holds no period.
126
+ * `null` means the oracle would not answer, or that it names another feed
127
+ * for the slot — in which case the slot has moved on since it was indexed
128
+ * and the period it holds is not this feed's to report.
116
129
  */
117
130
  marketStalenessPeriod: number | null;
118
131
  }
132
+ /**
133
+ * One `(market, token, role)` slot of a chain, with the feed holding it.
134
+ *
135
+ * The same row {@link PermissionlessIndexedPriceFeedMarket} is, read from the
136
+ * chain's end rather than from one feed's: the feed is a column here because
137
+ * it is no longer what was asked for, and the chain is named because the read
138
+ * spans several.
139
+ *
140
+ * Unpivoted — a token's main and reserve feeds are two rows. What reads them
141
+ * this way is analysis over every slot at once, where the two roles of a
142
+ * token are the pair being compared and folding them together would hide it.
143
+ **/
144
+ export interface PermissionlessMarketSlot extends PermissionlessIndexedPriceFeedMarket {
145
+ chainId: number;
146
+ /** The market's underlying, which its quota figures are denominated in. */
147
+ underlyingToken: Address;
148
+ /**
149
+ * The market has been shut down: no new borrowing, but its open accounts
150
+ * are quoting all the same.
151
+ */
152
+ isShutdown: boolean;
153
+ /** The feed in force for the slot. */
154
+ priceFeed: Address;
155
+ /** Display name the store recorded, or `null` for a feed it never had. */
156
+ priceFeedName: string | null;
157
+ /**
158
+ * Whether the PriceFeedStore still carries that feed.
159
+ *
160
+ * `false` is the case worth looking at: the market goes on pricing with
161
+ * something the store has removed, or never had.
162
+ */
163
+ priceFeedInStore: boolean;
164
+ /**
165
+ * The feed the market prices its own underlying with, which is what
166
+ * converts this row's quota figures. `null` for a market that has none.
167
+ */
168
+ underlyingPriceFeed: Address | null;
169
+ }
119
170
  /**
120
171
  * One feed of the store, with everywhere the store lets it be used.
121
172
  *
122
- * Feeds a tree carries but the store never added have no identity to report —
123
- * no status history, hence no name or staleness — so the read throws for them
124
- * rather than answering a half-filled row.
173
+ * Feeds a tree carries but the store never added have no identity to report
174
+ * here — no status history, hence no name or staleness — so the backend does
175
+ * not answer for them; the SDK reads them off the chain instead, see
176
+ * {@link PermissionlessPriceFeedDetails.inStore}.
125
177
  **/
126
- export interface PermissionlessPriceFeedDetails {
178
+ export interface PermissionlessIndexedPriceFeedDetails {
127
179
  chainId: number;
128
180
  priceFeed: PriceFeed;
129
181
  assets: PermissionlessPriceFeedAsset[];
@@ -132,7 +184,21 @@ export interface PermissionlessPriceFeedDetails {
132
184
  * ahead of the reserve ones — the grouping a reader wants, so a caller
133
185
  * rendering a table does not have to sort it again.
134
186
  */
187
+ markets: PermissionlessIndexedPriceFeedMarket[];
188
+ }
189
+ /**
190
+ * The same feed with each slot's staleness period read off its oracle.
191
+ **/
192
+ export interface PermissionlessPriceFeedDetails extends PermissionlessIndexedPriceFeedDetails {
135
193
  markets: PermissionlessPriceFeedMarket[];
194
+ /**
195
+ * Whether the answer is the store's.
196
+ *
197
+ * `false` is a deployed feed the store never added, read off the chain
198
+ * instead: `deployedBy` is the zero address, `stalenessPeriod` is 0, and
199
+ * `assets` and `markets` are empty, because all of them are store rows.
200
+ */
201
+ inStore: boolean;
136
202
  }
137
203
  /**
138
204
  * One feed as a market slot holds it.
@@ -165,24 +231,20 @@ export interface PermissionlessAssetMarketFeed {
165
231
  * columns of the same market's row, and the quota is the market's whatever
166
232
  * feed holds which slot.
167
233
  **/
168
- export interface PermissionlessAssetMarket {
169
- market: Address;
170
- marketConfigurator: Address;
171
- /** The configurator's own name, as the backend's sync recorded it. */
172
- curatorName: string | null;
173
- /** The market's own name, which is the name of its pool token. */
174
- marketName: string | null;
234
+ export interface PermissionlessAssetMarket extends PermissionlessMarket {
175
235
  /** The market's underlying, which its quota figures are denominated in. */
176
236
  underlyingToken: Address;
177
- /** `null` for an underlying the backend has no metadata row for. */
178
- underlyingSymbol: string | null;
179
- /** The asset is this market's own underlying, so it is not quota-managed. */
180
- isUnderlying: boolean;
237
+ /**
238
+ * The feed the market prices its own underlying with, which is what converts
239
+ * this row's quota figures. `null` for a market that has no main feed for
240
+ * its underlying, whose figures therefore cannot be converted at all.
241
+ */
242
+ underlyingPriceFeed: Address | null;
181
243
  /**
182
244
  * The market has been shut down.
183
245
  *
184
246
  * Still reported, and still counted in {@link
185
- * PermissionlessAssetDetails.quotaUsedUsd}: a shut down market carries no
247
+ * PermissionlessQuotaTotals.quotaUsedUsd}: a shut down market carries no
186
248
  * new borrowing but its open accounts are quoting all the same.
187
249
  */
188
250
  isShutdown: boolean;
@@ -190,16 +252,6 @@ export interface PermissionlessAssetMarket {
190
252
  mainFeed: PermissionlessAssetMarketFeed | null;
191
253
  /** The feed the market falls back to, or `null` if it has none. */
192
254
  reserveFeed: PermissionlessAssetMarketFeed | null;
193
- /**
194
- * What the pool will take of the asset, in units of {@link underlyingToken}.
195
- *
196
- * `null` for an asset the quota keeper was never told a limit for, which the
197
- * market's own underlying always is. A zero is a limit set to zero, and the
198
- * two are different answers.
199
- */
200
- quotaLimit: number | null;
201
- /** How much of {@link quotaLimit} is actually taken, in the same units. */
202
- quotaUsed: number | null;
203
255
  }
204
256
  /**
205
257
  * One asset of the store: what prices it, and what it is used as collateral
@@ -208,7 +260,7 @@ export interface PermissionlessAssetMarket {
208
260
  * The counterpart of {@link PermissionlessPriceFeedDetails} — the same corner
209
261
  * of the chain read from the asset's end instead of the feed's.
210
262
  **/
211
- export interface PermissionlessAssetDetails {
263
+ export interface PermissionlessIndexedAssetDetails {
212
264
  chainId: number;
213
265
  asset: PermissionlessPriceFeedAsset;
214
266
  /**
@@ -220,63 +272,211 @@ export interface PermissionlessAssetDetails {
220
272
  priceFeeds: PriceFeed[];
221
273
  /** Ordered by curator, then by market. */
222
274
  markets: PermissionlessAssetMarket[];
275
+ }
276
+ /**
277
+ * The same asset with its quotas totalled, which is what a reader gets.
278
+ *
279
+ * The totals are over the very rows {@link markets} reports, converted at the
280
+ * price each market's own oracle holds for its underlying, so the header and
281
+ * the table under it cannot disagree.
282
+ **/
283
+ export interface PermissionlessAssetDetails extends PermissionlessIndexedAssetDetails, PermissionlessQuotaTotals {}
284
+ /**
285
+ * One asset of the PriceFeedStore, with what its markets make of it.
286
+ *
287
+ * Everything a list of assets renders and nothing else: the store's own read
288
+ * carries each asset's feeds too, which is several times this payload and not
289
+ * what a reader scanning for the big positions is looking at.
290
+ *
291
+ * The quota rows are the ones {@link PermissionlessAssetDetails} heads an
292
+ * asset's own page with, off the same query, so the list and the page a row of
293
+ * it opens are totalling the very same figures.
294
+ *
295
+ * What a reader gets is {@link PermissionlessAssetSummary}, this plus what the
296
+ * SDK makes of the asset.
297
+ **/
298
+ export interface PermissionlessIndexedAssetSummary {
299
+ chainId: number;
300
+ /** Lowercased, as everything addressed in these payloads is. */
301
+ address: Address;
302
+ symbol: string;
223
303
  /**
224
- * Total quota limit across the markets still running, in USD.
304
+ * How many markets still running are underlain by this asset.
225
305
  *
226
- * In USD and not in token units because there is no token to state it in: a
227
- * limit is denominated in its own market's underlying, and an asset is
228
- * routinely collateral in markets underlain by different tokens, so the
229
- * figures are not comparable until each is priced. Each market's limit is
230
- * converted at the price that market's own oracle holds for its underlying.
306
+ * What makes an asset central rather than merely listed: a token several
307
+ * markets borrow against is the one a reader opens the list for. Shut down
308
+ * markets are left out for the reason their limits are — they are no longer
309
+ * a place anything happens.
310
+ */
311
+ underlyingMarketCount: number;
312
+ /**
313
+ * What each market holding the asset has committed to it, unconverted.
231
314
  *
232
- * Shut down markets are left out — their limits are not borrowable — and so
233
- * are markets whose underlying could not be priced, which makes this a floor
234
- * rather than an estimate. `null` when no market contributed at all.
315
+ * One entry per market, in that market's own underlying — see
316
+ * {@link PermissionlessAssetQuota}. Totalling them is
317
+ * {@link PermissionlessAssetSummary}'s two USD figures, which is why they
318
+ * are carried rather than summed: the sum needs a price, and a price needs
319
+ * the chain.
235
320
  */
236
- quotaLimitUsd: number | null;
321
+ marketQuotas: PermissionlessAssetQuota[];
322
+ }
323
+ /**
324
+ * One market's commitment to an asset, in that market's own underlying.
325
+ *
326
+ * Unconverted on purpose: a limit is denominated in its market's underlying,
327
+ * and an asset is routinely collateral in markets underlain by different
328
+ * tokens — WETH is collateral in USDC, WETH and wstETH markets at once on
329
+ * mainnet — so the figures are not comparable until each is priced. The feed
330
+ * that prices the underlying is named here so that whoever totals them knows
331
+ * what to ask the chain.
332
+ **/
333
+ export interface PermissionlessAssetQuota {
334
+ /**
335
+ * What the pool will take of the asset, in units of the market's underlying.
336
+ *
337
+ * `null` for a token the quota keeper was never told a limit for, which the
338
+ * market's own underlying always is — it is not quota-managed. A zero is a
339
+ * limit the curator has actually set to zero, and the two are different
340
+ * answers.
341
+ */
342
+ quotaLimit: number | null;
343
+ /** How much of that limit is taken, in the same units. */
344
+ quotaUsed: number | null;
345
+ /** The market has been shut down, so its limit is no longer borrowable. */
346
+ isShutdown: boolean;
237
347
  /**
238
- * Total quota actually taken across every market, in USD, converted the same
239
- * way as {@link quotaLimitUsd}.
348
+ * The feed the market prices its own underlying with.
240
349
  *
241
- * Every market, including the shut down ones: debt outstanding is exposure
242
- * whether or not the market still takes new borrowers.
350
+ * `null` for a market with no main feed for its underlying, whose figures
351
+ * therefore cannot be converted at all.
243
352
  */
353
+ underlyingPriceFeed: Address | null;
354
+ }
355
+ /**
356
+ * Totals of {@link PermissionlessAssetQuota}, converted to USD.
357
+ *
358
+ * Limits count only the markets still running, because a shut down market's
359
+ * limit is not borrowable; what is already quoted counts everywhere, because
360
+ * debt outstanding is exposure either way. A market whose underlying could not
361
+ * be priced is skipped, which makes both figures floors, and `null` is nothing
362
+ * to total rather than a zero.
363
+ **/
364
+ export interface PermissionlessQuotaTotals {
365
+ /** Total quota limit across the markets still running, in USD. */
366
+ quotaLimitUsd: number | null;
367
+ /** Total quota actually taken across every market, in USD. */
244
368
  quotaUsedUsd: number | null;
245
369
  }
246
370
  /**
247
- * What each of one asset's feeds says the asset is worth, and what the market
248
- * values the asset at through each.
371
+ * The same asset with what this SDK makes of it.
372
+ *
373
+ * Two things the backend does not answer for. What the asset is comes off this
374
+ * package's curated tables, because a backend consulting them could only
375
+ * answer from whichever version it was built against — a reader on a newer SDK
376
+ * than the deployment it talks to still classifies by the newer tables. The
377
+ * quota totals come off the chain, because converting a market's own
378
+ * denomination needs a price and the chain is where prices are.
379
+ **/
380
+ export interface PermissionlessAssetSummary extends PermissionlessIndexedAssetSummary, PermissionlessQuotaTotals {
381
+ /**
382
+ * What the asset is, where the tables say so.
383
+ *
384
+ * `null` for anything they do not name, which is most of a store: they
385
+ * classify the tokens markets are built on, and a store carries everything
386
+ * those markets will take as collateral. A filter over this sorts the
387
+ * assets worth sorting and leaves the rest in one heap, which is the honest
388
+ * answer rather than a guess from the symbol.
389
+ */
390
+ assetType: AssetType | null;
391
+ /**
392
+ * Whether the asset stands for something outside the chain.
393
+ *
394
+ * A flag rather than a value of {@link assetType}, because the two answer
395
+ * different questions and an asset can be both: a tokenised treasury is a
396
+ * real-world asset and may still be the stable a market is built on. Unlike
397
+ * {@link assetType} there is no third state — the curated list naming it is
398
+ * the whole of what makes an asset one, so not being on it is a real `false`
399
+ * rather than something unknown.
400
+ */
401
+ isRwa: boolean;
402
+ }
403
+ /**
404
+ * One feed of a chain, named so it can be read alongside another chain's.
405
+ *
406
+ * An address alone does not identify a feed: the same aggregator is deployed
407
+ * to several chains, and reading it on the wrong one answers the wrong price.
408
+ **/
409
+ export interface PriceFeedRef {
410
+ chainId: number;
411
+ address: Address;
412
+ }
413
+ /**
414
+ * The price one feed reports, as {@link PermissionlessOracles.getPrices}
415
+ * answers.
416
+ *
417
+ * `price` is `null` for a feed whose read reverted, which is not a zero, and
418
+ * is in the 8 decimals every Gearbox feed reports.
419
+ **/
420
+ export interface PriceFeedPrice extends PriceFeedRef {
421
+ price: bigint | null;
422
+ }
423
+ /**
424
+ * How many decimals a feed's answer carries, as
425
+ * {@link PermissionlessOracles.getDecimals} answers.
426
+ *
427
+ * Its own call rather than a field of {@link PriceFeedPrice}, because the two
428
+ * are not read on the same schedule: a price is the figure that moves and is
429
+ * re-read for it, while a deployed feed's decimals never change, so a caller
430
+ * reads these once and keeps them.
431
+ *
432
+ * Needed wherever the feeds are not only the ones a market reads. Every
433
+ * Gearbox feed an oracle holds reports 8, which is why most of this namespace
434
+ * can assume it — but a composite's own dependencies are whatever the
435
+ * aggregator underneath happens to be, and a rate leg of one is routinely 18.
436
+ *
437
+ * `null` is a feed that would not answer `decimals()` at all, which a caller
438
+ * showing the figure should treat as unknown rather than as 8.
439
+ **/
440
+ export interface PriceFeedDecimals extends PriceFeedRef {
441
+ decimals: number | null;
442
+ }
443
+ /**
444
+ * One asset with the feeds to value it through.
249
445
  *
250
- * Keyed by the lowercased feed address throughout. The asset is the one asked
251
- * for, so a cap here is that feed's price times the asset's supply — the same
252
- * figure {@link PermissionlessPriceFeedMarketCaps} answers from the other
253
- * side, and the reason both exist is that a page shows one row per feed or one
254
- * row per asset, never the full cross product.
446
+ * The asset's side of {@link PermissionlessOracles.getMarketCap} — the shape a
447
+ * screen showing one asset's feeds asks with.
448
+ **/
449
+ export interface AssetCap {
450
+ chainId: number;
451
+ asset: Address;
452
+ priceFeeds: Address[];
453
+ }
454
+ /**
455
+ * One feed with the assets to value through it.
255
456
  *
256
- * `null` is a read that failed, not a zero.
457
+ * The feed's side of the same call. Both exist because a screen shows one row
458
+ * per feed or one row per asset, never the full cross product.
257
459
  **/
258
- export interface PermissionlessAssetPrices {
259
- prices: Record<Address, string | null>;
260
- marketCaps: Record<Address, string | null>;
261
- /** When the backend computed the figures; they are read live, not indexed. */
262
- time: number;
460
+ export interface FeedCap {
461
+ chainId: number;
462
+ priceFeed: Address;
463
+ assets: Address[];
263
464
  }
264
465
  /**
265
- * Market caps of one feed's assets, keyed by the lowercased asset address.
466
+ * What one feed values one asset's supply at, in USD.
266
467
  *
267
- * Scoped to the feed rather than to the chain, which is what
268
- * {@link PermissionlessOracles.prices} answers. A cap is
269
- * `price × totalSupply`, so the chain-wide read pays for one `totalSupply` per
270
- * asset of every market on it; a screen showing one feed's handful of rows
271
- * should not.
468
+ * `price × totalSupply`, as a decimal string: the product of an 8-decimal
469
+ * price and a supply in the asset's own decimals does not fit a JS number
470
+ * without losing the small end of it.
272
471
  *
273
- * `null` for an asset whose price or supply could not be read — not a zero,
472
+ * `null` for a pair whose price or supply could not be read — not a zero,
274
473
  * since an asset nobody could price is not an asset worth nothing.
275
- */
276
- export interface PermissionlessPriceFeedMarketCaps {
277
- marketCaps: Record<Address, string | null>;
278
- /** When the backend computed the figures; they are read live, not indexed. */
279
- time: number;
474
+ **/
475
+ export interface MarketCap {
476
+ chainId: number;
477
+ priceFeed: Address;
478
+ asset: Address;
479
+ cap: string | null;
280
480
  }
281
481
  /** Args of a read scoped to one feed. */
282
482
  export interface PriceFeedArgs {
@@ -288,14 +488,9 @@ export interface AssetArgs {
288
488
  chainId: number;
289
489
  address: Address;
290
490
  }
291
- /** Args of {@link PermissionlessOracles.getPrices}. */
292
- export interface GetPricesArgs {
293
- chainId: number;
294
- /**
295
- * The feeds to price. Any address answering `latestRoundData` works — the
296
- * store does not have to carry it, which is the point of reading the chain
297
- * rather than asking the backend.
298
- **/
299
- priceFeeds: Address[];
491
+ /** Args of {@link PermissionlessOracles.assets}. */
492
+ export interface AssetsArgs {
493
+ /** Omit for every chain the backend serves. */
494
+ chainId?: number;
300
495
  }
301
496
  //#endregion
@@ -11,8 +11,6 @@ import { z } from "zod/v4";
11
11
  **/
12
12
  /** An address, in whatever case the backend serves it. */
13
13
  export declare const addressSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
14
- /** A `0x`-prefixed hex string, as viem's `Hex`. */
15
- export declare const hexSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
16
14
  /**
17
15
  * A record keyed by address. Spelled out here because zod types a record key
18
16
  * by the schema's output, which the branded `Address` is not inferred as.
@@ -8,9 +8,17 @@ import { Address, PublicClient } from "viem";
8
8
  * transaction. Returns nothing when the bound still fits.
9
9
  **/
10
10
  export declare function updateBounds(client: PublicClient, address: Address): Promise<RawTx[]>;
11
+ /** An LP feed found in a feed tree, with what it calls itself on chain. */
12
+ export interface LPFeed {
13
+ address: Address;
14
+ description: string;
15
+ }
11
16
  /**
12
17
  * Of the whole feed tree behind `feeds`, the ones that are LP feeds: the
13
18
  * probe keeps whatever answers `getLPExchangeRate`.
19
+ *
20
+ * The trees reach past `feeds` themselves, so an LP feed read inside one of
21
+ * them is among the results whether or not it is one of `feeds`.
14
22
  **/
15
- export declare function getFeedsToUpdate(client: PublicClient, pfCompressor: Address, feeds: Address[]): Promise<Address[]>;
23
+ export declare function getFeedsToUpdate(client: PublicClient, pfCompressor: Address, feeds: Address[]): Promise<LPFeed[]>;
16
24
  //#endregion
@@ -1145,11 +1145,15 @@ declare const abi: readonly [{
1145
1145
  }];
1146
1146
  readonly name: "VersionNotFoundException";
1147
1147
  }];
1148
- interface ComputeAddressArgs {
1148
+ export interface ComputeAddressArgs {
1149
1149
  contractType: string;
1150
1150
  version: number;
1151
1151
  encodedParams: Hex;
1152
1152
  salt: Hex;
1153
+ /**
1154
+ * Deployer, i.e. address that will call `deploy` on the bytecode repository.
1155
+ * It is mixed into the salt, so it is not necessarily the owner of the deployed contract
1156
+ */
1153
1157
  owner: Address;
1154
1158
  }
1155
1159
  export declare class BytecodeRepositoryContract extends BaseContract<typeof abi> {
@@ -1171,6 +1175,11 @@ export declare class BytecodeRepositoryContract extends BaseContract<typeof abi>
1171
1175
  isBytecodeUploaded(hash: `0x${string}`): Promise<boolean>;
1172
1176
  isBytecodeAudited(hash: `0x${string}`): Promise<boolean>;
1173
1177
  getLatestVersion(type_: string): Promise<bigint>;
1178
+ /**
1179
+ * Returns the latest allowed patch version of the contract type within given minor version
1180
+ * @throws if no bytecode of this contract type and minor version is allowed
1181
+ */
1182
+ getLatestPatchVersion(type_: string, minorVersion: number): Promise<number>;
1174
1183
  getAllowedBytecodeHash(type_: string, version: number): Promise<Hex>;
1175
1184
  isPublicDomain(domain: string): Promise<boolean>;
1176
1185
  isSystemDomain(domain: string): Promise<boolean>;
@@ -1,5 +1,5 @@
1
1
  import { AddressProviderContract } from "./address-provider.js";
2
- import { BytecodeRepositoryContract } from "./bytecode-repository.js";
2
+ import { BytecodeRepositoryContract, ComputeAddressArgs } from "./bytecode-repository.js";
3
3
  import { TokenCompressorContract } from "./compressors/token-compressor.js";
4
4
  import { WithdrawalCompressorContract } from "./compressors/withdrawal-compressor.js";
5
5
  import "./compressors/index.js";
@@ -9,7 +9,8 @@ import { GovernorContract } from "./governance/governor.js";
9
9
  import { TimeLockContract } from "./governance/timelock.js";
10
10
  import "./governance/index.js";
11
11
  import { InstanceManagerContract } from "./instance-manager.js";
12
- import { AccessMode, AddAssetParams, AllowTokenParams, CreditManagerFees, DeployParams, ForbidAdapterParams, ForbidTokenParams, Market, PauseCreditManagerParams, PeripheryDomain, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, UnpauseCreditManagerParams } from "./types.js";
12
+ import { KILL_SWITCH_PROXY_MINOR_VERSION, KillSwitchProxyContract, KillSwitchProxyNotAllowedError, PreparedKillSwitchProxyDeployment, killSwitchProxySalt } from "./kill-switch-proxy.js";
13
+ import { AccessMode, AddAssetParams, AllowTokenParams, CreditManagerFees, DeployParams, EmergencyAdmin, ForbidAdapterParams, ForbidTokenParams, Market, PauseCreditManagerParams, PeripheryDomain, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, UnpauseCreditManagerParams } from "./types.js";
13
14
  import { MarketConfiguratorContract } from "./market-configurator.js";
14
15
  import { MarketConfiguratorFactoryContract } from "./market-configurator-factory.js";
15
16
  import { PriceFeedStoreContract } from "./price-feed-store.js";
@@ -17,4 +18,4 @@ import { priceFeedSetupParams } from "./pricefeeds/index.js";
17
18
  import { RoutingManagerContract } from "./router/routing-manager.js";
18
19
  import "./router/index.js";
19
20
  import { TreasurySplitterContract } from "./treasury-splitter.js";
20
- export { AccessMode, AddAssetParams, AddressProviderContract, AllowTokenParams, BytecodeRepositoryContract, ConstructorParams, CreditManagerFees, CrossChainMultisigContract, DeployParams, ForbidAdapterParams, ForbidTokenParams, GovernorContract, InstanceManagerContract, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PauseCreditManagerParams, PeripheryDomain, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, TimeLockContract, TimelockTransaction, TimelockTxParams, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, WithdrawalCompressorContract, priceFeedSetupParams };
21
+ export { AccessMode, AddAssetParams, AddressProviderContract, AllowTokenParams, BytecodeRepositoryContract, ComputeAddressArgs, ConstructorParams, CreditManagerFees, CrossChainMultisigContract, DeployParams, EmergencyAdmin, ForbidAdapterParams, ForbidTokenParams, GovernorContract, InstanceManagerContract, KILL_SWITCH_PROXY_MINOR_VERSION, KillSwitchProxyContract, KillSwitchProxyNotAllowedError, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PauseCreditManagerParams, PeripheryDomain, PreparedKillSwitchProxyDeployment, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, TimeLockContract, TimelockTransaction, TimelockTxParams, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, WithdrawalCompressorContract, killSwitchProxySalt, priceFeedSetupParams };