@gearbox-protocol/sdk 3.0.0-vfour.324 → 3.0.0-vfour.325

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.
@@ -86,7 +86,7 @@ class GearboxSDK {
86
86
  blockNumber,
87
87
  redstoneHistoricTimestamp,
88
88
  ignoreUpdateablePrices,
89
- marketConfigurators
89
+ marketConfigurators: mcs
90
90
  } = options;
91
91
  let { networkType, addressProvider, chainId } = options;
92
92
  const attachClient = (0, import_viem.createPublicClient)({
@@ -101,6 +101,7 @@ class GearboxSDK {
101
101
  if (!addressProvider) {
102
102
  addressProvider = import_constants.ADDRESS_PROVIDER_V310;
103
103
  }
104
+ const marketConfigurators = mcs ?? (0, import_constants.getDefaultMarketConfigurators)(networkType);
104
105
  const provider = new import_chain.Provider({
105
106
  ...options,
106
107
  chainId,
@@ -19,10 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var chains_exports = {};
20
20
  __export(chains_exports, {
21
21
  NetworkType: () => NetworkType,
22
+ PUBLIC_NETWORKS: () => PUBLIC_NETWORKS,
22
23
  SUPPORTED_NETWORKS: () => SUPPORTED_NETWORKS,
23
24
  chains: () => chains,
24
25
  getChain: () => getChain,
25
26
  getNetworkType: () => getNetworkType,
27
+ isPublicNetwork: () => isPublicNetwork,
26
28
  isSupportedNetwork: () => isSupportedNetwork
27
29
  });
28
30
  module.exports = __toCommonJS(chains_exports);
@@ -37,6 +39,10 @@ const SUPPORTED_NETWORKS = [
37
39
  "Sonic"
38
40
  ];
39
41
  const NetworkType = import_zod.z.enum(SUPPORTED_NETWORKS);
42
+ const PUBLIC_NETWORKS = SUPPORTED_NETWORKS;
43
+ function isPublicNetwork(network) {
44
+ return PUBLIC_NETWORKS.includes(network);
45
+ }
40
46
  function withPublicNode(chain, subdomain) {
41
47
  return (0, import_viem.defineChain)({
42
48
  ...chain,
@@ -96,9 +102,11 @@ function isSupportedNetwork(chainId) {
96
102
  // Annotate the CommonJS export names for ESM import in node:
97
103
  0 && (module.exports = {
98
104
  NetworkType,
105
+ PUBLIC_NETWORKS,
99
106
  SUPPORTED_NETWORKS,
100
107
  chains,
101
108
  getChain,
102
109
  getNetworkType,
110
+ isPublicNetwork,
103
111
  isSupportedNetwork
104
112
  });
@@ -18,6 +18,7 @@ module.exports = __toCommonJS(constants_exports);
18
18
  __reExport(constants_exports, require("./address-provider.js"), module.exports);
19
19
  __reExport(constants_exports, require("./addresses.js"), module.exports);
20
20
  __reExport(constants_exports, require("./bot-permissions.js"), module.exports);
21
+ __reExport(constants_exports, require("./market-configurators.js"), module.exports);
21
22
  __reExport(constants_exports, require("./math.js"), module.exports);
22
23
  __reExport(constants_exports, require("./networks.js"), module.exports);
23
24
  __reExport(constants_exports, require("./periphery.js"), module.exports);
@@ -26,6 +27,7 @@ __reExport(constants_exports, require("./periphery.js"), module.exports);
26
27
  ...require("./address-provider.js"),
27
28
  ...require("./addresses.js"),
28
29
  ...require("./bot-permissions.js"),
30
+ ...require("./market-configurators.js"),
29
31
  ...require("./math.js"),
30
32
  ...require("./networks.js"),
31
33
  ...require("./periphery.js")
@@ -0,0 +1,48 @@
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 market_configurators_exports = {};
20
+ __export(market_configurators_exports, {
21
+ DEFAULT_MARKET_CONFIGURATORS: () => DEFAULT_MARKET_CONFIGURATORS,
22
+ getDefaultMarketConfigurators: () => getDefaultMarketConfigurators
23
+ });
24
+ module.exports = __toCommonJS(market_configurators_exports);
25
+ var import_viem = require("viem");
26
+ const DEFAULT_MARKET_CONFIGURATORS = {
27
+ Mainnet: {
28
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
29
+ },
30
+ Arbitrum: {
31
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
32
+ },
33
+ Optimism: {
34
+ "0x2a15969CE5320868eb609680751cF8896DD92De5": "Chaos Labs"
35
+ },
36
+ Base: {},
37
+ Sonic: { "0x8FFDd1F1433674516f83645a768E8900A2A5D076": "Chaos Labs" }
38
+ };
39
+ function getDefaultMarketConfigurators(network) {
40
+ return Object.keys(DEFAULT_MARKET_CONFIGURATORS[network]).map(
41
+ (a) => (0, import_viem.getAddress)(a)
42
+ );
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ DEFAULT_MARKET_CONFIGURATORS,
47
+ getDefaultMarketConfigurators
48
+ });
@@ -28,6 +28,7 @@ var import_base = require("../../base/index.js");
28
28
  var import_constants = require("../../constants/index.js");
29
29
  var import_utils = require("../../utils/index.js");
30
30
  var import_pricefeeds = require("../pricefeeds/index.js");
31
+ const ZERO_PRICE_FEED = (0, import_viem.stringToHex)("PRICE_FEED::ZERO", { size: 32 });
31
32
  class PriceOracleBaseContract extends import_base.BaseContract {
32
33
  /**
33
34
  * Underlying token of market to which this price oracle belongs
@@ -231,12 +232,13 @@ class PriceOracleBaseContract extends import_base.BaseContract {
231
232
  (n) => n.baseParams.addr === priceFeed
232
233
  );
233
234
  const price = node?.answer?.price;
235
+ const priceFeedType = node?.baseParams.contractType;
234
236
  if (reserve) {
235
237
  this.reservePriceFeeds.upsert(token, ref);
236
238
  if (price !== void 0) {
237
239
  this.reservePrices.upsert(token, price);
238
240
  }
239
- if (!price) {
241
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
240
242
  this.logger?.warn(
241
243
  node ?? {},
242
244
  `answer not found for reserve price feed ${this.labelAddress(priceFeed)}`
@@ -247,7 +249,7 @@ class PriceOracleBaseContract extends import_base.BaseContract {
247
249
  if (price !== void 0) {
248
250
  this.mainPrices.upsert(token, price);
249
251
  }
250
- if (!price) {
252
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
251
253
  this.logger?.warn(
252
254
  node ?? {},
253
255
  `answer not found for main price feed ${this.labelAddress(priceFeed)}`
@@ -6,6 +6,7 @@ import {
6
6
  AP_BOT_LIST,
7
7
  AP_GEAR_STAKING,
8
8
  AP_GEAR_TOKEN,
9
+ getDefaultMarketConfigurators,
9
10
  NO_VERSION
10
11
  } from "./constants/index.js";
11
12
  import {
@@ -75,7 +76,7 @@ class GearboxSDK {
75
76
  blockNumber,
76
77
  redstoneHistoricTimestamp,
77
78
  ignoreUpdateablePrices,
78
- marketConfigurators
79
+ marketConfigurators: mcs
79
80
  } = options;
80
81
  let { networkType, addressProvider, chainId } = options;
81
82
  const attachClient = createPublicClient({
@@ -90,6 +91,7 @@ class GearboxSDK {
90
91
  if (!addressProvider) {
91
92
  addressProvider = ADDRESS_PROVIDER_V310;
92
93
  }
94
+ const marketConfigurators = mcs ?? getDefaultMarketConfigurators(networkType);
93
95
  const provider = new Provider({
94
96
  ...options,
95
97
  chainId,
@@ -9,6 +9,10 @@ const SUPPORTED_NETWORKS = [
9
9
  "Sonic"
10
10
  ];
11
11
  const NetworkType = z.enum(SUPPORTED_NETWORKS);
12
+ const PUBLIC_NETWORKS = SUPPORTED_NETWORKS;
13
+ function isPublicNetwork(network) {
14
+ return PUBLIC_NETWORKS.includes(network);
15
+ }
12
16
  function withPublicNode(chain, subdomain) {
13
17
  return defineChain({
14
18
  ...chain,
@@ -67,9 +71,11 @@ function isSupportedNetwork(chainId) {
67
71
  }
68
72
  export {
69
73
  NetworkType,
74
+ PUBLIC_NETWORKS,
70
75
  SUPPORTED_NETWORKS,
71
76
  chains,
72
77
  getChain,
73
78
  getNetworkType,
79
+ isPublicNetwork,
74
80
  isSupportedNetwork
75
81
  };
@@ -1,6 +1,7 @@
1
1
  export * from "./address-provider.js";
2
2
  export * from "./addresses.js";
3
3
  export * from "./bot-permissions.js";
4
+ export * from "./market-configurators.js";
4
5
  export * from "./math.js";
5
6
  export * from "./networks.js";
6
7
  export * from "./periphery.js";
@@ -0,0 +1,23 @@
1
+ import { getAddress } from "viem";
2
+ const DEFAULT_MARKET_CONFIGURATORS = {
3
+ Mainnet: {
4
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
5
+ },
6
+ Arbitrum: {
7
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
8
+ },
9
+ Optimism: {
10
+ "0x2a15969CE5320868eb609680751cF8896DD92De5": "Chaos Labs"
11
+ },
12
+ Base: {},
13
+ Sonic: { "0x8FFDd1F1433674516f83645a768E8900A2A5D076": "Chaos Labs" }
14
+ };
15
+ function getDefaultMarketConfigurators(network) {
16
+ return Object.keys(DEFAULT_MARKET_CONFIGURATORS[network]).map(
17
+ (a) => getAddress(a)
18
+ );
19
+ }
20
+ export {
21
+ DEFAULT_MARKET_CONFIGURATORS,
22
+ getDefaultMarketConfigurators
23
+ };
@@ -1,10 +1,11 @@
1
- import { decodeFunctionData } from "viem";
1
+ import { decodeFunctionData, stringToHex } from "viem";
2
2
  import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
3
3
  import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
4
4
  import { BaseContract } from "../../base/index.js";
5
5
  import { AP_PRICE_FEED_COMPRESSOR } from "../../constants/index.js";
6
6
  import { AddressMap, formatBN } from "../../utils/index.js";
7
7
  import { PriceFeedRef } from "../pricefeeds/index.js";
8
+ const ZERO_PRICE_FEED = stringToHex("PRICE_FEED::ZERO", { size: 32 });
8
9
  class PriceOracleBaseContract extends BaseContract {
9
10
  /**
10
11
  * Underlying token of market to which this price oracle belongs
@@ -208,12 +209,13 @@ class PriceOracleBaseContract extends BaseContract {
208
209
  (n) => n.baseParams.addr === priceFeed
209
210
  );
210
211
  const price = node?.answer?.price;
212
+ const priceFeedType = node?.baseParams.contractType;
211
213
  if (reserve) {
212
214
  this.reservePriceFeeds.upsert(token, ref);
213
215
  if (price !== void 0) {
214
216
  this.reservePrices.upsert(token, price);
215
217
  }
216
- if (!price) {
218
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
217
219
  this.logger?.warn(
218
220
  node ?? {},
219
221
  `answer not found for reserve price feed ${this.labelAddress(priceFeed)}`
@@ -224,7 +226,7 @@ class PriceOracleBaseContract extends BaseContract {
224
226
  if (price !== void 0) {
225
227
  this.mainPrices.upsert(token, price);
226
228
  }
227
- if (!price) {
229
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
228
230
  this.logger?.warn(
229
231
  node ?? {},
230
232
  `answer not found for main price feed ${this.labelAddress(priceFeed)}`
@@ -19,7 +19,7 @@ export interface SDKOptions<Plugins extends PluginMap = {}> {
19
19
  /**
20
20
  * Market configurators
21
21
  */
22
- marketConfigurators: Address[];
22
+ marketConfigurators?: Address[];
23
23
  /**
24
24
  * Attach and load state at this specific block number
25
25
  */
@@ -3,6 +3,8 @@ import { z } from "zod";
3
3
  export declare const SUPPORTED_NETWORKS: readonly ["Mainnet", "Arbitrum", "Optimism", "Base", "Sonic"];
4
4
  export declare const NetworkType: z.ZodEnum<["Mainnet", "Arbitrum", "Optimism", "Base", "Sonic"]>;
5
5
  export type NetworkType = z.infer<typeof NetworkType>;
6
+ export declare const PUBLIC_NETWORKS: readonly NetworkType[];
7
+ export declare function isPublicNetwork(network: NetworkType): boolean;
6
8
  export declare const chains: Record<NetworkType, Chain>;
7
9
  export declare function getChain(chainIdOrNetworkType: number | bigint | NetworkType): Chain;
8
10
  export declare function getNetworkType(chainId: number): NetworkType;
@@ -1,6 +1,7 @@
1
1
  export * from "./address-provider.js";
2
2
  export * from "./addresses.js";
3
3
  export * from "./bot-permissions.js";
4
+ export * from "./market-configurators.js";
4
5
  export * from "./math.js";
5
6
  export * from "./networks.js";
6
7
  export * from "./periphery.js";
@@ -0,0 +1,4 @@
1
+ import type { Address } from "abitype";
2
+ import type { NetworkType } from "../chain/index.js";
3
+ export declare const DEFAULT_MARKET_CONFIGURATORS: Record<NetworkType, Record<Address, string>>;
4
+ export declare function getDefaultMarketConfigurators(network: NetworkType): Address[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfour.324",
3
+ "version": "3.0.0-vfour.325",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",