annotation && v2proxy add gasreturn and trade incentive && proxyV2 incentive test

This commit is contained in:
owen05
2021-01-08 17:19:23 +08:00
parent 267ad24edc
commit 34d9ccf668
33 changed files with 537 additions and 90 deletions

View File

@@ -14,6 +14,12 @@ import {IPermissionManager} from "../../lib/PermissionManager.sol";
import {IFeeRateModel} from "../../lib/FeeRateModel.sol";
import {SafeMath} from "../../lib/SafeMath.sol";
/**
* @title DODO CrowdPooling
* @author DODO Breeder
*
* @notice CrowdPooling initialization
*/
contract CP is CPVesting {
using SafeMath for uint256;

View File

@@ -20,12 +20,14 @@ import {IDODOCallee} from "../../intf/IDODOCallee.sol";
contract CPFunding is CPStorage {
using SafeERC20 for IERC20;
// ============ Events ============
event Bid(address to, uint256 amount, uint256 fee);
event Cancel(address to,uint256 amount);
// ============ BID & CALM PHASE ============
modifier isBidderAllow(address bidder) {
require(_BIDDER_PERMISSION_.isAllowed(bidder), "BIDDER_NOT_ALLOWED");
_;
@@ -72,9 +74,10 @@ contract CPFunding is CPStorage {
_UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this)).sub(poolQuote);
_UNUSED_BASE_ = _BASE_TOKEN_.balanceOf(address(this)).sub(poolBase);
// 这里的目的是让midPrice尽量等于avgPrice
// 我们统一设定k=1如果quote和base不平衡就必然要截断一边
// DVM截断了quote所以如果进入池子的quote很多就要把quote设置成DVM的base
// Try to make midPrice equal to avgPrice
// k=1, If quote and base are not balanced, one side must be cut off
// DVM truncated quote, but if more quote than base entering the pool, we need set the quote to the base
// m = avgPrice
// i = m (1-quote/(m*base))
// if quote = m*base i = 1
@@ -199,8 +202,6 @@ contract CPFunding is CPStorage {
}
}
// ============ Asset Out ============
function getShares(address user) external view returns (uint256) {
return _SHARES_[user];
}

View File

@@ -18,6 +18,8 @@ import {IERC20} from "../../intf/IERC20.sol";
contract CPStorage is InitializableOwnable, ReentrancyGuard {
using SafeMath for uint256;
// ============ Constant ============
uint256 internal constant _SETTLEMENT_EXPIRE_ = 86400 * 7;
uint256 internal constant _SETTEL_FUND_ = 200 finney;

View File

@@ -27,6 +27,8 @@ contract CPVesting is CPFunding {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// ================ Modifiers ================
modifier afterSettlement() {
require(_SETTLED_, "NOT_SETTLED");
_;