Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions contracts/UserYieldFarming.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
*Submitted for verification at BscScan.com on 2022-05-18
*/

/**
*Submitted for verification at BscScan.com on 2022-05-16
*/

/**
*Submitted for verification at BscScan.com on 2021-09-10
*/

/**
*Rigelprotocol Liquidity Mining..
Expand Down Expand Up @@ -999,7 +1010,7 @@ contract RigelToken is BEP20('Rigel Token', 'Rigel') {
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol

/// @notice A record of each accounts delegate
// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;

/// @notice A checkpoint for marking number of votes from a given block
Expand Down Expand Up @@ -1264,6 +1275,7 @@ contract MasterChef is Ownable {
uint256 allocPoint; // How many allocation points assigned to this pool. Rigel to distribute per block.
uint256 lastRewardBlock; // Last block number that Rigel distribution occurs.
uint256 accRigelPerShare; // Accumulated Rigel per share, times 1e12. See below.
bool extPool;
}

// The RIGEL TOKEN!
Expand All @@ -1286,6 +1298,7 @@ contract MasterChef is Ownable {
uint256 public startBlock;
// Dev Percentage;
uint256 public devPercentage = 0.1E18;
uint256 public devSetpercentOnExternalPool;
// Fee Collected
uint256 public feeCollected;

Expand All @@ -1297,25 +1310,31 @@ contract MasterChef is Ownable {
RigelToken _rigel,
address _devaddr,
uint256 _rigelPerBlock,
uint256 _startBlock
uint256 _startBlock,
uint256 _devPercent
) public {
rigel = _rigel;
devaddr = _devaddr;
rigelPerBlock = _rigelPerBlock;
startBlock = _startBlock;

devSetpercentOnExternalPool = _devPercent;
// staking pool
poolInfo.push(PoolInfo({
lpToken: _rigel,
allocPoint: 0,
lastRewardBlock: startBlock,
accRigelPerShare: 0
accRigelPerShare: 0,
extPool: false
}));

totalAllocPoint = 0;

}


function setRGPPerBlock(uint256 _newRGPPerBlock) public onlyOwner {
rigelPerBlock = _newRGPPerBlock;
}

function updateMultiplier(uint256 multiplierNumber) public onlyOwner {
BONUS_MULTIPLIER = multiplierNumber;
}
Expand All @@ -1330,17 +1349,19 @@ contract MasterChef is Ownable {

// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IBEP20 _lpToken, bool _withUpdate) public onlyOwner {
function add(uint256 _allocPoint, IBEP20 _lpToken, bool _withUpdate, bool _extPool) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}

uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accRigelPerShare: 0
accRigelPerShare: 0,
extPool: _extPool
}));
updateStakingPool();
}
Expand All @@ -1358,6 +1379,10 @@ contract MasterChef is Ownable {
}
}

function ownerSetPercent(uint256 _setPercent) public onlyOwner {
devSetpercentOnExternalPool = _setPercent;
}

function updateStakingPool() internal {
uint256 length = poolInfo.length;
uint256 points = 0;
Expand Down Expand Up @@ -1419,30 +1444,31 @@ contract MasterChef is Ownable {

// Deposit LP tokens to MasterChef for RIGEL allocation.
function deposit(uint256 _pid, uint256 _amount) public {

require (_pid != 0, 'deposit RIGEL by staking');

PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];

updatePool(_pid);

if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRigelPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeRigelTransfer(msg.sender, pending);
}
}

if(user.amount == 0) {
feeCollected = feeCollected.add(farmingFee);
rigel.transferFrom(msg.sender,address(this), farmingFee);
}


if (_amount > 0) {
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
pool.lpToken.safeTransferFrom(msg.sender, address(this), _amount);
if (pool.extPool) {
uint256 userPct = ((_amount * devSetpercentOnExternalPool) / 100E18);
IBEP20(pool.lpToken).transfer(address(devaddr), userPct);
uint256 newAmt = ( _amount - userPct);
user.amount = user.amount.add(newAmt);
} else {
user.amount = user.amount.add(_amount);
}

}
user.rewardDebt = user.amount.mul(pool.accRigelPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
Expand Down Expand Up @@ -1506,4 +1532,4 @@ contract MasterChef is Ownable {
}
}

}
}
Loading