Skip to content

Commit 3af0655

Browse files
authored
fix: unstake limits for ERC4626 (#491)
1 parent b5b87c3 commit 3af0655

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.changeset/calm-owls-accept.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: unstake limits for ERC4626

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { SupportedSKChains } from "./chains";
1111
import type { InitParams } from "./init-params";
1212
import type { PositionsData } from "./positions";
1313
import type { TokenString } from "./tokens";
14+
import { isBittensorStaking } from "./yields";
1415

1516
const amountGreaterThanZero = (val: TokenBalanceScanResponseDto) =>
1617
new BigNumber(val.amount).isGreaterThan(0);
@@ -197,9 +198,9 @@ export const getMinUnstakeAmount = (
197198

198199
const pricePerShareBN = new BigNumber(pricePerShare ?? 0);
199200

200-
if (pricePerShareBN.isZero()) {
201+
if (pricePerShareBN.isZero() || !isBittensorStaking(yieldDto.id)) {
201202
return integrationMin;
202203
}
203204

204-
return integrationMin.dividedBy(pricePerShareBN).decimalPlaces(8);
205+
return integrationMin.dividedBy(pricePerShareBN).decimalPlaces(16);
205206
};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,6 @@ export const getComputedRewardRate = (yieldDto: YieldDto) => {
194194

195195
return yieldDto.rewardRate;
196196
};
197+
198+
export const isERC4626 = (yieldDto: YieldDto) =>
199+
yieldDto.metadata.supportedStandards?.includes("ERC4626") ?? false;

packages/widget/src/pages/position-details/state/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "react";
1919
import { config } from "../../../config";
2020
import { isForceMaxAmount } from "../../../domain/types/stake";
21+
import { isERC4626 } from "../../../domain/types/yields";
2122
import { usePrices } from "../../../hooks/api/use-prices";
2223
import { useYieldOpportunity } from "../../../hooks/api/use-yield-opportunity";
2324
import { useUnstakeOrPendingActionParams } from "../../../hooks/navigation/use-unstake-or-pending-action-params";
@@ -158,7 +159,8 @@ export const UnstakeOrPendingActionProvider = ({
158159
});
159160

160161
const canChangeUnstakeAmount = integrationData.map(
161-
(d) => !!(!isForceMax && d.args.exit?.args?.amount?.required)
162+
(d) =>
163+
!!(!isForceMax && (d.args.exit?.args?.amount?.required || isERC4626(d)))
162164
);
163165

164166
const positionBalancesByTypePendingActions = useMemo(

0 commit comments

Comments
 (0)