文件 8 的 8:MemeCoin.sol
pragma solidity ^0.8.25;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
contract MemeCoinManager {
MemeCoin public memeCoin;
address public uniswapRouterAddress = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
address public uniswapFactoryAddress = 0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6;
address constant WETH_ADDRESS = 0x4200000000000000000000000000000000000006;
address public pair;
uint256 public initialLiq;
IUniswapV2Router02 private uniswapRouter;
IUniswapV2Factory private uniswapFactory;
address immutable public initiator;
constructor() payable {
initiator = msg.sender;
memeCoin = new MemeCoin(address(this), 100000000 * 1e18);
uniswapRouter = IUniswapV2Router02(uniswapRouterAddress);
uniswapFactory = IUniswapV2Factory(uniswapFactoryAddress);
memeCoin.approve(address(uniswapRouter), memeCoin.totalSupply());
uniswapRouter.addLiquidityETH{ value: address(this).balance }(
address(memeCoin),
memeCoin.balanceOf(address(this)),
0,
0,
address(this),
block.timestamp + 5 minutes
);
pair = uniswapFactory.getPair(address(memeCoin), WETH_ADDRESS);
initialLiq = IERC20(pair).balanceOf(address(this));
}
}
contract MemeCoin is ERC20 {
uint256 public maxWalletToken;
uint256 public unlockTime;
constructor(address manager, uint256 initialSupply) ERC20("TeteroAguapnelaconLeche", "TAL") {
unlockTime = block.timestamp + 3 days;
maxWalletToken = (initialSupply * 3) / 100;
_mint(manager, (initialSupply * 9975)/10000);
_mint(0x3C59562c0F0DC46e4e5A95f5569E794628a562BF, (initialSupply * 25) / 10000);
}
function _transfer(address sender, address recipient, uint256 amount) internal override {
if (block.timestamp > unlockTime) {
require(balanceOf(recipient) + amount <= maxWalletToken, "Transfer would exceed the 3% wallet token limit");
}
super._transfer(sender, recipient, amount);
}
}
{
"compilationTarget": {
"contracts/MemeCoin.sol": "MemeCoin"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@aave/core-v3/=../lib/aave-v3-core/",
":@aave/periphery-v3/=../lib/aave-v3-periphery/",
":@chainlink/contracts/=../lib/chainlink-contracts/contracts/",
":@devforu/=../lib/devforu-contracts/",
":@layerzerolabs/solidity-examples/contracts/=../lib/layerzerolabs-solidity-examples/contracts/",
":@mimic-fi/v2-helpers/=../lib/mimic-fi-v2/packages/helpers/contracts/",
":@mimic-fi/v2-smart-vaults-base/=../lib/mimic-fi-v2/packages/smart-vault/contracts/",
":@mimic-fi/v3-helpers/=../lib/mimic-fi-v3/packages/helpers/contracts/",
":@openzeppelin-4.7.3/=../lib/@openzeppelin-4.7.3/",
":@openzeppelin/=../lib/@openzeppelin-4.7.3/",
":@synthetixio/core-contracts/=../lib/synthetixio-core-contracts/contracts/",
":@uniswap/v2-core/=../lib/uniswap-v2-core/",
":@uniswap/v2-periphery/=../lib/uniswap-v2-periphery/",
":@uniswap/v3-core/=../lib/uniswap-v3-core/",
":@uniswap/v3-periphery/=../lib/uniswap-v3-periphery/",
":aave-v3-core/=../lib/aave-v3-core/",
":aave-v3-periphery/=../lib/aave-v3-periphery/contracts/",
":chainlink-contracts/=../lib/chainlink-contracts/",
":devforu-contracts/=../lib/devforu-contracts/",
":ds-test/=/usr/src/app/lib/forge-std/lib/ds-test/src/",
":forge-std/=../lib/forge-std/src/",
":layerzerolabs-solidity-examples/=../lib/layerzerolabs-solidity-examples/contracts/",
":mimic-fi-v2/=../lib/mimic-fi-v2/",
":mimic-fi-v3/=../lib/mimic-fi-v3/",
":synthetixio-core-contracts/=../lib/synthetixio-core-contracts/contracts/",
":uniswap-v2-core/=../lib/uniswap-v2-core/contracts/",
":uniswap-v2-periphery/=../lib/uniswap-v2-periphery/contracts/",
":uniswap-v3-core/=../lib/uniswap-v3-core/",
":uniswap-v3-periphery/=../lib/uniswap-v3-periphery/contracts/"
]
}