@gearbox-protocol/sdk 7.11.0 → 8.0.0-next.2
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/dev/index.js +0 -2
- package/dist/cjs/{dev → plugins/accounts-counter}/AccountsCounterPlugin.js +22 -17
- package/dist/cjs/{sdk/sdk-legacy/pathfinder → plugins/accounts-counter}/index.js +4 -4
- package/dist/cjs/{adapters → plugins/adapters}/AbstractAdapter.js +1 -1
- package/dist/cjs/{adapters → plugins/adapters}/AdaptersPlugin.js +7 -7
- package/dist/cjs/{adapters → plugins/adapters}/UniswapV2AdapterContract.js +1 -1
- package/dist/cjs/{adapters → plugins/adapters}/UniswapV3AdapterContract.js +1 -1
- package/dist/cjs/{bots → plugins/bots}/BotsPlugin.js +29 -29
- package/dist/cjs/{bots → plugins/bots}/PartialLiquidationBotBaseContract.js +1 -1
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +103 -0
- package/dist/cjs/plugins/degen-distributors/index.js +24 -0
- package/dist/cjs/plugins/degen-distributors/package.json +1 -0
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +109 -0
- package/dist/cjs/plugins/pools-history/index.js +24 -0
- package/dist/cjs/plugins/pools-history/package.json +1 -0
- package/dist/cjs/{sdk/sdk-legacy/pathfinder/core.js → plugins/pools-history/types.js} +2 -2
- package/dist/cjs/{zappers → plugins/zappers}/ZappersPlugin.js +11 -9
- package/dist/cjs/plugins/zappers/package.json +1 -0
- package/dist/cjs/plugins/zappers/types.js +16 -0
- package/dist/cjs/sdk/GearboxSDK.js +18 -11
- package/dist/cjs/sdk/accounts/CreditAccountsService.js +15 -6
- package/dist/cjs/sdk/chain/chains.js +9 -8
- package/dist/cjs/sdk/plugins/BasePlugin.js +69 -0
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +14 -15
- package/dist/cjs/sdk/plugins/index.js +2 -0
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +94 -159
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/cjs/sdk/sdk-legacy/index.js +0 -2
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +0 -1
- package/dist/esm/dev/index.js +0 -1
- package/dist/esm/{dev → plugins/accounts-counter}/AccountsCounterPlugin.js +23 -18
- package/dist/esm/plugins/accounts-counter/index.js +1 -0
- package/dist/esm/{adapters → plugins/adapters}/AbstractAdapter.js +1 -1
- package/dist/esm/{adapters → plugins/adapters}/AdaptersPlugin.js +7 -7
- package/dist/esm/{adapters → plugins/adapters}/UniswapV2AdapterContract.js +1 -1
- package/dist/esm/{adapters → plugins/adapters}/UniswapV3AdapterContract.js +1 -1
- package/dist/esm/{bots → plugins/bots}/BotsPlugin.js +30 -30
- package/dist/esm/{bots → plugins/bots}/PartialLiquidationBotBaseContract.js +1 -1
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +79 -0
- package/dist/esm/plugins/degen-distributors/index.js +2 -0
- package/dist/esm/plugins/degen-distributors/package.json +1 -0
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +92 -0
- package/dist/esm/plugins/pools-history/index.js +2 -0
- package/dist/esm/plugins/pools-history/package.json +1 -0
- package/dist/esm/{zappers → plugins/zappers}/ZappersPlugin.js +12 -10
- package/dist/esm/plugins/zappers/package.json +1 -0
- package/dist/esm/plugins/zappers/types.js +0 -0
- package/dist/esm/sdk/GearboxSDK.js +18 -11
- package/dist/esm/sdk/accounts/CreditAccountsService.js +16 -10
- package/dist/esm/sdk/chain/chains.js +9 -8
- package/dist/esm/sdk/plugins/BasePlugin.js +45 -0
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +14 -15
- package/dist/esm/sdk/plugins/index.js +1 -0
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +94 -159
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/esm/sdk/sdk-legacy/index.js +0 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +0 -1
- package/dist/types/dev/index.d.ts +0 -1
- package/dist/types/plugins/accounts-counter/AccountsCounterPlugin.d.ts +19 -0
- package/dist/types/plugins/accounts-counter/index.d.ts +1 -0
- package/dist/types/{adapters → plugins/adapters}/AbstractAdapter.d.ts +2 -2
- package/dist/types/plugins/adapters/AdaptersPlugin.d.ts +11 -0
- package/dist/types/{adapters → plugins/adapters}/BalancerV2VaultAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/BalancerV3RouterAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/CamelotV3AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/ConvexV1BaseRewardPoolAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/ConvexV1BoosterAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/Curve2AssetsAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/Curve3AssetsAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/Curve4AssetsAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/CurveV1AdapterDeposit.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/CurveV1AdapterStETHContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/CurveV1StableNGAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/DaiUsdsAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/ERC4626AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/EqualizerRouterAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/MellowERC4626VaultAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/MellowVaultAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/PendleRouterAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/StakingRewardsAdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/UniswapV2AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/UniswapV3AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/VelodromeV2AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/WstETHV1AdapterContract.d.ts +1 -1
- package/dist/types/{adapters → plugins/adapters}/YearnV2AdapterContract.d.ts +1 -1
- package/dist/types/{bots → plugins/bots}/BotsPlugin.d.ts +7 -8
- package/dist/types/{bots → plugins/bots}/PartialLiquidationBotBaseContract.d.ts +2 -2
- package/dist/types/{bots → plugins/bots}/PartialLiquidationBotV300Contract.d.ts +1 -1
- package/dist/types/{bots → plugins/bots}/PartialLiquidationBotV310Contract.d.ts +1 -1
- package/dist/types/{bots → plugins/bots}/types.d.ts +3 -3
- package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +20 -0
- package/dist/types/plugins/degen-distributors/index.d.ts +2 -0
- package/dist/types/plugins/degen-distributors/types.d.ts +4 -0
- package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +20 -0
- package/dist/types/plugins/pools-history/index.d.ts +2 -0
- package/dist/types/plugins/pools-history/types.d.ts +9 -0
- package/dist/types/plugins/zappers/ZappersPlugin.d.ts +16 -0
- package/dist/types/{zappers → plugins/zappers}/types.d.ts +2 -2
- package/dist/types/sdk/GearboxSDK.d.ts +6 -5
- package/dist/types/sdk/plugins/BasePlugin.d.ts +20 -0
- package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +7 -8
- package/dist/types/sdk/plugins/index.d.ts +1 -0
- package/dist/types/sdk/plugins/types.d.ts +37 -21
- package/dist/types/sdk/sdk-legacy/gearboxRewards/api.d.ts +16 -27
- package/dist/types/sdk/sdk-legacy/gearboxRewards/apy.d.ts +9 -15
- package/dist/types/sdk/sdk-legacy/index.d.ts +0 -1
- package/package.json +5 -15
- package/dist/esm/sdk/sdk-legacy/pathfinder/index.js +0 -1
- package/dist/types/adapters/AdaptersPlugin.d.ts +0 -10
- package/dist/types/dev/AccountsCounterPlugin.d.ts +0 -19
- package/dist/types/sdk/sdk-legacy/pathfinder/core.d.ts +0 -14
- package/dist/types/sdk/sdk-legacy/pathfinder/index.d.ts +0 -1
- package/dist/types/zappers/ZappersPlugin.d.ts +0 -17
- /package/dist/cjs/{adapters → plugins/accounts-counter}/package.json +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/BalancerV2VaultAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/BalancerV3RouterAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/CamelotV3AdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/ConvexV1BaseRewardPoolAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/ConvexV1BoosterAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/Curve2AssetsAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/Curve3AssetsAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/Curve4AssetsAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/CurveV1AdapterDeposit.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/CurveV1AdapterStETHContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/CurveV1StableNGAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/DaiUsdsAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/ERC4626AdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/EqualizerRouterAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/MellowERC4626VaultAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/MellowVaultAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/PendleRouterAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/StakingRewardsAdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/VelodromeV2AdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/WstETHV1AdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/YearnV2AdapterContract.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/abi/adapters.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/abi/index.js +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/index.js +0 -0
- /package/dist/cjs/{bots → plugins/adapters}/package.json +0 -0
- /package/dist/cjs/{adapters → plugins/adapters}/types.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/PartialLiquidationBotV300Contract.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/PartialLiquidationBotV310Contract.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/abi/iPartialLiquidationBotV300.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/abi/iPartialLiquidationBotV310.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/abi/index.js +0 -0
- /package/dist/cjs/{bots → plugins/bots}/index.js +0 -0
- /package/dist/cjs/{zappers → plugins/bots}/package.json +0 -0
- /package/dist/cjs/{bots → plugins/bots}/types.js +0 -0
- /package/dist/cjs/{zappers → plugins/degen-distributors}/types.js +0 -0
- /package/dist/cjs/{zappers → plugins/zappers}/index.js +0 -0
- /package/dist/esm/{adapters → plugins/accounts-counter}/package.json +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/BalancerV2VaultAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/BalancerV3RouterAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/CamelotV3AdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/ConvexV1BaseRewardPoolAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/ConvexV1BoosterAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/Curve2AssetsAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/Curve3AssetsAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/Curve4AssetsAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/CurveV1AdapterDeposit.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/CurveV1AdapterStETHContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/CurveV1StableNGAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/DaiUsdsAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/ERC4626AdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/EqualizerRouterAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/MellowERC4626VaultAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/MellowVaultAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/PendleRouterAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/StakingRewardsAdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/VelodromeV2AdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/WstETHV1AdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/YearnV2AdapterContract.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/abi/adapters.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/abi/index.js +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/index.js +0 -0
- /package/dist/esm/{bots → plugins/adapters}/package.json +0 -0
- /package/dist/esm/{adapters → plugins/adapters}/types.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/PartialLiquidationBotV300Contract.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/PartialLiquidationBotV310Contract.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/abi/iPartialLiquidationBotV300.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/abi/iPartialLiquidationBotV310.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/abi/index.js +0 -0
- /package/dist/esm/{bots → plugins/bots}/index.js +0 -0
- /package/dist/esm/{zappers → plugins/bots}/package.json +0 -0
- /package/dist/esm/{bots → plugins/bots}/types.js +0 -0
- /package/dist/esm/{zappers → plugins/degen-distributors}/types.js +0 -0
- /package/dist/esm/{sdk/sdk-legacy/pathfinder/core.js → plugins/pools-history/types.js} +0 -0
- /package/dist/esm/{zappers → plugins/zappers}/index.js +0 -0
- /package/dist/types/{adapters → plugins/adapters}/abi/adapters.d.ts +0 -0
- /package/dist/types/{adapters → plugins/adapters}/abi/index.d.ts +0 -0
- /package/dist/types/{adapters → plugins/adapters}/index.d.ts +0 -0
- /package/dist/types/{adapters → plugins/adapters}/types.d.ts +0 -0
- /package/dist/types/{bots → plugins/bots}/abi/iPartialLiquidationBotV300.d.ts +0 -0
- /package/dist/types/{bots → plugins/bots}/abi/iPartialLiquidationBotV310.d.ts +0 -0
- /package/dist/types/{bots → plugins/bots}/abi/index.d.ts +0 -0
- /package/dist/types/{bots → plugins/bots}/index.d.ts +0 -0
- /package/dist/types/{zappers → plugins/zappers}/index.d.ts +0 -0
|
@@ -135,13 +135,10 @@ class GearboxSDK {
|
|
|
135
135
|
this.#provider = options.provider;
|
|
136
136
|
this.logger = options.logger;
|
|
137
137
|
this.strictContractTypes = options.strictContractTypes ?? false;
|
|
138
|
-
|
|
139
|
-
for (const
|
|
140
|
-
|
|
141
|
-
)) {
|
|
142
|
-
pluginsInstances[name] = new Plugin(this);
|
|
138
|
+
this.plugins = options.plugins ?? {};
|
|
139
|
+
for (const plugin of Object.values(this.plugins)) {
|
|
140
|
+
plugin.sdk = this;
|
|
143
141
|
}
|
|
144
|
-
this.plugins = pluginsInstances;
|
|
145
142
|
}
|
|
146
143
|
async #attach(opts) {
|
|
147
144
|
const {
|
|
@@ -244,6 +241,12 @@ class GearboxSDK {
|
|
|
244
241
|
for (const [name, plugin] of import_utils.TypedObjectUtils.entries(this.plugins)) {
|
|
245
242
|
const pluginState = state.plugins[name];
|
|
246
243
|
if (plugin.hydrate && pluginState) {
|
|
244
|
+
if (!pluginState.loaded) {
|
|
245
|
+
this.logger?.debug(
|
|
246
|
+
`skipping ${re}hydrating plugin ${name} state: not loaded`
|
|
247
|
+
);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
247
250
|
if (pluginState.version !== plugin.version) {
|
|
248
251
|
throw new import_plugins.PluginStateVersionError(plugin, pluginState);
|
|
249
252
|
}
|
|
@@ -266,7 +269,7 @@ class GearboxSDK {
|
|
|
266
269
|
/**
|
|
267
270
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
268
271
|
*/
|
|
269
|
-
rehydrate(state) {
|
|
272
|
+
async rehydrate(state) {
|
|
270
273
|
if (!this.#attachConfig) {
|
|
271
274
|
throw new Error("cannot rehydrate, attach config is not set");
|
|
272
275
|
}
|
|
@@ -275,6 +278,10 @@ class GearboxSDK {
|
|
|
275
278
|
redstone: this.#attachConfig.redstone
|
|
276
279
|
};
|
|
277
280
|
this.#hydrate(opts, state);
|
|
281
|
+
await this.#hooks.triggerHooks("rehydrate", {
|
|
282
|
+
blockNumber: state.currentBlock,
|
|
283
|
+
timestamp: state.timestamp
|
|
284
|
+
});
|
|
278
285
|
}
|
|
279
286
|
/**
|
|
280
287
|
* Converts contract call into some human-friendly string
|
|
@@ -337,7 +344,7 @@ class GearboxSDK {
|
|
|
337
344
|
plugins: Object.fromEntries(
|
|
338
345
|
import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
339
346
|
name,
|
|
340
|
-
plugin.stateHuman?.(raw)
|
|
347
|
+
plugin.loaded ? plugin.stateHuman?.(raw) : void 0
|
|
341
348
|
])
|
|
342
349
|
),
|
|
343
350
|
...this.marketRegister.stateHuman(raw)
|
|
@@ -355,7 +362,7 @@ class GearboxSDK {
|
|
|
355
362
|
plugins: Object.fromEntries(
|
|
356
363
|
import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
357
364
|
name,
|
|
358
|
-
plugin.state
|
|
365
|
+
plugin.loaded ? { version: plugin.version, loaded: true, ...plugin.state } : { version: plugin.version, loaded: false }
|
|
359
366
|
])
|
|
360
367
|
)
|
|
361
368
|
};
|
|
@@ -427,9 +434,9 @@ class GearboxSDK {
|
|
|
427
434
|
);
|
|
428
435
|
pluginResponse.forEach((r, i) => {
|
|
429
436
|
const [name, plugin] = pluginsList[i];
|
|
430
|
-
if (plugin.
|
|
437
|
+
if (plugin.syncState && r.status === "fulfilled") {
|
|
431
438
|
this.logger?.debug(`synced plugin ${name}`);
|
|
432
|
-
} else if (plugin.
|
|
439
|
+
} else if (plugin.syncState && r.status === "rejected") {
|
|
433
440
|
this.logger?.error(r.reason, `failed to sync plugin ${name}`);
|
|
434
441
|
}
|
|
435
442
|
});
|
|
@@ -25,7 +25,6 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_compressors = require("../../abi/compressors.js");
|
|
26
26
|
var import_iBaseRewardPool = require("../../abi/iBaseRewardPool.js");
|
|
27
27
|
var import_v300 = require("../../abi/v300.js");
|
|
28
|
-
var import_adapters = require("../../adapters/abi/adapters.js");
|
|
29
28
|
var import_base = require("../base/index.js");
|
|
30
29
|
var import_constants = require("../constants/index.js");
|
|
31
30
|
var import_router = require("../router/index.js");
|
|
@@ -1126,7 +1125,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1126
1125
|
return {
|
|
1127
1126
|
target: address,
|
|
1128
1127
|
callData: (0, import_viem.encodeFunctionData)({
|
|
1129
|
-
abi:
|
|
1128
|
+
abi: (0, import_viem.parseAbi)([
|
|
1129
|
+
"function withdrawAndUnwrap(uint256, bool claim) returns (uint256 tokensToEnable, uint256 tokensToDisable)"
|
|
1130
|
+
]),
|
|
1130
1131
|
functionName: "withdrawAndUnwrap",
|
|
1131
1132
|
args: [amount, claim]
|
|
1132
1133
|
})
|
|
@@ -1137,7 +1138,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1137
1138
|
return {
|
|
1138
1139
|
target: address,
|
|
1139
1140
|
callData: (0, import_viem.encodeFunctionData)({
|
|
1140
|
-
abi:
|
|
1141
|
+
abi: (0, import_viem.parseAbi)([
|
|
1142
|
+
"function withdrawDiffAndUnwrap(uint256 leftoverAmount, bool claim) returns (uint256 tokensToEnable, uint256 tokensToDisable)"
|
|
1143
|
+
]),
|
|
1141
1144
|
functionName: "withdrawDiffAndUnwrap",
|
|
1142
1145
|
args: [1n, claim]
|
|
1143
1146
|
})
|
|
@@ -1148,7 +1151,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1148
1151
|
return {
|
|
1149
1152
|
target: address,
|
|
1150
1153
|
callData: (0, import_viem.encodeFunctionData)({
|
|
1151
|
-
abi:
|
|
1154
|
+
abi: (0, import_viem.parseAbi)([
|
|
1155
|
+
"function withdrawDiff(uint256 leftoverAmount) external returns (bool useSafePrices)"
|
|
1156
|
+
]),
|
|
1152
1157
|
functionName: "withdrawDiff",
|
|
1153
1158
|
args: [1n]
|
|
1154
1159
|
})
|
|
@@ -1159,7 +1164,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1159
1164
|
return {
|
|
1160
1165
|
target: address,
|
|
1161
1166
|
callData: (0, import_viem.encodeFunctionData)({
|
|
1162
|
-
abi:
|
|
1167
|
+
abi: (0, import_viem.parseAbi)([
|
|
1168
|
+
"function withdraw(uint256 amount) external returns (bool useSafePrices)"
|
|
1169
|
+
]),
|
|
1163
1170
|
functionName: "withdraw",
|
|
1164
1171
|
args: [amount]
|
|
1165
1172
|
})
|
|
@@ -1170,7 +1177,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1170
1177
|
return {
|
|
1171
1178
|
target: address,
|
|
1172
1179
|
callData: (0, import_viem.encodeFunctionData)({
|
|
1173
|
-
abi:
|
|
1180
|
+
abi: (0, import_viem.parseAbi)([
|
|
1181
|
+
"function getReward() external returns (bool useSafePrices)"
|
|
1182
|
+
]),
|
|
1174
1183
|
functionName: "getReward",
|
|
1175
1184
|
args: []
|
|
1176
1185
|
})
|
|
@@ -30,7 +30,6 @@ module.exports = __toCommonJS(chains_exports);
|
|
|
30
30
|
var import_viem = require("viem");
|
|
31
31
|
var import_chains = require("viem/chains");
|
|
32
32
|
var import_zod = require("zod");
|
|
33
|
-
var import_utils = require("../utils/index.js");
|
|
34
33
|
const SUPPORTED_NETWORKS = [
|
|
35
34
|
"Mainnet",
|
|
36
35
|
"Arbitrum",
|
|
@@ -245,6 +244,10 @@ const chains = {
|
|
|
245
244
|
// TODO: has no block explorer API
|
|
246
245
|
})
|
|
247
246
|
};
|
|
247
|
+
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
|
248
|
+
acc[chain.id] = chain.network;
|
|
249
|
+
return acc;
|
|
250
|
+
}, {});
|
|
248
251
|
function getChain(chainIdOrNetworkType) {
|
|
249
252
|
const network = typeof chainIdOrNetworkType === "string" ? chainIdOrNetworkType : getNetworkType(Number(chainIdOrNetworkType));
|
|
250
253
|
const chain = chains[network];
|
|
@@ -254,15 +257,13 @@ function getChain(chainIdOrNetworkType) {
|
|
|
254
257
|
return chain;
|
|
255
258
|
}
|
|
256
259
|
function getNetworkType(chainId) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
throw new Error(`Unsupported network with chainId ${chainId}`);
|
|
260
|
+
const network = networkByChainId[Number(chainId)];
|
|
261
|
+
if (!network) throw new Error(`Unsupported network with chainId ${chainId}`);
|
|
262
|
+
return network;
|
|
263
263
|
}
|
|
264
264
|
function isSupportedNetwork(chainId) {
|
|
265
|
-
|
|
265
|
+
if (chainId === void 0) return false;
|
|
266
|
+
return !!networkByChainId[chainId];
|
|
266
267
|
}
|
|
267
268
|
function isPublicNetwork(networkOrChainId) {
|
|
268
269
|
return Object.values(chains).some((c) => {
|
|
@@ -0,0 +1,69 @@
|
|
|
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 BasePlugin_exports = {};
|
|
20
|
+
__export(BasePlugin_exports, {
|
|
21
|
+
BasePlugin: () => BasePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(BasePlugin_exports);
|
|
24
|
+
class BasePlugin {
|
|
25
|
+
#sdk;
|
|
26
|
+
logger;
|
|
27
|
+
version = 1;
|
|
28
|
+
loadOnAttach;
|
|
29
|
+
constructor(loadOnAttach = false) {
|
|
30
|
+
this.loadOnAttach = loadOnAttach;
|
|
31
|
+
}
|
|
32
|
+
get sdk() {
|
|
33
|
+
if (!this.#sdk) {
|
|
34
|
+
throw new Error("SDK is not attached");
|
|
35
|
+
}
|
|
36
|
+
return this.#sdk;
|
|
37
|
+
}
|
|
38
|
+
set sdk(sdk) {
|
|
39
|
+
if (this.#sdk) {
|
|
40
|
+
throw new Error("SDK is already attached");
|
|
41
|
+
}
|
|
42
|
+
this.#sdk = sdk;
|
|
43
|
+
this.logger = sdk.logger?.child?.({ name: this.constructor.name }) ?? sdk.logger;
|
|
44
|
+
}
|
|
45
|
+
async attach() {
|
|
46
|
+
if (this.loadOnAttach) {
|
|
47
|
+
await this.load(true);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async syncState() {
|
|
51
|
+
await this.load(false);
|
|
52
|
+
}
|
|
53
|
+
get provider() {
|
|
54
|
+
return this.sdk.provider;
|
|
55
|
+
}
|
|
56
|
+
get network() {
|
|
57
|
+
return this.provider.networkType;
|
|
58
|
+
}
|
|
59
|
+
get client() {
|
|
60
|
+
return this.provider.publicClient;
|
|
61
|
+
}
|
|
62
|
+
labelAddress(address) {
|
|
63
|
+
return this.provider.addressLabels.get(address);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
BasePlugin
|
|
69
|
+
});
|
|
@@ -23,32 +23,31 @@ __export(V300StalenessPeriodPlugin_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(V300StalenessPeriodPlugin_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_v300 = require("../../abi/v300.js");
|
|
26
|
-
var import_base = require("../base/index.js");
|
|
27
26
|
var import_constants = require("../constants/index.js");
|
|
28
27
|
var import_market = require("../market/index.js");
|
|
29
28
|
var import_utils = require("../utils/index.js");
|
|
30
29
|
var import_viem2 = require("../utils/viem/index.js");
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var import_BasePlugin = require("./BasePlugin.js");
|
|
31
|
+
class V300StalenessPeriodPlugin extends import_BasePlugin.BasePlugin {
|
|
32
|
+
#syncedTo = 0n;
|
|
33
33
|
#logger;
|
|
34
34
|
#events = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
super
|
|
35
|
+
// eslint-disable-next-line accessor-pairs
|
|
36
|
+
set sdk(sdk) {
|
|
37
|
+
super.sdk = sdk;
|
|
38
38
|
this.#syncedTo = import_constants.ADDRESS_PROVIDER_BLOCK[sdk.provider.networkType] - 1n;
|
|
39
|
-
this.#logger = sdk.logger?.child?.({ name: "V300StalenessPeriodPlugin" }) ?? sdk.logger;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
get loaded() {
|
|
41
|
+
return !!this.#syncedTo;
|
|
43
42
|
}
|
|
44
|
-
async
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
async load(force) {
|
|
44
|
+
if (!force && this.loaded) {
|
|
45
|
+
return this.state;
|
|
46
|
+
}
|
|
48
47
|
const oracles = this.#getOraclesMap();
|
|
49
48
|
const [fromBlock, toBlock] = [this.#syncedTo + 1n, this.sdk.currentBlock];
|
|
50
49
|
if (oracles.size === 0 || fromBlock > toBlock) {
|
|
51
|
-
return;
|
|
50
|
+
return this.state;
|
|
52
51
|
}
|
|
53
52
|
const events = await (0, import_viem2.getLogsSafe)(this.client, {
|
|
54
53
|
address: oracles.keys(),
|
|
@@ -95,10 +94,10 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
this.#syncedTo = toBlock;
|
|
97
|
+
return this.state;
|
|
98
98
|
}
|
|
99
99
|
get state() {
|
|
100
100
|
return {
|
|
101
|
-
version: this.version,
|
|
102
101
|
events: this.#events
|
|
103
102
|
};
|
|
104
103
|
}
|
|
@@ -15,11 +15,13 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var plugins_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(plugins_exports);
|
|
18
|
+
__reExport(plugins_exports, require("./BasePlugin.js"), module.exports);
|
|
18
19
|
__reExport(plugins_exports, require("./errors.js"), module.exports);
|
|
19
20
|
__reExport(plugins_exports, require("./types.js"), module.exports);
|
|
20
21
|
__reExport(plugins_exports, require("./V300StalenessPeriodPlugin.js"), module.exports);
|
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
23
|
0 && (module.exports = {
|
|
24
|
+
...require("./BasePlugin.js"),
|
|
23
25
|
...require("./errors.js"),
|
|
24
26
|
...require("./types.js"),
|
|
25
27
|
...require("./V300StalenessPeriodPlugin.js")
|
|
@@ -41,10 +41,48 @@ var import_endpoint = require("../core/endpoint.js");
|
|
|
41
41
|
var import_math = require("../utils/math.js");
|
|
42
42
|
var import_merklAPI = require("./merklAPI.js");
|
|
43
43
|
class GearboxRewardsApi {
|
|
44
|
-
static async
|
|
44
|
+
static async getLmRewardsV2({
|
|
45
|
+
provider,
|
|
46
|
+
account,
|
|
47
|
+
currentTokenData,
|
|
48
|
+
network,
|
|
49
|
+
airdropDistributorAddress,
|
|
50
|
+
reportError
|
|
51
|
+
}) {
|
|
52
|
+
if (!airdropDistributorAddress) return [];
|
|
53
|
+
const [claimedRespUnsafe, merkleDataRespUnsafe] = await Promise.allSettled([
|
|
54
|
+
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
55
|
+
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
56
|
+
]);
|
|
57
|
+
const claimedResp = this.extractFulfilled(claimedRespUnsafe, reportError, "getLmRewardsV2") || 0n;
|
|
58
|
+
const merkleDataResp = this.extractFulfilled(
|
|
59
|
+
merkleDataRespUnsafe,
|
|
60
|
+
reportError,
|
|
61
|
+
"getLmRewardsV2"
|
|
62
|
+
);
|
|
63
|
+
const amountOnContract = this.getAmountOnContract({
|
|
64
|
+
account,
|
|
65
|
+
merkleData: merkleDataResp
|
|
66
|
+
});
|
|
67
|
+
const diff = amountOnContract - claimedResp;
|
|
68
|
+
const availableToClaimV2 = import_math.BigIntMath.max(0n, diff);
|
|
69
|
+
const rewards = [
|
|
70
|
+
{
|
|
71
|
+
amount: availableToClaimV2,
|
|
72
|
+
type: "merkleV2",
|
|
73
|
+
rewardToken: currentTokenData.GEAR,
|
|
74
|
+
rewardTokenDecimals: 18,
|
|
75
|
+
rewardTokenSymbol: "GEAR"
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
return rewards;
|
|
79
|
+
}
|
|
80
|
+
static async getLmRewardsV3({
|
|
45
81
|
pools,
|
|
82
|
+
tokensList,
|
|
46
83
|
provider,
|
|
47
|
-
|
|
84
|
+
account,
|
|
85
|
+
reportError
|
|
48
86
|
}) {
|
|
49
87
|
const poolByStakedDiesel = Object.values(pools).reduce((acc, p) => {
|
|
50
88
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -55,155 +93,85 @@ class GearboxRewardsApi {
|
|
|
55
93
|
});
|
|
56
94
|
return acc;
|
|
57
95
|
}, {});
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
acc[p.dieselToken] = p.address;
|
|
61
|
-
return acc;
|
|
62
|
-
},
|
|
63
|
-
{}
|
|
64
|
-
);
|
|
65
|
-
const poolByItsToken = { ...poolByStakedDiesel, ...poolByDiesel };
|
|
66
|
-
const poolStakedTokens = import_utils.TypedObjectUtils.keys(poolByStakedDiesel);
|
|
67
|
-
const allPoolTokens = import_utils.TypedObjectUtils.keys(poolByItsToken);
|
|
68
|
-
const farmInfoCalls = poolStakedTokens.map((address) => ({
|
|
96
|
+
const stakedDieselTokens = import_utils.TypedObjectUtils.keys(poolByStakedDiesel);
|
|
97
|
+
const farmInfoCalls = stakedDieselTokens.map((address) => ({
|
|
69
98
|
address,
|
|
70
99
|
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
71
100
|
functionName: "farmInfo",
|
|
72
101
|
args: []
|
|
73
102
|
}));
|
|
74
|
-
const
|
|
75
|
-
address,
|
|
76
|
-
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
77
|
-
functionName: "totalSupply",
|
|
78
|
-
args: []
|
|
79
|
-
}));
|
|
80
|
-
const rewardTokenCalls = poolStakedTokens.map((address) => ({
|
|
103
|
+
const rewardTokenCalls = stakedDieselTokens.map((address) => ({
|
|
81
104
|
address,
|
|
82
105
|
abi: POOL_REWARDS_ABI,
|
|
83
106
|
functionName: "rewardsToken",
|
|
84
107
|
args: []
|
|
85
108
|
}));
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
const farmedCalls = stakedDieselTokens.map((address) => ({
|
|
110
|
+
address,
|
|
111
|
+
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
112
|
+
functionName: "farmed",
|
|
113
|
+
args: [account]
|
|
114
|
+
}));
|
|
115
|
+
const [response] = await Promise.allSettled([
|
|
116
|
+
provider.multicall({
|
|
117
|
+
allowFailure: false,
|
|
118
|
+
contracts: [...farmInfoCalls, ...rewardTokenCalls, ...farmedCalls]
|
|
119
|
+
})
|
|
120
|
+
]);
|
|
121
|
+
const safeResponse = this.extractFulfilled(response, reportError, "v3Rewards") || [];
|
|
92
122
|
const farmInfoCallsEnd = farmInfoCalls.length;
|
|
93
|
-
const farmInfo =
|
|
123
|
+
const farmInfo = safeResponse.slice(
|
|
94
124
|
0,
|
|
95
125
|
farmInfoCallsEnd
|
|
96
126
|
);
|
|
97
|
-
const
|
|
98
|
-
const
|
|
127
|
+
const rewardTokenCallsEnd = farmInfoCallsEnd + rewardTokenCalls.length;
|
|
128
|
+
const rewardTokens = safeResponse.slice(
|
|
99
129
|
farmInfoCallsEnd,
|
|
100
|
-
farmSupplyCallsEnd
|
|
101
|
-
);
|
|
102
|
-
const rewardTokenCallsEnd = farmSupplyCallsEnd + rewardTokenCalls.length;
|
|
103
|
-
const rewardTokens = restMCResponse.slice(
|
|
104
|
-
farmSupplyCallsEnd,
|
|
105
130
|
rewardTokenCallsEnd
|
|
106
131
|
);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return acc;
|
|
112
|
-
},
|
|
113
|
-
{}
|
|
114
|
-
);
|
|
115
|
-
const rewardTokenPool = poolStakedTokens.reduce(
|
|
116
|
-
(acc, p, index) => {
|
|
117
|
-
const token = rewardTokens[index];
|
|
118
|
-
if (token) {
|
|
119
|
-
acc[p] = token.toLowerCase();
|
|
120
|
-
}
|
|
121
|
-
return acc;
|
|
122
|
-
},
|
|
123
|
-
{}
|
|
132
|
+
const farmedCallsEnd = rewardTokenCallsEnd + farmedCalls.length;
|
|
133
|
+
const farmedList = safeResponse.slice(
|
|
134
|
+
rewardTokenCallsEnd,
|
|
135
|
+
farmedCallsEnd
|
|
124
136
|
);
|
|
125
|
-
const
|
|
126
|
-
(
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
{ base: {}, all: {} }
|
|
137
|
+
const gearboxLmRewards = stakedDieselTokens.map(
|
|
138
|
+
(address, i) => {
|
|
139
|
+
const pool = poolByStakedDiesel[address];
|
|
140
|
+
const info = farmInfo[i];
|
|
141
|
+
const rewardToken = rewardTokens[i]?.toLowerCase();
|
|
142
|
+
const farmed = farmedList[i];
|
|
143
|
+
if (!pool || !info || !rewardToken) return void 0;
|
|
144
|
+
return {
|
|
145
|
+
pool,
|
|
146
|
+
poolToken: address,
|
|
147
|
+
rewardToken,
|
|
148
|
+
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
149
|
+
rewardTokenSymbol: tokensList[rewardToken]?.symbol || "unknown",
|
|
150
|
+
amount: farmed ?? 0n,
|
|
151
|
+
type: "stakedV3"
|
|
152
|
+
};
|
|
153
|
+
}
|
|
143
154
|
);
|
|
144
|
-
const
|
|
145
|
-
(acc,
|
|
146
|
-
|
|
155
|
+
const { zero, nonZero } = gearboxLmRewards.reduce(
|
|
156
|
+
(acc, r) => {
|
|
157
|
+
if (r && r.amount > 0n) {
|
|
158
|
+
acc.nonZero.push(r);
|
|
159
|
+
} else if (r) {
|
|
160
|
+
acc.zero.push(r);
|
|
161
|
+
}
|
|
147
162
|
return acc;
|
|
148
163
|
},
|
|
149
|
-
{}
|
|
164
|
+
{ nonZero: [], zero: [] }
|
|
150
165
|
);
|
|
151
|
-
return
|
|
152
|
-
rewardPoolsInfo: stakedTokenRewards.all,
|
|
153
|
-
baseRewardPoolsInfo: stakedTokenRewards.base,
|
|
154
|
-
rewardPoolsSupply
|
|
155
|
-
};
|
|
166
|
+
return [...nonZero, zero];
|
|
156
167
|
}
|
|
157
|
-
static async
|
|
158
|
-
provider,
|
|
159
|
-
account,
|
|
160
|
-
currentTokenData,
|
|
161
|
-
network,
|
|
162
|
-
airdropDistributorAddress
|
|
163
|
-
}) {
|
|
164
|
-
if (!airdropDistributorAddress) return { rewards: [] };
|
|
165
|
-
const [claimedResp, merkleDataResp] = await Promise.all([
|
|
166
|
-
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
167
|
-
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
168
|
-
]);
|
|
169
|
-
const amountOnContract = this.getAmountOnContract({
|
|
170
|
-
account,
|
|
171
|
-
merkleData: merkleDataResp
|
|
172
|
-
});
|
|
173
|
-
const diff = amountOnContract - claimedResp;
|
|
174
|
-
const availableToClaimV2 = import_math.BigIntMath.max(0n, diff);
|
|
175
|
-
const rewards = [
|
|
176
|
-
{
|
|
177
|
-
amount: availableToClaimV2,
|
|
178
|
-
type: "merkleV2",
|
|
179
|
-
rewardToken: currentTokenData.GEAR,
|
|
180
|
-
rewardTokenDecimals: 18,
|
|
181
|
-
rewardTokenSymbol: "GEAR"
|
|
182
|
-
}
|
|
183
|
-
];
|
|
184
|
-
return { rewards };
|
|
185
|
-
}
|
|
186
|
-
static async getLmRewardsV3({
|
|
168
|
+
static async getLmRewardsMerkle({
|
|
187
169
|
pools,
|
|
188
|
-
baseRewardPoolsInfo,
|
|
189
|
-
currentTokenData,
|
|
190
|
-
tokensList,
|
|
191
|
-
provider,
|
|
192
170
|
account,
|
|
193
171
|
network,
|
|
194
172
|
reportError
|
|
195
173
|
}) {
|
|
196
|
-
const
|
|
197
|
-
const [gearboxLmResponse, merkleXYZLMResponse] = await Promise.allSettled([
|
|
198
|
-
provider.multicall({
|
|
199
|
-
allowFailure: false,
|
|
200
|
-
contracts: poolTokens.map((address) => ({
|
|
201
|
-
address,
|
|
202
|
-
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
203
|
-
functionName: "farmed",
|
|
204
|
-
args: [account]
|
|
205
|
-
}))
|
|
206
|
-
}),
|
|
174
|
+
const [merkleXYZLMResponse] = await Promise.allSettled([
|
|
207
175
|
import_axios.default.get(
|
|
208
176
|
import_merklAPI.MerkleXYZApi.getUserRewardsUrl({
|
|
209
177
|
params: {
|
|
@@ -213,15 +181,10 @@ class GearboxRewardsApi {
|
|
|
213
181
|
})
|
|
214
182
|
)
|
|
215
183
|
]);
|
|
216
|
-
const gearboxLm = this.extractFulfilled(
|
|
217
|
-
gearboxLmResponse,
|
|
218
|
-
reportError,
|
|
219
|
-
"v3Rewards"
|
|
220
|
-
) || [];
|
|
221
184
|
const merkleXYZLm = this.extractFulfilled(
|
|
222
185
|
merkleXYZLMResponse,
|
|
223
186
|
reportError,
|
|
224
|
-
"
|
|
187
|
+
"merkleXYZLm"
|
|
225
188
|
)?.data;
|
|
226
189
|
const poolByItsToken = Object.values(pools).reduce((acc, p) => {
|
|
227
190
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -259,34 +222,7 @@ class GearboxRewardsApi {
|
|
|
259
222
|
});
|
|
260
223
|
return acc;
|
|
261
224
|
}, {});
|
|
262
|
-
|
|
263
|
-
const info = baseRewardPoolsInfo[address];
|
|
264
|
-
const rewardToken = currentTokenData[info.symbol];
|
|
265
|
-
return {
|
|
266
|
-
pool: info.pool,
|
|
267
|
-
poolToken: address,
|
|
268
|
-
rewardToken,
|
|
269
|
-
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
270
|
-
rewardTokenSymbol: info.symbol,
|
|
271
|
-
amount: gearboxLm[i] || 0n,
|
|
272
|
-
type: "stakedV3"
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
const { zero, nonZero } = gearboxLmRewards.reduce(
|
|
276
|
-
(acc, r) => {
|
|
277
|
-
const amount = r.amount || 0n;
|
|
278
|
-
if (amount > 0n) {
|
|
279
|
-
acc.nonZero.push(r);
|
|
280
|
-
} else {
|
|
281
|
-
acc.zero.push(r);
|
|
282
|
-
}
|
|
283
|
-
return acc;
|
|
284
|
-
},
|
|
285
|
-
{ nonZero: [], zero: [] }
|
|
286
|
-
);
|
|
287
|
-
return {
|
|
288
|
-
rewards: [...nonZero, ...Object.values(extraRewards), zero]
|
|
289
|
-
};
|
|
225
|
+
return Object.values(extraRewards);
|
|
290
226
|
}
|
|
291
227
|
static extractFulfilled(r, reportError, description) {
|
|
292
228
|
if (r.status === "fulfilled") {
|
|
@@ -391,8 +327,7 @@ class GearboxRewardsApi {
|
|
|
391
327
|
account,
|
|
392
328
|
merkleData
|
|
393
329
|
}) {
|
|
394
|
-
const {
|
|
395
|
-
const { amount } = claims[(0, import_viem.getAddress)(account)] || {};
|
|
330
|
+
const { amount } = merkleData?.claims?.[(0, import_viem.getAddress)(account)] || {};
|
|
396
331
|
return BigInt(amount || 0);
|
|
397
332
|
}
|
|
398
333
|
}
|
|
@@ -37,7 +37,7 @@ class GearboxRewardsApy {
|
|
|
37
37
|
if (!isV3 || !stakedDieselToken) return [];
|
|
38
38
|
const info = rewardPoolsInfo[stakedDieselToken];
|
|
39
39
|
if (!info) return [];
|
|
40
|
-
const extra = info.map(
|
|
40
|
+
const extra = (Array.isArray(info) ? info : [info]).map(
|
|
41
41
|
(inf) => this.getPoolSingleExtraLmAPY_V3({
|
|
42
42
|
...restProps,
|
|
43
43
|
stakedDieselToken,
|
|
@@ -26,7 +26,6 @@ __reExport(sdk_legacy_exports, require("./core/pool.js"), module.exports);
|
|
|
26
26
|
__reExport(sdk_legacy_exports, require("./core/strategy.js"), module.exports);
|
|
27
27
|
__reExport(sdk_legacy_exports, require("./core/transactions.js"), module.exports);
|
|
28
28
|
__reExport(sdk_legacy_exports, require("./gearboxRewards/index.js"), module.exports);
|
|
29
|
-
__reExport(sdk_legacy_exports, require("./pathfinder/index.js"), module.exports);
|
|
30
29
|
__reExport(sdk_legacy_exports, require("./payload/creditAccount.js"), module.exports);
|
|
31
30
|
__reExport(sdk_legacy_exports, require("./payload/creditManager.js"), module.exports);
|
|
32
31
|
__reExport(sdk_legacy_exports, require("./payload/creditSession.js"), module.exports);
|
|
@@ -48,7 +47,6 @@ __reExport(sdk_legacy_exports, require("./utils/index.js"), module.exports);
|
|
|
48
47
|
...require("./core/strategy.js"),
|
|
49
48
|
...require("./core/transactions.js"),
|
|
50
49
|
...require("./gearboxRewards/index.js"),
|
|
51
|
-
...require("./pathfinder/index.js"),
|
|
52
50
|
...require("./payload/creditAccount.js"),
|
|
53
51
|
...require("./payload/creditManager.js"),
|
|
54
52
|
...require("./payload/creditSession.js"),
|