@gearbox-protocol/sdk 9.15.4 → 9.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cjs/permissionless/bindings/pricefeeds/balancer-stable.js +1 -1
  2. package/dist/cjs/permissionless/bindings/pricefeeds/balancer-weighted.js +1 -1
  3. package/dist/cjs/permissionless/bindings/pricefeeds/bounded.js +1 -1
  4. package/dist/cjs/permissionless/bindings/pricefeeds/composite.js +1 -1
  5. package/dist/cjs/permissionless/bindings/pricefeeds/curve-crypto.js +1 -1
  6. package/dist/cjs/permissionless/bindings/pricefeeds/curve-stable.js +1 -1
  7. package/dist/cjs/permissionless/bindings/pricefeeds/curve-twap.js +1 -1
  8. package/dist/cjs/permissionless/bindings/pricefeeds/curve-usd.js +1 -1
  9. package/dist/cjs/permissionless/bindings/pricefeeds/erc4626.js +1 -1
  10. package/dist/cjs/permissionless/bindings/pricefeeds/kodiak.js +1 -1
  11. package/dist/cjs/permissionless/bindings/pricefeeds/mellow-lrt.js +1 -1
  12. package/dist/cjs/permissionless/bindings/pricefeeds/pendle-pt-twap.js +1 -1
  13. package/dist/cjs/permissionless/bindings/pricefeeds/wsteth.js +1 -1
  14. package/dist/cjs/permissionless/bindings/pricefeeds/zero.js +1 -1
  15. package/dist/cjs/sdk/GearboxSDK.js +1 -2
  16. package/dist/cjs/sdk/chain/Provider.js +21 -11
  17. package/dist/esm/permissionless/bindings/pricefeeds/balancer-stable.js +1 -1
  18. package/dist/esm/permissionless/bindings/pricefeeds/balancer-weighted.js +1 -1
  19. package/dist/esm/permissionless/bindings/pricefeeds/bounded.js +1 -1
  20. package/dist/esm/permissionless/bindings/pricefeeds/composite.js +1 -1
  21. package/dist/esm/permissionless/bindings/pricefeeds/curve-crypto.js +1 -1
  22. package/dist/esm/permissionless/bindings/pricefeeds/curve-stable.js +1 -1
  23. package/dist/esm/permissionless/bindings/pricefeeds/curve-twap.js +1 -1
  24. package/dist/esm/permissionless/bindings/pricefeeds/curve-usd.js +1 -1
  25. package/dist/esm/permissionless/bindings/pricefeeds/erc4626.js +1 -1
  26. package/dist/esm/permissionless/bindings/pricefeeds/kodiak.js +1 -1
  27. package/dist/esm/permissionless/bindings/pricefeeds/mellow-lrt.js +1 -1
  28. package/dist/esm/permissionless/bindings/pricefeeds/pendle-pt-twap.js +1 -1
  29. package/dist/esm/permissionless/bindings/pricefeeds/wsteth.js +1 -1
  30. package/dist/esm/permissionless/bindings/pricefeeds/zero.js +1 -1
  31. package/dist/esm/sdk/GearboxSDK.js +3 -4
  32. package/dist/esm/sdk/chain/Provider.js +20 -10
  33. package/dist/types/sdk/chain/Provider.d.ts +8 -3
  34. package/package.json +1 -1
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(balancer_stable_exports);
24
24
  var import_viem = require("viem");
