// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.30; import "forge-std/Script.sol"; import "forge-std/console2.sol"; import "@abdk/ABDKMath64x64.sol"; import "../test/MockERC20.sol"; import "../src/IPartyPool.sol"; import "../src/PartyPool.sol"; import "../src/PartyPlanner.sol"; contract DeployMock is Script { address constant devAccount0 = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; // private key 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 address constant devAccount7 = 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955; function run() public { vm.startBroadcast(); // create mock tokens usxd = new MockERC20('Joke Currency', 'USXD', 6); fusd = new MockERC20('Fake USD', 'FUSD', 6); dive = new MockERC20('DAI Virtually Equal', 'DIVE', 18); string memory name = 'Mock Pool'; string memory symbol = 'MP'; IERC20[] memory tokens = new IERC20[](3); tokens[0] = IERC20(usxd); tokens[1] = IERC20(fusd); tokens[2] = IERC20(dive); uint256[] memory _bases = new uint256[](3); _bases[0] = 10**6; _bases[1] = 10**6; _bases[2] = 10**18; int128 _tradeFrac = ABDKMath64x64.divu(1, 10); int128 _targetSlippage = ABDKMath64x64.divu(1,10000); uint256 _feePpm = 100; // deploy a PartyPlanner factory and create the pool via factory PartyPlanner planner = new PartyPlanner(); // prepare initial deposits (10_000 units of each token, scaled by bases) uint256[] memory initialDeposits = new uint256[](3); initialDeposits[0] = _bases[0] * 10_000; initialDeposits[1] = _bases[1] * 10_000; initialDeposits[2] = _bases[2] * 10_000; uint256 initialLpAmount = 0; uint256 deadline = 0; // mint tokens to the deployer so it can fund the initial deposits and approve the factory mintAll(msg.sender, 10_000); // approve factory to move initial deposits for (uint i = 0; i < tokens.length; i++) { IERC20(tokens[i]).approve(address(planner), initialDeposits[i]); } // call full createPool signature on factory which will take the deposits and mint initial LP (PartyPool pool, uint256 lpAmount) = planner.createPool( name, symbol, tokens, _bases, _tradeFrac, _targetSlippage, _feePpm, _feePpm, false, msg.sender, // payer: this script devAccount7, // receiver of initial LP initialDeposits, initialLpAmount, deadline ); // give tokens to dev7 for later use mintAll(devAccount7, 1_000_000); vm.stopBroadcast(); // Set ENV vars string memory plannerStr = vm.toString(address(planner)); vm.setEnv('PLANNER', plannerStr); vm.setEnv('POOL', vm.toString(address(pool))); vm.setEnv('USXD', vm.toString(address(usxd))); vm.setEnv('FUSD', vm.toString(address(fusd))); vm.setEnv('DIVE', vm.toString(address(dive))); // Write JSON config file string memory config = 'config'; string memory chainConfig = 'chain config'; string memory chainConfigStr = vm.serializeString(chainConfig, 'PartyPlannerV1', plannerStr); string memory configStr = vm.serializeString(config, vm.toString(block.chainid), chainConfigStr); vm.writeJson(configStr, 'chain.json'); console2.log('\nPartyPlanner', address(planner)); console2.log(' PartyPool', address(pool)); console2.log(' USXD', address(usxd)); console2.log(' FUSD', address(fusd)); console2.log(' DIVE', address(dive)); } MockERC20 private usxd; MockERC20 private fusd; MockERC20 private dive; function mintAll(address who, uint256 amount) internal { usxd.mint(who, amount * 1e6); fusd.mint(who, amount * 1e6); dive.mint(who, amount * 1e18); } }