[audit]#1 add decimals and name to lptoken
This commit is contained in:
@@ -9,13 +9,13 @@ pragma solidity 0.6.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import {Types} from "./lib/Types.sol";
|
import {Types} from "./lib/Types.sol";
|
||||||
|
import {IERC20} from "./intf/IERC20.sol";
|
||||||
import {Storage} from "./impl/Storage.sol";
|
import {Storage} from "./impl/Storage.sol";
|
||||||
import {Trader} from "./impl/Trader.sol";
|
import {Trader} from "./impl/Trader.sol";
|
||||||
import {LiquidityProvider} from "./impl/LiquidityProvider.sol";
|
import {LiquidityProvider} from "./impl/LiquidityProvider.sol";
|
||||||
import {Admin} from "./impl/Admin.sol";
|
import {Admin} from "./impl/Admin.sol";
|
||||||
import {DODOLpToken} from "./impl/DODOLpToken.sol";
|
import {DODOLpToken} from "./impl/DODOLpToken.sol";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title DODO
|
* @title DODO
|
||||||
* @author DODO Breeder
|
* @author DODO Breeder
|
||||||
@@ -53,8 +53,19 @@ contract DODO is Admin, Trader, LiquidityProvider {
|
|||||||
_K_ = k;
|
_K_ = k;
|
||||||
_R_STATUS_ = Types.RStatus.ONE;
|
_R_STATUS_ = Types.RStatus.ONE;
|
||||||
|
|
||||||
_BASE_CAPITAL_TOKEN_ = address(new DODOLpToken());
|
string memory lpTokenSuffix = "_DODO_LP_TOKEN_";
|
||||||
_QUOTE_CAPITAL_TOKEN_ = address(new DODOLpToken());
|
|
||||||
|
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();
|
_checkDODOParameters();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,23 @@ pragma solidity 0.6.9;
|
|||||||
|
|
||||||
import {SafeMath} from "../lib/SafeMath.sol";
|
import {SafeMath} from "../lib/SafeMath.sol";
|
||||||
|
|
||||||
|
|
||||||
contract TestERC20 {
|
contract TestERC20 {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
string public name;
|
||||||
|
uint8 public decimals;
|
||||||
|
|
||||||
mapping(address => uint256) balances;
|
mapping(address => uint256) balances;
|
||||||
mapping(address => mapping(address => uint256)) internal allowed;
|
mapping(address => mapping(address => uint256)) internal allowed;
|
||||||
|
|
||||||
event Transfer(address indexed from, address indexed to, uint256 amount);
|
event Transfer(address indexed from, address indexed to, uint256 amount);
|
||||||
event Approval(address indexed owner, address indexed spender, 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) {
|
function transfer(address to, uint256 amount) public returns (bool) {
|
||||||
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
||||||
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
|
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ import {Ownable} from "../lib/Ownable.sol";
|
|||||||
contract DODOLpToken is Ownable {
|
contract DODOLpToken is Ownable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
string public name;
|
||||||
|
uint8 public decimals;
|
||||||
|
|
||||||
uint256 public totalSupply;
|
uint256 public totalSupply;
|
||||||
mapping(address => uint256) internal balances;
|
mapping(address => uint256) internal balances;
|
||||||
mapping(address => mapping(address => uint256)) internal allowed;
|
mapping(address => mapping(address => uint256)) internal allowed;
|
||||||
@@ -36,6 +39,11 @@ contract DODOLpToken is Ownable {
|
|||||||
|
|
||||||
// ============ Functions ============
|
// ============ Functions ============
|
||||||
|
|
||||||
|
constructor(string memory _name, uint8 _decimals) public {
|
||||||
|
name = _name;
|
||||||
|
decimals = _decimals;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev transfer token for a specified address
|
* @dev transfer token for a specified address
|
||||||
* @param to The address to transfer to.
|
* @param to The address to transfer to.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
pragma solidity 0.6.9;
|
pragma solidity 0.6.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Interface of the ERC20 standard as defined in the EIP.
|
* @dev Interface of the ERC20 standard as defined in the EIP.
|
||||||
*/
|
*/
|
||||||
@@ -14,6 +13,10 @@ interface IERC20 {
|
|||||||
*/
|
*/
|
||||||
function totalSupply() external view returns (uint256);
|
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`.
|
* @dev Returns the amount of tokens owned by `account`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user