Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const StakingFlowModal = ({
headerSubtitle="Select your staking source and amount to be staked"
stakeCountLabel="Stake Count"
maxStakesOverride={queueLength}
blockInsiderVaults
/>
)
}
25 changes: 20 additions & 5 deletions staking-dashboard/src/components/SourceSelectionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useRollupData } from "@/hooks/rollup/useRollupData"
import { useATP } from "@/hooks/useATP"
import { useMultipleStakeableAmounts, type StakeableATPData } from "@/hooks/atp/useMultipleStakeableAmounts"
import { formatTokenAmount } from "@/utils/atpFormatters"
import { INSIDER_DELEGATION_MESSAGE, isInsiderAtp } from "@/utils/insiderAtp"

// Internal type for modal selection state - includes vault data for display
type SelectedStakingSource = "wallet" | { type: "vault"; atp: StakeableATPData }
Expand All @@ -23,6 +24,8 @@ export interface SourceSelectionModalProps {
stakeCountLabel: string
// Optional constraint (e.g., provider queue length)
maxStakesOverride?: number
// Delegation only: insider ATPs earn no rewards on locked tokens (AZIP-32), so they can't be picked
blockInsiderVaults?: boolean
}

/**
Expand All @@ -38,6 +41,7 @@ export const SourceSelectionModal = ({
headerSubtitle,
stakeCountLabel,
maxStakesOverride,
blockInsiderVaults = false,
}: SourceSelectionModalProps) => {
const { address } = useAccount()
const { stakingAssetAddress, decimals, symbol } = useStakingAssetTokenDetails()
Expand Down Expand Up @@ -197,15 +201,19 @@ export const SourceSelectionModal = ({
? Math.min(maxFromVault, maxStakesOverride)
: maxFromVault
const isSelected = selectedSource !== "wallet" && selectedSource?.type === "vault" && selectedSource.atp.atpAddress === atp.atpAddress
const isBlocked = blockInsiderVaults && isInsiderAtp(atp.registry)

return (
<button
key={atp.atpAddress}
onClick={() => handleSourceSelect({ type: "vault", atp })}
onClick={() => !isBlocked && handleSourceSelect({ type: "vault", atp })}
disabled={isBlocked}
className={`w-full text-left p-4 border rounded-inset transition-all ${
isSelected
? "bg-aqua/10 border-aqua"
: "bg-parchment/5 border-parchment/30 hover:border-aqua/50"
: isBlocked
? "bg-parchment/5 border-parchment/10 cursor-not-allowed"
: "bg-parchment/5 border-parchment/30 hover:border-aqua/50"
}`}
>
<div className="flex items-center gap-4">
Expand All @@ -219,15 +227,22 @@ export const SourceSelectionModal = ({
<span className="font-oracle-standard font-bold text-sm uppercase tracking-wide text-parchment">
Token Vault #{index + 1}
</span>
<span className="text-xs font-mono text-aqua">
Up to {maxStakesFromVault} stake{maxStakesFromVault !== 1 ? "s" : ""}
</span>
{!isBlocked && (
<span className="text-xs font-mono text-aqua">
Up to {maxStakesFromVault} stake{maxStakesFromVault !== 1 ? "s" : ""}
</span>
)}
</div>
<div className="text-xs font-mono text-parchment/60">
{decimals !== undefined && symbol
? formatTokenAmount(atp.stakeableAmount, decimals, symbol)
: "Loading..."}
</div>
{isBlocked && (
<div className="text-xs text-amber-400 mt-2">
{INSIDER_DELEGATION_MESSAGE}
</div>
)}
</div>
{isSelected && (
<Icon name="check" className="w-5 h-5 text-aqua" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useATPSelection } from "@/contexts/ATPSelectionContext"
import { TooltipIcon } from "@/components/Tooltip"
import { Icon } from "@/components/Icon"
import type { ATPData } from "@/hooks/atp/atpTypes"
import { INSIDER_DELEGATION_MESSAGE, isInsiderAtp } from "@/utils/insiderAtp"

interface StakingChoiceModalProps {
isOpen: boolean
Expand All @@ -14,6 +15,8 @@ interface StakingChoiceModalProps {
export const StakingChoiceModal = ({ isOpen, onClose, selectedAtp }: StakingChoiceModalProps) => {
const navigate = useNavigate()
const { setSelectedAtp } = useATPSelection()
// Insider ATPs earn no rewards on locked tokens (AZIP-32), so they may only run their own node
const delegationBlocked = isInsiderAtp(selectedAtp?.registry)

if (!isOpen) return null

Expand All @@ -33,6 +36,7 @@ export const StakingChoiceModal = ({ isOpen, onClose, selectedAtp }: StakingChoi
}

const handleDelegateToProvider = () => {
if (delegationBlocked) return
// Store ATP in context for Delegation flow
if (selectedAtp) {
setSelectedAtp(selectedAtp, "delegation")
Expand Down Expand Up @@ -72,7 +76,7 @@ export const StakingChoiceModal = ({ isOpen, onClose, selectedAtp }: StakingChoi
{/* Options - Side by Side */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
{/* Delegate to Operator Option */}
<div className="glass p-6 hover:bg-parchment/5 transition-all">
<div className={`glass p-6 transition-all ${delegationBlocked ? "opacity-60" : "hover:bg-parchment/5"}`}>
<div className="flex flex-col items-center text-center h-full">
{/* Icon */}
<div className="w-20 h-20 mb-4 flex items-center justify-center glass">
Expand All @@ -93,9 +97,16 @@ export const StakingChoiceModal = ({ isOpen, onClose, selectedAtp }: StakingChoi
Delegate your tokens to an existing provider. This is perfect if you don't want to run your own infrastructure.
</p>

{delegationBlocked && (
<p className="font-oracle-standard text-sm font-medium leading-140 text-amber-400 mb-4">
{INSIDER_DELEGATION_MESSAGE}
</p>
)}

<button
onClick={handleDelegateToProvider}
className="w-full mt-auto btn-lime py-3 px-6 text-sm"
disabled={delegationBlocked}
className="w-full mt-auto btn-lime py-3 px-6 text-sm disabled:opacity-50 disabled:cursor-not-allowed"
>
Browse Delegates
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import { useEffect, useState } from "react"
import { createPortal } from "react-dom"
import { useAccount } from "wagmi"
import { isAddressEqual, type Address } from "viem"
import { useATP } from "@/hooks/useATP"
import { useRollupData } from "@/hooks/rollup/useRollupData"
import { useStakingAssetTokenDetails } from "@/hooks/stakingRegistry"
import { Icon } from "@/components/Icon"
import { useMultipleStakeableAmounts } from "@/hooks/atp"
import { formatTokenAmount } from "@/utils/atpFormatters"

// Employee and investor ATP registries on mainnet. Their ATPs have no staking requirement
// before withdrawal, so they don't count towards this alert.
const INSIDER_ATP_REGISTRIES: Address[] = [
"0xD938bE4A2cB41105Bc2FbE707dca124A2e5d0c80",
"0x667d2641cb96734f386adA6A9afCF07B1815fB8b",
]

const isInsiderAtp = (registry: Address | undefined) =>
!!registry && INSIDER_ATP_REGISTRIES.some((insider) => isAddressEqual(insider, registry))
import { isInsiderAtp } from "@/utils/insiderAtp"

interface WalletConnectionAlertModalProps {
isSafeWarningShown: boolean
Expand Down
15 changes: 15 additions & 0 deletions staking-dashboard/src/utils/insiderAtp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isAddressEqual, type Address } from "viem"

// ATP registries covered by AZIP-32. Their ATPs have no staking requirement before
// withdrawal, and their locked tokens earn no sequencer rewards. They may still run their
// own node, but delegating them to a provider is disabled.
export const INSIDER_ATP_REGISTRIES: Address[] = [
"0xD938bE4A2cB41105Bc2FbE707dca124A2e5d0c80",
"0x667d2641cb96734f386adA6A9afCF07B1815fB8b",
]

export const isInsiderAtp = (registry: Address | undefined) =>
!!registry && INSIDER_ATP_REGISTRIES.some((insider) => isAddressEqual(insider, registry))

export const INSIDER_DELEGATION_MESSAGE =
"Locked tokens don't earn staking rewards. To delegate, claim your unlocked tokens from this Token Vault first, then stake them from your wallet."
Loading