Skip to content

Commit 313028d

Browse files
authored
Merge pull request #289 from Gearbox-protocol/lp-tokens
fix: lp tokens
2 parents 00e7f6f + bf8bc62 commit 313028d

File tree

3 files changed

+42
-57
lines changed

3 files changed

+42
-57
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"dependencies": {
3131
"@gearbox-protocol/bots-v3": "^1.5.1",
32-
"@gearbox-protocol/sdk-gov": "^2.15.1",
32+
"@gearbox-protocol/sdk-gov": "^2.18.0",
3333
"@wagmi/cli": "^2.1.13",
3434
"axios": "^1.2.6",
3535
"decimal.js-light": "^2.5.1",

src/apy/index.ts

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import {
55
SupportedToken,
66
} from "@gearbox-protocol/sdk-gov";
77

8-
type AdditionalTokensWithAPY = Extract<
9-
SupportedToken,
10-
"STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH"
11-
>;
12-
13-
type AdditionalLPTokens = Extract<
8+
// all extra tokens
9+
type ExtraFarmTokens = Extract<
1410
SupportedToken,
11+
| "STETH"
12+
| "rETH"
13+
| "osETH"
14+
| "cbETH"
15+
| "wstETH"
1516
| "weETH"
1617
| "ezETH"
1718
| "sfrxETH"
@@ -23,30 +24,24 @@ type AdditionalLPTokens = Extract<
2324
| "rstETH"
2425
| "steakLRT"
2526
| "amphrETH"
27+
| "LBTC"
2628
>;
2729

28-
type ExtraFarmTokens = AdditionalTokensWithAPY | AdditionalLPTokens;
29-
export type LRTAndLSDTokens = Extract<
30+
// tokens with apy among them
31+
type ExtraTokensWithAPY = Extract<
3032
ExtraFarmTokens,
31-
| "weETH"
32-
| "rsETH"
33-
| "rswETH"
34-
| "pufETH"
35-
| "ezETH"
36-
| "STETH"
37-
| "wstETH"
38-
| "sfrxETH"
39-
| "osETH"
40-
| "cbETH"
41-
| "rETH"
33+
"STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH"
4234
>;
4335

44-
export type TokensWithAPY = LPTokens | AdditionalTokensWithAPY;
45-
export type TokensWithApyRecord = PartialRecord<TokensWithAPY, number>;
46-
47-
export type AllLPTokens = LPTokens | ExtraFarmTokens;
36+
// LRT & LST tokens among them
37+
type LRTAndLSTTokens = Exclude<ExtraFarmTokens, "USDe">;
4838

49-
const ADDITIONAL_LP_TOKENS: Record<AdditionalLPTokens, true> = {
39+
const EXTRA_FARM_TOKENS: Record<ExtraFarmTokens, true> = {
40+
STETH: true,
41+
rETH: true,
42+
osETH: true,
43+
cbETH: true,
44+
wstETH: true,
5045
weETH: true,
5146
ezETH: true,
5247
sfrxETH: true,
@@ -58,9 +53,15 @@ const ADDITIONAL_LP_TOKENS: Record<AdditionalLPTokens, true> = {
5853
rstETH: true,
5954
steakLRT: true,
6055
amphrETH: true,
56+
LBTC: true,
57+
};
58+
59+
export const isExtraFarmToken = (t: unknown): t is ExtraFarmTokens => {
60+
if (typeof t !== "string") return false;
61+
return !!EXTRA_FARM_TOKENS[t as ExtraFarmTokens];
6162
};
6263

63-
const TOKENS_WITH_APY: Record<AdditionalTokensWithAPY, true> = {
64+
const EXTRA_TOKENS_WITH_APY: Record<ExtraTokensWithAPY, true> = {
6465
STETH: true,
6566
osETH: true,
6667
rETH: true,
@@ -69,45 +70,29 @@ const TOKENS_WITH_APY: Record<AdditionalTokensWithAPY, true> = {
6970
sfrxETH: true,
7071
};
7172

72-
const LRT_LSD: Record<LRTAndLSDTokens, true> = {
73-
weETH: true,
74-
rsETH: true,
75-
rswETH: true,
76-
pufETH: true,
77-
ezETH: true,
78-
STETH: true,
79-
wstETH: true,
80-
sfrxETH: true,
81-
osETH: true,
82-
cbETH: true,
83-
rETH: true,
84-
};
85-
86-
export const isLRT_LSDToken = (t: unknown): t is LRTAndLSDTokens => {
73+
const isExtraTokenWithAPY = (t: unknown): t is ExtraTokensWithAPY => {
8774
if (typeof t !== "string") return false;
88-
return !!LRT_LSD[t as LRTAndLSDTokens];
75+
return !!EXTRA_TOKENS_WITH_APY[t as ExtraTokensWithAPY];
8976
};
9077

91-
export const isAdditionalLPToken = (t: unknown): t is AdditionalLPTokens => {
92-
if (typeof t !== "string") return false;
93-
return !!ADDITIONAL_LP_TOKENS[t as AdditionalLPTokens];
94-
};
78+
const { USDe, ...rest } = EXTRA_FARM_TOKENS;
79+
const LRT_LST: Record<LRTAndLSTTokens, true> = rest;
9580

96-
export const isAdditionalTokenWithAPY = (
97-
t: unknown,
98-
): t is AdditionalTokensWithAPY => {
81+
export const isLRT_LSTToken = (t: unknown): t is LRTAndLSTTokens => {
9982
if (typeof t !== "string") return false;
100-
return !!TOKENS_WITH_APY[t as AdditionalTokensWithAPY];
83+
return !!LRT_LST[t as LRTAndLSTTokens];
10184
};
10285

103-
export const isExtraFarmToken = (t: unknown): t is ExtraFarmTokens =>
104-
isAdditionalLPToken(t) || isAdditionalTokenWithAPY(t);
86+
export type TokensWithAPY = LPTokens | ExtraTokensWithAPY;
87+
export type TokensWithApyRecord = PartialRecord<TokensWithAPY, number>;
10588

10689
export const isTokenWithAPY = (t: unknown): t is TokensWithAPY => {
10790
if (typeof t !== "string") return false;
108-
return isLPToken(t) || isAdditionalTokenWithAPY(t);
91+
return isLPToken(t) || isExtraTokenWithAPY(t);
10992
};
11093

94+
export type AllLPTokens = LPTokens | ExtraFarmTokens;
95+
11196
export const isFarmToken = (t: unknown): t is AllLPTokens => {
11297
return isLPToken(t) || isExtraFarmToken(t);
11398
};

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,10 @@
15161516
yarn "^1.22.19"
15171517
zod "^3.22.2"
15181518

1519-
"@gearbox-protocol/sdk-gov@^2.15.1":
1520-
version "2.15.1"
1521-
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk-gov/-/sdk-gov-2.15.1.tgz#328ebb5c6c53b6e76431f4ace857e4088f3d7b6f"
1522-
integrity sha512-GwC4CgL0V0c6pOMPy2LpY3uP2H2p8me3DeOCSIGD4ZPpT3cvF/22mpojO9IoeLBg+bg53W8l2+gX/+Fkyz06vw==
1519+
"@gearbox-protocol/sdk-gov@^2.18.0":
1520+
version "2.18.0"
1521+
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk-gov/-/sdk-gov-2.18.0.tgz#bfef8a51355434d20d95998abb7cb3cbb84304e1"
1522+
integrity sha512-Gqf8mHOWFXwn2Nk8f926OsjDYHrTSh3QN3RL9fKCv8uv0vktPDg8KWZFfifljwQQ3nVGNKwqWaa8RcGr/rdAxw==
15231523
dependencies:
15241524
ethers "6.12.1"
15251525
humanize-duration-ts "^2.1.1"

0 commit comments

Comments
 (0)