[audit]#1 add decimals and name to lptoken

This commit is contained in:
mingda
2020-07-08 17:04:48 +08:00
parent 44d1f28606
commit 11eb3d7103
4 changed files with 34 additions and 5 deletions

View File

@@ -9,13 +9,13 @@ pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import {Types} from "./lib/Types.sol";
import {IERC20} from "./intf/IERC20.sol";
import {Storage} from "./impl/Storage.sol";
import {Trader} from "./impl/Trader.sol";
import {LiquidityProvider} from "./impl/LiquidityProvider.sol";
import {Admin} from "./impl/Admin.sol";
import {DODOLpToken} from "./impl/DODOLpToken.sol";
/**
* @title DODO
* @author DODO Breeder
@@ -53,8 +53,19 @@ contract DODO is Admin, Trader, LiquidityProvider {
_K_ = k;
_R_STATUS_ = Types.RStatus.ONE;
_BASE_CAPITAL_TOKEN_ = address(new DODOLpToken());
_QUOTE_CAPITAL_TOKEN_ = address(new DODOLpToken());
string memory lpTokenSuffix = "_DODO_LP_TOKEN_";
string memory baseName = string(
abi.encodePacked(IERC20(_BASE_TOKEN_).name(), lpTokenSuffix)
);
uint8 baseDecimals = IERC20(_BASE_TOKEN_).decimals();
_BASE_CAPITAL_TOKEN_ = address(new DODOLpToken(baseName, baseDecimals));
string memory quoteName = string(
abi.encodePacked(IERC20(_QUOTE_TOKEN_).name(), lpTokenSuffix)
);
uint8 quoteDecimals = IERC20(_QUOTE_TOKEN_).decimals();
_QUOTE_CAPITAL_TOKEN_ = address(new DODOLpToken(quoteName, quoteDecimals));
_checkDODOParameters();
}

View File

@@ -9,16 +9,23 @@ pragma solidity 0.6.9;
import {SafeMath} from "../lib/SafeMath.sol";
contract TestERC20 {
using SafeMath for uint256;
string public name;
uint8 public decimals;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) internal allowed;
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
constructor(string memory _name, uint8 _decimals) public {
name = _name;
decimals = _decimals;
}
function transfer(address to, uint256 amount) public returns (bool) {
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");

View File

@@ -20,6 +20,9 @@ import {Ownable} from "../lib/Ownable.sol";
contract DODOLpToken is Ownable {
using SafeMath for uint256;
string public name;
uint8 public decimals;
uint256 public totalSupply;
mapping(address => uint256) internal balances;
mapping(address => mapping(address => uint256)) internal allowed;
@@ -36,6 +39,11 @@ contract DODOLpToken is Ownable {
// ============ Functions ============
constructor(string memory _name, uint8 _decimals) public {
name = _name;
decimals = _decimals;
}
/**
* @dev transfer token for a specified address
* @param to The address to transfer to.

View File

@@ -4,7 +4,6 @@
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
@@ -14,6 +13,10 @@ interface IERC20 {
*/
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function name() external view returns (string memory);
/**
* @dev Returns the amount of tokens owned by `account`.
*/