@zoralabs/coins 2.3.1 → 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 +119 -128
- package/CHANGELOG.md +30 -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/ITrustedMsgSenderProviderLookup.json +21 -0
- package/abis/IZoraLimitOrderBookCoinsInterface.json +67 -0
- package/abis/IZoraV4CoinHook.json +15 -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/TrustedMsgSenderProviderLookup.json +215 -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 +41 -51
- 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/foundry.toml +5 -1
- package/package/wagmiGenerated.ts +951 -44
- package/package.json +7 -7
- package/remappings.txt +2 -1
- package/src/ZoraFactoryImpl.sol +8 -0
- package/src/deployment/ForkedCoinsAddresses.sol +54 -0
- package/src/hooks/ZoraV4CoinHook.sol +92 -74
- package/src/hooks/deployment/BuySupplyWithV4SwapHook.sol +20 -142
- package/src/interfaces/ISupportsLimitOrderFill.sol +11 -0
- package/src/interfaces/ITrustedMsgSenderProviderLookup.sol +18 -0
- package/src/interfaces/IZoraLimitOrderBookCoinsInterface.sol +21 -0
- package/src/interfaces/IZoraV4CoinHook.sol +9 -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 +25 -12
- package/src/libs/UniV4SwapHelper.sol +35 -0
- package/src/libs/V3ToV4SwapLib.sol +261 -0
- package/src/libs/V4Liquidity.sol +50 -6
- package/src/utils/TrustedMsgSenderProviderLookup.sol +73 -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 +7 -1
- package/test/Factory.t.sol +20 -7
- package/test/HooksDeployment.t.sol +73 -8
- package/test/LiquidityMigration.t.sol +55 -43
- package/test/MultiOwnable.t.sol +2 -1
- package/test/TrustedMsgSenderProviderLookup.t.sol +112 -0
- package/test/Upgrades.t.sol +112 -78
- 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 +17 -425
- package/test/utils/FeeEstimatorHook.sol +8 -2
- package/test/utils/TrustedSenderTestHelper.sol +18 -0
- 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 -1915
- 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/VmContractHelper239.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/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 -276
- /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";
|
|
@@ -44,6 +45,9 @@ import {ContractAddresses} from "./ContractAddresses.sol";
|
|
|
44
45
|
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
|
|
45
46
|
import {HookUpgradeGate} from "../../src/hooks/HookUpgradeGate.sol";
|
|
46
47
|
import {ZoraHookRegistry} from "../../src/hook-registry/ZoraHookRegistry.sol";
|
|
48
|
+
import {TrustedMsgSenderProviderLookup} from "../../src/utils/TrustedMsgSenderProviderLookup.sol";
|
|
49
|
+
import {ITrustedMsgSenderProviderLookup} from "../../src/interfaces/ITrustedMsgSenderProviderLookup.sol";
|
|
50
|
+
import {TrustedSenderTestHelper} from "./TrustedSenderTestHelper.sol";
|
|
47
51
|
|
|
48
52
|
// Hookmate imports for non-forked testing
|
|
49
53
|
import {V4PoolManagerDeployer} from "./hookmate/artifacts/V4PoolManager.sol";
|
|
@@ -56,403 +60,26 @@ import {MockERC20} from "../mocks/MockERC20.sol";
|
|
|
56
60
|
import {MockAirlock} from "../mocks/MockAirlock.sol";
|
|
57
61
|
import {SimpleERC20} from "../mocks/SimpleERC20.sol";
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
uint16 internal constant DEFAULT_NUM_DISCOVERY_POSITIONS = CoinConstants.DEFAULT_NUM_DISCOVERY_POSITIONS;
|
|
66
|
-
uint256 internal constant DEFAULT_DISCOVERY_SUPPLY_SHARE = CoinConstants.DEFAULT_DISCOVERY_SUPPLY_SHARE;
|
|
67
|
-
|
|
68
|
-
struct Users {
|
|
69
|
-
address factoryOwner;
|
|
70
|
-
address feeRecipient;
|
|
71
|
-
address creator;
|
|
72
|
-
address platformReferrer;
|
|
73
|
-
address buyer;
|
|
74
|
-
address seller;
|
|
75
|
-
address coinRecipient;
|
|
76
|
-
address tradeReferrer;
|
|
77
|
-
address dopplerRecipient;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
uint256 internal forkId;
|
|
81
|
-
IERC20Metadata internal zoraToken;
|
|
82
|
-
IERC20Metadata internal usdc;
|
|
83
|
-
IWETH internal weth;
|
|
84
|
-
|
|
85
|
-
ProtocolRewards internal protocolRewards;
|
|
86
|
-
IUniswapV3Factory internal v3Factory;
|
|
87
|
-
INonfungiblePositionManager internal nonfungiblePositionManager;
|
|
88
|
-
IPermit2 internal permit2;
|
|
89
|
-
IUniversalRouter internal router;
|
|
90
|
-
IPoolManager internal poolManager;
|
|
91
|
-
IV4Quoter internal quoter;
|
|
92
|
-
ContentCoin internal coinV4;
|
|
93
|
-
|
|
94
|
-
ISwapRouter internal swapRouter;
|
|
95
|
-
IAirlock internal airlock;
|
|
96
|
-
Users internal users;
|
|
97
|
-
|
|
98
|
-
// Coin internal coinV3Impl;
|
|
99
|
-
ContentCoin internal coinV4Impl;
|
|
100
|
-
CreatorCoin internal creatorCoinImpl;
|
|
101
|
-
ZoraFactoryImpl internal factoryImpl;
|
|
102
|
-
IZoraFactory internal factory;
|
|
103
|
-
ZoraV4CoinHook internal hook;
|
|
104
|
-
HookUpgradeGate internal hookUpgradeGate;
|
|
105
|
-
ZoraHookRegistry internal zoraHookRegistry;
|
|
106
|
-
|
|
107
|
-
function _defaultPoolConfig(address currency) internal pure returns (bytes memory) {
|
|
108
|
-
return CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(currency);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _deployV4Coin(address currency) internal returns (ICoin) {
|
|
112
|
-
bytes32 salt = keccak256(abi.encode(bytes("randomSalt")));
|
|
113
|
-
return _deployV4Coin(currency, address(0), salt);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
string constant DEFAULT_NAME = "Testcoin";
|
|
117
|
-
string constant DEFAULT_SYMBOL = "TEST";
|
|
118
|
-
|
|
119
|
-
function _deployV4Coin(address currency, address createReferral, bytes32 salt) internal returns (ICoin) {
|
|
120
|
-
address[] memory owners = new address[](1);
|
|
121
|
-
owners[0] = users.creator;
|
|
122
|
-
|
|
123
|
-
bytes memory poolConfig = _defaultPoolConfig(currency);
|
|
124
|
-
|
|
125
|
-
vm.prank(users.creator);
|
|
126
|
-
(address coinAddress, ) = factory.deploy(
|
|
127
|
-
users.creator,
|
|
128
|
-
owners,
|
|
129
|
-
"https://test.com",
|
|
130
|
-
DEFAULT_NAME,
|
|
131
|
-
DEFAULT_SYMBOL,
|
|
132
|
-
poolConfig,
|
|
133
|
-
createReferral,
|
|
134
|
-
address(0),
|
|
135
|
-
bytes(""),
|
|
136
|
-
salt
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
coinV4 = ContentCoin(payable(coinAddress));
|
|
140
|
-
return coinV4;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function _deployV4Coin() internal returns (ICoin) {
|
|
144
|
-
// deploy with eth and no referral
|
|
145
|
-
return _deployV4Coin(address(0), address(0), bytes32(0));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function _deployCoinUSDCPair() internal {
|
|
149
|
-
bytes memory poolConfig_ = _defaultPoolConfig(USDC_ADDRESS);
|
|
150
|
-
vm.prank(users.creator);
|
|
151
|
-
(address coinAddress, ) = factory.deploy(
|
|
152
|
-
users.creator,
|
|
153
|
-
_getDefaultOwners(),
|
|
154
|
-
"https://test.com",
|
|
155
|
-
"Testcoin",
|
|
156
|
-
"TEST",
|
|
157
|
-
poolConfig_,
|
|
158
|
-
users.platformReferrer,
|
|
159
|
-
0
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
vm.label(coinAddress, "COIN");
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function _swapSomeCurrencyForCoin(ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
166
|
-
_swapSomeCurrencyForCoin(_coin.getPoolKey(), _coin, currency, amountIn, trader);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function _swapSomeCurrencyForCoin(PoolKey memory poolKey, ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
170
|
-
uint128 minAmountOut = uint128(0);
|
|
171
|
-
|
|
172
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
173
|
-
currency,
|
|
174
|
-
amountIn,
|
|
175
|
-
address(_coin),
|
|
176
|
-
minAmountOut,
|
|
177
|
-
poolKey,
|
|
178
|
-
bytes("")
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
vm.startPrank(trader);
|
|
182
|
-
if (currency != address(0)) {
|
|
183
|
-
UniV4SwapHelper.approveTokenWithPermit2(permit2, address(router), currency, amountIn, uint48(block.timestamp + 1 days));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
uint256 value = currency == address(0) ? amountIn : 0;
|
|
187
|
-
|
|
188
|
-
// Execute the swap
|
|
189
|
-
uint256 deadline = block.timestamp + 20;
|
|
190
|
-
router.execute{value: value}(commands, inputs, deadline);
|
|
191
|
-
|
|
192
|
-
vm.stopPrank();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function _swapSomeCoinForCurrency(ICoin _coin, address currency, uint128 amountIn, address trader) internal {
|
|
196
|
-
uint128 minAmountOut = uint128(0);
|
|
197
|
-
|
|
198
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
199
|
-
address(_coin),
|
|
200
|
-
amountIn,
|
|
201
|
-
currency,
|
|
202
|
-
minAmountOut,
|
|
203
|
-
_coin.getPoolKey(),
|
|
204
|
-
bytes("")
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
vm.startPrank(trader);
|
|
208
|
-
UniV4SwapHelper.approveTokenWithPermit2(permit2, address(router), address(_coin), amountIn, uint48(block.timestamp + 1 days));
|
|
209
|
-
|
|
210
|
-
// Execute the swap
|
|
211
|
-
uint256 deadline = block.timestamp + 20;
|
|
212
|
-
router.execute(commands, inputs, deadline);
|
|
213
|
-
|
|
214
|
-
vm.stopPrank();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function _deployFeeEstimatorHook(address hooks) internal {
|
|
218
|
-
deployCodeTo("FeeEstimatorHook.sol", abi.encode(address(poolManager), address(factory), hookUpgradeGate), hooks);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function getSalt(address[] memory trustedMessageSenders) public returns (bytes32 hookSalt) {
|
|
222
|
-
address deployer = address(this);
|
|
223
|
-
|
|
224
|
-
(, hookSalt) = HooksDeployment.mineForCoinSalt(deployer, V4_POOL_MANAGER, address(factory), trustedMessageSenders, address(hookUpgradeGate));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function _deployHooks() internal {
|
|
228
|
-
address[] memory trustedMessageSenders = new address[](2);
|
|
229
|
-
trustedMessageSenders[0] = UNIVERSAL_ROUTER;
|
|
230
|
-
trustedMessageSenders[1] = V4_POSITION_MANAGER;
|
|
231
|
-
|
|
232
|
-
bytes32 hookSalt = getSalt(trustedMessageSenders);
|
|
233
|
-
|
|
234
|
-
hook = ZoraV4CoinHook(
|
|
235
|
-
payable(
|
|
236
|
-
address(
|
|
237
|
-
HooksDeployment.deployHookWithSalt(
|
|
238
|
-
HooksDeployment.makeHookCreationCode(V4_POOL_MANAGER, address(factory), trustedMessageSenders, address(hookUpgradeGate)),
|
|
239
|
-
hookSalt
|
|
240
|
-
)
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
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 {
|
|
246
69
|
function setUp() public virtual {
|
|
247
70
|
setUpWithBlockNumber(28415528);
|
|
248
71
|
}
|
|
249
72
|
|
|
250
|
-
function setUpWithBlockNumber(uint256 forkBlockNumber) public {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
weth = IWETH(WETH_ADDRESS);
|
|
254
|
-
usdc = IERC20Metadata(USDC_ADDRESS);
|
|
255
|
-
zoraToken = IERC20Metadata(ZORA_TOKEN_ADDRESS);
|
|
256
|
-
v3Factory = IUniswapV3Factory(V3_FACTORY);
|
|
257
|
-
nonfungiblePositionManager = INonfungiblePositionManager(NONFUNGIBLE_POSITION_MANAGER);
|
|
258
|
-
swapRouter = ISwapRouter(SWAP_ROUTER);
|
|
259
|
-
airlock = IAirlock(DOPPLER_AIRLOCK);
|
|
260
|
-
protocolRewards = new ProtocolRewards();
|
|
261
|
-
permit2 = IPermit2(V4_PERMIT2);
|
|
262
|
-
router = IUniversalRouter(UNIVERSAL_ROUTER);
|
|
263
|
-
poolManager = IPoolManager(V4_POOL_MANAGER);
|
|
264
|
-
quoter = IV4Quoter(V4_QUOTER);
|
|
265
|
-
users = Users({
|
|
266
|
-
factoryOwner: makeAddr("factoryOwner"),
|
|
267
|
-
feeRecipient: makeAddr("feeRecipient"),
|
|
268
|
-
creator: makeAddr("creator"),
|
|
269
|
-
platformReferrer: makeAddr("platformReferrer"),
|
|
270
|
-
buyer: makeAddr("buyer"),
|
|
271
|
-
seller: makeAddr("seller"),
|
|
272
|
-
coinRecipient: makeAddr("coinRecipient"),
|
|
273
|
-
tradeReferrer: makeAddr("tradeReferrer"),
|
|
274
|
-
dopplerRecipient: makeAddr("dopplerRecipient")
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
ProxyShim mockUpgradeableImpl = new ProxyShim();
|
|
278
|
-
factory = IZoraFactory(address(new ZoraFactory(address(mockUpgradeableImpl))));
|
|
279
|
-
|
|
280
|
-
hookUpgradeGate = new HookUpgradeGate(users.factoryOwner);
|
|
281
|
-
|
|
282
|
-
zoraHookRegistry = new ZoraHookRegistry();
|
|
283
|
-
|
|
284
|
-
address[] memory initialOwners = new address[](2);
|
|
285
|
-
initialOwners[0] = users.factoryOwner;
|
|
286
|
-
initialOwners[1] = address(factory);
|
|
287
|
-
zoraHookRegistry.initialize(initialOwners);
|
|
288
|
-
|
|
289
|
-
_deployHooks();
|
|
290
|
-
|
|
291
|
-
coinV4Impl = new ContentCoin(users.feeRecipient, address(protocolRewards), IPoolManager(V4_POOL_MANAGER), DOPPLER_AIRLOCK);
|
|
292
|
-
|
|
293
|
-
creatorCoinImpl = new CreatorCoin(users.feeRecipient, address(protocolRewards), IPoolManager(V4_POOL_MANAGER), DOPPLER_AIRLOCK);
|
|
294
|
-
|
|
295
|
-
factoryImpl = new ZoraFactoryImpl(address(coinV4Impl), address(creatorCoinImpl), address(hook), address(zoraHookRegistry));
|
|
296
|
-
UUPSUpgradeable(address(factory)).upgradeToAndCall(address(factoryImpl), "");
|
|
297
|
-
factory = IZoraFactory(address(factory));
|
|
298
|
-
|
|
299
|
-
ZoraFactoryImpl(address(factory)).initialize(users.factoryOwner);
|
|
300
|
-
|
|
301
|
-
vm.label(address(factory), "ZORA_FACTORY");
|
|
302
|
-
vm.label(address(protocolRewards), "PROTOCOL_REWARDS");
|
|
303
|
-
vm.label(address(nonfungiblePositionManager), "NONFUNGIBLE_POSITION_MANAGER");
|
|
304
|
-
vm.label(address(v3Factory), "V3_FACTORY");
|
|
305
|
-
vm.label(address(swapRouter), "SWAP_ROUTER");
|
|
306
|
-
vm.label(address(weth), "WETH");
|
|
307
|
-
vm.label(address(usdc), "USDC");
|
|
308
|
-
vm.label(address(airlock), "AIRLOCK");
|
|
309
|
-
vm.label(address(zoraToken), "$ZORA");
|
|
310
|
-
vm.label(address(V4_POOL_MANAGER), "V4_POOL_MANAGER");
|
|
311
|
-
vm.label(address(V4_POSITION_MANAGER), "V4_POSITION_MANAGER");
|
|
312
|
-
vm.label(address(V4_QUOTER), "V4_QUOTER");
|
|
313
|
-
vm.label(address(V4_PERMIT2), "V4_PERMIT2");
|
|
314
|
-
vm.label(address(UNIVERSAL_ROUTER), "UNIVERSAL_ROUTER");
|
|
315
|
-
vm.label(address(hook), "HOOK");
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function setUpNonForked() public {
|
|
319
|
-
// Initialize users first
|
|
320
|
-
users = Users({
|
|
321
|
-
factoryOwner: makeAddr("factoryOwner"),
|
|
322
|
-
feeRecipient: makeAddr("feeRecipient"),
|
|
323
|
-
creator: makeAddr("creator"),
|
|
324
|
-
platformReferrer: makeAddr("platformReferrer"),
|
|
325
|
-
buyer: makeAddr("buyer"),
|
|
326
|
-
seller: makeAddr("seller"),
|
|
327
|
-
coinRecipient: makeAddr("coinRecipient"),
|
|
328
|
-
tradeReferrer: makeAddr("tradeReferrer"),
|
|
329
|
-
dopplerRecipient: makeAddr("dopplerRecipient")
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
// Deploy mock airlock with the dopplerRecipient as owner (for doppler rewards)
|
|
333
|
-
MockAirlock mockAirlock = new MockAirlock(users.dopplerRecipient);
|
|
334
|
-
|
|
335
|
-
// Deploy V4 infrastructure using hookmate
|
|
336
|
-
_deployV4InfrastructureNonForked();
|
|
337
|
-
|
|
338
|
-
// Deploy mock ZORA token at the correct address
|
|
339
|
-
deployCodeTo("SimpleERC20.sol:SimpleERC20", abi.encode("ZORA", "$ZORA"), ZORA_TOKEN_ADDRESS);
|
|
340
|
-
zoraToken = IERC20Metadata(ZORA_TOKEN_ADDRESS);
|
|
341
|
-
|
|
342
|
-
// Fund the pool manager with ZORA tokens
|
|
343
|
-
deal(address(zoraToken), address(poolManager), 1_000_000_000e18);
|
|
344
|
-
|
|
345
|
-
// Deploy protocol rewards
|
|
346
|
-
protocolRewards = new ProtocolRewards();
|
|
347
|
-
|
|
348
|
-
// Deploy factory proxy
|
|
349
|
-
ProxyShim mockUpgradeableImpl = new ProxyShim();
|
|
350
|
-
factory = IZoraFactory(address(new ZoraFactory(address(mockUpgradeableImpl))));
|
|
351
|
-
|
|
352
|
-
// Deploy hook upgrade gate
|
|
353
|
-
hookUpgradeGate = new HookUpgradeGate(users.factoryOwner);
|
|
354
|
-
|
|
355
|
-
// Deploy zora hook registry
|
|
356
|
-
zoraHookRegistry = new ZoraHookRegistry();
|
|
357
|
-
address[] memory initialOwners = new address[](2);
|
|
358
|
-
initialOwners[0] = users.factoryOwner;
|
|
359
|
-
initialOwners[1] = address(factory);
|
|
360
|
-
zoraHookRegistry.initialize(initialOwners);
|
|
361
|
-
|
|
362
|
-
// Deploy hooks for non-forked environment
|
|
363
|
-
_deployHooksNonForked(address(mockAirlock));
|
|
364
|
-
|
|
365
|
-
// Deploy coin implementations
|
|
366
|
-
coinV4Impl = new ContentCoin(users.feeRecipient, address(protocolRewards), poolManager, address(mockAirlock));
|
|
367
|
-
creatorCoinImpl = new CreatorCoin(users.feeRecipient, address(protocolRewards), poolManager, address(mockAirlock));
|
|
368
|
-
|
|
369
|
-
// Deploy and initialize factory implementation
|
|
370
|
-
factoryImpl = new ZoraFactoryImpl(address(coinV4Impl), address(creatorCoinImpl), address(hook), address(zoraHookRegistry));
|
|
371
|
-
UUPSUpgradeable(address(factory)).upgradeToAndCall(address(factoryImpl), "");
|
|
372
|
-
ZoraFactoryImpl(address(factory)).initialize(users.factoryOwner);
|
|
373
|
-
|
|
374
|
-
// Labels for easier debugging
|
|
375
|
-
vm.label(address(factory), "ZORA_FACTORY");
|
|
376
|
-
vm.label(address(protocolRewards), "PROTOCOL_REWARDS");
|
|
377
|
-
vm.label(address(poolManager), "V4_POOL_MANAGER");
|
|
378
|
-
vm.label(address(permit2), "V4_PERMIT2");
|
|
379
|
-
vm.label(address(router), "UNIVERSAL_ROUTER");
|
|
380
|
-
vm.label(address(hook), "HOOK");
|
|
381
|
-
vm.label(address(mockAirlock), "MOCK_AIRLOCK");
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function _deployV4InfrastructureNonForked() internal {
|
|
385
|
-
// Deploy Permit2 to canonical address
|
|
386
|
-
_deployPermit2NonForked();
|
|
387
|
-
|
|
388
|
-
// Deploy PoolManager
|
|
389
|
-
_deployPoolManagerNonForked();
|
|
390
|
-
|
|
391
|
-
// Deploy Quoter
|
|
392
|
-
_deployQuoterNonForked();
|
|
393
|
-
|
|
394
|
-
// Deploy Universal Router
|
|
395
|
-
_deployUniversalRouterNonForked();
|
|
73
|
+
function setUpWithBlockNumber(uint256 forkBlockNumber) public virtual {
|
|
74
|
+
_setUpWithBlockNumber(forkBlockNumber);
|
|
396
75
|
}
|
|
397
76
|
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (permit2Address.code.length > 0) {
|
|
402
|
-
// Permit2 is already deployed
|
|
403
|
-
} else {
|
|
404
|
-
address tempDeployAddress = address(Permit2Deployer.deploy());
|
|
405
|
-
vm.etch(permit2Address, tempDeployAddress.code);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
permit2 = IPermit2(permit2Address);
|
|
77
|
+
function setUpNonForked() public virtual {
|
|
78
|
+
_setUpNonForked();
|
|
409
79
|
}
|
|
410
80
|
|
|
411
|
-
function
|
|
412
|
-
|
|
413
|
-
poolManager = IPoolManager(address(V4PoolManagerDeployer.deploy(address(0x4444))));
|
|
414
|
-
} else {
|
|
415
|
-
poolManager = IPoolManager(AddressConstants.getPoolManagerAddress(block.chainid));
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
deal(address(poolManager), 10000 ether);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
function _deployQuoterNonForked() internal {
|
|
422
|
-
quoter = IV4Quoter(V4QuoterDeployer.deploy(address(poolManager)));
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function _deployUniversalRouterNonForked() internal {
|
|
426
|
-
RouterParameters memory params = RouterParameters({
|
|
427
|
-
permit2: address(permit2),
|
|
428
|
-
weth9: address(0),
|
|
429
|
-
v2Factory: address(0),
|
|
430
|
-
v3Factory: address(0),
|
|
431
|
-
pairInitCodeHash: bytes32(0),
|
|
432
|
-
poolInitCodeHash: bytes32(0),
|
|
433
|
-
v4PoolManager: address(poolManager),
|
|
434
|
-
v3NFTPositionManager: address(0),
|
|
435
|
-
v4PositionManager: address(0)
|
|
436
|
-
});
|
|
437
|
-
router = IUniversalRouter(UniversalRouterDeployer.deploy(params));
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function _deployHooksNonForked(address airlockAddress) internal {
|
|
441
|
-
address[] memory trustedMessageSenders = new address[](1);
|
|
442
|
-
trustedMessageSenders[0] = address(router);
|
|
443
|
-
|
|
444
|
-
// Use proper salt mining for hook deployment
|
|
445
|
-
address deployer = address(this);
|
|
446
|
-
(, bytes32 salt) = HooksDeployment.mineForCoinSalt(deployer, address(poolManager), address(factory), trustedMessageSenders, address(hookUpgradeGate));
|
|
447
|
-
|
|
448
|
-
bytes memory hookCreationCode = HooksDeployment.makeHookCreationCode(
|
|
449
|
-
address(poolManager),
|
|
450
|
-
address(factory),
|
|
451
|
-
trustedMessageSenders,
|
|
452
|
-
address(hookUpgradeGate)
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
hook = ZoraV4CoinHook(payable(DeployHelper.deploy(hookCreationCode, salt)));
|
|
81
|
+
function setUpNonForked(address limitOrderBook) public virtual {
|
|
82
|
+
_setUpNonForked(limitOrderBook);
|
|
456
83
|
}
|
|
457
84
|
|
|
458
85
|
struct TradeRewards {
|
|
@@ -479,11 +106,6 @@ contract BaseTest is Test, ContractAddresses {
|
|
|
479
106
|
});
|
|
480
107
|
}
|
|
481
108
|
|
|
482
|
-
function _calculateExpectedFee(uint256 ethAmount) internal pure returns (uint256) {
|
|
483
|
-
uint256 feeBps = 100; // 1%
|
|
484
|
-
return (ethAmount * feeBps) / 10_000;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
109
|
function _calculateMarketRewards(uint256 ethAmount) internal pure returns (MarketRewards memory) {
|
|
488
110
|
uint256 creator = (ethAmount * 5000) / 10_000;
|
|
489
111
|
uint256 platformReferrer = (ethAmount * 2500) / 10_000;
|
|
@@ -492,34 +114,4 @@ contract BaseTest is Test, ContractAddresses {
|
|
|
492
114
|
|
|
493
115
|
return MarketRewards({creator: creator, platformReferrer: platformReferrer, doppler: doppler, protocol: protocol});
|
|
494
116
|
}
|
|
495
|
-
|
|
496
|
-
function dealUSDC(address to, uint256 numUSDC) internal returns (uint256) {
|
|
497
|
-
uint256 amount = numUSDC * 1e6;
|
|
498
|
-
deal(address(usdc), to, amount);
|
|
499
|
-
return amount;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function _getDefaultOwners() internal view returns (address[] memory owners) {
|
|
503
|
-
owners = new address[](1);
|
|
504
|
-
owners[0] = users.creator;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function dopplerFeeRecipient() internal view returns (address) {
|
|
508
|
-
return airlock.owner();
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function _generatePoolConfig(address currency_) internal pure returns (bytes memory) {
|
|
512
|
-
return CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(currency_);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function _generatePoolConfig(
|
|
516
|
-
uint8 version_,
|
|
517
|
-
address currency_,
|
|
518
|
-
int24 tickLower_,
|
|
519
|
-
int24 tickUpper_,
|
|
520
|
-
uint16 numDiscoveryPositions_,
|
|
521
|
-
uint256 maxDiscoverySupplyShare_
|
|
522
|
-
) internal pure returns (bytes memory) {
|
|
523
|
-
return abi.encode(version_, currency_, tickLower_, tickUpper_, numDiscoveryPositions_, maxDiscoverySupplyShare_);
|
|
524
|
-
}
|
|
525
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";
|
|
@@ -16,6 +18,7 @@ import {UniV4SwapToCurrency} from "../../src/libs/UniV4SwapToCurrency.sol";
|
|
|
16
18
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
17
19
|
import {CoinRewardsV4} from "../../src/libs/CoinRewardsV4.sol";
|
|
18
20
|
import {IHooksUpgradeGate} from "../../src/interfaces/IHooksUpgradeGate.sol";
|
|
21
|
+
import {ITrustedMsgSenderProviderLookup} from "../../src/interfaces/ITrustedMsgSenderProviderLookup.sol";
|
|
19
22
|
|
|
20
23
|
/// @dev Test util - meant to be able to etched where a normal zora hook is, to gather the fees from swaps but not distribute them
|
|
21
24
|
contract FeeEstimatorHook is ZoraV4CoinHook {
|
|
@@ -33,8 +36,11 @@ contract FeeEstimatorHook is ZoraV4CoinHook {
|
|
|
33
36
|
constructor(
|
|
34
37
|
IPoolManager _poolManager,
|
|
35
38
|
IDeployedCoinVersionLookup _coinVersionLookup,
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
ITrustedMsgSenderProviderLookup trustedMsgSenderLookup,
|
|
40
|
+
IHooksUpgradeGate upgradeGate,
|
|
41
|
+
IZoraLimitOrderBookCoinsInterface zoraLimitOrderBook,
|
|
42
|
+
IZoraHookRegistry zoraHookRegistry
|
|
43
|
+
) ZoraV4CoinHook(_poolManager, _coinVersionLookup, trustedMsgSenderLookup, upgradeGate, zoraLimitOrderBook, zoraHookRegistry) {}
|
|
38
44
|
|
|
39
45
|
FeeEstimatorState public feeState;
|
|
40
46
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.13;
|
|
3
|
+
|
|
4
|
+
import {TrustedMsgSenderProviderLookup} from "../../src/utils/TrustedMsgSenderProviderLookup.sol";
|
|
5
|
+
import {ITrustedMsgSenderProviderLookup} from "../../src/interfaces/ITrustedMsgSenderProviderLookup.sol";
|
|
6
|
+
|
|
7
|
+
/// @title TrustedSenderTestHelper
|
|
8
|
+
/// @notice Helper library for deploying TrustedMsgSenderProviderLookup in tests
|
|
9
|
+
library TrustedSenderTestHelper {
|
|
10
|
+
/// @notice Deploys a TrustedMsgSenderProviderLookup with direct constructor
|
|
11
|
+
/// @param owner The owner address for the deployed contract
|
|
12
|
+
/// @param initialTrustedSenders Array of initially trusted sender addresses
|
|
13
|
+
/// @return The deployed ITrustedMsgSenderProviderLookup contract
|
|
14
|
+
function deployTrustedMessageSender(address owner, address[] memory initialTrustedSenders) internal returns (ITrustedMsgSenderProviderLookup) {
|
|
15
|
+
// Deploy the contract directly using constructor
|
|
16
|
+
return ITrustedMsgSenderProviderLookup(address(new TrustedMsgSenderProviderLookup(initialTrustedSenders, owner)));
|
|
17
|
+
}
|
|
18
|
+
}
|