@zoralabs/coins 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.turbo/turbo-build$colon$js.log +116 -97
  2. package/CHANGELOG.md +7 -1
  3. package/README.md +1 -0
  4. package/abis/AddressConstants.json +7 -0
  5. package/abis/BaseTest.json +62 -0
  6. package/abis/BuySupplyWithV4SwapHook.json +429 -0
  7. package/abis/IUniswapV4Router04.json +484 -0
  8. package/abis/MockAirlock.json +39 -0
  9. package/abis/SimpleERC20.json +326 -0
  10. package/addresses/8453.json +7 -9
  11. package/audits/report-cantinacode-zora-1021.pdf +0 -0
  12. package/dist/index.cjs +140 -19
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +139 -18
  15. package/dist/index.js.map +1 -1
  16. package/dist/wagmiGenerated.d.ts +205 -28
  17. package/dist/wagmiGenerated.d.ts.map +1 -1
  18. package/package/wagmiGenerated.ts +139 -18
  19. package/package.json +1 -1
  20. package/script/DeployPostDeploymentHooks.s.sol +1 -3
  21. package/src/deployment/CoinsDeployerBase.sol +9 -8
  22. package/src/hooks/deployment/BuySupplyWithV4SwapHook.sol +310 -0
  23. package/src/utils/AutoSwapper.sol +1 -1
  24. package/src/version/ContractVersionBase.sol +1 -1
  25. package/test/BuySupplyWithV4SwapHook.t.sol +509 -0
  26. package/test/Coin.t.sol +21 -9
  27. package/test/CoinUniV4.t.sol +1 -2
  28. package/test/ContentCoinRewards.t.sol +1 -3
  29. package/test/CreatorCoin.t.sol +1 -4
  30. package/test/CreatorCoinRewards.t.sol +1 -3
  31. package/test/Factory.t.sol +3 -3
  32. package/test/MultiOwnable.t.sol +4 -4
  33. package/test/Upgrades.t.sol +26 -17
  34. package/test/ZoraHookRegistry.t.sol +19 -9
  35. package/test/mocks/MockAirlock.sol +22 -0
  36. package/test/mocks/SimpleERC20.sol +8 -0
  37. package/test/utils/BaseTest.sol +155 -2
  38. package/test/utils/hookmate/README.md +50 -0
  39. package/test/utils/hookmate/artifacts/DeployHelper.sol +20 -0
  40. package/test/utils/hookmate/artifacts/Permit2.sol +16 -0
  41. package/test/utils/hookmate/artifacts/UniversalRouter.sol +29 -0
  42. package/test/utils/hookmate/artifacts/V4PoolManager.sol +17 -0
  43. package/test/utils/hookmate/artifacts/V4PositionManager.sol +23 -0
  44. package/test/utils/hookmate/artifacts/V4Quoter.sol +17 -0
  45. package/test/utils/hookmate/artifacts/V4Router.sol +18 -0
  46. package/test/utils/hookmate/constants/AddressConstants.sol +193 -0
  47. package/test/utils/hookmate/interfaces/router/IUniswapV4Router04.sol +173 -0
  48. package/test/utils/hookmate/interfaces/router/PathKey.sol +34 -0
  49. package/test/utils/hookmate/test/utils/SwapFeeEventAsserter.sol +24 -0
  50. package/wagmi.config.ts +1 -1
  51. package/src/utils/uniswap/BytesLib.sol +0 -35
  52. package/src/utils/uniswap/Path.sol +0 -31
  53. /package/abis/{VmContractHelper226.json → VmContractHelper239.json} +0 -0
