MiniDexPair 合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract MiniDexPair is ReentrancyGuard { address public immutable tokenA; address public immutable tokenB; uint256 public reserveA; uint256 public reserveB; uint256 public totalLPSupply; mapping(address => uint256) public lpBalances; event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint...
MiniDexPair 合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract MiniDexPair is ReentrancyGuard { address public immutable tokenA; address public immutable tokenB; uint256 public reserveA; uint256 public reserveB; uint256 public totalLPSupply; mapping(address => uint256) public lpBalances; event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint...
SimpleStablecoin 合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; co...
SimpleStablecoin 合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; co...
去中心化治理系统(Decentralized Governance System)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; co...
去中心化治理系统(Decentralized Governance System)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; co...
收益农场(Yield Farming)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; // For SafeCast if needed // Interface for fetching ERC-20 metadata (decimals) interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns ...
收益农场(Yield Farming)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; // For SafeCast if needed // Interface for fetching ERC-20 metadata (decimals) interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns ...
自动化做市商(Automated Market Maker)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /// @title Automated Market Maker with Liquidity Token contract AutomatedMarketMaker is ERC20 { IERC20 public tokenA; IERC20 public tokenB; uint256 public reserveA; uint256 public reserveB; address public owner; event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint256 liquidity); event LiquidityRemoved(address indexed provider, uint256 amountA, uint2...
自动化做市商(Automated Market Maker)合约学习笔记
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /// @title Automated Market Maker with Liquidity Token contract AutomatedMarketMaker is ERC20 { IERC20 public tokenA; IERC20 public tokenB; uint256 public reserveA; uint256 public reserveB; address public owner; event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint256 liquidity); event LiquidityRemoved(address indexed provider, uint256 amountA, uint2...