@zoralabs/coins 2.0.0 → 2.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.
- package/.turbo/turbo-build.log +107 -114
- package/CHANGELOG.md +34 -0
- package/README.md +30 -109
- package/abis/BaseCoin.json +442 -0
- package/abis/CoinTest.json +3 -246
- package/abis/FactoryTest.json +5 -137
- package/abis/HooksTest.json +0 -26
- package/abis/ICoin.json +378 -0
- package/abis/ICoinV3.json +378 -0
- package/abis/IZoraFactory.json +0 -18
- package/abis/LiquidityMigrationTest.json +101 -0
- package/abis/MockBadFactory.json +15 -0
- package/abis/ZoraFactoryImpl.json +1 -67
- package/dist/index.cjs +236 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +235 -264
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +389 -493
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/foundry.toml +1 -3
- package/package/wagmiGenerated.ts +240 -269
- package/package.json +3 -3
- package/script/DeployPostDeploymentHooks.s.sol +2 -2
- package/script/TestBackingCoinSwap.s.sol +8 -8
- package/script/TestV4Swap.s.sol +8 -8
- package/script/UpgradeFactoryImpl.s.sol +0 -1
- package/src/BaseCoin.sol +111 -7
- package/src/ContentCoin.sol +4 -4
- package/src/CreatorCoin.sol +5 -5
- package/src/ZoraFactoryImpl.sol +10 -93
- package/src/deployment/CoinsDeployerBase.sol +10 -27
- package/src/hooks/BaseZoraV4CoinHook.sol +5 -5
- package/src/hooks/ContentCoinHook.sol +2 -2
- package/src/hooks/deployment/BuySupplyWithSwapRouterHook.sol +4 -5
- package/src/interfaces/ICoin.sol +67 -1
- package/src/interfaces/ICreatorCoin.sol +2 -2
- package/src/interfaces/IZoraFactory.sol +0 -5
- package/src/libs/CoinConfigurationVersions.sol +1 -39
- package/src/libs/CoinRewardsV4.sol +2 -2
- package/src/libs/CoinSetup.sol +1 -4
- package/src/libs/MarketConstants.sol +0 -4
- package/src/libs/UniV4SwapHelper.sol +1 -1
- package/src/libs/UniV4SwapToCurrency.sol +2 -2
- package/src/libs/V4Liquidity.sol +1 -1
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/Coin.t.sol +112 -535
- package/test/CoinUniV4.t.sol +7 -7
- package/test/DeploymentHooks.t.sol +5 -102
- package/test/Factory.t.sol +23 -306
- package/test/LiquidityMigration.t.sol +160 -2
- package/test/MultiOwnable.t.sol +36 -36
- package/test/Upgrades.t.sol +16 -35
- package/test/utils/BaseTest.sol +16 -69
- package/test/utils/FeeEstimatorHook.sol +3 -3
- package/wagmi.config.ts +1 -1
- package/abis/BaseCoinV4.json +0 -1840
- package/abis/Coin.json +0 -1912
- package/abis/DopplerUniswapV3Test.json +0 -800
- package/abis/ICoinV4.json +0 -1048
- package/abis/Simulate.json +0 -29
- package/abis/UniV3BuySell.json +0 -12
- package/abis/UniV3Errors.json +0 -32
- package/script/Simulate.s.sol +0 -59
- package/src/BaseCoinV4.sol +0 -143
- package/src/Coin.sol +0 -236
- package/src/interfaces/ICoinV4.sol +0 -74
- package/src/libs/CoinDopplerUniV3.sol +0 -50
- package/src/libs/CoinRewards.sol +0 -201
- package/src/libs/CoinSetupV3.sol +0 -50
- package/src/libs/UniV3BuySell.sol +0 -231
- package/src/libs/UniV3Errors.sol +0 -11
- package/test/CoinDopplerUniV3.t.sol +0 -310
|
@@ -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/
|
|
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 {
|
|
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";
|
|
@@ -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(
|
|
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(
|
|
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,
|
|
315
|
+
_distributeMarketRewards(payoutCurrency, payoutAmount, ICoin(coin), CoinRewardsV4.getTradeReferral(hookData));
|
|
316
316
|
|
|
317
317
|
{
|
|
318
318
|
(address swapper, bool isTrustedSwapSenderAddress) = _getOriginalMsgSender(sender);
|
|
@@ -9,7 +9,7 @@ pragma solidity ^0.8.28;
|
|
|
9
9
|
|
|
10
10
|
import {IPoolManager, IDeployedCoinVersionLookup, IHasRewardsRecipients, Currency, BaseZoraV4CoinHook} from "./BaseZoraV4CoinHook.sol";
|
|
11
11
|
import {CoinRewardsV4} from "../libs/CoinRewardsV4.sol";
|
|
12
|
-
import {
|
|
12
|
+
import {CoinConstants} from "../libs/CoinConstants.sol";
|
|
13
13
|
import {IHooksUpgradeGate} from "../interfaces/IHooksUpgradeGate.sol";
|
|
14
14
|
|
|
15
15
|
contract ContentCoinHook is BaseZoraV4CoinHook {
|
|
@@ -18,7 +18,7 @@ contract ContentCoinHook is BaseZoraV4CoinHook {
|
|
|
18
18
|
IDeployedCoinVersionLookup coinVersionLookup_,
|
|
19
19
|
address[] memory trustedMessageSenders_,
|
|
20
20
|
IHooksUpgradeGate upgradeGate
|
|
21
|
-
) BaseZoraV4CoinHook(poolManager_, coinVersionLookup_, trustedMessageSenders_, upgradeGate,
|
|
21
|
+
) BaseZoraV4CoinHook(poolManager_, coinVersionLookup_, trustedMessageSenders_, upgradeGate, CoinConstants.POOL_LAUNCH_SUPPLY) {}
|
|
22
22
|
|
|
23
23
|
/// @dev Override for market reward distribution
|
|
24
24
|
function _distributeMarketRewards(Currency currency, uint128 fees, IHasRewardsRecipients coin, address tradeReferrer) internal override {
|
|
@@ -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 {
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
package/src/interfaces/ICoin.sol
CHANGED
|
@@ -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
|
-
|
|
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 {
|
|
4
|
+
import {ICoin} from "./ICoin.sol";
|
|
5
5
|
|
|
6
|
-
interface ICreatorCoin is
|
|
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
|
|
@@ -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
|
|
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/
|
|
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
|
|
56
|
+
return hookData.length >= 20 ? 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
|
package/src/libs/CoinSetup.sol
CHANGED
|
@@ -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.
|
|
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();
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
library MarketConstants {
|
|
5
|
-
/// @notice The number of coins allocated to the liquidity pool
|
|
6
|
-
/// @dev 990 million coins
|
|
7
|
-
uint256 internal constant POOL_LAUNCH_SUPPLY = 990_000_000e18;
|
|
8
|
-
|
|
9
5
|
/// @dev Constant used to increase precision during calculations
|
|
10
6
|
uint256 constant WAD = 1e18;
|
|
11
7
|
|
|
@@ -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/
|
|
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/
|
|
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/
|
|
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";
|
package/src/libs/V4Liquidity.sol
CHANGED
|
@@ -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/
|
|
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 "2.
|
|
12
|
+
return "2.1.1";
|
|
13
13
|
}
|
|
14
14
|
}
|