@gearbox-protocol/sdk 3.0.0-next.280 → 3.0.0-next.282

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.
@@ -1,6 +1,6 @@
1
1
  import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
- type ExtraFarmTokens = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH" | "LBTC" | "Re7LRT" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "eBTC" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "pumpBTC" | "PT_sUSDe_27MAR2025" | "DVstETH" | "beraSTONE">;
3
- type ExtraTokensWithAPY = Extract<ExtraFarmTokens, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH" | "pzETH" | "ezETH" | "Re7LRT" | "rsETH" | "weETH" | "rswETH" | "rstETH" | "steakLRT" | "amphrETH" | "pufETH" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "PT_sUSDe_27MAR2025" | "DVstETH">;
2
+ type ExtraFarmTokens = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH" | "LBTC" | "Re7LRT" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "eBTC" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "pumpBTC" | "PT_sUSDe_27MAR2025" | "DVstETH" | "beraSTONE" | "PT_sUSDe_29MAY2025">;
3
+ type ExtraTokensWithAPY = Extract<ExtraFarmTokens, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH" | "pzETH" | "ezETH" | "Re7LRT" | "rsETH" | "weETH" | "rswETH" | "rstETH" | "steakLRT" | "amphrETH" | "pufETH" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "PT_sUSDe_27MAR2025" | "DVstETH" | "PT_sUSDe_29MAY2025">;
4
4
  type LRTAndLSTTokens = Exclude<ExtraFarmTokens, "USDe">;
5
5
  export declare const isExtraFarmToken: (t: unknown) => t is ExtraFarmTokens;
6
6
  export declare const isLRT_LSTToken: (t: unknown) => t is LRTAndLSTTokens;
package/lib/apy/index.js CHANGED
@@ -34,6 +34,7 @@ const EXTRA_FARM_TOKENS = {
34
34
  PT_sUSDe_27MAR2025: true,
35
35
  DVstETH: true,
36
36
  beraSTONE: true,
37
+ PT_sUSDe_29MAY2025: true,
37
38
  };
