CA add owner ratio & mt fee
This commit is contained in:
@@ -11,6 +11,7 @@ pragma experimental ABIEncoderV2;
|
|||||||
import {CAVesting} from "./CAVesting.sol";
|
import {CAVesting} from "./CAVesting.sol";
|
||||||
import {IERC20} from "../../intf/IERC20.sol";
|
import {IERC20} from "../../intf/IERC20.sol";
|
||||||
import {IPermissionManager} from "../../lib/PermissionManager.sol";
|
import {IPermissionManager} from "../../lib/PermissionManager.sol";
|
||||||
|
import {IFeeRateModel} from "../../lib/FeeRateModel.sol";
|
||||||
|
|
||||||
contract CA is CAVesting {
|
contract CA is CAVesting {
|
||||||
function init(
|
function init(
|
||||||
@@ -23,19 +24,23 @@ contract CA is CAVesting {
|
|||||||
/*
|
/*
|
||||||
Address List
|
Address List
|
||||||
0. owner
|
0. owner
|
||||||
1. baseToken
|
1. maintainer
|
||||||
2. quoteToken
|
2. baseToken
|
||||||
3. basePayBack
|
3. quoteToken
|
||||||
4. quotePayBack
|
4. basePayBack
|
||||||
5. permissionManager
|
5. quotePayBack
|
||||||
|
6. permissionManager
|
||||||
|
7. feeRateModel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
initOwner(addressList[0]);
|
initOwner(addressList[0]);
|
||||||
_BASE_TOKEN_ = IERC20(addressList[1]);
|
_MAINTAINER_ = addressList[1];
|
||||||
_QUOTE_TOKEN_ = IERC20(addressList[2]);
|
_BASE_TOKEN_ = IERC20(addressList[2]);
|
||||||
_BASE_PAY_BACK_ = addressList[3];
|
_QUOTE_TOKEN_ = IERC20(addressList[3]);
|
||||||
_QUOTE_PAY_BACK_ = addressList[4];
|
_BASE_PAY_BACK_ = addressList[4];
|
||||||
_BIDDER_PERMISSION_ = IPermissionManager(addressList[5]);
|
_QUOTE_PAY_BACK_ = addressList[5];
|
||||||
|
_BIDDER_PERMISSION_ = IPermissionManager(addressList[6]);
|
||||||
|
_MT_FEE_RATE_MODEL_ = IFeeRateModel(addressList[7]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Time Line
|
Time Line
|
||||||
@@ -67,13 +72,15 @@ contract CA is CAVesting {
|
|||||||
1. cliff rate
|
1. cliff rate
|
||||||
2. k
|
2. k
|
||||||
3. i
|
3. i
|
||||||
|
4. owner ratio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require(
|
require(
|
||||||
valueList[1] <= 10**18 &&
|
valueList[1] <= 10**18 &&
|
||||||
valueList[2] <= 10**18 &&
|
valueList[2] <= 10**18 &&
|
||||||
valueList[3] > 0 &&
|
valueList[3] > 0 &&
|
||||||
valueList[3] <= 10**36,
|
valueList[3] <= 10**36 &&
|
||||||
|
valueList[4] <= 10**18,
|
||||||
"VALUE_RANGE_WRONG"
|
"VALUE_RANGE_WRONG"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -81,6 +88,7 @@ contract CA is CAVesting {
|
|||||||
_CLIFF_RATE_ = valueList[1];
|
_CLIFF_RATE_ = valueList[1];
|
||||||
_K_ = valueList[2];
|
_K_ = valueList[2];
|
||||||
_I_ = valueList[3];
|
_I_ = valueList[3];
|
||||||
|
_OWNER_RATIO_ = valueList[4];
|
||||||
|
|
||||||
// ============ External Call Data ============
|
// ============ External Call Data ============
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ contract CAFunding is CAStorage {
|
|||||||
|
|
||||||
function bid(address to) external phaseBid preventReentrant isBidderAllow(to) {
|
function bid(address to) external phaseBid preventReentrant isBidderAllow(to) {
|
||||||
uint256 input = _getQuoteInput();
|
uint256 input = _getQuoteInput();
|
||||||
_QUOTE_SHARES_[to] = _QUOTE_SHARES_[to].add(input);
|
uint256 mtFee = DecimalMath.mulFloor(input, _MT_FEE_RATE_MODEL_.getFeeRate(to));
|
||||||
_TOTAL_QUOTE_SHARES_ = _TOTAL_QUOTE_SHARES_.add(input);
|
_transferQuoteOut(_MAINTAINER_, mtFee);
|
||||||
|
_QUOTE_SHARES_[to] = _QUOTE_SHARES_[to].add(input.sub(mtFee));
|
||||||
|
_TOTAL_QUOTE_SHARES_ = _TOTAL_QUOTE_SHARES_.add(input.sub(mtFee));
|
||||||
_sync();
|
_sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +66,9 @@ contract CAFunding is CAStorage {
|
|||||||
|
|
||||||
// 3. used quote token
|
// 3. used quote token
|
||||||
uint256 usedQuote = _QUOTE_CAP_ <= quoteBalance ? _QUOTE_CAP_ : quoteBalance;
|
uint256 usedQuote = _QUOTE_CAP_ <= quoteBalance ? _QUOTE_CAP_ : quoteBalance;
|
||||||
_transferQuoteOut(_QUOTE_PAY_BACK_, usedQuote);
|
uint256 ownerQuote = DecimalMath.mulFloor(usedQuote, _OWNER_RATIO_);
|
||||||
|
_transferQuoteOut(_OWNER_, ownerQuote);
|
||||||
|
_transferQuoteOut(_QUOTE_PAY_BACK_, usedQuote.sub(usedQuote));
|
||||||
|
|
||||||
// 4. leave unused quote token in contract
|
// 4. leave unused quote token in contract
|
||||||
_TOTAL_UNUSED_QUOTE_ = quoteBalance.sub(usedQuote);
|
_TOTAL_UNUSED_QUOTE_ = quoteBalance.sub(usedQuote);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pragma experimental ABIEncoderV2;
|
|||||||
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
||||||
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
|
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
|
||||||
import {IPermissionManager} from "../../lib/PermissionManager.sol";
|
import {IPermissionManager} from "../../lib/PermissionManager.sol";
|
||||||
|
import {IFeeRateModel} from "../../lib/FeeRateModel.sol";
|
||||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||||
import {IERC20} from "../../intf/IERC20.sol";
|
import {IERC20} from "../../intf/IERC20.sol";
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ contract CAStorage is InitializableOwnable, ReentrancyGuard {
|
|||||||
// ============ Distribution Parameters ============
|
// ============ Distribution Parameters ============
|
||||||
|
|
||||||
uint256 _QUOTE_CAP_;
|
uint256 _QUOTE_CAP_;
|
||||||
|
uint256 _OWNER_RATIO_;
|
||||||
address public _BASE_PAY_BACK_;
|
address public _BASE_PAY_BACK_;
|
||||||
address public _QUOTE_PAY_BACK_;
|
address public _QUOTE_PAY_BACK_;
|
||||||
bytes _BASE_PAY_BACK_CALL_DATA_;
|
bytes _BASE_PAY_BACK_CALL_DATA_;
|
||||||
@@ -48,6 +50,11 @@ contract CAStorage is InitializableOwnable, ReentrancyGuard {
|
|||||||
mapping(address => uint256) internal _QUOTE_SHARES_;
|
mapping(address => uint256) internal _QUOTE_SHARES_;
|
||||||
mapping(address => bool) internal _QUOTE_CLAIMED_;
|
mapping(address => bool) internal _QUOTE_CLAIMED_;
|
||||||
mapping(address => uint256) internal _CLAIMED_BASE_;
|
mapping(address => uint256) internal _CLAIMED_BASE_;
|
||||||
|
|
||||||
|
// ============ Advanced Control ============
|
||||||
|
|
||||||
|
address public _MAINTAINER_;
|
||||||
|
IFeeRateModel public _MT_FEE_RATE_MODEL_;
|
||||||
IPermissionManager public _BIDDER_PERMISSION_;
|
IPermissionManager public _BIDDER_PERMISSION_;
|
||||||
|
|
||||||
// ============ Time Lock ============
|
// ============ Time Lock ============
|
||||||
|
|||||||
Reference in New Issue
Block a user