@gearbox-protocol/sdk 18.2.0-next.1 → 18.2.0-next.10
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.
- package/dist/cjs/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +179 -0
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +534 -0
- package/dist/cjs/abi/router/treehouseWorker.js +885 -0
- package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +3 -0
- package/dist/cjs/onchain/market/adapters/types.js +3 -0
- package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +397 -50
- package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
- package/dist/cjs/permissionless/api/oracles/schemas.js +85 -35
- package/dist/cjs/permissionless/api/schemas.js +0 -3
- package/dist/cjs/permissionless/bindings/index.js +1 -1
- package/dist/cjs/permissionless/index.js +2 -1
- package/dist/cjs/permissionless/utils/index.js +1 -0
- package/dist/cjs/permissionless/utils/price-update/get-prices.js +25 -0
- package/dist/cjs/permissionless/utils/price-update/index.js +1 -0
- package/dist/cjs/testnets/TestnetsAPI.js +179 -0
- package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
- package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
- package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
- package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
- package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
- package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
- package/dist/cjs/testnets/errors/index.js +13 -0
- package/dist/cjs/testnets/index.js +32 -0
- package/dist/cjs/testnets/package.json +1 -0
- package/dist/cjs/testnets/schemas.js +242 -0
- package/dist/cjs/testnets/types.js +1 -0
- package/dist/esm/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +178 -0
- package/dist/esm/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +533 -0
- package/dist/esm/abi/router/treehouseWorker.js +884 -0
- package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +3 -0
- package/dist/esm/onchain/market/adapters/types.js +3 -0
- package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +399 -52
- package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
- package/dist/esm/permissionless/api/oracles/schemas.js +80 -35
- package/dist/esm/permissionless/api/schemas.js +2 -4
- package/dist/esm/permissionless/bindings/index.js +1 -1
- package/dist/esm/permissionless/index.js +3 -3
- package/dist/esm/permissionless/utils/index.js +2 -2
- package/dist/esm/permissionless/utils/price-update/get-prices.js +25 -1
- package/dist/esm/permissionless/utils/price-update/index.js +2 -2
- package/dist/esm/testnets/TestnetsAPI.js +178 -0
- package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
- package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
- package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
- package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
- package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
- package/dist/esm/testnets/errors/TestnetsError.js +33 -0
- package/dist/esm/testnets/errors/index.js +7 -0
- package/dist/esm/testnets/index.js +11 -0
- package/dist/esm/testnets/package.json +1 -0
- package/dist/esm/testnets/schemas.js +228 -0
- package/dist/esm/testnets/types.js +1 -0
- package/dist/types/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.d.ts +148 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.d.ts +440 -0
- package/dist/types/abi/router/treehouseWorker.d.ts +728 -0
- package/dist/types/onchain/market/adapters/types.d.ts +4 -1
- package/dist/types/permissionless/api/index.d.ts +2 -2
- package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +120 -37
- package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
- package/dist/types/permissionless/api/oracles/index.d.ts +2 -2
- package/dist/types/permissionless/api/oracles/schemas.d.ts +164 -24
- package/dist/types/permissionless/api/oracles/types.d.ts +350 -63
- package/dist/types/permissionless/api/schemas.d.ts +0 -2
- package/dist/types/permissionless/index.d.ts +3 -3
- package/dist/types/permissionless/utils/index.d.ts +2 -2
- package/dist/types/permissionless/utils/price-update/get-prices.d.ts +17 -0
- package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
- package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
- package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
- package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
- package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
- package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
- package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
- package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
- package/dist/types/testnets/errors/index.d.ts +7 -0
- package/dist/types/testnets/index.d.ts +11 -0
- package/dist/types/testnets/schemas.d.ts +554 -0
- package/dist/types/testnets/types.d.ts +717 -0
- package/package.json +9 -3
|
@@ -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
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
*
|
|
56
|
-
*
|
|
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
|
|
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
|
|
62
|
+
* pictured by and what its quota figures are denominated in.
|
|
75
63
|
*/
|
|
76
64
|
underlyingSymbol: string | null;
|
|
77
|
-
/**
|
|
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
|
|
@@ -88,6 +74,60 @@ export interface PermissionlessPriceFeedMarket {
|
|
|
88
74
|
* answers.
|
|
89
75
|
*/
|
|
90
76
|
quotaLimit: number | null;
|
|
77
|
+
/**
|
|
78
|
+
* How much of {@link quotaLimit} the market's borrowers have actually taken,
|
|
79
|
+
* in the same units.
|
|
80
|
+
*
|
|
81
|
+
* The sum of every open credit account's current quota for this token across
|
|
82
|
+
* the credit managers borrowing from the market, so it is what the token is
|
|
83
|
+
* backing right now rather than what it is allowed to back.
|
|
84
|
+
*
|
|
85
|
+
* `null` only where {@link quotaLimit} is: a token nobody quotes reads as a
|
|
86
|
+
* zero against a limit, which is a different answer from a token the keeper
|
|
87
|
+
* holds no entry for at all.
|
|
88
|
+
*/
|
|
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 {
|
|
122
|
+
/**
|
|
123
|
+
* Staleness period this market's own price oracle holds for the slot, in
|
|
124
|
+
* seconds.
|
|
125
|
+
*
|
|
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.
|
|
129
|
+
*/
|
|
130
|
+
marketStalenessPeriod: number | null;
|
|
91
131
|
}
|
|
92
132
|
/**
|
|
93
133
|
* One feed of the store, with everywhere the store lets it be used.
|
|
@@ -96,7 +136,7 @@ export interface PermissionlessPriceFeedMarket {
|
|
|
96
136
|
* no status history, hence no name or staleness — so the read throws for them
|
|
97
137
|
* rather than answering a half-filled row.
|
|
98
138
|
**/
|
|
99
|
-
export interface
|
|
139
|
+
export interface PermissionlessIndexedPriceFeedDetails {
|
|
100
140
|
chainId: number;
|
|
101
141
|
priceFeed: PriceFeed;
|
|
102
142
|
assets: PermissionlessPriceFeedAsset[];
|
|
@@ -105,38 +145,285 @@ export interface PermissionlessPriceFeedDetails {
|
|
|
105
145
|
* ahead of the reserve ones — the grouping a reader wants, so a caller
|
|
106
146
|
* rendering a table does not have to sort it again.
|
|
107
147
|
*/
|
|
148
|
+
markets: PermissionlessIndexedPriceFeedMarket[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The same feed with each slot's staleness period read off its oracle.
|
|
152
|
+
**/
|
|
153
|
+
export interface PermissionlessPriceFeedDetails extends PermissionlessIndexedPriceFeedDetails {
|
|
108
154
|
markets: PermissionlessPriceFeedMarket[];
|
|
109
155
|
}
|
|
110
156
|
/**
|
|
111
|
-
*
|
|
157
|
+
* One feed as a market slot holds it.
|
|
158
|
+
*
|
|
159
|
+
* The store's view of the feed and not the feed itself: a market keeps
|
|
160
|
+
* pricing with whatever it was last pointed at, and nothing removes it from a
|
|
161
|
+
* market when the store drops it. {@link inStore} is what tells those apart,
|
|
162
|
+
* and the name survives either way because the store recorded it before.
|
|
163
|
+
**/
|
|
164
|
+
export interface PermissionlessAssetMarketFeed {
|
|
165
|
+
address: Address;
|
|
166
|
+
/**
|
|
167
|
+
* Display name the store recorded, or `null` for a feed it never carried —
|
|
168
|
+
* an aggregator a curator pointed a market straight at, say.
|
|
169
|
+
*/
|
|
170
|
+
name: string | null;
|
|
171
|
+
/**
|
|
172
|
+
* Whether the PriceFeedStore still carries the feed.
|
|
173
|
+
*
|
|
174
|
+
* `false` is the case worth showing: the market goes on pricing the asset
|
|
175
|
+
* with a feed the store has removed, or never had. Nothing on chain forbids
|
|
176
|
+
* that, which is exactly why it has to be visible.
|
|
177
|
+
*/
|
|
178
|
+
inStore: boolean;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* One market that prices an asset, with both of the slots it may fill.
|
|
182
|
+
*
|
|
183
|
+
* A row per market rather than per `(market, role)`: the two roles are two
|
|
184
|
+
* columns of the same market's row, and the quota is the market's whatever
|
|
185
|
+
* feed holds which slot.
|
|
186
|
+
**/
|
|
187
|
+
export interface PermissionlessAssetMarket extends PermissionlessMarket {
|
|
188
|
+
/** The market's underlying, which its quota figures are denominated in. */
|
|
189
|
+
underlyingToken: Address;
|
|
190
|
+
/**
|
|
191
|
+
* The feed the market prices its own underlying with, which is what converts
|
|
192
|
+
* this row's quota figures. `null` for a market that has no main feed for
|
|
193
|
+
* its underlying, whose figures therefore cannot be converted at all.
|
|
194
|
+
*/
|
|
195
|
+
underlyingPriceFeed: Address | null;
|
|
196
|
+
/**
|
|
197
|
+
* The market has been shut down.
|
|
198
|
+
*
|
|
199
|
+
* Still reported, and still counted in {@link
|
|
200
|
+
* PermissionlessQuotaTotals.quotaUsedUsd}: a shut down market carries no
|
|
201
|
+
* new borrowing but its open accounts are quoting all the same.
|
|
202
|
+
*/
|
|
203
|
+
isShutdown: boolean;
|
|
204
|
+
/** The feed the market prices the asset with, or `null` if it has none. */
|
|
205
|
+
mainFeed: PermissionlessAssetMarketFeed | null;
|
|
206
|
+
/** The feed the market falls back to, or `null` if it has none. */
|
|
207
|
+
reserveFeed: PermissionlessAssetMarketFeed | null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* One asset of the store: what prices it, and what it is used as collateral
|
|
211
|
+
* for.
|
|
112
212
|
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
213
|
+
* The counterpart of {@link PermissionlessPriceFeedDetails} — the same corner
|
|
214
|
+
* of the chain read from the asset's end instead of the feed's.
|
|
215
|
+
**/
|
|
216
|
+
export interface PermissionlessIndexedAssetDetails {
|
|
217
|
+
chainId: number;
|
|
218
|
+
asset: PermissionlessPriceFeedAsset;
|
|
219
|
+
/**
|
|
220
|
+
* Feeds the store currently allows for the asset.
|
|
221
|
+
*
|
|
222
|
+
* Only the store's. A feed a market still prices the asset with but the
|
|
223
|
+
* store has dropped is not here — it is on its market's row, flagged.
|
|
224
|
+
*/
|
|
225
|
+
priceFeeds: PriceFeed[];
|
|
226
|
+
/** Ordered by curator, then by market. */
|
|
227
|
+
markets: PermissionlessAssetMarket[];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The same asset with its quotas totalled, which is what a reader gets.
|
|
231
|
+
*
|
|
232
|
+
* The totals are over the very rows {@link markets} reports, converted at the
|
|
233
|
+
* price each market's own oracle holds for its underlying, so the header and
|
|
234
|
+
* the table under it cannot disagree.
|
|
235
|
+
**/
|
|
236
|
+
export interface PermissionlessAssetDetails extends PermissionlessIndexedAssetDetails, PermissionlessQuotaTotals {}
|
|
237
|
+
/**
|
|
238
|
+
* One asset of the PriceFeedStore, with what its markets make of it.
|
|
239
|
+
*
|
|
240
|
+
* Everything a list of assets renders and nothing else: the store's own read
|
|
241
|
+
* carries each asset's feeds too, which is several times this payload and not
|
|
242
|
+
* what a reader scanning for the big positions is looking at.
|
|
243
|
+
*
|
|
244
|
+
* The quota rows are the ones {@link PermissionlessAssetDetails} heads an
|
|
245
|
+
* asset's own page with, off the same query, so the list and the page a row of
|
|
246
|
+
* it opens are totalling the very same figures.
|
|
247
|
+
*
|
|
248
|
+
* What a reader gets is {@link PermissionlessAssetSummary}, this plus what the
|
|
249
|
+
* SDK makes of the asset.
|
|
250
|
+
**/
|
|
251
|
+
export interface PermissionlessIndexedAssetSummary {
|
|
252
|
+
chainId: number;
|
|
253
|
+
/** Lowercased, as everything addressed in these payloads is. */
|
|
254
|
+
address: Address;
|
|
255
|
+
symbol: string;
|
|
256
|
+
/**
|
|
257
|
+
* How many markets still running are underlain by this asset.
|
|
258
|
+
*
|
|
259
|
+
* What makes an asset central rather than merely listed: a token several
|
|
260
|
+
* markets borrow against is the one a reader opens the list for. Shut down
|
|
261
|
+
* markets are left out for the reason their limits are — they are no longer
|
|
262
|
+
* a place anything happens.
|
|
263
|
+
*/
|
|
264
|
+
underlyingMarketCount: number;
|
|
265
|
+
/**
|
|
266
|
+
* What each market holding the asset has committed to it, unconverted.
|
|
267
|
+
*
|
|
268
|
+
* One entry per market, in that market's own underlying — see
|
|
269
|
+
* {@link PermissionlessAssetQuota}. Totalling them is
|
|
270
|
+
* {@link PermissionlessAssetSummary}'s two USD figures, which is why they
|
|
271
|
+
* are carried rather than summed: the sum needs a price, and a price needs
|
|
272
|
+
* the chain.
|
|
273
|
+
*/
|
|
274
|
+
marketQuotas: PermissionlessAssetQuota[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* One market's commitment to an asset, in that market's own underlying.
|
|
118
278
|
*
|
|
119
|
-
*
|
|
279
|
+
* Unconverted on purpose: a limit is denominated in its market's underlying,
|
|
280
|
+
* and an asset is routinely collateral in markets underlain by different
|
|
281
|
+
* tokens — WETH is collateral in USDC, WETH and wstETH markets at once on
|
|
282
|
+
* mainnet — so the figures are not comparable until each is priced. The feed
|
|
283
|
+
* that prices the underlying is named here so that whoever totals them knows
|
|
284
|
+
* what to ask the chain.
|
|
285
|
+
**/
|
|
286
|
+
export interface PermissionlessAssetQuota {
|
|
287
|
+
/**
|
|
288
|
+
* What the pool will take of the asset, in units of the market's underlying.
|
|
289
|
+
*
|
|
290
|
+
* `null` for a token the quota keeper was never told a limit for, which the
|
|
291
|
+
* market's own underlying always is — it is not quota-managed. A zero is a
|
|
292
|
+
* limit the curator has actually set to zero, and the two are different
|
|
293
|
+
* answers.
|
|
294
|
+
*/
|
|
295
|
+
quotaLimit: number | null;
|
|
296
|
+
/** How much of that limit is taken, in the same units. */
|
|
297
|
+
quotaUsed: number | null;
|
|
298
|
+
/** The market has been shut down, so its limit is no longer borrowable. */
|
|
299
|
+
isShutdown: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* The feed the market prices its own underlying with.
|
|
302
|
+
*
|
|
303
|
+
* `null` for a market with no main feed for its underlying, whose figures
|
|
304
|
+
* therefore cannot be converted at all.
|
|
305
|
+
*/
|
|
306
|
+
underlyingPriceFeed: Address | null;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Totals of {@link PermissionlessAssetQuota}, converted to USD.
|
|
310
|
+
*
|
|
311
|
+
* Limits count only the markets still running, because a shut down market's
|
|
312
|
+
* limit is not borrowable; what is already quoted counts everywhere, because
|
|
313
|
+
* debt outstanding is exposure either way. A market whose underlying could not
|
|
314
|
+
* be priced is skipped, which makes both figures floors, and `null` is nothing
|
|
315
|
+
* to total rather than a zero.
|
|
316
|
+
**/
|
|
317
|
+
export interface PermissionlessQuotaTotals {
|
|
318
|
+
/** Total quota limit across the markets still running, in USD. */
|
|
319
|
+
quotaLimitUsd: number | null;
|
|
320
|
+
/** Total quota actually taken across every market, in USD. */
|
|
321
|
+
quotaUsedUsd: number | null;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The same asset with what this SDK makes of it.
|
|
325
|
+
*
|
|
326
|
+
* Two things the backend does not answer for. What the asset is comes off this
|
|
327
|
+
* package's curated tables, because a backend consulting them could only
|
|
328
|
+
* answer from whichever version it was built against — a reader on a newer SDK
|
|
329
|
+
* than the deployment it talks to still classifies by the newer tables. The
|
|
330
|
+
* quota totals come off the chain, because converting a market's own
|
|
331
|
+
* denomination needs a price and the chain is where prices are.
|
|
332
|
+
**/
|
|
333
|
+
export interface PermissionlessAssetSummary extends PermissionlessIndexedAssetSummary, PermissionlessQuotaTotals {
|
|
334
|
+
/**
|
|
335
|
+
* What the asset is, where the tables say so.
|
|
336
|
+
*
|
|
337
|
+
* `null` for anything they do not name, which is most of a store: they
|
|
338
|
+
* classify the tokens markets are built on, and a store carries everything
|
|
339
|
+
* those markets will take as collateral. A filter over this sorts the
|
|
340
|
+
* assets worth sorting and leaves the rest in one heap, which is the honest
|
|
341
|
+
* answer rather than a guess from the symbol.
|
|
342
|
+
*/
|
|
343
|
+
assetType: AssetType | null;
|
|
344
|
+
/**
|
|
345
|
+
* Whether the asset stands for something outside the chain.
|
|
346
|
+
*
|
|
347
|
+
* A flag rather than a value of {@link assetType}, because the two answer
|
|
348
|
+
* different questions and an asset can be both: a tokenised treasury is a
|
|
349
|
+
* real-world asset and may still be the stable a market is built on. Unlike
|
|
350
|
+
* {@link assetType} there is no third state — the curated list naming it is
|
|
351
|
+
* the whole of what makes an asset one, so not being on it is a real `false`
|
|
352
|
+
* rather than something unknown.
|
|
353
|
+
*/
|
|
354
|
+
isRwa: boolean;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* One feed of a chain, named so it can be read alongside another chain's.
|
|
358
|
+
*
|
|
359
|
+
* An address alone does not identify a feed: the same aggregator is deployed
|
|
360
|
+
* to several chains, and reading it on the wrong one answers the wrong price.
|
|
361
|
+
**/
|
|
362
|
+
export interface PriceFeedRef {
|
|
363
|
+
chainId: number;
|
|
364
|
+
address: Address;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The price one feed reports, as {@link PermissionlessOracles.getPrices}
|
|
368
|
+
* answers.
|
|
369
|
+
*
|
|
370
|
+
* `price` is `null` for a feed whose read reverted, which is not a zero, and
|
|
371
|
+
* is in the 8 decimals every Gearbox feed reports.
|
|
372
|
+
**/
|
|
373
|
+
export interface PriceFeedPrice extends PriceFeedRef {
|
|
374
|
+
price: bigint | null;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* One asset with the feeds to value it through.
|
|
378
|
+
*
|
|
379
|
+
* The asset's side of {@link PermissionlessOracles.getMarketCap} — the shape a
|
|
380
|
+
* screen showing one asset's feeds asks with.
|
|
381
|
+
**/
|
|
382
|
+
export interface AssetCap {
|
|
383
|
+
chainId: number;
|
|
384
|
+
asset: Address;
|
|
385
|
+
priceFeeds: Address[];
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* One feed with the assets to value through it.
|
|
389
|
+
*
|
|
390
|
+
* The feed's side of the same call. Both exist because a screen shows one row
|
|
391
|
+
* per feed or one row per asset, never the full cross product.
|
|
392
|
+
**/
|
|
393
|
+
export interface FeedCap {
|
|
394
|
+
chainId: number;
|
|
395
|
+
priceFeed: Address;
|
|
396
|
+
assets: Address[];
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* What one feed values one asset's supply at, in USD.
|
|
400
|
+
*
|
|
401
|
+
* `price × totalSupply`, as a decimal string: the product of an 8-decimal
|
|
402
|
+
* price and a supply in the asset's own decimals does not fit a JS number
|
|
403
|
+
* without losing the small end of it.
|
|
404
|
+
*
|
|
405
|
+
* `null` for a pair whose price or supply could not be read — not a zero,
|
|
120
406
|
* since an asset nobody could price is not an asset worth nothing.
|
|
121
|
-
|
|
122
|
-
export interface
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
407
|
+
**/
|
|
408
|
+
export interface MarketCap {
|
|
409
|
+
chainId: number;
|
|
410
|
+
priceFeed: Address;
|
|
411
|
+
asset: Address;
|
|
412
|
+
cap: string | null;
|
|
126
413
|
}
|
|
127
414
|
/** Args of a read scoped to one feed. */
|
|
128
415
|
export interface PriceFeedArgs {
|
|
129
416
|
chainId: number;
|
|
130
417
|
address: Address;
|
|
131
418
|
}
|
|
132
|
-
/** Args of
|
|
133
|
-
export interface
|
|
419
|
+
/** Args of a read scoped to one asset. */
|
|
420
|
+
export interface AssetArgs {
|
|
134
421
|
chainId: number;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
422
|
+
address: Address;
|
|
423
|
+
}
|
|
424
|
+
/** Args of {@link PermissionlessOracles.assets}. */
|
|
425
|
+
export interface AssetsArgs {
|
|
426
|
+
/** Omit for every chain the backend serves. */
|
|
427
|
+
chainId?: number;
|
|
141
428
|
}
|
|
142
429
|
//#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.
|
|
@@ -13,7 +13,7 @@ import "./core/index.js";
|
|
|
13
13
|
import { FunctionParams, ValueParams, encodeFunctionParams } from "./utils/abi-encoder.js";
|
|
14
14
|
import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./api/deploy/types.js";
|
|
15
15
|
import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
|
|
16
|
-
import {
|
|
16
|
+
import { AssetArgs, AssetCap, AssetsArgs, FeedCap, MarketCap, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedPrice, PriceFeedRef } from "./api/oracles/types.js";
|
|
17
17
|
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
|
|
18
18
|
import { AddressProviderContract } from "./bindings/address-provider.js";
|
|
19
19
|
import { BytecodeRepositoryContract } from "./bindings/bytecode-repository.js";
|
|
@@ -50,8 +50,8 @@ import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeB
|
|
|
50
50
|
import { convertQueueBatchToExecuteTx } from "./utils/governance/timelock-txs.js";
|
|
51
51
|
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./utils/literals.js";
|
|
52
52
|
import { getPriceUpdateTx } from "./utils/price-update/get-price-update-tx.js";
|
|
53
|
-
import { getPrices } from "./utils/price-update/get-prices.js";
|
|
53
|
+
import { getLatestPrices, getPrices } from "./utils/price-update/get-prices.js";
|
|
54
54
|
import { GetUpdatablePriceFeedsArgs, getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
|
|
55
55
|
import { normalizeSignature } from "./utils/signature.js";
|
|
56
56
|
import "./utils/index.js";
|
|
57
|
-
export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions,
|
|
57
|
+
export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AssetArgs, AssetCap, AssetsArgs, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, FeedCap, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetUpdatablePriceFeedsArgs, GovernorContract, INSTANCE_MANAGER, InputValueParams, InstanceManagerContract, InstanceOwnerTransactions, InstanceTxs, InstanceTxsArgs, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, Market, MarketCap, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PauseCreditManagerParams, PeripheryDomain, PermissionlessAnalytics, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeed, PriceFeedArgs, PriceFeedChartPoint, PriceFeedConstructorParam, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedParamType, PriceFeedParams, PriceFeedPrice, PriceFeedPriceChart, PriceFeedRef, PriceFeedSaltMissingError, PriceFeedSetupParams, PriceFeedStalenessUnknownError, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RecoveryMessage, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, Signature, TOKEN_COMPRESSOR, TimeLockContract, TimelockTransaction, TimelockTxParams, TimelockTxs, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, ValueParams, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getLatestPrices, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
|
|
@@ -8,8 +8,8 @@ import { convertQueueBatchToExecuteTx } from "./governance/timelock-txs.js";
|
|
|
8
8
|
import "./governance/index.js";
|
|
9
9
|
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./literals.js";
|
|
10
10
|
import { getPriceUpdateTx } from "./price-update/get-price-update-tx.js";
|
|
11
|
-
import { getPrices } from "./price-update/get-prices.js";
|
|
11
|
+
import { getLatestPrices, getPrices } from "./price-update/get-prices.js";
|
|
12
12
|
import { GetUpdatablePriceFeedsArgs, getUpdatablePriceFeeds } from "./price-update/get-updatable-feeds.js";
|
|
13
13
|
import "./price-update/index.js";
|
|
14
14
|
import { normalizeSignature } from "./signature.js";
|
|
15
|
-
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, FunctionParams, GetUpdatablePriceFeedsArgs, INSTANCE_MANAGER, InstanceTxs, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, TimelockTxs, ValueParams, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
15
|
+
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, FunctionParams, GetUpdatablePriceFeedsArgs, INSTANCE_MANAGER, InstanceTxs, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, TimelockTxs, ValueParams, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getLatestPrices, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { Address, PublicClient } from "viem";
|
|
2
2
|
//#region src/permissionless/utils/price-update/get-prices.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What the feeds report as they stand, in one multicall.
|
|
5
|
+
*
|
|
6
|
+
* What {@link getPrices} does without the part that makes it expensive: no
|
|
7
|
+
* `OnchainSDK` to attach and no update transactions to assemble, which is the
|
|
8
|
+
* whole cost of that call and is wasted on a feed that answers already. A feed
|
|
9
|
+
* that needs a fresh answer before it will be read comes back `null` here, so
|
|
10
|
+
* a caller that must price those falls back to {@link getPrices} for them and
|
|
11
|
+
* pays once for the few rather than once for all.
|
|
12
|
+
*
|
|
13
|
+
* `null` is also a feed whose read reverted for any other reason, which is not
|
|
14
|
+
* a zero.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getLatestPrices({ client, priceFeeds }: {
|
|
17
|
+
client: PublicClient;
|
|
18
|
+
priceFeeds: Address[];
|
|
19
|
+
}): Promise<Record<Address, bigint | null>>;
|
|
3
20
|
export declare function getPrices({ client, priceFeeds, chunkSize, gasLimit }: {
|
|
4
21
|
client: PublicClient;
|
|
5
22
|
priceFeeds: Address[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { getPriceUpdateTx } from "./get-price-update-tx.js";
|
|
2
|
-
import { getPrices } from "./get-prices.js";
|
|
2
|
+
import { getLatestPrices, getPrices } from "./get-prices.js";
|
|
3
3
|
import { GetUpdatablePriceFeedsArgs, getUpdatablePriceFeeds } from "./get-updatable-feeds.js";
|
|
4
|
-
export { GetUpdatablePriceFeedsArgs, getPriceUpdateTx, getPrices, getUpdatablePriceFeeds };
|
|
4
|
+
export { GetUpdatablePriceFeedsArgs, getLatestPrices, getPriceUpdateTx, getPrices, getUpdatablePriceFeeds };
|