@gearbox-protocol/sdk 8.26.3 → 8.26.5
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/market/pricefeeds/updates/PythUpdater.js +21 -9
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +10 -1
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +21 -9
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +10 -1
- package/package.json +1 -1
|
@@ -91,22 +91,34 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
91
91
|
feeds.filter(isPyth).map((f) => [f.priceFeedId, f])
|
|
92
92
|
);
|
|
93
93
|
const payloads = await this.#getPayloads(new Set(pythFeeds.keys()));
|
|
94
|
-
|
|
94
|
+
let [minTimestamp, maxTimestamp] = [Number.POSITIVE_INFINITY, 0];
|
|
95
|
+
const results = [];
|
|
96
|
+
for (const p of payloads) {
|
|
95
97
|
const priceFeed = pythFeeds.get(p.dataFeedId);
|
|
96
98
|
if (!priceFeed) {
|
|
97
99
|
throw new Error(`cannot find price feed for ${p.dataFeedId}`);
|
|
98
100
|
}
|
|
99
101
|
const { dataFeedId, timestamp, cached, data } = p;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
minTimestamp = Math.min(minTimestamp, timestamp);
|
|
103
|
+
maxTimestamp = Math.max(maxTimestamp, timestamp);
|
|
104
|
+
results.push(
|
|
105
|
+
new PythUpdateTx(priceFeed.createPriceUpdateTx(data), {
|
|
106
|
+
dataFeedId,
|
|
107
|
+
priceFeed: priceFeed.address,
|
|
108
|
+
timestamp,
|
|
109
|
+
cached
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
let tsRange = "";
|
|
114
|
+
if (results.length) {
|
|
115
|
+
const minDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
116
|
+
const maxDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
117
|
+
tsRange = `, timestamps ${minTimestamp} (${minDelta}) - ${maxTimestamp} (${maxDelta})`;
|
|
118
|
+
}
|
|
107
119
|
this.#logger?.debug(
|
|
108
120
|
logContext,
|
|
109
|
-
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}`
|
|
121
|
+
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}${tsRange}`
|
|
110
122
|
);
|
|
111
123
|
return results;
|
|
112
124
|
}
|
|
@@ -109,6 +109,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
109
109
|
priceFeeds.set(feed.dataId, pfsForDataId);
|
|
110
110
|
}
|
|
111
111
|
const results = [];
|
|
112
|
+
let [minTimestamp, maxTimestamp] = [Number.POSITIVE_INFINITY, 0];
|
|
112
113
|
for (const [key, group] of Object.entries(groupedFeeds)) {
|
|
113
114
|
const [dataServiceId, signersStr] = key.split(":");
|
|
114
115
|
const uniqueSignersCount = parseInt(signersStr, 10);
|
|
@@ -123,6 +124,8 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
123
124
|
throw new Error(`cannot get price feed addresses for ${dataFeedId}`);
|
|
124
125
|
}
|
|
125
126
|
for (const priceFeed of pfsForDataId.values()) {
|
|
127
|
+
minTimestamp = Math.min(minTimestamp, timestamp);
|
|
128
|
+
maxTimestamp = Math.max(maxTimestamp, timestamp);
|
|
126
129
|
results.push(
|
|
127
130
|
new RedstoneUpdateTx(priceFeed.createPriceUpdateTx(data), {
|
|
128
131
|
dataFeedId,
|
|
@@ -135,9 +138,15 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
}
|
|
141
|
+
let tsRange = "";
|
|
142
|
+
if (results.length) {
|
|
143
|
+
const minDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
144
|
+
const maxDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
145
|
+
tsRange = `, timestamps ${minTimestamp} (${minDelta}) - ${maxTimestamp} (${maxDelta})`;
|
|
146
|
+
}
|
|
138
147
|
this.#logger?.debug(
|
|
139
148
|
logContext,
|
|
140
|
-
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}`
|
|
149
|
+
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}${tsRange}`
|
|
141
150
|
);
|
|
142
151
|
return results;
|
|
143
152
|
}
|
|
@@ -71,22 +71,34 @@ class PythUpdater extends SDKConstruct {
|
|
|
71
71
|
feeds.filter(isPyth).map((f) => [f.priceFeedId, f])
|
|
72
72
|
);
|
|
73
73
|
const payloads = await this.#getPayloads(new Set(pythFeeds.keys()));
|
|
74
|
-
|
|
74
|
+
let [minTimestamp, maxTimestamp] = [Number.POSITIVE_INFINITY, 0];
|
|
75
|
+
const results = [];
|
|
76
|
+
for (const p of payloads) {
|
|
75
77
|
const priceFeed = pythFeeds.get(p.dataFeedId);
|
|
76
78
|
if (!priceFeed) {
|
|
77
79
|
throw new Error(`cannot find price feed for ${p.dataFeedId}`);
|
|
78
80
|
}
|
|
79
81
|
const { dataFeedId, timestamp, cached, data } = p;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
minTimestamp = Math.min(minTimestamp, timestamp);
|
|
83
|
+
maxTimestamp = Math.max(maxTimestamp, timestamp);
|
|
84
|
+
results.push(
|
|
85
|
+
new PythUpdateTx(priceFeed.createPriceUpdateTx(data), {
|
|
86
|
+
dataFeedId,
|
|
87
|
+
priceFeed: priceFeed.address,
|
|
88
|
+
timestamp,
|
|
89
|
+
cached
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
let tsRange = "";
|
|
94
|
+
if (results.length) {
|
|
95
|
+
const minDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
96
|
+
const maxDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
97
|
+
tsRange = `, timestamps ${minTimestamp} (${minDelta}) - ${maxTimestamp} (${maxDelta})`;
|
|
98
|
+
}
|
|
87
99
|
this.#logger?.debug(
|
|
88
100
|
logContext,
|
|
89
|
-
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}`
|
|
101
|
+
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}${tsRange}`
|
|
90
102
|
);
|
|
91
103
|
return results;
|
|
92
104
|
}
|
|
@@ -85,6 +85,7 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
85
85
|
priceFeeds.set(feed.dataId, pfsForDataId);
|
|
86
86
|
}
|
|
87
87
|
const results = [];
|
|
88
|
+
let [minTimestamp, maxTimestamp] = [Number.POSITIVE_INFINITY, 0];
|
|
88
89
|
for (const [key, group] of Object.entries(groupedFeeds)) {
|
|
89
90
|
const [dataServiceId, signersStr] = key.split(":");
|
|
90
91
|
const uniqueSignersCount = parseInt(signersStr, 10);
|
|
@@ -99,6 +100,8 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
99
100
|
throw new Error(`cannot get price feed addresses for ${dataFeedId}`);
|
|
100
101
|
}
|
|
101
102
|
for (const priceFeed of pfsForDataId.values()) {
|
|
103
|
+
minTimestamp = Math.min(minTimestamp, timestamp);
|
|
104
|
+
maxTimestamp = Math.max(maxTimestamp, timestamp);
|
|
102
105
|
results.push(
|
|
103
106
|
new RedstoneUpdateTx(priceFeed.createPriceUpdateTx(data), {
|
|
104
107
|
dataFeedId,
|
|
@@ -111,9 +114,15 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
}
|
|
117
|
+
let tsRange = "";
|
|
118
|
+
if (results.length) {
|
|
119
|
+
const minDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
120
|
+
const maxDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
121
|
+
tsRange = `, timestamps ${minTimestamp} (${minDelta}) - ${maxTimestamp} (${maxDelta})`;
|
|
122
|
+
}
|
|
114
123
|
this.#logger?.debug(
|
|
115
124
|
logContext,
|
|
116
|
-
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}`
|
|
125
|
+
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}${tsRange}`
|
|
117
126
|
);
|
|
118
127
|
return results;
|
|
119
128
|
}
|