@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.
Files changed (1196) hide show
  1. package/lib/openzeppelin-contracts/contracts/drafts/IERC20Permit.sol +14 -0
  2. package/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol +14 -0
  3. package/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol +227 -0
  4. package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol +20 -0
  5. package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Enumerable.sol +10 -0
  6. package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Metadata.sol +10 -0
  7. package/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol +8 -0
  8. package/lib/openzeppelin-contracts/contracts/utils/Address.sol +12 -0
  9. package/lib/openzeppelin-contracts/contracts/utils/Context.sol +8 -0
  10. package/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol +10 -0
  11. package/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol +6 -0
  12. package/lib/openzeppelin-contracts-master/.changeset/better-tires-pull.md +5 -0
  13. package/lib/openzeppelin-contracts-master/.changeset/blue-jars-lay.md +5 -0
  14. package/lib/openzeppelin-contracts-master/.changeset/bright-cooks-brush.md +5 -0
  15. package/lib/openzeppelin-contracts-master/.changeset/chatty-dryers-joke.md +5 -0
  16. package/lib/openzeppelin-contracts-master/.changeset/config.json +12 -0
  17. package/lib/openzeppelin-contracts-master/.changeset/cool-clocks-tick.md +5 -0
  18. package/lib/openzeppelin-contracts-master/.changeset/curly-pandas-flow.md +5 -0
  19. package/lib/openzeppelin-contracts-master/.changeset/flat-flies-hear.md +5 -0
  20. package/lib/openzeppelin-contracts-master/.changeset/floppy-symbols-burn.md +5 -0
  21. package/lib/openzeppelin-contracts-master/.changeset/fruity-coats-smash.md +5 -0
  22. package/lib/openzeppelin-contracts-master/.changeset/gentle-apples-dance.md +5 -0
  23. package/lib/openzeppelin-contracts-master/.changeset/happy-pants-decide.md +5 -0
  24. package/lib/openzeppelin-contracts-master/.changeset/heavy-pots-reply.md +5 -0
  25. package/lib/openzeppelin-contracts-master/.changeset/legal-cameras-sin.md +5 -0
  26. package/lib/openzeppelin-contracts-master/.changeset/rare-bushes-march.md +5 -0
  27. package/lib/openzeppelin-contracts-master/.changeset/red-gifts-appear.md +5 -0
  28. package/lib/openzeppelin-contracts-master/.changeset/silver-falcons-lay.md +5 -0
  29. package/lib/openzeppelin-contracts-master/.changeset/smooth-cows-notice.md +5 -0
  30. package/lib/openzeppelin-contracts-master/.changeset/some-dolls-shine.md +5 -0
  31. package/lib/openzeppelin-contracts-master/.changeset/spicy-seals-bake.md +5 -0
  32. package/lib/openzeppelin-contracts-master/.changeset/sweet-houses-cheer.md +5 -0
  33. package/lib/openzeppelin-contracts-master/.changeset/swift-trees-build.md +5 -0
  34. package/lib/openzeppelin-contracts-master/.changeset/tame-rules-run.md +5 -0
  35. package/lib/openzeppelin-contracts-master/.changeset/tangy-jokes-begin.md +5 -0
  36. package/lib/openzeppelin-contracts-master/.changeset/tidy-turkeys-build.md +5 -0
  37. package/lib/openzeppelin-contracts-master/.codecov.yml +16 -0
  38. package/lib/openzeppelin-contracts-master/.editorconfig +21 -0
  39. package/lib/openzeppelin-contracts-master/.gitattributes +3 -0
  40. package/lib/openzeppelin-contracts-master/.github/CODEOWNERS +10 -0
  41. package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
  42. package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/config.yml +4 -0
  43. package/lib/openzeppelin-contracts-master/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
  44. package/lib/openzeppelin-contracts-master/.github/PULL_REQUEST_TEMPLATE.md +20 -0
  45. package/lib/openzeppelin-contracts-master/.github/actions/gas-compare/action.yml +51 -0
  46. package/lib/openzeppelin-contracts-master/.github/actions/setup/action.yml +108 -0
  47. package/lib/openzeppelin-contracts-master/.github/actions/storage-layout/action.yml +57 -0
  48. package/lib/openzeppelin-contracts-master/.github/workflows/actionlint.yml +18 -0
  49. package/lib/openzeppelin-contracts-master/.github/workflows/changeset.yml +28 -0
  50. package/lib/openzeppelin-contracts-master/.github/workflows/checks.yml +132 -0
  51. package/lib/openzeppelin-contracts-master/.github/workflows/docs.yml +19 -0
  52. package/lib/openzeppelin-contracts-master/.github/workflows/formal-verification.yml +63 -0
  53. package/lib/openzeppelin-contracts-master/.github/workflows/release-cycle.yml +212 -0
  54. package/lib/openzeppelin-contracts-master/.github/workflows/release-upgradeable.yml +97 -0
  55. package/lib/openzeppelin-contracts-master/.github/workflows/upgradeable.yml +35 -0
  56. package/lib/openzeppelin-contracts-master/.gitmodules +10 -0
  57. package/lib/openzeppelin-contracts-master/.husky/pre-commit +2 -0
  58. package/lib/openzeppelin-contracts-master/.mocharc.js +4 -0
  59. package/lib/openzeppelin-contracts-master/.prettierrc +15 -0
  60. package/lib/openzeppelin-contracts-master/.solcover.js +21 -0
  61. package/lib/openzeppelin-contracts-master/CHANGELOG.md +1424 -0
  62. package/lib/openzeppelin-contracts-master/CODE_OF_CONDUCT.md +73 -0
  63. package/lib/openzeppelin-contracts-master/CONTRIBUTING.md +36 -0
  64. package/lib/openzeppelin-contracts-master/FUNDING.json +10 -0
  65. package/lib/openzeppelin-contracts-master/GUIDELINES.md +170 -0
  66. package/lib/openzeppelin-contracts-master/LICENSE +22 -0
  67. package/lib/openzeppelin-contracts-master/README.md +122 -0
  68. package/lib/openzeppelin-contracts-master/RELEASING.md +45 -0
  69. package/lib/openzeppelin-contracts-master/SECURITY.md +43 -0
  70. package/lib/openzeppelin-contracts-master/audits/2017-03.md +292 -0
  71. package/lib/openzeppelin-contracts-master/audits/2018-10.pdf +0 -0
  72. package/lib/openzeppelin-contracts-master/audits/2022-10-Checkpoints.pdf +0 -0
  73. package/lib/openzeppelin-contracts-master/audits/2022-10-ERC4626.pdf +0 -0
  74. package/lib/openzeppelin-contracts-master/audits/2023-05-v4.9.pdf +0 -0
  75. package/lib/openzeppelin-contracts-master/audits/2023-10-v5.0.pdf +0 -0
  76. package/lib/openzeppelin-contracts-master/audits/2024-10-v5.1.pdf +0 -0
  77. package/lib/openzeppelin-contracts-master/audits/2024-12-v5.2.pdf +0 -0
  78. package/lib/openzeppelin-contracts-master/audits/2025-04-v5.3.pdf +0 -0
  79. package/lib/openzeppelin-contracts-master/audits/2025-07-v5.4.pdf +0 -0
  80. package/lib/openzeppelin-contracts-master/audits/2025-10-v5.5.pdf +0 -0
  81. package/lib/openzeppelin-contracts-master/audits/2025-11-RLP.pdf +0 -0
  82. package/lib/openzeppelin-contracts-master/audits/2026-02-v5.6.pdf +0 -0
  83. package/lib/openzeppelin-contracts-master/audits/README.md +24 -0
  84. package/lib/openzeppelin-contracts-master/contracts/access/AccessControl.sol +207 -0
  85. package/lib/openzeppelin-contracts-master/contracts/access/IAccessControl.sol +98 -0
  86. package/lib/openzeppelin-contracts-master/contracts/access/Ownable.sol +100 -0
  87. package/lib/openzeppelin-contracts-master/contracts/access/Ownable2Step.sol +67 -0
  88. package/lib/openzeppelin-contracts-master/contracts/access/README.adoc +45 -0
  89. package/lib/openzeppelin-contracts-master/contracts/access/extensions/AccessControlDefaultAdminRules.sol +372 -0
  90. package/lib/openzeppelin-contracts-master/contracts/access/extensions/AccessControlEnumerable.sol +81 -0
  91. package/lib/openzeppelin-contracts-master/contracts/access/extensions/IAccessControlDefaultAdminRules.sol +192 -0
  92. package/lib/openzeppelin-contracts-master/contracts/access/extensions/IAccessControlEnumerable.sol +31 -0
  93. package/lib/openzeppelin-contracts-master/contracts/access/manager/AccessManaged.sol +112 -0
  94. package/lib/openzeppelin-contracts-master/contracts/access/manager/AccessManager.sol +751 -0
  95. package/lib/openzeppelin-contracts-master/contracts/access/manager/AuthorityUtils.sol +36 -0
  96. package/lib/openzeppelin-contracts-master/contracts/access/manager/IAccessManaged.sol +32 -0
  97. package/lib/openzeppelin-contracts-master/contracts/access/manager/IAccessManager.sol +404 -0
  98. package/lib/openzeppelin-contracts-master/contracts/access/manager/IAuthority.sol +14 -0
  99. package/lib/openzeppelin-contracts-master/contracts/account/Account.sol +151 -0
  100. package/lib/openzeppelin-contracts-master/contracts/account/README.adoc +30 -0
  101. package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-AccountERC7579.sol +420 -0
  102. package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-AccountERC7579Hooked.sol +171 -0
  103. package/lib/openzeppelin-contracts-master/contracts/account/extensions/draft-ERC7821.sol +70 -0
  104. package/lib/openzeppelin-contracts-master/contracts/account/utils/EIP7702Utils.sol +21 -0
  105. package/lib/openzeppelin-contracts-master/contracts/account/utils/draft-ERC4337Utils.sol +279 -0
  106. package/lib/openzeppelin-contracts-master/contracts/account/utils/draft-ERC7579Utils.sol +280 -0
  107. package/lib/openzeppelin-contracts-master/contracts/crosschain/CrosschainLinked.sol +109 -0
  108. package/lib/openzeppelin-contracts-master/contracts/crosschain/CrosschainRemoteExecutor.sol +98 -0
  109. package/lib/openzeppelin-contracts-master/contracts/crosschain/ERC7786Recipient.sol +66 -0
  110. package/lib/openzeppelin-contracts-master/contracts/crosschain/README.adoc +44 -0
  111. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC1155.sol +101 -0
  112. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC20.sol +37 -0
  113. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC721.sol +61 -0
  114. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/BridgeERC7802.sol +34 -0
  115. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeFungible.sol +83 -0
  116. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeMultiToken.sol +92 -0
  117. package/lib/openzeppelin-contracts-master/contracts/crosschain/bridges/abstract/BridgeNonFungible.sol +75 -0
  118. package/lib/openzeppelin-contracts-master/contracts/finance/README.adoc +14 -0
  119. package/lib/openzeppelin-contracts-master/contracts/finance/VestingWallet.sol +160 -0
  120. package/lib/openzeppelin-contracts-master/contracts/finance/VestingWalletCliff.sol +54 -0
  121. package/lib/openzeppelin-contracts-master/contracts/governance/Governor.sol +820 -0
  122. package/lib/openzeppelin-contracts-master/contracts/governance/IGovernor.sol +449 -0
  123. package/lib/openzeppelin-contracts-master/contracts/governance/README.adoc +201 -0
  124. package/lib/openzeppelin-contracts-master/contracts/governance/TimelockController.sol +470 -0
  125. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingFractional.sol +190 -0
  126. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingOverridable.sol +222 -0
  127. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCountingSimple.sol +96 -0
  128. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorCrosschain.sol +30 -0
  129. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorNoncesKeyed.sol +91 -0
  130. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorPreventLateQuorum.sol +92 -0
  131. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorProposalGuardian.sol +59 -0
  132. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSequentialProposalId.sol +75 -0
  133. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSettings.sol +106 -0
  134. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorStorage.sol +134 -0
  135. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorSuperQuorum.sol +59 -0
  136. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockAccess.sol +346 -0
  137. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockCompound.sol +162 -0
  138. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorTimelockControl.sol +167 -0
  139. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotes.sol +64 -0
  140. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotesQuorumFraction.sol +113 -0
  141. package/lib/openzeppelin-contracts-master/contracts/governance/extensions/GovernorVotesSuperQuorumFraction.sol +135 -0
  142. package/lib/openzeppelin-contracts-master/contracts/governance/utils/IVotes.sol +60 -0
  143. package/lib/openzeppelin-contracts-master/contracts/governance/utils/Votes.sol +245 -0
  144. package/lib/openzeppelin-contracts-master/contracts/governance/utils/VotesExtended.sol +85 -0
  145. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155.sol +6 -0
  146. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155MetadataURI.sol +6 -0
  147. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1155Receiver.sol +6 -0
  148. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1271.sol +17 -0
  149. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363.sol +86 -0
  150. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363Receiver.sol +32 -0
  151. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1363Spender.sol +26 -0
  152. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC165.sol +6 -0
  153. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1820Implementer.sol +20 -0
  154. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1820Registry.sol +112 -0
  155. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC1967.sol +24 -0
  156. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC20.sol +6 -0
  157. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC20Metadata.sol +6 -0
  158. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2309.sol +19 -0
  159. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2612.sol +8 -0
  160. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC2981.sol +26 -0
  161. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156.sol +7 -0
  162. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156FlashBorrower.sol +27 -0
  163. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC3156FlashLender.sol +41 -0
  164. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC4626.sol +230 -0
  165. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC4906.sol +20 -0
  166. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5267.sol +28 -0
  167. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5313.sol +16 -0
  168. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC5805.sol +9 -0
  169. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC6372.sol +17 -0
  170. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC6909.sol +125 -0
  171. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721.sol +6 -0
  172. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Enumerable.sol +6 -0
  173. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Metadata.sol +6 -0
  174. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC721Receiver.sol +6 -0
  175. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC7751.sol +12 -0
  176. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777.sol +200 -0
  177. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777Recipient.sol +35 -0
  178. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC777Sender.sol +35 -0
  179. package/lib/openzeppelin-contracts-master/contracts/interfaces/IERC7913.sol +18 -0
  180. package/lib/openzeppelin-contracts-master/contracts/interfaces/README.adoc +138 -0
  181. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC1822.sol +20 -0
  182. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC4337.sol +255 -0
  183. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC6093.sol +162 -0
  184. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7579.sol +227 -0
  185. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7674.sol +17 -0
  186. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7786.sol +64 -0
  187. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7802.sol +32 -0
  188. package/lib/openzeppelin-contracts-master/contracts/interfaces/draft-IERC7821.sol +44 -0
  189. package/lib/openzeppelin-contracts-master/contracts/metatx/ERC2771Context.sol +90 -0
  190. package/lib/openzeppelin-contracts-master/contracts/metatx/ERC2771Forwarder.sol +379 -0
  191. package/lib/openzeppelin-contracts-master/contracts/metatx/README.adoc +17 -0
  192. package/lib/openzeppelin-contracts-master/contracts/mocks/AccessManagedTarget.sol +34 -0
  193. package/lib/openzeppelin-contracts-master/contracts/mocks/AccessManagerMock.sol +20 -0
  194. package/lib/openzeppelin-contracts-master/contracts/mocks/ArraysMock.sol +171 -0
  195. package/lib/openzeppelin-contracts-master/contracts/mocks/AuthorityMock.sol +69 -0
  196. package/lib/openzeppelin-contracts-master/contracts/mocks/Base64Dirty.sol +19 -0
  197. package/lib/openzeppelin-contracts-master/contracts/mocks/BatchCaller.sol +20 -0
  198. package/lib/openzeppelin-contracts-master/contracts/mocks/CallReceiverMock.sol +107 -0
  199. package/lib/openzeppelin-contracts-master/contracts/mocks/ConstructorMock.sol +34 -0
  200. package/lib/openzeppelin-contracts-master/contracts/mocks/ContextMock.sol +35 -0
  201. package/lib/openzeppelin-contracts-master/contracts/mocks/DummyImplementation.sol +61 -0
  202. package/lib/openzeppelin-contracts-master/contracts/mocks/EIP712Verifier.sol +16 -0
  203. package/lib/openzeppelin-contracts-master/contracts/mocks/ERC1271WalletMock.sol +24 -0
  204. package/lib/openzeppelin-contracts-master/contracts/mocks/ERC165Mock.sol +100 -0
  205. package/lib/openzeppelin-contracts-master/contracts/mocks/ERC2771ContextMock.sol +28 -0
  206. package/lib/openzeppelin-contracts-master/contracts/mocks/ERC3156FlashBorrowerMock.sol +53 -0
  207. package/lib/openzeppelin-contracts-master/contracts/mocks/EtherReceiverMock.sol +17 -0
  208. package/lib/openzeppelin-contracts-master/contracts/mocks/InitializableMock.sol +130 -0
  209. package/lib/openzeppelin-contracts-master/contracts/mocks/MerkleProofCustomHashMock.sol +62 -0
  210. package/lib/openzeppelin-contracts-master/contracts/mocks/MerkleTreeMock.sol +52 -0
  211. package/lib/openzeppelin-contracts-master/contracts/mocks/MulticallHelper.sol +23 -0
  212. package/lib/openzeppelin-contracts-master/contracts/mocks/MultipleInheritanceInitializableMocks.sol +131 -0
  213. package/lib/openzeppelin-contracts-master/contracts/mocks/PausableMock.sol +31 -0
  214. package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyAttack.sol +17 -0
  215. package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyMock.sol +59 -0
  216. package/lib/openzeppelin-contracts-master/contracts/mocks/ReentrancyTransientMock.sol +59 -0
  217. package/lib/openzeppelin-contracts-master/contracts/mocks/RegressionImplementation.sol +61 -0
  218. package/lib/openzeppelin-contracts-master/contracts/mocks/SingleInheritanceInitializableMocks.sol +49 -0
  219. package/lib/openzeppelin-contracts-master/contracts/mocks/Stateless.sol +64 -0
  220. package/lib/openzeppelin-contracts-master/contracts/mocks/StorageSlotMock.sol +87 -0
  221. package/lib/openzeppelin-contracts-master/contracts/mocks/TimelockReentrant.sol +26 -0
  222. package/lib/openzeppelin-contracts-master/contracts/mocks/TransientSlotMock.sol +61 -0
  223. package/lib/openzeppelin-contracts-master/contracts/mocks/UpgradeableBeaconMock.sol +27 -0
  224. package/lib/openzeppelin-contracts-master/contracts/mocks/VotesExtendedMock.sol +44 -0
  225. package/lib/openzeppelin-contracts-master/contracts/mocks/VotesMock.sol +44 -0
  226. package/lib/openzeppelin-contracts-master/contracts/mocks/account/AccountMock.sol +181 -0
  227. package/lib/openzeppelin-contracts-master/contracts/mocks/account/modules/ERC7579Mock.sol +141 -0
  228. package/lib/openzeppelin-contracts-master/contracts/mocks/account/utils/ERC7579UtilsMock.sol +23 -0
  229. package/lib/openzeppelin-contracts-master/contracts/mocks/compound/CompTimelock.sol +174 -0
  230. package/lib/openzeppelin-contracts-master/contracts/mocks/crosschain/ERC7786GatewayMock.sol +56 -0
  231. package/lib/openzeppelin-contracts-master/contracts/mocks/crosschain/ERC7786RecipientMock.sol +31 -0
  232. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/AccessManagerEnumerable.sol +161 -0
  233. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/ERC20WithAutoMinerReward.sol +22 -0
  234. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/ERC4626Fees.sol +109 -0
  235. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/MyNFT.sol +9 -0
  236. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintBase.sol +25 -0
  237. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintMissing.sol +24 -0
  238. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRole.sol +23 -0
  239. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessControlModified.sol +14 -0
  240. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/AccessManagedERC20MintBase.sol +16 -0
  241. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/access-control/MyContractOwnable.sol +17 -0
  242. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/account/MyAccountEIP7702.sol +20 -0
  243. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/account/MyFactoryAccount.sol +37 -0
  244. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyGovernor.sol +80 -0
  245. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyToken.sol +21 -0
  246. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyTokenTimestampBased.sol +32 -0
  247. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/governance/MyTokenWrapped.sol +28 -0
  248. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC1155/GameItems.sol +21 -0
  249. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC1155/MyERC115HolderContract.sol +7 -0
  250. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC20/GLDToken.sol +11 -0
  251. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC6909/ERC6909GameItems.sol +26 -0
  252. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/token/ERC721/GameItem.sol +19 -0
  253. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/utilities/Base64NFT.sol +27 -0
  254. package/lib/openzeppelin-contracts-master/contracts/mocks/docs/utilities/Multicall.sol +15 -0
  255. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorCountingOverridableMock.sol +18 -0
  256. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorCrosschain.sol +20 -0
  257. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorFractionalMock.sol +14 -0
  258. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorMock.sol +14 -0
  259. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorNoncesKeyedMock.sol +44 -0
  260. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorPreventLateQuorumMock.sol +40 -0
  261. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorProposalGuardianMock.sol +27 -0
  262. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorSequentialProposalIdMock.sol +39 -0
  263. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorStorageMock.sol +79 -0
  264. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorSuperQuorumMock.sol +95 -0
  265. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockAccessMock.sol +70 -0
  266. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockCompoundMock.sol +69 -0
  267. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorTimelockControlMock.sol +69 -0
  268. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorVoteMock.sol +20 -0
  269. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorVotesSuperQuorumFractionMock.sol +37 -0
  270. package/lib/openzeppelin-contracts-master/contracts/mocks/governance/GovernorWithParamsMock.sol +51 -0
  271. package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/BadBeacon.sol +11 -0
  272. package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/ClashingImplementation.sol +19 -0
  273. package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/ERC1967ProxyUnsafe.sol +13 -0
  274. package/lib/openzeppelin-contracts-master/contracts/mocks/proxy/UUPSUpgradeableMock.sol +35 -0
  275. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1155ReceiverMock.sol +74 -0
  276. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ForceApproveMock.sol +13 -0
  277. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363NoReturnMock.sol +33 -0
  278. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ReceiverMock.sol +52 -0
  279. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363ReturnFalseMock.sol +34 -0
  280. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC1363SpenderMock.sol +47 -0
  281. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ApprovalMock.sol +10 -0
  282. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20BridgeableMock.sol +30 -0
  283. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20DecimalsMock.sol +17 -0
  284. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ExcessDecimalsMock.sol +9 -0
  285. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20FlashMintMock.sol +26 -0
  286. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ForceApproveMock.sol +13 -0
  287. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20GetterHelper.sol +38 -0
  288. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20Mock.sol +16 -0
  289. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20MulticallMock.sol +8 -0
  290. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20NoReturnMock.sol +30 -0
  291. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20Reentrant.sol +39 -0
  292. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20ReturnFalseMock.sol +19 -0
  293. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesAdditionalCheckpointsMock.sol +33 -0
  294. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesLegacyMock.sol +253 -0
  295. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC20VotesTimestampMock.sol +31 -0
  296. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626LimitsMock.sol +23 -0
  297. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626Mock.sol +17 -0
  298. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4626OffsetMock.sol +17 -0
  299. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC4646FeesMock.sol +40 -0
  300. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ConsecutiveEnumerableMock.sol +42 -0
  301. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ConsecutiveMock.sol +61 -0
  302. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721ReceiverMock.sol +47 -0
  303. package/lib/openzeppelin-contracts-master/contracts/mocks/token/ERC721URIStorageMock.sol +17 -0
  304. package/lib/openzeppelin-contracts-master/contracts/mocks/utils/cryptography/ERC7739Mock.sol +12 -0
  305. package/lib/openzeppelin-contracts-master/contracts/package.json +32 -0
  306. package/lib/openzeppelin-contracts-master/contracts/proxy/Clones.sol +294 -0
  307. package/lib/openzeppelin-contracts-master/contracts/proxy/ERC1967/ERC1967Proxy.sol +62 -0
  308. package/lib/openzeppelin-contracts-master/contracts/proxy/ERC1967/ERC1967Utils.sol +177 -0
  309. package/lib/openzeppelin-contracts-master/contracts/proxy/Proxy.sol +69 -0
  310. package/lib/openzeppelin-contracts-master/contracts/proxy/README.adoc +87 -0
  311. package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/BeaconProxy.sol +57 -0
  312. package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/IBeacon.sol +16 -0
  313. package/lib/openzeppelin-contracts-master/contracts/proxy/beacon/UpgradeableBeacon.sol +70 -0
  314. package/lib/openzeppelin-contracts-master/contracts/proxy/transparent/ProxyAdmin.sol +45 -0
  315. package/lib/openzeppelin-contracts-master/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +118 -0
  316. package/lib/openzeppelin-contracts-master/contracts/proxy/utils/Initializable.sol +238 -0
  317. package/lib/openzeppelin-contracts-master/contracts/proxy/utils/UUPSUpgradeable.sol +148 -0
  318. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/ERC1155.sol +417 -0
  319. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/IERC1155.sol +123 -0
  320. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/IERC1155Receiver.sol +59 -0
  321. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/README.adoc +46 -0
  322. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +22 -0
  323. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Crosschain.sol +53 -0
  324. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +38 -0
  325. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155Supply.sol +88 -0
  326. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +58 -0
  327. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol +20 -0
  328. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/utils/ERC1155Holder.sol +42 -0
  329. package/lib/openzeppelin-contracts-master/contracts/token/ERC1155/utils/ERC1155Utils.sol +88 -0
  330. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/ERC20.sol +305 -0
  331. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/IERC20.sol +79 -0
  332. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/README.adoc +81 -0
  333. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC1363.sol +135 -0
  334. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Burnable.sol +39 -0
  335. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Capped.sol +54 -0
  336. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Crosschain.sol +39 -0
  337. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20FlashMint.sol +130 -0
  338. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Pausable.sol +33 -0
  339. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Permit.sol +77 -0
  340. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Votes.sol +83 -0
  341. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC20Wrapper.sol +93 -0
  342. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/ERC4626.sol +298 -0
  343. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/IERC20Metadata.sol +26 -0
  344. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/IERC20Permit.sol +90 -0
  345. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol +51 -0
  346. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol +119 -0
  347. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/utils/ERC1363Utils.sol +95 -0
  348. package/lib/openzeppelin-contracts-master/contracts/token/ERC20/utils/SafeERC20.sol +292 -0
  349. package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/ERC6909.sol +224 -0
  350. package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/README.adoc +27 -0
  351. package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909ContentURI.sol +59 -0
  352. package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909Metadata.sol +83 -0
  353. package/lib/openzeppelin-contracts-master/contracts/token/ERC6909/extensions/ERC6909TokenSupply.sol +41 -0
  354. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/ERC721.sol +433 -0
  355. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/IERC721.sol +135 -0
  356. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/IERC721Receiver.sol +28 -0
  357. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/README.adoc +72 -0
  358. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Burnable.sol +26 -0
  359. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Consecutive.sol +176 -0
  360. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Crosschain.sol +37 -0
  361. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Enumerable.sol +165 -0
  362. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Pausable.sol +37 -0
  363. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Royalty.sol +26 -0
  364. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721URIStorage.sol +62 -0
  365. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Votes.sol +47 -0
  366. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/ERC721Wrapper.sol +102 -0
  367. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/IERC721Enumerable.sol +29 -0
  368. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/extensions/IERC721Metadata.sol +27 -0
  369. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/utils/ERC721Holder.sol +26 -0
  370. package/lib/openzeppelin-contracts-master/contracts/token/ERC721/utils/ERC721Utils.sol +50 -0
  371. package/lib/openzeppelin-contracts-master/contracts/token/common/ERC2981.sol +139 -0
  372. package/lib/openzeppelin-contracts-master/contracts/token/common/README.adoc +10 -0
  373. package/lib/openzeppelin-contracts-master/contracts/utils/Address.sol +167 -0
  374. package/lib/openzeppelin-contracts-master/contracts/utils/Arrays.sol +888 -0
  375. package/lib/openzeppelin-contracts-master/contracts/utils/Base58.sol +240 -0
  376. package/lib/openzeppelin-contracts-master/contracts/utils/Base64.sol +234 -0
  377. package/lib/openzeppelin-contracts-master/contracts/utils/Blockhash.sol +54 -0
  378. package/lib/openzeppelin-contracts-master/contracts/utils/Bytes.sol +329 -0
  379. package/lib/openzeppelin-contracts-master/contracts/utils/CAIP10.sol +54 -0
  380. package/lib/openzeppelin-contracts-master/contracts/utils/CAIP2.sol +51 -0
  381. package/lib/openzeppelin-contracts-master/contracts/utils/Calldata.sol +25 -0
  382. package/lib/openzeppelin-contracts-master/contracts/utils/Comparators.sol +19 -0
  383. package/lib/openzeppelin-contracts-master/contracts/utils/Context.sol +28 -0
  384. package/lib/openzeppelin-contracts-master/contracts/utils/Create2.sol +91 -0
  385. package/lib/openzeppelin-contracts-master/contracts/utils/Create3.sol +134 -0
  386. package/lib/openzeppelin-contracts-master/contracts/utils/ERC6372Utils.sol +52 -0
  387. package/lib/openzeppelin-contracts-master/contracts/utils/Errors.sol +34 -0
  388. package/lib/openzeppelin-contracts-master/contracts/utils/LowLevelCall.sol +127 -0
  389. package/lib/openzeppelin-contracts-master/contracts/utils/Memory.sol +149 -0
  390. package/lib/openzeppelin-contracts-master/contracts/utils/Multicall.sol +37 -0
  391. package/lib/openzeppelin-contracts-master/contracts/utils/Nonces.sol +46 -0
  392. package/lib/openzeppelin-contracts-master/contracts/utils/NoncesKeyed.sol +74 -0
  393. package/lib/openzeppelin-contracts-master/contracts/utils/Packing.sol +1656 -0
  394. package/lib/openzeppelin-contracts-master/contracts/utils/Panic.sol +57 -0
  395. package/lib/openzeppelin-contracts-master/contracts/utils/Pausable.sol +112 -0
  396. package/lib/openzeppelin-contracts-master/contracts/utils/README.adoc +169 -0
  397. package/lib/openzeppelin-contracts-master/contracts/utils/RLP.sol +487 -0
  398. package/lib/openzeppelin-contracts-master/contracts/utils/ReentrancyGuard.sol +119 -0
  399. package/lib/openzeppelin-contracts-master/contracts/utils/ReentrancyGuardTransient.sol +84 -0
  400. package/lib/openzeppelin-contracts-master/contracts/utils/RelayedCall.sol +145 -0
  401. package/lib/openzeppelin-contracts-master/contracts/utils/ShortStrings.sol +122 -0
  402. package/lib/openzeppelin-contracts-master/contracts/utils/SimulateCall.sol +113 -0
  403. package/lib/openzeppelin-contracts-master/contracts/utils/SlotDerivation.sol +155 -0
  404. package/lib/openzeppelin-contracts-master/contracts/utils/StorageSlot.sol +143 -0
  405. package/lib/openzeppelin-contracts-master/contracts/utils/Strings.sol +532 -0
  406. package/lib/openzeppelin-contracts-master/contracts/utils/TransientSlot.sol +183 -0
  407. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/ECDSA.sol +284 -0
  408. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/EIP712.sol +160 -0
  409. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/Hashes.sol +31 -0
  410. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/MerkleProof.sol +510 -0
  411. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/MessageHashUtils.sol +228 -0
  412. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/P256.sol +408 -0
  413. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/README.adoc +76 -0
  414. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/RSA.sol +154 -0
  415. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/SignatureChecker.sol +191 -0
  416. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/TrieProof.sol +256 -0
  417. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/WebAuthn.sol +269 -0
  418. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/draft-ERC7739Utils.sol +207 -0
  419. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/AbstractSigner.sol +23 -0
  420. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/MultiSignerERC7913.sol +259 -0
  421. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/MultiSignerERC7913Weighted.sol +208 -0
  422. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerECDSA.sol +56 -0
  423. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerEIP7702.sol +25 -0
  424. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerERC7913.sol +63 -0
  425. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerP256.sol +64 -0
  426. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerRSA.sol +65 -0
  427. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/SignerWebAuthn.sol +46 -0
  428. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/signers/draft-ERC7739.sol +98 -0
  429. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913P256Verifier.sol +29 -0
  430. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913RSAVerifier.sol +23 -0
  431. package/lib/openzeppelin-contracts-master/contracts/utils/cryptography/verifiers/ERC7913WebAuthnVerifier.sol +35 -0
  432. package/lib/openzeppelin-contracts-master/contracts/utils/draft-InteroperableAddress.sol +245 -0
  433. package/lib/openzeppelin-contracts-master/contracts/utils/introspection/ERC165.sol +25 -0
  434. package/lib/openzeppelin-contracts-master/contracts/utils/introspection/ERC165Checker.sol +142 -0
  435. package/lib/openzeppelin-contracts-master/contracts/utils/introspection/IERC165.sol +25 -0
  436. package/lib/openzeppelin-contracts-master/contracts/utils/math/Math.sol +763 -0
  437. package/lib/openzeppelin-contracts-master/contracts/utils/math/SafeCast.sol +1162 -0
  438. package/lib/openzeppelin-contracts-master/contracts/utils/math/SignedMath.sol +68 -0
  439. package/lib/openzeppelin-contracts-master/contracts/utils/structs/Accumulators.sol +135 -0
  440. package/lib/openzeppelin-contracts-master/contracts/utils/structs/BitMaps.sol +60 -0
  441. package/lib/openzeppelin-contracts-master/contracts/utils/structs/Checkpoints.sol +833 -0
  442. package/lib/openzeppelin-contracts-master/contracts/utils/structs/CircularBuffer.sol +152 -0
  443. package/lib/openzeppelin-contracts-master/contracts/utils/structs/DoubleEndedQueue.sol +238 -0
  444. package/lib/openzeppelin-contracts-master/contracts/utils/structs/EnumerableMap.sol +1443 -0
  445. package/lib/openzeppelin-contracts-master/contracts/utils/structs/EnumerableSet.sol +895 -0
  446. package/lib/openzeppelin-contracts-master/contracts/utils/structs/Heap.sol +259 -0
  447. package/lib/openzeppelin-contracts-master/contracts/utils/structs/MerkleTree.sol +267 -0
  448. package/lib/openzeppelin-contracts-master/contracts/utils/types/Time.sol +133 -0
  449. package/lib/openzeppelin-contracts-master/contracts/vendor/compound/ICompoundTimelock.sol +86 -0
  450. package/lib/openzeppelin-contracts-master/contracts/vendor/compound/LICENSE +11 -0
  451. package/lib/openzeppelin-contracts-master/docs/README.md +16 -0
  452. package/lib/openzeppelin-contracts-master/docs/antora.yml +7 -0
  453. package/lib/openzeppelin-contracts-master/docs/config.js +21 -0
  454. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-control-multiple.svg +97 -0
  455. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-manager-functions.svg +47 -0
  456. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/access-manager.svg +99 -0
  457. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-3a.png +0 -0
  458. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-3b.png +0 -0
  459. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack-6.png +0 -0
  460. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-attack.png +0 -0
  461. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-deposit.png +0 -0
  462. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-mint.png +0 -0
  463. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-linear.png +0 -0
  464. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-loglog.png +0 -0
  465. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/erc4626-rate-loglogext.png +0 -0
  466. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/tally-exec.png +0 -0
  467. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/images/tally-vote.png +0 -0
  468. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/nav.adoc +29 -0
  469. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/access-control.adoc +339 -0
  470. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/account-abstraction.adoc +100 -0
  471. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/accounts.adoc +354 -0
  472. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/backwards-compatibility.adoc +50 -0
  473. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/eoa-delegation.adoc +143 -0
  474. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc1155.adoc +118 -0
  475. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc20-supply.adoc +71 -0
  476. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc20.adoc +67 -0
  477. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc4626.adoc +208 -0
  478. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc6909.adoc +47 -0
  479. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/erc721.adoc +58 -0
  480. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/extending-contracts.adoc +67 -0
  481. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/faq.adoc +13 -0
  482. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/governance.adoc +242 -0
  483. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/index.adoc +100 -0
  484. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/multisig.adoc +308 -0
  485. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/tokens.adoc +31 -0
  486. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/upgradeable.adoc +75 -0
  487. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/utilities.adoc +634 -0
  488. package/lib/openzeppelin-contracts-master/docs/modules/ROOT/pages/wizard.adoc +15 -0
  489. package/lib/openzeppelin-contracts-master/docs/templates/contract.hbs +141 -0
  490. package/lib/openzeppelin-contracts-master/docs/templates/helpers.js +46 -0
  491. package/lib/openzeppelin-contracts-master/docs/templates/page.hbs +4 -0
  492. package/lib/openzeppelin-contracts-master/docs/templates/properties.js +88 -0
  493. package/lib/openzeppelin-contracts-master/eslint.config.mjs +29 -0
  494. package/lib/openzeppelin-contracts-master/foundry.toml +20 -0
  495. package/lib/openzeppelin-contracts-master/fv/Makefile +54 -0
  496. package/lib/openzeppelin-contracts-master/fv/README.md +60 -0
  497. package/lib/openzeppelin-contracts-master/fv/diff/access_manager_AccessManager.sol.patch +97 -0
  498. package/lib/openzeppelin-contracts-master/fv/diff/account_extensions_draft-AccountERC7579.sol.patch +25 -0
  499. package/lib/openzeppelin-contracts-master/fv/diff/token_ERC721_ERC721.sol.patch +11 -0
  500. package/lib/openzeppelin-contracts-master/fv/harnesses/AccessControlDefaultAdminRulesHarness.sol +46 -0
  501. package/lib/openzeppelin-contracts-master/fv/harnesses/AccessControlHarness.sol +6 -0
  502. package/lib/openzeppelin-contracts-master/fv/harnesses/AccessManagedHarness.sol +36 -0
  503. package/lib/openzeppelin-contracts-master/fv/harnesses/AccessManagerHarness.sol +116 -0
  504. package/lib/openzeppelin-contracts-master/fv/harnesses/AccountHarness.sol +60 -0
  505. package/lib/openzeppelin-contracts-master/fv/harnesses/DoubleEndedQueueHarness.sol +58 -0
  506. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20FlashMintHarness.sol +36 -0
  507. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20PermitHarness.sol +16 -0
  508. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC20WrapperHarness.sol +22 -0
  509. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC3156FlashBorrowerHarness.sol +13 -0
  510. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC721Harness.sol +37 -0
  511. package/lib/openzeppelin-contracts-master/fv/harnesses/ERC721ReceiverHarness.sol +11 -0
  512. package/lib/openzeppelin-contracts-master/fv/harnesses/EnumerableMapHarness.sol +55 -0
  513. package/lib/openzeppelin-contracts-master/fv/harnesses/EnumerableSetHarness.sol +35 -0
  514. package/lib/openzeppelin-contracts-master/fv/harnesses/InitializableHarness.sol +23 -0
  515. package/lib/openzeppelin-contracts-master/fv/harnesses/NoncesHarness.sol +14 -0
  516. package/lib/openzeppelin-contracts-master/fv/harnesses/Ownable2StepHarness.sol +10 -0
  517. package/lib/openzeppelin-contracts-master/fv/harnesses/OwnableHarness.sol +10 -0
  518. package/lib/openzeppelin-contracts-master/fv/harnesses/PausableHarness.sol +18 -0
  519. package/lib/openzeppelin-contracts-master/fv/harnesses/TimelockControllerHarness.sol +13 -0
  520. package/lib/openzeppelin-contracts-master/fv/reports/2021-10.pdf +0 -0
  521. package/lib/openzeppelin-contracts-master/fv/reports/2022-03.pdf +0 -0
  522. package/lib/openzeppelin-contracts-master/fv/reports/2022-05.pdf +0 -0
  523. package/lib/openzeppelin-contracts-master/fv/run.js +68 -0
  524. package/lib/openzeppelin-contracts-master/fv/specs/AccessControl.conf +8 -0
  525. package/lib/openzeppelin-contracts-master/fv/specs/AccessControl.spec +119 -0
  526. package/lib/openzeppelin-contracts-master/fv/specs/AccessControlDefaultAdminRules.conf +8 -0
  527. package/lib/openzeppelin-contracts-master/fv/specs/AccessControlDefaultAdminRules.spec +467 -0
  528. package/lib/openzeppelin-contracts-master/fv/specs/AccessManaged.conf +14 -0
  529. package/lib/openzeppelin-contracts-master/fv/specs/AccessManaged.spec +49 -0
  530. package/lib/openzeppelin-contracts-master/fv/specs/AccessManager.conf +10 -0
  531. package/lib/openzeppelin-contracts-master/fv/specs/AccessManager.spec +837 -0
  532. package/lib/openzeppelin-contracts-master/fv/specs/Account.conf +9 -0
  533. package/lib/openzeppelin-contracts-master/fv/specs/Account.spec +490 -0
  534. package/lib/openzeppelin-contracts-master/fv/specs/DoubleEndedQueue.conf +8 -0
  535. package/lib/openzeppelin-contracts-master/fv/specs/DoubleEndedQueue.spec +300 -0
  536. package/lib/openzeppelin-contracts-master/fv/specs/ERC20.conf +9 -0
  537. package/lib/openzeppelin-contracts-master/fv/specs/ERC20.spec +352 -0
  538. package/lib/openzeppelin-contracts-master/fv/specs/ERC20FlashMint.conf +10 -0
  539. package/lib/openzeppelin-contracts-master/fv/specs/ERC20FlashMint.spec +55 -0
  540. package/lib/openzeppelin-contracts-master/fv/specs/ERC20Wrapper.conf +13 -0
  541. package/lib/openzeppelin-contracts-master/fv/specs/ERC20Wrapper.spec +226 -0
  542. package/lib/openzeppelin-contracts-master/fv/specs/ERC721.conf +10 -0
  543. package/lib/openzeppelin-contracts-master/fv/specs/ERC721.spec +695 -0
  544. package/lib/openzeppelin-contracts-master/fv/specs/EnumerableMap.conf +8 -0
  545. package/lib/openzeppelin-contracts-master/fv/specs/EnumerableMap.spec +364 -0
  546. package/lib/openzeppelin-contracts-master/fv/specs/EnumerableSet.conf +8 -0
  547. package/lib/openzeppelin-contracts-master/fv/specs/EnumerableSet.spec +272 -0
  548. package/lib/openzeppelin-contracts-master/fv/specs/Initializable.conf +8 -0
  549. package/lib/openzeppelin-contracts-master/fv/specs/Initializable.spec +176 -0
  550. package/lib/openzeppelin-contracts-master/fv/specs/Nonces.conf +8 -0
  551. package/lib/openzeppelin-contracts-master/fv/specs/Nonces.spec +92 -0
  552. package/lib/openzeppelin-contracts-master/fv/specs/Ownable.conf +8 -0
  553. package/lib/openzeppelin-contracts-master/fv/specs/Ownable.spec +77 -0
  554. package/lib/openzeppelin-contracts-master/fv/specs/Ownable2Step.conf +8 -0
  555. package/lib/openzeppelin-contracts-master/fv/specs/Ownable2Step.spec +108 -0
  556. package/lib/openzeppelin-contracts-master/fv/specs/Pausable.conf +8 -0
  557. package/lib/openzeppelin-contracts-master/fv/specs/Pausable.spec +96 -0
  558. package/lib/openzeppelin-contracts-master/fv/specs/TimelockController.conf +10 -0
  559. package/lib/openzeppelin-contracts-master/fv/specs/TimelockController.spec +299 -0
  560. package/lib/openzeppelin-contracts-master/fv/specs/helpers/helpers.spec +13 -0
  561. package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessControl.spec +8 -0
  562. package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessControlDefaultAdminRules.spec +36 -0
  563. package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessManaged.spec +5 -0
  564. package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccessManager.spec +33 -0
  565. package/lib/openzeppelin-contracts-master/fv/specs/methods/IAccount.spec +34 -0
  566. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC20.spec +11 -0
  567. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC2612.spec +5 -0
  568. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC3156FlashBorrower.spec +3 -0
  569. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC3156FlashLender.spec +5 -0
  570. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC5313.spec +3 -0
  571. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC721.spec +17 -0
  572. package/lib/openzeppelin-contracts-master/fv/specs/methods/IERC721Receiver.spec +3 -0
  573. package/lib/openzeppelin-contracts-master/fv/specs/methods/IOwnable.spec +5 -0
  574. package/lib/openzeppelin-contracts-master/fv/specs/methods/IOwnable2Step.spec +7 -0
  575. package/lib/openzeppelin-contracts-master/fv-requirements.txt +4 -0
  576. package/lib/openzeppelin-contracts-master/hardhat/async-test-sanity.js +10 -0
  577. package/lib/openzeppelin-contracts-master/hardhat/env-artifacts.js +29 -0
  578. package/lib/openzeppelin-contracts-master/hardhat/ignore-unreachable-warnings.js +45 -0
  579. package/lib/openzeppelin-contracts-master/hardhat/remappings.js +18 -0
  580. package/lib/openzeppelin-contracts-master/hardhat/skip-foundry-tests.js +6 -0
  581. package/lib/openzeppelin-contracts-master/hardhat/task-test-get-files.js +25 -0
  582. package/lib/openzeppelin-contracts-master/hardhat.config.js +124 -0
  583. package/lib/openzeppelin-contracts-master/logo.svg +15 -0
  584. package/lib/openzeppelin-contracts-master/netlify.toml +3 -0
  585. package/lib/openzeppelin-contracts-master/package-lock.json +11197 -0
  586. package/lib/openzeppelin-contracts-master/package.json +109 -0
  587. package/lib/openzeppelin-contracts-master/remappings.txt +1 -0
  588. package/lib/openzeppelin-contracts-master/renovate.json +4 -0
  589. package/lib/openzeppelin-contracts-master/scripts/checks/compare-layout.js +28 -0
  590. package/lib/openzeppelin-contracts-master/scripts/checks/compareGasReports.js +249 -0
  591. package/lib/openzeppelin-contracts-master/scripts/checks/coverage.sh +24 -0
  592. package/lib/openzeppelin-contracts-master/scripts/checks/extract-layout.js +39 -0
  593. package/lib/openzeppelin-contracts-master/scripts/checks/generation.sh +6 -0
  594. package/lib/openzeppelin-contracts-master/scripts/checks/inheritance-ordering.js +56 -0
  595. package/lib/openzeppelin-contracts-master/scripts/checks/pragma-validity.js +45 -0
  596. package/lib/openzeppelin-contracts-master/scripts/fetch-common-contracts.js +50 -0
  597. package/lib/openzeppelin-contracts-master/scripts/gen-nav.js +81 -0
  598. package/lib/openzeppelin-contracts-master/scripts/generate/format-lines.js +16 -0
  599. package/lib/openzeppelin-contracts-master/scripts/generate/helpers/sanitize.js +5 -0
  600. package/lib/openzeppelin-contracts-master/scripts/generate/run.js +61 -0
  601. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Arrays.js +505 -0
  602. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Arrays.opts.js +9 -0
  603. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.js +242 -0
  604. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.opts.js +18 -0
  605. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Checkpoints.t.js +141 -0
  606. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Enumerable.opts.js +56 -0
  607. package/lib/openzeppelin-contracts-master/scripts/generate/templates/EnumerableMap.js +464 -0
  608. package/lib/openzeppelin-contracts-master/scripts/generate/templates/EnumerableSet.js +470 -0
  609. package/lib/openzeppelin-contracts-master/scripts/generate/templates/MerkleProof.js +186 -0
  610. package/lib/openzeppelin-contracts-master/scripts/generate/templates/MerkleProof.opts.js +11 -0
  611. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.js +92 -0
  612. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.opts.js +3 -0
  613. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Packing.t.js +48 -0
  614. package/lib/openzeppelin-contracts-master/scripts/generate/templates/SafeCast.js +136 -0
  615. package/lib/openzeppelin-contracts-master/scripts/generate/templates/Slot.opts.js +15 -0
  616. package/lib/openzeppelin-contracts-master/scripts/generate/templates/SlotDerivation.js +119 -0
  617. package/lib/openzeppelin-contracts-master/scripts/generate/templates/SlotDerivation.t.js +127 -0
  618. package/lib/openzeppelin-contracts-master/scripts/generate/templates/StorageSlot.js +77 -0
  619. package/lib/openzeppelin-contracts-master/scripts/generate/templates/StorageSlotMock.js +57 -0
  620. package/lib/openzeppelin-contracts-master/scripts/generate/templates/TransientSlot.js +80 -0
  621. package/lib/openzeppelin-contracts-master/scripts/generate/templates/TransientSlotMock.js +35 -0
  622. package/lib/openzeppelin-contracts-master/scripts/generate/templates/conversion.js +34 -0
  623. package/lib/openzeppelin-contracts-master/scripts/get-contracts-metadata.js +55 -0
  624. package/lib/openzeppelin-contracts-master/scripts/git-user-config.sh +6 -0
  625. package/lib/openzeppelin-contracts-master/scripts/helpers.js +7 -0
  626. package/lib/openzeppelin-contracts-master/scripts/minimize-pragma.js +140 -0
  627. package/lib/openzeppelin-contracts-master/scripts/prepack.sh +23 -0
  628. package/lib/openzeppelin-contracts-master/scripts/prepare-docs.sh +26 -0
  629. package/lib/openzeppelin-contracts-master/scripts/release/format-changelog.js +33 -0
  630. package/lib/openzeppelin-contracts-master/scripts/release/synchronize-versions.js +15 -0
  631. package/lib/openzeppelin-contracts-master/scripts/release/update-comment.js +34 -0
  632. package/lib/openzeppelin-contracts-master/scripts/release/version.sh +11 -0
  633. package/lib/openzeppelin-contracts-master/scripts/release/workflow/check-upgradeable.sh +27 -0
  634. package/lib/openzeppelin-contracts-master/scripts/release/workflow/exit-prerelease.sh +8 -0
  635. package/lib/openzeppelin-contracts-master/scripts/release/workflow/github-release.js +48 -0
  636. package/lib/openzeppelin-contracts-master/scripts/release/workflow/integrity-check.sh +20 -0
  637. package/lib/openzeppelin-contracts-master/scripts/release/workflow/pack.sh +26 -0
  638. package/lib/openzeppelin-contracts-master/scripts/release/workflow/publish.sh +26 -0
  639. package/lib/openzeppelin-contracts-master/scripts/release/workflow/rerun.js +7 -0
  640. package/lib/openzeppelin-contracts-master/scripts/release/workflow/set-changesets-pr-title.js +17 -0
  641. package/lib/openzeppelin-contracts-master/scripts/release/workflow/start.sh +35 -0
  642. package/lib/openzeppelin-contracts-master/scripts/release/workflow/state.js +112 -0
  643. package/lib/openzeppelin-contracts-master/scripts/remove-ignored-artifacts.js +45 -0
  644. package/lib/openzeppelin-contracts-master/scripts/set-max-old-space-size.sh +10 -0
  645. package/lib/openzeppelin-contracts-master/scripts/solc-versions.js +15 -0
  646. package/lib/openzeppelin-contracts-master/scripts/solhint-custom/index.js +118 -0
  647. package/lib/openzeppelin-contracts-master/scripts/solhint-custom/package.json +8 -0
  648. package/lib/openzeppelin-contracts-master/scripts/update-docs-branch.js +65 -0
  649. package/lib/openzeppelin-contracts-master/scripts/upgradeable/README.md +21 -0
  650. package/lib/openzeppelin-contracts-master/scripts/upgradeable/alias/Initializable.sol +5 -0
  651. package/lib/openzeppelin-contracts-master/scripts/upgradeable/alias/UUPSUpgradeable.sol +5 -0
  652. package/lib/openzeppelin-contracts-master/scripts/upgradeable/patch-apply.sh +19 -0
  653. package/lib/openzeppelin-contracts-master/scripts/upgradeable/patch-save.sh +18 -0
  654. package/lib/openzeppelin-contracts-master/scripts/upgradeable/transpile-onto.sh +54 -0
  655. package/lib/openzeppelin-contracts-master/scripts/upgradeable/transpile.sh +50 -0
  656. package/lib/openzeppelin-contracts-master/scripts/upgradeable/upgradeable.patch +390 -0
  657. package/lib/openzeppelin-contracts-master/slither.config.json +4 -0
  658. package/lib/openzeppelin-contracts-master/solhint.config.js +29 -0
  659. package/lib/openzeppelin-contracts-master/test/TESTING.md +3 -0
  660. package/lib/openzeppelin-contracts-master/test/access/AccessControl.behavior.js +874 -0
  661. package/lib/openzeppelin-contracts-master/test/access/AccessControl.test.js +19 -0
  662. package/lib/openzeppelin-contracts-master/test/access/Ownable.test.js +79 -0
  663. package/lib/openzeppelin-contracts-master/test/access/Ownable2Step.test.js +102 -0
  664. package/lib/openzeppelin-contracts-master/test/access/extensions/AccessControlDefaultAdminRules.test.js +32 -0
  665. package/lib/openzeppelin-contracts-master/test/access/extensions/AccessControlEnumerable.test.js +24 -0
  666. package/lib/openzeppelin-contracts-master/test/access/manager/AccessManaged.test.js +146 -0
  667. package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.behavior.js +252 -0
  668. package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.predicate.js +456 -0
  669. package/lib/openzeppelin-contracts-master/test/access/manager/AccessManager.test.js +2536 -0
  670. package/lib/openzeppelin-contracts-master/test/access/manager/AuthorityUtils.test.js +112 -0
  671. package/lib/openzeppelin-contracts-master/test/account/Account.behavior.js +144 -0
  672. package/lib/openzeppelin-contracts-master/test/account/Account.test.js +48 -0
  673. package/lib/openzeppelin-contracts-master/test/account/AccountECDSA.test.js +52 -0
  674. package/lib/openzeppelin-contracts-master/test/account/AccountEIP7702.t.sol +116 -0
  675. package/lib/openzeppelin-contracts-master/test/account/AccountEIP7702.test.js +52 -0
  676. package/lib/openzeppelin-contracts-master/test/account/AccountERC7913.test.js +138 -0
  677. package/lib/openzeppelin-contracts-master/test/account/AccountMultiSigner.test.js +326 -0
  678. package/lib/openzeppelin-contracts-master/test/account/AccountMultiSignerWeighted.test.js +312 -0
  679. package/lib/openzeppelin-contracts-master/test/account/AccountP256.test.js +58 -0
  680. package/lib/openzeppelin-contracts-master/test/account/AccountRSA.test.js +58 -0
  681. package/lib/openzeppelin-contracts-master/test/account/AccountWebAuthn.test.js +75 -0
  682. package/lib/openzeppelin-contracts-master/test/account/examples/AccountEIP7702WithModulesMock.test.js +99 -0
  683. package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579.behavior.js +724 -0
  684. package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579.test.js +60 -0
  685. package/lib/openzeppelin-contracts-master/test/account/extensions/AccountERC7579Hooked.test.js +60 -0
  686. package/lib/openzeppelin-contracts-master/test/account/extensions/ERC7821.behavior.js +145 -0
  687. package/lib/openzeppelin-contracts-master/test/account/utils/EIP7702Utils.test.js +53 -0
  688. package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC4337Utils.test.js +594 -0
  689. package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC7579Utils.t.sol +434 -0
  690. package/lib/openzeppelin-contracts-master/test/account/utils/draft-ERC7579Utils.test.js +399 -0
  691. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC1155.behavior.js +333 -0
  692. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC1155.test.js +70 -0
  693. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC20.behavior.js +146 -0
  694. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC20.test.js +46 -0
  695. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC721.behavior.js +218 -0
  696. package/lib/openzeppelin-contracts-master/test/crosschain/BridgeERC721.test.js +48 -0
  697. package/lib/openzeppelin-contracts-master/test/crosschain/CrosschainExecutor.test.js +144 -0
  698. package/lib/openzeppelin-contracts-master/test/crosschain/ERC7786Recipient.test.js +55 -0
  699. package/lib/openzeppelin-contracts-master/test/finance/VestingWallet.behavior.js +87 -0
  700. package/lib/openzeppelin-contracts-master/test/finance/VestingWallet.test.js +65 -0
  701. package/lib/openzeppelin-contracts-master/test/finance/VestingWalletCliff.test.js +70 -0
  702. package/lib/openzeppelin-contracts-master/test/governance/Governor.t.sol +59 -0
  703. package/lib/openzeppelin-contracts-master/test/governance/Governor.test.js +980 -0
  704. package/lib/openzeppelin-contracts-master/test/governance/TimelockController.test.js +1279 -0
  705. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCountingFractional.test.js +248 -0
  706. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCountingOverridable.test.js +346 -0
  707. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorCrosschain.test.js +158 -0
  708. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorERC721.test.js +131 -0
  709. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorNoncesKeyed.test.js +243 -0
  710. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorPreventLateQuorum.test.js +185 -0
  711. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorProposalGuardian.test.js +132 -0
  712. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSequentialProposalId.test.js +202 -0
  713. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorStorage.test.js +175 -0
  714. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSuperQuorum.test.js +168 -0
  715. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorSuperQuorumGreaterThanQuorum.t.sol +79 -0
  716. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockAccess.test.js +906 -0
  717. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockCompound.test.js +450 -0
  718. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorTimelockControl.test.js +506 -0
  719. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorVotesQuorumFraction.test.js +165 -0
  720. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorVotesSuperQuorumFraction.test.js +160 -0
  721. package/lib/openzeppelin-contracts-master/test/governance/extensions/GovernorWithParams.test.js +245 -0
  722. package/lib/openzeppelin-contracts-master/test/governance/utils/ERC6372.behavior.js +29 -0
  723. package/lib/openzeppelin-contracts-master/test/governance/utils/Votes.behavior.js +325 -0
  724. package/lib/openzeppelin-contracts-master/test/governance/utils/Votes.test.js +102 -0
  725. package/lib/openzeppelin-contracts-master/test/governance/utils/VotesExtended.test.js +152 -0
  726. package/lib/openzeppelin-contracts-master/test/helpers/access-manager.js +85 -0
  727. package/lib/openzeppelin-contracts-master/test/helpers/account.js +16 -0
  728. package/lib/openzeppelin-contracts-master/test/helpers/chains.js +56 -0
  729. package/lib/openzeppelin-contracts-master/test/helpers/constants.js +7 -0
  730. package/lib/openzeppelin-contracts-master/test/helpers/deploy.js +14 -0
  731. package/lib/openzeppelin-contracts-master/test/helpers/eip712-types.js +61 -0
  732. package/lib/openzeppelin-contracts-master/test/helpers/eip712.js +45 -0
  733. package/lib/openzeppelin-contracts-master/test/helpers/enums.js +15 -0
  734. package/lib/openzeppelin-contracts-master/test/helpers/erc4337.js +244 -0
  735. package/lib/openzeppelin-contracts-master/test/helpers/erc7579.js +58 -0
  736. package/lib/openzeppelin-contracts-master/test/helpers/erc7739.js +118 -0
  737. package/lib/openzeppelin-contracts-master/test/helpers/governance.js +218 -0
  738. package/lib/openzeppelin-contracts-master/test/helpers/iterate.js +41 -0
  739. package/lib/openzeppelin-contracts-master/test/helpers/math.js +33 -0
  740. package/lib/openzeppelin-contracts-master/test/helpers/methods.js +14 -0
  741. package/lib/openzeppelin-contracts-master/test/helpers/precompiles.js +12 -0
  742. package/lib/openzeppelin-contracts-master/test/helpers/random.js +26 -0
  743. package/lib/openzeppelin-contracts-master/test/helpers/signers.js +225 -0
  744. package/lib/openzeppelin-contracts-master/test/helpers/storage.js +48 -0
  745. package/lib/openzeppelin-contracts-master/test/helpers/strings.js +5 -0
  746. package/lib/openzeppelin-contracts-master/test/helpers/time.js +33 -0
  747. package/lib/openzeppelin-contracts-master/test/helpers/trie.js +79 -0
  748. package/lib/openzeppelin-contracts-master/test/helpers/txpool.js +28 -0
  749. package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Context.test.js +109 -0
  750. package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Forwarder.t.sol +279 -0
  751. package/lib/openzeppelin-contracts-master/test/metatx/ERC2771Forwarder.test.js +398 -0
  752. package/lib/openzeppelin-contracts-master/test/proxy/Clones.behaviour.js +160 -0
  753. package/lib/openzeppelin-contracts-master/test/proxy/Clones.t.sol +91 -0
  754. package/lib/openzeppelin-contracts-master/test/proxy/Clones.test.js +177 -0
  755. package/lib/openzeppelin-contracts-master/test/proxy/ERC1967/ERC1967Proxy.test.js +36 -0
  756. package/lib/openzeppelin-contracts-master/test/proxy/ERC1967/ERC1967Utils.test.js +162 -0
  757. package/lib/openzeppelin-contracts-master/test/proxy/Proxy.behaviour.js +198 -0
  758. package/lib/openzeppelin-contracts-master/test/proxy/beacon/BeaconProxy.test.js +141 -0
  759. package/lib/openzeppelin-contracts-master/test/proxy/beacon/UpgradeableBeacon.test.js +55 -0
  760. package/lib/openzeppelin-contracts-master/test/proxy/transparent/ProxyAdmin.test.js +82 -0
  761. package/lib/openzeppelin-contracts-master/test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js +367 -0
  762. package/lib/openzeppelin-contracts-master/test/proxy/transparent/TransparentUpgradeableProxy.test.js +28 -0
  763. package/lib/openzeppelin-contracts-master/test/proxy/utils/Initializable.test.js +216 -0
  764. package/lib/openzeppelin-contracts-master/test/proxy/utils/UUPSUpgradeable.test.js +120 -0
  765. package/lib/openzeppelin-contracts-master/test/sanity.test.js +27 -0
  766. package/lib/openzeppelin-contracts-master/test/token/ERC1155/ERC1155.behavior.js +865 -0
  767. package/lib/openzeppelin-contracts-master/test/token/ERC1155/ERC1155.test.js +258 -0
  768. package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Burnable.test.js +66 -0
  769. package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Crosschain.test.js +43 -0
  770. package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Pausable.test.js +105 -0
  771. package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155Supply.test.js +119 -0
  772. package/lib/openzeppelin-contracts-master/test/token/ERC1155/extensions/ERC1155URIStorage.test.js +70 -0
  773. package/lib/openzeppelin-contracts-master/test/token/ERC1155/utils/ERC1155Holder.test.js +56 -0
  774. package/lib/openzeppelin-contracts-master/test/token/ERC1155/utils/ERC1155Utils.test.js +299 -0
  775. package/lib/openzeppelin-contracts-master/test/token/ERC20/ERC20.behavior.js +269 -0
  776. package/lib/openzeppelin-contracts-master/test/token/ERC20/ERC20.test.js +199 -0
  777. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC1363.test.js +370 -0
  778. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Burnable.test.js +105 -0
  779. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Capped.test.js +55 -0
  780. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Crosschain.test.js +83 -0
  781. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20FlashMint.test.js +164 -0
  782. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Pausable.test.js +129 -0
  783. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Permit.test.js +109 -0
  784. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Votes.test.js +546 -0
  785. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC20Wrapper.test.js +203 -0
  786. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC4626.t.sol +41 -0
  787. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/ERC4626.test.js +888 -0
  788. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/draft-ERC20Bridgeable.test.js +89 -0
  789. package/lib/openzeppelin-contracts-master/test/token/ERC20/extensions/draft-ERC20TemporaryApproval.test.js +142 -0
  790. package/lib/openzeppelin-contracts-master/test/token/ERC20/utils/SafeERC20.test.js +493 -0
  791. package/lib/openzeppelin-contracts-master/test/token/ERC6909/ERC6909.behavior.js +216 -0
  792. package/lib/openzeppelin-contracts-master/test/token/ERC6909/ERC6909.test.js +104 -0
  793. package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909ContentURI.test.js +52 -0
  794. package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909Metadata.test.js +62 -0
  795. package/lib/openzeppelin-contracts-master/test/token/ERC6909/extensions/ERC6909TokenSupply.test.js +56 -0
  796. package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721.behavior.js +954 -0
  797. package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721.test.js +23 -0
  798. package/lib/openzeppelin-contracts-master/test/token/ERC721/ERC721Enumerable.test.js +28 -0
  799. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Burnable.test.js +77 -0
  800. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Consecutive.t.sol +187 -0
  801. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Consecutive.test.js +228 -0
  802. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Crosschain.test.js +44 -0
  803. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Pausable.test.js +81 -0
  804. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Royalty.test.js +57 -0
  805. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721URIStorage.test.js +134 -0
  806. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Votes.test.js +194 -0
  807. package/lib/openzeppelin-contracts-master/test/token/ERC721/extensions/ERC721Wrapper.test.js +201 -0
  808. package/lib/openzeppelin-contracts-master/test/token/ERC721/utils/ERC721Holder.test.js +20 -0
  809. package/lib/openzeppelin-contracts-master/test/token/ERC721/utils/ERC721Utils.test.js +94 -0
  810. package/lib/openzeppelin-contracts-master/test/token/common/ERC2981.behavior.js +152 -0
  811. package/lib/openzeppelin-contracts-master/test/utils/Address.test.js +332 -0
  812. package/lib/openzeppelin-contracts-master/test/utils/Arrays.t.sol +416 -0
  813. package/lib/openzeppelin-contracts-master/test/utils/Arrays.test.js +284 -0
  814. package/lib/openzeppelin-contracts-master/test/utils/Base58.t.sol +24 -0
  815. package/lib/openzeppelin-contracts-master/test/utils/Base58.test.js +65 -0
  816. package/lib/openzeppelin-contracts-master/test/utils/Base64.t.sol +36 -0
  817. package/lib/openzeppelin-contracts-master/test/utils/Base64.test.js +79 -0
  818. package/lib/openzeppelin-contracts-master/test/utils/Blockhash.t.sol +101 -0
  819. package/lib/openzeppelin-contracts-master/test/utils/Blockhash.test.js +59 -0
  820. package/lib/openzeppelin-contracts-master/test/utils/Bytes.t.sol +322 -0
  821. package/lib/openzeppelin-contracts-master/test/utils/Bytes.test.js +371 -0
  822. package/lib/openzeppelin-contracts-master/test/utils/CAIP.test.js +56 -0
  823. package/lib/openzeppelin-contracts-master/test/utils/Calldata.test.js +22 -0
  824. package/lib/openzeppelin-contracts-master/test/utils/Context.behavior.js +48 -0
  825. package/lib/openzeppelin-contracts-master/test/utils/Context.test.js +18 -0
  826. package/lib/openzeppelin-contracts-master/test/utils/Create2.t.sol +17 -0
  827. package/lib/openzeppelin-contracts-master/test/utils/Create2.test.js +190 -0
  828. package/lib/openzeppelin-contracts-master/test/utils/Create3.t.sol +25 -0
  829. package/lib/openzeppelin-contracts-master/test/utils/Create3.test.js +185 -0
  830. package/lib/openzeppelin-contracts-master/test/utils/ERC6372Utils.test.js +59 -0
  831. package/lib/openzeppelin-contracts-master/test/utils/LowLevelCall.test.js +257 -0
  832. package/lib/openzeppelin-contracts-master/test/utils/Memory.t.sol +90 -0
  833. package/lib/openzeppelin-contracts-master/test/utils/Memory.test.js +94 -0
  834. package/lib/openzeppelin-contracts-master/test/utils/Multicall.test.js +72 -0
  835. package/lib/openzeppelin-contracts-master/test/utils/Nonces.behavior.js +189 -0
  836. package/lib/openzeppelin-contracts-master/test/utils/Nonces.test.js +16 -0
  837. package/lib/openzeppelin-contracts-master/test/utils/NoncesKeyed.t.sol +51 -0
  838. package/lib/openzeppelin-contracts-master/test/utils/NoncesKeyed.test.js +17 -0
  839. package/lib/openzeppelin-contracts-master/test/utils/Packing.t.sol +993 -0
  840. package/lib/openzeppelin-contracts-master/test/utils/Packing.test.js +70 -0
  841. package/lib/openzeppelin-contracts-master/test/utils/Panic.test.js +37 -0
  842. package/lib/openzeppelin-contracts-master/test/utils/Pausable.test.js +90 -0
  843. package/lib/openzeppelin-contracts-master/test/utils/RLP.t.sol +144 -0
  844. package/lib/openzeppelin-contracts-master/test/utils/RLP.test.js +224 -0
  845. package/lib/openzeppelin-contracts-master/test/utils/ReentrancyGuard.test.js +58 -0
  846. package/lib/openzeppelin-contracts-master/test/utils/RelayedCall.test.js +223 -0
  847. package/lib/openzeppelin-contracts-master/test/utils/ShortStrings.t.sol +109 -0
  848. package/lib/openzeppelin-contracts-master/test/utils/ShortStrings.test.js +64 -0
  849. package/lib/openzeppelin-contracts-master/test/utils/SimulatedCall.test.js +101 -0
  850. package/lib/openzeppelin-contracts-master/test/utils/SlotDerivation.t.sol +248 -0
  851. package/lib/openzeppelin-contracts-master/test/utils/SlotDerivation.test.js +58 -0
  852. package/lib/openzeppelin-contracts-master/test/utils/StorageSlot.test.js +73 -0
  853. package/lib/openzeppelin-contracts-master/test/utils/Strings.t.sol +50 -0
  854. package/lib/openzeppelin-contracts-master/test/utils/Strings.test.js +366 -0
  855. package/lib/openzeppelin-contracts-master/test/utils/TransientSlot.test.js +59 -0
  856. package/lib/openzeppelin-contracts-master/test/utils/cryptography/ECDSA.test.js +322 -0
  857. package/lib/openzeppelin-contracts-master/test/utils/cryptography/EIP712.test.js +105 -0
  858. package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC1271.behavior.js +111 -0
  859. package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC7739.test.js +42 -0
  860. package/lib/openzeppelin-contracts-master/test/utils/cryptography/ERC7739Utils.test.js +203 -0
  861. package/lib/openzeppelin-contracts-master/test/utils/cryptography/MerkleProof.test.js +216 -0
  862. package/lib/openzeppelin-contracts-master/test/utils/cryptography/MessageHashUtils.t.sol +33 -0
  863. package/lib/openzeppelin-contracts-master/test/utils/cryptography/MessageHashUtils.test.js +149 -0
  864. package/lib/openzeppelin-contracts-master/test/utils/cryptography/P256.t.sol +44 -0
  865. package/lib/openzeppelin-contracts-master/test/utils/cryptography/P256.test.js +174 -0
  866. package/lib/openzeppelin-contracts-master/test/utils/cryptography/RSA.helper.js +17 -0
  867. package/lib/openzeppelin-contracts-master/test/utils/cryptography/RSA.test.js +102 -0
  868. package/lib/openzeppelin-contracts-master/test/utils/cryptography/SigVer15_186-3.rsp +3850 -0
  869. package/lib/openzeppelin-contracts-master/test/utils/cryptography/SignatureChecker.test.js +427 -0
  870. package/lib/openzeppelin-contracts-master/test/utils/cryptography/TrieProof.test.js +707 -0
  871. package/lib/openzeppelin-contracts-master/test/utils/cryptography/WebAuthn.t.sol +340 -0
  872. package/lib/openzeppelin-contracts-master/test/utils/cryptography/ecdsa_secp256r1_sha256_p1363_test.json +3719 -0
  873. package/lib/openzeppelin-contracts-master/test/utils/draft-InteroperableAddress.t.sol +99 -0
  874. package/lib/openzeppelin-contracts-master/test/utils/draft-InteroperableAddress.test.js +217 -0
  875. package/lib/openzeppelin-contracts-master/test/utils/introspection/ERC165.test.js +18 -0
  876. package/lib/openzeppelin-contracts-master/test/utils/introspection/ERC165Checker.test.js +272 -0
  877. package/lib/openzeppelin-contracts-master/test/utils/introspection/SupportsInterface.behavior.js +169 -0
  878. package/lib/openzeppelin-contracts-master/test/utils/math/Math.t.sol +370 -0
  879. package/lib/openzeppelin-contracts-master/test/utils/math/Math.test.js +746 -0
  880. package/lib/openzeppelin-contracts-master/test/utils/math/SafeCast.test.js +159 -0
  881. package/lib/openzeppelin-contracts-master/test/utils/math/SignedMath.t.sol +81 -0
  882. package/lib/openzeppelin-contracts-master/test/utils/math/SignedMath.test.js +53 -0
  883. package/lib/openzeppelin-contracts-master/test/utils/structs/Accumulators.t.sol +35 -0
  884. package/lib/openzeppelin-contracts-master/test/utils/structs/BitMap.test.js +149 -0
  885. package/lib/openzeppelin-contracts-master/test/utils/structs/Checkpoints.t.sol +440 -0
  886. package/lib/openzeppelin-contracts-master/test/utils/structs/Checkpoints.test.js +147 -0
  887. package/lib/openzeppelin-contracts-master/test/utils/structs/CircularBuffer.test.js +83 -0
  888. package/lib/openzeppelin-contracts-master/test/utils/structs/DoubleEndedQueue.test.js +144 -0
  889. package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableMap.behavior.js +214 -0
  890. package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableMap.test.js +83 -0
  891. package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableSet.behavior.js +175 -0
  892. package/lib/openzeppelin-contracts-master/test/utils/structs/EnumerableSet.test.js +66 -0
  893. package/lib/openzeppelin-contracts-master/test/utils/structs/Heap.t.sol +74 -0
  894. package/lib/openzeppelin-contracts-master/test/utils/structs/Heap.test.js +113 -0
  895. package/lib/openzeppelin-contracts-master/test/utils/structs/MerkleTree.test.js +180 -0
  896. package/lib/openzeppelin-contracts-master/test/utils/types/Time.test.js +135 -0
  897. package/lib/v3-core-main/.gitattributes +1 -0
  898. package/lib/v3-core-main/.github/stale.yml +25 -0
  899. package/lib/v3-core-main/.github/workflows/fuzz-testing.yml +60 -0
  900. package/lib/v3-core-main/.github/workflows/lint.yml +34 -0
  901. package/lib/v3-core-main/.github/workflows/mythx.yml +65 -0
  902. package/lib/v3-core-main/.github/workflows/tests.yml +38 -0
  903. package/lib/v3-core-main/.prettierrc +5 -0
  904. package/lib/v3-core-main/.solhint.json +6 -0
  905. package/lib/v3-core-main/.yarnrc +1 -0
  906. package/lib/v3-core-main/LICENSE +100 -0
  907. package/lib/v3-core-main/README.md +66 -0
  908. package/lib/v3-core-main/audits/abdk/audit.pdf +0 -0
  909. package/lib/v3-core-main/audits/tob/README.md +166 -0
  910. package/lib/v3-core-main/audits/tob/audit.pdf +0 -0
  911. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_mint_burn.config.yaml +16 -0
  912. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_mint_burn.sol +503 -0
  913. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_swap.config.yaml +10 -0
  914. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/E2E_swap.sol +487 -0
  915. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Other.config.yaml +7 -0
  916. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Other.sol +21 -0
  917. package/lib/v3-core-main/audits/tob/contracts/crytic/echidna/Setup.sol +205 -0
  918. package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/001.sol +11 -0
  919. package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/002.sol +12 -0
  920. package/lib/v3-core-main/audits/tob/contracts/crytic/manticore/003.sol +9 -0
  921. package/lib/v3-core-main/bug-bounty.md +76 -0
  922. package/lib/v3-core-main/contracts/NoDelegateCall.sol +27 -0
  923. package/lib/v3-core-main/contracts/UniswapV3Factory.sol +73 -0
  924. package/lib/v3-core-main/contracts/UniswapV3Pool.sol +869 -0
  925. package/lib/v3-core-main/contracts/UniswapV3PoolDeployer.sol +38 -0
  926. package/lib/v3-core-main/contracts/interfaces/IERC20Minimal.sol +52 -0
  927. package/lib/v3-core-main/contracts/interfaces/IUniswapV3Factory.sol +78 -0
  928. package/lib/v3-core-main/contracts/interfaces/IUniswapV3Pool.sol +24 -0
  929. package/lib/v3-core-main/contracts/interfaces/IUniswapV3PoolDeployer.sol +26 -0
  930. package/lib/v3-core-main/contracts/interfaces/LICENSE +445 -0
  931. package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3FlashCallback.sol +18 -0
  932. package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3MintCallback.sol +18 -0
  933. package/lib/v3-core-main/contracts/interfaces/callback/IUniswapV3SwapCallback.sol +21 -0
  934. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolActions.sol +103 -0
  935. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol +40 -0
  936. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolEvents.sol +121 -0
  937. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol +35 -0
  938. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol +23 -0
  939. package/lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolState.sol +116 -0
  940. package/lib/v3-core-main/contracts/libraries/BitMath.sol +94 -0
  941. package/lib/v3-core-main/contracts/libraries/FixedPoint128.sol +8 -0
  942. package/lib/v3-core-main/contracts/libraries/FixedPoint96.sol +10 -0
  943. package/lib/v3-core-main/contracts/libraries/FullMath.sol +124 -0
  944. package/lib/v3-core-main/contracts/libraries/LICENSE +445 -0
  945. package/lib/v3-core-main/contracts/libraries/LICENSE_MIT +20 -0
  946. package/lib/v3-core-main/contracts/libraries/LiquidityMath.sol +17 -0
  947. package/lib/v3-core-main/contracts/libraries/LowGasSafeMath.sol +46 -0
  948. package/lib/v3-core-main/contracts/libraries/Oracle.sol +325 -0
  949. package/lib/v3-core-main/contracts/libraries/Position.sol +88 -0
  950. package/lib/v3-core-main/contracts/libraries/SafeCast.sol +28 -0
  951. package/lib/v3-core-main/contracts/libraries/SqrtPriceMath.sol +227 -0
  952. package/lib/v3-core-main/contracts/libraries/SwapMath.sol +98 -0
  953. package/lib/v3-core-main/contracts/libraries/Tick.sol +185 -0
  954. package/lib/v3-core-main/contracts/libraries/TickBitmap.sol +78 -0
  955. package/lib/v3-core-main/contracts/libraries/TickMath.sol +205 -0
  956. package/lib/v3-core-main/contracts/libraries/TransferHelper.sol +23 -0
  957. package/lib/v3-core-main/contracts/libraries/UnsafeMath.sol +17 -0
  958. package/lib/v3-core-main/contracts/test/BitMathEchidnaTest.sol +18 -0
  959. package/lib/v3-core-main/contracts/test/BitMathTest.sol +26 -0
  960. package/lib/v3-core-main/contracts/test/FullMathEchidnaTest.sol +67 -0
  961. package/lib/v3-core-main/contracts/test/FullMathTest.sol +22 -0
  962. package/lib/v3-core-main/contracts/test/LiquidityMathTest.sol +16 -0
  963. package/lib/v3-core-main/contracts/test/LowGasSafeMathEchidnaTest.sol +36 -0
  964. package/lib/v3-core-main/contracts/test/MockTimeUniswapV3Pool.sol +26 -0
  965. package/lib/v3-core-main/contracts/test/MockTimeUniswapV3PoolDeployer.sol +35 -0
  966. package/lib/v3-core-main/contracts/test/NoDelegateCallTest.sol +32 -0
  967. package/lib/v3-core-main/contracts/test/OracleEchidnaTest.sol +137 -0
  968. package/lib/v3-core-main/contracts/test/OracleTest.sol +100 -0
  969. package/lib/v3-core-main/contracts/test/SqrtPriceMathEchidnaTest.sol +232 -0
  970. package/lib/v3-core-main/contracts/test/SqrtPriceMathTest.sol +86 -0
  971. package/lib/v3-core-main/contracts/test/SwapMathEchidnaTest.sol +52 -0
  972. package/lib/v3-core-main/contracts/test/SwapMathTest.sol +37 -0
  973. package/lib/v3-core-main/contracts/test/TestERC20.sol +59 -0
  974. package/lib/v3-core-main/contracts/test/TestUniswapV3Callee.sol +142 -0
  975. package/lib/v3-core-main/contracts/test/TestUniswapV3ReentrantCallee.sol +56 -0
  976. package/lib/v3-core-main/contracts/test/TestUniswapV3Router.sol +91 -0
  977. package/lib/v3-core-main/contracts/test/TestUniswapV3SwapPay.sol +41 -0
  978. package/lib/v3-core-main/contracts/test/TickBitmapEchidnaTest.sol +47 -0
  979. package/lib/v3-core-main/contracts/test/TickBitmapTest.sol +40 -0
  980. package/lib/v3-core-main/contracts/test/TickEchidnaTest.sol +27 -0
  981. package/lib/v3-core-main/contracts/test/TickMathEchidnaTest.sol +22 -0
  982. package/lib/v3-core-main/contracts/test/TickMathTest.sol +34 -0
  983. package/lib/v3-core-main/contracts/test/TickOverflowSafetyEchidnaTest.sol +111 -0
  984. package/lib/v3-core-main/contracts/test/TickTest.sol +79 -0
  985. package/lib/v3-core-main/contracts/test/UniswapV3PoolSwapTest.sol +50 -0
  986. package/lib/v3-core-main/contracts/test/UnsafeMathEchidnaTest.sol +17 -0
  987. package/lib/v3-core-main/echidna.config.yml +74 -0
  988. package/lib/v3-core-main/hardhat.config.ts +68 -0
  989. package/lib/v3-core-main/package.json +59 -0
  990. package/lib/v3-core-main/test/BitMath.spec.ts +79 -0
  991. package/lib/v3-core-main/test/FullMath.spec.ts +182 -0
  992. package/lib/v3-core-main/test/LiquidityMath.spec.ts +44 -0
  993. package/lib/v3-core-main/test/NoDelegateCall.spec.ts +54 -0
  994. package/lib/v3-core-main/test/Oracle.spec.ts +798 -0
  995. package/lib/v3-core-main/test/SqrtPriceMath.spec.ts +379 -0
  996. package/lib/v3-core-main/test/SwapMath.spec.ts +324 -0
  997. package/lib/v3-core-main/test/Tick.spec.ts +329 -0
  998. package/lib/v3-core-main/test/TickBitmap.spec.ts +227 -0
  999. package/lib/v3-core-main/test/TickMath.spec.ts +166 -0
  1000. package/lib/v3-core-main/test/UniswapV3Factory.spec.ts +177 -0
  1001. package/lib/v3-core-main/test/UniswapV3Pool.arbitrage.spec.ts +373 -0
  1002. package/lib/v3-core-main/test/UniswapV3Pool.gas.spec.ts +315 -0
  1003. package/lib/v3-core-main/test/UniswapV3Pool.spec.ts +2043 -0
  1004. package/lib/v3-core-main/test/UniswapV3Pool.swaps.spec.ts +588 -0
  1005. package/lib/v3-core-main/test/UniswapV3Router.spec.ts +133 -0
  1006. package/lib/v3-core-main/test/__snapshots__/BitMath.spec.ts.snap +13 -0
  1007. package/lib/v3-core-main/test/__snapshots__/LiquidityMath.spec.ts.snap +5 -0
  1008. package/lib/v3-core-main/test/__snapshots__/NoDelegateCall.spec.ts.snap +3 -0
  1009. package/lib/v3-core-main/test/__snapshots__/Oracle.spec.ts.snap +87 -0
  1010. package/lib/v3-core-main/test/__snapshots__/SqrtPriceMath.spec.ts.snap +17 -0
  1011. package/lib/v3-core-main/test/__snapshots__/SwapMath.spec.ts.snap +17 -0
  1012. package/lib/v3-core-main/test/__snapshots__/TickBitmap.spec.ts.snap +19 -0
  1013. package/lib/v3-core-main/test/__snapshots__/TickMath.spec.ts.snap +165 -0
  1014. package/lib/v3-core-main/test/__snapshots__/UniswapV3Factory.spec.ts.snap +7 -0
  1015. package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.arbitrage.spec.ts.snap +977 -0
  1016. package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.gas.spec.ts.snap +169 -0
  1017. package/lib/v3-core-main/test/__snapshots__/UniswapV3Pool.swaps.spec.ts.snap +3541 -0
  1018. package/lib/v3-core-main/test/shared/checkObservationEquals.ts +38 -0
  1019. package/lib/v3-core-main/test/shared/expect.ts +8 -0
  1020. package/lib/v3-core-main/test/shared/fixtures.ts +92 -0
  1021. package/lib/v3-core-main/test/shared/format.ts +10 -0
  1022. package/lib/v3-core-main/test/shared/snapshotGasCost.ts +27 -0
  1023. package/lib/v3-core-main/test/shared/utilities.ts +258 -0
  1024. package/lib/v3-core-main/test/snapshotCumulativesInside.test.ts +73 -0
  1025. package/lib/v3-core-main/tsconfig.json +13 -0
  1026. package/lib/v3-core-main/yarn.lock +9271 -0
  1027. package/lib/v3-periphery-main/.gitattributes +1 -0
  1028. package/lib/v3-periphery-main/.github/stale.yml +25 -0
  1029. package/lib/v3-periphery-main/.github/workflows/lint.yml +33 -0
  1030. package/lib/v3-periphery-main/.github/workflows/tests.yml +39 -0
  1031. package/lib/v3-periphery-main/.prettierignore +1 -0
  1032. package/lib/v3-periphery-main/.prettierrc +5 -0
  1033. package/lib/v3-periphery-main/.solhint.json +6 -0
  1034. package/lib/v3-periphery-main/.yarnrc +1 -0
  1035. package/lib/v3-periphery-main/LICENSE +339 -0
  1036. package/lib/v3-periphery-main/README.md +52 -0
  1037. package/lib/v3-periphery-main/audits/abdk/audit.pdf +0 -0
  1038. package/lib/v3-periphery-main/bug-bounty.md +80 -0
  1039. package/lib/v3-periphery-main/contracts/NonfungiblePositionManager.sol +400 -0
  1040. package/lib/v3-periphery-main/contracts/NonfungibleTokenPositionDescriptor.sol +124 -0
  1041. package/lib/v3-periphery-main/contracts/SwapRouter.sol +244 -0
  1042. package/lib/v3-periphery-main/contracts/V3Migrator.sol +99 -0
  1043. package/lib/v3-periphery-main/contracts/base/BlockTimestamp.sol +12 -0
  1044. package/lib/v3-periphery-main/contracts/base/ERC721Permit.sol +86 -0
  1045. package/lib/v3-periphery-main/contracts/base/LiquidityManagement.sol +90 -0
  1046. package/lib/v3-periphery-main/contracts/base/Multicall.sol +28 -0
  1047. package/lib/v3-periphery-main/contracts/base/PeripheryImmutableState.sol +18 -0
  1048. package/lib/v3-periphery-main/contracts/base/PeripheryPayments.sol +70 -0
  1049. package/lib/v3-periphery-main/contracts/base/PeripheryPaymentsWithFee.sol +55 -0
  1050. package/lib/v3-periphery-main/contracts/base/PeripheryValidation.sol +11 -0
  1051. package/lib/v3-periphery-main/contracts/base/PoolInitializer.sol +32 -0
  1052. package/lib/v3-periphery-main/contracts/base/SelfPermit.sol +63 -0
  1053. package/lib/v3-periphery-main/contracts/examples/PairFlash.sol +149 -0
  1054. package/lib/v3-periphery-main/contracts/interfaces/IERC20Metadata.sol +18 -0
  1055. package/lib/v3-periphery-main/contracts/interfaces/IERC721Permit.sol +32 -0
  1056. package/lib/v3-periphery-main/contracts/interfaces/IMulticall.sol +13 -0
  1057. package/lib/v3-periphery-main/contracts/interfaces/INonfungiblePositionManager.sol +179 -0
  1058. package/lib/v3-periphery-main/contracts/interfaces/INonfungibleTokenPositionDescriptor.sol +17 -0
  1059. package/lib/v3-periphery-main/contracts/interfaces/IPeripheryImmutableState.sol +12 -0
  1060. package/lib/v3-periphery-main/contracts/interfaces/IPeripheryPayments.sol +28 -0
  1061. package/lib/v3-periphery-main/contracts/interfaces/IPeripheryPaymentsWithFee.sol +29 -0
  1062. package/lib/v3-periphery-main/contracts/interfaces/IPoolInitializer.sol +22 -0
  1063. package/lib/v3-periphery-main/contracts/interfaces/IQuoter.sol +51 -0
  1064. package/lib/v3-periphery-main/contracts/interfaces/IQuoterV2.sol +98 -0
  1065. package/lib/v3-periphery-main/contracts/interfaces/ISelfPermit.sol +76 -0
  1066. package/lib/v3-periphery-main/contracts/interfaces/ISwapRouter.sol +67 -0
  1067. package/lib/v3-periphery-main/contracts/interfaces/ITickLens.sol +25 -0
  1068. package/lib/v3-periphery-main/contracts/interfaces/IV3Migrator.sol +34 -0
  1069. package/lib/v3-periphery-main/contracts/interfaces/external/IERC1271.sol +16 -0
  1070. package/lib/v3-periphery-main/contracts/interfaces/external/IERC20PermitAllowed.sol +27 -0
  1071. package/lib/v3-periphery-main/contracts/interfaces/external/IWETH9.sol +13 -0
  1072. package/lib/v3-periphery-main/contracts/lens/Quoter.sol +170 -0
  1073. package/lib/v3-periphery-main/contracts/lens/QuoterV2.sol +273 -0
  1074. package/lib/v3-periphery-main/contracts/lens/README.md +4 -0
  1075. package/lib/v3-periphery-main/contracts/lens/TickLens.sol +42 -0
  1076. package/lib/v3-periphery-main/contracts/lens/UniswapInterfaceMulticall.sol +39 -0
  1077. package/lib/v3-periphery-main/contracts/libraries/BytesLib.sol +101 -0
  1078. package/lib/v3-periphery-main/contracts/libraries/CallbackValidation.sol +36 -0
  1079. package/lib/v3-periphery-main/contracts/libraries/ChainId.sol +13 -0
  1080. package/lib/v3-periphery-main/contracts/libraries/HexStrings.sol +29 -0
  1081. package/lib/v3-periphery-main/contracts/libraries/LiquidityAmounts.sol +137 -0
  1082. package/lib/v3-periphery-main/contracts/libraries/NFTDescriptor.sol +477 -0
  1083. package/lib/v3-periphery-main/contracts/libraries/NFTSVG.sol +406 -0
  1084. package/lib/v3-periphery-main/contracts/libraries/OracleLibrary.sol +180 -0
  1085. package/lib/v3-periphery-main/contracts/libraries/Path.sol +69 -0
  1086. package/lib/v3-periphery-main/contracts/libraries/PoolAddress.sol +48 -0
  1087. package/lib/v3-periphery-main/contracts/libraries/PoolTicksCounter.sol +96 -0
  1088. package/lib/v3-periphery-main/contracts/libraries/PositionKey.sol +13 -0
  1089. package/lib/v3-periphery-main/contracts/libraries/PositionValue.sol +167 -0
  1090. package/lib/v3-periphery-main/contracts/libraries/SqrtPriceMathPartial.sol +62 -0
  1091. package/lib/v3-periphery-main/contracts/libraries/TokenRatioSortOrder.sol +12 -0
  1092. package/lib/v3-periphery-main/contracts/libraries/TransferHelper.sol +60 -0
  1093. package/lib/v3-periphery-main/contracts/test/Base64Test.sol +16 -0
  1094. package/lib/v3-periphery-main/contracts/test/LiquidityAmountsTest.sol +120 -0
  1095. package/lib/v3-periphery-main/contracts/test/MockObservable.sol +48 -0
  1096. package/lib/v3-periphery-main/contracts/test/MockObservations.sol +82 -0
  1097. package/lib/v3-periphery-main/contracts/test/MockTimeNonfungiblePositionManager.sol +23 -0
  1098. package/lib/v3-periphery-main/contracts/test/MockTimeSwapRouter.sol +19 -0
  1099. package/lib/v3-periphery-main/contracts/test/NFTDescriptorTest.sol +75 -0
  1100. package/lib/v3-periphery-main/contracts/test/NonfungiblePositionManagerPositionsGasTest.sol +18 -0
  1101. package/lib/v3-periphery-main/contracts/test/OracleTest.sol +67 -0
  1102. package/lib/v3-periphery-main/contracts/test/PathTest.sol +37 -0
  1103. package/lib/v3-periphery-main/contracts/test/PeripheryImmutableStateTest.sol +8 -0
  1104. package/lib/v3-periphery-main/contracts/test/PoolAddressTest.sol +30 -0
  1105. package/lib/v3-periphery-main/contracts/test/PoolTicksCounterTest.sol +18 -0
  1106. package/lib/v3-periphery-main/contracts/test/PositionValueTest.sol +57 -0
  1107. package/lib/v3-periphery-main/contracts/test/SelfPermitTest.sol +9 -0
  1108. package/lib/v3-periphery-main/contracts/test/TestCallbackValidation.sol +15 -0
  1109. package/lib/v3-periphery-main/contracts/test/TestERC20.sol +10 -0
  1110. package/lib/v3-periphery-main/contracts/test/TestERC20Metadata.sol +14 -0
  1111. package/lib/v3-periphery-main/contracts/test/TestERC20PermitAllowed.sol +24 -0
  1112. package/lib/v3-periphery-main/contracts/test/TestMulticall.sol +30 -0
  1113. package/lib/v3-periphery-main/contracts/test/TestPositionNFTOwner.sol +28 -0
  1114. package/lib/v3-periphery-main/contracts/test/TestUniswapV3Callee.sol +62 -0
  1115. package/lib/v3-periphery-main/contracts/test/TickLensTest.sol +15 -0
  1116. package/lib/v3-periphery-main/deploys.md +25 -0
  1117. package/lib/v3-periphery-main/hardhat.config.ts +104 -0
  1118. package/lib/v3-periphery-main/package.json +68 -0
  1119. package/lib/v3-periphery-main/test/Base64.spec.ts +81 -0
  1120. package/lib/v3-periphery-main/test/CallbackValidation.spec.ts +56 -0
  1121. package/lib/v3-periphery-main/test/LiquidityAmounts.spec.ts +241 -0
  1122. package/lib/v3-periphery-main/test/Multicall.spec.ts +65 -0
  1123. package/lib/v3-periphery-main/test/NFTDescriptor.spec.ts +907 -0
  1124. package/lib/v3-periphery-main/test/NonfungiblePositionManager.spec.ts +1304 -0
  1125. package/lib/v3-periphery-main/test/NonfungibleTokenPositionDescriptor.spec.ts +217 -0
  1126. package/lib/v3-periphery-main/test/OracleLibrary.spec.ts +675 -0
  1127. package/lib/v3-periphery-main/test/PairFlash.spec.ts +168 -0
  1128. package/lib/v3-periphery-main/test/Path.spec.ts +90 -0
  1129. package/lib/v3-periphery-main/test/PeripheryImmutableState.spec.ts +56 -0
  1130. package/lib/v3-periphery-main/test/PoolAddress.spec.ts +72 -0
  1131. package/lib/v3-periphery-main/test/PoolTicksCounter.spec.ts +280 -0
  1132. package/lib/v3-periphery-main/test/PositionValue.spec.ts +490 -0
  1133. package/lib/v3-periphery-main/test/Quoter.spec.ts +201 -0
  1134. package/lib/v3-periphery-main/test/QuoterV2.spec.ts +578 -0
  1135. package/lib/v3-periphery-main/test/SelfPermit.spec.ts +198 -0
  1136. package/lib/v3-periphery-main/test/SwapRouter.gas.spec.ts +453 -0
  1137. package/lib/v3-periphery-main/test/SwapRouter.spec.ts +916 -0
  1138. package/lib/v3-periphery-main/test/TickLens.spec.ts +223 -0
  1139. package/lib/v3-periphery-main/test/V3Migrator.spec.ts +446 -0
  1140. package/lib/v3-periphery-main/test/__snapshots__/Base64.spec.ts.snap +32 -0
  1141. package/lib/v3-periphery-main/test/__snapshots__/LiquidityAmounts.spec.ts.snap +21 -0
  1142. package/lib/v3-periphery-main/test/__snapshots__/Multicall.spec.ts.snap +5 -0
  1143. package/lib/v3-periphery-main/test/__snapshots__/NFTDescriptor.spec.ts.snap +7 -0
  1144. package/lib/v3-periphery-main/test/__snapshots__/NFTDescriptor.svg +1 -0
  1145. package/lib/v3-periphery-main/test/__snapshots__/NonfungiblePositionManager.spec.ts.snap +41 -0
  1146. package/lib/v3-periphery-main/test/__snapshots__/OracleLibrary.spec.ts.snap +3 -0
  1147. package/lib/v3-periphery-main/test/__snapshots__/PairFlash.spec.ts.snap +3 -0
  1148. package/lib/v3-periphery-main/test/__snapshots__/Path.spec.ts.snap +3 -0
  1149. package/lib/v3-periphery-main/test/__snapshots__/PeripheryImmutableState.spec.ts.snap +3 -0
  1150. package/lib/v3-periphery-main/test/__snapshots__/PoolAddress.spec.ts.snap +5 -0
  1151. package/lib/v3-periphery-main/test/__snapshots__/PositionValue.spec.ts.snap +11 -0
  1152. package/lib/v3-periphery-main/test/__snapshots__/QuoterV2.spec.ts.snap +51 -0
  1153. package/lib/v3-periphery-main/test/__snapshots__/SwapRouter.gas.spec.ts.snap +37 -0
  1154. package/lib/v3-periphery-main/test/__snapshots__/SwapRouter.spec.ts.snap +3 -0
  1155. package/lib/v3-periphery-main/test/__snapshots__/TickLens.spec.ts.snap +5 -0
  1156. package/lib/v3-periphery-main/test/__snapshots__/V3Migrator.spec.ts.snap +3 -0
  1157. package/lib/v3-periphery-main/test/contracts/WETH9.json +156 -0
  1158. package/lib/v3-periphery-main/test/shared/base64.ts +7 -0
  1159. package/lib/v3-periphery-main/test/shared/completeFixture.ts +63 -0
  1160. package/lib/v3-periphery-main/test/shared/computePoolAddress.ts +22 -0
  1161. package/lib/v3-periphery-main/test/shared/constants.ts +15 -0
  1162. package/lib/v3-periphery-main/test/shared/encodePriceSqrt.ts +16 -0
  1163. package/lib/v3-periphery-main/test/shared/expandTo18Decimals.ts +5 -0
  1164. package/lib/v3-periphery-main/test/shared/expect.ts +8 -0
  1165. package/lib/v3-periphery-main/test/shared/externalFixtures.ts +57 -0
  1166. package/lib/v3-periphery-main/test/shared/extractJSONFromURI.ts +5 -0
  1167. package/lib/v3-periphery-main/test/shared/formatSqrtRatioX96.spec.ts +30 -0
  1168. package/lib/v3-periphery-main/test/shared/formatSqrtRatioX96.ts +30 -0
  1169. package/lib/v3-periphery-main/test/shared/getPermitNFTSignature.ts +57 -0
  1170. package/lib/v3-periphery-main/test/shared/path.ts +61 -0
  1171. package/lib/v3-periphery-main/test/shared/permit.ts +61 -0
  1172. package/lib/v3-periphery-main/test/shared/poolAtAddress.ts +7 -0
  1173. package/lib/v3-periphery-main/test/shared/quoter.ts +153 -0
  1174. package/lib/v3-periphery-main/test/shared/snapshotGasCost.ts +27 -0
  1175. package/lib/v3-periphery-main/test/shared/ticks.ts +9 -0
  1176. package/lib/v3-periphery-main/test/shared/tokenSort.ts +10 -0
  1177. package/lib/v3-periphery-main/testnet-deploys.md +3 -0
  1178. package/lib/v3-periphery-main/tsconfig.json +14 -0
  1179. package/lib/v3-periphery-main/yarn.lock +8111 -0
  1180. package/package.json +44 -0
  1181. package/src/LPStateStorage.sol +74 -0
  1182. package/src/MinimalPositionDescriptor.sol +38 -0
  1183. package/src/NonfungiblePositionManagerImporter.sol +13 -0
  1184. package/src/QuoterV2Importer.sol +9 -0
  1185. package/src/RapidexV3FactoryImporter.sol +6 -0
  1186. package/src/SwapRouterImporter.sol +9 -0
  1187. package/src/TestToken.sol +60 -0
  1188. package/src/WMST.sol +63 -0
  1189. package/src/flattened/LPStateStorage.flat.sol +76 -0
  1190. package/src/flattened/MinimalPositionDescriptor.flat.sol +40 -0
  1191. package/src/flattened/NonfungiblePositionManagerImporter.flat.sol +2695 -0
  1192. package/src/flattened/QuoterV2Importer.flat.sol +1616 -0
  1193. package/src/flattened/RapidexV3FactoryImporter.flat.sol +3193 -0
  1194. package/src/flattened/SwapRouterImporter.flat.sol +1811 -0
  1195. package/src/flattened/TestToken.flat.sol +62 -0
  1196. package/src/flattened/WMST.flat.sol +65 -0