@@ -0,0 +1,326 @@
1
+ [
2
+ {
3
+ "type": "constructor",
4
+ "inputs": [
5
+ {
6
+ "name": "name",
7
+ "type": "string",
8
+ "internalType": "string"
9
+ },
10
+ {
11
+ "name": "symbol",
12
+ "type": "string",
13
+ "internalType": "string"
14
+ }
15
+ ],
16
+ "stateMutability": "nonpayable"
17
+ },
18
+ {
19
+ "type": "function",
20
+ "name": "allowance",
21
+ "inputs": [
22
+ {
23
+ "name": "owner",
24
+ "type": "address",
25
+ "internalType": "address"
26
+ },
27
+ {
28
+ "name": "spender",
29
+ "type": "address",
30
+ "internalType": "address"
31
+ }
32
+ ],
33
+ "outputs": [
34
+ {
35
+ "name": "",
36
+ "type": "uint256",
37
+ "internalType": "uint256"
38
+ }
39
+ ],
40
+ "stateMutability": "view"
41
+ },
42
+ {
43
+ "type": "function",
44
+ "name": "approve",
45
+ "inputs": [
46
+ {
47
+ "name": "spender",
48
+ "type": "address",
49
+ "internalType": "address"
50
+ },
51
+ {
52
+ "name": "value",
53
+ "type": "uint256",
54
+ "internalType": "uint256"
55
+ }
56
+ ],
57
+ "outputs": [
58
+ {
59
+ "name": "",
60
+ "type": "bool",
61
+ "internalType": "bool"
62
+ }
63
+ ],
64
+ "stateMutability": "nonpayable"
65
+ },
66
+ {
67
+ "type": "function",
68
+ "name": "balanceOf",
69
+ "inputs": [
70
+ {
71
+ "name": "account",
72
+ "type": "address",
73
+ "internalType": "address"
74
+ }
75
+ ],
76
+ "outputs": [
77
+ {
78
+ "name": "",
79
+ "type": "uint256",
80
+ "internalType": "uint256"
81
+ }
82
+ ],
83
+ "stateMutability": "view"
84
+ },
85
+ {
86
+ "type": "function",
87
+ "name": "decimals",
88
+ "inputs": [],
89
+ "outputs": [
90
+ {
91
+ "name": "",
92
+ "type": "uint8",
93
+ "internalType": "uint8"
94
+ }
95
+ ],
96
+ "stateMutability": "view"
97
+ },
98
+ {
99
+ "type": "function",
100
+ "name": "name",
101
+ "inputs": [],
102
+ "outputs": [
103
+ {
104
+ "name": "",
105
+ "type": "string",
106
+ "internalType": "string"
107
+ }
108
+ ],
109
+ "stateMutability": "view"
110
+ },
111
+ {
112
+ "type": "function",
113
+ "name": "symbol",
114
+ "inputs": [],
115
+ "outputs": [
116
+ {
117
+ "name": "",
118
+ "type": "string",
119
+ "internalType": "string"
120
+ }
121
+ ],
122
+ "stateMutability": "view"
123
+ },
124
+ {
125
+ "type": "function",
126
+ "name": "totalSupply",
127
+ "inputs": [],
128
+ "outputs": [
129
+ {
130
+ "name": "",
131
+ "type": "uint256",
132
+ "internalType": "uint256"
133
+ }
134
+ ],
135
+ "stateMutability": "view"
136
+ },
137
+ {
138
+ "type": "function",
139
+ "name": "transfer",
140
+ "inputs": [
141
+ {
142
+ "name": "to",
143
+ "type": "address",
144
+ "internalType": "address"
145
+ },
146
+ {
147
+ "name": "value",
148
+ "type": "uint256",
149
+ "internalType": "uint256"
150
+ }
151
+ ],
152
+ "outputs": [
153
+ {
154
+ "name": "",
155
+ "type": "bool",
156
+ "internalType": "bool"
157
+ }
158
+ ],
159
+ "stateMutability": "nonpayable"
160
+ },
161
+ {
162
+ "type": "function",
163
+ "name": "transferFrom",
164
+ "inputs": [
165
+ {
166
+ "name": "from",
167
+ "type": "address",
168
+ "internalType": "address"
169
+ },
170
+ {
171
+ "name": "to",
172
+ "type": "address",
173
+ "internalType": "address"
174
+ },
175
+ {
176
+ "name": "value",
177
+ "type": "uint256",
178
+ "internalType": "uint256"
179
+ }
180
+ ],
181
+ "outputs": [
182
+ {
183
+ "name": "",
184
+ "type": "bool",
185
+ "internalType": "bool"
186
+ }
187
+ ],
188
+ "stateMutability": "nonpayable"
189
+ },
190
+ {
191
+ "type": "event",
192
+ "name": "Approval",
193
+ "inputs": [
194
+ {
195
+ "name": "owner",
196
+ "type": "address",
197
+ "indexed": true,
198
+ "internalType": "address"
199
+ },
200
+ {
201
+ "name": "spender",
202
+ "type": "address",
203
+ "indexed": true,
204
+ "internalType": "address"
205
+ },
206
+ {
207
+ "name": "value",
208
+ "type": "uint256",
209
+ "indexed": false,
210
+ "internalType": "uint256"
211
+ }
212
+ ],
213
+ "anonymous": false
214
+ },
215
+ {
216
+ "type": "event",
217
+ "name": "Transfer",
218
+ "inputs": [
219
+ {
220
+ "name": "from",
221
+ "type": "address",
222
+ "indexed": true,
223
+ "internalType": "address"
224
+ },
225
+ {
226
+ "name": "to",
227
+ "type": "address",
228
+ "indexed": true,
229
+ "internalType": "address"
230
+ },
231
+ {
232
+ "name": "value",
233
+ "type": "uint256",
234
+ "indexed": false,
235
+ "internalType": "uint256"
236
+ }
237
+ ],
238
+ "anonymous": false
239
+ },
240
+ {
241
+ "type": "error",
242
+ "name": "ERC20InsufficientAllowance",
243
+ "inputs": [
244
+ {
245
+ "name": "spender",
246
+ "type": "address",
247
+ "internalType": "address"
248
+ },
249
+ {
250
+ "name": "allowance",
251
+ "type": "uint256",
252
+ "internalType": "uint256"
253
+ },
254
+ {
255
+ "name": "needed",
256
+ "type": "uint256",
257
+ "internalType": "uint256"
258
+ }
259
+ ]
260
+ },
261
+ {
262
+ "type": "error",
263
+ "name": "ERC20InsufficientBalance",
264
+ "inputs": [
265
+ {
266
+ "name": "sender",
267
+ "type": "address",
268
+ "internalType": "address"
269
+ },
270
+ {
271
+ "name": "balance",
272
+ "type": "uint256",
273
+ "internalType": "uint256"
274
+ },
275
+ {
276
+ "name": "needed",
277
+ "type": "uint256",
278
+ "internalType": "uint256"
279
+ }
280
+ ]
281
+ },
282
+ {
283
+ "type": "error",
284
+ "name": "ERC20InvalidApprover",
285
+ "inputs": [
286
+ {
287
+ "name": "approver",
288
+ "type": "address",
289
+ "internalType": "address"
290
+ }
291
+ ]
292
+ },
293
+ {
294
+ "type": "error",
295
+ "name": "ERC20InvalidReceiver",
296
+ "inputs": [
297
+ {
298
+ "name": "receiver",
299
+ "type": "address",
300
+ "internalType": "address"
301
+ }
302
+ ]
303
+ },
304
+ {
305
+ "type": "error",
306
+ "name": "ERC20InvalidSender",
307
+ "inputs": [
308
+ {
309
+ "name": "sender",
310
+ "type": "address",
311
+ "internalType": "address"
312
+ }
313
+ ]
314
+ },
315
+ {
316
+ "type": "error",
317
+ "name": "ERC20InvalidSpender",
318
+ "inputs": [
319
+ {
320
+ "name": "spender",
321
+ "type": "address",
322
+ "internalType": "address"
323
+ }
324
+ ]
325
+ }
326
+ ]
@@ -1,15 +1,13 @@
1
1
  {
2
- "BUY_SUPPLY_WITH_SWAP_ROUTER_HOOK": "0xc90e349360C43a0217CEF289f231C66D4748960F",
2
+ "BUY_SUPPLY_WITH_SWAP_ROUTER_HOOK": "0xd8CC7bCA1dE52eA788829B16E375e9B96C18D433",
3
3
  "COIN_V3_IMPL": "0x45Bf86430af7CD071Ea23aE52325A78C8d12aD5a",
4
- "COIN_V4_IMPL": "0xca72309AaF706d290E08608b1Af47943902f69b2",
5
- "COIN_VERSION": "1.1.0",
6
- "CREATOR_COIN_HOOK": "0x1258e5f3C71ca9dCE95Ce734Ba5759532E46D040",
7
- "CREATOR_COIN_HOOK_SALT": "0x00000000000000000000000000000000000000000000000000000000000029b1",
8
- "CREATOR_COIN_IMPL": "0x88CC4E08C7608723f3E44e17aC669Fb43b6A8313",
4
+ "COIN_V4_IMPL": "0x7Cad62748DDf516CF85bC2C05C14786D84Cf861c",
5
+ "COIN_VERSION": "2.3.0",
6
+ "CREATOR_COIN_IMPL": "0x36853f9f48fAEe51Bd3db15db21EB4B9038bB795",
9
7
  "HOOK_UPGRADE_GATE": "0xD88f6BdD765313CaFA5888C177c325E2C3AbF2D2",
10
8
  "ZORA_FACTORY": "0x777777751622c0d3258f214F9DF38E35BF45baF3",
11
- "ZORA_FACTORY_IMPL": "0x57e338b97757f6E416965BEB9A5Cd2DB48b10c42",
9
+ "ZORA_FACTORY_IMPL": "0x8Ec7f068A77fa5FC1925110f82381374BA054Ff2",
12
10
  "ZORA_HOOK_REGISTRY": "0x777777C4c14b133858c3982D41Dbf02509fc18d7",
13
- "ZORA_V4_COIN_HOOK": "0x2b15a16B3Ef024005bA899Bb51764FCd58Cf9040",
14
- "ZORA_V4_COIN_HOOK_SALT": "0x0000000000000000000000000000000000000000000000000000000000000f90"
11
+ "ZORA_V4_COIN_HOOK": "0xC8d077444625eB300A427a6dfB2b1DBf9b159040",
12
+ "ZORA_V4_COIN_HOOK_SALT": "0x0000000000000000000000000000000000000000000000000000000000001624"
15
13
  }
