PartyPlanner; chain.json
This commit is contained in:
@@ -7,6 +7,7 @@ import "@abdk/ABDKMath64x64.sol";
|
||||
import "../test/MockERC20.sol";
|
||||
import "../src/IPartyPool.sol";
|
||||
import "../src/PartyPool.sol";
|
||||
import "../src/PartyPlanner.sol";
|
||||
|
||||
contract DeployMock is Script {
|
||||
|
||||
@@ -24,10 +25,10 @@ contract DeployMock is Script {
|
||||
|
||||
string memory name = 'Mock Pool';
|
||||
string memory symbol = 'MP';
|
||||
address[] memory tokens = new address[](3);
|
||||
tokens[0] = address(usxd);
|
||||
tokens[1] = address(fusd);
|
||||
tokens[2] = address(dive);
|
||||
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;
|
||||
@@ -36,21 +37,68 @@ contract DeployMock is Script {
|
||||
int128 _targetSlippage = ABDKMath64x64.divu(1,10000);
|
||||
uint256 _feePpm = 100;
|
||||
|
||||
IPartyPool pool = new PartyPool(name, symbol, tokens, _bases, _tradeFrac, _targetSlippage, _feePpm, _feePpm, false);
|
||||
// deploy a PartyPlanner factory and create the pool via factory
|
||||
PartyPlanner planner = new PartyPlanner();
|
||||
|
||||
// initial mint
|
||||
mintAll(address(pool), 10_000);
|
||||
pool.mint(devAccount7, devAccount7, 0, 0);
|
||||
// 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;
|
||||
|
||||
// give tokens to dev7
|
||||
// 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();
|
||||
|
||||
console2.log('\nPartyPool', address(pool));
|
||||
console2.log(' USXD', address(usxd));
|
||||
console2.log(' FUSD', address(fusd));
|
||||
console2.log(' DIVE', address(dive));
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user