@@ -0,0 +1,3193 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity <0.8.0 =0.7.6 >=0.4.0 >=0.5.0 >=0.6.0 >=0.7.0;
3
+
4
+ // lib/v3-core-main/contracts/libraries/BitMath.sol
5
+
6
+ /// @title BitMath
7
+ /// @dev This library provides functionality for computing bit properties of an unsigned integer
8
+ library BitMath {
9
+ /// @notice Returns the index of the most significant bit of the number,
10
+ /// where the least significant bit is at index 0 and the most significant bit is at index 255
11
+ /// @dev The function satisfies the property:
12
+ /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)
13
+ /// @param x the value for which to compute the most significant bit, must be greater than 0
14
+ /// @return r the index of the most significant bit
15
+ function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {
16
+ require(x > 0);
17
+
18
+ if (x >= 0x100000000000000000000000000000000) {
19
+ x >>= 128;
20
+ r += 128;
21
+ }
22
+ if (x >= 0x10000000000000000) {
23
+ x >>= 64;
24
+ r += 64;
25
+ }
26
+ if (x >= 0x100000000) {
27
+ x >>= 32;
28
+ r += 32;
29
+ }
30
+ if (x >= 0x10000) {
31
+ x >>= 16;
32
+ r += 16;
33
+ }
34
+ if (x >= 0x100) {
35
+ x >>= 8;
36
+ r += 8;
37
+ }
38
+ if (x >= 0x10) {
39
+ x >>= 4;
40
+ r += 4;
41
+ }
42
+ if (x >= 0x4) {
43
+ x >>= 2;
44
+ r += 2;
45
+ }
46
+ if (x >= 0x2) r += 1;
47
+ }
48
+
49
+ /// @notice Returns the index of the least significant bit of the number,
50
+ /// where the least significant bit is at index 0 and the most significant bit is at index 255
51
+ /// @dev The function satisfies the property:
52
+ /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)
53
+ /// @param x the value for which to compute the least significant bit, must be greater than 0
54
+ /// @return r the index of the least significant bit
55
+ function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {
56
+ require(x > 0);
57
+
58
+ r = 255;
59
+ if (x & type(uint128).max > 0) {
60
+ r -= 128;
61
+ } else {
62
+ x >>= 128;
63
+ }
64
+ if (x & type(uint64).max > 0) {
65
+ r -= 64;
66
+ } else {
67
+ x >>= 64;
68
+ }
69
+ if (x & type(uint32).max > 0) {
70
+ r -= 32;
71
+ } else {
72
+ x >>= 32;
73
+ }
74
+ if (x & type(uint16).max > 0) {
75
+ r -= 16;
76
+ } else {
77
+ x >>= 16;
78
+ }
79
+ if (x & type(uint8).max > 0) {
80
+ r -= 8;
81
+ } else {
82
+ x >>= 8;
83
+ }
84
+ if (x & 0xf > 0) {
85
+ r -= 4;
86
+ } else {
87
+ x >>= 4;
88
+ }
89
+ if (x & 0x3 > 0) {
90
+ r -= 2;
91
+ } else {
92
+ x >>= 2;
93
+ }
94
+ if (x & 0x1 > 0) r -= 1;
95
+ }
96
+ }
97
+
98
+ // lib/v3-core-main/contracts/libraries/FixedPoint128.sol
99
+
100
+ /// @title FixedPoint128
101
+ /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
102
+ library FixedPoint128 {
103
+ uint256 internal constant Q128 = 0x100000000000000000000000000000000;
104
+ }
105
+
106
+ // lib/v3-core-main/contracts/libraries/FixedPoint96.sol
107
+
108
+ /// @title FixedPoint96
109
+ /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
110
+ /// @dev Used in SqrtPriceMath.sol
111
+ library FixedPoint96 {
112
+ uint8 internal constant RESOLUTION = 96;
113
+ uint256 internal constant Q96 = 0x1000000000000000000000000;
114
+ }
115
+
116
+ // lib/v3-core-main/contracts/libraries/FullMath.sol
117
+
118
+ /// @title Contains 512-bit math functions
119
+ /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
120
+ /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
121
+ library FullMath {
122
+ /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
123
+ /// @param a The multiplicand
124
+ /// @param b The multiplier
125
+ /// @param denominator The divisor
126
+ /// @return result The 256-bit result
127
+ /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
128
+ function mulDiv(
129
+ uint256 a,
130
+ uint256 b,
131
+ uint256 denominator
132
+ ) internal pure returns (uint256 result) {
133
+ // 512-bit multiply [prod1 prod0] = a * b
134
+ // Compute the product mod 2**256 and mod 2**256 - 1
135
+ // then use the Chinese Remainder Theorem to reconstruct
136
+ // the 512 bit result. The result is stored in two 256
137
+ // variables such that product = prod1 * 2**256 + prod0
138
+ uint256 prod0; // Least significant 256 bits of the product
139
+ uint256 prod1; // Most significant 256 bits of the product
140
+ assembly {
141
+ let mm := mulmod(a, b, not(0))
142
+ prod0 := mul(a, b)
143
+ prod1 := sub(sub(mm, prod0), lt(mm, prod0))
144
+ }
145
+
146
+ // Handle non-overflow cases, 256 by 256 division
147
+ if (prod1 == 0) {
148
+ require(denominator > 0);
149
+ assembly {
150
+ result := div(prod0, denominator)
151
+ }
152
+ return result;
153
+ }
154
+
155
+ // Make sure the result is less than 2**256.
156
+ // Also prevents denominator == 0
157
+ require(denominator > prod1);
158
+
159
+ ///////////////////////////////////////////////
160
+ // 512 by 256 division.
161
+ ///////////////////////////////////////////////
162
+
163
+ // Make division exact by subtracting the remainder from [prod1 prod0]
164
+ // Compute remainder using mulmod
165
+ uint256 remainder;
166
+ assembly {
167
+ remainder := mulmod(a, b, denominator)
168
+ }
169
+ // Subtract 256 bit number from 512 bit number
170
+ assembly {
171
+ prod1 := sub(prod1, gt(remainder, prod0))
172
+ prod0 := sub(prod0, remainder)
173
+ }
174
+
175
+ // Factor powers of two out of denominator
176
+ // Compute largest power of two divisor of denominator.
177
+ // Always >= 1.
178
+ uint256 twos = -denominator & denominator;
179
+ // Divide denominator by power of two
180
+ assembly {
181
+ denominator := div(denominator, twos)
182
+ }
183
+
184
+ // Divide [prod1 prod0] by the factors of two
185
+ assembly {
186
+ prod0 := div(prod0, twos)
187
+ }
188
+ // Shift in bits from prod1 into prod0. For this we need
189
+ // to flip `twos` such that it is 2**256 / twos.
190
+ // If twos is zero, then it becomes one
191
+ assembly {
192
+ twos := add(div(sub(0, twos), twos), 1)
193
+ }
194
+ prod0 |= prod1 * twos;
195
+
196
+ // Invert denominator mod 2**256
197
+ // Now that denominator is an odd number, it has an inverse
198
+ // modulo 2**256 such that denominator * inv = 1 mod 2**256.
199
+ // Compute the inverse by starting with a seed that is correct
200
+ // correct for four bits. That is, denominator * inv = 1 mod 2**4
201
+ uint256 inv = (3 * denominator) ^ 2;
202
+ // Now use Newton-Raphson iteration to improve the precision.
203
+ // Thanks to Hensel's lifting lemma, this also works in modular
204
+ // arithmetic, doubling the correct bits in each step.
205
+ inv *= 2 - denominator * inv; // inverse mod 2**8
206
+ inv *= 2 - denominator * inv; // inverse mod 2**16
207
+ inv *= 2 - denominator * inv; // inverse mod 2**32
208
+ inv *= 2 - denominator * inv; // inverse mod 2**64
209
+ inv *= 2 - denominator * inv; // inverse mod 2**128
210
+ inv *= 2 - denominator * inv; // inverse mod 2**256
211
+
212
+ // Because the division is now exact we can divide by multiplying
213
+ // with the modular inverse of denominator. This will give us the
214
+ // correct result modulo 2**256. Since the precoditions guarantee
215
+ // that the outcome is less than 2**256, this is the final result.
216
+ // We don't need to compute the high bits of the result and prod1
217
+ // is no longer required.
218
+ result = prod0 * inv;
219
+ return result;
220
+ }
221
+
222
+ /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
223
+ /// @param a The multiplicand
224
+ /// @param b The multiplier
225
+ /// @param denominator The divisor
226
+ /// @return result The 256-bit result
227
+ function mulDivRoundingUp(
228
+ uint256 a,
229
+ uint256 b,
230
+ uint256 denominator
231
+ ) internal pure returns (uint256 result) {
232
+ result = mulDiv(a, b, denominator);
233
+ if (mulmod(a, b, denominator) > 0) {
234
+ require(result < type(uint256).max);
235
+ result++;
236
+ }
237
+ }
238
+ }
239
+
240
+ // lib/v3-core-main/contracts/interfaces/IERC20Minimal.sol
241
+
242
+ /// @title Minimal ERC20 interface for Uniswap
243
+ /// @notice Contains a subset of the full ERC20 interface that is used in Uniswap V3
244
+ interface IERC20Minimal {
245
+ /// @notice Returns the balance of a token
246
+ /// @param account The account for which to look up the number of tokens it has, i.e. its balance
247
+ /// @return The number of tokens held by the account
248
+ function balanceOf(address account) external view returns (uint256);
249
+
250
+ /// @notice Transfers the amount of token from the `msg.sender` to the recipient
251
+ /// @param recipient The account that will receive the amount transferred
252
+ /// @param amount The number of tokens to send from the sender to the recipient
253
+ /// @return Returns true for a successful transfer, false for an unsuccessful transfer
254
+ function transfer(address recipient, uint256 amount) external returns (bool);
255
+
256
+ /// @notice Returns the current allowance given to a spender by an owner
257
+ /// @param owner The account of the token owner
258
+ /// @param spender The account of the token spender
259
+ /// @return The current allowance granted by `owner` to `spender`
260
+ function allowance(address owner, address spender) external view returns (uint256);
261
+
262
+ /// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
263
+ /// @param spender The account which will be allowed to spend a given amount of the owners tokens
264
+ /// @param amount The amount of tokens allowed to be used by `spender`
265
+ /// @return Returns true for a successful approval, false for unsuccessful
266
+ function approve(address spender, uint256 amount) external returns (bool);
267
+
268
+ /// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
269
+ /// @param sender The account from which the transfer will be initiated
270
+ /// @param recipient The recipient of the transfer
271
+ /// @param amount The amount of the transfer
272
+ /// @return Returns true for a successful transfer, false for unsuccessful
273
+ function transferFrom(
274
+ address sender,
275
+ address recipient,
276
+ uint256 amount
277
+ ) external returns (bool);
278
+
279
+ /// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
280
+ /// @param from The account from which the tokens were sent, i.e. the balance decreased
281
+ /// @param to The account to which the tokens were sent, i.e. the balance increased
282
+ /// @param value The amount of tokens that were transferred
283
+ event Transfer(address indexed from, address indexed to, uint256 value);
284
+
285
+ /// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
286
+ /// @param owner The account that approved spending of its tokens
287
+ /// @param spender The account for which the spending allowance was modified
288
+ /// @param value The new allowance from the owner to the spender
289
+ event Approval(address indexed owner, address indexed spender, uint256 value);
290
+ }
291
+
292
+ // lib/v3-core-main/contracts/interfaces/IUniswapV3Factory.sol
293
+
294
+ /// @title The interface for the Uniswap V3 Factory
295
+ /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
296
+ interface IUniswapV3Factory {
297
+ /// @notice Emitted when the owner of the factory is changed
298
+ /// @param oldOwner The owner before the owner was changed
299
+ /// @param newOwner The owner after the owner was changed
300
+ event OwnerChanged(address indexed oldOwner, address indexed newOwner);
301
+
302
+ /// @notice Emitted when a pool is created
303
+ /// @param token0 The first token of the pool by address sort order
304
+ /// @param token1 The second token of the pool by address sort order
305
+ /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
306
+ /// @param tickSpacing The minimum number of ticks between initialized ticks
307
+ /// @param pool The address of the created pool
308
+ event PoolCreated(
309
+ address indexed token0,
310
+ address indexed token1,
311
+ uint24 indexed fee,
312
+ int24 tickSpacing,
313
+ address pool
314
+ );
315
+
316
+ /// @notice Emitted when a new fee amount is enabled for pool creation via the factory
317
+ /// @param fee The enabled fee, denominated in hundredths of a bip
318
+ /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
319
+ event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);
320
+
321
+ /// @notice Returns the current owner of the factory
322
+ /// @dev Can be changed by the current owner via setOwner
323
+ /// @return The address of the factory owner
324
+ function owner() external view returns (address);
325
+
326
+ /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
327
+ /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
328
+ /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
329
+ /// @return The tick spacing
330
+ function feeAmountTickSpacing(uint24 fee) external view returns (int24);
331
+
332
+ /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
333
+ /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
334
+ /// @param tokenA The contract address of either token0 or token1
335
+ /// @param tokenB The contract address of the other token
336
+ /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
337
+ /// @return pool The pool address
338
+ function getPool(
339
+ address tokenA,
340
+ address tokenB,
341
+ uint24 fee
342
+ ) external view returns (address pool);
343
+
344
+ /// @notice Creates a pool for the given two tokens and fee
345
+ /// @param tokenA One of the two tokens in the desired pool
346
+ /// @param tokenB The other of the two tokens in the desired pool
347
+ /// @param fee The desired fee for the pool
348
+ /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
349
+ /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
350
+ /// are invalid.
351
+ /// @return pool The address of the newly created pool
352
+ function createPool(
353
+ address tokenA,
354
+ address tokenB,
355
+ uint24 fee
356
+ ) external returns (address pool);
357
+
358
+ /// @notice Updates the owner of the factory
359
+ /// @dev Must be called by the current owner
360
+ /// @param _owner The new owner of the factory
361
+ function setOwner(address _owner) external;
362
+
363
+ /// @notice Enables a fee amount with the given tickSpacing
364
+ /// @dev Fee amounts may never be removed once enabled
365
+ /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
366
+ /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
367
+ function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
368
+ }
369
+
370
+ // lib/v3-core-main/contracts/interfaces/callback/IUniswapV3FlashCallback.sol
371
+
372
+ /// @title Callback for IUniswapV3PoolActions#flash
373
+ /// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface
374
+ interface IUniswapV3FlashCallback {
375
+ /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.
376
+ /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.
377
+ /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
378
+ /// @param fee0 The fee amount in token0 due to the pool by the end of the flash
379
+ /// @param fee1 The fee amount in token1 due to the pool by the end of the flash
380
+ /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call
381
+ function uniswapV3FlashCallback(
382
+ uint256 fee0,
383
+ uint256 fee1,
384
+ bytes calldata data
385
+ ) external;
386
+ }
387
+
388
+ // lib/v3-core-main/contracts/interfaces/callback/IUniswapV3MintCallback.sol
389
+
390
+ /// @title Callback for IUniswapV3PoolActions#mint
391
+ /// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface
392
+ interface IUniswapV3MintCallback {
393
+ /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
394
+ /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.
395
+ /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
396
+ /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
397
+ /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
398
+ /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
399
+ function uniswapV3MintCallback(
400
+ uint256 amount0Owed,
401
+ uint256 amount1Owed,
402
+ bytes calldata data
403
+ ) external;
404
+ }
405
+
406
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolActions.sol
407
+
408
+ /// @title Permissionless pool actions
409
+ /// @notice Contains pool methods that can be called by anyone
410
+ interface IUniswapV3PoolActions {
411
+ /// @notice Sets the initial price for the pool
412
+ /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
413
+ /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
414
+ function initialize(uint160 sqrtPriceX96) external;
415
+
416
+ /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
417
+ /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
418
+ /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
419
+ /// on tickLower, tickUpper, the amount of liquidity, and the current price.
420
+ /// @param recipient The address for which the liquidity will be created
421
+ /// @param tickLower The lower tick of the position in which to add liquidity
422
+ /// @param tickUpper The upper tick of the position in which to add liquidity
423
+ /// @param amount The amount of liquidity to mint
424
+ /// @param data Any data that should be passed through to the callback
425
+ /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
426
+ /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
427
+ function mint(
428
+ address recipient,
429
+ int24 tickLower,
430
+ int24 tickUpper,
431
+ uint128 amount,
432
+ bytes calldata data
433
+ ) external returns (uint256 amount0, uint256 amount1);
434
+
435
+ /// @notice Collects tokens owed to a position
436
+ /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
437
+ /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
438
+ /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
439
+ /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
440
+ /// @param recipient The address which should receive the fees collected
441
+ /// @param tickLower The lower tick of the position for which to collect fees
442
+ /// @param tickUpper The upper tick of the position for which to collect fees
443
+ /// @param amount0Requested How much token0 should be withdrawn from the fees owed
444
+ /// @param amount1Requested How much token1 should be withdrawn from the fees owed
445
+ /// @return amount0 The amount of fees collected in token0
446
+ /// @return amount1 The amount of fees collected in token1
447
+ function collect(
448
+ address recipient,
449
+ int24 tickLower,
450
+ int24 tickUpper,
451
+ uint128 amount0Requested,
452
+ uint128 amount1Requested
453
+ ) external returns (uint128 amount0, uint128 amount1);
454
+
455
+ /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
456
+ /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
457
+ /// @dev Fees must be collected separately via a call to #collect
458
+ /// @param tickLower The lower tick of the position for which to burn liquidity
459
+ /// @param tickUpper The upper tick of the position for which to burn liquidity
460
+ /// @param amount How much liquidity to burn
461
+ /// @return amount0 The amount of token0 sent to the recipient
462
+ /// @return amount1 The amount of token1 sent to the recipient
463
+ function burn(
464
+ int24 tickLower,
465
+ int24 tickUpper,
466
+ uint128 amount
467
+ ) external returns (uint256 amount0, uint256 amount1);
468
+
469
+ /// @notice Swap token0 for token1, or token1 for token0
470
+ /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
471
+ /// @param recipient The address to receive the output of the swap
472
+ /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
473
+ /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
474
+ /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
475
+ /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
476
+ /// @param data Any data to be passed through to the callback
477
+ /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
478
+ /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
479
+ function swap(
480
+ address recipient,
481
+ bool zeroForOne,
482
+ int256 amountSpecified,
483
+ uint160 sqrtPriceLimitX96,
484
+ bytes calldata data
485
+ ) external returns (int256 amount0, int256 amount1);
486
+
487
+ /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
488
+ /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
489
+ /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
490
+ /// with 0 amount{0,1} and sending the donation amount(s) from the callback
491
+ /// @param recipient The address which will receive the token0 and token1 amounts
492
+ /// @param amount0 The amount of token0 to send
493
+ /// @param amount1 The amount of token1 to send
494
+ /// @param data Any data to be passed through to the callback
495
+ function flash(
496
+ address recipient,
497
+ uint256 amount0,
498
+ uint256 amount1,
499
+ bytes calldata data
500
+ ) external;
501
+
502
+ /// @notice Increase the maximum number of price and liquidity observations that this pool will store
503
+ /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
504
+ /// the input observationCardinalityNext.
505
+ /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
506
+ function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
507
+ }
508
+
509
+ // lib/v3-core-main/contracts/interfaces/IUniswapV3PoolDeployer.sol
510
+
511
+ /// @title An interface for a contract that is capable of deploying Uniswap V3 Pools
512
+ /// @notice A contract that constructs a pool must implement this to pass arguments to the pool
513
+ /// @dev This is used to avoid having constructor arguments in the pool contract, which results in the init code hash
514
+ /// of the pool being constant allowing the CREATE2 address of the pool to be cheaply computed on-chain
515
+ interface IUniswapV3PoolDeployer {
516
+ /// @notice Get the parameters to be used in constructing the pool, set transiently during pool creation.
517
+ /// @dev Called by the pool constructor to fetch the parameters of the pool
518
+ /// Returns factory The factory address
519
+ /// Returns token0 The first token of the pool by address sort order
520
+ /// Returns token1 The second token of the pool by address sort order
521
+ /// Returns fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
522
+ /// Returns tickSpacing The minimum number of ticks between initialized ticks
523
+ function parameters()
524
+ external
525
+ view
526
+ returns (
527
+ address factory,
528
+ address token0,
529
+ address token1,
530
+ uint24 fee,
531
+ int24 tickSpacing
532
+ );
533
+ }
534
+
535
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol
536
+
537
+ /// @title Pool state that is not stored
538
+ /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
539
+ /// blockchain. The functions here may have variable gas costs.
540
+ interface IUniswapV3PoolDerivedState {
541
+ /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
542
+ /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
543
+ /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
544
+ /// you must call it with secondsAgos = [3600, 0].
545
+ /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
546
+ /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
547
+ /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
548
+ /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
549
+ /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
550
+ /// timestamp
551
+ function observe(uint32[] calldata secondsAgos)
552
+ external
553
+ view
554
+ returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
555
+
556
+ /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
557
+ /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
558
+ /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
559
+ /// snapshot is taken and the second snapshot is taken.
560
+ /// @param tickLower The lower tick of the range
561
+ /// @param tickUpper The upper tick of the range
562
+ /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
563
+ /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
564
+ /// @return secondsInside The snapshot of seconds per liquidity for the range
565
+ function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
566
+ external
567
+ view
568
+ returns (
569
+ int56 tickCumulativeInside,
570
+ uint160 secondsPerLiquidityInsideX128,
571
+ uint32 secondsInside
572
+ );
573
+ }
574
+
575
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolEvents.sol
576
+
577
+ /// @title Events emitted by a pool
578
+ /// @notice Contains all events emitted by the pool
579
+ interface IUniswapV3PoolEvents {
580
+ /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
581
+ /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
582
+ /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
583
+ /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
584
+ event Initialize(uint160 sqrtPriceX96, int24 tick);
585
+
586
+ /// @notice Emitted when liquidity is minted for a given position
587
+ /// @param sender The address that minted the liquidity
588
+ /// @param owner The owner of the position and recipient of any minted liquidity
589
+ /// @param tickLower The lower tick of the position
590
+ /// @param tickUpper The upper tick of the position
591
+ /// @param amount The amount of liquidity minted to the position range
592
+ /// @param amount0 How much token0 was required for the minted liquidity
593
+ /// @param amount1 How much token1 was required for the minted liquidity
594
+ event Mint(
595
+ address sender,
596
+ address indexed owner,
597
+ int24 indexed tickLower,
598
+ int24 indexed tickUpper,
599
+ uint128 amount,
600
+ uint256 amount0,
601
+ uint256 amount1
602
+ );
603
+
604
+ /// @notice Emitted when fees are collected by the owner of a position
605
+ /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
606
+ /// @param owner The owner of the position for which fees are collected
607
+ /// @param tickLower The lower tick of the position
608
+ /// @param tickUpper The upper tick of the position
609
+ /// @param amount0 The amount of token0 fees collected
610
+ /// @param amount1 The amount of token1 fees collected
611
+ event Collect(
612
+ address indexed owner,
613
+ address recipient,
614
+ int24 indexed tickLower,
615
+ int24 indexed tickUpper,
616
+ uint128 amount0,
617
+ uint128 amount1
618
+ );
619
+
620
+ /// @notice Emitted when a position's liquidity is removed
621
+ /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
622
+ /// @param owner The owner of the position for which liquidity is removed
623
+ /// @param tickLower The lower tick of the position
624
+ /// @param tickUpper The upper tick of the position
625
+ /// @param amount The amount of liquidity to remove
626
+ /// @param amount0 The amount of token0 withdrawn
627
+ /// @param amount1 The amount of token1 withdrawn
628
+ event Burn(
629
+ address indexed owner,
630
+ int24 indexed tickLower,
631
+ int24 indexed tickUpper,
632
+ uint128 amount,
633
+ uint256 amount0,
634
+ uint256 amount1
635
+ );
636
+
637
+ /// @notice Emitted by the pool for any swaps between token0 and token1
638
+ /// @param sender The address that initiated the swap call, and that received the callback
639
+ /// @param recipient The address that received the output of the swap
640
+ /// @param amount0 The delta of the token0 balance of the pool
641
+ /// @param amount1 The delta of the token1 balance of the pool
642
+ /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
643
+ /// @param liquidity The liquidity of the pool after the swap
644
+ /// @param tick The log base 1.0001 of price of the pool after the swap
645
+ event Swap(
646
+ address indexed sender,
647
+ address indexed recipient,
648
+ int256 amount0,
649
+ int256 amount1,
650
+ uint160 sqrtPriceX96,
651
+ uint128 liquidity,
652
+ int24 tick
653
+ );
654
+
655
+ /// @notice Emitted by the pool for any flashes of token0/token1
656
+ /// @param sender The address that initiated the swap call, and that received the callback
657
+ /// @param recipient The address that received the tokens from flash
658
+ /// @param amount0 The amount of token0 that was flashed
659
+ /// @param amount1 The amount of token1 that was flashed
660
+ /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
661
+ /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
662
+ event Flash(
663
+ address indexed sender,
664
+ address indexed recipient,
665
+ uint256 amount0,
666
+ uint256 amount1,
667
+ uint256 paid0,
668
+ uint256 paid1
669
+ );
670
+
671
+ /// @notice Emitted by the pool for increases to the number of observations that can be stored
672
+ /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
673
+ /// just before a mint/swap/burn.
674
+ /// @param observationCardinalityNextOld The previous value of the next observation cardinality
675
+ /// @param observationCardinalityNextNew The updated value of the next observation cardinality
676
+ event IncreaseObservationCardinalityNext(
677
+ uint16 observationCardinalityNextOld,
678
+ uint16 observationCardinalityNextNew
679
+ );
680
+
681
+ /// @notice Emitted when the protocol fee is changed by the pool
682
+ /// @param feeProtocol0Old The previous value of the token0 protocol fee
683
+ /// @param feeProtocol1Old The previous value of the token1 protocol fee
684
+ /// @param feeProtocol0New The updated value of the token0 protocol fee
685
+ /// @param feeProtocol1New The updated value of the token1 protocol fee
686
+ event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
687
+
688
+ /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
689
+ /// @param sender The address that collects the protocol fees
690
+ /// @param recipient The address that receives the collected protocol fees
691
+ /// @param amount0 The amount of token0 protocol fees that is withdrawn
692
+ /// @param amount0 The amount of token1 protocol fees that is withdrawn
693
+ event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
694
+ }
695
+
696
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol
697
+
698
+ /// @title Pool state that never changes
699
+ /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
700
+ interface IUniswapV3PoolImmutables {
701
+ /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
702
+ /// @return The contract address
703
+ function factory() external view returns (address);
704
+
705
+ /// @notice The first of the two tokens of the pool, sorted by address
706
+ /// @return The token contract address
707
+ function token0() external view returns (address);
708
+
709
+ /// @notice The second of the two tokens of the pool, sorted by address
710
+ /// @return The token contract address
711
+ function token1() external view returns (address);
712
+
713
+ /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
714
+ /// @return The fee
715
+ function fee() external view returns (uint24);
716
+
717
+ /// @notice The pool tick spacing
718
+ /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
719
+ /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
720
+ /// This value is an int24 to avoid casting even though it is always positive.
721
+ /// @return The tick spacing
722
+ function tickSpacing() external view returns (int24);
723
+
724
+ /// @notice The maximum amount of position liquidity that can use any tick in the range
725
+ /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
726
+ /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
727
+ /// @return The max amount of liquidity per tick
728
+ function maxLiquidityPerTick() external view returns (uint128);
729
+ }
730
+
731
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol
732
+
733
+ /// @title Permissioned pool actions
734
+ /// @notice Contains pool methods that may only be called by the factory owner
735
+ interface IUniswapV3PoolOwnerActions {
736
+ /// @notice Set the denominator of the protocol's % share of the fees
737
+ /// @param feeProtocol0 new protocol fee for token0 of the pool
738
+ /// @param feeProtocol1 new protocol fee for token1 of the pool
739
+ function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
740
+
741
+ /// @notice Collect the protocol fee accrued to the pool
742
+ /// @param recipient The address to which collected protocol fees should be sent
743
+ /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
744
+ /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
745
+ /// @return amount0 The protocol fee collected in token0
746
+ /// @return amount1 The protocol fee collected in token1
747
+ function collectProtocol(
748
+ address recipient,
749
+ uint128 amount0Requested,
750
+ uint128 amount1Requested
751
+ ) external returns (uint128 amount0, uint128 amount1);
752
+ }
753
+
754
+ // lib/v3-core-main/contracts/interfaces/pool/IUniswapV3PoolState.sol
755
+
756
+ /// @title Pool state that can change
757
+ /// @notice These methods compose the pool's state, and can change with any frequency including multiple times
758
+ /// per transaction
759
+ interface IUniswapV3PoolState {
760
+ /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
761
+ /// when accessed externally.
762
+ /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
763
+ /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
764
+ /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
765
+ /// boundary.
766
+ /// observationIndex The index of the last oracle observation that was written,
767
+ /// observationCardinality The current maximum number of observations stored in the pool,
768
+ /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
769
+ /// feeProtocol The protocol fee for both tokens of the pool.
770
+ /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
771
+ /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
772
+ /// unlocked Whether the pool is currently locked to reentrancy
773
+ function slot0()
774
+ external
775
+ view
776
+ returns (
777
+ uint160 sqrtPriceX96,
778
+ int24 tick,
779
+ uint16 observationIndex,
780
+ uint16 observationCardinality,
781
+ uint16 observationCardinalityNext,
782
+ uint8 feeProtocol,
783
+ bool unlocked
784
+ );
785
+
786
+ /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
787
+ /// @dev This value can overflow the uint256
788
+ function feeGrowthGlobal0X128() external view returns (uint256);
789
+
790
+ /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
791
+ /// @dev This value can overflow the uint256
792
+ function feeGrowthGlobal1X128() external view returns (uint256);
793
+
794
+ /// @notice The amounts of token0 and token1 that are owed to the protocol
795
+ /// @dev Protocol fees will never exceed uint128 max in either token
796
+ function protocolFees() external view returns (uint128 token0, uint128 token1);
797
+
798
+ /// @notice The currently in range liquidity available to the pool
799
+ /// @dev This value has no relationship to the total liquidity across all ticks
800
+ function liquidity() external view returns (uint128);
801
+
802
+ /// @notice Look up information about a specific tick in the pool
803
+ /// @param tick The tick to look up
804
+ /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
805
+ /// tick upper,
806
+ /// liquidityNet how much liquidity changes when the pool price crosses the tick,
807
+ /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
808
+ /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
809
+ /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
810
+ /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
811
+ /// secondsOutside the seconds spent on the other side of the tick from the current tick,
812
+ /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
813
+ /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
814
+ /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
815
+ /// a specific position.
816
+ function ticks(int24 tick)
817
+ external
818
+ view
819
+ returns (
820
+ uint128 liquidityGross,
821
+ int128 liquidityNet,
822
+ uint256 feeGrowthOutside0X128,
823
+ uint256 feeGrowthOutside1X128,
824
+ int56 tickCumulativeOutside,
825
+ uint160 secondsPerLiquidityOutsideX128,
826
+ uint32 secondsOutside,
827
+ bool initialized
828
+ );
829
+
830
+ /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
831
+ function tickBitmap(int16 wordPosition) external view returns (uint256);
832
+
833
+ /// @notice Returns the information about a position by the position's key
834
+ /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
835
+ /// @return _liquidity The amount of liquidity in the position,
836
+ /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
837
+ /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
838
+ /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
839
+ /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
840
+ function positions(bytes32 key)
841
+ external
842
+ view
843
+ returns (
844
+ uint128 _liquidity,
845
+ uint256 feeGrowthInside0LastX128,
846
+ uint256 feeGrowthInside1LastX128,
847
+ uint128 tokensOwed0,
848
+ uint128 tokensOwed1
849
+ );
850
+
851
+ /// @notice Returns data about a specific observation index
852
+ /// @param index The element of the observations array to fetch
853
+ /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
854
+ /// ago, rather than at a specific index in the array.
855
+ /// @return blockTimestamp The timestamp of the observation,
856
+ /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
857
+ /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
858
+ /// Returns initialized whether the observation has been initialized and the values are safe to use
859
+ function observations(uint256 index)
860
+ external
861
+ view
862
+ returns (
863
+ uint32 blockTimestamp,
864
+ int56 tickCumulative,
865
+ uint160 secondsPerLiquidityCumulativeX128,
866
+ bool initialized
867
+ );
868
+ }
869
+
870
+ // lib/v3-core-main/contracts/interfaces/callback/IUniswapV3SwapCallback.sol
871
+
872
+ /// @title Callback for IUniswapV3PoolActions#swap
873
+ /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
874
+ interface IUniswapV3SwapCallback {
875
+ /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
876
+ /// @dev In the implementation you must pay the pool tokens owed for the swap.
877
+ /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
878
+ /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
879
+ /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
880
+ /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
881
+ /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
882
+ /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
883
+ /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
884
+ function uniswapV3SwapCallback(
885
+ int256 amount0Delta,
886
+ int256 amount1Delta,
887
+ bytes calldata data
888
+ ) external;
889
+ }
890
+
891
+ // lib/v3-core-main/contracts/libraries/LiquidityMath.sol
892
+
893
+ /// @title Math library for liquidity
894
+ library LiquidityMath {
895
+ /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows
896
+ /// @param x The liquidity before change
897
+ /// @param y The delta by which liquidity should be changed
898
+ /// @return z The liquidity delta
899
+ function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {
900
+ if (y < 0) {
901
+ require((z = x - uint128(-y)) < x, 'LS');
902
+ } else {
903
+ require((z = x + uint128(y)) >= x, 'LA');
904
+ }
905
+ }
906
+ }
907
+
908
+ // lib/v3-core-main/contracts/libraries/LowGasSafeMath.sol
909
+
910
+ /// @title Optimized overflow and underflow safe math operations
911
+ /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost
912
+ library LowGasSafeMath {
913
+ /// @notice Returns x + y, reverts if sum overflows uint256
914
+ /// @param x The augend
915
+ /// @param y The addend
916
+ /// @return z The sum of x and y
917
+ function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
918
+ require((z = x + y) >= x);
919
+ }
920
+
921
+ /// @notice Returns x - y, reverts if underflows
922
+ /// @param x The minuend
923
+ /// @param y The subtrahend
924
+ /// @return z The difference of x and y
925
+ function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
926
+ require((z = x - y) <= x);
927
+ }
928
+
929
+ /// @notice Returns x * y, reverts if overflows
930
+ /// @param x The multiplicand
931
+ /// @param y The multiplier
932
+ /// @return z The product of x and y
933
+ function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
934
+ require(x == 0 || (z = x * y) / x == y);
935
+ }
936
+
937
+ /// @notice Returns x + y, reverts if overflows or underflows
938
+ /// @param x The augend
939
+ /// @param y The addend
940
+ /// @return z The sum of x and y
941
+ function add(int256 x, int256 y) internal pure returns (int256 z) {
942
+ require((z = x + y) >= x == (y >= 0));
943
+ }
944
+
945
+ /// @notice Returns x - y, reverts if overflows or underflows
946
+ /// @param x The minuend
947
+ /// @param y The subtrahend
948
+ /// @return z The difference of x and y
949
+ function sub(int256 x, int256 y) internal pure returns (int256 z) {
950
+ require((z = x - y) <= x == (y >= 0));
951
+ }
952
+ }
953
+
954
+ // lib/v3-core-main/contracts/NoDelegateCall.sol
955
+
956
+ /// @title Prevents delegatecall to a contract
957
+ /// @notice Base contract that provides a modifier for preventing delegatecall to methods in a child contract
958
+ abstract contract NoDelegateCall {
959
+ /// @dev The original address of this contract
960
+ address private immutable original;
961
+
962
+ constructor() {
963
+ // Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode.
964
+ // In other words, this variable won't change when it's checked at runtime.
965
+ original = address(this);
966
+ }
967
+
968
+ /// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method,
969
+ /// and the use of immutable means the address bytes are copied in every place the modifier is used.
970
+ function checkNotDelegateCall() private view {
971
+ require(address(this) == original);
972
+ }
973
+
974
+ /// @notice Prevents delegatecall into the modified method
975
+ modifier noDelegateCall() {
976
+ checkNotDelegateCall();
977
+ _;
978
+ }
979
+ }
980
+
981
+ // lib/v3-core-main/contracts/libraries/Oracle.sol
982
+
983
+ /// @title Oracle
984
+ /// @notice Provides price and liquidity data useful for a wide variety of system designs
985
+ /// @dev Instances of stored oracle data, "observations", are collected in the oracle array
986
+ /// Every pool is initialized with an oracle array length of 1. Anyone can pay the SSTOREs to increase the
987
+ /// maximum length of the oracle array. New slots will be added when the array is fully populated.
988
+ /// Observations are overwritten when the full length of the oracle array is populated.
989
+ /// The most recent observation is available, independent of the length of the oracle array, by passing 0 to observe()
990
+ library Oracle {
991
+ struct Observation {
992
+ // the block timestamp of the observation
993
+ uint32 blockTimestamp;
994
+ // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized
995
+ int56 tickCumulative;
996
+ // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized
997
+ uint160 secondsPerLiquidityCumulativeX128;
998
+ // whether or not the observation is initialized
999
+ bool initialized;
1000
+ }
1001
+
1002
+ /// @notice Transforms a previous observation into a new observation, given the passage of time and the current tick and liquidity values
1003
+ /// @dev blockTimestamp _must_ be chronologically equal to or greater than last.blockTimestamp, safe for 0 or 1 overflows
1004
+ /// @param last The specified observation to be transformed
1005
+ /// @param blockTimestamp The timestamp of the new observation
1006
+ /// @param tick The active tick at the time of the new observation
1007
+ /// @param liquidity The total in-range liquidity at the time of the new observation
1008
+ /// @return Observation The newly populated observation
1009
+ function transform(
1010
+ Observation memory last,
1011
+ uint32 blockTimestamp,
1012
+ int24 tick,
1013
+ uint128 liquidity
1014
+ ) private pure returns (Observation memory) {
1015
+ uint32 delta = blockTimestamp - last.blockTimestamp;
1016
+ return
1017
+ Observation({
1018
+ blockTimestamp: blockTimestamp,
1019
+ tickCumulative: last.tickCumulative + int56(tick) * delta,
1020
+ secondsPerLiquidityCumulativeX128: last.secondsPerLiquidityCumulativeX128 +
1021
+ ((uint160(delta) << 128) / (liquidity > 0 ? liquidity : 1)),
1022
+ initialized: true
1023
+ });
1024
+ }
1025
+
1026
+ /// @notice Initialize the oracle array by writing the first slot. Called once for the lifecycle of the observations array
1027
+ /// @param self The stored oracle array
1028
+ /// @param time The time of the oracle initialization, via block.timestamp truncated to uint32
1029
+ /// @return cardinality The number of populated elements in the oracle array
1030
+ /// @return cardinalityNext The new length of the oracle array, independent of population
1031
+ function initialize(Observation[65535] storage self, uint32 time)
1032
+ internal
1033
+ returns (uint16 cardinality, uint16 cardinalityNext)
1034
+ {
1035
+ self[0] = Observation({
1036
+ blockTimestamp: time,
1037
+ tickCumulative: 0,
1038
+ secondsPerLiquidityCumulativeX128: 0,
1039
+ initialized: true
1040
+ });
1041
+ return (1, 1);
1042
+ }
1043
+
1044
+ /// @notice Writes an oracle observation to the array
1045
+ /// @dev Writable at most once per block. Index represents the most recently written element. cardinality and index must be tracked externally.
1046
+ /// If the index is at the end of the allowable array length (according to cardinality), and the next cardinality
1047
+ /// is greater than the current one, cardinality may be increased. This restriction is created to preserve ordering.
1048
+ /// @param self The stored oracle array
1049
+ /// @param index The index of the observation that was most recently written to the observations array
1050
+ /// @param blockTimestamp The timestamp of the new observation
1051
+ /// @param tick The active tick at the time of the new observation
1052
+ /// @param liquidity The total in-range liquidity at the time of the new observation
1053
+ /// @param cardinality The number of populated elements in the oracle array
1054
+ /// @param cardinalityNext The new length of the oracle array, independent of population
1055
+ /// @return indexUpdated The new index of the most recently written element in the oracle array
1056
+ /// @return cardinalityUpdated The new cardinality of the oracle array
1057
+ function write(
1058
+ Observation[65535] storage self,
1059
+ uint16 index,
1060
+ uint32 blockTimestamp,
1061
+ int24 tick,
1062
+ uint128 liquidity,
1063
+ uint16 cardinality,
1064
+ uint16 cardinalityNext
1065
+ ) internal returns (uint16 indexUpdated, uint16 cardinalityUpdated) {
1066
+ Observation memory last = self[index];
1067
+
1068
+ // early return if we've already written an observation this block
1069
+ if (last.blockTimestamp == blockTimestamp) return (index, cardinality);
1070
+
1071
+ // if the conditions are right, we can bump the cardinality
1072
+ if (cardinalityNext > cardinality && index == (cardinality - 1)) {
1073
+ cardinalityUpdated = cardinalityNext;
1074
+ } else {
1075
+ cardinalityUpdated = cardinality;
1076
+ }
1077
+
1078
+ indexUpdated = (index + 1) % cardinalityUpdated;
1079
+ self[indexUpdated] = transform(last, blockTimestamp, tick, liquidity);
1080
+ }
1081
+
1082
+ /// @notice Prepares the oracle array to store up to `next` observations
1083
+ /// @param self The stored oracle array
1084
+ /// @param current The current next cardinality of the oracle array
1085
+ /// @param next The proposed next cardinality which will be populated in the oracle array
1086
+ /// @return next The next cardinality which will be populated in the oracle array
1087
+ function grow(
1088
+ Observation[65535] storage self,
1089
+ uint16 current,
1090
+ uint16 next
1091
+ ) internal returns (uint16) {
1092
+ require(current > 0, 'I');
1093
+ // no-op if the passed next value isn't greater than the current next value
1094
+ if (next <= current) return current;
1095
+ // store in each slot to prevent fresh SSTOREs in swaps
1096
+ // this data will not be used because the initialized boolean is still false
1097
+ for (uint16 i = current; i < next; i++) self[i].blockTimestamp = 1;
1098
+ return next;
1099
+ }
1100
+
1101
+ /// @notice comparator for 32-bit timestamps
1102
+ /// @dev safe for 0 or 1 overflows, a and b _must_ be chronologically before or equal to time
1103
+ /// @param time A timestamp truncated to 32 bits
1104
+ /// @param a A comparison timestamp from which to determine the relative position of `time`
1105
+ /// @param b From which to determine the relative position of `time`
1106
+ /// @return bool Whether `a` is chronologically <= `b`
1107
+ function lte(
1108
+ uint32 time,
1109
+ uint32 a,
1110
+ uint32 b
1111
+ ) private pure returns (bool) {
1112
+ // if there hasn't been overflow, no need to adjust
1113
+ if (a <= time && b <= time) return a <= b;
1114
+
1115
+ uint256 aAdjusted = a > time ? a : a + 2**32;
1116
+ uint256 bAdjusted = b > time ? b : b + 2**32;
1117
+
1118
+ return aAdjusted <= bAdjusted;
1119
+ }
1120
+
1121
+ /// @notice Fetches the observations beforeOrAt and atOrAfter a target, i.e. where [beforeOrAt, atOrAfter] is satisfied.
1122
+ /// The result may be the same observation, or adjacent observations.
1123
+ /// @dev The answer must be contained in the array, used when the target is located within the stored observation
1124
+ /// boundaries: older than the most recent observation and younger, or the same age as, the oldest observation
1125
+ /// @param self The stored oracle array
1126
+ /// @param time The current block.timestamp
1127
+ /// @param target The timestamp at which the reserved observation should be for
1128
+ /// @param index The index of the observation that was most recently written to the observations array
1129
+ /// @param cardinality The number of populated elements in the oracle array
1130
+ /// @return beforeOrAt The observation recorded before, or at, the target
1131
+ /// @return atOrAfter The observation recorded at, or after, the target
1132
+ function binarySearch(
1133
+ Observation[65535] storage self,
1134
+ uint32 time,
1135
+ uint32 target,
1136
+ uint16 index,
1137
+ uint16 cardinality
1138
+ ) private view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {
1139
+ uint256 l = (index + 1) % cardinality; // oldest observation
1140
+ uint256 r = l + cardinality - 1; // newest observation
1141
+ uint256 i;
1142
+ while (true) {
1143
+ i = (l + r) / 2;
1144
+
1145
+ beforeOrAt = self[i % cardinality];
1146
+
1147
+ // we've landed on an uninitialized tick, keep searching higher (more recently)
1148
+ if (!beforeOrAt.initialized) {
1149
+ l = i + 1;
1150
+ continue;
1151
+ }
1152
+
1153
+ atOrAfter = self[(i + 1) % cardinality];
1154
+
1155
+ bool targetAtOrAfter = lte(time, beforeOrAt.blockTimestamp, target);
1156
+
1157
+ // check if we've found the answer!
1158
+ if (targetAtOrAfter && lte(time, target, atOrAfter.blockTimestamp)) break;
1159
+
1160
+ if (!targetAtOrAfter) r = i - 1;
1161
+ else l = i + 1;
1162
+ }
1163
+ }
1164
+
1165
+ /// @notice Fetches the observations beforeOrAt and atOrAfter a given target, i.e. where [beforeOrAt, atOrAfter] is satisfied
1166
+ /// @dev Assumes there is at least 1 initialized observation.
1167
+ /// Used by observeSingle() to compute the counterfactual accumulator values as of a given block timestamp.
1168
+ /// @param self The stored oracle array
1169
+ /// @param time The current block.timestamp
1170
+ /// @param target The timestamp at which the reserved observation should be for
1171
+ /// @param tick The active tick at the time of the returned or simulated observation
1172
+ /// @param index The index of the observation that was most recently written to the observations array
1173
+ /// @param liquidity The total pool liquidity at the time of the call
1174
+ /// @param cardinality The number of populated elements in the oracle array
1175
+ /// @return beforeOrAt The observation which occurred at, or before, the given timestamp
1176
+ /// @return atOrAfter The observation which occurred at, or after, the given timestamp
1177
+ function getSurroundingObservations(
1178
+ Observation[65535] storage self,
1179
+ uint32 time,
1180
+ uint32 target,
1181
+ int24 tick,
1182
+ uint16 index,
1183
+ uint128 liquidity,
1184
+ uint16 cardinality
1185
+ ) private view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {
1186
+ // optimistically set before to the newest observation
1187
+ beforeOrAt = self[index];
1188
+
1189
+ // if the target is chronologically at or after the newest observation, we can early return
1190
+ if (lte(time, beforeOrAt.blockTimestamp, target)) {
1191
+ if (beforeOrAt.blockTimestamp == target) {
1192
+ // if newest observation equals target, we're in the same block, so we can ignore atOrAfter
1193
+ return (beforeOrAt, atOrAfter);
1194
+ } else {
1195
+ // otherwise, we need to transform
1196
+ return (beforeOrAt, transform(beforeOrAt, target, tick, liquidity));
1197
+ }
1198
+ }
1199
+
1200
+ // now, set before to the oldest observation
1201
+ beforeOrAt = self[(index + 1) % cardinality];
1202
+ if (!beforeOrAt.initialized) beforeOrAt = self[0];
1203
+
1204
+ // ensure that the target is chronologically at or after the oldest observation
1205
+ require(lte(time, beforeOrAt.blockTimestamp, target), 'OLD');
1206
+
1207
+ // if we've reached this point, we have to binary search
1208
+ return binarySearch(self, time, target, index, cardinality);
1209
+ }
1210
+
1211
+ /// @dev Reverts if an observation at or before the desired observation timestamp does not exist.
1212
+ /// 0 may be passed as `secondsAgo' to return the current cumulative values.
1213
+ /// If called with a timestamp falling between two observations, returns the counterfactual accumulator values
1214
+ /// at exactly the timestamp between the two observations.
1215
+ /// @param self The stored oracle array
1216
+ /// @param time The current block timestamp
1217
+ /// @param secondsAgo The amount of time to look back, in seconds, at which point to return an observation
1218
+ /// @param tick The current tick
1219
+ /// @param index The index of the observation that was most recently written to the observations array
1220
+ /// @param liquidity The current in-range pool liquidity
1221
+ /// @param cardinality The number of populated elements in the oracle array
1222
+ /// @return tickCumulative The tick * time elapsed since the pool was first initialized, as of `secondsAgo`
1223
+ /// @return secondsPerLiquidityCumulativeX128 The time elapsed / max(1, liquidity) since the pool was first initialized, as of `secondsAgo`
1224
+ function observeSingle(
1225
+ Observation[65535] storage self,
1226
+ uint32 time,
1227
+ uint32 secondsAgo,
1228
+ int24 tick,
1229
+ uint16 index,
1230
+ uint128 liquidity,
1231
+ uint16 cardinality
1232
+ ) internal view returns (int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) {
1233
+ if (secondsAgo == 0) {
1234
+ Observation memory last = self[index];
1235
+ if (last.blockTimestamp != time) last = transform(last, time, tick, liquidity);
1236
+ return (last.tickCumulative, last.secondsPerLiquidityCumulativeX128);
1237
+ }
1238
+
1239
+ uint32 target = time - secondsAgo;
1240
+
1241
+ (Observation memory beforeOrAt, Observation memory atOrAfter) =
1242
+ getSurroundingObservations(self, time, target, tick, index, liquidity, cardinality);
1243
+
1244
+ if (target == beforeOrAt.blockTimestamp) {
1245
+ // we're at the left boundary
1246
+ return (beforeOrAt.tickCumulative, beforeOrAt.secondsPerLiquidityCumulativeX128);
1247
+ } else if (target == atOrAfter.blockTimestamp) {
1248
+ // we're at the right boundary
1249
+ return (atOrAfter.tickCumulative, atOrAfter.secondsPerLiquidityCumulativeX128);
1250
+ } else {
1251
+ // we're in the middle
1252
+ uint32 observationTimeDelta = atOrAfter.blockTimestamp - beforeOrAt.blockTimestamp;
1253
+ uint32 targetDelta = target - beforeOrAt.blockTimestamp;
1254
+ return (
1255
+ beforeOrAt.tickCumulative +
1256
+ ((atOrAfter.tickCumulative - beforeOrAt.tickCumulative) / observationTimeDelta) *
1257
+ targetDelta,
1258
+ beforeOrAt.secondsPerLiquidityCumulativeX128 +
1259
+ uint160(
1260
+ (uint256(
1261
+ atOrAfter.secondsPerLiquidityCumulativeX128 - beforeOrAt.secondsPerLiquidityCumulativeX128
1262
+ ) * targetDelta) / observationTimeDelta
1263
+ )
1264
+ );
1265
+ }
1266
+ }
1267
+
1268
+ /// @notice Returns the accumulator values as of each time seconds ago from the given time in the array of `secondsAgos`
1269
+ /// @dev Reverts if `secondsAgos` > oldest observation
1270
+ /// @param self The stored oracle array
1271
+ /// @param time The current block.timestamp
1272
+ /// @param secondsAgos Each amount of time to look back, in seconds, at which point to return an observation
1273
+ /// @param tick The current tick
1274
+ /// @param index The index of the observation that was most recently written to the observations array
1275
+ /// @param liquidity The current in-range pool liquidity
1276
+ /// @param cardinality The number of populated elements in the oracle array
1277
+ /// @return tickCumulatives The tick * time elapsed since the pool was first initialized, as of each `secondsAgo`
1278
+ /// @return secondsPerLiquidityCumulativeX128s The cumulative seconds / max(1, liquidity) since the pool was first initialized, as of each `secondsAgo`
1279
+ function observe(
1280
+ Observation[65535] storage self,
1281
+ uint32 time,
1282
+ uint32[] memory secondsAgos,
1283
+ int24 tick,
1284
+ uint16 index,
1285
+ uint128 liquidity,
1286
+ uint16 cardinality
1287
+ ) internal view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) {
1288
+ require(cardinality > 0, 'I');
1289
+
1290
+ tickCumulatives = new int56[](secondsAgos.length);
1291
+ secondsPerLiquidityCumulativeX128s = new uint160[](secondsAgos.length);
1292
+ for (uint256 i = 0; i < secondsAgos.length; i++) {
1293
+ (tickCumulatives[i], secondsPerLiquidityCumulativeX128s[i]) = observeSingle(
1294
+ self,
1295
+ time,
1296
+ secondsAgos[i],
1297
+ tick,
1298
+ index,
1299
+ liquidity,
1300
+ cardinality
1301
+ );
1302
+ }
1303
+ }
1304
+ }
1305
+
1306
+ // lib/v3-core-main/contracts/libraries/SafeCast.sol
1307
+
1308
+ /// @title Safe casting methods
1309
+ /// @notice Contains methods for safely casting between types
1310
+ library SafeCast {
1311
+ /// @notice Cast a uint256 to a uint160, revert on overflow
1312
+ /// @param y The uint256 to be downcasted
1313
+ /// @return z The downcasted integer, now type uint160
1314
+ function toUint160(uint256 y) internal pure returns (uint160 z) {
1315
+ require((z = uint160(y)) == y);
1316
+ }
1317
+
1318
+ /// @notice Cast a int256 to a int128, revert on overflow or underflow
1319
+ /// @param y The int256 to be downcasted
1320
+ /// @return z The downcasted integer, now type int128
1321
+ function toInt128(int256 y) internal pure returns (int128 z) {
1322
+ require((z = int128(y)) == y);
1323
+ }
1324
+
1325
+ /// @notice Cast a uint256 to a int256, revert on overflow
1326
+ /// @param y The uint256 to be casted
1327
+ /// @return z The casted integer, now type int256
1328
+ function toInt256(uint256 y) internal pure returns (int256 z) {
1329
+ require(y < 2**255);
1330
+ z = int256(y);
1331
+ }
1332
+ }
1333
+
1334
+ // lib/v3-core-main/contracts/libraries/TickMath.sol
1335
+
1336
+ /// @title Math library for computing sqrt prices from ticks and vice versa
1337
+ /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
1338
+ /// prices between 2**-128 and 2**128
1339
+ library TickMath {
1340
+ /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
1341
+ int24 internal constant MIN_TICK = -887272;
1342
+ /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
1343
+ int24 internal constant MAX_TICK = -MIN_TICK;
1344
+
1345
+ /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
1346
+ uint160 internal constant MIN_SQRT_RATIO = 4295128739;
1347
+ /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
1348
+ uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
1349
+
1350
+ /// @notice Calculates sqrt(1.0001^tick) * 2^96
1351
+ /// @dev Throws if |tick| > max tick
1352
+ /// @param tick The input tick for the above formula
1353
+ /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
1354
+ /// at the given tick
1355
+ function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
1356
+ uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
1357
+ require(absTick <= uint256(MAX_TICK), 'T');
1358
+
1359
+ uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
1360
+ if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
1361
+ if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
1362
+ if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
1363
+ if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
1364
+ if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
1365
+ if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
1366
+ if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
1367
+ if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
1368
+ if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
1369
+ if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
1370
+ if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
1371
+ if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
1372
+ if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
1373
+ if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
1374
+ if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
1375
+ if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
1376
+ if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
1377
+ if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
1378
+ if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
1379
+
1380
+ if (tick > 0) ratio = type(uint256).max / ratio;
1381
+
1382
+ // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
1383
+ // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
1384
+ // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
1385
+ sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
1386
+ }
1387
+
1388
+ /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
1389
+ /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
1390
+ /// ever return.
1391
+ /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
1392
+ /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
1393
+ function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
1394
+ // second inequality must be < because the price can never reach the price at the max tick
1395
+ require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');
1396
+ uint256 ratio = uint256(sqrtPriceX96) << 32;
1397
+
1398
+ uint256 r = ratio;
1399
+ uint256 msb = 0;
1400
+
1401
+ assembly {
1402
+ let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
1403
+ msb := or(msb, f)
1404
+ r := shr(f, r)
1405
+ }
1406
+ assembly {
1407
+ let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
1408
+ msb := or(msb, f)
1409
+ r := shr(f, r)
1410
+ }
1411
+ assembly {
1412
+ let f := shl(5, gt(r, 0xFFFFFFFF))
1413
+ msb := or(msb, f)
1414
+ r := shr(f, r)
1415
+ }
1416
+ assembly {
1417
+ let f := shl(4, gt(r, 0xFFFF))
1418
+ msb := or(msb, f)
1419
+ r := shr(f, r)
1420
+ }
1421
+ assembly {
1422
+ let f := shl(3, gt(r, 0xFF))
1423
+ msb := or(msb, f)
1424
+ r := shr(f, r)
1425
+ }
1426
+ assembly {
1427
+ let f := shl(2, gt(r, 0xF))
1428
+ msb := or(msb, f)
1429
+ r := shr(f, r)
1430
+ }
1431
+ assembly {
1432
+ let f := shl(1, gt(r, 0x3))
1433
+ msb := or(msb, f)
1434
+ r := shr(f, r)
1435
+ }
1436
+ assembly {
1437
+ let f := gt(r, 0x1)
1438
+ msb := or(msb, f)
1439
+ }
1440
+
1441
+ if (msb >= 128) r = ratio >> (msb - 127);
1442
+ else r = ratio << (127 - msb);
1443
+
1444
+ int256 log_2 = (int256(msb) - 128) << 64;
1445
+
1446
+ assembly {
1447
+ r := shr(127, mul(r, r))
1448
+ let f := shr(128, r)
1449
+ log_2 := or(log_2, shl(63, f))
1450
+ r := shr(f, r)
1451
+ }
1452
+ assembly {
1453
+ r := shr(127, mul(r, r))
1454
+ let f := shr(128, r)
1455
+ log_2 := or(log_2, shl(62, f))
1456
+ r := shr(f, r)
1457
+ }
1458
+ assembly {
1459
+ r := shr(127, mul(r, r))
1460
+ let f := shr(128, r)
1461
+ log_2 := or(log_2, shl(61, f))
1462
+ r := shr(f, r)
1463
+ }
1464
+ assembly {
1465
+ r := shr(127, mul(r, r))
1466
+ let f := shr(128, r)
1467
+ log_2 := or(log_2, shl(60, f))
1468
+ r := shr(f, r)
1469
+ }
1470
+ assembly {
1471
+ r := shr(127, mul(r, r))
1472
+ let f := shr(128, r)
1473
+ log_2 := or(log_2, shl(59, f))
1474
+ r := shr(f, r)
1475
+ }
1476
+ assembly {
1477
+ r := shr(127, mul(r, r))
1478
+ let f := shr(128, r)
1479
+ log_2 := or(log_2, shl(58, f))
1480
+ r := shr(f, r)
1481
+ }
1482
+ assembly {
1483
+ r := shr(127, mul(r, r))
1484
+ let f := shr(128, r)
1485
+ log_2 := or(log_2, shl(57, f))
1486
+ r := shr(f, r)
1487
+ }
1488
+ assembly {
1489
+ r := shr(127, mul(r, r))
1490
+ let f := shr(128, r)
1491
+ log_2 := or(log_2, shl(56, f))
1492
+ r := shr(f, r)
1493
+ }
1494
+ assembly {
1495
+ r := shr(127, mul(r, r))
1496
+ let f := shr(128, r)
1497
+ log_2 := or(log_2, shl(55, f))
1498
+ r := shr(f, r)
1499
+ }
1500
+ assembly {
1501
+ r := shr(127, mul(r, r))
1502
+ let f := shr(128, r)
1503
+ log_2 := or(log_2, shl(54, f))
1504
+ r := shr(f, r)
1505
+ }
1506
+ assembly {
1507
+ r := shr(127, mul(r, r))
1508
+ let f := shr(128, r)
1509
+ log_2 := or(log_2, shl(53, f))
1510
+ r := shr(f, r)
1511
+ }
1512
+ assembly {
1513
+ r := shr(127, mul(r, r))
1514
+ let f := shr(128, r)
1515
+ log_2 := or(log_2, shl(52, f))
1516
+ r := shr(f, r)
1517
+ }
1518
+ assembly {
1519
+ r := shr(127, mul(r, r))
1520
+ let f := shr(128, r)
1521
+ log_2 := or(log_2, shl(51, f))
1522
+ r := shr(f, r)
1523
+ }
1524
+ assembly {
1525
+ r := shr(127, mul(r, r))
1526
+ let f := shr(128, r)
1527
+ log_2 := or(log_2, shl(50, f))
1528
+ }
1529
+
1530
+ int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
1531
+
1532
+ int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
1533
+ int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
1534
+
1535
+ tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
1536
+ }
1537
+ }
1538
+
1539
+ // lib/v3-core-main/contracts/libraries/UnsafeMath.sol
1540
+
1541
+ /// @title Math functions that do not check inputs or outputs
1542
+ /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks
1543
+ library UnsafeMath {
1544
+ /// @notice Returns ceil(x / y)
1545
+ /// @dev division by 0 has unspecified behavior, and must be checked externally
1546
+ /// @param x The dividend
1547
+ /// @param y The divisor
1548
+ /// @return z The quotient, ceil(x / y)
1549
+ function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
1550
+ assembly {
1551
+ z := add(div(x, y), gt(mod(x, y), 0))
1552
+ }
1553
+ }
1554
+ }
1555
+
1556
+ // lib/v3-core-main/contracts/libraries/TickBitmap.sol
1557
+
1558
+ /// @title Packed tick initialized state library
1559
+ /// @notice Stores a packed mapping of tick index to its initialized state
1560
+ /// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.
1561
+ library TickBitmap {
1562
+ /// @notice Computes the position in the mapping where the initialized bit for a tick lives
1563
+ /// @param tick The tick for which to compute the position
1564
+ /// @return wordPos The key in the mapping containing the word in which the bit is stored
1565
+ /// @return bitPos The bit position in the word where the flag is stored
1566
+ function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) {
1567
+ wordPos = int16(tick >> 8);
1568
+ bitPos = uint8(tick % 256);
1569
+ }
1570
+
1571
+ /// @notice Flips the initialized state for a given tick from false to true, or vice versa
1572
+ /// @param self The mapping in which to flip the tick
1573
+ /// @param tick The tick to flip
1574
+ /// @param tickSpacing The spacing between usable ticks
1575
+ function flipTick(
1576
+ mapping(int16 => uint256) storage self,
1577
+ int24 tick,
1578
+ int24 tickSpacing
1579
+ ) internal {
1580
+ require(tick % tickSpacing == 0); // ensure that the tick is spaced
1581
+ (int16 wordPos, uint8 bitPos) = position(tick / tickSpacing);
1582
+ uint256 mask = 1 << bitPos;
1583
+ self[wordPos] ^= mask;
1584
+ }
1585
+
1586
+ /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either
1587
+ /// to the left (less than or equal to) or right (greater than) of the given tick
1588
+ /// @param self The mapping in which to compute the next initialized tick
1589
+ /// @param tick The starting tick
1590
+ /// @param tickSpacing The spacing between usable ticks
1591
+ /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)
1592
+ /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick
1593
+ /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks
1594
+ function nextInitializedTickWithinOneWord(
1595
+ mapping(int16 => uint256) storage self,
1596
+ int24 tick,
1597
+ int24 tickSpacing,
1598
+ bool lte
1599
+ ) internal view returns (int24 next, bool initialized) {
1600
+ int24 compressed = tick / tickSpacing;
1601
+ if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity
1602
+
1603
+ if (lte) {
1604
+ (int16 wordPos, uint8 bitPos) = position(compressed);
1605
+ // all the 1s at or to the right of the current bitPos
1606
+ uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);
1607
+ uint256 masked = self[wordPos] & mask;
1608
+
1609
+ // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word
1610
+ initialized = masked != 0;
1611
+ // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick
1612
+ next = initialized
1613
+ ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing
1614
+ : (compressed - int24(bitPos)) * tickSpacing;
1615
+ } else {
1616
+ // start from the word of the next tick, since the current tick state doesn't matter
1617
+ (int16 wordPos, uint8 bitPos) = position(compressed + 1);
1618
+ // all the 1s at or to the left of the bitPos
1619
+ uint256 mask = ~((1 << bitPos) - 1);
1620
+ uint256 masked = self[wordPos] & mask;
1621
+
1622
+ // if there are no initialized ticks to the left of the current tick, return leftmost in the word
1623
+ initialized = masked != 0;
1624
+ // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick
1625
+ next = initialized
1626
+ ? (compressed + 1 + int24(BitMath.leastSignificantBit(masked) - bitPos)) * tickSpacing
1627
+ : (compressed + 1 + int24(type(uint8).max - bitPos)) * tickSpacing;
1628
+ }
1629
+ }
1630
+ }
1631
+
1632
+ // lib/v3-core-main/contracts/libraries/TransferHelper.sol
1633
+
1634
+ /// @title TransferHelper
1635
+ /// @notice Contains helper methods for interacting with ERC20 tokens that do not consistently return true/false
1636
+ library TransferHelper {
1637
+ /// @notice Transfers tokens from msg.sender to a recipient
1638
+ /// @dev Calls transfer on token contract, errors with TF if transfer fails
1639
+ /// @param token The contract address of the token which will be transferred
1640
+ /// @param to The recipient of the transfer
1641
+ /// @param value The value of the transfer
1642
+ function safeTransfer(
1643
+ address token,
1644
+ address to,
1645
+ uint256 value
1646
+ ) internal {
1647
+ (bool success, bytes memory data) =
1648
+ token.call(abi.encodeWithSelector(IERC20Minimal.transfer.selector, to, value));
1649
+ require(success && (data.length == 0 || abi.decode(data, (bool))), 'TF');
1650
+ }
1651
+ }
1652
+
1653
+ // lib/v3-core-main/contracts/libraries/Position.sol
1654
+
1655
+ /// @title Position
1656
+ /// @notice Positions represent an owner address' liquidity between a lower and upper tick boundary
1657
+ /// @dev Positions store additional state for tracking fees owed to the position
1658
+ library Position {
1659
+ // info stored for each user's position
1660
+ struct Info {
1661
+ // the amount of liquidity owned by this position
1662
+ uint128 liquidity;
1663
+ // fee growth per unit of liquidity as of the last update to liquidity or fees owed
1664
+ uint256 feeGrowthInside0LastX128;
1665
+ uint256 feeGrowthInside1LastX128;
1666
+ // the fees owed to the position owner in token0/token1
1667
+ uint128 tokensOwed0;
1668
+ uint128 tokensOwed1;
1669
+ }
1670
+
1671
+ /// @notice Returns the Info struct of a position, given an owner and position boundaries
1672
+ /// @param self The mapping containing all user positions
1673
+ /// @param owner The address of the position owner
1674
+ /// @param tickLower The lower tick boundary of the position
1675
+ /// @param tickUpper The upper tick boundary of the position
1676
+ /// @return position The position info struct of the given owners' position
1677
+ function get(
1678
+ mapping(bytes32 => Info) storage self,
1679
+ address owner,
1680
+ int24 tickLower,
1681
+ int24 tickUpper
1682
+ ) internal view returns (Position.Info storage position) {
1683
+ position = self[keccak256(abi.encodePacked(owner, tickLower, tickUpper))];
1684
+ }
1685
+
1686
+ /// @notice Credits accumulated fees to a user's position
1687
+ /// @param self The individual position to update
1688
+ /// @param liquidityDelta The change in pool liquidity as a result of the position update
1689
+ /// @param feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries
1690
+ /// @param feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries
1691
+ function update(
1692
+ Info storage self,
1693
+ int128 liquidityDelta,
1694
+ uint256 feeGrowthInside0X128,
1695
+ uint256 feeGrowthInside1X128
1696
+ ) internal {
1697
+ Info memory _self = self;
1698
+
1699
+ uint128 liquidityNext;
1700
+ if (liquidityDelta == 0) {
1701
+ require(_self.liquidity > 0, 'NP'); // disallow pokes for 0 liquidity positions
1702
+ liquidityNext = _self.liquidity;
1703
+ } else {
1704
+ liquidityNext = LiquidityMath.addDelta(_self.liquidity, liquidityDelta);
1705
+ }
1706
+
1707
+ // calculate accumulated fees
1708
+ uint128 tokensOwed0 =
1709
+ uint128(
1710
+ FullMath.mulDiv(
1711
+ feeGrowthInside0X128 - _self.feeGrowthInside0LastX128,
1712
+ _self.liquidity,
1713
+ FixedPoint128.Q128
1714
+ )
1715
+ );
1716
+ uint128 tokensOwed1 =
1717
+ uint128(
1718
+ FullMath.mulDiv(
1719
+ feeGrowthInside1X128 - _self.feeGrowthInside1LastX128,
1720
+ _self.liquidity,
1721
+ FixedPoint128.Q128
1722
+ )
1723
+ );
1724
+
1725
+ // update the position
1726
+ if (liquidityDelta != 0) self.liquidity = liquidityNext;
1727
+ self.feeGrowthInside0LastX128 = feeGrowthInside0X128;
1728
+ self.feeGrowthInside1LastX128 = feeGrowthInside1X128;
1729
+ if (tokensOwed0 > 0 || tokensOwed1 > 0) {
1730
+ // overflow is acceptable, have to withdraw before you hit type(uint128).max fees
1731
+ self.tokensOwed0 += tokensOwed0;
1732
+ self.tokensOwed1 += tokensOwed1;
1733
+ }
1734
+ }
1735
+ }
1736
+
1737
+ // lib/v3-core-main/contracts/libraries/Tick.sol
1738
+
1739
+ /// @title Tick
1740
+ /// @notice Contains functions for managing tick processes and relevant calculations
1741
+ library Tick {
1742
+ using LowGasSafeMath for int256;
1743
+ using SafeCast for int256;
1744
+
1745
+ // info stored for each initialized individual tick
1746
+ struct Info {
1747
+ // the total position liquidity that references this tick
1748
+ uint128 liquidityGross;
1749
+ // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),
1750
+ int128 liquidityNet;
1751
+ // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)
1752
+ // only has relative meaning, not absolute — the value depends on when the tick is initialized
1753
+ uint256 feeGrowthOutside0X128;
1754
+ uint256 feeGrowthOutside1X128;
1755
+ // the cumulative tick value on the other side of the tick
1756
+ int56 tickCumulativeOutside;
1757
+ // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)
1758
+ // only has relative meaning, not absolute — the value depends on when the tick is initialized
1759
+ uint160 secondsPerLiquidityOutsideX128;
1760
+ // the seconds spent on the other side of the tick (relative to the current tick)
1761
+ // only has relative meaning, not absolute — the value depends on when the tick is initialized
1762
+ uint32 secondsOutside;
1763
+ // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0
1764
+ // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks
1765
+ bool initialized;
1766
+ }
1767
+
1768
+ /// @notice Derives max liquidity per tick from given tick spacing
1769
+ /// @dev Executed within the pool constructor
1770
+ /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`
1771
+ /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...
1772
+ /// @return The max liquidity per tick
1773
+ function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {
1774
+ int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;
1775
+ int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;
1776
+ uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;
1777
+ return type(uint128).max / numTicks;
1778
+ }
1779
+
1780
+ /// @notice Retrieves fee growth data
1781
+ /// @param self The mapping containing all tick information for initialized ticks
1782
+ /// @param tickLower The lower tick boundary of the position
1783
+ /// @param tickUpper The upper tick boundary of the position
1784
+ /// @param tickCurrent The current tick
1785
+ /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0
1786
+ /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1
1787
+ /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries
1788
+ /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries
1789
+ function getFeeGrowthInside(
1790
+ mapping(int24 => Tick.Info) storage self,
1791
+ int24 tickLower,
1792
+ int24 tickUpper,
1793
+ int24 tickCurrent,
1794
+ uint256 feeGrowthGlobal0X128,
1795
+ uint256 feeGrowthGlobal1X128
1796
+ ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {
1797
+ Info storage lower = self[tickLower];
1798
+ Info storage upper = self[tickUpper];
1799
+
1800
+ // calculate fee growth below
1801
+ uint256 feeGrowthBelow0X128;
1802
+ uint256 feeGrowthBelow1X128;
1803
+ if (tickCurrent >= tickLower) {
1804
+ feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;
1805
+ feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;
1806
+ } else {
1807
+ feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;
1808
+ feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;
1809
+ }
1810
+
1811
+ // calculate fee growth above
1812
+ uint256 feeGrowthAbove0X128;
1813
+ uint256 feeGrowthAbove1X128;
1814
+ if (tickCurrent < tickUpper) {
1815
+ feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;
1816
+ feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;
1817
+ } else {
1818
+ feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;
1819
+ feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;
1820
+ }
1821
+
1822
+ feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;
1823
+ feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;
1824
+ }
1825
+
1826
+ /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa
1827
+ /// @param self The mapping containing all tick information for initialized ticks
1828
+ /// @param tick The tick that will be updated
1829
+ /// @param tickCurrent The current tick
1830
+ /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)
1831
+ /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0
1832
+ /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1
1833
+ /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool
1834
+ /// @param tickCumulative The tick * time elapsed since the pool was first initialized
1835
+ /// @param time The current block timestamp cast to a uint32
1836
+ /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick
1837
+ /// @param maxLiquidity The maximum liquidity allocation for a single tick
1838
+ /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa
1839
+ function update(
1840
+ mapping(int24 => Tick.Info) storage self,
1841
+ int24 tick,
1842
+ int24 tickCurrent,
1843
+ int128 liquidityDelta,
1844
+ uint256 feeGrowthGlobal0X128,
1845
+ uint256 feeGrowthGlobal1X128,
1846
+ uint160 secondsPerLiquidityCumulativeX128,
1847
+ int56 tickCumulative,
1848
+ uint32 time,
1849
+ bool upper,
1850
+ uint128 maxLiquidity
1851
+ ) internal returns (bool flipped) {
1852
+ Tick.Info storage info = self[tick];
1853
+
1854
+ uint128 liquidityGrossBefore = info.liquidityGross;
1855
+ uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);
1856
+
1857
+ require(liquidityGrossAfter <= maxLiquidity, 'LO');
1858
+
1859
+ flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);
1860
+
1861
+ if (liquidityGrossBefore == 0) {
1862
+ // by convention, we assume that all growth before a tick was initialized happened _below_ the tick
1863
+ if (tick <= tickCurrent) {
1864
+ info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;
1865
+ info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;
1866
+ info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;
1867
+ info.tickCumulativeOutside = tickCumulative;
1868
+ info.secondsOutside = time;
1869
+ }
1870
+ info.initialized = true;
1871
+ }
1872
+
1873
+ info.liquidityGross = liquidityGrossAfter;
1874
+
1875
+ // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)
1876
+ info.liquidityNet = upper
1877
+ ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()
1878
+ : int256(info.liquidityNet).add(liquidityDelta).toInt128();
1879
+ }
1880
+
1881
+ /// @notice Clears tick data
1882
+ /// @param self The mapping containing all initialized tick information for initialized ticks
1883
+ /// @param tick The tick that will be cleared
1884
+ function clear(mapping(int24 => Tick.Info) storage self, int24 tick) internal {
1885
+ delete self[tick];
1886
+ }
1887
+
1888
+ /// @notice Transitions to next tick as needed by price movement
1889
+ /// @param self The mapping containing all tick information for initialized ticks
1890
+ /// @param tick The destination tick of the transition
1891
+ /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0
1892
+ /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1
1893
+ /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity
1894
+ /// @param tickCumulative The tick * time elapsed since the pool was first initialized
1895
+ /// @param time The current block.timestamp
1896
+ /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
1897
+ function cross(
1898
+ mapping(int24 => Tick.Info) storage self,
1899
+ int24 tick,
1900
+ uint256 feeGrowthGlobal0X128,
1901
+ uint256 feeGrowthGlobal1X128,
1902
+ uint160 secondsPerLiquidityCumulativeX128,
1903
+ int56 tickCumulative,
1904
+ uint32 time
1905
+ ) internal returns (int128 liquidityNet) {
1906
+ Tick.Info storage info = self[tick];
1907
+ info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;
1908
+ info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;
1909
+ info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;
1910
+ info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;
1911
+ info.secondsOutside = time - info.secondsOutside;
1912
+ liquidityNet = info.liquidityNet;
1913
+ }
1914
+ }
1915
+
1916
+ // lib/v3-core-main/contracts/libraries/SqrtPriceMath.sol
1917
+
1918
+ /// @title Functions based on Q64.96 sqrt price and liquidity
1919
+ /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas
1920
+ library SqrtPriceMath {
1921
+ using LowGasSafeMath for uint256;
1922
+ using SafeCast for uint256;
1923
+
1924
+ /// @notice Gets the next sqrt price given a delta of token0
1925
+ /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least
1926
+ /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the
1927
+ /// price less in order to not send too much output.
1928
+ /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),
1929
+ /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).
1930
+ /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta
1931
+ /// @param liquidity The amount of usable liquidity
1932
+ /// @param amount How much of token0 to add or remove from virtual reserves
1933
+ /// @param add Whether to add or remove the amount of token0
1934
+ /// @return The price after adding or removing amount, depending on add
1935
+ function getNextSqrtPriceFromAmount0RoundingUp(
1936
+ uint160 sqrtPX96,
1937
+ uint128 liquidity,
1938
+ uint256 amount,
1939
+ bool add
1940
+ ) internal pure returns (uint160) {
1941
+ // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price
1942
+ if (amount == 0) return sqrtPX96;
1943
+ uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;
1944
+
1945
+ if (add) {
1946
+ uint256 product;
1947
+ if ((product = amount * sqrtPX96) / amount == sqrtPX96) {
1948
+ uint256 denominator = numerator1 + product;
1949
+ if (denominator >= numerator1)
1950
+ // always fits in 160 bits
1951
+ return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));
1952
+ }
1953
+
1954
+ return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));
1955
+ } else {
1956
+ uint256 product;
1957
+ // if the product overflows, we know the denominator underflows
1958
+ // in addition, we must check that the denominator does not underflow
1959
+ require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);
1960
+ uint256 denominator = numerator1 - product;
1961
+ return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();
1962
+ }
1963
+ }
1964
+
1965
+ /// @notice Gets the next sqrt price given a delta of token1
1966
+ /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least
1967
+ /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the
1968
+ /// price less in order to not send too much output.
1969
+ /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity
1970
+ /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta
1971
+ /// @param liquidity The amount of usable liquidity
1972
+ /// @param amount How much of token1 to add, or remove, from virtual reserves
1973
+ /// @param add Whether to add, or remove, the amount of token1
1974
+ /// @return The price after adding or removing `amount`
1975
+ function getNextSqrtPriceFromAmount1RoundingDown(
1976
+ uint160 sqrtPX96,
1977
+ uint128 liquidity,
1978
+ uint256 amount,
1979
+ bool add
1980
+ ) internal pure returns (uint160) {
1981
+ // if we're adding (subtracting), rounding down requires rounding the quotient down (up)
1982
+ // in both cases, avoid a mulDiv for most inputs
1983
+ if (add) {
1984
+ uint256 quotient =
1985
+ (
1986
+ amount <= type(uint160).max
1987
+ ? (amount << FixedPoint96.RESOLUTION) / liquidity
1988
+ : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)
1989
+ );
1990
+
1991
+ return uint256(sqrtPX96).add(quotient).toUint160();
1992
+ } else {
1993
+ uint256 quotient =
1994
+ (
1995
+ amount <= type(uint160).max
1996
+ ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)
1997
+ : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)
1998
+ );
1999
+
2000
+ require(sqrtPX96 > quotient);
2001
+ // always fits 160 bits
2002
+ return uint160(sqrtPX96 - quotient);
2003
+ }
2004
+ }
2005
+
2006
+ /// @notice Gets the next sqrt price given an input amount of token0 or token1
2007
+ /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds
2008
+ /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount
2009
+ /// @param liquidity The amount of usable liquidity
2010
+ /// @param amountIn How much of token0, or token1, is being swapped in
2011
+ /// @param zeroForOne Whether the amount in is token0 or token1
2012
+ /// @return sqrtQX96 The price after adding the input amount to token0 or token1
2013
+ function getNextSqrtPriceFromInput(
2014
+ uint160 sqrtPX96,
2015
+ uint128 liquidity,
2016
+ uint256 amountIn,
2017
+ bool zeroForOne
2018
+ ) internal pure returns (uint160 sqrtQX96) {
2019
+ require(sqrtPX96 > 0);
2020
+ require(liquidity > 0);
2021
+
2022
+ // round to make sure that we don't pass the target price
2023
+ return
2024
+ zeroForOne
2025
+ ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)
2026
+ : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);
2027
+ }
2028
+
2029
+ /// @notice Gets the next sqrt price given an output amount of token0 or token1
2030
+ /// @dev Throws if price or liquidity are 0 or the next price is out of bounds
2031
+ /// @param sqrtPX96 The starting price before accounting for the output amount
2032
+ /// @param liquidity The amount of usable liquidity
2033
+ /// @param amountOut How much of token0, or token1, is being swapped out
2034
+ /// @param zeroForOne Whether the amount out is token0 or token1
2035
+ /// @return sqrtQX96 The price after removing the output amount of token0 or token1
2036
+ function getNextSqrtPriceFromOutput(
2037
+ uint160 sqrtPX96,
2038
+ uint128 liquidity,
2039
+ uint256 amountOut,
2040
+ bool zeroForOne
2041
+ ) internal pure returns (uint160 sqrtQX96) {
2042
+ require(sqrtPX96 > 0);
2043
+ require(liquidity > 0);
2044
+
2045
+ // round to make sure that we pass the target price
2046
+ return
2047
+ zeroForOne
2048
+ ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)
2049
+ : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
2050
+ }
2051
+
2052
+ /// @notice Gets the amount0 delta between two prices
2053
+ /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),
2054
+ /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))
2055
+ /// @param sqrtRatioAX96 A sqrt price
2056
+ /// @param sqrtRatioBX96 Another sqrt price
2057
+ /// @param liquidity The amount of usable liquidity
2058
+ /// @param roundUp Whether to round the amount up or down
2059
+ /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices
2060
+ function getAmount0Delta(
2061
+ uint160 sqrtRatioAX96,
2062
+ uint160 sqrtRatioBX96,
2063
+ uint128 liquidity,
2064
+ bool roundUp
2065
+ ) internal pure returns (uint256 amount0) {
2066
+ if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
2067
+
2068
+ uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;
2069
+ uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;
2070
+
2071
+ require(sqrtRatioAX96 > 0);
2072
+
2073
+ return
2074
+ roundUp
2075
+ ? UnsafeMath.divRoundingUp(
2076
+ FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),
2077
+ sqrtRatioAX96
2078
+ )
2079
+ : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;
2080
+ }
2081
+
2082
+ /// @notice Gets the amount1 delta between two prices
2083
+ /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))
2084
+ /// @param sqrtRatioAX96 A sqrt price
2085
+ /// @param sqrtRatioBX96 Another sqrt price
2086
+ /// @param liquidity The amount of usable liquidity
2087
+ /// @param roundUp Whether to round the amount up, or down
2088
+ /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices
2089
+ function getAmount1Delta(
2090
+ uint160 sqrtRatioAX96,
2091
+ uint160 sqrtRatioBX96,
2092
+ uint128 liquidity,
2093
+ bool roundUp
2094
+ ) internal pure returns (uint256 amount1) {
2095
+ if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
2096
+
2097
+ return
2098
+ roundUp
2099
+ ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)
2100
+ : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
2101
+ }
2102
+
2103
+ /// @notice Helper that gets signed token0 delta
2104
+ /// @param sqrtRatioAX96 A sqrt price
2105
+ /// @param sqrtRatioBX96 Another sqrt price
2106
+ /// @param liquidity The change in liquidity for which to compute the amount0 delta
2107
+ /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices
2108
+ function getAmount0Delta(
2109
+ uint160 sqrtRatioAX96,
2110
+ uint160 sqrtRatioBX96,
2111
+ int128 liquidity
2112
+ ) internal pure returns (int256 amount0) {
2113
+ return
2114
+ liquidity < 0
2115
+ ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()
2116
+ : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();
2117
+ }
2118
+
2119
+ /// @notice Helper that gets signed token1 delta
2120
+ /// @param sqrtRatioAX96 A sqrt price
2121
+ /// @param sqrtRatioBX96 Another sqrt price
2122
+ /// @param liquidity The change in liquidity for which to compute the amount1 delta
2123
+ /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices
2124
+ function getAmount1Delta(
2125
+ uint160 sqrtRatioAX96,
2126
+ uint160 sqrtRatioBX96,
2127
+ int128 liquidity
2128
+ ) internal pure returns (int256 amount1) {
2129
+ return
2130
+ liquidity < 0
2131
+ ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()
2132
+ : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();
2133
+ }
2134
+ }
2135
+
2136
+ // lib/v3-core-main/contracts/interfaces/IUniswapV3Pool.sol
2137
+
2138
+ /// @title The interface for a Uniswap V3 Pool
2139
+ /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
2140
+ /// to the ERC20 specification
2141
+ /// @dev The pool interface is broken up into many smaller pieces
2142
+ interface IUniswapV3Pool is
2143
+ IUniswapV3PoolImmutables,
2144
+ IUniswapV3PoolState,
2145
+ IUniswapV3PoolDerivedState,
2146
+ IUniswapV3PoolActions,
2147
+ IUniswapV3PoolOwnerActions,
2148
+ IUniswapV3PoolEvents
2149
+ {
2150
+
2151
+ }
2152
+
2153
+ // lib/v3-core-main/contracts/libraries/SwapMath.sol
2154
+
2155
+ /// @title Computes the result of a swap within ticks
2156
+ /// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.
2157
+ library SwapMath {
2158
+ /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap
2159
+ /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive
2160
+ /// @param sqrtRatioCurrentX96 The current sqrt price of the pool
2161
+ /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred
2162
+ /// @param liquidity The usable liquidity
2163
+ /// @param amountRemaining How much input or output amount is remaining to be swapped in/out
2164
+ /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip
2165
+ /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target
2166
+ /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap
2167
+ /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap
2168
+ /// @return feeAmount The amount of input that will be taken as a fee
2169
+ function computeSwapStep(
2170
+ uint160 sqrtRatioCurrentX96,
2171
+ uint160 sqrtRatioTargetX96,
2172
+ uint128 liquidity,
2173
+ int256 amountRemaining,
2174
+ uint24 feePips
2175
+ )
2176
+ internal
2177
+ pure
2178
+ returns (
2179
+ uint160 sqrtRatioNextX96,
2180
+ uint256 amountIn,
2181
+ uint256 amountOut,
2182
+ uint256 feeAmount
2183
+ )
2184
+ {
2185
+ bool zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96;
2186
+ bool exactIn = amountRemaining >= 0;
2187
+
2188
+ if (exactIn) {
2189
+ uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);
2190
+ amountIn = zeroForOne
2191
+ ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)
2192
+ : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);
2193
+ if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;
2194
+ else
2195
+ sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(
2196
+ sqrtRatioCurrentX96,
2197
+ liquidity,
2198
+ amountRemainingLessFee,
2199
+ zeroForOne
2200
+ );
2201
+ } else {
2202
+ amountOut = zeroForOne
2203
+ ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)
2204
+ : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);
2205
+ if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;
2206
+ else
2207
+ sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(
2208
+ sqrtRatioCurrentX96,
2209
+ liquidity,
2210
+ uint256(-amountRemaining),
2211
+ zeroForOne
2212
+ );
2213
+ }
2214
+
2215
+ bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;
2216
+
2217
+ // get the input/output amounts
2218
+ if (zeroForOne) {
2219
+ amountIn = max && exactIn
2220
+ ? amountIn
2221
+ : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);
2222
+ amountOut = max && !exactIn
2223
+ ? amountOut
2224
+ : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);
2225
+ } else {
2226
+ amountIn = max && exactIn
2227
+ ? amountIn
2228
+ : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);
2229
+ amountOut = max && !exactIn
2230
+ ? amountOut
2231
+ : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);
2232
+ }
2233
+
2234
+ // cap the output amount to not exceed the remaining output amount
2235
+ if (!exactIn && amountOut > uint256(-amountRemaining)) {
2236
+ amountOut = uint256(-amountRemaining);
2237
+ }
2238
+
2239
+ if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {
2240
+ // we didn't reach the target, so take the remainder of the maximum input as fee
2241
+ feeAmount = uint256(amountRemaining) - amountIn;
2242
+ } else {
2243
+ feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);
2244
+ }
2245
+ }
2246
+ }
2247
+
2248
+ // lib/v3-core-main/contracts/UniswapV3Pool.sol
2249
+
2250
+ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
2251
+ using LowGasSafeMath for uint256;
2252
+ using LowGasSafeMath for int256;
2253
+ using SafeCast for uint256;
2254
+ using SafeCast for int256;
2255
+ using Tick for mapping(int24 => Tick.Info);
2256
+ using TickBitmap for mapping(int16 => uint256);
2257
+ using Position for mapping(bytes32 => Position.Info);
2258
+ using Position for Position.Info;
2259
+ using Oracle for Oracle.Observation[65535];
2260
+
2261
+ /// @inheritdoc IUniswapV3PoolImmutables
2262
+ address public immutable override factory;
2263
+ /// @inheritdoc IUniswapV3PoolImmutables
2264
+ address public immutable override token0;
2265
+ /// @inheritdoc IUniswapV3PoolImmutables
2266
+ address public immutable override token1;
2267
+ /// @inheritdoc IUniswapV3PoolImmutables
2268
+ uint24 public immutable override fee;
2269
+
2270
+ /// @inheritdoc IUniswapV3PoolImmutables
2271
+ int24 public immutable override tickSpacing;
2272
+
2273
+ /// @inheritdoc IUniswapV3PoolImmutables
2274
+ uint128 public immutable override maxLiquidityPerTick;
2275
+
2276
+ struct Slot0 {
2277
+ // the current price
2278
+ uint160 sqrtPriceX96;
2279
+ // the current tick
2280
+ int24 tick;
2281
+ // the most-recently updated index of the observations array
2282
+ uint16 observationIndex;
2283
+ // the current maximum number of observations that are being stored
2284
+ uint16 observationCardinality;
2285
+ // the next maximum number of observations to store, triggered in observations.write
2286
+ uint16 observationCardinalityNext;
2287
+ // the current protocol fee as a percentage of the swap fee taken on withdrawal
2288
+ // represented as an integer denominator (1/x)%
2289
+ uint8 feeProtocol;
2290
+ // whether the pool is locked
2291
+ bool unlocked;
2292
+ }
2293
+ /// @inheritdoc IUniswapV3PoolState
2294
+ Slot0 public override slot0;
2295
+
2296
+ /// @inheritdoc IUniswapV3PoolState
2297
+ uint256 public override feeGrowthGlobal0X128;
2298
+ /// @inheritdoc IUniswapV3PoolState
2299
+ uint256 public override feeGrowthGlobal1X128;
2300
+
2301
+ // accumulated protocol fees in token0/token1 units
2302
+ struct ProtocolFees {
2303
+ uint128 token0;
2304
+ uint128 token1;
2305
+ }
2306
+ /// @inheritdoc IUniswapV3PoolState
2307
+ ProtocolFees public override protocolFees;
2308
+
2309
+ /// @inheritdoc IUniswapV3PoolState
2310
+ uint128 public override liquidity;
2311
+
2312
+ /// @inheritdoc IUniswapV3PoolState
2313
+ mapping(int24 => Tick.Info) public override ticks;
2314
+ /// @inheritdoc IUniswapV3PoolState
2315
+ mapping(int16 => uint256) public override tickBitmap;
2316
+ /// @inheritdoc IUniswapV3PoolState
2317
+ mapping(bytes32 => Position.Info) public override positions;
2318
+ /// @inheritdoc IUniswapV3PoolState
2319
+ Oracle.Observation[65535] public override observations;
2320
+
2321
+ /// @dev Mutually exclusive reentrancy protection into the pool to/from a method. This method also prevents entrance
2322
+ /// to a function before the pool is initialized. The reentrancy guard is required throughout the contract because
2323
+ /// we use balance checks to determine the payment status of interactions such as mint, swap and flash.
2324
+ modifier lock() {
2325
+ require(slot0.unlocked, 'LOK');
2326
+ slot0.unlocked = false;
2327
+ _;
2328
+ slot0.unlocked = true;
2329
+ }
2330
+
2331
+ /// @dev Prevents calling a function from anyone except the address returned by IUniswapV3Factory#owner()
2332
+ modifier onlyFactoryOwner() {
2333
+ require(msg.sender == IUniswapV3Factory(factory).owner());
2334
+ _;
2335
+ }
2336
+
2337
+ constructor() {
2338
+ int24 _tickSpacing;
2339
+ (factory, token0, token1, fee, _tickSpacing) = IUniswapV3PoolDeployer(msg.sender).parameters();
2340
+ tickSpacing = _tickSpacing;
2341
+
2342
+ maxLiquidityPerTick = Tick.tickSpacingToMaxLiquidityPerTick(_tickSpacing);
2343
+ }
2344
+
2345
+ /// @dev Common checks for valid tick inputs.
2346
+ function checkTicks(int24 tickLower, int24 tickUpper) private pure {
2347
+ require(tickLower < tickUpper, 'TLU');
2348
+ require(tickLower >= TickMath.MIN_TICK, 'TLM');
2349
+ require(tickUpper <= TickMath.MAX_TICK, 'TUM');
2350
+ }
2351
+
2352
+ /// @dev Returns the block timestamp truncated to 32 bits, i.e. mod 2**32. This method is overridden in tests.
2353
+ function _blockTimestamp() internal view virtual returns (uint32) {
2354
+ return uint32(block.timestamp); // truncation is desired
2355
+ }
2356
+
2357
+ /// @dev Get the pool's balance of token0
2358
+ /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
2359
+ /// check
2360
+ function balance0() private view returns (uint256) {
2361
+ (bool success, bytes memory data) =
2362
+ token0.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
2363
+ require(success && data.length >= 32);
2364
+ return abi.decode(data, (uint256));
2365
+ }
2366
+
2367
+ /// @dev Get the pool's balance of token1
2368
+ /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
2369
+ /// check
2370
+ function balance1() private view returns (uint256) {
2371
+ (bool success, bytes memory data) =
2372
+ token1.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
2373
+ require(success && data.length >= 32);
2374
+ return abi.decode(data, (uint256));
2375
+ }
2376
+
2377
+ /// @inheritdoc IUniswapV3PoolDerivedState
2378
+ function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
2379
+ external
2380
+ view
2381
+ override
2382
+ noDelegateCall
2383
+ returns (
2384
+ int56 tickCumulativeInside,
2385
+ uint160 secondsPerLiquidityInsideX128,
2386
+ uint32 secondsInside
2387
+ )
2388
+ {
2389
+ checkTicks(tickLower, tickUpper);
2390
+
2391
+ int56 tickCumulativeLower;
2392
+ int56 tickCumulativeUpper;
2393
+ uint160 secondsPerLiquidityOutsideLowerX128;
2394
+ uint160 secondsPerLiquidityOutsideUpperX128;
2395
+ uint32 secondsOutsideLower;
2396
+ uint32 secondsOutsideUpper;
2397
+
2398
+ {
2399
+ Tick.Info storage lower = ticks[tickLower];
2400
+ Tick.Info storage upper = ticks[tickUpper];
2401
+ bool initializedLower;
2402
+ (tickCumulativeLower, secondsPerLiquidityOutsideLowerX128, secondsOutsideLower, initializedLower) = (
2403
+ lower.tickCumulativeOutside,
2404
+ lower.secondsPerLiquidityOutsideX128,
2405
+ lower.secondsOutside,
2406
+ lower.initialized
2407
+ );
2408
+ require(initializedLower);
2409
+
2410
+ bool initializedUpper;
2411
+ (tickCumulativeUpper, secondsPerLiquidityOutsideUpperX128, secondsOutsideUpper, initializedUpper) = (
2412
+ upper.tickCumulativeOutside,
2413
+ upper.secondsPerLiquidityOutsideX128,
2414
+ upper.secondsOutside,
2415
+ upper.initialized
2416
+ );
2417
+ require(initializedUpper);
2418
+ }
2419
+
2420
+ Slot0 memory _slot0 = slot0;
2421
+
2422
+ if (_slot0.tick < tickLower) {
2423
+ return (
2424
+ tickCumulativeLower - tickCumulativeUpper,
2425
+ secondsPerLiquidityOutsideLowerX128 - secondsPerLiquidityOutsideUpperX128,
2426
+ secondsOutsideLower - secondsOutsideUpper
2427
+ );
2428
+ } else if (_slot0.tick < tickUpper) {
2429
+ uint32 time = _blockTimestamp();
2430
+ (int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
2431
+ observations.observeSingle(
2432
+ time,
2433
+ 0,
2434
+ _slot0.tick,
2435
+ _slot0.observationIndex,
2436
+ liquidity,
2437
+ _slot0.observationCardinality
2438
+ );
2439
+ return (
2440
+ tickCumulative - tickCumulativeLower - tickCumulativeUpper,
2441
+ secondsPerLiquidityCumulativeX128 -
2442
+ secondsPerLiquidityOutsideLowerX128 -
2443
+ secondsPerLiquidityOutsideUpperX128,
2444
+ time - secondsOutsideLower - secondsOutsideUpper
2445
+ );
2446
+ } else {
2447
+ return (
2448
+ tickCumulativeUpper - tickCumulativeLower,
2449
+ secondsPerLiquidityOutsideUpperX128 - secondsPerLiquidityOutsideLowerX128,
2450
+ secondsOutsideUpper - secondsOutsideLower
2451
+ );
2452
+ }
2453
+ }
2454
+
2455
+ /// @inheritdoc IUniswapV3PoolDerivedState
2456
+ function observe(uint32[] calldata secondsAgos)
2457
+ external
2458
+ view
2459
+ override
2460
+ noDelegateCall
2461
+ returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s)
2462
+ {
2463
+ return
2464
+ observations.observe(
2465
+ _blockTimestamp(),
2466
+ secondsAgos,
2467
+ slot0.tick,
2468
+ slot0.observationIndex,
2469
+ liquidity,
2470
+ slot0.observationCardinality
2471
+ );
2472
+ }
2473
+
2474
+ /// @inheritdoc IUniswapV3PoolActions
2475
+ function increaseObservationCardinalityNext(uint16 observationCardinalityNext)
2476
+ external
2477
+ override
2478
+ lock
2479
+ noDelegateCall
2480
+ {
2481
+ uint16 observationCardinalityNextOld = slot0.observationCardinalityNext; // for the event
2482
+ uint16 observationCardinalityNextNew =
2483
+ observations.grow(observationCardinalityNextOld, observationCardinalityNext);
2484
+ slot0.observationCardinalityNext = observationCardinalityNextNew;
2485
+ if (observationCardinalityNextOld != observationCardinalityNextNew)
2486
+ emit IncreaseObservationCardinalityNext(observationCardinalityNextOld, observationCardinalityNextNew);
2487
+ }
2488
+
2489
+ /// @inheritdoc IUniswapV3PoolActions
2490
+ /// @dev not locked because it initializes unlocked
2491
+ function initialize(uint160 sqrtPriceX96) external override {
2492
+ require(slot0.sqrtPriceX96 == 0, 'AI');
2493
+
2494
+ int24 tick = TickMath.getTickAtSqrtRatio(sqrtPriceX96);
2495
+
2496
+ (uint16 cardinality, uint16 cardinalityNext) = observations.initialize(_blockTimestamp());
2497
+
2498
+ slot0 = Slot0({
2499
+ sqrtPriceX96: sqrtPriceX96,
2500
+ tick: tick,
2501
+ observationIndex: 0,
2502
+ observationCardinality: cardinality,
2503
+ observationCardinalityNext: cardinalityNext,
2504
+ feeProtocol: 0,
2505
+ unlocked: true
2506
+ });
2507
+
2508
+ emit Initialize(sqrtPriceX96, tick);
2509
+ }
2510
+
2511
+ struct ModifyPositionParams {
2512
+ // the address that owns the position
2513
+ address owner;
2514
+ // the lower and upper tick of the position
2515
+ int24 tickLower;
2516
+ int24 tickUpper;
2517
+ // any change in liquidity
2518
+ int128 liquidityDelta;
2519
+ }
2520
+
2521
+ /// @dev Effect some changes to a position
2522
+ /// @param params the position details and the change to the position's liquidity to effect
2523
+ /// @return position a storage pointer referencing the position with the given owner and tick range
2524
+ /// @return amount0 the amount of token0 owed to the pool, negative if the pool should pay the recipient
2525
+ /// @return amount1 the amount of token1 owed to the pool, negative if the pool should pay the recipient
2526
+ function _modifyPosition(ModifyPositionParams memory params)
2527
+ private
2528
+ noDelegateCall
2529
+ returns (
2530
+ Position.Info storage position,
2531
+ int256 amount0,
2532
+ int256 amount1
2533
+ )
2534
+ {
2535
+ checkTicks(params.tickLower, params.tickUpper);
2536
+
2537
+ Slot0 memory _slot0 = slot0; // SLOAD for gas optimization
2538
+
2539
+ position = _updatePosition(
2540
+ params.owner,
2541
+ params.tickLower,
2542
+ params.tickUpper,
2543
+ params.liquidityDelta,
2544
+ _slot0.tick
2545
+ );
2546
+
2547
+ if (params.liquidityDelta != 0) {
2548
+ if (_slot0.tick < params.tickLower) {
2549
+ // current tick is below the passed range; liquidity can only become in range by crossing from left to
2550
+ // right, when we'll need _more_ token0 (it's becoming more valuable) so user must provide it
2551
+ amount0 = SqrtPriceMath.getAmount0Delta(
2552
+ TickMath.getSqrtRatioAtTick(params.tickLower),
2553
+ TickMath.getSqrtRatioAtTick(params.tickUpper),
2554
+ params.liquidityDelta
2555
+ );
2556
+ } else if (_slot0.tick < params.tickUpper) {
2557
+ // current tick is inside the passed range
2558
+ uint128 liquidityBefore = liquidity; // SLOAD for gas optimization
2559
+
2560
+ // write an oracle entry
2561
+ (slot0.observationIndex, slot0.observationCardinality) = observations.write(
2562
+ _slot0.observationIndex,
2563
+ _blockTimestamp(),
2564
+ _slot0.tick,
2565
+ liquidityBefore,
2566
+ _slot0.observationCardinality,
2567
+ _slot0.observationCardinalityNext
2568
+ );
2569
+
2570
+ amount0 = SqrtPriceMath.getAmount0Delta(
2571
+ _slot0.sqrtPriceX96,
2572
+ TickMath.getSqrtRatioAtTick(params.tickUpper),
2573
+ params.liquidityDelta
2574
+ );
2575
+ amount1 = SqrtPriceMath.getAmount1Delta(
2576
+ TickMath.getSqrtRatioAtTick(params.tickLower),
2577
+ _slot0.sqrtPriceX96,
2578
+ params.liquidityDelta
2579
+ );
2580
+
2581
+ liquidity = LiquidityMath.addDelta(liquidityBefore, params.liquidityDelta);
2582
+ } else {
2583
+ // current tick is above the passed range; liquidity can only become in range by crossing from right to
2584
+ // left, when we'll need _more_ token1 (it's becoming more valuable) so user must provide it
2585
+ amount1 = SqrtPriceMath.getAmount1Delta(
2586
+ TickMath.getSqrtRatioAtTick(params.tickLower),
2587
+ TickMath.getSqrtRatioAtTick(params.tickUpper),
2588
+ params.liquidityDelta
2589
+ );
2590
+ }
2591
+ }
2592
+ }
2593
+
2594
+ /// @dev Gets and updates a position with the given liquidity delta
2595
+ /// @param owner the owner of the position
2596
+ /// @param tickLower the lower tick of the position's tick range
2597
+ /// @param tickUpper the upper tick of the position's tick range
2598
+ /// @param tick the current tick, passed to avoid sloads
2599
+ function _updatePosition(
2600
+ address owner,
2601
+ int24 tickLower,
2602
+ int24 tickUpper,
2603
+ int128 liquidityDelta,
2604
+ int24 tick
2605
+ ) private returns (Position.Info storage position) {
2606
+ position = positions.get(owner, tickLower, tickUpper);
2607
+
2608
+ uint256 _feeGrowthGlobal0X128 = feeGrowthGlobal0X128; // SLOAD for gas optimization
2609
+ uint256 _feeGrowthGlobal1X128 = feeGrowthGlobal1X128; // SLOAD for gas optimization
2610
+
2611
+ // if we need to update the ticks, do it
2612
+ bool flippedLower;
2613
+ bool flippedUpper;
2614
+ if (liquidityDelta != 0) {
2615
+ uint32 time = _blockTimestamp();
2616
+ (int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
2617
+ observations.observeSingle(
2618
+ time,
2619
+ 0,
2620
+ slot0.tick,
2621
+ slot0.observationIndex,
2622
+ liquidity,
2623
+ slot0.observationCardinality
2624
+ );
2625
+
2626
+ flippedLower = ticks.update(
2627
+ tickLower,
2628
+ tick,
2629
+ liquidityDelta,
2630
+ _feeGrowthGlobal0X128,
2631
+ _feeGrowthGlobal1X128,
2632
+ secondsPerLiquidityCumulativeX128,
2633
+ tickCumulative,
2634
+ time,
2635
+ false,
2636
+ maxLiquidityPerTick
2637
+ );
2638
+ flippedUpper = ticks.update(
2639
+ tickUpper,
2640
+ tick,
2641
+ liquidityDelta,
2642
+ _feeGrowthGlobal0X128,
2643
+ _feeGrowthGlobal1X128,
2644
+ secondsPerLiquidityCumulativeX128,
2645
+ tickCumulative,
2646
+ time,
2647
+ true,
2648
+ maxLiquidityPerTick
2649
+ );
2650
+
2651
+ if (flippedLower) {
2652
+ tickBitmap.flipTick(tickLower, tickSpacing);
2653
+ }
2654
+ if (flippedUpper) {
2655
+ tickBitmap.flipTick(tickUpper, tickSpacing);
2656
+ }
2657
+ }
2658
+
2659
+ (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) =
2660
+ ticks.getFeeGrowthInside(tickLower, tickUpper, tick, _feeGrowthGlobal0X128, _feeGrowthGlobal1X128);
2661
+
2662
+ position.update(liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128);
2663
+
2664
+ // clear any tick data that is no longer needed
2665
+ if (liquidityDelta < 0) {
2666
+ if (flippedLower) {
2667
+ ticks.clear(tickLower);
2668
+ }
2669
+ if (flippedUpper) {
2670
+ ticks.clear(tickUpper);
2671
+ }
2672
+ }
2673
+ }
2674
+
2675
+ /// @inheritdoc IUniswapV3PoolActions
2676
+ /// @dev noDelegateCall is applied indirectly via _modifyPosition
2677
+ function mint(
2678
+ address recipient,
2679
+ int24 tickLower,
2680
+ int24 tickUpper,
2681
+ uint128 amount,
2682
+ bytes calldata data
2683
+ ) external override lock returns (uint256 amount0, uint256 amount1) {
2684
+ require(amount > 0);
2685
+ (, int256 amount0Int, int256 amount1Int) =
2686
+ _modifyPosition(
2687
+ ModifyPositionParams({
2688
+ owner: recipient,
2689
+ tickLower: tickLower,
2690
+ tickUpper: tickUpper,
2691
+ liquidityDelta: int256(amount).toInt128()
2692
+ })
2693
+ );
2694
+
2695
+ amount0 = uint256(amount0Int);
2696
+ amount1 = uint256(amount1Int);
2697
+
2698
+ uint256 balance0Before;
2699
+ uint256 balance1Before;
2700
+ if (amount0 > 0) balance0Before = balance0();
2701
+ if (amount1 > 0) balance1Before = balance1();
2702
+ IUniswapV3MintCallback(msg.sender).uniswapV3MintCallback(amount0, amount1, data);
2703
+ if (amount0 > 0) require(balance0Before.add(amount0) <= balance0(), 'M0');
2704
+ if (amount1 > 0) require(balance1Before.add(amount1) <= balance1(), 'M1');
2705
+
2706
+ emit Mint(msg.sender, recipient, tickLower, tickUpper, amount, amount0, amount1);
2707
+ }
2708
+
2709
+ /// @inheritdoc IUniswapV3PoolActions
2710
+ function collect(
2711
+ address recipient,
2712
+ int24 tickLower,
2713
+ int24 tickUpper,
2714
+ uint128 amount0Requested,
2715
+ uint128 amount1Requested
2716
+ ) external override lock returns (uint128 amount0, uint128 amount1) {
2717
+ // we don't need to checkTicks here, because invalid positions will never have non-zero tokensOwed{0,1}
2718
+ Position.Info storage position = positions.get(msg.sender, tickLower, tickUpper);
2719
+
2720
+ amount0 = amount0Requested > position.tokensOwed0 ? position.tokensOwed0 : amount0Requested;
2721
+ amount1 = amount1Requested > position.tokensOwed1 ? position.tokensOwed1 : amount1Requested;
2722
+
2723
+ if (amount0 > 0) {
2724
+ position.tokensOwed0 -= amount0;
2725
+ TransferHelper.safeTransfer(token0, recipient, amount0);
2726
+ }
2727
+ if (amount1 > 0) {
2728
+ position.tokensOwed1 -= amount1;
2729
+ TransferHelper.safeTransfer(token1, recipient, amount1);
2730
+ }
2731
+
2732
+ emit Collect(msg.sender, recipient, tickLower, tickUpper, amount0, amount1);
2733
+ }
2734
+
2735
+ /// @inheritdoc IUniswapV3PoolActions
2736
+ /// @dev noDelegateCall is applied indirectly via _modifyPosition
2737
+ function burn(
2738
+ int24 tickLower,
2739
+ int24 tickUpper,
2740
+ uint128 amount
2741
+ ) external override lock returns (uint256 amount0, uint256 amount1) {
2742
+ (Position.Info storage position, int256 amount0Int, int256 amount1Int) =
2743
+ _modifyPosition(
2744
+ ModifyPositionParams({
2745
+ owner: msg.sender,
2746
+ tickLower: tickLower,
2747
+ tickUpper: tickUpper,
2748
+ liquidityDelta: -int256(amount).toInt128()
2749
+ })
2750
+ );
2751
+
2752
+ amount0 = uint256(-amount0Int);
2753
+ amount1 = uint256(-amount1Int);
2754
+
2755
+ if (amount0 > 0 || amount1 > 0) {
2756
+ (position.tokensOwed0, position.tokensOwed1) = (
2757
+ position.tokensOwed0 + uint128(amount0),
2758
+ position.tokensOwed1 + uint128(amount1)
2759
+ );
2760
+ }
2761
+
2762
+ emit Burn(msg.sender, tickLower, tickUpper, amount, amount0, amount1);
2763
+ }
2764
+
2765
+ struct SwapCache {
2766
+ // the protocol fee for the input token
2767
+ uint8 feeProtocol;
2768
+ // liquidity at the beginning of the swap
2769
+ uint128 liquidityStart;
2770
+ // the timestamp of the current block
2771
+ uint32 blockTimestamp;
2772
+ // the current value of the tick accumulator, computed only if we cross an initialized tick
2773
+ int56 tickCumulative;
2774
+ // the current value of seconds per liquidity accumulator, computed only if we cross an initialized tick
2775
+ uint160 secondsPerLiquidityCumulativeX128;
2776
+ // whether we've computed and cached the above two accumulators
2777
+ bool computedLatestObservation;
2778
+ }
2779
+
2780
+ // the top level state of the swap, the results of which are recorded in storage at the end
2781
+ struct SwapState {
2782
+ // the amount remaining to be swapped in/out of the input/output asset
2783
+ int256 amountSpecifiedRemaining;
2784
+ // the amount already swapped out/in of the output/input asset
2785
+ int256 amountCalculated;
2786
+ // current sqrt(price)
2787
+ uint160 sqrtPriceX96;
2788
+ // the tick associated with the current price
2789
+ int24 tick;
2790
+ // the global fee growth of the input token
2791
+ uint256 feeGrowthGlobalX128;
2792
+ // amount of input token paid as protocol fee
2793
+ uint128 protocolFee;
2794
+ // the current liquidity in range
2795
+ uint128 liquidity;
2796
+ }
2797
+
2798
+ struct StepComputations {
2799
+ // the price at the beginning of the step
2800
+ uint160 sqrtPriceStartX96;
2801
+ // the next tick to swap to from the current tick in the swap direction
2802
+ int24 tickNext;
2803
+ // whether tickNext is initialized or not
2804
+ bool initialized;
2805
+ // sqrt(price) for the next tick (1/0)
2806
+ uint160 sqrtPriceNextX96;
2807
+ // how much is being swapped in in this step
2808
+ uint256 amountIn;
2809
+ // how much is being swapped out
2810
+ uint256 amountOut;
2811
+ // how much fee is being paid in
2812
+ uint256 feeAmount;
2813
+ }
2814
+
2815
+ /// @inheritdoc IUniswapV3PoolActions
2816
+ function swap(
2817
+ address recipient,
2818
+ bool zeroForOne,
2819
+ int256 amountSpecified,
2820
+ uint160 sqrtPriceLimitX96,
2821
+ bytes calldata data
2822
+ ) external override noDelegateCall returns (int256 amount0, int256 amount1) {
2823
+ require(amountSpecified != 0, 'AS');
2824
+
2825
+ Slot0 memory slot0Start = slot0;
2826
+
2827
+ require(slot0Start.unlocked, 'LOK');
2828
+ require(
2829
+ zeroForOne
2830
+ ? sqrtPriceLimitX96 < slot0Start.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO
2831
+ : sqrtPriceLimitX96 > slot0Start.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,
2832
+ 'SPL'
2833
+ );
2834
+
2835
+ slot0.unlocked = false;
2836
+
2837
+ SwapCache memory cache =
2838
+ SwapCache({
2839
+ liquidityStart: liquidity,
2840
+ blockTimestamp: _blockTimestamp(),
2841
+ feeProtocol: zeroForOne ? (slot0Start.feeProtocol % 16) : (slot0Start.feeProtocol >> 4),
2842
+ secondsPerLiquidityCumulativeX128: 0,
2843
+ tickCumulative: 0,
2844
+ computedLatestObservation: false
2845
+ });
2846
+
2847
+ bool exactInput = amountSpecified > 0;
2848
+
2849
+ SwapState memory state =
2850
+ SwapState({
2851
+ amountSpecifiedRemaining: amountSpecified,
2852
+ amountCalculated: 0,
2853
+ sqrtPriceX96: slot0Start.sqrtPriceX96,
2854
+ tick: slot0Start.tick,
2855
+ feeGrowthGlobalX128: zeroForOne ? feeGrowthGlobal0X128 : feeGrowthGlobal1X128,
2856
+ protocolFee: 0,
2857
+ liquidity: cache.liquidityStart
2858
+ });
2859
+
2860
+ // continue swapping as long as we haven't used the entire input/output and haven't reached the price limit
2861
+ while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {
2862
+ StepComputations memory step;
2863
+
2864
+ step.sqrtPriceStartX96 = state.sqrtPriceX96;
2865
+
2866
+ (step.tickNext, step.initialized) = tickBitmap.nextInitializedTickWithinOneWord(
2867
+ state.tick,
2868
+ tickSpacing,
2869
+ zeroForOne
2870
+ );
2871
+
2872
+ // ensure that we do not overshoot the min/max tick, as the tick bitmap is not aware of these bounds
2873
+ if (step.tickNext < TickMath.MIN_TICK) {
2874
+ step.tickNext = TickMath.MIN_TICK;
2875
+ } else if (step.tickNext > TickMath.MAX_TICK) {
2876
+ step.tickNext = TickMath.MAX_TICK;
2877
+ }
2878
+
2879
+ // get the price for the next tick
2880
+ step.sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(step.tickNext);
2881
+
2882
+ // compute values to swap to the target tick, price limit, or point where input/output amount is exhausted
2883
+ (state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(
2884
+ state.sqrtPriceX96,
2885
+ (zeroForOne ? step.sqrtPriceNextX96 < sqrtPriceLimitX96 : step.sqrtPriceNextX96 > sqrtPriceLimitX96)
2886
+ ? sqrtPriceLimitX96
2887
+ : step.sqrtPriceNextX96,
2888
+ state.liquidity,
2889
+ state.amountSpecifiedRemaining,
2890
+ fee
2891
+ );
2892
+
2893
+ if (exactInput) {
2894
+ state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();
2895
+ state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());
2896
+ } else {
2897
+ state.amountSpecifiedRemaining += step.amountOut.toInt256();
2898
+ state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());
2899
+ }
2900
+
2901
+ // if the protocol fee is on, calculate how much is owed, decrement feeAmount, and increment protocolFee
2902
+ if (cache.feeProtocol > 0) {
2903
+ uint256 delta = step.feeAmount / cache.feeProtocol;
2904
+ step.feeAmount -= delta;
2905
+ state.protocolFee += uint128(delta);
2906
+ }
2907
+
2908
+ // update global fee tracker
2909
+ if (state.liquidity > 0)
2910
+ state.feeGrowthGlobalX128 += FullMath.mulDiv(step.feeAmount, FixedPoint128.Q128, state.liquidity);
2911
+
2912
+ // shift tick if we reached the next price
2913
+ if (state.sqrtPriceX96 == step.sqrtPriceNextX96) {
2914
+ // if the tick is initialized, run the tick transition
2915
+ if (step.initialized) {
2916
+ // check for the placeholder value, which we replace with the actual value the first time the swap
2917
+ // crosses an initialized tick
2918
+ if (!cache.computedLatestObservation) {
2919
+ (cache.tickCumulative, cache.secondsPerLiquidityCumulativeX128) = observations.observeSingle(
2920
+ cache.blockTimestamp,
2921
+ 0,
2922
+ slot0Start.tick,
2923
+ slot0Start.observationIndex,
2924
+ cache.liquidityStart,
2925
+ slot0Start.observationCardinality
2926
+ );
2927
+ cache.computedLatestObservation = true;
2928
+ }
2929
+ int128 liquidityNet =
2930
+ ticks.cross(
2931
+ step.tickNext,
2932
+ (zeroForOne ? state.feeGrowthGlobalX128 : feeGrowthGlobal0X128),
2933
+ (zeroForOne ? feeGrowthGlobal1X128 : state.feeGrowthGlobalX128),
2934
+ cache.secondsPerLiquidityCumulativeX128,
2935
+ cache.tickCumulative,
2936
+ cache.blockTimestamp
2937
+ );
2938
+ // if we're moving leftward, we interpret liquidityNet as the opposite sign
2939
+ // safe because liquidityNet cannot be type(int128).min
2940
+ if (zeroForOne) liquidityNet = -liquidityNet;
2941
+
2942
+ state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);
2943
+ }
2944
+
2945
+ state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;
2946
+ } else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) {
2947
+ // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved
2948
+ state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);
2949
+ }
2950
+ }
2951
+
2952
+ // update tick and write an oracle entry if the tick change
2953
+ if (state.tick != slot0Start.tick) {
2954
+ (uint16 observationIndex, uint16 observationCardinality) =
2955
+ observations.write(
2956
+ slot0Start.observationIndex,
2957
+ cache.blockTimestamp,
2958
+ slot0Start.tick,
2959
+ cache.liquidityStart,
2960
+ slot0Start.observationCardinality,
2961
+ slot0Start.observationCardinalityNext
2962
+ );
2963
+ (slot0.sqrtPriceX96, slot0.tick, slot0.observationIndex, slot0.observationCardinality) = (
2964
+ state.sqrtPriceX96,
2965
+ state.tick,
2966
+ observationIndex,
2967
+ observationCardinality
2968
+ );
2969
+ } else {
2970
+ // otherwise just update the price
2971
+ slot0.sqrtPriceX96 = state.sqrtPriceX96;
2972
+ }
2973
+
2974
+ // update liquidity if it changed
2975
+ if (cache.liquidityStart != state.liquidity) liquidity = state.liquidity;
2976
+
2977
+ // update fee growth global and, if necessary, protocol fees
2978
+ // overflow is acceptable, protocol has to withdraw before it hits type(uint128).max fees
2979
+ if (zeroForOne) {
2980
+ feeGrowthGlobal0X128 = state.feeGrowthGlobalX128;
2981
+ if (state.protocolFee > 0) protocolFees.token0 += state.protocolFee;
2982
+ } else {
2983
+ feeGrowthGlobal1X128 = state.feeGrowthGlobalX128;
2984
+ if (state.protocolFee > 0) protocolFees.token1 += state.protocolFee;
2985
+ }
2986
+
2987
+ (amount0, amount1) = zeroForOne == exactInput
2988
+ ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)
2989
+ : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);
2990
+
2991
+ // do the transfers and collect payment
2992
+ if (zeroForOne) {
2993
+ if (amount1 < 0) TransferHelper.safeTransfer(token1, recipient, uint256(-amount1));
2994
+
2995
+ uint256 balance0Before = balance0();
2996
+ IUniswapV3SwapCallback(msg.sender).uniswapV3SwapCallback(amount0, amount1, data);
2997
+ require(balance0Before.add(uint256(amount0)) <= balance0(), 'IIA');
2998
+ } else {
2999
+ if (amount0 < 0) TransferHelper.safeTransfer(token0, recipient, uint256(-amount0));
3000
+
3001
+ uint256 balance1Before = balance1();
3002
+ IUniswapV3SwapCallback(msg.sender).uniswapV3SwapCallback(amount0, amount1, data);
3003
+ require(balance1Before.add(uint256(amount1)) <= balance1(), 'IIA');
3004
+ }
3005
+
3006
+ emit Swap(msg.sender, recipient, amount0, amount1, state.sqrtPriceX96, state.liquidity, state.tick);
3007
+ slot0.unlocked = true;
3008
+ }
3009
+
3010
+ /// @inheritdoc IUniswapV3PoolActions
3011
+ function flash(
3012
+ address recipient,
3013
+ uint256 amount0,
3014
+ uint256 amount1,
3015
+ bytes calldata data
3016
+ ) external override lock noDelegateCall {
3017
+ uint128 _liquidity = liquidity;
3018
+ require(_liquidity > 0, 'L');
3019
+
3020
+ uint256 fee0 = FullMath.mulDivRoundingUp(amount0, fee, 1e6);
3021
+ uint256 fee1 = FullMath.mulDivRoundingUp(amount1, fee, 1e6);
3022
+ uint256 balance0Before = balance0();
3023
+ uint256 balance1Before = balance1();
3024
+
3025
+ if (amount0 > 0) TransferHelper.safeTransfer(token0, recipient, amount0);
3026
+ if (amount1 > 0) TransferHelper.safeTransfer(token1, recipient, amount1);
3027
+
3028
+ IUniswapV3FlashCallback(msg.sender).uniswapV3FlashCallback(fee0, fee1, data);
3029
+
3030
+ uint256 balance0After = balance0();
3031
+ uint256 balance1After = balance1();
3032
+
3033
+ require(balance0Before.add(fee0) <= balance0After, 'F0');
3034
+ require(balance1Before.add(fee1) <= balance1After, 'F1');
3035
+
3036
+ // sub is safe because we know balanceAfter is gt balanceBefore by at least fee
3037
+ uint256 paid0 = balance0After - balance0Before;
3038
+ uint256 paid1 = balance1After - balance1Before;
3039
+
3040
+ if (paid0 > 0) {
3041
+ uint8 feeProtocol0 = slot0.feeProtocol % 16;
3042
+ uint256 fees0 = feeProtocol0 == 0 ? 0 : paid0 / feeProtocol0;
3043
+ if (uint128(fees0) > 0) protocolFees.token0 += uint128(fees0);
3044
+ feeGrowthGlobal0X128 += FullMath.mulDiv(paid0 - fees0, FixedPoint128.Q128, _liquidity);
3045
+ }
3046
+ if (paid1 > 0) {
3047
+ uint8 feeProtocol1 = slot0.feeProtocol >> 4;
3048
+ uint256 fees1 = feeProtocol1 == 0 ? 0 : paid1 / feeProtocol1;
3049
+ if (uint128(fees1) > 0) protocolFees.token1 += uint128(fees1);
3050
+ feeGrowthGlobal1X128 += FullMath.mulDiv(paid1 - fees1, FixedPoint128.Q128, _liquidity);
3051
+ }
3052
+
3053
+ emit Flash(msg.sender, recipient, amount0, amount1, paid0, paid1);
3054
+ }
3055
+
3056
+ /// @inheritdoc IUniswapV3PoolOwnerActions
3057
+ function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external override lock onlyFactoryOwner {
3058
+ require(
3059
+ (feeProtocol0 == 0 || (feeProtocol0 >= 4 && feeProtocol0 <= 10)) &&
3060
+ (feeProtocol1 == 0 || (feeProtocol1 >= 4 && feeProtocol1 <= 10))
3061
+ );
3062
+ uint8 feeProtocolOld = slot0.feeProtocol;
3063
+ slot0.feeProtocol = feeProtocol0 + (feeProtocol1 << 4);
3064
+ emit SetFeeProtocol(feeProtocolOld % 16, feeProtocolOld >> 4, feeProtocol0, feeProtocol1);
3065
+ }
3066
+
3067
+ /// @inheritdoc IUniswapV3PoolOwnerActions
3068
+ function collectProtocol(
3069
+ address recipient,
3070
+ uint128 amount0Requested,
3071
+ uint128 amount1Requested
3072
+ ) external override lock onlyFactoryOwner returns (uint128 amount0, uint128 amount1) {
3073
+ amount0 = amount0Requested > protocolFees.token0 ? protocolFees.token0 : amount0Requested;
3074
+ amount1 = amount1Requested > protocolFees.token1 ? protocolFees.token1 : amount1Requested;
3075
+
3076
+ if (amount0 > 0) {
3077
+ if (amount0 == protocolFees.token0) amount0--; // ensure that the slot is not cleared, for gas savings
3078
+ protocolFees.token0 -= amount0;
3079
+ TransferHelper.safeTransfer(token0, recipient, amount0);
3080
+ }
3081
+ if (amount1 > 0) {
3082
+ if (amount1 == protocolFees.token1) amount1--; // ensure that the slot is not cleared, for gas savings
3083
+ protocolFees.token1 -= amount1;
3084
+ TransferHelper.safeTransfer(token1, recipient, amount1);
3085
+ }
3086
+
3087
+ emit CollectProtocol(msg.sender, recipient, amount0, amount1);
3088
+ }
3089
+ }
3090
+
3091
+ // lib/v3-core-main/contracts/UniswapV3PoolDeployer.sol
3092
+
3093
+ contract UniswapV3PoolDeployer is IUniswapV3PoolDeployer {
3094
+ struct Parameters {
3095
+ address factory;
3096
+ address token0;
3097
+ address token1;
3098
+ uint24 fee;
3099
+ int24 tickSpacing;
3100
+ }
3101
+
3102
+ /// @inheritdoc IUniswapV3PoolDeployer
3103
+ Parameters public override parameters;
3104
+
3105
+ /// @dev Deploys a pool with the given parameters by transiently setting the parameters storage slot and then
3106
+ /// clearing it after deploying the pool.
3107
+ /// @param factory The contract address of the Uniswap V3 factory
3108
+ /// @param token0 The first token of the pool by address sort order
3109
+ /// @param token1 The second token of the pool by address sort order
3110
+ /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
3111
+ /// @param tickSpacing The spacing between usable ticks
3112
+ function deploy(
3113
+ address factory,
3114
+ address token0,
3115
+ address token1,
3116
+ uint24 fee,
3117
+ int24 tickSpacing
3118
+ ) internal returns (address pool) {
3119
+ parameters = Parameters({factory: factory, token0: token0, token1: token1, fee: fee, tickSpacing: tickSpacing});
3120
+ pool = address(new UniswapV3Pool{salt: keccak256(abi.encode(token0, token1, fee))}());
3121
+ delete parameters;
3122
+ }
3123
+ }
3124
+
3125
+ // lib/v3-core-main/contracts/UniswapV3Factory.sol
3126
+
3127
+ /// @title Canonical Uniswap V3 factory
3128
+ /// @notice Deploys Uniswap V3 pools and manages ownership and control over pool protocol fees
3129
+ contract UniswapV3Factory is IUniswapV3Factory, UniswapV3PoolDeployer, NoDelegateCall {
3130
+ /// @inheritdoc IUniswapV3Factory
3131
+ address public override owner;
3132
+
3133
+ /// @inheritdoc IUniswapV3Factory
3134
+ mapping(uint24 => int24) public override feeAmountTickSpacing;
3135
+ /// @inheritdoc IUniswapV3Factory
3136
+ mapping(address => mapping(address => mapping(uint24 => address))) public override getPool;
3137
+
3138
+ constructor() {
3139
+ owner = msg.sender;
3140
+ emit OwnerChanged(address(0), msg.sender);
3141
+
3142
+ feeAmountTickSpacing[500] = 10;
3143
+ emit FeeAmountEnabled(500, 10);
3144
+ feeAmountTickSpacing[3000] = 60;
3145
+ emit FeeAmountEnabled(3000, 60);
3146
+ feeAmountTickSpacing[10000] = 200;
3147
+ emit FeeAmountEnabled(10000, 200);
3148
+ }
3149
+
3150
+ /// @inheritdoc IUniswapV3Factory
3151
+ function createPool(
3152
+ address tokenA,
3153
+ address tokenB,
3154
+ uint24 fee
3155
+ ) external override noDelegateCall returns (address pool) {
3156
+ require(tokenA != tokenB);
3157
+ (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
3158
+ require(token0 != address(0));
3159
+ int24 tickSpacing = feeAmountTickSpacing[fee];
3160
+ require(tickSpacing != 0);
3161
+ require(getPool[token0][token1][fee] == address(0));
3162
+ pool = deploy(address(this), token0, token1, fee, tickSpacing);
3163
+ getPool[token0][token1][fee] = pool;
3164
+ // populate mapping in the reverse direction, deliberate choice to avoid the cost of comparing addresses
3165
+ getPool[token1][token0][fee] = pool;
3166
+ emit PoolCreated(token0, token1, fee, tickSpacing, pool);
3167
+ }
3168
+
3169
+ /// @inheritdoc IUniswapV3Factory
3170
+ function setOwner(address _owner) external override {
3171
+ require(msg.sender == owner);
3172
+ emit OwnerChanged(owner, _owner);
3173
+ owner = _owner;
3174
+ }
3175
+
3176
+ /// @inheritdoc IUniswapV3Factory
3177
+ function enableFeeAmount(uint24 fee, int24 tickSpacing) public override {
3178
+ require(msg.sender == owner);
3179
+ require(fee < 1000000);
3180
+ // tick spacing is capped at 16384 to prevent the situation where tickSpacing is so large that
3181
+ // TickBitmap#nextInitializedTickWithinOneWord overflows int24 container from a valid tick
3182
+ // 16384 ticks represents a >5x price change with ticks of 1 bips
3183
+ require(tickSpacing > 0 && tickSpacing < 16384);
3184
+ require(feeAmountTickSpacing[fee] == 0);
3185
+
3186
+ feeAmountTickSpacing[fee] = tickSpacing;
3187
+ emit FeeAmountEnabled(fee, tickSpacing);
3188
+ }
3189
+ }
3190
+
3191
+ // src/RapidexV3FactoryImporter.sol
3192
+
3193
+ contract RapidexV3FactoryImporter is UniswapV3Factory {}