@gearbox-protocol/sdk 14.11.0-next.7 → 14.11.0-next.9
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/preview/simulate/simulatePoolOperation.js +4 -1
- package/dist/cjs/rewards/rewards/api.js +4 -2
- package/dist/cjs/rewards/rewards/merkl-api.js +9 -3
- package/dist/esm/preview/simulate/simulatePoolOperation.js +4 -1
- package/dist/esm/rewards/rewards/api.js +4 -2
- package/dist/esm/rewards/rewards/merkl-api.js +9 -3
- package/dist/types/rewards/rewards/api.d.ts +2 -1
- package/dist/types/rewards/rewards/merkl-api.d.ts +2 -1
- package/package.json +1 -1
|
@@ -21,11 +21,14 @@ __export(simulatePoolOperation_exports, {
|
|
|
21
21
|
simulatePoolOperation: () => simulatePoolOperation
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(simulatePoolOperation_exports);
|
|
24
|
+
var import_constants = require("./constants.js");
|
|
24
25
|
var import_errors = require("./errors.js");
|
|
25
26
|
var import_simulatePoolOpMulticall = require("./simulatePoolOpMulticall.js");
|
|
26
27
|
var import_simulatePoolOpV1 = require("./simulatePoolOpV1.js");
|
|
27
28
|
async function simulatePoolOperation(input, options = {}) {
|
|
28
|
-
const {
|
|
29
|
+
const { sdk } = input;
|
|
30
|
+
const { logger } = options;
|
|
31
|
+
const useSimulateV1 = options.useSimulateV1 ?? import_constants.ETH_SIMULATE_V1_NETWORKS.has(sdk.networkType);
|
|
29
32
|
logger?.debug(
|
|
30
33
|
{ wallet: input.wallet, to: input.to },
|
|
31
34
|
"simulating pool operation"
|
|
@@ -32,7 +32,8 @@ class RewardAmountAPI {
|
|
|
32
32
|
pools,
|
|
33
33
|
account,
|
|
34
34
|
network,
|
|
35
|
-
reportError
|
|
35
|
+
reportError,
|
|
36
|
+
apiKey
|
|
36
37
|
}) {
|
|
37
38
|
const [merkleXYZLMResponse] = await Promise.allSettled([
|
|
38
39
|
import_merkl_api.MerkleXYZApi.fetchWithFallback(
|
|
@@ -41,7 +42,8 @@ class RewardAmountAPI {
|
|
|
41
42
|
chainId: import_sdk.chains[network].id,
|
|
42
43
|
user: (0, import_viem.getAddress)(account)
|
|
43
44
|
}
|
|
44
|
-
})
|
|
45
|
+
}),
|
|
46
|
+
apiKey
|
|
45
47
|
)
|
|
46
48
|
]);
|
|
47
49
|
const merkleXYZLm = RewardAmountAPI.extractFulfilled(
|
|
@@ -37,11 +37,17 @@ class MerkleXYZApi {
|
|
|
37
37
|
}
|
|
38
38
|
static defaultDomain = "https://api.merkl.xyz";
|
|
39
39
|
static angleDomain = "https://api-merkl.angle.money";
|
|
40
|
-
static
|
|
40
|
+
static apiKeyHeader = "X-API-Key";
|
|
41
|
+
static fetchWithFallback = async (getUrl, apiKey) => {
|
|
42
|
+
const headers = apiKey ? { [MerkleXYZApi.apiKeyHeader]: apiKey } : void 0;
|
|
41
43
|
try {
|
|
42
|
-
return await import_axios.default.get(getUrl(MerkleXYZApi.defaultDomain)
|
|
44
|
+
return await import_axios.default.get(getUrl(MerkleXYZApi.defaultDomain), {
|
|
45
|
+
headers
|
|
46
|
+
});
|
|
43
47
|
} catch {
|
|
44
|
-
return await import_axios.default.get(getUrl(MerkleXYZApi.angleDomain)
|
|
48
|
+
return await import_axios.default.get(getUrl(MerkleXYZApi.angleDomain), {
|
|
49
|
+
headers
|
|
50
|
+
});
|
|
45
51
|
}
|
|
46
52
|
};
|
|
47
53
|
static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ETH_SIMULATE_V1_NETWORKS } from "./constants.js";
|
|
1
2
|
import {
|
|
2
3
|
asPreviewSimulationError,
|
|
3
4
|
combinePreviewSimulationErrors
|
|
@@ -5,7 +6,9 @@ import {
|
|
|
5
6
|
import { simulatePoolOpMulticall } from "./simulatePoolOpMulticall.js";
|
|
6
7
|
import { simulatePoolOpV1 } from "./simulatePoolOpV1.js";
|
|
7
8
|
async function simulatePoolOperation(input, options = {}) {
|
|
8
|
-
const {
|
|
9
|
+
const { sdk } = input;
|
|
10
|
+
const { logger } = options;
|
|
11
|
+
const useSimulateV1 = options.useSimulateV1 ?? ETH_SIMULATE_V1_NETWORKS.has(sdk.networkType);
|
|
9
12
|
logger?.debug(
|
|
10
13
|
{ wallet: input.wallet, to: input.to },
|
|
11
14
|
"simulating pool operation"
|
|
@@ -11,7 +11,8 @@ class RewardAmountAPI {
|
|
|
11
11
|
pools,
|
|
12
12
|
account,
|
|
13
13
|
network,
|
|
14
|
-
reportError
|
|
14
|
+
reportError,
|
|
15
|
+
apiKey
|
|
15
16
|
}) {
|
|
16
17
|
const [merkleXYZLMResponse] = await Promise.allSettled([
|
|
17
18
|
MerkleXYZApi.fetchWithFallback(
|
|
@@ -20,7 +21,8 @@ class RewardAmountAPI {
|
|
|
20
21
|
chainId: chains[network].id,
|
|
21
22
|
user: getAddress(account)
|
|
22
23
|
}
|
|
23
|
-
})
|
|
24
|
+
}),
|
|
25
|
+
apiKey
|
|
24
26
|
)
|
|
25
27
|
]);
|
|
26
28
|
const merkleXYZLm = RewardAmountAPI.extractFulfilled(
|
|
@@ -4,11 +4,17 @@ class MerkleXYZApi {
|
|
|
4
4
|
}
|
|
5
5
|
static defaultDomain = "https://api.merkl.xyz";
|
|
6
6
|
static angleDomain = "https://api-merkl.angle.money";
|
|
7
|
-
static
|
|
7
|
+
static apiKeyHeader = "X-API-Key";
|
|
8
|
+
static fetchWithFallback = async (getUrl, apiKey) => {
|
|
9
|
+
const headers = apiKey ? { [MerkleXYZApi.apiKeyHeader]: apiKey } : void 0;
|
|
8
10
|
try {
|
|
9
|
-
return await axios.get(getUrl(MerkleXYZApi.defaultDomain)
|
|
11
|
+
return await axios.get(getUrl(MerkleXYZApi.defaultDomain), {
|
|
12
|
+
headers
|
|
13
|
+
});
|
|
10
14
|
} catch {
|
|
11
|
-
return await axios.get(getUrl(MerkleXYZApi.angleDomain)
|
|
15
|
+
return await axios.get(getUrl(MerkleXYZApi.angleDomain), {
|
|
16
|
+
headers
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
19
|
};
|
|
14
20
|
static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
@@ -26,10 +26,11 @@ export interface GetLmRewardsMerkleProps {
|
|
|
26
26
|
account: Address;
|
|
27
27
|
network: NetworkType;
|
|
28
28
|
reportError?: ReportHandler;
|
|
29
|
+
apiKey?: string;
|
|
29
30
|
}
|
|
30
31
|
export declare class RewardAmountAPI {
|
|
31
32
|
private constructor();
|
|
32
|
-
static getLmRewardsMerkle({ pools, account, network, reportError, }: GetLmRewardsMerkleProps): Promise<GearboxExtraMerkleLmReward[]>;
|
|
33
|
+
static getLmRewardsMerkle({ pools, account, network, reportError, apiKey, }: GetLmRewardsMerkleProps): Promise<GearboxExtraMerkleLmReward[]>;
|
|
33
34
|
private static extractFulfilled;
|
|
34
35
|
}
|
|
35
36
|
export {};
|
|
@@ -39,7 +39,8 @@ export declare class MerkleXYZApi {
|
|
|
39
39
|
private constructor();
|
|
40
40
|
static defaultDomain: string;
|
|
41
41
|
static angleDomain: string;
|
|
42
|
-
static
|
|
42
|
+
static apiKeyHeader: string;
|
|
43
|
+
static fetchWithFallback: <T>(getUrl: (domain: string) => string, apiKey?: string) => Promise<import("axios").AxiosResponse<T, any, {}>>;
|
|
43
44
|
static getUserRewardsUrl: (options: UserOptions) => (domain: string) => string;
|
|
44
45
|
}
|
|
45
46
|
export {};
|