@gearbox-protocol/sdk 3.0.0-next.256 → 3.0.0-next.258
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/lib/apy/defiLamaAPY.js +1 -0
- package/lib/apy/index.d.ts +2 -2
- package/lib/apy/index.js +2 -0
- package/lib/gearboxRewards/api.js +4 -2
- package/lib/gearboxRewards/apy.d.ts +16 -3
- package/lib/gearboxRewards/apy.js +39 -1
- package/lib/gearboxRewards/extraAPY.d.ts +2 -2
- package/lib/gearboxRewards/extraAPY.js +14 -5
- package/lib/tokens/tokenData.js +1 -0
- package/package.json +2 -2
package/lib/apy/defiLamaAPY.js
CHANGED
|
@@ -46,6 +46,7 @@ const NORMAL_TO_LAMA = {
|
|
|
46
46
|
PT_cornLBTC_26DEC2024: "f7826423-8043-4799-b12a-83a68adc992d",
|
|
47
47
|
PT_corn_eBTC_27MAR2025: "eb7de368-b460-4638-bde1-50a129109b7b",
|
|
48
48
|
PT_corn_pumpBTC_26DEC2024: "a23e2b97-ff92-4ebf-8c7d-171cad8431ad",
|
|
49
|
+
PT_sUSDe_27MAR2025: "6b28892f-0909-418d-b4bb-3106fff72449",
|
|
49
50
|
},
|
|
50
51
|
Optimism: { rETH: "d4b3c522-6127-4b89-bedf-83641cdcd2eb" },
|
|
51
52
|
Arbitrum: {
|
package/lib/apy/index.d.ts
CHANGED
|
@@ -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">;
|
|
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">;
|
|
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">;
|
|
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">;
|
|
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
|
@@ -45,6 +45,7 @@ const EXTRA_FARM_TOKENS = {
|
|
|
45
45
|
PT_corn_eBTC_27MAR2025: true,
|
|
46
46
|
PT_corn_pumpBTC_26DEC2024: true,
|
|
47
47
|
pumpBTC: true,
|
|
48
|
+
PT_sUSDe_27MAR2025: true,
|
|
48
49
|
};
|
|
49
50
|
const isExtraFarmToken = (t) => {
|
|
50
51
|
if (typeof t !== "string")
|
|
@@ -77,6 +78,7 @@ const EXTRA_TOKENS_WITH_APY = {
|
|
|
77
78
|
PT_cornLBTC_26DEC2024: true,
|
|
78
79
|
PT_corn_eBTC_27MAR2025: true,
|
|
79
80
|
PT_corn_pumpBTC_26DEC2024: true,
|
|
81
|
+
PT_sUSDe_27MAR2025: true,
|
|
80
82
|
};
|
|
81
83
|
const isExtraTokenWithAPY = (t) => {
|
|
82
84
|
if (typeof t !== "string")
|
|
@@ -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
|
-
|
|
25
|
+
if (t)
|
|
26
|
+
acc[t] = p.address;
|
|
26
27
|
});
|
|
27
28
|
p.stakedDieselToken_old.forEach(t => {
|
|
28
|
-
|
|
29
|
+
if (t)
|
|
30
|
+
acc[t] = p.address;
|
|
29
31
|
});
|
|
30
32
|
return acc;
|
|
31
33
|
}, {});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { 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,8 +17,9 @@ interface CalculateV3PoolLmAPYProps {
|
|
|
16
17
|
price: bigint;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
20
|
+
export interface ExtraRewardApy {
|
|
21
|
+
token: Address;
|
|
22
|
+
rewardInfo: FarmInfo;
|
|
21
23
|
apy: number;
|
|
22
24
|
}
|
|
23
25
|
interface GetPoolExtraAPY_V3Props {
|
|
@@ -30,9 +32,20 @@ interface GetPoolExtraAPY_V3Props {
|
|
|
30
32
|
currentTokenData: Record<SupportedToken, Address>;
|
|
31
33
|
currentTimestamp: number;
|
|
32
34
|
}
|
|
35
|
+
interface GetCAExtraAPYProps {
|
|
36
|
+
assets: Array<Asset>;
|
|
37
|
+
supply: Record<Address, bigint> | Record<Address, Asset>;
|
|
38
|
+
rewardInfo: Record<Address, Array<FarmInfo>>;
|
|
39
|
+
currentTimestamp: number;
|
|
40
|
+
prices: Record<Address, bigint>;
|
|
41
|
+
tokensList: Record<Address, TokenData>;
|
|
42
|
+
currentTokenData: Record<SupportedToken, Address>;
|
|
43
|
+
}
|
|
33
44
|
export declare class GearboxRewardsApy {
|
|
34
|
-
static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<
|
|
45
|
+
static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy>;
|
|
35
46
|
private static getPoolSingleExtraLmAPY_V3;
|
|
36
47
|
static calculateAPY_V3({ info, supply, reward, currentTimestamp, }: CalculateV3PoolLmAPYProps): number;
|
|
48
|
+
static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }: GetCAExtraAPYProps): Array<ExtraRewardApy>;
|
|
49
|
+
private static getCASingleExtraAPY_V3;
|
|
37
50
|
}
|
|
38
51
|
export {};
|
|
@@ -43,7 +43,7 @@ class GearboxRewardsApy {
|
|
|
43
43
|
decimals: rewardDecimals,
|
|
44
44
|
},
|
|
45
45
|
}) / Number(sdk_gov_1.PERCENTAGE_FACTOR);
|
|
46
|
-
return {
|
|
46
|
+
return { token: stakedDieselToken, rewardInfo: rewardPoolsInfo, apy: r };
|
|
47
47
|
}
|
|
48
48
|
static calculateAPY_V3({ info, supply, reward, currentTimestamp, }) {
|
|
49
49
|
const finished = info.finished <= currentTimestamp;
|
|
@@ -61,5 +61,43 @@ class GearboxRewardsApy {
|
|
|
61
61
|
const apyBn = (((rewardMoney * ONE) / supplyMoney) * durationRatio) / sdk_gov_1.WAD;
|
|
62
62
|
return Math.round(Number(apyBn) / 10);
|
|
63
63
|
}
|
|
64
|
+
static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }) {
|
|
65
|
+
const extra = assets.reduce((acc, asset) => {
|
|
66
|
+
const { token } = asset;
|
|
67
|
+
const info = rewardInfo[token];
|
|
68
|
+
if (!info)
|
|
69
|
+
return acc;
|
|
70
|
+
const extra = info.map(inf => this.getCASingleExtraAPY_V3({
|
|
71
|
+
...restProps,
|
|
72
|
+
token,
|
|
73
|
+
rewardInfo: inf,
|
|
74
|
+
}));
|
|
75
|
+
acc.push(...extra);
|
|
76
|
+
return acc;
|
|
77
|
+
}, []);
|
|
78
|
+
return extra;
|
|
79
|
+
}
|
|
80
|
+
static getCASingleExtraAPY_V3({ token, prices, rewardInfo, supply, tokensList, currentTokenData, currentTimestamp, }) {
|
|
81
|
+
const safeSupply = supply[token] ?? 0n;
|
|
82
|
+
const { decimals: tokenDecimals = 18 } = tokensList[token] || {};
|
|
83
|
+
const tokenPrice = prices[token] ?? 0n;
|
|
84
|
+
const rewardAddress = currentTokenData[rewardInfo.symbol];
|
|
85
|
+
const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
|
|
86
|
+
const rewardPrice = prices[rewardAddress] ?? 0n;
|
|
87
|
+
const r = this.calculateAPY_V3({
|
|
88
|
+
currentTimestamp,
|
|
89
|
+
info: rewardInfo,
|
|
90
|
+
supply: {
|
|
91
|
+
amount: typeof safeSupply === "bigint" ? safeSupply : safeSupply.balance,
|
|
92
|
+
decimals: tokenDecimals,
|
|
93
|
+
price: tokenPrice,
|
|
94
|
+
},
|
|
95
|
+
reward: {
|
|
96
|
+
price: rewardPrice,
|
|
97
|
+
decimals: rewardDecimals,
|
|
98
|
+
},
|
|
99
|
+
}) / Number(sdk_gov_1.PERCENTAGE_FACTOR);
|
|
100
|
+
return { token: token, rewardInfo: rewardInfo, apy: r };
|
|
101
|
+
}
|
|
64
102
|
}
|
|
65
103
|
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,
|
|
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,
|
|
56
|
-
const
|
|
57
|
-
const
|
|
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
|
-
|
|
67
|
+
list[i],
|
|
60
68
|
r,
|
|
61
69
|
]);
|
|
62
70
|
}
|
|
63
|
-
static async getTokenTotal(token,
|
|
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,
|
package/lib/tokens/tokenData.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.258",
|
|
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.
|
|
31
|
+
"@gearbox-protocol/sdk-gov": "^2.31.0",
|
|
32
32
|
"@wagmi/cli": "^2.1.13",
|
|
33
33
|
"axios": "^1.2.6",
|
|
34
34
|
"decimal.js-light": "^2.5.1",
|