@gearbox-protocol/sdk 11.1.7 → 11.2.1
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/bindings/instance-manager.js +1 -1
- package/dist/cjs/permissionless/chains/chunked-log-transport.js +120 -0
- package/dist/cjs/permissionless/index.js +2 -0
- package/dist/cjs/permissionless/utils/price-update/get-price-feeds.js +5 -3
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +5 -3
- package/dist/cjs/permissionless/utils/price-update/get-prices.js +7 -2
- package/dist/cjs/sdk/chain/chains.js +30 -5
- package/dist/cjs/sdk/constants/networks.js +2 -3
- package/dist/esm/permissionless/bindings/instance-manager.js +1 -1
- package/dist/esm/permissionless/chains/chunked-log-transport.js +100 -0
- package/dist/esm/permissionless/index.js +1 -0
- package/dist/esm/permissionless/utils/price-update/get-price-feeds.js +5 -3
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +5 -3
- package/dist/esm/permissionless/utils/price-update/get-prices.js +10 -3
- package/dist/esm/sdk/chain/chains.js +30 -6
- package/dist/esm/sdk/constants/networks.js +2 -3
- package/dist/types/permissionless/chains/chunked-log-transport.d.ts +30 -0
- package/dist/types/permissionless/index.d.ts +1 -0
- package/dist/types/permissionless/utils/price-update/get-price-feeds.d.ts +2 -1
- package/dist/types/permissionless/utils/price-update/get-price-update-tx.d.ts +2 -1
- package/dist/types/permissionless/utils/price-update/get-prices.d.ts +2 -1
- package/package.json +1 -1
|
@@ -168,7 +168,7 @@ class InstanceManagerContract extends import_base_contract.BaseContract {
|
|
|
168
168
|
}
|
|
169
169
|
case "configureTreasury": {
|
|
170
170
|
const [target, data] = params.args;
|
|
171
|
-
let decoded
|
|
171
|
+
let decoded;
|
|
172
172
|
try {
|
|
173
173
|
const treasurySplitter = new import_treasury_splitter.TreasurySplitterContract(
|
|
174
174
|
target,
|
|
@@ -0,0 +1,120 @@
|
|
|
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 chunked_log_transport_exports = {};
|
|
20
|
+
__export(chunked_log_transport_exports, {
|
|
21
|
+
chunkedLogsTransport: () => chunkedLogsTransport
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(chunked_log_transport_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
function chunkedLogsTransport({
|
|
26
|
+
transport,
|
|
27
|
+
chunkSize,
|
|
28
|
+
startBlock,
|
|
29
|
+
enableLogging = false
|
|
30
|
+
}) {
|
|
31
|
+
return (opts) => {
|
|
32
|
+
const baseTransport = transport(opts);
|
|
33
|
+
const customTransport = (0, import_viem.custom)({
|
|
34
|
+
async request({ method, params }) {
|
|
35
|
+
if (method === "eth_getLogs") {
|
|
36
|
+
const [logsParams] = params;
|
|
37
|
+
if (logsParams.blockHash) {
|
|
38
|
+
return baseTransport.request({ method, params });
|
|
39
|
+
}
|
|
40
|
+
const fromBlock = logsParams.fromBlock !== void 0 ? typeof logsParams.fromBlock === "string" ? (0, import_viem.hexToNumber)(logsParams.fromBlock) : logsParams.fromBlock : void 0;
|
|
41
|
+
const toBlock = logsParams.toBlock !== void 0 ? typeof logsParams.toBlock === "string" ? (0, import_viem.hexToNumber)(logsParams.toBlock) : logsParams.toBlock : void 0;
|
|
42
|
+
if (startBlock !== void 0 && toBlock !== void 0 && toBlock < startBlock) {
|
|
43
|
+
if (enableLogging) {
|
|
44
|
+
console.log(
|
|
45
|
+
`[ChunkedLogsTransport] Request range (${fromBlock} -> ${toBlock}) is before startBlock (${startBlock}), returning empty array`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const adjustedFromBlock = startBlock !== void 0 && fromBlock !== void 0 && fromBlock < startBlock ? startBlock : fromBlock;
|
|
51
|
+
if (enableLogging && adjustedFromBlock !== fromBlock) {
|
|
52
|
+
console.log(
|
|
53
|
+
`[ChunkedLogsTransport] Adjusted fromBlock from ${fromBlock} to ${adjustedFromBlock} (startBlock: ${startBlock})`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (adjustedFromBlock === void 0 || toBlock === void 0 || toBlock - adjustedFromBlock <= chunkSize) {
|
|
57
|
+
const adjustedParams = [
|
|
58
|
+
{
|
|
59
|
+
...logsParams,
|
|
60
|
+
fromBlock: adjustedFromBlock !== void 0 ? (0, import_viem.numberToHex)(adjustedFromBlock) : logsParams.fromBlock
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
return baseTransport.request({ method, params: adjustedParams });
|
|
64
|
+
}
|
|
65
|
+
const chunks = [];
|
|
66
|
+
for (let start = adjustedFromBlock; start <= toBlock; start += chunkSize) {
|
|
67
|
+
chunks.push({
|
|
68
|
+
from: start,
|
|
69
|
+
to: Math.min(start + chunkSize - 1, toBlock)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (enableLogging) {
|
|
73
|
+
console.log(
|
|
74
|
+
`[ChunkedLogsTransport] Adjusted fromBlock: ${adjustedFromBlock}, toBlock: ${toBlock}`
|
|
75
|
+
);
|
|
76
|
+
console.log(
|
|
77
|
+
`[ChunkedLogsTransport] Splitting getLogs request into ${chunks.length} chunks (${adjustedFromBlock} -> ${toBlock}, chunk size: ${chunkSize})`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const batchRequests = chunks.map((chunk) => ({
|
|
81
|
+
method: "eth_getLogs",
|
|
82
|
+
params: [
|
|
83
|
+
{
|
|
84
|
+
...logsParams,
|
|
85
|
+
fromBlock: (0, import_viem.numberToHex)(chunk.from),
|
|
86
|
+
toBlock: (0, import_viem.numberToHex)(chunk.to)
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}));
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
const results = await Promise.all(
|
|
92
|
+
batchRequests.map(
|
|
93
|
+
(req) => baseTransport.request({ method: req.method, params: req.params })
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
if (enableLogging) {
|
|
97
|
+
const duration = Date.now() - startTime;
|
|
98
|
+
const totalLogs = results.reduce(
|
|
99
|
+
(sum, logs) => sum + logs.length,
|
|
100
|
+
0
|
|
101
|
+
);
|
|
102
|
+
console.log(
|
|
103
|
+
`[ChunkedLogsTransport] Completed ${chunks.length} requests in ${duration}ms, retrieved ${totalLogs} logs`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return results.flat();
|
|
107
|
+
}
|
|
108
|
+
return baseTransport.request({ method, params });
|
|
109
|
+
}
|
|
110
|
+
})(opts);
|
|
111
|
+
return {
|
|
112
|
+
...customTransport,
|
|
113
|
+
value: baseTransport.value
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
+
0 && (module.exports = {
|
|
119
|
+
chunkedLogsTransport
|
|
120
|
+
});
|
|
@@ -17,6 +17,7 @@ var permissionless_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(permissionless_exports);
|
|
18
18
|
__reExport(permissionless_exports, require("./bindings/index.js"), module.exports);
|
|
19
19
|
__reExport(permissionless_exports, require("./chains/archive-transport.js"), module.exports);
|
|
20
|
+
__reExport(permissionless_exports, require("./chains/chunked-log-transport.js"), module.exports);
|
|
20
21
|
__reExport(permissionless_exports, require("./core/index.js"), module.exports);
|
|
21
22
|
__reExport(permissionless_exports, require("./deployment/addresses.js"), module.exports);
|
|
22
23
|
__reExport(permissionless_exports, require("./deployment/mainnet.js"), module.exports);
|
|
@@ -25,6 +26,7 @@ __reExport(permissionless_exports, require("./utils/index.js"), module.exports);
|
|
|
25
26
|
0 && (module.exports = {
|
|
26
27
|
...require("./bindings/index.js"),
|
|
27
28
|
...require("./chains/archive-transport.js"),
|
|
29
|
+
...require("./chains/chunked-log-transport.js"),
|
|
28
30
|
...require("./core/index.js"),
|
|
29
31
|
...require("./deployment/addresses.js"),
|
|
30
32
|
...require("./deployment/mainnet.js"),
|
|
@@ -59,7 +59,8 @@ function getCallsTouchedPriceFeeds(parsedCalls) {
|
|
|
59
59
|
}
|
|
60
60
|
async function getCallsTouchedUpdatablePriceFeeds({
|
|
61
61
|
parsedCalls,
|
|
62
|
-
client
|
|
62
|
+
client,
|
|
63
|
+
gasLimit
|
|
63
64
|
}) {
|
|
64
65
|
const addressProvider = new import_bindings.AddressProviderContract(
|
|
65
66
|
import_addresses.Addresses.ADDRESS_PROVIDER,
|
|
@@ -70,8 +71,9 @@ async function getCallsTouchedUpdatablePriceFeeds({
|
|
|
70
71
|
310n
|
|
71
72
|
);
|
|
72
73
|
const sdk = await import_sdk.GearboxSDK.attach({
|
|
73
|
-
|
|
74
|
-
marketConfigurators: []
|
|
74
|
+
client,
|
|
75
|
+
marketConfigurators: [],
|
|
76
|
+
gasLimit
|
|
75
77
|
});
|
|
76
78
|
const touchedFeeds = parsedCalls.flatMap(
|
|
77
79
|
(call) => getCallTouchedPriceFeeds(call)
|
|
@@ -40,15 +40,17 @@ function getUpdateCalldata(tx) {
|
|
|
40
40
|
async function getPriceUpdateTx({
|
|
41
41
|
client,
|
|
42
42
|
priceFeeds,
|
|
43
|
-
useMulticall3 = false
|
|
43
|
+
useMulticall3 = false,
|
|
44
|
+
gasLimit
|
|
44
45
|
}) {
|
|
45
46
|
const pfStore = new import_bindings.PriceFeedStoreContract(
|
|
46
47
|
import_addresses.Addresses.PRICE_FEED_STORE,
|
|
47
48
|
client
|
|
48
49
|
);
|
|
49
50
|
const sdk = await import_sdk.GearboxSDK.attach({
|
|
50
|
-
|
|
51
|
-
marketConfigurators: []
|
|
51
|
+
client,
|
|
52
|
+
marketConfigurators: [],
|
|
53
|
+
gasLimit
|
|
52
54
|
});
|
|
53
55
|
const updateTxs = await sdk.priceFeeds.generateExternalPriceFeedsUpdateTxs(priceFeeds);
|
|
54
56
|
if (useMulticall3) {
|
|
@@ -96,10 +96,15 @@ async function getPricesChunk({
|
|
|
96
96
|
async function getPrices({
|
|
97
97
|
client,
|
|
98
98
|
priceFeeds,
|
|
99
|
-
chunkSize = 10
|
|
99
|
+
chunkSize = 10,
|
|
100
|
+
gasLimit
|
|
100
101
|
}) {
|
|
102
|
+
if (!client.chain) {
|
|
103
|
+
throw new Error("Chain not defined");
|
|
104
|
+
}
|
|
101
105
|
const sdk = await import_sdk.GearboxSDK.attach({
|
|
102
|
-
|
|
106
|
+
client,
|
|
107
|
+
gasLimit,
|
|
103
108
|
marketConfigurators: [],
|
|
104
109
|
redstone: {
|
|
105
110
|
ignoreMissingFeeds: true
|
|
@@ -171,16 +171,41 @@ const chains = {
|
|
|
171
171
|
symbol: "WETH"
|
|
172
172
|
}
|
|
173
173
|
}),
|
|
174
|
+
// NOTE: Monad chain configs should be updated once the public mainnet is available
|
|
174
175
|
Monad: (0, import_viem.defineChain)({
|
|
175
|
-
|
|
176
|
+
id: 143,
|
|
177
|
+
name: "Monad",
|
|
178
|
+
nativeCurrency: {
|
|
179
|
+
name: "Monad",
|
|
180
|
+
symbol: "MON",
|
|
181
|
+
decimals: 18
|
|
182
|
+
},
|
|
183
|
+
rpcUrls: {
|
|
184
|
+
default: {
|
|
185
|
+
http: [
|
|
186
|
+
"https://permissionless-staging.gearbox.foundation/api/proxy/rpc/143"
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
blockExplorers: {
|
|
191
|
+
default: {
|
|
192
|
+
name: "Monvision",
|
|
193
|
+
url: "https://mainnet-beta.monvision.io"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
contracts: {
|
|
197
|
+
multicall3: {
|
|
198
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
199
|
+
blockCreated: 9248132
|
|
200
|
+
}
|
|
201
|
+
},
|
|
176
202
|
network: "Monad",
|
|
177
203
|
defaultMarketConfigurators: {},
|
|
178
|
-
isPublic:
|
|
204
|
+
isPublic: true,
|
|
179
205
|
wellKnownToken: {
|
|
180
|
-
address: "
|
|
181
|
-
symbol: "
|
|
206
|
+
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
207
|
+
symbol: "USDT0"
|
|
182
208
|
}
|
|
183
|
-
// TODO: has no block explorer API
|
|
184
209
|
}),
|
|
185
210
|
Berachain: withPublicNode(
|
|
186
211
|
{
|
|
@@ -35,7 +35,7 @@ const ADDRESS_PROVIDER_BLOCK = {
|
|
|
35
35
|
// New networks
|
|
36
36
|
MegaETH: 1677017n,
|
|
37
37
|
// arbitrary not deployed yet
|
|
38
|
-
Monad:
|
|
38
|
+
Monad: 34650265n,
|
|
39
39
|
// arbitrary not deployed yet
|
|
40
40
|
Berachain: 2788903n,
|
|
41
41
|
// arbitrary not deployed yet
|
|
@@ -63,8 +63,7 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
63
63
|
// New networks
|
|
64
64
|
MegaETH: 10,
|
|
65
65
|
// <10ms/block, on testnet
|
|
66
|
-
Monad:
|
|
67
|
-
// on testnet
|
|
66
|
+
Monad: 400,
|
|
68
67
|
Berachain: 1900,
|
|
69
68
|
Avalanche: 1700,
|
|
70
69
|
BNB: 3e3,
|
|
@@ -148,7 +148,7 @@ class InstanceManagerContract extends BaseContract {
|
|
|
148
148
|
}
|
|
149
149
|
case "configureTreasury": {
|
|
150
150
|
const [target, data] = params.args;
|
|
151
|
-
let decoded
|
|
151
|
+
let decoded;
|
|
152
152
|
try {
|
|
153
153
|
const treasurySplitter = new TreasurySplitterContract(
|
|
154
154
|
target,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
custom,
|
|
3
|
+
hexToNumber,
|
|
4
|
+
numberToHex
|
|
5
|
+
} from "viem";
|
|
6
|
+
function chunkedLogsTransport({
|
|
7
|
+
transport,
|
|
8
|
+
chunkSize,
|
|
9
|
+
startBlock,
|
|
10
|
+
enableLogging = false
|
|
11
|
+
}) {
|
|
12
|
+
return (opts) => {
|
|
13
|
+
const baseTransport = transport(opts);
|
|
14
|
+
const customTransport = custom({
|
|
15
|
+
async request({ method, params }) {
|
|
16
|
+
if (method === "eth_getLogs") {
|
|
17
|
+
const [logsParams] = params;
|
|
18
|
+
if (logsParams.blockHash) {
|
|
19
|
+
return baseTransport.request({ method, params });
|
|
20
|
+
}
|
|
21
|
+
const fromBlock = logsParams.fromBlock !== void 0 ? typeof logsParams.fromBlock === "string" ? hexToNumber(logsParams.fromBlock) : logsParams.fromBlock : void 0;
|
|
22
|
+
const toBlock = logsParams.toBlock !== void 0 ? typeof logsParams.toBlock === "string" ? hexToNumber(logsParams.toBlock) : logsParams.toBlock : void 0;
|
|
23
|
+
if (startBlock !== void 0 && toBlock !== void 0 && toBlock < startBlock) {
|
|
24
|
+
if (enableLogging) {
|
|
25
|
+
console.log(
|
|
26
|
+
`[ChunkedLogsTransport] Request range (${fromBlock} -> ${toBlock}) is before startBlock (${startBlock}), returning empty array`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const adjustedFromBlock = startBlock !== void 0 && fromBlock !== void 0 && fromBlock < startBlock ? startBlock : fromBlock;
|
|
32
|
+
if (enableLogging && adjustedFromBlock !== fromBlock) {
|
|
33
|
+
console.log(
|
|
34
|
+
`[ChunkedLogsTransport] Adjusted fromBlock from ${fromBlock} to ${adjustedFromBlock} (startBlock: ${startBlock})`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (adjustedFromBlock === void 0 || toBlock === void 0 || toBlock - adjustedFromBlock <= chunkSize) {
|
|
38
|
+
const adjustedParams = [
|
|
39
|
+
{
|
|
40
|
+
...logsParams,
|
|
41
|
+
fromBlock: adjustedFromBlock !== void 0 ? numberToHex(adjustedFromBlock) : logsParams.fromBlock
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
return baseTransport.request({ method, params: adjustedParams });
|
|
45
|
+
}
|
|
46
|
+
const chunks = [];
|
|
47
|
+
for (let start = adjustedFromBlock; start <= toBlock; start += chunkSize) {
|
|
48
|
+
chunks.push({
|
|
49
|
+
from: start,
|
|
50
|
+
to: Math.min(start + chunkSize - 1, toBlock)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (enableLogging) {
|
|
54
|
+
console.log(
|
|
55
|
+
`[ChunkedLogsTransport] Adjusted fromBlock: ${adjustedFromBlock}, toBlock: ${toBlock}`
|
|
56
|
+
);
|
|
57
|
+
console.log(
|
|
58
|
+
`[ChunkedLogsTransport] Splitting getLogs request into ${chunks.length} chunks (${adjustedFromBlock} -> ${toBlock}, chunk size: ${chunkSize})`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const batchRequests = chunks.map((chunk) => ({
|
|
62
|
+
method: "eth_getLogs",
|
|
63
|
+
params: [
|
|
64
|
+
{
|
|
65
|
+
...logsParams,
|
|
66
|
+
fromBlock: numberToHex(chunk.from),
|
|
67
|
+
toBlock: numberToHex(chunk.to)
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}));
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
const results = await Promise.all(
|
|
73
|
+
batchRequests.map(
|
|
74
|
+
(req) => baseTransport.request({ method: req.method, params: req.params })
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
if (enableLogging) {
|
|
78
|
+
const duration = Date.now() - startTime;
|
|
79
|
+
const totalLogs = results.reduce(
|
|
80
|
+
(sum, logs) => sum + logs.length,
|
|
81
|
+
0
|
|
82
|
+
);
|
|
83
|
+
console.log(
|
|
84
|
+
`[ChunkedLogsTransport] Completed ${chunks.length} requests in ${duration}ms, retrieved ${totalLogs} logs`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return results.flat();
|
|
88
|
+
}
|
|
89
|
+
return baseTransport.request({ method, params });
|
|
90
|
+
}
|
|
91
|
+
})(opts);
|
|
92
|
+
return {
|
|
93
|
+
...customTransport,
|
|
94
|
+
value: baseTransport.value
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
chunkedLogsTransport
|
|
100
|
+
};
|
|
@@ -34,7 +34,8 @@ function getCallsTouchedPriceFeeds(parsedCalls) {
|
|
|
34
34
|
}
|
|
35
35
|
async function getCallsTouchedUpdatablePriceFeeds({
|
|
36
36
|
parsedCalls,
|
|
37
|
-
client
|
|
37
|
+
client,
|
|
38
|
+
gasLimit
|
|
38
39
|
}) {
|
|
39
40
|
const addressProvider = new AddressProviderContract(
|
|
40
41
|
Addresses.ADDRESS_PROVIDER,
|
|
@@ -45,8 +46,9 @@ async function getCallsTouchedUpdatablePriceFeeds({
|
|
|
45
46
|
310n
|
|
46
47
|
);
|
|
47
48
|
const sdk = await GearboxSDK.attach({
|
|
48
|
-
|
|
49
|
-
marketConfigurators: []
|
|
49
|
+
client,
|
|
50
|
+
marketConfigurators: [],
|
|
51
|
+
gasLimit
|
|
50
52
|
});
|
|
51
53
|
const touchedFeeds = parsedCalls.flatMap(
|
|
52
54
|
(call) => getCallTouchedPriceFeeds(call)
|
|
@@ -24,15 +24,17 @@ function getUpdateCalldata(tx) {
|
|
|
24
24
|
async function getPriceUpdateTx({
|
|
25
25
|
client,
|
|
26
26
|
priceFeeds,
|
|
27
|
-
useMulticall3 = false
|
|
27
|
+
useMulticall3 = false,
|
|
28
|
+
gasLimit
|
|
28
29
|
}) {
|
|
29
30
|
const pfStore = new PriceFeedStoreContract(
|
|
30
31
|
Addresses.PRICE_FEED_STORE,
|
|
31
32
|
client
|
|
32
33
|
);
|
|
33
34
|
const sdk = await GearboxSDK.attach({
|
|
34
|
-
|
|
35
|
-
marketConfigurators: []
|
|
35
|
+
client,
|
|
36
|
+
marketConfigurators: [],
|
|
37
|
+
gasLimit
|
|
36
38
|
});
|
|
37
39
|
const updateTxs = await sdk.priceFeeds.generateExternalPriceFeedsUpdateTxs(priceFeeds);
|
|
38
40
|
if (useMulticall3) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
multicall3Abi
|
|
3
|
+
} from "viem";
|
|
2
4
|
import { GearboxSDK } from "../../../sdk/index.js";
|
|
3
5
|
import { simulateMulticall } from "../../../sdk/utils/viem/index.js";
|
|
4
6
|
const latestRoundDataAbi = [
|
|
@@ -73,10 +75,15 @@ async function getPricesChunk({
|
|
|
73
75
|
async function getPrices({
|
|
74
76
|
client,
|
|
75
77
|
priceFeeds,
|
|
76
|
-
chunkSize = 10
|
|
78
|
+
chunkSize = 10,
|
|
79
|
+
gasLimit
|
|
77
80
|
}) {
|
|
81
|
+
if (!client.chain) {
|
|
82
|
+
throw new Error("Chain not defined");
|
|
83
|
+
}
|
|
78
84
|
const sdk = await GearboxSDK.attach({
|
|
79
|
-
|
|
85
|
+
client,
|
|
86
|
+
gasLimit,
|
|
80
87
|
marketConfigurators: [],
|
|
81
88
|
redstone: {
|
|
82
89
|
ignoreMissingFeeds: true
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
lisk,
|
|
11
11
|
mainnet,
|
|
12
12
|
megaethTestnet,
|
|
13
|
-
monadTestnet,
|
|
14
13
|
optimism,
|
|
15
14
|
plasma,
|
|
16
15
|
sonic,
|
|
@@ -156,16 +155,41 @@ const chains = {
|
|
|
156
155
|
symbol: "WETH"
|
|
157
156
|
}
|
|
158
157
|
}),
|
|
158
|
+
// NOTE: Monad chain configs should be updated once the public mainnet is available
|
|
159
159
|
Monad: defineChain({
|
|
160
|
-
|
|
160
|
+
id: 143,
|
|
161
|
+
name: "Monad",
|
|
162
|
+
nativeCurrency: {
|
|
163
|
+
name: "Monad",
|
|
164
|
+
symbol: "MON",
|
|
165
|
+
decimals: 18
|
|
166
|
+
},
|
|
167
|
+
rpcUrls: {
|
|
168
|
+
default: {
|
|
169
|
+
http: [
|
|
170
|
+
"https://permissionless-staging.gearbox.foundation/api/proxy/rpc/143"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
blockExplorers: {
|
|
175
|
+
default: {
|
|
176
|
+
name: "Monvision",
|
|
177
|
+
url: "https://mainnet-beta.monvision.io"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
contracts: {
|
|
181
|
+
multicall3: {
|
|
182
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
183
|
+
blockCreated: 9248132
|
|
184
|
+
}
|
|
185
|
+
},
|
|
161
186
|
network: "Monad",
|
|
162
187
|
defaultMarketConfigurators: {},
|
|
163
|
-
isPublic:
|
|
188
|
+
isPublic: true,
|
|
164
189
|
wellKnownToken: {
|
|
165
|
-
address: "
|
|
166
|
-
symbol: "
|
|
190
|
+
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
191
|
+
symbol: "USDT0"
|
|
167
192
|
}
|
|
168
|
-
// TODO: has no block explorer API
|
|
169
193
|
}),
|
|
170
194
|
Berachain: withPublicNode(
|
|
171
195
|
{
|
|
@@ -10,7 +10,7 @@ const ADDRESS_PROVIDER_BLOCK = {
|
|
|
10
10
|
// New networks
|
|
11
11
|
MegaETH: 1677017n,
|
|
12
12
|
// arbitrary not deployed yet
|
|
13
|
-
Monad:
|
|
13
|
+
Monad: 34650265n,
|
|
14
14
|
// arbitrary not deployed yet
|
|
15
15
|
Berachain: 2788903n,
|
|
16
16
|
// arbitrary not deployed yet
|
|
@@ -38,8 +38,7 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
38
38
|
// New networks
|
|
39
39
|
MegaETH: 10,
|
|
40
40
|
// <10ms/block, on testnet
|
|
41
|
-
Monad:
|
|
42
|
-
// on testnet
|
|
41
|
+
Monad: 400,
|
|
43
42
|
Berachain: 1900,
|
|
44
43
|
Avalanche: 1700,
|
|
45
44
|
BNB: 3e3,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Transport } from "viem";
|
|
2
|
+
interface ChunkedLogsTransportConfig {
|
|
3
|
+
transport: Transport;
|
|
4
|
+
chunkSize: number;
|
|
5
|
+
startBlock?: number;
|
|
6
|
+
enableLogging?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a custom viem transport that chunks getLogs requests by block range
|
|
10
|
+
* and makes batch RPC requests for better performance with large block ranges.
|
|
11
|
+
*
|
|
12
|
+
* @param config Configuration object
|
|
13
|
+
* @param config.transport Base transport to wrap
|
|
14
|
+
* @param config.chunkSize Number of blocks per chunk
|
|
15
|
+
* @param config.startBlock Optional minimum block - logs before this block are filtered out
|
|
16
|
+
* @param config.enableLogging Enable debug logging
|
|
17
|
+
* @returns Viem Transport
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const transport = chunkedLogsTransport({
|
|
21
|
+
* transport: http('https://eth.llamarpc.com'),
|
|
22
|
+
* chunkSize: 2000,
|
|
23
|
+
* startBlock: 18000000,
|
|
24
|
+
* enableLogging: true,
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const client = createPublicClient({ transport });
|
|
28
|
+
*/
|
|
29
|
+
export declare function chunkedLogsTransport({ transport, chunkSize, startBlock, enableLogging, }: ChunkedLogsTransportConfig): Transport;
|
|
30
|
+
export {};
|
|
@@ -11,7 +11,8 @@ export declare function getCallsTouchedPriceFeeds(parsedCalls: ParsedCall[]): Ad
|
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated This helper will be removed in the next releases.
|
|
13
13
|
*/
|
|
14
|
-
export declare function getCallsTouchedUpdatablePriceFeeds({ parsedCalls, client, }: {
|
|
14
|
+
export declare function getCallsTouchedUpdatablePriceFeeds({ parsedCalls, client, gasLimit, }: {
|
|
15
15
|
client: PublicClient;
|
|
16
16
|
parsedCalls: ParsedCall[];
|
|
17
|
+
gasLimit?: bigint;
|
|
17
18
|
}): Promise<Address[]>;
|
|
@@ -2,8 +2,9 @@ import { type Address, type PublicClient } from "viem";
|
|
|
2
2
|
import { type IPriceUpdateTx, type RawTx } from "../../../sdk/index.js";
|
|
3
3
|
import { type PriceUpdate } from "../../bindings/index.js";
|
|
4
4
|
export declare function getUpdateCalldata(tx: IPriceUpdateTx): PriceUpdate;
|
|
5
|
-
export declare function getPriceUpdateTx({ client, priceFeeds, useMulticall3, }: {
|
|
5
|
+
export declare function getPriceUpdateTx({ client, priceFeeds, useMulticall3, gasLimit, }: {
|
|
6
6
|
client: PublicClient;
|
|
7
7
|
priceFeeds: Address[];
|
|
8
8
|
useMulticall3?: boolean;
|
|
9
|
+
gasLimit?: bigint;
|
|
9
10
|
}): Promise<RawTx | undefined>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address, type PublicClient } from "viem";
|
|
2
|
-
export declare function getPrices({ client, priceFeeds, chunkSize, }: {
|
|
2
|
+
export declare function getPrices({ client, priceFeeds, chunkSize, gasLimit }: {
|
|
3
3
|
client: PublicClient;
|
|
4
4
|
priceFeeds: Address[];
|
|
5
5
|
chunkSize?: number;
|
|
6
|
+
gasLimit?: bigint;
|
|
6
7
|
}): Promise<Record<Address, bigint | null>>;
|