@gearbox-protocol/sdk 8.6.6 → 8.8.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.
- package/dist/cjs/sdk/GearboxSDK.js +8 -4
- package/dist/cjs/sdk/index.js +2 -0
- package/dist/cjs/sdk/market/MarketRegister.js +21 -6
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +25 -0
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +29 -0
- package/dist/cjs/sdk/market/pricefeeds/updates/index.js +4 -0
- package/dist/cjs/sdk/options.js +73 -0
- package/dist/cjs/sdk/utils/index.js +3 -1
- package/dist/cjs/sdk/utils/zod.js +39 -0
- package/dist/esm/sdk/GearboxSDK.js +8 -4
- package/dist/esm/sdk/index.js +1 -0
- package/dist/esm/sdk/market/MarketRegister.js +21 -6
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +24 -0
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +28 -0
- package/dist/esm/sdk/market/pricefeeds/updates/index.js +4 -2
- package/dist/esm/sdk/options.js +52 -0
- package/dist/esm/sdk/utils/index.js +1 -0
- package/dist/esm/sdk/utils/zod.js +15 -0
- package/dist/types/sdk/GearboxSDK.d.ts +1 -40
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +8 -22
- package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +9 -26
- package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +2 -2
- package/dist/types/sdk/options.d.ts +36 -0
- package/dist/types/sdk/utils/index.d.ts +1 -0
- package/dist/types/sdk/utils/zod.d.ts +5 -0
- package/package.json +1 -1
|
@@ -83,6 +83,7 @@ class GearboxSDK {
|
|
|
83
83
|
redstone,
|
|
84
84
|
pyth,
|
|
85
85
|
ignoreUpdateablePrices,
|
|
86
|
+
ignoreMarkets,
|
|
86
87
|
marketConfigurators: mcs,
|
|
87
88
|
strictContractTypes
|
|
88
89
|
} = options;
|
|
@@ -114,6 +115,7 @@ class GearboxSDK {
|
|
|
114
115
|
addressProvider,
|
|
115
116
|
blockNumber,
|
|
116
117
|
ignoreUpdateablePrices,
|
|
118
|
+
ignoreMarkets,
|
|
117
119
|
marketConfigurators,
|
|
118
120
|
redstone,
|
|
119
121
|
pyth
|
|
@@ -147,6 +149,7 @@ class GearboxSDK {
|
|
|
147
149
|
addressProvider,
|
|
148
150
|
blockNumber,
|
|
149
151
|
ignoreUpdateablePrices,
|
|
152
|
+
ignoreMarkets,
|
|
150
153
|
marketConfigurators,
|
|
151
154
|
redstone,
|
|
152
155
|
pyth
|
|
@@ -158,7 +161,8 @@ class GearboxSDK {
|
|
|
158
161
|
chainId: this.provider.chainId,
|
|
159
162
|
addressProvider,
|
|
160
163
|
marketConfigurators,
|
|
161
|
-
blockNumber
|
|
164
|
+
blockNumber,
|
|
165
|
+
ignoreMarkets
|
|
162
166
|
},
|
|
163
167
|
`${re}attaching gearbox sdk`
|
|
164
168
|
);
|
|
@@ -190,7 +194,7 @@ class GearboxSDK {
|
|
|
190
194
|
`address provider version: ${this.#addressProvider.version}`
|
|
191
195
|
);
|
|
192
196
|
await this.#addressProvider.syncState(this.currentBlock);
|
|
193
|
-
this.#marketRegister = new import_MarketRegister.MarketRegister(this);
|
|
197
|
+
this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
|
|
194
198
|
await this.#marketRegister.loadMarkets(
|
|
195
199
|
marketConfigurators,
|
|
196
200
|
ignoreUpdateablePrices
|
|
@@ -217,7 +221,7 @@ class GearboxSDK {
|
|
|
217
221
|
return this;
|
|
218
222
|
}
|
|
219
223
|
#hydrate(options, state) {
|
|
220
|
-
const { logger: _logger, ...opts } = options;
|
|
224
|
+
const { logger: _logger, ignoreMarkets, ...opts } = options;
|
|
221
225
|
if (state.version !== STATE_VERSION) {
|
|
222
226
|
throw new Error(
|
|
223
227
|
`hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
|
|
@@ -240,7 +244,7 @@ class GearboxSDK {
|
|
|
240
244
|
this.logger?.debug(
|
|
241
245
|
`address provider version: ${this.#addressProvider.version}`
|
|
242
246
|
);
|
|
243
|
-
this.#marketRegister = new import_MarketRegister.MarketRegister(this);
|
|
247
|
+
this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
|
|
244
248
|
this.#marketRegister.hydrate(state.markets);
|
|
245
249
|
this.#attachConfig = {
|
|
246
250
|
...opts,
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __reExport(sdk_exports, require("./core/index.js"), module.exports);
|
|
|
23
23
|
__reExport(sdk_exports, require("./GearboxSDK.js"), module.exports);
|
|
24
24
|
__reExport(sdk_exports, require("./gauges/index.js"), module.exports);
|
|
25
25
|
__reExport(sdk_exports, require("./market/index.js"), module.exports);
|
|
26
|
+
__reExport(sdk_exports, require("./options.js"), module.exports);
|
|
26
27
|
__reExport(sdk_exports, require("./plugins/index.js"), module.exports);
|
|
27
28
|
__reExport(sdk_exports, require("./router/index.js"), module.exports);
|
|
28
29
|
__reExport(sdk_exports, require("./sdk-gov-legacy/index.js"), module.exports);
|
|
@@ -40,6 +41,7 @@ __reExport(sdk_exports, require("./utils/viem/index.js"), module.exports);
|
|
|
40
41
|
...require("./GearboxSDK.js"),
|
|
41
42
|
...require("./gauges/index.js"),
|
|
42
43
|
...require("./market/index.js"),
|
|
44
|
+
...require("./options.js"),
|
|
43
45
|
...require("./plugins/index.js"),
|
|
44
46
|
...require("./router/index.js"),
|
|
45
47
|
...require("./sdk-gov-legacy/index.js"),
|
|
@@ -39,15 +39,26 @@ class MarketRegister extends import_base.SDKConstruct {
|
|
|
39
39
|
void 0,
|
|
40
40
|
"marketConfigurators"
|
|
41
41
|
);
|
|
42
|
-
|
|
42
|
+
#ignoreMarkets;
|
|
43
|
+
constructor(sdk, ignoreMarkets = []) {
|
|
43
44
|
super(sdk);
|
|
44
45
|
this.#logger = (0, import_utils.childLogger)("MarketRegister", sdk.logger);
|
|
46
|
+
this.#ignoreMarkets = new Set(
|
|
47
|
+
ignoreMarkets.map((m) => m.toLowerCase())
|
|
48
|
+
);
|
|
45
49
|
}
|
|
46
50
|
hydrate(state) {
|
|
47
51
|
this.#markets.clear();
|
|
48
52
|
const configurators = new Set(state.map((m) => m.configurator));
|
|
49
53
|
this.#setMarketFilter([...configurators]);
|
|
50
54
|
for (const data of state) {
|
|
55
|
+
const pool = data.pool.baseParams.addr;
|
|
56
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
57
|
+
this.#logger?.debug(
|
|
58
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
59
|
+
);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
51
62
|
this.#markets.upsert(
|
|
52
63
|
data.pool.baseParams.addr,
|
|
53
64
|
new import_MarketSuite.MarketSuite(this.sdk, data)
|
|
@@ -148,13 +159,17 @@ class MarketRegister extends import_base.SDKConstruct {
|
|
|
148
159
|
});
|
|
149
160
|
}
|
|
150
161
|
for (const data of markets) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
const pool = data.pool.baseParams.addr;
|
|
163
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
164
|
+
this.#logger?.debug(
|
|
165
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
166
|
+
);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
this.#markets.upsert(pool, new import_MarketSuite.MarketSuite(this.sdk, data));
|
|
155
170
|
}
|
|
156
171
|
this.#logger?.info(
|
|
157
|
-
`loaded ${markets.
|
|
172
|
+
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
158
173
|
);
|
|
159
174
|
}
|
|
160
175
|
/**
|
|
@@ -18,11 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var PythUpdater_exports = {};
|
|
20
20
|
__export(PythUpdater_exports, {
|
|
21
|
+
PythOptions: () => PythOptions,
|
|
21
22
|
PythUpdater: () => PythUpdater
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(PythUpdater_exports);
|
|
24
25
|
var import_buffer = require("buffer");
|
|
25
26
|
var import_viem = require("viem");
|
|
27
|
+
var import_v4 = require("zod/v4");
|
|
26
28
|
var import_base = require("../../../base/index.js");
|
|
27
29
|
var import_utils = require("../../../utils/index.js");
|
|
28
30
|
var import_PriceUpdatesCache = require("./PriceUpdatesCache.js");
|
|
@@ -31,6 +33,28 @@ var import_PythAccumulatorUpdateData = require("./PythAccumulatorUpdateData.js")
|
|
|
31
33
|
class PythUpdateTx extends import_PriceUpdateTx.PriceUpdateTx {
|
|
32
34
|
name = "pyth";
|
|
33
35
|
}
|
|
36
|
+
const PythOptions = import_v4.z.object({
|
|
37
|
+
/**
|
|
38
|
+
* Fixed pyth historic timestamp in seconds
|
|
39
|
+
* Set to true to enable pyth historical mode using timestamp from attach block
|
|
40
|
+
*/
|
|
41
|
+
historicTimestamp: import_v4.z.union([import_v4.z.number().nonnegative(), import_v4.z.literal(true)]).optional(),
|
|
42
|
+
/**
|
|
43
|
+
* Override Hermes API with this proxy. Can be used to set caching proxies, to avoid rate limiting
|
|
44
|
+
*/
|
|
45
|
+
apiProxy: import_v4.z.url().optional(),
|
|
46
|
+
/**
|
|
47
|
+
* TTL for pyth cache in milliseconds
|
|
48
|
+
* If 0, disables caching
|
|
49
|
+
* If not set, uses some default value
|
|
50
|
+
* Cache is always enabled in historical mode
|
|
51
|
+
*/
|
|
52
|
+
cacheTTL: import_v4.z.number().nonnegative().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* When true, no error will be thrown when pyth is unable to fetch data for some feeds
|
|
55
|
+
*/
|
|
56
|
+
ignoreMissingFeeds: import_v4.z.boolean().optional()
|
|
57
|
+
});
|
|
34
58
|
class PythUpdater extends import_base.SDKConstruct {
|
|
35
59
|
#logger;
|
|
36
60
|
#cache;
|
|
@@ -186,5 +210,6 @@ function splitAccumulatorUpdates(binary) {
|
|
|
186
210
|
}
|
|
187
211
|
// Annotate the CommonJS export names for ESM import in node:
|
|
188
212
|
0 && (module.exports = {
|
|
213
|
+
PythOptions,
|
|
189
214
|
PythUpdater
|
|
190
215
|
});
|
|
@@ -18,12 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var RedstoneUpdater_exports = {};
|
|
20
20
|
__export(RedstoneUpdater_exports, {
|
|
21
|
+
RedstoneOptions: () => RedstoneOptions,
|
|
21
22
|
RedstoneUpdater: () => RedstoneUpdater
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(RedstoneUpdater_exports);
|
|
24
25
|
var import_evm_connector = require("@redstone-finance/evm-connector");
|
|
25
26
|
var import_protocol = require("@redstone-finance/protocol");
|
|
26
27
|
var import_viem = require("viem");
|
|
28
|
+
var import_v4 = require("zod/v4");
|
|
27
29
|
var import_base = require("../../../base/index.js");
|
|
28
30
|
var import_utils = require("../../../utils/index.js");
|
|
29
31
|
var import_PriceUpdatesCache = require("./PriceUpdatesCache.js");
|
|
@@ -31,6 +33,32 @@ var import_PriceUpdateTx = require("./PriceUpdateTx.js");
|
|
|
31
33
|
class RedstoneUpdateTx extends import_PriceUpdateTx.PriceUpdateTx {
|
|
32
34
|
name = "redstone";
|
|
33
35
|
}
|
|
36
|
+
const RedstoneOptions = import_v4.z.object({
|
|
37
|
+
/**
|
|
38
|
+
* Fixed redstone historic timestamp in ms
|
|
39
|
+
* Set to true to enable redstone historical mode using timestamp from attach block
|
|
40
|
+
*/
|
|
41
|
+
historicTimestamp: import_v4.z.union([import_v4.z.number().nonnegative(), import_v4.z.literal(true)]).optional(),
|
|
42
|
+
/**
|
|
43
|
+
* Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
|
|
44
|
+
*/
|
|
45
|
+
gateways: import_v4.z.array(import_v4.z.url()).optional(),
|
|
46
|
+
/**
|
|
47
|
+
* TTL for redstone cache in milliseconds
|
|
48
|
+
* If 0, disables caching
|
|
49
|
+
* If not set, uses some default value
|
|
50
|
+
* Cache is always enabled in historical mode
|
|
51
|
+
*/
|
|
52
|
+
cacheTTL: import_v4.z.number().nonnegative().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* When true, no error will be thrown when redstone is unable to fetch data for some feeds
|
|
55
|
+
*/
|
|
56
|
+
ignoreMissingFeeds: import_v4.z.boolean().optional(),
|
|
57
|
+
/**
|
|
58
|
+
* Enable redstone internal logging
|
|
59
|
+
*/
|
|
60
|
+
enableLogging: import_v4.z.boolean().optional()
|
|
61
|
+
});
|
|
34
62
|
class RedstoneUpdater extends import_base.SDKConstruct {
|
|
35
63
|
#logger;
|
|
36
64
|
#cache;
|
|
@@ -248,5 +276,6 @@ function isRedstone(pf) {
|
|
|
248
276
|
}
|
|
249
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
250
278
|
0 && (module.exports = {
|
|
279
|
+
RedstoneOptions,
|
|
251
280
|
RedstoneUpdater
|
|
252
281
|
});
|
|
@@ -18,7 +18,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var updates_exports = {};
|
|
20
20
|
__export(updates_exports, {
|
|
21
|
+
PythOptions: () => import_PythUpdater.PythOptions,
|
|
21
22
|
PythUpdater: () => import_PythUpdater.PythUpdater,
|
|
23
|
+
RedstoneOptions: () => import_RedstoneUpdater.RedstoneOptions,
|
|
22
24
|
RedstoneUpdater: () => import_RedstoneUpdater.RedstoneUpdater
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(updates_exports);
|
|
@@ -26,6 +28,8 @@ var import_PythUpdater = require("./PythUpdater.js");
|
|
|
26
28
|
var import_RedstoneUpdater = require("./RedstoneUpdater.js");
|
|
27
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
30
|
0 && (module.exports = {
|
|
31
|
+
PythOptions,
|
|
29
32
|
PythUpdater,
|
|
33
|
+
RedstoneOptions,
|
|
30
34
|
RedstoneUpdater
|
|
31
35
|
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var options_exports = {};
|
|
20
|
+
__export(options_exports, {
|
|
21
|
+
SDKOptions: () => SDKOptions
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(options_exports);
|
|
24
|
+
var import_v4 = require("zod/v4");
|
|
25
|
+
var import_updates = require("./market/pricefeeds/updates/index.js");
|
|
26
|
+
var import_utils = require("./utils/index.js");
|
|
27
|
+
const SDKOptions = import_v4.z.object({
|
|
28
|
+
/**
|
|
29
|
+
* If not set, address provider address is determinted automatically from networkType
|
|
30
|
+
*/
|
|
31
|
+
addressProvider: (0, import_utils.ZodAddress)().optional(),
|
|
32
|
+
/**
|
|
33
|
+
* Market configurators
|
|
34
|
+
*/
|
|
35
|
+
marketConfigurators: import_v4.z.array((0, import_utils.ZodAddress)()).optional(),
|
|
36
|
+
/**
|
|
37
|
+
* Attach and load state at this specific block number
|
|
38
|
+
*/
|
|
39
|
+
blockNumber: import_v4.z.union([import_v4.z.bigint().nonnegative(), import_v4.z.number().int().nonnegative()]).optional(),
|
|
40
|
+
/**
|
|
41
|
+
* Will skip updateable prices on attach and sync
|
|
42
|
+
* Makes things faster when your service is not intereseted in prices
|
|
43
|
+
*/
|
|
44
|
+
ignoreUpdateablePrices: import_v4.z.boolean().optional(),
|
|
45
|
+
/**
|
|
46
|
+
* Will skip loading markets for these pools on attach/hydrate/sync
|
|
47
|
+
*/
|
|
48
|
+
ignoreMarkets: import_v4.z.array((0, import_utils.ZodAddress)()).optional(),
|
|
49
|
+
/**
|
|
50
|
+
* Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
|
|
51
|
+
*/
|
|
52
|
+
strictContractTypes: import_v4.z.boolean().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* Plugins to extends SDK functionality
|
|
55
|
+
*/
|
|
56
|
+
plugins: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
|
|
57
|
+
/**
|
|
58
|
+
* Bring your own logger
|
|
59
|
+
*/
|
|
60
|
+
logger: import_v4.z.any(),
|
|
61
|
+
/**
|
|
62
|
+
* Options related to redstone price feeds
|
|
63
|
+
*/
|
|
64
|
+
redstone: import_updates.RedstoneOptions.optional(),
|
|
65
|
+
/**
|
|
66
|
+
* Options related to pyth price feeds
|
|
67
|
+
*/
|
|
68
|
+
pyth: import_updates.PythOptions.optional()
|
|
69
|
+
});
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
SDKOptions
|
|
73
|
+
});
|
|
@@ -28,6 +28,7 @@ __reExport(utils_exports, require("./mappers.js"), module.exports);
|
|
|
28
28
|
__reExport(utils_exports, require("./retry.js"), module.exports);
|
|
29
29
|
__reExport(utils_exports, require("./toAddress.js"), module.exports);
|
|
30
30
|
__reExport(utils_exports, require("./type-utils.js"), module.exports);
|
|
31
|
+
__reExport(utils_exports, require("./zod.js"), module.exports);
|
|
31
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
33
|
0 && (module.exports = {
|
|
33
34
|
...require("./AddressMap.js"),
|
|
@@ -42,5 +43,6 @@ __reExport(utils_exports, require("./type-utils.js"), module.exports);
|
|
|
42
43
|
...require("./mappers.js"),
|
|
43
44
|
...require("./retry.js"),
|
|
44
45
|
...require("./toAddress.js"),
|
|
45
|
-
...require("./type-utils.js")
|
|
46
|
+
...require("./type-utils.js"),
|
|
47
|
+
...require("./zod.js")
|
|
46
48
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var zod_exports = {};
|
|
20
|
+
__export(zod_exports, {
|
|
21
|
+
ZodAddress: () => ZodAddress
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(zod_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_v4 = require("zod/v4");
|
|
26
|
+
const ZodAddress = () => import_v4.z.string().transform((val, ctx) => {
|
|
27
|
+
if (!(0, import_viem.isAddress)(val)) {
|
|
28
|
+
ctx.issues.push({
|
|
29
|
+
code: "custom",
|
|
30
|
+
message: `invalid address ${val}`,
|
|
31
|
+
input: ctx.value
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return (0, import_viem.getAddress)(val);
|
|
35
|
+
});
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
ZodAddress
|
|
39
|
+
});
|
|
@@ -81,6 +81,7 @@ class GearboxSDK {
|
|
|
81
81
|
redstone,
|
|
82
82
|
pyth,
|
|
83
83
|
ignoreUpdateablePrices,
|
|
84
|
+
ignoreMarkets,
|
|
84
85
|
marketConfigurators: mcs,
|
|
85
86
|
strictContractTypes
|
|
86
87
|
} = options;
|
|
@@ -112,6 +113,7 @@ class GearboxSDK {
|
|
|
112
113
|
addressProvider,
|
|
113
114
|
blockNumber,
|
|
114
115
|
ignoreUpdateablePrices,
|
|
116
|
+
ignoreMarkets,
|
|
115
117
|
marketConfigurators,
|
|
116
118
|
redstone,
|
|
117
119
|
pyth
|
|
@@ -145,6 +147,7 @@ class GearboxSDK {
|
|
|
145
147
|
addressProvider,
|
|
146
148
|
blockNumber,
|
|
147
149
|
ignoreUpdateablePrices,
|
|
150
|
+
ignoreMarkets,
|
|
148
151
|
marketConfigurators,
|
|
149
152
|
redstone,
|
|
150
153
|
pyth
|
|
@@ -156,7 +159,8 @@ class GearboxSDK {
|
|
|
156
159
|
chainId: this.provider.chainId,
|
|
157
160
|
addressProvider,
|
|
158
161
|
marketConfigurators,
|
|
159
|
-
blockNumber
|
|
162
|
+
blockNumber,
|
|
163
|
+
ignoreMarkets
|
|
160
164
|
},
|
|
161
165
|
`${re}attaching gearbox sdk`
|
|
162
166
|
);
|
|
@@ -188,7 +192,7 @@ class GearboxSDK {
|
|
|
188
192
|
`address provider version: ${this.#addressProvider.version}`
|
|
189
193
|
);
|
|
190
194
|
await this.#addressProvider.syncState(this.currentBlock);
|
|
191
|
-
this.#marketRegister = new MarketRegister(this);
|
|
195
|
+
this.#marketRegister = new MarketRegister(this, ignoreMarkets);
|
|
192
196
|
await this.#marketRegister.loadMarkets(
|
|
193
197
|
marketConfigurators,
|
|
194
198
|
ignoreUpdateablePrices
|
|
@@ -215,7 +219,7 @@ class GearboxSDK {
|
|
|
215
219
|
return this;
|
|
216
220
|
}
|
|
217
221
|
#hydrate(options, state) {
|
|
218
|
-
const { logger: _logger, ...opts } = options;
|
|
222
|
+
const { logger: _logger, ignoreMarkets, ...opts } = options;
|
|
219
223
|
if (state.version !== STATE_VERSION) {
|
|
220
224
|
throw new Error(
|
|
221
225
|
`hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
|
|
@@ -238,7 +242,7 @@ class GearboxSDK {
|
|
|
238
242
|
this.logger?.debug(
|
|
239
243
|
`address provider version: ${this.#addressProvider.version}`
|
|
240
244
|
);
|
|
241
|
-
this.#marketRegister = new MarketRegister(this);
|
|
245
|
+
this.#marketRegister = new MarketRegister(this, ignoreMarkets);
|
|
242
246
|
this.#marketRegister.hydrate(state.markets);
|
|
243
247
|
this.#attachConfig = {
|
|
244
248
|
...opts,
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./core/index.js";
|
|
|
6
6
|
export * from "./GearboxSDK.js";
|
|
7
7
|
export * from "./gauges/index.js";
|
|
8
8
|
export * from "./market/index.js";
|
|
9
|
+
export * from "./options.js";
|
|
9
10
|
export * from "./plugins/index.js";
|
|
10
11
|
export * from "./router/index.js";
|
|
11
12
|
export * from "./sdk-gov-legacy/index.js";
|
|
@@ -20,15 +20,26 @@ class MarketRegister extends SDKConstruct {
|
|
|
20
20
|
void 0,
|
|
21
21
|
"marketConfigurators"
|
|
22
22
|
);
|
|
23
|
-
|
|
23
|
+
#ignoreMarkets;
|
|
24
|
+
constructor(sdk, ignoreMarkets = []) {
|
|
24
25
|
super(sdk);
|
|
25
26
|
this.#logger = childLogger("MarketRegister", sdk.logger);
|
|
27
|
+
this.#ignoreMarkets = new Set(
|
|
28
|
+
ignoreMarkets.map((m) => m.toLowerCase())
|
|
29
|
+
);
|
|
26
30
|
}
|
|
27
31
|
hydrate(state) {
|
|
28
32
|
this.#markets.clear();
|
|
29
33
|
const configurators = new Set(state.map((m) => m.configurator));
|
|
30
34
|
this.#setMarketFilter([...configurators]);
|
|
31
35
|
for (const data of state) {
|
|
36
|
+
const pool = data.pool.baseParams.addr;
|
|
37
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
38
|
+
this.#logger?.debug(
|
|
39
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
40
|
+
);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
32
43
|
this.#markets.upsert(
|
|
33
44
|
data.pool.baseParams.addr,
|
|
34
45
|
new MarketSuite(this.sdk, data)
|
|
@@ -129,13 +140,17 @@ class MarketRegister extends SDKConstruct {
|
|
|
129
140
|
});
|
|
130
141
|
}
|
|
131
142
|
for (const data of markets) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
const pool = data.pool.baseParams.addr;
|
|
144
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
145
|
+
this.#logger?.debug(
|
|
146
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
147
|
+
);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
this.#markets.upsert(pool, new MarketSuite(this.sdk, data));
|
|
136
151
|
}
|
|
137
152
|
this.#logger?.info(
|
|
138
|
-
`loaded ${markets.
|
|
153
|
+
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
139
154
|
);
|
|
140
155
|
}
|
|
141
156
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import { encodeAbiParameters, toHex } from "viem";
|
|
3
|
+
import { z } from "zod/v4";
|
|
3
4
|
import { SDKConstruct } from "../../../base/index.js";
|
|
4
5
|
import { childLogger, retry } from "../../../utils/index.js";
|
|
5
6
|
import { PriceUpdatesCache } from "./PriceUpdatesCache.js";
|
|
@@ -12,6 +13,28 @@ import {
|
|
|
12
13
|
class PythUpdateTx extends PriceUpdateTx {
|
|
13
14
|
name = "pyth";
|
|
14
15
|
}
|
|
16
|
+
const PythOptions = z.object({
|
|
17
|
+
/**
|
|
18
|
+
* Fixed pyth historic timestamp in seconds
|
|
19
|
+
* Set to true to enable pyth historical mode using timestamp from attach block
|
|
20
|
+
*/
|
|
21
|
+
historicTimestamp: z.union([z.number().nonnegative(), z.literal(true)]).optional(),
|
|
22
|
+
/**
|
|
23
|
+
* Override Hermes API with this proxy. Can be used to set caching proxies, to avoid rate limiting
|
|
24
|
+
*/
|
|
25
|
+
apiProxy: z.url().optional(),
|
|
26
|
+
/**
|
|
27
|
+
* TTL for pyth cache in milliseconds
|
|
28
|
+
* If 0, disables caching
|
|
29
|
+
* If not set, uses some default value
|
|
30
|
+
* Cache is always enabled in historical mode
|
|
31
|
+
*/
|
|
32
|
+
cacheTTL: z.number().nonnegative().optional(),
|
|
33
|
+
/**
|
|
34
|
+
* When true, no error will be thrown when pyth is unable to fetch data for some feeds
|
|
35
|
+
*/
|
|
36
|
+
ignoreMissingFeeds: z.boolean().optional()
|
|
37
|
+
});
|
|
15
38
|
class PythUpdater extends SDKConstruct {
|
|
16
39
|
#logger;
|
|
17
40
|
#cache;
|
|
@@ -166,5 +189,6 @@ function splitAccumulatorUpdates(binary) {
|
|
|
166
189
|
return results;
|
|
167
190
|
}
|
|
168
191
|
export {
|
|
192
|
+
PythOptions,
|
|
169
193
|
PythUpdater
|
|
170
194
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataServiceWrapper } from "@redstone-finance/evm-connector";
|
|
2
2
|
import { RedstonePayload } from "@redstone-finance/protocol";
|
|
3
3
|
import { encodeAbiParameters, toBytes } from "viem";
|
|
4
|
+
import { z } from "zod/v4";
|
|
4
5
|
import { SDKConstruct } from "../../../base/index.js";
|
|
5
6
|
import { AddressMap, childLogger, retry } from "../../../utils/index.js";
|
|
6
7
|
import { PriceUpdatesCache } from "./PriceUpdatesCache.js";
|
|
@@ -8,6 +9,32 @@ import { PriceUpdateTx } from "./PriceUpdateTx.js";
|
|
|
8
9
|
class RedstoneUpdateTx extends PriceUpdateTx {
|
|
9
10
|
name = "redstone";
|
|
10
11
|
}
|
|
12
|
+
const RedstoneOptions = z.object({
|
|
13
|
+
/**
|
|
14
|
+
* Fixed redstone historic timestamp in ms
|
|
15
|
+
* Set to true to enable redstone historical mode using timestamp from attach block
|
|
16
|
+
*/
|
|
17
|
+
historicTimestamp: z.union([z.number().nonnegative(), z.literal(true)]).optional(),
|
|
18
|
+
/**
|
|
19
|
+
* Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
|
|
20
|
+
*/
|
|
21
|
+
gateways: z.array(z.url()).optional(),
|
|
22
|
+
/**
|
|
23
|
+
* TTL for redstone cache in milliseconds
|
|
24
|
+
* If 0, disables caching
|
|
25
|
+
* If not set, uses some default value
|
|
26
|
+
* Cache is always enabled in historical mode
|
|
27
|
+
*/
|
|
28
|
+
cacheTTL: z.number().nonnegative().optional(),
|
|
29
|
+
/**
|
|
30
|
+
* When true, no error will be thrown when redstone is unable to fetch data for some feeds
|
|
31
|
+
*/
|
|
32
|
+
ignoreMissingFeeds: z.boolean().optional(),
|
|
33
|
+
/**
|
|
34
|
+
* Enable redstone internal logging
|
|
35
|
+
*/
|
|
36
|
+
enableLogging: z.boolean().optional()
|
|
37
|
+
});
|
|
11
38
|
class RedstoneUpdater extends SDKConstruct {
|
|
12
39
|
#logger;
|
|
13
40
|
#cache;
|
|
@@ -224,5 +251,6 @@ function isRedstone(pf) {
|
|
|
224
251
|
return pf.contractType === "PRICE_FEED::REDSTONE";
|
|
225
252
|
}
|
|
226
253
|
export {
|
|
254
|
+
RedstoneOptions,
|
|
227
255
|
RedstoneUpdater
|
|
228
256
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PythUpdater } from "./PythUpdater.js";
|
|
2
|
-
import { RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
1
|
+
import { PythOptions, PythUpdater } from "./PythUpdater.js";
|
|
2
|
+
import { RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
3
3
|
export {
|
|
4
|
+
PythOptions,
|
|
4
5
|
PythUpdater,
|
|
6
|
+
RedstoneOptions,
|
|
5
7
|
RedstoneUpdater
|
|
6
8
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import {
|
|
3
|
+
PythOptions,
|
|
4
|
+
RedstoneOptions
|
|
5
|
+
} from "./market/pricefeeds/updates/index.js";
|
|
6
|
+
import { ZodAddress } from "./utils/index.js";
|
|
7
|
+
const SDKOptions = z.object({
|
|
8
|
+
/**
|
|
9
|
+
* If not set, address provider address is determinted automatically from networkType
|
|
10
|
+
*/
|
|
11
|
+
addressProvider: ZodAddress().optional(),
|
|
12
|
+
/**
|
|
13
|
+
* Market configurators
|
|
14
|
+
*/
|
|
15
|
+
marketConfigurators: z.array(ZodAddress()).optional(),
|
|
16
|
+
/**
|
|
17
|
+
* Attach and load state at this specific block number
|
|
18
|
+
*/
|
|
19
|
+
blockNumber: z.union([z.bigint().nonnegative(), z.number().int().nonnegative()]).optional(),
|
|
20
|
+
/**
|
|
21
|
+
* Will skip updateable prices on attach and sync
|
|
22
|
+
* Makes things faster when your service is not intereseted in prices
|
|
23
|
+
*/
|
|
24
|
+
ignoreUpdateablePrices: z.boolean().optional(),
|
|
25
|
+
/**
|
|
26
|
+
* Will skip loading markets for these pools on attach/hydrate/sync
|
|
27
|
+
*/
|
|
28
|
+
ignoreMarkets: z.array(ZodAddress()).optional(),
|
|
29
|
+
/**
|
|
30
|
+
* Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
|
|
31
|
+
*/
|
|
32
|
+
strictContractTypes: z.boolean().optional(),
|
|
33
|
+
/**
|
|
34
|
+
* Plugins to extends SDK functionality
|
|
35
|
+
*/
|
|
36
|
+
plugins: z.record(z.string(), z.any()).optional(),
|
|
37
|
+
/**
|
|
38
|
+
* Bring your own logger
|
|
39
|
+
*/
|
|
40
|
+
logger: z.any(),
|
|
41
|
+
/**
|
|
42
|
+
* Options related to redstone price feeds
|
|
43
|
+
*/
|
|
44
|
+
redstone: RedstoneOptions.optional(),
|
|
45
|
+
/**
|
|
46
|
+
* Options related to pyth price feeds
|
|
47
|
+
*/
|
|
48
|
+
pyth: PythOptions.optional()
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
SDKOptions
|
|
52
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getAddress, isAddress } from "viem";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
const ZodAddress = () => z.string().transform((val, ctx) => {
|
|
4
|
+
if (!isAddress(val)) {
|
|
5
|
+
ctx.issues.push({
|
|
6
|
+
code: "custom",
|
|
7
|
+
message: `invalid address ${val}`,
|
|
8
|
+
input: ctx.value
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return getAddress(val);
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
ZodAddress
|
|
15
|
+
};
|
|
@@ -8,7 +8,7 @@ import type { IAddressProviderContract } from "./core/index.js";
|
|
|
8
8
|
import { BotListContract, GearStakingContract } from "./core/index.js";
|
|
9
9
|
import { MarketRegister } from "./market/MarketRegister.js";
|
|
10
10
|
import { PriceFeedRegister } from "./market/pricefeeds/index.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { SDKOptions } from "./options.js";
|
|
12
12
|
import { type PluginsMap } from "./plugins/index.js";
|
|
13
13
|
import { type IRouterContract } from "./router/index.js";
|
|
14
14
|
import type { GearboxState, GearboxStateHuman, ILogger, MultiCall } from "./types/index.js";
|
|
@@ -17,45 +17,6 @@ import { AddressMap } from "./utils/index.js";
|
|
|
17
17
|
* State version, checked duryng hydration
|
|
18
18
|
*/
|
|
19
19
|
export declare const STATE_VERSION = 1;
|
|
20
|
-
export interface SDKOptions<Plugins extends PluginsMap> {
|
|
21
|
-
/**
|
|
22
|
-
* If not set, address provider address is determinted automatically from networkType
|
|
23
|
-
*/
|
|
24
|
-
addressProvider?: Address;
|
|
25
|
-
/**
|
|
26
|
-
* Market configurators
|
|
27
|
-
*/
|
|
28
|
-
marketConfigurators?: Address[];
|
|
29
|
-
/**
|
|
30
|
-
* Attach and load state at this specific block number
|
|
31
|
-
*/
|
|
32
|
-
blockNumber?: bigint | number;
|
|
33
|
-
/**
|
|
34
|
-
* Will skip updateable prices on attach and sync
|
|
35
|
-
* Makes things faster when your service is not intereseted in prices
|
|
36
|
-
*/
|
|
37
|
-
ignoreUpdateablePrices?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
|
|
40
|
-
*/
|
|
41
|
-
strictContractTypes?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Plugins to extends SDK functionality
|
|
44
|
-
*/
|
|
45
|
-
plugins?: Plugins;
|
|
46
|
-
/**
|
|
47
|
-
* Bring your own logger
|
|
48
|
-
*/
|
|
49
|
-
logger?: ILogger;
|
|
50
|
-
/**
|
|
51
|
-
* Options related to redstone price feeds
|
|
52
|
-
*/
|
|
53
|
-
redstone?: RedstoneOptions;
|
|
54
|
-
/**
|
|
55
|
-
* Options related to pyth price feeds
|
|
56
|
-
*/
|
|
57
|
-
pyth?: PythOptions;
|
|
58
|
-
}
|
|
59
20
|
export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
|
|
60
21
|
export interface SyncStateOptions {
|
|
61
22
|
blockNumber: bigint;
|
|
@@ -6,6 +6,7 @@ export * from "./core/index.js";
|
|
|
6
6
|
export * from "./GearboxSDK.js";
|
|
7
7
|
export * from "./gauges/index.js";
|
|
8
8
|
export * from "./market/index.js";
|
|
9
|
+
export * from "./options.js";
|
|
9
10
|
export * from "./plugins/index.js";
|
|
10
11
|
export * from "./router/index.js";
|
|
11
12
|
export * from "./sdk-gov-legacy/index.js";
|
|
@@ -10,7 +10,7 @@ import { MarketSuite } from "./MarketSuite.js";
|
|
|
10
10
|
import type { PoolSuite } from "./pool/index.js";
|
|
11
11
|
export declare class MarketRegister extends SDKConstruct {
|
|
12
12
|
#private;
|
|
13
|
-
constructor(sdk: GearboxSDK);
|
|
13
|
+
constructor(sdk: GearboxSDK, ignoreMarkets?: Address[]);
|
|
14
14
|
hydrate(state: MarketData[]): void;
|
|
15
15
|
loadMarkets(marketConfigurators: Address[], ignoreUpdateablePrices?: boolean): Promise<void>;
|
|
16
16
|
get marketFilter(): MarketFilter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
1
2
|
import { SDKConstruct } from "../../../base/index.js";
|
|
2
3
|
import type { GearboxSDK } from "../../../GearboxSDK.js";
|
|
3
4
|
import type { IPriceFeedContract } from "../types.js";
|
|
@@ -7,28 +8,13 @@ export type PythUpdateTask = IPriceUpdateTask;
|
|
|
7
8
|
declare class PythUpdateTx extends PriceUpdateTx<PythUpdateTask> {
|
|
8
9
|
readonly name = "pyth";
|
|
9
10
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Override Hermes API with this proxy. Can be used to set caching proxies, to avoid rate limiting
|
|
18
|
-
*/
|
|
19
|
-
apiProxy?: string;
|
|
20
|
-
/**
|
|
21
|
-
* TTL for pyth cache in milliseconds
|
|
22
|
-
* If 0, disables caching
|
|
23
|
-
* If not set, uses some default value
|
|
24
|
-
* Cache is always enabled in historical mode
|
|
25
|
-
*/
|
|
26
|
-
cacheTTL?: number;
|
|
27
|
-
/**
|
|
28
|
-
* When true, no error will be thrown when pyth is unable to fetch data for some feeds
|
|
29
|
-
*/
|
|
30
|
-
ignoreMissingFeeds?: boolean;
|
|
31
|
-
}
|
|
11
|
+
export declare const PythOptions: z.ZodObject<{
|
|
12
|
+
historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
|
|
13
|
+
apiProxy: z.ZodOptional<z.ZodURL>;
|
|
14
|
+
cacheTTL: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type PythOptions = z.infer<typeof PythOptions>;
|
|
32
18
|
/**
|
|
33
19
|
* Class to update multiple pyth price feeds at once
|
|
34
20
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
1
2
|
import { SDKConstruct } from "../../../base/index.js";
|
|
2
3
|
import type { GearboxSDK } from "../../../GearboxSDK.js";
|
|
3
4
|
import type { IPriceFeedContract } from "../types.js";
|
|
@@ -9,32 +10,14 @@ interface RedstoneUpdateTask extends IPriceUpdateTask {
|
|
|
9
10
|
declare class RedstoneUpdateTx extends PriceUpdateTx<RedstoneUpdateTask> {
|
|
10
11
|
readonly name = "redstone";
|
|
11
12
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
gateways?: string[];
|
|
22
|
-
/**
|
|
23
|
-
* TTL for redstone cache in milliseconds
|
|
24
|
-
* If 0, disables caching
|
|
25
|
-
* If not set, uses some default value
|
|
26
|
-
* Cache is always enabled in historical mode
|
|
27
|
-
*/
|
|
28
|
-
cacheTTL?: number;
|
|
29
|
-
/**
|
|
30
|
-
* When true, no error will be thrown when redstone is unable to fetch data for some feeds
|
|
31
|
-
*/
|
|
32
|
-
ignoreMissingFeeds?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Enable redstone internal logging
|
|
35
|
-
*/
|
|
36
|
-
enableLogging?: boolean;
|
|
37
|
-
}
|
|
13
|
+
export declare const RedstoneOptions: z.ZodObject<{
|
|
14
|
+
historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
|
|
15
|
+
gateways: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
16
|
+
cacheTTL: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
enableLogging: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type RedstoneOptions = z.infer<typeof RedstoneOptions>;
|
|
38
21
|
/**
|
|
39
22
|
* Class to update multiple redstone price feeds at once
|
|
40
23
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { PythOptions, PythUpdater } from "./PythUpdater.js";
|
|
2
|
+
export { RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
3
3
|
export type * from "./types.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import type { PluginsMap } from "./plugins/index.js";
|
|
3
|
+
import type { ILogger } from "./types/index.js";
|
|
4
|
+
export declare const SDKOptions: z.ZodObject<{
|
|
5
|
+
addressProvider: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
6
|
+
marketConfigurators: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
|
|
7
|
+
blockNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>>;
|
|
8
|
+
ignoreUpdateablePrices: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
ignoreMarkets: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
|
|
10
|
+
strictContractTypes: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
plugins: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
12
|
+
logger: z.ZodAny;
|
|
13
|
+
redstone: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
|
|
15
|
+
gateways: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
16
|
+
cacheTTL: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
enableLogging: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
pyth: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
|
|
22
|
+
apiProxy: z.ZodOptional<z.ZodURL>;
|
|
23
|
+
cacheTTL: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type SDKOptions<Plugins extends PluginsMap> = Omit<z.infer<typeof SDKOptions>, "logger" | "plugins"> & {
|
|
28
|
+
/**
|
|
29
|
+
* Plugins to extends SDK functionality
|
|
30
|
+
*/
|
|
31
|
+
plugins?: Plugins;
|
|
32
|
+
/**
|
|
33
|
+
* Bring your own logger
|
|
34
|
+
*/
|
|
35
|
+
logger?: ILogger;
|
|
36
|
+
};
|