@gearbox-protocol/sdk 12.9.5 → 12.9.7
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/sdk/market/pricefeeds/PythPriceFeed.js +20 -0
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +3 -1
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/merklAPI.js +23 -1
- package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +21 -1
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +3 -1
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/merklAPI.js +13 -1
- package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +21 -1
- package/dist/types/sdk/sdk-legacy/gearboxRewards/api.d.ts +1 -0
- package/dist/types/sdk/sdk-legacy/gearboxRewards/merklAPI.d.ts +5 -1
- package/package.json +1 -1
|
@@ -25,6 +25,9 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_oracles = require("../../abi/oracles.js");
|
|
26
26
|
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
27
27
|
const abi = import_oracles.pythPriceFeedAbi;
|
|
28
|
+
const iPythAbi = (0, import_viem.parseAbi)([
|
|
29
|
+
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
30
|
+
]);
|
|
28
31
|
class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
29
32
|
token;
|
|
30
33
|
priceFeedId;
|
|
@@ -71,6 +74,23 @@ class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
|
71
74
|
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
72
75
|
});
|
|
73
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
79
|
+
* @param calldata
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
getUpdateFeeParams(calldata) {
|
|
83
|
+
const [, updateData] = (0, import_viem.decodeAbiParameters)(
|
|
84
|
+
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
85
|
+
calldata
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
address: this.pyth,
|
|
89
|
+
abi: iPythAbi,
|
|
90
|
+
functionName: "getUpdateFee",
|
|
91
|
+
args: [updateData]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
96
|
0 && (module.exports = {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 = {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { decodeAbiParameters } from "viem";
|
|
1
|
+
import { decodeAbiParameters, parseAbi } from "viem";
|
|
2
2
|
import { pythPriceFeedAbi } from "../../abi/oracles.js";
|
|
3
3
|
import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
|
|
4
4
|
const abi = pythPriceFeedAbi;
|
|
5
|
+
const iPythAbi = parseAbi([
|
|
6
|
+
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
7
|
+
]);
|
|
5
8
|
class PythPriceFeed extends AbstractPriceFeedContract {
|
|
6
9
|
token;
|
|
7
10
|
priceFeedId;
|
|
@@ -48,6 +51,23 @@ class PythPriceFeed extends AbstractPriceFeedContract {
|
|
|
48
51
|
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
49
52
|
});
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
56
|
+
* @param calldata
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
getUpdateFeeParams(calldata) {
|
|
60
|
+
const [, updateData] = decodeAbiParameters(
|
|
61
|
+
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
62
|
+
calldata
|
|
63
|
+
);
|
|
64
|
+
return {
|
|
65
|
+
address: this.pyth,
|
|
66
|
+
abi: iPythAbi,
|
|
67
|
+
functionName: "getUpdateFee",
|
|
68
|
+
args: [updateData]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
51
71
|
}
|
|
52
72
|
export {
|
|
53
73
|
PythPriceFeed
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
1
|
+
import type { Address, ContractFunctionParameters, Hex } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/Construct.js";
|
|
3
3
|
import type { RawTx } from "../../types/index.js";
|
|
4
4
|
import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
@@ -217,6 +217,20 @@ declare const abi: readonly [{
|
|
|
217
217
|
readonly inputs: readonly [];
|
|
218
218
|
}];
|
|
219
219
|
type abi = typeof abi;
|
|
220
|
+
declare const iPythAbi: readonly [{
|
|
221
|
+
readonly name: "getUpdateFee";
|
|
222
|
+
readonly type: "function";
|
|
223
|
+
readonly stateMutability: "view";
|
|
224
|
+
readonly inputs: readonly [{
|
|
225
|
+
readonly type: "bytes[]";
|
|
226
|
+
readonly name: "updateData";
|
|
227
|
+
}];
|
|
228
|
+
readonly outputs: readonly [{
|
|
229
|
+
readonly type: "uint256";
|
|
230
|
+
readonly name: "feeAmount";
|
|
231
|
+
}];
|
|
232
|
+
}];
|
|
233
|
+
type iPythAbi = typeof iPythAbi;
|
|
220
234
|
export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implements IUpdatablePriceFeedContract {
|
|
221
235
|
readonly token: Address;
|
|
222
236
|
readonly priceFeedId: Hex;
|
|
@@ -224,5 +238,11 @@ export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implem
|
|
|
224
238
|
readonly maxConfToPriceRatio?: bigint;
|
|
225
239
|
constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
|
|
226
240
|
createPriceUpdateTx(data: `0x${string}`): RawTx;
|
|
241
|
+
/**
|
|
242
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
243
|
+
* @param calldata
|
|
244
|
+
* @returns
|
|
245
|
+
*/
|
|
246
|
+
getUpdateFeeParams(calldata: Hex): ContractFunctionParameters<iPythAbi, "view", "getUpdateFee">;
|
|
227
247
|
}
|
|
228
248
|
export {};
|
|
@@ -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
|
-
|
|
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 {};
|