package/dist/index.cjs CHANGED
@@ -22,7 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  autoSwapperABI: () => autoSwapperABI,
24
24
  baseCoinABI: () => baseCoinABI,
25
- buySupplyWithSwapRouterHookABI: () => buySupplyWithSwapRouterHookABI,
25
+ buySupplyWithV4SwapHookABI: () => buySupplyWithV4SwapHookABI,
26
26
  contentCoinABI: () => contentCoinABI,
27
27
  creatorCoinABI: () => creatorCoinABI,
28
28
  iPermit2ABI: () => iPermit2ABI,
@@ -1204,7 +1204,7 @@ var baseCoinABI = [
1204
1204
  { type: "error", inputs: [], name: "SlippageBoundsExceeded" },
1205
1205
  { type: "error", inputs: [], name: "UseRevokeOwnershipToRemoveSelf" }
1206
1206
  ];
1207
- var buySupplyWithSwapRouterHookABI = [
1207
+ var buySupplyWithV4SwapHookABI = [
1208
1208
  {
1209
1209
  type: "constructor",
1210
1210
  inputs: [
@@ -1229,6 +1229,63 @@ var buySupplyWithSwapRouterHookABI = [
1229
1229
  outputs: [{ name: "", internalType: "bytes", type: "bytes" }],
1230
1230
  stateMutability: "payable"
1231
1231
  },
1232
+ {
1233
+ type: "function",
1234
+ inputs: [{ name: "data", internalType: "bytes", type: "bytes" }],
1235
+ name: "decodeV4RouteData",
1236
+ outputs: [
1237
+ {
1238
+ name: "v4Route",
1239
+ internalType: "struct PoolKey[]",
1240
+ type: "tuple[]",
1241
+ components: [
1242
+ { name: "currency0", internalType: "Currency", type: "address" },
1243
+ { name: "currency1", internalType: "Currency", type: "address" },
1244
+ { name: "fee", internalType: "uint24", type: "uint24" },
1245
+ { name: "tickSpacing", internalType: "int24", type: "int24" },
1246
+ { name: "hooks", internalType: "contract IHooks", type: "address" }
1247
+ ]
1248
+ },
1249
+ { name: "startAmount", internalType: "uint256", type: "uint256" }
1250
+ ],
1251
+ stateMutability: "pure"
1252
+ },
1253
+ {
1254
+ type: "function",
1255
+ inputs: [
1256
+ {
1257
+ name: "params",
1258
+ internalType: "struct BuySupplyWithV4SwapHook.InitialSupplyParams",
1259
+ type: "tuple",
1260
+ components: [
1261
+ { name: "buyRecipient", internalType: "address", type: "address" },
1262
+ { name: "v3Route", internalType: "bytes", type: "bytes" },
1263
+ {
1264
+ name: "v4Route",
1265
+ internalType: "struct PoolKey[]",
1266
+ type: "tuple[]",
1267
+ components: [
1268
+ { name: "currency0", internalType: "Currency", type: "address" },
1269
+ { name: "currency1", internalType: "Currency", type: "address" },
1270
+ { name: "fee", internalType: "uint24", type: "uint24" },
1271
+ { name: "tickSpacing", internalType: "int24", type: "int24" },
1272
+ {
1273
+ name: "hooks",
1274
+ internalType: "contract IHooks",
1275
+ type: "address"
1276
+ }
1277
+ ]
1278
+ },
1279
+ { name: "inputCurrency", internalType: "address", type: "address" },
1280
+ { name: "inputAmount", internalType: "uint256", type: "uint256" },
1281
+ { name: "minAmountOut", internalType: "uint256", type: "uint256" }
1282
+ ]
1283
+ }
1284
+ ],
1285
+ name: "encodeBuySupplyWithV4SwapHookData",
1286
+ outputs: [{ name: "", internalType: "bytes", type: "bytes" }],
1287
+ stateMutability: "pure"
1288
+ },
1232
1289
  {
1233
1290
  type: "function",
1234
1291
  inputs: [],
@@ -1238,6 +1295,15 @@ var buySupplyWithSwapRouterHookABI = [
1238
1295
  ],
1239
1296
  stateMutability: "view"
1240
1297
  },
1298
+ {
1299
+ type: "function",
1300
+ inputs: [],
1301
+ name: "poolManager",
1302
+ outputs: [
1303
+ { name: "", internalType: "contract IPoolManager", type: "address" }
1304
+ ],
1305
+ stateMutability: "view"
1306
+ },
1241
1307
  {
1242
1308
  type: "function",
1243
1309
  inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }],
@@ -1245,6 +1311,15 @@ var buySupplyWithSwapRouterHookABI = [
1245
1311
  outputs: [{ name: "", internalType: "bool", type: "bool" }],
1246
1312
  stateMutability: "pure"
1247
1313
  },
1314
+ {
1315
+ type: "function",
1316
+ inputs: [],
1317
+ name: "swapRouter",
1318
+ outputs: [
1319
+ { name: "", internalType: "contract ISwapRouter", type: "address" }
1320
+ ],
1321
+ stateMutability: "view"
1322
+ },
1248
1323
  {
1249
1324
  type: "function",
1250
1325
  inputs: [{ name: "data", internalType: "bytes", type: "bytes" }],
@@ -1252,6 +1327,58 @@ var buySupplyWithSwapRouterHookABI = [
1252
1327
  outputs: [{ name: "", internalType: "bytes", type: "bytes" }],
1253
1328
  stateMutability: "nonpayable"
1254
1329
  },
1330
+ {
1331
+ type: "event",
1332
+ anonymous: false,
1333
+ inputs: [
1334
+ { name: "coin", internalType: "address", type: "address", indexed: true },
1335
+ {
1336
+ name: "recipient",
1337
+ internalType: "address",
1338
+ type: "address",
1339
+ indexed: true
1340
+ },
1341
+ {
1342
+ name: "coinsPurchased",
1343
+ internalType: "uint256",
1344
+ type: "uint256",
1345
+ indexed: true
1346
+ },
1347
+ { name: "v3Route", internalType: "bytes", type: "bytes", indexed: false },
1348
+ {
1349
+ name: "v4Route",
1350
+ internalType: "struct PoolKey[]",
1351
+ type: "tuple[]",
1352
+ components: [
1353
+ { name: "currency0", internalType: "Currency", type: "address" },
1354
+ { name: "currency1", internalType: "Currency", type: "address" },
1355
+ { name: "fee", internalType: "uint24", type: "uint24" },
1356
+ { name: "tickSpacing", internalType: "int24", type: "int24" },
1357
+ { name: "hooks", internalType: "contract IHooks", type: "address" }
1358
+ ],
1359
+ indexed: false
1360
+ },
1361
+ {
1362
+ name: "inputCurrency",
1363
+ internalType: "address",
1364
+ type: "address",
1365
+ indexed: false
1366
+ },
1367
+ {
1368
+ name: "inputAmount",
1369
+ internalType: "uint256",
1370
+ type: "uint256",
1371
+ indexed: false
1372
+ },
1373
+ {
1374
+ name: "v4SwapInput",
1375
+ internalType: "uint256",
1376
+ type: "uint256",
1377
+ indexed: false
1378
+ }
1379
+ ],
1380
+ name: "BuyInitialSupply"
1381
+ },
1255
1382
  {
1256
1383
  type: "error",
1257
1384
  inputs: [{ name: "target", internalType: "address", type: "address" }],
@@ -1263,20 +1390,17 @@ var buySupplyWithSwapRouterHookABI = [
1263
1390
  name: "AddressInsufficientBalance"
1264
1391
  },
1265
1392
  { type: "error", inputs: [], name: "AddressZero" },
1393
+ { type: "error", inputs: [], name: "FailedInnerCall" },
1394
+ { type: "error", inputs: [], name: "HookNotImplemented" },
1266
1395
  {
1267
1396
  type: "error",
1268
- inputs: [{ name: "balance", internalType: "uint256", type: "uint256" }],
1269
- name: "CoinBalanceNot0"
1270
- },
1271
- {
1272
- type: "error",
1273
- inputs: [{ name: "balance", internalType: "uint256", type: "uint256" }],
1274
- name: "CurrencyBalanceNot0"
1397
+ inputs: [
1398
+ { name: "inputAmount", internalType: "uint256", type: "uint256" },
1399
+ { name: "availableAmount", internalType: "uint256", type: "uint256" }
1400
+ ],
1401
+ name: "InsufficientInputCurrency"
1275
1402
  },
1276
- { type: "error", inputs: [], name: "Erc20NotReceived" },
1277
- { type: "error", inputs: [], name: "FailedInnerCall" },
1278
- { type: "error", inputs: [], name: "HookNotImplemented" },
1279
- { type: "error", inputs: [], name: "InvalidSwapRouterCall" },
1403
+ { type: "error", inputs: [], name: "InsufficientOutputAmount" },
1280
1404
  { type: "error", inputs: [], name: "NotFactory" },
1281
1405
  { type: "error", inputs: [], name: "OnlyPoolManager" },
1282
1406
  {
@@ -1284,11 +1408,8 @@ var buySupplyWithSwapRouterHookABI = [
1284
1408
  inputs: [{ name: "token", internalType: "address", type: "address" }],
1285
1409
  name: "SafeERC20FailedOperation"
1286
1410
  },
1287
- {
1288
- type: "error",
1289
- inputs: [{ name: "error", internalType: "bytes", type: "bytes" }],
1290
- name: "SwapReverted"
1291
- }
1411
+ { type: "error", inputs: [], name: "V3RouteCannotStartWithInputCurrency" },
1412
+ { type: "error", inputs: [], name: "V3RouteDoesNotConnectToV4RouteStart" }
1292
1413
  ];
1293
1414
  var contentCoinABI = [
1294
1415
  {
@@ -4855,7 +4976,7 @@ var zoraFactoryImplABI = [
4855
4976
  0 && (module.exports = {
4856
4977
  autoSwapperABI,
4857
4978
  baseCoinABI,
4858
- buySupplyWithSwapRouterHookABI,
4979
+ buySupplyWithV4SwapHookABI,
4859
4980
  contentCoinABI,
4860
4981
  creatorCoinABI,
4861
4982
  iPermit2ABI,