38
39
  const isExtraFarmToken = (t) => {
39
40
  if (typeof t !== "string")
@@ -68,6 +69,7 @@ const EXTRA_TOKENS_WITH_APY = {
68
69
  PT_corn_eBTC_27MAR2025: true,
69
70
  PT_corn_pumpBTC_26DEC2024: true,
70
71
  PT_sUSDe_27MAR2025: true,
72
+ PT_sUSDe_29MAY2025: true,
71
73
  };
72
74
  const isExtraTokenWithAPY = (t) => {
73
75
  if (typeof t !== "string")
@@ -3,7 +3,7 @@ interface ProtocolData {
3
3
  name: string;
4
4
  icon: string;
5
5
  }
6
- export type ExtendedProtocols = keyof typeof Protocols | "Stakewise" | "Etherfi" | "Rocketpool" | "Renzo" | "Coinbase" | "Kelp" | "Swell" | "Puffer" | "Mellow" | "Lombard" | "pumpBTC" | "Stakestone";
6
+ export type ExtendedProtocols = keyof typeof Protocols | "Stakewise" | "Etherfi" | "Rocketpool" | "Renzo" | "Coinbase" | "Kelp" | "Swell" | "Puffer" | "Mellow" | "Lombard" | "pumpBTC" | "Stakestone" | "Treehouse";
7
7
  export declare const isExtendedProtocol: (t: unknown) => t is ExtendedProtocols;
8
8
  export declare function getProtocolData(t: string): ProtocolData;
9
9
  export {};
@@ -146,6 +146,10 @@ const PROTOCOL_DATA = {
146
146
  name: "Stakestone",
147
147
  icon: "/protocols/stakestone.svg",
148
148
  },
149
+ Treehouse: {
150
+ name: "Treehouse",
151
+ icon: "/protocols/treehouse.svg",
152
+ },
149
153
  };
150
154
  const isExtendedProtocol = (t) => typeof t === "string" && !!PROTOCOL_DATA[t];
151
155
  exports.isExtendedProtocol = isExtendedProtocol;
@@ -41,11 +41,10 @@ export interface FarmInfo {
41
41
  balance: bigint;
42
42
  symbol: SupportedToken;
43
43
  }
44
- type PoolsWithExtraRewardsList = Record<NetworkType, Array<SupportedToken>>;
44
+ type PoolsWithExtraRewardsList = Record<NetworkType, Array<Address>>;
45
45
  type ReportHandler = (e: unknown, description?: string) => void;
46
46
  export interface GetLmRewardsInfoProps {
47
47
  pools: Record<Address, PoolData>;
48
- currentTokenData: Record<SupportedToken, Address>;
49
48
  tokensList: Record<Address, TokenData>;
50
49
  provider: PublicClient;
51
50
  multicallAddress: Address;
@@ -76,7 +75,7 @@ export interface ClaimLmRewardsV3Props {
76
75
  signer: WalletClient;
77
76
  }
78
77
  export declare class GearboxRewardsApi {
79
- static getLmRewardsInfo({ pools, currentTokenData, provider, multicallAddress, tokensList, poolsWithExtraRewards, network, reportError, }: GetLmRewardsInfoProps): Promise<{
78
+ static getLmRewardsInfo({ pools, provider, multicallAddress, tokensList, poolsWithExtraRewards, network, reportError, }: GetLmRewardsInfoProps): Promise<{
80
79
  rewardPoolsInfo: Record<string, FarmInfo[]>;
81
80
  baseRewardPoolsInfo: Record<string, FarmInfo>;
82
81
  extraRewardPoolsInfo: Record<string, FarmInfo[]>;
@@ -13,14 +13,16 @@ const formatter_1 = require("../utils/formatter");
13
13
  const math_1 = require("../utils/math");
14
14
  const merklAPI_1 = require("./merklAPI");
15
15
  const DEFAULT_POOLS_WITH_EXTRA_REWARDS = {
16
- Mainnet: ["dtBTCV3"],
16
+ Mainnet: [
17
+ "0x7354EC6E852108411e681D13E11185c3a2567981", // dtBTCV3
18
+ ],
17
19
  Arbitrum: [],
18
20
  Optimism: [],
19
21
  Base: [],
20
22
  };
21
23
  class GearboxRewardsApi {
22
- static async getLmRewardsInfo({ pools, currentTokenData, provider, multicallAddress, tokensList, poolsWithExtraRewards = DEFAULT_POOLS_WITH_EXTRA_REWARDS, network, reportError, }) {
23
- const poolByStakedToken = Object.values(pools).reduce((acc, p) => {
24
+ static async getLmRewardsInfo({ pools, provider, multicallAddress, tokensList, poolsWithExtraRewards = DEFAULT_POOLS_WITH_EXTRA_REWARDS, network, reportError, }) {
25
+ const poolByStakedDiesel = Object.values(pools).reduce((acc, p) => {
24
26
  p.stakedDieselToken.forEach(t => {
25
27
  if (t)
26
28
  acc[t] = p.address;
@@ -31,29 +33,35 @@ class GearboxRewardsApi {
31
33
  });
32
34
  return acc;
33
35
  }, {});
34
- const poolTokens = sdk_gov_1.TypedObjectUtils.keys(poolByStakedToken);
36
+ const poolByDiesel = Object.values(pools).reduce((acc, p) => {
37
+ acc[p.dieselToken] = p.address;
38
+ return acc;
39
+ }, {});
40
+ const poolByItsToken = { ...poolByStakedDiesel, ...poolByDiesel };
41
+ const poolStakedTokens = sdk_gov_1.TypedObjectUtils.keys(poolByStakedDiesel);
42
+ const allPoolTokens = sdk_gov_1.TypedObjectUtils.keys(poolByItsToken);
35
43
  const chainId = sdk_gov_1.CHAINS[network];
36
- const poolTokensWithExtraReward = (poolsWithExtraRewards[network] || []).filter(symbol => {
37
- const addr = currentTokenData[symbol];
38
- if (!addr) {
39
- console.error(`Pool staked token not found ${symbol}`);
44
+ const poolTokensWithExtraReward = (poolsWithExtraRewards[network] || []).filter(p => {
45
+ const token = tokensList[p.toLowerCase()];
46
+ if (!token) {
47
+ console.error(`Pool token not found ${p}`);
40
48
  return false;
41
49
  }
42
50
  return true;
43
51
  });
44
- const farmInfoCalls = poolTokens.map(address => ({
52
+ const farmInfoCalls = poolStakedTokens.map(address => ({
45
53
  address,
46
54
  abi: types_1.iFarmingPoolAbi,
47
55
  functionName: "farmInfo",
48
56
  args: [],
49
57
  }));
50
- const farmSupplyCalls = poolTokens.map(address => ({
58
+ const farmSupplyCalls = allPoolTokens.map(address => ({
51
59
  address,
52
60
  abi: types_1.iFarmingPoolAbi,
53
61
  functionName: "totalSupply",
54
62
  args: [],
55
63
  }));
56
- const rewardTokenCalls = poolTokens.map(address => ({
64
+ const rewardTokenCalls = poolStakedTokens.map(address => ({
57
65
  address,
58
66
  abi: POOL_REWARDS_ABI,
59
67
  functionName: "rewardsToken",
@@ -75,12 +83,11 @@ class GearboxRewardsApi {
75
83
  ...rewardTokenCalls,
76
84
  ],
77
85
  }),
78
- ...poolTokensWithExtraReward.map(symbol => {
79
- const addr = currentTokenData[symbol];
86
+ ...poolTokensWithExtraReward.map(t => {
80
87
  return axios_1.default.get(merklAPI_1.MerkleXYZApi.getRewardsCampaignsUrl({
81
88
  params: {
82
89
  chainId,
83
- mainParameter: (0, viem_1.getAddress)(addr),
90
+ mainParameter: (0, viem_1.getAddress)(t),
84
91
  },
85
92
  }));
86
93
  }),
@@ -94,9 +101,22 @@ class GearboxRewardsApi {
94
101
  const farmSupply = restMCResponse.slice(farmInfoCallsEnd, farmSupplyCallsEnd);
95
102
  const rewardTokenCallsEnd = farmSupplyCallsEnd + rewardTokenCalls.length;
96
103
  const rewardTokens = restMCResponse.slice(farmSupplyCallsEnd, rewardTokenCallsEnd);
104
+ const infoByPool = poolStakedTokens.reduce((acc, p, index) => {
105
+ const info = farmInfo[index];
106
+ if (info)
107
+ acc[p] = info;
108
+ return acc;
109
+ }, {});
110
+ const rewardTokenPool = poolStakedTokens.reduce((acc, p, index) => {
111
+ const token = rewardTokens[index];
112
+ if (token) {
113
+ acc[p] = token.toLowerCase();
114
+ }
115
+ return acc;
116
+ }, {});
97
117
  const extraRewards = extra.reduce((acc, r, index) => {
98
- const stakedSymbol = poolTokensWithExtraReward[index];
99
- const safeResp = this.extractFulfilled(r, reportError, `merkleCampaign: ${stakedSymbol}`);
118
+ const p = poolTokensWithExtraReward[index].toLowerCase();
119
+ const safeResp = this.extractFulfilled(r, reportError, `merkleCampaign: ${p}`);
100
120
  const l = safeResp?.data.reduce((infos, d) => {
101
121
  const started = (0, sdk_gov_1.toBigInt)(d.startTimestamp || 0);
102
122
  const finished = (0, sdk_gov_1.toBigInt)(d.endTimestamp || 0);
@@ -106,7 +126,7 @@ class GearboxRewardsApi {
106
126
  const reward = (0, formatter_1.toBN)(d.amountDecimal, rewardTokenData?.decimals || 18);
107
127
  if (rewardTokenData && reward > 0) {
108
128
  infos.push({
109
- pool: poolByStakedToken[currentTokenData[stakedSymbol]],
129
+ pool: poolByItsToken[p],
110
130
  duration: (0, sdk_gov_1.toBigInt)(d.endTimestamp - d.startTimestamp),
111
131
  finished,
112
132
  reward,
@@ -118,38 +138,39 @@ class GearboxRewardsApi {
118
138
  return infos;
119
139
  }, []);
120
140
  if (l) {
121
- acc[currentTokenData[stakedSymbol]] = l;
141
+ acc[p] = l;
122
142
  }
123
143
  return acc;
124
144
  }, {});
125
- const rewardPoolsInfo = poolTokens.reduce((acc, address, i) => {
126
- const currentInfo = farmInfo[i];
127
- const poolBaseRewardTokenLc = (rewardTokens[i] || "").toLowerCase();
128
- const tokenData = tokensList[poolBaseRewardTokenLc];
129
- if (tokenData) {
130
- const baseReward = {
131
- pool: poolByStakedToken[address],
132
- duration: BigInt(currentInfo.duration),
133
- finished: BigInt(currentInfo.finished),
134
- reward: currentInfo.reward,
135
- balance: currentInfo.balance,
145
+ const stakedTokenRewards = allPoolTokens.reduce((acc, pool) => {
146
+ const info = infoByPool[pool];
147
+ const token = rewardTokenPool[pool];
148
+ const tokenData = tokensList[token];
149
+ const baseReward = info && tokenData
150
+ ? {
151
+ pool: poolByItsToken[pool],
152
+ duration: BigInt(info.duration),
153
+ finished: BigInt(info.finished),
154
+ reward: info.reward,
155
+ balance: info.balance,
136
156
  symbol: tokenData.symbol,
137
- };
138
- const extra = extraRewards[address] || [];
139
- acc.base[address] = baseReward;
140
- acc.extra[address] = extra;
141
- acc.all[address] = [baseReward, ...extra];
142
- }
157
+ }
158
+ : undefined;
159
+ const extra = extraRewards[pool] || [];
160
+ if (baseReward)
161
+ acc.base[pool] = baseReward;
162
+ acc.extra[pool] = extra;
163
+ acc.all[pool] = [...(baseReward ? [baseReward] : []), ...extra];
143
164
  return acc;
144
165
  }, { base: {}, extra: {}, all: {} });
145
- const rewardPoolsSupply = poolTokens.reduce((acc, address, i) => {
166
+ const rewardPoolsSupply = allPoolTokens.reduce((acc, address, i) => {
146
167
  acc[address] = farmSupply[i] || 0n;
147
168
  return acc;
148
169
  }, {});
149
170
  return {
150
- rewardPoolsInfo: rewardPoolsInfo.all,
151
- baseRewardPoolsInfo: rewardPoolsInfo.base,
152
- extraRewardPoolsInfo: rewardPoolsInfo.extra,
171
+ rewardPoolsInfo: stakedTokenRewards.all,
172
+ baseRewardPoolsInfo: stakedTokenRewards.base,
173
+ extraRewardPoolsInfo: stakedTokenRewards.extra,
153
174
  rewardPoolsSupply,
154
175
  };
155
176
  }
@@ -10,6 +10,7 @@ const GAS_PER_BLOCK = 400000000n;
10
10
  const PT_IN = {
11
11
  ["0xEe9085fC268F6727d5D4293dBABccF901ffDCC29".toLowerCase()]: "PT_sUSDe_26DEC2024",
12
12
  ["0xE00bd3Df25fb187d6ABBB620b3dfd19839947b81".toLowerCase()]: "PT_sUSDe_27MAR20251",
13
+ ["0xE00bd3Df25fb187d6ABBB620b3dfd19839947b81".toLowerCase()]: "PT_sUSDe_29MAY2025",
13
14
  };
14
15
  const OUT = {
15
16
  ["0x9D39A5DE30e57443BfF2A8307A4256c8797A3497".toLowerCase()]: "sUSDe",
@@ -17,6 +17,7 @@ const ALIASES = {
17
17
  PT_corn_eBTC_27MAR2025: "p.c.eBTC(27.03.25)",
18
18
  PT_corn_pumpBTC_26DEC2024: "p.c.pumpBTC(26.12.24)",
19
19
  PT_sUSDe_27MAR2025: "p.sUSDe(27.03.25)",
20
+ PT_sUSDe_29MAY2025: "p.sUSDe(29.05.25)",
20
21
  };
21
22
  class TokenData {
22
23
  title;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.280",
3
+ "version": "3.0.0-next.282",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "test": "npx mocha -r ts-node/register -r dotenv/config 'src/**/*.spec.ts'"
29
29
  },
30
30
  "dependencies": {
31
- "@gearbox-protocol/sdk-gov": "^2.34.0",
31
+ "@gearbox-protocol/sdk-gov": "v2.34.0-next.36",
32
32
  "@wagmi/cli": "^2.1.13",
33
33
  "axios": "^1.2.6",
34
34
  "decimal.js-light": "^2.5.1",