120 lines
4.2 KiB
Solidity
120 lines
4.2 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.30;
|
|
|
|
import "../test/Deploy.sol";
|
|
import "../src/IPartyPool.sol";
|
|
import "../src/PartyPlanner.sol";
|
|
import "../src/PartyPool.sol";
|
|
import "../test/MockERC20.sol";
|
|
import "@abdk/ABDKMath64x64.sol";
|
|
import "forge-std/Script.sol";
|
|
import "forge-std/console2.sol";
|
|
|
|
contract DeployMock is Script {
|
|
|
|
address constant public DEV_ACCOUNT_0 = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
|
|
// private key 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356
|
|
address constant public DEV_ACCOUNT_7 = 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 = Deploy.newPartyPlanner();
|
|
|
|
// 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 newPool signature on factory which will take the deposits and mint initial LP
|
|
(IPartyPool pool, ) = planner.newPool(
|
|
name,
|
|
symbol,
|
|
tokens,
|
|
_bases,
|
|
_tradeFrac,
|
|
_targetSlippage,
|
|
_feePpm,
|
|
_feePpm,
|
|
false,
|
|
msg.sender, // payer: this script
|
|
DEV_ACCOUNT_7, // receiver of initial LP
|
|
initialDeposits,
|
|
initialLpAmount,
|
|
deadline
|
|
);
|
|
|
|
// give _tokens to dev7 for later use
|
|
mintAll(DEV_ACCOUNT_7, 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');
|
|
|
|
PartyPoolViewer viewer = Deploy.newViewer();
|
|
|
|
console2.log();
|
|
console2.log(' PartyPlanner', address(planner));
|
|
console2.log(' PartyPool', address(pool));
|
|
console2.log('PartyPoolViewer', address(viewer));
|
|
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);
|
|
}
|
|
|
|
}
|