@gearbox-protocol/sdk 13.6.0-apy-plugin.5 → 13.6.0-apy-plugin.6
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/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
- package/dist/cjs/plugins/adapters/types.js +1 -1
- package/dist/cjs/plugins/pools-history/ApyPlugin.js +2 -65
- package/dist/cjs/sdk/GearboxSDK.js +1 -12
- package/dist/cjs/sdk/chain/chains.js +31 -15
- package/dist/cjs/sdk/options.js +1 -1
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
- package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/plugins/adapters/createAdapter.js +1 -1
- package/dist/esm/plugins/adapters/types.js +1 -1
- package/dist/esm/plugins/pools-history/ApyPlugin.js +2 -65
- package/dist/esm/sdk/GearboxSDK.js +1 -12
- package/dist/esm/sdk/chain/chains.js +31 -15
- package/dist/esm/sdk/options.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
- package/dist/types/plugins/adapters/types.d.ts +2 -2
- package/dist/types/plugins/pools-history/ApyPlugin.d.ts +2 -26
- package/dist/types/sdk/GearboxSDK.d.ts +0 -19
- package/dist/types/sdk/base/types.d.ts +9 -0
- package/dist/types/sdk/chain/chains.d.ts +4 -0
- package/package.json +1 -1
|
@@ -73,7 +73,7 @@ const adapterActionSignatures = {
|
|
|
73
73
|
310: "function setPairStatusBatch((address,address,address,uint8)[])",
|
|
74
74
|
311: "function setPairStatusBatch((address,address,address,uint8,uint8)[])"
|
|
75
75
|
},
|
|
76
|
-
[import_types.AdapterType.
|
|
76
|
+
[import_types.AdapterType.TRADER_JOE_ROUTER]: {
|
|
77
77
|
310: "function setPoolStatusBatch((address,address,uint256,uint8,bool)[])"
|
|
78
78
|
},
|
|
79
79
|
[import_types.AdapterType.UNISWAP_V2_ROUTER]: {
|
|
@@ -72,7 +72,7 @@ const adapterConstructorAbi = {
|
|
|
72
72
|
[import_types.AdapterType.DAI_USDS_EXCHANGE]: {
|
|
73
73
|
310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI
|
|
74
74
|
},
|
|
75
|
-
[import_types.AdapterType.
|
|
75
|
+
[import_types.AdapterType.TRADER_JOE_ROUTER]: {
|
|
76
76
|
310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI
|
|
77
77
|
},
|
|
78
78
|
[import_types.AdapterType.UNISWAP_V2_ROUTER]: {
|
|
@@ -93,7 +93,7 @@ function createAdapter(options, data, strict) {
|
|
|
93
93
|
return new import_contracts.PendleRouterAdapterContract(options, data);
|
|
94
94
|
case "ADAPTER::STAKING_REWARDS":
|
|
95
95
|
return new import_contracts.StakingRewardsAdapterContract(options, data);
|
|
96
|
-
case "ADAPTER::
|
|
96
|
+
case "ADAPTER::TRADER_JOE_ROUTER":
|
|
97
97
|
return new import_contracts.TraderJoeRouterAdapterContract(options, data);
|
|
98
98
|
case "ADAPTER::UNISWAP_V2_ROUTER":
|
|
99
99
|
return new import_contracts.UniswapV2AdapterContract(options, data);
|
|
@@ -59,7 +59,7 @@ var AdapterType = /* @__PURE__ */ ((AdapterType2) => {
|
|
|
59
59
|
AdapterType2["MIDAS_REDEMPTION_VAULT"] = "MIDAS_REDEMPTION_VAULT";
|
|
60
60
|
AdapterType2["PENDLE_ROUTER"] = "PENDLE_ROUTER";
|
|
61
61
|
AdapterType2["STAKING_REWARDS"] = "STAKING_REWARDS";
|
|
62
|
-
AdapterType2["
|
|
62
|
+
AdapterType2["TRADER_JOE_ROUTER"] = "TRADER_JOE_ROUTER";
|
|
63
63
|
AdapterType2["UNISWAP_V2_ROUTER"] = "UNISWAP_V2_ROUTER";
|
|
64
64
|
AdapterType2["UNISWAP_V3_ROUTER"] = "UNISWAP_V3_ROUTER";
|
|
65
65
|
AdapterType2["UNISWAP_V4_GATEWAY"] = "UNISWAP_V4_GATEWAY";
|
|
@@ -31,40 +31,15 @@ var import_apy_parser = require("./apy-parser.js");
|
|
|
31
31
|
var import_constants = require("./constants.js");
|
|
32
32
|
var import_pool_apy_utils = require("./pool-apy-utils.js");
|
|
33
33
|
const MAP_LABEL = "pools7DAgo";
|
|
34
|
-
const PLUGIN_KEY = "ApyPlugin";
|
|
35
34
|
class ApyPlugin extends import_sdk.BasePlugin {
|
|
36
|
-
#timerInterval;
|
|
37
35
|
#apyUrl;
|
|
38
36
|
#cacheTtlMs;
|
|
39
37
|
#pools7DAgo;
|
|
40
38
|
#apySnapshot;
|
|
41
|
-
|
|
42
|
-
* Default timer options
|
|
43
|
-
* @see PluginTimerOptions
|
|
44
|
-
*/
|
|
45
|
-
#defaultTimerOptions;
|
|
46
|
-
/**
|
|
47
|
-
* When `true`, the timer is started eagerly during the `attach` phase
|
|
48
|
-
* rather than waiting for an explicit `load` call.
|
|
49
|
-
**/
|
|
50
|
-
startTimerOnAttach;
|
|
51
|
-
constructor(loadOnAttach = false, startTimerOnAttach = false, options) {
|
|
39
|
+
constructor(loadOnAttach = false, options) {
|
|
52
40
|
super(loadOnAttach);
|
|
53
|
-
this.startTimerOnAttach = startTimerOnAttach;
|
|
54
41
|
this.#apyUrl = options?.apyUrl ?? import_constants.APY_STATE_CACHE_URL;
|
|
55
42
|
this.#cacheTtlMs = options?.cacheTtlMs ?? import_constants.DEFAULT_APY_INTERVAL_MS;
|
|
56
|
-
this.#defaultTimerOptions = options?.timer ?? {
|
|
57
|
-
refreshPools7DAgoOnTick: false,
|
|
58
|
-
intervalMs: import_constants.DEFAULT_APY_INTERVAL_MS,
|
|
59
|
-
onChange: () => {
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async attach() {
|
|
64
|
-
await super.attach();
|
|
65
|
-
if (this.startTimerOnAttach) {
|
|
66
|
-
this.startTimer();
|
|
67
|
-
}
|
|
68
43
|
}
|
|
69
44
|
// ---------------------------------------------------------------------------
|
|
70
45
|
// Load — single entry point for all data (on-chain + state-cache)
|
|
@@ -207,48 +182,10 @@ class ApyPlugin extends import_sdk.BasePlugin {
|
|
|
207
182
|
return { data, data7DAgo, pointsBase: poolPointsBase, points };
|
|
208
183
|
}
|
|
209
184
|
// ---------------------------------------------------------------------------
|
|
210
|
-
// Periodic full refresh
|
|
211
|
-
// ---------------------------------------------------------------------------
|
|
212
|
-
/**
|
|
213
|
-
* Starts a periodic timer that performs a full plugin state refresh.
|
|
214
|
-
* Only one timer can be active; calling again is a no-op.
|
|
215
|
-
* @returns Cleanup function that stops the timer.
|
|
216
|
-
*/
|
|
217
|
-
startTimer(opts) {
|
|
218
|
-
if (this.#timerInterval) {
|
|
219
|
-
this.#logger?.debug("plugin timer already running");
|
|
220
|
-
return () => this.stopTimer();
|
|
221
|
-
}
|
|
222
|
-
const intervalMs = opts?.intervalMs ?? this.#defaultTimerOptions.intervalMs;
|
|
223
|
-
this.#logger?.debug(`starting plugin timer (interval: ${intervalMs}ms)`);
|
|
224
|
-
this.#timerInterval = setInterval(async () => {
|
|
225
|
-
try {
|
|
226
|
-
const prevTimestamp = this.#apySnapshot?.timestamp;
|
|
227
|
-
await this.load(true, {
|
|
228
|
-
loadPools7DAgo: opts?.refreshPools7DAgoOnTick ?? this.#defaultTimerOptions.refreshPools7DAgoOnTick
|
|
229
|
-
});
|
|
230
|
-
if (this.#apySnapshot?.timestamp !== prevTimestamp) {
|
|
231
|
-
opts?.onChange?.() ?? this.#defaultTimerOptions.onChange?.();
|
|
232
|
-
await this.sdk.triggerPluginUpdate(PLUGIN_KEY);
|
|
233
|
-
}
|
|
234
|
-
} catch (e) {
|
|
235
|
-
this.#logger?.error(e, "periodic refresh failed");
|
|
236
|
-
}
|
|
237
|
-
}, intervalMs);
|
|
238
|
-
return () => this.stopTimer();
|
|
239
|
-
}
|
|
240
|
-
stopTimer() {
|
|
241
|
-
if (this.#timerInterval) {
|
|
242
|
-
clearInterval(this.#timerInterval);
|
|
243
|
-
this.#timerInterval = void 0;
|
|
244
|
-
this.#logger?.debug("plugin timer stopped");
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
// ---------------------------------------------------------------------------
|
|
248
185
|
// Plugin lifecycle
|
|
249
186
|
// ---------------------------------------------------------------------------
|
|
250
187
|
async syncState() {
|
|
251
|
-
await this.load(
|
|
188
|
+
await this.load();
|
|
252
189
|
}
|
|
253
190
|
stateHuman(_) {
|
|
254
191
|
return this.pools7DAgo.values().flatMap((p) => ({
|
|
@@ -110,17 +110,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
110
110
|
* @see {@link SDKHooks} for available event names.
|
|
111
111
|
**/
|
|
112
112
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
113
|
-
/**
|
|
114
|
-
* Triggers the `pluginUpdate` hook.
|
|
115
|
-
*
|
|
116
|
-
* Intended to be called by plugins when they update their internal state
|
|
117
|
-
* outside of the normal `syncState`/`rehydrate` cycle (e.g. via an
|
|
118
|
-
* internal timer). Frontend listeners registered with
|
|
119
|
-
* `sdk.addHook("pluginUpdate", …)` will be notified.
|
|
120
|
-
**/
|
|
121
|
-
async triggerPluginUpdate(plugin) {
|
|
122
|
-
await this.#hooks.triggerHooks("pluginUpdate", { plugin });
|
|
123
|
-
}
|
|
124
113
|
/**
|
|
125
114
|
* Creates and initialises a new SDK instance by reading live on-chain state.
|
|
126
115
|
*
|
|
@@ -201,7 +190,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
201
190
|
plugin.sdk = this;
|
|
202
191
|
}
|
|
203
192
|
if (options.gasLimit !== null) {
|
|
204
|
-
this.gasLimit = options.gasLimit ||
|
|
193
|
+
this.gasLimit = options.gasLimit || (0, import_chain.getChain)(this.networkType).gasLimit;
|
|
205
194
|
}
|
|
206
195
|
}
|
|
207
196
|
async #attach(opts) {
|
|
@@ -86,7 +86,8 @@ const chains = {
|
|
|
86
86
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
87
87
|
symbol: "USDC"
|
|
88
88
|
},
|
|
89
|
-
firstBlock: 22358644n
|
|
89
|
+
firstBlock: 22358644n,
|
|
90
|
+
gasLimit: 550000000n
|
|
90
91
|
},
|
|
91
92
|
"ethereum-rpc"
|
|
92
93
|
),
|
|
@@ -102,7 +103,8 @@ const chains = {
|
|
|
102
103
|
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
103
104
|
symbol: "USDC"
|
|
104
105
|
},
|
|
105
|
-
firstBlock: 184650310n
|
|
106
|
+
firstBlock: 184650310n,
|
|
107
|
+
gasLimit: 550000000n
|
|
106
108
|
},
|
|
107
109
|
"arbitrum-one-rpc"
|
|
108
110
|
),
|
|
@@ -119,7 +121,8 @@ const chains = {
|
|
|
119
121
|
address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
120
122
|
symbol: "USDC"
|
|
121
123
|
},
|
|
122
|
-
firstBlock: 118410666n
|
|
124
|
+
firstBlock: 118410666n,
|
|
125
|
+
gasLimit: 550000000n
|
|
123
126
|
},
|
|
124
127
|
"optimism-rpc"
|
|
125
128
|
),
|
|
@@ -132,7 +135,8 @@ const chains = {
|
|
|
132
135
|
wellKnownToken: {
|
|
133
136
|
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
134
137
|
symbol: "USDC"
|
|
135
|
-
}
|
|
138
|
+
},
|
|
139
|
+
gasLimit: 550000000n
|
|
136
140
|
},
|
|
137
141
|
"base-rpc"
|
|
138
142
|
),
|
|
@@ -155,6 +159,7 @@ const chains = {
|
|
|
155
159
|
address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
156
160
|
symbol: "USDC"
|
|
157
161
|
},
|
|
162
|
+
gasLimit: 550000000n,
|
|
158
163
|
firstBlock: 9779380n
|
|
159
164
|
}),
|
|
160
165
|
"sonic-rpc"
|
|
@@ -167,7 +172,8 @@ const chains = {
|
|
|
167
172
|
wellKnownToken: {
|
|
168
173
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
169
174
|
symbol: "USDm"
|
|
170
|
-
}
|
|
175
|
+
},
|
|
176
|
+
gasLimit: 550000000n
|
|
171
177
|
}),
|
|
172
178
|
// NOTE: Monad chain configs should be updated once the public mainnet is available
|
|
173
179
|
Monad: (0, import_viem.defineChain)({
|
|
@@ -188,7 +194,8 @@ const chains = {
|
|
|
188
194
|
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
189
195
|
symbol: "USDT0"
|
|
190
196
|
},
|
|
191
|
-
firstBlock: 34650262n
|
|
197
|
+
firstBlock: 34650262n,
|
|
198
|
+
gasLimit: 200000000n
|
|
192
199
|
}),
|
|
193
200
|
Berachain: withPublicNode(
|
|
194
201
|
{
|
|
@@ -206,7 +213,8 @@ const chains = {
|
|
|
206
213
|
wellKnownToken: {
|
|
207
214
|
address: "0x549943e04f40284185054145c6e4e9568c1d3241",
|
|
208
215
|
symbol: "USDC.e"
|
|
209
|
-
}
|
|
216
|
+
},
|
|
217
|
+
gasLimit: 550000000n
|
|
210
218
|
},
|
|
211
219
|
"berachain-rpc"
|
|
212
220
|
),
|
|
@@ -219,7 +227,8 @@ const chains = {
|
|
|
219
227
|
wellKnownToken: {
|
|
220
228
|
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
221
229
|
symbol: "USDC"
|
|
222
|
-
}
|
|
230
|
+
},
|
|
231
|
+
gasLimit: 550000000n
|
|
223
232
|
},
|
|
224
233
|
"avalanche-c-chain-rpc"
|
|
225
234
|
),
|
|
@@ -237,7 +246,8 @@ const chains = {
|
|
|
237
246
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
238
247
|
symbol: "USDC"
|
|
239
248
|
},
|
|
240
|
-
firstBlock: 48761804n
|
|
249
|
+
firstBlock: 48761804n,
|
|
250
|
+
gasLimit: 550000000n
|
|
241
251
|
},
|
|
242
252
|
"bsc-rpc"
|
|
243
253
|
),
|
|
@@ -249,8 +259,9 @@ const chains = {
|
|
|
249
259
|
wellKnownToken: {
|
|
250
260
|
address: "0x79a02482a880bce3f13e09da970dc34db4cd24d1",
|
|
251
261
|
symbol: "USDC"
|
|
252
|
-
}
|
|
262
|
+
},
|
|
253
263
|
// TODO: has no block explorer API
|
|
264
|
+
gasLimit: 550000000n
|
|
254
265
|
}),
|
|
255
266
|
Etherlink: (0, import_viem.defineChain)({
|
|
256
267
|
...import_chains.etherlink,
|
|
@@ -263,7 +274,8 @@ const chains = {
|
|
|
263
274
|
address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
|
|
264
275
|
symbol: "USDC"
|
|
265
276
|
},
|
|
266
|
-
firstBlock: 16672963n
|
|
277
|
+
firstBlock: 16672963n,
|
|
278
|
+
gasLimit: 550000000n
|
|
267
279
|
}),
|
|
268
280
|
Hemi: (0, import_viem.defineChain)({
|
|
269
281
|
...import_chains.hemi,
|
|
@@ -281,7 +293,8 @@ const chains = {
|
|
|
281
293
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
282
294
|
blockCreated: 484490
|
|
283
295
|
}
|
|
284
|
-
}
|
|
296
|
+
},
|
|
297
|
+
gasLimit: 550000000n
|
|
285
298
|
}),
|
|
286
299
|
Lisk: (0, import_viem.defineChain)({
|
|
287
300
|
...import_chains.lisk,
|
|
@@ -293,7 +306,8 @@ const chains = {
|
|
|
293
306
|
wellKnownToken: {
|
|
294
307
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
295
308
|
symbol: "USDC.e"
|
|
296
|
-
}
|
|
309
|
+
},
|
|
310
|
+
gasLimit: 550000000n
|
|
297
311
|
}),
|
|
298
312
|
Plasma: (0, import_viem.defineChain)({
|
|
299
313
|
...import_chains.plasma,
|
|
@@ -314,7 +328,8 @@ const chains = {
|
|
|
314
328
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11"
|
|
315
329
|
}
|
|
316
330
|
},
|
|
317
|
-
firstBlock: 670913n
|
|
331
|
+
firstBlock: 670913n,
|
|
332
|
+
gasLimit: 550000000n
|
|
318
333
|
}),
|
|
319
334
|
Somnia: (0, import_viem.defineChain)({
|
|
320
335
|
...import_chains.somnia,
|
|
@@ -334,7 +349,8 @@ const chains = {
|
|
|
334
349
|
address: "0x67B302E35Aef5EEE8c32D934F5856869EF428330",
|
|
335
350
|
symbol: "USDT"
|
|
336
351
|
},
|
|
337
|
-
firstBlock: 147687380n
|
|
352
|
+
firstBlock: 147687380n,
|
|
353
|
+
gasLimit: 550000000n
|
|
338
354
|
})
|
|
339
355
|
};
|
|
340
356
|
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
package/dist/cjs/sdk/options.js
CHANGED
|
@@ -74,7 +74,7 @@ const SDKOptions = import_v4.z.object({
|
|
|
74
74
|
/**
|
|
75
75
|
* Explicit gas limit for read-only `eth_call` requests.
|
|
76
76
|
* `null` disables the gas limit entirely; `undefined` uses the SDK default.
|
|
77
|
-
* Default
|
|
77
|
+
* Default to value from {@link GearboxChain.gasLimit}
|
|
78
78
|
**/
|
|
79
79
|
gasLimit: import_v4.z.bigint().nonnegative().nullable().optional()
|
|
80
80
|
});
|
|
@@ -24,6 +24,8 @@ __export(simulateWithPriceUpdates_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(simulateWithPriceUpdates_exports);
|
|
26
26
|
var import_viem = require("viem");
|
|
27
|
+
var import_actions = require("viem/actions");
|
|
28
|
+
var import_utils = require("viem/utils");
|
|
27
29
|
var import_errors = require("../../../abi/errors.js");
|
|
28
30
|
var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
|
|
29
31
|
var import_cast = require("./cast.js");
|
|
@@ -53,6 +55,41 @@ async function simulateWithPriceUpdates(client, parameters) {
|
|
|
53
55
|
"client chain not configured. multicallAddress is required."
|
|
54
56
|
);
|
|
55
57
|
}
|
|
58
|
+
if (priceUpdates.length === 0 && restContracts.length === 1) {
|
|
59
|
+
const contract = restContracts[0];
|
|
60
|
+
const { abi, address, args, functionName } = contract;
|
|
61
|
+
const callData = (0, import_viem.encodeFunctionData)({ abi, args, functionName });
|
|
62
|
+
const request2 = {
|
|
63
|
+
batch: false,
|
|
64
|
+
data: callData,
|
|
65
|
+
to: address,
|
|
66
|
+
blockNumber: rest.blockNumber,
|
|
67
|
+
blockTag: rest.blockTag,
|
|
68
|
+
gas: rest.gas,
|
|
69
|
+
account: rest.account ? (0, import_utils.parseAccount)(rest.account) : client.account,
|
|
70
|
+
value: rest.value
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const { data } = await (0, import_utils.getAction)(client, import_actions.call, "call")(request2);
|
|
74
|
+
const result = (0, import_viem.decodeFunctionResult)({
|
|
75
|
+
abi,
|
|
76
|
+
args,
|
|
77
|
+
data: data || "0x",
|
|
78
|
+
functionName
|
|
79
|
+
});
|
|
80
|
+
return [
|
|
81
|
+
result
|
|
82
|
+
];
|
|
83
|
+
} catch (e) {
|
|
84
|
+
throw getSimulateWithPriceUpdatesError(
|
|
85
|
+
e,
|
|
86
|
+
priceUpdates,
|
|
87
|
+
restContracts,
|
|
88
|
+
void 0,
|
|
89
|
+
request2
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
56
93
|
let request;
|
|
57
94
|
try {
|
|
58
95
|
const contracts = [
|
|
@@ -173,8 +210,8 @@ function getSimulateWithPriceUpdatesError(cause, priceUpdates, calls, results, r
|
|
|
173
210
|
return [extractCallError(result), p.pretty, tsValid].filter(Boolean).join(" ");
|
|
174
211
|
});
|
|
175
212
|
const prettyCalls = callsResults.map((c, i) => {
|
|
176
|
-
const
|
|
177
|
-
return [extractCallError(c), `${
|
|
213
|
+
const call2 = calls[i];
|
|
214
|
+
return [extractCallError(c), `${call2.address}.${call2.functionName}`].filter(Boolean).join(" ");
|
|
178
215
|
});
|
|
179
216
|
if (results[0]?.status === "failure") {
|
|
180
217
|
prettyCalls.unshift(
|
|
@@ -48,7 +48,7 @@ const adapterActionSignatures = {
|
|
|
48
48
|
310: "function setPairStatusBatch((address,address,address,uint8)[])",
|
|
49
49
|
311: "function setPairStatusBatch((address,address,address,uint8,uint8)[])"
|
|
50
50
|
},
|
|
51
|
-
[AdapterType.
|
|
51
|
+
[AdapterType.TRADER_JOE_ROUTER]: {
|
|
52
52
|
310: "function setPoolStatusBatch((address,address,uint256,uint8,bool)[])"
|
|
53
53
|
},
|
|
54
54
|
[AdapterType.UNISWAP_V2_ROUTER]: {
|
|
@@ -109,7 +109,7 @@ function createAdapter(options, data, strict) {
|
|
|
109
109
|
return new PendleRouterAdapterContract(options, data);
|
|
110
110
|
case "ADAPTER::STAKING_REWARDS":
|
|
111
111
|
return new StakingRewardsAdapterContract(options, data);
|
|
112
|
-
case "ADAPTER::
|
|
112
|
+
case "ADAPTER::TRADER_JOE_ROUTER":
|
|
113
113
|
return new TraderJoeRouterAdapterContract(options, data);
|
|
114
114
|
case "ADAPTER::UNISWAP_V2_ROUTER":
|
|
115
115
|
return new UniswapV2AdapterContract(options, data);
|
|
@@ -36,7 +36,7 @@ var AdapterType = /* @__PURE__ */ ((AdapterType2) => {
|
|
|
36
36
|
AdapterType2["MIDAS_REDEMPTION_VAULT"] = "MIDAS_REDEMPTION_VAULT";
|
|
37
37
|
AdapterType2["PENDLE_ROUTER"] = "PENDLE_ROUTER";
|
|
38
38
|
AdapterType2["STAKING_REWARDS"] = "STAKING_REWARDS";
|
|
39
|
-
AdapterType2["
|
|
39
|
+
AdapterType2["TRADER_JOE_ROUTER"] = "TRADER_JOE_ROUTER";
|
|
40
40
|
AdapterType2["UNISWAP_V2_ROUTER"] = "UNISWAP_V2_ROUTER";
|
|
41
41
|
AdapterType2["UNISWAP_V3_ROUTER"] = "UNISWAP_V3_ROUTER";
|
|
42
42
|
AdapterType2["UNISWAP_V4_GATEWAY"] = "UNISWAP_V4_GATEWAY";
|
|
@@ -21,40 +21,15 @@ import {
|
|
|
21
21
|
getPoolExtraAPY
|
|
22
22
|
} from "./pool-apy-utils.js";
|
|
23
23
|
const MAP_LABEL = "pools7DAgo";
|
|
24
|
-
const PLUGIN_KEY = "ApyPlugin";
|
|
25
24
|
class ApyPlugin extends BasePlugin {
|
|
26
|
-
#timerInterval;
|
|
27
25
|
#apyUrl;
|
|
28
26
|
#cacheTtlMs;
|
|
29
27
|
#pools7DAgo;
|
|
30
28
|
#apySnapshot;
|
|
31
|
-
|
|
32
|
-
* Default timer options
|
|
33
|
-
* @see PluginTimerOptions
|
|
34
|
-
*/
|
|
35
|
-
#defaultTimerOptions;
|
|
36
|
-
/**
|
|
37
|
-
* When `true`, the timer is started eagerly during the `attach` phase
|
|
38
|
-
* rather than waiting for an explicit `load` call.
|
|
39
|
-
**/
|
|
40
|
-
startTimerOnAttach;
|
|
41
|
-
constructor(loadOnAttach = false, startTimerOnAttach = false, options) {
|
|
29
|
+
constructor(loadOnAttach = false, options) {
|
|
42
30
|
super(loadOnAttach);
|
|
43
|
-
this.startTimerOnAttach = startTimerOnAttach;
|
|
44
31
|
this.#apyUrl = options?.apyUrl ?? APY_STATE_CACHE_URL;
|
|
45
32
|
this.#cacheTtlMs = options?.cacheTtlMs ?? DEFAULT_APY_INTERVAL_MS;
|
|
46
|
-
this.#defaultTimerOptions = options?.timer ?? {
|
|
47
|
-
refreshPools7DAgoOnTick: false,
|
|
48
|
-
intervalMs: DEFAULT_APY_INTERVAL_MS,
|
|
49
|
-
onChange: () => {
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
async attach() {
|
|
54
|
-
await super.attach();
|
|
55
|
-
if (this.startTimerOnAttach) {
|
|
56
|
-
this.startTimer();
|
|
57
|
-
}
|
|
58
33
|
}
|
|
59
34
|
// ---------------------------------------------------------------------------
|
|
60
35
|
// Load — single entry point for all data (on-chain + state-cache)
|
|
@@ -197,48 +172,10 @@ class ApyPlugin extends BasePlugin {
|
|
|
197
172
|
return { data, data7DAgo, pointsBase: poolPointsBase, points };
|
|
198
173
|
}
|
|
199
174
|
// ---------------------------------------------------------------------------
|
|
200
|
-
// Periodic full refresh
|
|
201
|
-
// ---------------------------------------------------------------------------
|
|
202
|
-
/**
|
|
203
|
-
* Starts a periodic timer that performs a full plugin state refresh.
|
|
204
|
-
* Only one timer can be active; calling again is a no-op.
|
|
205
|
-
* @returns Cleanup function that stops the timer.
|
|
206
|
-
*/
|
|
207
|
-
startTimer(opts) {
|
|
208
|
-
if (this.#timerInterval) {
|
|
209
|
-
this.#logger?.debug("plugin timer already running");
|
|
210
|
-
return () => this.stopTimer();
|
|
211
|
-
}
|
|
212
|
-
const intervalMs = opts?.intervalMs ?? this.#defaultTimerOptions.intervalMs;
|
|
213
|
-
this.#logger?.debug(`starting plugin timer (interval: ${intervalMs}ms)`);
|
|
214
|
-
this.#timerInterval = setInterval(async () => {
|
|
215
|
-
try {
|
|
216
|
-
const prevTimestamp = this.#apySnapshot?.timestamp;
|
|
217
|
-
await this.load(true, {
|
|
218
|
-
loadPools7DAgo: opts?.refreshPools7DAgoOnTick ?? this.#defaultTimerOptions.refreshPools7DAgoOnTick
|
|
219
|
-
});
|
|
220
|
-
if (this.#apySnapshot?.timestamp !== prevTimestamp) {
|
|
221
|
-
opts?.onChange?.() ?? this.#defaultTimerOptions.onChange?.();
|
|
222
|
-
await this.sdk.triggerPluginUpdate(PLUGIN_KEY);
|
|
223
|
-
}
|
|
224
|
-
} catch (e) {
|
|
225
|
-
this.#logger?.error(e, "periodic refresh failed");
|
|
226
|
-
}
|
|
227
|
-
}, intervalMs);
|
|
228
|
-
return () => this.stopTimer();
|
|
229
|
-
}
|
|
230
|
-
stopTimer() {
|
|
231
|
-
if (this.#timerInterval) {
|
|
232
|
-
clearInterval(this.#timerInterval);
|
|
233
|
-
this.#timerInterval = void 0;
|
|
234
|
-
this.#logger?.debug("plugin timer stopped");
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
// ---------------------------------------------------------------------------
|
|
238
175
|
// Plugin lifecycle
|
|
239
176
|
// ---------------------------------------------------------------------------
|
|
240
177
|
async syncState() {
|
|
241
|
-
await this.load(
|
|
178
|
+
await this.load();
|
|
242
179
|
}
|
|
243
180
|
stateHuman(_) {
|
|
244
181
|
return this.pools7DAgo.values().flatMap((p) => ({
|
|
@@ -101,17 +101,6 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
101
101
|
* @see {@link SDKHooks} for available event names.
|
|
102
102
|
**/
|
|
103
103
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
104
|
-
/**
|
|
105
|
-
* Triggers the `pluginUpdate` hook.
|
|
106
|
-
*
|
|
107
|
-
* Intended to be called by plugins when they update their internal state
|
|
108
|
-
* outside of the normal `syncState`/`rehydrate` cycle (e.g. via an
|
|
109
|
-
* internal timer). Frontend listeners registered with
|
|
110
|
-
* `sdk.addHook("pluginUpdate", …)` will be notified.
|
|
111
|
-
**/
|
|
112
|
-
async triggerPluginUpdate(plugin) {
|
|
113
|
-
await this.#hooks.triggerHooks("pluginUpdate", { plugin });
|
|
114
|
-
}
|
|
115
104
|
/**
|
|
116
105
|
* Creates and initialises a new SDK instance by reading live on-chain state.
|
|
117
106
|
*
|
|
@@ -192,7 +181,7 @@ class GearboxSDK extends ChainContractsRegister {
|
|
|
192
181
|
plugin.sdk = this;
|
|
193
182
|
}
|
|
194
183
|
if (options.gasLimit !== null) {
|
|
195
|
-
this.gasLimit = options.gasLimit ||
|
|
184
|
+
this.gasLimit = options.gasLimit || getChain(this.networkType).gasLimit;
|
|
196
185
|
}
|
|
197
186
|
}
|
|
198
187
|
async #attach(opts) {
|
|
@@ -72,7 +72,8 @@ const chains = {
|
|
|
72
72
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
73
73
|
symbol: "USDC"
|
|
74
74
|
},
|
|
75
|
-
firstBlock: 22358644n
|
|
75
|
+
firstBlock: 22358644n,
|
|
76
|
+
gasLimit: 550000000n
|
|
76
77
|
},
|
|
77
78
|
"ethereum-rpc"
|
|
78
79
|
),
|
|
@@ -88,7 +89,8 @@ const chains = {
|
|
|
88
89
|
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
89
90
|
symbol: "USDC"
|
|
90
91
|
},
|
|
91
|
-
firstBlock: 184650310n
|
|
92
|
+
firstBlock: 184650310n,
|
|
93
|
+
gasLimit: 550000000n
|
|
92
94
|
},
|
|
93
95
|
"arbitrum-one-rpc"
|
|
94
96
|
),
|
|
@@ -105,7 +107,8 @@ const chains = {
|
|
|
105
107
|
address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
106
108
|
symbol: "USDC"
|
|
107
109
|
},
|
|
108
|
-
firstBlock: 118410666n
|
|
110
|
+
firstBlock: 118410666n,
|
|
111
|
+
gasLimit: 550000000n
|
|
109
112
|
},
|
|
110
113
|
"optimism-rpc"
|
|
111
114
|
),
|
|
@@ -118,7 +121,8 @@ const chains = {
|
|
|
118
121
|
wellKnownToken: {
|
|
119
122
|
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
120
123
|
symbol: "USDC"
|
|
121
|
-
}
|
|
124
|
+
},
|
|
125
|
+
gasLimit: 550000000n
|
|
122
126
|
},
|
|
123
127
|
"base-rpc"
|
|
124
128
|
),
|
|
@@ -141,6 +145,7 @@ const chains = {
|
|
|
141
145
|
address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
142
146
|
symbol: "USDC"
|
|
143
147
|
},
|
|
148
|
+
gasLimit: 550000000n,
|
|
144
149
|
firstBlock: 9779380n
|
|
145
150
|
}),
|
|
146
151
|
"sonic-rpc"
|
|
@@ -153,7 +158,8 @@ const chains = {
|
|
|
153
158
|
wellKnownToken: {
|
|
154
159
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
155
160
|
symbol: "USDm"
|
|
156
|
-
}
|
|
161
|
+
},
|
|
162
|
+
gasLimit: 550000000n
|
|
157
163
|
}),
|
|
158
164
|
// NOTE: Monad chain configs should be updated once the public mainnet is available
|
|
159
165
|
Monad: defineChain({
|
|
@@ -174,7 +180,8 @@ const chains = {
|
|
|
174
180
|
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
175
181
|
symbol: "USDT0"
|
|
176
182
|
},
|
|
177
|
-
firstBlock: 34650262n
|
|
183
|
+
firstBlock: 34650262n,
|
|
184
|
+
gasLimit: 200000000n
|
|
178
185
|
}),
|
|
179
186
|
Berachain: withPublicNode(
|
|
180
187
|
{
|
|
@@ -192,7 +199,8 @@ const chains = {
|
|
|
192
199
|
wellKnownToken: {
|
|
193
200
|
address: "0x549943e04f40284185054145c6e4e9568c1d3241",
|
|
194
201
|
symbol: "USDC.e"
|
|
195
|
-
}
|
|
202
|
+
},
|
|
203
|
+
gasLimit: 550000000n
|
|
196
204
|
},
|
|
197
205
|
"berachain-rpc"
|
|
198
206
|
),
|
|
@@ -205,7 +213,8 @@ const chains = {
|
|
|
205
213
|
wellKnownToken: {
|
|
206
214
|
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
207
215
|
symbol: "USDC"
|
|
208
|
-
}
|
|
216
|
+
},
|
|
217
|
+
gasLimit: 550000000n
|
|
209
218
|
},
|
|
210
219
|
"avalanche-c-chain-rpc"
|
|
211
220
|
),
|
|
@@ -223,7 +232,8 @@ const chains = {
|
|
|
223
232
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
224
233
|
symbol: "USDC"
|
|
225
234
|
},
|
|
226
|
-
firstBlock: 48761804n
|
|
235
|
+
firstBlock: 48761804n,
|
|
236
|
+
gasLimit: 550000000n
|
|
227
237
|
},
|
|
228
238
|
"bsc-rpc"
|
|
229
239
|
),
|
|
@@ -235,8 +245,9 @@ const chains = {
|
|
|
235
245
|
wellKnownToken: {
|
|
236
246
|
address: "0x79a02482a880bce3f13e09da970dc34db4cd24d1",
|
|
237
247
|
symbol: "USDC"
|
|
238
|
-
}
|
|
248
|
+
},
|
|
239
249
|
// TODO: has no block explorer API
|
|
250
|
+
gasLimit: 550000000n
|
|
240
251
|
}),
|
|
241
252
|
Etherlink: defineChain({
|
|
242
253
|
...etherlink,
|
|
@@ -249,7 +260,8 @@ const chains = {
|
|
|
249
260
|
address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
|
|
250
261
|
symbol: "USDC"
|
|
251
262
|
},
|
|
252
|
-
firstBlock: 16672963n
|
|
263
|
+
firstBlock: 16672963n,
|
|
264
|
+
gasLimit: 550000000n
|
|
253
265
|
}),
|
|
254
266
|
Hemi: defineChain({
|
|
255
267
|
...hemi,
|
|
@@ -267,7 +279,8 @@ const chains = {
|
|
|
267
279
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
268
280
|
blockCreated: 484490
|
|
269
281
|
}
|
|
270
|
-
}
|
|
282
|
+
},
|
|
283
|
+
gasLimit: 550000000n
|
|
271
284
|
}),
|
|
272
285
|
Lisk: defineChain({
|
|
273
286
|
...lisk,
|
|
@@ -279,7 +292,8 @@ const chains = {
|
|
|
279
292
|
wellKnownToken: {
|
|
280
293
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
281
294
|
symbol: "USDC.e"
|
|
282
|
-
}
|
|
295
|
+
},
|
|
296
|
+
gasLimit: 550000000n
|
|
283
297
|
}),
|
|
284
298
|
Plasma: defineChain({
|
|
285
299
|
...plasma,
|
|
@@ -300,7 +314,8 @@ const chains = {
|
|
|
300
314
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11"
|
|
301
315
|
}
|
|
302
316
|
},
|
|
303
|
-
firstBlock: 670913n
|
|
317
|
+
firstBlock: 670913n,
|
|
318
|
+
gasLimit: 550000000n
|
|
304
319
|
}),
|
|
305
320
|
Somnia: defineChain({
|
|
306
321
|
...somnia,
|
|
@@ -320,7 +335,8 @@ const chains = {
|
|
|
320
335
|
address: "0x67B302E35Aef5EEE8c32D934F5856869EF428330",
|
|
321
336
|
symbol: "USDT"
|
|
322
337
|
},
|
|
323
|
-
firstBlock: 147687380n
|
|
338
|
+
firstBlock: 147687380n,
|
|
339
|
+
gasLimit: 550000000n
|
|
324
340
|
})
|
|
325
341
|
};
|
|
326
342
|
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
package/dist/esm/sdk/options.js
CHANGED
|
@@ -54,7 +54,7 @@ const SDKOptions = z.object({
|
|
|
54
54
|
/**
|
|
55
55
|
* Explicit gas limit for read-only `eth_call` requests.
|
|
56
56
|
* `null` disables the gas limit entirely; `undefined` uses the SDK default.
|
|
57
|
-
* Default
|
|
57
|
+
* Default to value from {@link GearboxChain.gasLimit}
|
|
58
58
|
**/
|
|
59
59
|
gasLimit: z.bigint().nonnegative().nullable().optional()
|
|
60
60
|
});
|
|
@@ -3,8 +3,12 @@ import {
|
|
|
3
3
|
CallExecutionError,
|
|
4
4
|
ContractFunctionRevertedError,
|
|
5
5
|
decodeFunctionData,
|
|
6
|
+
decodeFunctionResult,
|
|
7
|
+
encodeFunctionData,
|
|
6
8
|
parseAbi
|
|
7
9
|
} from "viem";
|
|
10
|
+
import { call } from "viem/actions";
|
|
11
|
+
import { getAction, parseAccount } from "viem/utils";
|
|
8
12
|
import { errorAbis } from "../../../abi/errors.js";
|
|
9
13
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
10
14
|
import { generateCastTraceCall } from "./cast.js";
|
|
@@ -34,6 +38,41 @@ async function simulateWithPriceUpdates(client, parameters) {
|
|
|
34
38
|
"client chain not configured. multicallAddress is required."
|
|
35
39
|
);
|
|
36
40
|
}
|
|
41
|
+
if (priceUpdates.length === 0 && restContracts.length === 1) {
|
|
42
|
+
const contract = restContracts[0];
|
|
43
|
+
const { abi, address, args, functionName } = contract;
|
|
44
|
+
const callData = encodeFunctionData({ abi, args, functionName });
|
|
45
|
+
const request2 = {
|
|
46
|
+
batch: false,
|
|
47
|
+
data: callData,
|
|
48
|
+
to: address,
|
|
49
|
+
blockNumber: rest.blockNumber,
|
|
50
|
+
blockTag: rest.blockTag,
|
|
51
|
+
gas: rest.gas,
|
|
52
|
+
account: rest.account ? parseAccount(rest.account) : client.account,
|
|
53
|
+
value: rest.value
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
const { data } = await getAction(client, call, "call")(request2);
|
|
57
|
+
const result = decodeFunctionResult({
|
|
58
|
+
abi,
|
|
59
|
+
args,
|
|
60
|
+
data: data || "0x",
|
|
61
|
+
functionName
|
|
62
|
+
});
|
|
63
|
+
return [
|
|
64
|
+
result
|
|
65
|
+
];
|
|
66
|
+
} catch (e) {
|
|
67
|
+
throw getSimulateWithPriceUpdatesError(
|
|
68
|
+
e,
|
|
69
|
+
priceUpdates,
|
|
70
|
+
restContracts,
|
|
71
|
+
void 0,
|
|
72
|
+
request2
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
37
76
|
let request;
|
|
38
77
|
try {
|
|
39
78
|
const contracts = [
|
|
@@ -154,8 +193,8 @@ function getSimulateWithPriceUpdatesError(cause, priceUpdates, calls, results, r
|
|
|
154
193
|
return [extractCallError(result), p.pretty, tsValid].filter(Boolean).join(" ");
|
|
155
194
|
});
|
|
156
195
|
const prettyCalls = callsResults.map((c, i) => {
|
|
157
|
-
const
|
|
158
|
-
return [extractCallError(c), `${
|
|
196
|
+
const call2 = calls[i];
|
|
197
|
+
return [extractCallError(c), `${call2.address}.${call2.functionName}`].filter(Boolean).join(" ");
|
|
159
198
|
});
|
|
160
199
|
if (results[0]?.status === "failure") {
|
|
161
200
|
prettyCalls.unshift(
|
|
@@ -2,7 +2,7 @@ import type { AbiParameter, Address } from "viem";
|
|
|
2
2
|
import type { BaseContractStateHuman } from "../../sdk/types/state-human.js";
|
|
3
3
|
import type { LegacyAdapterOperation } from "./legacyAdapterOperations.js";
|
|
4
4
|
export type VersionedAbi = Record<number, readonly AbiParameter[]>;
|
|
5
|
-
export type AdapterContractType = "ADAPTER::ACCOUNT_MIGRATOR" | "ADAPTER::BALANCER_V3_ROUTER" | "ADAPTER::BALANCER_V3_WRAPPER" | "ADAPTER::BALANCER_VAULT" | "ADAPTER::CAMELOT_V3_ROUTER" | "ADAPTER::CURVE_STABLE_NG" | "ADAPTER::CURVE_V1_2ASSETS" | "ADAPTER::CURVE_V1_3ASSETS" | "ADAPTER::CURVE_V1_4ASSETS" | "ADAPTER::CURVE_V1_STECRV_POOL" | "ADAPTER::CURVE_V1_WRAPPER" | "ADAPTER::CVX_V1_BASE_REWARD_POOL" | "ADAPTER::CVX_V1_BOOSTER" | "ADAPTER::DAI_USDS_EXCHANGE" | "ADAPTER::EQUALIZER_ROUTER" | "ADAPTER::ERC4626_VAULT" | "ADAPTER::ERC4626_VAULT_REFERRAL" | "ADAPTER::FLUID_DEX" | "ADAPTER::INFINIFI_GATEWAY" | "ADAPTER::INFINIFI_UNWINDING" | "ADAPTER::INFRARED_VAULT" | "ADAPTER::KELP_DEPOSIT_POOL" | "ADAPTER::KELP_WITHDRAWAL" | "ADAPTER::KODIAK_ISLAND_GATEWAY" | "ADAPTER::LIDO_V1" | "ADAPTER::LIDO_WSTETH_V1" | "ADAPTER::MELLOW_CLAIMER" | "ADAPTER::MELLOW_DVV" | "ADAPTER::MELLOW_ERC4626_VAULT" | "ADAPTER::MELLOW_LRT_VAULT" | "ADAPTER::MELLOW_WRAPPER" | "ADAPTER::MELLOW_DEPOSIT_QUEUE_QUEUE" | "ADAPTER::MELLOW_REDEEM_QUEUE_QUEUE" | "ADAPTER::MIDAS_ISSUANCE_VAULT" | "ADAPTER::MIDAS_REDEMPTION_VAULT" | "ADAPTER::PENDLE_ROUTER" | "ADAPTER::STAKING_REWARDS" | "ADAPTER::
|
|
5
|
+
export type AdapterContractType = "ADAPTER::ACCOUNT_MIGRATOR" | "ADAPTER::BALANCER_V3_ROUTER" | "ADAPTER::BALANCER_V3_WRAPPER" | "ADAPTER::BALANCER_VAULT" | "ADAPTER::CAMELOT_V3_ROUTER" | "ADAPTER::CURVE_STABLE_NG" | "ADAPTER::CURVE_V1_2ASSETS" | "ADAPTER::CURVE_V1_3ASSETS" | "ADAPTER::CURVE_V1_4ASSETS" | "ADAPTER::CURVE_V1_STECRV_POOL" | "ADAPTER::CURVE_V1_WRAPPER" | "ADAPTER::CVX_V1_BASE_REWARD_POOL" | "ADAPTER::CVX_V1_BOOSTER" | "ADAPTER::DAI_USDS_EXCHANGE" | "ADAPTER::EQUALIZER_ROUTER" | "ADAPTER::ERC4626_VAULT" | "ADAPTER::ERC4626_VAULT_REFERRAL" | "ADAPTER::FLUID_DEX" | "ADAPTER::INFINIFI_GATEWAY" | "ADAPTER::INFINIFI_UNWINDING" | "ADAPTER::INFRARED_VAULT" | "ADAPTER::KELP_DEPOSIT_POOL" | "ADAPTER::KELP_WITHDRAWAL" | "ADAPTER::KODIAK_ISLAND_GATEWAY" | "ADAPTER::LIDO_V1" | "ADAPTER::LIDO_WSTETH_V1" | "ADAPTER::MELLOW_CLAIMER" | "ADAPTER::MELLOW_DVV" | "ADAPTER::MELLOW_ERC4626_VAULT" | "ADAPTER::MELLOW_LRT_VAULT" | "ADAPTER::MELLOW_WRAPPER" | "ADAPTER::MELLOW_DEPOSIT_QUEUE_QUEUE" | "ADAPTER::MELLOW_REDEEM_QUEUE_QUEUE" | "ADAPTER::MIDAS_ISSUANCE_VAULT" | "ADAPTER::MIDAS_REDEMPTION_VAULT" | "ADAPTER::PENDLE_ROUTER" | "ADAPTER::STAKING_REWARDS" | "ADAPTER::TRADER_JOE_ROUTER" | "ADAPTER::UNISWAP_V2_ROUTER" | "ADAPTER::UNISWAP_V3_ROUTER" | "ADAPTER::UNISWAP_V4_GATEWAY" | "ADAPTER::UPSHIFT_VAULT" | "ADAPTER::VELODROME_V2_ROUTER" | "ADAPTER::YEARN_V2";
|
|
6
6
|
export declare enum AdapterType {
|
|
7
7
|
ACCOUNT_MIGRATOR = "ACCOUNT_MIGRATOR",
|
|
8
8
|
BALANCER_V3_ROUTER = "BALANCER_V3_ROUTER",
|
|
@@ -41,7 +41,7 @@ export declare enum AdapterType {
|
|
|
41
41
|
MIDAS_REDEMPTION_VAULT = "MIDAS_REDEMPTION_VAULT",
|
|
42
42
|
PENDLE_ROUTER = "PENDLE_ROUTER",
|
|
43
43
|
STAKING_REWARDS = "STAKING_REWARDS",
|
|
44
|
-
|
|
44
|
+
TRADER_JOE_ROUTER = "TRADER_JOE_ROUTER",
|
|
45
45
|
UNISWAP_V2_ROUTER = "UNISWAP_V2_ROUTER",
|
|
46
46
|
UNISWAP_V3_ROUTER = "UNISWAP_V3_ROUTER",
|
|
47
47
|
UNISWAP_V4_GATEWAY = "UNISWAP_V4_GATEWAY",
|
|
@@ -9,9 +9,8 @@ export interface ApyPluginState {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ApyPluginConstructorOptions {
|
|
11
11
|
apyUrl?: string;
|
|
12
|
-
/** TTL for the shared HTTP cache in milliseconds (default:
|
|
12
|
+
/** TTL for the shared HTTP cache in milliseconds (default: 10 minutes, see `DEFAULT_APY_INTERVAL_MS`) */
|
|
13
13
|
cacheTtlMs?: number;
|
|
14
|
-
timer?: PluginTimerOptions;
|
|
15
14
|
}
|
|
16
15
|
export interface ApyPluginLoadOptions {
|
|
17
16
|
/**
|
|
@@ -21,25 +20,9 @@ export interface ApyPluginLoadOptions {
|
|
|
21
20
|
*/
|
|
22
21
|
loadPools7DAgo?: boolean;
|
|
23
22
|
}
|
|
24
|
-
export interface PluginTimerOptions {
|
|
25
|
-
/** Polling interval in milliseconds (default: 10 minutes) */
|
|
26
|
-
intervalMs?: number;
|
|
27
|
-
/** Callback fired after each successful refresh */
|
|
28
|
-
onChange?: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* When `true`, each tick also refreshes 7d-ago pool state on-chain.
|
|
31
|
-
*/
|
|
32
|
-
refreshPools7DAgoOnTick?: boolean;
|
|
33
|
-
}
|
|
34
23
|
export declare class ApyPlugin extends BasePlugin<ApyPluginState> implements IGearboxSDKPlugin<ApyPluginState> {
|
|
35
24
|
#private;
|
|
36
|
-
|
|
37
|
-
* When `true`, the timer is started eagerly during the `attach` phase
|
|
38
|
-
* rather than waiting for an explicit `load` call.
|
|
39
|
-
**/
|
|
40
|
-
readonly startTimerOnAttach: boolean;
|
|
41
|
-
constructor(loadOnAttach?: boolean, startTimerOnAttach?: boolean, options?: ApyPluginConstructorOptions);
|
|
42
|
-
attach(): Promise<void>;
|
|
25
|
+
constructor(loadOnAttach?: boolean, options?: ApyPluginConstructorOptions);
|
|
43
26
|
load(force?: boolean, loadOptions?: ApyPluginLoadOptions): Promise<ApyPluginState>;
|
|
44
27
|
get loaded(): boolean;
|
|
45
28
|
/**
|
|
@@ -56,13 +39,6 @@ export declare class ApyPlugin extends BasePlugin<ApyPluginState> implements IGe
|
|
|
56
39
|
* @throws if plugin is not loaded
|
|
57
40
|
*/
|
|
58
41
|
getPoolsAPY(): GetPoolsAPYResult;
|
|
59
|
-
/**
|
|
60
|
-
* Starts a periodic timer that performs a full plugin state refresh.
|
|
61
|
-
* Only one timer can be active; calling again is a no-op.
|
|
62
|
-
* @returns Cleanup function that stops the timer.
|
|
63
|
-
*/
|
|
64
|
-
startTimer(opts?: PluginTimerOptions): () => void;
|
|
65
|
-
stopTimer(): void;
|
|
66
42
|
syncState(): Promise<void>;
|
|
67
43
|
stateHuman(_?: boolean): Pools7DAgoStateHuman[];
|
|
68
44
|
get state(): ApyPluginState;
|
|
@@ -115,13 +115,6 @@ export interface SyncStateOptions {
|
|
|
115
115
|
**/
|
|
116
116
|
ignoreUpdateablePrices?: boolean;
|
|
117
117
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Payload carried by the `pluginUpdate` hook.
|
|
120
|
-
**/
|
|
121
|
-
export interface PluginUpdateInfo {
|
|
122
|
-
/** Identifier of the plugin that triggered the update (e.g. `"pools7DAgo"`). */
|
|
123
|
-
plugin: string;
|
|
124
|
-
}
|
|
125
118
|
/**
|
|
126
119
|
* Hook event map for the SDK lifecycle.
|
|
127
120
|
*
|
|
@@ -130,13 +123,10 @@ export interface PluginUpdateInfo {
|
|
|
130
123
|
*
|
|
131
124
|
* - `syncState` — fired after {@link GearboxSDK.syncState} completes.
|
|
132
125
|
* - `rehydrate` — fired after {@link GearboxSDK.rehydrate} completes.
|
|
133
|
-
* - `pluginUpdate` — fired by a plugin when its internal state changes
|
|
134
|
-
* outside of the normal `syncState`/`rehydrate` cycle (e.g. timer tick).
|
|
135
126
|
**/
|
|
136
127
|
export type SDKHooks = {
|
|
137
128
|
syncState: [SyncStateOptions];
|
|
138
129
|
rehydrate: [SyncStateOptions];
|
|
139
|
-
pluginUpdate: [PluginUpdateInfo];
|
|
140
130
|
};
|
|
141
131
|
/**
|
|
142
132
|
* Main entry point for the Gearbox SDK.
|
|
@@ -185,15 +175,6 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> extends C
|
|
|
185
175
|
* @see {@link SDKHooks} for available event names.
|
|
186
176
|
**/
|
|
187
177
|
removeHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
|
|
188
|
-
/**
|
|
189
|
-
* Triggers the `pluginUpdate` hook.
|
|
190
|
-
*
|
|
191
|
-
* Intended to be called by plugins when they update their internal state
|
|
192
|
-
* outside of the normal `syncState`/`rehydrate` cycle (e.g. via an
|
|
193
|
-
* internal timer). Frontend listeners registered with
|
|
194
|
-
* `sdk.addHook("pluginUpdate", …)` will be notified.
|
|
195
|
-
**/
|
|
196
|
-
triggerPluginUpdate(plugin: string): Promise<void>;
|
|
197
178
|
/**
|
|
198
179
|
* Creates and initialises a new SDK instance by reading live on-chain state.
|
|
199
180
|
*
|
|
@@ -5,6 +5,7 @@ import type { gaugeCompressorAbi } from "../../abi/compressors/gaugeCompressor.j
|
|
|
5
5
|
import type { marketCompressorAbi } from "../../abi/compressors/marketCompressor.js";
|
|
6
6
|
import type { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
7
7
|
import type { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
8
|
+
import type { NetworkType } from "../chain/index.js";
|
|
8
9
|
/**
|
|
9
10
|
* Recursively unwraps array types to their element type.
|
|
10
11
|
**/
|
|
@@ -244,6 +245,14 @@ export interface IBaseContract {
|
|
|
244
245
|
* labeling methods for user-facing output.
|
|
245
246
|
*/
|
|
246
247
|
readonly name: string;
|
|
248
|
+
/**
|
|
249
|
+
* Chain ID of the contract.
|
|
250
|
+
**/
|
|
251
|
+
readonly chainId: number;
|
|
252
|
+
/**
|
|
253
|
+
* Network type of the contract.
|
|
254
|
+
**/
|
|
255
|
+
readonly networkType: NetworkType;
|
|
247
256
|
/**
|
|
248
257
|
* @internal
|
|
249
258
|
* `true` when the local state has diverged from on-chain and needs a sync.
|
|
@@ -42,6 +42,10 @@ export interface GearboxChain extends Chain {
|
|
|
42
42
|
* Block number when the Gearbox address provider was deployed.
|
|
43
43
|
**/
|
|
44
44
|
firstBlock?: bigint;
|
|
45
|
+
/**
|
|
46
|
+
* Default read-only calls gas limit for this chain.
|
|
47
|
+
*/
|
|
48
|
+
gasLimit: bigint;
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Tuple of all network labels the SDK can work with.
|