DAPP代币合约流动性质押分红挖矿系统开发丨技术分析

2022-11-07 11:25:50 浏览数 (2)

在开发过程当中,最常用的是浏览器插件钱包。浏览器插件钱包配置简单,插件钱包的安装和使用都很便捷。此外,由于目前大多数区块链应用都是网页的,因此通过浏览器钱包可以轻松访问目前主流的所有 Defi 和 NFT 应用。

部署参数: 例如: name_: (名称) symbol_: (符号) totalSupply_: (发行量) rewardAddr_: 要分红的代币合约,BSC常用代币地址在下方 marketingWalletAddr_: 自己的钱包 serviceAddr_: 0x333336b1f76404693a4bd3885170A0F9a807940F buyFeeSetting_: [4,3,2,1] (分红、流动性、市场营销、燃烧) sellFeeSetting_: [5,4,3,2] (分红、流动性、市场营销、燃烧) tokenBalanceForReward_: 1000000000000000000000000000 (持有多少代币参与分红。数量后要加18个0) 编译/开源参数: COMPILER: v0.8.7 commit.e28d00a7.js Enable optimization: 开启并使用默认值200 Other Settings: default evmVersion, MIT license // SPDX-License-Identifier: MIT pragma solidity ^0.8.6;

interface IUniswapV2Pair {

代码语言:javascript复制
event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
);
event Transfer(address indexed from, address indexed to, uint256 value);

function name() external pure returns (string memory);

function symbol() external pure returns (string memory);

function decimals() external pure returns (uint8);

function totalSupply() external view returns (uint256);

function balanceOf(address owner) external view returns (uint256);

function allowance(address owner, address spender)
external
view
returns (uint256);

function approve(address spender, uint256 value) external returns (bool);

function transfer(address to, uint256 value) external returns (bool);

function transferFrom(
    address from,
    address to,
    uint256 value
) external returns (bool);

function DOMAIN_SEPARATOR() external view returns (bytes32);

function PERMIT_TYPEHASH() external pure returns (bytes32);

function nonces(address owner) external view returns (uint256);

function permit(
    address owner,
    address spender,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
) external;

event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(
    address indexed sender,
    uint256 amount0,
    uint256 amount1,
    address indexed to
);
event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);

function MINIMUM_LIQUIDITY() external pure returns (uint256);

function factory() external view returns (address);

function token0() external view returns (address);

function token1() external view returns (address);

function getReserves()
external
view
returns (
    uint112 reserve0,
    uint112 reserve1,
    uint32 blockTimestampLast
);

function price0CumulativeLast() external view returns (uint256);

function price1CumulativeLast() external view returns (uint256);

function kLast() external view returns (uint256);

function mint(address to) external returns (uint256 liquidity);

function burn(address to)
external
returns (uint256 amount0, uint256 amount1);

function swap(
    uint256 amount0Out,
    uint256 amount1Out,
    address to,
    bytes calldata data
) external;

function skim(address to) external;

function sync() external;

function initialize(address, address) external;

}

interface IUniswapV2Factory {

代码语言:javascript复制
event PairCreated(
    address indexed token0,
    address indexed token1,
    address pair,
    uint256
);

function feeTo() external view returns (address);

function feeToSetter() external view returns (address);

function getPair(address tokenA, address tokenB)
external
view
returns (address pair);

function allPairs(uint256) external view returns (address pair);

function allPairsLength() external view returns (uint256);

function createPair(address tokenA, address tokenB)
external
returns (address pair);

function setFeeTo(address) external;

function setFeeToSetter(address) external;

}

interface IERC20 {

代码语言:javascript复制
/**
 * @dev Returns the amount of tokens in existence.
 */
function totalSupply() external view returns (uint256);

function decimals() external view returns (uint8);

function name() external view returns (string memory);
function symbol() external view returns (string memory);

/**
 * @dev Returns the amount of tokens owned by `account`.
 */
function balanceOf(address account) external view returns (uint256);

/**
 * @dev Moves `amount` tokens from the caller's account to `recipient`.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */
function transfer(address recipient, uint256 amount)
external
returns (bool);

/**
 * @dev Returns the remaining number of tokens that `spender` will be
 * allowed to spend on behalf of `owner` through {transferFrom}. This is
 * zero by default.
 *
 * This value changes when {approve} or {transferFrom} are called.
 */
function allowance(address owner, address spender)
external
view
returns (uint256);

/**
 * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * IMPORTANT: Beware that changing an allowance with this method brings the risk
 * that someone may use both the old and the new allowance by unfortunate
 * transaction ordering. One possible solution to mitigate this race
 * condition is to first reduce the spender's allowance to 0 and set the
 * desired value afterwards:
 * 
 *
 * Emits an {Approval} event.
 */
function approve(address spender, uint256 amount) external returns (bool);

/**
 * @dev Moves `amount` tokens from `sender` to `recipient` using the
 * allowance mechanism. `amount` is then deducted from the caller's
 * allowance.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */
function transferFrom(
    address sender,
    address recipient,
    uint256 amount
) external returns (bool);

/**
 * @dev Emitted when `value` tokens are moved from one account (`from`) to
 * another (`to`).
 *
 * Note that `value` may be zero.
 */
event Transfer(address indexed from, address indexed to, uint256 value);

/**
 * @dev Emitted when the allowance of a `spender` for an `owner` is set by
 * a call to {approve}. `value` is the new allowance.
 */
event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
);

0 人点赞