@gearbox-protocol/sdk 3.0.0-next.284 → 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;
|
|
@@ -15,13 +15,34 @@ class GearboxRewardsApi {
|
|
|
15
15
|
static async getExtraRewards({ chainId, tokensList }) {
|
|
16
16
|
const res = await axios_1.default.get(merklAPI_1.MerkleXYZApi.getGearboxCampaignsUrl());
|
|
17
17
|
const currentActiveCampaigns = res.data.filter(c => c.status === "LIVE" && c.chainId === chainId);
|
|
18
|
+
const aprIdsList = currentActiveCampaigns
|
|
19
|
+
.map(c =>
|
|
20
|
+
// apr token for campaigns with a single reward is obvious
|
|
21
|
+
c.aprRecord.breakdowns.length > 1
|
|
22
|
+
? c.aprRecord.breakdowns.map(b => {
|
|
23
|
+
return {
|
|
24
|
+
campaignId: c.id,
|
|
25
|
+
aprId: b.identifier,
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
: [])
|
|
29
|
+
.flat(1);
|
|
30
|
+
const aprIdsResponse = await Promise.allSettled(aprIdsList.map(id => axios_1.default.get(merklAPI_1.MerkleXYZApi.getGearboxRewardCampaignUrl(id.aprId))));
|
|
31
|
+
const aprCampaignByAPRId = aprIdsResponse.reduce((acc, r, i) => {
|
|
32
|
+
const id = aprIdsList[i].aprId;
|
|
33
|
+
acc[id] = r.status === "fulfilled" ? r.value.data : undefined;
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
18
36
|
const r = currentActiveCampaigns.reduce((acc, campaign) => {
|
|
19
37
|
const rewardSource = (campaign.tokens[0]?.address || campaign.identifier).toLowerCase();
|
|
20
|
-
const allRewards = campaign.
|
|
38
|
+
const allRewards = campaign.aprRecord.breakdowns
|
|
21
39
|
.map((r, i) => {
|
|
22
|
-
const
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
40
|
+
const apy = r.value;
|
|
41
|
+
const { rewardToken } = aprCampaignByAPRId[r.identifier]?.[0] || {};
|
|
42
|
+
const tokenRewardsRecord = campaign.rewardsRecord.breakdowns[i]?.token;
|
|
43
|
+
const { address = tokenRewardsRecord?.address || "" } = rewardToken || {};
|
|
44
|
+
const tokenLc = address.toLowerCase();
|
|
45
|
+
const { symbol = rewardToken?.symbol || tokenRewardsRecord?.symbol || "", } = tokensList[tokenLc] || {};
|
|
25
46
|
const apyObject = {
|
|
26
47
|
token: rewardSource,
|
|
27
48
|
balance: null,
|
|
@@ -147,11 +168,13 @@ class GearboxRewardsApi {
|
|
|
147
168
|
amount: availableToClaimV2,
|
|
148
169
|
type: "merkleV2",
|
|
149
170
|
rewardToken: currentTokenData.GEAR,
|
|
171
|
+
rewardTokenDecimals: 18,
|
|
172
|
+
rewardTokenSymbol: "GEAR",
|
|
150
173
|
},
|
|
151
174
|
];
|
|
152
175
|
return { rewards: rewards };
|
|
153
176
|
}
|
|
154
|
-
static async getLmRewardsV3({ baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }) {
|
|
177
|
+
static async getLmRewardsV3({ pools, baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }) {
|
|
155
178
|
const poolTokens = Object.keys(baseRewardPoolsInfo);
|
|
156
179
|
const [gearboxLmResponse, merkleXYZLMResponse] = await Promise.allSettled([
|
|
157
180
|
provider.multicall({
|
|
@@ -172,34 +195,53 @@ class GearboxRewardsApi {
|
|
|
172
195
|
})),
|
|
173
196
|
]);
|
|
174
197
|
const gearboxLm = (this.extractFulfilled(gearboxLmResponse, reportError, "v3Rewards") || []);
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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;
|
|
180
209
|
return acc;
|
|
181
210
|
}, {});
|
|
182
|
-
const extraRewards =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
+
});
|
|
195
233
|
});
|
|
196
234
|
return acc;
|
|
197
235
|
}, []);
|
|
198
236
|
const gearboxLmRewards = poolTokens.map((address, i) => {
|
|
237
|
+
const info = baseRewardPoolsInfo[address];
|
|
238
|
+
const rewardToken = currentTokenData[info.symbol];
|
|
199
239
|
return {
|
|
200
|
-
pool:
|
|
240
|
+
pool: info.pool,
|
|
201
241
|
poolToken: address,
|
|
202
|
-
rewardToken
|
|
242
|
+
rewardToken,
|
|
243
|
+
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
244
|
+
rewardTokenSymbol: info.symbol,
|
|
203
245
|
amount: gearboxLm[i] || 0n,
|
|
204
246
|
type: "stakedV3",
|
|
205
247
|
};
|
|
@@ -4,21 +4,50 @@ 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
|
}>;
|
|
32
|
+
}
|
|
33
|
+
export type MerkleXYZUserRewardsV4Response = Array<MerkleXYZUserRewardsV4>;
|
|
34
|
+
interface MerkleXYZChain {
|
|
35
|
+
id: number;
|
|
36
|
+
name: string;
|
|
37
|
+
icon: string;
|
|
38
|
+
}
|
|
39
|
+
interface MerkleXYZToken {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
chainId: number;
|
|
43
|
+
address: Address;
|
|
44
|
+
decimals: number;
|
|
45
|
+
icon: string;
|
|
46
|
+
verified: boolean;
|
|
47
|
+
isTest: boolean;
|
|
48
|
+
price: number | null;
|
|
18
49
|
symbol: string;
|
|
19
|
-
unclaimed: BigNumberish;
|
|
20
50
|
}
|
|
21
|
-
export type MerkleXYZUserRewardsResponse = Record<string, MerkleXYZUserRewards>;
|
|
22
51
|
export interface MerklXYZV4Campaign {
|
|
23
52
|
chainId: number;
|
|
24
53
|
type: string;
|
|
@@ -31,23 +60,8 @@ export interface MerklXYZV4Campaign {
|
|
|
31
60
|
dailyRewards: number;
|
|
32
61
|
tags: Array<string>;
|
|
33
62
|
id: string;
|
|
34
|
-
tokens: Array<
|
|
35
|
-
|
|
36
|
-
name: string;
|
|
37
|
-
chainId: number;
|
|
38
|
-
address: Address;
|
|
39
|
-
decimals: number;
|
|
40
|
-
icon: string;
|
|
41
|
-
verified: boolean;
|
|
42
|
-
isTest: boolean;
|
|
43
|
-
price: number | null;
|
|
44
|
-
symbol: string;
|
|
45
|
-
}>;
|
|
46
|
-
chain: {
|
|
47
|
-
id: number;
|
|
48
|
-
name: string;
|
|
49
|
-
icon: string;
|
|
50
|
-
};
|
|
63
|
+
tokens: Array<MerkleXYZToken>;
|
|
64
|
+
chain: MerkleXYZChain;
|
|
51
65
|
aprRecord: {
|
|
52
66
|
cumulated: number;
|
|
53
67
|
timestamp: string;
|
|
@@ -70,19 +84,7 @@ export interface MerklXYZV4Campaign {
|
|
|
70
84
|
total: number;
|
|
71
85
|
timestamp: string;
|
|
72
86
|
breakdowns: Array<{
|
|
73
|
-
token:
|
|
74
|
-
id: string;
|
|
75
|
-
name: string;
|
|
76
|
-
chainId: number;
|
|
77
|
-
address: Address;
|
|
78
|
-
decimals: 18;
|
|
79
|
-
symbol: string;
|
|
80
|
-
displaySymbol: string;
|
|
81
|
-
icon: string;
|
|
82
|
-
verified: boolean;
|
|
83
|
-
isTest: boolean;
|
|
84
|
-
price: number;
|
|
85
|
-
};
|
|
87
|
+
token: MerkleXYZToken;
|
|
86
88
|
amount: string;
|
|
87
89
|
id: number;
|
|
88
90
|
value: number;
|
|
@@ -92,19 +94,45 @@ export interface MerklXYZV4Campaign {
|
|
|
92
94
|
};
|
|
93
95
|
}
|
|
94
96
|
export type MerkleXYZV4CampaignsResponse = Array<MerklXYZV4Campaign>;
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
export interface MerklXYZV4RewardCampaign {
|
|
98
|
+
id: string;
|
|
99
|
+
computeChainId: number;
|
|
100
|
+
distributionChainId: number;
|
|
101
|
+
campaignId: Address;
|
|
102
|
+
rewardTokenId: string;
|
|
103
|
+
amount: string;
|
|
104
|
+
opportunityId: string;
|
|
105
|
+
startTimestamp: string;
|
|
106
|
+
endTimestamp: string;
|
|
107
|
+
creatorAddress: Address;
|
|
108
|
+
params: {
|
|
109
|
+
url: string;
|
|
110
|
+
duration: number;
|
|
111
|
+
blacklist: Array<Address>;
|
|
112
|
+
whitelist: Array<Address>;
|
|
113
|
+
forwarders: Array<Address>;
|
|
114
|
+
targetToken: Address;
|
|
115
|
+
symbolRewardToken: string;
|
|
116
|
+
symbolTargetToken: string;
|
|
117
|
+
decimalsRewardToken: number;
|
|
118
|
+
decimalsTargetToken: number;
|
|
119
|
+
};
|
|
120
|
+
chain: MerkleXYZChain;
|
|
121
|
+
rewardToken: MerkleXYZToken;
|
|
122
|
+
distributionChain: MerkleXYZChain;
|
|
123
|
+
campaignStatus: {
|
|
124
|
+
campaignId: string;
|
|
125
|
+
computedUntil: string;
|
|
126
|
+
processingStarted: string;
|
|
127
|
+
status: "SUCCESS";
|
|
128
|
+
error: string;
|
|
129
|
+
details: string;
|
|
130
|
+
};
|
|
103
131
|
}
|
|
104
|
-
export type
|
|
132
|
+
export type MerkleXYZV4RewardCampaignResponse = Array<MerklXYZV4RewardCampaign>;
|
|
105
133
|
export declare class MerkleXYZApi {
|
|
106
|
-
static domain: string;
|
|
107
134
|
static getUserRewardsUrl: (options: UserOptions) => string;
|
|
108
135
|
static getGearboxCampaignsUrl: () => string;
|
|
136
|
+
static getGearboxRewardCampaignUrl: (campaignId: Address) => string;
|
|
109
137
|
}
|
|
110
138
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
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";
|
|
8
|
+
static getGearboxRewardCampaignUrl = (campaignId) => `https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
10
9
|
}
|
|
11
10
|
exports.MerkleXYZApi = MerkleXYZApi;
|