25
25
  const balancerStablePriceFeed = {
26
26
  contractType: "PRICE_FEED::BALANCER_STABLE",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(balancer_weighted_exports);
24
24
  var import_viem = require("viem");
25
25
  const balancerWeightedPriceFeed = {
26
26
  contractType: "PRICE_FEED::BALANCER_WEIGHTED",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -23,7 +23,7 @@ __export(bounded_exports, {
23
23
  module.exports = __toCommonJS(bounded_exports);
24
24
  const boundedPriceFeed = {
25
25
  contractType: "PRICE_FEED::BOUNDED",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "underlyingPriceFeed",
@@ -23,7 +23,7 @@ __export(composite_exports, {
23
23
  module.exports = __toCommonJS(composite_exports);
24
24
  const compositePriceFeed = {
25
25
  contractType: "PRICE_FEED::COMPOSITE",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "underlyingPriceFeed",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(curve_crypto_exports);
24
24
  var import_viem = require("viem");
25
25
  const curveCryptoPriceFeed = {
26
26
  contractType: "PRICE_FEED::CURVE_CRYPTO",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(curve_stable_exports);
24
24
  var import_viem = require("viem");
25
25
  const curveStablePriceFeed = {
26
26
  contractType: "PRICE_FEED::CURVE_STABLE",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -23,7 +23,7 @@ __export(curve_twap_exports, {
23
23
  module.exports = __toCommonJS(curve_twap_exports);
24
24
  const curveTwapPriceFeed = {
25
25
  contractType: "PRICE_FEED::CURVE_TWAP",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "lowerBound ($)",
@@ -23,7 +23,7 @@ __export(curve_usd_exports, {
23
23
  module.exports = __toCommonJS(curve_usd_exports);
24
24
  const curveUsdPriceFeed = {
25
25
  contractType: "PRICE_FEED::CURVE_USD",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "priceStore",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(erc4626_exports);
24
24
  var import_viem = require("viem");
25
25
  const erc4626PriceFeed = {
26
26
  contractType: "PRICE_FEED::ERC4626",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -23,7 +23,7 @@ __export(kodiak_exports, {
23
23
  module.exports = __toCommonJS(kodiak_exports);
24
24
  const kodiakPriceFeed = {
25
25
  contractType: "PRICE_FEED::KODIAK_ISLAND",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "kodiakIsland",
@@ -23,7 +23,7 @@ __export(mellow_lrt_exports, {
23
23
  module.exports = __toCommonJS(mellow_lrt_exports);
24
24
  const mellowLrtPriceFeed = {
25
25
  contractType: "PRICE_FEED::MELLOW_LRT",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "priceStore",
@@ -23,7 +23,7 @@ __export(pendle_pt_twap_exports, {
23
23
  module.exports = __toCommonJS(pendle_pt_twap_exports);
24
24
  const pendlePtTwapPriceFeed = {
25
25
  contractType: "PRICE_FEED::PENDLE_PT_TWAP",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [
28
28
  {
29
29
  label: "market",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(wsteth_exports);
24
24
  var import_viem = require("viem");
25
25
  const wstethPriceFeed = {
26
26
  contractType: "PRICE_FEED::WSTETH",
27
- version: 310,
27
+ version: 311,
28
28
  constructorParams: [
29
29
  {
30
30
  label: "priceStore",
@@ -23,7 +23,7 @@ __export(zero_exports, {
23
23
  module.exports = __toCommonJS(zero_exports);
24
24
  const zeroPriceFeed = {
25
25
  contractType: "PRICE_FEED::ZERO",
26
- version: 310,
26
+ version: 311,
27
27
  constructorParams: [],
28
28
  stalenessPeriod: false
29
29
  };
@@ -89,8 +89,7 @@ class GearboxSDK {
89
89
  gasLimit
90
90
  } = options;
91
91
  let { networkType, addressProvider, chainId } = options;
92
- const transport = (0, import_chain.createTransport)(options);
93
- const attachClient = (0, import_viem.createPublicClient)({ transport });
92
+ const [transport, attachClient] = (0, import_chain.createTransportClient)(options);
94
93
  if (!networkType) {
95
94
  networkType = await (0, import_chain.detectNetwork)(attachClient);
96
95
  }
@@ -19,19 +19,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var Provider_exports = {};
20
20
  __export(Provider_exports, {
21
21
  Provider: () => Provider,
22
- createTransport: () => createTransport
22
+ createTransportClient: () => createTransportClient
23
23
  });
24
24
  module.exports = __toCommonJS(Provider_exports);
25
25
  var import_viem = require("viem");
26
26
  var import_AddressLabeller = require("../base/AddressLabeller.js");
27
27
  var import_chains = require("./chains.js");
28
- function createTransport(opts) {
28
+ function createTransportClient(opts, chain) {
29
29
  const { timeout = 12e4, retryCount } = opts;
30
+ let transport;
31
+ if ("client" in opts) {
32
+ transport = () => ({
33
+ config: opts.client.transport.config,
34
+ request: opts.client.transport.request,
35
+ value: opts.client.transport.value
36
+ });
37
+ return [transport, opts.client];
38
+ }
30
39
  if ("transport" in opts) {
31
- return opts.transport;
40
+ transport = opts.transport;
41
+ } else {
42
+ const rpcs = opts.rpcURLs.map((url) => (0, import_viem.http)(url, { timeout, retryCount }));
43
+ transport = rpcs.length > 1 ? (0, import_viem.fallback)(rpcs) : rpcs[0];
32
44
  }
33
- const rpcs = opts.rpcURLs.map((url) => (0, import_viem.http)(url, { timeout, retryCount }));
34
- return rpcs.length > 1 ? (0, import_viem.fallback)(rpcs) : rpcs[0];
45
+ return [transport, (0, import_viem.createPublicClient)({ transport, chain })];
35
46
  }
36
47
  class Provider {
37
48
  chainId;
@@ -48,11 +59,10 @@ class Provider {
48
59
  ...import_chains.chains[networkType],
49
60
  id: chainId
50
61
  });
51
- this.#transport = createTransport(opts);
52
- this.#publicClient = (0, import_viem.createPublicClient)({
53
- chain: this.chain,
54
- transport: this.#transport
55
- });
62
+ [this.#transport, this.#publicClient] = createTransportClient(
63
+ opts,
64
+ this.chain
65
+ );
56
66
  this.addressLabels = new import_AddressLabeller.AddressLabeller();
57
67
  }
58
68
  get transport() {
@@ -72,5 +82,5 @@ class Provider {
72
82
  // Annotate the CommonJS export names for ESM import in node:
73
83
  0 && (module.exports = {
74
84
  Provider,
75
- createTransport
85
+ createTransportClient
76
86
  });
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const balancerStablePriceFeed = {
3
3
  contractType: "PRICE_FEED::BALANCER_STABLE",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const balancerWeightedPriceFeed = {
3
3
  contractType: "PRICE_FEED::BALANCER_WEIGHTED",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,6 +1,6 @@
1
1
  const boundedPriceFeed = {
2
2
  contractType: "PRICE_FEED::BOUNDED",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "underlyingPriceFeed",
@@ -1,6 +1,6 @@
1
1
  const compositePriceFeed = {
2
2
  contractType: "PRICE_FEED::COMPOSITE",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "underlyingPriceFeed",
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const curveCryptoPriceFeed = {
3
3
  contractType: "PRICE_FEED::CURVE_CRYPTO",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const curveStablePriceFeed = {
3
3
  contractType: "PRICE_FEED::CURVE_STABLE",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,6 +1,6 @@
1
1
  const curveTwapPriceFeed = {
2
2
  contractType: "PRICE_FEED::CURVE_TWAP",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "lowerBound ($)",
@@ -1,6 +1,6 @@
1
1
  const curveUsdPriceFeed = {
2
2
  contractType: "PRICE_FEED::CURVE_USD",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "priceStore",
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const erc4626PriceFeed = {
3
3
  contractType: "PRICE_FEED::ERC4626",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,6 +1,6 @@
1
1
  const kodiakPriceFeed = {
2
2
  contractType: "PRICE_FEED::KODIAK_ISLAND",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "kodiakIsland",
@@ -1,6 +1,6 @@
1
1
  const mellowLrtPriceFeed = {
2
2
  contractType: "PRICE_FEED::MELLOW_LRT",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "priceStore",
@@ -1,6 +1,6 @@
1
1
  const pendlePtTwapPriceFeed = {
2
2
  contractType: "PRICE_FEED::PENDLE_PT_TWAP",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [
5
5
  {
6
6
  label: "market",
@@ -1,7 +1,7 @@
1
1
  import { parseAbi } from "viem";
2
2
  const wstethPriceFeed = {
3
3
  contractType: "PRICE_FEED::WSTETH",
4
- version: 310,
4
+ version: 311,
5
5
  constructorParams: [
6
6
  {
7
7
  label: "priceStore",
@@ -1,6 +1,6 @@
1
1
  const zeroPriceFeed = {
2
2
  contractType: "PRICE_FEED::ZERO",
3
- version: 310,
3
+ version: 311,
4
4
  constructorParams: [],
5
5
  stalenessPeriod: false
6
6
  };
@@ -1,8 +1,8 @@
1
- import { createPublicClient, parseEventLogs } from "viem";
1
+ import { parseEventLogs } from "viem";
2
2
  import { TokensMeta } from "./base/index.js";
3
3
  import {
4
4
  chains,
5
- createTransport,
5
+ createTransportClient,
6
6
  detectNetwork,
7
7
  Provider
8
8
  } from "./chain/index.js";
@@ -87,8 +87,7 @@ class GearboxSDK {
87
87
  gasLimit
88
88
  } = options;
89
89
  let { networkType, addressProvider, chainId } = options;
90
- const transport = createTransport(options);
91
- const attachClient = createPublicClient({ transport });
90
+ const [transport, attachClient] = createTransportClient(options);
92
91
  if (!networkType) {
93
92
  networkType = await detectNetwork(attachClient);
94
93
  }
@@ -1,13 +1,24 @@
1
1
  import { createPublicClient, defineChain, fallback, http } from "viem";
2
2
  import { AddressLabeller } from "../base/AddressLabeller.js";
3
3
  import { chains } from "./chains.js";
4
- function createTransport(opts) {
4
+ function createTransportClient(opts, chain) {
5
5
  const { timeout = 12e4, retryCount } = opts;
6
+ let transport;
7
+ if ("client" in opts) {
8
+ transport = () => ({
9
+ config: opts.client.transport.config,
10
+ request: opts.client.transport.request,
11
+ value: opts.client.transport.value
12
+ });
13
+ return [transport, opts.client];
14
+ }
6
15
  if ("transport" in opts) {
7
- return opts.transport;
16
+ transport = opts.transport;
17
+ } else {
18
+ const rpcs = opts.rpcURLs.map((url) => http(url, { timeout, retryCount }));
19
+ transport = rpcs.length > 1 ? fallback(rpcs) : rpcs[0];
8
20
  }
9
- const rpcs = opts.rpcURLs.map((url) => http(url, { timeout, retryCount }));
10
- return rpcs.length > 1 ? fallback(rpcs) : rpcs[0];
21
+ return [transport, createPublicClient({ transport, chain })];
11
22
  }
12
23
  class Provider {
13
24
  chainId;
@@ -24,11 +35,10 @@ class Provider {
24
35
  ...chains[networkType],
25
36
  id: chainId
26
37
  });
27
- this.#transport = createTransport(opts);
28
- this.#publicClient = createPublicClient({
29
- chain: this.chain,
30
- transport: this.#transport
31
- });
38
+ [this.#transport, this.#publicClient] = createTransportClient(
39
+ opts,
40
+ this.chain
41
+ );
32
42
  this.addressLabels = new AddressLabeller();
33
43
  }
34
44
  get transport() {
@@ -47,5 +57,5 @@ class Provider {
47
57
  }
48
58
  export {
49
59
  Provider,
50
- createTransport
60
+ createTransportClient
51
61
  };
@@ -1,4 +1,4 @@
1
- import type { PublicClient, Transport } from "viem";
1
+ import type { Chain, PublicClient, Transport } from "viem";
2
2
  import type { IAddressLabeller } from "../base/IAddressLabeller.js";
3
3
  import type { GearboxChain, NetworkType } from "./chains.js";
4
4
  export interface NetworkOptions {
@@ -18,9 +18,14 @@ export type TransportOptions = {
18
18
  rpcURLs: string[];
19
19
  } | {
20
20
  /**
21
- * Alternatively, can pass entire viem transport
21
+ * Alternatively, can pass viem transport
22
22
  */
23
23
  transport: Transport;
24
+ } | {
25
+ /**
26
+ * Alternatively, can pass entire viem client
27
+ */
28
+ client: PublicClient;
24
29
  };
25
30
  export interface ConnectionOptions {
26
31
  /**
@@ -32,7 +37,7 @@ export interface ConnectionOptions {
32
37
  */
33
38
  retryCount?: number;
34
39
  }
35
- export declare function createTransport(opts: TransportOptions & ConnectionOptions): Transport;
40
+ export declare function createTransportClient(opts: TransportOptions & ConnectionOptions, chain?: Chain): [Transport, PublicClient];
36
41
  export declare class Provider {
37
42
  #private;
38
43
  readonly chainId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "9.15.4",
3
+ "version": "9.16.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",