Skip to content

Commit 4c2fafe

Browse files
committed
fix(yields): allow whitelisted zero-rate yields
1 parent cc64fae commit 4c2fafe

5 files changed

Lines changed: 25 additions & 4 deletions

File tree

.changeset/tidy-files-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stakekit/widget": patch
3+
---
4+
5+
fix(yields): allow whitelisted zero-rate yields

packages/widget/src/domain/types/yields.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ export const isEthenaUsdeStaking = (yieldId: string) =>
179179
export const isBittensorStaking = (yieldId: string) =>
180180
yieldId === "bittensor-native-staking";
181181

182+
const zeroRewardRateYieldIdWhitelist = new Set<string>([
183+
"optimism-usdc-gtusdcb-0x4ffc4e5f1f1f5c43dc9bc27b53728da13b02be35-4626-vault",
184+
]);
185+
186+
export const isNonZeroRewardRateYield = (
187+
yieldDto: Pick<YieldDto, "id" | "rewardRate">
188+
) =>
189+
yieldDto.rewardRate > 0 || zeroRewardRateYieldIdWhitelist.has(yieldDto.id);
190+
182191
export const getComputedRewardRate = (yieldDto: YieldDto) => {
183192
const liveFeeConfigurations = yieldDto.feeConfigurations.filter(
184193
(fc) => fc.status === "LIVE"

packages/widget/src/hooks/api/use-multi-yields.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ import {
3131
type PreferredTokenYieldsPerNetwork,
3232
} from "../../domain/types/stake";
3333
import type { SKWallet } from "../../domain/types/wallet";
34-
import type { ValidatorsConfig } from "../../domain/types/yields";
34+
import {
35+
isNonZeroRewardRateYield,
36+
type ValidatorsConfig,
37+
} from "../../domain/types/yields";
3538
import { useSKQueryClient } from "../../providers/query-client";
3639
import { useSKWallet } from "../../providers/sk-wallet";
3740
import { useSavedRef } from "../use-saved-ref";
@@ -192,7 +195,9 @@ const firstEligibleYield$ = (args: {
192195

193196
const successStream = multipleYields$(args).pipe(
194197
tap((v) => {
195-
defaultYield = v;
198+
if (isNonZeroRewardRateYield(v) || !defaultYield) {
199+
defaultYield = v;
200+
}
196201
}),
197202
filter((y) => {
198203
const preferredYieldId = Maybe.fromNullable(

packages/widget/src/hooks/use-summary.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getBaseToken, getTokenPriceInUSD } from "../domain";
88
import { getPositionTotalAmount } from "../domain/types/positions";
99
import type { Prices } from "../domain/types/price";
1010
import type { EnabledRewardsSummaryYieldId } from "../domain/types/rewards";
11+
import { isNonZeroRewardRateYield } from "../domain/types/yields";
1112
import { usePositions } from "../pages/details/positions-page/hooks/use-positions";
1213
import { useMultiYields } from "./api/use-multi-yields";
1314
import { usePrices } from "./api/use-prices";
@@ -294,7 +295,7 @@ export const SummaryProvider = ({
294295
prices,
295296
});
296297

297-
if (yieldDto.rewardRate > 0 && usdAmount.gt(0)) {
298+
if (isNonZeroRewardRateYield(yieldDto) && usdAmount.gt(0)) {
298299
return {
299300
totalWeightedApy: acc.totalWeightedApy.plus(
300301
usdAmount.times(yieldDto.rewardRate * 100)

packages/widget/src/pages/details/earn-page/state/earn-page-context.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
import {
3030
type ExtendedYieldType,
3131
getExtendedYieldType,
32+
isNonZeroRewardRateYield,
3233
getYieldTypeLabels,
3334
getYieldTypesSortRank,
3435
isBittensorStaking,
@@ -236,7 +237,7 @@ export const EarnPageContextProvider = ({ children }: PropsWithChildren) => {
236237
() =>
237238
Maybe.of(multiYields)
238239
.map((val) => [...val].sort((a, b) => b.rewardRate - a.rewardRate))
239-
.map((val) => val.filter((v) => v.rewardRate > 0))
240+
.map((val) => val.filter(isNonZeroRewardRateYield))
240241
.chain((yieldDtos) =>
241242
Maybe.of(deferredStakeSearch)
242243
.chain((val) =>

0 commit comments

Comments
 (0)