update starter view

This commit is contained in:
owen05
2022-02-18 21:12:18 +08:00
parent 999242a316
commit a3d788f87e
7 changed files with 148 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ contract UserQuota is InitializableOwnable, IQuota {
for(uint256 i = 0; i< users.length; i++) {
require(users[i] != address(0), "USER_INVALID");
userQuota[users[i]] = quotas[i];
// emit SetQuota(users[i],quotas[i]);
emit SetQuota(users[i],quotas[i]);
}
}

View File

@@ -0,0 +1,53 @@
/*
Copyright 2022 DODO ZOO.
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import {ICloneFactory} from "../lib/CloneFactory.sol";
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
interface IQuota {
function initOwner(address newOwner) external;
function getUserQuota(address user) external view returns (int);
}
/**
* @title DODO UserQuotaFactory
* @author DODO Breeder
*
*/
contract UserQuotaFactory is InitializableOwnable{
// ============ Templates ============
address public immutable _CLONE_FACTORY_;
address public immutable _USER_QUOTA_TEMPLATE_;
// ============ Events ============
event NewQuota(address quota);
// ============ Functions ============
constructor(
address cloneFactory,
address quotaTemplate
) public {
_CLONE_FACTORY_ = cloneFactory;
_USER_QUOTA_TEMPLATE_ = quotaTemplate;
}
function createQuota(
address quotaOwner
) external onlyOwner returns(address newQuota){
newQuota = ICloneFactory(_CLONE_FACTORY_).clone(_USER_QUOTA_TEMPLATE_);
IQuota(newQuota).initOwner(quotaOwner);
emit NewQuota(newQuota);
}
}

View File

@@ -322,7 +322,9 @@ contract FairFunding is Vesting {
uint256 userFundAmount,
uint256 currentPrice,
uint256 soldTokenAmount,
uint256 totalClaimAmount,
uint256 claimableTokenAmount,
uint256 claimedTokenAmount,
bool isHaveCap,
uint256 userQuota,
uint256 userCurrentQuota
@@ -339,9 +341,29 @@ contract FairFunding is Vesting {
getRemainingRatio(block.timestamp,0),
totalAllocation
);
claimableTokenAmount = totalAllocation.sub(remainingToken).sub(_CLAIMED_TOKEN_[user]);
claimedTokenAmount = _CLAIMED_TOKEN_[user];
claimableTokenAmount = totalAllocation.sub(remainingToken).sub(claimedTokenAmount);
}else {
claimableTokenAmount = 0;
claimedTokenAmount =0;
}
if(raiseFundAmount == 0) {
totalClaimAmount = 0;
} else {
uint256 usedFundRatio = DecimalMath.divFloor(
DecimalMath.mulFloor(_TOTAL_TOKEN_AMOUNT_, currentPrice),
raiseFundAmount
);
if (usedFundRatio > DecimalMath.ONE) {
usedFundRatio = DecimalMath.ONE;
}
totalClaimAmount = DecimalMath.divFloor(
DecimalMath.mulFloor(userFundAmount, usedFundRatio),
currentPrice
);
}
if(_QUOTA_ == address(0)) {

View File

@@ -245,7 +245,9 @@ contract InstantFunding is Vesting {
uint256 userFundAmount,
uint256 currentPrice,
uint256 soldTokenAmount,
uint256 totalClaimAmount,
uint256 claimableTokenAmount,
uint256 claimedTokenAmount,
bool isHaveCap,
uint256 userQuota,
uint256 userCurrentQuota
@@ -260,12 +262,17 @@ contract InstantFunding is Vesting {
uint256 remainingToken = DecimalMath.mulFloor(
getRemainingRatio(block.timestamp,0),
totalAllocation
);
claimableTokenAmount = totalAllocation.sub(remainingToken).sub(_CLAIMED_TOKEN_[user]);
);
claimedTokenAmount = _CLAIMED_TOKEN_[user];
claimableTokenAmount = totalAllocation.sub(remainingToken).sub(claimedTokenAmount);
}else {
claimableTokenAmount = 0;
claimedTokenAmount = 0;
}
totalClaimAmount = getUserTokenAllocation(user);
if(_QUOTA_ == address(0)) {
isHaveCap = false;
userQuota = uint256(-1);