@gearbox-protocol/sdk 3.0.0-prevfour.11 → 3.0.0-prevfour.13

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,4 +1,4 @@
1
- import { NetworkType, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { NetworkType, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
3
  interface CurvePoolData {
4
4
  address: Address;
@@ -49,9 +49,8 @@ interface CurveAPY {
49
49
  crv: number;
50
50
  gauge: Array<[Address, number]>;
51
51
  }
52
- export type CurveAPYResult = PartialRecord<Address, CurveAPY>;
53
52
  export declare function getCurveAPY(network: NetworkType, currentTokens: Record<SupportedToken, Address>): Promise<{
54
- curveAPY: CurveAPYResult;
53
+ curveAPY: Record<`0x${string}`, CurveAPY>;
55
54
  gearAPY: CurveAPY;
56
55
  }>;
57
56
  export declare function getCurveGearPool(): Promise<CurvePoolData | undefined>;
@@ -1,4 +1,3 @@
1
- import { NetworkType, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { NetworkType, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
- import { TokensWithAPY } from ".";
4
- export declare function getDefiLamaAPY(networkType: NetworkType, currentTokens: Record<SupportedToken, Address>): Promise<PartialRecord<TokensWithAPY, number>>;
3
+ export declare function getDefiLamaAPY(networkType: NetworkType, currentTokens: Record<SupportedToken, Address>): Promise<Record<Address, number>>;
@@ -42,8 +42,12 @@ const NORMAL_TO_LAMA = {
42
42
  PT_sUSDe_26DEC2024: "992d00f3-d43f-44fe-8b62-987e8610c9a8",
43
43
  PT_ezETH_26DEC2024: "76953dd9-3132-49ad-ae88-b551c5b5c774",
44
44
  PT_eETH_26DEC2024: "7bafc0e5-3789-4920-944f-d734d3ef0cef",
45
- PT_LBTC_27MAR2025: "b1b3b3b4-1b3b-4b3b-8b3b-1b3b3b3b3b3b",
45
+ PT_LBTC_27MAR2025: "05216992-5538-4c93-aecc-49398388464f",
46
46
  PT_eBTC_26DEC2024: "e093fa52-1f6a-4256-9e3e-a58490468c0e",
47
+ PT_cornLBTC_26DEC2024: "f7826423-8043-4799-b12a-83a68adc992d",
48
+ PT_corn_eBTC_27MAR2025: "eb7de368-b460-4638-bde1-50a129109b7b",
49
+ PT_corn_pumpBTC_26DEC2024: "a23e2b97-ff92-4ebf-8c7d-171cad8431ad",
50
+ PT_sUSDe_27MAR2025: "6b28892f-0909-418d-b4bb-3106fff72449",
47
51
  },
48
52
  Optimism: { rETH: "d4b3c522-6127-4b89-bedf-83641cdcd2eb" },
49
53
  Arbitrum: {
@@ -1,7 +1,7 @@
1
1
  import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
- 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">;
4
- 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">;
3
+ 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">;
4
+ 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">;
5
5
  type LRTAndLSTTokens = Exclude<ExtraFarmTokens, "USDe">;
6
6
  export declare const isExtraFarmToken: (t: unknown) => t is ExtraFarmTokens;
7
7
  export declare const isLRT_LSTToken: (t: unknown) => t is LRTAndLSTTokens;
@@ -13,5 +13,6 @@ export declare const isFarmToken: (t: unknown) => t is AllLPTokens;
13
13
  export * from "./curveAPY";
14
14
  export * from "./defiLamaAPY";
15
15
  export * from "./lidoAPY";
16
+ export * from "./pendleAPY";
16
17
  export * from "./skyAPY";
17
18
  export * from "./yearnAPY";
package/lib/apy/index.js CHANGED
@@ -41,6 +41,11 @@ const EXTRA_FARM_TOKENS = {
41
41
  PT_eBTC_26DEC2024: true,
42
42
  PT_LBTC_27MAR2025: true,
43
43
  eBTC: true,
44
+ PT_cornLBTC_26DEC2024: true,
45
+ PT_corn_eBTC_27MAR2025: true,
46
+ PT_corn_pumpBTC_26DEC2024: true,
47
+ pumpBTC: true,
48
+ PT_sUSDe_27MAR2025: true,
44
49
  };
45
50
  const isExtraFarmToken = (t) => {
46
51
  if (typeof t !== "string")
@@ -70,6 +75,10 @@ const EXTRA_TOKENS_WITH_APY = {
70
75
  PT_sUSDe_26DEC2024: true,
71
76
  PT_eBTC_26DEC2024: true,
72
77
  PT_LBTC_27MAR2025: true,
78
+ PT_cornLBTC_26DEC2024: true,
79
+ PT_corn_eBTC_27MAR2025: true,
80
+ PT_corn_pumpBTC_26DEC2024: true,
81
+ PT_sUSDe_27MAR2025: true,
73
82
  };
74
83
  const isExtraTokenWithAPY = (t) => {
75
84
  if (typeof t !== "string")
@@ -97,5 +106,6 @@ exports.isFarmToken = isFarmToken;
97
106
  __exportStar(require("./curveAPY"), exports);
98
107
  __exportStar(require("./defiLamaAPY"), exports);
99
108
  __exportStar(require("./lidoAPY"), exports);
109
+ __exportStar(require("./pendleAPY"), exports);
100
110
  __exportStar(require("./skyAPY"), exports);
101
111
  __exportStar(require("./yearnAPY"), exports);
@@ -1,4 +1,3 @@
1
- import { PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
- export type LidoAPYResult = PartialRecord<Address, number>;
4
- export declare function getLidoAPY(currentTokens: Record<SupportedToken, Address>): Promise<LidoAPYResult>;
3
+ export declare function getLidoAPY(currentTokens: Record<SupportedToken, Address>): Promise<Record<Address, number>>;
@@ -0,0 +1,3 @@
1
+ import { SupportedToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ export declare function getPendleAPY(currentTokens: Record<SupportedToken, Address>): Promise<Record<Address, number>>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPendleAPY = void 0;
7
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const getAPYURL = () => "https://api-v2.pendle.finance/core/v2/1/markets/0xcdd26eb5eb2ce0f203a84553853667ae69ca29ce/data";
10
+ async function getPendleAPY(currentTokens) {
11
+ try {
12
+ const resp = await axios_1.default.get(getAPYURL());
13
+ const apyInfo = resp?.data;
14
+ const rate = apyInfo?.underlyingInterestApy || 0;
15
+ return {
16
+ [currentTokens.sUSDe]: numberToAPY(Number(rate)),
17
+ };
18
+ }
19
+ catch (e) {
20
+ return {};
21
+ }
22
+ }
23
+ exports.getPendleAPY = getPendleAPY;
24
+ function numberToAPY(baseApy) {
25
+ return Math.round(baseApy * Number(sdk_gov_1.PERCENTAGE_FACTOR) * Number(sdk_gov_1.PERCENTAGE_DECIMALS));
26
+ }
@@ -1,6 +1,3 @@
1
- import { PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
- type SkyTokens = Extract<SupportedToken, "sUSDS" | "stkUSDS">;
4
- export type SkyAPYResult = PartialRecord<SkyTokens, number>;
5
- export declare function getSkyAPY(currentTokens: Record<SupportedToken, Address>): Promise<SkyAPYResult>;
6
- export {};
3
+ export declare function getSkyAPY(currentTokens: Record<SupportedToken, Address>): Promise<Record<Address, number>>;
package/lib/apy/skyAPY.js CHANGED
@@ -6,16 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSkyAPY = void 0;
7
7
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
8
8
  const axios_1 = __importDefault(require("axios"));
9
- const getSavingsURL = () => `https://info-sky.blockanalitica.com/save/?format=json`;
10
- const getFarmingURL = () => `https://info-sky.blockanalitica.com/farms/?format=json`;
9
+ const getAPYURL = () => "https://info-sky.blockanalitica.com/api/v1/overall/";
11
10
  async function getSkyAPY(currentTokens) {
12
11
  try {
13
- const [savings, farm] = await Promise.all([
14
- axios_1.default.get(getSavingsURL()),
15
- axios_1.default.get(getFarmingURL()),
16
- ]);
17
- const savingsRate = savings?.data?.ssr_rate || 0;
18
- const farmRate = farm?.data?.sky_farm.apy || 0;
12
+ const resp = await axios_1.default.get(getAPYURL());
13
+ const apyInfo = resp?.data?.[0];
14
+ const savingsRate = apyInfo?.sky_savings_rate_apy || 0;
15
+ const farmRate = apyInfo?.sky_farm_apy || 0;
19
16
  return {
20
17
  [currentTokens.sUSDS]: numberToAPY(Number(savingsRate)),
21
18
  [currentTokens.stkUSDS]: numberToAPY(Number(farmRate)),
@@ -1,4 +1,3 @@
1
- import { NetworkType, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { NetworkType, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
- export type YearnAPYResult = PartialRecord<Address, number>;
4
- export declare function getYearnAPY(network: NetworkType, currentTokens: Record<SupportedToken, Address>): Promise<YearnAPYResult>;
3
+ export declare function getYearnAPY(network: NetworkType, currentTokens: Record<SupportedToken, Address>): Promise<Record<Address, number>>;
@@ -25,9 +25,14 @@ export declare class AssetUtils {
25
25
  static memoWrap: (unwrappedAddress: Address, wrappedAddress: Address, prices: Record<Address, bigint>, tokensList: Record<Address, TokenData>) => (assets: Array<Asset>) => WrapResult;
26
26
  /**
27
27
  * Sums the the second assets list into the first assets list
28
- * Balances cant be negative; Creates new assets.
28
+ * Balances cant be negative; creates new assets.
29
29
  */
30
30
  static sumAssets<A extends Asset, B extends Asset>(a: Array<A>, b: Array<B>): Array<A | B>;
31
+ /**
32
+ * Sums the the second assets list into the first assets list
33
+ * Balances cant be negative; doesn't create new assets.
34
+ */
35
+ static addBalances<A extends Asset, B extends Asset>(a: Array<A>, b: Array<B>): Array<A | B>;
31
36
  /**
32
37
  * Subtracts the the second assets list from the first assets list
33
38
  * Balances cant be negative; doesn't create new assets.
@@ -65,7 +65,7 @@ class AssetUtils {
65
65
  };
66
66
  /**
67
67
  * Sums the the second assets list into the first assets list
68
- * Balances cant be negative; Creates new assets.
68
+ * Balances cant be negative; creates new assets.
69
69
  */
70
70
  static sumAssets(a, b) {
71
71
  const aRecord = AssetUtils.constructAssetRecord(a);
@@ -82,6 +82,19 @@ class AssetUtils {
82
82
  }, aRecord);
83
83
  return Object.values(resRecord);
84
84
  }
85
+ /**
86
+ * Sums the the second assets list into the first assets list
87
+ * Balances cant be negative; doesn't create new assets.
88
+ */
89
+ static addBalances(a, b) {
90
+ const bRecord = AssetUtils.constructAssetRecord(b);
91
+ return a.map(asset => {
92
+ const bAsset = bRecord[asset.token];
93
+ const { balance: bAmount = 0n } = bAsset || {};
94
+ const amountSum = math_1.BigIntMath.max(0n, asset.balance) + math_1.BigIntMath.max(0n, bAmount);
95
+ return { ...asset, balance: amountSum };
96
+ });
97
+ }
85
98
  /**
86
99
  * Subtracts the the second assets list from the first assets list
87
100
  * Balances cant be negative; doesn't create new assets.
@@ -188,8 +188,8 @@ class CreditAccountData {
188
188
  const underlyingTokenDecimals = tokensList[underlyingToken]?.decimals || 18;
189
189
  const underlyingPrice = prices[underlyingToken];
190
190
  const assetAPYMoney = caAssets.reduce((acc, { token: tokenAddress, balance: amount }) => {
191
- const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
192
191
  const apy = lpAPY[tokenAddress] || 0;
192
+ const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
193
193
  const price = prices[tokenAddress] || 0n;
194
194
  const money = price_1.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
195
195
  const apyMoney = money * BigInt(apy);
@@ -9,10 +9,6 @@ export declare class GearboxBackendApi {
9
9
  static getRewardsMerkleUrl: (network: NetworkType, root: Address, account: Address) => string;
10
10
  static getNFTMerkleUrl: (network: NetworkType, root: Address) => string;
11
11
  static getLeaderboardUrl: (url: string, chainId: number) => string;
12
- static getTradingGraphsUrl: (url: string, chainId: number) => string;
13
- static getTradingPricesWSUrl: (url: string, chainId: number) => string;
14
- static getTradingSessionsWSUrl: (url: string, chainId: number) => string;
15
- static getTradingSessionsUrl: (url: string, chainId: number) => string;
16
12
  static getReferralUrl: () => string;
17
13
  }
18
14
  interface Options {
@@ -30,42 +30,6 @@ const LEADERBOARD_APIS = {
30
30
  [exports.TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation/gpointbot",
31
31
  [exports.TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot",
32
32
  };
33
- const TRADING_GRAPHS_API = {
34
- [sdk_gov_1.CHAINS.Mainnet]: "https://trading-price.fly.dev/api/tradingview",
35
- [sdk_gov_1.CHAINS.Optimism]: "https://trading-price.fly.dev/api/tradingview",
36
- [sdk_gov_1.CHAINS.Arbitrum]: "https://trading-price.fly.dev/api/tradingview",
37
- [sdk_gov_1.CHAINS.Local]: "https://trading-price.fly.dev/api/tradingview",
38
- [exports.TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation/api/tradingview",
39
- [exports.TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation/api/tradingview",
40
- [exports.TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/api/tradingview",
41
- };
42
- const TRADING_PRICES_API_WS = {
43
- [sdk_gov_1.CHAINS.Mainnet]: "wss://trading-price.fly.dev/api/tradingview/ws",
44
- [sdk_gov_1.CHAINS.Optimism]: "wss://trading-price.fly.dev/api/tradingview/ws",
45
- [sdk_gov_1.CHAINS.Arbitrum]: "wss://trading-price.fly.dev/api/tradingview/ws",
46
- [sdk_gov_1.CHAINS.Local]: "wss://trading-price.fly.dev/api/tradingview/ws",
47
- [exports.TESTNET_CHAINS.Mainnet]: "wss://testnet.gearbox.foundation/api/tradingview/ws",
48
- [exports.TESTNET_CHAINS.Optimism]: "wss://testnet.gearbox.foundation/api/tradingview/ws",
49
- [exports.TESTNET_CHAINS.Arbitrum]: "wss://testnet.gearbox.foundation/api/tradingview/ws",
50
- };
51
- const TRADING_SESSIONS_API_WS = {
52
- [sdk_gov_1.CHAINS.Mainnet]: "wss://gearbox-ws.fly.dev/ws",
53
- [sdk_gov_1.CHAINS.Optimism]: "wss://optimism.gearbox.foundation/gearbox-ws/ws",
54
- [sdk_gov_1.CHAINS.Arbitrum]: "wss://arbitrum.gearbox.foundation/gearbox-ws/ws",
55
- [sdk_gov_1.CHAINS.Local]: "wss://gearbox-ws.fly.dev/ws",
56
- [exports.TESTNET_CHAINS.Mainnet]: "wss://testnet.gearbox.foundation/gearbox-ws/ws",
57
- [exports.TESTNET_CHAINS.Optimism]: "wss://opttest.gearbox.foundation/gearbox-ws/ws",
58
- [exports.TESTNET_CHAINS.Arbitrum]: "wss://arbtest.gearbox.foundation/gearbox-ws/ws",
59
- };
60
- const TRADING_SESSIONS_API = {
61
- [sdk_gov_1.CHAINS.Mainnet]: "https://gearbox-ws.fly.dev",
62
- [sdk_gov_1.CHAINS.Optimism]: "https://optimism.gearbox.foundation/gearbox-ws",
63
- [sdk_gov_1.CHAINS.Arbitrum]: "https://arbitrum.gearbox.foundation/gearbox-ws",
64
- [sdk_gov_1.CHAINS.Local]: "https://gearbox-ws.fly.dev",
65
- [exports.TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation/gearbox-ws",
66
- [exports.TESTNET_CHAINS.Optimism]: "https://opttest.gearbox.foundation/gearbox-ws",
67
- [exports.TESTNET_CHAINS.Arbitrum]: "https://arbtest.gearbox.foundation/gearbox-ws",
68
- };
69
33
  const REFERRAL_API = "https://referral-gen.fly.dev/generate";
70
34
  class GearboxBackendApi {
71
35
  static getChartsUrl = (url, chainId, options = { params: {} }, priceSource) => {
@@ -97,18 +61,6 @@ class GearboxBackendApi {
97
61
  static getLeaderboardUrl = (url, chainId) => {
98
62
  return `${LEADERBOARD_APIS[chainId]}${url}`;
99
63
  };
100
- static getTradingGraphsUrl = (url, chainId) => {
101
- return `${TRADING_GRAPHS_API[chainId]}${url}`;
102
- };
103
- static getTradingPricesWSUrl = (url, chainId) => {
104
- return `${TRADING_PRICES_API_WS[chainId]}${url}`;
105
- };
106
- static getTradingSessionsWSUrl = (url, chainId) => {
107
- return `${TRADING_SESSIONS_API_WS[chainId]}${url}`;
108
- };
109
- static getTradingSessionsUrl = (url, chainId) => {
110
- return `${TRADING_SESSIONS_API[chainId]}${url}`;
111
- };
112
64
  static getReferralUrl = () => REFERRAL_API;
113
65
  }
114
66
  exports.GearboxBackendApi = GearboxBackendApi;
@@ -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";
6
+ export type ExtendedProtocols = keyof typeof Protocols | "Stakewise" | "Etherfi" | "Rocketpool" | "Renzo" | "Coinbase" | "Kelp" | "Swell" | "Puffer" | "Mellow" | "Lombard" | "pumpBTC";
7
7
  export declare const isExtendedProtocol: (t: unknown) => t is ExtendedProtocols;
8
8
  export declare function getProtocolData(t: string): ProtocolData;
9
9
  export {};
@@ -134,6 +134,14 @@ const PROTOCOL_DATA = {
134
134
  name: "Sky",
135
135
  icon: "/protocols/sky.svg",
136
136
  },
137
+ pumpBTC: {
138
+ name: "Pump BTC",
139
+ icon: "/protocols/pumpbtc.svg",
140
+ },
141
+ Equalizer: {
142
+ name: "Equalizer",
143
+ icon: "/protocols/equalizer.svg",
144
+ },
137
145
  };
138
146
  const isExtendedProtocol = (t) => typeof t === "string" && !!PROTOCOL_DATA[t];
139
147
  exports.isExtendedProtocol = isExtendedProtocol;
@@ -22,10 +22,12 @@ class GearboxRewardsApi {
22
22
  static async getLmRewardsInfo({ pools, currentTokenData, provider, multicallAddress, tokensList, poolsWithExtraRewards = DEFAULT_POOLS_WITH_EXTRA_REWARDS, network, reportError, }) {
23
23
  const poolByStakedToken = Object.values(pools).reduce((acc, p) => {
24
24
  p.stakedDieselToken.forEach(t => {
25
- acc[t] = p.address;
25
+ if (t)
26
+ acc[t] = p.address;
26
27
  });
27
28
  p.stakedDieselToken_old.forEach(t => {
28
- acc[t] = p.address;
29
+ if (t)
30
+ acc[t] = p.address;
29
31
  });
30
32
  return acc;
31
33
  }, {});
@@ -258,7 +260,7 @@ class GearboxRewardsApi {
258
260
  if (!airdropDistributorAddress)
259
261
  throw new Error(`V2 rewards are not supported on chain: ${network}`);
260
262
  const merkleData = await this.getMerkle(provider, airdropDistributorAddress, network, account);
261
- const rewardFromMerkle = merkleData?.claims[account];
263
+ const rewardFromMerkle = merkleData?.claims[(0, viem_1.getAddress)(account)];
262
264
  if (!rewardFromMerkle)
263
265
  throw new Error("No rewards found");
264
266
  const distributor = (0, viem_1.getContract)({
@@ -314,7 +316,7 @@ class GearboxRewardsApi {
314
316
  }
315
317
  static getAmountOnContract({ account, merkleData, }) {
316
318
  const { claims = {} } = merkleData || {};
317
- const { amount } = claims[account] || {};
319
+ const { amount } = claims[(0, viem_1.getAddress)(account)] || {};
318
320
  return BigInt(amount || 0);
319
321
  }
320
322
  }
@@ -1,5 +1,6 @@
1
- import { SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
+ import { Asset } from "../core/assets";
3
4
  import { PoolData } from "../core/pool";
4
5
  import { TokenData } from "../tokens/tokenData";
5
6
  import { FarmInfo } from "./api";
@@ -16,9 +17,11 @@ interface CalculateV3PoolLmAPYProps {
16
17
  price: bigint;
17
18
  };
18
19
  }
19
- export interface PoolExtraRewardApy {
20
- symbol: SupportedToken;
20
+ export interface ExtraRewardApy {
21
+ token: Address;
22
+ balance: bigint | null;
21
23
  apy: number;
24
+ rewardInfo: FarmInfo;
22
25
  }
23
26
  interface GetPoolExtraAPY_V3Props {
24
27
  stakedDieselToken: Address | undefined;
@@ -30,9 +33,20 @@ interface GetPoolExtraAPY_V3Props {
30
33
  currentTokenData: Record<SupportedToken, Address>;
31
34
  currentTimestamp: number;
32
35
  }
36
+ interface GetCAExtraAPYProps {
37
+ assets: Array<Asset>;
38
+ supply: Record<Address, bigint> | Record<Address, Asset>;
39
+ rewardInfo: PartialRecord<SupportedToken, Array<FarmInfo>>;
40
+ currentTimestamp: number;
41
+ prices: Record<Address, bigint>;
42
+ tokensList: Record<Address, TokenData>;
43
+ currentTokenData: Record<SupportedToken, Address>;
44
+ }
33
45
  export declare class GearboxRewardsApy {
34
- static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<PoolExtraRewardApy>;
46
+ static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy>;
35
47
  private static getPoolSingleExtraLmAPY_V3;
36
48
  static calculateAPY_V3({ info, supply, reward, currentTimestamp, }: CalculateV3PoolLmAPYProps): number;
49
+ static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }: GetCAExtraAPYProps): Array<ExtraRewardApy>;
50
+ private static getCASingleExtraAPY_V3;
37
51
  }
38
52
  export {};
@@ -43,7 +43,12 @@ class GearboxRewardsApy {
43
43
  decimals: rewardDecimals,
44
44
  },
45
45
  }) / Number(sdk_gov_1.PERCENTAGE_FACTOR);
46
- return { symbol: rewardPoolsInfo.symbol, apy: r };
46
+ return {
47
+ token: stakedDieselToken,
48
+ balance: null,
49
+ apy: r,
50
+ rewardInfo: rewardPoolsInfo,
51
+ };
47
52
  }
48
53
  static calculateAPY_V3({ info, supply, reward, currentTimestamp, }) {
49
54
  const finished = info.finished <= currentTimestamp;
@@ -61,5 +66,45 @@ class GearboxRewardsApy {
61
66
  const apyBn = (((rewardMoney * ONE) / supplyMoney) * durationRatio) / sdk_gov_1.WAD;
62
67
  return Math.round(Number(apyBn) / 10);
63
68
  }
69
+ static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }) {
70
+ const extra = assets.reduce((acc, asset) => {
71
+ const { token } = asset;
72
+ const { symbol } = restProps.tokensList[token] || {};
73
+ const info = rewardInfo[symbol || ""];
74
+ if (!info)
75
+ return acc;
76
+ const extra = info.map(inf => this.getCASingleExtraAPY_V3({
77
+ ...restProps,
78
+ asset,
79
+ rewardInfo: inf,
80
+ }));
81
+ acc.push(...extra);
82
+ return acc;
83
+ }, []);
84
+ return extra;
85
+ }
86
+ static getCASingleExtraAPY_V3({ asset, prices, rewardInfo, supply, tokensList, currentTokenData, currentTimestamp, }) {
87
+ const { token, balance } = asset;
88
+ const safeSupply = supply[token] ?? 0n;
89
+ const { decimals: tokenDecimals = 18 } = tokensList[token] || {};
90
+ const tokenPrice = prices[token] ?? 0n;
91
+ const rewardAddress = currentTokenData[rewardInfo.symbol];
92
+ const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
93
+ const rewardPrice = prices[rewardAddress] ?? 0n;
94
+ const r = this.calculateAPY_V3({
95
+ currentTimestamp,
96
+ info: rewardInfo,
97
+ supply: {
98
+ amount: typeof safeSupply === "bigint" ? safeSupply : safeSupply.balance,
99
+ decimals: tokenDecimals,
100
+ price: tokenPrice,
101
+ },
102
+ reward: {
103
+ price: rewardPrice,
104
+ decimals: rewardDecimals,
105
+ },
106
+ }) / Number(sdk_gov_1.PERCENTAGE_FACTOR);
107
+ return { token, balance, rewardInfo, apy: r };
108
+ }
64
109
  }
65
110
  exports.GearboxRewardsApy = GearboxRewardsApy;
@@ -13,8 +13,8 @@ export interface GetPointsByPoolProps {
13
13
  export interface GetTotalTokensOnProtocolProps {
14
14
  currentTokenData: Record<SupportedToken, Address>;
15
15
  tokensList: Record<Address, TokenData>;
16
- chainId: number;
17
16
  network: NetworkType;
17
+ extraTokens?: Array<SupportedToken>;
18
18
  }
19
19
  interface PoolPointsInfo {
20
20
  amount: bigint;
@@ -24,7 +24,7 @@ interface PoolPointsInfo {
24
24
  estimation: "absolute" | "relative";
25
25
  }
26
26
  export declare class GearboxRewardsExtraApy {
27
- static getTotalTokensOnProtocol({ currentTokenData, chainId, tokensList, network, }: GetTotalTokensOnProtocolProps): Promise<[SupportedToken, PromiseSettledResult<Asset>][]>;
27
+ static getTotalTokensOnProtocol({ currentTokenData, tokensList, network, extraTokens, }: GetTotalTokensOnProtocolProps): Promise<[SupportedToken, PromiseSettledResult<Asset>][]>;
28
28
  private static getTokenTotal;
29
29
  static getPointsByPool({ totalTokenBalances, pools, tokensList, currentTokenData, network, }: GetPointsByPoolProps): Record<`0x${string}`, Asset[]>;
30
30
  private static getPoolTokenPoints;
@@ -51,16 +51,25 @@ const TOKENS = sdk_gov_1.TypedObjectUtils.entries(POOL_POINTS).reduce((acc, [net
51
51
  acc[network] = r;
52
52
  return acc;
53
53
  }, {});
54
+ const CA_REWARDS = {
55
+ Mainnet: [],
56
+ Arbitrum: [],
57
+ Optimism: ["ezETH"],
58
+ Base: [],
59
+ };
54
60
  class GearboxRewardsExtraApy {
55
- static async getTotalTokensOnProtocol({ currentTokenData, chainId, tokensList, network, }) {
56
- const currTokens = TOKENS[network];
57
- const res = await Promise.allSettled(currTokens.map(s => this.getTokenTotal(currentTokenData[s], chainId, tokensList)));
61
+ static async getTotalTokensOnProtocol({ currentTokenData, tokensList, network, extraTokens = [], }) {
62
+ const poolTokens = TOKENS[network];
63
+ const caTokens = CA_REWARDS[network];
64
+ const list = [...new Set([...poolTokens, ...caTokens, ...extraTokens])];
65
+ const res = await Promise.allSettled(list.map(s => this.getTokenTotal(currentTokenData[s], network, tokensList)));
58
66
  return res.map((r, i) => [
59
- currTokens[i],
67
+ list[i],
60
68
  r,
61
69
  ]);
62
70
  }
63
- static async getTokenTotal(token, chainId, tokensList) {
71
+ static async getTokenTotal(token, network, tokensList) {
72
+ const chainId = sdk_gov_1.CHAINS[network];
64
73
  const url = endpoint_1.GearboxBackendApi.getChartsUrl("getBalanceAt", chainId, {
65
74
  params: {
66
75
  asset: token,
@@ -13,6 +13,10 @@ const ALIASES = {
13
13
  PT_ezETH_26DEC2024: "p.ezETH(26.12.24)",
14
14
  PT_eBTC_26DEC2024: "p.eBTC(26.12.24)",
15
15
  PT_LBTC_27MAR2025: "p.LBTC(27.03.25)",
16
+ PT_cornLBTC_26DEC2024: "p.c.LBTC(26.12.24)",
17
+ PT_corn_eBTC_27MAR2025: "p.c.eBTC(27.03.25)",
18
+ PT_corn_pumpBTC_26DEC2024: "p.c.pumpBTC(26.12.24)",
19
+ PT_sUSDe_27MAR2025: "p.sUSDe(27.03.25)",
16
20
  };
17
21
  class TokenData {
18
22
  title;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-prevfour.11",
3
+ "version": "3.0.0-prevfour.13",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@gearbox-protocol/bots-v3": "^1.5.1",
32
- "@gearbox-protocol/sdk-gov": "^2.26.1",
32
+ "@gearbox-protocol/sdk-gov": "^2.32.2",
33
33
  "@wagmi/cli": "^2.1.13",
34
34
  "axios": "^1.2.6",
35
35
  "decimal.js-light": "^2.5.1",
@@ -41,6 +41,7 @@
41
41
  "@1inch/solidity-utils": "^2.2.27",
42
42
  "@commitlint/cli": "^17.6.3",
43
43
  "@commitlint/config-conventional": "^17.0.3",
44
+ "@gearbox-protocol/bots-v3": "^1.5.1",
44
45
  "@gearbox-protocol/core-v2": "1.19.0-base.17",
45
46
  "@gearbox-protocol/core-v3": "^1.50.0",
46
47
  "@gearbox-protocol/eslint-config": "^1.4.1",