@gearbox-protocol/sdk 8.7.0 → 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/index.js +2 -0
- 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/index.js +1 -0
- 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 -44
- package/dist/types/sdk/index.d.ts +1 -0
- 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
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"),
|
|
@@ -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
|
+
});
|
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";
|
|
@@ -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,49 +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 skip loading markets for these pools on attach/hydrate/sync
|
|
40
|
-
*/
|
|
41
|
-
ignoreMarkets?: Address[];
|
|
42
|
-
/**
|
|
43
|
-
* Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
|
|
44
|
-
*/
|
|
45
|
-
strictContractTypes?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Plugins to extends SDK functionality
|
|
48
|
-
*/
|
|
49
|
-
plugins?: Plugins;
|
|
50
|
-
/**
|
|
51
|
-
* Bring your own logger
|
|
52
|
-
*/
|
|
53
|
-
logger?: ILogger;
|
|
54
|
-
/**
|
|
55
|
-
* Options related to redstone price feeds
|
|
56
|
-
*/
|
|
57
|
-
redstone?: RedstoneOptions;
|
|
58
|
-
/**
|
|
59
|
-
* Options related to pyth price feeds
|
|
60
|
-
*/
|
|
61
|
-
pyth?: PythOptions;
|
|
62
|
-
}
|
|
63
20
|
export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
|
|
64
21
|
export interface SyncStateOptions {
|
|
65
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";
|
|
@@ -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
|
+
};
|