@towns-protocol/contracts 0.0.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +206 -0
- package/docs/permitAndStake_integration_guide.md +266 -0
- package/docs/swap_integration_guide.md +591 -0
- package/package.json +57 -0
- package/scripts/common/DeployBase.s.sol +26 -0
- package/scripts/common/DeployFacet.s.sol +7 -0
- package/scripts/common/Deployer.s.sol +33 -0
- package/scripts/common/Interaction.s.sol +51 -0
- package/scripts/deployments/diamonds/DeployAppRegistry.s.sol +168 -0
- package/scripts/deployments/diamonds/DeployBaseRegistry.s.sol +263 -0
- package/scripts/deployments/diamonds/DeployRiverAirdrop.s.sol +203 -0
- package/scripts/deployments/diamonds/DeployRiverMigration.s.sol +129 -0
- package/scripts/deployments/diamonds/DeployRiverRegistry.s.sol +175 -0
- package/scripts/deployments/diamonds/DeploySpace.s.sol +285 -0
- package/scripts/deployments/diamonds/DeploySpaceFactory.s.sol +416 -0
- package/scripts/deployments/diamonds/DeploySpaceOwner.s.sol +183 -0
- package/scripts/deployments/diamonds/DeploySwapRouter.s.sol +176 -0
- package/scripts/deployments/diamonds/IDiamondInitHelper.sol +11 -0
- package/scripts/deployments/facets/DeployAppAccount.s.sol +51 -0
- package/scripts/deployments/facets/DeployAppRegistryFacet.s.sol +69 -0
- package/scripts/deployments/facets/DeployArchitect.s.sol +51 -0
- package/scripts/deployments/facets/DeployAttestationRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployBanning.s.sol +30 -0
- package/scripts/deployments/facets/DeployChannels.s.sol +35 -0
- package/scripts/deployments/facets/DeployCreateSpace.s.sol +42 -0
- package/scripts/deployments/facets/DeployDropFacet.s.sol +49 -0
- package/scripts/deployments/facets/DeployERC721A.s.sol +48 -0
- package/scripts/deployments/facets/DeployERC721ANonTransferable.s.sol +49 -0
- package/scripts/deployments/facets/DeployERC721AQueryable.s.sol +30 -0
- package/scripts/deployments/facets/DeployEntitlementChecker.s.sol +49 -0
- package/scripts/deployments/facets/DeployEntitlementDataQueryable.s.sol +29 -0
- package/scripts/deployments/facets/DeployEntitlementsManager.s.sol +33 -0
- package/scripts/deployments/facets/DeployExecutorFacet.s.sol +60 -0
- package/scripts/deployments/facets/DeployFeatureManager.s.sol +38 -0
- package/scripts/deployments/facets/DeployGuardianFacet.s.sol +39 -0
- package/scripts/deployments/facets/DeployImplementationRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployMainnetDelegation.s.sol +43 -0
- package/scripts/deployments/facets/DeployMembership.s.sol +77 -0
- package/scripts/deployments/facets/DeployMembershipMetadata.s.sol +30 -0
- package/scripts/deployments/facets/DeployMembershipToken.s.sol +47 -0
- package/scripts/deployments/facets/DeployMerkleAirdrop.s.sol +37 -0
- package/scripts/deployments/facets/DeployMetadata.s.sol +39 -0
- package/scripts/deployments/facets/DeployMockLegacyArchitect.s.sol +33 -0
- package/scripts/deployments/facets/DeployNodeOperator.s.sol +49 -0
- package/scripts/deployments/facets/DeployNodeRegistry.s.sol +37 -0
- package/scripts/deployments/facets/DeployOperatorRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployPartnerRegistry.s.sol +41 -0
- package/scripts/deployments/facets/DeployPlatformRequirements.s.sol +75 -0
- package/scripts/deployments/facets/DeployPrepayFacet.s.sol +31 -0
- package/scripts/deployments/facets/DeployPricingModules.s.sol +36 -0
- package/scripts/deployments/facets/DeployReferrals.s.sol +34 -0
- package/scripts/deployments/facets/DeployReviewFacet.s.sol +31 -0
- package/scripts/deployments/facets/DeployRewardsDistributionV2.s.sol +76 -0
- package/scripts/deployments/facets/DeployRiverConfig.s.sol +41 -0
- package/scripts/deployments/facets/DeployRoles.s.sol +48 -0
- package/scripts/deployments/facets/DeploySchemaRegistry.s.sol +35 -0
- package/scripts/deployments/facets/DeploySignerFacet.s.sol +47 -0
- package/scripts/deployments/facets/DeploySimpleApp.s.sol +10 -0
- package/scripts/deployments/facets/DeploySpaceDelegation.s.sol +43 -0
- package/scripts/deployments/facets/DeploySpaceEntitlementGated.s.sol +31 -0
- package/scripts/deployments/facets/DeploySpaceFactoryInit.s.sol +33 -0
- package/scripts/deployments/facets/DeploySpaceOwnerFacet.s.sol +71 -0
- package/scripts/deployments/facets/DeployStreamRegistry.s.sol +50 -0
- package/scripts/deployments/facets/DeploySwapFacet.s.sol +33 -0
- package/scripts/deployments/facets/DeploySwapRouterFacet.s.sol +38 -0
- package/scripts/deployments/facets/DeployTipping.s.sol +31 -0
- package/scripts/deployments/facets/DeployTokenMigration.s.sol +40 -0
- package/scripts/deployments/facets/DeployTownsPoints.s.sol +53 -0
- package/scripts/deployments/facets/DeployTreasury.s.sol +30 -0
- package/scripts/deployments/facets/DeployUpgradeableBeacon.s.sol +34 -0
- package/scripts/deployments/facets/DeployWalletLink.s.sol +56 -0
- package/scripts/deployments/facets/DeployXChain.s.sol +35 -0
- package/scripts/deployments/utils/DeployAccountFactory.s.sol +40 -0
- package/scripts/deployments/utils/DeployEntitlementGatedExample.s.sol +23 -0
- package/scripts/deployments/utils/DeployEntrypoint.s.sol +28 -0
- package/scripts/deployments/utils/DeployMember.s.sol +95 -0
- package/scripts/deployments/utils/DeployMockDiamond.s.sol +7 -0
- package/scripts/deployments/utils/DeployMockERC20.s.sol +24 -0
- package/scripts/deployments/utils/DeployMockERC721A.s.sol +45 -0
- package/scripts/deployments/utils/DeployMockLegacyMembership.s.sol +29 -0
- package/scripts/deployments/utils/DeployMockMessenger.s.sol +42 -0
- package/scripts/deployments/utils/DeployMockNFT.s.sol +86 -0
- package/scripts/deployments/utils/DeployPoapEntitlement.s.sol +16 -0
- package/scripts/deployments/utils/DeployProxyBatchDelegation.s.sol +112 -0
- package/scripts/deployments/utils/DeploySpaceProxyInitializer.s.sol +28 -0
- package/scripts/deployments/utils/DeployTieredLogPricingV2.s.sol +23 -0
- package/scripts/deployments/utils/DeployTieredLogPricingV3.s.sol +23 -0
- package/scripts/deployments/utils/DeployTownsBase.s.sol +95 -0
- package/scripts/deployments/utils/DeployTownsMainnet.s.sol +66 -0
- package/scripts/deployments/utils/DeployTownsMulti.s.sol +53 -0
- package/scripts/deployments/utils/DeployWrappedTowns.s.sol +52 -0
- package/scripts/deployments/utils/LibLayerZeroValues.sol +34 -0
- package/scripts/deployments/utils/pricing/TieredLogPricing.s.sol +45 -0
- package/scripts/interactions/InteractAirdrop.s.sol +57 -0
- package/scripts/interactions/InteractAlphaPost.s.sol +32 -0
- package/scripts/interactions/InteractAlphaSparse.s.sol +173 -0
- package/scripts/interactions/InteractBaseAlpha.s.sol +84 -0
- package/scripts/interactions/InteractBaseBridge.s.sol +48 -0
- package/scripts/interactions/InteractBridgeLayerZero.s.sol +102 -0
- package/scripts/interactions/InteractClaimCondition.s.sol +56 -0
- package/scripts/interactions/InteractCreateSpace.s.sol +50 -0
- package/scripts/interactions/InteractDiamondCut.s.sol +47 -0
- package/scripts/interactions/InteractDropFacet.s.sol +32 -0
- package/scripts/interactions/InteractEnableNewSnapshotFormat.s.sol +27 -0
- package/scripts/interactions/InteractEnableNode2NodeAuth.s.sol +27 -0
- package/scripts/interactions/InteractMembership.s.sol +42 -0
- package/scripts/interactions/InteractMockERC721A.s.sol +20 -0
- package/scripts/interactions/InteractNodeOperators.s.sol +41 -0
- package/scripts/interactions/InteractPostDeploy.s.sol +59 -0
- package/scripts/interactions/InteractPrepay.s.sol +30 -0
- package/scripts/interactions/InteractRegisterApp.s.sol +61 -0
- package/scripts/interactions/InteractRiverAlpha.s.sol +30 -0
- package/scripts/interactions/InteractRiverAlphaSparse.s.sol +117 -0
- package/scripts/interactions/InteractRiverMainnet.s.sol +27 -0
- package/scripts/interactions/InteractRiverRegistry.s.sol +36 -0
- package/scripts/interactions/InteractRiverRegistrySetBlocklist.s.sol +30 -0
- package/scripts/interactions/InteractRiverRegistrySetFreq.s.sol +27 -0
- package/scripts/interactions/InteractRiverRegistrySetRepl.s.sol +30 -0
- package/scripts/interactions/InteractSetDefaultUri.s.sol +20 -0
- package/scripts/interactions/InteractSetDefaultUriLocalhost.s.sol +19 -0
- package/scripts/interactions/InteractTransferOwnership.s.sol +21 -0
- package/scripts/interactions/InteractUpdateMbRecencyCheck.s.sol +27 -0
- package/scripts/interactions/InteractUpdateMediaChunkCount.s.sol +27 -0
- package/scripts/interactions/InteractUpdateMediaChunkSize.s.sol +27 -0
- package/scripts/interactions/helpers/AlphaHelper.sol +149 -0
- package/scripts/interactions/helpers/RiverConfigValues.sol +22 -0
- package/scripts/interactions/interfaces/IL1StandardBridge.sol +35 -0
- package/scripts/interactions/interfaces/IL2StandardBridge.sol +69 -0
- package/src/airdrop/drop/DropBase.sol +210 -0
- package/src/airdrop/drop/DropClaim.sol +55 -0
- package/src/airdrop/drop/DropFacet.sol +176 -0
- package/src/airdrop/drop/DropGroup.sol +111 -0
- package/src/airdrop/drop/DropStorage.sol +23 -0
- package/src/airdrop/drop/IDropFacet.sol +136 -0
- package/src/airdrop/points/CheckIn.sol +71 -0
- package/src/airdrop/points/ITownsPoints.sol +64 -0
- package/src/airdrop/points/TownsPoints.sol +196 -0
- package/src/airdrop/points/TownsPointsStorage.sol +22 -0
- package/src/apps/BaseApp.sol +62 -0
- package/src/apps/ITownsApp.sol +28 -0
- package/src/apps/SchemaResolver.sol +170 -0
- package/src/apps/facets/attest/AttestationBase.sol +335 -0
- package/src/apps/facets/attest/AttestationLib.sol +64 -0
- package/src/apps/facets/attest/AttestationRegistry.sol +39 -0
- package/src/apps/facets/attest/AttestationStorage.sol +35 -0
- package/src/apps/facets/attest/IAttestationRegistry.sol +43 -0
- package/src/apps/facets/registry/AppRegistryBase.sol +403 -0
- package/src/apps/facets/registry/AppRegistryFacet.sol +173 -0
- package/src/apps/facets/registry/AppRegistryStorage.sol +53 -0
- package/src/apps/facets/registry/IAppRegistry.sol +159 -0
- package/src/apps/facets/schema/ISchema.sol +14 -0
- package/src/apps/facets/schema/SchemaBase.sol +88 -0
- package/src/apps/facets/schema/SchemaLib.sol +14 -0
- package/src/apps/facets/schema/SchemaRegistry.sol +51 -0
- package/src/apps/facets/schema/SchemaStorage.sol +34 -0
- package/src/apps/helpers/ISimpleApp.sol +51 -0
- package/src/apps/helpers/SimpleApp.sol +97 -0
- package/src/apps/helpers/SimpleAppStorage.sol +27 -0
- package/src/base/registry/facets/checker/EntitlementChecker.sol +237 -0
- package/src/base/registry/facets/checker/EntitlementCheckerStorage.sol +28 -0
- package/src/base/registry/facets/checker/IEntitlementChecker.sol +95 -0
- package/src/base/registry/facets/delegation/ISpaceDelegation.sol +69 -0
- package/src/base/registry/facets/delegation/SpaceDelegationFacet.sol +250 -0
- package/src/base/registry/facets/delegation/SpaceDelegationStorage.sol +35 -0
- package/src/base/registry/facets/distribution/v1/IRewardsDistribution.sol +51 -0
- package/src/base/registry/facets/distribution/v1/RewardsDistribution.sol +439 -0
- package/src/base/registry/facets/distribution/v1/RewardsDistributionStorage.sol +32 -0
- package/src/base/registry/facets/distribution/v2/DelegationProxy.sol +53 -0
- package/src/base/registry/facets/distribution/v2/IRewardsDistribution.sol +372 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionBase.sol +299 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionStorage.sol +37 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionV2.sol +392 -0
- package/src/base/registry/facets/distribution/v2/StakingRewards.sol +466 -0
- package/src/base/registry/facets/mainnet/ICrossDomainMessenger.sol +58 -0
- package/src/base/registry/facets/mainnet/IMainnetDelegation.sol +127 -0
- package/src/base/registry/facets/mainnet/MainnetDelegation.sol +119 -0
- package/src/base/registry/facets/mainnet/MainnetDelegationBase.sol +274 -0
- package/src/base/registry/facets/mainnet/MainnetDelegationStorage.sol +36 -0
- package/src/base/registry/facets/operator/INodeOperator.sol +91 -0
- package/src/base/registry/facets/operator/NodeOperatorFacet.sol +189 -0
- package/src/base/registry/facets/operator/NodeOperatorStorage.sol +39 -0
- package/src/base/registry/facets/xchain/IXChain.sol +54 -0
- package/src/base/registry/facets/xchain/XChain.sol +158 -0
- package/src/base/registry/facets/xchain/XChainCheckLib.sol +105 -0
- package/src/base/registry/facets/xchain/XChainLib.sol +46 -0
- package/src/diamond/facets/beacon/UpgradeableBeacon.sol +38 -0
- package/src/diamond/facets/beacon/UpgradeableBeaconFacet.sol +34 -0
- package/src/diamond/facets/governance/votes/Checkpoints.sol +642 -0
- package/src/diamond/facets/governance/votes/Votes.sol +63 -0
- package/src/diamond/facets/governance/votes/VotesBase.sol +274 -0
- package/src/diamond/facets/governance/votes/VotesStorage.sol +21 -0
- package/src/diamond/facets/governance/votes/enumerable/IVotesEnumerable.sol +38 -0
- package/src/diamond/facets/governance/votes/enumerable/VotesEnumerable.sol +39 -0
- package/src/diamond/facets/governance/votes/enumerable/VotesEnumerableLib.sol +102 -0
- package/src/diamond/facets/metadata/IMetadata.sol +27 -0
- package/src/diamond/facets/metadata/MetadataFacet.sol +71 -0
- package/src/diamond/facets/token/ERC5643/ERC5643.sol +51 -0
- package/src/diamond/facets/token/ERC5643/ERC5643Base.sol +48 -0
- package/src/diamond/facets/token/ERC5643/ERC5643Storage.sol +26 -0
- package/src/diamond/facets/token/ERC5643/IERC5643.sol +44 -0
- package/src/diamond/facets/token/ERC721A/ERC721A.sol +270 -0
- package/src/diamond/facets/token/ERC721A/ERC721ABase.sol +829 -0
- package/src/diamond/facets/token/ERC721A/ERC721ANonTransferable.sol +21 -0
- package/src/diamond/facets/token/ERC721A/ERC721AStorage.sol +115 -0
- package/src/diamond/facets/token/ERC721A/IERC721A.sol +283 -0
- package/src/diamond/facets/token/ERC721A/extensions/ERC721AQueryable.sol +134 -0
- package/src/diamond/facets/token/ERC721A/extensions/IERC721AQueryable.sol +83 -0
- package/src/diamond/utils/Context.sol +19 -0
- package/src/factory/SpaceFactoryInit.sol +17 -0
- package/src/factory/facets/architect/Architect.sol +98 -0
- package/src/factory/facets/architect/ArchitectBase.sol +95 -0
- package/src/factory/facets/architect/ArchitectStorage.sol +28 -0
- package/src/factory/facets/architect/IArchitect.sol +155 -0
- package/src/factory/facets/architect/ImplementationStorage.sol +42 -0
- package/src/factory/facets/architect/pricing/IPricingModules.sol +41 -0
- package/src/factory/facets/architect/pricing/PricingModulesBase.sol +89 -0
- package/src/factory/facets/architect/pricing/PricingModulesFacet.sol +40 -0
- package/src/factory/facets/architect/pricing/PricingModulesStorage.sol +30 -0
- package/src/factory/facets/create/CreateSpace.sol +107 -0
- package/src/factory/facets/create/CreateSpaceLib.sol +335 -0
- package/src/factory/facets/create/ICreateSpace.sol +70 -0
- package/src/factory/facets/feature/FeatureConditionLib.sol +53 -0
- package/src/factory/facets/feature/FeatureManagerFacet.sol +66 -0
- package/src/factory/facets/feature/FeatureManagerLib.sol +168 -0
- package/src/factory/facets/feature/IFeatureManagerFacet.sol +73 -0
- package/src/factory/facets/partner/IPartnerRegistry.sol +56 -0
- package/src/factory/facets/partner/PartnerRegistry.sol +57 -0
- package/src/factory/facets/partner/PartnerRegistryBase.sol +132 -0
- package/src/factory/facets/partner/PartnerRegistryStorage.sol +40 -0
- package/src/factory/facets/platform/requirements/IPlatformRequirements.sol +143 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsBase.sol +124 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsFacet.sol +122 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsStorage.sol +41 -0
- package/src/factory/facets/registry/IImplementationRegistry.sol +46 -0
- package/src/factory/facets/registry/ImplementationRegistry.sol +64 -0
- package/src/factory/facets/registry/ImplementationRegistryStorage.sol +28 -0
- package/src/factory/facets/wallet-link/IWalletLink.sol +218 -0
- package/src/factory/facets/wallet-link/WalletLink.sol +108 -0
- package/src/factory/facets/wallet-link/WalletLinkBase.sol +492 -0
- package/src/factory/facets/wallet-link/interfaces/IDelegateRegistry.sol +63 -0
- package/src/factory/facets/wallet-link/interfaces/IDelegateRegistryV1.sol +35 -0
- package/src/factory/facets/wallet-link/interfaces/ISCL_EIP6565.sol +24 -0
- package/src/factory/facets/wallet-link/libraries/SolanaUtils.sol +161 -0
- package/src/factory/facets/wallet-link/libraries/WalletLib.sol +62 -0
- package/src/river/registry/facets/config/IRiverConfig.sol +117 -0
- package/src/river/registry/facets/config/RiverConfig.sol +174 -0
- package/src/river/registry/facets/node/INodeRegistry.sol +69 -0
- package/src/river/registry/facets/node/NodeRegistry.sol +143 -0
- package/src/river/registry/facets/operator/IOperatorRegistry.sol +28 -0
- package/src/river/registry/facets/operator/OperatorRegistry.sol +86 -0
- package/src/river/registry/facets/stream/IStreamRegistry.sol +184 -0
- package/src/river/registry/facets/stream/StreamRegistry.sol +396 -0
- package/src/river/registry/libraries/RegistryErrors.sol +24 -0
- package/src/river/registry/libraries/RegistryStorage.sol +181 -0
- package/src/router/ISwapRouter.sol +226 -0
- package/src/router/Permit2Hash.sol +92 -0
- package/src/router/SwapRouter.sol +463 -0
- package/src/router/SwapRouterStorage.sol +21 -0
- package/src/spaces/entitlements/ICrossChainEntitlement.sol +22 -0
- package/src/spaces/entitlements/IEntitlement.sol +61 -0
- package/src/spaces/entitlements/PolymarketEntitlement.sol +79 -0
- package/src/spaces/entitlements/poap/IPOAP.sol +26 -0
- package/src/spaces/entitlements/poap/PoapEntitlement.sol +56 -0
- package/src/spaces/entitlements/rule/IRuleEntitlement.sol +174 -0
- package/src/spaces/entitlements/rule/RuleEntitlement.sol +183 -0
- package/src/spaces/entitlements/rule/RuleEntitlementV2.sol +219 -0
- package/src/spaces/entitlements/user/IUserEntitlement.sol +24 -0
- package/src/spaces/entitlements/user/UserEntitlement.sol +273 -0
- package/src/spaces/facets/DependencyLib.sol +60 -0
- package/src/spaces/facets/Entitled.sol +172 -0
- package/src/spaces/facets/Permissions.sol +21 -0
- package/src/spaces/facets/account/AppAccount.sol +93 -0
- package/src/spaces/facets/account/AppAccountBase.sol +275 -0
- package/src/spaces/facets/account/AppAccountStorage.sol +63 -0
- package/src/spaces/facets/account/IAppAccount.sol +71 -0
- package/src/spaces/facets/account/SignerFacet.sol +26 -0
- package/src/spaces/facets/banning/Banning.sol +41 -0
- package/src/spaces/facets/banning/BanningBase.sol +33 -0
- package/src/spaces/facets/banning/BanningStorage.sol +23 -0
- package/src/spaces/facets/banning/IBanning.sol +35 -0
- package/src/spaces/facets/channels/ChannelBase.sol +87 -0
- package/src/spaces/facets/channels/ChannelService.sol +177 -0
- package/src/spaces/facets/channels/ChannelStorage.sol +34 -0
- package/src/spaces/facets/channels/Channels.sol +80 -0
- package/src/spaces/facets/channels/IChannel.sol +98 -0
- package/src/spaces/facets/dispatcher/DispatcherBase.sol +86 -0
- package/src/spaces/facets/dispatcher/DispatcherStorage.sol +21 -0
- package/src/spaces/facets/dispatcher/IDispatcher.sol +6 -0
- package/src/spaces/facets/entitlements/EntitlementsManager.sol +49 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerBase.sol +87 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerService.sol +142 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerStorage.sol +34 -0
- package/src/spaces/facets/entitlements/IEntitlementsManager.sol +67 -0
- package/src/spaces/facets/entitlements/extensions/EntitlementDataQueryable.sol +153 -0
- package/src/spaces/facets/entitlements/extensions/IEntitlementDataQueryable.sol +32 -0
- package/src/spaces/facets/executor/ExecutorBase.sol +564 -0
- package/src/spaces/facets/executor/ExecutorFacet.sol +178 -0
- package/src/spaces/facets/executor/ExecutorStorage.sol +99 -0
- package/src/spaces/facets/executor/GroupLib.sol +128 -0
- package/src/spaces/facets/executor/IExecutor.sol +287 -0
- package/src/spaces/facets/executor/hooks/HookBase.sol +172 -0
- package/src/spaces/facets/executor/hooks/HookLib.sol +38 -0
- package/src/spaces/facets/executor/hooks/IHookBase.sol +48 -0
- package/src/spaces/facets/gated/EntitlementGated.sol +59 -0
- package/src/spaces/facets/gated/EntitlementGatedBase.sol +324 -0
- package/src/spaces/facets/gated/EntitlementGatedStorage.sol +29 -0
- package/src/spaces/facets/gated/IEntitlementGated.sol +55 -0
- package/src/spaces/facets/guardian/GuardianBase.sol +80 -0
- package/src/spaces/facets/guardian/GuardianFacet.sol +43 -0
- package/src/spaces/facets/guardian/GuardianStorage.sol +27 -0
- package/src/spaces/facets/guardian/IGuardian.sol +54 -0
- package/src/spaces/facets/membership/IMembership.sol +216 -0
- package/src/spaces/facets/membership/MembershipBase.sol +272 -0
- package/src/spaces/facets/membership/MembershipFacet.sol +191 -0
- package/src/spaces/facets/membership/MembershipStorage.sol +40 -0
- package/src/spaces/facets/membership/join/MembershipJoin.sol +547 -0
- package/src/spaces/facets/membership/metadata/IMembershipMetadata.sol +9 -0
- package/src/spaces/facets/membership/metadata/MembershipMetadata.sol +32 -0
- package/src/spaces/facets/membership/pricing/IMembershipPricing.sol +18 -0
- package/src/spaces/facets/membership/pricing/fixed/FixedPricing.sol +29 -0
- package/src/spaces/facets/membership/pricing/fixed/FixedPricingStorage.sol +27 -0
- package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV2.sol +148 -0
- package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV3.sol +137 -0
- package/src/spaces/facets/membership/token/MembershipToken.sol +25 -0
- package/src/spaces/facets/owner/ISpaceOwner.sol +85 -0
- package/src/spaces/facets/owner/SpaceOwner.sol +174 -0
- package/src/spaces/facets/owner/SpaceOwnerBase.sol +121 -0
- package/src/spaces/facets/owner/SpaceOwnerStorage.sol +41 -0
- package/src/spaces/facets/owner/SpaceOwnerUriBase.sol +54 -0
- package/src/spaces/facets/points/PointsBase.sol +35 -0
- package/src/spaces/facets/prepay/IPrepay.sol +43 -0
- package/src/spaces/facets/prepay/PrepayBase.sol +27 -0
- package/src/spaces/facets/prepay/PrepayFacet.sol +59 -0
- package/src/spaces/facets/prepay/PrepayStorage.sol +26 -0
- package/src/spaces/facets/proxy/ISpaceProxyInitializer.sol +21 -0
- package/src/spaces/facets/proxy/SpaceProxy.sol +15 -0
- package/src/spaces/facets/proxy/SpaceProxyInitializer.sol +55 -0
- package/src/spaces/facets/referrals/IReferrals.sol +98 -0
- package/src/spaces/facets/referrals/ReferralsBase.sol +81 -0
- package/src/spaces/facets/referrals/ReferralsFacet.sol +65 -0
- package/src/spaces/facets/referrals/ReferralsStorage.sol +36 -0
- package/src/spaces/facets/review/IReview.sol +50 -0
- package/src/spaces/facets/review/ReviewFacet.sol +105 -0
- package/src/spaces/facets/review/ReviewStorage.sol +29 -0
- package/src/spaces/facets/roles/IRoles.sol +197 -0
- package/src/spaces/facets/roles/Roles.sol +123 -0
- package/src/spaces/facets/roles/RolesBase.sol +420 -0
- package/src/spaces/facets/roles/RolesStorage.sol +132 -0
- package/src/spaces/facets/swap/ISwapFacet.sol +91 -0
- package/src/spaces/facets/swap/SwapFacet.sol +290 -0
- package/src/spaces/facets/swap/SwapFacetStorage.sol +24 -0
- package/src/spaces/facets/tipping/ITipping.sol +80 -0
- package/src/spaces/facets/tipping/TippingBase.sol +73 -0
- package/src/spaces/facets/tipping/TippingFacet.sol +123 -0
- package/src/spaces/facets/treasury/ITreasury.sol +64 -0
- package/src/spaces/facets/treasury/Treasury.sol +82 -0
- package/src/spaces/facets/xchain/SpaceEntitlementGated.sol +62 -0
- package/src/tokens/Member.sol +246 -0
- package/src/tokens/lock/ILock.sol +42 -0
- package/src/tokens/lock/LockBase.sol +64 -0
- package/src/tokens/lock/LockFacet.sol +44 -0
- package/src/tokens/lock/LockStorage.sol +26 -0
- package/src/tokens/mainnet/claimer/AuthorizedClaimerStorage.sol +26 -0
- package/src/tokens/mainnet/claimer/AuthorizedClaimers.sol +84 -0
- package/src/tokens/mainnet/claimer/IAuthorizedClaimers.sol +36 -0
- package/src/tokens/mainnet/delegation/ProxyBatchDelegation.sol +86 -0
- package/src/tokens/migration/ITokenMigration.sol +35 -0
- package/src/tokens/migration/TokenMigrationFacet.sol +86 -0
- package/src/tokens/migration/TokenMigrationStorage.sol +27 -0
- package/src/tokens/towns/base/IERC7802.sol +30 -0
- package/src/tokens/towns/base/IOptimismMintableERC20.sol +31 -0
- package/src/tokens/towns/base/ISemver.sol +13 -0
- package/src/tokens/towns/base/Towns.sol +283 -0
- package/src/tokens/towns/base/TownsDeployer.sol +32 -0
- package/src/tokens/towns/base/TownsLib.sol +31 -0
- package/src/tokens/towns/base/versions/TownsV2.sol +15 -0
- package/src/tokens/towns/mainnet/ITowns.sol +56 -0
- package/src/tokens/towns/mainnet/Towns.sol +220 -0
- package/src/tokens/towns/mainnet/libs/TokenInflationLib.sol +89 -0
- package/src/tokens/towns/multichain/Towns.sol +19 -0
- package/src/tokens/towns/multichain/wTowns.sol +18 -0
- package/src/utils/Airdrop.sol +156 -0
- package/src/utils/airdrop/merkle/IMerkleAirdrop.sol +55 -0
- package/src/utils/airdrop/merkle/MerkleAirdrop.sol +118 -0
- package/src/utils/airdrop/merkle/MerkleAirdropStorage.sol +29 -0
- package/src/utils/interfaces/AggregatorV3Interface.sol +37 -0
- package/src/utils/interfaces/IMulticall.sol +10 -0
- package/src/utils/interfaces/IWETH.sol +10 -0
- package/src/utils/libraries/BasisPoints.sol +24 -0
- package/src/utils/libraries/Create2Utils.sol +74 -0
- package/src/utils/libraries/CurrencyTransfer.sol +99 -0
- package/src/utils/libraries/CustomRevert.sol +49 -0
- package/src/utils/libraries/Factory.sol +66 -0
- package/src/utils/libraries/StringSet.sol +190 -0
- package/src/utils/libraries/Validator.sol +31 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.18;
|
|
3
|
+
|
|
4
|
+
import {StakingRewards} from "./StakingRewards.sol";
|
|
5
|
+
|
|
6
|
+
interface IRewardsDistributionBase {
|
|
7
|
+
/// @notice The state of the staking rewards contract
|
|
8
|
+
/// @param riverToken The token that is being staked and used for rewards
|
|
9
|
+
/// @param totalStaked The total amount of stakeToken that is staked
|
|
10
|
+
/// @param rewardDuration The duration of the reward distribution
|
|
11
|
+
/// @param rewardEndTime The time at which the reward distribution ends
|
|
12
|
+
/// @param lastUpdateTime The time at which the reward was last updated
|
|
13
|
+
/// @param rewardRate The scaled rate of reward distributed per second
|
|
14
|
+
/// @param rewardPerTokenAccumulated The scaled amount of rewardToken that has been accumulated
|
|
15
|
+
/// per staked token
|
|
16
|
+
/// @param nextDepositId The next deposit ID that will be used
|
|
17
|
+
struct StakingState {
|
|
18
|
+
address riverToken;
|
|
19
|
+
uint96 totalStaked;
|
|
20
|
+
uint256 rewardDuration;
|
|
21
|
+
uint256 rewardEndTime;
|
|
22
|
+
uint256 lastUpdateTime;
|
|
23
|
+
uint256 rewardRate;
|
|
24
|
+
uint256 rewardPerTokenAccumulated;
|
|
25
|
+
uint256 nextDepositId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
29
|
+
/* CUSTOM ERRORS */
|
|
30
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
31
|
+
|
|
32
|
+
/// @dev Self-explanatory
|
|
33
|
+
error RewardsDistribution__NotBeneficiary();
|
|
34
|
+
error RewardsDistribution__NotClaimer();
|
|
35
|
+
error RewardsDistribution__NotDepositOwner();
|
|
36
|
+
error RewardsDistribution__NotRewardNotifier();
|
|
37
|
+
error RewardsDistribution__NotOperatorOrSpace();
|
|
38
|
+
error RewardsDistribution__NotActiveOperator();
|
|
39
|
+
error RewardsDistribution__ExpiredDeadline();
|
|
40
|
+
error RewardsDistribution__InvalidSignature();
|
|
41
|
+
error RewardsDistribution__CannotWithdrawFromSelf();
|
|
42
|
+
error RewardsDistribution__NoPendingWithdrawal();
|
|
43
|
+
|
|
44
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
45
|
+
/* EVENTS */
|
|
46
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
47
|
+
|
|
48
|
+
/// @notice Emitted when the rewards distribution facet is initialized
|
|
49
|
+
/// @param stakeToken The token that is being staked
|
|
50
|
+
/// @param rewardToken The token that is being distributed as rewards
|
|
51
|
+
/// @param rewardDuration The duration of each reward distribution period
|
|
52
|
+
event RewardsDistributionInitialized(
|
|
53
|
+
address stakeToken,
|
|
54
|
+
address rewardToken,
|
|
55
|
+
uint256 rewardDuration
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/// @notice Emitted when a delegation proxy is deployed
|
|
59
|
+
/// @param depositId The ID of the deposit
|
|
60
|
+
/// @param delegatee The address of the delegatee
|
|
61
|
+
/// @param proxy The address of the delegation proxy
|
|
62
|
+
event DelegationProxyDeployed(
|
|
63
|
+
uint256 indexed depositId,
|
|
64
|
+
address indexed delegatee,
|
|
65
|
+
address proxy
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
/// @notice Emitted when a reward notifier is set
|
|
69
|
+
/// @param notifier The address of the notifier
|
|
70
|
+
/// @param enabled The whitelist status
|
|
71
|
+
event RewardNotifierSet(address indexed notifier, bool enabled);
|
|
72
|
+
|
|
73
|
+
/// @notice Emitted when the reward amount for a period is set
|
|
74
|
+
/// @param amount The amount of rewardToken to distribute
|
|
75
|
+
event PeriodRewardAmountSet(uint256 amount);
|
|
76
|
+
|
|
77
|
+
/// @notice Emitted when a deposit is staked
|
|
78
|
+
/// @param owner The address of the depositor
|
|
79
|
+
/// @param delegatee The address of the delegatee
|
|
80
|
+
/// @param beneficiary The address of the beneficiary
|
|
81
|
+
/// @param depositId The ID of the deposit
|
|
82
|
+
/// @param amount The amount of stakeToken that is staked
|
|
83
|
+
event Stake(
|
|
84
|
+
address indexed owner,
|
|
85
|
+
address indexed delegatee,
|
|
86
|
+
address indexed beneficiary,
|
|
87
|
+
uint256 depositId,
|
|
88
|
+
uint96 amount
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
/// @notice Emitted when the stake of a deposit is increased
|
|
92
|
+
/// @param depositId The ID of the deposit
|
|
93
|
+
/// @param amount The amount of stakeToken that is staked
|
|
94
|
+
event IncreaseStake(uint256 indexed depositId, uint96 amount);
|
|
95
|
+
|
|
96
|
+
/// @notice Emitted when a deposit is redelegated
|
|
97
|
+
/// @param depositId The ID of the deposit
|
|
98
|
+
/// @param delegatee The address of the delegatee
|
|
99
|
+
event Redelegate(uint256 indexed depositId, address indexed delegatee);
|
|
100
|
+
|
|
101
|
+
/// @notice Emitted when the beneficiary of a deposit is changed
|
|
102
|
+
/// @param depositId The ID of the deposit
|
|
103
|
+
/// @param newBeneficiary The address of the new beneficiary
|
|
104
|
+
event ChangeBeneficiary(uint256 indexed depositId, address indexed newBeneficiary);
|
|
105
|
+
|
|
106
|
+
/// @notice Emitted when the withdrawal of a deposit is initiated
|
|
107
|
+
/// @param owner The address of the depositor
|
|
108
|
+
/// @param depositId The ID of the deposit
|
|
109
|
+
/// @param amount The amount of stakeToken that will be withdrawn
|
|
110
|
+
event InitiateWithdraw(address indexed owner, uint256 indexed depositId, uint96 amount);
|
|
111
|
+
|
|
112
|
+
/// @notice Emitted when the stakeToken is withdrawn from a deposit
|
|
113
|
+
/// @param depositId The ID of the deposit
|
|
114
|
+
/// @param amount The amount of stakeToken that is withdrawn
|
|
115
|
+
event Withdraw(uint256 indexed depositId, uint96 amount);
|
|
116
|
+
|
|
117
|
+
/// @notice Emitted when a reward is claimed
|
|
118
|
+
/// @param beneficiary The address of the beneficiary whose reward is claimed
|
|
119
|
+
/// @param recipient The address of the recipient where the reward is sent
|
|
120
|
+
/// @param reward The amount of rewardToken that is claimed
|
|
121
|
+
event ClaimReward(address indexed beneficiary, address indexed recipient, uint256 reward);
|
|
122
|
+
|
|
123
|
+
/// @notice Emitted when a reward is notified
|
|
124
|
+
/// @param notifier The address of the notifier
|
|
125
|
+
/// @param reward The amount of rewardToken that is added
|
|
126
|
+
event NotifyRewardAmount(address indexed notifier, uint256 reward);
|
|
127
|
+
|
|
128
|
+
/// @notice Emitted when space delegation rewards are swept to the operator
|
|
129
|
+
/// @param space The address of the space
|
|
130
|
+
/// @param operator The address of the operator
|
|
131
|
+
/// @param scaledReward The scaled amount of rewardToken that is swept
|
|
132
|
+
event SpaceRewardsSwept(address indexed space, address indexed operator, uint256 scaledReward);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// @title IRewardsDistribution
|
|
136
|
+
/// @notice The interface for the rewards distribution facet
|
|
137
|
+
interface IRewardsDistribution is IRewardsDistributionBase {
|
|
138
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
139
|
+
/* ADMIN FUNCTIONS */
|
|
140
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
141
|
+
|
|
142
|
+
/// @notice Upgrades the delegation proxy implementation in the beacon
|
|
143
|
+
/// @dev Only the owner can call this function
|
|
144
|
+
/// @param newImplementation The address of the new implementation
|
|
145
|
+
function upgradeDelegationProxy(address newImplementation) external;
|
|
146
|
+
|
|
147
|
+
/// @notice Sets whitelist status for reward notifiers
|
|
148
|
+
/// @dev Only the owner can call this function
|
|
149
|
+
/// @param notifier The address of the notifier
|
|
150
|
+
/// @param enabled The whitelist status
|
|
151
|
+
function setRewardNotifier(address notifier, bool enabled) external;
|
|
152
|
+
|
|
153
|
+
/// @notice Sets the reward amount for a period
|
|
154
|
+
/// @dev Only the owner can call this function
|
|
155
|
+
/// @param amount The amount of rewardToken to distribute
|
|
156
|
+
function setPeriodRewardAmount(uint256 amount) external;
|
|
157
|
+
|
|
158
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
159
|
+
/* STATE MUTATING */
|
|
160
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
161
|
+
|
|
162
|
+
/// @notice Stakes the stakeToken for rewards
|
|
163
|
+
/// @dev The caller must approve the contract to spend the stakeToken
|
|
164
|
+
/// @param amount The amount of stakeToken to stake
|
|
165
|
+
/// @param delegatee The address of the delegatee
|
|
166
|
+
/// @param beneficiary The address of the beneficiary who is receiving the rewards
|
|
167
|
+
/// @return depositId The ID of the deposit
|
|
168
|
+
function stake(
|
|
169
|
+
uint96 amount,
|
|
170
|
+
address delegatee,
|
|
171
|
+
address beneficiary
|
|
172
|
+
) external returns (uint256 depositId);
|
|
173
|
+
|
|
174
|
+
/// @notice Approves the contract to spend the stakeToken with Permit2 and stakes the
|
|
175
|
+
/// stakeToken for rewards
|
|
176
|
+
/// @param amount The amount of stakeToken to stake
|
|
177
|
+
/// @param delegatee The address of the delegatee
|
|
178
|
+
/// @param beneficiary The address of the beneficiary who is receiving the rewards
|
|
179
|
+
/// @param nonce The nonce for the permit
|
|
180
|
+
/// @param deadline The deadline for the permit
|
|
181
|
+
/// @param signature The signature for the permit
|
|
182
|
+
/// @return depositId The ID of the deposit
|
|
183
|
+
function permitAndStake(
|
|
184
|
+
uint96 amount,
|
|
185
|
+
address delegatee,
|
|
186
|
+
address beneficiary,
|
|
187
|
+
uint256 nonce,
|
|
188
|
+
uint256 deadline,
|
|
189
|
+
bytes calldata signature
|
|
190
|
+
) external returns (uint256 depositId);
|
|
191
|
+
|
|
192
|
+
/// @notice Stakes on behalf of a user with an EIP-712 signature
|
|
193
|
+
/// @dev The caller must approve the contract to spend the stakeToken
|
|
194
|
+
/// @param amount The amount of stakeToken to stake
|
|
195
|
+
/// @param delegatee The address of the delegatee
|
|
196
|
+
/// @param beneficiary The address of the beneficiary who is receiving the rewards
|
|
197
|
+
/// @param owner The address of the deposit owner
|
|
198
|
+
/// @return depositId The ID of the deposit
|
|
199
|
+
function stakeOnBehalf(
|
|
200
|
+
uint96 amount,
|
|
201
|
+
address delegatee,
|
|
202
|
+
address beneficiary,
|
|
203
|
+
address owner,
|
|
204
|
+
uint256,
|
|
205
|
+
bytes calldata
|
|
206
|
+
) external returns (uint256 depositId);
|
|
207
|
+
|
|
208
|
+
/// @notice Increases the stake of an existing deposit
|
|
209
|
+
/// @dev The caller must be the owner of the deposit
|
|
210
|
+
/// @dev The caller must approve the contract to spend the stakeToken
|
|
211
|
+
/// @param depositId The ID of the deposit
|
|
212
|
+
/// @param amount The amount of stakeToken to stake
|
|
213
|
+
function increaseStake(uint256 depositId, uint96 amount) external;
|
|
214
|
+
|
|
215
|
+
/// @notice Approves the contract to spend the stakeToken with Permit2 and increases
|
|
216
|
+
/// the stake of an existing deposit
|
|
217
|
+
/// @dev The caller must be the owner of the deposit
|
|
218
|
+
/// @param depositId The ID of the deposit
|
|
219
|
+
/// @param amount The amount of stakeToken to stake
|
|
220
|
+
/// @param nonce The nonce for the permit
|
|
221
|
+
/// @param deadline The deadline for the permit
|
|
222
|
+
/// @param signature The signature for the permit
|
|
223
|
+
function permitAndIncreaseStake(
|
|
224
|
+
uint256 depositId,
|
|
225
|
+
uint96 amount,
|
|
226
|
+
uint256 nonce,
|
|
227
|
+
uint256 deadline,
|
|
228
|
+
bytes calldata signature
|
|
229
|
+
) external;
|
|
230
|
+
|
|
231
|
+
/// @notice Redelegates an existing deposit to a new delegatee or reactivates a pending
|
|
232
|
+
/// withdrawal
|
|
233
|
+
/// @dev The caller must be the owner of the deposit
|
|
234
|
+
/// @param depositId The ID of the deposit
|
|
235
|
+
/// @param delegatee The address of the new delegatee
|
|
236
|
+
function redelegate(uint256 depositId, address delegatee) external;
|
|
237
|
+
|
|
238
|
+
/// @notice Changes the beneficiary of a deposit
|
|
239
|
+
/// @dev The caller must be the owner of the deposit
|
|
240
|
+
/// @param depositId The ID of the deposit
|
|
241
|
+
/// @param newBeneficiary The address of the new beneficiary
|
|
242
|
+
function changeBeneficiary(uint256 depositId, address newBeneficiary) external;
|
|
243
|
+
|
|
244
|
+
/// @notice Initiates the withdrawal of a deposit, subject to the lockup period
|
|
245
|
+
/// @dev The caller must be the owner of the deposit
|
|
246
|
+
/// @param depositId The ID of the deposit
|
|
247
|
+
/// @return amount The amount of stakeToken that will be withdrawn
|
|
248
|
+
function initiateWithdraw(uint256 depositId) external returns (uint96 amount);
|
|
249
|
+
|
|
250
|
+
/// @notice Withdraws the stakeToken from a deposit
|
|
251
|
+
/// @dev The caller must be the owner of the deposit
|
|
252
|
+
/// @param depositId The ID of the deposit
|
|
253
|
+
/// @return amount The amount of stakeToken that is withdrawn
|
|
254
|
+
function withdraw(uint256 depositId) external returns (uint96 amount);
|
|
255
|
+
|
|
256
|
+
/// @notice Claims accumulated rewards for a beneficiary and sends them to a recipient
|
|
257
|
+
///
|
|
258
|
+
/// @dev **For Regular Users (Stakers):**
|
|
259
|
+
/// - Call with `beneficiary = your_address` to claim your own staking rewards
|
|
260
|
+
/// - You can send rewards to any `recipient` address (yourself or someone else)
|
|
261
|
+
///
|
|
262
|
+
/// @dev **For Node Operators:**
|
|
263
|
+
/// - Operators earn commission from delegated stakes and can claim their own operator rewards
|
|
264
|
+
/// - Call with `beneficiary = operator_address` to claim operator commission rewards
|
|
265
|
+
/// - Only the operator's designated claimer can call this function for the operator
|
|
266
|
+
///
|
|
267
|
+
/// @dev **For Space Rewards:**
|
|
268
|
+
/// - Spaces accumulate rewards from users who delegate to them
|
|
269
|
+
/// - Only the space's current operator's claimer can claim space rewards
|
|
270
|
+
/// - Call with `beneficiary = space_address` to claim rewards accumulated by the space
|
|
271
|
+
/// - Space rewards are automatically transferred to the operator when claimed
|
|
272
|
+
///
|
|
273
|
+
/// @dev **Authorization Rules:**
|
|
274
|
+
/// 1. Self-claim: Anyone can claim their own rewards (`msg.sender == beneficiary`)
|
|
275
|
+
/// 2. Authorized claimer: If you're set as the authorized claimer for a beneficiary
|
|
276
|
+
/// 3. Operator claimer: Only operator's claimer can claim operator rewards
|
|
277
|
+
/// 4. Space operator claimer: Only the space's operator's claimer can claim space rewards
|
|
278
|
+
///
|
|
279
|
+
/// @param beneficiary The address whose rewards are being claimed (user, operator, or space)
|
|
280
|
+
/// @param recipient The address where the claimed reward tokens will be sent
|
|
281
|
+
/// @return reward The amount of reward tokens claimed and transferred
|
|
282
|
+
function claimReward(address beneficiary, address recipient) external returns (uint256 reward);
|
|
283
|
+
|
|
284
|
+
/// @notice Notifies the contract of an incoming reward
|
|
285
|
+
/// @dev The caller must be a reward notifier
|
|
286
|
+
/// @param reward The amount of rewardToken that has been added
|
|
287
|
+
function notifyRewardAmount(uint256 reward) external;
|
|
288
|
+
|
|
289
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
290
|
+
/* GETTERS */
|
|
291
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
292
|
+
|
|
293
|
+
/// @notice Returns the current state of the staking rewards contract
|
|
294
|
+
/// @return Staking state variables
|
|
295
|
+
/// riverToken The token that is being staked and used for rewards
|
|
296
|
+
/// totalStaked The total amount of stakeToken that is staked
|
|
297
|
+
/// rewardDuration The duration of the reward distribution
|
|
298
|
+
/// rewardEndTime The time at which the reward distribution ends
|
|
299
|
+
/// lastUpdateTime The time at which the reward was last updated
|
|
300
|
+
/// rewardRate The scaled rate of reward distributed per second
|
|
301
|
+
/// rewardPerTokenAccumulated The scaled amount of rewardToken that has been accumulated per
|
|
302
|
+
/// staked token
|
|
303
|
+
/// nextDepositId The next deposit ID that will be used
|
|
304
|
+
function stakingState() external view returns (StakingState memory);
|
|
305
|
+
|
|
306
|
+
/// @notice Returns the amount of stakeToken that is staked by a particular depositor
|
|
307
|
+
/// @param depositor The address of the depositor
|
|
308
|
+
/// @return amount The amount of stakeToken that is staked by the depositor
|
|
309
|
+
function stakedByDepositor(address depositor) external view returns (uint96 amount);
|
|
310
|
+
|
|
311
|
+
/// @notice Returns the deposit IDs for a particular depositor
|
|
312
|
+
/// @param depositor The address of the depositor
|
|
313
|
+
/// @return The deposit IDs for the depositor
|
|
314
|
+
function getDepositsByDepositor(address depositor) external view returns (uint256[] memory);
|
|
315
|
+
|
|
316
|
+
/// @notice Returns the account information for a beneficiary
|
|
317
|
+
/// @param beneficiary The address of the beneficiary
|
|
318
|
+
/// @return The account information for the beneficiary
|
|
319
|
+
/// earningPower The amount of stakeToken that is yielding rewards
|
|
320
|
+
/// rewardPerTokenAccumulated The scaled amount of rewardToken that has been accumulated per
|
|
321
|
+
/// staked token
|
|
322
|
+
/// unclaimedRewardSnapshot The snapshot of the unclaimed reward scaled
|
|
323
|
+
function treasureByBeneficiary(
|
|
324
|
+
address beneficiary
|
|
325
|
+
) external view returns (StakingRewards.Treasure memory);
|
|
326
|
+
|
|
327
|
+
/// @notice Returns the information for a deposit
|
|
328
|
+
/// @param depositId The ID of the deposit
|
|
329
|
+
/// @return The information for the deposit
|
|
330
|
+
/// amount The amount of stakeToken that is staked
|
|
331
|
+
/// owner The address of the depositor
|
|
332
|
+
/// commissionEarningPower The amount of stakeToken assigned to the commission
|
|
333
|
+
/// delegatee The address of the delegatee
|
|
334
|
+
/// pendingWithdrawal The amount of stakeToken that is pending withdrawal
|
|
335
|
+
/// beneficiary The address of the beneficiary
|
|
336
|
+
function depositById(uint256 depositId) external view returns (StakingRewards.Deposit memory);
|
|
337
|
+
|
|
338
|
+
/// @notice Returns the address of the delegation proxy for a deposit
|
|
339
|
+
/// @param depositId The ID of the deposit
|
|
340
|
+
/// @return The address of the delegation proxy
|
|
341
|
+
function delegationProxyById(uint256 depositId) external view returns (address);
|
|
342
|
+
|
|
343
|
+
/// @notice Returns whether a particular address is a reward notifier
|
|
344
|
+
/// @param notifier The address to check
|
|
345
|
+
/// @return True if the address is a reward notifier
|
|
346
|
+
function isRewardNotifier(address notifier) external view returns (bool);
|
|
347
|
+
|
|
348
|
+
/// @notice Returns the lesser of rewardEndTime and the current time
|
|
349
|
+
/// @return The lesser of rewardEndTime and the current time
|
|
350
|
+
function lastTimeRewardDistributed() external view returns (uint256);
|
|
351
|
+
|
|
352
|
+
/// @notice Returns the current scaled amount of rewardToken that has been accumulated per
|
|
353
|
+
/// staked token
|
|
354
|
+
/// @return The current scaled amount of rewardToken that has been accumulated per staked token
|
|
355
|
+
function currentRewardPerTokenAccumulated() external view returns (uint256);
|
|
356
|
+
|
|
357
|
+
/// @notice Returns the current unclaimed reward for a beneficiary
|
|
358
|
+
/// @param beneficiary The address of the beneficiary who is receiving the rewards
|
|
359
|
+
/// @return The current unclaimed reward for the beneficiary
|
|
360
|
+
function currentReward(address beneficiary) external view returns (uint256);
|
|
361
|
+
|
|
362
|
+
/// @notice Returns the current unclaimed reward for an operator from delegating spaces
|
|
363
|
+
/// @param operator The address of the operator
|
|
364
|
+
/// @return The current unclaimed reward for the operator from delegating spaces
|
|
365
|
+
function currentSpaceDelegationReward(address operator) external view returns (uint256);
|
|
366
|
+
|
|
367
|
+
/// @notice Returns the implementation stored in the beacon
|
|
368
|
+
function implementation() external view returns (address);
|
|
369
|
+
|
|
370
|
+
/// @notice Returns the period reward amount
|
|
371
|
+
function getPeriodRewardAmount() external view returns (uint256);
|
|
372
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IRewardsDistributionBase} from "./IRewardsDistribution.sol";
|
|
6
|
+
import {ISignatureTransfer} from "@uniswap/permit2/src/interfaces/ISignatureTransfer.sol";
|
|
7
|
+
|
|
8
|
+
// libraries
|
|
9
|
+
import {CustomRevert} from "../../../../../utils/libraries/CustomRevert.sol";
|
|
10
|
+
import {SpaceDelegationStorage} from "../../delegation/SpaceDelegationStorage.sol";
|
|
11
|
+
import {NodeOperatorStatus, NodeOperatorStorage} from "../../operator/NodeOperatorStorage.sol";
|
|
12
|
+
import {RewardsDistributionStorage} from "./RewardsDistributionStorage.sol";
|
|
13
|
+
import {StakingRewards} from "./StakingRewards.sol";
|
|
14
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
15
|
+
import {FixedPointMathLib} from "solady/utils/FixedPointMathLib.sol";
|
|
16
|
+
import {LibClone} from "solady/utils/LibClone.sol";
|
|
17
|
+
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
|
|
18
|
+
import {SignatureCheckerLib} from "solady/utils/SignatureCheckerLib.sol";
|
|
19
|
+
|
|
20
|
+
// contracts
|
|
21
|
+
import {DelegationProxy} from "./DelegationProxy.sol";
|
|
22
|
+
|
|
23
|
+
abstract contract RewardsDistributionBase is IRewardsDistributionBase {
|
|
24
|
+
using CustomRevert for bytes4;
|
|
25
|
+
using EnumerableSet for EnumerableSet.AddressSet;
|
|
26
|
+
using EnumerableSet for EnumerableSet.UintSet;
|
|
27
|
+
using SafeTransferLib for address;
|
|
28
|
+
using StakingRewards for StakingRewards.Layout;
|
|
29
|
+
|
|
30
|
+
/// @notice Universal Permit2 contract address
|
|
31
|
+
address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
|
|
32
|
+
|
|
33
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
34
|
+
/* STAKING */
|
|
35
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
36
|
+
|
|
37
|
+
/// @notice Creates a new staking deposit for the specified owner
|
|
38
|
+
/// @dev Validates delegatee, deploys proxy, transfers tokens, and updates accounting
|
|
39
|
+
/// @param amount Amount of stake tokens to deposit
|
|
40
|
+
/// @param delegatee Address to delegate to (operator or space)
|
|
41
|
+
/// @param beneficiary Address that receives staking rewards
|
|
42
|
+
/// @param owner Address that owns the deposit
|
|
43
|
+
/// @param fromPermit Whether tokens are already in contract from permit
|
|
44
|
+
/// @return depositId The unique ID for this deposit
|
|
45
|
+
function _stake(
|
|
46
|
+
uint96 amount,
|
|
47
|
+
address delegatee,
|
|
48
|
+
address beneficiary,
|
|
49
|
+
address owner,
|
|
50
|
+
bool fromPermit
|
|
51
|
+
) internal returns (uint256 depositId) {
|
|
52
|
+
_revertIfNotOperatorOrSpace(delegatee);
|
|
53
|
+
|
|
54
|
+
RewardsDistributionStorage.Layout storage ds = RewardsDistributionStorage.layout();
|
|
55
|
+
depositId = ds.staking.stake(
|
|
56
|
+
owner,
|
|
57
|
+
amount,
|
|
58
|
+
delegatee,
|
|
59
|
+
beneficiary,
|
|
60
|
+
_getCommissionRate(delegatee)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
_sweepSpaceRewardsIfNecessary(delegatee);
|
|
64
|
+
|
|
65
|
+
if (owner != address(this)) {
|
|
66
|
+
address proxy = _deployDelegationProxy(depositId, delegatee);
|
|
67
|
+
if (!fromPermit) {
|
|
68
|
+
ds.staking.stakeToken.safeTransferFrom(msg.sender, proxy, amount);
|
|
69
|
+
} else {
|
|
70
|
+
ds.staking.stakeToken.safeTransfer(proxy, amount);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
ds.depositsByDepositor[owner].add(depositId);
|
|
74
|
+
|
|
75
|
+
emit Stake(owner, delegatee, beneficiary, depositId, amount);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// @notice Increases the stake amount for an existing deposit
|
|
79
|
+
/// @dev Validates ownership, transfers additional tokens, and updates deposit accounting
|
|
80
|
+
/// @param depositId The ID of the existing deposit to increase
|
|
81
|
+
/// @param amount Additional amount of stake tokens to add
|
|
82
|
+
/// @param fromPermit Whether tokens are already in contract from permit
|
|
83
|
+
function _increaseStake(uint256 depositId, uint96 amount, bool fromPermit) internal {
|
|
84
|
+
RewardsDistributionStorage.Layout storage ds = RewardsDistributionStorage.layout();
|
|
85
|
+
StakingRewards.Deposit storage deposit = ds.staking.depositById[depositId];
|
|
86
|
+
address owner = deposit.owner;
|
|
87
|
+
_revertIfNotDepositOwner(owner);
|
|
88
|
+
|
|
89
|
+
address delegatee = deposit.delegatee;
|
|
90
|
+
_revertIfNotOperatorOrSpace(delegatee);
|
|
91
|
+
|
|
92
|
+
ds.staking.increaseStake(
|
|
93
|
+
deposit,
|
|
94
|
+
owner,
|
|
95
|
+
amount,
|
|
96
|
+
delegatee,
|
|
97
|
+
deposit.beneficiary,
|
|
98
|
+
_getCommissionRate(delegatee)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
_sweepSpaceRewardsIfNecessary(delegatee);
|
|
102
|
+
|
|
103
|
+
if (owner != address(this)) {
|
|
104
|
+
address proxy = ds.proxyById[depositId];
|
|
105
|
+
if (!fromPermit) {
|
|
106
|
+
ds.staking.stakeToken.safeTransferFrom(msg.sender, proxy, amount);
|
|
107
|
+
} else {
|
|
108
|
+
ds.staking.stakeToken.safeTransfer(proxy, amount);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
emit IncreaseStake(depositId, amount);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @notice Executes a Permit2 transfer using signed permit for stake token authorization
|
|
117
|
+
* @dev This function uses Uniswap's Permit2 protocol instead of EIP-2612 to enable
|
|
118
|
+
* smart contract wallet support through ERC-1271 signature verification.
|
|
119
|
+
*
|
|
120
|
+
* Design Principles:
|
|
121
|
+
* - Uses `permitTransferFrom` (not `permitWitnessTransferFrom`) since staking doesn't
|
|
122
|
+
* require binding signatures to additional contract-specific parameters
|
|
123
|
+
* - Transfers tokens directly from caller to RewardsDistribution contract address
|
|
124
|
+
* - Supports both EOA signatures (via ecrecover) and smart contract signatures (via ERC-1271)
|
|
125
|
+
* - Towns token gives Permit2 infinite allowance by default, so no pre-approval needed
|
|
126
|
+
*
|
|
127
|
+
* Security Considerations:
|
|
128
|
+
* - Front-running protection: The permit signature cryptographically binds the owner
|
|
129
|
+
* field to `msg.sender`. An attacker cannot use someone else's permit signature
|
|
130
|
+
* because the signature verification will fail when called by a different address.
|
|
131
|
+
* - The beneficiary parameter can be specified by the caller, but the attacker cannot
|
|
132
|
+
* execute the permit without being the original signer, so no funds can be stolen.
|
|
133
|
+
* - Users must have pre-approved tokens to Permit2 contract before calling this function.
|
|
134
|
+
*
|
|
135
|
+
* @param amount The amount of stake tokens to transfer
|
|
136
|
+
* @param nonce The unique nonce for this permit to prevent replay attacks
|
|
137
|
+
* @param deadline The deadline after which the permit expires
|
|
138
|
+
* @param signature The signature authorizing the transfer (supports both EOA and smart contract wallets)
|
|
139
|
+
*/
|
|
140
|
+
function _permitStakeToken(
|
|
141
|
+
uint96 amount,
|
|
142
|
+
uint256 nonce,
|
|
143
|
+
uint256 deadline,
|
|
144
|
+
bytes calldata signature
|
|
145
|
+
) internal {
|
|
146
|
+
address stakeToken = RewardsDistributionStorage.layout().staking.stakeToken;
|
|
147
|
+
|
|
148
|
+
// execute permit transfer from the caller to this contract via Permit2
|
|
149
|
+
ISignatureTransfer(PERMIT2).permitTransferFrom(
|
|
150
|
+
ISignatureTransfer.PermitTransferFrom(
|
|
151
|
+
ISignatureTransfer.TokenPermissions(stakeToken, amount),
|
|
152
|
+
nonce,
|
|
153
|
+
deadline
|
|
154
|
+
),
|
|
155
|
+
ISignatureTransfer.SignatureTransferDetails({
|
|
156
|
+
to: address(this),
|
|
157
|
+
requestedAmount: amount
|
|
158
|
+
}),
|
|
159
|
+
msg.sender, // owner has to be the caller
|
|
160
|
+
signature
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// @dev Deploys a beacon proxy for the delegation
|
|
165
|
+
function _deployDelegationProxy(
|
|
166
|
+
uint256 depositId,
|
|
167
|
+
address delegatee
|
|
168
|
+
) internal returns (address proxy) {
|
|
169
|
+
RewardsDistributionStorage.Layout storage ds = RewardsDistributionStorage.layout();
|
|
170
|
+
proxy = LibClone.deployDeterministicERC1967BeaconProxy(address(this), bytes32(depositId));
|
|
171
|
+
ds.proxyById[depositId] = proxy;
|
|
172
|
+
DelegationProxy(proxy).initialize(ds.staking.stakeToken, delegatee);
|
|
173
|
+
|
|
174
|
+
emit DelegationProxyDeployed(depositId, delegatee, proxy);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
178
|
+
/* OPERATOR */
|
|
179
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
180
|
+
|
|
181
|
+
/// @dev Returns the commission rate of the operator or space
|
|
182
|
+
function _getCommissionRate(address delegatee) internal view returns (uint256) {
|
|
183
|
+
// if the delegatee is a space, get the active operator or revert
|
|
184
|
+
if (_isSpace(delegatee)) {
|
|
185
|
+
delegatee = _getValidOperatorOrRevert(delegatee);
|
|
186
|
+
}
|
|
187
|
+
NodeOperatorStorage.Layout storage nos = NodeOperatorStorage.layout();
|
|
188
|
+
return nos.commissionByOperator[delegatee];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// @dev Checks if the delegatee is an operator
|
|
192
|
+
function _isOperator(address delegatee) internal view returns (bool) {
|
|
193
|
+
NodeOperatorStorage.Layout storage nos = NodeOperatorStorage.layout();
|
|
194
|
+
return nos.operators.contains(delegatee);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// @dev Checks if the delegatee is an active operator
|
|
198
|
+
function _isValidOperator(address delegatee) internal view returns (bool) {
|
|
199
|
+
NodeOperatorStorage.Layout storage nos = NodeOperatorStorage.layout();
|
|
200
|
+
if (!nos.operators.contains(delegatee)) return false;
|
|
201
|
+
NodeOperatorStatus status = nos.statusByOperator[delegatee];
|
|
202
|
+
return status == NodeOperatorStatus.Approved || status == NodeOperatorStatus.Active;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
206
|
+
/* SPACE DELEGATION */
|
|
207
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
208
|
+
|
|
209
|
+
/// @dev Sweeps the rewards in the space delegation to the operator if necessary
|
|
210
|
+
function _sweepSpaceRewardsIfNecessary(address space) internal {
|
|
211
|
+
address operator = _getOperatorBySpace(space);
|
|
212
|
+
if (operator == address(0)) return;
|
|
213
|
+
|
|
214
|
+
StakingRewards.Layout storage staking = RewardsDistributionStorage.layout().staking;
|
|
215
|
+
uint256 scaledReward = staking.transferReward(space, operator);
|
|
216
|
+
|
|
217
|
+
if (scaledReward != 0) emit SpaceRewardsSwept(space, operator, scaledReward);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// @dev Checks if the delegatee is a space
|
|
221
|
+
function _isSpace(address delegatee) internal view returns (bool) {
|
|
222
|
+
return _getOperatorBySpace(delegatee) != address(0);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// @dev Returns the operator of the space
|
|
226
|
+
function _getOperatorBySpace(address space) internal view returns (address operator) {
|
|
227
|
+
SpaceDelegationStorage.Layout storage sd = SpaceDelegationStorage.layout();
|
|
228
|
+
operator = sd.operatorBySpace[space];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/// @dev Returns the active operator of the space or reverts
|
|
232
|
+
function _getValidOperatorOrRevert(address space) internal view returns (address operator) {
|
|
233
|
+
operator = _getOperatorBySpace(space);
|
|
234
|
+
if (!_isValidOperator(operator)) {
|
|
235
|
+
RewardsDistribution__NotActiveOperator.selector.revertWith();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function _currentSpaceDelegationReward(address operator) internal view returns (uint256 total) {
|
|
240
|
+
StakingRewards.Layout storage staking = RewardsDistributionStorage.layout().staking;
|
|
241
|
+
address[] memory spaces = SpaceDelegationStorage
|
|
242
|
+
.layout()
|
|
243
|
+
.spacesByOperator[operator]
|
|
244
|
+
.values();
|
|
245
|
+
|
|
246
|
+
uint256 currentRewardPerTokenAccumulated = staking.currentRewardPerTokenAccumulated();
|
|
247
|
+
uint256 rewardPerTokenGrowth;
|
|
248
|
+
for (uint256 i; i < spaces.length; ++i) {
|
|
249
|
+
StakingRewards.Treasure storage treasure = staking.treasureByBeneficiary[spaces[i]];
|
|
250
|
+
unchecked {
|
|
251
|
+
rewardPerTokenGrowth =
|
|
252
|
+
currentRewardPerTokenAccumulated -
|
|
253
|
+
treasure.rewardPerTokenAccumulated;
|
|
254
|
+
}
|
|
255
|
+
total +=
|
|
256
|
+
treasure.unclaimedRewardSnapshot +
|
|
257
|
+
(uint256(treasure.earningPower) * rewardPerTokenGrowth);
|
|
258
|
+
}
|
|
259
|
+
total /= StakingRewards.SCALE_FACTOR;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
263
|
+
/* SANITY CHECKS */
|
|
264
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
265
|
+
|
|
266
|
+
/// @dev Reverts if the delegatee is not an operator or space
|
|
267
|
+
function _revertIfNotOperatorOrSpace(address delegatee) internal view {
|
|
268
|
+
if (_isSpace(delegatee)) return;
|
|
269
|
+
if (!_isValidOperator(delegatee)) {
|
|
270
|
+
RewardsDistribution__NotOperatorOrSpace.selector.revertWith();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/// @dev Reverts if the caller is not the owner of the deposit
|
|
275
|
+
function _revertIfNotDepositOwner(address owner) internal view {
|
|
276
|
+
if (msg.sender != owner) RewardsDistribution__NotDepositOwner.selector.revertWith();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/// @dev Checks if the caller is the claimer of the operator
|
|
280
|
+
function _revertIfNotOperatorClaimer(address operator) internal view {
|
|
281
|
+
NodeOperatorStorage.Layout storage nos = NodeOperatorStorage.layout();
|
|
282
|
+
address claimer = nos.claimerByOperator[operator];
|
|
283
|
+
if (msg.sender != claimer) RewardsDistribution__NotClaimer.selector.revertWith();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function _revertIfPastDeadline(uint256 deadline) internal view {
|
|
287
|
+
if (block.timestamp > deadline) RewardsDistribution__ExpiredDeadline.selector.revertWith();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function _revertIfSignatureIsNotValidNow(
|
|
291
|
+
address signer,
|
|
292
|
+
bytes32 hash,
|
|
293
|
+
bytes calldata signature
|
|
294
|
+
) internal view {
|
|
295
|
+
if (!SignatureCheckerLib.isValidSignatureNowCalldata(signer, hash, signature)) {
|
|
296
|
+
RewardsDistribution__InvalidSignature.selector.revertWith();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|