@zoralabs/coins 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$js.log +116 -124
- package/CHANGELOG.md +6 -0
- package/abis/Address.json +0 -16
- package/abis/BuySupplyWithSwapRouterHook.json +0 -27
- package/abis/BuySupplyWithV4SwapHook.json +0 -32
- package/abis/Clones.json +1 -1
- package/abis/CoinDopplerMultiCurve.json +109 -0
- package/abis/Create2.json +0 -21
- package/abis/ERC1967Proxy.json +1 -1
- package/abis/ERC1967Utils.json +0 -45
- package/abis/{UpgradeCoinImpl.json → Errors.json} +14 -10
- package/abis/{MockERC20.json → IERC1363.json} +134 -104
- package/abis/IERC1967.json +47 -0
- package/abis/IERC20.json +0 -36
- package/abis/IProtocolRewards.json +0 -258
- package/abis/{Script.json → ISupportsLimitOrderFill.json} +2 -2
- package/abis/IZoraLimitOrderBookCoinsInterface.json +67 -0
- package/abis/IZoraV4CoinHook.json +10 -0
- package/abis/ProxyShim.json +15 -16
- package/abis/SafeCast.json +51 -0
- package/abis/{AddressConstants.json → SafeCast160.json} +1 -1
- package/abis/Strings.json +10 -0
- package/abis/UUPSUpgradeable.json +1 -1
- package/abis/V3ToV4SwapLib.json +28 -0
- package/abis/ZoraFactory.json +1 -1
- package/abis/ZoraFactoryImpl.json +22 -6
- package/abis/ZoraV4CoinHook.json +20 -48
- package/dist/index.cjs +950 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +948 -41
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +1459 -76
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/wagmiGenerated.ts +951 -44
- package/package.json +9 -9
- package/remappings.txt +2 -1
- package/src/ZoraFactoryImpl.sol +8 -0
- package/src/deployment/ForkedCoinsAddresses.sol +54 -0
- package/src/hooks/ZoraV4CoinHook.sol +74 -20
- package/src/hooks/deployment/BuySupplyWithV4SwapHook.sol +20 -142
- package/src/interfaces/ISupportsLimitOrderFill.sol +11 -0
- package/src/interfaces/IZoraLimitOrderBookCoinsInterface.sol +21 -0
- package/src/interfaces/IZoraV4CoinHook.sol +6 -0
- package/src/libs/CoinConstants.sol +6 -0
- package/src/libs/CoinDopplerMultiCurve.sol +1 -1
- package/src/libs/CoinRewardsV4.sol +0 -1
- package/src/libs/HooksDeployment.sol +20 -8
- package/src/libs/UniV4SwapHelper.sol +35 -0
- package/src/libs/V3ToV4SwapLib.sol +261 -0
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/BuySupplyWithV4SwapHook.t.sol +4 -3
- package/test/Coin.t.sol +7 -1
- package/test/CoinUniV4.t.sol +2 -1
- package/test/ContentCoinRewards.t.sol +5 -1
- package/test/CreatorCoin.t.sol +3 -1
- package/test/CreatorCoinRewards.t.sol +3 -1
- package/test/Factory.t.sol +20 -7
- package/test/HooksDeployment.t.sol +16 -3
- package/test/LiquidityMigration.t.sol +52 -44
- package/test/MultiOwnable.t.sol +2 -1
- package/test/Upgrades.t.sol +110 -81
- package/test/V4Liquidity.t.sol +1 -1
- package/test/mocks/MockSwapRouter.sol +33 -0
- package/test/mocks/MockZoraLimitOrderBook.sol +14 -0
- package/test/utils/BaseTest.sol +14 -448
- package/test/utils/FeeEstimatorHook.sol +6 -2
- package/test/utils/V4TestSetup.sol +595 -0
- package/wagmi.config.ts +1 -1
- package/abis/BaseTest.json +0 -718
- package/abis/DeterministicDeployerAndCaller.json +0 -315
- package/abis/DeterministicUUPSProxyDeployer.json +0 -167
- package/abis/EIP712.json +0 -67
- package/abis/ERC20.json +0 -310
- package/abis/FeeEstimatorHook.json +0 -1938
- package/abis/IERC721.json +0 -287
- package/abis/IERC721Enumerable.json +0 -343
- package/abis/IERC721Metadata.json +0 -332
- package/abis/IERC721TokenReceiver.json +0 -36
- package/abis/IImmutableCreate2Factory.json +0 -93
- package/abis/IMulticall3.json +0 -440
- package/abis/ISafe.json +0 -15
- package/abis/ISymbol.json +0 -15
- package/abis/IUniswapV4Router04.json +0 -484
- package/abis/IUniversalRouter.json +0 -61
- package/abis/IV4Quoter.json +0 -310
- package/abis/ImmutableCreate2FactoryUtils.json +0 -15
- package/abis/LibString.json +0 -7
- package/abis/Math.json +0 -7
- package/abis/MockAirlock.json +0 -39
- package/abis/MockERC721.json +0 -350
- package/abis/ProtocolRewards.json +0 -494
- package/abis/ShortStrings.json +0 -18
- package/abis/SimpleERC20.json +0 -326
- package/abis/StdAssertions.json +0 -379
- package/abis/StdInvariant.json +0 -180
- package/abis/Test.json +0 -570
- package/abis/VmContractHelper235.json +0 -233
- package/abis/VmContractHelper242.json +0 -233
- package/abis/stdError.json +0 -119
- package/abis/stdStorageSafe.json +0 -52
- package/addresses/8453.json +0 -13
- package/addresses/84532.json +0 -10
- package/deterministicConfig/deployerAndCaller.json +0 -5
- package/deterministicConfig/zoraFactory.json +0 -8
- package/script/Deploy.s.sol +0 -23
- package/script/DeployAutoSwapper.s.sol +0 -30
- package/script/DeployDevFactory.s.sol +0 -21
- package/script/DeployPostDeploymentHooks.s.sol +0 -20
- package/script/DeployTrustedMsgSenderLookup.s.sol +0 -20
- package/script/DeployUpgradeGate.s.sol +0 -21
- package/script/GenerateDeterministicParams.s.sol +0 -43
- package/script/PrintRegisterUpgradePath.s.sol +0 -28
- package/script/PrintUpgradeCommand.s.sol +0 -13
- package/script/TestBackingCoinSwap.s.sol +0 -144
- package/script/TestV4Swap.s.sol +0 -133
- package/script/UpgradeCoinImpl.sol +0 -23
- package/script/UpgradeFactoryImpl.s.sol +0 -28
- package/script/UpgradeHooks.s.sol +0 -23
- package/src/deployment/CoinsDeployerBase.sol +0 -297
- /package/{test → src}/utils/ProxyShim.sol +0 -0
package/script/Deploy.s.sol
DELETED
|
@@ -1,23 +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
|
-
contract DeployScript is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
// get deployer contract
|
|
14
|
-
DeterministicDeployerAndCaller deployer = createOrGetDeployerAndCaller();
|
|
15
|
-
|
|
16
|
-
deployZoraDeterministic(deployment, deployer);
|
|
17
|
-
|
|
18
|
-
vm.stopBroadcast();
|
|
19
|
-
|
|
20
|
-
// save the deployment json
|
|
21
|
-
saveDeployment(deployment);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.28;
|
|
4
|
-
|
|
5
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
6
|
-
import {AutoSwapper} from "../src/utils/AutoSwapper.sol";
|
|
7
|
-
import {ISwapRouter} from "@zoralabs/shared-contracts/interfaces/uniswap/ISwapRouter.sol";
|
|
8
|
-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
9
|
-
|
|
10
|
-
import "forge-std/console.sol";
|
|
11
|
-
|
|
12
|
-
contract Deploy is CoinsDeployerBase {
|
|
13
|
-
function run() public {
|
|
14
|
-
address swapper = vm.envAddress("SWAPPER");
|
|
15
|
-
|
|
16
|
-
vm.startBroadcast();
|
|
17
|
-
|
|
18
|
-
AutoSwapper autoSwapper = new AutoSwapper(ISwapRouter(getUniswapSwapRouter()), getZoraRecipient(), swapper);
|
|
19
|
-
|
|
20
|
-
vm.stopBroadcast();
|
|
21
|
-
|
|
22
|
-
console.log("multisig:", autoSwapper.swapRecipient());
|
|
23
|
-
|
|
24
|
-
console.log("target:", address(autoSwapper));
|
|
25
|
-
|
|
26
|
-
console.log("approval call:");
|
|
27
|
-
bytes memory call = abi.encodeWithSelector(IERC20.approve.selector, address(autoSwapper), type(uint256).max);
|
|
28
|
-
console.logBytes(call);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,21 +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
|
-
contract DeployScript is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment(true);
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
// get deployer contract
|
|
14
|
-
deployDevFactory(deployment);
|
|
15
|
-
|
|
16
|
-
vm.stopBroadcast();
|
|
17
|
-
|
|
18
|
-
// save the deployment json
|
|
19
|
-
saveDeployment(deployment);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,20 +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 DeployHooks is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
deployment.buySupplyWithSwapRouterHook = address(deployBuySupplyWithV4SwapHook(deployment));
|
|
14
|
-
|
|
15
|
-
vm.stopBroadcast();
|
|
16
|
-
|
|
17
|
-
// save the deployment json
|
|
18
|
-
saveDeployment(deployment);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import {CoinsDeployerBase} from "../src/deployment/CoinsDeployerBase.sol";
|
|
5
|
-
|
|
6
|
-
contract DeployTrustedMsgSenderLookup is CoinsDeployerBase {
|
|
7
|
-
function run() public {
|
|
8
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
9
|
-
|
|
10
|
-
vm.startBroadcast();
|
|
11
|
-
|
|
12
|
-
// Deploy the trusted message sender lookup contract
|
|
13
|
-
deployment = deployTrustedMsgSenderLookup(deployment);
|
|
14
|
-
|
|
15
|
-
vm.stopBroadcast();
|
|
16
|
-
|
|
17
|
-
// Save the updated deployment json
|
|
18
|
-
saveDeployment(deployment);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,21 +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
|
-
contract DeployScript is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment(false);
|
|
10
|
-
|
|
11
|
-
vm.startBroadcast();
|
|
12
|
-
|
|
13
|
-
// get deployer contract
|
|
14
|
-
deployment = deployUpgradeGate(deployment);
|
|
15
|
-
|
|
16
|
-
vm.stopBroadcast();
|
|
17
|
-
|
|
18
|
-
// save the deployment json
|
|
19
|
-
saveDeployment(deployment);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.28;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Script.sol";
|
|
5
|
-
|
|
6
|
-
import {ImmutableCreate2FactoryUtils} from "@zoralabs/shared-contracts/utils/ImmutableCreate2FactoryUtils.sol";
|
|
7
|
-
import {ProxyDeployerScript, DeterministicDeployerAndCaller, DeterministicContractConfig} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
|
|
8
|
-
import {ZoraFactory} from "../src/proxy/ZoraFactory.sol";
|
|
9
|
-
|
|
10
|
-
contract GenerateDeterministicParams is ProxyDeployerScript {
|
|
11
|
-
function mineForZoraAddress(DeterministicDeployerAndCaller deployer, address caller) private returns (DeterministicContractConfig memory config) {
|
|
12
|
-
// get proxy creation code
|
|
13
|
-
bytes memory initCode = deployer.proxyCreationCode(type(ZoraFactory).creationCode);
|
|
14
|
-
bytes32 initCodeHash = keccak256(initCode);
|
|
15
|
-
|
|
16
|
-
// uupsProxyDeployer is deployer
|
|
17
|
-
(bytes32 salt, address expectedAddress) = mineSalt(address(deployer), initCodeHash, "7777777", caller);
|
|
18
|
-
|
|
19
|
-
console2.log("salt");
|
|
20
|
-
console2.log(vm.toString(salt));
|
|
21
|
-
|
|
22
|
-
config.salt = salt;
|
|
23
|
-
config.deployedAddress = expectedAddress;
|
|
24
|
-
config.creationCode = initCode;
|
|
25
|
-
config.constructorArgs = deployer.proxyConstructorArgs();
|
|
26
|
-
config.contractName = "Zora";
|
|
27
|
-
config.deploymentCaller = caller;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function run() public {
|
|
31
|
-
address caller = vm.envAddress("DEPLOYER");
|
|
32
|
-
|
|
33
|
-
vm.startBroadcast();
|
|
34
|
-
|
|
35
|
-
// create a proxy deployer, which we can use to generate deterministic addresses and corresponding params
|
|
36
|
-
DeterministicDeployerAndCaller deployer = createOrGetDeployerAndCaller();
|
|
37
|
-
|
|
38
|
-
vm.stopBroadcast();
|
|
39
|
-
|
|
40
|
-
DeterministicContractConfig memory zoraConfig = mineForZoraAddress(deployer, caller);
|
|
41
|
-
saveDeterministicContractConfig(zoraConfig, "zoraFactory");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,28 +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
|
-
import {IHooksUpgradeGate} from "../src/interfaces/IHooksUpgradeGate.sol";
|
|
7
|
-
|
|
8
|
-
import {console} from "forge-std/console.sol";
|
|
9
|
-
|
|
10
|
-
contract DeployScript is CoinsDeployerBase {
|
|
11
|
-
function run() public {
|
|
12
|
-
CoinsDeployment memory deployment = readDeployment(false);
|
|
13
|
-
|
|
14
|
-
address existingContentCoinHook = 0xd3D133469ADC85e01A4887404D8AC12d630e9040;
|
|
15
|
-
|
|
16
|
-
address[] memory baseImpls = new address[](1);
|
|
17
|
-
baseImpls[0] = existingContentCoinHook;
|
|
18
|
-
|
|
19
|
-
bytes memory contentCoinUpgradeCall = abi.encodeWithSelector(IHooksUpgradeGate.registerUpgradePath.selector, baseImpls, deployment.zoraV4CoinHook);
|
|
20
|
-
|
|
21
|
-
printUpgradeFactoryCommand(deployment);
|
|
22
|
-
|
|
23
|
-
console.log("register upgrade gate target", deployment.hookUpgradeGate);
|
|
24
|
-
|
|
25
|
-
console.log("contentCoinUpgradeCall");
|
|
26
|
-
console.logBytes(contentCoinUpgradeCall);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,13 +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 PrintUpgradeCommand is CoinsDeployerBase {
|
|
8
|
-
function run() public {
|
|
9
|
-
CoinsDeployment memory deployment = readDeployment();
|
|
10
|
-
|
|
11
|
-
printUpgradeFactoryCommand(deployment);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -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
|
-
}
|