@gearbox-protocol/sdk 3.0.0-next.285 → 3.0.0-next.286
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.
|
@@ -6,6 +6,8 @@ import { ExtraRewardApy } from "./apy";
|
|
|
6
6
|
export interface GearboxExtraMerkleLmReward {
|
|
7
7
|
pool: Address;
|
|
8
8
|
poolToken: Address;
|
|
9
|
+
rewardTokenSymbol: string;
|
|
10
|
+
rewardTokenDecimals: number;
|
|
9
11
|
rewardToken: Address;
|
|
10
12
|
amount: bigint;
|
|
11
13
|
type: "extraMerkle";
|
|
@@ -13,6 +15,8 @@ export interface GearboxExtraMerkleLmReward {
|
|
|
13
15
|
export interface GearboxStakedV3LmReward {
|
|
14
16
|
pool: Address;
|
|
15
17
|
poolToken: Address;
|
|
18
|
+
rewardTokenSymbol: string;
|
|
19
|
+
rewardTokenDecimals: number;
|
|
16
20
|
rewardToken: Address;
|
|
17
21
|
amount: bigint;
|
|
18
22
|
type: "stakedV3";
|
|
@@ -20,6 +24,8 @@ export interface GearboxStakedV3LmReward {
|
|
|
20
24
|
export interface GearboxMerkleV2LmReward {
|
|
21
25
|
pool?: undefined;
|
|
22
26
|
poolToken?: undefined;
|
|
27
|
+
rewardTokenSymbol: string;
|
|
28
|
+
rewardTokenDecimals: number;
|
|
23
29
|
rewardToken: Address;
|
|
24
30
|
amount: bigint;
|
|
25
31
|
type: "merkleV2";
|
|
@@ -53,6 +59,7 @@ export interface GetExtraRewardsProps {
|
|
|
53
59
|
tokensList: Record<Address, TokenData>;
|
|
54
60
|
}
|
|
55
61
|
export interface GetLmRewardsProps {
|
|
62
|
+
pools: Array<PoolData>;
|
|
56
63
|
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
57
64
|
currentTokenData: Record<SupportedToken, Address>;
|
|
58
65
|
tokensList: Record<Address, TokenData>;
|
|
@@ -84,7 +91,7 @@ export declare class GearboxRewardsApi {
|
|
|
84
91
|
static getLmRewardsV2({ provider, account, currentTokenData, network, airdropDistributorAddress, }: GetLmRewardsProps): Promise<{
|
|
85
92
|
rewards: GearboxLmReward[];
|
|
86
93
|
}>;
|
|
87
|
-
static getLmRewardsV3({ baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }: GetLmRewardsProps): Promise<{
|
|
94
|
+
static getLmRewardsV3({ pools, baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }: GetLmRewardsProps): Promise<{
|
|
88
95
|
rewards: (GearboxLmReward | GearboxLmReward[])[];
|
|
89
96
|
}>;
|
|
90
97
|
private static extractFulfilled;
|
|
@@ -168,11 +168,13 @@ class GearboxRewardsApi {
|
|
|
168
168
|
amount: availableToClaimV2,
|
|
169
169
|
type: "merkleV2",
|
|
170
170
|
rewardToken: currentTokenData.GEAR,
|
|
171
|
+
rewardTokenDecimals: 18,
|
|
172
|
+
rewardTokenSymbol: "GEAR",
|
|
171
173
|
},
|
|
172
174
|
];
|
|
173
175
|
return { rewards: rewards };
|
|
174
176
|
}
|
|
175
|
-
static async getLmRewardsV3({ baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }) {
|
|
177
|
+
static async getLmRewardsV3({ pools, baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }) {
|
|
176
178
|
const poolTokens = Object.keys(baseRewardPoolsInfo);
|
|
177
179
|
const [gearboxLmResponse, merkleXYZLMResponse] = await Promise.allSettled([
|
|
178
180
|
provider.multicall({
|
|
@@ -193,34 +195,53 @@ class GearboxRewardsApi {
|
|
|
193
195
|
})),
|
|
194
196
|
]);
|
|
195
197
|
const gearboxLm = (this.extractFulfilled(gearboxLmResponse, reportError, "v3Rewards") || []);
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
const merkleXYZLm = this.extractFulfilled(merkleXYZLMResponse, reportError, "merkleRewards")?.data;
|
|
199
|
+
const poolByItsToken = Object.values(pools).reduce((acc, p) => {
|
|
200
|
+
p.stakedDieselToken.forEach(t => {
|
|
201
|
+
if (t)
|
|
202
|
+
acc[t] = p.address;
|
|
203
|
+
});
|
|
204
|
+
p.stakedDieselToken_old.forEach(t => {
|
|
205
|
+
if (t)
|
|
206
|
+
acc[t] = p.address;
|
|
207
|
+
});
|
|
208
|
+
acc[p.dieselToken] = p.address;
|
|
201
209
|
return acc;
|
|
202
210
|
}, {});
|
|
203
|
-
const extraRewards =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
const extraRewards = (merkleXYZLm || []).reduce((acc, chainRewards) => {
|
|
212
|
+
chainRewards.rewards.forEach(reward => {
|
|
213
|
+
const rewardToken = reward.token.address.toLowerCase();
|
|
214
|
+
reward.breakdowns.forEach(reason => {
|
|
215
|
+
const poolToken = ((reason.reason || "").split("_")[1] || "").toLowerCase();
|
|
216
|
+
const pool = (baseRewardPoolsInfo[poolToken]?.pool ||
|
|
217
|
+
poolToken ||
|
|
218
|
+
"").toLowerCase();
|
|
219
|
+
if (poolByItsToken[poolToken] && poolByItsToken[pool]) {
|
|
220
|
+
const total = (0, sdk_gov_1.toBigInt)(reason.amount || 0);
|
|
221
|
+
const claimed = (0, sdk_gov_1.toBigInt)(reason.claimed || 0);
|
|
222
|
+
acc.push({
|
|
223
|
+
pool,
|
|
224
|
+
poolToken,
|
|
225
|
+
rewardToken,
|
|
226
|
+
rewardTokenSymbol: reward.token.symbol,
|
|
227
|
+
rewardTokenDecimals: reward.token.decimals || 18,
|
|
228
|
+
amount: math_1.BigIntMath.max(total - claimed, 0n),
|
|
229
|
+
type: "extraMerkle",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
216
233
|
});
|
|
217
234
|
return acc;
|
|
218
235
|
}, []);
|
|
219
236
|
const gearboxLmRewards = poolTokens.map((address, i) => {
|
|
237
|
+
const info = baseRewardPoolsInfo[address];
|
|
238
|
+
const rewardToken = currentTokenData[info.symbol];
|
|
220
239
|
return {
|
|
221
|
-
pool:
|
|
240
|
+
pool: info.pool,
|
|
222
241
|
poolToken: address,
|
|
223
|
-
rewardToken
|
|
242
|
+
rewardToken,
|
|
243
|
+
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
244
|
+
rewardTokenSymbol: info.symbol,
|
|
224
245
|
amount: gearboxLm[i] || 0n,
|
|
225
246
|
type: "stakedV3",
|
|
226
247
|
};
|
|
@@ -4,21 +4,33 @@ interface UserOptions {
|
|
|
4
4
|
params: {
|
|
5
5
|
user: string;
|
|
6
6
|
chainId: number;
|
|
7
|
-
mainParameter?: string;
|
|
8
|
-
rewardToken?: string;
|
|
9
7
|
};
|
|
10
8
|
}
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export interface MerkleXYZUserRewardsV4 {
|
|
10
|
+
chain: MerkleXYZChain;
|
|
11
|
+
rewards: Array<{
|
|
12
|
+
root: Address;
|
|
13
|
+
recipient: Address;
|
|
14
|
+
amount: BigNumberish;
|
|
15
|
+
claimed: BigNumberish;
|
|
16
|
+
pending: BigNumberish;
|
|
17
|
+
proofs: Array<Address>;
|
|
18
|
+
token: {
|
|
19
|
+
address: Address;
|
|
20
|
+
chainId: number;
|
|
21
|
+
symbol: string;
|
|
22
|
+
decimals: number;
|
|
23
|
+
};
|
|
24
|
+
breakdowns: Array<{
|
|
25
|
+
reason: string;
|
|
26
|
+
amount: BigNumberish;
|
|
27
|
+
claimed: BigNumberish;
|
|
28
|
+
pending: BigNumberish;
|
|
29
|
+
campaignId: Address;
|
|
30
|
+
}>;
|
|
17
31
|
}>;
|
|
18
|
-
symbol: string;
|
|
19
|
-
unclaimed: BigNumberish;
|
|
20
32
|
}
|
|
21
|
-
export type
|
|
33
|
+
export type MerkleXYZUserRewardsV4Response = Array<MerkleXYZUserRewardsV4>;
|
|
22
34
|
interface MerkleXYZChain {
|
|
23
35
|
id: number;
|
|
24
36
|
name: string;
|
|
@@ -119,7 +131,6 @@ export interface MerklXYZV4RewardCampaign {
|
|
|
119
131
|
}
|
|
120
132
|
export type MerkleXYZV4RewardCampaignResponse = Array<MerklXYZV4RewardCampaign>;
|
|
121
133
|
export declare class MerkleXYZApi {
|
|
122
|
-
static domain: string;
|
|
123
134
|
static getUserRewardsUrl: (options: UserOptions) => string;
|
|
124
135
|
static getGearboxCampaignsUrl: () => string;
|
|
125
136
|
static getGearboxRewardCampaignUrl: (campaignId: Address) => string;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MerkleXYZApi = void 0;
|
|
4
|
-
const endpoint_1 = require("../core/endpoint");
|
|
5
4
|
// https://api.merkl.xyz/v3/campaignsForMainParameter?chainId=1&mainParameter=0xE2037090f896A858E3168B978668F22026AC52e7
|
|
6
5
|
class MerkleXYZApi {
|
|
7
|
-
static
|
|
8
|
-
static getUserRewardsUrl = (options) => endpoint_1.URLApi.getRelativeUrl([this.domain, "userRewards"].join("/"), options);
|
|
6
|
+
static getUserRewardsUrl = (options) => `https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
9
7
|
static getGearboxCampaignsUrl = () => "https://api.merkl.xyz/v4/opportunities?name=gearbox";
|
|
10
8
|
static getGearboxRewardCampaignUrl = (campaignId) => `https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
11
9
|
}
|