@zoralabs/coins 1.1.2 → 2.1.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 (78) hide show
  1. package/.turbo/turbo-build.log +107 -110
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +48 -1
  4. package/abis/BaseCoin.json +442 -0
  5. package/abis/BaseZoraV4CoinHook.json +6 -2
  6. package/abis/CoinTest.json +3 -246
  7. package/abis/CoinUniV4Test.json +20 -0
  8. package/abis/ContentCoinHook.json +6 -2
  9. package/abis/CreatorCoinHook.json +6 -2
  10. package/abis/FactoryTest.json +8 -133
  11. package/abis/FeeEstimatorHook.json +6 -2
  12. package/abis/HooksTest.json +0 -26
  13. package/abis/ICoin.json +378 -0
  14. package/abis/ICoinV3.json +378 -0
  15. package/abis/IZoraFactory.json +0 -18
  16. package/abis/IZoraV4CoinHook.json +2 -2
  17. package/abis/LiquidityMigrationTest.json +101 -0
  18. package/abis/MockBadFactory.json +15 -0
  19. package/abis/Ownable2StepUpgradeable.json +138 -0
  20. package/abis/ZoraFactoryImpl.json +38 -65
  21. package/addresses/8453.json +5 -5
  22. package/dist/index.cjs +272 -268
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.js +270 -266
  25. package/dist/index.js.map +1 -1
  26. package/dist/wagmiGenerated.d.ts +397 -470
  27. package/dist/wagmiGenerated.d.ts.map +1 -1
  28. package/package/wagmiGenerated.ts +275 -271
  29. package/package.json +3 -3
  30. package/script/DeployPostDeploymentHooks.s.sol +2 -2
  31. package/script/TestBackingCoinSwap.s.sol +9 -9
  32. package/script/TestV4Swap.s.sol +9 -9
  33. package/script/UpgradeFactoryImpl.s.sol +0 -1
  34. package/src/BaseCoin.sol +109 -6
  35. package/src/ContentCoin.sol +45 -0
  36. package/src/CreatorCoin.sol +7 -5
  37. package/src/ZoraFactoryImpl.sol +12 -95
  38. package/src/deployment/CoinsDeployerBase.sol +13 -30
  39. package/src/hooks/BaseZoraV4CoinHook.sol +8 -6
  40. package/src/hooks/deployment/BuySupplyWithSwapRouterHook.sol +4 -5
  41. package/src/interfaces/ICoin.sol +67 -1
  42. package/src/interfaces/ICreatorCoin.sol +2 -2
  43. package/src/interfaces/IZoraFactory.sol +0 -5
  44. package/src/interfaces/IZoraV4CoinHook.sol +1 -1
  45. package/src/libs/CoinConfigurationVersions.sol +1 -39
  46. package/src/libs/CoinRewardsV4.sol +2 -2
  47. package/src/libs/CoinSetup.sol +1 -4
  48. package/src/libs/UniV4SwapHelper.sol +1 -1
  49. package/src/libs/UniV4SwapToCurrency.sol +2 -2
  50. package/src/libs/V4Liquidity.sol +1 -1
  51. package/src/version/ContractVersionBase.sol +1 -1
  52. package/test/Coin.t.sol +112 -535
  53. package/test/CoinUniV4.t.sol +66 -10
  54. package/test/DeploymentHooks.t.sol +5 -102
  55. package/test/Factory.t.sol +49 -291
  56. package/test/LiquidityMigration.t.sol +160 -2
  57. package/test/MultiOwnable.t.sol +36 -36
  58. package/test/Upgrades.t.sol +23 -42
  59. package/test/utils/BaseTest.sol +39 -84
  60. package/test/utils/FeeEstimatorHook.sol +3 -3
  61. package/wagmi.config.ts +2 -2
  62. package/abis/Coin.json +0 -1912
  63. package/abis/DopplerUniswapV3Test.json +0 -800
  64. package/abis/ICoinV4.json +0 -1048
  65. package/abis/Simulate.json +0 -29
  66. package/abis/UniV3BuySell.json +0 -12
  67. package/abis/UniV3Errors.json +0 -32
  68. package/script/Simulate.s.sol +0 -59
  69. package/src/Coin.sol +0 -236
  70. package/src/CoinV4.sol +0 -151
  71. package/src/interfaces/ICoinV4.sol +0 -74
  72. package/src/libs/CoinDopplerUniV3.sol +0 -50
  73. package/src/libs/CoinRewards.sol +0 -201
  74. package/src/libs/CoinSetupV3.sol +0 -50
  75. package/src/libs/UniV3BuySell.sol +0 -231
  76. package/src/libs/UniV3Errors.sol +0 -11
  77. package/test/CoinDopplerUniV3.t.sol +0 -310
  78. /package/abis/{CoinV4.json → ContentCoin.json} +0 -0
