Skip to content

Commit

Permalink
more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler committed Jan 31, 2025
1 parent 5ef71e2 commit 6fe731b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/PositionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const PositionCard: FC<{
const elapsedTime = new BN(unixNow).sub(lockup.startTs);
const totalTime = lockup.endTs.sub(lockup.startTs);
const decayedPercentage = elapsedTime.muln(100).div(totalTime);
const canDelegate = canDelegateIn && network === "hnt";
const canDelegate = canDelegateIn && isHNT;
const { knownProxy } = useKnownProxy(position?.proxy?.nextVoter);

const lockedTokens =
Expand Down
24 changes: 11 additions & 13 deletions src/components/PositionManager/PositionCallout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const PositionCallout: FC<{
}) => {
const { lockup, isDelegated, hasGenesisMultiplier } = position;
const { loading: loadingGov, network, mintAcc, subDaos } = useGovernance();
const isHNT = network === "hnt";
const unixNow = useSolanaUnixNow() || Date.now() / 1000;
const lockupKind = Object.keys(lockup.kind)[0] as string;
const isConstant = lockupKind === "constant";
Expand All @@ -50,7 +51,6 @@ export const PositionCallout: FC<{
? decayedEpoch.add(new BN(1)).mul(new BN(EPOCH_LENGTH)).sub(lockup.startTs)
: lockup.endTs.sub(lockup.startTs);
const decayedPercentage = elapsedTime.muln(100).div(totalTime);
const canDelegate = network === "hnt";

const delegatedSubDaoMetadata = position.delegatedSubDao
? subDaos?.find((sd) => sd.pubkey.equals(position.delegatedSubDao!))
Expand Down Expand Up @@ -176,7 +176,7 @@ export const PositionCallout: FC<{
</p>
</div>
</div>
{!position.isProxiedToMe && (
{!position.isProxiedToMe && isHNT && (
<>
{!isDecayed ? (
<div className="flex flex-row justify-between gap-2">
Expand All @@ -187,17 +187,15 @@ export const PositionCallout: FC<{
>
{isConstant ? "Decay Position" : "Pause Position"}
</Button>
{canDelegate && (
<Button
variant="secondary"
className="flex-1 gap-2"
disabled={!position.hasRewards || isClaiming}
onClick={handleClaimRewards}
>
{isClaiming && <Loader2 className="size-5 animate-spin" />}
{isClaiming ? "Claiming Rewards..." : "Claim Rewards"}
</Button>
)}
<Button
variant="secondary"
className="flex-1 gap-2"
disabled={!position.hasRewards || isClaiming}
onClick={handleClaimRewards}
>
{isClaiming && <Loader2 className="size-5 animate-spin" />}
{isClaiming ? "Claiming Rewards..." : "Claim Rewards"}
</Button>
</div>
) : (
<div className="flex flex-row justify-between gap-2">
Expand Down
19 changes: 8 additions & 11 deletions src/components/PositionManager/PositionManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const PositionManager: FC<PositionManagerProps> = ({
(isDelegated
? currentEpoch.gt(decayedEpoch)
: lockup.endTs.lte(new BN(unixNow)));
const canDelegate = network === "hnt";
const mergablePositions: PositionWithMeta[] = useMemo(() => {
if (!unixNow || !positions || !positions.length) {
return [];
Expand Down Expand Up @@ -404,16 +403,14 @@ export const PositionManager: FC<PositionManagerProps> = ({
>
Update Proxy
</PositionAction>
{canDelegate && (
<PositionAction
active={action === "delegate"}
disabled={!position.delegatedSubDao && isDecayed}
Icon={CheckCheck}
onClick={() => setAction("delegate")}
>
Update Delegation
</PositionAction>
)}
<PositionAction
active={action === "delegate"}
disabled={!position.delegatedSubDao && isDecayed}
Icon={CheckCheck}
onClick={() => setAction("delegate")}
>
Update Delegation
</PositionAction>
<PositionAction
active={action === "extend"}
Icon={() => (
Expand Down

0 comments on commit 6fe731b

Please sign in to comment.