@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,31 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/// @title TownsLib
|
|
5
|
+
library TownsLib {
|
|
6
|
+
/// @notice Address of the L2StandardBridge predeploy.
|
|
7
|
+
address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
|
|
8
|
+
|
|
9
|
+
/// @notice Address of the SuperchainTokenBridge predeploy.
|
|
10
|
+
address internal constant SUPERCHAIN_TOKEN_BRIDGE = 0x4200000000000000000000000000000000000028;
|
|
11
|
+
|
|
12
|
+
// keccak256(abi.encode(uint256(keccak256("towns.tokens.l2.storage")) - 1)) &
|
|
13
|
+
// ~bytes32(uint256(0xff))
|
|
14
|
+
bytes32 constant STORAGE_SLOT =
|
|
15
|
+
0x708ba15393f53e4db9d749d00ba2ba89a43d1e182bc44eaf801b83b223310b00;
|
|
16
|
+
|
|
17
|
+
struct Layout {
|
|
18
|
+
address remoteToken;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function layout() internal pure returns (Layout storage l) {
|
|
22
|
+
assembly {
|
|
23
|
+
l.slot := STORAGE_SLOT
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function initializeRemoteToken(address _remoteToken) internal {
|
|
28
|
+
Layout storage l = layout();
|
|
29
|
+
l.remoteToken = _remoteToken;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
import {Towns} from "../Towns.sol";
|
|
10
|
+
|
|
11
|
+
contract TownsV2 is Towns {
|
|
12
|
+
function updateCoolDown(uint256 newCoolDown) external onlyOwner {
|
|
13
|
+
_setDefaultCooldown(newCoolDown);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
|
|
10
|
+
interface ITownsBase {
|
|
11
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
12
|
+
/* Structs */
|
|
13
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
14
|
+
struct InflationConfig {
|
|
15
|
+
uint256 initialMintTime;
|
|
16
|
+
uint256 initialInflationRate;
|
|
17
|
+
uint256 finalInflationRate;
|
|
18
|
+
uint256 finalInflationYears;
|
|
19
|
+
uint256 inflationDecayRate;
|
|
20
|
+
address inflationReceiver;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
24
|
+
/* Errors */
|
|
25
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
26
|
+
error InvalidAddress();
|
|
27
|
+
error InvalidInflationRate();
|
|
28
|
+
error MintingTooSoon();
|
|
29
|
+
error InitialSupplyAlreadyMinted();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ITowns is ITownsBase {
|
|
33
|
+
/// @notice Mints the initial supply to the given address
|
|
34
|
+
/// @dev Can only be called by the owner
|
|
35
|
+
/// @dev Can only be called once
|
|
36
|
+
function mintInitialSupply(address to) external;
|
|
37
|
+
|
|
38
|
+
/// @notice Creates new tokens according to the current inflation rate
|
|
39
|
+
/// @dev Can only be called by accounts with ROLE_INFLATION_MANAGER
|
|
40
|
+
/// @dev Mints tokens to the inflation receiver based on current total supply and inflation rate
|
|
41
|
+
/// @dev Updates lastMintTime to current block timestamp after minting
|
|
42
|
+
function createInflation() external;
|
|
43
|
+
|
|
44
|
+
/// @notice Allows the inflation rate manager to override the normal inflation rate
|
|
45
|
+
/// @param overrideInflation Whether to override the normal inflation rate
|
|
46
|
+
/// @param overrideInflationRate The inflation rate to use when overriding, in basis points
|
|
47
|
+
/// @dev Can only be called by accounts with ROLE_INFLATION_RATE_MANAGER
|
|
48
|
+
/// @dev overrideInflationRate must be less than or equal to finalInflationRate
|
|
49
|
+
function setOverrideInflation(bool overrideInflation, uint256 overrideInflationRate) external;
|
|
50
|
+
|
|
51
|
+
/// @notice Sets the receiver address for inflation rewards
|
|
52
|
+
/// @param receiver The new inflation receiver address
|
|
53
|
+
/// @dev Can only be called by accounts with ROLE_INFLATION_MANAGER
|
|
54
|
+
/// @dev receiver cannot be the zero address
|
|
55
|
+
function setInflationReceiver(address receiver) external;
|
|
56
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {ITowns} from "./ITowns.sol";
|
|
6
|
+
|
|
7
|
+
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
|
|
8
|
+
|
|
9
|
+
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
|
|
10
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
|
|
11
|
+
import {IERC6372} from "@openzeppelin/contracts/interfaces/IERC6372.sol";
|
|
12
|
+
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
|
|
13
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
14
|
+
import {IVotesEnumerable} from "src/diamond/facets/governance/votes/enumerable/IVotesEnumerable.sol";
|
|
15
|
+
|
|
16
|
+
// libraries
|
|
17
|
+
|
|
18
|
+
import {VotesEnumerableLib} from "src/diamond/facets/governance/votes/enumerable/VotesEnumerableLib.sol";
|
|
19
|
+
import {TokenInflationLib} from "src/tokens/towns/mainnet/libs/TokenInflationLib.sol";
|
|
20
|
+
import {BasisPoints} from "src/utils/libraries/BasisPoints.sol";
|
|
21
|
+
|
|
22
|
+
import {CustomRevert} from "src/utils/libraries/CustomRevert.sol";
|
|
23
|
+
import {OwnableRoles} from "solady/auth/OwnableRoles.sol";
|
|
24
|
+
|
|
25
|
+
// contracts
|
|
26
|
+
import {IntrospectionBase} from "@towns-protocol/diamond/src/facets/introspection/IntrospectionBase.sol";
|
|
27
|
+
import {VotesEnumerable} from "src/diamond/facets/governance/votes/enumerable/VotesEnumerable.sol";
|
|
28
|
+
import {ERC20Votes} from "solady/tokens/ERC20Votes.sol";
|
|
29
|
+
|
|
30
|
+
contract Towns is OwnableRoles, ERC20Votes, IntrospectionBase, VotesEnumerable, ITowns, IERC165 {
|
|
31
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
32
|
+
/* Constants & Immutables */
|
|
33
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
34
|
+
|
|
35
|
+
/// @notice The name of the token
|
|
36
|
+
string internal constant NAME = "Towns";
|
|
37
|
+
|
|
38
|
+
/// @notice The symbol of the token
|
|
39
|
+
string internal constant SYMBOL = "TOWNS";
|
|
40
|
+
|
|
41
|
+
/// @notice The name hash of the token
|
|
42
|
+
bytes32 internal constant NAME_HASH = keccak256(bytes(NAME));
|
|
43
|
+
|
|
44
|
+
/// @dev initial supply is 10 billion tokens
|
|
45
|
+
uint256 internal constant INITIAL_SUPPLY = 10_000_000_000 ether;
|
|
46
|
+
|
|
47
|
+
/// @dev the role for the inflation caller
|
|
48
|
+
uint256 public constant ROLE_INFLATION_MANAGER = 1;
|
|
49
|
+
|
|
50
|
+
/// @dev the role for the inflation rate manager
|
|
51
|
+
uint256 public constant ROLE_INFLATION_RATE_MANAGER = 2;
|
|
52
|
+
|
|
53
|
+
/// @dev the initial mint time
|
|
54
|
+
uint256 public immutable initialMintTime;
|
|
55
|
+
|
|
56
|
+
/// @dev whether the initial supply has been minted
|
|
57
|
+
bool internal initialSupplyMinted;
|
|
58
|
+
|
|
59
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
60
|
+
/* Constructor */
|
|
61
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
62
|
+
|
|
63
|
+
constructor(address vault, address manager, InflationConfig memory config) {
|
|
64
|
+
if (vault == address(0) || manager == address(0)) {
|
|
65
|
+
CustomRevert.revertWith(InvalidAddress.selector);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (config.inflationReceiver == address(0)) {
|
|
69
|
+
CustomRevert.revertWith(InvalidAddress.selector);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_initializeOwner(vault);
|
|
73
|
+
|
|
74
|
+
_grantRoles(vault, ROLE_INFLATION_MANAGER);
|
|
75
|
+
_grantRoles(manager, ROLE_INFLATION_RATE_MANAGER);
|
|
76
|
+
|
|
77
|
+
_addInterface(type(ITowns).interfaceId);
|
|
78
|
+
_addInterface(type(IERC20).interfaceId);
|
|
79
|
+
_addInterface(type(IERC20Metadata).interfaceId);
|
|
80
|
+
_addInterface(type(IERC20Permit).interfaceId);
|
|
81
|
+
_addInterface(type(IVotesEnumerable).interfaceId);
|
|
82
|
+
_addInterface(type(IERC165).interfaceId);
|
|
83
|
+
_addInterface(type(IVotes).interfaceId);
|
|
84
|
+
_addInterface(type(IERC6372).interfaceId);
|
|
85
|
+
|
|
86
|
+
initialMintTime = config.initialMintTime;
|
|
87
|
+
|
|
88
|
+
TokenInflationLib.initialize(config);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// @notice Mints the initial supply to the given address
|
|
92
|
+
/// @dev Can only be called by the owner
|
|
93
|
+
/// @dev Can only be called once
|
|
94
|
+
function mintInitialSupply(address to) external onlyOwner {
|
|
95
|
+
if (initialSupplyMinted) {
|
|
96
|
+
CustomRevert.revertWith(InitialSupplyAlreadyMinted.selector);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_mint(to, INITIAL_SUPPLY);
|
|
100
|
+
initialSupplyMinted = true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
104
|
+
/* Inflation */
|
|
105
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
106
|
+
|
|
107
|
+
/// @notice The final inflation rate in basis points (0-10_000)
|
|
108
|
+
function finalInflationRate() external view returns (uint256) {
|
|
109
|
+
return TokenInflationLib.finalInflationRate();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// @notice The address that receives the inflation
|
|
113
|
+
function inflationReceiver() external view returns (address) {
|
|
114
|
+
return TokenInflationLib.inflationReceiver();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// @notice The last time the inflation was minted
|
|
118
|
+
function lastMintTime() external view returns (uint256) {
|
|
119
|
+
return TokenInflationLib.lastMintTime();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// @notice The current inflation rate in basis points (0-10_000)
|
|
123
|
+
function currentInflationRate() external view returns (uint256) {
|
|
124
|
+
return TokenInflationLib.getCurrentInflationRateBPS(initialMintTime);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// @inheritdoc ITowns
|
|
128
|
+
function setOverrideInflation(
|
|
129
|
+
bool overrideInflation,
|
|
130
|
+
uint256 overrideInflationRate
|
|
131
|
+
) external onlyRoles(ROLE_INFLATION_RATE_MANAGER) {
|
|
132
|
+
if (overrideInflationRate > TokenInflationLib.finalInflationRate()) {
|
|
133
|
+
CustomRevert.revertWith(InvalidInflationRate.selector);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
TokenInflationLib.setOverrideInflation(overrideInflation, overrideInflationRate);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// @inheritdoc ITowns
|
|
140
|
+
function setInflationReceiver(address receiver) external onlyRoles(ROLE_INFLATION_MANAGER) {
|
|
141
|
+
if (receiver == address(0)) {
|
|
142
|
+
CustomRevert.revertWith(InvalidAddress.selector);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
TokenInflationLib.setInflationReceiver(receiver);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// @inheritdoc ITowns
|
|
149
|
+
function createInflation() external onlyRoles(ROLE_INFLATION_MANAGER) {
|
|
150
|
+
// verify that minting can only happen once per year
|
|
151
|
+
uint256 timeSinceLastMint = block.timestamp - TokenInflationLib.lastMintTime();
|
|
152
|
+
|
|
153
|
+
if (timeSinceLastMint < 365 days) {
|
|
154
|
+
CustomRevert.revertWith(MintingTooSoon.selector);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
uint256 inflationRateBPS = TokenInflationLib.getCurrentInflationRateBPS(initialMintTime);
|
|
158
|
+
uint256 inflationAmount = BasisPoints.calculate(totalSupply(), inflationRateBPS);
|
|
159
|
+
|
|
160
|
+
address receiver = TokenInflationLib.inflationReceiver();
|
|
161
|
+
_mint(receiver, inflationAmount);
|
|
162
|
+
|
|
163
|
+
TokenInflationLib.updateLastMintTime();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
167
|
+
/* Introspection */
|
|
168
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
169
|
+
|
|
170
|
+
/// @inheritdoc IERC165
|
|
171
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
172
|
+
return _supportsInterface(interfaceId);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
176
|
+
/* Overrides */
|
|
177
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
178
|
+
|
|
179
|
+
function name() public pure override returns (string memory) {
|
|
180
|
+
return NAME;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function symbol() public pure override returns (string memory) {
|
|
184
|
+
return SYMBOL;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/// @notice Clock used for flagging checkpoints, overridden to implement timestamp based
|
|
188
|
+
/// checkpoints (and voting).
|
|
189
|
+
function clock() public view override returns (uint48) {
|
|
190
|
+
return uint48(block.timestamp);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/// @notice Machine-readable description of the clock as specified in EIP-6372.
|
|
194
|
+
function CLOCK_MODE() public pure override returns (string memory) {
|
|
195
|
+
return "mode=timestamp";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
199
|
+
/* Internal Overrides */
|
|
200
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
201
|
+
|
|
202
|
+
/// @dev Override the name hash to be a constant value for performance in EIP-712
|
|
203
|
+
function _constantNameHash() internal pure override returns (bytes32) {
|
|
204
|
+
return NAME_HASH;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// @dev This allows Permit2 to be used without prior approval.
|
|
208
|
+
function _givePermit2InfiniteAllowance() internal pure override returns (bool) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/// @dev Override the delegate function to update the delegators and delegation time
|
|
213
|
+
function _delegate(address account, address delegatee) internal override {
|
|
214
|
+
address currentDelegatee = delegates(account);
|
|
215
|
+
|
|
216
|
+
super._delegate(account, delegatee);
|
|
217
|
+
|
|
218
|
+
VotesEnumerableLib.setDelegators(account, delegatee, currentDelegatee);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {ITownsBase} from "src/tokens/towns/mainnet/ITowns.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
|
|
9
|
+
// contracts
|
|
10
|
+
|
|
11
|
+
library TokenInflationLib {
|
|
12
|
+
struct Layout {
|
|
13
|
+
uint256 lastMintTime;
|
|
14
|
+
address inflationReceiver;
|
|
15
|
+
uint256 initialInflationRate;
|
|
16
|
+
uint256 finalInflationRate;
|
|
17
|
+
uint256 inflationDecayRate;
|
|
18
|
+
uint256 finalInflationYears;
|
|
19
|
+
bool overrideInflation;
|
|
20
|
+
uint256 overrideInflationRate;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// keccak256(abi.encode(uint256(keccak256("tokens.towns.mainnet.lib.storage")) - 1)) &
|
|
24
|
+
// ~bytes32(uint256(0xff))
|
|
25
|
+
function layout() internal pure returns (Layout storage l) {
|
|
26
|
+
bytes32 slot = 0x366bbacac8c1291905a47c4b12670e7c8ce975e09c84414dddf77ba98c85af00;
|
|
27
|
+
assembly {
|
|
28
|
+
l.slot := slot
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function initialize(ITownsBase.InflationConfig memory config) internal {
|
|
33
|
+
Layout storage ds = layout();
|
|
34
|
+
ds.lastMintTime = config.initialMintTime;
|
|
35
|
+
ds.inflationReceiver = config.inflationReceiver;
|
|
36
|
+
ds.initialInflationRate = config.initialInflationRate;
|
|
37
|
+
ds.finalInflationRate = config.finalInflationRate;
|
|
38
|
+
ds.inflationDecayRate = config.inflationDecayRate;
|
|
39
|
+
ds.finalInflationYears = config.finalInflationYears;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function finalInflationRate() internal view returns (uint256) {
|
|
43
|
+
return layout().finalInflationRate;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function inflationReceiver() internal view returns (address) {
|
|
47
|
+
return layout().inflationReceiver;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function lastMintTime() internal view returns (uint256) {
|
|
51
|
+
return layout().lastMintTime;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function setInflationReceiver(address receiver) internal {
|
|
55
|
+
layout().inflationReceiver = receiver;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function updateLastMintTime() internal {
|
|
59
|
+
layout().lastMintTime = block.timestamp;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function setOverrideInflation(
|
|
63
|
+
bool overrideInflation,
|
|
64
|
+
uint256 overrideInflationRateBps
|
|
65
|
+
) internal {
|
|
66
|
+
layout().overrideInflation = overrideInflation;
|
|
67
|
+
layout().overrideInflationRate = overrideInflationRateBps;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @dev Returns the current inflation rate.
|
|
72
|
+
* @return inflation rate in basis points (0-10_000)
|
|
73
|
+
*/
|
|
74
|
+
function getCurrentInflationRateBPS(uint256 initialMintTime) internal view returns (uint256) {
|
|
75
|
+
Layout storage ds = layout();
|
|
76
|
+
|
|
77
|
+
if (ds.overrideInflation) return ds.overrideInflationRate; // override inflation rate
|
|
78
|
+
|
|
79
|
+
uint256 yearsSinceInitialMint = (block.timestamp - initialMintTime) / 365 days;
|
|
80
|
+
|
|
81
|
+
if (yearsSinceInitialMint >= ds.finalInflationYears) {
|
|
82
|
+
return ds.finalInflationRate;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
uint256 inflationRateDecrease = (yearsSinceInitialMint * ds.inflationDecayRate) /
|
|
86
|
+
ds.finalInflationYears;
|
|
87
|
+
return ds.initialInflationRate - inflationRateDecrease;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
import {OFT} from "@layerzerolabs/oft-evm/contracts/OFT.sol";
|
|
10
|
+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
11
|
+
|
|
12
|
+
contract Towns is OFT {
|
|
13
|
+
constructor(
|
|
14
|
+
string memory _name,
|
|
15
|
+
string memory _symbol,
|
|
16
|
+
address _lzEndpoint,
|
|
17
|
+
address _owner
|
|
18
|
+
) OFT(_name, _symbol, _lzEndpoint, _owner) Ownable(_owner) {}
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
import {OFTAdapter} from "@layerzerolabs/oft-evm/contracts/OFTAdapter.sol";
|
|
10
|
+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
11
|
+
|
|
12
|
+
contract wTowns is OFTAdapter {
|
|
13
|
+
constructor(
|
|
14
|
+
address _token,
|
|
15
|
+
address _lzEndpoint,
|
|
16
|
+
address _owner
|
|
17
|
+
) OFTAdapter(_token, _lzEndpoint, _owner) Ownable(_owner) {}
|
|
18
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @title Airdrop
|
|
12
|
+
* @notice highly optimized airdrop contract
|
|
13
|
+
*/
|
|
14
|
+
contract Airdrop {
|
|
15
|
+
/// @notice Airdrop ERC721 tokens to a list of addresses
|
|
16
|
+
/// @param nft The address of the ERC721 contract
|
|
17
|
+
/// @param addresses The addresses to airdrop to
|
|
18
|
+
/// @param tokenIds The tokenIds to airdrop
|
|
19
|
+
function airdropERC721(
|
|
20
|
+
address nft,
|
|
21
|
+
address[] calldata addresses,
|
|
22
|
+
uint256[] calldata tokenIds
|
|
23
|
+
) external payable {
|
|
24
|
+
assembly {
|
|
25
|
+
// Check that the number of addresses matches the number of tokenIds
|
|
26
|
+
if iszero(eq(tokenIds.length, addresses.length)) {
|
|
27
|
+
revert(0, 0)
|
|
28
|
+
}
|
|
29
|
+
// transferFrom(address from, address to, uint256 tokenId)
|
|
30
|
+
mstore(0x00, hex"23b872dd")
|
|
31
|
+
// from address
|
|
32
|
+
mstore(0x04, caller())
|
|
33
|
+
|
|
34
|
+
// end of array
|
|
35
|
+
let end := add(addresses.offset, shl(5, addresses.length))
|
|
36
|
+
// diff = addresses.offset - tokenIds.offset
|
|
37
|
+
let diff := sub(addresses.offset, tokenIds.offset)
|
|
38
|
+
|
|
39
|
+
// Loop through the addresses
|
|
40
|
+
for {
|
|
41
|
+
let addressOffset := addresses.offset
|
|
42
|
+
} 1 {} {
|
|
43
|
+
// to address
|
|
44
|
+
mstore(0x24, calldataload(addressOffset))
|
|
45
|
+
// tokenId
|
|
46
|
+
mstore(0x44, calldataload(sub(addressOffset, diff)))
|
|
47
|
+
// transfer the token
|
|
48
|
+
if iszero(call(gas(), nft, 0, 0x00, 0x64, 0, 0)) {
|
|
49
|
+
revert(0, 0)
|
|
50
|
+
}
|
|
51
|
+
// increment the address offset
|
|
52
|
+
addressOffset := add(addressOffset, 0x20)
|
|
53
|
+
// if addressOffset >= end, break
|
|
54
|
+
if iszero(lt(addressOffset, end)) {
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// @notice Airdrop ERC20 tokens to a list of addresses
|
|
62
|
+
/// @param token The address of the ERC20 contract
|
|
63
|
+
/// @param addresses The addresses to airdrop to
|
|
64
|
+
/// @param amounts The amounts to airdrop
|
|
65
|
+
/// @param totalAmount The total amount to airdrop
|
|
66
|
+
function airdropERC20(
|
|
67
|
+
address token,
|
|
68
|
+
address[] calldata addresses,
|
|
69
|
+
uint256[] calldata amounts,
|
|
70
|
+
uint256 totalAmount
|
|
71
|
+
) external payable {
|
|
72
|
+
assembly {
|
|
73
|
+
// Check that the number of addresses matches the number of amounts
|
|
74
|
+
if iszero(eq(amounts.length, addresses.length)) {
|
|
75
|
+
revert(0, 0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// transferFrom(address from, address to, uint256 amount)
|
|
79
|
+
mstore(0x00, hex"23b872dd")
|
|
80
|
+
// from address
|
|
81
|
+
mstore(0x04, caller())
|
|
82
|
+
// to address (this contract)
|
|
83
|
+
mstore(0x24, address())
|
|
84
|
+
// total amount
|
|
85
|
+
mstore(0x44, totalAmount)
|
|
86
|
+
|
|
87
|
+
// transfer total amount to this contract
|
|
88
|
+
if iszero(call(gas(), token, 0, 0x00, 0x64, 0, 0)) {
|
|
89
|
+
revert(0, 0)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// transfer(address to, uint256 value)
|
|
93
|
+
mstore(0x00, hex"a9059cbb")
|
|
94
|
+
|
|
95
|
+
// end of array
|
|
96
|
+
let end := add(addresses.offset, shl(5, addresses.length))
|
|
97
|
+
// diff = addresses.offset - amounts.offset
|
|
98
|
+
let diff := sub(addresses.offset, amounts.offset)
|
|
99
|
+
|
|
100
|
+
// Loop through the addresses
|
|
101
|
+
for {
|
|
102
|
+
let addressOffset := addresses.offset
|
|
103
|
+
} 1 {} {
|
|
104
|
+
// to address
|
|
105
|
+
mstore(0x04, calldataload(addressOffset))
|
|
106
|
+
// amount
|
|
107
|
+
mstore(0x24, calldataload(sub(addressOffset, diff)))
|
|
108
|
+
// transfer the tokens
|
|
109
|
+
if iszero(call(gas(), token, 0, 0x00, 0x64, 0, 0)) {
|
|
110
|
+
revert(0, 0)
|
|
111
|
+
}
|
|
112
|
+
// increment the address offset
|
|
113
|
+
addressOffset := add(addressOffset, 0x20)
|
|
114
|
+
// if addressOffset >= end, break
|
|
115
|
+
if iszero(lt(addressOffset, end)) {
|
|
116
|
+
break
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// @notice Airdrop ETH to a list of addresses
|
|
123
|
+
/// @param addresses The addresses to airdrop to
|
|
124
|
+
/// @param amounts The amounts to airdrop
|
|
125
|
+
function airdropETH(address[] calldata addresses, uint256[] calldata amounts) external payable {
|
|
126
|
+
assembly {
|
|
127
|
+
// Check that the number of addresses matches the number of amounts
|
|
128
|
+
if iszero(eq(amounts.length, addresses.length)) {
|
|
129
|
+
revert(0, 0)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// iterator
|
|
133
|
+
let i := addresses.offset
|
|
134
|
+
// end of array
|
|
135
|
+
let end := add(i, shl(5, addresses.length))
|
|
136
|
+
// diff = addresses.offset - amounts.offset
|
|
137
|
+
let diff := sub(amounts.offset, addresses.offset)
|
|
138
|
+
|
|
139
|
+
// Loop through the addresses
|
|
140
|
+
for {} 1 {} {
|
|
141
|
+
// transfer the ETH
|
|
142
|
+
if iszero(
|
|
143
|
+
call(gas(), calldataload(i), calldataload(add(i, diff)), 0x00, 0x00, 0x00, 0x00)
|
|
144
|
+
) {
|
|
145
|
+
revert(0x00, 0x00)
|
|
146
|
+
}
|
|
147
|
+
// increment the iterator
|
|
148
|
+
i := add(i, 0x20)
|
|
149
|
+
// if i >= end, break
|
|
150
|
+
if eq(end, i) {
|
|
151
|
+
break
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.24;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
interface IMerkleAirdropBase {
|
|
10
|
+
error MerkleAirdrop__InvalidProof();
|
|
11
|
+
error MerkleAirdrop__AlreadyClaimed();
|
|
12
|
+
error MerkleAirdrop__InvalidSignature();
|
|
13
|
+
|
|
14
|
+
event Claimed(address account, uint256 amount, address recipient);
|
|
15
|
+
event MerkleRootUpdated(bytes32 merkleRoot);
|
|
16
|
+
|
|
17
|
+
struct AirdropClaim {
|
|
18
|
+
address account;
|
|
19
|
+
uint256 amount;
|
|
20
|
+
address receiver;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface IMerkleAirdrop is IMerkleAirdropBase {
|
|
25
|
+
/// @notice Computes the hash of the EIP-712 typed data for an airdrop claim
|
|
26
|
+
/// @param account The address of the account claiming the airdrop
|
|
27
|
+
/// @param amount The amount of tokens to be claimed
|
|
28
|
+
/// @return The computed message hash
|
|
29
|
+
function getMessageHash(
|
|
30
|
+
address account,
|
|
31
|
+
uint256 amount,
|
|
32
|
+
address receiver
|
|
33
|
+
) external view returns (bytes32);
|
|
34
|
+
|
|
35
|
+
/// @notice Retrieves the current Merkle root used for verifying claims
|
|
36
|
+
/// @return The current Merkle root
|
|
37
|
+
function getMerkleRoot() external view returns (bytes32);
|
|
38
|
+
|
|
39
|
+
/// @notice Gets the ERC20 token used for the airdrop
|
|
40
|
+
/// @return The IERC20 interface of the airdrop token
|
|
41
|
+
function getToken() external view returns (IERC20);
|
|
42
|
+
|
|
43
|
+
/// @notice Allows a user to claim their airdrop tokens
|
|
44
|
+
/// @param account The address of the account claiming the airdrop
|
|
45
|
+
/// @param amount The amount of tokens to be claimed
|
|
46
|
+
/// @param merkleProof The merkle proof for the claim
|
|
47
|
+
/// @param signature The EIP-712 signature authorizing the claim
|
|
48
|
+
function claim(
|
|
49
|
+
address account,
|
|
50
|
+
uint256 amount,
|
|
51
|
+
bytes32[] calldata merkleProof,
|
|
52
|
+
bytes calldata signature,
|
|
53
|
+
address receiver
|
|
54
|
+
) external;
|
|
55
|
+
}
|