58 lines
2.7 KiB
Solidity
58 lines
2.7 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
import {Vm, VM_ADDRESS} from "../test/Vm.sol";
|
|
import {WIGN} from "../src/WIGN.sol";
|
|
import {TestToken} from "../src/TestToken.sol";
|
|
import {IgneumFactory} from "../src/IgneumPair.sol";
|
|
import {IgneumRouter} from "../src/IgneumRouter.sol";
|
|
|
|
/// Deploys the AMM on Devnet 3 from the key in DEX_DEPLOYER_KEY (read from the environment, never printed), seeds
|
|
/// three pools from the faucet and 200 IGN, and writes the addresses to deploy-out.json for docs/contracts.
|
|
///
|
|
/// forge script script/Deploy.s.sol:Deploy --rpc-url devnet3 --broadcast --sig "run()"
|
|
///
|
|
/// Devnet 3, test tokens, no value.
|
|
contract Deploy {
|
|
Vm constant vm = Vm(VM_ADDRESS);
|
|
|
|
function run() external {
|
|
uint256 key = vm.envUint("DEX_DEPLOYER_KEY");
|
|
address deployer = vm.addr(key);
|
|
vm.startBroadcast(key);
|
|
|
|
WIGN wign = new WIGN();
|
|
TestToken tta = new TestToken("Test Token A", "TTA");
|
|
TestToken ttb = new TestToken("Test Token B", "TTB");
|
|
IgneumFactory factory = new IgneumFactory();
|
|
IgneumRouter router = new IgneumRouter(address(factory), address(wign));
|
|
|
|
tta.drip();
|
|
ttb.drip();
|
|
tta.approve(address(router), type(uint256).max);
|
|
ttb.approve(address(router), type(uint256).max);
|
|
uint256 deadline = block.timestamp + 1 hours;
|
|
router.addLiquidityIGN{value: 100 ether}(address(tta), 500 ether, 0, 0, deployer, deadline);
|
|
router.addLiquidityIGN{value: 100 ether}(address(ttb), 500 ether, 0, 0, deployer, deadline);
|
|
router.addLiquidity(address(tta), address(ttb), 500 ether, 500 ether, 0, 0, deployer, deadline);
|
|
|
|
vm.stopBroadcast();
|
|
|
|
string memory json = "{\n";
|
|
json = _line(json, "WIGN", address(wign), ",");
|
|
json = _line(json, "TTA", address(tta), ",");
|
|
json = _line(json, "TTB", address(ttb), ",");
|
|
json = _line(json, "IgneumFactory", address(factory), ",");
|
|
json = _line(json, "IgneumRouter", address(router), ",");
|
|
json = _line(json, "pair_TTA_WIGN", factory.getPair(address(tta), address(wign)), ",");
|
|
json = _line(json, "pair_TTB_WIGN", factory.getPair(address(ttb), address(wign)), ",");
|
|
json = _line(json, "pair_TTA_TTB", factory.getPair(address(tta), address(ttb)), ",");
|
|
json = _line(json, "deployer", deployer, "");
|
|
json = string.concat(json, "}\n");
|
|
vm.writeFile("deploy-out.json", json);
|
|
}
|
|
|
|
function _line(string memory json, string memory key, address value, string memory comma) private pure returns (string memory) {
|
|
return string.concat(json, " \"", key, "\": \"", vm.toString(value), "\"", comma, "\n");
|
|
}
|
|
}
|