@zoralabs/coins 0.1.1

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 (116) hide show
  1. package/.turbo/turbo-build.log +76 -0
  2. package/CHANGELOG.md +14 -0
  3. package/LICENSE +21 -0
  4. package/abis/Address.json +29 -0
  5. package/abis/BaseTest.json +691 -0
  6. package/abis/Clones.json +7 -0
  7. package/abis/Coin.json +1693 -0
  8. package/abis/CoinConstants.json +93 -0
  9. package/abis/CoinTest.json +998 -0
  10. package/abis/ContextUpgradeable.json +25 -0
  11. package/abis/ContractVersionBase.json +15 -0
  12. package/abis/Deploy.json +29 -0
  13. package/abis/ECDSA.json +29 -0
  14. package/abis/EIP712.json +67 -0
  15. package/abis/EIP712Upgradeable.json +74 -0
  16. package/abis/ERC1967Proxy.json +67 -0
  17. package/abis/ERC1967Utils.json +85 -0
  18. package/abis/ERC20PermitUpgradeable.json +527 -0
  19. package/abis/ERC20Upgradeable.json +333 -0
  20. package/abis/FactoryTest.json +845 -0
  21. package/abis/IBeacon.json +15 -0
  22. package/abis/ICoin.json +541 -0
  23. package/abis/ICoinComments.json +53 -0
  24. package/abis/IERC1155Errors.json +104 -0
  25. package/abis/IERC165.json +21 -0
  26. package/abis/IERC1822Proxiable.json +15 -0
  27. package/abis/IERC20.json +221 -0
  28. package/abis/IERC20Errors.json +88 -0
  29. package/abis/IERC20Metadata.json +224 -0
  30. package/abis/IERC20Permit.json +77 -0
  31. package/abis/IERC5267.json +51 -0
  32. package/abis/IERC721.json +287 -0
  33. package/abis/IERC721Enumerable.json +343 -0
  34. package/abis/IERC721Errors.json +105 -0
  35. package/abis/IERC721Metadata.json +332 -0
  36. package/abis/IERC721Receiver.json +36 -0
  37. package/abis/IERC721TokenReceiver.json +36 -0
  38. package/abis/IERC7572.json +21 -0
  39. package/abis/IMulticall3.json +440 -0
  40. package/abis/INonfungiblePositionManager.json +366 -0
  41. package/abis/IProtocolRewards.json +348 -0
  42. package/abis/ISwapRouter.json +137 -0
  43. package/abis/IUniswapV3Pool.json +148 -0
  44. package/abis/IUniswapV3SwapCallback.json +25 -0
  45. package/abis/IVersionedContract.json +15 -0
  46. package/abis/IWETH.json +118 -0
  47. package/abis/IZoraFactory.json +138 -0
  48. package/abis/Initializable.json +25 -0
  49. package/abis/Math.json +7 -0
  50. package/abis/MockERC20.json +322 -0
  51. package/abis/MockERC721.json +350 -0
  52. package/abis/MultiOwnable.json +171 -0
  53. package/abis/MultiOwnableTest.json +796 -0
  54. package/abis/NoncesUpgradeable.json +60 -0
  55. package/abis/OwnableUpgradeable.json +99 -0
  56. package/abis/ProtocolRewards.json +494 -0
  57. package/abis/Proxy.json +6 -0
  58. package/abis/ReentrancyGuardUpgradeable.json +30 -0
  59. package/abis/SafeERC20.json +34 -0
  60. package/abis/Script.json +15 -0
  61. package/abis/ShortStrings.json +18 -0
  62. package/abis/StdAssertions.json +379 -0
  63. package/abis/StdInvariant.json +180 -0
  64. package/abis/Strings.json +18 -0
  65. package/abis/Test.json +570 -0
  66. package/abis/UUPSUpgradeable.json +130 -0
  67. package/abis/Vm.json +8627 -0
  68. package/abis/VmSafe.json +7297 -0
  69. package/abis/ZoraFactory.json +67 -0
  70. package/abis/ZoraFactoryImpl.json +422 -0
  71. package/abis/stdError.json +119 -0
  72. package/abis/stdStorageSafe.json +52 -0
  73. package/addresses/1.json +4 -0
  74. package/addresses/8453.json +9 -0
  75. package/addresses/84532.json +9 -0
  76. package/dist/index.cjs +1236 -0
  77. package/dist/index.cjs.map +1 -0
  78. package/dist/index.d.ts +2 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +1208 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/wagmiGenerated.d.ts +1645 -0
  83. package/dist/wagmiGenerated.d.ts.map +1 -0
  84. package/foundry.toml +9 -0
  85. package/package/index.ts +1 -0
  86. package/package/wagmiGenerated.ts +1211 -0
  87. package/package.json +48 -0
  88. package/remappings.txt +4 -0
  89. package/script/Deploy.s.sol +14 -0
  90. package/slither.config.json +6 -0
  91. package/src/Coin.sol +579 -0
  92. package/src/ZoraFactoryImpl.sol +142 -0
  93. package/src/interfaces/ICoin.sol +194 -0
  94. package/src/interfaces/ICoinComments.sol +8 -0
  95. package/src/interfaces/IERC7572.sol +12 -0
  96. package/src/interfaces/INonfungiblePositionManager.sol +104 -0
  97. package/src/interfaces/IProtocolRewards.sol +12 -0
  98. package/src/interfaces/ISwapRouter.sol +38 -0
  99. package/src/interfaces/IUniswapV3Pool.sol +43 -0
  100. package/src/interfaces/IUniswapV3SwapCallback.sol +17 -0
  101. package/src/interfaces/IWETH.sol +16 -0
  102. package/src/interfaces/IZoraFactory.sol +56 -0
  103. package/src/proxy/ZoraFactory.sol +26 -0
  104. package/src/utils/CoinConstants.sol +67 -0
  105. package/src/utils/MultiOwnable.sol +126 -0
  106. package/src/utils/TickMath.sol +210 -0
  107. package/src/version/ContractVersionBase.sol +14 -0
  108. package/test/Coin.t.sol +443 -0
  109. package/test/Factory.t.sol +298 -0
  110. package/test/MultiOwnable.t.sol +156 -0
  111. package/test/utils/BaseTest.sol +178 -0
  112. package/test/utils/ProtocolRewards.sol +1499 -0
  113. package/tsconfig.build.json +10 -0
  114. package/tsconfig.json +9 -0
  115. package/tsup.config.ts +11 -0
  116. package/wagmi.config.ts +16 -0
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
5
+
6
+ /*
7
+ ░░░░░░░░░░░░░░
8
+ ░░▒▒░░░░░░░░░░░░░░░░░░░░
9
+ ░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░
10
+ ░░▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░
11
+ ░▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░
12
+ ░▓▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░░
13
+ ░▓▓▓▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░
14
+ ░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░
15
+ ░▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░
16
+ ░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░
17
+ ░░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
18
+ ░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒░░
19
+ ░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
20
+ ░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░
21
+
22
+ OURS TRULY,
23
+ */
24
+ contract ZoraFactory is ERC1967Proxy {
25
+ constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) {}
26
+ }
@@ -0,0 +1,67 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ abstract contract CoinConstants {
5
+ /// @notice The maximum total supply
6
+ /// @dev Set to 1 billion coins with 18 decimals
7
+ uint256 public constant MAX_TOTAL_SUPPLY = 1_000_000_000e18;
8
+
9
+ /// @notice The number of coins allocated to the liquidity pool
10
+ /// @dev Set to 980 million coins
11
+ uint256 internal constant POOL_LAUNCH_SUPPLY = 980_000_000e18;
12
+
13
+ /// @notice The number of coins rewarded to the creator
14
+ /// @dev Set to 10 million coins
15
+ uint256 internal constant CREATOR_LAUNCH_REWARD = 10_000_000e18;
16
+
17
+ /// @notice The number of coins rewarded to the platform referrer
18
+ /// @dev Set to 5 million coins
19
+ uint256 internal constant PLATFORM_REFERRER_LAUNCH_REWARD = 5_000_000e18;
20
+
21
+ /// @notice The number of coins rewarded to the protocol
22
+ /// @dev Set to 5 million coins
23
+ uint256 internal constant PROTOCOL_LAUNCH_REWARD = 5_000_000e18;
24
+
25
+ /// @notice The minimum order size allowed for trades
26
+ /// @dev Set to 0.0000001 ETH to prevent dust transactions
27
+ uint256 public constant MIN_ORDER_SIZE = 0.0000001 ether;
28
+
29
+ /// @notice The total fee percentage in basis points
30
+ /// @dev 100 basis points = 1%
31
+ uint256 public constant TOTAL_FEE_BPS = 100;
32
+
33
+ /// @notice The percentage of the total fee allocated to creators
34
+ /// @dev 5000 basis points = 50% of TOTAL_FEE_BPS
35
+ uint256 public constant TOKEN_CREATOR_FEE_BPS = 5000;
36
+
37
+ /// @notice The percentage of the total fee allocated to the protocol
38
+ /// @dev 2000 basis points = 20% of TOTAL_FEE_BPS
39
+ uint256 public constant PROTOCOL_FEE_BPS = 2000;
40
+
41
+ /// @notice The percentage of the total fee allocated to platform referrers
42
+ /// @dev 1500 basis points = 15% of TOTAL_FEE_BPS
43
+ uint256 public constant PLATFORM_REFERRER_FEE_BPS = 1500;
44
+
45
+ /// @notice The percentage of the total fee allocated to trade referrers
46
+ /// @dev 1500 basis points = 15% of TOTAL_FEE_BPS
47
+ uint256 public constant TRADE_REFERRER_FEE_BPS = 1500;
48
+
49
+ /// @notice The percentage of the LP fee allocated to creators
50
+ /// @dev 5000 basis points = 50% of LP_FEE
51
+ uint256 internal constant CREATOR_MARKET_REWARD_BPS = 5000;
52
+
53
+ /// @notice The percentage of the LP fee allocated to platform referrers
54
+ /// @dev 2500 basis points = 25% of LP_FEE
55
+ uint256 internal constant PLATFORM_REFERRER_MARKET_REWARD_BPS = 2500;
56
+
57
+ /// @notice The LP fee
58
+ /// @dev 10000 basis points = 1%
59
+ uint24 internal constant LP_FEE = 10000;
60
+
61
+ /// @notice The LP's lower tick
62
+ /// @dev This is only used if the currency is WETH
63
+ int24 internal constant LP_TICK_LOWER_WETH = -219200;
64
+
65
+ /// @notice The LP's upper tick
66
+ int24 internal constant LP_TICK_UPPER = 887200;
67
+ }
@@ -0,0 +1,126 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6
+
7
+ /// @title MultiOwnable
8
+ /// @notice Allows multiple addresses to have owner privileges
9
+ contract MultiOwnable is Initializable {
10
+ using EnumerableSet for EnumerableSet.AddressSet;
11
+
12
+ event OwnerUpdated(address indexed caller, address indexed prevOwner, address indexed newOwner);
13
+
14
+ error AlreadyOwner();
15
+ error NotOwner();
16
+ error OneOwnerRequired();
17
+ error OwnerCannotBeAddressZero();
18
+ error OnlyOwner();
19
+ error UseRevokeOwnershipToRemoveSelf();
20
+
21
+ EnumerableSet.AddressSet internal _owners;
22
+
23
+ /// @notice Restricts function access to current owners
24
+ modifier onlyOwner() {
25
+ if (!isOwner(msg.sender)) {
26
+ revert OnlyOwner();
27
+ }
28
+ _;
29
+ }
30
+
31
+ /// @dev Initializes the contract with a set of owners
32
+ /// @param initialOwners An list of initial owner addresses
33
+ function __MultiOwnable_init(address[] memory initialOwners) internal onlyInitializing {
34
+ uint256 numOwners = initialOwners.length;
35
+
36
+ if (numOwners == 0) {
37
+ revert OneOwnerRequired();
38
+ }
39
+
40
+ for (uint256 i; i < numOwners; ++i) {
41
+ if (initialOwners[i] == address(0)) {
42
+ revert OwnerCannotBeAddressZero();
43
+ }
44
+
45
+ if (isOwner(initialOwners[i])) {
46
+ revert AlreadyOwner();
47
+ }
48
+
49
+ _owners.add(initialOwners[i]);
50
+
51
+ emit OwnerUpdated(msg.sender, address(0), initialOwners[i]);
52
+ }
53
+ }
54
+
55
+ /// @notice Checks if an address is an owner
56
+ /// @param account The address to check
57
+ function isOwner(address account) public view returns (bool) {
58
+ return _owners.contains(account);
59
+ }
60
+
61
+ /// @notice The current owner addresses
62
+ function owners() public view returns (address[] memory) {
63
+ return _owners.values();
64
+ }
65
+
66
+ /// @notice Adds multiple owners
67
+ /// @param accounts The addresses to add as owners
68
+ function addOwners(address[] memory accounts) public onlyOwner {
69
+ for (uint256 i; i < accounts.length; ++i) {
70
+ addOwner(accounts[i]);
71
+ }
72
+ }
73
+
74
+ /// @notice Adds a new owner
75
+ /// @dev Only callable by existing owners
76
+ /// @param account The address to add as an owner
77
+ function addOwner(address account) public onlyOwner {
78
+ if (account == address(0)) {
79
+ revert OwnerCannotBeAddressZero();
80
+ }
81
+
82
+ if (isOwner(account)) {
83
+ revert AlreadyOwner();
84
+ }
85
+
86
+ _owners.add(account);
87
+
88
+ emit OwnerUpdated(msg.sender, address(0), account);
89
+ }
90
+
91
+ /// @notice Removes multiple owners
92
+ /// @param accounts The addresses to remove as owners
93
+ function removeOwners(address[] memory accounts) public onlyOwner {
94
+ for (uint256 i; i < accounts.length; ++i) {
95
+ removeOwner(accounts[i]);
96
+ }
97
+ }
98
+
99
+ /// @notice Removes an existing owner
100
+ /// @dev Only callable by existing owners
101
+ /// @param account The address to remove as an owner
102
+ function removeOwner(address account) public onlyOwner {
103
+ if (account == address(0)) {
104
+ revert OwnerCannotBeAddressZero();
105
+ }
106
+
107
+ if (account == msg.sender) {
108
+ revert UseRevokeOwnershipToRemoveSelf();
109
+ }
110
+
111
+ if (!isOwner(account)) {
112
+ revert NotOwner();
113
+ }
114
+
115
+ _owners.remove(account);
116
+
117
+ emit OwnerUpdated(msg.sender, account, address(0));
118
+ }
119
+
120
+ /// @notice Revokes ownership for the caller
121
+ function revokeOwnership() public onlyOwner {
122
+ _owners.remove(msg.sender);
123
+
124
+ emit OwnerUpdated(msg.sender, msg.sender, address(0));
125
+ }
126
+ }
@@ -0,0 +1,210 @@
1
+ // SPDX-License-Identifier: GPL-2.0-or-later
2
+ // Source: https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/libraries/TickMath.sol
3
+ pragma solidity >=0.5.0;
4
+
5
+ /// @title Math library for computing sqrt prices from ticks and vice versa
6
+ /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
7
+ /// prices between 2**-128 and 2**128
8
+ library TickMath {
9
+ /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
10
+ int24 internal constant MIN_TICK = -887272;
11
+ /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
12
+ int24 internal constant MAX_TICK = -MIN_TICK;
13
+
14
+ /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
15
+ uint160 internal constant MIN_SQRT_RATIO = 4295128739;
16
+ /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
17
+ uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
18
+
19
+ /// @notice Calculates sqrt(1.0001^tick) * 2^96
20
+ /// @dev Throws if |tick| > max tick
21
+ /// @param tick The input tick for the above formula
22
+ /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
23
+ /// at the given tick
24
+ function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
25
+ uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
26
+ require(absTick <= uint256(int256(MAX_TICK)), "T");
27
+
28
+ uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
29
+ if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
30
+ if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
31
+ if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
32
+ if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
33
+ if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
34
+ if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
35
+ if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
36
+ if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
37
+ if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
38
+ if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
39
+ if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
40
+ if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
41
+ if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
42
+ if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
43
+ if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
44
+ if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
45
+ if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
46
+ if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
47
+ if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
48
+
49
+ if (tick > 0) ratio = type(uint256).max / ratio;
50
+
51
+ // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
52
+ // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
53
+ // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
54
+ sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
55
+ }
56
+
57
+ /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
58
+ /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
59
+ /// ever return.
60
+ /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
61
+ /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
62
+ function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
63
+ // second inequality must be < because the price can never reach the price at the max tick
64
+ require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, "R");
65
+ uint256 ratio = uint256(sqrtPriceX96) << 32;
66
+
67
+ uint256 r = ratio;
68
+ uint256 msb = 0;
69
+
70
+ assembly {
71
+ let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
72
+ msb := or(msb, f)
73
+ r := shr(f, r)
74
+ }
75
+ assembly {
76
+ let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
77
+ msb := or(msb, f)
78
+ r := shr(f, r)
79
+ }
80
+ assembly {
81
+ let f := shl(5, gt(r, 0xFFFFFFFF))
82
+ msb := or(msb, f)
83
+ r := shr(f, r)
84
+ }
85
+ assembly {
86
+ let f := shl(4, gt(r, 0xFFFF))
87
+ msb := or(msb, f)
88
+ r := shr(f, r)
89
+ }
90
+ assembly {
91
+ let f := shl(3, gt(r, 0xFF))
92
+ msb := or(msb, f)
93
+ r := shr(f, r)
94
+ }
95
+ assembly {
96
+ let f := shl(2, gt(r, 0xF))
97
+ msb := or(msb, f)
98
+ r := shr(f, r)
99
+ }
100
+ assembly {
101
+ let f := shl(1, gt(r, 0x3))
102
+ msb := or(msb, f)
103
+ r := shr(f, r)
104
+ }
105
+ assembly {
106
+ let f := gt(r, 0x1)
107
+ msb := or(msb, f)
108
+ }
109
+
110
+ if (msb >= 128) r = ratio >> (msb - 127);
111
+ else r = ratio << (127 - msb);
112
+
113
+ int256 log_2 = (int256(msb) - 128) << 64;
114
+
115
+ assembly {
116
+ r := shr(127, mul(r, r))
117
+ let f := shr(128, r)
118
+ log_2 := or(log_2, shl(63, f))
119
+ r := shr(f, r)
120
+ }
121
+ assembly {
122
+ r := shr(127, mul(r, r))
123
+ let f := shr(128, r)
124
+ log_2 := or(log_2, shl(62, f))
125
+ r := shr(f, r)
126
+ }
127
+ assembly {
128
+ r := shr(127, mul(r, r))
129
+ let f := shr(128, r)
130
+ log_2 := or(log_2, shl(61, f))
131
+ r := shr(f, r)
132
+ }
133
+ assembly {
134
+ r := shr(127, mul(r, r))
135
+ let f := shr(128, r)
136
+ log_2 := or(log_2, shl(60, f))
137
+ r := shr(f, r)
138
+ }
139
+ assembly {
140
+ r := shr(127, mul(r, r))
141
+ let f := shr(128, r)
142
+ log_2 := or(log_2, shl(59, f))
143
+ r := shr(f, r)
144
+ }
145
+ assembly {
146
+ r := shr(127, mul(r, r))
147
+ let f := shr(128, r)
148
+ log_2 := or(log_2, shl(58, f))
149
+ r := shr(f, r)
150
+ }
151
+ assembly {
152
+ r := shr(127, mul(r, r))
153
+ let f := shr(128, r)
154
+ log_2 := or(log_2, shl(57, f))
155
+ r := shr(f, r)
156
+ }
157
+ assembly {
158
+ r := shr(127, mul(r, r))
159
+ let f := shr(128, r)
160
+ log_2 := or(log_2, shl(56, f))
161
+ r := shr(f, r)
162
+ }
163
+ assembly {
164
+ r := shr(127, mul(r, r))
165
+ let f := shr(128, r)
166
+ log_2 := or(log_2, shl(55, f))
167
+ r := shr(f, r)
168
+ }
169
+ assembly {
170
+ r := shr(127, mul(r, r))
171
+ let f := shr(128, r)
172
+ log_2 := or(log_2, shl(54, f))
173
+ r := shr(f, r)
174
+ }
175
+ assembly {
176
+ r := shr(127, mul(r, r))
177
+ let f := shr(128, r)
178
+ log_2 := or(log_2, shl(53, f))
179
+ r := shr(f, r)
180
+ }
181
+ assembly {
182
+ r := shr(127, mul(r, r))
183
+ let f := shr(128, r)
184
+ log_2 := or(log_2, shl(52, f))
185
+ r := shr(f, r)
186
+ }
187
+ assembly {
188
+ r := shr(127, mul(r, r))
189
+ let f := shr(128, r)
190
+ log_2 := or(log_2, shl(51, f))
191
+ r := shr(f, r)
192
+ }
193
+ assembly {
194
+ r := shr(127, mul(r, r))
195
+ let f := shr(128, r)
196
+ log_2 := or(log_2, shl(50, f))
197
+ }
198
+
199
+ int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
200
+
201
+ int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
202
+ int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
203
+
204
+ tick = tickLow == tickHi
205
+ ? tickLow
206
+ : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96
207
+ ? tickHi
208
+ : tickLow;
209
+ }
210
+ }
@@ -0,0 +1,14 @@
1
+ // This file is automatically generated by code; do not manually update
2
+ // SPDX-License-Identifier: MIT
3
+ pragma solidity ^0.8.23;
4
+
5
+ import {IVersionedContract} from "@zoralabs/shared-contracts/interfaces/IVersionedContract.sol";
6
+
7
+ /// @title ContractVersionBase
8
+ /// @notice Base contract for versioning contracts
9
+ contract ContractVersionBase is IVersionedContract {
10
+ /// @notice The version of the contract
11
+ function contractVersion() external pure override returns (string memory) {
12
+ return "0.1.1";
13
+ }
14
+ }