@gearbox-protocol/sdk 12.9.8 → 12.10.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/permissionless/utils/price-update/get-prices.js +0 -3
- package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -9
- package/dist/cjs/sdk/GearboxSDK.js +7 -17
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +1 -4
- package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +3 -27
- package/dist/cjs/sdk/market/pricefeeds/index.js +0 -2
- package/dist/cjs/sdk/market/pricefeeds/updates/index.js +0 -7
- package/dist/cjs/sdk/options.js +0 -4
- package/dist/esm/permissionless/utils/price-update/get-prices.js +0 -3
- package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +2 -10
- package/dist/esm/sdk/GearboxSDK.js +7 -17
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -5
- package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +4 -28
- package/dist/esm/sdk/market/pricefeeds/index.js +0 -2
- package/dist/esm/sdk/market/pricefeeds/updates/index.js +0 -4
- package/dist/esm/sdk/options.js +1 -8
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -2
- package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +2 -25
- package/dist/types/sdk/market/pricefeeds/index.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +0 -2
- package/dist/types/sdk/options.d.ts +0 -6
- package/package.json +5 -2
- package/dist/cjs/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +0 -195
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +0 -183
- package/dist/cjs/sdk/market/pricefeeds/updates/fetchPythPayloads.js +0 -135
- package/dist/esm/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +0 -157
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +0 -158
- package/dist/esm/sdk/market/pricefeeds/updates/fetchPythPayloads.js +0 -115
- package/dist/types/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.d.ts +0 -41
- package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +0 -26
- package/dist/types/sdk/market/pricefeeds/updates/fetchPythPayloads.d.ts +0 -45
|
@@ -34,15 +34,8 @@ async function getUpdatablePriceFeeds(args) {
|
|
|
34
34
|
const updatablePriceFeeds = (await priceFeedCompressor.read.loadPriceFeedTree([
|
|
35
35
|
priceFeeds
|
|
36
36
|
])).filter(
|
|
37
|
-
(data) =>
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
).map((data) => {
|
|
41
|
-
if ((0, import_sdk.bytes32ToString)(data.baseParams.contractType) === "PRICE_FEED::PYTH") {
|
|
42
|
-
return new import_sdk.PythPriceFeed(sdk, data);
|
|
43
|
-
}
|
|
44
|
-
return new import_sdk.RedstonePriceFeedContract(sdk, data);
|
|
45
|
-
});
|
|
37
|
+
(data) => (0, import_sdk.bytes32ToString)(data.baseParams.contractType) === "PRICE_FEED::REDSTONE"
|
|
38
|
+
).map((data) => new import_sdk.RedstonePriceFeedContract(sdk, data));
|
|
46
39
|
return updatablePriceFeeds;
|
|
47
40
|
}
|
|
48
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -100,7 +100,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
100
100
|
plugins,
|
|
101
101
|
blockNumber,
|
|
102
102
|
redstone,
|
|
103
|
-
pyth,
|
|
104
103
|
ignoreUpdateablePrices,
|
|
105
104
|
ignoreMarkets,
|
|
106
105
|
marketConfigurators: mcs,
|
|
@@ -125,8 +124,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
125
124
|
ignoreUpdateablePrices,
|
|
126
125
|
ignoreMarkets,
|
|
127
126
|
marketConfigurators,
|
|
128
|
-
redstone
|
|
129
|
-
pyth
|
|
127
|
+
redstone
|
|
130
128
|
});
|
|
131
129
|
}
|
|
132
130
|
static hydrate(options, state) {
|
|
@@ -163,8 +161,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
163
161
|
ignoreUpdateablePrices,
|
|
164
162
|
ignoreMarkets,
|
|
165
163
|
marketConfigurators,
|
|
166
|
-
redstone
|
|
167
|
-
pyth
|
|
164
|
+
redstone
|
|
168
165
|
} = opts;
|
|
169
166
|
const re = this.#attachConfig ? "re" : "";
|
|
170
167
|
this.logger?.info(
|
|
@@ -183,11 +180,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
183
180
|
`${re}attaching to fixed block number, but redstone historicTimestamp is not set. price updates might fail`
|
|
184
181
|
);
|
|
185
182
|
}
|
|
186
|
-
if (!!blockNumber && !opts.pyth?.historicTimestamp) {
|
|
187
|
-
this.logger?.warn(
|
|
188
|
-
`${re}attaching to fixed block number, but pyth historicTimestamp is not set. price updates might fail`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
183
|
this.#attachConfig = opts;
|
|
192
184
|
const time = Date.now();
|
|
193
185
|
const block = await this.client.getBlock(
|
|
@@ -197,7 +189,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
197
189
|
);
|
|
198
190
|
this.#currentBlock = block.number;
|
|
199
191
|
this.#timestamp = block.timestamp;
|
|
200
|
-
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone
|
|
192
|
+
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone });
|
|
201
193
|
this.logger?.debug(
|
|
202
194
|
`${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
|
|
203
195
|
);
|
|
@@ -247,8 +239,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
247
239
|
this.#currentBlock = state.currentBlock;
|
|
248
240
|
this.#timestamp = state.timestamp;
|
|
249
241
|
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, {
|
|
250
|
-
redstone: opts.redstone
|
|
251
|
-
pyth: opts.pyth
|
|
242
|
+
redstone: opts.redstone
|
|
252
243
|
});
|
|
253
244
|
this.#addressProvider = (0, import_core.hydrateAddressProvider)(this, state.addressProvider);
|
|
254
245
|
this.logger?.debug(
|
|
@@ -301,8 +292,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
301
292
|
}
|
|
302
293
|
const opts = {
|
|
303
294
|
ignoreUpdateablePrices: this.#attachConfig.ignoreUpdateablePrices,
|
|
304
|
-
redstone: this.#attachConfig.redstone
|
|
305
|
-
pyth: this.#attachConfig.pyth
|
|
295
|
+
redstone: this.#attachConfig.redstone
|
|
306
296
|
};
|
|
307
297
|
this.#hydrate(opts, state);
|
|
308
298
|
await this.#hooks.triggerHooks("rehydrate", {
|
|
@@ -360,9 +350,9 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
360
350
|
timestamp,
|
|
361
351
|
ignoreUpdateablePrices = this.#attachConfig?.ignoreUpdateablePrices
|
|
362
352
|
} = opts ?? {};
|
|
363
|
-
if (this.#attachConfig?.redstone?.historicTimestamp
|
|
353
|
+
if (this.#attachConfig?.redstone?.historicTimestamp) {
|
|
364
354
|
throw new Error(
|
|
365
|
-
"syncState is not supported with redstone
|
|
355
|
+
"syncState is not supported with redstone historicTimestamp"
|
|
366
356
|
);
|
|
367
357
|
}
|
|
368
358
|
if (!blockNumber || !timestamp) {
|
|
@@ -54,10 +54,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
54
54
|
updaters;
|
|
55
55
|
constructor(sdk, opts = {}) {
|
|
56
56
|
super(sdk);
|
|
57
|
-
this.updaters = [
|
|
58
|
-
new import_updates.RedstoneUpdater(sdk, opts?.redstone),
|
|
59
|
-
new import_updates.PythUpdater(sdk, opts?.pyth)
|
|
60
|
-
];
|
|
57
|
+
this.updaters = [new import_updates.RedstoneUpdater(sdk, opts?.redstone)];
|
|
61
58
|
}
|
|
62
59
|
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
63
60
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
@@ -25,9 +25,6 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_oracles = require("../../abi/oracles.js");
|
|
26
26
|
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
27
27
|
const abi = import_oracles.pythPriceFeedAbi;
|
|
28
|
-
const iPythAbi = (0, import_viem.parseAbi)([
|
|
29
|
-
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
30
|
-
]);
|
|
31
28
|
class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
32
29
|
token;
|
|
33
30
|
priceFeedId;
|
|
@@ -36,6 +33,9 @@ class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
|
36
33
|
constructor(options, args) {
|
|
37
34
|
super(options, {
|
|
38
35
|
...args,
|
|
36
|
+
// the sdk does not push pyth price updates, so these feeds are never
|
|
37
|
+
// treated as updatable even though the contract implements the interface
|
|
38
|
+
updatable: false,
|
|
39
39
|
name: "PythPriceFeed",
|
|
40
40
|
abi
|
|
41
41
|
});
|
|
@@ -67,30 +67,6 @@ class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
|
67
67
|
this.pyth = decoded[2];
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
createPriceUpdateTx(data) {
|
|
71
|
-
return this.createRawTx({
|
|
72
|
-
functionName: "updatePrice",
|
|
73
|
-
args: [data],
|
|
74
|
-
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
79
|
-
* @param calldata
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
getUpdateFeeParams(calldata) {
|
|
83
|
-
const [, updateData] = (0, import_viem.decodeAbiParameters)(
|
|
84
|
-
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
85
|
-
calldata
|
|
86
|
-
);
|
|
87
|
-
return {
|
|
88
|
-
address: this.pyth,
|
|
89
|
-
abi: iPythAbi,
|
|
90
|
-
functionName: "getUpdateFee",
|
|
91
|
-
args: [updateData]
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
70
|
}
|
|
95
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
72
|
0 && (module.exports = {
|
|
@@ -19,7 +19,6 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var pricefeeds_exports = {};
|
|
21
21
|
__export(pricefeeds_exports, {
|
|
22
|
-
fetchPythPayloads: () => import_updates.fetchPythPayloads,
|
|
23
22
|
fetchRedstonePayloads: () => import_updates.fetchRedstonePayloads
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(pricefeeds_exports);
|
|
@@ -49,7 +48,6 @@ __reExport(pricefeeds_exports, require("./YearnPriceFeed.js"), module.exports);
|
|
|
49
48
|
__reExport(pricefeeds_exports, require("./ZeroPriceFeed.js"), module.exports);
|
|
50
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
51
50
|
0 && (module.exports = {
|
|
52
|
-
fetchPythPayloads,
|
|
53
51
|
fetchRedstonePayloads,
|
|
54
52
|
...require("./AbstractLPPriceFeed.js"),
|
|
55
53
|
...require("./AbstractPriceFeed.js"),
|
|
@@ -19,22 +19,15 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var updates_exports = {};
|
|
21
21
|
__export(updates_exports, {
|
|
22
|
-
PythOptions: () => import_PythUpdater.PythOptions,
|
|
23
|
-
PythUpdater: () => import_PythUpdater.PythUpdater,
|
|
24
22
|
RedstoneOptions: () => import_RedstoneUpdater.RedstoneOptions,
|
|
25
23
|
RedstoneUpdater: () => import_RedstoneUpdater.RedstoneUpdater
|
|
26
24
|
});
|
|
27
25
|
module.exports = __toCommonJS(updates_exports);
|
|
28
|
-
__reExport(updates_exports, require("./fetchPythPayloads.js"), module.exports);
|
|
29
26
|
__reExport(updates_exports, require("./fetchRedstonePayloads.js"), module.exports);
|
|
30
|
-
var import_PythUpdater = require("./PythUpdater.js");
|
|
31
27
|
var import_RedstoneUpdater = require("./RedstoneUpdater.js");
|
|
32
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
29
|
0 && (module.exports = {
|
|
34
|
-
PythOptions,
|
|
35
|
-
PythUpdater,
|
|
36
30
|
RedstoneOptions,
|
|
37
31
|
RedstoneUpdater,
|
|
38
|
-
...require("./fetchPythPayloads.js"),
|
|
39
32
|
...require("./fetchRedstonePayloads.js")
|
|
40
33
|
});
|
package/dist/cjs/sdk/options.js
CHANGED
|
@@ -62,10 +62,6 @@ const SDKOptions = import_v4.z.object({
|
|
|
62
62
|
* Options related to redstone price feeds
|
|
63
63
|
*/
|
|
64
64
|
redstone: import_updates.RedstoneOptions.optional(),
|
|
65
|
-
/**
|
|
66
|
-
* Options related to pyth price feeds
|
|
67
|
-
*/
|
|
68
|
-
pyth: import_updates.PythOptions.optional(),
|
|
69
65
|
/**
|
|
70
66
|
* Explicit gas limit for read eth_calls
|
|
71
67
|
* Null to disable explicitly setting gas limit, undefined to use default sdk value
|
|
@@ -2,7 +2,6 @@ import { getContract } from "viem";
|
|
|
2
2
|
import { priceFeedCompressorAbi } from "../../../abi/compressors/priceFeedCompressor.js";
|
|
3
3
|
import {
|
|
4
4
|
bytes32ToString,
|
|
5
|
-
PythPriceFeed,
|
|
6
5
|
RedstonePriceFeedContract
|
|
7
6
|
} from "../../../sdk/index.js";
|
|
8
7
|
async function getUpdatablePriceFeeds(args) {
|
|
@@ -15,15 +14,8 @@ async function getUpdatablePriceFeeds(args) {
|
|
|
15
14
|
const updatablePriceFeeds = (await priceFeedCompressor.read.loadPriceFeedTree([
|
|
16
15
|
priceFeeds
|
|
17
16
|
])).filter(
|
|
18
|
-
(data) =>
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
).map((data) => {
|
|
22
|
-
if (bytes32ToString(data.baseParams.contractType) === "PRICE_FEED::PYTH") {
|
|
23
|
-
return new PythPriceFeed(sdk, data);
|
|
24
|
-
}
|
|
25
|
-
return new RedstonePriceFeedContract(sdk, data);
|
|
26
|
-
});
|
|
17
|
+
(data) => bytes32ToString(data.baseParams.contractType) === "PRICE_FEED::REDSTONE"
|
|
18
|
+
).map((data) => new RedstonePriceFeedContract(sdk, data));
|
|
27
19
|
return updatablePriceFeeds;
|
|
28
20
|
}
|
|
29
21
|
export {
|
|
@@ -99,7 +99,6 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
99
99
|
plugins,
|
|
100
100
|
blockNumber,
|
|
101
101
|
redstone,
|
|
102
|
-
pyth,
|
|
103
102
|
ignoreUpdateablePrices,
|
|
104
103
|
ignoreMarkets,
|
|
105
104
|
marketConfigurators: mcs,
|
|
@@ -124,8 +123,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
124
123
|
ignoreUpdateablePrices,
|
|
125
124
|
ignoreMarkets,
|
|
126
125
|
marketConfigurators,
|
|
127
|
-
redstone
|
|
128
|
-
pyth
|
|
126
|
+
redstone
|
|
129
127
|
});
|
|
130
128
|
}
|
|
131
129
|
static hydrate(options, state) {
|
|
@@ -162,8 +160,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
162
160
|
ignoreUpdateablePrices,
|
|
163
161
|
ignoreMarkets,
|
|
164
162
|
marketConfigurators,
|
|
165
|
-
redstone
|
|
166
|
-
pyth
|
|
163
|
+
redstone
|
|
167
164
|
} = opts;
|
|
168
165
|
const re = this.#attachConfig ? "re" : "";
|
|
169
166
|
this.logger?.info(
|
|
@@ -182,11 +179,6 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
182
179
|
`${re}attaching to fixed block number, but redstone historicTimestamp is not set. price updates might fail`
|
|
183
180
|
);
|
|
184
181
|
}
|
|
185
|
-
if (!!blockNumber && !opts.pyth?.historicTimestamp) {
|
|
186
|
-
this.logger?.warn(
|
|
187
|
-
`${re}attaching to fixed block number, but pyth historicTimestamp is not set. price updates might fail`
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
182
|
this.#attachConfig = opts;
|
|
191
183
|
const time = Date.now();
|
|
192
184
|
const block = await this.client.getBlock(
|
|
@@ -196,7 +188,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
196
188
|
);
|
|
197
189
|
this.#currentBlock = block.number;
|
|
198
190
|
this.#timestamp = block.timestamp;
|
|
199
|
-
this.#priceFeeds = new PriceFeedRegister(this, { redstone
|
|
191
|
+
this.#priceFeeds = new PriceFeedRegister(this, { redstone });
|
|
200
192
|
this.logger?.debug(
|
|
201
193
|
`${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
|
|
202
194
|
);
|
|
@@ -246,8 +238,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
246
238
|
this.#currentBlock = state.currentBlock;
|
|
247
239
|
this.#timestamp = state.timestamp;
|
|
248
240
|
this.#priceFeeds = new PriceFeedRegister(this, {
|
|
249
|
-
redstone: opts.redstone
|
|
250
|
-
pyth: opts.pyth
|
|
241
|
+
redstone: opts.redstone
|
|
251
242
|
});
|
|
252
243
|
this.#addressProvider = hydrateAddressProvider(this, state.addressProvider);
|
|
253
244
|
this.logger?.debug(
|
|
@@ -300,8 +291,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
300
291
|
}
|
|
301
292
|
const opts = {
|
|
302
293
|
ignoreUpdateablePrices: this.#attachConfig.ignoreUpdateablePrices,
|
|
303
|
-
redstone: this.#attachConfig.redstone
|
|
304
|
-
pyth: this.#attachConfig.pyth
|
|
294
|
+
redstone: this.#attachConfig.redstone
|
|
305
295
|
};
|
|
306
296
|
this.#hydrate(opts, state);
|
|
307
297
|
await this.#hooks.triggerHooks("rehydrate", {
|
|
@@ -359,9 +349,9 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
359
349
|
timestamp,
|
|
360
350
|
ignoreUpdateablePrices = this.#attachConfig?.ignoreUpdateablePrices
|
|
361
351
|
} = opts ?? {};
|
|
362
|
-
if (this.#attachConfig?.redstone?.historicTimestamp
|
|
352
|
+
if (this.#attachConfig?.redstone?.historicTimestamp) {
|
|
363
353
|
throw new Error(
|
|
364
|
-
"syncState is not supported with redstone
|
|
354
|
+
"syncState is not supported with redstone historicTimestamp"
|
|
365
355
|
);
|
|
366
356
|
}
|
|
367
357
|
if (!blockNumber || !timestamp) {
|
|
@@ -27,7 +27,7 @@ import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
|
|
|
27
27
|
import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
|
|
28
28
|
import { PythPriceFeed } from "./PythPriceFeed.js";
|
|
29
29
|
import { RedstonePriceFeedContract } from "./RedstonePriceFeed.js";
|
|
30
|
-
import {
|
|
30
|
+
import { RedstoneUpdater } from "./updates/index.js";
|
|
31
31
|
import { WstETHPriceFeedContract } from "./WstETHPriceFeed.js";
|
|
32
32
|
import { YearnPriceFeedContract } from "./YearnPriceFeed.js";
|
|
33
33
|
import { ZeroPriceFeedContract } from "./ZeroPriceFeed.js";
|
|
@@ -38,10 +38,7 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
38
38
|
updaters;
|
|
39
39
|
constructor(sdk, opts = {}) {
|
|
40
40
|
super(sdk);
|
|
41
|
-
this.updaters = [
|
|
42
|
-
new RedstoneUpdater(sdk, opts?.redstone),
|
|
43
|
-
new PythUpdater(sdk, opts?.pyth)
|
|
44
|
-
];
|
|
41
|
+
this.updaters = [new RedstoneUpdater(sdk, opts?.redstone)];
|
|
45
42
|
}
|
|
46
43
|
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
47
44
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { decodeAbiParameters
|
|
1
|
+
import { decodeAbiParameters } from "viem";
|
|
2
2
|
import { pythPriceFeedAbi } from "../../abi/oracles.js";
|
|
3
3
|
import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
|
|
4
4
|
const abi = pythPriceFeedAbi;
|
|
5
|
-
const iPythAbi = parseAbi([
|
|
6
|
-
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
7
|
-
]);
|
|
8
5
|
class PythPriceFeed extends AbstractPriceFeedContract {
|
|
9
6
|
token;
|
|
10
7
|
priceFeedId;
|
|
@@ -13,6 +10,9 @@ class PythPriceFeed extends AbstractPriceFeedContract {
|
|
|
13
10
|
constructor(options, args) {
|
|
14
11
|
super(options, {
|
|
15
12
|
...args,
|
|
13
|
+
// the sdk does not push pyth price updates, so these feeds are never
|
|
14
|
+
// treated as updatable even though the contract implements the interface
|
|
15
|
+
updatable: false,
|
|
16
16
|
name: "PythPriceFeed",
|
|
17
17
|
abi
|
|
18
18
|
});
|
|
@@ -44,30 +44,6 @@ class PythPriceFeed extends AbstractPriceFeedContract {
|
|
|
44
44
|
this.pyth = decoded[2];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
createPriceUpdateTx(data) {
|
|
48
|
-
return this.createRawTx({
|
|
49
|
-
functionName: "updatePrice",
|
|
50
|
-
args: [data],
|
|
51
|
-
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
56
|
-
* @param calldata
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
getUpdateFeeParams(calldata) {
|
|
60
|
-
const [, updateData] = decodeAbiParameters(
|
|
61
|
-
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
62
|
-
calldata
|
|
63
|
-
);
|
|
64
|
-
return {
|
|
65
|
-
address: this.pyth,
|
|
66
|
-
abi: iPythAbi,
|
|
67
|
-
functionName: "getUpdateFee",
|
|
68
|
-
args: [updateData]
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
47
|
}
|
|
72
48
|
export {
|
|
73
49
|
PythPriceFeed
|
|
@@ -19,13 +19,11 @@ export * from "./PythPriceFeed.js";
|
|
|
19
19
|
export * from "./RedstonePriceFeed.js";
|
|
20
20
|
export * from "./types.js";
|
|
21
21
|
import {
|
|
22
|
-
fetchPythPayloads,
|
|
23
22
|
fetchRedstonePayloads
|
|
24
23
|
} from "./updates/index.js";
|
|
25
24
|
export * from "./WstETHPriceFeed.js";
|
|
26
25
|
export * from "./YearnPriceFeed.js";
|
|
27
26
|
export * from "./ZeroPriceFeed.js";
|
|
28
27
|
export {
|
|
29
|
-
fetchPythPayloads,
|
|
30
28
|
fetchRedstonePayloads
|
|
31
29
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export * from "./fetchPythPayloads.js";
|
|
2
1
|
export * from "./fetchRedstonePayloads.js";
|
|
3
|
-
import { PythOptions, PythUpdater } from "./PythUpdater.js";
|
|
4
2
|
import { RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
5
3
|
export {
|
|
6
|
-
PythOptions,
|
|
7
|
-
PythUpdater,
|
|
8
4
|
RedstoneOptions,
|
|
9
5
|
RedstoneUpdater
|
|
10
6
|
};
|
package/dist/esm/sdk/options.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
-
import {
|
|
3
|
-
PythOptions,
|
|
4
|
-
RedstoneOptions
|
|
5
|
-
} from "./market/pricefeeds/updates/index.js";
|
|
2
|
+
import { RedstoneOptions } from "./market/pricefeeds/updates/index.js";
|
|
6
3
|
import { ZodAddress } from "./utils/index.js";
|
|
7
4
|
const SDKOptions = z.object({
|
|
8
5
|
/**
|
|
@@ -42,10 +39,6 @@ const SDKOptions = z.object({
|
|
|
42
39
|
* Options related to redstone price feeds
|
|
43
40
|
*/
|
|
44
41
|
redstone: RedstoneOptions.optional(),
|
|
45
|
-
/**
|
|
46
|
-
* Options related to pyth price feeds
|
|
47
|
-
*/
|
|
48
|
-
pyth: PythOptions.optional(),
|
|
49
42
|
/**
|
|
50
43
|
* Explicit gas limit for read eth_calls
|
|
51
44
|
* Null to disable explicitly setting gas limit, undefined to use default sdk value
|
|
@@ -6,7 +6,7 @@ import type { RawTx } from "../../types/index.js";
|
|
|
6
6
|
import type { IHooks } from "../../utils/internal/index.js";
|
|
7
7
|
import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
8
8
|
import type { IPriceFeedContract, PriceUpdateV310, UpdatePriceFeedsResult } from "./types.js";
|
|
9
|
-
import type { IPriceUpdater, IPriceUpdateTask,
|
|
9
|
+
import type { IPriceUpdater, IPriceUpdateTask, RedstoneOptions } from "./updates/index.js";
|
|
10
10
|
export type PriceFeedRegisterHooks = {
|
|
11
11
|
/**
|
|
12
12
|
* Emitted when transactions to update price feeds have been generated, but before they're used anywhere
|
|
@@ -15,7 +15,6 @@ export type PriceFeedRegisterHooks = {
|
|
|
15
15
|
};
|
|
16
16
|
export interface PriceFeedRegisterOptions {
|
|
17
17
|
redstone?: RedstoneOptions;
|
|
18
|
-
pyth?: PythOptions;
|
|
19
18
|
}
|
|
20
19
|
export interface LatestUpdate {
|
|
21
20
|
timestamp: number;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { Address,
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/Construct.js";
|
|
3
|
-
import type { RawTx } from "../../types/index.js";
|
|
4
3
|
import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
5
4
|
import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
|
|
6
|
-
import type { IUpdatablePriceFeedContract } from "./types.js";
|
|
7
5
|
declare const abi: readonly [{
|
|
8
6
|
readonly type: "constructor";
|
|
9
7
|
readonly inputs: readonly [{
|
|
@@ -217,32 +215,11 @@ declare const abi: readonly [{
|
|
|
217
215
|
readonly inputs: readonly [];
|
|
218
216
|
}];
|
|
219
217
|
type abi = typeof abi;
|
|
220
|
-
declare
|
|
221
|
-
readonly name: "getUpdateFee";
|
|
222
|
-
readonly type: "function";
|
|
223
|
-
readonly stateMutability: "view";
|
|
224
|
-
readonly inputs: readonly [{
|
|
225
|
-
readonly type: "bytes[]";
|
|
226
|
-
readonly name: "updateData";
|
|
227
|
-
}];
|
|
228
|
-
readonly outputs: readonly [{
|
|
229
|
-
readonly type: "uint256";
|
|
230
|
-
readonly name: "feeAmount";
|
|
231
|
-
}];
|
|
232
|
-
}];
|
|
233
|
-
type iPythAbi = typeof iPythAbi;
|
|
234
|
-
export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implements IUpdatablePriceFeedContract {
|
|
218
|
+
export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> {
|
|
235
219
|
readonly token: Address;
|
|
236
220
|
readonly priceFeedId: Hex;
|
|
237
221
|
readonly pyth: Address;
|
|
238
222
|
readonly maxConfToPriceRatio?: bigint;
|
|
239
223
|
constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
|
|
240
|
-
createPriceUpdateTx(data: `0x${string}`): RawTx;
|
|
241
|
-
/**
|
|
242
|
-
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
243
|
-
* @param calldata
|
|
244
|
-
* @returns
|
|
245
|
-
*/
|
|
246
|
-
getUpdateFeeParams(calldata: Hex): ContractFunctionParameters<iPythAbi, "view", "getUpdateFee">;
|
|
247
224
|
}
|
|
248
225
|
export {};
|
|
@@ -18,7 +18,7 @@ export * from "./PriceFeedsRegister.js";
|
|
|
18
18
|
export * from "./PythPriceFeed.js";
|
|
19
19
|
export * from "./RedstonePriceFeed.js";
|
|
20
20
|
export * from "./types.js";
|
|
21
|
-
export { type
|
|
21
|
+
export { type FetchRedstonePayloadsOptions, fetchRedstonePayloads, type TimestampedCalldata, } from "./updates/index.js";
|
|
22
22
|
export * from "./WstETHPriceFeed.js";
|
|
23
23
|
export * from "./YearnPriceFeed.js";
|
|
24
24
|
export * from "./ZeroPriceFeed.js";
|
|
@@ -17,12 +17,6 @@ export declare const SDKOptions: z.ZodObject<{
|
|
|
17
17
|
ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
18
18
|
enableLogging: z.ZodOptional<z.ZodBoolean>;
|
|
19
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
20
|
gasLimit: z.ZodOptional<z.ZodNullable<z.ZodBigInt>>;
|
|
27
21
|
}, z.core.$strip>;
|
|
28
22
|
export type SDKOptions<Plugins extends PluginsMap> = Omit<z.infer<typeof SDKOptions>, "logger" | "plugins"> & {
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.10.0",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Gearbox-protocol/sdk.git"
|
|
9
|
+
},
|
|
6
10
|
"main": "./dist/cjs/sdk/index.js",
|
|
7
11
|
"module": "./dist/esm/sdk/index.js",
|
|
8
12
|
"types": "./dist/types/sdk/index.d.ts",
|
|
@@ -64,7 +68,6 @@
|
|
|
64
68
|
"@types/bn.js": "^5.2.0",
|
|
65
69
|
"abitype": "^1.2.3",
|
|
66
70
|
"bn.js": "^5.2.3",
|
|
67
|
-
"buffer": "^6.0.3",
|
|
68
71
|
"date-fns": "^4.1.0",
|
|
69
72
|
"decimal.js-light": "^2.5.1",
|
|
70
73
|
"viem": ">=2.23.15 <3.0.0",
|