@gearbox-protocol/sdk 13.0.0-next.32 → 13.0.0-next.33

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.
@@ -41,6 +41,8 @@ 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
+ constructor() {
45
+ }
44
46
  static async getLmRewardsV2({
45
47
  provider,
46
48
  account,
@@ -186,7 +188,7 @@ class GearboxRewardsApi {
186
188
  reportError
187
189
  }) {
188
190
  const [merkleXYZLMResponse] = await Promise.allSettled([
189
- import_axios.default.get(
191
+ import_merklAPI.MerkleXYZApi.fetchWithFallback(
190
192
  import_merklAPI.MerkleXYZApi.getUserRewardsUrl({
191
193
  params: {
192
194
  chainId: import_chain.chains[network].id,
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,14 +17,34 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var merklAPI_exports = {};
20
30
  __export(merklAPI_exports, {
21
31
  MerkleXYZApi: () => MerkleXYZApi
22
32
  });
23
33
  module.exports = __toCommonJS(merklAPI_exports);
34
+ var import_axios = __toESM(require("axios"));
24
35
  class MerkleXYZApi {
25
- static getUserRewardsUrl = (options) => `https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
36
+ constructor() {
37
+ }
38
+ static defaultDomain = "https://api.merkl.xyz";
39
+ static angleDomain = "https://api-merkl.angle.money";
40
+ static fetchWithFallback = async (getUrl) => {
41
+ try {
42
+ return await import_axios.default.get(getUrl(MerkleXYZApi.defaultDomain));
43
+ } catch {
44
+ return await import_axios.default.get(getUrl(MerkleXYZApi.angleDomain));
45
+ }
46
+ };
47
+ static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
26
48
  }
27
49
  // Annotate the CommonJS export names for ESM import in node:
28
50
  0 && (module.exports = {
@@ -8,6 +8,8 @@ import { GearboxBackendApi } from "../core/endpoint.js";
8
8
  import { BigIntMath } from "../utils/math.js";
9
9
  import { MerkleXYZApi } from "./merklAPI.js";
10
10
  class GearboxRewardsApi {
11
+ constructor() {
12
+ }
11
13
  static async getLmRewardsV2({
12
14
  provider,
13
15
  account,
@@ -153,7 +155,7 @@ class GearboxRewardsApi {
153
155
  reportError
154
156
  }) {
155
157
  const [merkleXYZLMResponse] = await Promise.allSettled([
156
- axios.get(
158
+ MerkleXYZApi.fetchWithFallback(
157
159
  MerkleXYZApi.getUserRewardsUrl({
158
160
  params: {
159
161
  chainId: chains[network].id,
@@ -1,5 +1,17 @@
1
+ import axios from "axios";
1
2
  class MerkleXYZApi {
2
- static getUserRewardsUrl = (options) => `https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
3
+ constructor() {
4
+ }
5
+ static defaultDomain = "https://api.merkl.xyz";
6
+ static angleDomain = "https://api-merkl.angle.money";
7
+ static fetchWithFallback = async (getUrl) => {
8
+ try {
9
+ return await axios.get(getUrl(MerkleXYZApi.defaultDomain));
10
+ } catch {
11
+ return await axios.get(getUrl(MerkleXYZApi.angleDomain));
12
+ }
13
+ };
14
+ static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
3
15
  }
4
16
  export {
5
17
  MerkleXYZApi
@@ -74,6 +74,7 @@ export interface ClaimLmRewardsV3Props {
74
74
  signer: WalletClient;
75
75
  }
76
76
  export declare class GearboxRewardsApi {
77
+ private constructor();
77
78
  static getLmRewardsV2({ provider, account, gearTokenAddress, network, airdropDistributorAddress, reportError, }: GetLmRewardsV2Props): Promise<GearboxLmReward[]>;
78
79
  static getLmRewardsV3({ pools, tokensList, provider, account, reportError, }: GetLmRewardsV3Props): Promise<(GearboxLmReward | GearboxLmReward[])[]>;
79
80
  static getLmRewardsMerkle({ pools, account, network, reportError, }: GetLmRewardsMerkleProps): Promise<GearboxLmReward[]>;
@@ -37,6 +37,10 @@ interface MerkleXYZChain {
37
37
  icon: string;
38
38
  }
39
39
  export declare class MerkleXYZApi {
40
- static getUserRewardsUrl: (options: UserOptions) => string;
40
+ private constructor();
41
+ static defaultDomain: string;
42
+ static angleDomain: string;
43
+ static fetchWithFallback: <T>(getUrl: (domain: string) => string) => Promise<import("axios").AxiosResponse<T, any, {}>>;
44
+ static getUserRewardsUrl: (options: UserOptions) => (domain: string) => string;
41
45
  }
42
46
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "13.0.0-next.32",
3
+ "version": "13.0.0-next.33",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",