Add buying, selling and capital limit controls

These advanced controls are disabled by default.

Also disable depositing and trading when creating a new DODO.
This commit is contained in:
Michael Zhou
2020-09-08 19:45:17 +08:00
parent 8a5cca991f
commit 30040834f6
9 changed files with 651 additions and 266 deletions

View File

@@ -15,6 +15,7 @@ import {Types} from "../lib/Types.sol";
import {IERC20} from "../intf/IERC20.sol";
import {Storage} from "./Storage.sol";
/**
* @title Settlement
* @author DODO Breeder
@@ -34,11 +35,16 @@ contract Settlement is Storage {
// ============ Assets IN/OUT Functions ============
function _baseTokenTransferIn(address from, uint256 amount) internal {
require(_BASE_BALANCE_.add(amount) <= _BASE_BALANCE_LIMIT_, "BASE_BALANCE_LIMIT_EXCEEDED");
IERC20(_BASE_TOKEN_).safeTransferFrom(from, address(this), amount);
_BASE_BALANCE_ = _BASE_BALANCE_.add(amount);
}
function _quoteTokenTransferIn(address from, uint256 amount) internal {
require(
_QUOTE_BALANCE_.add(amount) <= _QUOTE_BALANCE_LIMIT_,
"QUOTE_BALANCE_LIMIT_EXCEEDED"
);
IERC20(_QUOTE_TOKEN_).safeTransferFrom(from, address(this), amount);
_QUOTE_BALANCE_ = _QUOTE_BALANCE_.add(amount);
}