@zoralabs/coins 2.4.0 → 2.4.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$colon$js.log +116 -124
- package/CHANGELOG.md +6 -0
- package/abis/Address.json +0 -16
- package/abis/BuySupplyWithSwapRouterHook.json +0 -27
- package/abis/BuySupplyWithV4SwapHook.json +0 -32
- package/abis/Clones.json +1 -1
- package/abis/CoinDopplerMultiCurve.json +109 -0
- package/abis/Create2.json +0 -21
- package/abis/ERC1967Proxy.json +1 -1
- package/abis/ERC1967Utils.json +0 -45
- package/abis/{UpgradeCoinImpl.json → Errors.json} +14 -10
- package/abis/{MockERC20.json → IERC1363.json} +134 -104
- package/abis/IERC1967.json +47 -0
- package/abis/IERC20.json +0 -36
- package/abis/IProtocolRewards.json +0 -258
- package/abis/{Script.json → ISupportsLimitOrderFill.json} +2 -2
- package/abis/IZoraLimitOrderBookCoinsInterface.json +67 -0
- package/abis/IZoraV4CoinHook.json +10 -0
- package/abis/ProxyShim.json +15 -16
- package/abis/SafeCast.json +51 -0
- package/abis/{AddressConstants.json → SafeCast160.json} +1 -1
- package/abis/Strings.json +10 -0
- package/abis/UUPSUpgradeable.json +1 -1
- package/abis/V3ToV4SwapLib.json +28 -0
- package/abis/ZoraFactory.json +1 -1
- package/abis/ZoraFactoryImpl.json +22 -6
- package/abis/ZoraV4CoinHook.json +20 -48
- package/dist/index.cjs +950 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +948 -41
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +1459 -76
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/wagmiGenerated.ts +951 -44
- package/package.json +9 -9
- package/remappings.txt +2 -1
- package/src/ZoraFactoryImpl.sol +8 -0
- package/src/deployment/ForkedCoinsAddresses.sol +54 -0
- package/src/hooks/ZoraV4CoinHook.sol +74 -20
- package/src/hooks/deployment/BuySupplyWithV4SwapHook.sol +20 -142
- package/src/interfaces/ISupportsLimitOrderFill.sol +11 -0
- package/src/interfaces/IZoraLimitOrderBookCoinsInterface.sol +21 -0
- package/src/interfaces/IZoraV4CoinHook.sol +6 -0
- package/src/libs/CoinConstants.sol +6 -0
- package/src/libs/CoinDopplerMultiCurve.sol +1 -1
- package/src/libs/CoinRewardsV4.sol +0 -1
- package/src/libs/HooksDeployment.sol +20 -8
- package/src/libs/UniV4SwapHelper.sol +35 -0
- package/src/libs/V3ToV4SwapLib.sol +261 -0
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/BuySupplyWithV4SwapHook.t.sol +4 -3
- package/test/Coin.t.sol +7 -1
- package/test/CoinUniV4.t.sol +2 -1
- package/test/ContentCoinRewards.t.sol +5 -1
- package/test/CreatorCoin.t.sol +3 -1
- package/test/CreatorCoinRewards.t.sol +3 -1
- package/test/Factory.t.sol +20 -7
- package/test/HooksDeployment.t.sol +16 -3
- package/test/LiquidityMigration.t.sol +52 -44
- package/test/MultiOwnable.t.sol +2 -1
- package/test/Upgrades.t.sol +110 -81
- package/test/V4Liquidity.t.sol +1 -1
- package/test/mocks/MockSwapRouter.sol +33 -0
- package/test/mocks/MockZoraLimitOrderBook.sol +14 -0
- package/test/utils/BaseTest.sol +14 -448
- package/test/utils/FeeEstimatorHook.sol +6 -2
- package/test/utils/V4TestSetup.sol +595 -0
- package/wagmi.config.ts +1 -1
- package/abis/BaseTest.json +0 -718
- package/abis/DeterministicDeployerAndCaller.json +0 -315
- package/abis/DeterministicUUPSProxyDeployer.json +0 -167
- package/abis/EIP712.json +0 -67
- package/abis/ERC20.json +0 -310
- package/abis/FeeEstimatorHook.json +0 -1938
- package/abis/IERC721.json +0 -287
- package/abis/IERC721Enumerable.json +0 -343
- package/abis/IERC721Metadata.json +0 -332
- package/abis/IERC721TokenReceiver.json +0 -36
- package/abis/IImmutableCreate2Factory.json +0 -93
- package/abis/IMulticall3.json +0 -440
- package/abis/ISafe.json +0 -15
- package/abis/ISymbol.json +0 -15
- package/abis/IUniswapV4Router04.json +0 -484
- package/abis/IUniversalRouter.json +0 -61
- package/abis/IV4Quoter.json +0 -310
- package/abis/ImmutableCreate2FactoryUtils.json +0 -15
- package/abis/LibString.json +0 -7
- package/abis/Math.json +0 -7
- package/abis/MockAirlock.json +0 -39
- package/abis/MockERC721.json +0 -350
- package/abis/ProtocolRewards.json +0 -494
- package/abis/ShortStrings.json +0 -18
- package/abis/SimpleERC20.json +0 -326
- package/abis/StdAssertions.json +0 -379
- package/abis/StdInvariant.json +0 -180
- package/abis/Test.json +0 -570
- package/abis/VmContractHelper235.json +0 -233
- package/abis/VmContractHelper242.json +0 -233
- package/abis/stdError.json +0 -119
- package/abis/stdStorageSafe.json +0 -52
- package/addresses/8453.json +0 -13
- package/addresses/84532.json +0 -10
- package/deterministicConfig/deployerAndCaller.json +0 -5
- package/deterministicConfig/zoraFactory.json +0 -8
- package/script/Deploy.s.sol +0 -23
- package/script/DeployAutoSwapper.s.sol +0 -30
- package/script/DeployDevFactory.s.sol +0 -21
- package/script/DeployPostDeploymentHooks.s.sol +0 -20
- package/script/DeployTrustedMsgSenderLookup.s.sol +0 -20
- package/script/DeployUpgradeGate.s.sol +0 -21
- package/script/GenerateDeterministicParams.s.sol +0 -43
- package/script/PrintRegisterUpgradePath.s.sol +0 -28
- package/script/PrintUpgradeCommand.s.sol +0 -13
- package/script/TestBackingCoinSwap.s.sol +0 -144
- package/script/TestV4Swap.s.sol +0 -133
- package/script/UpgradeCoinImpl.sol +0 -23
- package/script/UpgradeFactoryImpl.s.sol +0 -28
- package/script/UpgradeHooks.s.sol +0 -23
- package/src/deployment/CoinsDeployerBase.sol +0 -297
- /package/{test → src}/utils/ProxyShim.sol +0 -0
package/test/utils/BaseTest.sol
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.13;
|
|
3
3
|
|
|
4
|
+
import {V4TestSetup} from "./V4TestSetup.sol";
|
|
4
5
|
import "forge-std/Test.sol";
|
|
5
6
|
|
|
6
7
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
@@ -29,7 +30,7 @@ import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
|
|
|
29
30
|
import {ZoraV4CoinHook} from "../../src/hooks/ZoraV4CoinHook.sol";
|
|
30
31
|
import {HooksDeployment} from "../../src/libs/HooksDeployment.sol";
|
|
31
32
|
import {CoinConstants} from "../../src/libs/CoinConstants.sol";
|
|
32
|
-
import {ProxyShim} from "
|
|
33
|
+
import {ProxyShim} from "../../src/utils/ProxyShim.sol";
|
|
33
34
|
import {ICoin} from "../../src/interfaces/ICoin.sol";
|
|
34
35
|
import {UniV4SwapHelper} from "../../src/libs/UniV4SwapHelper.sol";
|
|
35
36
|
import {IPermit2} from "permit2/src/interfaces/IPermit2.sol";
|
|
@@ -59,426 +60,26 @@ import {MockERC20} from "../mocks/MockERC20.sol";
|
|
|
59
60
|
import {MockAirlock} from "../mocks/MockAirlock.sol";
|
|
60
61
|
import {SimpleERC20} from "../mocks/SimpleERC20.sol";
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
uint16 internal constant DEFAULT_NUM_DISCOVERY_POSITIONS = CoinConstants.DEFAULT_NUM_DISCOVERY_POSITIONS;
|
|
69
|
-
uint256 internal constant DEFAULT_DISCOVERY_SUPPLY_SHARE = CoinConstants.DEFAULT_DISCOVERY_SUPPLY_SHARE;
|
|
70
|
-
|
|
71
|
-
struct Users {
|
|
72
|
-
address factoryOwner;
|
|
73
|
-
address feeRecipient;
|
|
74
|
-
address creator;
|
|
75
|
-
address platformReferrer;
|
|
76
|
-
address buyer;
|
|
77
|
-
address seller;
|
|
78
|
-
address coinRecipient;
|
|
79
|
-
address tradeReferrer;
|
|
80
|
-
address dopplerRecipient;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
uint256 internal forkId;
|
|
84
|
-
IERC20Metadata internal zoraToken;
|
|
85
|
-
IERC20Metadata internal usdc;
|
|
86
|
-
IWETH internal weth;
|
|
87
|
-
|
|
88
|
-
ProtocolRewards internal protocolRewards;
|
|
89
|
-
IUniswapV3Factory internal v3Factory;
|
|
90
|
-
INonfungiblePositionManager internal nonfungiblePositionManager;
|
|
91
|
-
IPermit2 internal permit2;
|
|
92
|
-
IUniversalRouter internal router;
|
|
93
|
-
IPoolManager internal poolManager;
|
|
94
|
-
IV4Quoter internal quoter;
|
|
95
|
-
ContentCoin internal coinV4;
|
|
96
|
-
|
|
97
|
-
ISwapRouter internal swapRouter;
|
|
98
|
-
IAirlock internal airlock;
|
|
99
|
-
Users internal users;
|
|
100
|
-
|
|
101
|
-
// Coin internal coinV3Impl;
|
|
102
|
-
ContentCoin internal coinV4Impl;
|
|
103
|
-
CreatorCoin internal creatorCoinImpl;
|
|
104
|
-
ZoraFactoryImpl internal factoryImpl;
|
|
105
|
-
IZoraFactory internal factory;
|
|
106
|
-
ZoraV4CoinHook internal hook;
|
|
107
|
-
HookUpgradeGate internal hookUpgradeGate;
|
|
108
|
-
ZoraHookRegistry internal zoraHookRegistry;
|
|
109
|
-
|
|
110
|
-
function _defaultPoolConfig(address currency) internal pure returns (bytes memory) {
|
|
111
|
-
return CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(currency);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function _deployV4Coin(address currency) internal returns (ICoin) {
|
|
115
|
-
bytes32 salt = keccak256(abi.encode(bytes("randomSalt")));
|
|
116
|
-
return _deployV4Coin(currency, address(0), salt);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
string constant DEFAULT_NAME = "Testcoin";
|
|
120
|
-
string constant DEFAULT_SYMBOL = "TEST";
|
|
121
|
-
|
|
122
|
-
function _deployV4Coin(address currency, address createReferral, bytes32 salt) internal returns (ICoin) {
|
|
123
|
-
address[] memory owners = new address[](1);
|
|
124
|
-
owners[0] = users.creator;
|
|
125
|
-
|
|
126
|
-
bytes memory poolConfig = _defaultPoolConfig(currency);
|
|
127
|
-
|
|
128
|
-
vm.prank(users.creator);
|
|
129
|
-
(address coinAddress, ) = factory.deploy(
|
|
130
|
-
users.creator,
|
|
131
|
-
owners,
|
|
132
|
-
"https://test.com",
|
|
133
|
-
DEFAULT_NAME,
|
|
134
|
-
DEFAULT_SYMBOL,
|
|
135
|
-
poolConfig,
|
|
136
|
-
createReferral,
|
|
137
|
-
address(0),
|
|
138
|
-
bytes(""),
|
|
139
|
-
salt
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
coinV4 = ContentCoin(payable(coinAddress));
|
|
143
|
-
return coinV4;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function _deployV4Coin() internal returns (ICoin) {
|
|
147
|
-
// deploy with eth and no referral
|
|
148
|
-
return _deployV4Coin(address(0), address(0), bytes32(0));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function _deployCoinUSDCPair() internal {
|
|
152
|
-
bytes memory poolConfig_ = _defaultPoolConfig(USDC_ADDRESS);
|
|
153
|
-
vm.prank(users.creator);
|
|
154
|
-
(address coinAddress, ) = factory.deploy(
|
|
155
|
-
users.creator,
|
|
156
|
-
_getDefaultOwners(),
|
|
157
|
-
"https://test.com",
|
|
158
|
-
"Testcoin",
|
|
159
|
-
"TEST",
|
|
160
|
-
poolConfig_,
|
|
161
|
-
users.platformReferrer,
|
|
162
|
-
0
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
vm.label(coinAddress, "COIN");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function _swapSomeCurrencyForCoin(ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
169
|
-
_swapSomeCurrencyForCoin(_coin.getPoolKey(), _coin, currency, amountIn, trader);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function _swapSomeCurrencyForCoin(PoolKey memory poolKey, ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
173
|
-
uint128 minAmountOut = uint128(0);
|
|
174
|
-
|
|
175
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
176
|
-
currency,
|
|
177
|
-
amountIn,
|
|
178
|
-
address(_coin),
|
|
179
|
-
minAmountOut,
|
|
180
|
-
poolKey,
|
|
181
|
-
bytes("")
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
vm.startPrank(trader);
|
|
185
|
-
if (currency != address(0)) {
|
|
186
|
-
UniV4SwapHelper.approveTokenWithPermit2(permit2, address(router), currency, amountIn, uint48(block.timestamp + 1 days));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
uint256 value = currency == address(0) ? amountIn : 0;
|
|
190
|
-
|
|
191
|
-
// Execute the swap
|
|
192
|
-
uint256 deadline = block.timestamp + 20;
|
|
193
|
-
router.execute{value: value}(commands, inputs, deadline);
|
|
194
|
-
|
|
195
|
-
vm.stopPrank();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function _swapSomeCoinForCurrency(ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
199
|
-
uint128 minAmountOut = uint128(0);
|
|
200
|
-
|
|
201
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
202
|
-
address(_coin),
|
|
203
|
-
amountIn,
|
|
204
|
-
currency,
|
|
205
|
-
minAmountOut,
|
|
206
|
-
_coin.getPoolKey(),
|
|
207
|
-
bytes("")
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
vm.startPrank(trader);
|
|
211
|
-
UniV4SwapHelper.approveTokenWithPermit2(permit2, address(router), address(_coin), amountIn, uint48(block.timestamp + 1 days));
|
|
212
|
-
|
|
213
|
-
// Execute the swap
|
|
214
|
-
uint256 deadline = block.timestamp + 20;
|
|
215
|
-
router.execute(commands, inputs, deadline);
|
|
216
|
-
|
|
217
|
-
vm.stopPrank();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function _deployFeeEstimatorHook(address hooks) internal {
|
|
221
|
-
// Deploy a new lookup with the same trusted senders
|
|
222
|
-
address[] memory trustedMessageSenders = new address[](2);
|
|
223
|
-
trustedMessageSenders[0] = UNIVERSAL_ROUTER;
|
|
224
|
-
trustedMessageSenders[1] = V4_POSITION_MANAGER;
|
|
225
|
-
ITrustedMsgSenderProviderLookup newLookup = TrustedSenderTestHelper.deployTrustedMessageSender(users.factoryOwner, trustedMessageSenders);
|
|
226
|
-
|
|
227
|
-
deployCodeTo(
|
|
228
|
-
"FeeEstimatorHook.sol",
|
|
229
|
-
HooksDeployment.hookConstructorArgs(address(poolManager), address(factory), newLookup, address(hookUpgradeGate)),
|
|
230
|
-
hooks
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function getSalt(ITrustedMsgSenderProviderLookup trustedMsgSenderLookup) public returns (bytes32 hookSalt) {
|
|
235
|
-
address deployer = address(this);
|
|
236
|
-
|
|
237
|
-
(, hookSalt) = HooksDeployment.mineForCoinSalt(deployer, V4_POOL_MANAGER, address(factory), trustedMsgSenderLookup, address(hookUpgradeGate));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function _deployHooks() internal {
|
|
241
|
-
address[] memory trustedMessageSenders = new address[](2);
|
|
242
|
-
trustedMessageSenders[0] = UNIVERSAL_ROUTER;
|
|
243
|
-
trustedMessageSenders[1] = V4_POSITION_MANAGER;
|
|
244
|
-
|
|
245
|
-
ITrustedMsgSenderProviderLookup trustedMsgSenderLookup = TrustedSenderTestHelper.deployTrustedMessageSender(users.factoryOwner, trustedMessageSenders);
|
|
246
|
-
|
|
247
|
-
bytes32 hookSalt = getSalt(trustedMsgSenderLookup);
|
|
248
|
-
|
|
249
|
-
hook = ZoraV4CoinHook(
|
|
250
|
-
payable(
|
|
251
|
-
address(
|
|
252
|
-
HooksDeployment.deployHookWithSalt(
|
|
253
|
-
HooksDeployment.makeHookCreationCode(
|
|
254
|
-
V4_POOL_MANAGER,
|
|
255
|
-
address(factory),
|
|
256
|
-
ITrustedMsgSenderProviderLookup(address(trustedMsgSenderLookup)),
|
|
257
|
-
address(hookUpgradeGate)
|
|
258
|
-
),
|
|
259
|
-
hookSalt
|
|
260
|
-
)
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @title BaseTest
|
|
65
|
+
* @notice Coins-specific test utilities extending V4TestSetup
|
|
66
|
+
* @dev This contract adds coins-specific reward calculations on top of shared V4 infrastructure
|
|
67
|
+
*/
|
|
68
|
+
contract BaseTest is V4TestSetup {
|
|
266
69
|
function setUp() public virtual {
|
|
267
70
|
setUpWithBlockNumber(28415528);
|
|
268
71
|
}
|
|
269
72
|
|
|
270
|
-
function setUpWithBlockNumber(uint256 forkBlockNumber) public {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
weth = IWETH(WETH_ADDRESS);
|
|
274
|
-
usdc = IERC20Metadata(USDC_ADDRESS);
|
|
275
|
-
zoraToken = IERC20Metadata(ZORA_TOKEN_ADDRESS);
|
|
276
|
-
v3Factory = IUniswapV3Factory(V3_FACTORY);
|
|
277
|
-
nonfungiblePositionManager = INonfungiblePositionManager(NONFUNGIBLE_POSITION_MANAGER);
|
|
278
|
-
swapRouter = ISwapRouter(SWAP_ROUTER);
|
|
279
|
-
airlock = IAirlock(DOPPLER_AIRLOCK);
|
|
280
|
-
protocolRewards = new ProtocolRewards();
|
|
281
|
-
permit2 = IPermit2(V4_PERMIT2);
|
|
282
|
-
router = IUniversalRouter(UNIVERSAL_ROUTER);
|
|
283
|
-
poolManager = IPoolManager(V4_POOL_MANAGER);
|
|
284
|
-
quoter = IV4Quoter(V4_QUOTER);
|
|
285
|
-
users = Users({
|
|
286
|
-
factoryOwner: makeAddr("factoryOwner"),
|
|
287
|
-
feeRecipient: makeAddr("feeRecipient"),
|
|
288
|
-
creator: makeAddr("creator"),
|
|
289
|
-
platformReferrer: makeAddr("platformReferrer"),
|
|
290
|
-
buyer: makeAddr("buyer"),
|
|
291
|
-
seller: makeAddr("seller"),
|
|
292
|
-
coinRecipient: makeAddr("coinRecipient"),
|
|
293
|
-
tradeReferrer: makeAddr("tradeReferrer"),
|
|
294
|
-
dopplerRecipient: makeAddr("dopplerRecipient")
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
ProxyShim mockUpgradeableImpl = new ProxyShim();
|
|
298
|
-
factory = IZoraFactory(address(new ZoraFactory(address(mockUpgradeableImpl))));
|
|
299
|
-
|
|
300
|
-
hookUpgradeGate = new HookUpgradeGate(users.factoryOwner);
|
|
301
|
-
|
|
302
|
-
zoraHookRegistry = new ZoraHookRegistry();
|
|
303
|
-
|
|
304
|
-
address[] memory initialOwners = new address[](2);
|
|
305
|
-
initialOwners[0] = users.factoryOwner;
|
|
306
|
-
initialOwners[1] = address(factory);
|
|
307
|
-
zoraHookRegistry.initialize(initialOwners);
|
|
308
|
-
|
|
309
|
-
_deployHooks();
|
|
310
|
-
|
|
311
|
-
coinV4Impl = new ContentCoin(users.feeRecipient, address(protocolRewards), IPoolManager(V4_POOL_MANAGER), DOPPLER_AIRLOCK);
|
|
312
|
-
|
|
313
|
-
creatorCoinImpl = new CreatorCoin(users.feeRecipient, address(protocolRewards), IPoolManager(V4_POOL_MANAGER), DOPPLER_AIRLOCK);
|
|
314
|
-
|
|
315
|
-
factoryImpl = new ZoraFactoryImpl(address(coinV4Impl), address(creatorCoinImpl), address(hook), address(zoraHookRegistry));
|
|
316
|
-
UUPSUpgradeable(address(factory)).upgradeToAndCall(address(factoryImpl), "");
|
|
317
|
-
factory = IZoraFactory(address(factory));
|
|
318
|
-
|
|
319
|
-
ZoraFactoryImpl(address(factory)).initialize(users.factoryOwner);
|
|
320
|
-
|
|
321
|
-
vm.label(address(factory), "ZORA_FACTORY");
|
|
322
|
-
vm.label(address(protocolRewards), "PROTOCOL_REWARDS");
|
|
323
|
-
vm.label(address(nonfungiblePositionManager), "NONFUNGIBLE_POSITION_MANAGER");
|
|
324
|
-
vm.label(address(v3Factory), "V3_FACTORY");
|
|
325
|
-
vm.label(address(swapRouter), "SWAP_ROUTER");
|
|
326
|
-
vm.label(address(weth), "WETH");
|
|
327
|
-
vm.label(address(usdc), "USDC");
|
|
328
|
-
vm.label(address(airlock), "AIRLOCK");
|
|
329
|
-
vm.label(address(zoraToken), "$ZORA");
|
|
330
|
-
vm.label(address(V4_POOL_MANAGER), "V4_POOL_MANAGER");
|
|
331
|
-
vm.label(address(V4_POSITION_MANAGER), "V4_POSITION_MANAGER");
|
|
332
|
-
vm.label(address(V4_QUOTER), "V4_QUOTER");
|
|
333
|
-
vm.label(address(V4_PERMIT2), "V4_PERMIT2");
|
|
334
|
-
vm.label(address(UNIVERSAL_ROUTER), "UNIVERSAL_ROUTER");
|
|
335
|
-
vm.label(address(hook), "HOOK");
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function setUpNonForked() public {
|
|
339
|
-
// Initialize users first
|
|
340
|
-
users = Users({
|
|
341
|
-
factoryOwner: makeAddr("factoryOwner"),
|
|
342
|
-
feeRecipient: makeAddr("feeRecipient"),
|
|
343
|
-
creator: makeAddr("creator"),
|
|
344
|
-
platformReferrer: makeAddr("platformReferrer"),
|
|
345
|
-
buyer: makeAddr("buyer"),
|
|
346
|
-
seller: makeAddr("seller"),
|
|
347
|
-
coinRecipient: makeAddr("coinRecipient"),
|
|
348
|
-
tradeReferrer: makeAddr("tradeReferrer"),
|
|
349
|
-
dopplerRecipient: makeAddr("dopplerRecipient")
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Deploy mock airlock with the dopplerRecipient as owner (for doppler rewards)
|
|
353
|
-
MockAirlock mockAirlock = new MockAirlock(users.dopplerRecipient);
|
|
354
|
-
|
|
355
|
-
// Deploy V4 infrastructure using hookmate
|
|
356
|
-
_deployV4InfrastructureNonForked();
|
|
357
|
-
|
|
358
|
-
// Deploy mock ZORA token at the correct address
|
|
359
|
-
deployCodeTo("SimpleERC20.sol:SimpleERC20", abi.encode("ZORA", "$ZORA"), ZORA_TOKEN_ADDRESS);
|
|
360
|
-
zoraToken = IERC20Metadata(ZORA_TOKEN_ADDRESS);
|
|
361
|
-
|
|
362
|
-
// Fund the pool manager with ZORA tokens
|
|
363
|
-
deal(address(zoraToken), address(poolManager), 1_000_000_000e18);
|
|
364
|
-
|
|
365
|
-
// Deploy protocol rewards
|
|
366
|
-
protocolRewards = new ProtocolRewards();
|
|
367
|
-
|
|
368
|
-
// Deploy factory proxy
|
|
369
|
-
ProxyShim mockUpgradeableImpl = new ProxyShim();
|
|
370
|
-
factory = IZoraFactory(address(new ZoraFactory(address(mockUpgradeableImpl))));
|
|
371
|
-
|
|
372
|
-
// Deploy hook upgrade gate
|
|
373
|
-
hookUpgradeGate = new HookUpgradeGate(users.factoryOwner);
|
|
374
|
-
|
|
375
|
-
// Deploy zora hook registry
|
|
376
|
-
zoraHookRegistry = new ZoraHookRegistry();
|
|
377
|
-
address[] memory initialOwners = new address[](2);
|
|
378
|
-
initialOwners[0] = users.factoryOwner;
|
|
379
|
-
initialOwners[1] = address(factory);
|
|
380
|
-
zoraHookRegistry.initialize(initialOwners);
|
|
381
|
-
|
|
382
|
-
// Deploy hooks for non-forked environment
|
|
383
|
-
_deployHooksNonForked();
|
|
384
|
-
|
|
385
|
-
// Deploy coin implementations
|
|
386
|
-
coinV4Impl = new ContentCoin(users.feeRecipient, address(protocolRewards), poolManager, address(mockAirlock));
|
|
387
|
-
creatorCoinImpl = new CreatorCoin(users.feeRecipient, address(protocolRewards), poolManager, address(mockAirlock));
|
|
388
|
-
|
|
389
|
-
// Deploy and initialize factory implementation
|
|
390
|
-
factoryImpl = new ZoraFactoryImpl(address(coinV4Impl), address(creatorCoinImpl), address(hook), address(zoraHookRegistry));
|
|
391
|
-
UUPSUpgradeable(address(factory)).upgradeToAndCall(address(factoryImpl), "");
|
|
392
|
-
ZoraFactoryImpl(address(factory)).initialize(users.factoryOwner);
|
|
393
|
-
|
|
394
|
-
// Labels for easier debugging
|
|
395
|
-
vm.label(address(factory), "ZORA_FACTORY");
|
|
396
|
-
vm.label(address(protocolRewards), "PROTOCOL_REWARDS");
|
|
397
|
-
vm.label(address(poolManager), "V4_POOL_MANAGER");
|
|
398
|
-
vm.label(address(permit2), "V4_PERMIT2");
|
|
399
|
-
vm.label(address(router), "UNIVERSAL_ROUTER");
|
|
400
|
-
vm.label(address(hook), "HOOK");
|
|
401
|
-
vm.label(address(mockAirlock), "MOCK_AIRLOCK");
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function _deployV4InfrastructureNonForked() internal {
|
|
405
|
-
// Deploy Permit2 to canonical address
|
|
406
|
-
_deployPermit2NonForked();
|
|
407
|
-
|
|
408
|
-
// Deploy PoolManager
|
|
409
|
-
_deployPoolManagerNonForked();
|
|
410
|
-
|
|
411
|
-
// Deploy Quoter
|
|
412
|
-
_deployQuoterNonForked();
|
|
413
|
-
|
|
414
|
-
// Deploy Universal Router
|
|
415
|
-
_deployUniversalRouterNonForked();
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function _deployPermit2NonForked() internal {
|
|
419
|
-
address permit2Address = AddressConstants.getPermit2Address();
|
|
420
|
-
|
|
421
|
-
if (permit2Address.code.length > 0) {
|
|
422
|
-
// Permit2 is already deployed
|
|
423
|
-
} else {
|
|
424
|
-
address tempDeployAddress = address(Permit2Deployer.deploy());
|
|
425
|
-
vm.etch(permit2Address, tempDeployAddress.code);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
permit2 = IPermit2(permit2Address);
|
|
429
|
-
vm.label(address(permit2), "V4_PERMIT2");
|
|
73
|
+
function setUpWithBlockNumber(uint256 forkBlockNumber) public virtual {
|
|
74
|
+
_setUpWithBlockNumber(forkBlockNumber);
|
|
430
75
|
}
|
|
431
76
|
|
|
432
|
-
function
|
|
433
|
-
|
|
434
|
-
poolManager = IPoolManager(address(V4PoolManagerDeployer.deploy(address(0x4444))));
|
|
435
|
-
} else {
|
|
436
|
-
poolManager = IPoolManager(AddressConstants.getPoolManagerAddress(block.chainid));
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
deal(address(poolManager), 10000 ether);
|
|
440
|
-
vm.label(address(poolManager), "V4_POOL_MANAGER");
|
|
77
|
+
function setUpNonForked() public virtual {
|
|
78
|
+
_setUpNonForked();
|
|
441
79
|
}
|
|
442
80
|
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
vm.label(address(quoter), "V4_QUOTER");
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
function _deployUniversalRouterNonForked() internal {
|
|
449
|
-
RouterParameters memory params = RouterParameters({
|
|
450
|
-
permit2: address(permit2),
|
|
451
|
-
weth9: address(0),
|
|
452
|
-
v2Factory: address(0),
|
|
453
|
-
v3Factory: address(0),
|
|
454
|
-
pairInitCodeHash: bytes32(0),
|
|
455
|
-
poolInitCodeHash: bytes32(0),
|
|
456
|
-
v4PoolManager: address(poolManager),
|
|
457
|
-
v3NFTPositionManager: address(0),
|
|
458
|
-
v4PositionManager: address(0)
|
|
459
|
-
});
|
|
460
|
-
router = IUniversalRouter(UniversalRouterDeployer.deploy(params));
|
|
461
|
-
vm.label(address(router), "UNIVERSAL_ROUTER");
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
function _deployHooksNonForked() internal {
|
|
465
|
-
address[] memory trustedMessageSenders = new address[](1);
|
|
466
|
-
trustedMessageSenders[0] = address(router);
|
|
467
|
-
|
|
468
|
-
ITrustedMsgSenderProviderLookup trustedMsgSenderLookup = TrustedSenderTestHelper.deployTrustedMessageSender(users.factoryOwner, trustedMessageSenders);
|
|
469
|
-
|
|
470
|
-
// Use proper salt mining for hook deployment
|
|
471
|
-
address deployer = address(this);
|
|
472
|
-
(, bytes32 salt) = HooksDeployment.mineForCoinSalt(deployer, address(poolManager), address(factory), trustedMsgSenderLookup, address(hookUpgradeGate));
|
|
473
|
-
|
|
474
|
-
bytes memory hookCreationCode = HooksDeployment.makeHookCreationCode(
|
|
475
|
-
address(poolManager),
|
|
476
|
-
address(factory),
|
|
477
|
-
trustedMsgSenderLookup,
|
|
478
|
-
address(hookUpgradeGate)
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
hook = ZoraV4CoinHook(payable(DeployHelper.deploy(hookCreationCode, salt)));
|
|
81
|
+
function setUpNonForked(address limitOrderBook) public virtual {
|
|
82
|
+
_setUpNonForked(limitOrderBook);
|
|
482
83
|
}
|
|
483
84
|
|
|
484
85
|
struct TradeRewards {
|
|
@@ -505,11 +106,6 @@ contract BaseTest is Test, ContractAddresses {
|
|
|
505
106
|
});
|
|
506
107
|
}
|
|
507
108
|
|
|
508
|
-
function _calculateExpectedFee(uint256 ethAmount) internal pure returns (uint256) {
|
|
509
|
-
uint256 feeBps = 100; // 1%
|
|
510
|
-
return (ethAmount * feeBps) / 10_000;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
109
|
function _calculateMarketRewards(uint256 ethAmount) internal pure returns (MarketRewards memory) {
|
|
514
110
|
uint256 creator = (ethAmount * 5000) / 10_000;
|
|
515
111
|
uint256 platformReferrer = (ethAmount * 2500) / 10_000;
|
|
@@ -518,34 +114,4 @@ contract BaseTest is Test, ContractAddresses {
|
|
|
518
114
|
|
|
519
115
|
return MarketRewards({creator: creator, platformReferrer: platformReferrer, doppler: doppler, protocol: protocol});
|
|
520
116
|
}
|
|
521
|
-
|
|
522
|
-
function dealUSDC(address to, uint256 numUSDC) internal returns (uint256) {
|
|
523
|
-
uint256 amount = numUSDC * 1e6;
|
|
524
|
-
deal(address(usdc), to, amount);
|
|
525
|
-
return amount;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function _getDefaultOwners() internal view returns (address[] memory owners) {
|
|
529
|
-
owners = new address[](1);
|
|
530
|
-
owners[0] = users.creator;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function dopplerFeeRecipient() internal view returns (address) {
|
|
534
|
-
return airlock.owner();
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function _generatePoolConfig(address currency_) internal pure returns (bytes memory) {
|
|
538
|
-
return CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(currency_);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
function _generatePoolConfig(
|
|
542
|
-
uint8 version_,
|
|
543
|
-
address currency_,
|
|
544
|
-
int24 tickLower_,
|
|
545
|
-
int24 tickUpper_,
|
|
546
|
-
uint16 numDiscoveryPositions_,
|
|
547
|
-
uint256 maxDiscoverySupplyShare_
|
|
548
|
-
) internal pure returns (bytes memory) {
|
|
549
|
-
return abi.encode(version_, currency_, tickLower_, tickUpper_, numDiscoveryPositions_, maxDiscoverySupplyShare_);
|
|
550
|
-
}
|
|
551
117
|
}
|
|
@@ -4,6 +4,8 @@ pragma solidity ^0.8.13;
|
|
|
4
4
|
import {ZoraV4CoinHook} from "../../src/hooks/ZoraV4CoinHook.sol";
|
|
5
5
|
import {IPoolManager, PoolKey} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
|
|
6
6
|
import {IDeployedCoinVersionLookup} from "../../src/interfaces/IDeployedCoinVersionLookup.sol";
|
|
7
|
+
import {IZoraLimitOrderBookCoinsInterface} from "../../src/interfaces/IZoraLimitOrderBookCoinsInterface.sol";
|
|
8
|
+
import {IZoraHookRegistry} from "../../src/interfaces/IZoraHookRegistry.sol";
|
|
7
9
|
import {IHasRewardsRecipients} from "../../src/interfaces/IHasRewardsRecipients.sol";
|
|
8
10
|
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
|
|
9
11
|
import {SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
|
|
@@ -35,8 +37,10 @@ contract FeeEstimatorHook is ZoraV4CoinHook {
|
|
|
35
37
|
IPoolManager _poolManager,
|
|
36
38
|
IDeployedCoinVersionLookup _coinVersionLookup,
|
|
37
39
|
ITrustedMsgSenderProviderLookup trustedMsgSenderLookup,
|
|
38
|
-
IHooksUpgradeGate upgradeGate
|
|
39
|
-
|
|
40
|
+
IHooksUpgradeGate upgradeGate,
|
|
41
|
+
IZoraLimitOrderBookCoinsInterface zoraLimitOrderBook,
|
|
42
|
+
IZoraHookRegistry zoraHookRegistry
|
|
43
|
+
) ZoraV4CoinHook(_poolManager, _coinVersionLookup, trustedMsgSenderLookup, upgradeGate, zoraLimitOrderBook, zoraHookRegistry) {}
|
|
40
44
|
|
|
41
45
|
FeeEstimatorState public feeState;
|
|
42
46
|
|