@diwantanushh/rapiddex-contracts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/openzeppelin-contracts/contracts/drafts/IERC20Permit.sol +14 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol +14 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol +227 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol +20 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Enumerable.sol +10 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Metadata.sol +10 -0
- package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol +8 -0
- package/lib/openzeppelin-contracts/contracts/utils/Address.sol +12 -0
- package/lib/openzeppelin-contracts/contracts/utils/Context.sol +8 -0
- package/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol +10 -0
- package/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol +6 -0
- package/lib/openzeppelin-contracts-master/.changeset/better-tires-pull.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/blue-jars-lay.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/bright-cooks-brush.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/chatty-dryers-joke.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/config.json +12 -0
- package/lib/openzeppelin-contracts-master/.changeset/cool-clocks-tick.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/curly-pandas-flow.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/flat-flies-hear.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/floppy-symbols-burn.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/fruity-coats-smash.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/gentle-apples-dance.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/happy-pants-decide.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/heavy-pots-reply.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/legal-cameras-sin.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/rare-bushes-march.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/red-gifts-appear.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/silver-falcons-lay.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/smooth-cows-notice.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/some-dolls-shine.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/spicy-seals-bake.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/sweet-houses-cheer.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/swift-trees-build.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/tame-rules-run.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/tangy-jokes-begin.md +5 -0
- package/lib/openzeppelin-contracts-master/.changeset/tidy-turkeys-build.md +5 -0
- package/lib/openzeppelin-contracts-master/.codecov.yml +16 -0
- package/lib/openzeppelin-contracts-master/.editorconfig +21 -0
- package/lib/openzeppelin-contracts-master/.gitattributes +3 -0
- package/lib/openzeppelin-contracts-master/.github/CODEOWNERS +10 -0
- package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
- package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/config.yml +4 -0
- package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
- package/lib/openzeppelin-contracts-master/.github/PULL_REQUEST_TEMPLATE.md +20 -0
- package/lib/openzeppelin-contracts-master/.github/actions/gas-compare/action.yml +51 -0
- package/lib/openzeppelin-contracts-master/.github/actions/setup/action.yml +108 -0
- package/lib/openzeppelin-contracts-master/.github/actions/storage-layout/action.yml +57 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/actionlint.yml +18 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/changeset.yml +28 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/checks.yml +132 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/docs.yml +19 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/formal-verification.yml +63 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/release-cycle.yml +212 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/release-upgradeable.yml +97 -0
- package/lib/openzeppelin-contracts-master/.github/workflows/upgradeable.yml +35 -0
- package/lib/openzeppelin-contracts-master/.gitmodules +10 -0
- package/lib/openzeppelin-contracts-master/.husky/pre-commit +2 -0
- package/lib/openzeppelin-contracts-master/.mocharc.js +4 -0
- package/lib/openzeppelin-contracts-master/.prettierrc +15 -0
- package/lib/openzeppelin-contracts-master/.solcover.js +21 -0
- package/lib/openzeppelin-contracts-master/CHANGELOG.md +1424 -0
- package/lib/openzeppelin-contracts-master/CODE_OF_CONDUCT.md +73 -0
- package/lib/openzeppelin-contracts-master/CONTRIBUTING.md +36 -0
- package/lib/openzeppelin-contracts-master/FUNDING.json +10 -0
- package/lib/openzeppelin-contracts-master/GUIDELINES.md +170 -0
- package/lib/openzeppelin-contracts-master/LICENSE +22 -0
- package/lib/openzeppelin-contracts-master/README.md +122 -0
- package/lib/openzeppelin-contracts-master/RELEASING.md +45 -0
- package/lib/openzeppelin-contracts-master/SECURITY.md +43 -0
- package/lib/openzeppelin-contracts-master/audits/2017-03.md +292 -0
- package/lib/openzeppelin-contracts-master/audits/2018-10.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2022-10-Checkpoints.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2022-10-ERC4626.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2023-05-v4.9.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2023-10-v5.0.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2024-10-v5.1.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2024-12-v5.2.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2025-04-v5.3.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2025-07-v5.4.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2025-10-v5.5.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2025-11-RLP.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/2026-02-v5.6.pdf +0 -0
- package/lib/openzeppelin-contracts-master/audits/README.md +24 -0
- package/lib/openzeppelin-contracts-master/contracts/access/AccessControl.sol +207 -0
- package/lib/openzeppelin-contracts-master/contracts/access/IAccessControl.sol +98 -0
- package/lib/openzeppelin-contracts-master/contracts/access/Ownable.sol +100 -0
- package/lib/openzeppelin-contracts-master/contracts/access/Ownable2Step.sol +67 -0
- package/lib/openzeppelin-contracts-master/contracts/access/README.adoc +45 -0
- package/lib/openzeppelin-contracts-master/contracts/access/extensions/AccessControlDefaultAdminRules.sol +372 -0
- package/lib/openzeppelin-contracts-master/contracts/access/extensions/AccessControlEnumerable.sol +81 -0
- package/lib/openzeppelin-contracts-master/contracts/access/extensions/IAccessControlDefaultAdminRules.sol +192 -0
- package/lib/openzeppelin-contracts-master/contracts/access/extensions/IAccessControlEnumerable.sol +31 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/AccessManaged.sol +112 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/AccessManager.sol +751 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/AuthorityUtils.sol +36 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/IAccessManaged.sol +32 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/IAccessManager.sol +404 -0
- package/lib/openzeppelin-contracts-master/contracts/access/manager/IAuthority.sol +14 -0
- package/lib/openzeppelin-contracts-master/contracts/account/Account.sol +151 -0
- package/lib/openzeppelin-contracts-master/contracts/account/README.adoc +30 -0
- package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-AccountERC7579.sol +420 -0
- package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-AccountERC7579Hooked.sol +171 -0
- package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-ERC7821.sol +70 -0
- package/lib/openzeppelin-contracts-master/contracts/account/utils/EIP7702Utils.sol +21 -0
- package/lib/openzeppelin-contracts-master/contracts/account/utils/draft-ERC4337Utils.sol +279 -0
- package/lib/openzeppelin-contracts-master/contracts/account/utils/draft-ERC7579Utils.sol +280 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/CrosschainLinked.sol +109 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/CrosschainRemoteExecutor.sol +98 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/ERC7786Recipient.sol +66 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/README.adoc +44 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC1155.sol +101 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC20.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC721.sol +61 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC7802.sol +34 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeFungible.sol +83 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeMultiToken.sol +92 -0
- package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeNonFungible.sol +75 -0
- package/lib/openzeppelin-contracts-master/contracts/finance/README.adoc +14 -0
- package/lib/openzeppelin-contracts-master/contracts/finance/VestingWallet.sol +160 -0
- package/lib/openzeppelin-contracts-master/contracts/finance/VestingWalletCliff.sol +54 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/Governor.sol +820 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/IGovernor.sol +449 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/README.adoc +201 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/TimelockController.sol +470 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingFractional.sol +190 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingOverridable.sol +222 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingSimple.sol +96 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCrosschain.sol +30 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorNoncesKeyed.sol +91 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorPreventLateQuorum.sol +92 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorProposalGuardian.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSequentialProposalId.sol +75 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSettings.sol +106 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorStorage.sol +134 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSuperQuorum.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockAccess.sol +346 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockCompound.sol +162 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockControl.sol +167 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotes.sol +64 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotesQuorumFraction.sol +113 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotesSuperQuorumFraction.sol +135 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/utils/IVotes.sol +60 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/utils/Votes.sol +245 -0
- package/lib/openzeppelin-contracts-master/contracts/governance/utils/VotesExtended.sol +85 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155MetadataURI.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155Receiver.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1271.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363.sol +86 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363Receiver.sol +32 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363Spender.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC165.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1820Implementer.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1820Registry.sol +112 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1967.sol +24 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC20.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC20Metadata.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2309.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2612.sol +8 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2981.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156.sol +7 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156FlashBorrower.sol +27 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156FlashLender.sol +41 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC4626.sol +230 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC4906.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5267.sol +28 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5313.sol +16 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5805.sol +9 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC6372.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC6909.sol +125 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Enumerable.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Metadata.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Receiver.sol +6 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC7751.sol +12 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777.sol +200 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777Recipient.sol +35 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777Sender.sol +35 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC7913.sol +18 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/README.adoc +138 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC1822.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC4337.sol +255 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC6093.sol +162 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7579.sol +227 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7674.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7786.sol +64 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7802.sol +32 -0
- package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7821.sol +44 -0
- package/lib/openzeppelin-contracts-master/contracts/metatx/ERC2771Context.sol +90 -0
- package/lib/openzeppelin-contracts-master/contracts/metatx/ERC2771Forwarder.sol +379 -0
- package/lib/openzeppelin-contracts-master/contracts/metatx/README.adoc +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/AccessManagedTarget.sol +34 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/AccessManagerMock.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ArraysMock.sol +171 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/AuthorityMock.sol +69 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/Base64Dirty.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/BatchCaller.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/CallReceiverMock.sol +107 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ConstructorMock.sol +34 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ContextMock.sol +35 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/DummyImplementation.sol +61 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/EIP712Verifier.sol +16 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ERC1271WalletMock.sol +24 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ERC165Mock.sol +100 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ERC2771ContextMock.sol +28 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ERC3156FlashBorrowerMock.sol +53 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/EtherReceiverMock.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/InitializableMock.sol +130 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/MerkleProofCustomHashMock.sol +62 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/MerkleTreeMock.sol +52 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/MulticallHelper.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/MultipleInheritanceInitializableMocks.sol +131 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/PausableMock.sol +31 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyAttack.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyMock.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyTransientMock.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/RegressionImplementation.sol +61 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/SingleInheritanceInitializableMocks.sol +49 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/Stateless.sol +64 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/StorageSlotMock.sol +87 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/TimelockReentrant.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/TransientSlotMock.sol +61 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/UpgradeableBeaconMock.sol +27 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/VotesExtendedMock.sol +44 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/VotesMock.sol +44 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/account/AccountMock.sol +181 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/account/modules/ERC7579Mock.sol +141 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/account/utils/ERC7579UtilsMock.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/compound/CompTimelock.sol +174 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/crosschain/ERC7786GatewayMock.sol +56 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/crosschain/ERC7786RecipientMock.sol +31 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/AccessManagerEnumerable.sol +161 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/ERC20WithAutoMinerReward.sol +22 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/ERC4626Fees.sol +109 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/MyNFT.sol +9 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintBase.sol +25 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintMissing.sol +24 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRole.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlModified.sol +14 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessManagedERC20MintBase.sol +16 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/MyContractOwnable.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/account/MyAccountEIP7702.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/account/MyFactoryAccount.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyGovernor.sol +80 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyToken.sol +21 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyTokenTimestampBased.sol +32 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyTokenWrapped.sol +28 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC1155/GameItems.sol +21 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC1155/MyERC115HolderContract.sol +7 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC20/GLDToken.sol +11 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC6909/ERC6909GameItems.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC721/GameItem.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/utilities/Base64NFT.sol +27 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/docs/utilities/Multicall.sol +15 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorCountingOverridableMock.sol +18 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorCrosschain.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorFractionalMock.sol +14 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorMock.sol +14 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorNoncesKeyedMock.sol +44 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorPreventLateQuorumMock.sol +40 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorProposalGuardianMock.sol +27 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorSequentialProposalIdMock.sol +39 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorStorageMock.sol +79 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorSuperQuorumMock.sol +95 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockAccessMock.sol +70 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockCompoundMock.sol +69 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockControlMock.sol +69 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorVoteMock.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorVotesSuperQuorumFractionMock.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorWithParamsMock.sol +51 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/BadBeacon.sol +11 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/ClashingImplementation.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/ERC1967ProxyUnsafe.sol +13 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/UUPSUpgradeableMock.sol +35 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1155ReceiverMock.sol +74 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ForceApproveMock.sol +13 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363NoReturnMock.sol +33 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ReceiverMock.sol +52 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ReturnFalseMock.sol +34 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363SpenderMock.sol +47 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ApprovalMock.sol +10 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20BridgeableMock.sol +30 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20DecimalsMock.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ExcessDecimalsMock.sol +9 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20FlashMintMock.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ForceApproveMock.sol +13 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20GetterHelper.sol +38 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20Mock.sol +16 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20MulticallMock.sol +8 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20NoReturnMock.sol +30 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20Reentrant.sol +39 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ReturnFalseMock.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesAdditionalCheckpointsMock.sol +33 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesLegacyMock.sol +253 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesTimestampMock.sol +31 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626LimitsMock.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626Mock.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626OffsetMock.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4646FeesMock.sol +40 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ConsecutiveEnumerableMock.sol +42 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ConsecutiveMock.sol +61 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ReceiverMock.sol +47 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721URIStorageMock.sol +17 -0
- package/lib/openzeppelin-contracts-master/contracts/mocks/utils/cryptography/ERC7739Mock.sol +12 -0
- package/lib/openzeppelin-contracts-master/contracts/package.json +32 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/Clones.sol +294 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/ERC1967/ERC1967Proxy.sol +62 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/ERC1967/ERC1967Utils.sol +177 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/Proxy.sol +69 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/README.adoc +87 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/BeaconProxy.sol +57 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/IBeacon.sol +16 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/UpgradeableBeacon.sol +70 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/transparent/ProxyAdmin.sol +45 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +118 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/utils/Initializable.sol +238 -0
- package/lib/openzeppelin-contracts-master/contracts/proxy/utils/UUPSUpgradeable.sol +148 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/ERC1155.sol +417 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/IERC1155.sol +123 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/IERC1155Receiver.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/README.adoc +46 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +22 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Crosschain.sol +53 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +38 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Supply.sol +88 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +58 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol +20 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/utils/ERC1155Holder.sol +42 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/utils/ERC1155Utils.sol +88 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/ERC20.sol +305 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/IERC20.sol +79 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/README.adoc +81 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC1363.sol +135 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Burnable.sol +39 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Capped.sol +54 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Crosschain.sol +39 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20FlashMint.sol +130 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Pausable.sol +33 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Permit.sol +77 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Votes.sol +83 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Wrapper.sol +93 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC4626.sol +298 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/IERC20Metadata.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/IERC20Permit.sol +90 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol +51 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol +119 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/utils/ERC1363Utils.sol +95 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC20/utils/SafeERC20.sol +292 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/ERC6909.sol +224 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/README.adoc +27 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909ContentURI.sol +59 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909Metadata.sol +83 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909TokenSupply.sol +41 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/ERC721.sol +433 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/IERC721.sol +135 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/IERC721Receiver.sol +28 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/README.adoc +72 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Burnable.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Consecutive.sol +176 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Crosschain.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Enumerable.sol +165 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Pausable.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Royalty.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721URIStorage.sol +62 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Votes.sol +47 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Wrapper.sol +102 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/IERC721Enumerable.sol +29 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/IERC721Metadata.sol +27 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/utils/ERC721Holder.sol +26 -0
- package/lib/openzeppelin-contracts-master/contracts/token/ERC721/utils/ERC721Utils.sol +50 -0
- package/lib/openzeppelin-contracts-master/contracts/token/common/ERC2981.sol +139 -0
- package/lib/openzeppelin-contracts-master/contracts/token/common/README.adoc +10 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Address.sol +167 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Arrays.sol +888 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Base58.sol +240 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Base64.sol +234 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Blockhash.sol +54 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Bytes.sol +329 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/CAIP10.sol +54 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/CAIP2.sol +51 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Calldata.sol +25 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Comparators.sol +19 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Context.sol +28 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Create2.sol +91 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Create3.sol +134 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/ERC6372Utils.sol +52 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Errors.sol +34 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/LowLevelCall.sol +127 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Memory.sol +149 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Multicall.sol +37 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Nonces.sol +46 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/NoncesKeyed.sol +74 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Packing.sol +1656 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Panic.sol +57 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Pausable.sol +112 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/README.adoc +169 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/RLP.sol +487 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/ReentrancyGuard.sol +119 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/ReentrancyGuardTransient.sol +84 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/RelayedCall.sol +145 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/ShortStrings.sol +122 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/SimulateCall.sol +113 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/SlotDerivation.sol +155 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/StorageSlot.sol +143 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/Strings.sol +532 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/TransientSlot.sol +183 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/ECDSA.sol +284 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/EIP712.sol +160 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/Hashes.sol +31 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/MerkleProof.sol +510 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/MessageHashUtils.sol +228 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/P256.sol +408 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/README.adoc +76 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/RSA.sol +154 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/SignatureChecker.sol +191 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/TrieProof.sol +256 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/WebAuthn.sol +269 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/draft-ERC7739Utils.sol +207 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/AbstractSigner.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/MultiSignerERC7913.sol +259 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/MultiSignerERC7913Weighted.sol +208 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerECDSA.sol +56 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerEIP7702.sol +25 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerERC7913.sol +63 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerP256.sol +64 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerRSA.sol +65 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerWebAuthn.sol +46 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/draft-ERC7739.sol +98 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913P256Verifier.sol +29 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913RSAVerifier.sol +23 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913WebAuthnVerifier.sol +35 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/draft-InteroperableAddress.sol +245 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/introspection/ERC165.sol +25 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/introspection/ERC165Checker.sol +142 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/introspection/IERC165.sol +25 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/math/Math.sol +763 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/math/SafeCast.sol +1162 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/math/SignedMath.sol +68 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/Accumulators.sol +135 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/BitMaps.sol +60 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/Checkpoints.sol +833 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/CircularBuffer.sol +152 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/DoubleEndedQueue.sol +238 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/EnumerableMap.sol +1443 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/EnumerableSet.sol +895 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/Heap.sol +259 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/structs/MerkleTree.sol +267 -0
- package/lib/openzeppelin-contracts-master/contracts/utils/types/Time.sol +133 -0
- package/lib/openzeppelin-contracts-master/contracts/vendor/compound/ICompoundTimelock.sol +86 -0
- package/lib/openzeppelin-contracts-master/contracts/vendor/compound/LICENSE +11 -0
- package/lib/openzeppelin-contracts-master/docs/README.md +16 -0
- package/lib/openzeppelin-contracts-master/docs/antora.yml +7 -0
- package/lib/openzeppelin-contracts-master/docs/config.js +21 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-control-multiple.svg +97 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-manager-functions.svg +47 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-manager.svg +99 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-3a.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-3b.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-6.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-deposit.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-mint.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-linear.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-loglog.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-loglogext.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/tally-exec.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/tally-vote.png +0 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/nav.adoc +29 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/access-control.adoc +339 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/account-abstraction.adoc +100 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/accounts.adoc +354 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/backwards-compatibility.adoc +50 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/eoa-delegation.adoc +143 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc1155.adoc +118 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc20-supply.adoc +71 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc20.adoc +67 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc4626.adoc +208 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc6909.adoc +47 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc721.adoc +58 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/extending-contracts.adoc +67 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/faq.adoc +13 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/governance.adoc +242 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/index.adoc +100 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/multisig.adoc +308 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/tokens.adoc +31 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/upgradeable.adoc +75 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/utilities.adoc +634 -0
- package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/wizard.adoc +15 -0
- package/lib/openzeppelin-contracts-master/docs/templates/contract.hbs +141 -0
- package/lib/openzeppelin-contracts-master/docs/templates/helpers.js +46 -0
- package/lib/openzeppelin-contracts-master/docs/templates/page.hbs +4 -0
- package/lib/openzeppelin-contracts-master/docs/templates/properties.js +88 -0
- package/lib/openzeppelin-contracts-master/eslint.config.mjs +29 -0
- package/lib/openzeppelin-contracts-master/foundry.toml +20 -0
- package/lib/openzeppelin-contracts-master/fv/Makefile +54 -0
- package/lib/openzeppelin-contracts-master/fv/README.md +60 -0
- package/lib/openzeppelin-contracts-master/fv/diff/access_manager_AccessManager.sol.patch +97 -0
- package/lib/openzeppelin-contracts-master/fv/diff/account_extensions_draft-AccountERC7579.sol.patch +25 -0
- package/lib/openzeppelin-contracts-master/fv/diff/token_ERC721_ERC721.sol.patch +11 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/AccessControlDefaultAdminRulesHarness.sol +46 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/AccessControlHarness.sol +6 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/AccessManagedHarness.sol +36 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/AccessManagerHarness.sol +116 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/AccountHarness.sol +60 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/DoubleEndedQueueHarness.sol +58 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20FlashMintHarness.sol +36 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20PermitHarness.sol +16 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20WrapperHarness.sol +22 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC3156FlashBorrowerHarness.sol +13 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC721Harness.sol +37 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/ERC721ReceiverHarness.sol +11 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/EnumerableMapHarness.sol +55 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/EnumerableSetHarness.sol +35 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/InitializableHarness.sol +23 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/NoncesHarness.sol +14 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/Ownable2StepHarness.sol +10 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/OwnableHarness.sol +10 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/PausableHarness.sol +18 -0
- package/lib/openzeppelin-contracts-master/fv/harnesses/TimelockControllerHarness.sol +13 -0
- package/lib/openzeppelin-contracts-master/fv/reports/2021-10.pdf +0 -0
- package/lib/openzeppelin-contracts-master/fv/reports/2022-03.pdf +0 -0
- package/lib/openzeppelin-contracts-master/fv/reports/2022-05.pdf +0 -0
- package/lib/openzeppelin-contracts-master/fv/run.js +68 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessControl.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessControl.spec +119 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessControlDefaultAdminRules.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessControlDefaultAdminRules.spec +467 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessManaged.conf +14 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessManaged.spec +49 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessManager.conf +10 -0
- package/lib/openzeppelin-contracts-master/fv/specs/AccessManager.spec +837 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Account.conf +9 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Account.spec +490 -0
- package/lib/openzeppelin-contracts-master/fv/specs/DoubleEndedQueue.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/DoubleEndedQueue.spec +300 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20.conf +9 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20.spec +352 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20FlashMint.conf +10 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20FlashMint.spec +55 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20Wrapper.conf +13 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC20Wrapper.spec +226 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC721.conf +10 -0
- package/lib/openzeppelin-contracts-master/fv/specs/ERC721.spec +695 -0
- package/lib/openzeppelin-contracts-master/fv/specs/EnumerableMap.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/EnumerableMap.spec +364 -0
- package/lib/openzeppelin-contracts-master/fv/specs/EnumerableSet.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/EnumerableSet.spec +272 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Initializable.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Initializable.spec +176 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Nonces.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Nonces.spec +92 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Ownable.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Ownable.spec +77 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Ownable2Step.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Ownable2Step.spec +108 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Pausable.conf +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/Pausable.spec +96 -0
- package/lib/openzeppelin-contracts-master/fv/specs/TimelockController.conf +10 -0
- package/lib/openzeppelin-contracts-master/fv/specs/TimelockController.spec +299 -0
- package/lib/openzeppelin-contracts-master/fv/specs/helpers/helpers.spec +13 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessControl.spec +8 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessControlDefaultAdminRules.spec +36 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessManaged.spec +5 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessManager.spec +33 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccount.spec +34 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC20.spec +11 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC2612.spec +5 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC3156FlashBorrower.spec +3 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC3156FlashLender.spec +5 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC5313.spec +3 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC721.spec +17 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC721Receiver.spec +3 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IOwnable.spec +5 -0
- package/lib/openzeppelin-contracts-master/fv/specs/methods/IOwnable2Step.spec +7 -0
- package/lib/openzeppelin-contracts-master/fv-requirements.txt +4 -0
- package/lib/openzeppelin-contracts-master/hardhat/async-test-sanity.js +10 -0
- package/lib/openzeppelin-contracts-master/hardhat/env-artifacts.js +29 -0
- package/lib/openzeppelin-contracts-master/hardhat/ignore-unreachable-warnings.js +45 -0
- package/lib/openzeppelin-contracts-master/hardhat/remappings.js +18 -0
- package/lib/openzeppelin-contracts-master/hardhat/skip-foundry-tests.js +6 -0
- package/lib/openzeppelin-contracts-master/hardhat/task-test-get-files.js +25 -0
- package/lib/openzeppelin-contracts-master/hardhat.config.js +124 -0
- package/lib/openzeppelin-contracts-master/logo.svg +15 -0
- package/lib/openzeppelin-contracts-master/netlify.toml +3 -0
- package/lib/openzeppelin-contracts-master/package-lock.json +11197 -0
- package/lib/openzeppelin-contracts-master/package.json +109 -0
- package/lib/openzeppelin-contracts-master/remappings.txt +1 -0
- package/lib/openzeppelin-contracts-master/renovate.json +4 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/compare-layout.js +28 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/compareGasReports.js +249 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/coverage.sh +24 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/extract-layout.js +39 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/generation.sh +6 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/inheritance-ordering.js +56 -0
- package/lib/openzeppelin-contracts-master/scripts/checks/pragma-validity.js +45 -0
- package/lib/openzeppelin-contracts-master/scripts/fetch-common-contracts.js +50 -0
- package/lib/openzeppelin-contracts-master/scripts/gen-nav.js +81 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/format-lines.js +16 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/helpers/sanitize.js +5 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/run.js +61 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Arrays.js +505 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Arrays.opts.js +9 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.js +242 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.opts.js +18 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.t.js +141 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Enumerable.opts.js +56 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/EnumerableMap.js +464 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/EnumerableSet.js +470 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/MerkleProof.js +186 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/MerkleProof.opts.js +11 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.js +92 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.opts.js +3 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.t.js +48 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/SafeCast.js +136 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/Slot.opts.js +15 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/SlotDerivation.js +119 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/SlotDerivation.t.js +127 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/StorageSlot.js +77 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/StorageSlotMock.js +57 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/TransientSlot.js +80 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/TransientSlotMock.js +35 -0
- package/lib/openzeppelin-contracts-master/scripts/generate/templates/conversion.js +34 -0
- package/lib/openzeppelin-contracts-master/scripts/get-contracts-metadata.js +55 -0
- package/lib/openzeppelin-contracts-master/scripts/git-user-config.sh +6 -0
- package/lib/openzeppelin-contracts-master/scripts/helpers.js +7 -0
- package/lib/openzeppelin-contracts-master/scripts/minimize-pragma.js +140 -0
- package/lib/openzeppelin-contracts-master/scripts/prepack.sh +23 -0
- package/lib/openzeppelin-contracts-master/scripts/prepare-docs.sh +26 -0
- package/lib/openzeppelin-contracts-master/scripts/release/format-changelog.js +33 -0
- package/lib/openzeppelin-contracts-master/scripts/release/synchronize-versions.js +15 -0
- package/lib/openzeppelin-contracts-master/scripts/release/update-comment.js +34 -0
- package/lib/openzeppelin-contracts-master/scripts/release/version.sh +11 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/check-upgradeable.sh +27 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/exit-prerelease.sh +8 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/github-release.js +48 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/integrity-check.sh +20 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/pack.sh +26 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/publish.sh +26 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/rerun.js +7 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/set-changesets-pr-title.js +17 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/start.sh +35 -0
- package/lib/openzeppelin-contracts-master/scripts/release/workflow/state.js +112 -0
- package/lib/openzeppelin-contracts-master/scripts/remove-ignored-artifacts.js +45 -0
- package/lib/openzeppelin-contracts-master/scripts/set-max-old-space-size.sh +10 -0
- package/lib/openzeppelin-contracts-master/scripts/solc-versions.js +15 -0
- package/lib/openzeppelin-contracts-master/scripts/solhint-custom/index.js +118 -0
- package/lib/openzeppelin-contracts-master/scripts/solhint-custom/package.json +8 -0
- package/lib/openzeppelin-contracts-master/scripts/update-docs-branch.js +65 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/README.md +21 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/alias/Initializable.sol +5 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/alias/UUPSUpgradeable.sol +5 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/patch-apply.sh +19 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/patch-save.sh +18 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/transpile-onto.sh +54 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/transpile.sh +50 -0
- package/lib/openzeppelin-contracts-master/scripts/upgradeable/upgradeable.patch +390 -0
- package/lib/openzeppelin-contracts-master/slither.config.json +4 -0
- package/lib/openzeppelin-contracts-master/solhint.config.js +29 -0
- package/lib/openzeppelin-contracts-master/test/TESTING.md +3 -0
- package/lib/openzeppelin-contracts-master/test/access/AccessControl.behavior.js +874 -0
- package/lib/openzeppelin-contracts-master/test/access/AccessControl.test.js +19 -0
- package/lib/openzeppelin-contracts-master/test/access/Ownable.test.js +79 -0
- package/lib/openzeppelin-contracts-master/test/access/Ownable2Step.test.js +102 -0
- package/lib/openzeppelin-contracts-master/test/access/extensions/AccessControlDefaultAdminRules.test.js +32 -0
- package/lib/openzeppelin-contracts-master/test/access/extensions/AccessControlEnumerable.test.js +24 -0
- package/lib/openzeppelin-contracts-master/test/access/manager/AccessManaged.test.js +146 -0
- package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.behavior.js +252 -0
- package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.predicate.js +456 -0
- package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.test.js +2536 -0
- package/lib/openzeppelin-contracts-master/test/access/manager/AuthorityUtils.test.js +112 -0
- package/lib/openzeppelin-contracts-master/test/account/Account.behavior.js +144 -0
- package/lib/openzeppelin-contracts-master/test/account/Account.test.js +48 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountECDSA.test.js +52 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountEIP7702.t.sol +116 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountEIP7702.test.js +52 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountERC7913.test.js +138 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountMultiSigner.test.js +326 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountMultiSignerWeighted.test.js +312 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountP256.test.js +58 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountRSA.test.js +58 -0
- package/lib/openzeppelin-contracts-master/test/account/AccountWebAuthn.test.js +75 -0
- package/lib/openzeppelin-contracts-master/test/account/examples/AccountEIP7702WithModulesMock.test.js +99 -0
- package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579.behavior.js +724 -0
- package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579.test.js +60 -0
- package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579Hooked.test.js +60 -0
- package/lib/openzeppelin-contracts-master/test/account/extensions/ERC7821.behavior.js +145 -0
- package/lib/openzeppelin-contracts-master/test/account/utils/EIP7702Utils.test.js +53 -0
- package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC4337Utils.test.js +594 -0
- package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC7579Utils.t.sol +434 -0
- package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC7579Utils.test.js +399 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC1155.behavior.js +333 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC1155.test.js +70 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC20.behavior.js +146 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC20.test.js +46 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC721.behavior.js +218 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC721.test.js +48 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/CrosschainExecutor.test.js +144 -0
- package/lib/openzeppelin-contracts-master/test/crosschain/ERC7786Recipient.test.js +55 -0
- package/lib/openzeppelin-contracts-master/test/finance/VestingWallet.behavior.js +87 -0
- package/lib/openzeppelin-contracts-master/test/finance/VestingWallet.test.js +65 -0
- package/lib/openzeppelin-contracts-master/test/finance/VestingWalletCliff.test.js +70 -0
- package/lib/openzeppelin-contracts-master/test/governance/Governor.t.sol +59 -0
- package/lib/openzeppelin-contracts-master/test/governance/Governor.test.js +980 -0
- package/lib/openzeppelin-contracts-master/test/governance/TimelockController.test.js +1279 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCountingFractional.test.js +248 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCountingOverridable.test.js +346 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCrosschain.test.js +158 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorERC721.test.js +131 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorNoncesKeyed.test.js +243 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorPreventLateQuorum.test.js +185 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorProposalGuardian.test.js +132 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSequentialProposalId.test.js +202 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorStorage.test.js +175 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSuperQuorum.test.js +168 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSuperQuorumGreaterThanQuorum.t.sol +79 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockAccess.test.js +906 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockCompound.test.js +450 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockControl.test.js +506 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorVotesQuorumFraction.test.js +165 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorVotesSuperQuorumFraction.test.js +160 -0
- package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorWithParams.test.js +245 -0
- package/lib/openzeppelin-contracts-master/test/governance/utils/ERC6372.behavior.js +29 -0
- package/lib/openzeppelin-contracts-master/test/governance/utils/Votes.behavior.js +325 -0
- package/lib/openzeppelin-contracts-master/test/governance/utils/Votes.test.js +102 -0
- package/lib/openzeppelin-contracts-master/test/governance/utils/VotesExtended.test.js +152 -0
- package/lib/openzeppelin-contracts-master/test/helpers/access-manager.js +85 -0
- package/lib/openzeppelin-contracts-master/test/helpers/account.js +16 -0
- package/lib/openzeppelin-contracts-master/test/helpers/chains.js +56 -0
- package/lib/openzeppelin-contracts-master/test/helpers/constants.js +7 -0
- package/lib/openzeppelin-contracts-master/test/helpers/deploy.js +14 -0
- package/lib/openzeppelin-contracts-master/test/helpers/eip712-types.js +61 -0
- package/lib/openzeppelin-contracts-master/test/helpers/eip712.js +45 -0
- package/lib/openzeppelin-contracts-master/test/helpers/enums.js +15 -0
- package/lib/openzeppelin-contracts-master/test/helpers/erc4337.js +244 -0
- package/lib/openzeppelin-contracts-master/test/helpers/erc7579.js +58 -0
- package/lib/openzeppelin-contracts-master/test/helpers/erc7739.js +118 -0
- package/lib/openzeppelin-contracts-master/test/helpers/governance.js +218 -0
- package/lib/openzeppelin-contracts-master/test/helpers/iterate.js +41 -0
- package/lib/openzeppelin-contracts-master/test/helpers/math.js +33 -0
- package/lib/openzeppelin-contracts-master/test/helpers/methods.js +14 -0
- package/lib/openzeppelin-contracts-master/test/helpers/precompiles.js +12 -0
- package/lib/openzeppelin-contracts-master/test/helpers/random.js +26 -0
- package/lib/openzeppelin-contracts-master/test/helpers/signers.js +225 -0
- package/lib/openzeppelin-contracts-master/test/helpers/storage.js +48 -0
- package/lib/openzeppelin-contracts-master/test/helpers/strings.js +5 -0
- package/lib/openzeppelin-contracts-master/test/helpers/time.js +33 -0
- package/lib/openzeppelin-contracts-master/test/helpers/trie.js +79 -0
- package/lib/openzeppelin-contracts-master/test/helpers/txpool.js +28 -0
- package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Context.test.js +109 -0
- package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Forwarder.t.sol +279 -0
- package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Forwarder.test.js +398 -0
- package/lib/openzeppelin-contracts-master/test/proxy/Clones.behaviour.js +160 -0
- package/lib/openzeppelin-contracts-master/test/proxy/Clones.t.sol +91 -0
- package/lib/openzeppelin-contracts-master/test/proxy/Clones.test.js +177 -0
- package/lib/openzeppelin-contracts-master/test/proxy/ERC1967/ERC1967Proxy.test.js +36 -0
- package/lib/openzeppelin-contracts-master/test/proxy/ERC1967/ERC1967Utils.test.js +162 -0
- package/lib/openzeppelin-contracts-master/test/proxy/Proxy.behaviour.js +198 -0
- package/lib/openzeppelin-contracts-master/test/proxy/beacon/BeaconProxy.test.js +141 -0
- package/lib/openzeppelin-contracts-master/test/proxy/beacon/UpgradeableBeacon.test.js +55 -0
- package/lib/openzeppelin-contracts-master/test/proxy/transparent/ProxyAdmin.test.js +82 -0
- package/lib/openzeppelin-contracts-master/test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js +367 -0
- package/lib/openzeppelin-contracts-master/test/proxy/transparent/TransparentUpgradeableProxy.test.js +28 -0
- package/lib/openzeppelin-contracts-master/test/proxy/utils/Initializable.test.js +216 -0
- package/lib/openzeppelin-contracts-master/test/proxy/utils/UUPSUpgradeable.test.js +120 -0
- package/lib/openzeppelin-contracts-master/test/sanity.test.js +27 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/ERC1155.behavior.js +865 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/ERC1155.test.js +258 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Burnable.test.js +66 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Crosschain.test.js +43 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Pausable.test.js +105 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Supply.test.js +119 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155URIStorage.test.js +70 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/utils/ERC1155Holder.test.js +56 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC1155/utils/ERC1155Utils.test.js +299 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/ERC20.behavior.js +269 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/ERC20.test.js +199 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC1363.test.js +370 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Burnable.test.js +105 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Capped.test.js +55 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Crosschain.test.js +83 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20FlashMint.test.js +164 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Pausable.test.js +129 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Permit.test.js +109 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Votes.test.js +546 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Wrapper.test.js +203 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC4626.t.sol +41 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC4626.test.js +888 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/draft-ERC20Bridgeable.test.js +89 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/draft-ERC20TemporaryApproval.test.js +142 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC20/utils/SafeERC20.test.js +493 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC6909/ERC6909.behavior.js +216 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC6909/ERC6909.test.js +104 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909ContentURI.test.js +52 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909Metadata.test.js +62 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909TokenSupply.test.js +56 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721.behavior.js +954 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721.test.js +23 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721Enumerable.test.js +28 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Burnable.test.js +77 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Consecutive.t.sol +187 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Consecutive.test.js +228 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Crosschain.test.js +44 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Pausable.test.js +81 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Royalty.test.js +57 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721URIStorage.test.js +134 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Votes.test.js +194 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Wrapper.test.js +201 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/utils/ERC721Holder.test.js +20 -0
- package/lib/openzeppelin-contracts-master/test/token/ERC721/utils/ERC721Utils.test.js +94 -0
- package/lib/openzeppelin-contracts-master/test/token/common/ERC2981.behavior.js +152 -0
- package/lib/openzeppelin-contracts-master/test/utils/Address.test.js +332 -0
- package/lib/openzeppelin-contracts-master/test/utils/Arrays.t.sol +416 -0
- package/lib/openzeppelin-contracts-master/test/utils/Arrays.test.js +284 -0
- package/lib/openzeppelin-contracts-master/test/utils/Base58.t.sol +24 -0
- package/lib/openzeppelin-contracts-master/test/utils/Base58.test.js +65 -0
- package/lib/openzeppelin-contracts-master/test/utils/Base64.t.sol +36 -0
- package/lib/openzeppelin-contracts-master/test/utils/Base64.test.js +79 -0
- package/lib/openzeppelin-contracts-master/test/utils/Blockhash.t.sol +101 -0
- package/lib/openzeppelin-contracts-master/test/utils/Blockhash.test.js +59 -0
- package/lib/openzeppelin-contracts-master/test/utils/Bytes.t.sol +322 -0
- package/lib/openzeppelin-contracts-master/test/utils/Bytes.test.js +371 -0
- package/lib/openzeppelin-contracts-master/test/utils/CAIP.test.js +56 -0
- package/lib/openzeppelin-contracts-master/test/utils/Calldata.test.js +22 -0
- package/lib/openzeppelin-contracts-master/test/utils/Context.behavior.js +48 -0
- package/lib/openzeppelin-contracts-master/test/utils/Context.test.js +18 -0
- package/lib/openzeppelin-contracts-master/test/utils/Create2.t.sol +17 -0
- package/lib/openzeppelin-contracts-master/test/utils/Create2.test.js +190 -0
- package/lib/openzeppelin-contracts-master/test/utils/Create3.t.sol +25 -0
- package/lib/openzeppelin-contracts-master/test/utils/Create3.test.js +185 -0
- package/lib/openzeppelin-contracts-master/test/utils/ERC6372Utils.test.js +59 -0
- package/lib/openzeppelin-contracts-master/test/utils/LowLevelCall.test.js +257 -0
- package/lib/openzeppelin-contracts-master/test/utils/Memory.t.sol +90 -0
- package/lib/openzeppelin-contracts-master/test/utils/Memory.test.js +94 -0
- package/lib/openzeppelin-contracts-master/test/utils/Multicall.test.js +72 -0
- package/lib/openzeppelin-contracts-master/test/utils/Nonces.behavior.js +189 -0
- package/lib/openzeppelin-contracts-master/test/utils/Nonces.test.js +16 -0
- package/lib/openzeppelin-contracts-master/test/utils/NoncesKeyed.t.sol +51 -0
- package/lib/openzeppelin-contracts-master/test/utils/NoncesKeyed.test.js +17 -0
- package/lib/openzeppelin-contracts-master/test/utils/Packing.t.sol +993 -0
- package/lib/openzeppelin-contracts-master/test/utils/Packing.test.js +70 -0
- package/lib/openzeppelin-contracts-master/test/utils/Panic.test.js +37 -0
- package/lib/openzeppelin-contracts-master/test/utils/Pausable.test.js +90 -0
- package/lib/openzeppelin-contracts-master/test/utils/RLP.t.sol +144 -0
- package/lib/openzeppelin-contracts-master/test/utils/RLP.test.js +224 -0
- package/lib/openzeppelin-contracts-master/test/utils/ReentrancyGuard.test.js +58 -0
- package/lib/openzeppelin-contracts-master/test/utils/RelayedCall.test.js +223 -0
- package/lib/openzeppelin-contracts-master/test/utils/ShortStrings.t.sol +109 -0
- package/lib/openzeppelin-contracts-master/test/utils/ShortStrings.test.js +64 -0
- package/lib/openzeppelin-contracts-master/test/utils/SimulatedCall.test.js +101 -0
- package/lib/openzeppelin-contracts-master/test/utils/SlotDerivation.t.sol +248 -0
- package/lib/openzeppelin-contracts-master/test/utils/SlotDerivation.test.js +58 -0
- package/lib/openzeppelin-contracts-master/test/utils/StorageSlot.test.js +73 -0
- package/lib/openzeppelin-contracts-master/test/utils/Strings.t.sol +50 -0
- package/lib/openzeppelin-contracts-master/test/utils/Strings.test.js +366 -0
- package/lib/openzeppelin-contracts-master/test/utils/TransientSlot.test.js +59 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/ECDSA.test.js +322 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/EIP712.test.js +105 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC1271.behavior.js +111 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC7739.test.js +42 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC7739Utils.test.js +203 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/MerkleProof.test.js +216 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/MessageHashUtils.t.sol +33 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/MessageHashUtils.test.js +149 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/P256.t.sol +44 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/P256.test.js +174 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/RSA.helper.js +17 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/RSA.test.js +102 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/SigVer15_186-3.rsp +3850 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/SignatureChecker.test.js +427 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/TrieProof.test.js +707 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/WebAuthn.t.sol +340 -0
- package/lib/openzeppelin-contracts-master/test/utils/cryptography/ecdsa_secp256r1_sha256_p1363_test.json +3719 -0
- package/lib/openzeppelin-contracts-master/test/utils/draft-InteroperableAddress.t.sol +99 -0
- package/lib/openzeppelin-contracts-master/test/utils/draft-InteroperableAddress.test.js +217 -0
- package/lib/openzeppelin-contracts-master/test/utils/introspection/ERC165.test.js +18 -0
- package/lib/openzeppelin-contracts-master/test/utils/introspection/ERC165Checker.test.js +272 -0
- package/lib/openzeppelin-contracts-master/test/utils/introspection/SupportsInterface.behavior.js +169 -0
- package/lib/openzeppelin-contracts-master/test/utils/math/Math.t.sol +370 -0
- package/lib/openzeppelin-contracts-master/test/utils/math/Math.test.js +746 -0
- package/lib/openzeppelin-contracts-master/test/utils/math/SafeCast.test.js +159 -0
- package/lib/openzeppelin-contracts-master/test/utils/math/SignedMath.t.sol +81 -0
- package/lib/openzeppelin-contracts-master/test/utils/math/SignedMath.test.js +53 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/Accumulators.t.sol +35 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/BitMap.test.js +149 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/Checkpoints.t.sol +440 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/Checkpoints.test.js +147 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/CircularBuffer.test.js +83 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/DoubleEndedQueue.test.js +144 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableMap.behavior.js +214 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableMap.test.js +83 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableSet.behavior.js +175 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableSet.test.js +66 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/Heap.t.sol +74 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/Heap.test.js +113 -0
- package/lib/openzeppelin-contracts-master/test/utils/structs/MerkleTree.test.js +180 -0
- package/lib/openzeppelin-contracts-master/test/utils/types/Time.test.js +135 -0
- package/lib/v3-core-main/.gitattributes +1 -0
- package/lib/v3-core-main/.github/stale.yml +25 -0
- package/lib/v3-core-main/.github/workflows/fuzz-testing.yml +60 -0
- package/lib/v3-core-main/.github/workflows/lint.yml +34 -0
- package/lib/v3-core-main/.github/workflows/mythx.yml +65 -0
- package/lib/v3-core-main/.github/workflows/tests.yml +38 -0
- package/lib/v3-core-main/.prettierrc +5 -0
- package/lib/v3-core-main/.solhint.json +6 -0
- package/lib/v3-core-main/.yarnrc +1 -0
- package/lib/v3-core-main/LICENSE +100 -0
- package/lib/v3-core-main/README.md +66 -0
- package/lib/v3-core-main/audits/abdk/audit.pdf +0 -0
- package/lib/v3-core-main/audits/tob/README.md +166 -0
- package/lib/v3-core-main/audits/tob/audit.pdf +0 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_mint_burn.config.yaml +16 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_mint_burn.sol +503 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_swap.config.yaml +10 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_swap.sol +487 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Other.config.yaml +7 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Other.sol +21 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Setup.sol +205 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/001.sol +11 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/002.sol +12 -0
- package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/003.sol +9 -0
- package/lib/v3-core-main/bug-bounty.md +76 -0
- package/lib/v3-core-main/contracts/NoDelegateCall.sol +27 -0
- package/lib/v3-core-main/contracts/UniswapV3Factory.sol +73 -0
- package/lib/v3-core-main/contracts/UniswapV3Pool.sol +869 -0
- package/lib/v3-core-main/contracts/UniswapV3PoolDeployer.sol +38 -0
- package/lib/v3-core-main/contracts/interfaces/IERC20Minimal.sol +52 -0
- package/lib/v3-core-main/contracts/interfaces/IUniswapV3Factory.sol +78 -0
- package/lib/v3-core-main/contracts/interfaces/IUniswapV3Pool.sol +24 -0
- package/lib/v3-core-main/contracts/interfaces/IUniswapV3PoolDeployer.sol +26 -0
- package/lib/v3-core-main/contracts/interfaces/LICENSE +445 -0
- package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3FlashCallback.sol +18 -0
- package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3MintCallback.sol +18 -0
- package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3SwapCallback.sol +21 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolActions.sol +103 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol +40 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolEvents.sol +121 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol +35 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol +23 -0
- package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolState.sol +116 -0
- package/lib/v3-core-main/contracts/libraries/BitMath.sol +94 -0
- package/lib/v3-core-main/contracts/libraries/FixedPoint128.sol +8 -0
- package/lib/v3-core-main/contracts/libraries/FixedPoint96.sol +10 -0
- package/lib/v3-core-main/contracts/libraries/FullMath.sol +124 -0
- package/lib/v3-core-main/contracts/libraries/LICENSE +445 -0
- package/lib/v3-core-main/contracts/libraries/LICENSE_MIT +20 -0
- package/lib/v3-core-main/contracts/libraries/LiquidityMath.sol +17 -0
- package/lib/v3-core-main/contracts/libraries/LowGasSafeMath.sol +46 -0
- package/lib/v3-core-main/contracts/libraries/Oracle.sol +325 -0
- package/lib/v3-core-main/contracts/libraries/Position.sol +88 -0
- package/lib/v3-core-main/contracts/libraries/SafeCast.sol +28 -0
- package/lib/v3-core-main/contracts/libraries/SqrtPriceMath.sol +227 -0
- package/lib/v3-core-main/contracts/libraries/SwapMath.sol +98 -0
- package/lib/v3-core-main/contracts/libraries/Tick.sol +185 -0
- package/lib/v3-core-main/contracts/libraries/TickBitmap.sol +78 -0
- package/lib/v3-core-main/contracts/libraries/TickMath.sol +205 -0
- package/lib/v3-core-main/contracts/libraries/TransferHelper.sol +23 -0
- package/lib/v3-core-main/contracts/libraries/UnsafeMath.sol +17 -0
- package/lib/v3-core-main/contracts/test/BitMathEchidnaTest.sol +18 -0
- package/lib/v3-core-main/contracts/test/BitMathTest.sol +26 -0
- package/lib/v3-core-main/contracts/test/FullMathEchidnaTest.sol +67 -0
- package/lib/v3-core-main/contracts/test/FullMathTest.sol +22 -0
- package/lib/v3-core-main/contracts/test/LiquidityMathTest.sol +16 -0
- package/lib/v3-core-main/contracts/test/LowGasSafeMathEchidnaTest.sol +36 -0
- package/lib/v3-core-main/contracts/test/MockTimeUniswapV3Pool.sol +26 -0
- package/lib/v3-core-main/contracts/test/MockTimeUniswapV3PoolDeployer.sol +35 -0
- package/lib/v3-core-main/contracts/test/NoDelegateCallTest.sol +32 -0
- package/lib/v3-core-main/contracts/test/OracleEchidnaTest.sol +137 -0
- package/lib/v3-core-main/contracts/test/OracleTest.sol +100 -0
- package/lib/v3-core-main/contracts/test/SqrtPriceMathEchidnaTest.sol +232 -0
- package/lib/v3-core-main/contracts/test/SqrtPriceMathTest.sol +86 -0
- package/lib/v3-core-main/contracts/test/SwapMathEchidnaTest.sol +52 -0
- package/lib/v3-core-main/contracts/test/SwapMathTest.sol +37 -0
- package/lib/v3-core-main/contracts/test/TestERC20.sol +59 -0
- package/lib/v3-core-main/contracts/test/TestUniswapV3Callee.sol +142 -0
- package/lib/v3-core-main/contracts/test/TestUniswapV3ReentrantCallee.sol +56 -0
- package/lib/v3-core-main/contracts/test/TestUniswapV3Router.sol +91 -0
- package/lib/v3-core-main/contracts/test/TestUniswapV3SwapPay.sol +41 -0
- package/lib/v3-core-main/contracts/test/TickBitmapEchidnaTest.sol +47 -0
- package/lib/v3-core-main/contracts/test/TickBitmapTest.sol +40 -0
- package/lib/v3-core-main/contracts/test/TickEchidnaTest.sol +27 -0
- package/lib/v3-core-main/contracts/test/TickMathEchidnaTest.sol +22 -0
- package/lib/v3-core-main/contracts/test/TickMathTest.sol +34 -0
- package/lib/v3-core-main/contracts/test/TickOverflowSafetyEchidnaTest.sol +111 -0
- package/lib/v3-core-main/contracts/test/TickTest.sol +79 -0
- package/lib/v3-core-main/contracts/test/UniswapV3PoolSwapTest.sol +50 -0
- package/lib/v3-core-main/contracts/test/UnsafeMathEchidnaTest.sol +17 -0
- package/lib/v3-core-main/echidna.config.yml +74 -0
- package/lib/v3-core-main/hardhat.config.ts +68 -0
- package/lib/v3-core-main/package.json +59 -0
- package/lib/v3-core-main/test/BitMath.spec.ts +79 -0
- package/lib/v3-core-main/test/FullMath.spec.ts +182 -0
- package/lib/v3-core-main/test/LiquidityMath.spec.ts +44 -0
- package/lib/v3-core-main/test/NoDelegateCall.spec.ts +54 -0
- package/lib/v3-core-main/test/Oracle.spec.ts +798 -0
- package/lib/v3-core-main/test/SqrtPriceMath.spec.ts +379 -0
- package/lib/v3-core-main/test/SwapMath.spec.ts +324 -0
- package/lib/v3-core-main/test/Tick.spec.ts +329 -0
- package/lib/v3-core-main/test/TickBitmap.spec.ts +227 -0
- package/lib/v3-core-main/test/TickMath.spec.ts +166 -0
- package/lib/v3-core-main/test/UniswapV3Factory.spec.ts +177 -0
- package/lib/v3-core-main/test/UniswapV3Pool.arbitrage.spec.ts +373 -0
- package/lib/v3-core-main/test/UniswapV3Pool.gas.spec.ts +315 -0
- package/lib/v3-core-main/test/UniswapV3Pool.spec.ts +2043 -0
- package/lib/v3-core-main/test/UniswapV3Pool.swaps.spec.ts +588 -0
- package/lib/v3-core-main/test/UniswapV3Router.spec.ts +133 -0
- package/lib/v3-core-main/test/__snapshots__/BitMath.spec.ts.snap +13 -0
- package/lib/v3-core-main/test/__snapshots__/LiquidityMath.spec.ts.snap +5 -0
- package/lib/v3-core-main/test/__snapshots__/NoDelegateCall.spec.ts.snap +3 -0
- package/lib/v3-core-main/test/__snapshots__/Oracle.spec.ts.snap +87 -0
- package/lib/v3-core-main/test/__snapshots__/SqrtPriceMath.spec.ts.snap +17 -0
- package/lib/v3-core-main/test/__snapshots__/SwapMath.spec.ts.snap +17 -0
- package/lib/v3-core-main/test/__snapshots__/TickBitmap.spec.ts.snap +19 -0
- package/lib/v3-core-main/test/__snapshots__/TickMath.spec.ts.snap +165 -0
- package/lib/v3-core-main/test/__snapshots__/UniswapV3Factory.spec.ts.snap +7 -0
- package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.arbitrage.spec.ts.snap +977 -0
- package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.gas.spec.ts.snap +169 -0
- package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.swaps.spec.ts.snap +3541 -0
- package/lib/v3-core-main/test/shared/checkObservationEquals.ts +38 -0
- package/lib/v3-core-main/test/shared/expect.ts +8 -0
- package/lib/v3-core-main/test/shared/fixtures.ts +92 -0
- package/lib/v3-core-main/test/shared/format.ts +10 -0
- package/lib/v3-core-main/test/shared/snapshotGasCost.ts +27 -0
- package/lib/v3-core-main/test/shared/utilities.ts +258 -0
- package/lib/v3-core-main/test/snapshotCumulativesInside.test.ts +73 -0
- package/lib/v3-core-main/tsconfig.json +13 -0
- package/lib/v3-core-main/yarn.lock +9271 -0
- package/lib/v3-periphery-main/.gitattributes +1 -0
- package/lib/v3-periphery-main/.github/stale.yml +25 -0
- package/lib/v3-periphery-main/.github/workflows/lint.yml +33 -0
- package/lib/v3-periphery-main/.github/workflows/tests.yml +39 -0
- package/lib/v3-periphery-main/.prettierignore +1 -0
- package/lib/v3-periphery-main/.prettierrc +5 -0
- package/lib/v3-periphery-main/.solhint.json +6 -0
- package/lib/v3-periphery-main/.yarnrc +1 -0
- package/lib/v3-periphery-main/LICENSE +339 -0
- package/lib/v3-periphery-main/README.md +52 -0
- package/lib/v3-periphery-main/audits/abdk/audit.pdf +0 -0
- package/lib/v3-periphery-main/bug-bounty.md +80 -0
- package/lib/v3-periphery-main/contracts/NonfungiblePositionManager.sol +400 -0
- package/lib/v3-periphery-main/contracts/NonfungibleTokenPositionDescriptor.sol +124 -0
- package/lib/v3-periphery-main/contracts/SwapRouter.sol +244 -0
- package/lib/v3-periphery-main/contracts/V3Migrator.sol +99 -0
- package/lib/v3-periphery-main/contracts/base/BlockTimestamp.sol +12 -0
- package/lib/v3-periphery-main/contracts/base/ERC721Permit.sol +86 -0
- package/lib/v3-periphery-main/contracts/base/LiquidityManagement.sol +90 -0
- package/lib/v3-periphery-main/contracts/base/Multicall.sol +28 -0
- package/lib/v3-periphery-main/contracts/base/PeripheryImmutableState.sol +18 -0
- package/lib/v3-periphery-main/contracts/base/PeripheryPayments.sol +70 -0
- package/lib/v3-periphery-main/contracts/base/PeripheryPaymentsWithFee.sol +55 -0
- package/lib/v3-periphery-main/contracts/base/PeripheryValidation.sol +11 -0
- package/lib/v3-periphery-main/contracts/base/PoolInitializer.sol +32 -0
- package/lib/v3-periphery-main/contracts/base/SelfPermit.sol +63 -0
- package/lib/v3-periphery-main/contracts/examples/PairFlash.sol +149 -0
- package/lib/v3-periphery-main/contracts/interfaces/IERC20Metadata.sol +18 -0
- package/lib/v3-periphery-main/contracts/interfaces/IERC721Permit.sol +32 -0
- package/lib/v3-periphery-main/contracts/interfaces/IMulticall.sol +13 -0
- package/lib/v3-periphery-main/contracts/interfaces/INonfungiblePositionManager.sol +179 -0
- package/lib/v3-periphery-main/contracts/interfaces/INonfungibleTokenPositionDescriptor.sol +17 -0
- package/lib/v3-periphery-main/contracts/interfaces/IPeripheryImmutableState.sol +12 -0
- package/lib/v3-periphery-main/contracts/interfaces/IPeripheryPayments.sol +28 -0
- package/lib/v3-periphery-main/contracts/interfaces/IPeripheryPaymentsWithFee.sol +29 -0
- package/lib/v3-periphery-main/contracts/interfaces/IPoolInitializer.sol +22 -0
- package/lib/v3-periphery-main/contracts/interfaces/IQuoter.sol +51 -0
- package/lib/v3-periphery-main/contracts/interfaces/IQuoterV2.sol +98 -0
- package/lib/v3-periphery-main/contracts/interfaces/ISelfPermit.sol +76 -0
- package/lib/v3-periphery-main/contracts/interfaces/ISwapRouter.sol +67 -0
- package/lib/v3-periphery-main/contracts/interfaces/ITickLens.sol +25 -0
- package/lib/v3-periphery-main/contracts/interfaces/IV3Migrator.sol +34 -0
- package/lib/v3-periphery-main/contracts/interfaces/external/IERC1271.sol +16 -0
- package/lib/v3-periphery-main/contracts/interfaces/external/IERC20PermitAllowed.sol +27 -0
- package/lib/v3-periphery-main/contracts/interfaces/external/IWETH9.sol +13 -0
- package/lib/v3-periphery-main/contracts/lens/Quoter.sol +170 -0
- package/lib/v3-periphery-main/contracts/lens/QuoterV2.sol +273 -0
- package/lib/v3-periphery-main/contracts/lens/README.md +4 -0
- package/lib/v3-periphery-main/contracts/lens/TickLens.sol +42 -0
- package/lib/v3-periphery-main/contracts/lens/UniswapInterfaceMulticall.sol +39 -0
- package/lib/v3-periphery-main/contracts/libraries/BytesLib.sol +101 -0
- package/lib/v3-periphery-main/contracts/libraries/CallbackValidation.sol +36 -0
- package/lib/v3-periphery-main/contracts/libraries/ChainId.sol +13 -0
- package/lib/v3-periphery-main/contracts/libraries/HexStrings.sol +29 -0
- package/lib/v3-periphery-main/contracts/libraries/LiquidityAmounts.sol +137 -0
- package/lib/v3-periphery-main/contracts/libraries/NFTDescriptor.sol +477 -0
- package/lib/v3-periphery-main/contracts/libraries/NFTSVG.sol +406 -0
- package/lib/v3-periphery-main/contracts/libraries/OracleLibrary.sol +180 -0
- package/lib/v3-periphery-main/contracts/libraries/Path.sol +69 -0
- package/lib/v3-periphery-main/contracts/libraries/PoolAddress.sol +48 -0
- package/lib/v3-periphery-main/contracts/libraries/PoolTicksCounter.sol +96 -0
- package/lib/v3-periphery-main/contracts/libraries/PositionKey.sol +13 -0
- package/lib/v3-periphery-main/contracts/libraries/PositionValue.sol +167 -0
- package/lib/v3-periphery-main/contracts/libraries/SqrtPriceMathPartial.sol +62 -0
- package/lib/v3-periphery-main/contracts/libraries/TokenRatioSortOrder.sol +12 -0
- package/lib/v3-periphery-main/contracts/libraries/TransferHelper.sol +60 -0
- package/lib/v3-periphery-main/contracts/test/Base64Test.sol +16 -0
- package/lib/v3-periphery-main/contracts/test/LiquidityAmountsTest.sol +120 -0
- package/lib/v3-periphery-main/contracts/test/MockObservable.sol +48 -0
- package/lib/v3-periphery-main/contracts/test/MockObservations.sol +82 -0
- package/lib/v3-periphery-main/contracts/test/MockTimeNonfungiblePositionManager.sol +23 -0
- package/lib/v3-periphery-main/contracts/test/MockTimeSwapRouter.sol +19 -0
- package/lib/v3-periphery-main/contracts/test/NFTDescriptorTest.sol +75 -0
- package/lib/v3-periphery-main/contracts/test/NonfungiblePositionManagerPositionsGasTest.sol +18 -0
- package/lib/v3-periphery-main/contracts/test/OracleTest.sol +67 -0
- package/lib/v3-periphery-main/contracts/test/PathTest.sol +37 -0
- package/lib/v3-periphery-main/contracts/test/PeripheryImmutableStateTest.sol +8 -0
- package/lib/v3-periphery-main/contracts/test/PoolAddressTest.sol +30 -0
- package/lib/v3-periphery-main/contracts/test/PoolTicksCounterTest.sol +18 -0
- package/lib/v3-periphery-main/contracts/test/PositionValueTest.sol +57 -0
- package/lib/v3-periphery-main/contracts/test/SelfPermitTest.sol +9 -0
- package/lib/v3-periphery-main/contracts/test/TestCallbackValidation.sol +15 -0
- package/lib/v3-periphery-main/contracts/test/TestERC20.sol +10 -0
- package/lib/v3-periphery-main/contracts/test/TestERC20Metadata.sol +14 -0
- package/lib/v3-periphery-main/contracts/test/TestERC20PermitAllowed.sol +24 -0
- package/lib/v3-periphery-main/contracts/test/TestMulticall.sol +30 -0
- package/lib/v3-periphery-main/contracts/test/TestPositionNFTOwner.sol +28 -0
- package/lib/v3-periphery-main/contracts/test/TestUniswapV3Callee.sol +62 -0
- package/lib/v3-periphery-main/contracts/test/TickLensTest.sol +15 -0
- package/lib/v3-periphery-main/deploys.md +25 -0
- package/lib/v3-periphery-main/hardhat.config.ts +104 -0
- package/lib/v3-periphery-main/package.json +68 -0
- package/lib/v3-periphery-main/test/Base64.spec.ts +81 -0
- package/lib/v3-periphery-main/test/CallbackValidation.spec.ts +56 -0
- package/lib/v3-periphery-main/test/LiquidityAmounts.spec.ts +241 -0
- package/lib/v3-periphery-main/test/Multicall.spec.ts +65 -0
- package/lib/v3-periphery-main/test/NFTDescriptor.spec.ts +907 -0
- package/lib/v3-periphery-main/test/NonfungiblePositionManager.spec.ts +1304 -0
- package/lib/v3-periphery-main/test/NonfungibleTokenPositionDescriptor.spec.ts +217 -0
- package/lib/v3-periphery-main/test/OracleLibrary.spec.ts +675 -0
- package/lib/v3-periphery-main/test/PairFlash.spec.ts +168 -0
- package/lib/v3-periphery-main/test/Path.spec.ts +90 -0
- package/lib/v3-periphery-main/test/PeripheryImmutableState.spec.ts +56 -0
- package/lib/v3-periphery-main/test/PoolAddress.spec.ts +72 -0
- package/lib/v3-periphery-main/test/PoolTicksCounter.spec.ts +280 -0
- package/lib/v3-periphery-main/test/PositionValue.spec.ts +490 -0
- package/lib/v3-periphery-main/test/Quoter.spec.ts +201 -0
- package/lib/v3-periphery-main/test/QuoterV2.spec.ts +578 -0
- package/lib/v3-periphery-main/test/SelfPermit.spec.ts +198 -0
- package/lib/v3-periphery-main/test/SwapRouter.gas.spec.ts +453 -0
- package/lib/v3-periphery-main/test/SwapRouter.spec.ts +916 -0
- package/lib/v3-periphery-main/test/TickLens.spec.ts +223 -0
- package/lib/v3-periphery-main/test/V3Migrator.spec.ts +446 -0
- package/lib/v3-periphery-main/test/__snapshots__/Base64.spec.ts.snap +32 -0
- package/lib/v3-periphery-main/test/__snapshots__/LiquidityAmounts.spec.ts.snap +21 -0
- package/lib/v3-periphery-main/test/__snapshots__/Multicall.spec.ts.snap +5 -0
- package/lib/v3-periphery-main/test/__snapshots__/NFTDescriptor.spec.ts.snap +7 -0
- package/lib/v3-periphery-main/test/__snapshots__/NFTDescriptor.svg +1 -0
- package/lib/v3-periphery-main/test/__snapshots__/NonfungiblePositionManager.spec.ts.snap +41 -0
- package/lib/v3-periphery-main/test/__snapshots__/OracleLibrary.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/__snapshots__/PairFlash.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/__snapshots__/Path.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/__snapshots__/PeripheryImmutableState.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/__snapshots__/PoolAddress.spec.ts.snap +5 -0
- package/lib/v3-periphery-main/test/__snapshots__/PositionValue.spec.ts.snap +11 -0
- package/lib/v3-periphery-main/test/__snapshots__/QuoterV2.spec.ts.snap +51 -0
- package/lib/v3-periphery-main/test/__snapshots__/SwapRouter.gas.spec.ts.snap +37 -0
- package/lib/v3-periphery-main/test/__snapshots__/SwapRouter.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/__snapshots__/TickLens.spec.ts.snap +5 -0
- package/lib/v3-periphery-main/test/__snapshots__/V3Migrator.spec.ts.snap +3 -0
- package/lib/v3-periphery-main/test/contracts/WETH9.json +156 -0
- package/lib/v3-periphery-main/test/shared/base64.ts +7 -0
- package/lib/v3-periphery-main/test/shared/completeFixture.ts +63 -0
- package/lib/v3-periphery-main/test/shared/computePoolAddress.ts +22 -0
- package/lib/v3-periphery-main/test/shared/constants.ts +15 -0
- package/lib/v3-periphery-main/test/shared/encodePriceSqrt.ts +16 -0
- package/lib/v3-periphery-main/test/shared/expandTo18Decimals.ts +5 -0
- package/lib/v3-periphery-main/test/shared/expect.ts +8 -0
- package/lib/v3-periphery-main/test/shared/externalFixtures.ts +57 -0
- package/lib/v3-periphery-main/test/shared/extractJSONFromURI.ts +5 -0
- package/lib/v3-periphery-main/test/shared/formatSqrtRatioX96.spec.ts +30 -0
- package/lib/v3-periphery-main/test/shared/formatSqrtRatioX96.ts +30 -0
- package/lib/v3-periphery-main/test/shared/getPermitNFTSignature.ts +57 -0
- package/lib/v3-periphery-main/test/shared/path.ts +61 -0
- package/lib/v3-periphery-main/test/shared/permit.ts +61 -0
- package/lib/v3-periphery-main/test/shared/poolAtAddress.ts +7 -0
- package/lib/v3-periphery-main/test/shared/quoter.ts +153 -0
- package/lib/v3-periphery-main/test/shared/snapshotGasCost.ts +27 -0
- package/lib/v3-periphery-main/test/shared/ticks.ts +9 -0
- package/lib/v3-periphery-main/test/shared/tokenSort.ts +10 -0
- package/lib/v3-periphery-main/testnet-deploys.md +3 -0
- package/lib/v3-periphery-main/tsconfig.json +14 -0
- package/lib/v3-periphery-main/yarn.lock +8111 -0
- package/package.json +44 -0
- package/src/LPStateStorage.sol +74 -0
- package/src/MinimalPositionDescriptor.sol +38 -0
- package/src/NonfungiblePositionManagerImporter.sol +13 -0
- package/src/QuoterV2Importer.sol +9 -0
- package/src/RapidexV3FactoryImporter.sol +6 -0
- package/src/SwapRouterImporter.sol +9 -0
- package/src/TestToken.sol +60 -0
- package/src/WMST.sol +63 -0
- package/src/flattened/LPStateStorage.flat.sol +76 -0
- package/src/flattened/MinimalPositionDescriptor.flat.sol +40 -0
- package/src/flattened/NonfungiblePositionManagerImporter.flat.sol +2695 -0
- package/src/flattened/QuoterV2Importer.flat.sol +1616 -0
- package/src/flattened/RapidexV3FactoryImporter.flat.sol +3193 -0
- package/src/flattened/SwapRouterImporter.flat.sol +1811 -0
- package/src/flattened/TestToken.flat.sol +62 -0
- package/src/flattened/WMST.flat.sol +65 -0
|
@@ -0,0 +1,2043 @@
|
|
|
1
|
+
import { ethers, waffle } from 'hardhat'
|
|
2
|
+
import { BigNumber, BigNumberish, constants, Wallet } from 'ethers'
|
|
3
|
+
import { TestERC20 } from '../typechain/TestERC20'
|
|
4
|
+
import { UniswapV3Factory } from '../typechain/UniswapV3Factory'
|
|
5
|
+
import { MockTimeUniswapV3Pool } from '../typechain/MockTimeUniswapV3Pool'
|
|
6
|
+
import { TestUniswapV3SwapPay } from '../typechain/TestUniswapV3SwapPay'
|
|
7
|
+
import checkObservationEquals from './shared/checkObservationEquals'
|
|
8
|
+
import { expect } from './shared/expect'
|
|
9
|
+
|
|
10
|
+
import { poolFixture, TEST_POOL_START_TIME } from './shared/fixtures'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
expandTo18Decimals,
|
|
14
|
+
FeeAmount,
|
|
15
|
+
getPositionKey,
|
|
16
|
+
getMaxTick,
|
|
17
|
+
getMinTick,
|
|
18
|
+
encodePriceSqrt,
|
|
19
|
+
TICK_SPACINGS,
|
|
20
|
+
createPoolFunctions,
|
|
21
|
+
SwapFunction,
|
|
22
|
+
MintFunction,
|
|
23
|
+
getMaxLiquidityPerTick,
|
|
24
|
+
FlashFunction,
|
|
25
|
+
MaxUint128,
|
|
26
|
+
MAX_SQRT_RATIO,
|
|
27
|
+
MIN_SQRT_RATIO,
|
|
28
|
+
SwapToPriceFunction,
|
|
29
|
+
} from './shared/utilities'
|
|
30
|
+
import { TestUniswapV3Callee } from '../typechain/TestUniswapV3Callee'
|
|
31
|
+
import { TestUniswapV3ReentrantCallee } from '../typechain/TestUniswapV3ReentrantCallee'
|
|
32
|
+
import { TickMathTest } from '../typechain/TickMathTest'
|
|
33
|
+
import { SwapMathTest } from '../typechain/SwapMathTest'
|
|
34
|
+
|
|
35
|
+
const createFixtureLoader = waffle.createFixtureLoader
|
|
36
|
+
|
|
37
|
+
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
|
|
38
|
+
|
|
39
|
+
describe('UniswapV3Pool', () => {
|
|
40
|
+
let wallet: Wallet, other: Wallet
|
|
41
|
+
|
|
42
|
+
let token0: TestERC20
|
|
43
|
+
let token1: TestERC20
|
|
44
|
+
let token2: TestERC20
|
|
45
|
+
|
|
46
|
+
let factory: UniswapV3Factory
|
|
47
|
+
let pool: MockTimeUniswapV3Pool
|
|
48
|
+
|
|
49
|
+
let swapTarget: TestUniswapV3Callee
|
|
50
|
+
|
|
51
|
+
let swapToLowerPrice: SwapToPriceFunction
|
|
52
|
+
let swapToHigherPrice: SwapToPriceFunction
|
|
53
|
+
let swapExact0For1: SwapFunction
|
|
54
|
+
let swap0ForExact1: SwapFunction
|
|
55
|
+
let swapExact1For0: SwapFunction
|
|
56
|
+
let swap1ForExact0: SwapFunction
|
|
57
|
+
|
|
58
|
+
let feeAmount: number
|
|
59
|
+
let tickSpacing: number
|
|
60
|
+
|
|
61
|
+
let minTick: number
|
|
62
|
+
let maxTick: number
|
|
63
|
+
|
|
64
|
+
let mint: MintFunction
|
|
65
|
+
let flash: FlashFunction
|
|
66
|
+
|
|
67
|
+
let loadFixture: ReturnType<typeof createFixtureLoader>
|
|
68
|
+
let createPool: ThenArg<ReturnType<typeof poolFixture>>['createPool']
|
|
69
|
+
|
|
70
|
+
before('create fixture loader', async () => {
|
|
71
|
+
;[wallet, other] = await (ethers as any).getSigners()
|
|
72
|
+
loadFixture = createFixtureLoader([wallet, other])
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
beforeEach('deploy fixture', async () => {
|
|
76
|
+
;({ token0, token1, token2, factory, createPool, swapTargetCallee: swapTarget } = await loadFixture(poolFixture))
|
|
77
|
+
|
|
78
|
+
const oldCreatePool = createPool
|
|
79
|
+
createPool = async (_feeAmount, _tickSpacing) => {
|
|
80
|
+
const pool = await oldCreatePool(_feeAmount, _tickSpacing)
|
|
81
|
+
;({
|
|
82
|
+
swapToLowerPrice,
|
|
83
|
+
swapToHigherPrice,
|
|
84
|
+
swapExact0For1,
|
|
85
|
+
swap0ForExact1,
|
|
86
|
+
swapExact1For0,
|
|
87
|
+
swap1ForExact0,
|
|
88
|
+
mint,
|
|
89
|
+
flash,
|
|
90
|
+
} = createPoolFunctions({
|
|
91
|
+
token0,
|
|
92
|
+
token1,
|
|
93
|
+
swapTarget,
|
|
94
|
+
pool,
|
|
95
|
+
}))
|
|
96
|
+
minTick = getMinTick(_tickSpacing)
|
|
97
|
+
maxTick = getMaxTick(_tickSpacing)
|
|
98
|
+
feeAmount = _feeAmount
|
|
99
|
+
tickSpacing = _tickSpacing
|
|
100
|
+
return pool
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// default to the 30 bips pool
|
|
104
|
+
pool = await createPool(FeeAmount.MEDIUM, TICK_SPACINGS[FeeAmount.MEDIUM])
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('constructor initializes immutables', async () => {
|
|
108
|
+
expect(await pool.factory()).to.eq(factory.address)
|
|
109
|
+
expect(await pool.token0()).to.eq(token0.address)
|
|
110
|
+
expect(await pool.token1()).to.eq(token1.address)
|
|
111
|
+
expect(await pool.maxLiquidityPerTick()).to.eq(getMaxLiquidityPerTick(tickSpacing))
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe('#initialize', () => {
|
|
115
|
+
it('fails if already initialized', async () => {
|
|
116
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
117
|
+
await expect(pool.initialize(encodePriceSqrt(1, 1))).to.be.reverted
|
|
118
|
+
})
|
|
119
|
+
it('fails if starting price is too low', async () => {
|
|
120
|
+
await expect(pool.initialize(1)).to.be.revertedWith('R')
|
|
121
|
+
await expect(pool.initialize(MIN_SQRT_RATIO.sub(1))).to.be.revertedWith('R')
|
|
122
|
+
})
|
|
123
|
+
it('fails if starting price is too high', async () => {
|
|
124
|
+
await expect(pool.initialize(MAX_SQRT_RATIO)).to.be.revertedWith('R')
|
|
125
|
+
await expect(pool.initialize(BigNumber.from(2).pow(160).sub(1))).to.be.revertedWith('R')
|
|
126
|
+
})
|
|
127
|
+
it('can be initialized at MIN_SQRT_RATIO', async () => {
|
|
128
|
+
await pool.initialize(MIN_SQRT_RATIO)
|
|
129
|
+
expect((await pool.slot0()).tick).to.eq(getMinTick(1))
|
|
130
|
+
})
|
|
131
|
+
it('can be initialized at MAX_SQRT_RATIO - 1', async () => {
|
|
132
|
+
await pool.initialize(MAX_SQRT_RATIO.sub(1))
|
|
133
|
+
expect((await pool.slot0()).tick).to.eq(getMaxTick(1) - 1)
|
|
134
|
+
})
|
|
135
|
+
it('sets initial variables', async () => {
|
|
136
|
+
const price = encodePriceSqrt(1, 2)
|
|
137
|
+
await pool.initialize(price)
|
|
138
|
+
|
|
139
|
+
const { sqrtPriceX96, observationIndex } = await pool.slot0()
|
|
140
|
+
expect(sqrtPriceX96).to.eq(price)
|
|
141
|
+
expect(observationIndex).to.eq(0)
|
|
142
|
+
expect((await pool.slot0()).tick).to.eq(-6932)
|
|
143
|
+
})
|
|
144
|
+
it('initializes the first observations slot', async () => {
|
|
145
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
146
|
+
checkObservationEquals(await pool.observations(0), {
|
|
147
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
148
|
+
initialized: true,
|
|
149
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
150
|
+
tickCumulative: 0,
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
it('emits a Initialized event with the input tick', async () => {
|
|
154
|
+
const sqrtPriceX96 = encodePriceSqrt(1, 2)
|
|
155
|
+
await expect(pool.initialize(sqrtPriceX96)).to.emit(pool, 'Initialize').withArgs(sqrtPriceX96, -6932)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
describe('#increaseObservationCardinalityNext', () => {
|
|
160
|
+
it('can only be called after initialize', async () => {
|
|
161
|
+
await expect(pool.increaseObservationCardinalityNext(2)).to.be.revertedWith('LOK')
|
|
162
|
+
})
|
|
163
|
+
it('emits an event including both old and new', async () => {
|
|
164
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
165
|
+
await expect(pool.increaseObservationCardinalityNext(2))
|
|
166
|
+
.to.emit(pool, 'IncreaseObservationCardinalityNext')
|
|
167
|
+
.withArgs(1, 2)
|
|
168
|
+
})
|
|
169
|
+
it('does not emit an event for no op call', async () => {
|
|
170
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
171
|
+
await pool.increaseObservationCardinalityNext(3)
|
|
172
|
+
await expect(pool.increaseObservationCardinalityNext(2)).to.not.emit(pool, 'IncreaseObservationCardinalityNext')
|
|
173
|
+
})
|
|
174
|
+
it('does not change cardinality next if less than current', async () => {
|
|
175
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
176
|
+
await pool.increaseObservationCardinalityNext(3)
|
|
177
|
+
await pool.increaseObservationCardinalityNext(2)
|
|
178
|
+
expect((await pool.slot0()).observationCardinalityNext).to.eq(3)
|
|
179
|
+
})
|
|
180
|
+
it('increases cardinality and cardinality next first time', async () => {
|
|
181
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
182
|
+
await pool.increaseObservationCardinalityNext(2)
|
|
183
|
+
const { observationCardinality, observationCardinalityNext } = await pool.slot0()
|
|
184
|
+
expect(observationCardinality).to.eq(1)
|
|
185
|
+
expect(observationCardinalityNext).to.eq(2)
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
describe('#mint', () => {
|
|
190
|
+
it('fails if not initialized', async () => {
|
|
191
|
+
await expect(mint(wallet.address, -tickSpacing, tickSpacing, 1)).to.be.revertedWith('LOK')
|
|
192
|
+
})
|
|
193
|
+
describe('after initialization', () => {
|
|
194
|
+
beforeEach('initialize the pool at price of 10:1', async () => {
|
|
195
|
+
await pool.initialize(encodePriceSqrt(1, 10))
|
|
196
|
+
await mint(wallet.address, minTick, maxTick, 3161)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
describe('failure cases', () => {
|
|
200
|
+
it('fails if tickLower greater than tickUpper', async () => {
|
|
201
|
+
// should be TLU but...hardhat
|
|
202
|
+
await expect(mint(wallet.address, 1, 0, 1)).to.be.reverted
|
|
203
|
+
})
|
|
204
|
+
it('fails if tickLower less than min tick', async () => {
|
|
205
|
+
// should be TLM but...hardhat
|
|
206
|
+
await expect(mint(wallet.address, -887273, 0, 1)).to.be.reverted
|
|
207
|
+
})
|
|
208
|
+
it('fails if tickUpper greater than max tick', async () => {
|
|
209
|
+
// should be TUM but...hardhat
|
|
210
|
+
await expect(mint(wallet.address, 0, 887273, 1)).to.be.reverted
|
|
211
|
+
})
|
|
212
|
+
it('fails if amount exceeds the max', async () => {
|
|
213
|
+
// these should fail with 'LO' but hardhat is bugged
|
|
214
|
+
const maxLiquidityGross = await pool.maxLiquidityPerTick()
|
|
215
|
+
await expect(mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, maxLiquidityGross.add(1))).to
|
|
216
|
+
.be.reverted
|
|
217
|
+
await expect(mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, maxLiquidityGross)).to.not.be
|
|
218
|
+
.reverted
|
|
219
|
+
})
|
|
220
|
+
it('fails if total amount at tick exceeds the max', async () => {
|
|
221
|
+
// these should fail with 'LO' but hardhat is bugged
|
|
222
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 1000)
|
|
223
|
+
|
|
224
|
+
const maxLiquidityGross = await pool.maxLiquidityPerTick()
|
|
225
|
+
await expect(
|
|
226
|
+
mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, maxLiquidityGross.sub(1000).add(1))
|
|
227
|
+
).to.be.reverted
|
|
228
|
+
await expect(
|
|
229
|
+
mint(wallet.address, minTick + tickSpacing * 2, maxTick - tickSpacing, maxLiquidityGross.sub(1000).add(1))
|
|
230
|
+
).to.be.reverted
|
|
231
|
+
await expect(
|
|
232
|
+
mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing * 2, maxLiquidityGross.sub(1000).add(1))
|
|
233
|
+
).to.be.reverted
|
|
234
|
+
await expect(mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, maxLiquidityGross.sub(1000)))
|
|
235
|
+
.to.not.be.reverted
|
|
236
|
+
})
|
|
237
|
+
it('fails if amount is 0', async () => {
|
|
238
|
+
await expect(mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 0)).to.be.reverted
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
describe('success cases', () => {
|
|
243
|
+
it('initial balances', async () => {
|
|
244
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996)
|
|
245
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('initial tick', async () => {
|
|
249
|
+
expect((await pool.slot0()).tick).to.eq(-23028)
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
describe('above current price', () => {
|
|
253
|
+
it('transfers token0 only', async () => {
|
|
254
|
+
await expect(mint(wallet.address, -22980, 0, 10000))
|
|
255
|
+
.to.emit(token0, 'Transfer')
|
|
256
|
+
.withArgs(wallet.address, pool.address, 21549)
|
|
257
|
+
.to.not.emit(token1, 'Transfer')
|
|
258
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996 + 21549)
|
|
259
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000)
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it('max tick with max leverage', async () => {
|
|
263
|
+
await mint(wallet.address, maxTick - tickSpacing, maxTick, BigNumber.from(2).pow(102))
|
|
264
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996 + 828011525)
|
|
265
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000)
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
it('works for max tick', async () => {
|
|
269
|
+
await expect(mint(wallet.address, -22980, maxTick, 10000))
|
|
270
|
+
.to.emit(token0, 'Transfer')
|
|
271
|
+
.withArgs(wallet.address, pool.address, 31549)
|
|
272
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996 + 31549)
|
|
273
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it('removing works', async () => {
|
|
277
|
+
await mint(wallet.address, -240, 0, 10000)
|
|
278
|
+
await pool.burn(-240, 0, 10000)
|
|
279
|
+
const { amount0, amount1 } = await pool.callStatic.collect(wallet.address, -240, 0, MaxUint128, MaxUint128)
|
|
280
|
+
expect(amount0, 'amount0').to.eq(120)
|
|
281
|
+
expect(amount1, 'amount1').to.eq(0)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('adds liquidity to liquidityGross', async () => {
|
|
285
|
+
await mint(wallet.address, -240, 0, 100)
|
|
286
|
+
expect((await pool.ticks(-240)).liquidityGross).to.eq(100)
|
|
287
|
+
expect((await pool.ticks(0)).liquidityGross).to.eq(100)
|
|
288
|
+
expect((await pool.ticks(tickSpacing)).liquidityGross).to.eq(0)
|
|
289
|
+
expect((await pool.ticks(tickSpacing * 2)).liquidityGross).to.eq(0)
|
|
290
|
+
await mint(wallet.address, -240, tickSpacing, 150)
|
|
291
|
+
expect((await pool.ticks(-240)).liquidityGross).to.eq(250)
|
|
292
|
+
expect((await pool.ticks(0)).liquidityGross).to.eq(100)
|
|
293
|
+
expect((await pool.ticks(tickSpacing)).liquidityGross).to.eq(150)
|
|
294
|
+
expect((await pool.ticks(tickSpacing * 2)).liquidityGross).to.eq(0)
|
|
295
|
+
await mint(wallet.address, 0, tickSpacing * 2, 60)
|
|
296
|
+
expect((await pool.ticks(-240)).liquidityGross).to.eq(250)
|
|
297
|
+
expect((await pool.ticks(0)).liquidityGross).to.eq(160)
|
|
298
|
+
expect((await pool.ticks(tickSpacing)).liquidityGross).to.eq(150)
|
|
299
|
+
expect((await pool.ticks(tickSpacing * 2)).liquidityGross).to.eq(60)
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
it('removes liquidity from liquidityGross', async () => {
|
|
303
|
+
await mint(wallet.address, -240, 0, 100)
|
|
304
|
+
await mint(wallet.address, -240, 0, 40)
|
|
305
|
+
await pool.burn(-240, 0, 90)
|
|
306
|
+
expect((await pool.ticks(-240)).liquidityGross).to.eq(50)
|
|
307
|
+
expect((await pool.ticks(0)).liquidityGross).to.eq(50)
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
it('clears tick lower if last position is removed', async () => {
|
|
311
|
+
await mint(wallet.address, -240, 0, 100)
|
|
312
|
+
await pool.burn(-240, 0, 100)
|
|
313
|
+
const { liquidityGross, feeGrowthOutside0X128, feeGrowthOutside1X128 } = await pool.ticks(-240)
|
|
314
|
+
expect(liquidityGross).to.eq(0)
|
|
315
|
+
expect(feeGrowthOutside0X128).to.eq(0)
|
|
316
|
+
expect(feeGrowthOutside1X128).to.eq(0)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
it('clears tick upper if last position is removed', async () => {
|
|
320
|
+
await mint(wallet.address, -240, 0, 100)
|
|
321
|
+
await pool.burn(-240, 0, 100)
|
|
322
|
+
const { liquidityGross, feeGrowthOutside0X128, feeGrowthOutside1X128 } = await pool.ticks(0)
|
|
323
|
+
expect(liquidityGross).to.eq(0)
|
|
324
|
+
expect(feeGrowthOutside0X128).to.eq(0)
|
|
325
|
+
expect(feeGrowthOutside1X128).to.eq(0)
|
|
326
|
+
})
|
|
327
|
+
it('only clears the tick that is not used at all', async () => {
|
|
328
|
+
await mint(wallet.address, -240, 0, 100)
|
|
329
|
+
await mint(wallet.address, -tickSpacing, 0, 250)
|
|
330
|
+
await pool.burn(-240, 0, 100)
|
|
331
|
+
|
|
332
|
+
let { liquidityGross, feeGrowthOutside0X128, feeGrowthOutside1X128 } = await pool.ticks(-240)
|
|
333
|
+
expect(liquidityGross).to.eq(0)
|
|
334
|
+
expect(feeGrowthOutside0X128).to.eq(0)
|
|
335
|
+
expect(feeGrowthOutside1X128).to.eq(0)
|
|
336
|
+
;({ liquidityGross, feeGrowthOutside0X128, feeGrowthOutside1X128 } = await pool.ticks(-tickSpacing))
|
|
337
|
+
expect(liquidityGross).to.eq(250)
|
|
338
|
+
expect(feeGrowthOutside0X128).to.eq(0)
|
|
339
|
+
expect(feeGrowthOutside1X128).to.eq(0)
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
it('does not write an observation', async () => {
|
|
343
|
+
checkObservationEquals(await pool.observations(0), {
|
|
344
|
+
tickCumulative: 0,
|
|
345
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
346
|
+
initialized: true,
|
|
347
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
348
|
+
})
|
|
349
|
+
await pool.advanceTime(1)
|
|
350
|
+
await mint(wallet.address, -240, 0, 100)
|
|
351
|
+
checkObservationEquals(await pool.observations(0), {
|
|
352
|
+
tickCumulative: 0,
|
|
353
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
354
|
+
initialized: true,
|
|
355
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
describe('including current price', () => {
|
|
361
|
+
it('price within range: transfers current price of both tokens', async () => {
|
|
362
|
+
await expect(mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 100))
|
|
363
|
+
.to.emit(token0, 'Transfer')
|
|
364
|
+
.withArgs(wallet.address, pool.address, 317)
|
|
365
|
+
.to.emit(token1, 'Transfer')
|
|
366
|
+
.withArgs(wallet.address, pool.address, 32)
|
|
367
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996 + 317)
|
|
368
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000 + 32)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
it('initializes lower tick', async () => {
|
|
372
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 100)
|
|
373
|
+
const { liquidityGross } = await pool.ticks(minTick + tickSpacing)
|
|
374
|
+
expect(liquidityGross).to.eq(100)
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
it('initializes upper tick', async () => {
|
|
378
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 100)
|
|
379
|
+
const { liquidityGross } = await pool.ticks(maxTick - tickSpacing)
|
|
380
|
+
expect(liquidityGross).to.eq(100)
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
it('works for min/max tick', async () => {
|
|
384
|
+
await expect(mint(wallet.address, minTick, maxTick, 10000))
|
|
385
|
+
.to.emit(token0, 'Transfer')
|
|
386
|
+
.withArgs(wallet.address, pool.address, 31623)
|
|
387
|
+
.to.emit(token1, 'Transfer')
|
|
388
|
+
.withArgs(wallet.address, pool.address, 3163)
|
|
389
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996 + 31623)
|
|
390
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000 + 3163)
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
it('removing works', async () => {
|
|
394
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 100)
|
|
395
|
+
await pool.burn(minTick + tickSpacing, maxTick - tickSpacing, 100)
|
|
396
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
397
|
+
wallet.address,
|
|
398
|
+
minTick + tickSpacing,
|
|
399
|
+
maxTick - tickSpacing,
|
|
400
|
+
MaxUint128,
|
|
401
|
+
MaxUint128
|
|
402
|
+
)
|
|
403
|
+
expect(amount0, 'amount0').to.eq(316)
|
|
404
|
+
expect(amount1, 'amount1').to.eq(31)
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
it('writes an observation', async () => {
|
|
408
|
+
checkObservationEquals(await pool.observations(0), {
|
|
409
|
+
tickCumulative: 0,
|
|
410
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
411
|
+
initialized: true,
|
|
412
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
413
|
+
})
|
|
414
|
+
await pool.advanceTime(1)
|
|
415
|
+
await mint(wallet.address, minTick, maxTick, 100)
|
|
416
|
+
checkObservationEquals(await pool.observations(0), {
|
|
417
|
+
tickCumulative: -23028,
|
|
418
|
+
blockTimestamp: TEST_POOL_START_TIME + 1,
|
|
419
|
+
initialized: true,
|
|
420
|
+
secondsPerLiquidityCumulativeX128: '107650226801941937191829992860413859',
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
describe('below current price', () => {
|
|
426
|
+
it('transfers token1 only', async () => {
|
|
427
|
+
await expect(mint(wallet.address, -46080, -23040, 10000))
|
|
428
|
+
.to.emit(token1, 'Transfer')
|
|
429
|
+
.withArgs(wallet.address, pool.address, 2162)
|
|
430
|
+
.to.not.emit(token0, 'Transfer')
|
|
431
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996)
|
|
432
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000 + 2162)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
it('min tick with max leverage', async () => {
|
|
436
|
+
await mint(wallet.address, minTick, minTick + tickSpacing, BigNumber.from(2).pow(102))
|
|
437
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996)
|
|
438
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000 + 828011520)
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
it('works for min tick', async () => {
|
|
442
|
+
await expect(mint(wallet.address, minTick, -23040, 10000))
|
|
443
|
+
.to.emit(token1, 'Transfer')
|
|
444
|
+
.withArgs(wallet.address, pool.address, 3161)
|
|
445
|
+
expect(await token0.balanceOf(pool.address)).to.eq(9996)
|
|
446
|
+
expect(await token1.balanceOf(pool.address)).to.eq(1000 + 3161)
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
it('removing works', async () => {
|
|
450
|
+
await mint(wallet.address, -46080, -46020, 10000)
|
|
451
|
+
await pool.burn(-46080, -46020, 10000)
|
|
452
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
453
|
+
wallet.address,
|
|
454
|
+
-46080,
|
|
455
|
+
-46020,
|
|
456
|
+
MaxUint128,
|
|
457
|
+
MaxUint128
|
|
458
|
+
)
|
|
459
|
+
expect(amount0, 'amount0').to.eq(0)
|
|
460
|
+
expect(amount1, 'amount1').to.eq(3)
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
it('does not write an observation', async () => {
|
|
464
|
+
checkObservationEquals(await pool.observations(0), {
|
|
465
|
+
tickCumulative: 0,
|
|
466
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
467
|
+
initialized: true,
|
|
468
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
469
|
+
})
|
|
470
|
+
await pool.advanceTime(1)
|
|
471
|
+
await mint(wallet.address, -46080, -23040, 100)
|
|
472
|
+
checkObservationEquals(await pool.observations(0), {
|
|
473
|
+
tickCumulative: 0,
|
|
474
|
+
blockTimestamp: TEST_POOL_START_TIME,
|
|
475
|
+
initialized: true,
|
|
476
|
+
secondsPerLiquidityCumulativeX128: 0,
|
|
477
|
+
})
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
it('protocol fees accumulate as expected during swap', async () => {
|
|
483
|
+
await pool.setFeeProtocol(6, 6)
|
|
484
|
+
|
|
485
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, expandTo18Decimals(1))
|
|
486
|
+
await swapExact0For1(expandTo18Decimals(1).div(10), wallet.address)
|
|
487
|
+
await swapExact1For0(expandTo18Decimals(1).div(100), wallet.address)
|
|
488
|
+
|
|
489
|
+
let { token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees()
|
|
490
|
+
expect(token0ProtocolFees).to.eq('50000000000000')
|
|
491
|
+
expect(token1ProtocolFees).to.eq('5000000000000')
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
it('positions are protected before protocol fee is turned on', async () => {
|
|
495
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, expandTo18Decimals(1))
|
|
496
|
+
await swapExact0For1(expandTo18Decimals(1).div(10), wallet.address)
|
|
497
|
+
await swapExact1For0(expandTo18Decimals(1).div(100), wallet.address)
|
|
498
|
+
|
|
499
|
+
let { token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees()
|
|
500
|
+
expect(token0ProtocolFees).to.eq(0)
|
|
501
|
+
expect(token1ProtocolFees).to.eq(0)
|
|
502
|
+
|
|
503
|
+
await pool.setFeeProtocol(6, 6)
|
|
504
|
+
;({ token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees())
|
|
505
|
+
expect(token0ProtocolFees).to.eq(0)
|
|
506
|
+
expect(token1ProtocolFees).to.eq(0)
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
it('poke is not allowed on uninitialized position', async () => {
|
|
510
|
+
await mint(other.address, minTick + tickSpacing, maxTick - tickSpacing, expandTo18Decimals(1))
|
|
511
|
+
await swapExact0For1(expandTo18Decimals(1).div(10), wallet.address)
|
|
512
|
+
await swapExact1For0(expandTo18Decimals(1).div(100), wallet.address)
|
|
513
|
+
|
|
514
|
+
// missing revert reason due to hardhat
|
|
515
|
+
await expect(pool.burn(minTick + tickSpacing, maxTick - tickSpacing, 0)).to.be.reverted
|
|
516
|
+
|
|
517
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, 1)
|
|
518
|
+
let {
|
|
519
|
+
liquidity,
|
|
520
|
+
feeGrowthInside0LastX128,
|
|
521
|
+
feeGrowthInside1LastX128,
|
|
522
|
+
tokensOwed1,
|
|
523
|
+
tokensOwed0,
|
|
524
|
+
} = await pool.positions(getPositionKey(wallet.address, minTick + tickSpacing, maxTick - tickSpacing))
|
|
525
|
+
expect(liquidity).to.eq(1)
|
|
526
|
+
expect(feeGrowthInside0LastX128).to.eq('102084710076281216349243831104605583')
|
|
527
|
+
expect(feeGrowthInside1LastX128).to.eq('10208471007628121634924383110460558')
|
|
528
|
+
expect(tokensOwed0, 'tokens owed 0 before').to.eq(0)
|
|
529
|
+
expect(tokensOwed1, 'tokens owed 1 before').to.eq(0)
|
|
530
|
+
|
|
531
|
+
await pool.burn(minTick + tickSpacing, maxTick - tickSpacing, 1)
|
|
532
|
+
;({
|
|
533
|
+
liquidity,
|
|
534
|
+
feeGrowthInside0LastX128,
|
|
535
|
+
feeGrowthInside1LastX128,
|
|
536
|
+
tokensOwed1,
|
|
537
|
+
tokensOwed0,
|
|
538
|
+
} = await pool.positions(getPositionKey(wallet.address, minTick + tickSpacing, maxTick - tickSpacing)))
|
|
539
|
+
expect(liquidity).to.eq(0)
|
|
540
|
+
expect(feeGrowthInside0LastX128).to.eq('102084710076281216349243831104605583')
|
|
541
|
+
expect(feeGrowthInside1LastX128).to.eq('10208471007628121634924383110460558')
|
|
542
|
+
expect(tokensOwed0, 'tokens owed 0 after').to.eq(3)
|
|
543
|
+
expect(tokensOwed1, 'tokens owed 1 after').to.eq(0)
|
|
544
|
+
})
|
|
545
|
+
})
|
|
546
|
+
})
|
|
547
|
+
|
|
548
|
+
describe('#burn', () => {
|
|
549
|
+
beforeEach('initialize at zero tick', () => initializeAtZeroTick(pool))
|
|
550
|
+
|
|
551
|
+
async function checkTickIsClear(tick: number) {
|
|
552
|
+
const { liquidityGross, feeGrowthOutside0X128, feeGrowthOutside1X128, liquidityNet } = await pool.ticks(tick)
|
|
553
|
+
expect(liquidityGross).to.eq(0)
|
|
554
|
+
expect(feeGrowthOutside0X128).to.eq(0)
|
|
555
|
+
expect(feeGrowthOutside1X128).to.eq(0)
|
|
556
|
+
expect(liquidityNet).to.eq(0)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async function checkTickIsNotClear(tick: number) {
|
|
560
|
+
const { liquidityGross } = await pool.ticks(tick)
|
|
561
|
+
expect(liquidityGross).to.not.eq(0)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
it('does not clear the position fee growth snapshot if no more liquidity', async () => {
|
|
565
|
+
// some activity that would make the ticks non-zero
|
|
566
|
+
await pool.advanceTime(10)
|
|
567
|
+
await mint(other.address, minTick, maxTick, expandTo18Decimals(1))
|
|
568
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
569
|
+
await swapExact1For0(expandTo18Decimals(1), wallet.address)
|
|
570
|
+
await pool.connect(other).burn(minTick, maxTick, expandTo18Decimals(1))
|
|
571
|
+
const {
|
|
572
|
+
liquidity,
|
|
573
|
+
tokensOwed0,
|
|
574
|
+
tokensOwed1,
|
|
575
|
+
feeGrowthInside0LastX128,
|
|
576
|
+
feeGrowthInside1LastX128,
|
|
577
|
+
} = await pool.positions(getPositionKey(other.address, minTick, maxTick))
|
|
578
|
+
expect(liquidity).to.eq(0)
|
|
579
|
+
expect(tokensOwed0).to.not.eq(0)
|
|
580
|
+
expect(tokensOwed1).to.not.eq(0)
|
|
581
|
+
expect(feeGrowthInside0LastX128).to.eq('340282366920938463463374607431768211')
|
|
582
|
+
expect(feeGrowthInside1LastX128).to.eq('340282366920938576890830247744589365')
|
|
583
|
+
})
|
|
584
|
+
|
|
585
|
+
it('clears the tick if its the last position using it', async () => {
|
|
586
|
+
const tickLower = minTick + tickSpacing
|
|
587
|
+
const tickUpper = maxTick - tickSpacing
|
|
588
|
+
// some activity that would make the ticks non-zero
|
|
589
|
+
await pool.advanceTime(10)
|
|
590
|
+
await mint(wallet.address, tickLower, tickUpper, 1)
|
|
591
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
592
|
+
await pool.burn(tickLower, tickUpper, 1)
|
|
593
|
+
await checkTickIsClear(tickLower)
|
|
594
|
+
await checkTickIsClear(tickUpper)
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
it('clears only the lower tick if upper is still used', async () => {
|
|
598
|
+
const tickLower = minTick + tickSpacing
|
|
599
|
+
const tickUpper = maxTick - tickSpacing
|
|
600
|
+
// some activity that would make the ticks non-zero
|
|
601
|
+
await pool.advanceTime(10)
|
|
602
|
+
await mint(wallet.address, tickLower, tickUpper, 1)
|
|
603
|
+
await mint(wallet.address, tickLower + tickSpacing, tickUpper, 1)
|
|
604
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
605
|
+
await pool.burn(tickLower, tickUpper, 1)
|
|
606
|
+
await checkTickIsClear(tickLower)
|
|
607
|
+
await checkTickIsNotClear(tickUpper)
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
it('clears only the upper tick if lower is still used', async () => {
|
|
611
|
+
const tickLower = minTick + tickSpacing
|
|
612
|
+
const tickUpper = maxTick - tickSpacing
|
|
613
|
+
// some activity that would make the ticks non-zero
|
|
614
|
+
await pool.advanceTime(10)
|
|
615
|
+
await mint(wallet.address, tickLower, tickUpper, 1)
|
|
616
|
+
await mint(wallet.address, tickLower, tickUpper - tickSpacing, 1)
|
|
617
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
618
|
+
await pool.burn(tickLower, tickUpper, 1)
|
|
619
|
+
await checkTickIsNotClear(tickLower)
|
|
620
|
+
await checkTickIsClear(tickUpper)
|
|
621
|
+
})
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
// the combined amount of liquidity that the pool is initialized with (including the 1 minimum liquidity that is burned)
|
|
625
|
+
const initializeLiquidityAmount = expandTo18Decimals(2)
|
|
626
|
+
async function initializeAtZeroTick(pool: MockTimeUniswapV3Pool): Promise<void> {
|
|
627
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
628
|
+
const tickSpacing = await pool.tickSpacing()
|
|
629
|
+
const [min, max] = [getMinTick(tickSpacing), getMaxTick(tickSpacing)]
|
|
630
|
+
await mint(wallet.address, min, max, initializeLiquidityAmount)
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
describe('#observe', () => {
|
|
634
|
+
beforeEach(() => initializeAtZeroTick(pool))
|
|
635
|
+
|
|
636
|
+
// zero tick
|
|
637
|
+
it('current tick accumulator increases by tick over time', async () => {
|
|
638
|
+
let {
|
|
639
|
+
tickCumulatives: [tickCumulative],
|
|
640
|
+
} = await pool.observe([0])
|
|
641
|
+
expect(tickCumulative).to.eq(0)
|
|
642
|
+
await pool.advanceTime(10)
|
|
643
|
+
;({
|
|
644
|
+
tickCumulatives: [tickCumulative],
|
|
645
|
+
} = await pool.observe([0]))
|
|
646
|
+
expect(tickCumulative).to.eq(0)
|
|
647
|
+
})
|
|
648
|
+
|
|
649
|
+
it('current tick accumulator after single swap', async () => {
|
|
650
|
+
// moves to tick -1
|
|
651
|
+
await swapExact0For1(1000, wallet.address)
|
|
652
|
+
await pool.advanceTime(4)
|
|
653
|
+
let {
|
|
654
|
+
tickCumulatives: [tickCumulative],
|
|
655
|
+
} = await pool.observe([0])
|
|
656
|
+
expect(tickCumulative).to.eq(-4)
|
|
657
|
+
})
|
|
658
|
+
|
|
659
|
+
it('current tick accumulator after two swaps', async () => {
|
|
660
|
+
await swapExact0For1(expandTo18Decimals(1).div(2), wallet.address)
|
|
661
|
+
expect((await pool.slot0()).tick).to.eq(-4452)
|
|
662
|
+
await pool.advanceTime(4)
|
|
663
|
+
await swapExact1For0(expandTo18Decimals(1).div(4), wallet.address)
|
|
664
|
+
expect((await pool.slot0()).tick).to.eq(-1558)
|
|
665
|
+
await pool.advanceTime(6)
|
|
666
|
+
let {
|
|
667
|
+
tickCumulatives: [tickCumulative],
|
|
668
|
+
} = await pool.observe([0])
|
|
669
|
+
// -4452*4 + -1558*6
|
|
670
|
+
expect(tickCumulative).to.eq(-27156)
|
|
671
|
+
})
|
|
672
|
+
})
|
|
673
|
+
|
|
674
|
+
describe('miscellaneous mint tests', () => {
|
|
675
|
+
beforeEach('initialize at zero tick', async () => {
|
|
676
|
+
pool = await createPool(FeeAmount.LOW, TICK_SPACINGS[FeeAmount.LOW])
|
|
677
|
+
await initializeAtZeroTick(pool)
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('mint to the right of the current price', async () => {
|
|
681
|
+
const liquidityDelta = 1000
|
|
682
|
+
const lowerTick = tickSpacing
|
|
683
|
+
const upperTick = tickSpacing * 2
|
|
684
|
+
|
|
685
|
+
const liquidityBefore = await pool.liquidity()
|
|
686
|
+
|
|
687
|
+
const b0 = await token0.balanceOf(pool.address)
|
|
688
|
+
const b1 = await token1.balanceOf(pool.address)
|
|
689
|
+
|
|
690
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
691
|
+
|
|
692
|
+
const liquidityAfter = await pool.liquidity()
|
|
693
|
+
expect(liquidityAfter).to.be.gte(liquidityBefore)
|
|
694
|
+
|
|
695
|
+
expect((await token0.balanceOf(pool.address)).sub(b0)).to.eq(1)
|
|
696
|
+
expect((await token1.balanceOf(pool.address)).sub(b1)).to.eq(0)
|
|
697
|
+
})
|
|
698
|
+
|
|
699
|
+
it('mint to the left of the current price', async () => {
|
|
700
|
+
const liquidityDelta = 1000
|
|
701
|
+
const lowerTick = -tickSpacing * 2
|
|
702
|
+
const upperTick = -tickSpacing
|
|
703
|
+
|
|
704
|
+
const liquidityBefore = await pool.liquidity()
|
|
705
|
+
|
|
706
|
+
const b0 = await token0.balanceOf(pool.address)
|
|
707
|
+
const b1 = await token1.balanceOf(pool.address)
|
|
708
|
+
|
|
709
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
710
|
+
|
|
711
|
+
const liquidityAfter = await pool.liquidity()
|
|
712
|
+
expect(liquidityAfter).to.be.gte(liquidityBefore)
|
|
713
|
+
|
|
714
|
+
expect((await token0.balanceOf(pool.address)).sub(b0)).to.eq(0)
|
|
715
|
+
expect((await token1.balanceOf(pool.address)).sub(b1)).to.eq(1)
|
|
716
|
+
})
|
|
717
|
+
|
|
718
|
+
it('mint within the current price', async () => {
|
|
719
|
+
const liquidityDelta = 1000
|
|
720
|
+
const lowerTick = -tickSpacing
|
|
721
|
+
const upperTick = tickSpacing
|
|
722
|
+
|
|
723
|
+
const liquidityBefore = await pool.liquidity()
|
|
724
|
+
|
|
725
|
+
const b0 = await token0.balanceOf(pool.address)
|
|
726
|
+
const b1 = await token1.balanceOf(pool.address)
|
|
727
|
+
|
|
728
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
729
|
+
|
|
730
|
+
const liquidityAfter = await pool.liquidity()
|
|
731
|
+
expect(liquidityAfter).to.be.gte(liquidityBefore)
|
|
732
|
+
|
|
733
|
+
expect((await token0.balanceOf(pool.address)).sub(b0)).to.eq(1)
|
|
734
|
+
expect((await token1.balanceOf(pool.address)).sub(b1)).to.eq(1)
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
it('cannot remove more than the entire position', async () => {
|
|
738
|
+
const lowerTick = -tickSpacing
|
|
739
|
+
const upperTick = tickSpacing
|
|
740
|
+
await mint(wallet.address, lowerTick, upperTick, expandTo18Decimals(1000))
|
|
741
|
+
// should be 'LS', hardhat is bugged
|
|
742
|
+
await expect(pool.burn(lowerTick, upperTick, expandTo18Decimals(1001))).to.be.reverted
|
|
743
|
+
})
|
|
744
|
+
|
|
745
|
+
it('collect fees within the current price after swap', async () => {
|
|
746
|
+
const liquidityDelta = expandTo18Decimals(100)
|
|
747
|
+
const lowerTick = -tickSpacing * 100
|
|
748
|
+
const upperTick = tickSpacing * 100
|
|
749
|
+
|
|
750
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
751
|
+
|
|
752
|
+
const liquidityBefore = await pool.liquidity()
|
|
753
|
+
|
|
754
|
+
const amount0In = expandTo18Decimals(1)
|
|
755
|
+
await swapExact0For1(amount0In, wallet.address)
|
|
756
|
+
|
|
757
|
+
const liquidityAfter = await pool.liquidity()
|
|
758
|
+
expect(liquidityAfter, 'k increases').to.be.gte(liquidityBefore)
|
|
759
|
+
|
|
760
|
+
const token0BalanceBeforePool = await token0.balanceOf(pool.address)
|
|
761
|
+
const token1BalanceBeforePool = await token1.balanceOf(pool.address)
|
|
762
|
+
const token0BalanceBeforeWallet = await token0.balanceOf(wallet.address)
|
|
763
|
+
const token1BalanceBeforeWallet = await token1.balanceOf(wallet.address)
|
|
764
|
+
|
|
765
|
+
await pool.burn(lowerTick, upperTick, 0)
|
|
766
|
+
await pool.collect(wallet.address, lowerTick, upperTick, MaxUint128, MaxUint128)
|
|
767
|
+
|
|
768
|
+
await pool.burn(lowerTick, upperTick, 0)
|
|
769
|
+
const { amount0: fees0, amount1: fees1 } = await pool.callStatic.collect(
|
|
770
|
+
wallet.address,
|
|
771
|
+
lowerTick,
|
|
772
|
+
upperTick,
|
|
773
|
+
MaxUint128,
|
|
774
|
+
MaxUint128
|
|
775
|
+
)
|
|
776
|
+
expect(fees0).to.be.eq(0)
|
|
777
|
+
expect(fees1).to.be.eq(0)
|
|
778
|
+
|
|
779
|
+
const token0BalanceAfterWallet = await token0.balanceOf(wallet.address)
|
|
780
|
+
const token1BalanceAfterWallet = await token1.balanceOf(wallet.address)
|
|
781
|
+
const token0BalanceAfterPool = await token0.balanceOf(pool.address)
|
|
782
|
+
const token1BalanceAfterPool = await token1.balanceOf(pool.address)
|
|
783
|
+
|
|
784
|
+
expect(token0BalanceAfterWallet).to.be.gt(token0BalanceBeforeWallet)
|
|
785
|
+
expect(token1BalanceAfterWallet).to.be.eq(token1BalanceBeforeWallet)
|
|
786
|
+
|
|
787
|
+
expect(token0BalanceAfterPool).to.be.lt(token0BalanceBeforePool)
|
|
788
|
+
expect(token1BalanceAfterPool).to.be.eq(token1BalanceBeforePool)
|
|
789
|
+
})
|
|
790
|
+
})
|
|
791
|
+
|
|
792
|
+
describe('post-initialize at medium fee', () => {
|
|
793
|
+
describe('k (implicit)', () => {
|
|
794
|
+
it('returns 0 before initialization', async () => {
|
|
795
|
+
expect(await pool.liquidity()).to.eq(0)
|
|
796
|
+
})
|
|
797
|
+
describe('post initialized', () => {
|
|
798
|
+
beforeEach(() => initializeAtZeroTick(pool))
|
|
799
|
+
|
|
800
|
+
it('returns initial liquidity', async () => {
|
|
801
|
+
expect(await pool.liquidity()).to.eq(expandTo18Decimals(2))
|
|
802
|
+
})
|
|
803
|
+
it('returns in supply in range', async () => {
|
|
804
|
+
await mint(wallet.address, -tickSpacing, tickSpacing, expandTo18Decimals(3))
|
|
805
|
+
expect(await pool.liquidity()).to.eq(expandTo18Decimals(5))
|
|
806
|
+
})
|
|
807
|
+
it('excludes supply at tick above current tick', async () => {
|
|
808
|
+
await mint(wallet.address, tickSpacing, tickSpacing * 2, expandTo18Decimals(3))
|
|
809
|
+
expect(await pool.liquidity()).to.eq(expandTo18Decimals(2))
|
|
810
|
+
})
|
|
811
|
+
it('excludes supply at tick below current tick', async () => {
|
|
812
|
+
await mint(wallet.address, -tickSpacing * 2, -tickSpacing, expandTo18Decimals(3))
|
|
813
|
+
expect(await pool.liquidity()).to.eq(expandTo18Decimals(2))
|
|
814
|
+
})
|
|
815
|
+
it('updates correctly when exiting range', async () => {
|
|
816
|
+
const kBefore = await pool.liquidity()
|
|
817
|
+
expect(kBefore).to.be.eq(expandTo18Decimals(2))
|
|
818
|
+
|
|
819
|
+
// add liquidity at and above current tick
|
|
820
|
+
const liquidityDelta = expandTo18Decimals(1)
|
|
821
|
+
const lowerTick = 0
|
|
822
|
+
const upperTick = tickSpacing
|
|
823
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
824
|
+
|
|
825
|
+
// ensure virtual supply has increased appropriately
|
|
826
|
+
const kAfter = await pool.liquidity()
|
|
827
|
+
expect(kAfter).to.be.eq(expandTo18Decimals(3))
|
|
828
|
+
|
|
829
|
+
// swap toward the left (just enough for the tick transition function to trigger)
|
|
830
|
+
await swapExact0For1(1, wallet.address)
|
|
831
|
+
const { tick } = await pool.slot0()
|
|
832
|
+
expect(tick).to.be.eq(-1)
|
|
833
|
+
|
|
834
|
+
const kAfterSwap = await pool.liquidity()
|
|
835
|
+
expect(kAfterSwap).to.be.eq(expandTo18Decimals(2))
|
|
836
|
+
})
|
|
837
|
+
it('updates correctly when entering range', async () => {
|
|
838
|
+
const kBefore = await pool.liquidity()
|
|
839
|
+
expect(kBefore).to.be.eq(expandTo18Decimals(2))
|
|
840
|
+
|
|
841
|
+
// add liquidity below the current tick
|
|
842
|
+
const liquidityDelta = expandTo18Decimals(1)
|
|
843
|
+
const lowerTick = -tickSpacing
|
|
844
|
+
const upperTick = 0
|
|
845
|
+
await mint(wallet.address, lowerTick, upperTick, liquidityDelta)
|
|
846
|
+
|
|
847
|
+
// ensure virtual supply hasn't changed
|
|
848
|
+
const kAfter = await pool.liquidity()
|
|
849
|
+
expect(kAfter).to.be.eq(kBefore)
|
|
850
|
+
|
|
851
|
+
// swap toward the left (just enough for the tick transition function to trigger)
|
|
852
|
+
await swapExact0For1(1, wallet.address)
|
|
853
|
+
const { tick } = await pool.slot0()
|
|
854
|
+
expect(tick).to.be.eq(-1)
|
|
855
|
+
|
|
856
|
+
const kAfterSwap = await pool.liquidity()
|
|
857
|
+
expect(kAfterSwap).to.be.eq(expandTo18Decimals(3))
|
|
858
|
+
})
|
|
859
|
+
})
|
|
860
|
+
})
|
|
861
|
+
})
|
|
862
|
+
|
|
863
|
+
describe('limit orders', () => {
|
|
864
|
+
beforeEach('initialize at tick 0', () => initializeAtZeroTick(pool))
|
|
865
|
+
|
|
866
|
+
it('limit selling 0 for 1 at tick 0 thru 1', async () => {
|
|
867
|
+
await expect(mint(wallet.address, 0, 120, expandTo18Decimals(1)))
|
|
868
|
+
.to.emit(token0, 'Transfer')
|
|
869
|
+
.withArgs(wallet.address, pool.address, '5981737760509663')
|
|
870
|
+
// somebody takes the limit order
|
|
871
|
+
await swapExact1For0(expandTo18Decimals(2), other.address)
|
|
872
|
+
await expect(pool.burn(0, 120, expandTo18Decimals(1)))
|
|
873
|
+
.to.emit(pool, 'Burn')
|
|
874
|
+
.withArgs(wallet.address, 0, 120, expandTo18Decimals(1), 0, '6017734268818165')
|
|
875
|
+
.to.not.emit(token0, 'Transfer')
|
|
876
|
+
.to.not.emit(token1, 'Transfer')
|
|
877
|
+
await expect(pool.collect(wallet.address, 0, 120, MaxUint128, MaxUint128))
|
|
878
|
+
.to.emit(token1, 'Transfer')
|
|
879
|
+
.withArgs(pool.address, wallet.address, BigNumber.from('6017734268818165').add('18107525382602')) // roughly 0.3% despite other liquidity
|
|
880
|
+
.to.not.emit(token0, 'Transfer')
|
|
881
|
+
expect((await pool.slot0()).tick).to.be.gte(120)
|
|
882
|
+
})
|
|
883
|
+
it('limit selling 1 for 0 at tick 0 thru -1', async () => {
|
|
884
|
+
await expect(mint(wallet.address, -120, 0, expandTo18Decimals(1)))
|
|
885
|
+
.to.emit(token1, 'Transfer')
|
|
886
|
+
.withArgs(wallet.address, pool.address, '5981737760509663')
|
|
887
|
+
// somebody takes the limit order
|
|
888
|
+
await swapExact0For1(expandTo18Decimals(2), other.address)
|
|
889
|
+
await expect(pool.burn(-120, 0, expandTo18Decimals(1)))
|
|
890
|
+
.to.emit(pool, 'Burn')
|
|
891
|
+
.withArgs(wallet.address, -120, 0, expandTo18Decimals(1), '6017734268818165', 0)
|
|
892
|
+
.to.not.emit(token0, 'Transfer')
|
|
893
|
+
.to.not.emit(token1, 'Transfer')
|
|
894
|
+
await expect(pool.collect(wallet.address, -120, 0, MaxUint128, MaxUint128))
|
|
895
|
+
.to.emit(token0, 'Transfer')
|
|
896
|
+
.withArgs(pool.address, wallet.address, BigNumber.from('6017734268818165').add('18107525382602')) // roughly 0.3% despite other liquidity
|
|
897
|
+
expect((await pool.slot0()).tick).to.be.lt(-120)
|
|
898
|
+
})
|
|
899
|
+
|
|
900
|
+
describe('fee is on', () => {
|
|
901
|
+
beforeEach(() => pool.setFeeProtocol(6, 6))
|
|
902
|
+
it('limit selling 0 for 1 at tick 0 thru 1', async () => {
|
|
903
|
+
await expect(mint(wallet.address, 0, 120, expandTo18Decimals(1)))
|
|
904
|
+
.to.emit(token0, 'Transfer')
|
|
905
|
+
.withArgs(wallet.address, pool.address, '5981737760509663')
|
|
906
|
+
// somebody takes the limit order
|
|
907
|
+
await swapExact1For0(expandTo18Decimals(2), other.address)
|
|
908
|
+
await expect(pool.burn(0, 120, expandTo18Decimals(1)))
|
|
909
|
+
.to.emit(pool, 'Burn')
|
|
910
|
+
.withArgs(wallet.address, 0, 120, expandTo18Decimals(1), 0, '6017734268818165')
|
|
911
|
+
.to.not.emit(token0, 'Transfer')
|
|
912
|
+
.to.not.emit(token1, 'Transfer')
|
|
913
|
+
await expect(pool.collect(wallet.address, 0, 120, MaxUint128, MaxUint128))
|
|
914
|
+
.to.emit(token1, 'Transfer')
|
|
915
|
+
.withArgs(pool.address, wallet.address, BigNumber.from('6017734268818165').add('15089604485501')) // roughly 0.25% despite other liquidity
|
|
916
|
+
.to.not.emit(token0, 'Transfer')
|
|
917
|
+
expect((await pool.slot0()).tick).to.be.gte(120)
|
|
918
|
+
})
|
|
919
|
+
it('limit selling 1 for 0 at tick 0 thru -1', async () => {
|
|
920
|
+
await expect(mint(wallet.address, -120, 0, expandTo18Decimals(1)))
|
|
921
|
+
.to.emit(token1, 'Transfer')
|
|
922
|
+
.withArgs(wallet.address, pool.address, '5981737760509663')
|
|
923
|
+
// somebody takes the limit order
|
|
924
|
+
await swapExact0For1(expandTo18Decimals(2), other.address)
|
|
925
|
+
await expect(pool.burn(-120, 0, expandTo18Decimals(1)))
|
|
926
|
+
.to.emit(pool, 'Burn')
|
|
927
|
+
.withArgs(wallet.address, -120, 0, expandTo18Decimals(1), '6017734268818165', 0)
|
|
928
|
+
.to.not.emit(token0, 'Transfer')
|
|
929
|
+
.to.not.emit(token1, 'Transfer')
|
|
930
|
+
await expect(pool.collect(wallet.address, -120, 0, MaxUint128, MaxUint128))
|
|
931
|
+
.to.emit(token0, 'Transfer')
|
|
932
|
+
.withArgs(pool.address, wallet.address, BigNumber.from('6017734268818165').add('15089604485501')) // roughly 0.25% despite other liquidity
|
|
933
|
+
expect((await pool.slot0()).tick).to.be.lt(-120)
|
|
934
|
+
})
|
|
935
|
+
})
|
|
936
|
+
})
|
|
937
|
+
|
|
938
|
+
describe('#collect', () => {
|
|
939
|
+
beforeEach(async () => {
|
|
940
|
+
pool = await createPool(FeeAmount.LOW, TICK_SPACINGS[FeeAmount.LOW])
|
|
941
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
942
|
+
})
|
|
943
|
+
|
|
944
|
+
it('works with multiple LPs', async () => {
|
|
945
|
+
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(1))
|
|
946
|
+
await mint(wallet.address, minTick + tickSpacing, maxTick - tickSpacing, expandTo18Decimals(2))
|
|
947
|
+
|
|
948
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
949
|
+
|
|
950
|
+
// poke positions
|
|
951
|
+
await pool.burn(minTick, maxTick, 0)
|
|
952
|
+
await pool.burn(minTick + tickSpacing, maxTick - tickSpacing, 0)
|
|
953
|
+
|
|
954
|
+
const { tokensOwed0: tokensOwed0Position0 } = await pool.positions(
|
|
955
|
+
getPositionKey(wallet.address, minTick, maxTick)
|
|
956
|
+
)
|
|
957
|
+
const { tokensOwed0: tokensOwed0Position1 } = await pool.positions(
|
|
958
|
+
getPositionKey(wallet.address, minTick + tickSpacing, maxTick - tickSpacing)
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
expect(tokensOwed0Position0).to.be.eq('166666666666667')
|
|
962
|
+
expect(tokensOwed0Position1).to.be.eq('333333333333334')
|
|
963
|
+
})
|
|
964
|
+
|
|
965
|
+
describe('works across large increases', () => {
|
|
966
|
+
beforeEach(async () => {
|
|
967
|
+
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(1))
|
|
968
|
+
})
|
|
969
|
+
|
|
970
|
+
// type(uint128).max * 2**128 / 1e18
|
|
971
|
+
// https://www.wolframalpha.com/input/?i=%282**128+-+1%29+*+2**128+%2F+1e18
|
|
972
|
+
const magicNumber = BigNumber.from('115792089237316195423570985008687907852929702298719625575994')
|
|
973
|
+
|
|
974
|
+
it('works just before the cap binds', async () => {
|
|
975
|
+
await pool.setFeeGrowthGlobal0X128(magicNumber)
|
|
976
|
+
await pool.burn(minTick, maxTick, 0)
|
|
977
|
+
|
|
978
|
+
const { tokensOwed0, tokensOwed1 } = await pool.positions(getPositionKey(wallet.address, minTick, maxTick))
|
|
979
|
+
|
|
980
|
+
expect(tokensOwed0).to.be.eq(MaxUint128.sub(1))
|
|
981
|
+
expect(tokensOwed1).to.be.eq(0)
|
|
982
|
+
})
|
|
983
|
+
|
|
984
|
+
it('works just after the cap binds', async () => {
|
|
985
|
+
await pool.setFeeGrowthGlobal0X128(magicNumber.add(1))
|
|
986
|
+
await pool.burn(minTick, maxTick, 0)
|
|
987
|
+
|
|
988
|
+
const { tokensOwed0, tokensOwed1 } = await pool.positions(getPositionKey(wallet.address, minTick, maxTick))
|
|
989
|
+
|
|
990
|
+
expect(tokensOwed0).to.be.eq(MaxUint128)
|
|
991
|
+
expect(tokensOwed1).to.be.eq(0)
|
|
992
|
+
})
|
|
993
|
+
|
|
994
|
+
it('works well after the cap binds', async () => {
|
|
995
|
+
await pool.setFeeGrowthGlobal0X128(constants.MaxUint256)
|
|
996
|
+
await pool.burn(minTick, maxTick, 0)
|
|
997
|
+
|
|
998
|
+
const { tokensOwed0, tokensOwed1 } = await pool.positions(getPositionKey(wallet.address, minTick, maxTick))
|
|
999
|
+
|
|
1000
|
+
expect(tokensOwed0).to.be.eq(MaxUint128)
|
|
1001
|
+
expect(tokensOwed1).to.be.eq(0)
|
|
1002
|
+
})
|
|
1003
|
+
})
|
|
1004
|
+
|
|
1005
|
+
describe('works across overflow boundaries', () => {
|
|
1006
|
+
beforeEach(async () => {
|
|
1007
|
+
await pool.setFeeGrowthGlobal0X128(constants.MaxUint256)
|
|
1008
|
+
await pool.setFeeGrowthGlobal1X128(constants.MaxUint256)
|
|
1009
|
+
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(10))
|
|
1010
|
+
})
|
|
1011
|
+
|
|
1012
|
+
it('token0', async () => {
|
|
1013
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
1014
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1015
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1016
|
+
wallet.address,
|
|
1017
|
+
minTick,
|
|
1018
|
+
maxTick,
|
|
1019
|
+
MaxUint128,
|
|
1020
|
+
MaxUint128
|
|
1021
|
+
)
|
|
1022
|
+
expect(amount0).to.be.eq('499999999999999')
|
|
1023
|
+
expect(amount1).to.be.eq(0)
|
|
1024
|
+
})
|
|
1025
|
+
it('token1', async () => {
|
|
1026
|
+
await swapExact1For0(expandTo18Decimals(1), wallet.address)
|
|
1027
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1028
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1029
|
+
wallet.address,
|
|
1030
|
+
minTick,
|
|
1031
|
+
maxTick,
|
|
1032
|
+
MaxUint128,
|
|
1033
|
+
MaxUint128
|
|
1034
|
+
)
|
|
1035
|
+
expect(amount0).to.be.eq(0)
|
|
1036
|
+
expect(amount1).to.be.eq('499999999999999')
|
|
1037
|
+
})
|
|
1038
|
+
it('token0 and token1', async () => {
|
|
1039
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
1040
|
+
await swapExact1For0(expandTo18Decimals(1), wallet.address)
|
|
1041
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1042
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1043
|
+
wallet.address,
|
|
1044
|
+
minTick,
|
|
1045
|
+
maxTick,
|
|
1046
|
+
MaxUint128,
|
|
1047
|
+
MaxUint128
|
|
1048
|
+
)
|
|
1049
|
+
expect(amount0).to.be.eq('499999999999999')
|
|
1050
|
+
expect(amount1).to.be.eq('500000000000000')
|
|
1051
|
+
})
|
|
1052
|
+
})
|
|
1053
|
+
})
|
|
1054
|
+
|
|
1055
|
+
describe('#feeProtocol', () => {
|
|
1056
|
+
const liquidityAmount = expandTo18Decimals(1000)
|
|
1057
|
+
|
|
1058
|
+
beforeEach(async () => {
|
|
1059
|
+
pool = await createPool(FeeAmount.LOW, TICK_SPACINGS[FeeAmount.LOW])
|
|
1060
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1061
|
+
await mint(wallet.address, minTick, maxTick, liquidityAmount)
|
|
1062
|
+
})
|
|
1063
|
+
|
|
1064
|
+
it('is initially set to 0', async () => {
|
|
1065
|
+
expect((await pool.slot0()).feeProtocol).to.eq(0)
|
|
1066
|
+
})
|
|
1067
|
+
|
|
1068
|
+
it('can be changed by the owner', async () => {
|
|
1069
|
+
await pool.setFeeProtocol(6, 6)
|
|
1070
|
+
expect((await pool.slot0()).feeProtocol).to.eq(102)
|
|
1071
|
+
})
|
|
1072
|
+
|
|
1073
|
+
it('cannot be changed out of bounds', async () => {
|
|
1074
|
+
await expect(pool.setFeeProtocol(3, 3)).to.be.reverted
|
|
1075
|
+
await expect(pool.setFeeProtocol(11, 11)).to.be.reverted
|
|
1076
|
+
})
|
|
1077
|
+
|
|
1078
|
+
it('cannot be changed by addresses that are not owner', async () => {
|
|
1079
|
+
await expect(pool.connect(other).setFeeProtocol(6, 6)).to.be.reverted
|
|
1080
|
+
})
|
|
1081
|
+
|
|
1082
|
+
async function swapAndGetFeesOwed({
|
|
1083
|
+
amount,
|
|
1084
|
+
zeroForOne,
|
|
1085
|
+
poke,
|
|
1086
|
+
}: {
|
|
1087
|
+
amount: BigNumberish
|
|
1088
|
+
zeroForOne: boolean
|
|
1089
|
+
poke: boolean
|
|
1090
|
+
}) {
|
|
1091
|
+
await (zeroForOne ? swapExact0For1(amount, wallet.address) : swapExact1For0(amount, wallet.address))
|
|
1092
|
+
|
|
1093
|
+
if (poke) await pool.burn(minTick, maxTick, 0)
|
|
1094
|
+
|
|
1095
|
+
const { amount0: fees0, amount1: fees1 } = await pool.callStatic.collect(
|
|
1096
|
+
wallet.address,
|
|
1097
|
+
minTick,
|
|
1098
|
+
maxTick,
|
|
1099
|
+
MaxUint128,
|
|
1100
|
+
MaxUint128
|
|
1101
|
+
)
|
|
1102
|
+
|
|
1103
|
+
expect(fees0, 'fees owed in token0 are greater than 0').to.be.gte(0)
|
|
1104
|
+
expect(fees1, 'fees owed in token1 are greater than 0').to.be.gte(0)
|
|
1105
|
+
|
|
1106
|
+
return { token0Fees: fees0, token1Fees: fees1 }
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
it('position owner gets full fees when protocol fee is off', async () => {
|
|
1110
|
+
const { token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1111
|
+
amount: expandTo18Decimals(1),
|
|
1112
|
+
zeroForOne: true,
|
|
1113
|
+
poke: true,
|
|
1114
|
+
})
|
|
1115
|
+
|
|
1116
|
+
// 6 bips * 1e18
|
|
1117
|
+
expect(token0Fees).to.eq('499999999999999')
|
|
1118
|
+
expect(token1Fees).to.eq(0)
|
|
1119
|
+
})
|
|
1120
|
+
|
|
1121
|
+
it('swap fees accumulate as expected (0 for 1)', async () => {
|
|
1122
|
+
let token0Fees
|
|
1123
|
+
let token1Fees
|
|
1124
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1125
|
+
amount: expandTo18Decimals(1),
|
|
1126
|
+
zeroForOne: true,
|
|
1127
|
+
poke: true,
|
|
1128
|
+
}))
|
|
1129
|
+
expect(token0Fees).to.eq('499999999999999')
|
|
1130
|
+
expect(token1Fees).to.eq(0)
|
|
1131
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1132
|
+
amount: expandTo18Decimals(1),
|
|
1133
|
+
zeroForOne: true,
|
|
1134
|
+
poke: true,
|
|
1135
|
+
}))
|
|
1136
|
+
expect(token0Fees).to.eq('999999999999998')
|
|
1137
|
+
expect(token1Fees).to.eq(0)
|
|
1138
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1139
|
+
amount: expandTo18Decimals(1),
|
|
1140
|
+
zeroForOne: true,
|
|
1141
|
+
poke: true,
|
|
1142
|
+
}))
|
|
1143
|
+
expect(token0Fees).to.eq('1499999999999997')
|
|
1144
|
+
expect(token1Fees).to.eq(0)
|
|
1145
|
+
})
|
|
1146
|
+
|
|
1147
|
+
it('swap fees accumulate as expected (1 for 0)', async () => {
|
|
1148
|
+
let token0Fees
|
|
1149
|
+
let token1Fees
|
|
1150
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1151
|
+
amount: expandTo18Decimals(1),
|
|
1152
|
+
zeroForOne: false,
|
|
1153
|
+
poke: true,
|
|
1154
|
+
}))
|
|
1155
|
+
expect(token0Fees).to.eq(0)
|
|
1156
|
+
expect(token1Fees).to.eq('499999999999999')
|
|
1157
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1158
|
+
amount: expandTo18Decimals(1),
|
|
1159
|
+
zeroForOne: false,
|
|
1160
|
+
poke: true,
|
|
1161
|
+
}))
|
|
1162
|
+
expect(token0Fees).to.eq(0)
|
|
1163
|
+
expect(token1Fees).to.eq('999999999999998')
|
|
1164
|
+
;({ token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1165
|
+
amount: expandTo18Decimals(1),
|
|
1166
|
+
zeroForOne: false,
|
|
1167
|
+
poke: true,
|
|
1168
|
+
}))
|
|
1169
|
+
expect(token0Fees).to.eq(0)
|
|
1170
|
+
expect(token1Fees).to.eq('1499999999999997')
|
|
1171
|
+
})
|
|
1172
|
+
|
|
1173
|
+
it('position owner gets partial fees when protocol fee is on', async () => {
|
|
1174
|
+
await pool.setFeeProtocol(6, 6)
|
|
1175
|
+
|
|
1176
|
+
const { token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1177
|
+
amount: expandTo18Decimals(1),
|
|
1178
|
+
zeroForOne: true,
|
|
1179
|
+
poke: true,
|
|
1180
|
+
})
|
|
1181
|
+
|
|
1182
|
+
expect(token0Fees).to.be.eq('416666666666666')
|
|
1183
|
+
expect(token1Fees).to.be.eq(0)
|
|
1184
|
+
})
|
|
1185
|
+
|
|
1186
|
+
describe('#collectProtocol', () => {
|
|
1187
|
+
it('returns 0 if no fees', async () => {
|
|
1188
|
+
await pool.setFeeProtocol(6, 6)
|
|
1189
|
+
const { amount0, amount1 } = await pool.callStatic.collectProtocol(wallet.address, MaxUint128, MaxUint128)
|
|
1190
|
+
expect(amount0).to.be.eq(0)
|
|
1191
|
+
expect(amount1).to.be.eq(0)
|
|
1192
|
+
})
|
|
1193
|
+
|
|
1194
|
+
it('can collect fees', async () => {
|
|
1195
|
+
await pool.setFeeProtocol(6, 6)
|
|
1196
|
+
|
|
1197
|
+
await swapAndGetFeesOwed({
|
|
1198
|
+
amount: expandTo18Decimals(1),
|
|
1199
|
+
zeroForOne: true,
|
|
1200
|
+
poke: true,
|
|
1201
|
+
})
|
|
1202
|
+
|
|
1203
|
+
await expect(pool.collectProtocol(other.address, MaxUint128, MaxUint128))
|
|
1204
|
+
.to.emit(token0, 'Transfer')
|
|
1205
|
+
.withArgs(pool.address, other.address, '83333333333332')
|
|
1206
|
+
})
|
|
1207
|
+
|
|
1208
|
+
it('fees collected can differ between token0 and token1', async () => {
|
|
1209
|
+
await pool.setFeeProtocol(8, 5)
|
|
1210
|
+
|
|
1211
|
+
await swapAndGetFeesOwed({
|
|
1212
|
+
amount: expandTo18Decimals(1),
|
|
1213
|
+
zeroForOne: true,
|
|
1214
|
+
poke: false,
|
|
1215
|
+
})
|
|
1216
|
+
await swapAndGetFeesOwed({
|
|
1217
|
+
amount: expandTo18Decimals(1),
|
|
1218
|
+
zeroForOne: false,
|
|
1219
|
+
poke: false,
|
|
1220
|
+
})
|
|
1221
|
+
|
|
1222
|
+
await expect(pool.collectProtocol(other.address, MaxUint128, MaxUint128))
|
|
1223
|
+
.to.emit(token0, 'Transfer')
|
|
1224
|
+
// more token0 fees because it's 1/5th the swap fees
|
|
1225
|
+
.withArgs(pool.address, other.address, '62499999999999')
|
|
1226
|
+
.to.emit(token1, 'Transfer')
|
|
1227
|
+
// less token1 fees because it's 1/8th the swap fees
|
|
1228
|
+
.withArgs(pool.address, other.address, '99999999999998')
|
|
1229
|
+
})
|
|
1230
|
+
})
|
|
1231
|
+
|
|
1232
|
+
it('fees collected by lp after two swaps should be double one swap', async () => {
|
|
1233
|
+
await swapAndGetFeesOwed({
|
|
1234
|
+
amount: expandTo18Decimals(1),
|
|
1235
|
+
zeroForOne: true,
|
|
1236
|
+
poke: true,
|
|
1237
|
+
})
|
|
1238
|
+
const { token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1239
|
+
amount: expandTo18Decimals(1),
|
|
1240
|
+
zeroForOne: true,
|
|
1241
|
+
poke: true,
|
|
1242
|
+
})
|
|
1243
|
+
|
|
1244
|
+
// 6 bips * 2e18
|
|
1245
|
+
expect(token0Fees).to.eq('999999999999998')
|
|
1246
|
+
expect(token1Fees).to.eq(0)
|
|
1247
|
+
})
|
|
1248
|
+
|
|
1249
|
+
it('fees collected after two swaps with fee turned on in middle are fees from last swap (not confiscatory)', async () => {
|
|
1250
|
+
await swapAndGetFeesOwed({
|
|
1251
|
+
amount: expandTo18Decimals(1),
|
|
1252
|
+
zeroForOne: true,
|
|
1253
|
+
poke: false,
|
|
1254
|
+
})
|
|
1255
|
+
|
|
1256
|
+
await pool.setFeeProtocol(6, 6)
|
|
1257
|
+
|
|
1258
|
+
const { token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1259
|
+
amount: expandTo18Decimals(1),
|
|
1260
|
+
zeroForOne: true,
|
|
1261
|
+
poke: true,
|
|
1262
|
+
})
|
|
1263
|
+
|
|
1264
|
+
expect(token0Fees).to.eq('916666666666666')
|
|
1265
|
+
expect(token1Fees).to.eq(0)
|
|
1266
|
+
})
|
|
1267
|
+
|
|
1268
|
+
it('fees collected by lp after two swaps with intermediate withdrawal', async () => {
|
|
1269
|
+
await pool.setFeeProtocol(6, 6)
|
|
1270
|
+
|
|
1271
|
+
const { token0Fees, token1Fees } = await swapAndGetFeesOwed({
|
|
1272
|
+
amount: expandTo18Decimals(1),
|
|
1273
|
+
zeroForOne: true,
|
|
1274
|
+
poke: true,
|
|
1275
|
+
})
|
|
1276
|
+
|
|
1277
|
+
expect(token0Fees).to.eq('416666666666666')
|
|
1278
|
+
expect(token1Fees).to.eq(0)
|
|
1279
|
+
|
|
1280
|
+
// collect the fees
|
|
1281
|
+
await pool.collect(wallet.address, minTick, maxTick, MaxUint128, MaxUint128)
|
|
1282
|
+
|
|
1283
|
+
const { token0Fees: token0FeesNext, token1Fees: token1FeesNext } = await swapAndGetFeesOwed({
|
|
1284
|
+
amount: expandTo18Decimals(1),
|
|
1285
|
+
zeroForOne: true,
|
|
1286
|
+
poke: false,
|
|
1287
|
+
})
|
|
1288
|
+
|
|
1289
|
+
expect(token0FeesNext).to.eq(0)
|
|
1290
|
+
expect(token1FeesNext).to.eq(0)
|
|
1291
|
+
|
|
1292
|
+
let { token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees()
|
|
1293
|
+
expect(token0ProtocolFees).to.eq('166666666666666')
|
|
1294
|
+
expect(token1ProtocolFees).to.eq(0)
|
|
1295
|
+
|
|
1296
|
+
await pool.burn(minTick, maxTick, 0) // poke to update fees
|
|
1297
|
+
await expect(pool.collect(wallet.address, minTick, maxTick, MaxUint128, MaxUint128))
|
|
1298
|
+
.to.emit(token0, 'Transfer')
|
|
1299
|
+
.withArgs(pool.address, wallet.address, '416666666666666')
|
|
1300
|
+
;({ token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees())
|
|
1301
|
+
expect(token0ProtocolFees).to.eq('166666666666666')
|
|
1302
|
+
expect(token1ProtocolFees).to.eq(0)
|
|
1303
|
+
})
|
|
1304
|
+
})
|
|
1305
|
+
|
|
1306
|
+
describe('#tickSpacing', () => {
|
|
1307
|
+
describe('tickSpacing = 12', () => {
|
|
1308
|
+
beforeEach('deploy pool', async () => {
|
|
1309
|
+
pool = await createPool(FeeAmount.MEDIUM, 12)
|
|
1310
|
+
})
|
|
1311
|
+
describe('post initialize', () => {
|
|
1312
|
+
beforeEach('initialize pool', async () => {
|
|
1313
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1314
|
+
})
|
|
1315
|
+
it('mint can only be called for multiples of 12', async () => {
|
|
1316
|
+
await expect(mint(wallet.address, -6, 0, 1)).to.be.reverted
|
|
1317
|
+
await expect(mint(wallet.address, 0, 6, 1)).to.be.reverted
|
|
1318
|
+
})
|
|
1319
|
+
it('mint can be called with multiples of 12', async () => {
|
|
1320
|
+
await mint(wallet.address, 12, 24, 1)
|
|
1321
|
+
await mint(wallet.address, -144, -120, 1)
|
|
1322
|
+
})
|
|
1323
|
+
it('swapping across gaps works in 1 for 0 direction', async () => {
|
|
1324
|
+
const liquidityAmount = expandTo18Decimals(1).div(4)
|
|
1325
|
+
await mint(wallet.address, 120000, 121200, liquidityAmount)
|
|
1326
|
+
await swapExact1For0(expandTo18Decimals(1), wallet.address)
|
|
1327
|
+
await expect(pool.burn(120000, 121200, liquidityAmount))
|
|
1328
|
+
.to.emit(pool, 'Burn')
|
|
1329
|
+
.withArgs(wallet.address, 120000, 121200, liquidityAmount, '30027458295511', '996999999999999999')
|
|
1330
|
+
.to.not.emit(token0, 'Transfer')
|
|
1331
|
+
.to.not.emit(token1, 'Transfer')
|
|
1332
|
+
expect((await pool.slot0()).tick).to.eq(120196)
|
|
1333
|
+
})
|
|
1334
|
+
it('swapping across gaps works in 0 for 1 direction', async () => {
|
|
1335
|
+
const liquidityAmount = expandTo18Decimals(1).div(4)
|
|
1336
|
+
await mint(wallet.address, -121200, -120000, liquidityAmount)
|
|
1337
|
+
await swapExact0For1(expandTo18Decimals(1), wallet.address)
|
|
1338
|
+
await expect(pool.burn(-121200, -120000, liquidityAmount))
|
|
1339
|
+
.to.emit(pool, 'Burn')
|
|
1340
|
+
.withArgs(wallet.address, -121200, -120000, liquidityAmount, '996999999999999999', '30027458295511')
|
|
1341
|
+
.to.not.emit(token0, 'Transfer')
|
|
1342
|
+
.to.not.emit(token1, 'Transfer')
|
|
1343
|
+
expect((await pool.slot0()).tick).to.eq(-120197)
|
|
1344
|
+
})
|
|
1345
|
+
})
|
|
1346
|
+
})
|
|
1347
|
+
})
|
|
1348
|
+
|
|
1349
|
+
// https://github.com/Uniswap/uniswap-v3-core/issues/214
|
|
1350
|
+
it('tick transition cannot run twice if zero for one swap ends at fractional price just below tick', async () => {
|
|
1351
|
+
pool = await createPool(FeeAmount.MEDIUM, 1)
|
|
1352
|
+
const sqrtTickMath = (await (await ethers.getContractFactory('TickMathTest')).deploy()) as TickMathTest
|
|
1353
|
+
const swapMath = (await (await ethers.getContractFactory('SwapMathTest')).deploy()) as SwapMathTest
|
|
1354
|
+
const p0 = (await sqrtTickMath.getSqrtRatioAtTick(-24081)).add(1)
|
|
1355
|
+
// initialize at a price of ~0.3 token1/token0
|
|
1356
|
+
// meaning if you swap in 2 token0, you should end up getting 0 token1
|
|
1357
|
+
await pool.initialize(p0)
|
|
1358
|
+
expect(await pool.liquidity(), 'current pool liquidity is 1').to.eq(0)
|
|
1359
|
+
expect((await pool.slot0()).tick, 'pool tick is -24081').to.eq(-24081)
|
|
1360
|
+
|
|
1361
|
+
// add a bunch of liquidity around current price
|
|
1362
|
+
const liquidity = expandTo18Decimals(1000)
|
|
1363
|
+
await mint(wallet.address, -24082, -24080, liquidity)
|
|
1364
|
+
expect(await pool.liquidity(), 'current pool liquidity is now liquidity + 1').to.eq(liquidity)
|
|
1365
|
+
|
|
1366
|
+
await mint(wallet.address, -24082, -24081, liquidity)
|
|
1367
|
+
expect(await pool.liquidity(), 'current pool liquidity is still liquidity + 1').to.eq(liquidity)
|
|
1368
|
+
|
|
1369
|
+
// check the math works out to moving the price down 1, sending no amount out, and having some amount remaining
|
|
1370
|
+
{
|
|
1371
|
+
const { feeAmount, amountIn, amountOut, sqrtQ } = await swapMath.computeSwapStep(
|
|
1372
|
+
p0,
|
|
1373
|
+
p0.sub(1),
|
|
1374
|
+
liquidity,
|
|
1375
|
+
3,
|
|
1376
|
+
FeeAmount.MEDIUM
|
|
1377
|
+
)
|
|
1378
|
+
expect(sqrtQ, 'price moves').to.eq(p0.sub(1))
|
|
1379
|
+
expect(feeAmount, 'fee amount is 1').to.eq(1)
|
|
1380
|
+
expect(amountIn, 'amount in is 1').to.eq(1)
|
|
1381
|
+
expect(amountOut, 'zero amount out').to.eq(0)
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
// swap 2 amount in, should get 0 amount out
|
|
1385
|
+
await expect(swapExact0For1(3, wallet.address))
|
|
1386
|
+
.to.emit(token0, 'Transfer')
|
|
1387
|
+
.withArgs(wallet.address, pool.address, 3)
|
|
1388
|
+
.to.not.emit(token1, 'Transfer')
|
|
1389
|
+
|
|
1390
|
+
const { tick, sqrtPriceX96 } = await pool.slot0()
|
|
1391
|
+
|
|
1392
|
+
expect(tick, 'pool is at the next tick').to.eq(-24082)
|
|
1393
|
+
expect(sqrtPriceX96, 'pool price is still on the p0 boundary').to.eq(p0.sub(1))
|
|
1394
|
+
expect(await pool.liquidity(), 'pool has run tick transition and liquidity changed').to.eq(liquidity.mul(2))
|
|
1395
|
+
})
|
|
1396
|
+
|
|
1397
|
+
describe('#flash', () => {
|
|
1398
|
+
it('fails if not initialized', async () => {
|
|
1399
|
+
await expect(flash(100, 200, other.address)).to.be.reverted
|
|
1400
|
+
await expect(flash(100, 0, other.address)).to.be.reverted
|
|
1401
|
+
await expect(flash(0, 200, other.address)).to.be.reverted
|
|
1402
|
+
})
|
|
1403
|
+
it('fails if no liquidity', async () => {
|
|
1404
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1405
|
+
await expect(flash(100, 200, other.address)).to.be.revertedWith('L')
|
|
1406
|
+
await expect(flash(100, 0, other.address)).to.be.revertedWith('L')
|
|
1407
|
+
await expect(flash(0, 200, other.address)).to.be.revertedWith('L')
|
|
1408
|
+
})
|
|
1409
|
+
describe('after liquidity added', () => {
|
|
1410
|
+
let balance0: BigNumber
|
|
1411
|
+
let balance1: BigNumber
|
|
1412
|
+
beforeEach('add some tokens', async () => {
|
|
1413
|
+
await initializeAtZeroTick(pool)
|
|
1414
|
+
;[balance0, balance1] = await Promise.all([token0.balanceOf(pool.address), token1.balanceOf(pool.address)])
|
|
1415
|
+
})
|
|
1416
|
+
|
|
1417
|
+
describe('fee off', () => {
|
|
1418
|
+
it('emits an event', async () => {
|
|
1419
|
+
await expect(flash(1001, 2001, other.address))
|
|
1420
|
+
.to.emit(pool, 'Flash')
|
|
1421
|
+
.withArgs(swapTarget.address, other.address, 1001, 2001, 4, 7)
|
|
1422
|
+
})
|
|
1423
|
+
|
|
1424
|
+
it('transfers the amount0 to the recipient', async () => {
|
|
1425
|
+
await expect(flash(100, 200, other.address))
|
|
1426
|
+
.to.emit(token0, 'Transfer')
|
|
1427
|
+
.withArgs(pool.address, other.address, 100)
|
|
1428
|
+
})
|
|
1429
|
+
it('transfers the amount1 to the recipient', async () => {
|
|
1430
|
+
await expect(flash(100, 200, other.address))
|
|
1431
|
+
.to.emit(token1, 'Transfer')
|
|
1432
|
+
.withArgs(pool.address, other.address, 200)
|
|
1433
|
+
})
|
|
1434
|
+
it('can flash only token0', async () => {
|
|
1435
|
+
await expect(flash(101, 0, other.address))
|
|
1436
|
+
.to.emit(token0, 'Transfer')
|
|
1437
|
+
.withArgs(pool.address, other.address, 101)
|
|
1438
|
+
.to.not.emit(token1, 'Transfer')
|
|
1439
|
+
})
|
|
1440
|
+
it('can flash only token1', async () => {
|
|
1441
|
+
await expect(flash(0, 102, other.address))
|
|
1442
|
+
.to.emit(token1, 'Transfer')
|
|
1443
|
+
.withArgs(pool.address, other.address, 102)
|
|
1444
|
+
.to.not.emit(token0, 'Transfer')
|
|
1445
|
+
})
|
|
1446
|
+
it('can flash entire token balance', async () => {
|
|
1447
|
+
await expect(flash(balance0, balance1, other.address))
|
|
1448
|
+
.to.emit(token0, 'Transfer')
|
|
1449
|
+
.withArgs(pool.address, other.address, balance0)
|
|
1450
|
+
.to.emit(token1, 'Transfer')
|
|
1451
|
+
.withArgs(pool.address, other.address, balance1)
|
|
1452
|
+
})
|
|
1453
|
+
it('no-op if both amounts are 0', async () => {
|
|
1454
|
+
await expect(flash(0, 0, other.address)).to.not.emit(token0, 'Transfer').to.not.emit(token1, 'Transfer')
|
|
1455
|
+
})
|
|
1456
|
+
it('fails if flash amount is greater than token balance', async () => {
|
|
1457
|
+
await expect(flash(balance0.add(1), balance1, other.address)).to.be.reverted
|
|
1458
|
+
await expect(flash(balance0, balance1.add(1), other.address)).to.be.reverted
|
|
1459
|
+
})
|
|
1460
|
+
it('calls the flash callback on the sender with correct fee amounts', async () => {
|
|
1461
|
+
await expect(flash(1001, 2002, other.address)).to.emit(swapTarget, 'FlashCallback').withArgs(4, 7)
|
|
1462
|
+
})
|
|
1463
|
+
it('increases the fee growth by the expected amount', async () => {
|
|
1464
|
+
await flash(1001, 2002, other.address)
|
|
1465
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1466
|
+
BigNumber.from(4).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1467
|
+
)
|
|
1468
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1469
|
+
BigNumber.from(7).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1470
|
+
)
|
|
1471
|
+
})
|
|
1472
|
+
it('fails if original balance not returned in either token', async () => {
|
|
1473
|
+
await expect(flash(1000, 0, other.address, 999, 0)).to.be.reverted
|
|
1474
|
+
await expect(flash(0, 1000, other.address, 0, 999)).to.be.reverted
|
|
1475
|
+
})
|
|
1476
|
+
it('fails if underpays either token', async () => {
|
|
1477
|
+
await expect(flash(1000, 0, other.address, 1002, 0)).to.be.reverted
|
|
1478
|
+
await expect(flash(0, 1000, other.address, 0, 1002)).to.be.reverted
|
|
1479
|
+
})
|
|
1480
|
+
it('allows donating token0', async () => {
|
|
1481
|
+
await expect(flash(0, 0, constants.AddressZero, 567, 0))
|
|
1482
|
+
.to.emit(token0, 'Transfer')
|
|
1483
|
+
.withArgs(wallet.address, pool.address, 567)
|
|
1484
|
+
.to.not.emit(token1, 'Transfer')
|
|
1485
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1486
|
+
BigNumber.from(567).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1487
|
+
)
|
|
1488
|
+
})
|
|
1489
|
+
it('allows donating token1', async () => {
|
|
1490
|
+
await expect(flash(0, 0, constants.AddressZero, 0, 678))
|
|
1491
|
+
.to.emit(token1, 'Transfer')
|
|
1492
|
+
.withArgs(wallet.address, pool.address, 678)
|
|
1493
|
+
.to.not.emit(token0, 'Transfer')
|
|
1494
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1495
|
+
BigNumber.from(678).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1496
|
+
)
|
|
1497
|
+
})
|
|
1498
|
+
it('allows donating token0 and token1 together', async () => {
|
|
1499
|
+
await expect(flash(0, 0, constants.AddressZero, 789, 1234))
|
|
1500
|
+
.to.emit(token0, 'Transfer')
|
|
1501
|
+
.withArgs(wallet.address, pool.address, 789)
|
|
1502
|
+
.to.emit(token1, 'Transfer')
|
|
1503
|
+
.withArgs(wallet.address, pool.address, 1234)
|
|
1504
|
+
|
|
1505
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1506
|
+
BigNumber.from(789).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1507
|
+
)
|
|
1508
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1509
|
+
BigNumber.from(1234).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1510
|
+
)
|
|
1511
|
+
})
|
|
1512
|
+
})
|
|
1513
|
+
|
|
1514
|
+
describe('fee on', () => {
|
|
1515
|
+
beforeEach('turn protocol fee on', async () => {
|
|
1516
|
+
await pool.setFeeProtocol(6, 6)
|
|
1517
|
+
})
|
|
1518
|
+
|
|
1519
|
+
it('emits an event', async () => {
|
|
1520
|
+
await expect(flash(1001, 2001, other.address))
|
|
1521
|
+
.to.emit(pool, 'Flash')
|
|
1522
|
+
.withArgs(swapTarget.address, other.address, 1001, 2001, 4, 7)
|
|
1523
|
+
})
|
|
1524
|
+
|
|
1525
|
+
it('increases the fee growth by the expected amount', async () => {
|
|
1526
|
+
await flash(2002, 4004, other.address)
|
|
1527
|
+
|
|
1528
|
+
const { token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees()
|
|
1529
|
+
expect(token0ProtocolFees).to.eq(1)
|
|
1530
|
+
expect(token1ProtocolFees).to.eq(2)
|
|
1531
|
+
|
|
1532
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1533
|
+
BigNumber.from(6).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1534
|
+
)
|
|
1535
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1536
|
+
BigNumber.from(11).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1537
|
+
)
|
|
1538
|
+
})
|
|
1539
|
+
it('allows donating token0', async () => {
|
|
1540
|
+
await expect(flash(0, 0, constants.AddressZero, 567, 0))
|
|
1541
|
+
.to.emit(token0, 'Transfer')
|
|
1542
|
+
.withArgs(wallet.address, pool.address, 567)
|
|
1543
|
+
.to.not.emit(token1, 'Transfer')
|
|
1544
|
+
|
|
1545
|
+
const { token0: token0ProtocolFees } = await pool.protocolFees()
|
|
1546
|
+
expect(token0ProtocolFees).to.eq(94)
|
|
1547
|
+
|
|
1548
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1549
|
+
BigNumber.from(473).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1550
|
+
)
|
|
1551
|
+
})
|
|
1552
|
+
it('allows donating token1', async () => {
|
|
1553
|
+
await expect(flash(0, 0, constants.AddressZero, 0, 678))
|
|
1554
|
+
.to.emit(token1, 'Transfer')
|
|
1555
|
+
.withArgs(wallet.address, pool.address, 678)
|
|
1556
|
+
.to.not.emit(token0, 'Transfer')
|
|
1557
|
+
|
|
1558
|
+
const { token1: token1ProtocolFees } = await pool.protocolFees()
|
|
1559
|
+
expect(token1ProtocolFees).to.eq(113)
|
|
1560
|
+
|
|
1561
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1562
|
+
BigNumber.from(565).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1563
|
+
)
|
|
1564
|
+
})
|
|
1565
|
+
it('allows donating token0 and token1 together', async () => {
|
|
1566
|
+
await expect(flash(0, 0, constants.AddressZero, 789, 1234))
|
|
1567
|
+
.to.emit(token0, 'Transfer')
|
|
1568
|
+
.withArgs(wallet.address, pool.address, 789)
|
|
1569
|
+
.to.emit(token1, 'Transfer')
|
|
1570
|
+
.withArgs(wallet.address, pool.address, 1234)
|
|
1571
|
+
|
|
1572
|
+
const { token0: token0ProtocolFees, token1: token1ProtocolFees } = await pool.protocolFees()
|
|
1573
|
+
expect(token0ProtocolFees).to.eq(131)
|
|
1574
|
+
expect(token1ProtocolFees).to.eq(205)
|
|
1575
|
+
|
|
1576
|
+
expect(await pool.feeGrowthGlobal0X128()).to.eq(
|
|
1577
|
+
BigNumber.from(658).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1578
|
+
)
|
|
1579
|
+
expect(await pool.feeGrowthGlobal1X128()).to.eq(
|
|
1580
|
+
BigNumber.from(1029).mul(BigNumber.from(2).pow(128)).div(expandTo18Decimals(2))
|
|
1581
|
+
)
|
|
1582
|
+
})
|
|
1583
|
+
})
|
|
1584
|
+
})
|
|
1585
|
+
})
|
|
1586
|
+
|
|
1587
|
+
describe('#increaseObservationCardinalityNext', () => {
|
|
1588
|
+
it('cannot be called before initialization', async () => {
|
|
1589
|
+
await expect(pool.increaseObservationCardinalityNext(2)).to.be.reverted
|
|
1590
|
+
})
|
|
1591
|
+
describe('after initialization', () => {
|
|
1592
|
+
beforeEach('initialize the pool', () => pool.initialize(encodePriceSqrt(1, 1)))
|
|
1593
|
+
it('oracle starting state after initialization', async () => {
|
|
1594
|
+
const { observationCardinality, observationIndex, observationCardinalityNext } = await pool.slot0()
|
|
1595
|
+
expect(observationCardinality).to.eq(1)
|
|
1596
|
+
expect(observationIndex).to.eq(0)
|
|
1597
|
+
expect(observationCardinalityNext).to.eq(1)
|
|
1598
|
+
const {
|
|
1599
|
+
secondsPerLiquidityCumulativeX128,
|
|
1600
|
+
tickCumulative,
|
|
1601
|
+
initialized,
|
|
1602
|
+
blockTimestamp,
|
|
1603
|
+
} = await pool.observations(0)
|
|
1604
|
+
expect(secondsPerLiquidityCumulativeX128).to.eq(0)
|
|
1605
|
+
expect(tickCumulative).to.eq(0)
|
|
1606
|
+
expect(initialized).to.eq(true)
|
|
1607
|
+
expect(blockTimestamp).to.eq(TEST_POOL_START_TIME)
|
|
1608
|
+
})
|
|
1609
|
+
it('increases observation cardinality next', async () => {
|
|
1610
|
+
await pool.increaseObservationCardinalityNext(2)
|
|
1611
|
+
const { observationCardinality, observationIndex, observationCardinalityNext } = await pool.slot0()
|
|
1612
|
+
expect(observationCardinality).to.eq(1)
|
|
1613
|
+
expect(observationIndex).to.eq(0)
|
|
1614
|
+
expect(observationCardinalityNext).to.eq(2)
|
|
1615
|
+
})
|
|
1616
|
+
it('is no op if target is already exceeded', async () => {
|
|
1617
|
+
await pool.increaseObservationCardinalityNext(5)
|
|
1618
|
+
await pool.increaseObservationCardinalityNext(3)
|
|
1619
|
+
const { observationCardinality, observationIndex, observationCardinalityNext } = await pool.slot0()
|
|
1620
|
+
expect(observationCardinality).to.eq(1)
|
|
1621
|
+
expect(observationIndex).to.eq(0)
|
|
1622
|
+
expect(observationCardinalityNext).to.eq(5)
|
|
1623
|
+
})
|
|
1624
|
+
})
|
|
1625
|
+
})
|
|
1626
|
+
|
|
1627
|
+
describe('#setFeeProtocol', () => {
|
|
1628
|
+
beforeEach('initialize the pool', async () => {
|
|
1629
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1630
|
+
})
|
|
1631
|
+
|
|
1632
|
+
it('can only be called by factory owner', async () => {
|
|
1633
|
+
await expect(pool.connect(other).setFeeProtocol(5, 5)).to.be.reverted
|
|
1634
|
+
})
|
|
1635
|
+
it('fails if fee is lt 4 or gt 10', async () => {
|
|
1636
|
+
await expect(pool.setFeeProtocol(3, 3)).to.be.reverted
|
|
1637
|
+
await expect(pool.setFeeProtocol(6, 3)).to.be.reverted
|
|
1638
|
+
await expect(pool.setFeeProtocol(3, 6)).to.be.reverted
|
|
1639
|
+
await expect(pool.setFeeProtocol(11, 11)).to.be.reverted
|
|
1640
|
+
await expect(pool.setFeeProtocol(6, 11)).to.be.reverted
|
|
1641
|
+
await expect(pool.setFeeProtocol(11, 6)).to.be.reverted
|
|
1642
|
+
})
|
|
1643
|
+
it('succeeds for fee of 4', async () => {
|
|
1644
|
+
await pool.setFeeProtocol(4, 4)
|
|
1645
|
+
})
|
|
1646
|
+
it('succeeds for fee of 10', async () => {
|
|
1647
|
+
await pool.setFeeProtocol(10, 10)
|
|
1648
|
+
})
|
|
1649
|
+
it('sets protocol fee', async () => {
|
|
1650
|
+
await pool.setFeeProtocol(7, 7)
|
|
1651
|
+
expect((await pool.slot0()).feeProtocol).to.eq(119)
|
|
1652
|
+
})
|
|
1653
|
+
it('can change protocol fee', async () => {
|
|
1654
|
+
await pool.setFeeProtocol(7, 7)
|
|
1655
|
+
await pool.setFeeProtocol(5, 8)
|
|
1656
|
+
expect((await pool.slot0()).feeProtocol).to.eq(133)
|
|
1657
|
+
})
|
|
1658
|
+
it('can turn off protocol fee', async () => {
|
|
1659
|
+
await pool.setFeeProtocol(4, 4)
|
|
1660
|
+
await pool.setFeeProtocol(0, 0)
|
|
1661
|
+
expect((await pool.slot0()).feeProtocol).to.eq(0)
|
|
1662
|
+
})
|
|
1663
|
+
it('emits an event when turned on', async () => {
|
|
1664
|
+
await expect(pool.setFeeProtocol(7, 7)).to.be.emit(pool, 'SetFeeProtocol').withArgs(0, 0, 7, 7)
|
|
1665
|
+
})
|
|
1666
|
+
it('emits an event when turned off', async () => {
|
|
1667
|
+
await pool.setFeeProtocol(7, 5)
|
|
1668
|
+
await expect(pool.setFeeProtocol(0, 0)).to.be.emit(pool, 'SetFeeProtocol').withArgs(7, 5, 0, 0)
|
|
1669
|
+
})
|
|
1670
|
+
it('emits an event when changed', async () => {
|
|
1671
|
+
await pool.setFeeProtocol(4, 10)
|
|
1672
|
+
await expect(pool.setFeeProtocol(6, 8)).to.be.emit(pool, 'SetFeeProtocol').withArgs(4, 10, 6, 8)
|
|
1673
|
+
})
|
|
1674
|
+
it('emits an event when unchanged', async () => {
|
|
1675
|
+
await pool.setFeeProtocol(5, 9)
|
|
1676
|
+
await expect(pool.setFeeProtocol(5, 9)).to.be.emit(pool, 'SetFeeProtocol').withArgs(5, 9, 5, 9)
|
|
1677
|
+
})
|
|
1678
|
+
})
|
|
1679
|
+
|
|
1680
|
+
describe('#lock', () => {
|
|
1681
|
+
beforeEach('initialize the pool', async () => {
|
|
1682
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1683
|
+
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(1))
|
|
1684
|
+
})
|
|
1685
|
+
|
|
1686
|
+
it('cannot reenter from swap callback', async () => {
|
|
1687
|
+
const reentrant = (await (
|
|
1688
|
+
await ethers.getContractFactory('TestUniswapV3ReentrantCallee')
|
|
1689
|
+
).deploy()) as TestUniswapV3ReentrantCallee
|
|
1690
|
+
|
|
1691
|
+
// the tests happen in solidity
|
|
1692
|
+
await expect(reentrant.swapToReenter(pool.address)).to.be.revertedWith('Unable to reenter')
|
|
1693
|
+
})
|
|
1694
|
+
})
|
|
1695
|
+
|
|
1696
|
+
describe('#snapshotCumulativesInside', () => {
|
|
1697
|
+
const tickLower = -TICK_SPACINGS[FeeAmount.MEDIUM]
|
|
1698
|
+
const tickUpper = TICK_SPACINGS[FeeAmount.MEDIUM]
|
|
1699
|
+
const tickSpacing = TICK_SPACINGS[FeeAmount.MEDIUM]
|
|
1700
|
+
beforeEach(async () => {
|
|
1701
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1702
|
+
await mint(wallet.address, tickLower, tickUpper, 10)
|
|
1703
|
+
})
|
|
1704
|
+
it('throws if ticks are in reverse order', async () => {
|
|
1705
|
+
await expect(pool.snapshotCumulativesInside(tickUpper, tickLower)).to.be.reverted
|
|
1706
|
+
})
|
|
1707
|
+
it('throws if ticks are the same', async () => {
|
|
1708
|
+
await expect(pool.snapshotCumulativesInside(tickUpper, tickUpper)).to.be.reverted
|
|
1709
|
+
})
|
|
1710
|
+
it('throws if tick lower is too low', async () => {
|
|
1711
|
+
await expect(pool.snapshotCumulativesInside(getMinTick(tickSpacing) - 1, tickUpper)).be.reverted
|
|
1712
|
+
})
|
|
1713
|
+
it('throws if tick upper is too high', async () => {
|
|
1714
|
+
await expect(pool.snapshotCumulativesInside(tickLower, getMaxTick(tickSpacing) + 1)).be.reverted
|
|
1715
|
+
})
|
|
1716
|
+
it('throws if tick lower is not initialized', async () => {
|
|
1717
|
+
await expect(pool.snapshotCumulativesInside(tickLower - tickSpacing, tickUpper)).to.be.reverted
|
|
1718
|
+
})
|
|
1719
|
+
it('throws if tick upper is not initialized', async () => {
|
|
1720
|
+
await expect(pool.snapshotCumulativesInside(tickLower, tickUpper + tickSpacing)).to.be.reverted
|
|
1721
|
+
})
|
|
1722
|
+
it('is zero immediately after initialize', async () => {
|
|
1723
|
+
const {
|
|
1724
|
+
secondsPerLiquidityInsideX128,
|
|
1725
|
+
tickCumulativeInside,
|
|
1726
|
+
secondsInside,
|
|
1727
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1728
|
+
expect(secondsPerLiquidityInsideX128).to.eq(0)
|
|
1729
|
+
expect(tickCumulativeInside).to.eq(0)
|
|
1730
|
+
expect(secondsInside).to.eq(0)
|
|
1731
|
+
})
|
|
1732
|
+
it('increases by expected amount when time elapses in the range', async () => {
|
|
1733
|
+
await pool.advanceTime(5)
|
|
1734
|
+
const {
|
|
1735
|
+
secondsPerLiquidityInsideX128,
|
|
1736
|
+
tickCumulativeInside,
|
|
1737
|
+
secondsInside,
|
|
1738
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1739
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(5).shl(128).div(10))
|
|
1740
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(0)
|
|
1741
|
+
expect(secondsInside).to.eq(5)
|
|
1742
|
+
})
|
|
1743
|
+
it('does not account for time increase above range', async () => {
|
|
1744
|
+
await pool.advanceTime(5)
|
|
1745
|
+
await swapToHigherPrice(encodePriceSqrt(2, 1), wallet.address)
|
|
1746
|
+
await pool.advanceTime(7)
|
|
1747
|
+
const {
|
|
1748
|
+
secondsPerLiquidityInsideX128,
|
|
1749
|
+
tickCumulativeInside,
|
|
1750
|
+
secondsInside,
|
|
1751
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1752
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(5).shl(128).div(10))
|
|
1753
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(0)
|
|
1754
|
+
expect(secondsInside).to.eq(5)
|
|
1755
|
+
})
|
|
1756
|
+
it('does not account for time increase below range', async () => {
|
|
1757
|
+
await pool.advanceTime(5)
|
|
1758
|
+
await swapToLowerPrice(encodePriceSqrt(1, 2), wallet.address)
|
|
1759
|
+
await pool.advanceTime(7)
|
|
1760
|
+
const {
|
|
1761
|
+
secondsPerLiquidityInsideX128,
|
|
1762
|
+
tickCumulativeInside,
|
|
1763
|
+
secondsInside,
|
|
1764
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1765
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(5).shl(128).div(10))
|
|
1766
|
+
// tick is 0 for 5 seconds, then not in range
|
|
1767
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(0)
|
|
1768
|
+
expect(secondsInside).to.eq(5)
|
|
1769
|
+
})
|
|
1770
|
+
it('time increase below range is not counted', async () => {
|
|
1771
|
+
await swapToLowerPrice(encodePriceSqrt(1, 2), wallet.address)
|
|
1772
|
+
await pool.advanceTime(5)
|
|
1773
|
+
await swapToHigherPrice(encodePriceSqrt(1, 1), wallet.address)
|
|
1774
|
+
await pool.advanceTime(7)
|
|
1775
|
+
const {
|
|
1776
|
+
secondsPerLiquidityInsideX128,
|
|
1777
|
+
tickCumulativeInside,
|
|
1778
|
+
secondsInside,
|
|
1779
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1780
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(7).shl(128).div(10))
|
|
1781
|
+
// tick is not in range then tick is 0 for 7 seconds
|
|
1782
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(0)
|
|
1783
|
+
expect(secondsInside).to.eq(7)
|
|
1784
|
+
})
|
|
1785
|
+
it('time increase above range is not counted', async () => {
|
|
1786
|
+
await swapToHigherPrice(encodePriceSqrt(2, 1), wallet.address)
|
|
1787
|
+
await pool.advanceTime(5)
|
|
1788
|
+
await swapToLowerPrice(encodePriceSqrt(1, 1), wallet.address)
|
|
1789
|
+
await pool.advanceTime(7)
|
|
1790
|
+
const {
|
|
1791
|
+
secondsPerLiquidityInsideX128,
|
|
1792
|
+
tickCumulativeInside,
|
|
1793
|
+
secondsInside,
|
|
1794
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1795
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(7).shl(128).div(10))
|
|
1796
|
+
expect((await pool.slot0()).tick).to.eq(-1) // justify the -7 tick cumulative inside value
|
|
1797
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(-7)
|
|
1798
|
+
expect(secondsInside).to.eq(7)
|
|
1799
|
+
})
|
|
1800
|
+
it('positions minted after time spent', async () => {
|
|
1801
|
+
await pool.advanceTime(5)
|
|
1802
|
+
await mint(wallet.address, tickUpper, getMaxTick(tickSpacing), 15)
|
|
1803
|
+
await swapToHigherPrice(encodePriceSqrt(2, 1), wallet.address)
|
|
1804
|
+
await pool.advanceTime(8)
|
|
1805
|
+
const {
|
|
1806
|
+
secondsPerLiquidityInsideX128,
|
|
1807
|
+
tickCumulativeInside,
|
|
1808
|
+
secondsInside,
|
|
1809
|
+
} = await pool.snapshotCumulativesInside(tickUpper, getMaxTick(tickSpacing))
|
|
1810
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(8).shl(128).div(15))
|
|
1811
|
+
// the tick of 2/1 is 6931
|
|
1812
|
+
// 8 seconds * 6931 = 55448
|
|
1813
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(55448)
|
|
1814
|
+
expect(secondsInside).to.eq(8)
|
|
1815
|
+
})
|
|
1816
|
+
it('overlapping liquidity is aggregated', async () => {
|
|
1817
|
+
await mint(wallet.address, tickLower, getMaxTick(tickSpacing), 15)
|
|
1818
|
+
await pool.advanceTime(5)
|
|
1819
|
+
await swapToHigherPrice(encodePriceSqrt(2, 1), wallet.address)
|
|
1820
|
+
await pool.advanceTime(8)
|
|
1821
|
+
const {
|
|
1822
|
+
secondsPerLiquidityInsideX128,
|
|
1823
|
+
tickCumulativeInside,
|
|
1824
|
+
secondsInside,
|
|
1825
|
+
} = await pool.snapshotCumulativesInside(tickLower, tickUpper)
|
|
1826
|
+
expect(secondsPerLiquidityInsideX128).to.eq(BigNumber.from(5).shl(128).div(25))
|
|
1827
|
+
expect(tickCumulativeInside, 'tickCumulativeInside').to.eq(0)
|
|
1828
|
+
expect(secondsInside).to.eq(5)
|
|
1829
|
+
})
|
|
1830
|
+
it('relative behavior of snapshots', async () => {
|
|
1831
|
+
await pool.advanceTime(5)
|
|
1832
|
+
await mint(wallet.address, getMinTick(tickSpacing), tickLower, 15)
|
|
1833
|
+
const {
|
|
1834
|
+
secondsPerLiquidityInsideX128: secondsPerLiquidityInsideX128Start,
|
|
1835
|
+
tickCumulativeInside: tickCumulativeInsideStart,
|
|
1836
|
+
secondsInside: secondsInsideStart,
|
|
1837
|
+
} = await pool.snapshotCumulativesInside(getMinTick(tickSpacing), tickLower)
|
|
1838
|
+
await pool.advanceTime(8)
|
|
1839
|
+
// 13 seconds in starting range, then 3 seconds in newly minted range
|
|
1840
|
+
await swapToLowerPrice(encodePriceSqrt(1, 2), wallet.address)
|
|
1841
|
+
await pool.advanceTime(3)
|
|
1842
|
+
const {
|
|
1843
|
+
secondsPerLiquidityInsideX128,
|
|
1844
|
+
tickCumulativeInside,
|
|
1845
|
+
secondsInside,
|
|
1846
|
+
} = await pool.snapshotCumulativesInside(getMinTick(tickSpacing), tickLower)
|
|
1847
|
+
const expectedDiffSecondsPerLiquidity = BigNumber.from(3).shl(128).div(15)
|
|
1848
|
+
expect(secondsPerLiquidityInsideX128.sub(secondsPerLiquidityInsideX128Start)).to.eq(
|
|
1849
|
+
expectedDiffSecondsPerLiquidity
|
|
1850
|
+
)
|
|
1851
|
+
expect(secondsPerLiquidityInsideX128).to.not.eq(expectedDiffSecondsPerLiquidity)
|
|
1852
|
+
// the tick is the one corresponding to the price of 1/2, or log base 1.0001 of 0.5
|
|
1853
|
+
// this is -6932, and 3 seconds have passed, so the cumulative computed from the diff equals 6932 * 3
|
|
1854
|
+
expect(tickCumulativeInside.sub(tickCumulativeInsideStart), 'tickCumulativeInside').to.eq(-20796)
|
|
1855
|
+
expect(secondsInside - secondsInsideStart).to.eq(3)
|
|
1856
|
+
expect(secondsInside).to.not.eq(3)
|
|
1857
|
+
})
|
|
1858
|
+
})
|
|
1859
|
+
|
|
1860
|
+
describe('fees overflow scenarios', async () => {
|
|
1861
|
+
it('up to max uint 128', async () => {
|
|
1862
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1863
|
+
await mint(wallet.address, minTick, maxTick, 1)
|
|
1864
|
+
await flash(0, 0, wallet.address, MaxUint128, MaxUint128)
|
|
1865
|
+
|
|
1866
|
+
const [feeGrowthGlobal0X128, feeGrowthGlobal1X128] = await Promise.all([
|
|
1867
|
+
pool.feeGrowthGlobal0X128(),
|
|
1868
|
+
pool.feeGrowthGlobal1X128(),
|
|
1869
|
+
])
|
|
1870
|
+
// all 1s in first 128 bits
|
|
1871
|
+
expect(feeGrowthGlobal0X128).to.eq(MaxUint128.shl(128))
|
|
1872
|
+
expect(feeGrowthGlobal1X128).to.eq(MaxUint128.shl(128))
|
|
1873
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1874
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1875
|
+
wallet.address,
|
|
1876
|
+
minTick,
|
|
1877
|
+
maxTick,
|
|
1878
|
+
MaxUint128,
|
|
1879
|
+
MaxUint128
|
|
1880
|
+
)
|
|
1881
|
+
expect(amount0).to.eq(MaxUint128)
|
|
1882
|
+
expect(amount1).to.eq(MaxUint128)
|
|
1883
|
+
})
|
|
1884
|
+
|
|
1885
|
+
it('overflow max uint 128', async () => {
|
|
1886
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1887
|
+
await mint(wallet.address, minTick, maxTick, 1)
|
|
1888
|
+
await flash(0, 0, wallet.address, MaxUint128, MaxUint128)
|
|
1889
|
+
await flash(0, 0, wallet.address, 1, 1)
|
|
1890
|
+
|
|
1891
|
+
const [feeGrowthGlobal0X128, feeGrowthGlobal1X128] = await Promise.all([
|
|
1892
|
+
pool.feeGrowthGlobal0X128(),
|
|
1893
|
+
pool.feeGrowthGlobal1X128(),
|
|
1894
|
+
])
|
|
1895
|
+
// all 1s in first 128 bits
|
|
1896
|
+
expect(feeGrowthGlobal0X128).to.eq(0)
|
|
1897
|
+
expect(feeGrowthGlobal1X128).to.eq(0)
|
|
1898
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1899
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1900
|
+
wallet.address,
|
|
1901
|
+
minTick,
|
|
1902
|
+
maxTick,
|
|
1903
|
+
MaxUint128,
|
|
1904
|
+
MaxUint128
|
|
1905
|
+
)
|
|
1906
|
+
// fees burned
|
|
1907
|
+
expect(amount0).to.eq(0)
|
|
1908
|
+
expect(amount1).to.eq(0)
|
|
1909
|
+
})
|
|
1910
|
+
|
|
1911
|
+
it('overflow max uint 128 after poke burns fees owed to 0', async () => {
|
|
1912
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1913
|
+
await mint(wallet.address, minTick, maxTick, 1)
|
|
1914
|
+
await flash(0, 0, wallet.address, MaxUint128, MaxUint128)
|
|
1915
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1916
|
+
await flash(0, 0, wallet.address, 1, 1)
|
|
1917
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1918
|
+
|
|
1919
|
+
const { amount0, amount1 } = await pool.callStatic.collect(
|
|
1920
|
+
wallet.address,
|
|
1921
|
+
minTick,
|
|
1922
|
+
maxTick,
|
|
1923
|
+
MaxUint128,
|
|
1924
|
+
MaxUint128
|
|
1925
|
+
)
|
|
1926
|
+
// fees burned
|
|
1927
|
+
expect(amount0).to.eq(0)
|
|
1928
|
+
expect(amount1).to.eq(0)
|
|
1929
|
+
})
|
|
1930
|
+
|
|
1931
|
+
it('two positions at the same snapshot', async () => {
|
|
1932
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1933
|
+
await mint(wallet.address, minTick, maxTick, 1)
|
|
1934
|
+
await mint(other.address, minTick, maxTick, 1)
|
|
1935
|
+
await flash(0, 0, wallet.address, MaxUint128, 0)
|
|
1936
|
+
await flash(0, 0, wallet.address, MaxUint128, 0)
|
|
1937
|
+
const feeGrowthGlobal0X128 = await pool.feeGrowthGlobal0X128()
|
|
1938
|
+
expect(feeGrowthGlobal0X128).to.eq(MaxUint128.shl(128))
|
|
1939
|
+
await flash(0, 0, wallet.address, 2, 0)
|
|
1940
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1941
|
+
await pool.connect(other).burn(minTick, maxTick, 0)
|
|
1942
|
+
let { amount0 } = await pool.callStatic.collect(wallet.address, minTick, maxTick, MaxUint128, MaxUint128)
|
|
1943
|
+
expect(amount0, 'amount0 of wallet').to.eq(0)
|
|
1944
|
+
;({ amount0 } = await pool
|
|
1945
|
+
.connect(other)
|
|
1946
|
+
.callStatic.collect(other.address, minTick, maxTick, MaxUint128, MaxUint128))
|
|
1947
|
+
expect(amount0, 'amount0 of other').to.eq(0)
|
|
1948
|
+
})
|
|
1949
|
+
|
|
1950
|
+
it('two positions 1 wei of fees apart overflows exactly once', async () => {
|
|
1951
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1952
|
+
await mint(wallet.address, minTick, maxTick, 1)
|
|
1953
|
+
await flash(0, 0, wallet.address, 1, 0)
|
|
1954
|
+
await mint(other.address, minTick, maxTick, 1)
|
|
1955
|
+
await flash(0, 0, wallet.address, MaxUint128, 0)
|
|
1956
|
+
await flash(0, 0, wallet.address, MaxUint128, 0)
|
|
1957
|
+
const feeGrowthGlobal0X128 = await pool.feeGrowthGlobal0X128()
|
|
1958
|
+
expect(feeGrowthGlobal0X128).to.eq(0)
|
|
1959
|
+
await flash(0, 0, wallet.address, 2, 0)
|
|
1960
|
+
await pool.burn(minTick, maxTick, 0)
|
|
1961
|
+
await pool.connect(other).burn(minTick, maxTick, 0)
|
|
1962
|
+
let { amount0 } = await pool.callStatic.collect(wallet.address, minTick, maxTick, MaxUint128, MaxUint128)
|
|
1963
|
+
expect(amount0, 'amount0 of wallet').to.eq(1)
|
|
1964
|
+
;({ amount0 } = await pool
|
|
1965
|
+
.connect(other)
|
|
1966
|
+
.callStatic.collect(other.address, minTick, maxTick, MaxUint128, MaxUint128))
|
|
1967
|
+
expect(amount0, 'amount0 of other').to.eq(0)
|
|
1968
|
+
})
|
|
1969
|
+
})
|
|
1970
|
+
|
|
1971
|
+
describe('swap underpayment tests', () => {
|
|
1972
|
+
let underpay: TestUniswapV3SwapPay
|
|
1973
|
+
beforeEach('deploy swap test', async () => {
|
|
1974
|
+
const underpayFactory = await ethers.getContractFactory('TestUniswapV3SwapPay')
|
|
1975
|
+
underpay = (await underpayFactory.deploy()) as TestUniswapV3SwapPay
|
|
1976
|
+
await token0.approve(underpay.address, constants.MaxUint256)
|
|
1977
|
+
await token1.approve(underpay.address, constants.MaxUint256)
|
|
1978
|
+
await pool.initialize(encodePriceSqrt(1, 1))
|
|
1979
|
+
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(1))
|
|
1980
|
+
})
|
|
1981
|
+
|
|
1982
|
+
it('underpay zero for one and exact in', async () => {
|
|
1983
|
+
await expect(
|
|
1984
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), 1000, 1, 0)
|
|
1985
|
+
).to.be.revertedWith('IIA')
|
|
1986
|
+
})
|
|
1987
|
+
it('pay in the wrong token zero for one and exact in', async () => {
|
|
1988
|
+
await expect(
|
|
1989
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), 1000, 0, 2000)
|
|
1990
|
+
).to.be.revertedWith('IIA')
|
|
1991
|
+
})
|
|
1992
|
+
it('overpay zero for one and exact in', async () => {
|
|
1993
|
+
await expect(
|
|
1994
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), 1000, 2000, 0)
|
|
1995
|
+
).to.not.be.revertedWith('IIA')
|
|
1996
|
+
})
|
|
1997
|
+
it('underpay zero for one and exact out', async () => {
|
|
1998
|
+
await expect(
|
|
1999
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), -1000, 1, 0)
|
|
2000
|
+
).to.be.revertedWith('IIA')
|
|
2001
|
+
})
|
|
2002
|
+
it('pay in the wrong token zero for one and exact out', async () => {
|
|
2003
|
+
await expect(
|
|
2004
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), -1000, 0, 2000)
|
|
2005
|
+
).to.be.revertedWith('IIA')
|
|
2006
|
+
})
|
|
2007
|
+
it('overpay zero for one and exact out', async () => {
|
|
2008
|
+
await expect(
|
|
2009
|
+
underpay.swap(pool.address, wallet.address, true, MIN_SQRT_RATIO.add(1), -1000, 2000, 0)
|
|
2010
|
+
).to.not.be.revertedWith('IIA')
|
|
2011
|
+
})
|
|
2012
|
+
it('underpay one for zero and exact in', async () => {
|
|
2013
|
+
await expect(
|
|
2014
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), 1000, 0, 1)
|
|
2015
|
+
).to.be.revertedWith('IIA')
|
|
2016
|
+
})
|
|
2017
|
+
it('pay in the wrong token one for zero and exact in', async () => {
|
|
2018
|
+
await expect(
|
|
2019
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), 1000, 2000, 0)
|
|
2020
|
+
).to.be.revertedWith('IIA')
|
|
2021
|
+
})
|
|
2022
|
+
it('overpay one for zero and exact in', async () => {
|
|
2023
|
+
await expect(
|
|
2024
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), 1000, 0, 2000)
|
|
2025
|
+
).to.not.be.revertedWith('IIA')
|
|
2026
|
+
})
|
|
2027
|
+
it('underpay one for zero and exact out', async () => {
|
|
2028
|
+
await expect(
|
|
2029
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), -1000, 0, 1)
|
|
2030
|
+
).to.be.revertedWith('IIA')
|
|
2031
|
+
})
|
|
2032
|
+
it('pay in the wrong token one for zero and exact out', async () => {
|
|
2033
|
+
await expect(
|
|
2034
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), -1000, 2000, 0)
|
|
2035
|
+
).to.be.revertedWith('IIA')
|
|
2036
|
+
})
|
|
2037
|
+
it('overpay one for zero and exact out', async () => {
|
|
2038
|
+
await expect(
|
|
2039
|
+
underpay.swap(pool.address, wallet.address, false, MAX_SQRT_RATIO.sub(1), -1000, 0, 2000)
|
|
2040
|
+
).to.not.be.revertedWith('IIA')
|
|
2041
|
+
})
|
|
2042
|
+
})
|
|
2043
|
+
})
|