@zoralabs/coins 2.2.1 → 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.
- package/.turbo/turbo-build$colon$js.log +125 -106
- package/CHANGELOG.md +50 -5
- package/README.md +5 -0
- package/abis/AddressConstants.json +7 -0
- package/abis/BaseCoin.json +0 -5
- package/abis/BaseTest.json +62 -0
- package/abis/BuySupplyWithV4SwapHook.json +429 -0
- package/abis/ContentCoin.json +0 -5
- package/abis/CreatorCoin.json +0 -5
- package/abis/FeeEstimatorHook.json +94 -1
- package/abis/IUniswapV4Router04.json +484 -0
- package/abis/IUpgradeableDestinationV4HookWithUpdateableFee.json +95 -0
- package/abis/IZoraFactory.json +69 -0
- package/abis/MockAirlock.json +39 -0
- package/abis/SimpleERC20.json +326 -0
- package/abis/ZoraFactoryImpl.json +69 -0
- package/abis/ZoraV4CoinHook.json +94 -1
- package/addresses/8453.json +8 -10
- package/audits/report-cantinacode-zora-0827.pdf +3498 -4
- package/audits/report-cantinacode-zora-1021.pdf +0 -0
- package/dist/index.cjs +161 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +160 -21
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +259 -40
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/foundry.toml +3 -3
- package/package/wagmiGenerated.ts +160 -21
- package/package.json +1 -1
- package/script/DeployPostDeploymentHooks.s.sol +1 -3
- package/script/TestBackingCoinSwap.s.sol +0 -2
- package/script/TestV4Swap.s.sol +0 -2
- package/src/BaseCoin.sol +4 -12
- package/src/ContentCoin.sol +3 -4
- package/src/CreatorCoin.sol +8 -10
- package/src/ZoraFactoryImpl.sol +115 -83
- package/src/deployment/CoinsDeployerBase.sol +9 -8
- package/src/hook-registry/ZoraHookRegistry.sol +4 -0
- package/src/hooks/ZoraV4CoinHook.sol +66 -9
- package/src/hooks/deployment/BuySupplyWithV4SwapHook.sol +310 -0
- package/src/interfaces/IUpgradeableV4Hook.sol +18 -0
- package/src/interfaces/IZoraFactory.sol +21 -2
- package/src/libs/CoinConstants.sol +51 -8
- package/src/libs/CoinDopplerMultiCurve.sol +11 -11
- package/src/libs/CoinRewardsV4.sol +26 -33
- package/src/libs/CoinSetup.sol +2 -9
- package/src/libs/DopplerMath.sol +2 -2
- package/src/libs/V4Liquidity.sol +79 -15
- package/src/utils/AutoSwapper.sol +1 -1
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/BuySupplyWithV4SwapHook.t.sol +509 -0
- package/test/Coin.t.sol +26 -14
- package/test/CoinRewardsV4.t.sol +33 -0
- package/test/CoinUniV4.t.sol +3 -5
- package/test/ContentCoinRewards.t.sol +44 -3
- package/test/CreatorCoin.t.sol +54 -33
- package/test/CreatorCoinRewards.t.sol +1 -3
- package/test/DeploymentHooks.t.sol +54 -2
- package/test/Factory.t.sol +3 -3
- package/test/LiquidityMigration.t.sol +145 -7
- package/test/MultiOwnable.t.sol +4 -4
- package/test/Upgrades.t.sol +26 -17
- package/test/V4Liquidity.t.sol +178 -0
- package/test/ZoraHookRegistry.t.sol +19 -9
- package/test/mocks/MockAirlock.sol +22 -0
- package/test/mocks/SimpleERC20.sol +8 -0
- package/test/utils/BaseTest.sol +155 -3
- package/test/utils/RewardTestHelpers.sol +4 -4
- package/test/utils/hookmate/README.md +50 -0
- package/test/utils/hookmate/artifacts/DeployHelper.sol +20 -0
- package/test/utils/hookmate/artifacts/Permit2.sol +16 -0
- package/test/utils/hookmate/artifacts/UniversalRouter.sol +29 -0
- package/test/utils/hookmate/artifacts/V4PoolManager.sol +17 -0
- package/test/utils/hookmate/artifacts/V4PositionManager.sol +23 -0
- package/test/utils/hookmate/artifacts/V4Quoter.sol +17 -0
- package/test/utils/hookmate/artifacts/V4Router.sol +18 -0
- package/test/utils/hookmate/constants/AddressConstants.sol +193 -0
- package/test/utils/hookmate/interfaces/router/IUniswapV4Router04.sol +173 -0
- package/test/utils/hookmate/interfaces/router/PathKey.sol +34 -0
- package/test/utils/hookmate/test/utils/SwapFeeEventAsserter.sol +24 -0
- package/wagmi.config.ts +1 -1
- package/abis/CoinConstants.json +0 -54
- package/abis/CoinRewardsV4.json +0 -67
- package/src/libs/CreatorCoinConstants.sol +0 -15
- package/src/libs/MarketConstants.sol +0 -23
- package/src/utils/uniswap/BytesLib.sol +0 -35
- package/src/utils/uniswap/Path.sol +0 -31
- /package/abis/{VmContractHelper227.json → VmContractHelper239.json} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.26;
|
|
3
|
+
|
|
4
|
+
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
|
|
5
|
+
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
|
|
6
|
+
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
|
|
7
|
+
|
|
8
|
+
struct PathKey {
|
|
9
|
+
Currency intermediateCurrency;
|
|
10
|
+
uint24 fee;
|
|
11
|
+
int24 tickSpacing;
|
|
12
|
+
IHooks hooks;
|
|
13
|
+
bytes hookData;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
using PathKeyLibrary for PathKey global;
|
|
17
|
+
|
|
18
|
+
/// @title PathKey Library
|
|
19
|
+
/// @notice Memory-oriented version of v4-periphery/src/libraries/PathKeyLibrary.sol
|
|
20
|
+
/// @dev Handles PathKey operations in memory rather than calldata for router operations
|
|
21
|
+
library PathKeyLibrary {
|
|
22
|
+
/// @notice Get the pool and swap direction for a given PathKey
|
|
23
|
+
/// @param params the given PathKey
|
|
24
|
+
/// @param currencyIn the input currency
|
|
25
|
+
/// @return poolKey the pool key of the swap
|
|
26
|
+
/// @return zeroForOne the direction of the swap, true if currency0 is being swapped for currency1
|
|
27
|
+
function getPoolAndSwapDirection(PathKey memory params, Currency currencyIn) internal pure returns (PoolKey memory poolKey, bool zeroForOne) {
|
|
28
|
+
Currency currencyOut = params.intermediateCurrency;
|
|
29
|
+
(Currency currency0, Currency currency1) = currencyIn < currencyOut ? (currencyIn, currencyOut) : (currencyOut, currencyIn);
|
|
30
|
+
|
|
31
|
+
zeroForOne = currencyIn == currency0;
|
|
32
|
+
poolKey = PoolKey(currency0, currency1, params.fee, params.tickSpacing, params.hooks);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.26;
|
|
3
|
+
|
|
4
|
+
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
|
|
5
|
+
import {Vm} from "forge-std/Vm.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @title Swap Fee Event Asserter
|
|
9
|
+
* @author saucepoint, akshatmittal
|
|
10
|
+
*/
|
|
11
|
+
library SwapFeeEventAsserter {
|
|
12
|
+
function getSwapFeeFromEvent(Vm.Log[] memory recordedLogs) internal pure returns (uint24 fee) {
|
|
13
|
+
for (uint256 i; i < recordedLogs.length; i++) {
|
|
14
|
+
if (recordedLogs[i].topics[0] == IPoolManager.Swap.selector) {
|
|
15
|
+
(, , , , , fee) = abi.decode(recordedLogs[i].data, (int128, int128, uint160, uint128, int24, uint24));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function assertSwapFee(Vm vm, Vm.Log[] memory recordedLogs, uint24 expectedFee) internal pure {
|
|
22
|
+
vm.assertEq(getSwapFeeFromEvent(recordedLogs), expectedFee);
|
|
23
|
+
}
|
|
24
|
+
}
|
package/wagmi.config.ts
CHANGED
|
@@ -14,11 +14,11 @@ export default defineConfig({
|
|
|
14
14
|
"CreatorCoin",
|
|
15
15
|
"ZoraFactoryImpl",
|
|
16
16
|
"IUniswapV3Pool",
|
|
17
|
-
"BuySupplyWithSwapRouterHook",
|
|
18
17
|
"IPoolConfigEncoding",
|
|
19
18
|
"IUniversalRouter",
|
|
20
19
|
"IPermit2",
|
|
21
20
|
"AutoSwapper",
|
|
21
|
+
"BuySupplyWithV4SwapHook",
|
|
22
22
|
].map((contractName) => `${contractName}.json`),
|
|
23
23
|
}),
|
|
24
24
|
],
|
package/abis/CoinConstants.json
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"type": "function",
|
|
4
|
-
"name": "CREATOR_LAUNCH_REWARD",
|
|
5
|
-
"inputs": [],
|
|
6
|
-
"outputs": [
|
|
7
|
-
{
|
|
8
|
-
"name": "",
|
|
9
|
-
"type": "uint256",
|
|
10
|
-
"internalType": "uint256"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"stateMutability": "view"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"type": "function",
|
|
17
|
-
"name": "MAX_TOTAL_SUPPLY",
|
|
18
|
-
"inputs": [],
|
|
19
|
-
"outputs": [
|
|
20
|
-
{
|
|
21
|
-
"name": "",
|
|
22
|
-
"type": "uint256",
|
|
23
|
-
"internalType": "uint256"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"stateMutability": "view"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"type": "function",
|
|
30
|
-
"name": "MIN_ORDER_SIZE",
|
|
31
|
-
"inputs": [],
|
|
32
|
-
"outputs": [
|
|
33
|
-
{
|
|
34
|
-
"name": "",
|
|
35
|
-
"type": "uint256",
|
|
36
|
-
"internalType": "uint256"
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
"stateMutability": "view"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"type": "function",
|
|
43
|
-
"name": "POOL_LAUNCH_SUPPLY",
|
|
44
|
-
"inputs": [],
|
|
45
|
-
"outputs": [
|
|
46
|
-
{
|
|
47
|
-
"name": "",
|
|
48
|
-
"type": "uint256",
|
|
49
|
-
"internalType": "uint256"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"stateMutability": "view"
|
|
53
|
-
}
|
|
54
|
-
]
|
package/abis/CoinRewardsV4.json
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"type": "function",
|
|
4
|
-
"name": "CREATE_REFERRAL_REWARD_BPS",
|
|
5
|
-
"inputs": [],
|
|
6
|
-
"outputs": [
|
|
7
|
-
{
|
|
8
|
-
"name": "",
|
|
9
|
-
"type": "uint256",
|
|
10
|
-
"internalType": "uint256"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"stateMutability": "view"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"type": "function",
|
|
17
|
-
"name": "CREATOR_REWARD_BPS",
|
|
18
|
-
"inputs": [],
|
|
19
|
-
"outputs": [
|
|
20
|
-
{
|
|
21
|
-
"name": "",
|
|
22
|
-
"type": "uint256",
|
|
23
|
-
"internalType": "uint256"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"stateMutability": "view"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"type": "function",
|
|
30
|
-
"name": "DOPPLER_REWARD_BPS",
|
|
31
|
-
"inputs": [],
|
|
32
|
-
"outputs": [
|
|
33
|
-
{
|
|
34
|
-
"name": "",
|
|
35
|
-
"type": "uint256",
|
|
36
|
-
"internalType": "uint256"
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
"stateMutability": "view"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"type": "function",
|
|
43
|
-
"name": "LP_REWARD_BPS",
|
|
44
|
-
"inputs": [],
|
|
45
|
-
"outputs": [
|
|
46
|
-
{
|
|
47
|
-
"name": "",
|
|
48
|
-
"type": "uint256",
|
|
49
|
-
"internalType": "uint256"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"stateMutability": "view"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"type": "function",
|
|
56
|
-
"name": "TRADE_REFERRAL_REWARD_BPS",
|
|
57
|
-
"inputs": [],
|
|
58
|
-
"outputs": [
|
|
59
|
-
{
|
|
60
|
-
"name": "",
|
|
61
|
-
"type": "uint256",
|
|
62
|
-
"internalType": "uint256"
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
"stateMutability": "view"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: ZORA-DELAYED-OSL-v1
|
|
2
|
-
// This software is licensed under the Zora Delayed Open Source License.
|
|
3
|
-
// Under this license, you may use, copy, modify, and distribute this software for
|
|
4
|
-
// non-commercial purposes only. Commercial use and competitive products are prohibited
|
|
5
|
-
// until the "Open Date" (3 years from first public distribution or earlier at Zora's discretion),
|
|
6
|
-
// at which point this software automatically becomes available under the MIT License.
|
|
7
|
-
// Full license terms available at: https://docs.zora.co/coins/license
|
|
8
|
-
pragma solidity ^0.8.23;
|
|
9
|
-
|
|
10
|
-
library CreatorCoinConstants {
|
|
11
|
-
uint256 internal constant TOTAL_SUPPLY = 1_000_000_000e18; // 1b coins
|
|
12
|
-
uint256 internal constant CREATOR_VESTING_SUPPLY = 500_000_000e18; // 500m coins
|
|
13
|
-
uint256 internal constant CREATOR_VESTING_DURATION = 5 * 365 days; // 5 years
|
|
14
|
-
address internal constant CURRENCY = 0x1111111111166b7FE7bd91427724B487980aFc69;
|
|
15
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.23;
|
|
3
|
-
|
|
4
|
-
library MarketConstants {
|
|
5
|
-
/// @dev Constant used to increase precision during calculations
|
|
6
|
-
uint256 internal constant WAD = 1e18;
|
|
7
|
-
|
|
8
|
-
/// @notice The number of coins allocated to the liquidity pool for content coins
|
|
9
|
-
/// @dev 990 million coins
|
|
10
|
-
uint256 internal constant CONTENT_COIN_MARKET_SUPPLY = 990_000_000 * WAD;
|
|
11
|
-
|
|
12
|
-
/// @notice The number of coins allocated to the liquidity pool for creator coins
|
|
13
|
-
/// @dev 500 million coins
|
|
14
|
-
uint256 internal constant CREATOR_COIN_MARKET_SUPPLY = 500_000_000 * WAD;
|
|
15
|
-
|
|
16
|
-
/// @notice The LP fee
|
|
17
|
-
/// @dev 10000 basis points = 1%
|
|
18
|
-
uint24 internal constant LP_FEE_V4 = 10_000;
|
|
19
|
-
|
|
20
|
-
/// @notice The spacing for 1% pools
|
|
21
|
-
/// @dev 200 ticks
|
|
22
|
-
int24 internal constant TICK_SPACING = 200;
|
|
23
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
2
|
-
/*
|
|
3
|
-
* @title Solidity Bytes Arrays Utils
|
|
4
|
-
* @author Gonçalo Sá <goncalo.sa@consensys.net>
|
|
5
|
-
*
|
|
6
|
-
* @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
|
|
7
|
-
* The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
|
|
8
|
-
*/
|
|
9
|
-
pragma solidity ^0.8.28;
|
|
10
|
-
|
|
11
|
-
library BytesLib {
|
|
12
|
-
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
|
|
13
|
-
require(_start + 20 >= _start, "toAddress_overflow");
|
|
14
|
-
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
|
|
15
|
-
address tempAddress;
|
|
16
|
-
|
|
17
|
-
assembly {
|
|
18
|
-
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return tempAddress;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) {
|
|
25
|
-
require(_start + 3 >= _start, "toUint24_overflow");
|
|
26
|
-
require(_bytes.length >= _start + 3, "toUint24_outOfBounds");
|
|
27
|
-
uint24 tempUint;
|
|
28
|
-
|
|
29
|
-
assembly {
|
|
30
|
-
tempUint := mload(add(add(_bytes, 0x3), _start))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return tempUint;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import "./BytesLib.sol";
|
|
5
|
-
|
|
6
|
-
// copied from https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/Path.sol
|
|
7
|
-
// with certain functionality removed
|
|
8
|
-
|
|
9
|
-
/// @title Functions for manipulating path data for multihop swaps
|
|
10
|
-
library Path {
|
|
11
|
-
using BytesLib for bytes;
|
|
12
|
-
|
|
13
|
-
/// @dev The length of the bytes encoded address
|
|
14
|
-
uint256 private constant ADDR_SIZE = 20;
|
|
15
|
-
/// @dev The length of the bytes encoded fee
|
|
16
|
-
uint256 private constant FEE_SIZE = 3;
|
|
17
|
-
|
|
18
|
-
/// @dev The offset of a single token address and pool fee
|
|
19
|
-
uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE;
|
|
20
|
-
|
|
21
|
-
/// @notice Decodes the first pool in path
|
|
22
|
-
/// @param path The bytes encoded swap path
|
|
23
|
-
/// @return tokenA The first token of the given pool
|
|
24
|
-
/// @return tokenB The second token of the given pool
|
|
25
|
-
/// @return fee The fee level of the pool
|
|
26
|
-
function decodeFirstPool(bytes memory path) internal pure returns (address tokenA, address tokenB, uint24 fee) {
|
|
27
|
-
tokenA = path.toAddress(0);
|
|
28
|
-
fee = path.toUint24(ADDR_SIZE);
|
|
29
|
-
tokenB = path.toAddress(NEXT_OFFSET);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
File without changes
|