@@ -6,11 +6,10 @@ import "forge-std/Script.sol";
6
6
  import {ProxyDeployerScript, DeterministicContractConfig, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
7
7
  import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
8
8
  import {ZoraFactoryImpl} from "../ZoraFactoryImpl.sol";
9
- import {Coin} from "../Coin.sol";
10
9
  import {IVersionedContract} from "@zoralabs/shared-contracts/interfaces/IVersionedContract.sol";
11
- import {BuySupplyWithSwapRouterHook} from "../hooks/deployment/BuySupplyWithSwapRouterHook.sol";
10
+ // import {BuySupplyWithSwapRouterHook} from "../hooks/deployment/BuySupplyWithSwapRouterHook.sol";
12
11
  import {IZoraFactory} from "../interfaces/IZoraFactory.sol";
13
- import {CoinV4} from "../CoinV4.sol";
12
+ import {ContentCoin} from "../ContentCoin.sol";
14
13
  import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
15
14
  import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
16
15
  import {ZoraFactory} from "../proxy/ZoraFactory.sol";
@@ -102,21 +101,9 @@ contract CoinsDeployerBase is ProxyDeployerScript {
102
101
  deployment.hookUpgradeGate = readAddressOrDefaultToZero(json, "HOOK_UPGRADE_GATE");
103
102
  }
104
103
 
105
- function deployCoinV3Impl() internal returns (Coin) {
104
+ function deployCoinV4Impl(address zoraV4CoinHook) internal returns (ContentCoin) {
106
105
  return
107
- new Coin({
108
- protocolRewardRecipient_: getZoraRecipient(),
109
- protocolRewards_: PROTOCOL_REWARDS,
110
- weth_: getWeth(),
111
- v3Factory_: getUniswapV3Factory(),
112
- swapRouter_: getUniswapSwapRouter(),
113
- airlock_: getDopplerAirlock()
114
- });
115
- }
116
-
117
- function deployCoinV4Impl(address zoraV4CoinHook) internal returns (CoinV4) {
118
- return
119
- new CoinV4({
106
+ new ContentCoin({
120
107
  protocolRewardRecipient_: getZoraRecipient(),
121
108
  protocolRewards_: PROTOCOL_REWARDS,
122
109
  poolManager_: IPoolManager(getUniswapV4PoolManager()),
@@ -135,7 +122,6 @@ contract CoinsDeployerBase is ProxyDeployerScript {
135
122
  }
136
123
 
137
124
  function deployZoraFactoryImpl(
138
- address _coinV3Impl,
139
125
  address _coinV4Impl,
140
126
  address _creatorCoinImpl,
141
127
  address _contentCoinHook,
@@ -143,7 +129,6 @@ contract CoinsDeployerBase is ProxyDeployerScript {
143
129
  ) internal returns (ZoraFactoryImpl) {
144
130
  return
145
131
  new ZoraFactoryImpl({
146
- _coinImpl: _coinV3Impl,
147
132
  _coinV4Impl: _coinV4Impl,
148
133
  _creatorCoinImpl: _creatorCoinImpl,
149
134
  _contentCoinHook: _contentCoinHook,
@@ -151,14 +136,14 @@ contract CoinsDeployerBase is ProxyDeployerScript {
151
136
  });
152
137
  }
153
138
 
154
- function deployBuySupplyWithSwapRouterHook(CoinsDeployment memory deployment) internal returns (BuySupplyWithSwapRouterHook) {
155
- return
156
- new BuySupplyWithSwapRouterHook({
157
- _factory: IZoraFactory(deployment.zoraFactory),
158
- _swapRouter: getUniswapSwapRouter(),
159
- _poolManager: getUniswapV4PoolManager()
160
- });
161
- }
139
+ // function deployBuySupplyWithSwapRouterHook(CoinsDeployment memory deployment) internal returns (BuySupplyWithSwapRouterHook) {
140
+ // return
141
+ // new BuySupplyWithSwapRouterHook({
142
+ // _factory: IZoraFactory(deployment.zoraFactory),
143
+ // _swapRouter: getUniswapSwapRouter(),
144
+ // _poolManager: getUniswapV4PoolManager()
145
+ // });
146
+ // }
162
147
 
163
148
  function deployUpgradeGate(CoinsDeployment memory deployment) internal returns (CoinsDeployment memory) {
164
149
  deployment.hookUpgradeGate = address(new HookUpgradeGate(getProxyAdmin()));
@@ -205,7 +190,6 @@ contract CoinsDeployerBase is ProxyDeployerScript {
205
190
  return
206
191
  address(
207
192
  deployZoraFactoryImpl({
208
- _coinV3Impl: deployment.coinV3Impl,
209
193
  _coinV4Impl: deployment.coinV4Impl,
210
194
  _creatorCoinImpl: deployment.creatorCoinImpl,
211
195
  _contentCoinHook: deployment.zoraV4CoinHook,
@@ -216,7 +200,6 @@ contract CoinsDeployerBase is ProxyDeployerScript {
216
200
 
217
201
  function deployImpls(CoinsDeployment memory deployment) internal returns (CoinsDeployment memory) {
218
202
  // Deploy implementation contracts
219
- deployment.coinV3Impl = address(deployCoinV3Impl());
220
203
 
221
204
  // Deploy hook first, then use its address for coin v4 impl
222
205
  console.log("deploying content coin hook");
@@ -233,7 +216,7 @@ contract CoinsDeployerBase is ProxyDeployerScript {
233
216
  deployment.creatorCoinImpl = address(deployCreatorCoinImpl(deployment.creatorCoinHook));
234
217
  deployment.zoraFactoryImpl = deployFactoryImpl(deployment);
235
218
  deployment.coinVersion = IVersionedContract(deployment.coinV4Impl).contractVersion();
236
- deployment.buySupplyWithSwapRouterHook = address(deployBuySupplyWithSwapRouterHook(deployment));
219
+ // deployment.buySupplyWithSwapRouterHook = address(deployBuySupplyWithSwapRouterHook(deployment));
237
220
 
238
221
  return deployment;
239
222
  }
@@ -16,11 +16,11 @@ import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
16
16
  import {SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
17
17
  import {IZoraV4CoinHook} from "../interfaces/IZoraV4CoinHook.sol";
18
18
  import {IMsgSender} from "../interfaces/IMsgSender.sol";
19
- import {IHasSwapPath} from "../interfaces/ICoinV4.sol";
19
+ import {IHasSwapPath} from "../interfaces/ICoin.sol";
20
20
  import {LpPosition} from "../types/LpPosition.sol";
21
21
  import {V4Liquidity} from "../libs/V4Liquidity.sol";
22
22
  import {CoinRewardsV4} from "../libs/CoinRewardsV4.sol";
23
- import {ICoinV4} from "../interfaces/ICoinV4.sol";
23
+ import {ICoin} from "../interfaces/ICoin.sol";
24
24
  import {IDeployedCoinVersionLookup} from "../interfaces/IDeployedCoinVersionLookup.sol";
25
25
  import {CoinCommon} from "../libs/CoinCommon.sol";
26
26
  import {CoinDopplerMultiCurve} from "../libs/CoinDopplerMultiCurve.sol";
@@ -119,7 +119,7 @@ abstract contract BaseZoraV4CoinHook is BaseHook, ContractVersionBase, IZoraV4Co
119
119
  }
120
120
 
121
121
  /// @inheritdoc IZoraV4CoinHook
122
- function getPoolCoinByHash(bytes23 poolKeyHash) external view returns (IZoraV4CoinHook.PoolCoin memory) {
122
+ function getPoolCoinByHash(bytes32 poolKeyHash) external view returns (IZoraV4CoinHook.PoolCoin memory) {
123
123
  return poolCoins[poolKeyHash];
124
124
  }
125
125
 
@@ -140,7 +140,7 @@ abstract contract BaseZoraV4CoinHook is BaseHook, ContractVersionBase, IZoraV4Co
140
140
  /// @param coin The coin address.
141
141
  /// @param key The pool key for the coin.
142
142
  /// @return positions The contract-created liquidity positions the positions for the coin's pool.
143
- function _generatePositions(ICoinV4 coin, PoolKey memory key) internal view returns (LpPosition[] memory positions) {
143
+ function _generatePositions(ICoin coin, PoolKey memory key) internal view returns (LpPosition[] memory positions) {
144
144
  bool isCoinToken0 = Currency.unwrap(key.currency0) == address(coin);
145
145
 
146
146
  positions = CoinDopplerMultiCurve.calculatePositions(isCoinToken0, coin.getPoolConfiguration(), totalSupplyForPositions);
@@ -163,7 +163,7 @@ abstract contract BaseZoraV4CoinHook is BaseHook, ContractVersionBase, IZoraV4Co
163
163
  revert NotACoin(coin);
164
164
  }
165
165
 
166
- LpPosition[] memory positions = _generatePositions(ICoinV4(coin), key);
166
+ LpPosition[] memory positions = _generatePositions(ICoin(coin), key);
167
167
 
168
168
  _initializeForPositions(key, coin, positions);
169
169
 
@@ -312,7 +312,7 @@ abstract contract BaseZoraV4CoinHook is BaseHook, ContractVersionBase, IZoraV4Co
312
312
  payoutSwapPath
313
313
  );
314
314
 
315
- _distributeMarketRewards(payoutCurrency, payoutAmount, ICoinV4(coin), CoinRewardsV4.getTradeReferral(hookData));
315
+ _distributeMarketRewards(payoutCurrency, payoutAmount, ICoin(coin), CoinRewardsV4.getTradeReferral(hookData));
316
316
 
317
317
  {
318
318
  (address swapper, bool isTrustedSwapSenderAddress) = _getOriginalMsgSender(sender);
@@ -372,4 +372,6 @@ abstract contract BaseZoraV4CoinHook is BaseHook, ContractVersionBase, IZoraV4Co
372
372
 
373
373
  newPoolKey = V4Liquidity.lockAndMigrate(poolManager, poolKey, poolCoin.positions, poolCoin.coin, newHook, additionalData);
374
374
  }
375
+
376
+ receive() external payable onlyPoolManager {}
375
377
  }
@@ -12,9 +12,8 @@ import {ICoin} from "../../interfaces/ICoin.sol";
12
12
  import {IZoraFactory} from "../../interfaces/IZoraFactory.sol";
13
13
  import {ISwapRouter} from "../../interfaces/ISwapRouter.sol";
14
14
  import {IWETH} from "../../interfaces/IWETH.sol";
15
- import {Coin} from "../../Coin.sol";
16
15
  import {ICoinV3} from "../../interfaces/ICoinV3.sol";
17
- import {ICoinV4} from "../../interfaces/ICoinV4.sol";
16
+ import {ICoin} from "../../interfaces/ICoin.sol";
18
17
  import {CoinConfigurationVersions} from "../../libs/CoinConfigurationVersions.sol";
19
18
 
20
19
  /// @title BuySupplyWithSwapRouter
@@ -84,7 +83,7 @@ contract BuySupplyWithSwapRouterHook is BaseCoinDeployHook {
84
83
  IERC20(coin.currency()).approve(address(coin), amountCurrency);
85
84
 
86
85
  if (CoinConfigurationVersions.isV4(factory.getVersionForDeployedCoin(address(coin)))) {
87
- coinsPurchased = _executeV4Buy(buyRecipient, ICoinV4(payable(address(coin))), amountCurrency);
86
+ coinsPurchased = _executeV4Buy(buyRecipient, ICoin(payable(address(coin))), amountCurrency);
88
87
  } else {
89
88
  coinsPurchased = _executeV3Buy(buyRecipient, ICoinV3(payable(address(coin))), amountCurrency);
90
89
  }
@@ -101,7 +100,7 @@ contract BuySupplyWithSwapRouterHook is BaseCoinDeployHook {
101
100
  (, coinsPurchased) = ICoinV3(payable(address(coin))).buy(buyRecipient, amountCurrency, 0, 0, address(0));
102
101
  }
103
102
 
104
- function _executeV4Buy(address buyRecipient, ICoinV4 coin, uint256 amountCurrency) internal returns (uint256 coinsPurchased) {
103
+ function _executeV4Buy(address buyRecipient, ICoin coin, uint256 amountCurrency) internal returns (uint256 coinsPurchased) {
105
104
  bytes memory data = abi.encode(buyRecipient, coin, amountCurrency);
106
105
 
107
106
  bytes memory result = poolManager.unlock(data);
@@ -115,7 +114,7 @@ contract BuySupplyWithSwapRouterHook is BaseCoinDeployHook {
115
114
  function unlockCallback(bytes calldata data) external returns (bytes memory) {
116
115
  require(msg.sender == address(poolManager), OnlyPoolManager());
117
116
 
118
- (address buyRecipient, ICoinV4 coin, uint256 amountCurrency) = abi.decode(data, (address, ICoinV4, uint256));
117
+ (address buyRecipient, ICoin coin, uint256 amountCurrency) = abi.decode(data, (address, ICoin, uint256));
119
118
 
120
119
  bool zeroForOne = coin.currency() == Currency.unwrap(coin.getPoolKey().currency0);
121
120
 
@@ -7,6 +7,10 @@ import {IDopplerErrors} from "./IDopplerErrors.sol";
7
7
  import {PoolKey} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
8
8
  import {PoolConfiguration} from "../types/PoolConfiguration.sol";
9
9
  import {IHasRewardsRecipients} from "./IHasRewardsRecipients.sol";
10
+ import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
11
+ import {PathKey} from "@uniswap/v4-periphery/src/libraries/PathKey.sol";
12
+ import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
13
+ import {IDeployedCoinVersionLookup} from "./IDeployedCoinVersionLookup.sol";
10
14
 
11
15
  struct PoolConfigurationV4 {
12
16
  uint8 version;
@@ -22,7 +26,31 @@ struct PoolKeyStruct {
22
26
  address hooks;
23
27
  }
24
28
 
25
- interface ICoin is IERC165, IERC7572, IDopplerErrors, IHasRewardsRecipients {
29
+ /// @notice Returns the pool key for the coin
30
+ interface IHasPoolKey {
31
+ /// @notice Returns the Uniswap V4 pool key associated with this coin
32
+ /// @return The PoolKey struct containing pool identification parameters
33
+ function getPoolKey() external view returns (PoolKey memory);
34
+ }
35
+
36
+ /// @notice Returns the pool configuration for the coin
37
+ interface IHasSwapPath {
38
+ /// @notice Struct containing the swap path configuration for converting fees to payout currency
39
+ /// @param path Array of PathKey structs defining the multi-hop swap route
40
+ /// @param currencyIn The input currency to start the swap path from
41
+ struct PayoutSwapPath {
42
+ PathKey[] path;
43
+ Currency currencyIn;
44
+ }
45
+
46
+ /// @notice Returns the swap path configuration for converting this coin to its final payout currency
47
+ /// @dev This enables multi-hop swaps through intermediate currencies to reach the target payout token
48
+ /// @param coinVersionLookup Contract for looking up deployed coin versions to build recursive paths
49
+ /// @return PayoutSwapPath struct containing the complete swap route configuration
50
+ function getPayoutSwapPath(IDeployedCoinVersionLookup coinVersionLookup) external view returns (PayoutSwapPath memory);
51
+ }
52
+
53
+ interface ICoin is IERC165, IERC7572, IDopplerErrors, IHasRewardsRecipients, IHasPoolKey, IHasSwapPath {
26
54
  /// @notice Thrown when the name is required for the coin
27
55
  error NameIsRequired();
28
56
 
@@ -216,4 +244,42 @@ interface ICoin is IERC165, IERC7572, IDopplerErrors, IHasRewardsRecipients {
216
244
  /// @param newName The new coin name
217
245
  /// @param newSymbol The new coin symbol
218
246
  function setNameAndSymbol(string memory newName, string memory newSymbol) external;
247
+
248
+ /// @notice Returns the pool configuration settings for this coin's Uniswap V4 pool
249
+ /// @return PoolConfiguration struct containing pool-specific settings and parameters
250
+ function getPoolConfiguration() external view returns (PoolConfiguration memory);
251
+
252
+ /// @notice Emitted when a hook is upgraded
253
+ /// @param fromPoolKey The pool key being upgraded
254
+ /// @param toPoolKey The new pool key returned from the destination hook
255
+ event LiquidityMigrated(PoolKey fromPoolKey, bytes32 fromPoolKeyHash, PoolKey toPoolKey, bytes32 toPoolKeyHash);
256
+
257
+ /// @notice Returns the hooks contract used by this coin's Uniswap V4 pool
258
+ /// @return The IHooks contract interface that handles pool lifecycle events
259
+ function hooks() external view returns (IHooks);
260
+
261
+ /// @notice Initializes the coin
262
+ /// @dev Called by the factory contract when the contract is deployed.
263
+ /// @param payoutRecipient_ The address of the payout recipient. Can be updated by the owner. Cannot be 0 address.
264
+ /// @param owners_ The addresses of the owners. All owners have the same full admin access. Cannot be 0 address.
265
+ /// @param tokenURI_ The URI of the token. Can be updated by the owner.
266
+ /// @param name_ The name of the token. Cannot be updated.
267
+ /// @param symbol_ The symbol of the token. Cannot be updated.
268
+ /// @param platformReferrer_ The address of the platform referrer. Cannot be updated.
269
+ /// @param currency_ The currency of the coin. Cannot be updated. Can be the zero address for ETH.
270
+ /// @param poolKey_ The pool key for the coin. Derived in the factory.
271
+ /// @param sqrtPriceX96 The initial sqrt price for the pool
272
+ /// @param poolConfiguration_ The configuration for the pool
273
+ function initialize(
274
+ address payoutRecipient_,
275
+ address[] memory owners_,
276
+ string memory tokenURI_,
277
+ string memory name_,
278
+ string memory symbol_,
279
+ address platformReferrer_,
280
+ address currency_,
281
+ PoolKey memory poolKey_,
282
+ uint160 sqrtPriceX96,
283
+ PoolConfiguration memory poolConfiguration_
284
+ ) external;
219
285
  }
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.23;
3
3
 
4
- import {ICoinV4} from "./ICoinV4.sol";
4
+ import {ICoin} from "./ICoin.sol";
5
5
 
6
- interface ICreatorCoin is ICoinV4 {
6
+ interface ICreatorCoin is ICoin {
7
7
  /// @notice Emitted when creator vesting tokens are claimed
8
8
  /// @param recipient The address that received the vested tokens
9
9
  /// @param claimAmount The amount of tokens claimed in this transaction
@@ -80,9 +80,6 @@ interface IZoraFactory is IDeployedCoinVersionLookup {
80
80
  string version
81
81
  );
82
82
 
83
- /// @notice Thrown when the amount of ERC20 tokens transferred does not match the expected amount
84
- error ERC20TransferAmountMismatch();
85
-
86
83
  /// @notice Thrown when ETH is sent with a transaction but the currency is not WETH
87
84
  error EthTransferInvalid();
88
85
 
@@ -166,8 +163,6 @@ interface IZoraFactory is IDeployedCoinVersionLookup {
166
163
  bytes calldata hookData
167
164
  ) external payable returns (address coin, bytes memory hookDataOut);
168
165
 
169
- function coinImpl() external view returns (address);
170
-
171
166
  function implementation() external view returns (address);
172
167
 
173
168
  /// @notice Thrown when the hook is invalid
@@ -117,7 +117,7 @@ interface IZoraV4CoinHook is IUpgradeableV4Hook {
117
117
  /// @notice Returns the pool coin for a given pool key hash.
118
118
  /// @param poolKeyHash The hash of the pool key for indexing.
119
119
  /// @return poolCoin The pool coin confirmation data.
120
- function getPoolCoinByHash(bytes23 poolKeyHash) external view returns (IZoraV4CoinHook.PoolCoin memory);
120
+ function getPoolCoinByHash(bytes32 poolKeyHash) external view returns (IZoraV4CoinHook.PoolCoin memory);
121
121
 
122
122
  /// @notice Returns the pool coin for a given pool key.
123
123
  /// @param key The pool key.
@@ -30,33 +30,6 @@ library CoinConfigurationVersions {
30
30
  (version, currency) = abi.decode(poolConfig, (uint8, address));
31
31
  }
32
32
 
33
- function decodeDopplerUniV3(
34
- bytes memory poolConfig
35
- )
36
- internal
37
- pure
38
- returns (uint8 version, address currency, int24 tickLower_, int24 tickUpper_, uint16 numDiscoveryPositions_, uint256 maxDiscoverySupplyShare_)
39
- {
40
- (version, currency, tickLower_, tickUpper_, numDiscoveryPositions_, maxDiscoverySupplyShare_) = abi.decode(
41
- poolConfig,
42
- (uint8, address, int24, int24, uint16, uint256)
43
- );
44
- }
45
-
46
- function encodeDopplerUniV3(
47
- address currency,
48
- int24 tickLower_,
49
- int24 tickUpper_,
50
- uint16 numDiscoveryPositions_,
51
- uint256 maxDiscoverySupplyShare_
52
- ) internal pure returns (bytes memory) {
53
- return abi.encode(DOPPLER_UNI_V3_POOL_VERSION, currency, tickLower_, tickUpper_, numDiscoveryPositions_, maxDiscoverySupplyShare_);
54
- }
55
-
56
- function decodeLegacy(bytes memory poolConfig) internal pure returns (uint8 version, address currency, int24 tickLower_) {
57
- (version, currency, tickLower_) = abi.decode(poolConfig, (uint8, address, int24));
58
- }
59
-
60
33
  function decodeVanillaUniV4(bytes memory poolConfig) internal pure returns (uint8 version, address currency, int24 tickLower_) {
61
34
  (version, currency, tickLower_) = abi.decode(poolConfig, (uint8, address, int24));
62
35
  }
@@ -91,17 +64,6 @@ library CoinConfigurationVersions {
91
64
  );
92
65
  }
93
66
 
94
- function defaultDopplerUniV3(address currency) internal pure returns (bytes memory) {
95
- return
96
- encodeDopplerUniV3(
97
- currency,
98
- CoinConstants.DEFAULT_DISCOVERY_TICK_LOWER,
99
- CoinConstants.DEFAULT_DISCOVERY_TICK_UPPER,
100
- CoinConstants.DEFAULT_NUM_DISCOVERY_POSITIONS,
101
- CoinConstants.DEFAULT_DISCOVERY_SUPPLY_SHARE
102
- );
103
- }
104
-
105
67
  function defaultDopplerMultiCurveUniV4(address currency) internal pure returns (bytes memory) {
106
68
  int24[] memory tickLower = new int24[](2);
107
69
  int24[] memory tickUpper = new int24[](2);
@@ -125,6 +87,6 @@ library CoinConfigurationVersions {
125
87
  }
126
88
 
127
89
  function defaultConfig(address currency) internal pure returns (bytes memory) {
128
- return defaultDopplerUniV3(currency);
90
+ return defaultDopplerMultiCurveUniV4(currency);
129
91
  }
130
92
  }
@@ -26,7 +26,7 @@ import {LiquidityAmounts} from "../utils/uniswap/LiquidityAmounts.sol";
26
26
  import {IHasRewardsRecipients} from "../interfaces/IHasRewardsRecipients.sol";
27
27
  import {ICoin} from "../interfaces/ICoin.sol";
28
28
  import {IZoraV4CoinHook} from "../interfaces/IZoraV4CoinHook.sol";
29
- import {IHasSwapPath} from "../interfaces/ICoinV4.sol";
29
+ import {IHasSwapPath} from "../interfaces/ICoin.sol";
30
30
  import {V4Liquidity} from "./V4Liquidity.sol";
31
31
  import {UniV4SwapToCurrency} from "./UniV4SwapToCurrency.sol";
32
32
 
@@ -53,7 +53,7 @@ library CoinRewardsV4 {
53
53
  uint256 public constant LP_REWARD_BPS = 3333;
54
54
 
55
55
  function getTradeReferral(bytes calldata hookData) internal pure returns (address) {
56
- return hookData.length > 0 ? abi.decode(hookData, (address)) : address(0);
56
+ return hookData.length >= 32 ? abi.decode(hookData, (address)) : address(0);
57
57
  }
58
58
 
59
59
  /// @dev Converts collected fees from LP positions into target payout currency, and transfers to hook contract, so
@@ -19,7 +19,6 @@ import {IPositionManager} from "@uniswap/v4-periphery/src/interfaces/IPositionMa
19
19
  import {MarketConstants} from "./MarketConstants.sol";
20
20
  import {LpPosition} from "../types/LpPosition.sol";
21
21
  import {CoinDopplerMultiCurve, PoolConfiguration} from "./CoinDopplerMultiCurve.sol";
22
- import {CoinDopplerUniV3} from "./CoinDopplerUniV3.sol";
23
22
 
24
23
  library CoinSetup {
25
24
  function generatePoolConfig(
@@ -52,9 +51,7 @@ library CoinSetup {
52
51
  bytes memory poolConfig_,
53
52
  bool isCoinToken0
54
53
  ) internal pure returns (uint160 sqrtPriceX96, PoolConfiguration memory poolConfiguration) {
55
- if (version == CoinConfigurationVersions.DOPPLER_UNI_V3_POOL_VERSION) {
56
- (sqrtPriceX96, poolConfiguration) = CoinDopplerUniV3.setupPool(isCoinToken0, poolConfig_);
57
- } else if (version == CoinConfigurationVersions.DOPPLER_MULTICURVE_UNI_V4_POOL_VERSION) {
54
+ if (version == CoinConfigurationVersions.DOPPLER_MULTICURVE_UNI_V4_POOL_VERSION) {
58
55
  (sqrtPriceX96, poolConfiguration) = CoinDopplerMultiCurve.setupPool(isCoinToken0, poolConfig_);
59
56
  } else {
60
57
  revert ICoin.InvalidPoolVersion();
@@ -16,7 +16,7 @@ import {IPermit2} from "permit2/src/interfaces/IPermit2.sol";
16
16
  import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
17
17
  import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
18
18
  import {ISwapPathRouter} from "../interfaces/ISwapPathRouter.sol";
19
- import {IHasPoolKey} from "../interfaces/ICoinV4.sol";
19
+ import {IHasPoolKey} from "../interfaces/ICoin.sol";
20
20
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
21
21
  import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
22
22
  import {PathKey} from "@uniswap/v4-periphery/src/libraries/PathKey.sol";
@@ -9,12 +9,12 @@ pragma solidity ^0.8.23;
9
9
 
10
10
  import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
11
11
  import {ISwapPathRouter} from "../interfaces/ISwapPathRouter.sol";
12
- import {IHasPoolKey} from "../interfaces/ICoinV4.sol";
12
+ import {IHasPoolKey} from "../interfaces/ICoin.sol";
13
13
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
14
14
  import {IPoolManager, PoolKey} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
15
15
  import {SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
16
16
  import {BalanceDelta, BalanceDeltaLibrary} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
17
- import {IHasSwapPath} from "../interfaces/ICoinV4.sol";
17
+ import {IHasSwapPath} from "../interfaces/ICoin.sol";
18
18
  import {TickMath} from "@uniswap/v4-core/src/libraries/TickMath.sol";
19
19
  import {PathKey} from "@uniswap/v4-periphery/src/libraries/PathKey.sol";
20
20
  import {IDeployedCoinVersionLookup} from "../interfaces/IDeployedCoinVersionLookup.sol";
@@ -22,7 +22,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
22
22
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
23
23
  import {SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
24
24
  import {IHasRewardsRecipients} from "../interfaces/ICoin.sol";
25
- import {IHasSwapPath} from "../interfaces/ICoinV4.sol";
25
+ import {IHasSwapPath} from "../interfaces/ICoin.sol";
26
26
  import {UniV4SwapToCurrency} from "./UniV4SwapToCurrency.sol";
27
27
  import {PathKey} from "@uniswap/v4-periphery/src/libraries/PathKey.sol";
28
28
  import {Position} from "@uniswap/v4-core/src/libraries/Position.sol";
@@ -9,6 +9,6 @@ import {IVersionedContract} from "@zoralabs/shared-contracts/interfaces/IVersion
9
9
  contract ContractVersionBase is IVersionedContract {
10
10
  /// @notice The version of the contract
11
11
  function contractVersion() external pure override returns (string memory) {
12
- return "1.1.2";
12
+ return "2.1.0";
13
13
  }
14
14
  }