├── .gitattributes ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── foundry.toml ├── lib ├── forge-gas-snapshot │ ├── .forge-snapshots │ │ ├── add.snap │ │ ├── addClosure.snap │ │ ├── addFirst.snap │ │ ├── addSecond.snap │ │ ├── addThird.snap │ │ ├── checkManyAdd.snap │ │ ├── checkManySstore.snap │ │ ├── checkSize.snap │ │ ├── checkSizeFail.snap │ │ ├── internalClosure.snap │ │ ├── manyAdd.snap │ │ ├── manySstore.snap │ │ ├── sizeTarget.snap │ │ ├── sstoreClosure.snap │ │ └── value.snap │ ├── .github │ │ └── workflows │ │ │ └── test.yml │ ├── .gitignore │ ├── .gitmodules │ ├── LICENSE │ ├── README.md │ ├── foundry.toml │ ├── src │ │ ├── GasSnapshot.sol │ │ ├── test │ │ │ └── SimpleOperations.sol │ │ └── utils │ │ │ └── UintString.sol │ └── test │ │ └── GasSnapshot.t.sol ├── forge-std │ ├── .github │ │ └── workflows │ │ │ ├── ci.yml │ │ │ └── sync.yml │ ├── .gitignore │ ├── .gitmodules │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── foundry.toml │ ├── lib │ │ └── ds-test │ │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── build.yml │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── default.nix │ │ │ ├── demo │ │ │ └── demo.sol │ │ │ ├── package.json │ │ │ └── src │ │ │ ├── test.sol │ │ │ └── test.t.sol │ ├── package.json │ ├── src │ │ ├── Base.sol │ │ ├── Script.sol │ │ ├── StdAssertions.sol │ │ ├── StdChains.sol │ │ ├── StdCheats.sol │ │ ├── StdError.sol │ │ ├── StdInvariant.sol │ │ ├── StdJson.sol │ │ ├── StdMath.sol │ │ ├── StdStorage.sol │ │ ├── StdStyle.sol │ │ ├── StdUtils.sol │ │ ├── Test.sol │ │ ├── Vm.sol │ │ ├── console.sol │ │ ├── console2.sol │ │ ├── interfaces │ │ │ ├── IERC1155.sol │ │ │ ├── IERC165.sol │ │ │ ├── IERC20.sol │ │ │ ├── IERC4626.sol │ │ │ ├── IERC721.sol │ │ │ └── IMulticall3.sol │ │ └── safeconsole.sol │ └── test │ │ ├── StdAssertions.t.sol │ │ ├── StdChains.t.sol │ │ ├── StdCheats.t.sol │ │ ├── StdError.t.sol │ │ ├── StdMath.t.sol │ │ ├── StdStorage.t.sol │ │ ├── StdStyle.t.sol │ │ ├── StdUtils.t.sol │ │ ├── compilation │ │ ├── CompilationScript.sol │ │ ├── CompilationScriptBase.sol │ │ ├── CompilationTest.sol │ │ └── CompilationTestBase.sol │ │ └── fixtures │ │ └── broadcast.log.json ├── openzeppelin-contracts │ ├── .changeset │ │ └── config.json │ ├── .codecov.yml │ ├── .editorconfig │ ├── .eslintrc │ ├── .github │ │ ├── ISSUE_TEMPLATE │ │ │ ├── bug_report.md │ │ │ ├── config.yml │ │ │ └── feature_request.md │ │ ├── PULL_REQUEST_TEMPLATE.md │ │ ├── actions │ │ │ ├── gas-compare │ │ │ │ └── action.yml │ │ │ ├── setup │ │ │ │ └── action.yml │ │ │ └── storage-layout │ │ │ │ └── action.yml │ │ └── workflows │ │ │ ├── actionlint.yml │ │ │ ├── changeset.yml │ │ │ ├── checks.yml │ │ │ ├── docs.yml │ │ │ ├── formal-verification.yml │ │ │ ├── release-cycle.yml │ │ │ └── upgradeable.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .mocharc.js │ ├── .prettierrc │ ├── .solcover.js │ ├── .solhint.json │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── GUIDELINES.md │ ├── LICENSE │ ├── README.md │ ├── RELEASING.md │ ├── SECURITY.md │ ├── audits │ │ ├── 2017-03.md │ │ ├── 2018-10.pdf │ │ ├── 2022-10-Checkpoints.pdf │ │ ├── 2022-10-ERC4626.pdf │ │ ├── 2023-05-v4.9.pdf │ │ └── README.md │ ├── certora │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.md │ │ ├── diff │ │ │ └── token_ERC721_ERC721.sol.patch │ │ ├── harnesses │ │ │ ├── AccessControlDefaultAdminRulesHarness.sol │ │ │ ├── AccessControlHarness.sol │ │ │ ├── DoubleEndedQueueHarness.sol │ │ │ ├── ERC20FlashMintHarness.sol │ │ │ ├── ERC20PermitHarness.sol │ │ │ ├── ERC20WrapperHarness.sol │ │ │ ├── ERC3156FlashBorrowerHarness.sol │ │ │ ├── ERC721Harness.sol │ │ │ ├── ERC721ReceiverHarness.sol │ │ │ ├── EnumerableMapHarness.sol │ │ │ ├── EnumerableSetHarness.sol │ │ │ ├── InitializableHarness.sol │ │ │ ├── Ownable2StepHarness.sol │ │ │ ├── OwnableHarness.sol │ │ │ ├── PausableHarness.sol │ │ │ └── TimelockControllerHarness.sol │ │ ├── reports │ │ │ ├── 2021-10.pdf │ │ │ ├── 2022-03.pdf │ │ │ └── 2022-05.pdf │ │ ├── run.js │ │ ├── specs.json │ │ └── specs │ │ │ ├── AccessControl.spec │ │ │ ├── AccessControlDefaultAdminRules.spec │ │ │ ├── DoubleEndedQueue.spec │ │ │ ├── ERC20.spec │ │ │ ├── ERC20FlashMint.spec │ │ │ ├── ERC20Wrapper.spec │ │ │ ├── ERC721.spec │ │ │ ├── EnumerableMap.spec │ │ │ ├── EnumerableSet.spec │ │ │ ├── Initializable.spec │ │ │ ├── Ownable.spec │ │ │ ├── Ownable2Step.spec │ │ │ ├── Pausable.spec │ │ │ ├── TimelockController.spec │ │ │ ├── helpers │ │ │ └── helpers.spec │ │ │ └── methods │ │ │ ├── IAccessControl.spec │ │ │ ├── IAccessControlDefaultAdminRules.spec │ │ │ ├── IERC20.spec │ │ │ ├── IERC2612.spec │ │ │ ├── IERC3156.spec │ │ │ ├── IERC5313.spec │ │ │ ├── IERC721.spec │ │ │ ├── IOwnable.spec │ │ │ └── IOwnable2Step.spec │ ├── contracts │ │ ├── access │ │ │ ├── AccessControl.sol │ │ │ ├── AccessControlCrossChain.sol │ │ │ ├── AccessControlDefaultAdminRules.sol │ │ │ ├── AccessControlEnumerable.sol │ │ │ ├── IAccessControl.sol │ │ │ ├── IAccessControlDefaultAdminRules.sol │ │ │ ├── IAccessControlEnumerable.sol │ │ │ ├── Ownable.sol │ │ │ ├── Ownable2Step.sol │ │ │ └── README.adoc │ │ ├── crosschain │ │ │ ├── CrossChainEnabled.sol │ │ │ ├── README.adoc │ │ │ ├── amb │ │ │ │ ├── CrossChainEnabledAMB.sol │ │ │ │ └── LibAMB.sol │ │ │ ├── arbitrum │ │ │ │ ├── CrossChainEnabledArbitrumL1.sol │ │ │ │ ├── CrossChainEnabledArbitrumL2.sol │ │ │ │ ├── LibArbitrumL1.sol │ │ │ │ └── LibArbitrumL2.sol │ │ │ ├── errors.sol │ │ │ ├── optimism │ │ │ │ ├── CrossChainEnabledOptimism.sol │ │ │ │ └── LibOptimism.sol │ │ │ └── polygon │ │ │ │ └── CrossChainEnabledPolygonChild.sol │ │ ├── finance │ │ │ ├── PaymentSplitter.sol │ │ │ ├── README.adoc │ │ │ └── VestingWallet.sol │ │ ├── governance │ │ │ ├── Governor.sol │ │ │ ├── IGovernor.sol │ │ │ ├── README.adoc │ │ │ ├── TimelockController.sol │ │ │ ├── compatibility │ │ │ │ ├── GovernorCompatibilityBravo.sol │ │ │ │ └── IGovernorCompatibilityBravo.sol │ │ │ ├── extensions │ │ │ │ ├── GovernorCountingSimple.sol │ │ │ │ ├── GovernorPreventLateQuorum.sol │ │ │ │ ├── GovernorProposalThreshold.sol │ │ │ │ ├── GovernorSettings.sol │ │ │ │ ├── GovernorTimelockCompound.sol │ │ │ │ ├── GovernorTimelockControl.sol │ │ │ │ ├── GovernorVotes.sol │ │ │ │ ├── GovernorVotesComp.sol │ │ │ │ ├── GovernorVotesQuorumFraction.sol │ │ │ │ └── IGovernorTimelock.sol │ │ │ └── utils │ │ │ │ ├── IVotes.sol │ │ │ │ └── Votes.sol │ │ ├── interfaces │ │ │ ├── IERC1155.sol │ │ │ ├── IERC1155MetadataURI.sol │ │ │ ├── IERC1155Receiver.sol │ │ │ ├── IERC1271.sol │ │ │ ├── IERC1363.sol │ │ │ ├── IERC1363Receiver.sol │ │ │ ├── IERC1363Spender.sol │ │ │ ├── IERC165.sol │ │ │ ├── IERC1820Implementer.sol │ │ │ ├── IERC1820Registry.sol │ │ │ ├── IERC1967.sol │ │ │ ├── IERC20.sol │ │ │ ├── IERC20Metadata.sol │ │ │ ├── IERC2309.sol │ │ │ ├── IERC2612.sol │ │ │ ├── IERC2981.sol │ │ │ ├── IERC3156.sol │ │ │ ├── IERC3156FlashBorrower.sol │ │ │ ├── IERC3156FlashLender.sol │ │ │ ├── IERC4626.sol │ │ │ ├── IERC4906.sol │ │ │ ├── IERC5267.sol │ │ │ ├── IERC5313.sol │ │ │ ├── IERC5805.sol │ │ │ ├── IERC6372.sol │ │ │ ├── IERC721.sol │ │ │ ├── IERC721Enumerable.sol │ │ │ ├── IERC721Metadata.sol │ │ │ ├── IERC721Receiver.sol │ │ │ ├── IERC777.sol │ │ │ ├── IERC777Recipient.sol │ │ │ ├── IERC777Sender.sol │ │ │ ├── README.adoc │ │ │ ├── draft-IERC1822.sol │ │ │ └── draft-IERC2612.sol │ │ ├── metatx │ │ │ ├── ERC2771Context.sol │ │ │ ├── MinimalForwarder.sol │ │ │ └── README.adoc │ │ ├── mocks │ │ │ ├── AccessControlCrossChainMock.sol │ │ │ ├── ArraysMock.sol │ │ │ ├── CallReceiverMock.sol │ │ │ ├── ConditionalEscrowMock.sol │ │ │ ├── ContextMock.sol │ │ │ ├── DummyImplementation.sol │ │ │ ├── EIP712Verifier.sol │ │ │ ├── ERC1271WalletMock.sol │ │ │ ├── ERC165 │ │ │ │ ├── ERC165MaliciousData.sol │ │ │ │ ├── ERC165MissingData.sol │ │ │ │ ├── ERC165NotSupported.sol │ │ │ │ └── ERC165ReturnBomb.sol │ │ │ ├── ERC20Mock.sol │ │ │ ├── ERC20Reentrant.sol │ │ │ ├── ERC2771ContextMock.sol │ │ │ ├── ERC3156FlashBorrowerMock.sol │ │ │ ├── ERC4626Mock.sol │ │ │ ├── EtherReceiverMock.sol │ │ │ ├── InitializableMock.sol │ │ │ ├── MulticallTest.sol │ │ │ ├── MultipleInheritanceInitializableMocks.sol │ │ │ ├── PausableMock.sol │ │ │ ├── PullPaymentMock.sol │ │ │ ├── ReentrancyAttack.sol │ │ │ ├── ReentrancyMock.sol │ │ │ ├── RegressionImplementation.sol │ │ │ ├── SafeMathMemoryCheck.sol │ │ │ ├── SingleInheritanceInitializableMocks.sol │ │ │ ├── StorageSlotMock.sol │ │ │ ├── TimelockReentrant.sol │ │ │ ├── TimersBlockNumberImpl.sol │ │ │ ├── TimersTimestampImpl.sol │ │ │ ├── VotesMock.sol │ │ │ ├── compound │ │ │ │ └── CompTimelock.sol │ │ │ ├── crosschain │ │ │ │ ├── bridges.sol │ │ │ │ └── receivers.sol │ │ │ ├── governance │ │ │ │ ├── GovernorCompMock.sol │ │ │ │ ├── GovernorCompatibilityBravoMock.sol │ │ │ │ ├── GovernorMock.sol │ │ │ │ ├── GovernorPreventLateQuorumMock.sol │ │ │ │ ├── GovernorTimelockCompoundMock.sol │ │ │ │ ├── GovernorTimelockControlMock.sol │ │ │ │ ├── GovernorVoteMock.sol │ │ │ │ └── GovernorWithParamsMock.sol │ │ │ ├── proxy │ │ │ │ ├── BadBeacon.sol │ │ │ │ ├── ClashingImplementation.sol │ │ │ │ ├── UUPSLegacy.sol │ │ │ │ └── UUPSUpgradeableMock.sol │ │ │ ├── token │ │ │ │ ├── ERC1155ReceiverMock.sol │ │ │ │ ├── ERC20DecimalsMock.sol │ │ │ │ ├── ERC20ExcessDecimalsMock.sol │ │ │ │ ├── ERC20FlashMintMock.sol │ │ │ │ ├── ERC20ForceApproveMock.sol │ │ │ │ ├── ERC20MulticallMock.sol │ │ │ │ ├── ERC20NoReturnMock.sol │ │ │ │ ├── ERC20PermitNoRevertMock.sol │ │ │ │ ├── ERC20ReturnFalseMock.sol │ │ │ │ ├── ERC20VotesLegacyMock.sol │ │ │ │ ├── ERC4626OffsetMock.sol │ │ │ │ ├── ERC4646FeesMock.sol │ │ │ │ ├── ERC721ConsecutiveEnumerableMock.sol │ │ │ │ ├── ERC721ConsecutiveMock.sol │ │ │ │ ├── ERC721ReceiverMock.sol │ │ │ │ ├── ERC721URIStorageMock.sol │ │ │ │ ├── ERC777Mock.sol │ │ │ │ ├── ERC777SenderRecipientMock.sol │ │ │ │ └── VotesTimestamp.sol │ │ │ └── wizard │ │ │ │ ├── MyGovernor1.sol │ │ │ │ ├── MyGovernor2.sol │ │ │ │ └── MyGovernor3.sol │ │ ├── package.json │ │ ├── proxy │ │ │ ├── Clones.sol │ │ │ ├── ERC1967 │ │ │ │ ├── ERC1967Proxy.sol │ │ │ │ └── ERC1967Upgrade.sol │ │ │ ├── Proxy.sol │ │ │ ├── README.adoc │ │ │ ├── beacon │ │ │ │ ├── BeaconProxy.sol │ │ │ │ ├── IBeacon.sol │ │ │ │ └── UpgradeableBeacon.sol │ │ │ ├── transparent │ │ │ │ ├── ProxyAdmin.sol │ │ │ │ └── TransparentUpgradeableProxy.sol │ │ │ └── utils │ │ │ │ ├── Initializable.sol │ │ │ │ └── UUPSUpgradeable.sol │ │ ├── security │ │ │ ├── Pausable.sol │ │ │ ├── PullPayment.sol │ │ │ ├── README.adoc │ │ │ └── ReentrancyGuard.sol │ │ ├── token │ │ │ ├── ERC1155 │ │ │ │ ├── ERC1155.sol │ │ │ │ ├── IERC1155.sol │ │ │ │ ├── IERC1155Receiver.sol │ │ │ │ ├── README.adoc │ │ │ │ ├── extensions │ │ │ │ │ ├── ERC1155Burnable.sol │ │ │ │ │ ├── ERC1155Pausable.sol │ │ │ │ │ ├── ERC1155Supply.sol │ │ │ │ │ ├── ERC1155URIStorage.sol │ │ │ │ │ └── IERC1155MetadataURI.sol │ │ │ │ ├── presets │ │ │ │ │ ├── ERC1155PresetMinterPauser.sol │ │ │ │ │ └── README.md │ │ │ │ └── utils │ │ │ │ │ ├── ERC1155Holder.sol │ │ │ │ │ └── ERC1155Receiver.sol │ │ │ ├── ERC20 │ │ │ │ ├── ERC20.sol │ │ │ │ ├── IERC20.sol │ │ │ │ ├── README.adoc │ │ │ │ ├── extensions │ │ │ │ │ ├── ERC20Burnable.sol │ │ │ │ │ ├── ERC20Capped.sol │ │ │ │ │ ├── ERC20FlashMint.sol │ │ │ │ │ ├── ERC20Pausable.sol │ │ │ │ │ ├── ERC20Permit.sol │ │ │ │ │ ├── ERC20Snapshot.sol │ │ │ │ │ ├── ERC20Votes.sol │ │ │ │ │ ├── ERC20VotesComp.sol │ │ │ │ │ ├── ERC20Wrapper.sol │ │ │ │ │ ├── ERC4626.sol │ │ │ │ │ ├── IERC20Metadata.sol │ │ │ │ │ ├── IERC20Permit.sol │ │ │ │ │ ├── draft-ERC20Permit.sol │ │ │ │ │ └── draft-IERC20Permit.sol │ │ │ │ ├── presets │ │ │ │ │ ├── ERC20PresetFixedSupply.sol │ │ │ │ │ ├── ERC20PresetMinterPauser.sol │ │ │ │ │ └── README.md │ │ │ │ └── utils │ │ │ │ │ ├── SafeERC20.sol │ │ │ │ │ └── TokenTimelock.sol │ │ │ ├── ERC721 │ │ │ │ ├── ERC721.sol │ │ │ │ ├── IERC721.sol │ │ │ │ ├── IERC721Receiver.sol │ │ │ │ ├── README.adoc │ │ │ │ ├── extensions │ │ │ │ │ ├── ERC721Burnable.sol │ │ │ │ │ ├── ERC721Consecutive.sol │ │ │ │ │ ├── ERC721Enumerable.sol │ │ │ │ │ ├── ERC721Pausable.sol │ │ │ │ │ ├── ERC721Royalty.sol │ │ │ │ │ ├── ERC721URIStorage.sol │ │ │ │ │ ├── ERC721Votes.sol │ │ │ │ │ ├── ERC721Wrapper.sol │ │ │ │ │ ├── IERC721Enumerable.sol │ │ │ │ │ ├── IERC721Metadata.sol │ │ │ │ │ └── draft-ERC721Votes.sol │ │ │ │ ├── presets │ │ │ │ │ ├── ERC721PresetMinterPauserAutoId.sol │ │ │ │ │ └── README.md │ │ │ │ └── utils │ │ │ │ │ └── ERC721Holder.sol │ │ │ ├── ERC777 │ │ │ │ ├── ERC777.sol │ │ │ │ ├── IERC777.sol │ │ │ │ ├── IERC777Recipient.sol │ │ │ │ ├── IERC777Sender.sol │ │ │ │ ├── README.adoc │ │ │ │ └── presets │ │ │ │ │ └── ERC777PresetFixedSupply.sol │ │ │ └── common │ │ │ │ ├── ERC2981.sol │ │ │ │ └── README.adoc │ │ ├── utils │ │ │ ├── Address.sol │ │ │ ├── Arrays.sol │ │ │ ├── Base64.sol │ │ │ ├── Checkpoints.sol │ │ │ ├── Context.sol │ │ │ ├── Counters.sol │ │ │ ├── Create2.sol │ │ │ ├── Multicall.sol │ │ │ ├── README.adoc │ │ │ ├── ShortStrings.sol │ │ │ ├── StorageSlot.sol │ │ │ ├── Strings.sol │ │ │ ├── Timers.sol │ │ │ ├── cryptography │ │ │ │ ├── ECDSA.sol │ │ │ │ ├── EIP712.sol │ │ │ │ ├── MerkleProof.sol │ │ │ │ ├── SignatureChecker.sol │ │ │ │ └── draft-EIP712.sol │ │ │ ├── escrow │ │ │ │ ├── ConditionalEscrow.sol │ │ │ │ ├── Escrow.sol │ │ │ │ └── RefundEscrow.sol │ │ │ ├── introspection │ │ │ │ ├── ERC165.sol │ │ │ │ ├── ERC165Checker.sol │ │ │ │ ├── ERC165Storage.sol │ │ │ │ ├── ERC1820Implementer.sol │ │ │ │ ├── IERC165.sol │ │ │ │ ├── IERC1820Implementer.sol │ │ │ │ └── IERC1820Registry.sol │ │ │ ├── math │ │ │ │ ├── Math.sol │ │ │ │ ├── SafeCast.sol │ │ │ │ ├── SafeMath.sol │ │ │ │ ├── SignedMath.sol │ │ │ │ └── SignedSafeMath.sol │ │ │ └── structs │ │ │ │ ├── BitMaps.sol │ │ │ │ ├── DoubleEndedQueue.sol │ │ │ │ ├── EnumerableMap.sol │ │ │ │ └── EnumerableSet.sol │ │ └── vendor │ │ │ ├── amb │ │ │ └── IAMB.sol │ │ │ ├── arbitrum │ │ │ ├── IArbSys.sol │ │ │ ├── IBridge.sol │ │ │ ├── IDelayedMessageProvider.sol │ │ │ ├── IInbox.sol │ │ │ └── IOutbox.sol │ │ │ ├── compound │ │ │ ├── ICompoundTimelock.sol │ │ │ └── LICENSE │ │ │ ├── optimism │ │ │ ├── ICrossDomainMessenger.sol │ │ │ └── LICENSE │ │ │ └── polygon │ │ │ └── IFxMessageProcessor.sol │ ├── foundry.toml │ ├── hardhat.config.js │ ├── hardhat │ │ ├── env-artifacts.js │ │ ├── env-contract.js │ │ ├── ignore-unreachable-warnings.js │ │ ├── skip-foundry-tests.js │ │ └── task-test-get-files.js │ ├── lib │ │ ├── erc4626-tests │ │ │ ├── ERC4626.prop.sol │ │ │ ├── ERC4626.test.sol │ │ │ ├── LICENSE │ │ │ └── README.md │ │ └── forge-std │ │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── ci.yml │ │ │ ├── .gitignore │ │ │ ├── .gitmodules │ │ │ ├── LICENSE-APACHE │ │ │ ├── LICENSE-MIT │ │ │ ├── README.md │ │ │ ├── foundry.toml │ │ │ ├── lib │ │ │ └── ds-test │ │ │ │ ├── .github │ │ │ │ └── workflows │ │ │ │ │ └── build.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── default.nix │ │ │ │ ├── demo │ │ │ │ └── demo.sol │ │ │ │ ├── package.json │ │ │ │ └── src │ │ │ │ ├── test.sol │ │ │ │ └── test.t.sol │ │ │ ├── package.json │ │ │ ├── src │ │ │ ├── Base.sol │ │ │ ├── Script.sol │ │ │ ├── StdAssertions.sol │ │ │ ├── StdChains.sol │ │ │ ├── StdCheats.sol │ │ │ ├── StdError.sol │ │ │ ├── StdInvariant.sol │ │ │ ├── StdJson.sol │ │ │ ├── StdMath.sol │ │ │ ├── StdStorage.sol │ │ │ ├── StdStyle.sol │ │ │ ├── StdUtils.sol │ │ │ ├── Test.sol │ │ │ ├── Vm.sol │ │ │ ├── console.sol │ │ │ ├── console2.sol │ │ │ └── interfaces │ │ │ │ ├── IERC1155.sol │ │ │ │ ├── IERC165.sol │ │ │ │ ├── IERC20.sol │ │ │ │ ├── IERC4626.sol │ │ │ │ ├── IERC721.sol │ │ │ │ └── IMulticall3.sol │ │ │ └── test │ │ │ ├── StdAssertions.t.sol │ │ │ ├── StdChains.t.sol │ │ │ ├── StdCheats.t.sol │ │ │ ├── StdError.t.sol │ │ │ ├── StdMath.t.sol │ │ │ ├── StdStorage.t.sol │ │ │ ├── StdStyle.t.sol │ │ │ ├── StdUtils.t.sol │ │ │ ├── compilation │ │ │ ├── CompilationScript.sol │ │ │ ├── CompilationScriptBase.sol │ │ │ ├── CompilationTest.sol │ │ │ └── CompilationTestBase.sol │ │ │ └── fixtures │ │ │ └── broadcast.log.json │ ├── logo.svg │ ├── netlify.toml │ ├── package-lock.json │ ├── package.json │ ├── remappings.txt │ ├── renovate.json │ ├── requirements.txt │ ├── scripts │ │ ├── checks │ │ │ ├── compare-layout.js │ │ │ ├── compareGasReports.js │ │ │ ├── extract-layout.js │ │ │ ├── generation.sh │ │ │ └── inheritance-ordering.js │ │ ├── gen-nav.js │ │ ├── generate │ │ │ ├── format-lines.js │ │ │ ├── run.js │ │ │ └── templates │ │ │ │ ├── Checkpoints.js │ │ │ │ ├── Checkpoints.opts.js │ │ │ │ ├── Checkpoints.t.js │ │ │ │ ├── EnumerableMap.js │ │ │ │ ├── EnumerableSet.js │ │ │ │ ├── SafeCast.js │ │ │ │ ├── StorageSlot.js │ │ │ │ └── conversion.js │ │ ├── git-user-config.sh │ │ ├── helpers.js │ │ ├── migrate-imports.js │ │ ├── prepack.sh │ │ ├── prepare-contracts-package.sh │ │ ├── prepare-docs.sh │ │ ├── prepare.sh │ │ ├── release │ │ │ ├── format-changelog.js │ │ │ ├── synchronize-versions.js │ │ │ ├── update-comment.js │ │ │ ├── version.sh │ │ │ └── workflow │ │ │ │ ├── exit-prerelease.sh │ │ │ │ ├── github-release.js │ │ │ │ ├── integrity-check.sh │ │ │ │ ├── pack.sh │ │ │ │ ├── publish.sh │ │ │ │ ├── rerun.js │ │ │ │ ├── set-changesets-pr-title.js │ │ │ │ ├── start.sh │ │ │ │ └── state.js │ │ ├── remove-ignored-artifacts.js │ │ ├── update-docs-branch.js │ │ └── upgradeable │ │ │ ├── README.md │ │ │ ├── patch-apply.sh │ │ │ ├── patch-save.sh │ │ │ ├── transpile-onto.sh │ │ │ ├── transpile.sh │ │ │ └── upgradeable.patch │ ├── slither.config.json │ └── test │ │ ├── TESTING.md │ │ ├── access │ │ ├── AccessControl.behavior.js │ │ ├── AccessControl.test.js │ │ ├── AccessControlCrossChain.test.js │ │ ├── AccessControlDefaultAdminRules.test.js │ │ ├── AccessControlEnumerable.test.js │ │ ├── Ownable.test.js │ │ └── Ownable2Step.test.js │ │ ├── crosschain │ │ └── CrossChainEnabled.test.js │ │ ├── finance │ │ ├── PaymentSplitter.test.js │ │ ├── VestingWallet.behavior.js │ │ └── VestingWallet.test.js │ │ ├── governance │ │ ├── Governor.t.sol │ │ ├── Governor.test.js │ │ ├── TimelockController.test.js │ │ ├── compatibility │ │ │ └── GovernorCompatibilityBravo.test.js │ │ ├── extensions │ │ │ ├── GovernorComp.test.js │ │ │ ├── GovernorERC721.test.js │ │ │ ├── GovernorPreventLateQuorum.test.js │ │ │ ├── GovernorTimelockCompound.test.js │ │ │ ├── GovernorTimelockControl.test.js │ │ │ ├── GovernorVotesQuorumFraction.test.js │ │ │ └── GovernorWithParams.test.js │ │ └── utils │ │ │ ├── EIP6372.behavior.js │ │ │ ├── Votes.behavior.js │ │ │ └── Votes.test.js │ │ ├── helpers │ │ ├── chainid.js │ │ ├── create2.js │ │ ├── crosschain.js │ │ ├── customError.js │ │ ├── eip712.js │ │ ├── enums.js │ │ ├── erc1967.js │ │ ├── governance.js │ │ ├── map-values.js │ │ ├── sign.js │ │ ├── time.js │ │ └── txpool.js │ │ ├── metatx │ │ ├── ERC2771Context.test.js │ │ └── MinimalForwarder.test.js │ │ ├── migrate-imports.test.js │ │ ├── proxy │ │ ├── Clones.behaviour.js │ │ ├── Clones.test.js │ │ ├── ERC1967 │ │ │ └── ERC1967Proxy.test.js │ │ ├── Proxy.behaviour.js │ │ ├── beacon │ │ │ ├── BeaconProxy.test.js │ │ │ └── UpgradeableBeacon.test.js │ │ ├── transparent │ │ │ ├── ProxyAdmin.test.js │ │ │ ├── TransparentUpgradeableProxy.behaviour.js │ │ │ └── TransparentUpgradeableProxy.test.js │ │ └── utils │ │ │ ├── Initializable.test.js │ │ │ └── UUPSUpgradeable.test.js │ │ ├── security │ │ ├── Pausable.test.js │ │ ├── PullPayment.test.js │ │ └── ReentrancyGuard.test.js │ │ ├── token │ │ ├── ERC1155 │ │ │ ├── ERC1155.behavior.js │ │ │ ├── ERC1155.test.js │ │ │ ├── extensions │ │ │ │ ├── ERC1155Burnable.test.js │ │ │ │ ├── ERC1155Pausable.test.js │ │ │ │ ├── ERC1155Supply.test.js │ │ │ │ └── ERC1155URIStorage.test.js │ │ │ ├── presets │ │ │ │ └── ERC1155PresetMinterPauser.test.js │ │ │ └── utils │ │ │ │ └── ERC1155Holder.test.js │ │ ├── ERC20 │ │ │ ├── ERC20.behavior.js │ │ │ ├── ERC20.test.js │ │ │ ├── extensions │ │ │ │ ├── ERC20Burnable.behavior.js │ │ │ │ ├── ERC20Burnable.test.js │ │ │ │ ├── ERC20Capped.behavior.js │ │ │ │ ├── ERC20Capped.test.js │ │ │ │ ├── ERC20FlashMint.test.js │ │ │ │ ├── ERC20Pausable.test.js │ │ │ │ ├── ERC20Snapshot.test.js │ │ │ │ ├── ERC20Votes.test.js │ │ │ │ ├── ERC20VotesComp.test.js │ │ │ │ ├── ERC20Wrapper.test.js │ │ │ │ ├── ERC4626.t.sol │ │ │ │ ├── ERC4626.test.js │ │ │ │ └── draft-ERC20Permit.test.js │ │ │ ├── presets │ │ │ │ ├── ERC20PresetFixedSupply.test.js │ │ │ │ └── ERC20PresetMinterPauser.test.js │ │ │ └── utils │ │ │ │ ├── SafeERC20.test.js │ │ │ │ └── TokenTimelock.test.js │ │ ├── ERC721 │ │ │ ├── ERC721.behavior.js │ │ │ ├── ERC721.test.js │ │ │ ├── ERC721Enumerable.test.js │ │ │ ├── extensions │ │ │ │ ├── ERC721Burnable.test.js │ │ │ │ ├── ERC721Consecutive.t.sol │ │ │ │ ├── ERC721Consecutive.test.js │ │ │ │ ├── ERC721Pausable.test.js │ │ │ │ ├── ERC721Royalty.test.js │ │ │ │ ├── ERC721URIStorage.test.js │ │ │ │ ├── ERC721Votes.test.js │ │ │ │ └── ERC721Wrapper.test.js │ │ │ ├── presets │ │ │ │ └── ERC721PresetMinterPauserAutoId.test.js │ │ │ └── utils │ │ │ │ └── ERC721Holder.test.js │ │ ├── ERC777 │ │ │ ├── ERC777.behavior.js │ │ │ ├── ERC777.test.js │ │ │ └── presets │ │ │ │ └── ERC777PresetFixedSupply.test.js │ │ └── common │ │ │ └── ERC2981.behavior.js │ │ └── utils │ │ ├── Address.test.js │ │ ├── Arrays.test.js │ │ ├── Base64.test.js │ │ ├── Checkpoints.t.sol │ │ ├── Checkpoints.test.js │ │ ├── Context.behavior.js │ │ ├── Context.test.js │ │ ├── Counters.test.js │ │ ├── Create2.test.js │ │ ├── Multicall.test.js │ │ ├── ShortStrings.t.sol │ │ ├── ShortStrings.test.js │ │ ├── StorageSlot.test.js │ │ ├── Strings.test.js │ │ ├── TimersBlockNumberImpl.test.js │ │ ├── TimersTimestamp.test.js │ │ ├── cryptography │ │ ├── ECDSA.test.js │ │ ├── EIP712.test.js │ │ ├── MerkleProof.test.js │ │ └── SignatureChecker.test.js │ │ ├── escrow │ │ ├── ConditionalEscrow.test.js │ │ ├── Escrow.behavior.js │ │ ├── Escrow.test.js │ │ └── RefundEscrow.test.js │ │ ├── introspection │ │ ├── ERC165.test.js │ │ ├── ERC165Checker.test.js │ │ ├── ERC165Storage.test.js │ │ ├── ERC1820Implementer.test.js │ │ └── SupportsInterface.behavior.js │ │ ├── math │ │ ├── Math.t.sol │ │ ├── Math.test.js │ │ ├── SafeCast.test.js │ │ ├── SafeMath.test.js │ │ ├── SignedMath.test.js │ │ └── SignedSafeMath.test.js │ │ └── structs │ │ ├── BitMap.test.js │ │ ├── DoubleEndedQueue.test.js │ │ ├── EnumerableMap.behavior.js │ │ ├── EnumerableMap.test.js │ │ ├── EnumerableSet.behavior.js │ │ └── EnumerableSet.test.js ├── v4-core │ ├── .forge-snapshots │ │ ├── BitMathLeastSignificantBitMaxUint128.snap │ │ ├── BitMathLeastSignificantBitMaxUint256.snap │ │ ├── BitMathLeastSignificantBitSmallNumber.snap │ │ ├── BitMathMostSignificantBitMaxUint128.snap │ │ ├── BitMathMostSignificantBitMaxUint256.snap │ │ ├── BitMathMostSignificantBitSmallNumber.snap │ │ ├── HooksShouldCallBeforeSwap.snap │ │ ├── NoDelegateCallOverhead.snap │ │ ├── donate gas with 1 token.snap │ │ ├── donate gas with 2 tokens.snap │ │ ├── gas overhead of no-op lock.snap │ │ ├── initialize.snap │ │ ├── mint with empty hook.snap │ │ ├── mint with native token.snap │ │ ├── mint.snap │ │ ├── poolExtsloadSlot0.snap │ │ ├── poolExtsloadTickInfoStruct.snap │ │ ├── simple swap.snap │ │ ├── swap against liquidity with native token.snap │ │ ├── swap against liquidity.snap │ │ ├── swap with hooks.snap │ │ └── swap with native.snap │ ├── .gitattributes │ ├── .github │ │ ├── ISSUE_TEMPLATE │ │ │ ├── BUG_REPORT.yml │ │ │ └── FEATURE_IMPROVEMENT.yml │ │ ├── pull_request_template.md │ │ └── workflows │ │ │ ├── lint.yml │ │ │ ├── mythx.yml │ │ │ └── tests.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .nvmrc │ ├── .prettierignore │ ├── .prettierrc │ ├── .solhint.json │ ├── .yarnrc │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── contracts │ │ ├── NoDelegateCall.sol │ │ ├── Owned.sol │ │ ├── PoolManager.sol │ │ ├── interfaces │ │ │ ├── IDynamicFeeManager.sol │ │ │ ├── IHookFeeManager.sol │ │ │ ├── IHooks.sol │ │ │ ├── IPoolManager.sol │ │ │ ├── IProtocolFeeController.sol │ │ │ ├── callback │ │ │ │ └── ILockCallback.sol │ │ │ └── external │ │ │ │ └── IERC20Minimal.sol │ │ ├── libraries │ │ │ ├── BitMath.sol │ │ │ ├── CurrencyLibrary.sol │ │ │ ├── Fees.sol │ │ │ ├── FixedPoint128.sol │ │ │ ├── FixedPoint96.sol │ │ │ ├── FullMath.sol │ │ │ ├── Hooks.sol │ │ │ ├── Pool.sol │ │ │ ├── PoolId.sol │ │ │ ├── Position.sol │ │ │ ├── SafeCast.sol │ │ │ ├── SqrtPriceMath.sol │ │ │ ├── SwapMath.sol │ │ │ ├── TickBitmap.sol │ │ │ ├── TickMath.sol │ │ │ └── UnsafeMath.sol │ │ ├── test │ │ │ ├── BitMathEchidnaTest.sol │ │ │ ├── EmptyTestHooks.sol │ │ │ ├── FullMathEchidnaTest.sol │ │ │ ├── FullMathTest.sol │ │ │ ├── HooksTest.sol │ │ │ ├── MockContract.sol │ │ │ ├── MockHooks.sol │ │ │ ├── NoDelegateCallTest.sol │ │ │ ├── PoolDonateTest.sol │ │ │ ├── PoolLockTest.sol │ │ │ ├── PoolManagerReentrancyTest.sol │ │ │ ├── PoolModifyPositionTest.sol │ │ │ ├── PoolSwapTest.sol │ │ │ ├── PoolTakeTest.sol │ │ │ ├── ProtocolFeeControllerTest.sol │ │ │ ├── SqrtPriceMathEchidnaTest.sol │ │ │ ├── SqrtPriceMathTest.sol │ │ │ ├── SwapMathEchidnaTest.sol │ │ │ ├── SwapMathTest.sol │ │ │ ├── TestERC20.sol │ │ │ ├── TestInvalidERC20.sol │ │ │ ├── TickBitmapEchidnaTest.sol │ │ │ ├── TickBitmapTest.sol │ │ │ ├── TickEchidnaTest.sol │ │ │ ├── TickMathEchidnaTest.sol │ │ │ ├── TickMathTest.sol │ │ │ ├── TickOverflowSafetyEchidnaTest.sol │ │ │ ├── TickTest.sol │ │ │ └── UnsafeMathEchidnaTest.sol │ │ └── types │ │ │ └── BalanceDelta.sol │ ├── echidna.config.yml │ ├── foundry.toml │ ├── hardhat.config.ts │ ├── justfile │ ├── latex │ │ ├── main.bib │ │ └── main.tex │ ├── lib │ │ ├── forge-gas-snapshot │ │ │ ├── .forge-snapshots │ │ │ │ ├── add.snap │ │ │ │ ├── addClosure.snap │ │ │ │ ├── addFirst.snap │ │ │ │ ├── addSecond.snap │ │ │ │ ├── addThird.snap │ │ │ │ ├── checkManyAdd.snap │ │ │ │ ├── checkManySstore.snap │ │ │ │ ├── checkSize.snap │ │ │ │ ├── checkSizeFail.snap │ │ │ │ ├── internalClosure.snap │ │ │ │ ├── manyAdd.snap │ │ │ │ ├── manySstore.snap │ │ │ │ ├── sizeTarget.snap │ │ │ │ ├── sstoreClosure.snap │ │ │ │ └── value.snap │ │ │ ├── .github │ │ │ │ └── workflows │ │ │ │ │ └── test.yml │ │ │ ├── .gitignore │ │ │ ├── .gitmodules │ │ │ ├── README.md │ │ │ ├── foundry.toml │ │ │ ├── src │ │ │ │ ├── GasSnapshot.sol │ │ │ │ ├── test │ │ │ │ │ └── SimpleOperations.sol │ │ │ │ └── utils │ │ │ │ │ └── UintString.sol │ │ │ └── test │ │ │ │ └── GasSnapshot.t.sol │ │ ├── forge-std │ │ │ ├── .github │ │ │ │ └── workflows │ │ │ │ │ └── ci.yml │ │ │ ├── .gitignore │ │ │ ├── .gitmodules │ │ │ ├── LICENSE-APACHE │ │ │ ├── LICENSE-MIT │ │ │ ├── README.md │ │ │ ├── foundry.toml │ │ │ ├── lib │ │ │ │ └── ds-test │ │ │ │ │ ├── .github │ │ │ │ │ └── workflows │ │ │ │ │ │ └── build.yml │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── default.nix │ │ │ │ │ ├── demo │ │ │ │ │ └── demo.sol │ │ │ │ │ ├── package.json │ │ │ │ │ └── src │ │ │ │ │ ├── test.sol │ │ │ │ │ └── test.t.sol │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── Base.sol │ │ │ │ ├── Script.sol │ │ │ │ ├── StdAssertions.sol │ │ │ │ ├── StdChains.sol │ │ │ │ ├── StdCheats.sol │ │ │ │ ├── StdError.sol │ │ │ │ ├── StdInvariant.sol │ │ │ │ ├── StdJson.sol │ │ │ │ ├── StdMath.sol │ │ │ │ ├── StdStorage.sol │ │ │ │ ├── StdStyle.sol │ │ │ │ ├── StdUtils.sol │ │ │ │ ├── Test.sol │ │ │ │ ├── Vm.sol │ │ │ │ ├── console.sol │ │ │ │ ├── console2.sol │ │ │ │ └── interfaces │ │ │ │ │ ├── IERC1155.sol │ │ │ │ │ ├── IERC165.sol │ │ │ │ │ ├── IERC20.sol │ │ │ │ │ ├── IERC4626.sol │ │ │ │ │ ├── IERC721.sol │ │ │ │ │ └── IMulticall3.sol │ │ │ └── test │ │ │ │ ├── StdAssertions.t.sol │ │ │ │ ├── StdChains.t.sol │ │ │ │ ├── StdCheats.t.sol │ │ │ │ ├── StdError.t.sol │ │ │ │ ├── StdMath.t.sol │ │ │ │ ├── StdStorage.t.sol │ │ │ │ ├── StdStyle.t.sol │ │ │ │ ├── StdUtils.t.sol │ │ │ │ ├── compilation │ │ │ │ ├── CompilationScript.sol │ │ │ │ ├── CompilationScriptBase.sol │ │ │ │ ├── CompilationTest.sol │ │ │ │ └── CompilationTestBase.sol │ │ │ │ └── fixtures │ │ │ │ └── broadcast.log.json │ │ └── solmate │ │ │ ├── .gas-snapshot │ │ │ ├── .gitattributes │ │ │ ├── .github │ │ │ ├── pull_request_template.md │ │ │ └── workflows │ │ │ │ └── tests.yml │ │ │ ├── .gitignore │ │ │ ├── .gitmodules │ │ │ ├── .prettierignore │ │ │ ├── .prettierrc │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── audits │ │ │ └── v6-Fixed-Point-Solutions.pdf │ │ │ ├── foundry.toml │ │ │ ├── lib │ │ │ └── ds-test │ │ │ │ ├── .gitignore │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── default.nix │ │ │ │ ├── demo │ │ │ │ └── demo.sol │ │ │ │ ├── package.json │ │ │ │ └── src │ │ │ │ └── test.sol │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── src │ │ │ ├── auth │ │ │ ├── Auth.sol │ │ │ ├── Owned.sol │ │ │ └── authorities │ │ │ │ ├── MultiRolesAuthority.sol │ │ │ │ └── RolesAuthority.sol │ │ │ ├── mixins │ │ │ └── ERC4626.sol │ │ │ ├── test │ │ │ ├── Auth.t.sol │ │ │ ├── Bytes32AddressLib.t.sol │ │ │ ├── CREATE3.t.sol │ │ │ ├── DSTestPlus.t.sol │ │ │ ├── ERC1155.t.sol │ │ │ ├── ERC20.t.sol │ │ │ ├── ERC4626.t.sol │ │ │ ├── ERC721.t.sol │ │ │ ├── FixedPointMathLib.t.sol │ │ │ ├── LibString.t.sol │ │ │ ├── MerkleProofLib.t.sol │ │ │ ├── MultiRolesAuthority.t.sol │ │ │ ├── Owned.t.sol │ │ │ ├── ReentrancyGuard.t.sol │ │ │ ├── RolesAuthority.t.sol │ │ │ ├── SSTORE2.t.sol │ │ │ ├── SafeCastLib.t.sol │ │ │ ├── SafeTransferLib.t.sol │ │ │ ├── SignedWadMath.t.sol │ │ │ ├── WETH.t.sol │ │ │ └── utils │ │ │ │ ├── DSInvariantTest.sol │ │ │ │ ├── DSTestPlus.sol │ │ │ │ ├── Hevm.sol │ │ │ │ ├── mocks │ │ │ │ ├── MockAuthChild.sol │ │ │ │ ├── MockAuthority.sol │ │ │ │ ├── MockERC1155.sol │ │ │ │ ├── MockERC20.sol │ │ │ │ ├── MockERC4626.sol │ │ │ │ ├── MockERC721.sol │ │ │ │ └── MockOwned.sol │ │ │ │ └── weird-tokens │ │ │ │ ├── MissingReturnToken.sol │ │ │ │ ├── ReturnsFalseToken.sol │ │ │ │ ├── ReturnsGarbageToken.sol │ │ │ │ ├── ReturnsTooLittleToken.sol │ │ │ │ ├── ReturnsTooMuchToken.sol │ │ │ │ ├── ReturnsTwoToken.sol │ │ │ │ └── RevertingToken.sol │ │ │ ├── tokens │ │ │ ├── ERC1155.sol │ │ │ ├── ERC20.sol │ │ │ ├── ERC721.sol │ │ │ └── WETH.sol │ │ │ └── utils │ │ │ ├── Bytes32AddressLib.sol │ │ │ ├── CREATE3.sol │ │ │ ├── FixedPointMathLib.sol │ │ │ ├── LibString.sol │ │ │ ├── MerkleProofLib.sol │ │ │ ├── ReentrancyGuard.sol │ │ │ ├── SSTORE2.sol │ │ │ ├── SafeCastLib.sol │ │ │ ├── SafeTransferLib.sol │ │ │ └── SignedWadMath.sol │ ├── package.json │ ├── remappings.txt │ ├── test │ │ ├── FullMath.spec.ts │ │ ├── PoolManager.gas.spec.ts │ │ ├── PoolManager.spec.ts │ │ ├── SqrtPriceMath.spec.ts │ │ ├── SwapMath.spec.ts │ │ ├── Tick.spec.ts │ │ ├── TickBitmap.spec.ts │ │ ├── TickMath.spec.ts │ │ ├── __snapshots__ │ │ │ ├── BitMath.spec.ts.snap │ │ │ ├── Hooks.spec.ts.snap │ │ │ ├── NoDelegateCall.spec.ts.snap │ │ │ ├── Oracle.spec.ts.snap │ │ │ ├── PoolManager.gas.spec.ts.snap │ │ │ ├── PoolManager.spec.ts.snap │ │ │ ├── SqrtPriceMath.spec.ts.snap │ │ │ ├── SwapMath.spec.ts.snap │ │ │ ├── Tick.spec.ts.snap │ │ │ ├── TickBitmap.spec.ts.snap │ │ │ └── TickMath.spec.ts.snap │ │ ├── foundry-tests │ │ │ ├── BitMath.t.sol │ │ │ ├── DynamicFees.t.sol │ │ │ ├── Fees.t.sol │ │ │ ├── Hooks.t.sol │ │ │ ├── NoDelegateCall.t.sol │ │ │ ├── Owned.t.sol │ │ │ ├── Pool.t.sol │ │ │ ├── PoolManager.t.sol │ │ │ ├── SafeCast.t.sol │ │ │ ├── types │ │ │ │ └── BalanceDelta.t.sol │ │ │ └── utils │ │ │ │ ├── Deployers.sol │ │ │ │ ├── MockERC20.sol │ │ │ │ └── TokenFixture.sol │ │ └── shared │ │ │ ├── checkObservationEquals.ts │ │ │ ├── constants.ts │ │ │ ├── expect.ts │ │ │ ├── fixtures.ts │ │ │ ├── format.ts │ │ │ ├── mockContract.ts │ │ │ └── utilities.ts │ ├── tsconfig.json │ ├── whitepaper-v4-draft.pdf │ └── yarn.lock └── v4-periphery │ ├── .forge-snapshots │ ├── FullOracleObserve0After5Seconds.snap │ ├── FullOracleObserve200By13.snap │ ├── FullOracleObserve200By13Plus5.snap │ ├── FullOracleObserve5After5Seconds.snap │ ├── FullOracleObserveOldest.snap │ ├── FullOracleObserveOldestAfter5Seconds.snap │ ├── FullOracleObserveZero.snap │ ├── OracleGrow10Slots.snap │ ├── OracleGrow10SlotsCardinalityGreater.snap │ ├── OracleGrow1Slot.snap │ ├── OracleGrow1SlotCardinalityGreater.snap │ ├── OracleInitialize.snap │ ├── OracleObserveBetweenOldestAndOldestPlusOne.snap │ ├── OracleObserveCurrentTime.snap │ ├── OracleObserveCurrentTimeCounterfactual.snap │ ├── OracleObserveLast20Seconds.snap │ ├── OracleObserveLatestEqual.snap │ ├── OracleObserveLatestTransform.snap │ ├── OracleObserveMiddle.snap │ ├── OracleObserveOldest.snap │ ├── OracleObserveSinceMostRecent.snap │ └── TWAMMSubmitOrder.snap │ ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── BUG_REPORT.yml │ │ └── FEATURE_IMPROVEMENT.yml │ ├── pull_request_template.md │ └── workflows │ │ ├── lint.yml │ │ └── test.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .nvmrc │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── contracts │ ├── BaseHook.sol │ ├── hooks │ │ └── examples │ │ │ ├── GeomeanOracle.sol │ │ │ ├── LimitOrder.sol │ │ │ ├── TWAMM.sol │ │ │ └── VolatilityOracle.sol │ ├── interfaces │ │ └── ITWAMM.sol │ └── libraries │ │ ├── Oracle.sol │ │ ├── PoolGetters.sol │ │ ├── TWAMM │ │ ├── ABDKMathQuad.sol │ │ ├── OrderPool.sol │ │ └── TwammMath.sol │ │ └── TransferHelper.sol │ ├── foundry.toml │ ├── remappings.txt │ └── test │ ├── GeomeanOracle.t.sol │ ├── LimitOrder.t.sol │ ├── Oracle.t.sol │ ├── TWAMM.t.sol │ └── shared │ ├── GetSender.sol │ └── implementation │ ├── GeomeanOracleImplementation.sol │ ├── LimitOrderImplementation.sol │ ├── OracleImplementation.sol │ └── TWAMMImplementation.sol ├── remappings.txt ├── script └── Counter.s.sol ├── src ├── TestHook.sol └── implementation │ └── TestImplementation.sol └── test └── TestHook.t.sol /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Docs 11 | docs/ 12 | 13 | # Dotenv file 14 | .env 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "lib/v4-core"] 5 | path = lib/v4-core 6 | url = https://github.com/Uniswap/v4-core 7 | [submodule "lib/v4-periphery"] 8 | path = lib/v4-periphery 9 | url = https://github.com/uniswap/v4-periphery 10 | [submodule "lib/openzeppelin-contracts"] 11 | path = lib/openzeppelin-contracts 12 | url = https://github.com/openzeppelin/openzeppelin-contracts 13 | [submodule "lib/forge-gas-snapshot"] 14 | path = lib/forge-gas-snapshot 15 | url = https://github.com/marktoda/forge-gas-snapshot 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Uniswap v4 Tests 2 | 3 | A Uniswap v4 hook which creates an afterSwap hook to check if price is above or below 1:1 for a stable pair. After a swap takes place if price is below 1:1 it will rebalance the pool either by adding liquidity or making a swap. 4 | 5 | Test in foundry (recommend using WSL or a unix based OS) 6 | ``` 7 | curl -L https://foundry.paradigm.xyz | bash 8 | source /home/james/.bashrc 9 | foundryup 10 | forge install https://github.com/Uniswap/v4-core --no-commit 11 | forge install openzeppelin/openzeppelin-contracts --no-commit 12 | forge install marktoda/forge-gas-snapshot --no-commit 13 | forge test 14 | ``` 15 | 16 | More info on Uniswap v4 hooks at https://jamesbachini.com/uniswap-v4-hooks/ 17 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = "src" 3 | out = "out" 4 | libs = ["lib"] 5 | ffi = true 6 | fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] 7 | 8 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/add.snap: -------------------------------------------------------------------------------- 1 | 5247 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/addClosure.snap: -------------------------------------------------------------------------------- 1 | 3060 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/addFirst.snap: -------------------------------------------------------------------------------- 1 | 5247 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/addSecond.snap: -------------------------------------------------------------------------------- 1 | 744 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/addThird.snap: -------------------------------------------------------------------------------- 1 | 744 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/checkManyAdd.snap: -------------------------------------------------------------------------------- 1 | 24330 2 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/checkManySstore.snap: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/checkSize.snap: -------------------------------------------------------------------------------- 1 | 303 2 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/checkSizeFail.snap: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/internalClosure.snap: -------------------------------------------------------------------------------- 1 | 19177 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/manyAdd.snap: -------------------------------------------------------------------------------- 1 | 24330 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/manySstore.snap: -------------------------------------------------------------------------------- 1 | 56084 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/sizeTarget.snap: -------------------------------------------------------------------------------- 1 | 303 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/sstoreClosure.snap: -------------------------------------------------------------------------------- 1 | 53894 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.forge-snapshots/value.snap: -------------------------------------------------------------------------------- 1 | 1234 -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | FOUNDRY_PROFILE: ci 7 | 8 | jobs: 9 | check: 10 | strategy: 11 | fail-fast: true 12 | 13 | name: Foundry project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | with: 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run Forge build 26 | run: | 27 | forge --version 28 | forge build --sizes 29 | id: build 30 | 31 | - name: Run Forge tests 32 | run: | 33 | forge test -vvv 34 | id: test 35 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | lib/ 3 | cache/ 4 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | ffi = true 6 | fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] 7 | -------------------------------------------------------------------------------- /lib/forge-gas-snapshot/src/test/SimpleOperations.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.15; 3 | 4 | contract SimpleOperations { 5 | uint256 internal test; 6 | 7 | function add() public pure { 8 | uint256 x = 1; 9 | x++; 10 | } 11 | 12 | function manyAdd() public pure { 13 | uint256 x; 14 | for (uint256 i = 0; i < 100; i++) { 15 | x = i + 1; 16 | } 17 | } 18 | 19 | function manySstore() public { 20 | for (uint256 i = 0; i < 100; i++) { 21 | test = i + 2; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/forge-std/.github/workflows/sync.yml: -------------------------------------------------------------------------------- 1 | name: Sync Release Branch 2 | 3 | on: 4 | release: 5 | types: 6 | - created 7 | 8 | jobs: 9 | sync-release-branch: 10 | runs-on: ubuntu-latest 11 | if: startsWith(github.event.release.tag_name, 'v1') 12 | steps: 13 | - name: Check out the repo 14 | uses: actions/checkout@v3 15 | with: 16 | fetch-depth: 0 17 | ref: v1 18 | 19 | - name: Configure Git 20 | run: | 21 | git config user.name github-actions[bot] 22 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com 23 | 24 | - name: Sync Release Branch 25 | run: | 26 | git fetch --tags 27 | git checkout v1 28 | git reset --hard ${GITHUB_REF} 29 | git push --force 30 | -------------------------------------------------------------------------------- /lib/forge-std/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | out/ 3 | .vscode 4 | .idea 5 | -------------------------------------------------------------------------------- /lib/forge-std/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /lib/forge-std/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | fs_permissions = [{ access = "read-write", path = "./"}] 3 | 4 | [rpc_endpoints] 5 | # The RPC URLs are modified versions of the default for testing initialization. 6 | mainnet = "https://mainnet.infura.io/v3/b1d3925804e74152b316ca7da97060d3" # Different API key. 7 | optimism_goerli = "https://goerli.optimism.io/" # Adds a trailing slash. 8 | arbitrum_one_goerli = "https://goerli-rollup.arbitrum.io/rpc/" # Adds a trailing slash. 9 | needs_undefined_env_var = "${UNDEFINED_RPC_URL_PLACEHOLDER}" 10 | 11 | [fmt] 12 | # These are all the `forge fmt` defaults. 13 | line_length = 120 14 | tab_width = 4 15 | bracket_spacing = false 16 | int_types = 'long' 17 | multiline_func_header = 'attributes_first' 18 | quote_style = 'double' 19 | number_underscore = 'preserve' 20 | single_line_statement_blocks = 'preserve' 21 | ignore = ["src/console.sol", "src/console2.sol"] -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/.gitignore: -------------------------------------------------------------------------------- 1 | /.dapple 2 | /build 3 | /out 4 | /cache/ 5 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/Makefile: -------------------------------------------------------------------------------- 1 | all:; dapp build 2 | 3 | test: 4 | -dapp --use solc:0.4.23 build 5 | -dapp --use solc:0.4.26 build 6 | -dapp --use solc:0.5.17 build 7 | -dapp --use solc:0.6.12 build 8 | -dapp --use solc:0.7.5 build 9 | 10 | demo: 11 | DAPP_SRC=demo dapp --use solc:0.7.5 build 12 | -hevm dapp-test --verbose 3 13 | 14 | .PHONY: test demo 15 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/default.nix: -------------------------------------------------------------------------------- 1 | { solidityPackage, dappsys }: solidityPackage { 2 | name = "ds-test"; 3 | src = ./src; 4 | } 5 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ds-test", 3 | "version": "1.0.0", 4 | "description": "Assertions, equality checks and other test helpers ", 5 | "bugs": "https://github.com/dapphub/ds-test/issues", 6 | "license": "GPL-3.0", 7 | "author": "Contributors to ds-test", 8 | "files": [ 9 | "src/*" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/dapphub/ds-test.git" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/forge-std/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "forge-std", 3 | "version": "1.5.6", 4 | "description": "Forge Standard Library is a collection of helpful contracts and libraries for use with Forge and Foundry.", 5 | "homepage": "https://book.getfoundry.sh/forge/forge-std", 6 | "bugs": "https://github.com/foundry-rs/forge-std/issues", 7 | "license": "(Apache-2.0 OR MIT)", 8 | "author": "Contributors to Forge Standard Library", 9 | "files": [ 10 | "src/**/*" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/foundry-rs/forge-std.git" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/forge-std/src/Script.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | // 💬 ABOUT 5 | // Standard Library's default Script. 6 | 7 | // 🧩 MODULES 8 | import {ScriptBase} from "./Base.sol"; 9 | import {console} from "./console.sol"; 10 | import {console2} from "./console2.sol"; 11 | import {StdChains} from "./StdChains.sol"; 12 | import {StdCheatsSafe} from "./StdCheats.sol"; 13 | import {stdJson} from "./StdJson.sol"; 14 | import {stdMath} from "./StdMath.sol"; 15 | import {StdStorage, stdStorageSafe} from "./StdStorage.sol"; 16 | import {StdUtils} from "./StdUtils.sol"; 17 | import {VmSafe} from "./Vm.sol"; 18 | 19 | // 📦 BOILERPLATE 20 | import {ScriptBase} from "./Base.sol"; 21 | 22 | // ⭐️ SCRIPT 23 | abstract contract Script is StdChains, StdCheatsSafe, StdUtils, ScriptBase { 24 | // Note: IS_SCRIPT() must return true. 25 | bool public IS_SCRIPT = true; 26 | } 27 | -------------------------------------------------------------------------------- /lib/forge-std/src/StdError.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // Panics work for versions >=0.8.0, but we lowered the pragma to make this compatible with Test 3 | pragma solidity >=0.6.2 <0.9.0; 4 | 5 | library stdError { 6 | bytes public constant assertionError = abi.encodeWithSignature("Panic(uint256)", 0x01); 7 | bytes public constant arithmeticError = abi.encodeWithSignature("Panic(uint256)", 0x11); 8 | bytes public constant divisionError = abi.encodeWithSignature("Panic(uint256)", 0x12); 9 | bytes public constant enumConversionError = abi.encodeWithSignature("Panic(uint256)", 0x21); 10 | bytes public constant encodeStorageError = abi.encodeWithSignature("Panic(uint256)", 0x22); 11 | bytes public constant popError = abi.encodeWithSignature("Panic(uint256)", 0x31); 12 | bytes public constant indexOOBError = abi.encodeWithSignature("Panic(uint256)", 0x32); 13 | bytes public constant memOverflowError = abi.encodeWithSignature("Panic(uint256)", 0x41); 14 | bytes public constant zeroVarError = abi.encodeWithSignature("Panic(uint256)", 0x51); 15 | } 16 | -------------------------------------------------------------------------------- /lib/forge-std/src/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2; 3 | 4 | interface IERC165 { 5 | /// @notice Query if a contract implements an interface 6 | /// @param interfaceID The interface identifier, as specified in ERC-165 7 | /// @dev Interface identification is specified in ERC-165. This function 8 | /// uses less than 30,000 gas. 9 | /// @return `true` if the contract implements `interfaceID` and 10 | /// `interfaceID` is not 0xffffffff, `false` otherwise 11 | function supportsInterface(bytes4 interfaceID) external view returns (bool); 12 | } 13 | -------------------------------------------------------------------------------- /lib/forge-std/test/compilation/CompilationScript.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScript is Script {} 11 | -------------------------------------------------------------------------------- /lib/forge-std/test/compilation/CompilationScriptBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScriptBase is ScriptBase {} 11 | -------------------------------------------------------------------------------- /lib/forge-std/test/compilation/CompilationTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTest is Test {} 11 | -------------------------------------------------------------------------------- /lib/forge-std/test/compilation/CompilationTestBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTestBase is TestBase {} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", 3 | "changelog": [ 4 | "@changesets/changelog-github", 5 | { 6 | "repo": "OpenZeppelin/openzeppelin-contracts" 7 | } 8 | ], 9 | "commit": false, 10 | "access": "public", 11 | "baseBranch": "master" 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: off 2 | github_checks: 3 | annotations: false 4 | coverage: 5 | status: 6 | patch: 7 | default: 8 | target: 95% 9 | only_pulls: true 10 | project: 11 | default: 12 | threshold: 1% 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | end_of_line = lf 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = false 12 | max_line_length = 120 13 | 14 | [*.sol] 15 | indent_size = 4 16 | 17 | [*.js] 18 | indent_size = 2 19 | 20 | [*.{adoc,md}] 21 | max_line_length = 0 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends" : [ 4 | "eslint:recommended", 5 | "prettier", 6 | ], 7 | "env": { 8 | "es2022": true, 9 | "browser": true, 10 | "node": true, 11 | "mocha": true, 12 | }, 13 | "globals" : { 14 | "artifacts": "readonly", 15 | "contract": "readonly", 16 | "web3": "readonly", 17 | "extendEnvironment": "readonly", 18 | "expect": "readonly", 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug in OpenZeppelin Contracts 4 | 5 | --- 6 | 7 | 8 | 9 | 10 | 11 | **💻 Environment** 12 | 13 | 14 | 15 | **📝 Details** 16 | 17 | 18 | 19 | **🔢 Code to reproduce bug** 20 | 21 | 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Questions & Support Requests 3 | url: https://forum.openzeppelin.com/c/support/contracts/18 4 | about: Ask in the OpenZeppelin Forum 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for OpenZeppelin Contracts 4 | 5 | --- 6 | 7 | **🧐 Motivation** 8 | 9 | 10 | **📝 Details** 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Fixes #???? 7 | 8 | 9 | 10 | 11 | 12 | #### PR Checklist 13 | 14 | 15 | 16 | 17 | 18 | - [ ] Tests 19 | - [ ] Documentation 20 | - [ ] Changeset entry (run `npx changeset add`) 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/actions/setup/action.yml: -------------------------------------------------------------------------------- 1 | name: Setup 2 | 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: actions/setup-node@v3 7 | with: 8 | node-version: 14.x 9 | - uses: actions/cache@v3 10 | id: cache 11 | with: 12 | path: '**/node_modules' 13 | key: npm-v3-${{ hashFiles('**/package-lock.json') }} 14 | - name: Install dependencies 15 | run: npm ci 16 | shell: bash 17 | if: steps.cache.outputs.cache-hit != 'true' 18 | env: 19 | SKIP_COMPILE: true 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/actionlint.yml: -------------------------------------------------------------------------------- 1 | name: lint workflows 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - '.github/**/*.ya?ml' 7 | 8 | jobs: 9 | lint: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: Add problem matchers 14 | run: | 15 | # https://github.com/rhysd/actionlint/blob/3a2f2c7/docs/usage.md#problem-matchers 16 | curl -LO https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json 17 | echo "::add-matcher::actionlint-matcher.json" 18 | - uses: docker://rhysd/actionlint:latest 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/changeset.yml: -------------------------------------------------------------------------------- 1 | name: changeset 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | types: 8 | - opened 9 | - synchronize 10 | - labeled 11 | - unlabeled 12 | 13 | concurrency: 14 | group: changeset-${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | check: 19 | runs-on: ubuntu-latest 20 | if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-changeset') }} 21 | steps: 22 | - uses: actions/checkout@v3 23 | with: 24 | fetch-depth: 0 # Include history so Changesets finds merge-base 25 | - name: Set up environment 26 | uses: ./.github/actions/setup 27 | - name: Check changeset 28 | run: npx changeset status --since=origin/${{ github.base_ref }} 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Build Docs 2 | 3 | on: 4 | push: 5 | branches: [release-v*] 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Set up environment 16 | uses: ./.github/actions/setup 17 | - run: bash scripts/git-user-config.sh 18 | - run: node scripts/update-docs-branch.js 19 | - run: git push --all origin 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | branch = v1 3 | path = lib/forge-std 4 | url = https://github.com/foundry-rs/forge-std 5 | [submodule "lib/erc4626-tests"] 6 | path = lib/erc4626-tests 7 | url = https://github.com/a16z/erc4626-tests.git 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | require: 'hardhat/register', 3 | timeout: 4000, 4 | }; 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "arrowParens": "avoid", 6 | "overrides": [ 7 | { 8 | "files": "*.sol", 9 | "options": { 10 | "singleQuote": false 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.solcover.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | norpc: true, 3 | testCommand: 'npm test', 4 | compileCommand: 'npm run compile', 5 | skipFiles: ['mocks'], 6 | providerOptions: { 7 | default_balance_ether: '10000000000000000000000000', 8 | }, 9 | mocha: { 10 | fgrep: '[skip-on-coverage]', 11 | invert: true, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-unused-vars": "error", 4 | "const-name-snakecase": "error", 5 | "contract-name-camelcase": "error", 6 | "event-name-camelcase": "error", 7 | "func-name-mixedcase": "error", 8 | "func-param-name-mixedcase": "error", 9 | "modifier-name-mixedcase": "error", 10 | "private-vars-leading-underscore": "error", 11 | "var-name-mixedcase": "error", 12 | "imports-on-top": "error" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/audits/2018-10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/audits/2018-10.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/audits/2022-10-Checkpoints.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/audits/2022-10-Checkpoints.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/audits/2022-10-ERC4626.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/audits/2022-10-ERC4626.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/audits/2023-05-v4.9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/audits/2023-05-v4.9.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/.gitignore: -------------------------------------------------------------------------------- 1 | patched 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/diff/token_ERC721_ERC721.sol.patch: -------------------------------------------------------------------------------- 1 | --- token/ERC721/ERC721.sol 2023-03-07 10:48:47.736822221 +0100 2 | +++ token/ERC721/ERC721.sol 2023-03-09 19:49:39.669338673 +0100 3 | @@ -199,6 +199,11 @@ 4 | return _owners[tokenId]; 5 | } 6 | 7 | + // FV 8 | + function _getApproved(uint256 tokenId) internal view returns (address) { 9 | + return _tokenApprovals[tokenId]; 10 | + } 11 | + 12 | /** 13 | * @dev Returns whether `tokenId` exists. 14 | * 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/AccessControlHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/access/AccessControl.sol"; 6 | 7 | contract AccessControlHarness is AccessControl {} 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/ERC20PermitHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/token/ERC20/extensions/ERC20Permit.sol"; 6 | 7 | contract ERC20PermitHarness is ERC20Permit { 8 | constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {} 9 | 10 | function mint(address account, uint256 amount) external { 11 | _mint(account, amount); 12 | } 13 | 14 | function burn(address account, uint256 amount) external { 15 | _burn(account, amount); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/ERC20WrapperHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/token/ERC20/extensions/ERC20Wrapper.sol"; 6 | 7 | contract ERC20WrapperHarness is ERC20Wrapper { 8 | constructor(IERC20 _underlying, string memory _name, string memory _symbol) ERC20(_name, _symbol) ERC20Wrapper(_underlying) {} 9 | 10 | function underlyingTotalSupply() public view returns (uint256) { 11 | return underlying().totalSupply(); 12 | } 13 | 14 | function underlyingBalanceOf(address account) public view returns (uint256) { 15 | return underlying().balanceOf(account); 16 | } 17 | 18 | function underlyingAllowanceToThis(address account) public view returns (uint256) { 19 | return underlying().allowance(account, address(this)); 20 | } 21 | 22 | function recover(address account) public returns (uint256) { 23 | return _recover(account); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/ERC3156FlashBorrowerHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | import "../patched/interfaces/IERC3156FlashBorrower.sol"; 4 | 5 | pragma solidity ^0.8.0; 6 | 7 | contract ERC3156FlashBorrowerHarness is IERC3156FlashBorrower { 8 | bytes32 somethingToReturn; 9 | 10 | function onFlashLoan(address, address, uint256, uint256, bytes calldata) external view override returns (bytes32) { 11 | return somethingToReturn; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/ERC721ReceiverHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/interfaces/IERC721Receiver.sol"; 6 | 7 | contract ERC721ReceiverHarness is IERC721Receiver { 8 | function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { 9 | return this.onERC721Received.selector; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/EnumerableSetHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/utils/structs/EnumerableSet.sol"; 6 | 7 | contract EnumerableSetHarness { 8 | using EnumerableSet for EnumerableSet.Bytes32Set; 9 | 10 | EnumerableSet.Bytes32Set private _set; 11 | 12 | function add(bytes32 value) public returns (bool) { 13 | return _set.add(value); 14 | } 15 | 16 | function remove(bytes32 value) public returns (bool) { 17 | return _set.remove(value); 18 | } 19 | 20 | function contains(bytes32 value) public view returns (bool) { 21 | return _set.contains(value); 22 | } 23 | 24 | function length() public view returns (uint256) { 25 | return _set.length(); 26 | } 27 | 28 | function at_(uint256 index) public view returns (bytes32) { 29 | return _set.at(index); 30 | } 31 | 32 | function _indexOf(bytes32 value) public view returns (uint256) { 33 | return _set._inner._indexes[value]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/Ownable2StepHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/access/Ownable2Step.sol"; 6 | 7 | contract Ownable2StepHarness is Ownable2Step { 8 | function restricted() external onlyOwner {} 9 | } 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/OwnableHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/access/Ownable.sol"; 6 | 7 | contract OwnableHarness is Ownable { 8 | function restricted() external onlyOwner {} 9 | } 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/PausableHarness.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../patched/security/Pausable.sol"; 6 | 7 | contract PausableHarness is Pausable { 8 | function pause() external { 9 | _pause(); 10 | } 11 | 12 | function unpause() external { 13 | _unpause(); 14 | } 15 | 16 | function onlyWhenPaused() external whenPaused {} 17 | 18 | function onlyWhenNotPaused() external whenNotPaused {} 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/TimelockControllerHarness.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | import "../patched/governance/TimelockController.sol"; 4 | 5 | contract TimelockControllerHarness is TimelockController { 6 | constructor( 7 | uint256 minDelay, 8 | address[] memory proposers, 9 | address[] memory executors, 10 | address admin 11 | ) TimelockController(minDelay, proposers, executors, admin) {} 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/reports/2021-10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/certora/reports/2021-10.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/reports/2022-03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/certora/reports/2022-03.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/reports/2022-05.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/openzeppelin-contracts/certora/reports/2022-05.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/helpers/helpers.spec: -------------------------------------------------------------------------------- 1 | definition nonpayable(env e) returns bool = e.msg.value == 0; 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IAccessControl.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | hasRole(bytes32, address) returns(bool) envfree 3 | getRoleAdmin(bytes32) returns(bytes32) envfree 4 | grantRole(bytes32, address) 5 | revokeRole(bytes32, address) 6 | renounceRole(bytes32, address) 7 | } 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IERC20.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | name() returns (string) envfree => DISPATCHER(true) 3 | symbol() returns (string) envfree => DISPATCHER(true) 4 | decimals() returns (uint8) envfree => DISPATCHER(true) 5 | totalSupply() returns (uint256) envfree => DISPATCHER(true) 6 | balanceOf(address) returns (uint256) envfree => DISPATCHER(true) 7 | allowance(address,address) returns (uint256) envfree => DISPATCHER(true) 8 | approve(address,uint256) returns (bool) => DISPATCHER(true) 9 | transfer(address,uint256) returns (bool) => DISPATCHER(true) 10 | transferFrom(address,address,uint256) returns (bool) => DISPATCHER(true) 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IERC2612.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | permit(address,address,uint256,uint256,uint8,bytes32,bytes32) => DISPATCHER(true) 3 | nonces(address) returns (uint256) envfree => DISPATCHER(true) 4 | DOMAIN_SEPARATOR() returns (bytes32) envfree => DISPATCHER(true) 5 | } 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IERC3156.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | maxFlashLoan(address) returns (uint256) envfree => DISPATCHER(true) 3 | flashFee(address,uint256) returns (uint256) envfree => DISPATCHER(true) 4 | flashLoan(address,address,uint256,bytes) returns (bool) => DISPATCHER(true) 5 | } 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IERC5313.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | owner() returns (address) envfree 3 | } 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IOwnable.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | owner() returns (address) envfree 3 | transferOwnership(address) 4 | renounceOwnership() 5 | } 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/methods/IOwnable2Step.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | owner() returns (address) envfree 3 | pendingOwner() returns (address) envfree 4 | transferOwnership(address) 5 | acceptOwnership() 6 | renounceOwnership() 7 | } 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/access/README.adoc: -------------------------------------------------------------------------------- 1 | = Access Control 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/access 5 | 6 | This directory provides ways to restrict who can access the functions of a contract or when they can do it. 7 | 8 | - {AccessControl} provides a general role based access control mechanism. Multiple hierarchical roles can be created and assigned each to multiple accounts. 9 | - {Ownable} is a simpler mechanism with a single owner "role" that can be assigned to a single account. This simpler mechanism can be useful for quick tests but projects with production concerns are likely to outgrow it. 10 | 11 | == Authorization 12 | 13 | {{Ownable}} 14 | 15 | {{Ownable2Step}} 16 | 17 | {{IAccessControl}} 18 | 19 | {{AccessControl}} 20 | 21 | {{AccessControlCrossChain}} 22 | 23 | {{IAccessControlEnumerable}} 24 | 25 | {{AccessControlEnumerable}} 26 | 27 | {{AccessControlDefaultAdminRules}} 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/crosschain/errors.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (crosschain/errors.sol) 3 | 4 | pragma solidity ^0.8.4; 5 | 6 | error NotCrossChainCall(); 7 | error InvalidCrossChainSender(address actual, address expected); 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/finance/README.adoc: -------------------------------------------------------------------------------- 1 | = Finance 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/finance 5 | 6 | This directory includes primitives for financial systems: 7 | 8 | - {PaymentSplitter} allows to split Ether and ERC20 payments among a group of accounts. The sender does not need to be 9 | aware that the assets will be split in this way, since it is handled transparently by the contract. The split can be 10 | in equal parts or in any other arbitrary proportion. 11 | 12 | - {VestingWallet} handles the vesting of Ether and ERC20 tokens for a given beneficiary. Custody of multiple tokens can 13 | be given to this contract, which will release the token to the beneficiary following a given, customizable, vesting 14 | schedule. 15 | 16 | == Contracts 17 | 18 | {{PaymentSplitter}} 19 | 20 | {{VestingWallet}} 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/GovernorProposalThreshold.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorProposalThreshold.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | 8 | /** 9 | * @dev Extension of {Governor} for proposal restriction to token holders with a minimum balance. 10 | * 11 | * _Available since v4.3._ 12 | * _Deprecated since v4.4._ 13 | */ 14 | abstract contract GovernorProposalThreshold is Governor { 15 | function propose( 16 | address[] memory targets, 17 | uint256[] memory values, 18 | bytes[] memory calldatas, 19 | string memory description 20 | ) public virtual override returns (uint256) { 21 | return super.propose(targets, values, calldatas, description); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/IGovernorTimelock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/IGovernorTimelock.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IGovernor.sol"; 7 | 8 | /** 9 | * @dev Extension of the {IGovernor} for timelock supporting modules. 10 | * 11 | * _Available since v4.3._ 12 | */ 13 | abstract contract IGovernorTimelock is IGovernor { 14 | event ProposalQueued(uint256 proposalId, uint256 eta); 15 | 16 | function timelock() public view virtual returns (address); 17 | 18 | function proposalEta(uint256 proposalId) public view virtual returns (uint256); 19 | 20 | function queue( 21 | address[] memory targets, 22 | uint256[] memory values, 23 | bytes[] memory calldatas, 24 | bytes32 descriptionHash 25 | ) public virtual returns (uint256 proposalId); 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/extensions/IERC1155MetadataURI.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155Receiver.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1271.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC1271 standard signature validation method for 8 | * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. 9 | * 10 | * _Available since v4.1._ 11 | */ 12 | interface IERC1271 { 13 | /** 14 | * @dev Should return whether the signature provided is valid for the provided data 15 | * @param hash Hash of the data to be signed 16 | * @param signature Signature byte array associated with _data 17 | */ 18 | function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC165.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Implementer.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1820Registry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Registry.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Registry.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. 8 | * 9 | * _Available since v4.8.3._ 10 | */ 11 | interface IERC1967 { 12 | /** 13 | * @dev Emitted when the implementation is upgraded. 14 | */ 15 | event Upgraded(address indexed implementation); 16 | 17 | /** 18 | * @dev Emitted when the admin account has changed. 19 | */ 20 | event AdminChanged(address previousAdmin, address newAdmin); 21 | 22 | /** 23 | * @dev Emitted when the beacon is changed. 24 | */ 25 | event BeaconUpgraded(address indexed beacon); 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/IERC20.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/IERC20Metadata.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC2309.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC2309.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC-2309: ERC-721 Consecutive Transfer Extension. 8 | * 9 | * _Available since v4.8._ 10 | */ 11 | interface IERC2309 { 12 | /** 13 | * @dev Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`. 14 | */ 15 | event ConsecutiveTransfer( 16 | uint256 indexed fromTokenId, 17 | uint256 toTokenId, 18 | address indexed fromAddress, 19 | address indexed toAddress 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC2612.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2612.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/IERC20Permit.sol"; 7 | 8 | interface IERC2612 is IERC20Permit {} 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC165.sol"; 7 | 8 | /** 9 | * @dev Interface for the NFT Royalty Standard. 10 | * 11 | * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal 12 | * support for royalty payments across all NFT marketplaces and ecosystem participants. 13 | * 14 | * _Available since v4.5._ 15 | */ 16 | interface IERC2981 is IERC165 { 17 | /** 18 | * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of 19 | * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. 20 | */ 21 | function royaltyInfo( 22 | uint256 tokenId, 23 | uint256 salePrice 24 | ) external view returns (address receiver, uint256 royaltyAmount); 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC3156.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC3156FlashBorrower.sol"; 7 | import "./IERC3156FlashLender.sol"; 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC4906.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4906.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC165.sol"; 7 | import "./IERC721.sol"; 8 | 9 | /// @title EIP-721 Metadata Update Extension 10 | interface IERC4906 is IERC165, IERC721 { 11 | /// @dev This event emits when the metadata of a token is changed. 12 | /// So that the third-party platforms such as NFT market could 13 | /// timely update the images and related attributes of the NFT. 14 | event MetadataUpdate(uint256 _tokenId); 15 | 16 | /// @dev This event emits when the metadata of a range of tokens is changed. 17 | /// So that the third-party platforms such as NFT market could 18 | /// timely update the images and related attributes of the NFTs. 19 | event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC5267.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | interface IERC5267 { 7 | /** 8 | * @dev MAY be emitted to signal that the domain could have changed. 9 | */ 10 | event EIP712DomainChanged(); 11 | 12 | /** 13 | * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 14 | * signature. 15 | */ 16 | function eip712Domain() 17 | external 18 | view 19 | returns ( 20 | bytes1 fields, 21 | string memory name, 22 | string memory version, 23 | uint256 chainId, 24 | address verifyingContract, 25 | bytes32 salt, 26 | uint256[] memory extensions 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC5313.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5313.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface for the Light Contract Ownership Standard. 8 | * 9 | * A standardized minimal interface required to identify an account that controls a contract 10 | * 11 | * _Available since v4.9._ 12 | */ 13 | interface IERC5313 { 14 | /** 15 | * @dev Gets the address of the owner. 16 | */ 17 | function owner() external view returns (address); 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC5805.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5805.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../governance/utils/IVotes.sol"; 7 | import "./IERC6372.sol"; 8 | 9 | interface IERC5805 is IERC6372, IVotes {} 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC6372.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC6372.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | interface IERC6372 { 7 | /** 8 | * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting). 9 | */ 10 | function clock() external view returns (uint48); 11 | 12 | /** 13 | * @dev Description of the clock 14 | */ 15 | // solhint-disable-next-line func-name-mixedcase 16 | function CLOCK_MODE() external view returns (string memory); 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Enumerable.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Metadata.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721Receiver.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777Recipient.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Recipient.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Recipient.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777Sender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Sender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Sender.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified 8 | * proxy whose upgrades are fully controlled by the current implementation. 9 | */ 10 | interface IERC1822Proxiable { 11 | /** 12 | * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation 13 | * address. 14 | * 15 | * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks 16 | * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this 17 | * function revert if invoked through a proxy. 18 | */ 19 | function proxiableUUID() external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/draft-IERC2612.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/draft-IERC2612.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // EIP-2612 is Final as of 2022-11-01. This file is deprecated. 7 | 8 | import "./IERC2612.sol"; 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/metatx/README.adoc: -------------------------------------------------------------------------------- 1 | = Meta Transactions 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/metatx 5 | 6 | == Core 7 | 8 | {{ERC2771Context}} 9 | 10 | == Utils 11 | 12 | {{MinimalForwarder}} 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/AccessControlCrossChainMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.4; 4 | 5 | import "../access/AccessControlCrossChain.sol"; 6 | import "../crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol"; 7 | 8 | contract AccessControlCrossChainMock is AccessControlCrossChain, CrossChainEnabledArbitrumL2 {} 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ConditionalEscrowMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/escrow/ConditionalEscrow.sol"; 6 | 7 | // mock class using ConditionalEscrow 8 | contract ConditionalEscrowMock is ConditionalEscrow { 9 | mapping(address => bool) private _allowed; 10 | 11 | function setAllowed(address payee, bool allowed) public { 12 | _allowed[payee] = allowed; 13 | } 14 | 15 | function withdrawalAllowed(address payee) public view override returns (bool) { 16 | return _allowed[payee]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ContextMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Context.sol"; 6 | 7 | contract ContextMock is Context { 8 | event Sender(address sender); 9 | 10 | function msgSender() public { 11 | emit Sender(_msgSender()); 12 | } 13 | 14 | event Data(bytes data, uint256 integerValue, string stringValue); 15 | 16 | function msgData(uint256 integerValue, string memory stringValue) public { 17 | emit Data(_msgData(), integerValue, stringValue); 18 | } 19 | } 20 | 21 | contract ContextMockCaller { 22 | function callSender(ContextMock context) public { 23 | context.msgSender(); 24 | } 25 | 26 | function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { 27 | context.msgData(integerValue, stringValue); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/EIP712Verifier.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/cryptography/ECDSA.sol"; 6 | import "../utils/cryptography/EIP712.sol"; 7 | 8 | abstract contract EIP712Verifier is EIP712 { 9 | function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view { 10 | bytes32 digest = _hashTypedDataV4( 11 | keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) 12 | ); 13 | address recoveredSigner = ECDSA.recover(digest, signature); 14 | require(recoveredSigner == signer); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../access/Ownable.sol"; 6 | import "../interfaces/IERC1271.sol"; 7 | import "../utils/cryptography/ECDSA.sol"; 8 | 9 | contract ERC1271WalletMock is Ownable, IERC1271 { 10 | constructor(address originalOwner) { 11 | transferOwnership(originalOwner); 12 | } 13 | 14 | function isValidSignature(bytes32 hash, bytes memory signature) public view override returns (bytes4 magicValue) { 15 | return ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0); 16 | } 17 | } 18 | 19 | contract ERC1271MaliciousMock is IERC1271 { 20 | function isValidSignature(bytes32, bytes memory) public pure override returns (bytes4) { 21 | assembly { 22 | mstore(0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) 23 | return(0, 32) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165MaliciousData.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC165MaliciousData { 6 | function supportsInterface(bytes4) public pure returns (bool) { 7 | assembly { 8 | mstore(0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) 9 | return(0, 32) 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165MissingData.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC165MissingData { 6 | function supportsInterface(bytes4 interfaceId) public view {} // missing return 7 | } 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165NotSupported.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC165NotSupported {} 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165ReturnBomb.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../utils/introspection/IERC165.sol"; 6 | 7 | contract ERC165ReturnBombMock is IERC165 { 8 | function supportsInterface(bytes4 interfaceId) public pure override returns (bool) { 9 | if (interfaceId == type(IERC165).interfaceId) { 10 | assembly { 11 | mstore(0, 1) 12 | } 13 | } 14 | assembly { 15 | return(0, 101500) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import {ERC20} from "../token/ERC20/ERC20.sol"; 5 | 6 | contract ERC20Mock is ERC20 { 7 | constructor() ERC20("ERC20Mock", "E20M") {} 8 | 9 | function mint(address account, uint256 amount) external { 10 | _mint(account, amount); 11 | } 12 | 13 | function burn(address account, uint256 amount) external { 14 | _burn(account, amount); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC2771ContextMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.9; 4 | 5 | import "./ContextMock.sol"; 6 | import "../metatx/ERC2771Context.sol"; 7 | 8 | // By inheriting from ERC2771Context, Context's internal functions are overridden automatically 9 | contract ERC2771ContextMock is ContextMock, ERC2771Context { 10 | /// @custom:oz-upgrades-unsafe-allow constructor 11 | constructor(address trustedForwarder) ERC2771Context(trustedForwarder) { 12 | emit Sender(_msgSender()); // _msgSender() should be accessible during construction 13 | } 14 | 15 | function _msgSender() internal view override(Context, ERC2771Context) returns (address) { 16 | return ERC2771Context._msgSender(); 17 | } 18 | 19 | function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata) { 20 | return ERC2771Context._msgData(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC4626Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "../token/ERC20/extensions/ERC4626.sol"; 5 | 6 | contract ERC4626Mock is ERC4626 { 7 | constructor(address underlying) ERC20("ERC4626Mock", "E4626M") ERC4626(IERC20(underlying)) {} 8 | 9 | function mint(address account, uint256 amount) external { 10 | _mint(account, amount); 11 | } 12 | 13 | function burn(address account, uint256 amount) external { 14 | _burn(account, amount); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/EtherReceiverMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract EtherReceiverMock { 6 | bool private _acceptEther; 7 | 8 | function setAcceptEther(bool acceptEther) public { 9 | _acceptEther = acceptEther; 10 | } 11 | 12 | receive() external payable { 13 | if (!_acceptEther) { 14 | revert(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/MulticallTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "./token/ERC20MulticallMock.sol"; 6 | 7 | contract MulticallTest { 8 | function checkReturnValues( 9 | ERC20MulticallMock multicallToken, 10 | address[] calldata recipients, 11 | uint256[] calldata amounts 12 | ) external { 13 | bytes[] memory calls = new bytes[](recipients.length); 14 | for (uint256 i = 0; i < recipients.length; i++) { 15 | calls[i] = abi.encodeWithSignature("transfer(address,uint256)", recipients[i], amounts[i]); 16 | } 17 | 18 | bytes[] memory results = multicallToken.multicall(calls); 19 | for (uint256 i = 0; i < results.length; i++) { 20 | require(abi.decode(results[i], (bool))); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/PausableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../security/Pausable.sol"; 6 | 7 | contract PausableMock is Pausable { 8 | bool public drasticMeasureTaken; 9 | uint256 public count; 10 | 11 | constructor() { 12 | drasticMeasureTaken = false; 13 | count = 0; 14 | } 15 | 16 | function normalProcess() external whenNotPaused { 17 | count++; 18 | } 19 | 20 | function drasticMeasure() external whenPaused { 21 | drasticMeasureTaken = true; 22 | } 23 | 24 | function pause() external { 25 | _pause(); 26 | } 27 | 28 | function unpause() external { 29 | _unpause(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/PullPaymentMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../security/PullPayment.sol"; 6 | 7 | // mock class using PullPayment 8 | contract PullPaymentMock is PullPayment { 9 | constructor() payable {} 10 | 11 | // test helper function to call asyncTransfer 12 | function callTransfer(address dest, uint256 amount) public { 13 | _asyncTransfer(dest, amount); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ReentrancyAttack.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Context.sol"; 6 | 7 | contract ReentrancyAttack is Context { 8 | function callSender(bytes4 data) public { 9 | (bool success, ) = _msgSender().call(abi.encodeWithSelector(data)); 10 | require(success, "ReentrancyAttack: failed call"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/TimelockReentrant.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "../utils/Address.sol"; 5 | 6 | contract TimelockReentrant { 7 | address private _reenterTarget; 8 | bytes private _reenterData; 9 | bool _reentered; 10 | 11 | function disableReentrancy() external { 12 | _reentered = true; 13 | } 14 | 15 | function enableRentrancy(address target, bytes calldata data) external { 16 | _reenterTarget = target; 17 | _reenterData = data; 18 | } 19 | 20 | function reenter() external { 21 | if (!_reentered) { 22 | _reentered = true; 23 | Address.functionCall(_reenterTarget, _reenterData); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/TimersBlockNumberImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Timers.sol"; 6 | 7 | contract TimersBlockNumberImpl { 8 | using Timers for Timers.BlockNumber; 9 | 10 | Timers.BlockNumber private _timer; 11 | 12 | function getDeadline() public view returns (uint64) { 13 | return _timer.getDeadline(); 14 | } 15 | 16 | function setDeadline(uint64 timestamp) public { 17 | _timer.setDeadline(timestamp); 18 | } 19 | 20 | function reset() public { 21 | _timer.reset(); 22 | } 23 | 24 | function isUnset() public view returns (bool) { 25 | return _timer.isUnset(); 26 | } 27 | 28 | function isStarted() public view returns (bool) { 29 | return _timer.isStarted(); 30 | } 31 | 32 | function isPending() public view returns (bool) { 33 | return _timer.isPending(); 34 | } 35 | 36 | function isExpired() public view returns (bool) { 37 | return _timer.isExpired(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/TimersTimestampImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Timers.sol"; 6 | 7 | contract TimersTimestampImpl { 8 | using Timers for Timers.Timestamp; 9 | 10 | Timers.Timestamp private _timer; 11 | 12 | function getDeadline() public view returns (uint64) { 13 | return _timer.getDeadline(); 14 | } 15 | 16 | function setDeadline(uint64 timestamp) public { 17 | _timer.setDeadline(timestamp); 18 | } 19 | 20 | function reset() public { 21 | _timer.reset(); 22 | } 23 | 24 | function isUnset() public view returns (bool) { 25 | return _timer.isUnset(); 26 | } 27 | 28 | function isStarted() public view returns (bool) { 29 | return _timer.isStarted(); 30 | } 31 | 32 | function isPending() public view returns (bool) { 33 | return _timer.isPending(); 34 | } 35 | 36 | function isExpired() public view returns (bool) { 37 | return _timer.isExpired(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/governance/GovernorCompMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../governance/extensions/GovernorCountingSimple.sol"; 6 | import "../../governance/extensions/GovernorVotesComp.sol"; 7 | 8 | abstract contract GovernorCompMock is GovernorVotesComp, GovernorCountingSimple { 9 | function quorum(uint256) public pure override returns (uint256) { 10 | return 0; 11 | } 12 | 13 | function votingDelay() public pure override returns (uint256) { 14 | return 4; 15 | } 16 | 17 | function votingPeriod() public pure override returns (uint256) { 18 | return 16; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/governance/GovernorVoteMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../governance/extensions/GovernorCountingSimple.sol"; 6 | import "../../governance/extensions/GovernorVotes.sol"; 7 | 8 | abstract contract GovernorVoteMocks is GovernorVotes, GovernorCountingSimple { 9 | function quorum(uint256) public pure override returns (uint256) { 10 | return 0; 11 | } 12 | 13 | function votingDelay() public pure override returns (uint256) { 14 | return 4; 15 | } 16 | 17 | function votingPeriod() public pure override returns (uint256) { 18 | return 16; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/proxy/BadBeacon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract BadBeaconNoImpl {} 6 | 7 | contract BadBeaconNotContract { 8 | function implementation() external pure returns (address) { 9 | return address(0x1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/proxy/ClashingImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | /** 6 | * @dev Implementation contract with a payable admin() function made to clash with TransparentUpgradeableProxy's to 7 | * test correct functioning of the Transparent Proxy feature. 8 | */ 9 | contract ClashingImplementation { 10 | function admin() external payable returns (address) { 11 | return 0x0000000000000000000000000000000011111142; 12 | } 13 | 14 | function delegatedFunction() external pure returns (bool) { 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20DecimalsMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/ERC20.sol"; 6 | 7 | abstract contract ERC20DecimalsMock is ERC20 { 8 | uint8 private immutable _decimals; 9 | 10 | constructor(uint8 decimals_) { 11 | _decimals = decimals_; 12 | } 13 | 14 | function decimals() public view override returns (uint8) { 15 | return _decimals; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20ExcessDecimalsMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC20ExcessDecimalsMock { 6 | function decimals() public pure returns (uint256) { 7 | return type(uint256).max; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20FlashMintMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/extensions/ERC20FlashMint.sol"; 6 | 7 | abstract contract ERC20FlashMintMock is ERC20FlashMint { 8 | uint256 _flashFeeAmount; 9 | address _flashFeeReceiverAddress; 10 | 11 | function setFlashFee(uint256 amount) public { 12 | _flashFeeAmount = amount; 13 | } 14 | 15 | function _flashFee(address, uint256) internal view override returns (uint256) { 16 | return _flashFeeAmount; 17 | } 18 | 19 | function setFlashFeeReceiver(address receiver) public { 20 | _flashFeeReceiverAddress = receiver; 21 | } 22 | 23 | function _flashFeeReceiver() internal view override returns (address) { 24 | return _flashFeeReceiverAddress; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20ForceApproveMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/ERC20.sol"; 6 | 7 | // contract that replicate USDT (0xdac17f958d2ee523a2206206994597c13d831ec7) approval beavior 8 | abstract contract ERC20ForceApproveMock is ERC20 { 9 | function approve(address spender, uint256 amount) public virtual override returns (bool) { 10 | require(amount == 0 || allowance(msg.sender, spender) == 0, "USDT approval failure"); 11 | return super.approve(spender, amount); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20MulticallMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/ERC20.sol"; 6 | import "../../utils/Multicall.sol"; 7 | 8 | abstract contract ERC20MulticallMock is ERC20, Multicall {} 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20NoReturnMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/ERC20.sol"; 6 | 7 | abstract contract ERC20NoReturnMock is ERC20 { 8 | function transfer(address to, uint256 amount) public override returns (bool) { 9 | super.transfer(to, amount); 10 | assembly { 11 | return(0, 0) 12 | } 13 | } 14 | 15 | function transferFrom(address from, address to, uint256 amount) public override returns (bool) { 16 | super.transferFrom(from, to, amount); 17 | assembly { 18 | return(0, 0) 19 | } 20 | } 21 | 22 | function approve(address spender, uint256 amount) public override returns (bool) { 23 | super.approve(spender, amount); 24 | assembly { 25 | return(0, 0) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC20ReturnFalseMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/ERC20.sol"; 6 | 7 | abstract contract ERC20ReturnFalseMock is ERC20 { 8 | function transfer(address, uint256) public pure override returns (bool) { 9 | return false; 10 | } 11 | 12 | function transferFrom(address, address, uint256) public pure override returns (bool) { 13 | return false; 14 | } 15 | 16 | function approve(address, uint256) public pure override returns (bool) { 17 | return false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC4626OffsetMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC20/extensions/ERC4626.sol"; 6 | 7 | abstract contract ERC4626OffsetMock is ERC4626 { 8 | uint8 private immutable _offset; 9 | 10 | constructor(uint8 offset_) { 11 | _offset = offset_; 12 | } 13 | 14 | function _decimalsOffset() internal view virtual override returns (uint8) { 15 | return _offset; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC721URIStorageMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC721/extensions/ERC721URIStorage.sol"; 6 | 7 | abstract contract ERC721URIStorageMock is ERC721URIStorage { 8 | string private _baseTokenURI; 9 | 10 | function _baseURI() internal view virtual override returns (string memory) { 11 | return _baseTokenURI; 12 | } 13 | 14 | function setBaseURI(string calldata newBaseTokenURI) public { 15 | _baseTokenURI = newBaseTokenURI; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/token/ERC777Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../../token/ERC777/ERC777.sol"; 6 | 7 | abstract contract ERC777Mock is ERC777 { 8 | event BeforeTokenTransfer(); 9 | 10 | function _beforeTokenTransfer(address, address, address, uint256) internal override { 11 | emit BeforeTokenTransfer(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@openzeppelin/contracts", 3 | "description": "Secure Smart Contract library for Solidity", 4 | "version": "4.9.2", 5 | "files": [ 6 | "**/*.sol", 7 | "/build/contracts/*.json", 8 | "!/mocks/**/*" 9 | ], 10 | "scripts": { 11 | "prepare": "bash ../scripts/prepare-contracts-package.sh", 12 | "prepare-docs": "cd ..; npm run prepare-docs" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts.git" 17 | }, 18 | "keywords": [ 19 | "solidity", 20 | "ethereum", 21 | "smart", 22 | "contracts", 23 | "security", 24 | "zeppelin" 25 | ], 26 | "author": "OpenZeppelin Community ", 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" 30 | }, 31 | "homepage": "https://openzeppelin.com/contracts/" 32 | } 33 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev This is the interface that {BeaconProxy} expects of its beacon. 8 | */ 9 | interface IBeacon { 10 | /** 11 | * @dev Must return an address that can be used as a delegate call target. 12 | * 13 | * {BeaconProxy} will check that this address is a contract. 14 | */ 15 | function implementation() external view returns (address); 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/security/README.adoc: -------------------------------------------------------------------------------- 1 | = Security 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/security 5 | 6 | These contracts aim to cover common security practices. 7 | 8 | * {PullPayment}: A pattern that can be used to avoid reentrancy attacks. 9 | * {ReentrancyGuard}: A modifier that can prevent reentrancy during certain functions. 10 | * {Pausable}: A common emergency response mechanism that can pause functionality while a remediation is pending. 11 | 12 | TIP: For an overview on reentrancy and the possible mechanisms to prevent it, read our article https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 13 | 14 | == Contracts 15 | 16 | {{PullPayment}} 17 | 18 | {{ReentrancyGuard}} 19 | 20 | {{Pausable}} 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155.sol"; 7 | 8 | /** 9 | * @dev Interface of the optional ERC1155MetadataExtension interface, as defined 10 | * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. 11 | * 12 | * _Available since v3.1._ 13 | */ 14 | interface IERC1155MetadataURI is IERC1155 { 15 | /** 16 | * @dev Returns the URI for token type `id`. 17 | * 18 | * If the `\{id\}` substring is present in the URI, it must be replaced by 19 | * clients with the actual token type ID. 20 | */ 21 | function uri(uint256 id) external view returns (string memory); 22 | } 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/utils/ERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155Receiver.sol"; 7 | import "../../../utils/introspection/ERC165.sol"; 8 | 9 | /** 10 | * @dev _Available since v3.1._ 11 | */ 12 | abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { 13 | /** 14 | * @dev See {IERC165-supportsInterface}. 15 | */ 16 | function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { 17 | return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC20.sol"; 7 | 8 | /** 9 | * @dev Interface for the optional metadata functions from the ERC20 standard. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | interface IERC20Metadata is IERC20 { 14 | /** 15 | * @dev Returns the name of the token. 16 | */ 17 | function name() external view returns (string memory); 18 | 19 | /** 20 | * @dev Returns the symbol of the token. 21 | */ 22 | function symbol() external view returns (string memory); 23 | 24 | /** 25 | * @dev Returns the decimals places of the token. 26 | */ 27 | function decimals() external view returns (uint8); 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-ERC20Permit.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-ERC20Permit.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // EIP-2612 is Final as of 2022-11-01. This file is deprecated. 7 | 8 | import "./ERC20Permit.sol"; 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-IERC20Permit.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-IERC20Permit.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // EIP-2612 is Final as of 2022-11-01. This file is deprecated. 7 | 8 | import "./IERC20Permit.sol"; 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Burnable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../utils/Context.sol"; 8 | 9 | /** 10 | * @title ERC721 Burnable Token 11 | * @dev ERC721 Token that can be burned (destroyed). 12 | */ 13 | abstract contract ERC721Burnable is Context, ERC721 { 14 | /** 15 | * @dev Burns `tokenId`. See {ERC721-_burn}. 16 | * 17 | * Requirements: 18 | * 19 | * - The caller must own `tokenId` or be an approved operator. 20 | */ 21 | function burn(uint256 tokenId) public virtual { 22 | //solhint-disable-next-line max-line-length 23 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); 24 | _burn(tokenId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721.sol"; 7 | 8 | /** 9 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 10 | * @dev See https://eips.ethereum.org/EIPS/eip-721 11 | */ 12 | interface IERC721Metadata is IERC721 { 13 | /** 14 | * @dev Returns the token collection name. 15 | */ 16 | function name() external view returns (string memory); 17 | 18 | /** 19 | * @dev Returns the token collection symbol. 20 | */ 21 | function symbol() external view returns (string memory); 22 | 23 | /** 24 | * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. 25 | */ 26 | function tokenURI(uint256 tokenId) external view returns (string memory); 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/draft-ERC721Votes.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/draft-ERC721Votes.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // ERC721Votes was marked as draft due to the EIP-712 dependency. 7 | // EIP-712 is Final as of 2022-08-11. This file is deprecated. 8 | 9 | import "./ERC721Votes.sol"; 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721Receiver.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC721Receiver} interface. 10 | * 11 | * Accepts all token transfers. 12 | * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. 13 | */ 14 | contract ERC721Holder is IERC721Receiver { 15 | /** 16 | * @dev See {IERC721Receiver-onERC721Received}. 17 | * 18 | * Always returns `IERC721Receiver.onERC721Received.selector`. 19 | */ 20 | function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { 21 | return this.onERC721Received.selector; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC777/presets/ERC777PresetFixedSupply.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | import "../ERC777.sol"; 6 | 7 | /** 8 | * @dev {ERC777} token, including: 9 | * 10 | * - Preminted initial supply 11 | * - No access control mechanism (for minting/pausing) and hence no governance 12 | * 13 | * _Available since v3.4._ 14 | */ 15 | contract ERC777PresetFixedSupply is ERC777 { 16 | /** 17 | * @dev Mints `initialSupply` amount of token and transfers them to `owner`. 18 | * 19 | * See {ERC777-constructor}. 20 | */ 21 | constructor( 22 | string memory name, 23 | string memory symbol, 24 | address[] memory defaultOperators, 25 | uint256 initialSupply, 26 | address owner 27 | ) ERC777(name, symbol, defaultOperators) { 28 | _mint(owner, initialSupply, "", ""); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/common/README.adoc: -------------------------------------------------------------------------------- 1 | = Common (Tokens) 2 | 3 | Functionality that is common to multiple token standards. 4 | 5 | * {ERC2981}: NFT Royalties compatible with both ERC721 and ERC1155. 6 | ** For ERC721 consider {ERC721Royalty} which clears the royalty information from storage on burn. 7 | 8 | == Contracts 9 | 10 | {{ERC2981}} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/Context.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Provides information about the current execution context, including the 8 | * sender of the transaction and its data. While these are generally available 9 | * via msg.sender and msg.data, they should not be accessed in such a direct 10 | * manner, since when dealing with meta-transactions the account sending and 11 | * paying for execution may not be the actual sender (as far as an application 12 | * is concerned). 13 | * 14 | * This contract is only required for intermediate, library-like contracts. 15 | */ 16 | abstract contract Context { 17 | function _msgSender() internal view virtual returns (address) { 18 | return msg.sender; 19 | } 20 | 21 | function _msgData() internal view virtual returns (bytes calldata) { 22 | return msg.data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/Multicall.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (utils/Multicall.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Address.sol"; 7 | 8 | /** 9 | * @dev Provides a function to batch together multiple calls in a single external call. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | abstract contract Multicall { 14 | /** 15 | * @dev Receives and executes a batch of function calls on this contract. 16 | * @custom:oz-upgrades-unsafe-allow-reachable delegatecall 17 | */ 18 | function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { 19 | results = new bytes[](data.length); 20 | for (uint256 i = 0; i < data.length; i++) { 21 | results[i] = Address.functionDelegateCall(address(this), data[i]); 22 | } 23 | return results; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/cryptography/draft-EIP712.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // EIP-712 is Final as of 2022-08-11. This file is deprecated. 7 | 8 | import "./EIP712.sol"; 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/escrow/ConditionalEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/escrow/ConditionalEscrow.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Escrow.sol"; 7 | 8 | /** 9 | * @title ConditionalEscrow 10 | * @dev Base abstract escrow to only allow withdrawal if a condition is met. 11 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. 12 | */ 13 | abstract contract ConditionalEscrow is Escrow { 14 | /** 15 | * @dev Returns whether an address is allowed to withdraw their funds. To be 16 | * implemented by derived contracts. 17 | * @param payee The destination address of the funds. 18 | */ 19 | function withdrawalAllowed(address payee) public view virtual returns (bool); 20 | 21 | function withdraw(address payable payee) public virtual override { 22 | require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); 23 | super.withdraw(payee); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC165 standard, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-165[EIP]. 9 | * 10 | * Implementers can declare support of contract interfaces, which can then be 11 | * queried by others ({ERC165Checker}). 12 | * 13 | * For an implementation, see {ERC165}. 14 | */ 15 | interface IERC165 { 16 | /** 17 | * @dev Returns true if this contract implements the interface defined by 18 | * `interfaceId`. See the corresponding 19 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] 20 | * to learn more about how these ids are created. 21 | * 22 | * This function call must use less than 30 000 gas. 23 | */ 24 | function supportsInterface(bytes4 interfaceId) external view returns (bool); 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface for an ERC1820 implementer, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. 9 | * Used by contracts that will be registered as implementers in the 10 | * {IERC1820Registry}. 11 | */ 12 | interface IERC1820Implementer { 13 | /** 14 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract 15 | * implements `interfaceHash` for `account`. 16 | * 17 | * See {IERC1820Registry-setInterfaceImplementer}. 18 | */ 19 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/vendor/arbitrum/IDelayedMessageProvider.sol: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2022, Offchain Labs, Inc. 2 | // For license information, see https://github.com/nitro/blob/master/LICENSE 3 | // SPDX-License-Identifier: BUSL-1.1 4 | // OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IDelayedMessageProvider.sol) 5 | 6 | // solhint-disable-next-line compiler-version 7 | pragma solidity >=0.6.9 <0.9.0; 8 | 9 | interface IDelayedMessageProvider { 10 | /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator 11 | event InboxMessageDelivered(uint256 indexed messageNum, bytes data); 12 | 13 | /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator 14 | /// same as InboxMessageDelivered but the batch data is available in tx.input 15 | event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum); 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/vendor/polygon/IFxMessageProcessor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.9.0) (vendor/polygon/IFxMessageProcessor.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | interface IFxMessageProcessor { 6 | function processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes calldata data) external; 7 | } 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/foundry.toml: -------------------------------------------------------------------------------- 1 | [fuzz] 2 | runs = 10000 3 | max_test_rejects = 150000 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/hardhat/env-artifacts.js: -------------------------------------------------------------------------------- 1 | const { HardhatError } = require('hardhat/internal/core/errors'); 2 | 3 | // Modifies `artifacts.require(X)` so that instead of X it loads the XUpgradeable contract. 4 | // This allows us to run the same test suite on both the original and the transpiled and renamed Upgradeable contracts. 5 | 6 | extendEnvironment(env => { 7 | const artifactsRequire = env.artifacts.require; 8 | 9 | env.artifacts.require = name => { 10 | for (const suffix of ['UpgradeableWithInit', 'Upgradeable', '']) { 11 | try { 12 | return artifactsRequire(name + suffix); 13 | } catch (e) { 14 | // HH700: Artifact not found - from https://hardhat.org/hardhat-runner/docs/errors#HH700 15 | if (HardhatError.isHardhatError(e) && e.number === 700 && suffix !== '') { 16 | continue; 17 | } else { 18 | throw e; 19 | } 20 | } 21 | } 22 | throw new Error('Unreachable'); 23 | }; 24 | }); 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/hardhat/env-contract.js: -------------------------------------------------------------------------------- 1 | extendEnvironment(env => { 2 | const { contract } = env; 3 | 4 | env.contract = function (name, body) { 5 | // remove the default account from the accounts list used in tests, in order 6 | // to protect tests against accidentally passing due to the contract 7 | // deployer being used subsequently as function caller 8 | contract(name, accounts => body(accounts.slice(1))); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/hardhat/skip-foundry-tests.js: -------------------------------------------------------------------------------- 1 | const { subtask } = require('hardhat/config'); 2 | const { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } = require('hardhat/builtin-tasks/task-names'); 3 | 4 | subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => 5 | (await runSuper()).filter(path => !path.endsWith('.t.sol')), 6 | ); 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | out/ 3 | .vscode 4 | .idea 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | fs_permissions = [{ access = "read-write", path = "./"}] 3 | 4 | [rpc_endpoints] 5 | # The RPC URLs are modified versions of the default for testing initialization. 6 | mainnet = "https://mainnet.infura.io/v3/16a8be88795540b9b3903d8de0f7baa5" # Different API key. 7 | optimism_goerli = "https://goerli.optimism.io/" # Adds a trailing slash. 8 | arbitrum_one_goerli = "https://goerli-rollup.arbitrum.io/rpc/" # Adds a trailing slash. 9 | needs_undefined_env_var = "${UNDEFINED_RPC_URL_PLACEHOLDER}" 10 | 11 | [fmt] 12 | # These are all the `forge fmt` defaults. 13 | line_length = 120 14 | tab_width = 4 15 | bracket_spacing = false 16 | int_types = 'long' 17 | multiline_func_header = 'attributes_first' 18 | quote_style = 'double' 19 | number_underscore = 'preserve' 20 | single_line_statement_blocks = 'preserve' 21 | ignore = ["src/console.sol", "src/console2.sol"] -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/.gitignore: -------------------------------------------------------------------------------- 1 | /.dapple 2 | /build 3 | /out 4 | /cache/ 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/Makefile: -------------------------------------------------------------------------------- 1 | all:; dapp build 2 | 3 | test: 4 | -dapp --use solc:0.4.23 build 5 | -dapp --use solc:0.4.26 build 6 | -dapp --use solc:0.5.17 build 7 | -dapp --use solc:0.6.12 build 8 | -dapp --use solc:0.7.5 build 9 | 10 | demo: 11 | DAPP_SRC=demo dapp --use solc:0.7.5 build 12 | -hevm dapp-test --verbose 3 13 | 14 | .PHONY: test demo 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/default.nix: -------------------------------------------------------------------------------- 1 | { solidityPackage, dappsys }: solidityPackage { 2 | name = "ds-test"; 3 | src = ./src; 4 | } 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ds-test", 3 | "version": "1.0.0", 4 | "description": "Assertions, equality checks and other test helpers ", 5 | "bugs": "https://github.com/dapphub/ds-test/issues", 6 | "license": "GPL-3.0", 7 | "author": "Contributors to ds-test", 8 | "files": [ 9 | "src/*" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/dapphub/ds-test.git" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "forge-std", 3 | "version": "1.5.0", 4 | "description": "Forge Standard Library is a collection of helpful contracts and libraries for use with Forge and Foundry.", 5 | "homepage": "https://book.getfoundry.sh/forge/forge-std", 6 | "bugs": "https://github.com/foundry-rs/forge-std/issues", 7 | "license": "(Apache-2.0 OR MIT)", 8 | "author": "Contributors to Forge Standard Library", 9 | "files": [ 10 | "src/*" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/foundry-rs/forge-std.git" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/src/Script.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | // 💬 ABOUT 5 | // Standard Library's default Script. 6 | 7 | // 🧩 MODULES 8 | import {ScriptBase} from "./Base.sol"; 9 | import {console} from "./console.sol"; 10 | import {console2} from "./console2.sol"; 11 | import {StdChains} from "./StdChains.sol"; 12 | import {StdCheatsSafe} from "./StdCheats.sol"; 13 | import {stdJson} from "./StdJson.sol"; 14 | import {stdMath} from "./StdMath.sol"; 15 | import {StdStorage, stdStorageSafe} from "./StdStorage.sol"; 16 | import {StdUtils} from "./StdUtils.sol"; 17 | import {VmSafe} from "./Vm.sol"; 18 | 19 | // 📦 BOILERPLATE 20 | import {ScriptBase} from "./Base.sol"; 21 | 22 | // ⭐️ SCRIPT 23 | abstract contract Script is StdChains, StdCheatsSafe, StdUtils, ScriptBase { 24 | // Note: IS_SCRIPT() must return true. 25 | bool public IS_SCRIPT = true; 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/src/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2; 3 | 4 | interface IERC165 { 5 | /// @notice Query if a contract implements an interface 6 | /// @param interfaceID The interface identifier, as specified in ERC-165 7 | /// @dev Interface identification is specified in ERC-165. This function 8 | /// uses less than 30,000 gas. 9 | /// @return `true` if the contract implements `interfaceID` and 10 | /// `interfaceID` is not 0xffffffff, `false` otherwise 11 | function supportsInterface(bytes4 interfaceID) external view returns (bool); 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/test/compilation/CompilationScript.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScript is Script {} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/test/compilation/CompilationScriptBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScriptBase is ScriptBase {} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/test/compilation/CompilationTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTest is Test {} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/lib/forge-std/test/compilation/CompilationTestBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTestBase is TestBase {} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "npm run docs" 3 | publish = "build/site" 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/remappings.txt: -------------------------------------------------------------------------------- 1 | openzeppelin/=contracts/ 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["github>OpenZeppelin/configs"], 3 | "labels": ["ignore-changeset"] 4 | } 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/requirements.txt: -------------------------------------------------------------------------------- 1 | certora-cli==3.6.4 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/checks/compare-layout.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const { getStorageUpgradeReport } = require('@openzeppelin/upgrades-core/dist/storage'); 3 | 4 | const { ref, head } = require('yargs').argv; 5 | 6 | const oldLayout = JSON.parse(fs.readFileSync(ref)); 7 | const newLayout = JSON.parse(fs.readFileSync(head)); 8 | 9 | for (const name in oldLayout) { 10 | if (name in newLayout) { 11 | const report = getStorageUpgradeReport(oldLayout[name], newLayout[name], {}); 12 | if (!report.ok) { 13 | console.log(report.explain()); 14 | process.exitCode = 1; 15 | } 16 | } else { 17 | console.log(`WARNING: ${name} is missing from the current branch`); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/checks/generation.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | npm run generate 6 | git diff -R --exit-code 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/generate/format-lines.js: -------------------------------------------------------------------------------- 1 | function formatLines(...lines) { 2 | return [...indentEach(0, lines)].join('\n') + '\n'; 3 | } 4 | 5 | function* indentEach(indent, lines) { 6 | for (const line of lines) { 7 | if (Array.isArray(line)) { 8 | yield* indentEach(indent + 1, line); 9 | } else { 10 | const padding = ' '.repeat(indent); 11 | yield* line.split('\n').map(subline => (subline === '' ? '' : padding + subline)); 12 | } 13 | } 14 | } 15 | 16 | module.exports = formatLines; 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/generate/templates/Checkpoints.opts.js: -------------------------------------------------------------------------------- 1 | // OPTIONS 2 | const VALUE_SIZES = [224, 160]; 3 | 4 | const defaultOpts = size => ({ 5 | historyTypeName: `Trace${size}`, 6 | checkpointTypeName: `Checkpoint${size}`, 7 | checkpointFieldName: '_checkpoints', 8 | keyTypeName: `uint${256 - size}`, 9 | keyFieldName: '_key', 10 | valueTypeName: `uint${size}`, 11 | valueFieldName: '_value', 12 | }); 13 | 14 | module.exports = { 15 | OPTS: VALUE_SIZES.map(size => defaultOpts(size)), 16 | LEGACY_OPTS: { 17 | ...defaultOpts(224), 18 | historyTypeName: 'History', 19 | checkpointTypeName: 'Checkpoint', 20 | keyFieldName: '_blockNumber', 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/generate/templates/conversion.js: -------------------------------------------------------------------------------- 1 | function toBytes32(type, value) { 2 | switch (type) { 3 | case 'bytes32': 4 | return value; 5 | case 'uint256': 6 | return `bytes32(${value})`; 7 | case 'address': 8 | return `bytes32(uint256(uint160(${value})))`; 9 | default: 10 | throw new Error(`Conversion from ${type} to bytes32 not supported`); 11 | } 12 | } 13 | 14 | function fromBytes32(type, value) { 15 | switch (type) { 16 | case 'bytes32': 17 | return value; 18 | case 'uint256': 19 | return `uint256(${value})`; 20 | case 'address': 21 | return `address(uint160(uint256(${value})))`; 22 | default: 23 | throw new Error(`Conversion from bytes32 to ${type} not supported`); 24 | } 25 | } 26 | 27 | module.exports = { 28 | toBytes32, 29 | fromBytes32, 30 | }; 31 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/git-user-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail -x 4 | 5 | git config user.name 'github-actions' 6 | git config user.email '41898282+github-actions[bot]@users.noreply.github.com' 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/helpers.js: -------------------------------------------------------------------------------- 1 | function chunk(array, size = 1) { 2 | return Array.range(Math.ceil(array.length / size)).map(i => array.slice(i * size, i * size + size)); 3 | } 4 | 5 | function range(start, stop = undefined, step = 1) { 6 | if (!stop) { 7 | stop = start; 8 | start = 0; 9 | } 10 | return start < stop 11 | ? Array(Math.ceil((stop - start) / step)) 12 | .fill() 13 | .map((_, i) => start + i * step) 14 | : []; 15 | } 16 | 17 | function unique(array, op = x => x) { 18 | return array.filter((obj, i) => array.findIndex(entry => op(obj) === op(entry)) === i); 19 | } 20 | 21 | function zip(...args) { 22 | return Array(Math.max(...args.map(arg => arg.length))) 23 | .fill(null) 24 | .map((_, i) => args.map(arg => arg[i])); 25 | } 26 | 27 | function capitalize(str) { 28 | return str.charAt(0).toUpperCase() + str.slice(1); 29 | } 30 | 31 | module.exports = { 32 | chunk, 33 | range, 34 | unique, 35 | zip, 36 | capitalize, 37 | }; 38 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | shopt -s globstar 5 | 6 | # cross platform `mkdir -p` 7 | node -e 'fs.mkdirSync("build/contracts", { recursive: true })' 8 | 9 | cp artifacts/contracts/**/*.json build/contracts 10 | rm build/contracts/*.dbg.json 11 | 12 | node scripts/remove-ignored-artifacts.js 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare-contracts-package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # cd to the root of the repo 4 | cd "$(git rev-parse --show-toplevel)" 5 | 6 | # avoids re-compilation during publishing of both packages 7 | if [[ ! -v ALREADY_COMPILED ]]; then 8 | npm run clean 9 | npm run prepare 10 | npm run prepack 11 | fi 12 | 13 | cp README.md contracts/ 14 | mkdir contracts/build contracts/build/contracts 15 | cp -r build/contracts/*.json contracts/build/contracts 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | shopt -s globstar 5 | 6 | OUTDIR="$(node -p 'require("./docs/config.js").outputDir')" 7 | 8 | if [ ! -d node_modules ]; then 9 | npm ci 10 | fi 11 | 12 | rm -rf "$OUTDIR" 13 | 14 | hardhat docgen 15 | 16 | # copy examples and adjust imports 17 | examples_source_dir="contracts/mocks/docs" 18 | examples_target_dir="docs/modules/api/examples" 19 | 20 | for f in "$examples_source_dir"/**/*.sol; do 21 | name="${f/#"$examples_source_dir/"/}" 22 | mkdir -p "$examples_target_dir/$(dirname "$name")" 23 | sed -Ee '/^import/s|"(\.\./)+|"@openzeppelin/contracts/|' "$f" > "$examples_target_dir/$name" 24 | done 25 | 26 | node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc" 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | if [ "${SKIP_COMPILE:-}" == true ]; then 6 | exit 7 | fi 8 | 9 | npm run clean 10 | env COMPILE_MODE=production npm run compile 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/synchronize-versions.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Synchronizes the version in contracts/package.json with the one in package.json. 4 | // This is run automatically when npm version is run. 5 | 6 | const fs = require('fs'); 7 | 8 | setVersion('package.json', 'contracts/package.json'); 9 | 10 | function setVersion(from, to) { 11 | const fromJson = JSON.parse(fs.readFileSync(from)); 12 | const toJson = JSON.parse(fs.readFileSync(to)); 13 | toJson.version = fromJson.version; 14 | fs.writeFileSync(to, JSON.stringify(toJson, null, 2) + '\n'); 15 | } 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | changeset version 6 | 7 | scripts/release/format-changelog.js 8 | scripts/release/synchronize-versions.js 9 | scripts/release/update-comment.js 10 | 11 | oz-docs update-version 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/exit-prerelease.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | npx changeset pre exit rc 6 | git add . 7 | git commit -m "Exit release candidate" 8 | git push origin 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/integrity-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | CHECKSUMS="$RUNNER_TEMP/checksums.txt" 6 | 7 | # Extract tarball content into a tmp directory 8 | tar xf "$TARBALL" -C "$RUNNER_TEMP" 9 | 10 | # Move to extracted directory 11 | cd "$RUNNER_TEMP/package" 12 | 13 | # Checksum all Solidity files 14 | find . -type f -name "*.sol" | xargs shasum > "$CHECKSUMS" 15 | 16 | # Back to directory with git contents 17 | cd "$GITHUB_WORKSPACE/contracts" 18 | 19 | # Check against tarball contents 20 | shasum -c "$CHECKSUMS" 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/pack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | dist_tag() { 6 | PACKAGE_JSON_NAME="$(jq -r .name ./package.json)" 7 | LATEST_NPM_VERSION="$(npm info "$PACKAGE_JSON_NAME" version)" 8 | PACKAGE_JSON_VERSION="$(jq -r .version ./package.json)" 9 | 10 | if [ "$PRERELEASE" = "true" ]; then 11 | echo "next" 12 | elif npx semver -r ">$LATEST_NPM_VERSION" "$PACKAGE_JSON_VERSION" > /dev/null; then 13 | echo "latest" 14 | else 15 | # This is a patch for an older version 16 | # npm can't publish without a tag 17 | echo "tmp" 18 | fi 19 | } 20 | 21 | cd contracts 22 | TARBALL="$(npm pack | tee /dev/stderr | tail -1)" 23 | echo "tarball_name=$TARBALL" >> $GITHUB_OUTPUT 24 | echo "tarball=$(pwd)/$TARBALL" >> $GITHUB_OUTPUT 25 | echo "tag=$(dist_tag)" >> $GITHUB_OUTPUT 26 | cd .. 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Intentionally escape $ to avoid interpolation and writing the token to disk 6 | echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc 7 | 8 | # Actual publish 9 | npm publish "$TARBALL" --tag "$TAG" 10 | 11 | delete_tag() { 12 | PACKAGE_JSON_NAME="$(tar xfO "$TARBALL" package/package.json | jq -r .name)" 13 | npm dist-tag rm "$PACKAGE_JSON_NAME" "$1" 14 | } 15 | 16 | if [ "$TAG" = tmp ]; then 17 | delete_tag "$TAG" 18 | elif [ "$TAG" = latest ]; then 19 | delete_tag next 20 | fi 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/rerun.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ github, context }) => 2 | github.rest.actions.createWorkflowDispatch({ 3 | owner: context.repo.owner, 4 | repo: context.repo.repo, 5 | workflow_id: 'release-cycle.yml', 6 | ref: process.env.REF || process.env.GITHUB_REF_NAME, 7 | }); 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/workflow/set-changesets-pr-title.js: -------------------------------------------------------------------------------- 1 | const { coerce, inc, rsort } = require('semver'); 2 | const { join } = require('path'); 3 | const { version } = require(join(__dirname, '../../../package.json')); 4 | 5 | module.exports = async ({ core }) => { 6 | // Variables not in the context 7 | const refName = process.env.GITHUB_REF_NAME; 8 | 9 | // Compare package.json version's next patch vs. first version patch 10 | // A recently opened branch will give the next patch for the previous minor 11 | // So, we get the max against the patch 0 of the release branch's version 12 | const branchPatch0 = coerce(refName.replace('release-v', '')).version; 13 | const packageJsonNextPatch = inc(version, 'patch'); 14 | const [nextVersion] = rsort([branchPatch0, packageJsonNextPatch], false); 15 | 16 | core.exportVariable('TITLE', `Release v${nextVersion}`); 17 | }; 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/upgradeable/patch-apply.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" 6 | PATCH="$DIRNAME/upgradeable.patch" 7 | 8 | error() { 9 | echo Error: "$*" >&2 10 | exit 1 11 | } 12 | 13 | if ! git diff-files --quiet ":!$PATCH" || ! git diff-index --quiet HEAD ":!$PATCH"; then 14 | error "Repository must have no staged or unstaged changes" 15 | fi 16 | 17 | if ! git apply -3 "$PATCH"; then 18 | error "Fix conflicts and run $DIRNAME/patch-save.sh" 19 | fi 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/upgradeable/patch-save.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" 6 | PATCH="$DIRNAME/upgradeable.patch" 7 | 8 | error() { 9 | echo Error: "$*" >&2 10 | exit 1 11 | } 12 | 13 | if ! git diff-files --quiet ":!$PATCH"; then 14 | error "Unstaged changes. Stage to include in patch or temporarily stash." 15 | fi 16 | 17 | git diff-index --cached --patch --output="$PATCH" HEAD 18 | git restore --staged --worktree ":!$PATCH" 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/slither.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "detectors_to_run": "arbitrary-send-erc20,array-by-reference,incorrect-shift,name-reused,rtlo,suicidal,uninitialized-state,uninitialized-storage,arbitrary-send-erc20-permit,controlled-array-length,controlled-delegatecall,delegatecall-loop,msg-value-loop,reentrancy-eth,unchecked-transfer,weak-prng,domain-separator-collision,erc20-interface,erc721-interface,locked-ether,mapping-deletion,shadowing-abstract,tautology,write-after-write,boolean-cst,reentrancy-no-eth,reused-constructor,tx-origin,unchecked-lowlevel,unchecked-send,variable-scope,void-cst,events-access,events-maths,incorrect-unary,boolean-equal,cyclomatic-complexity,deprecated-standards,erc20-indexed,function-init-state,pragma,unused-state,reentrancy-unlimited-gas,constable-states,immutable-states,var-read-using-this", 3 | "filter_paths": "contracts/mocks,contracts-exposed", 4 | "compile_force_framework": "hardhat" 5 | } 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/TESTING.md: -------------------------------------------------------------------------------- 1 | ## Testing 2 | 3 | Unit test are critical to OpenZeppelin Contracts. They help ensure code quality and mitigate against security vulnerabilities. The directory structure within the `/test` directory corresponds to the `/contracts` directory. 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/access/AccessControl.test.js: -------------------------------------------------------------------------------- 1 | const { DEFAULT_ADMIN_ROLE, shouldBehaveLikeAccessControl } = require('./AccessControl.behavior.js'); 2 | 3 | const AccessControl = artifacts.require('$AccessControl'); 4 | 5 | contract('AccessControl', function (accounts) { 6 | beforeEach(async function () { 7 | this.accessControl = await AccessControl.new({ from: accounts[0] }); 8 | await this.accessControl.$_grantRole(DEFAULT_ADMIN_ROLE, accounts[0]); 9 | }); 10 | 11 | shouldBehaveLikeAccessControl('AccessControl', ...accounts); 12 | }); 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/access/AccessControlEnumerable.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | DEFAULT_ADMIN_ROLE, 3 | shouldBehaveLikeAccessControl, 4 | shouldBehaveLikeAccessControlEnumerable, 5 | } = require('./AccessControl.behavior.js'); 6 | 7 | const AccessControlEnumerable = artifacts.require('$AccessControlEnumerable'); 8 | 9 | contract('AccessControl', function (accounts) { 10 | beforeEach(async function () { 11 | this.accessControl = await AccessControlEnumerable.new({ from: accounts[0] }); 12 | await this.accessControl.$_grantRole(DEFAULT_ADMIN_ROLE, accounts[0]); 13 | }); 14 | 15 | shouldBehaveLikeAccessControl('AccessControl', ...accounts); 16 | shouldBehaveLikeAccessControlEnumerable('AccessControl', ...accounts); 17 | }); 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/governance/utils/EIP6372.behavior.js: -------------------------------------------------------------------------------- 1 | const { clock } = require('../../helpers/time'); 2 | 3 | function shouldBehaveLikeEIP6372(mode = 'blocknumber') { 4 | describe('should implement EIP6372', function () { 5 | beforeEach(async function () { 6 | this.mock = this.mock ?? this.token ?? this.votes; 7 | }); 8 | 9 | it('clock is correct', async function () { 10 | expect(await this.mock.clock()).to.be.bignumber.equal(await clock[mode]().then(web3.utils.toBN)); 11 | }); 12 | 13 | it('CLOCK_MODE is correct', async function () { 14 | const params = new URLSearchParams(await this.mock.CLOCK_MODE()); 15 | expect(params.get('mode')).to.be.equal(mode); 16 | expect(params.get('from')).to.be.equal(mode == 'blocknumber' ? 'default' : null); 17 | }); 18 | }); 19 | } 20 | 21 | module.exports = { 22 | shouldBehaveLikeEIP6372, 23 | }; 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/chainid.js: -------------------------------------------------------------------------------- 1 | const hre = require('hardhat'); 2 | 3 | async function getChainId() { 4 | const chainIdHex = await hre.network.provider.send('eth_chainId', []); 5 | return new hre.web3.utils.BN(chainIdHex, 'hex'); 6 | } 7 | 8 | module.exports = { 9 | getChainId, 10 | }; 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/create2.js: -------------------------------------------------------------------------------- 1 | function computeCreate2Address(saltHex, bytecode, deployer) { 2 | return web3.utils.toChecksumAddress( 3 | `0x${web3.utils 4 | .sha3(`0x${['ff', deployer, saltHex, web3.utils.soliditySha3(bytecode)].map(x => x.replace(/0x/, '')).join('')}`) 5 | .slice(-40)}`, 6 | ); 7 | } 8 | 9 | module.exports = { 10 | computeCreate2Address, 11 | }; 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/customError.js: -------------------------------------------------------------------------------- 1 | const { config } = require('hardhat'); 2 | 3 | const optimizationsEnabled = config.solidity.compilers.some(c => c.settings.optimizer.enabled); 4 | 5 | /** Revert handler that supports custom errors. */ 6 | async function expectRevertCustomError(promise, reason) { 7 | try { 8 | await promise; 9 | expect.fail("Expected promise to throw but it didn't"); 10 | } catch (revert) { 11 | if (reason) { 12 | if (optimizationsEnabled) { 13 | // Optimizations currently mess with Hardhat's decoding of custom errors 14 | expect(revert.message).to.include.oneOf([reason, 'unrecognized return data or custom error']); 15 | } else { 16 | expect(revert.message).to.include(reason); 17 | } 18 | } 19 | } 20 | } 21 | 22 | module.exports = { 23 | expectRevertCustomError, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/enums.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | function Enum(...options) { 4 | return Object.fromEntries(options.map((key, i) => [key, new BN(i)])); 5 | } 6 | 7 | module.exports = { 8 | Enum, 9 | ProposalState: Enum('Pending', 'Active', 'Canceled', 'Defeated', 'Succeeded', 'Queued', 'Expired', 'Executed'), 10 | VoteType: Enum('Against', 'For', 'Abstain'), 11 | Rounding: Enum('Down', 'Up', 'Zero'), 12 | }; 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/erc1967.js: -------------------------------------------------------------------------------- 1 | const ImplementationLabel = 'eip1967.proxy.implementation'; 2 | const AdminLabel = 'eip1967.proxy.admin'; 3 | const BeaconLabel = 'eip1967.proxy.beacon'; 4 | 5 | function labelToSlot(label) { 6 | return '0x' + web3.utils.toBN(web3.utils.keccak256(label)).subn(1).toString(16); 7 | } 8 | 9 | function getSlot(address, slot) { 10 | return web3.eth.getStorageAt( 11 | web3.utils.isAddress(address) ? address : address.address, 12 | web3.utils.isHex(slot) ? slot : labelToSlot(slot), 13 | ); 14 | } 15 | 16 | module.exports = { 17 | ImplementationLabel, 18 | AdminLabel, 19 | BeaconLabel, 20 | ImplementationSlot: labelToSlot(ImplementationLabel), 21 | AdminSlot: labelToSlot(AdminLabel), 22 | BeaconSlot: labelToSlot(BeaconLabel), 23 | getSlot, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/map-values.js: -------------------------------------------------------------------------------- 1 | function mapValues(obj, fn) { 2 | return Object.fromEntries([...Object.entries(obj)].map(([k, v]) => [k, fn(v)])); 3 | } 4 | 5 | module.exports = { 6 | mapValues, 7 | }; 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/time.js: -------------------------------------------------------------------------------- 1 | const ozHelpers = require('@openzeppelin/test-helpers'); 2 | const helpers = require('@nomicfoundation/hardhat-network-helpers'); 3 | 4 | module.exports = { 5 | clock: { 6 | blocknumber: () => helpers.time.latestBlock(), 7 | timestamp: () => helpers.time.latest(), 8 | }, 9 | clockFromReceipt: { 10 | blocknumber: receipt => Promise.resolve(receipt.blockNumber), 11 | timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp), 12 | }, 13 | forward: { 14 | blocknumber: ozHelpers.time.advanceBlockTo, 15 | timestamp: helpers.time.increaseTo, 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/proxy/ERC1967/ERC1967Proxy.test.js: -------------------------------------------------------------------------------- 1 | const shouldBehaveLikeProxy = require('../Proxy.behaviour'); 2 | 3 | const ERC1967Proxy = artifacts.require('ERC1967Proxy'); 4 | 5 | contract('ERC1967Proxy', function (accounts) { 6 | const [proxyAdminOwner] = accounts; 7 | 8 | const createProxy = async function (implementation, _admin, initData, opts) { 9 | return ERC1967Proxy.new(implementation, initData, opts); 10 | }; 11 | 12 | shouldBehaveLikeProxy(createProxy, undefined, proxyAdminOwner); 13 | }); 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/proxy/transparent/TransparentUpgradeableProxy.test.js: -------------------------------------------------------------------------------- 1 | const shouldBehaveLikeProxy = require('../Proxy.behaviour'); 2 | const shouldBehaveLikeTransparentUpgradeableProxy = require('./TransparentUpgradeableProxy.behaviour'); 3 | 4 | const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy'); 5 | const ITransparentUpgradeableProxy = artifacts.require('ITransparentUpgradeableProxy'); 6 | 7 | contract('TransparentUpgradeableProxy', function (accounts) { 8 | const [proxyAdminAddress, proxyAdminOwner] = accounts; 9 | 10 | const createProxy = async function (logic, admin, initData, opts) { 11 | const { address } = await TransparentUpgradeableProxy.new(logic, admin, initData, opts); 12 | return ITransparentUpgradeableProxy.at(address); 13 | }; 14 | 15 | shouldBehaveLikeProxy(createProxy, proxyAdminAddress, proxyAdminOwner); 16 | shouldBehaveLikeTransparentUpgradeableProxy(createProxy, accounts); 17 | }); 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC20/extensions/ERC20Burnable.test.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | const { shouldBehaveLikeERC20Burnable } = require('./ERC20Burnable.behavior'); 4 | const ERC20Burnable = artifacts.require('$ERC20Burnable'); 5 | 6 | contract('ERC20Burnable', function (accounts) { 7 | const [owner, ...otherAccounts] = accounts; 8 | 9 | const initialBalance = new BN(1000); 10 | 11 | const name = 'My Token'; 12 | const symbol = 'MTKN'; 13 | 14 | beforeEach(async function () { 15 | this.token = await ERC20Burnable.new(name, symbol, { from: owner }); 16 | await this.token.$_mint(owner, initialBalance); 17 | }); 18 | 19 | shouldBehaveLikeERC20Burnable(owner, initialBalance, otherAccounts); 20 | }); 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC20/extensions/ERC20Capped.test.js: -------------------------------------------------------------------------------- 1 | const { ether, expectRevert } = require('@openzeppelin/test-helpers'); 2 | const { shouldBehaveLikeERC20Capped } = require('./ERC20Capped.behavior'); 3 | 4 | const ERC20Capped = artifacts.require('$ERC20Capped'); 5 | 6 | contract('ERC20Capped', function (accounts) { 7 | const cap = ether('1000'); 8 | 9 | const name = 'My Token'; 10 | const symbol = 'MTKN'; 11 | 12 | it('requires a non-zero cap', async function () { 13 | await expectRevert(ERC20Capped.new(name, symbol, 0), 'ERC20Capped: cap is 0'); 14 | }); 15 | 16 | context('once deployed', async function () { 17 | beforeEach(async function () { 18 | this.token = await ERC20Capped.new(name, symbol, cap); 19 | }); 20 | 21 | shouldBehaveLikeERC20Capped(accounts, cap); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/ERC721.test.js: -------------------------------------------------------------------------------- 1 | const { shouldBehaveLikeERC721, shouldBehaveLikeERC721Metadata } = require('./ERC721.behavior'); 2 | 3 | const ERC721 = artifacts.require('$ERC721'); 4 | 5 | contract('ERC721', function (accounts) { 6 | const name = 'Non Fungible Token'; 7 | const symbol = 'NFT'; 8 | 9 | beforeEach(async function () { 10 | this.token = await ERC721.new(name, symbol); 11 | }); 12 | 13 | shouldBehaveLikeERC721('ERC721', ...accounts); 14 | shouldBehaveLikeERC721Metadata('ERC721', name, symbol, ...accounts); 15 | }); 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/ERC721Enumerable.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | shouldBehaveLikeERC721, 3 | shouldBehaveLikeERC721Metadata, 4 | shouldBehaveLikeERC721Enumerable, 5 | } = require('./ERC721.behavior'); 6 | 7 | const ERC721Enumerable = artifacts.require('$ERC721Enumerable'); 8 | 9 | contract('ERC721Enumerable', function (accounts) { 10 | const name = 'Non Fungible Token'; 11 | const symbol = 'NFT'; 12 | 13 | beforeEach(async function () { 14 | this.token = await ERC721Enumerable.new(name, symbol); 15 | }); 16 | 17 | shouldBehaveLikeERC721('ERC721', ...accounts); 18 | shouldBehaveLikeERC721Metadata('ERC721', name, symbol, ...accounts); 19 | shouldBehaveLikeERC721Enumerable('ERC721', ...accounts); 20 | }); 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/utils/ERC721Holder.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | const ERC721Holder = artifacts.require('ERC721Holder'); 4 | const ERC721 = artifacts.require('$ERC721'); 5 | 6 | contract('ERC721Holder', function (accounts) { 7 | const [owner] = accounts; 8 | 9 | const name = 'Non Fungible Token'; 10 | const symbol = 'NFT'; 11 | const tokenId = web3.utils.toBN(1); 12 | 13 | it('receives an ERC721 token', async function () { 14 | const token = await ERC721.new(name, symbol); 15 | await token.$_mint(owner, tokenId); 16 | 17 | const receiver = await ERC721Holder.new(); 18 | await token.safeTransferFrom(owner, receiver.address, tokenId, { from: owner }); 19 | 20 | expect(await token.ownerOf(tokenId)).to.be.equal(receiver.address); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/Context.test.js: -------------------------------------------------------------------------------- 1 | require('@openzeppelin/test-helpers'); 2 | 3 | const ContextMock = artifacts.require('ContextMock'); 4 | const ContextMockCaller = artifacts.require('ContextMockCaller'); 5 | 6 | const { shouldBehaveLikeRegularContext } = require('./Context.behavior'); 7 | 8 | contract('Context', function (accounts) { 9 | const [sender] = accounts; 10 | 11 | beforeEach(async function () { 12 | this.context = await ContextMock.new(); 13 | this.caller = await ContextMockCaller.new(); 14 | }); 15 | 16 | shouldBehaveLikeRegularContext(sender); 17 | }); 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/escrow/Escrow.test.js: -------------------------------------------------------------------------------- 1 | require('@openzeppelin/test-helpers'); 2 | const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); 3 | 4 | const Escrow = artifacts.require('Escrow'); 5 | 6 | contract('Escrow', function (accounts) { 7 | const [owner, ...otherAccounts] = accounts; 8 | 9 | beforeEach(async function () { 10 | this.escrow = await Escrow.new({ from: owner }); 11 | }); 12 | 13 | shouldBehaveLikeEscrow(owner, otherAccounts); 14 | }); 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/introspection/ERC165.test.js: -------------------------------------------------------------------------------- 1 | const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); 2 | 3 | const ERC165 = artifacts.require('$ERC165'); 4 | 5 | contract('ERC165', function () { 6 | beforeEach(async function () { 7 | this.mock = await ERC165.new(); 8 | }); 9 | 10 | shouldSupportInterfaces(['ERC165']); 11 | }); 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/introspection/ERC165Storage.test.js: -------------------------------------------------------------------------------- 1 | const { expectRevert } = require('@openzeppelin/test-helpers'); 2 | 3 | const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); 4 | 5 | const ERC165Storage = artifacts.require('$ERC165Storage'); 6 | 7 | contract('ERC165Storage', function () { 8 | beforeEach(async function () { 9 | this.mock = await ERC165Storage.new(); 10 | }); 11 | 12 | it('register interface', async function () { 13 | expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(false); 14 | await this.mock.$_registerInterface('0x00000001'); 15 | expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(true); 16 | }); 17 | 18 | it('does not allow 0xffffffff', async function () { 19 | await expectRevert(this.mock.$_registerInterface('0xffffffff'), 'ERC165: invalid interface id'); 20 | }); 21 | 22 | shouldSupportInterfaces(['ERC165']); 23 | }); 24 | -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathLeastSignificantBitMaxUint128.snap: -------------------------------------------------------------------------------- 1 | 458 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathLeastSignificantBitMaxUint256.snap: -------------------------------------------------------------------------------- 1 | 461 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathLeastSignificantBitSmallNumber.snap: -------------------------------------------------------------------------------- 1 | 456 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathMostSignificantBitMaxUint128.snap: -------------------------------------------------------------------------------- 1 | 394 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathMostSignificantBitMaxUint256.snap: -------------------------------------------------------------------------------- 1 | 415 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/BitMathMostSignificantBitSmallNumber.snap: -------------------------------------------------------------------------------- 1 | 322 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/HooksShouldCallBeforeSwap.snap: -------------------------------------------------------------------------------- 1 | 34 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/NoDelegateCallOverhead.snap: -------------------------------------------------------------------------------- 1 | 41 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/donate gas with 1 token.snap: -------------------------------------------------------------------------------- 1 | 131232 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/donate gas with 2 tokens.snap: -------------------------------------------------------------------------------- 1 | 185897 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/gas overhead of no-op lock.snap: -------------------------------------------------------------------------------- 1 | 61078 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/initialize.snap: -------------------------------------------------------------------------------- 1 | 37658 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/mint with empty hook.snap: -------------------------------------------------------------------------------- 1 | 320430 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/mint with native token.snap: -------------------------------------------------------------------------------- 1 | 294443 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/mint.snap: -------------------------------------------------------------------------------- 1 | 313107 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/poolExtsloadSlot0.snap: -------------------------------------------------------------------------------- 1 | 1129 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/poolExtsloadTickInfoStruct.snap: -------------------------------------------------------------------------------- 1 | 2763 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/simple swap.snap: -------------------------------------------------------------------------------- 1 | 67800 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/swap against liquidity with native token.snap: -------------------------------------------------------------------------------- 1 | 161637 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/swap against liquidity.snap: -------------------------------------------------------------------------------- 1 | 146344 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/swap with hooks.snap: -------------------------------------------------------------------------------- 1 | 67775 -------------------------------------------------------------------------------- /lib/v4-core/.forge-snapshots/swap with native.snap: -------------------------------------------------------------------------------- 1 | 67800 -------------------------------------------------------------------------------- /lib/v4-core/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity -------------------------------------------------------------------------------- /lib/v4-core/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Related Issue 2 | Which issue does this pull request resolve? 3 | 4 | ## Description of changes -------------------------------------------------------------------------------- /lib/v4-core/.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | run-linters: 11 | name: Run linters 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Check out Git repository 16 | uses: actions/checkout@v3 17 | 18 | - name: Set up node 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: 16 22 | cache: 'yarn' 23 | 24 | - name: Install dependencies 25 | run: yarn install --frozen-lockfile 26 | 27 | - name: Install Foundry 28 | uses: foundry-rs/foundry-toolchain@v1 29 | with: 30 | version: nightly 31 | 32 | - name: Compile 33 | run: yarn prettier-check 34 | -------------------------------------------------------------------------------- /lib/v4-core/.gitignore: -------------------------------------------------------------------------------- 1 | artifacts/ 2 | cache/ 3 | crytic-export/ 4 | node_modules/ 5 | typechain/ 6 | foundry-out/ 7 | .vscode/ -------------------------------------------------------------------------------- /lib/v4-core/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "lib/forge-gas-snapshot"] 5 | path = lib/forge-gas-snapshot 6 | url = https://github.com/marktoda/forge-gas-snapshot 7 | [submodule "lib/solmate"] 8 | path = lib/solmate 9 | url = https://github.com/transmissions11/solmate 10 | -------------------------------------------------------------------------------- /lib/v4-core/.nvmrc: -------------------------------------------------------------------------------- 1 | v16 -------------------------------------------------------------------------------- /lib/v4-core/.prettierignore: -------------------------------------------------------------------------------- 1 | typechain/ 2 | lib/forge-std/ 3 | -------------------------------------------------------------------------------- /lib/v4-core/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "printWidth": 120 5 | } 6 | -------------------------------------------------------------------------------- /lib/v4-core/.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["prettier"], 3 | "rules": { 4 | "prettier/prettier": "error" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/v4-core/.yarnrc: -------------------------------------------------------------------------------- 1 | ignore-scripts true 2 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/Owned.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BUSL-1.1 2 | pragma solidity ^0.8.19; 3 | 4 | contract Owned { 5 | address public owner; 6 | 7 | error InvalidCaller(); 8 | 9 | /// @notice Emitted when the owner of the factory is changed 10 | /// @param oldOwner The owner before the owner was changed 11 | /// @param newOwner The owner after the owner was changed 12 | event OwnerChanged(address indexed oldOwner, address indexed newOwner); 13 | 14 | modifier onlyOwner() { 15 | if (msg.sender != owner) revert InvalidCaller(); 16 | _; 17 | } 18 | 19 | constructor() { 20 | owner = msg.sender; 21 | emit OwnerChanged(address(0), msg.sender); 22 | } 23 | 24 | function setOwner(address _owner) external onlyOwner { 25 | emit OwnerChanged(owner, _owner); 26 | owner = _owner; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/interfaces/IDynamicFeeManager.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | import {IPoolManager} from "./IPoolManager.sol"; 5 | 6 | /// @notice The dynamic fee manager determines fees for pools 7 | /// @dev note that this pool is only called if the PoolKey fee value is equal to the DYNAMIC_FEE magic value 8 | interface IDynamicFeeManager { 9 | function getFee(IPoolManager.PoolKey calldata key) external returns (uint24); 10 | } 11 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/interfaces/IHookFeeManager.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | import {IPoolManager} from "./IPoolManager.sol"; 5 | 6 | /// @notice The interface for setting a fee on swap or fee on withdraw to the hook 7 | /// @dev This callback is only made if the Fee.HOOK_SWAP_FEE_FLAG or Fee.HOOK_WITHDRAW_FEE_FLAG in set in the pool's key.fee. 8 | interface IHookFeeManager { 9 | /// @notice Sets the fee a hook can take at swap. 10 | /// @param key The pool key 11 | /// @return The fee as an integer denominator for 1 to 0 swaps (upper bits set) or 0 to 1 swaps (lower bits set). 12 | function getHookSwapFee(IPoolManager.PoolKey calldata key) external view returns (uint8); 13 | 14 | /// @notice Sets the fee a hook can take at withdraw. 15 | /// @param key The pool key 16 | /// @return The fee as an integer denominator for amount1 (upper bits set) or amount0 (lower bits set). 17 | function getHookWithdrawFee(IPoolManager.PoolKey calldata key) external view returns (uint8); 18 | } 19 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/interfaces/IProtocolFeeController.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | import {IPoolManager} from "./IPoolManager.sol"; 5 | 6 | interface IProtocolFeeController { 7 | /// @notice Returns the protocol fees for a pool given the conditions of this contract 8 | /// @param poolKey The pool key to identify the pool. The controller may want to use attributes on the pool 9 | /// to determine the protocol fee, hence the entire key is needed. 10 | function protocolFeesForPool(IPoolManager.PoolKey memory poolKey) external view returns (uint8, uint8); 11 | } 12 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/interfaces/callback/ILockCallback.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | interface ILockCallback { 5 | /// @notice Called by the pool manager on `msg.sender` when a lock is acquired 6 | /// @param id The id of the lock that was acquired 7 | /// @param data The data that was passed to the call to lock 8 | /// @return Any data that you want to be returned from the lock call 9 | function lockAcquired(uint256 id, bytes calldata data) external returns (bytes memory); 10 | } 11 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/libraries/Fees.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | library Fees { 5 | uint24 public constant STATIC_FEE_MASK = 0x0FFFFF; 6 | uint24 public constant DYNAMIC_FEE_FLAG = 0x800000; // 1000 7 | uint24 public constant HOOK_SWAP_FEE_FLAG = 0x400000; // 0100 8 | uint24 public constant HOOK_WITHDRAW_FEE_FLAG = 0x200000; // 0010 9 | 10 | function isDynamicFee(uint24 self) internal pure returns (bool) { 11 | return self & DYNAMIC_FEE_FLAG != 0; 12 | } 13 | 14 | function hasHookSwapFee(uint24 self) internal pure returns (bool) { 15 | return self & HOOK_SWAP_FEE_FLAG != 0; 16 | } 17 | 18 | function hasHookWithdrawFee(uint24 self) internal pure returns (bool) { 19 | return self & HOOK_WITHDRAW_FEE_FLAG != 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/libraries/FixedPoint128.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | /// @title FixedPoint128 5 | /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) 6 | library FixedPoint128 { 7 | uint256 internal constant Q128 = 0x100000000000000000000000000000000; 8 | } 9 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/libraries/FixedPoint96.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | /// @title FixedPoint96 5 | /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) 6 | /// @dev Used in SqrtPriceMath.sol 7 | library FixedPoint96 { 8 | uint8 internal constant RESOLUTION = 96; 9 | uint256 internal constant Q96 = 0x1000000000000000000000000; 10 | } 11 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/libraries/PoolId.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | import {IPoolManager} from "../interfaces/IPoolManager.sol"; 5 | 6 | /// @notice Library for computing the ID of a pool 7 | library PoolId { 8 | function toId(IPoolManager.PoolKey memory poolKey) internal pure returns (bytes32) { 9 | return keccak256(abi.encode(poolKey)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/libraries/UnsafeMath.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | pragma solidity ^0.8.19; 3 | 4 | /// @title Math functions that do not check inputs or outputs 5 | /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks 6 | library UnsafeMath { 7 | /// @notice Returns ceil(x / y) 8 | /// @dev division by 0 has unspecified behavior, and must be checked externally 9 | /// @param x The dividend 10 | /// @param y The divisor 11 | /// @return z The quotient, ceil(x / y) 12 | function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { 13 | unchecked { 14 | assembly { 15 | z := add(div(x, y), gt(mod(x, y), 0)) 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/BitMathEchidnaTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {BitMath} from "../libraries/BitMath.sol"; 5 | 6 | contract BitMathEchidnaTest { 7 | function mostSignificantBitInvariant(uint256 input) external pure { 8 | unchecked { 9 | uint8 msb = BitMath.mostSignificantBit(input); 10 | assert(input >= (uint256(2) ** msb)); 11 | assert(msb == 255 || input < uint256(2) ** (msb + 1)); 12 | } 13 | } 14 | 15 | function leastSignificantBitInvariant(uint256 input) external pure { 16 | unchecked { 17 | uint8 lsb = BitMath.leastSignificantBit(input); 18 | assert(input & (uint256(2) ** lsb) != 0); 19 | assert(input & (uint256(2) ** lsb - 1) == 0); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/FullMathTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {FullMath} from "../libraries/FullMath.sol"; 5 | 6 | contract FullMathTest { 7 | function mulDiv(uint256 x, uint256 y, uint256 z) external pure returns (uint256) { 8 | return FullMath.mulDiv(x, y, z); 9 | } 10 | 11 | function mulDivRoundingUp(uint256 x, uint256 y, uint256 z) external pure returns (uint256) { 12 | return FullMath.mulDivRoundingUp(x, y, z); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/PoolLockTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol"; 5 | import {IPoolManager} from "../interfaces/IPoolManager.sol"; 6 | import {ILockCallback} from "../interfaces/callback/ILockCallback.sol"; 7 | 8 | contract PoolLockTest is ILockCallback { 9 | event LockAcquired(uint256 id); 10 | 11 | IPoolManager manager; 12 | 13 | constructor(IPoolManager _manager) { 14 | manager = _manager; 15 | } 16 | 17 | function lock() external { 18 | manager.lock(""); 19 | } 20 | 21 | /// @notice Called by the pool manager on `msg.sender` when a lock is acquired 22 | function lockAcquired(uint256 id, bytes calldata) external override returns (bytes memory) { 23 | emit LockAcquired(id); 24 | return ""; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/ProtocolFeeControllerTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {IProtocolFeeController} from "../interfaces/IProtocolFeeController.sol"; 5 | import {IPoolManager} from "../interfaces/IPoolManager.sol"; 6 | import {PoolId} from "../libraries/PoolId.sol"; 7 | 8 | contract ProtocolFeeControllerTest is IProtocolFeeController { 9 | using PoolId for IPoolManager.PoolKey; 10 | 11 | mapping(bytes32 => uint8) public swapFeeForPool; 12 | mapping(bytes32 => uint8) public withdrawFeeForPool; 13 | 14 | function protocolFeesForPool(IPoolManager.PoolKey memory key) external view returns (uint8, uint8) { 15 | return (swapFeeForPool[key.toId()], withdrawFeeForPool[key.toId()]); 16 | } 17 | 18 | // for tests to set pool protocol fees 19 | function setSwapFeeForPool(bytes32 id, uint8 fee) external { 20 | swapFeeForPool[id] = fee; 21 | } 22 | 23 | function setWithdrawFeeForPool(bytes32 id, uint8 fee) external { 24 | withdrawFeeForPool[id] = fee; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/SwapMathTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {SwapMath} from "../libraries/SwapMath.sol"; 5 | 6 | contract SwapMathTest { 7 | function computeSwapStep( 8 | uint160 sqrtP, 9 | uint160 sqrtPTarget, 10 | uint128 liquidity, 11 | int256 amountRemaining, 12 | uint24 feePips 13 | ) external pure returns (uint160 sqrtQ, uint256 amountIn, uint256 amountOut, uint256 feeAmount) { 14 | return SwapMath.computeSwapStep(sqrtP, sqrtPTarget, liquidity, amountRemaining, feePips); 15 | } 16 | 17 | function getGasCostOfComputeSwapStep( 18 | uint160 sqrtP, 19 | uint160 sqrtPTarget, 20 | uint128 liquidity, 21 | int256 amountRemaining, 22 | uint24 feePips 23 | ) external view returns (uint256) { 24 | uint256 gasBefore = gasleft(); 25 | SwapMath.computeSwapStep(sqrtP, sqrtPTarget, liquidity, amountRemaining, feePips); 26 | return gasBefore - gasleft(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/TickMathEchidnaTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {TickMath} from "../libraries/TickMath.sol"; 5 | 6 | contract TickMathEchidnaTest { 7 | // uniqueness and increasing order 8 | function checkGetSqrtRatioAtTickInvariants(int24 tick) external pure { 9 | uint160 ratio = TickMath.getSqrtRatioAtTick(tick); 10 | assert(TickMath.getSqrtRatioAtTick(tick - 1) < ratio && ratio < TickMath.getSqrtRatioAtTick(tick + 1)); 11 | assert(ratio >= TickMath.MIN_SQRT_RATIO); 12 | assert(ratio <= TickMath.MAX_SQRT_RATIO); 13 | } 14 | 15 | // the ratio is always between the returned tick and the returned tick+1 16 | function checkGetTickAtSqrtRatioInvariants(uint160 ratio) external pure { 17 | int24 tick = TickMath.getTickAtSqrtRatio(ratio); 18 | assert(ratio >= TickMath.getSqrtRatioAtTick(tick) && ratio < TickMath.getSqrtRatioAtTick(tick + 1)); 19 | assert(tick >= TickMath.MIN_TICK); 20 | assert(tick < TickMath.MAX_TICK); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/v4-core/contracts/test/UnsafeMathEchidnaTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {UnsafeMath} from "../libraries/UnsafeMath.sol"; 5 | 6 | contract UnsafeMathEchidnaTest { 7 | function checkDivRoundingUp(uint256 x, uint256 d) external pure { 8 | require(d > 0); 9 | uint256 z = UnsafeMath.divRoundingUp(x, d); 10 | uint256 diff = z - (x / d); 11 | if (x % d == 0) { 12 | assert(diff == 0); 13 | } else { 14 | assert(diff == 1); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/v4-core/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'contracts' 3 | out = 'foundry-out' 4 | solc_version = '0.8.19' 5 | optimizer_runs = 800 6 | ffi = true 7 | fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access = "read", path = "./foundry-out"}] 8 | 9 | [profile.ci] 10 | fuzz_runs = 100000 11 | 12 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config 13 | -------------------------------------------------------------------------------- /lib/v4-core/justfile: -------------------------------------------------------------------------------- 1 | test: test-forge test-hardhat 2 | prep: fix snapshots 3 | snapshots: snapshots-forge snapshots-hardhat 4 | 5 | test-forge: install-forge build-forge 6 | forge test 7 | 8 | test-hardhat: install-hardhat 9 | yarn test 10 | 11 | build-forge: install-forge 12 | forge build 13 | 14 | build-hardhat: install-hardhat 15 | yarn build 16 | 17 | snapshots-forge: install-forge 18 | forge snapshot 19 | 20 | snapshots-hardhat: install-hardhat 21 | yarn snapshots 22 | 23 | install-forge: 24 | forge install 25 | 26 | install-hardhat: 27 | yarn install 28 | 29 | fix: 30 | forge fmt 31 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/add.snap: -------------------------------------------------------------------------------- 1 | 5247 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/addClosure.snap: -------------------------------------------------------------------------------- 1 | 3060 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/addFirst.snap: -------------------------------------------------------------------------------- 1 | 5247 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/addSecond.snap: -------------------------------------------------------------------------------- 1 | 744 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/addThird.snap: -------------------------------------------------------------------------------- 1 | 744 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/checkManyAdd.snap: -------------------------------------------------------------------------------- 1 | 24330 2 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/checkManySstore.snap: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/checkSize.snap: -------------------------------------------------------------------------------- 1 | 303 2 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/checkSizeFail.snap: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/internalClosure.snap: -------------------------------------------------------------------------------- 1 | 19177 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/manyAdd.snap: -------------------------------------------------------------------------------- 1 | 24330 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/manySstore.snap: -------------------------------------------------------------------------------- 1 | 56084 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/sizeTarget.snap: -------------------------------------------------------------------------------- 1 | 303 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/sstoreClosure.snap: -------------------------------------------------------------------------------- 1 | 53894 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.forge-snapshots/value.snap: -------------------------------------------------------------------------------- 1 | 1234 -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | FOUNDRY_PROFILE: ci 7 | 8 | jobs: 9 | check: 10 | strategy: 11 | fail-fast: true 12 | 13 | name: Foundry project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | with: 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run Forge build 26 | run: | 27 | forge --version 28 | forge build --sizes 29 | id: build 30 | 31 | - name: Run Forge tests 32 | run: | 33 | forge test -vvv 34 | id: test 35 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | lib/ 3 | cache/ 4 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | ffi = true 6 | fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] 7 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-gas-snapshot/src/test/SimpleOperations.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.15; 3 | 4 | contract SimpleOperations { 5 | uint256 internal test; 6 | 7 | function add() public pure { 8 | uint256 x = 1; 9 | x++; 10 | } 11 | 12 | function manyAdd() public pure { 13 | uint256 x; 14 | for (uint256 i = 0; i < 100; i++) { 15 | x = i + 1; 16 | } 17 | } 18 | 19 | function manySstore() public { 20 | for (uint256 i = 0; i < 100; i++) { 21 | test = i + 2; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | out/ 3 | .vscode 4 | .idea 5 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | fs_permissions = [{ access = "read-write", path = "./"}] 3 | 4 | [rpc_endpoints] 5 | # The RPC URLs are modified versions of the default for testing initialization. 6 | mainnet = "https://mainnet.infura.io/v3/16a8be88795540b9b3903d8de0f7baa5" # Different API key. 7 | optimism_goerli = "https://goerli.optimism.io/" # Adds a trailing slash. 8 | arbitrum_one_goerli = "https://goerli-rollup.arbitrum.io/rpc/" # Adds a trailing slash. 9 | needs_undefined_env_var = "${UNDEFINED_RPC_URL_PLACEHOLDER}" 10 | 11 | [fmt] 12 | # These are all the `forge fmt` defaults. 13 | line_length = 120 14 | tab_width = 4 15 | bracket_spacing = false 16 | int_types = 'long' 17 | multiline_func_header = 'attributes_first' 18 | quote_style = 'double' 19 | number_underscore = 'preserve' 20 | single_line_statement_blocks = 'preserve' 21 | ignore = ["src/console.sol", "src/console2.sol"] -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/lib/ds-test/.gitignore: -------------------------------------------------------------------------------- 1 | /.dapple 2 | /build 3 | /out 4 | /cache/ 5 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/lib/ds-test/Makefile: -------------------------------------------------------------------------------- 1 | all:; dapp build 2 | 3 | test: 4 | -dapp --use solc:0.4.23 build 5 | -dapp --use solc:0.4.26 build 6 | -dapp --use solc:0.5.17 build 7 | -dapp --use solc:0.6.12 build 8 | -dapp --use solc:0.7.5 build 9 | 10 | demo: 11 | DAPP_SRC=demo dapp --use solc:0.7.5 build 12 | -hevm dapp-test --verbose 3 13 | 14 | .PHONY: test demo 15 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/lib/ds-test/default.nix: -------------------------------------------------------------------------------- 1 | { solidityPackage, dappsys }: solidityPackage { 2 | name = "ds-test"; 3 | src = ./src; 4 | } 5 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/lib/ds-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ds-test", 3 | "version": "1.0.0", 4 | "description": "Assertions, equality checks and other test helpers ", 5 | "bugs": "https://github.com/dapphub/ds-test/issues", 6 | "license": "GPL-3.0", 7 | "author": "Contributors to ds-test", 8 | "files": [ 9 | "src/*" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/dapphub/ds-test.git" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "forge-std", 3 | "version": "1.5.2", 4 | "description": "Forge Standard Library is a collection of helpful contracts and libraries for use with Forge and Foundry.", 5 | "homepage": "https://book.getfoundry.sh/forge/forge-std", 6 | "bugs": "https://github.com/foundry-rs/forge-std/issues", 7 | "license": "(Apache-2.0 OR MIT)", 8 | "author": "Contributors to Forge Standard Library", 9 | "files": [ 10 | "src/**/*" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/foundry-rs/forge-std.git" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/src/Script.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | // 💬 ABOUT 5 | // Standard Library's default Script. 6 | 7 | // 🧩 MODULES 8 | import {ScriptBase} from "./Base.sol"; 9 | import {console} from "./console.sol"; 10 | import {console2} from "./console2.sol"; 11 | import {StdChains} from "./StdChains.sol"; 12 | import {StdCheatsSafe} from "./StdCheats.sol"; 13 | import {stdJson} from "./StdJson.sol"; 14 | import {stdMath} from "./StdMath.sol"; 15 | import {StdStorage, stdStorageSafe} from "./StdStorage.sol"; 16 | import {StdUtils} from "./StdUtils.sol"; 17 | import {VmSafe} from "./Vm.sol"; 18 | 19 | // 📦 BOILERPLATE 20 | import {ScriptBase} from "./Base.sol"; 21 | 22 | // ⭐️ SCRIPT 23 | abstract contract Script is StdChains, StdCheatsSafe, StdUtils, ScriptBase { 24 | // Note: IS_SCRIPT() must return true. 25 | bool public IS_SCRIPT = true; 26 | } 27 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/src/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2; 3 | 4 | interface IERC165 { 5 | /// @notice Query if a contract implements an interface 6 | /// @param interfaceID The interface identifier, as specified in ERC-165 7 | /// @dev Interface identification is specified in ERC-165. This function 8 | /// uses less than 30,000 gas. 9 | /// @return `true` if the contract implements `interfaceID` and 10 | /// `interfaceID` is not 0xffffffff, `false` otherwise 11 | function supportsInterface(bytes4 interfaceID) external view returns (bool); 12 | } 13 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/test/compilation/CompilationScript.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScript is Script {} 11 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/test/compilation/CompilationScriptBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Script.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationScriptBase is ScriptBase {} 11 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/test/compilation/CompilationTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTest is Test {} 11 | -------------------------------------------------------------------------------- /lib/v4-core/lib/forge-std/test/compilation/CompilationTestBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.2 <0.9.0; 3 | 4 | pragma experimental ABIEncoderV2; 5 | 6 | import "../../src/Test.sol"; 7 | 8 | // The purpose of this contract is to benchmark compilation time to avoid accidentally introducing 9 | // a change that results in very long compilation times with via-ir. See https://github.com/foundry-rs/forge-std/issues/207 10 | contract CompilationTestBase is TestBase {} 11 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.gitattributes: -------------------------------------------------------------------------------- 1 | .gas-snapshot linguist-language=Julia -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Describe the changes made in your pull request here. 4 | 5 | ## Checklist 6 | 7 | Ensure you completed **all of the steps** below before submitting your pull request: 8 | 9 | - [ ] Ran `forge snapshot`? 10 | - [ ] Ran `npm run lint`? 11 | - [ ] Ran `forge test`? 12 | 13 | _Pull requests with an incomplete checklist will be thrown out._ 14 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | tests: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - name: Install Foundry 12 | uses: onbjerg/foundry-toolchain@v1 13 | with: 14 | version: nightly 15 | 16 | - name: Install dependencies 17 | run: forge install 18 | 19 | - name: Check contract sizes 20 | run: forge build --sizes 21 | 22 | - name: Check gas snapshots 23 | run: forge snapshot --check 24 | 25 | - name: Run tests 26 | run: forge test 27 | env: 28 | # Only fuzz intensely if we're running this action on a push to main or for a PR going into main: 29 | FOUNDRY_PROFILE: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'intense' }} 30 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.gitignore: -------------------------------------------------------------------------------- 1 | /cache 2 | /node_modules 3 | /out -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.prettierignore: -------------------------------------------------------------------------------- 1 | lib -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "printWidth": 100, 4 | 5 | "overrides": [ 6 | { 7 | "files": "*.sol", 8 | "options": { 9 | "tabWidth": 4, 10 | "printWidth": 120 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/audits/v6-Fixed-Point-Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/v4-core/lib/solmate/audits/v6-Fixed-Point-Solutions.pdf -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | solc = "0.8.15" 3 | bytecode_hash = "none" 4 | optimizer_runs = 1000000 5 | 6 | [profile.intense.fuzz] 7 | runs = 10000 8 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/lib/ds-test/.gitignore: -------------------------------------------------------------------------------- 1 | /.dapple 2 | /build 3 | /out 4 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/lib/ds-test/Makefile: -------------------------------------------------------------------------------- 1 | all:; dapp build 2 | 3 | test: 4 | -dapp --use solc:0.4.23 build 5 | -dapp --use solc:0.4.26 build 6 | -dapp --use solc:0.5.17 build 7 | -dapp --use solc:0.6.12 build 8 | -dapp --use solc:0.7.5 build 9 | 10 | demo: 11 | DAPP_SRC=demo dapp --use solc:0.7.5 build 12 | -hevm dapp-test --verbose 3 13 | 14 | .PHONY: test demo 15 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/lib/ds-test/default.nix: -------------------------------------------------------------------------------- 1 | { solidityPackage, dappsys }: solidityPackage { 2 | name = "ds-test"; 3 | src = ./src; 4 | } 5 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/lib/ds-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ds-test", 3 | "version": "1.0.0", 4 | "description": "Assertions, equality checks and other test helpers ", 5 | "bugs": "https://github.com/dapphub/ds-test/issues", 6 | "license": "GPL-3.0", 7 | "author": "Contributors to ds-test", 8 | "files": [ 9 | "src/*" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/dapphub/ds-test.git" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "solmate", 3 | "license": "AGPL-3.0-only", 4 | "version": "6.7.0", 5 | "description": "Modern, opinionated and gas optimized building blocks for smart contract development.", 6 | "files": [ 7 | "src/**/*.sol" 8 | ], 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/transmissions11/solmate.git" 12 | }, 13 | "devDependencies": { 14 | "prettier": "^2.3.1", 15 | "prettier-plugin-solidity": "^1.0.0-beta.13" 16 | }, 17 | "scripts": { 18 | "lint": "prettier --write **.sol" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/Bytes32AddressLib.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.15; 3 | 4 | import {DSTestPlus} from "./utils/DSTestPlus.sol"; 5 | 6 | import {Bytes32AddressLib} from "../utils/Bytes32AddressLib.sol"; 7 | 8 | contract Bytes32AddressLibTest is DSTestPlus { 9 | function testFillLast12Bytes() public { 10 | assertEq( 11 | Bytes32AddressLib.fillLast12Bytes(0xfEEDFaCEcaFeBEEFfEEDFACecaFEBeeFfeEdfAce), 12 | 0xfeedfacecafebeeffeedfacecafebeeffeedface000000000000000000000000 13 | ); 14 | } 15 | 16 | function testFromLast20Bytes() public { 17 | assertEq( 18 | Bytes32AddressLib.fromLast20Bytes(0xfeedfacecafebeeffeedfacecafebeeffeedfacecafebeeffeedfacecafebeef), 19 | 0xCAfeBeefFeedfAceCAFeBEEffEEDfaCecafEBeeF 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/DSInvariantTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | contract DSInvariantTest { 5 | address[] private targets; 6 | 7 | function targetContracts() public view virtual returns (address[] memory) { 8 | require(targets.length > 0, "NO_TARGET_CONTRACTS"); 9 | 10 | return targets; 11 | } 12 | 13 | function addTargetContract(address newTargetContract) internal virtual { 14 | targets.push(newTargetContract); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockAuthChild.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {Auth, Authority} from "../../../auth/Auth.sol"; 5 | 6 | contract MockAuthChild is Auth(msg.sender, Authority(address(0))) { 7 | bool public flag; 8 | 9 | function updateFlag() public virtual requiresAuth { 10 | flag = true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockAuthority.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {Authority} from "../../../auth/Auth.sol"; 5 | 6 | contract MockAuthority is Authority { 7 | bool immutable allowCalls; 8 | 9 | constructor(bool _allowCalls) { 10 | allowCalls = _allowCalls; 11 | } 12 | 13 | function canCall( 14 | address, 15 | address, 16 | bytes4 17 | ) public view override returns (bool) { 18 | return allowCalls; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {ERC20} from "../../../tokens/ERC20.sol"; 5 | 6 | contract MockERC20 is ERC20 { 7 | constructor( 8 | string memory _name, 9 | string memory _symbol, 10 | uint8 _decimals 11 | ) ERC20(_name, _symbol, _decimals) {} 12 | 13 | function mint(address to, uint256 value) public virtual { 14 | _mint(to, value); 15 | } 16 | 17 | function burn(address from, uint256 value) public virtual { 18 | _burn(from, value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockERC4626.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {ERC20} from "../../../tokens/ERC20.sol"; 5 | import {ERC4626} from "../../../mixins/ERC4626.sol"; 6 | 7 | contract MockERC4626 is ERC4626 { 8 | uint256 public beforeWithdrawHookCalledCounter = 0; 9 | uint256 public afterDepositHookCalledCounter = 0; 10 | 11 | constructor( 12 | ERC20 _underlying, 13 | string memory _name, 14 | string memory _symbol 15 | ) ERC4626(_underlying, _name, _symbol) {} 16 | 17 | function totalAssets() public view override returns (uint256) { 18 | return asset.balanceOf(address(this)); 19 | } 20 | 21 | function beforeWithdraw(uint256, uint256) internal override { 22 | beforeWithdrawHookCalledCounter++; 23 | } 24 | 25 | function afterDeposit(uint256, uint256) internal override { 26 | afterDepositHookCalledCounter++; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {ERC721} from "../../../tokens/ERC721.sol"; 5 | 6 | contract MockERC721 is ERC721 { 7 | constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {} 8 | 9 | function tokenURI(uint256) public pure virtual override returns (string memory) {} 10 | 11 | function mint(address to, uint256 tokenId) public virtual { 12 | _mint(to, tokenId); 13 | } 14 | 15 | function burn(uint256 tokenId) public virtual { 16 | _burn(tokenId); 17 | } 18 | 19 | function safeMint(address to, uint256 tokenId) public virtual { 20 | _safeMint(to, tokenId); 21 | } 22 | 23 | function safeMint( 24 | address to, 25 | uint256 tokenId, 26 | bytes memory data 27 | ) public virtual { 28 | _safeMint(to, tokenId, data); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/test/utils/mocks/MockOwned.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | import {Owned} from "../../../auth/Owned.sol"; 5 | 6 | contract MockOwned is Owned(msg.sender) { 7 | bool public flag; 8 | 9 | function updateFlag() public virtual onlyOwner { 10 | flag = true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/utils/Bytes32AddressLib.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | /// @notice Library for converting between addresses and bytes32 values. 5 | /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Bytes32AddressLib.sol) 6 | library Bytes32AddressLib { 7 | function fromLast20Bytes(bytes32 bytesValue) internal pure returns (address) { 8 | return address(uint160(uint256(bytesValue))); 9 | } 10 | 11 | function fillLast12Bytes(address addressValue) internal pure returns (bytes32) { 12 | return bytes32(bytes20(addressValue)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/v4-core/lib/solmate/src/utils/ReentrancyGuard.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.8.0; 3 | 4 | /// @notice Gas optimized reentrancy protection for smart contracts. 5 | /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol) 6 | /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol) 7 | abstract contract ReentrancyGuard { 8 | uint256 private locked = 1; 9 | 10 | modifier nonReentrant() virtual { 11 | require(locked == 1, "REENTRANCY"); 12 | 13 | locked = 2; 14 | 15 | _; 16 | 17 | locked = 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/v4-core/remappings.txt: -------------------------------------------------------------------------------- 1 | ds-test/=lib/forge-std/lib/ds-test/src/ 2 | forge-std/=lib/forge-std/src/ 3 | forge-gas-snapshot/=lib/forge-gas-snapshot/src/ 4 | @openzeppelin/contracts/=node_modules/@openzeppelin/contracts 5 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/BitMath.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BitMath #leastSignificantBit gas cost of max uint128 1`] = `431`; 4 | 5 | exports[`BitMath #leastSignificantBit gas cost of max uint256 1`] = `431`; 6 | 7 | exports[`BitMath #leastSignificantBit gas cost of smaller number 1`] = `429`; 8 | 9 | exports[`BitMath #mostSignificantBit gas cost of max uint128 1`] = `368`; 10 | 11 | exports[`BitMath #mostSignificantBit gas cost of max uint256 1`] = `386`; 12 | 13 | exports[`BitMath #mostSignificantBit gas cost of smaller number 1`] = `296`; 14 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/Hooks.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Hooks #shouldCall gas cost of shouldCall 1`] = `7`; 4 | 5 | exports[`Hooks #validateHookAddress gas cost of validateHookAddress 1`] = `1443`; 6 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/NoDelegateCall.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`NoDelegateCall runtime overhead 1`] = `41`; 4 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/PoolManager.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`PoolManager bytecode size 1`] = `28950`; 4 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/SqrtPriceMath.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`SqrtPriceMath #getAmount0Delta gas cost for amount0 where roundUp = true 1`] = `603`; 4 | 5 | exports[`SqrtPriceMath #getAmount0Delta gas cost for amount0 where roundUp = true 2`] = `483`; 6 | 7 | exports[`SqrtPriceMath #getAmount1Delta gas cost for amount0 where roundUp = false 1`] = `483`; 8 | 9 | exports[`SqrtPriceMath #getAmount1Delta gas cost for amount0 where roundUp = true 1`] = `603`; 10 | 11 | exports[`SqrtPriceMath #getNextSqrtPriceFromInput zeroForOne = false gas 1`] = `567`; 12 | 13 | exports[`SqrtPriceMath #getNextSqrtPriceFromInput zeroForOne = true gas 1`] = `761`; 14 | 15 | exports[`SqrtPriceMath #getNextSqrtPriceFromOutput zeroForOne = false gas 1`] = `859`; 16 | 17 | exports[`SqrtPriceMath #getNextSqrtPriceFromOutput zeroForOne = true gas 1`] = `500`; 18 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/SwapMath.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`SwapMath #computeSwapStep gas swap one for zero exact in capped 1`] = `2221`; 4 | 5 | exports[`SwapMath #computeSwapStep gas swap one for zero exact in partial 1`] = `3049`; 6 | 7 | exports[`SwapMath #computeSwapStep gas swap one for zero exact out capped 1`] = `1968`; 8 | 9 | exports[`SwapMath #computeSwapStep gas swap one for zero exact out partial 1`] = `3049`; 10 | 11 | exports[`SwapMath #computeSwapStep gas swap zero for one exact in capped 1`] = `2210`; 12 | 13 | exports[`SwapMath #computeSwapStep gas swap zero for one exact in partial 1`] = `3208`; 14 | 15 | exports[`SwapMath #computeSwapStep gas swap zero for one exact out capped 1`] = `1957`; 16 | 17 | exports[`SwapMath #computeSwapStep gas swap zero for one exact out partial 1`] = `3208`; 18 | -------------------------------------------------------------------------------- /lib/v4-core/test/__snapshots__/Tick.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Tick #tickSpacingToMaxLiquidityPerTick gas cost 60 tick spacing 1`] = `128`; 4 | 5 | exports[`Tick #tickSpacingToMaxLiquidityPerTick gas cost max tick spacing 1`] = `128`; 6 | 7 | exports[`Tick #tickSpacingToMaxLiquidityPerTick gas cost min tick spacing 1`] = `128`; 8 | -------------------------------------------------------------------------------- /lib/v4-core/test/foundry-tests/utils/MockERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {ERC20} from "solmate/tokens/ERC20.sol"; 5 | 6 | contract MockERC20 is ERC20 { 7 | constructor(string memory name, string memory symbol, uint8 decimals) ERC20(name, symbol, decimals) {} 8 | 9 | function mint(address _to, uint256 _amount) public { 10 | _mint(_to, _amount); 11 | } 12 | 13 | function forceApprove(address _from, address _to, uint256 _amount) public returns (bool) { 14 | allowance[_from][_to] = _amount; 15 | 16 | emit Approval(_from, _to, _amount); 17 | 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/v4-core/test/shared/constants.ts: -------------------------------------------------------------------------------- 1 | export const MIN_TICK = -887272 2 | export const MAX_TICK = 887272 3 | export const MAX_TICK_SPACING = 32767 4 | export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' 5 | -------------------------------------------------------------------------------- /lib/v4-core/test/shared/expect.ts: -------------------------------------------------------------------------------- 1 | import { expect, use } from 'chai' 2 | import { solidity } from 'ethereum-waffle' 3 | import { jestSnapshotPlugin } from 'mocha-chai-jest-snapshot' 4 | 5 | use(solidity) 6 | use(jestSnapshotPlugin()) 7 | 8 | export { expect } 9 | -------------------------------------------------------------------------------- /lib/v4-core/test/shared/fixtures.ts: -------------------------------------------------------------------------------- 1 | import { BigNumber } from 'ethers' 2 | import { ethers } from 'hardhat' 3 | import { TestERC20 } from '../../typechain/TestERC20' 4 | 5 | interface TokensFixture { 6 | currency0: TestERC20 7 | currency1: TestERC20 8 | token2: TestERC20 9 | } 10 | 11 | export async function tokensFixture(): Promise { 12 | const tokenFactory = await ethers.getContractFactory('TestERC20') 13 | const tokenA = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 14 | const tokenB = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 15 | const tokenC = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 16 | 17 | const [currency0, currency1, token2] = [tokenA, tokenB, tokenC].sort((tokenA, tokenB) => 18 | tokenA.address.toLowerCase() < tokenB.address.toLowerCase() ? -1 : 1 19 | ) 20 | 21 | return { currency0, currency1, token2 } 22 | } 23 | -------------------------------------------------------------------------------- /lib/v4-core/test/shared/format.ts: -------------------------------------------------------------------------------- 1 | import { Decimal } from 'decimal.js' 2 | import { BigNumberish } from 'ethers' 3 | 4 | export function formatTokenAmount(num: BigNumberish): string { 5 | return new Decimal(num.toString()).dividedBy(new Decimal(10).pow(18)).toPrecision(5) 6 | } 7 | 8 | export function formatPrice(price: BigNumberish): string { 9 | return new Decimal(price.toString()).dividedBy(new Decimal(2).pow(96)).pow(2).toPrecision(5) 10 | } 11 | -------------------------------------------------------------------------------- /lib/v4-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2018", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "outDir": "dist", 8 | "typeRoots": ["./typechain", "./node_modules/@types"], 9 | "types": ["@nomiclabs/hardhat-ethers", "@nomiclabs/hardhat-waffle"] 10 | }, 11 | "include": ["./test"], 12 | "files": ["./hardhat.config.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /lib/v4-core/whitepaper-v4-draft.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesbachini/Uniswap-v4-Tests/87f3a5704889a8455cd9b578ee2de924a59d1901/lib/v4-core/whitepaper-v4-draft.pdf -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserve0After5Seconds.snap: -------------------------------------------------------------------------------- 1 | 2000 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserve200By13.snap: -------------------------------------------------------------------------------- 1 | 21068 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserve200By13Plus5.snap: -------------------------------------------------------------------------------- 1 | 21318 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserve5After5Seconds.snap: -------------------------------------------------------------------------------- 1 | 2076 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserveOldest.snap: -------------------------------------------------------------------------------- 1 | 20164 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserveOldestAfter5Seconds.snap: -------------------------------------------------------------------------------- 1 | 20458 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/FullOracleObserveZero.snap: -------------------------------------------------------------------------------- 1 | 1525 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleGrow10Slots.snap: -------------------------------------------------------------------------------- 1 | 233028 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap: -------------------------------------------------------------------------------- 1 | 223717 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleGrow1Slot.snap: -------------------------------------------------------------------------------- 1 | 32886 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap: -------------------------------------------------------------------------------- 1 | 23586 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleInitialize.snap: -------------------------------------------------------------------------------- 1 | 51411 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveBetweenOldestAndOldestPlusOne.snap: -------------------------------------------------------------------------------- 1 | 5571 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveCurrentTime.snap: -------------------------------------------------------------------------------- 1 | 1525 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveCurrentTimeCounterfactual.snap: -------------------------------------------------------------------------------- 1 | 1525 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveLast20Seconds.snap: -------------------------------------------------------------------------------- 1 | 75965 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveLatestEqual.snap: -------------------------------------------------------------------------------- 1 | 1525 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveLatestTransform.snap: -------------------------------------------------------------------------------- 1 | 2000 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveMiddle.snap: -------------------------------------------------------------------------------- 1 | 5746 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveOldest.snap: -------------------------------------------------------------------------------- 1 | 5277 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/OracleObserveSinceMostRecent.snap: -------------------------------------------------------------------------------- 1 | 2615 -------------------------------------------------------------------------------- /lib/v4-periphery/.forge-snapshots/TWAMMSubmitOrder.snap: -------------------------------------------------------------------------------- 1 | 123624 -------------------------------------------------------------------------------- /lib/v4-periphery/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Related Issue 2 | Which issue does this pull request resolve? 3 | 4 | ## Description of changes -------------------------------------------------------------------------------- /lib/v4-periphery/.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | run-linters: 11 | name: Forge Linting 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | token: ${{ secrets.CORE_NEXT_GITHUB_TOKEN }} 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run tests 26 | run: forge fmt --check 27 | -------------------------------------------------------------------------------- /lib/v4-periphery/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | run-tests: 11 | name: Forge Tests 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | token: ${{ secrets.CORE_NEXT_GITHUB_TOKEN }} 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run tests 26 | run: forge test -vvv 27 | env: 28 | FOUNDRY_PROFILE: ci 29 | -------------------------------------------------------------------------------- /lib/v4-periphery/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | foundry-out/ -------------------------------------------------------------------------------- /lib/v4-periphery/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "lib/openzeppelin-contracts"] 5 | path = lib/openzeppelin-contracts 6 | url = https://github.com/OpenZeppelin/openzeppelin-contracts 7 | [submodule "lib/forge-gas-snapshot"] 8 | path = lib/forge-gas-snapshot 9 | url = https://github.com/marktoda/forge-gas-snapshot 10 | [submodule "lib/v4-core"] 11 | path = lib/v4-core 12 | url = git@github.com:Uniswap/v4-core.git 13 | -------------------------------------------------------------------------------- /lib/v4-periphery/.nvmrc: -------------------------------------------------------------------------------- 1 | v16 -------------------------------------------------------------------------------- /lib/v4-periphery/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'contracts' 3 | out = 'foundry-out' 4 | solc_version = '0.8.19' 5 | optimizer_runs = 800 6 | ffi = true 7 | fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] 8 | 9 | [profile.ci] 10 | fuzz_runs = 100000 11 | 12 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config 13 | -------------------------------------------------------------------------------- /lib/v4-periphery/remappings.txt: -------------------------------------------------------------------------------- 1 | @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ 2 | @uniswap/v4-core/=lib/v4-core/ 3 | forge-std/=lib/forge-std/src/ 4 | -------------------------------------------------------------------------------- /lib/v4-periphery/test/shared/GetSender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | contract GetSender { 5 | function sender() external view returns (address) { 6 | return msg.sender; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lib/v4-periphery/test/shared/implementation/GeomeanOracleImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {BaseHook} from "../../../contracts/BaseHook.sol"; 5 | import {GeomeanOracle} from "../../../contracts/hooks/examples/GeomeanOracle.sol"; 6 | import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; 7 | import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol"; 8 | 9 | contract GeomeanOracleImplementation is GeomeanOracle { 10 | uint32 public time; 11 | 12 | constructor(IPoolManager _poolManager, GeomeanOracle addressToEtch) GeomeanOracle(_poolManager) { 13 | Hooks.validateHookAddress(addressToEtch, getHooksCalls()); 14 | } 15 | 16 | // make this a no-op in testing 17 | function validateHookAddress(BaseHook _this) internal pure override {} 18 | 19 | function setTime(uint32 _time) external { 20 | time = _time; 21 | } 22 | 23 | function _blockTimestamp() internal view override returns (uint32) { 24 | return time; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/v4-periphery/test/shared/implementation/LimitOrderImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {BaseHook} from "../../../contracts/BaseHook.sol"; 5 | import {LimitOrder} from "../../../contracts/hooks/examples/LimitOrder.sol"; 6 | import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; 7 | import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol"; 8 | 9 | contract LimitOrderImplementation is LimitOrder { 10 | constructor(IPoolManager _poolManager, LimitOrder addressToEtch) LimitOrder(_poolManager) { 11 | Hooks.validateHookAddress(addressToEtch, getHooksCalls()); 12 | } 13 | 14 | // make this a no-op in testing 15 | function validateHookAddress(BaseHook _this) internal pure override {} 16 | } 17 | -------------------------------------------------------------------------------- /lib/v4-periphery/test/shared/implementation/TWAMMImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {BaseHook} from "../../../contracts/BaseHook.sol"; 5 | import {TWAMM} from "../../../contracts/hooks/examples/TWAMM.sol"; 6 | import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; 7 | import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol"; 8 | 9 | contract TWAMMImplementation is TWAMM { 10 | constructor(IPoolManager poolManager, uint256 interval, TWAMM addressToEtch) TWAMM(poolManager, interval) { 11 | Hooks.validateHookAddress(addressToEtch, getHooksCalls()); 12 | } 13 | 14 | // make this a no-op in testing 15 | function validateHookAddress(BaseHook _this) internal pure override {} 16 | } 17 | -------------------------------------------------------------------------------- /remappings.txt: -------------------------------------------------------------------------------- 1 | @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ 2 | @uniswap/v4-core/=lib/v4-core/ 3 | ds-test/=lib/forge-std/lib/ds-test/src/ 4 | forge-gas-snapshot/=lib/forge-gas-snapshot/src/ 5 | forge-std/=lib/forge-std/src/ 6 | openzeppelin-contracts/=lib/openzeppelin-contracts/ 7 | solmate/=lib/v4-core/lib/solmate/src/ 8 | v4-core/=lib/v4-core/contracts/ 9 | v4-periphery/=lib/v4-periphery/contracts/ 10 | -------------------------------------------------------------------------------- /script/Counter.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.15; 3 | 4 | import "forge-std/Script.sol"; 5 | 6 | contract CounterScript is Script { 7 | function setUp() public {} 8 | 9 | function run() public { 10 | vm.broadcast(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/implementation/TestImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.19; 3 | 4 | import {TestHook} from "../TestHook.sol"; 5 | 6 | import {BaseHook} from "v4-periphery/BaseHook.sol"; 7 | import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; 8 | import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol"; 9 | 10 | contract TestImplementation is TestHook { 11 | constructor(IPoolManager poolManager, TestHook addressToEtch) TestHook(poolManager) { 12 | Hooks.validateHookAddress(addressToEtch, getHooksCalls()); 13 | } 14 | 15 | // make this a no-op in testing 16 | function validateHookAddress(BaseHook _this) internal pure override {} 17 | } 18 | --------------------------------------------------------------------------------