@gearbox-protocol/sdk 3.0.0-next.284 → 3.0.0-next.285
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.
|
@@ -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,
|
|
@@ -19,6 +19,23 @@ export interface MerkleXYZUserRewards {
|
|
|
19
19
|
unclaimed: BigNumberish;
|
|
20
20
|
}
|
|
21
21
|
export type MerkleXYZUserRewardsResponse = Record<string, MerkleXYZUserRewards>;
|
|
22
|
+
interface MerkleXYZChain {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string;
|
|
25
|
+
icon: string;
|
|
26
|
+
}
|
|
27
|
+
interface MerkleXYZToken {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
chainId: number;
|
|
31
|
+
address: Address;
|
|
32
|
+
decimals: number;
|
|
33
|
+
icon: string;
|
|
34
|
+
verified: boolean;
|
|
35
|
+
isTest: boolean;
|
|
36
|
+
price: number | null;
|
|
37
|
+
symbol: string;
|
|
38
|
+
}
|
|
22
39
|
export interface MerklXYZV4Campaign {
|
|
23
40
|
chainId: number;
|
|
24
41
|
type: string;
|
|
@@ -31,23 +48,8 @@ export interface MerklXYZV4Campaign {
|
|
|
31
48
|
dailyRewards: number;
|
|
32
49
|
tags: Array<string>;
|
|
33
50
|
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
|
-
};
|
|
51
|
+
tokens: Array<MerkleXYZToken>;
|
|
52
|
+
chain: MerkleXYZChain;
|
|
51
53
|
aprRecord: {
|
|
52
54
|
cumulated: number;
|
|
53
55
|
timestamp: string;
|
|
@@ -70,19 +72,7 @@ export interface MerklXYZV4Campaign {
|
|
|
70
72
|
total: number;
|
|
71
73
|
timestamp: string;
|
|
72
74
|
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
|
-
};
|
|
75
|
+
token: MerkleXYZToken;
|
|
86
76
|
amount: string;
|
|
87
77
|
id: number;
|
|
88
78
|
value: number;
|
|
@@ -92,19 +82,46 @@ export interface MerklXYZV4Campaign {
|
|
|
92
82
|
};
|
|
93
83
|
}
|
|
94
84
|
export type MerkleXYZV4CampaignsResponse = Array<MerklXYZV4Campaign>;
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
export interface MerklXYZV4RewardCampaign {
|
|
86
|
+
id: string;
|
|
87
|
+
computeChainId: number;
|
|
88
|
+
distributionChainId: number;
|
|
89
|
+
campaignId: Address;
|
|
90
|
+
rewardTokenId: string;
|
|
91
|
+
amount: string;
|
|
92
|
+
opportunityId: string;
|
|
93
|
+
startTimestamp: string;
|
|
94
|
+
endTimestamp: string;
|
|
95
|
+
creatorAddress: Address;
|
|
96
|
+
params: {
|
|
97
|
+
url: string;
|
|
98
|
+
duration: number;
|
|
99
|
+
blacklist: Array<Address>;
|
|
100
|
+
whitelist: Array<Address>;
|
|
101
|
+
forwarders: Array<Address>;
|
|
102
|
+
targetToken: Address;
|
|
103
|
+
symbolRewardToken: string;
|
|
104
|
+
symbolTargetToken: string;
|
|
105
|
+
decimalsRewardToken: number;
|
|
106
|
+
decimalsTargetToken: number;
|
|
107
|
+
};
|
|
108
|
+
chain: MerkleXYZChain;
|
|
109
|
+
rewardToken: MerkleXYZToken;
|
|
110
|
+
distributionChain: MerkleXYZChain;
|
|
111
|
+
campaignStatus: {
|
|
112
|
+
campaignId: string;
|
|
113
|
+
computedUntil: string;
|
|
114
|
+
processingStarted: string;
|
|
115
|
+
status: "SUCCESS";
|
|
116
|
+
error: string;
|
|
117
|
+
details: string;
|
|
118
|
+
};
|
|
103
119
|
}
|
|
104
|
-
export type
|
|
120
|
+
export type MerkleXYZV4RewardCampaignResponse = Array<MerklXYZV4RewardCampaign>;
|
|
105
121
|
export declare class MerkleXYZApi {
|
|
106
122
|
static domain: string;
|
|
107
123
|
static getUserRewardsUrl: (options: UserOptions) => string;
|
|
108
124
|
static getGearboxCampaignsUrl: () => string;
|
|
125
|
+
static getGearboxRewardCampaignUrl: (campaignId: Address) => string;
|
|
109
126
|
}
|
|
110
127
|
export {};
|
|
@@ -7,5 +7,6 @@ class MerkleXYZApi {
|
|
|
7
7
|
static domain = "https://api.merkl.xyz/v3";
|
|
8
8
|
static getUserRewardsUrl = (options) => endpoint_1.URLApi.getRelativeUrl([this.domain, "userRewards"].join("/"), options);
|
|
9
9
|
static getGearboxCampaignsUrl = () => "https://api.merkl.xyz/v4/opportunities?name=gearbox";
|
|
10
|
+
static getGearboxRewardCampaignUrl = (campaignId) => `https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
10
11
|
}
|
|
11
12
|
exports.MerkleXYZApi = MerkleXYZApi;
|