@gearbox-protocol/sdk 3.0.0-vfour.392 → 3.0.0-vfour.393
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/sdk-legacy/gearboxRewards/api.js +0 -60
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/merklAPI.js +0 -2
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +0 -60
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/merklAPI.js +0 -2
- package/dist/types/sdk/sdk-legacy/gearboxRewards/api.d.ts +0 -6
- package/dist/types/sdk/sdk-legacy/gearboxRewards/merklAPI.d.ts +0 -116
- package/package.json +1 -1
|
@@ -40,67 +40,7 @@ var import_utils = require("../../utils/index.js");
|
|
|
40
40
|
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
|
-
const BROKEN_CAMPAIGNS = {
|
|
44
|
-
"11136065905617273958": true
|
|
45
|
-
};
|
|
46
43
|
class GearboxRewardsApi {
|
|
47
|
-
static async getExtraRewards({ chainId, tokensList }) {
|
|
48
|
-
const res = await import_axios.default.get(
|
|
49
|
-
import_merklAPI.MerkleXYZApi.getGearboxCampaignsUrl()
|
|
50
|
-
);
|
|
51
|
-
const currentActiveCampaigns = res.data.filter(
|
|
52
|
-
(c) => c.status === "LIVE" && c.chainId === chainId && !BROKEN_CAMPAIGNS[c.id]
|
|
53
|
-
);
|
|
54
|
-
const aprIdsList = currentActiveCampaigns.map(
|
|
55
|
-
(c) => (
|
|
56
|
-
// apr token for campaigns with a single reward is obvious
|
|
57
|
-
c.aprRecord.breakdowns.length > 1 ? c.aprRecord.breakdowns.map((b) => {
|
|
58
|
-
return {
|
|
59
|
-
campaignId: c.id,
|
|
60
|
-
aprId: b.identifier
|
|
61
|
-
};
|
|
62
|
-
}) : []
|
|
63
|
-
)
|
|
64
|
-
).flat(1);
|
|
65
|
-
const aprIdsResponse = await Promise.allSettled(
|
|
66
|
-
aprIdsList.map(
|
|
67
|
-
(id) => import_axios.default.get(
|
|
68
|
-
import_merklAPI.MerkleXYZApi.getGearboxRewardCampaignUrl(id.aprId)
|
|
69
|
-
)
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
|
-
const aprCampaignByAPRId = aprIdsResponse.reduce((acc, r2, i) => {
|
|
73
|
-
const id = aprIdsList[i].aprId;
|
|
74
|
-
acc[id] = r2.status === "fulfilled" ? r2.value.data : void 0;
|
|
75
|
-
return acc;
|
|
76
|
-
}, {});
|
|
77
|
-
const r = currentActiveCampaigns.reduce((acc, campaign) => {
|
|
78
|
-
const rewardSource = campaign.identifier.toLowerCase();
|
|
79
|
-
const allRewards = campaign.aprRecord.breakdowns.map((r2, i) => {
|
|
80
|
-
const apy = r2.value;
|
|
81
|
-
const aprCampaign = aprCampaignByAPRId[r2.identifier]?.[0];
|
|
82
|
-
const { rewardToken } = aprCampaign || {};
|
|
83
|
-
const tokenRewardsRecord = campaign.rewardsRecord.breakdowns[i]?.token;
|
|
84
|
-
const { address = tokenRewardsRecord?.address || "" } = rewardToken || {};
|
|
85
|
-
const tokenLc = address.toLowerCase();
|
|
86
|
-
const {
|
|
87
|
-
symbol = rewardToken?.symbol || tokenRewardsRecord?.symbol || ""
|
|
88
|
-
} = tokensList[tokenLc] || {};
|
|
89
|
-
const apyObject = {
|
|
90
|
-
token: rewardSource,
|
|
91
|
-
balance: null,
|
|
92
|
-
apy,
|
|
93
|
-
rewardToken: tokenLc,
|
|
94
|
-
rewardTokenSymbol: symbol,
|
|
95
|
-
endTimestamp: aprCampaign?.endTimestamp ? Number(aprCampaign.endTimestamp) : void 0
|
|
96
|
-
};
|
|
97
|
-
return apyObject;
|
|
98
|
-
}).filter((r2) => r2.apy > 0);
|
|
99
|
-
acc[rewardSource] = [...acc[rewardSource] || [], ...allRewards];
|
|
100
|
-
return acc;
|
|
101
|
-
}, {});
|
|
102
|
-
return r;
|
|
103
|
-
}
|
|
104
44
|
static async getLmRewardsInfo({
|
|
105
45
|
pools,
|
|
106
46
|
provider,
|
|
@@ -23,8 +23,6 @@ __export(merklAPI_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(merklAPI_exports);
|
|
24
24
|
class MerkleXYZApi {
|
|
25
25
|
static getUserRewardsUrl = (options) => `https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
26
|
-
static getGearboxCampaignsUrl = () => "https://api.merkl.xyz/v4/opportunities?name=gearbox";
|
|
27
|
-
static getGearboxRewardCampaignUrl = (campaignId) => `https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
28
26
|
}
|
|
29
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
28
|
0 && (module.exports = {
|
|
@@ -7,67 +7,7 @@ import { toBigInt, TypedObjectUtils } from "../../utils/index.js";
|
|
|
7
7
|
import { GearboxBackendApi } from "../core/endpoint.js";
|
|
8
8
|
import { BigIntMath } from "../utils/math.js";
|
|
9
9
|
import { MerkleXYZApi } from "./merklAPI.js";
|
|
10
|
-
const BROKEN_CAMPAIGNS = {
|
|
11
|
-
"11136065905617273958": true
|
|
12
|
-
};
|
|
13
10
|
class GearboxRewardsApi {
|
|
14
|
-
static async getExtraRewards({ chainId, tokensList }) {
|
|
15
|
-
const res = await axios.get(
|
|
16
|
-
MerkleXYZApi.getGearboxCampaignsUrl()
|
|
17
|
-
);
|
|
18
|
-
const currentActiveCampaigns = res.data.filter(
|
|
19
|
-
(c) => c.status === "LIVE" && c.chainId === chainId && !BROKEN_CAMPAIGNS[c.id]
|
|
20
|
-
);
|
|
21
|
-
const aprIdsList = currentActiveCampaigns.map(
|
|
22
|
-
(c) => (
|
|
23
|
-
// apr token for campaigns with a single reward is obvious
|
|
24
|
-
c.aprRecord.breakdowns.length > 1 ? c.aprRecord.breakdowns.map((b) => {
|
|
25
|
-
return {
|
|
26
|
-
campaignId: c.id,
|
|
27
|
-
aprId: b.identifier
|
|
28
|
-
};
|
|
29
|
-
}) : []
|
|
30
|
-
)
|
|
31
|
-
).flat(1);
|
|
32
|
-
const aprIdsResponse = await Promise.allSettled(
|
|
33
|
-
aprIdsList.map(
|
|
34
|
-
(id) => axios.get(
|
|
35
|
-
MerkleXYZApi.getGearboxRewardCampaignUrl(id.aprId)
|
|
36
|
-
)
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
const aprCampaignByAPRId = aprIdsResponse.reduce((acc, r2, i) => {
|
|
40
|
-
const id = aprIdsList[i].aprId;
|
|
41
|
-
acc[id] = r2.status === "fulfilled" ? r2.value.data : void 0;
|
|
42
|
-
return acc;
|
|
43
|
-
}, {});
|
|
44
|
-
const r = currentActiveCampaigns.reduce((acc, campaign) => {
|
|
45
|
-
const rewardSource = campaign.identifier.toLowerCase();
|
|
46
|
-
const allRewards = campaign.aprRecord.breakdowns.map((r2, i) => {
|
|
47
|
-
const apy = r2.value;
|
|
48
|
-
const aprCampaign = aprCampaignByAPRId[r2.identifier]?.[0];
|
|
49
|
-
const { rewardToken } = aprCampaign || {};
|
|
50
|
-
const tokenRewardsRecord = campaign.rewardsRecord.breakdowns[i]?.token;
|
|
51
|
-
const { address = tokenRewardsRecord?.address || "" } = rewardToken || {};
|
|
52
|
-
const tokenLc = address.toLowerCase();
|
|
53
|
-
const {
|
|
54
|
-
symbol = rewardToken?.symbol || tokenRewardsRecord?.symbol || ""
|
|
55
|
-
} = tokensList[tokenLc] || {};
|
|
56
|
-
const apyObject = {
|
|
57
|
-
token: rewardSource,
|
|
58
|
-
balance: null,
|
|
59
|
-
apy,
|
|
60
|
-
rewardToken: tokenLc,
|
|
61
|
-
rewardTokenSymbol: symbol,
|
|
62
|
-
endTimestamp: aprCampaign?.endTimestamp ? Number(aprCampaign.endTimestamp) : void 0
|
|
63
|
-
};
|
|
64
|
-
return apyObject;
|
|
65
|
-
}).filter((r2) => r2.apy > 0);
|
|
66
|
-
acc[rewardSource] = [...acc[rewardSource] || [], ...allRewards];
|
|
67
|
-
return acc;
|
|
68
|
-
}, {});
|
|
69
|
-
return r;
|
|
70
|
-
}
|
|
71
11
|
static async getLmRewardsInfo({
|
|
72
12
|
pools,
|
|
73
13
|
provider,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
class MerkleXYZApi {
|
|
2
2
|
static getUserRewardsUrl = (options) => `https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
3
|
-
static getGearboxCampaignsUrl = () => "https://api.merkl.xyz/v4/opportunities?name=gearbox";
|
|
4
|
-
static getGearboxRewardCampaignUrl = (campaignId) => `https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
5
3
|
}
|
|
6
4
|
export {
|
|
7
5
|
MerkleXYZApi
|
|
@@ -3,7 +3,6 @@ import type { NetworkType } from "../../chain/index.js";
|
|
|
3
3
|
import type { SupportedToken } from "../../sdk-gov-legacy/index.js";
|
|
4
4
|
import type { PoolData_Legacy } from "../core/pool.js";
|
|
5
5
|
import type { TokenData } from "../tokens/tokenData.js";
|
|
6
|
-
import type { ExtraRewardApy } from "./apy.js";
|
|
7
6
|
export interface GearboxExtraMerkleLmReward {
|
|
8
7
|
pool: Address;
|
|
9
8
|
poolToken: Address;
|
|
@@ -55,10 +54,6 @@ export interface GetLmRewardsInfoProps {
|
|
|
55
54
|
tokensList: Record<Address, TokenData>;
|
|
56
55
|
provider: PublicClient;
|
|
57
56
|
}
|
|
58
|
-
export interface GetExtraRewardsProps {
|
|
59
|
-
chainId: number;
|
|
60
|
-
tokensList: Record<Address, TokenData>;
|
|
61
|
-
}
|
|
62
57
|
export interface GetLmRewardsProps {
|
|
63
58
|
pools: Record<Address, PoolData_Legacy>;
|
|
64
59
|
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
@@ -83,7 +78,6 @@ export interface ClaimLmRewardsV3Props {
|
|
|
83
78
|
signer: WalletClient;
|
|
84
79
|
}
|
|
85
80
|
export declare class GearboxRewardsApi {
|
|
86
|
-
static getExtraRewards({ chainId, tokensList }: GetExtraRewardsProps): Promise<Record<`0x${string}`, ExtraRewardApy[]>>;
|
|
87
81
|
static getLmRewardsInfo({ pools, provider, tokensList, }: GetLmRewardsInfoProps): Promise<{
|
|
88
82
|
rewardPoolsInfo: Record<string, FarmInfo[]>;
|
|
89
83
|
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
@@ -36,123 +36,7 @@ interface MerkleXYZChain {
|
|
|
36
36
|
name: string;
|
|
37
37
|
icon: string;
|
|
38
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;
|
|
49
|
-
symbol: string;
|
|
50
|
-
}
|
|
51
|
-
export interface MerklXYZV4Campaign {
|
|
52
|
-
chainId: number;
|
|
53
|
-
type: string;
|
|
54
|
-
identifier: Address;
|
|
55
|
-
name: string;
|
|
56
|
-
status: "LIVE" | "PAST";
|
|
57
|
-
action: "LEND" | "BORROW";
|
|
58
|
-
tvl: number;
|
|
59
|
-
apr: number;
|
|
60
|
-
dailyRewards: number;
|
|
61
|
-
tags: Array<string>;
|
|
62
|
-
id: string;
|
|
63
|
-
tokens: Array<MerkleXYZToken>;
|
|
64
|
-
chain: MerkleXYZChain;
|
|
65
|
-
aprRecord: {
|
|
66
|
-
cumulated: number;
|
|
67
|
-
timestamp: string;
|
|
68
|
-
breakdowns: Array<{
|
|
69
|
-
id: number;
|
|
70
|
-
identifier: Address;
|
|
71
|
-
type: "CAMPAIGN";
|
|
72
|
-
value: number;
|
|
73
|
-
aprRecordId: string;
|
|
74
|
-
}>;
|
|
75
|
-
};
|
|
76
|
-
tvlRecord: {
|
|
77
|
-
id: string;
|
|
78
|
-
total: number;
|
|
79
|
-
timestamp: string;
|
|
80
|
-
breakdowns: [];
|
|
81
|
-
};
|
|
82
|
-
rewardsRecord: {
|
|
83
|
-
id: string;
|
|
84
|
-
total: number;
|
|
85
|
-
timestamp: string;
|
|
86
|
-
breakdowns: Array<{
|
|
87
|
-
token: MerkleXYZToken;
|
|
88
|
-
amount: string;
|
|
89
|
-
id: number;
|
|
90
|
-
value: number;
|
|
91
|
-
campaignId: string;
|
|
92
|
-
dailyRewardsRecordid: string;
|
|
93
|
-
}>;
|
|
94
|
-
};
|
|
95
|
-
depositUrl: string;
|
|
96
|
-
explorerAddress: Address;
|
|
97
|
-
lastCampaignCreatedAt: string;
|
|
98
|
-
protocol: {
|
|
99
|
-
description: string;
|
|
100
|
-
icon: string;
|
|
101
|
-
id: string;
|
|
102
|
-
name: string;
|
|
103
|
-
tags: Array<string>;
|
|
104
|
-
url: string;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export type MerkleXYZV4CampaignsResponse = Array<MerklXYZV4Campaign>;
|
|
108
|
-
export interface MerklXYZV4RewardCampaign {
|
|
109
|
-
id: string;
|
|
110
|
-
computeChainId: number;
|
|
111
|
-
distributionChainId: number;
|
|
112
|
-
campaignId: Address;
|
|
113
|
-
rewardTokenId: string;
|
|
114
|
-
amount: string;
|
|
115
|
-
opportunityId: string;
|
|
116
|
-
startTimestamp: number;
|
|
117
|
-
endTimestamp: number;
|
|
118
|
-
creatorAddress: Address;
|
|
119
|
-
params: {
|
|
120
|
-
url: string;
|
|
121
|
-
duration: number;
|
|
122
|
-
blacklist: Array<Address>;
|
|
123
|
-
whitelist: Array<Address>;
|
|
124
|
-
forwarders: Array<Address>;
|
|
125
|
-
targetToken: Address;
|
|
126
|
-
symbolRewardToken: string;
|
|
127
|
-
symbolTargetToken: string;
|
|
128
|
-
decimalsRewardToken: number;
|
|
129
|
-
decimalsTargetToken: number;
|
|
130
|
-
};
|
|
131
|
-
chain: MerkleXYZChain;
|
|
132
|
-
rewardToken: MerkleXYZToken;
|
|
133
|
-
distributionChain: MerkleXYZChain;
|
|
134
|
-
campaignStatus: {
|
|
135
|
-
campaignId: string;
|
|
136
|
-
computedUntil: string;
|
|
137
|
-
processingStarted: string;
|
|
138
|
-
status: "SUCCESS";
|
|
139
|
-
error: string;
|
|
140
|
-
details: string;
|
|
141
|
-
};
|
|
142
|
-
createdAt: string;
|
|
143
|
-
creator: {
|
|
144
|
-
address: Address;
|
|
145
|
-
creatorId: null;
|
|
146
|
-
tags: Array<string>;
|
|
147
|
-
};
|
|
148
|
-
distributionType: string;
|
|
149
|
-
subType: number;
|
|
150
|
-
type: string;
|
|
151
|
-
}
|
|
152
|
-
export type MerkleXYZV4RewardCampaignResponse = Array<MerklXYZV4RewardCampaign>;
|
|
153
39
|
export declare class MerkleXYZApi {
|
|
154
40
|
static getUserRewardsUrl: (options: UserOptions) => string;
|
|
155
|
-
static getGearboxCampaignsUrl: () => string;
|
|
156
|
-
static getGearboxRewardCampaignUrl: (campaignId: Address) => string;
|
|
157
41
|
}
|
|
158
42
|
export {};
|