@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
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import {ProxyDeployerScript, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
5
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
6
|
-
|
|
7
|
-
import {IZoraFactory} from "../src/interfaces/IZoraFactory.sol";
|
|
8
|
-
import {CoinConfigurationVersions} from "../src/libs/CoinConfigurationVersions.sol";
|
|
9
|
-
import {UniV4SwapHelper} from "../src/libs/UniV4SwapHelper.sol";
|
|
10
|
-
import {ContentCoin} from "../src/ContentCoin.sol";
|
|
11
|
-
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
|
|
12
|
-
import {IUniversalRouter} from "@uniswap/universal-router/contracts/interfaces/IUniversalRouter.sol";
|
|
13
|
-
import {IPermit2} from "permit2/src/interfaces/IPermit2.sol";
|
|
14
|
-
import {MockERC20} from "../test/mocks/MockERC20.sol";
|
|
15
|
-
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
|
|
16
|
-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
17
|
-
import {ICoin} from "../src/interfaces/ICoin.sol";
|
|
18
|
-
|
|
19
|
-
import {console} from "forge-std/console.sol";
|
|
20
|
-
|
|
21
|
-
contract TestV4Swap is CoinsDeployerBase {
|
|
22
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_LOWER = -777000;
|
|
23
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_UPPER = 222000;
|
|
24
|
-
uint16 internal constant DEFAULT_NUM_DISCOVERY_POSITIONS = 10; // will be 11 total with tail position
|
|
25
|
-
uint256 internal constant DEFAULT_DISCOVERY_SUPPLY_SHARE = 0.495e18; //
|
|
26
|
-
|
|
27
|
-
function _deployCoin(
|
|
28
|
-
address currency,
|
|
29
|
-
address creator,
|
|
30
|
-
string memory name,
|
|
31
|
-
string memory symbol,
|
|
32
|
-
string memory uri,
|
|
33
|
-
address createReferral,
|
|
34
|
-
bytes32 salt
|
|
35
|
-
) internal returns (ICoin coin) {
|
|
36
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
37
|
-
address[] memory owners = new address[](1);
|
|
38
|
-
owners[0] = creator;
|
|
39
|
-
|
|
40
|
-
bytes memory poolConfig = CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(address(currency));
|
|
41
|
-
|
|
42
|
-
(address coinAddress, ) = IZoraFactory(deployment.zoraFactory).deploy(
|
|
43
|
-
creator,
|
|
44
|
-
owners,
|
|
45
|
-
uri,
|
|
46
|
-
name,
|
|
47
|
-
symbol,
|
|
48
|
-
poolConfig,
|
|
49
|
-
createReferral,
|
|
50
|
-
address(0),
|
|
51
|
-
"",
|
|
52
|
-
salt
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
coin = ICoin(coinAddress);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _swap(address currencyIn, uint128 amountIn, ICoin coin, address trader, address tradeReferral) internal returns (uint256 amountOut) {
|
|
59
|
-
uint128 minAmountOut = 0;
|
|
60
|
-
|
|
61
|
-
PoolKey memory poolKey = coin.getPoolKey();
|
|
62
|
-
|
|
63
|
-
bytes memory hookData = tradeReferral != address(0) ? abi.encode(tradeReferral) : bytes("");
|
|
64
|
-
|
|
65
|
-
address currencyOut = Currency.unwrap(Currency.unwrap(poolKey.currency0) == currencyIn ? poolKey.currency1 : poolKey.currency0);
|
|
66
|
-
|
|
67
|
-
// now we need to swap some currency into the coin
|
|
68
|
-
// first let
|
|
69
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
70
|
-
currencyIn,
|
|
71
|
-
amountIn,
|
|
72
|
-
currencyOut,
|
|
73
|
-
minAmountOut,
|
|
74
|
-
poolKey,
|
|
75
|
-
hookData
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
UniV4SwapHelper.approveTokenWithPermit2(
|
|
79
|
-
IPermit2(getUniswapPermit2()),
|
|
80
|
-
getUniswapUniversalRouter(),
|
|
81
|
-
currencyIn,
|
|
82
|
-
amountIn,
|
|
83
|
-
uint48(block.timestamp + 1 days)
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
uint256 balanceBefore = IERC20(currencyOut).balanceOf(trader);
|
|
87
|
-
|
|
88
|
-
// Execute the swap
|
|
89
|
-
uint256 deadline = block.timestamp + 1 days;
|
|
90
|
-
IUniversalRouter(getUniswapUniversalRouter()).execute(commands, inputs, deadline);
|
|
91
|
-
|
|
92
|
-
amountOut = IERC20(currencyOut).balanceOf(trader) - balanceBefore;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function run() public {
|
|
96
|
-
address trader = vm.envAddress("TRADER");
|
|
97
|
-
|
|
98
|
-
require(block.chainid == 8453, "only on base");
|
|
99
|
-
|
|
100
|
-
address zora = 0x1111111111166b7FE7bd91427724B487980aFc69;
|
|
101
|
-
|
|
102
|
-
vm.startBroadcast(trader);
|
|
103
|
-
|
|
104
|
-
address createReferral = 0xC077e4cC02fa01A5b7fAca1acE9BBe9f5ac5Af9F;
|
|
105
|
-
|
|
106
|
-
ICoin backingCoin = _deployCoin(zora, trader, "Backing Coin", "BACK", "https://testc.com", createReferral, bytes32("creator"));
|
|
107
|
-
ICoin contentCoin = _deployCoin(
|
|
108
|
-
address(backingCoin),
|
|
109
|
-
trader,
|
|
110
|
-
"Content Coin",
|
|
111
|
-
"CONTENT",
|
|
112
|
-
"https://content.com",
|
|
113
|
-
createReferral,
|
|
114
|
-
bytes32("content coin")
|
|
115
|
-
);
|
|
116
|
-
// ICoin backingCoin = ICoin(0xeA734b5997F35cD469921cCa7BB9A03C104f2f64);
|
|
117
|
-
// ICoin contentCoin = ICoin(0x72218BFEEc7D556BD3Dd8eFf2a317CEd49533769);
|
|
118
|
-
|
|
119
|
-
console.log("backingCoin", address(backingCoin));
|
|
120
|
-
console.log("contentCoin", address(contentCoin));
|
|
121
|
-
// console.log("currency", address(currency));
|
|
122
|
-
|
|
123
|
-
// (MockERC20 currency, address coinAddress) = _deployMockCurrencyAndCoin(trader, createReferral);
|
|
124
|
-
|
|
125
|
-
// address coinAddress = vm.parseAddress("0x58c0d8803Ae97bEF212EdFA8ba2FE303670cca9D");
|
|
126
|
-
// console.log("currency", address(currency));
|
|
127
|
-
// console.log("coinAddress", coinAddress);
|
|
128
|
-
|
|
129
|
-
// // swap in 2 ether of currency into the coin
|
|
130
|
-
// uint128 amountIn = uint128(IERC20(zora).balanceOf(trader));
|
|
131
|
-
// // currency.mint(trader, amountIn);
|
|
132
|
-
|
|
133
|
-
// // // swap some currency into the backing coin
|
|
134
|
-
// uint256 backingCoinReceived = _swap(zora, amountIn, backingCoin, trader, tradeReferral);
|
|
135
|
-
|
|
136
|
-
// // // swap balance of backing coin into the content coin
|
|
137
|
-
// uint256 contentCoinReceived = _swap(address(backingCoin), uint128(backingCoinReceived), contentCoin, trader, tradeReferral);
|
|
138
|
-
|
|
139
|
-
// // swap balance of content coin into the currency
|
|
140
|
-
// _swap(address(contentCoin), uint128(contentCoinReceived), contentCoin, trader, tradeReferral);
|
|
141
|
-
|
|
142
|
-
vm.stopBroadcast();
|
|
143
|
-
}
|
|
144
|
-
}
|
package/script/TestV4Swap.s.sol
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import {ProxyDeployerScript, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
5
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
6
|
-
|
|
7
|
-
import {IZoraFactory} from "../src/interfaces/IZoraFactory.sol";
|
|
8
|
-
import {CoinConfigurationVersions} from "../src/libs/CoinConfigurationVersions.sol";
|
|
9
|
-
import {UniV4SwapHelper} from "../src/libs/UniV4SwapHelper.sol";
|
|
10
|
-
import {ContentCoin} from "../src/ContentCoin.sol";
|
|
11
|
-
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
|
|
12
|
-
import {IUniversalRouter} from "@uniswap/universal-router/contracts/interfaces/IUniversalRouter.sol";
|
|
13
|
-
import {IPermit2} from "permit2/src/interfaces/IPermit2.sol";
|
|
14
|
-
import {MockERC20} from "../test/mocks/MockERC20.sol";
|
|
15
|
-
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
|
|
16
|
-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
17
|
-
import {ICoin} from "../src/interfaces/ICoin.sol";
|
|
18
|
-
|
|
19
|
-
import {console} from "forge-std/console.sol";
|
|
20
|
-
|
|
21
|
-
contract TestV4Swap is CoinsDeployerBase {
|
|
22
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_LOWER = -777000;
|
|
23
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_UPPER = 222000;
|
|
24
|
-
uint16 internal constant DEFAULT_NUM_DISCOVERY_POSITIONS = 10; // will be 11 total with tail position
|
|
25
|
-
uint256 internal constant DEFAULT_DISCOVERY_SUPPLY_SHARE = 0.495e18; //
|
|
26
|
-
|
|
27
|
-
function _deployMockCurrency() internal returns (MockERC20 currency) {
|
|
28
|
-
currency = new MockERC20("Testcoin", "TEST");
|
|
29
|
-
currency.mint(getUniswapV4PoolManager(), 1000000 ether);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _deployMockCoin(address currency, address creator, address createReferral, bytes32 salt) internal returns (ICoin coin) {
|
|
33
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
34
|
-
address[] memory owners = new address[](1);
|
|
35
|
-
owners[0] = creator;
|
|
36
|
-
|
|
37
|
-
bytes memory poolConfig = CoinConfigurationVersions.defaultDopplerMultiCurveUniV4(address(currency));
|
|
38
|
-
|
|
39
|
-
(address coinAddress, ) = IZoraFactory(deployment.zoraFactory).deploy(
|
|
40
|
-
creator,
|
|
41
|
-
owners,
|
|
42
|
-
"https://test.com",
|
|
43
|
-
"Testcoin",
|
|
44
|
-
"TEST",
|
|
45
|
-
poolConfig,
|
|
46
|
-
createReferral,
|
|
47
|
-
address(0),
|
|
48
|
-
"",
|
|
49
|
-
salt
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
coin = ICoin(coinAddress);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _swap(address currencyIn, uint128 amountIn, ICoin coin, address trader, address tradeReferral) internal returns (uint256 amountOut) {
|
|
56
|
-
uint128 minAmountOut = 0;
|
|
57
|
-
|
|
58
|
-
PoolKey memory poolKey = coin.getPoolKey();
|
|
59
|
-
|
|
60
|
-
bytes memory hookData = tradeReferral != address(0) ? abi.encode(tradeReferral) : bytes("");
|
|
61
|
-
|
|
62
|
-
address currencyOut = Currency.unwrap(Currency.unwrap(poolKey.currency0) == currencyIn ? poolKey.currency1 : poolKey.currency0);
|
|
63
|
-
|
|
64
|
-
// now we need to swap some currency into the coin
|
|
65
|
-
// first let
|
|
66
|
-
(bytes memory commands, bytes[] memory inputs) = UniV4SwapHelper.buildExactInputSingleSwapCommand(
|
|
67
|
-
currencyIn,
|
|
68
|
-
amountIn,
|
|
69
|
-
currencyOut,
|
|
70
|
-
minAmountOut,
|
|
71
|
-
poolKey,
|
|
72
|
-
hookData
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
UniV4SwapHelper.approveTokenWithPermit2(
|
|
76
|
-
IPermit2(getUniswapPermit2()),
|
|
77
|
-
getUniswapUniversalRouter(),
|
|
78
|
-
currencyIn,
|
|
79
|
-
amountIn,
|
|
80
|
-
uint48(block.timestamp + 1 days)
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
uint256 balanceBefore = IERC20(currencyOut).balanceOf(trader);
|
|
84
|
-
|
|
85
|
-
// Execute the swap
|
|
86
|
-
uint256 deadline = block.timestamp + 1 days;
|
|
87
|
-
IUniversalRouter(getUniswapUniversalRouter()).execute(commands, inputs, deadline);
|
|
88
|
-
|
|
89
|
-
amountOut = IERC20(currencyOut).balanceOf(trader) - balanceBefore;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function run() public {
|
|
93
|
-
address trader = vm.envAddress("TRADER");
|
|
94
|
-
|
|
95
|
-
vm.startBroadcast(trader);
|
|
96
|
-
|
|
97
|
-
address tradeReferral = 0xC077e4cC02fa01A5b7fAca1acE9BBe9f5ac5Af9F;
|
|
98
|
-
|
|
99
|
-
// MockERC20 currency = _deployMockCurrency();
|
|
100
|
-
|
|
101
|
-
// ICoin backingCoin = _deployMockCoin(address(currency), trader, createReferral, bytes32("backing coin"));
|
|
102
|
-
// ICoin contentCoin = _deployMockCoin(address(backingCoin), trader, createReferral, bytes32("content coin"));
|
|
103
|
-
|
|
104
|
-
MockERC20 currency = MockERC20(0x1b183Bd0E2c03Fc830F4d813bA37E82F9F97cA21);
|
|
105
|
-
ICoin backingCoin = ICoin(0x7D74416C4c295A592Fc6F9232911C945354b253C);
|
|
106
|
-
ICoin contentCoin = ICoin(0xf6d6660bcdA588F7f99e2961f279f500fB501730);
|
|
107
|
-
|
|
108
|
-
console.log("currency", address(currency));
|
|
109
|
-
console.log("backingCoin", address(backingCoin));
|
|
110
|
-
console.log("contentCoin", address(contentCoin));
|
|
111
|
-
|
|
112
|
-
// (MockERC20 currency, address coinAddress) = _deployMockCurrencyAndCoin(trader, createReferral);
|
|
113
|
-
|
|
114
|
-
// address coinAddress = vm.parseAddress("0x58c0d8803Ae97bEF212EdFA8ba2FE303670cca9D");
|
|
115
|
-
// console.log("currency", address(currency));
|
|
116
|
-
// console.log("coinAddress", coinAddress);
|
|
117
|
-
|
|
118
|
-
// swap in 2 ether of currency into the coin
|
|
119
|
-
uint128 amountIn = 2 ether;
|
|
120
|
-
currency.mint(trader, amountIn);
|
|
121
|
-
|
|
122
|
-
// swap some currency into the backing coin
|
|
123
|
-
uint256 backingCoinReceived = _swap(address(currency), amountIn, backingCoin, trader, tradeReferral);
|
|
124
|
-
|
|
125
|
-
// swap balance of backing coin into the content coin
|
|
126
|
-
uint256 contentCoinReceived = _swap(address(backingCoin), uint128(backingCoinReceived), contentCoin, trader, tradeReferral);
|
|
127
|
-
|
|
128
|
-
// swap balance of content coin into the currency
|
|
129
|
-
_swap(address(contentCoin), uint128(contentCoinReceived), contentCoin, trader, tradeReferral);
|
|
130
|
-
|
|
131
|
-
vm.stopBroadcast();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.26;
|
|
3
|
-
|
|
4
|
-
import {ProxyDeployerScript, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
5
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
6
|
-
|
|
7
|
-
contract UpgradeCoinImpl is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment(false);
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
// get deployer contract
|
|
14
|
-
deployment = deployImpls(deployment);
|
|
15
|
-
|
|
16
|
-
vm.stopBroadcast();
|
|
17
|
-
|
|
18
|
-
// save the deployment json
|
|
19
|
-
saveDeployment(deployment);
|
|
20
|
-
|
|
21
|
-
printUpgradeFactoryCommand(deployment);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
5
|
-
import {ZoraFactoryImpl} from "../src/ZoraFactoryImpl.sol";
|
|
6
|
-
|
|
7
|
-
contract UpgradeFactoryImpl is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
ZoraFactoryImpl zoraFactoryImpl = deployZoraFactoryImpl(
|
|
14
|
-
deployment.coinV4Impl,
|
|
15
|
-
deployment.creatorCoinImpl,
|
|
16
|
-
deployment.zoraV4CoinHook,
|
|
17
|
-
deployment.zoraHookRegistry
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
deployment.zoraFactoryImpl = address(zoraFactoryImpl);
|
|
21
|
-
|
|
22
|
-
vm.stopBroadcast();
|
|
23
|
-
|
|
24
|
-
// save the deployment json
|
|
25
|
-
saveDeployment(deployment);
|
|
26
|
-
printUpgradeFactoryCommand(deployment);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.26;
|
|
3
|
-
|
|
4
|
-
import {ProxyDeployerScript, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
5
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
6
|
-
|
|
7
|
-
contract UpgradeHooks is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment(false);
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
// get deployer contract
|
|
14
|
-
deployment = deployHooks(deployment);
|
|
15
|
-
|
|
16
|
-
vm.stopBroadcast();
|
|
17
|
-
|
|
18
|
-
// save the deployment json
|
|
19
|
-
saveDeployment(deployment);
|
|
20
|
-
|
|
21
|
-
printUpgradeFactoryCommand(deployment);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Script.sol";
|
|
5
|
-
|
|
6
|
-
import {ProxyDeployerScript, DeterministicContractConfig, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
7
|
-
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
|
|
8
|
-
import {ZoraFactoryImpl} from "../ZoraFactoryImpl.sol";
|
|
9
|
-
import {IVersionedContract} from "@zoralabs/shared-contracts/interfaces/IVersionedContract.sol";
|
|
10
|
-
// import {BuySupplyWithSwapRouterHook} from "../hooks/deployment/BuySupplyWithSwapRouterHook.sol";
|
|
11
|
-
import {IZoraFactory} from "../interfaces/IZoraFactory.sol";
|
|
12
|
-
import {ContentCoin} from "../ContentCoin.sol";
|
|
13
|
-
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
|
|
14
|
-
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
|
|
15
|
-
import {ZoraFactory} from "../proxy/ZoraFactory.sol";
|
|
16
|
-
import {HooksDeployment} from "../libs/HooksDeployment.sol";
|
|
17
|
-
import {ProxyShim} from "../../test/utils/ProxyShim.sol";
|
|
18
|
-
import {CreatorCoin} from "../CreatorCoin.sol";
|
|
19
|
-
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
20
|
-
import {HookUpgradeGate} from "../hooks/HookUpgradeGate.sol";
|
|
21
|
-
import {BuySupplyWithV4SwapHook} from "../hooks/deployment/BuySupplyWithV4SwapHook.sol";
|
|
22
|
-
|
|
23
|
-
contract CoinsDeployerBase is ProxyDeployerScript {
|
|
24
|
-
address internal constant PROTOCOL_REWARDS = 0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B;
|
|
25
|
-
address internal constant ZORA = 0x1111111111166b7FE7bd91427724B487980aFc69;
|
|
26
|
-
|
|
27
|
-
using stdJson for string;
|
|
28
|
-
|
|
29
|
-
struct CoinsDeployment {
|
|
30
|
-
// Factory
|
|
31
|
-
address zoraFactory;
|
|
32
|
-
address zoraFactoryImpl;
|
|
33
|
-
// Implementation
|
|
34
|
-
address coinV3Impl;
|
|
35
|
-
address coinV4Impl;
|
|
36
|
-
address creatorCoinImpl;
|
|
37
|
-
string coinVersion;
|
|
38
|
-
// hooks
|
|
39
|
-
address buySupplyWithSwapRouterHook;
|
|
40
|
-
address zoraV4CoinHook;
|
|
41
|
-
address hookUpgradeGate;
|
|
42
|
-
// Hook deployment salt (for deterministic deployment)
|
|
43
|
-
bytes32 zoraV4CoinHookSalt;
|
|
44
|
-
bool isDev;
|
|
45
|
-
// Hook registry
|
|
46
|
-
address zoraHookRegistry;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function addressesFile() internal view returns (string memory) {
|
|
50
|
-
return addressesFile(false);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function addressesFile(bool dev) internal view returns (string memory) {
|
|
54
|
-
if (dev) {
|
|
55
|
-
return string.concat("./addresses/dev/", vm.toString(block.chainid), ".json");
|
|
56
|
-
}
|
|
57
|
-
return string.concat("./addresses/", vm.toString(block.chainid), ".json");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function saveDeployment(CoinsDeployment memory deployment) internal {
|
|
61
|
-
string memory objectKey = "config";
|
|
62
|
-
|
|
63
|
-
vm.serializeAddress(objectKey, "ZORA_FACTORY", deployment.zoraFactory);
|
|
64
|
-
vm.serializeAddress(objectKey, "ZORA_FACTORY_IMPL", deployment.zoraFactoryImpl);
|
|
65
|
-
vm.serializeString(objectKey, "COIN_VERSION", deployment.coinVersion);
|
|
66
|
-
vm.serializeAddress(objectKey, "BUY_SUPPLY_WITH_SWAP_ROUTER_HOOK", deployment.buySupplyWithSwapRouterHook);
|
|
67
|
-
vm.serializeAddress(objectKey, "COIN_V3_IMPL", deployment.coinV3Impl);
|
|
68
|
-
vm.serializeAddress(objectKey, "ZORA_V4_COIN_HOOK", deployment.zoraV4CoinHook);
|
|
69
|
-
vm.serializeBytes32(objectKey, "ZORA_V4_COIN_HOOK_SALT", deployment.zoraV4CoinHookSalt);
|
|
70
|
-
vm.serializeAddress(objectKey, "CREATOR_COIN_IMPL", deployment.creatorCoinImpl);
|
|
71
|
-
vm.serializeAddress(objectKey, "HOOK_UPGRADE_GATE", deployment.hookUpgradeGate);
|
|
72
|
-
vm.serializeAddress(objectKey, "ZORA_HOOK_REGISTRY", deployment.zoraHookRegistry);
|
|
73
|
-
string memory result = vm.serializeAddress(objectKey, "COIN_V4_IMPL", deployment.coinV4Impl);
|
|
74
|
-
|
|
75
|
-
vm.writeJson(result, addressesFile(deployment.isDev));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function readDeployment() internal returns (CoinsDeployment memory deployment) {
|
|
79
|
-
return readDeployment(false);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function readDeployment(bool dev) internal returns (CoinsDeployment memory deployment) {
|
|
83
|
-
string memory file = addressesFile(dev);
|
|
84
|
-
deployment.isDev = dev;
|
|
85
|
-
if (!vm.exists(file)) {
|
|
86
|
-
return deployment;
|
|
87
|
-
}
|
|
88
|
-
string memory json = vm.readFile(file);
|
|
89
|
-
|
|
90
|
-
deployment.zoraFactory = readAddressOrDefaultToZero(json, "ZORA_FACTORY");
|
|
91
|
-
deployment.zoraFactoryImpl = readAddressOrDefaultToZero(json, "ZORA_FACTORY_IMPL");
|
|
92
|
-
deployment.coinV3Impl = readAddressOrDefaultToZero(json, "COIN_V3_IMPL");
|
|
93
|
-
deployment.coinV4Impl = readAddressOrDefaultToZero(json, "COIN_V4_IMPL");
|
|
94
|
-
deployment.coinVersion = readStringOrDefaultToEmpty(json, "COIN_VERSION");
|
|
95
|
-
deployment.buySupplyWithSwapRouterHook = readAddressOrDefaultToZero(json, "BUY_SUPPLY_WITH_SWAP_ROUTER_HOOK");
|
|
96
|
-
deployment.zoraV4CoinHook = readAddressOrDefaultToZero(json, "ZORA_V4_COIN_HOOK");
|
|
97
|
-
deployment.zoraV4CoinHookSalt = readBytes32OrDefaultToZero(json, "ZORA_V4_COIN_HOOK_SALT");
|
|
98
|
-
deployment.creatorCoinImpl = readAddressOrDefaultToZero(json, "CREATOR_COIN_IMPL");
|
|
99
|
-
deployment.hookUpgradeGate = readAddressOrDefaultToZero(json, "HOOK_UPGRADE_GATE");
|
|
100
|
-
deployment.zoraHookRegistry = readAddressOrDefaultToZero(json, "ZORA_HOOK_REGISTRY");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function deployCoinV4Impl() internal returns (ContentCoin) {
|
|
104
|
-
return
|
|
105
|
-
new ContentCoin({
|
|
106
|
-
protocolRewardRecipient_: getZoraRecipient(),
|
|
107
|
-
protocolRewards_: PROTOCOL_REWARDS,
|
|
108
|
-
poolManager_: IPoolManager(getUniswapV4PoolManager()),
|
|
109
|
-
airlock_: getDopplerAirlock()
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function deployCreatorCoinImpl() internal returns (CreatorCoin) {
|
|
114
|
-
return
|
|
115
|
-
new CreatorCoin({
|
|
116
|
-
protocolRewardRecipient_: getZoraRecipient(),
|
|
117
|
-
protocolRewards_: PROTOCOL_REWARDS,
|
|
118
|
-
poolManager_: IPoolManager(getUniswapV4PoolManager()),
|
|
119
|
-
airlock_: getDopplerAirlock()
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function deployZoraFactoryImpl(address coinV4Impl_, address creatorCoinImpl_, address hook_, address zoraHookRegistry_) internal returns (ZoraFactoryImpl) {
|
|
124
|
-
return new ZoraFactoryImpl({coinV4Impl_: coinV4Impl_, creatorCoinImpl_: creatorCoinImpl_, hook_: hook_, zoraHookRegistry_: zoraHookRegistry_});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function deployBuySupplyWithV4SwapHook(CoinsDeployment memory deployment) internal returns (BuySupplyWithV4SwapHook) {
|
|
128
|
-
return
|
|
129
|
-
new BuySupplyWithV4SwapHook({
|
|
130
|
-
_factory: IZoraFactory(deployment.zoraFactory),
|
|
131
|
-
_swapRouter: getUniswapSwapRouter(),
|
|
132
|
-
_poolManager: getUniswapV4PoolManager()
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function deployUpgradeGate(CoinsDeployment memory deployment) internal returns (CoinsDeployment memory) {
|
|
137
|
-
deployment.hookUpgradeGate = address(new HookUpgradeGate(getProxyAdmin()));
|
|
138
|
-
|
|
139
|
-
return deployment;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function deployZoraV4CoinHook(CoinsDeployment memory deployment) internal returns (IHooks hook, bytes32 salt) {
|
|
143
|
-
return
|
|
144
|
-
HooksDeployment.deployHookWithExistingOrNewSalt(
|
|
145
|
-
HooksDeployment.FOUNDRY_SCRIPT_ADDRESS,
|
|
146
|
-
HooksDeployment.makeHookCreationCode(
|
|
147
|
-
getUniswapV4PoolManager(),
|
|
148
|
-
deployment.zoraFactory,
|
|
149
|
-
getDefaultTrustedMessageSenders(),
|
|
150
|
-
deployment.hookUpgradeGate
|
|
151
|
-
),
|
|
152
|
-
deployment.zoraV4CoinHookSalt
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function getDefaultTrustedMessageSenders() internal view returns (address[] memory) {
|
|
157
|
-
address[] memory trustedMessageSenders = new address[](2);
|
|
158
|
-
trustedMessageSenders[0] = getUniswapUniversalRouter();
|
|
159
|
-
trustedMessageSenders[1] = getUniswapV4PositionManager();
|
|
160
|
-
return trustedMessageSenders;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function deployFactoryImpl(CoinsDeployment memory deployment) internal returns (address) {
|
|
164
|
-
return
|
|
165
|
-
address(
|
|
166
|
-
deployZoraFactoryImpl({
|
|
167
|
-
coinV4Impl_: deployment.coinV4Impl,
|
|
168
|
-
creatorCoinImpl_: deployment.creatorCoinImpl,
|
|
169
|
-
hook_: deployment.zoraV4CoinHook,
|
|
170
|
-
zoraHookRegistry_: deployment.zoraHookRegistry
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function deployImpls(CoinsDeployment memory deployment) internal returns (CoinsDeployment memory) {
|
|
176
|
-
// Deploy implementation contracts
|
|
177
|
-
|
|
178
|
-
// Deploy hook first, then use its address for coin v4 impl
|
|
179
|
-
console.log("deploying content coin hook");
|
|
180
|
-
(IHooks zoraV4CoinHook, bytes32 usedSalt) = deployZoraV4CoinHook(deployment);
|
|
181
|
-
deployment.zoraV4CoinHook = address(zoraV4CoinHook);
|
|
182
|
-
deployment.zoraV4CoinHookSalt = usedSalt;
|
|
183
|
-
|
|
184
|
-
deployment.coinV4Impl = address(deployCoinV4Impl());
|
|
185
|
-
deployment.creatorCoinImpl = address(deployCreatorCoinImpl());
|
|
186
|
-
deployment.zoraFactoryImpl = deployFactoryImpl(deployment);
|
|
187
|
-
deployment.coinVersion = IVersionedContract(deployment.coinV4Impl).contractVersion();
|
|
188
|
-
// deployment.buySupplyWithSwapRouterHook = address(deployBuySupplyWithSwapRouterHook(deployment));
|
|
189
|
-
|
|
190
|
-
return deployment;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function deployHooks(CoinsDeployment memory deployment) internal returns (CoinsDeployment memory) {
|
|
194
|
-
// Deploy hook first, then use its address for coin v4 impl
|
|
195
|
-
(IHooks zoraV4CoinHook, bytes32 usedSalt) = deployZoraV4CoinHook(deployment);
|
|
196
|
-
deployment.zoraV4CoinHook = address(zoraV4CoinHook);
|
|
197
|
-
deployment.zoraV4CoinHookSalt = usedSalt;
|
|
198
|
-
|
|
199
|
-
deployment.zoraFactoryImpl = deployFactoryImpl(deployment);
|
|
200
|
-
|
|
201
|
-
return deployment;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function deployZoraDeterministic(CoinsDeployment memory deployment, DeterministicDeployerAndCaller deployer) internal {
|
|
205
|
-
// read previously saved deterministic config
|
|
206
|
-
DeterministicContractConfig memory zoraConfig = readDeterministicContractConfig("zoraFactory");
|
|
207
|
-
|
|
208
|
-
deployment = deployImpls(deployment);
|
|
209
|
-
|
|
210
|
-
if (deployment.zoraFactoryImpl.code.length == 0) {
|
|
211
|
-
revert("Factory Impl not yet deployed. Make sure to deploy it with DeployImpl.s.sol");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// build upgrade to and call for factory, with init call
|
|
215
|
-
bytes memory upgradeToAndCall = abi.encodeWithSelector(
|
|
216
|
-
UUPSUpgradeable.upgradeToAndCall.selector,
|
|
217
|
-
deployment.zoraFactoryImpl,
|
|
218
|
-
abi.encodeWithSelector(ZoraFactoryImpl.initialize.selector, getProxyAdmin())
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
// sign deployment with turnkey account
|
|
222
|
-
bytes memory signature = signDeploymentWithTurnkey(zoraConfig, upgradeToAndCall, deployer);
|
|
223
|
-
|
|
224
|
-
printVerificationCommand(zoraConfig);
|
|
225
|
-
|
|
226
|
-
deployment.zoraFactory = deployer.permitSafeCreate2AndCall(
|
|
227
|
-
signature,
|
|
228
|
-
zoraConfig.salt,
|
|
229
|
-
zoraConfig.creationCode,
|
|
230
|
-
upgradeToAndCall,
|
|
231
|
-
zoraConfig.deployedAddress
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// validate that the zora factory owner is the proxy admin
|
|
235
|
-
require(ZoraFactoryImpl(deployment.zoraFactory).owner() == getProxyAdmin(), "Zora factory owner is not the proxy admin");
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function deployDevFactory(CoinsDeployment memory deployment) internal returns (ZoraFactory devFactory) {
|
|
239
|
-
address owner = 0x63545B401283c993320A5b886ecF0fc6CB5668a9;
|
|
240
|
-
|
|
241
|
-
ProxyShim shim = new ProxyShim();
|
|
242
|
-
|
|
243
|
-
deployment.zoraFactory = address(new ZoraFactory(address(shim)));
|
|
244
|
-
|
|
245
|
-
deployment = deployImpls(deployment);
|
|
246
|
-
|
|
247
|
-
UUPSUpgradeable(deployment.zoraFactory).upgradeToAndCall(deployment.zoraFactoryImpl, "");
|
|
248
|
-
|
|
249
|
-
ZoraFactoryImpl(deployment.zoraFactory).initialize(owner);
|
|
250
|
-
|
|
251
|
-
saveDeployment(deployment);
|
|
252
|
-
|
|
253
|
-
return ZoraFactory(payable(deployment.zoraFactory));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function printUpgradeFactoryCommand(CoinsDeployment memory deployment) internal view {
|
|
257
|
-
// build upgrade to and call for factory, with init call
|
|
258
|
-
bytes memory call = abi.encodeWithSelector(UUPSUpgradeable.upgradeToAndCall.selector, deployment.zoraFactoryImpl, "");
|
|
259
|
-
|
|
260
|
-
address proxyAdmin = getProxyAdmin();
|
|
261
|
-
|
|
262
|
-
address target = address(deployment.zoraFactory);
|
|
263
|
-
|
|
264
|
-
// print the details for upgrading:
|
|
265
|
-
|
|
266
|
-
console.log("To upgrade the factory, this is the call information:");
|
|
267
|
-
|
|
268
|
-
console.log("Multisig:", proxyAdmin);
|
|
269
|
-
console.log("Target (the factory proxy):", target);
|
|
270
|
-
console.log("Upgrade call:");
|
|
271
|
-
console.logBytes(call);
|
|
272
|
-
console.log("Function to call: upgradeToAndCall");
|
|
273
|
-
// concat the args into a string, factoryImpl, ""
|
|
274
|
-
console.log("Args: ", string.concat(vm.toString(deployment.zoraFactoryImpl), ",", '"'));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
File without changes
|