@gearbox-protocol/sdk 7.10.1-next.1 → 7.11.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.
Files changed (44) hide show
  1. package/dist/cjs/adapters/AdaptersPlugin.js +2 -3
  2. package/dist/cjs/bots/BotsPlugin.js +29 -17
  3. package/dist/cjs/degenDistributors/DegenDistributorsPlugin.js +110 -0
  4. package/dist/cjs/degenDistributors/index.js +24 -0
  5. package/dist/cjs/degenDistributors/package.json +1 -0
  6. package/dist/cjs/degenDistributors/types.js +16 -0
  7. package/dist/cjs/dev/AccountsCounterPlugin.js +19 -10
  8. package/dist/cjs/pools7DAgo/Pools7DAgoPlugin.js +116 -0
  9. package/dist/cjs/pools7DAgo/index.js +24 -0
  10. package/dist/cjs/pools7DAgo/package.json +1 -0
  11. package/dist/cjs/pools7DAgo/types.js +16 -0
  12. package/dist/cjs/sdk/GearboxSDK.js +8 -2
  13. package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +3 -1
  14. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +0 -1
  15. package/dist/cjs/zappers/ZappersPlugin.js +13 -4
  16. package/dist/esm/adapters/AdaptersPlugin.js +2 -3
  17. package/dist/esm/bots/BotsPlugin.js +29 -17
  18. package/dist/esm/degenDistributors/DegenDistributorsPlugin.js +86 -0
  19. package/dist/esm/degenDistributors/index.js +2 -0
  20. package/dist/esm/degenDistributors/package.json +1 -0
  21. package/dist/esm/degenDistributors/types.js +0 -0
  22. package/dist/esm/dev/AccountsCounterPlugin.js +19 -10
  23. package/dist/esm/pools7DAgo/Pools7DAgoPlugin.js +99 -0
  24. package/dist/esm/pools7DAgo/index.js +2 -0
  25. package/dist/esm/pools7DAgo/package.json +1 -0
  26. package/dist/esm/pools7DAgo/types.js +0 -0
  27. package/dist/esm/sdk/GearboxSDK.js +8 -2
  28. package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +3 -1
  29. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +0 -1
  30. package/dist/esm/zappers/ZappersPlugin.js +13 -4
  31. package/dist/types/adapters/AdaptersPlugin.d.ts +5 -4
  32. package/dist/types/bots/BotsPlugin.d.ts +5 -3
  33. package/dist/types/bots/types.d.ts +2 -2
  34. package/dist/types/degenDistributors/DegenDistributorsPlugin.d.ts +22 -0
  35. package/dist/types/degenDistributors/index.d.ts +2 -0
  36. package/dist/types/degenDistributors/types.d.ts +4 -0
  37. package/dist/types/dev/AccountsCounterPlugin.d.ts +4 -2
  38. package/dist/types/pools7DAgo/Pools7DAgoPlugin.d.ts +22 -0
  39. package/dist/types/pools7DAgo/index.d.ts +2 -0
  40. package/dist/types/pools7DAgo/types.d.ts +9 -0
  41. package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +3 -2
  42. package/dist/types/sdk/plugins/types.d.ts +33 -15
  43. package/dist/types/zappers/ZappersPlugin.d.ts +5 -4
  44. package/package.json +1 -1
