@gearbox-protocol/sdk 8.1.0-next.2 → 8.1.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 -20
- package/dist/cjs/sdk/abi/oracles.js +0 -141
- package/dist/cjs/sdk/chain/chains.js +3 -0
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +1 -2
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +23 -17
- package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +1 -9
- package/dist/cjs/sdk/market/pricefeeds/{updates/PriceUpdatesCache.js → RedstoneCache.js} +12 -12
- package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +7 -9
- package/dist/cjs/sdk/market/pricefeeds/{updates/RedstoneUpdater.js → RedstoneUpdater.js} +45 -21
- package/dist/cjs/sdk/market/pricefeeds/index.js +0 -2
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/normal.js +5 -0
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/token.js +5 -0
- package/dist/cjs/sdk/sdk-legacy/apy/index.js +1 -0
- package/dist/cjs/sdk/utils/retry.js +2 -4
- package/dist/esm/sdk/GearboxSDK.js +8 -20
- package/dist/esm/sdk/abi/oracles.js +0 -140
- package/dist/esm/sdk/chain/chains.js +3 -0
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +1 -2
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +24 -18
- package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +1 -9
- package/dist/esm/sdk/market/pricefeeds/{updates/PriceUpdatesCache.js → RedstoneCache.js} +8 -8
- package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +5 -8
- package/dist/esm/sdk/market/pricefeeds/{updates/RedstoneUpdater.js → RedstoneUpdater.js} +44 -21
- package/dist/esm/sdk/market/pricefeeds/index.js +0 -1
- package/dist/esm/sdk/sdk-gov-legacy/tokens/normal.js +5 -0
- package/dist/esm/sdk/sdk-gov-legacy/tokens/token.js +5 -0
- package/dist/esm/sdk/sdk-legacy/apy/index.js +1 -0
- package/dist/esm/sdk/utils/retry.js +2 -4
- package/dist/types/sdk/GearboxSDK.d.ts +1 -5
- package/dist/types/sdk/abi/oracles.d.ts +0 -212
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +2 -2
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +4 -4
- package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +4 -218
- package/dist/types/sdk/market/pricefeeds/RedstoneCache.d.ts +25 -0
- package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +4 -4
- package/dist/types/sdk/market/pricefeeds/{updates/RedstoneUpdater.d.ts → RedstoneUpdater.d.ts} +18 -11
- package/dist/types/sdk/market/pricefeeds/index.d.ts +0 -1
- package/dist/types/sdk/market/pricefeeds/types.d.ts +2 -5
- package/dist/types/sdk/sdk-gov-legacy/tokens/normal.d.ts +1 -1
- package/dist/types/sdk/sdk-legacy/apy/index.d.ts +1 -1
- package/dist/types/sdk/utils/retry.d.ts +0 -1
- package/package.json +1 -4
- package/dist/cjs/sdk/market/pricefeeds/isUpdatablePriceFeed.js +0 -30
- package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdateTx.js +0 -52
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +0 -189
- package/dist/cjs/sdk/market/pricefeeds/updates/index.js +0 -31
- package/dist/cjs/sdk/market/pricefeeds/updates/types.js +0 -16
- package/dist/esm/sdk/market/pricefeeds/isUpdatablePriceFeed.js +0 -6
- package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdateTx.js +0 -28
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +0 -169
- package/dist/esm/sdk/market/pricefeeds/updates/index.js +0 -6
- package/dist/esm/sdk/market/pricefeeds/updates/types.js +0 -0
- package/dist/types/sdk/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -2
- package/dist/types/sdk/market/pricefeeds/updates/PriceUpdateTx.d.ts +0 -10
- package/dist/types/sdk/market/pricefeeds/updates/PriceUpdatesCache.d.ts +0 -17
- package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +0 -40
- package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.test.d.ts +0 -1
- package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +0 -3
- package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +0 -21
|
@@ -81,7 +81,6 @@ class GearboxSDK {
|
|
|
81
81
|
plugins,
|
|
82
82
|
blockNumber,
|
|
83
83
|
redstone,
|
|
84
|
-
pyth,
|
|
85
84
|
ignoreUpdateablePrices,
|
|
86
85
|
marketConfigurators: mcs,
|
|
87
86
|
strictContractTypes
|
|
@@ -115,8 +114,7 @@ class GearboxSDK {
|
|
|
115
114
|
blockNumber,
|
|
116
115
|
ignoreUpdateablePrices,
|
|
117
116
|
marketConfigurators,
|
|
118
|
-
redstone
|
|
119
|
-
pyth
|
|
117
|
+
redstone
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
120
|
static hydrate(options, state) {
|
|
@@ -148,8 +146,7 @@ class GearboxSDK {
|
|
|
148
146
|
blockNumber,
|
|
149
147
|
ignoreUpdateablePrices,
|
|
150
148
|
marketConfigurators,
|
|
151
|
-
redstone
|
|
152
|
-
pyth
|
|
149
|
+
redstone
|
|
153
150
|
} = opts;
|
|
154
151
|
const re = this.#attachConfig ? "re" : "";
|
|
155
152
|
this.logger?.info(
|
|
@@ -164,12 +161,7 @@ class GearboxSDK {
|
|
|
164
161
|
);
|
|
165
162
|
if (!!blockNumber && !opts.redstone?.historicTimestamp) {
|
|
166
163
|
this.logger?.warn(
|
|
167
|
-
`${re}attaching to fixed block number, but
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
if (!!blockNumber && !opts.pyth?.historicTimestamp) {
|
|
171
|
-
this.logger?.warn(
|
|
172
|
-
`${re}attaching to fixed block number, but pyth historicTimestamp is not set. price updates might fail`
|
|
164
|
+
`${re}attaching to fixed block number, but redstoneHistoricTimestamp is not set. price updates might fail`
|
|
173
165
|
);
|
|
174
166
|
}
|
|
175
167
|
this.#attachConfig = opts;
|
|
@@ -181,7 +173,7 @@ class GearboxSDK {
|
|
|
181
173
|
);
|
|
182
174
|
this.#currentBlock = block.number;
|
|
183
175
|
this.#timestamp = block.timestamp;
|
|
184
|
-
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone
|
|
176
|
+
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone });
|
|
185
177
|
this.logger?.debug(
|
|
186
178
|
`${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
|
|
187
179
|
);
|
|
@@ -232,10 +224,7 @@ class GearboxSDK {
|
|
|
232
224
|
);
|
|
233
225
|
this.#currentBlock = state.currentBlock;
|
|
234
226
|
this.#timestamp = state.timestamp;
|
|
235
|
-
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, {
|
|
236
|
-
redstone: opts.redstone,
|
|
237
|
-
pyth: opts.pyth
|
|
238
|
-
});
|
|
227
|
+
this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone: opts.redstone });
|
|
239
228
|
this.#addressProvider = (0, import_core.hydrateAddressProvider)(this, state.addressProvider);
|
|
240
229
|
this.logger?.debug(
|
|
241
230
|
`address provider version: ${this.#addressProvider.version}`
|
|
@@ -287,8 +276,7 @@ class GearboxSDK {
|
|
|
287
276
|
}
|
|
288
277
|
const opts = {
|
|
289
278
|
ignoreUpdateablePrices: this.#attachConfig.ignoreUpdateablePrices,
|
|
290
|
-
redstone: this.#attachConfig.redstone
|
|
291
|
-
pyth: this.#attachConfig.pyth
|
|
279
|
+
redstone: this.#attachConfig.redstone
|
|
292
280
|
};
|
|
293
281
|
this.#hydrate(opts, state);
|
|
294
282
|
await this.#hooks.triggerHooks("rehydrate", {
|
|
@@ -387,9 +375,9 @@ class GearboxSDK {
|
|
|
387
375
|
*/
|
|
388
376
|
async syncState(opts) {
|
|
389
377
|
let { blockNumber, timestamp, skipPriceUpdate } = opts ?? {};
|
|
390
|
-
if (this.#attachConfig?.redstone?.historicTimestamp
|
|
378
|
+
if (this.#attachConfig?.redstone?.historicTimestamp) {
|
|
391
379
|
throw new Error(
|
|
392
|
-
"syncState is not supported with
|
|
380
|
+
"syncState is not supported with redstoneHistoricTimestamp"
|
|
393
381
|
);
|
|
394
382
|
}
|
|
395
383
|
if (!blockNumber || !timestamp) {
|
|
@@ -38,7 +38,6 @@ __export(oracles_exports, {
|
|
|
38
38
|
iyVaultAbi: () => iyVaultAbi,
|
|
39
39
|
mellowLrtPriceFeedAbi: () => mellowLrtPriceFeedAbi,
|
|
40
40
|
pendleTWAPPTPriceFeedAbi: () => pendleTWAPPTPriceFeedAbi,
|
|
41
|
-
pythPriceFeedAbi: () => pythPriceFeedAbi,
|
|
42
41
|
redstonePriceFeedAbi: () => redstonePriceFeedAbi,
|
|
43
42
|
wstEthPriceFeedAbi: () => wstEthPriceFeedAbi,
|
|
44
43
|
yearnPriceFeedAbi: () => yearnPriceFeedAbi,
|
|
@@ -4544,145 +4543,6 @@ const pendleTWAPPTPriceFeedAbi = [
|
|
|
4544
4543
|
inputs: []
|
|
4545
4544
|
}
|
|
4546
4545
|
];
|
|
4547
|
-
const pythPriceFeedAbi = [
|
|
4548
|
-
{
|
|
4549
|
-
type: "constructor",
|
|
4550
|
-
inputs: [
|
|
4551
|
-
{ name: "_token", type: "address", internalType: "address" },
|
|
4552
|
-
{ name: "_priceFeedId", type: "bytes32", internalType: "bytes32" },
|
|
4553
|
-
{ name: "_pyth", type: "address", internalType: "address" },
|
|
4554
|
-
{
|
|
4555
|
-
name: "_maxConfToPriceRatio",
|
|
4556
|
-
type: "uint256",
|
|
4557
|
-
internalType: "uint256"
|
|
4558
|
-
},
|
|
4559
|
-
{ name: "descriptionTicker", type: "string", internalType: "string" }
|
|
4560
|
-
],
|
|
4561
|
-
stateMutability: "nonpayable"
|
|
4562
|
-
},
|
|
4563
|
-
{ type: "receive", stateMutability: "payable" },
|
|
4564
|
-
{
|
|
4565
|
-
type: "function",
|
|
4566
|
-
name: "contractType",
|
|
4567
|
-
inputs: [],
|
|
4568
|
-
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
4569
|
-
stateMutability: "view"
|
|
4570
|
-
},
|
|
4571
|
-
{
|
|
4572
|
-
type: "function",
|
|
4573
|
-
name: "decimals",
|
|
4574
|
-
inputs: [],
|
|
4575
|
-
outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
|
|
4576
|
-
stateMutability: "view"
|
|
4577
|
-
},
|
|
4578
|
-
{
|
|
4579
|
-
type: "function",
|
|
4580
|
-
name: "description",
|
|
4581
|
-
inputs: [],
|
|
4582
|
-
outputs: [{ name: "", type: "string", internalType: "string" }],
|
|
4583
|
-
stateMutability: "view"
|
|
4584
|
-
},
|
|
4585
|
-
{
|
|
4586
|
-
type: "function",
|
|
4587
|
-
name: "latestRoundData",
|
|
4588
|
-
inputs: [],
|
|
4589
|
-
outputs: [
|
|
4590
|
-
{ name: "", type: "uint80", internalType: "uint80" },
|
|
4591
|
-
{ name: "", type: "int256", internalType: "int256" },
|
|
4592
|
-
{ name: "", type: "uint256", internalType: "uint256" },
|
|
4593
|
-
{ name: "", type: "uint256", internalType: "uint256" },
|
|
4594
|
-
{ name: "", type: "uint80", internalType: "uint80" }
|
|
4595
|
-
],
|
|
4596
|
-
stateMutability: "view"
|
|
4597
|
-
},
|
|
4598
|
-
{
|
|
4599
|
-
type: "function",
|
|
4600
|
-
name: "maxConfToPriceRatio",
|
|
4601
|
-
inputs: [],
|
|
4602
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
4603
|
-
stateMutability: "view"
|
|
4604
|
-
},
|
|
4605
|
-
{
|
|
4606
|
-
type: "function",
|
|
4607
|
-
name: "priceFeedId",
|
|
4608
|
-
inputs: [],
|
|
4609
|
-
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
4610
|
-
stateMutability: "view"
|
|
4611
|
-
},
|
|
4612
|
-
{
|
|
4613
|
-
type: "function",
|
|
4614
|
-
name: "pyth",
|
|
4615
|
-
inputs: [],
|
|
4616
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
4617
|
-
stateMutability: "view"
|
|
4618
|
-
},
|
|
4619
|
-
{
|
|
4620
|
-
type: "function",
|
|
4621
|
-
name: "serialize",
|
|
4622
|
-
inputs: [],
|
|
4623
|
-
outputs: [{ name: "", type: "bytes", internalType: "bytes" }],
|
|
4624
|
-
stateMutability: "view"
|
|
4625
|
-
},
|
|
4626
|
-
{
|
|
4627
|
-
type: "function",
|
|
4628
|
-
name: "skipPriceCheck",
|
|
4629
|
-
inputs: [],
|
|
4630
|
-
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
4631
|
-
stateMutability: "view"
|
|
4632
|
-
},
|
|
4633
|
-
{
|
|
4634
|
-
type: "function",
|
|
4635
|
-
name: "token",
|
|
4636
|
-
inputs: [],
|
|
4637
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
4638
|
-
stateMutability: "view"
|
|
4639
|
-
},
|
|
4640
|
-
{
|
|
4641
|
-
type: "function",
|
|
4642
|
-
name: "updatable",
|
|
4643
|
-
inputs: [],
|
|
4644
|
-
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
4645
|
-
stateMutability: "view"
|
|
4646
|
-
},
|
|
4647
|
-
{
|
|
4648
|
-
type: "function",
|
|
4649
|
-
name: "updatePrice",
|
|
4650
|
-
inputs: [{ name: "data", type: "bytes", internalType: "bytes" }],
|
|
4651
|
-
outputs: [],
|
|
4652
|
-
stateMutability: "nonpayable"
|
|
4653
|
-
},
|
|
4654
|
-
{
|
|
4655
|
-
type: "function",
|
|
4656
|
-
name: "version",
|
|
4657
|
-
inputs: [],
|
|
4658
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
4659
|
-
stateMutability: "view"
|
|
4660
|
-
},
|
|
4661
|
-
{
|
|
4662
|
-
type: "event",
|
|
4663
|
-
name: "UpdatePrice",
|
|
4664
|
-
inputs: [
|
|
4665
|
-
{
|
|
4666
|
-
name: "price",
|
|
4667
|
-
type: "uint256",
|
|
4668
|
-
indexed: false,
|
|
4669
|
-
internalType: "uint256"
|
|
4670
|
-
}
|
|
4671
|
-
],
|
|
4672
|
-
anonymous: false
|
|
4673
|
-
},
|
|
4674
|
-
{ type: "error", name: "ConfToPriceRatioTooHighException", inputs: [] },
|
|
4675
|
-
{
|
|
4676
|
-
type: "error",
|
|
4677
|
-
name: "IncorrectExpectedPublishTimestampException",
|
|
4678
|
-
inputs: []
|
|
4679
|
-
},
|
|
4680
|
-
{ type: "error", name: "IncorrectParameterException", inputs: [] },
|
|
4681
|
-
{ type: "error", name: "IncorrectPriceDecimalsException", inputs: [] },
|
|
4682
|
-
{ type: "error", name: "IncorrectPriceException", inputs: [] },
|
|
4683
|
-
{ type: "error", name: "PriceTimestampTooFarAheadException", inputs: [] },
|
|
4684
|
-
{ type: "error", name: "PriceTimestampTooFarBehindException", inputs: [] }
|
|
4685
|
-
];
|
|
4686
4546
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4687
4547
|
0 && (module.exports = {
|
|
4688
4548
|
boundedPriceFeedAbi,
|
|
@@ -4705,7 +4565,6 @@ const pythPriceFeedAbi = [
|
|
|
4705
4565
|
iyVaultAbi,
|
|
4706
4566
|
mellowLrtPriceFeedAbi,
|
|
4707
4567
|
pendleTWAPPTPriceFeedAbi,
|
|
4708
|
-
pythPriceFeedAbi,
|
|
4709
4568
|
redstonePriceFeedAbi,
|
|
4710
4569
|
wstEthPriceFeedAbi,
|
|
4711
4570
|
yearnPriceFeedAbi,
|
|
@@ -66,6 +66,9 @@ const chains = {
|
|
|
66
66
|
"0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs",
|
|
67
67
|
"0x4d427D418342d8CE89a7634c3a402851978B680A": "K3"
|
|
68
68
|
},
|
|
69
|
+
testMarketConfigurators: {
|
|
70
|
+
"0xc168343c791d56dd1da4b4b8b0cc1c1ec1a16e6b": "cp0x"
|
|
71
|
+
},
|
|
69
72
|
isPublic: true,
|
|
70
73
|
wellKnownToken: {
|
|
71
74
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -24,7 +24,6 @@ __export(AbstractPriceFeed_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(AbstractPriceFeed_exports);
|
|
25
25
|
var import_abi = require("../../abi/index.js");
|
|
26
26
|
var import_base = require("../../base/index.js");
|
|
27
|
-
var import_isUpdatablePriceFeed = require("./isUpdatablePriceFeed.js");
|
|
28
27
|
var import_PriceFeedRef = require("./PriceFeedRef.js");
|
|
29
28
|
class PartialPriceFeedInitError extends Error {
|
|
30
29
|
priceFeed;
|
|
@@ -129,7 +128,7 @@ class AbstractPriceFeedContract extends import_base.BaseContract {
|
|
|
129
128
|
const underlying = this.underlyingPriceFeeds.flatMap(
|
|
130
129
|
(f) => f.priceFeed.updatableDependencies()
|
|
131
130
|
);
|
|
132
|
-
return
|
|
131
|
+
return this.updatable ? [this, ...underlying] : underlying;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -40,7 +40,7 @@ var import_MellowLRTPriceFeed = require("./MellowLRTPriceFeed.js");
|
|
|
40
40
|
var import_PendleTWAPPTPriceFeed = require("./PendleTWAPPTPriceFeed.js");
|
|
41
41
|
var import_PythPriceFeed = require("./PythPriceFeed.js");
|
|
42
42
|
var import_RedstonePriceFeed = require("./RedstonePriceFeed.js");
|
|
43
|
-
var
|
|
43
|
+
var import_RedstoneUpdater = require("./RedstoneUpdater.js");
|
|
44
44
|
var import_WstETHPriceFeed = require("./WstETHPriceFeed.js");
|
|
45
45
|
var import_YearnPriceFeed = require("./YearnPriceFeed.js");
|
|
46
46
|
var import_ZeroPriceFeed = require("./ZeroPriceFeed.js");
|
|
@@ -49,14 +49,11 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
49
49
|
#hooks = new import_internal.Hooks();
|
|
50
50
|
#feeds = new import_utils.AddressMap(void 0, "priceFeeds");
|
|
51
51
|
#latestUpdate;
|
|
52
|
-
|
|
52
|
+
redstoneUpdater;
|
|
53
53
|
constructor(sdk, opts = {}) {
|
|
54
54
|
super(sdk);
|
|
55
55
|
this.logger = (0, import_utils.childLogger)("PriceFeedRegister", sdk.logger);
|
|
56
|
-
this.
|
|
57
|
-
new import_updates.RedstoneUpdater(sdk, opts?.redstone),
|
|
58
|
-
new import_updates.PythUpdater(sdk, opts?.pyth)
|
|
59
|
-
];
|
|
56
|
+
this.redstoneUpdater = new import_RedstoneUpdater.RedstoneUpdater(sdk, opts?.redstone);
|
|
60
57
|
}
|
|
61
58
|
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
62
59
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
@@ -69,22 +66,31 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
69
66
|
async generatePriceFeedsUpdateTxs(priceFeeds, logContext = {}) {
|
|
70
67
|
const updateables = priceFeeds ? priceFeeds.flatMap((pf) => pf.updatableDependencies()) : this.#feeds.values();
|
|
71
68
|
const txs = [];
|
|
69
|
+
const redstonePFs = [];
|
|
72
70
|
const latestUpdate = {
|
|
73
|
-
|
|
71
|
+
redstone: [],
|
|
74
72
|
timestamp: Math.floor(Date.now() / 1e3)
|
|
75
73
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
for (const pf of updateables) {
|
|
75
|
+
if ((0, import_RedstonePriceFeed.isRedstone)(pf)) {
|
|
76
|
+
redstonePFs.push(pf);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
79
|
let maxTimestamp = 0;
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if (redstonePFs.length > 0) {
|
|
81
|
+
const redstoneUpdates = await this.redstoneUpdater.getUpdateTxs(
|
|
82
|
+
redstonePFs,
|
|
83
|
+
logContext
|
|
84
|
+
);
|
|
85
|
+
for (const tx of redstoneUpdates) {
|
|
86
|
+
const { data } = tx;
|
|
87
|
+
const { timestamp } = data;
|
|
88
|
+
if (timestamp > maxTimestamp) {
|
|
89
|
+
maxTimestamp = timestamp;
|
|
90
|
+
}
|
|
91
|
+
txs.push(tx);
|
|
92
|
+
latestUpdate.redstone.push(data);
|
|
85
93
|
}
|
|
86
|
-
txs.push(tx);
|
|
87
|
-
latestUpdate.updates.push(data);
|
|
88
94
|
}
|
|
89
95
|
const result = { txs, timestamp: maxTimestamp };
|
|
90
96
|
const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
@@ -22,9 +22,8 @@ __export(PythPriceFeed_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PythPriceFeed_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
|
-
var import_oracles = require("../../abi/oracles.js");
|
|
26
25
|
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
27
|
-
const abi =
|
|
26
|
+
const abi = [];
|
|
28
27
|
class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
29
28
|
token;
|
|
30
29
|
priceFeedId;
|
|
@@ -64,13 +63,6 @@ class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
|
64
63
|
this.pyth = decoded[2];
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
|
-
createPriceUpdateTx(data) {
|
|
68
|
-
return this.createRawTx({
|
|
69
|
-
functionName: "updatePrice",
|
|
70
|
-
args: [data],
|
|
71
|
-
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
66
|
}
|
|
75
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
68
|
0 && (module.exports = {
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var RedstoneCache_exports = {};
|
|
20
|
+
__export(RedstoneCache_exports, {
|
|
21
|
+
RedstoneCache: () => RedstoneCache
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
class
|
|
23
|
+
module.exports = __toCommonJS(RedstoneCache_exports);
|
|
24
|
+
class RedstoneCache {
|
|
25
25
|
#cache = /* @__PURE__ */ new Map();
|
|
26
26
|
#ttlMs;
|
|
27
27
|
#historical;
|
|
@@ -29,8 +29,8 @@ class PriceUpdatesCache {
|
|
|
29
29
|
this.#ttlMs = opts.ttl;
|
|
30
30
|
this.#historical = opts.historical;
|
|
31
31
|
}
|
|
32
|
-
get(
|
|
33
|
-
const key = this.#cacheKey(
|
|
32
|
+
get(dataServiceId, dataFeedId, uniqueSignersCount) {
|
|
33
|
+
const key = this.#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount);
|
|
34
34
|
const data = this.#cache.get(key);
|
|
35
35
|
if (!data) {
|
|
36
36
|
return void 0;
|
|
@@ -41,8 +41,8 @@ class PriceUpdatesCache {
|
|
|
41
41
|
}
|
|
42
42
|
return data;
|
|
43
43
|
}
|
|
44
|
-
set(
|
|
45
|
-
const key = this.#cacheKey(
|
|
44
|
+
set(dataServiceId, dataFeedId, uniqueSignersCount, value) {
|
|
45
|
+
const key = this.#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount);
|
|
46
46
|
this.#cache.set(key, value);
|
|
47
47
|
}
|
|
48
48
|
#expired(value) {
|
|
@@ -51,11 +51,11 @@ class PriceUpdatesCache {
|
|
|
51
51
|
}
|
|
52
52
|
return value.timestamp * 1e3 + this.#ttlMs < Date.now();
|
|
53
53
|
}
|
|
54
|
-
#cacheKey(
|
|
55
|
-
return
|
|
54
|
+
#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount) {
|
|
55
|
+
return `${dataServiceId}:${dataFeedId}:${uniqueSignersCount}`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
59
|
0 && (module.exports = {
|
|
60
|
-
|
|
60
|
+
RedstoneCache
|
|
61
61
|
});
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var RedstonePriceFeed_exports = {};
|
|
20
20
|
__export(RedstonePriceFeed_exports, {
|
|
21
|
-
RedstonePriceFeedContract: () => RedstonePriceFeedContract
|
|
21
|
+
RedstonePriceFeedContract: () => RedstonePriceFeedContract,
|
|
22
|
+
isRedstone: () => isRedstone
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(RedstonePriceFeed_exports);
|
|
24
25
|
var import_viem = require("viem");
|
|
@@ -98,15 +99,12 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
98
99
|
lastPayloadTimestamp: this.lastPayloadTimestamp.toString()
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
args: [data],
|
|
105
|
-
description: `updating redstone price for ${this.dataId} [${this.labelAddress(this.address)}]`
|
|
106
|
-
});
|
|
107
|
-
}
|
|
102
|
+
}
|
|
103
|
+
function isRedstone(pf) {
|
|
104
|
+
return pf.contractType === "PRICE_FEED::REDSTONE";
|
|
108
105
|
}
|
|
109
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
107
|
0 && (module.exports = {
|
|
111
|
-
RedstonePriceFeedContract
|
|
108
|
+
RedstonePriceFeedContract,
|
|
109
|
+
isRedstone
|
|
112
110
|
});
|
|
@@ -18,18 +18,40 @@ 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
|
+
RedstoneUpdateTx: () => RedstoneUpdateTx,
|
|
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");
|
|
27
|
-
var import_base = require("
|
|
28
|
-
var import_utils = require("
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
var import_base = require("../../base/index.js");
|
|
29
|
+
var import_utils = require("../../utils/index.js");
|
|
30
|
+
var import_RedstoneCache = require("./RedstoneCache.js");
|
|
31
|
+
const MAX_DATA_TIMESTAMP_DELAY_SECONDS = 10n * 60n;
|
|
32
|
+
const MAX_DATA_TIMESTAMP_AHEAD_SECONDS = 60n;
|
|
33
|
+
class RedstoneUpdateTx {
|
|
34
|
+
raw;
|
|
35
|
+
data;
|
|
36
|
+
constructor(raw, data) {
|
|
37
|
+
this.raw = raw;
|
|
38
|
+
this.data = data;
|
|
39
|
+
}
|
|
40
|
+
get pretty() {
|
|
41
|
+
const cached = this.data.cached ? " (cached)" : "";
|
|
42
|
+
return `redstone feed ${this.data.dataFeedId} at ${this.data.priceFeed} with timestamp ${this.data.timestamp}${cached}`;
|
|
43
|
+
}
|
|
44
|
+
validateTimestamp(blockTimestamp) {
|
|
45
|
+
const { timestamp: expectedPayloadTimestamp } = this.data;
|
|
46
|
+
if (blockTimestamp < expectedPayloadTimestamp) {
|
|
47
|
+
if (BigInt(expectedPayloadTimestamp) - blockTimestamp > MAX_DATA_TIMESTAMP_AHEAD_SECONDS) {
|
|
48
|
+
return "in future";
|
|
49
|
+
}
|
|
50
|
+
} else if (blockTimestamp - BigInt(expectedPayloadTimestamp) > MAX_DATA_TIMESTAMP_DELAY_SECONDS) {
|
|
51
|
+
return "too old";
|
|
52
|
+
}
|
|
53
|
+
return "valid";
|
|
54
|
+
}
|
|
33
55
|
}
|
|
34
56
|
class RedstoneUpdater extends import_base.SDKConstruct {
|
|
35
57
|
#logger;
|
|
@@ -49,7 +71,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
49
71
|
ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
|
|
50
72
|
this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
|
|
51
73
|
}
|
|
52
|
-
this.#cache = new
|
|
74
|
+
this.#cache = new import_RedstoneCache.RedstoneCache({
|
|
53
75
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
54
76
|
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
55
77
|
// so it's unlikely to decrease
|
|
@@ -65,9 +87,6 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
65
87
|
const groupedFeeds = {};
|
|
66
88
|
const priceFeeds = /* @__PURE__ */ new Map();
|
|
67
89
|
for (const feed of feeds) {
|
|
68
|
-
if (!isRedstone(feed)) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
90
|
const key = `${feed.dataServiceId}:${feed.signersThreshold}`;
|
|
72
91
|
if (!groupedFeeds[key]) {
|
|
73
92
|
groupedFeeds[key] = /* @__PURE__ */ new Set();
|
|
@@ -93,13 +112,20 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
93
112
|
}
|
|
94
113
|
for (const priceFeed of pfsForDataId.values()) {
|
|
95
114
|
results.push(
|
|
96
|
-
new RedstoneUpdateTx(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
new RedstoneUpdateTx(
|
|
116
|
+
priceFeed.createRawTx({
|
|
117
|
+
functionName: "updatePrice",
|
|
118
|
+
args: [data],
|
|
119
|
+
description: `updating price for ${dataFeedId} [${this.labelAddress(priceFeed.address)}]`
|
|
120
|
+
}),
|
|
121
|
+
{
|
|
122
|
+
dataFeedId,
|
|
123
|
+
dataServiceId,
|
|
124
|
+
priceFeed: priceFeed.address,
|
|
125
|
+
timestamp,
|
|
126
|
+
cached
|
|
127
|
+
}
|
|
128
|
+
)
|
|
103
129
|
);
|
|
104
130
|
}
|
|
105
131
|
}
|
|
@@ -142,7 +168,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
142
168
|
uniqueSignersCount
|
|
143
169
|
);
|
|
144
170
|
for (const resp of fromRedstone) {
|
|
145
|
-
this.#cache.set(
|
|
171
|
+
this.#cache.set(dataServiceId, resp.dataFeedId, uniqueSignersCount, resp);
|
|
146
172
|
}
|
|
147
173
|
this.#logger?.debug(
|
|
148
174
|
`got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`
|
|
@@ -243,10 +269,8 @@ function getCalldataWithTimestamp(dataFeedId, packages, unsignedMetadata) {
|
|
|
243
269
|
cached: false
|
|
244
270
|
};
|
|
245
271
|
}
|
|
246
|
-
function isRedstone(pf) {
|
|
247
|
-
return pf.contractType === "PRICE_FEED::REDSTONE";
|
|
248
|
-
}
|
|
249
272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
250
273
|
0 && (module.exports = {
|
|
274
|
+
RedstoneUpdateTx,
|
|
251
275
|
RedstoneUpdater
|
|
252
276
|
});
|
|
@@ -25,7 +25,6 @@ __reExport(pricefeeds_exports, require("./CurveStablePriceFeed.js"), module.expo
|
|
|
25
25
|
__reExport(pricefeeds_exports, require("./CurveUSDPriceFeed.js"), module.exports);
|
|
26
26
|
__reExport(pricefeeds_exports, require("./Erc4626PriceFeed.js"), module.exports);
|
|
27
27
|
__reExport(pricefeeds_exports, require("./ExternalPriceFeed.js"), module.exports);
|
|
28
|
-
__reExport(pricefeeds_exports, require("./isUpdatablePriceFeed.js"), module.exports);
|
|
29
28
|
__reExport(pricefeeds_exports, require("./MellowLRTPriceFeed.js"), module.exports);
|
|
30
29
|
__reExport(pricefeeds_exports, require("./PendleTWAPPTPriceFeed.js"), module.exports);
|
|
31
30
|
__reExport(pricefeeds_exports, require("./PriceFeedRef.js"), module.exports);
|
|
@@ -48,7 +47,6 @@ __reExport(pricefeeds_exports, require("./ZeroPriceFeed.js"), module.exports);
|
|
|
48
47
|
...require("./CurveUSDPriceFeed.js"),
|
|
49
48
|
...require("./Erc4626PriceFeed.js"),
|
|
50
49
|
...require("./ExternalPriceFeed.js"),
|
|
51
|
-
...require("./isUpdatablePriceFeed.js"),
|
|
52
50
|
...require("./MellowLRTPriceFeed.js"),
|
|
53
51
|
...require("./PendleTWAPPTPriceFeed.js"),
|
|
54
52
|
...require("./PriceFeedRef.js"),
|
|
@@ -485,6 +485,11 @@ const normalTokens = {
|
|
|
485
485
|
name: "USDX",
|
|
486
486
|
symbol: "USDX",
|
|
487
487
|
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
488
|
+
},
|
|
489
|
+
cp0xLRT: {
|
|
490
|
+
name: "cp0xLRT",
|
|
491
|
+
symbol: "cp0xLRT",
|
|
492
|
+
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
488
493
|
}
|
|
489
494
|
};
|
|
490
495
|
const isNormalToken = (t) => typeof t === "string" && !!normalTokens[t];
|
|
@@ -359,6 +359,7 @@ const tokenDataByNetwork = {
|
|
|
359
359
|
pzETH: "0x8c9532a60E0E7C6BbD2B2c1303F63aCE1c3E9811",
|
|
360
360
|
DVstETH: "0x5E362eb2c0706Bd1d134689eC75176018385430B",
|
|
361
361
|
waEthLidowstETH: "0x775F661b0bD1739349b9A2A3EF60be277c5d2D29",
|
|
362
|
+
cp0xLRT: "0xB908c9FE885369643adB5FBA4407d52bD726c72d",
|
|
362
363
|
BTCB: import_constants.NOT_DEPLOYED,
|
|
363
364
|
WBNB: import_constants.NOT_DEPLOYED,
|
|
364
365
|
dUSDTv310: import_constants.NOT_DEPLOYED,
|
|
@@ -676,6 +677,7 @@ const tokenDataByNetwork = {
|
|
|
676
677
|
pzETH: import_constants.NOT_DEPLOYED,
|
|
677
678
|
DVstETH: import_constants.NOT_DEPLOYED,
|
|
678
679
|
waEthLidowstETH: import_constants.NOT_DEPLOYED,
|
|
680
|
+
cp0xLRT: import_constants.NOT_DEPLOYED,
|
|
679
681
|
BTCB: import_constants.NOT_DEPLOYED,
|
|
680
682
|
WBNB: import_constants.NOT_DEPLOYED,
|
|
681
683
|
dUSDTv310: import_constants.NOT_DEPLOYED,
|
|
@@ -993,6 +995,7 @@ const tokenDataByNetwork = {
|
|
|
993
995
|
pzETH: import_constants.NOT_DEPLOYED,
|
|
994
996
|
DVstETH: import_constants.NOT_DEPLOYED,
|
|
995
997
|
waEthLidowstETH: import_constants.NOT_DEPLOYED,
|
|
998
|
+
cp0xLRT: import_constants.NOT_DEPLOYED,
|
|
996
999
|
BTCB: import_constants.NOT_DEPLOYED,
|
|
997
1000
|
WBNB: import_constants.NOT_DEPLOYED,
|
|
998
1001
|
dUSDTv310: import_constants.NOT_DEPLOYED,
|
|
@@ -1309,6 +1312,7 @@ const tokenDataByNetwork = {
|
|
|
1309
1312
|
pzETH: import_constants.NOT_DEPLOYED,
|
|
1310
1313
|
DVstETH: import_constants.NOT_DEPLOYED,
|
|
1311
1314
|
waEthLidowstETH: import_constants.NOT_DEPLOYED,
|
|
1315
|
+
cp0xLRT: import_constants.NOT_DEPLOYED,
|
|
1312
1316
|
BTCB: import_constants.NOT_DEPLOYED,
|
|
1313
1317
|
WBNB: import_constants.NOT_DEPLOYED,
|
|
1314
1318
|
dUSDTv310: import_constants.NOT_DEPLOYED,
|
|
@@ -1625,6 +1629,7 @@ const tokenDataByNetwork = {
|
|
|
1625
1629
|
pzETH: import_constants.NOT_DEPLOYED,
|
|
1626
1630
|
DVstETH: import_constants.NOT_DEPLOYED,
|
|
1627
1631
|
waEthLidowstETH: import_constants.NOT_DEPLOYED,
|
|
1632
|
+
cp0xLRT: import_constants.NOT_DEPLOYED,
|
|
1628
1633
|
BTCB: import_constants.NOT_DEPLOYED,
|
|
1629
1634
|
WBNB: import_constants.NOT_DEPLOYED,
|
|
1630
1635
|
dUSDTv310: import_constants.NOT_DEPLOYED,
|
|
@@ -22,8 +22,7 @@ __export(retry_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(retry_exports);
|
|
24
24
|
async function retry(fn, options = {}) {
|
|
25
|
-
const { attempts = 3, interval = 200
|
|
26
|
-
let wait = interval;
|
|
25
|
+
const { attempts = 3, interval = 200 } = options;
|
|
27
26
|
let cause;
|
|
28
27
|
for (let i = 0; i < attempts; i++) {
|
|
29
28
|
try {
|
|
@@ -32,9 +31,8 @@ async function retry(fn, options = {}) {
|
|
|
32
31
|
} catch (e) {
|
|
33
32
|
cause = e;
|
|
34
33
|
await new Promise((resolve) => {
|
|
35
|
-
setTimeout(resolve,
|
|
34
|
+
setTimeout(resolve, interval);
|
|
36
35
|
});
|
|
37
|
-
wait = wait * exponent;
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
throw new Error(`all attempts failed: ${cause}`);
|