@@ -48,6 +48,7 @@ var import_YearnV2AdapterContract = require("./YearnV2AdapterContract.js");
48
48
  class AdaptersPlugin extends import_sdk.SDKConstruct {
49
49
  name = "Adapters";
50
50
  version = 1;
51
+ loaded = true;
51
52
  createContract(data) {
52
53
  const args = data;
53
54
  const adapterType = (0, import_sdk.bytes32ToString)(
@@ -116,9 +117,7 @@ class AdaptersPlugin extends import_sdk.SDKConstruct {
116
117
  return {};
117
118
  }
118
119
  get state() {
119
- return {
120
- version: this.version
121
- };
120
+ return {};
122
121
  }
123
122
  hydrate(_) {
124
123
  }
@@ -39,25 +39,25 @@ class UnsupportedBotVersionError extends Error {
39
39
  class BotsPlugin extends import_sdk.SDKConstruct {
40
40
  #logger;
41
41
  version = 1;
42
- #botsByMarket = new import_sdk.AddressMap();
42
+ #botsByMarket;
43
43
  constructor(sdk) {
44
44
  super(sdk);
45
45
  this.#logger = sdk.logger?.child?.({ name: "BotsPlugin" }) ?? sdk.logger;
46
46
  }
47
- async attach() {
48
- await this.#load();
49
- }
47
+ // public async attach(): Promise<void> {
48
+ // await this.#load();
49
+ // }
50
50
  async syncState() {
51
- await this.#load();
52
- }
53
- botsByMarketConfigurator(mc) {
54
- return this.#botsByMarket.get(mc) ?? [];
51
+ await this.load(false);
55
52
  }
56
- get allBots() {
57
- return this.#botsByMarket.values().flat();
53
+ get loaded() {
54
+ return !!this.#botsByMarket;
58
55
  }
59
- async #load() {
60
- this.#botsByMarket.clear();
56
+ async load(force) {
57
+ if (!force && this.loaded) {
58
+ return this.state;
59
+ }
60
+ this.#botsByMarket = new import_sdk.AddressMap();
61
61
  const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
62
62
  import_sdk.AP_PERIPHERY_COMPRESSOR,
63
63
  import_sdk.VERSION_RANGE_310
@@ -82,6 +82,7 @@ class BotsPlugin extends import_sdk.SDKConstruct {
82
82
  const marketBotData = botsData[i];
83
83
  this.#loadStateMarketState(mc, marketBotData);
84
84
  }
85
+ return this.state;
85
86
  }
86
87
  #loadStateMarketState(mc, state) {
87
88
  const bots = state.map((state2) => this.#createBot(mc, state2)).sort((a, b) => a.minHealthFactor - b.minHealthFactor);
@@ -93,28 +94,39 @@ class BotsPlugin extends import_sdk.SDKConstruct {
93
94
  bots[i].botType = import_types.BOT_TYPES[i];
94
95
  }
95
96
  }
96
- this.#botsByMarket.upsert(mc, bots);
97
+ this.botsByMarket.upsert(mc, bots);
97
98
  }
98
99
  stateHuman(raw) {
99
100
  return {
100
101
  bots: Object.fromEntries(
101
- this.#botsByMarket.entries().map(([mc, bots]) => [
102
+ this.botsByMarket.entries().map(([mc, bots]) => [
102
103
  this.labelAddress(mc),
103
104
  bots.map((b) => b.stateHuman(raw))
104
105
  ])
105
106
  )
106
107
  };
107
108
  }
109
+ get botsByMarket() {
110
+ if (!this.#botsByMarket) {
111
+ throw new Error("bots plugin not loaded");
112
+ }
113
+ return this.#botsByMarket;
114
+ }
115
+ botsByMarketConfigurator(mc) {
116
+ return this.botsByMarket.get(mc) ?? [];
117
+ }
118
+ get allBots() {
119
+ return this.botsByMarket.values().flat();
120
+ }
108
121
  get state() {
109
122
  return {
110
- version: this.version,
111
123
  bots: import_sdk.TypedObjectUtils.fromEntries(
112
- this.#botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
124
+ this.botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
113
125
  )
114
126
  };
115
127
  }
116
128
  hydrate(state) {
117
- this.#botsByMarket.clear();
129
+ this.#botsByMarket = new import_sdk.AddressMap();
118
130
  for (const [mc, botStates] of import_sdk.TypedObjectUtils.entries(state.bots)) {
119
131
  this.#loadStateMarketState(mc, botStates);
120
132
  }
@@ -0,0 +1,110 @@
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 DegenDistributorsPlugin_exports = {};
20
+ __export(DegenDistributorsPlugin_exports, {
21
+ DegenDistributorsPlugin: () => DegenDistributorsPlugin
22
+ });
23
+ module.exports = __toCommonJS(DegenDistributorsPlugin_exports);
24
+ var import_sdk = require("../sdk/index.js");
25
+ const MAP_LABEL = "degenDistributors";
26
+ class DegenDistributorsPlugin extends import_sdk.SDKConstruct {
27
+ #distributors;
28
+ version = 1;
29
+ // public async attach(): Promise<void> {
30
+ // await this.loadDegenDistributors();
31
+ // }
32
+ async syncState() {
33
+ await this.load();
34
+ }
35
+ async load(force) {
36
+ if (!force && this.loaded) {
37
+ return this.state;
38
+ }
39
+ const configurators = Object.values(
40
+ this.sdk.marketRegister.markets.reduce((acc, market) => {
41
+ const cfgLC = market.configurator.address.toLowerCase();
42
+ acc[cfgLC] = market.configurator;
43
+ return acc;
44
+ }, {})
45
+ );
46
+ this.sdk.logger?.debug(
47
+ `loading degen distributors for ${this.sdk.provider.networkType}`
48
+ );
49
+ const distributors = await Promise.allSettled(
50
+ configurators.map((cfg) => cfg.getPeripheryContract("DEGEN_DISTRIBUTOR"))
51
+ );
52
+ const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
53
+ const cfgLC = cfg.address.toLowerCase();
54
+ acc[cfgLC] = distributors[index];
55
+ return acc;
56
+ }, {});
57
+ this.sdk.marketRegister.markets.forEach((m) => {
58
+ const pool = m.pool.pool.address;
59
+ const cfg = m.configurator.address;
60
+ const cfgLC = cfg.toLowerCase();
61
+ const r = distributorByConfigurator?.[cfgLC];
62
+ if (!this.#distributors) {
63
+ this.#distributors = new import_sdk.AddressMap(void 0, MAP_LABEL);
64
+ }
65
+ if (r.status === "fulfilled") {
66
+ this.#distributors.upsert(pool, r.value);
67
+ } else {
68
+ this.sdk.logger?.error(
69
+ `failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.reason}`
70
+ );
71
+ }
72
+ });
73
+ return this.state;
74
+ }
75
+ get loaded() {
76
+ return !!this.#distributors;
77
+ }
78
+ /**
79
+ * Returns a map of pool addresses to degen distributor addresses
80
+ * @throws if degen distributor plugin is not attached
81
+ */
82
+ get distributors() {
83
+ if (!this.#distributors) {
84
+ throw new Error("degen distributor plugin not attached");
85
+ }
86
+ return this.#distributors;
87
+ }
88
+ stateHuman(_) {
89
+ return this.distributors.entries().flatMap(([pool, distributor]) => ({
90
+ address: distributor,
91
+ version: this.version,
92
+ pool
93
+ }));
94
+ }
95
+ get state() {
96
+ return {
97
+ distributors: this.distributors.asRecord()
98
+ };
99
+ }
100
+ hydrate(state) {
101
+ this.#distributors = new import_sdk.AddressMap(
102
+ Object.entries(state.distributors),
103
+ MAP_LABEL
104
+ );
105
+ }
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ DegenDistributorsPlugin
110
+ });
@@ -0,0 +1,24 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var degenDistributors_exports = {};
17
+ module.exports = __toCommonJS(degenDistributors_exports);
18
+ __reExport(degenDistributors_exports, require("./DegenDistributorsPlugin.js"), module.exports);
19
+ __reExport(degenDistributors_exports, require("./types.js"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./DegenDistributorsPlugin.js"),
23
+ ...require("./types.js")
24
+ });
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -24,21 +24,30 @@ module.exports = __toCommonJS(AccountsCounterPlugin_exports);
24
24
  var import_compressors = require("../abi/compressors.js");
25
25
  var import_sdk = require("../sdk/index.js");
26
26
  class AccountsCounterPlugin extends import_sdk.SDKConstruct {
27
- #accounts = new import_sdk.AddressMap();
27
+ #accounts;
28
28
  version = 1;
29
29
  async attach() {
30
- await this.#load();
30
+ await this.load();
31
31
  }
32
32
  async syncState() {
33
- await this.#load();
33
+ await this.load();
34
34
  }
35
35
  get accounts() {
36
+ if (!this.#accounts) {
37
+ throw new Error("AccountsCounterPlugin is not loaded");
38
+ }
36
39
  return this.#accounts;
37
40
  }
41
+ get loaded() {
42
+ return !!this.#accounts;
43
+ }
38
44
  forCreditManager(addr) {
39
- return this.#accounts.mustGet(addr);
45
+ return this.accounts.mustGet(addr);
40
46
  }
41
- async #load() {
47
+ async load(force) {
48
+ if (!force && this.loaded) {
49
+ return this.state;
50
+ }
42
51
  const [compressor] = this.sdk.addressProvider.mustGetLatest(
43
52
  import_sdk.AP_CREDIT_ACCOUNT_COMPRESSOR,
44
53
  import_sdk.VERSION_RANGE_310
@@ -81,23 +90,23 @@ class AccountsCounterPlugin extends import_sdk.SDKConstruct {
81
90
  ),
82
91
  allowFailure: false
83
92
  });
84
- this.#accounts.clear();
93
+ this.#accounts = new import_sdk.AddressMap();
85
94
  for (let i = 0; i < cms.length; i++) {
86
95
  const cm = cms[i];
87
96
  const [reverting, nonReverting] = [count[2 * i], count[2 * i + 1]];
88
97
  this.#accounts.upsert(cm.creditManager.address, reverting + nonReverting);
89
98
  }
99
+ return this.state;
90
100
  }
91
101
  get state() {
92
102
  return {
93
- version: this.version,
94
- accounts: this.#accounts.asRecord()
103
+ accounts: this.accounts.asRecord()
95
104
  };
96
105
  }
97
106
  hydrate(state) {
98
- this.#accounts.clear();
107
+ this.#accounts = new import_sdk.AddressMap();
99
108
  for (const [addr, count] of import_sdk.TypedObjectUtils.entries(state.accounts)) {
100
- this.#accounts.upsert(addr, count);
109
+ this.accounts.upsert(addr, count);
101
110
  }
102
111
  }
103
112
  }
@@ -0,0 +1,116 @@
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 Pools7DAgoPlugin_exports = {};
20
+ __export(Pools7DAgoPlugin_exports, {
21
+ Pools7DAgoPlugin: () => Pools7DAgoPlugin
22
+ });
23
+ module.exports = __toCommonJS(Pools7DAgoPlugin_exports);
24
+ var import_compressors = require("../abi/compressors.js");
25
+ var import_sdk = require("../sdk/index.js");
26
+ const MAP_LABEL = "pools7DAgo";
27
+ class Pools7DAgoPlugin extends import_sdk.SDKConstruct {
28
+ #pools7DAgo;
29
+ version = 1;
30
+ // public async attach(): Promise<void> {
31
+ // await this.loadPools7DAgo();
32
+ // }
33
+ async syncState() {
34
+ await this.load();
35
+ }
36
+ async load(force) {
37
+ if (!force && this.loaded) {
38
+ return this.state;
39
+ }
40
+ const targetBlock = this.sdk.currentBlock - import_sdk.BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.provider.networkType];
41
+ const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
42
+ import_sdk.AP_MARKET_COMPRESSOR,
43
+ import_sdk.VERSION_RANGE_310
44
+ );
45
+ this.sdk.logger?.debug(
46
+ `loading pools 7d ago with market compressor ${marketCompressorAddress}`
47
+ );
48
+ const markets = this.sdk.marketRegister.markets;
49
+ const resp = await this.provider.publicClient.multicall({
50
+ allowFailure: true,
51
+ contracts: markets.map(
52
+ (m) => ({
53
+ address: marketCompressorAddress,
54
+ abi: import_compressors.iMarketCompressorAbi,
55
+ functionName: "getPoolState",
56
+ args: [m.pool.pool.address]
57
+ })
58
+ ),
59
+ blockNumber: import_sdk.BigIntMath.max(0n, targetBlock)
60
+ });
61
+ resp.forEach((r, index) => {
62
+ const m = markets[index];
63
+ const cfg = m.configurator.address;
64
+ const pool = m.pool.pool.address;
65
+ if (!this.#pools7DAgo) {
66
+ this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
67
+ }
68
+ if (r.status === "success") {
69
+ this.#pools7DAgo.upsert(m.pool.pool.address, {
70
+ dieselRate: r.result.dieselRate,
71
+ pool
72
+ });
73
+ } else {
74
+ this.sdk.logger?.error(
75
+ `failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
76
+ );
77
+ }
78
+ });
79
+ return this.state;
80
+ }
81
+ get loaded() {
82
+ return !!this.#pools7DAgo;
83
+ }
84
+ /**
85
+ * Returns a map of pool addresses to minified pool 7d ago state
86
+ * @throws if pool 7d ago plugin is not attached
87
+ */
88
+ get pools7DAgo() {
89
+ if (!this.#pools7DAgo) {
90
+ throw new Error("pools 7d ago plugin not attached");
91
+ }
92
+ return this.#pools7DAgo;
93
+ }
94
+ stateHuman(_) {
95
+ return this.pools7DAgo.values().flatMap((p) => ({
96
+ address: p.pool,
97
+ version: this.version,
98
+ dieselRate: p.dieselRate
99
+ }));
100
+ }
101
+ get state() {
102
+ return {
103
+ pools7DAgo: this.pools7DAgo.asRecord()
104
+ };
105
+ }
106
+ hydrate(state) {
107
+ this.#pools7DAgo = new import_sdk.AddressMap(
108
+ Object.entries(state.pools7DAgo),
109
+ MAP_LABEL
110
+ );
111
+ }
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ Pools7DAgoPlugin
116
+ });
@@ -0,0 +1,24 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var pools7DAgo_exports = {};
17
+ module.exports = __toCommonJS(pools7DAgo_exports);
18
+ __reExport(pools7DAgo_exports, require("./Pools7DAgoPlugin.js"), module.exports);
19
+ __reExport(pools7DAgo_exports, require("./types.js"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./Pools7DAgoPlugin.js"),
23
+ ...require("./types.js")
24
+ });
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -244,6 +244,12 @@ class GearboxSDK {
244
244
  for (const [name, plugin] of import_utils.TypedObjectUtils.entries(this.plugins)) {
245
245
  const pluginState = state.plugins[name];
246
246
  if (plugin.hydrate && pluginState) {
247
+ if (!pluginState.loaded) {
248
+ this.logger?.debug(
249
+ `skipping ${re}hydrating plugin ${name} state: not loaded`
250
+ );
251
+ continue;
252
+ }
247
253
  if (pluginState.version !== plugin.version) {
248
254
  throw new import_plugins.PluginStateVersionError(plugin, pluginState);
249
255
  }
@@ -341,7 +347,7 @@ class GearboxSDK {
341
347
  plugins: Object.fromEntries(
342
348
  import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
343
349
  name,
344
- plugin.stateHuman?.(raw) ?? {}
350
+ plugin.loaded ? plugin.stateHuman?.(raw) : void 0
345
351
  ])
346
352
  ),
347
353
  ...this.marketRegister.stateHuman(raw)
@@ -359,7 +365,7 @@ class GearboxSDK {
359
365
  plugins: Object.fromEntries(
360
366
  import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
361
367
  name,
362
- plugin.state
368
+ plugin.loaded ? { version: plugin.version, loaded: true, ...plugin.state } : { version: plugin.version, loaded: false }
363
369
  ])
364
370
  )
365
371
  };
@@ -38,6 +38,9 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
38
38
  this.#syncedTo = import_constants.ADDRESS_PROVIDER_BLOCK[sdk.provider.networkType] - 1n;
39
39
  this.#logger = sdk.logger?.child?.({ name: "V300StalenessPeriodPlugin" }) ?? sdk.logger;
40
40
  }
41
+ get loaded() {
42
+ return !!this.#syncedTo;
43
+ }
41
44
  async attach() {
42
45
  await this.#syncPriceFeeds();
43
46
  }
@@ -98,7 +101,6 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
98
101
  }
99
102
  get state() {
100
103
  return {
101
- version: this.version,
102
104
  events: this.#events
103
105
  };
104
106
  }
@@ -98,7 +98,6 @@ async function simulateWithPriceUpdates(client, parameters) {
98
98
  if (mustThrow) {
99
99
  throw err;
100
100
  }
101
- console.warn(err);
102
101
  }
103
102
  const restResults = multicallResults.slice(priceUpdates.length + 2).map((r) => r.result);
104
103
  return restResults;
@@ -26,10 +26,16 @@ var import_sdk = require("../sdk/index.js");
26
26
  class ZappersPlugin extends import_sdk.SDKConstruct {
27
27
  #zappers;
28
28
  version = 1;
29
- async attach() {
30
- await this.loadZappers();
29
+ // public async attach(): Promise<void> {
30
+ // await this.load(true);
31
+ // }
32
+ async syncState() {
33
+ await this.load();
31
34
  }
32
- async loadZappers() {
35
+ async load(force) {
36
+ if (!force && this.loaded) {
37
+ return this.state;
38
+ }
33
39
  this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
34
40
  const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
35
41
  import_sdk.AP_PERIPHERY_COMPRESSOR,
@@ -66,6 +72,7 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
66
72
  }
67
73
  }
68
74
  this.#loadZapperTokens();
75
+ return this.state;
69
76
  }
70
77
  get zappers() {
71
78
  if (!this.#zappers) {
@@ -73,6 +80,9 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
73
80
  }
74
81
  return this.#zappers;
75
82
  }
83
+ get loaded() {
84
+ return !!this.#zappers;
85
+ }
76
86
  stateHuman(_) {
77
87
  return this.zappers.values().flatMap(
78
88
  (l) => l.flatMap((z) => ({
@@ -86,7 +96,6 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
86
96
  }
87
97
  get state() {
88
98
  return {
89
- version: this.version,
90
99
  zappers: this.zappers.asRecord()
91
100
  };
92
101
  }
@@ -25,6 +25,7 @@ import { YearnV2RouterAdapterContract } from "./YearnV2AdapterContract.js";
25
25
  class AdaptersPlugin extends SDKConstruct {
26
26
  name = "Adapters";
27
27
  version = 1;
28
+ loaded = true;
28
29
  createContract(data) {
29
30
  const args = data;
30
31
  const adapterType = bytes32ToString(
@@ -93,9 +94,7 @@ class AdaptersPlugin extends SDKConstruct {
93
94
  return {};
94
95
  }
95
96
  get state() {
96
- return {
97
- version: this.version
98
- };
97
+ return {};
99
98
  }
100
99
  hydrate(_) {
101
100
  }