Address Contract Verified
Address
0xe8632364fB496Bc7e323E22E2BaD153f9BD9762d
Balance
0.593047 ETH
Nonce
1
Code Size
8115 bytes
Creator
0xE6d8a62a...75f9 at tx 0x8d87b9ca...1c78a4
Indexed Transactions
0
Contract Bytecode
8115 bytes
0x6080604052600436106101bd575f3560e01c80637a098727116100f2578063ae169a5011610092578063e3161ddd11610062578063e3161ddd14610581578063f2fde38b14610589578063f430cf0d146105a8578063facdc679146105c7575f80fd5b8063ae169a501461050b578063c2a672e01461052a578063c6ee20d214610549578063cdd8d69c14610562575f80fd5b80638da5cb5b116100cd5780638da5cb5b146104885780639d902fc0146104b8578063a40e5e21146104cd578063ab9e91b8146104ec575f80fd5b80637a0987271461042b5780637aa335431461044a5780637b0472f014610469575f80fd5b806365fd2baa1161015d5780636c2a68be116101385780636c2a68be1461039c5780636fa8dd4e146103bb578063715018a6146103f957806379e186cd1461040d575f80fd5b806365fd2baa1461033f57806368a7d4751461035e578063693775521461037d575f80fd5b80631c557fa2116101985780631c557fa2146102305780631e38ef841461024f5780632e17de781461027a5780635981e00b14610299575f80fd5b8063099a04e5146101c85780631185aad7146101e957806316a9313b1461021b575f80fd5b366101c457005b5f80fd5b3480156101d3575f80fd5b506101e76101e2366004611cc5565b6105e6565b005b3480156101f4575f80fd5b50610208610203366004611ced565b61070f565b6040519081526020015b60405180910390f35b348015610226575f80fd5b5061020860045481565b34801561023b575f80fd5b506101e761024a366004611d11565b610725565b34801561025a575f80fd5b50610208610269366004611d2c565b60196020525f908152604090205481565b348015610285575f80fd5b506101e7610294366004611ced565b6107cf565b3480156102a4575f80fd5b506103046102b3366004611cc5565b601860209081525f92835260408084209091529082529020805460018201546002830154600384015460048501546005860154600687015460079097015495969495939460ff909316939192909188565b604080519889526020890197909752958701949094529115156060860152608085015260a084015260c083015260e082015261010001610212565b34801561034a575f80fd5b506101e7610359366004611d11565b610a6c565b348015610369575f80fd5b506101e7610378366004611d45565b610b48565b348015610388575f80fd5b50610208610397366004611ced565b610c22565b3480156103a7575f80fd5b506102086103b6366004611ced565b610c31565b3480156103c6575f80fd5b506103e96103d5366004611d2c565b601a6020525f908152604090205460ff1681565b6040519015158152602001610212565b348015610404575f80fd5b506101e7610c40565b348015610418575f80fd5b506005546103e990610100900460ff1681565b348015610436575f80fd5b506101e7610445366004611d6a565b610c53565b348015610455575f80fd5b50610208610464366004611ced565b610d7a565b348015610474575f80fd5b506101e7610483366004611d9f565b610d89565b348015610493575f80fd5b505f546001600160a01b03165b6040516001600160a01b039091168152602001610212565b3480156104c3575f80fd5b5061020860035481565b3480156104d8575f80fd5b506101e76104e7366004611d45565b61109b565b3480156104f7575f80fd5b506002546104a0906001600160a01b031681565b348015610516575f80fd5b506101e7610525366004611ced565b61115c565b348015610535575f80fd5b506101e7610544366004611cc5565b6112e5565b348015610554575f80fd5b506005546103e99060ff1681565b34801561056d575f80fd5b5061020861057c366004611ced565b6114a6565b6101e76114b5565b348015610594575f80fd5b506101e76105a3366004611d2c565b6115b7565b3480156105b3575f80fd5b506102086105c2366004611cc5565b611630565b3480156105d2575f80fd5b506102086105e1366004611ced565b61172f565b6105ee61173e565b6001600160a01b0382166106385760405162461bcd60e51b815260206004820152600c60248201526b5a65726f206164647265737360a01b60448201526064015b60405180910390fd5b804710156106945760405162461bcd60e51b8152602060048201526024808201527f496e73756666696369656e74204554482062616c616e636520696e20636f6e746044820152631c9858dd60e21b606482015260840161062f565b6040516001600160a01b0383169082156108fc029083905f818181858888f193505050501580156106c7573d5f803e3d5ffd5b50604080516001600160a01b0384168152602081018390527f6c2a9e720617c7f9f1fc74c76b146721ce92a3425aff8fdba90a7fc5aeb36e0e91015b60405180910390a15050565b600c816003811061071e575f80fd5b0154905081565b61072d61173e565b60055481151560ff9091161515036107875760405162461bcd60e51b815260206004820152601a60248201527f53616d652073746174757320616c726561647920616374697665000000000000604482015260640161062f565b6005805460ff19168215159081179091556040519081527f89cb8aeac390e3fc9016dc87a4ed02fbbb63c5adafcbb03db9b6227a14fe589d906020015b60405180910390a150565b6002600154036107f15760405162461bcd60e51b815260040161062f90611dbf565b600260015560055460ff166108185760405162461bcd60e51b815260040161062f90611df6565b335f90815260186020908152604080832084845290915290206003015460ff16156108805760405162461bcd60e51b815260206004820152601860248201527714dd185ada5b99c8185b1c9958591e481d5b9cdd185ad95960421b604482015260640161062f565b335f9081526018602090815260408083208484529091529020600201544210156108ec5760405162461bcd60e51b815260206004820152601860248201527f5374616b696e672074696d65206973206e6f74206f7665720000000000000000604482015260640161062f565b335f9081526019602052604090205481106109195760405162461bcd60e51b815260040161062f90611e2d565b5f6109243383611630565b335f908152601860209081526040808320868452909152902080546004909101549192509081600c826003811061095d5761095d611e58565b015f82825461096c9190611e80565b9091555050335f9081526018602090815260408083208784529091529020600301805460ff1916600117905582158015906109a75750824710155b15610a0957604051339084156108fc029085905f818181858888f193505050501580156109d6573d5f803e3d5ffd5b50335f90815260186020908152604080832087845290915281206006018054859290610a03908490611e93565b90915550505b600254610a20906001600160a01b03163384611797565b60408051338152602081018490529081018490527f7fc4727e062e336010f2c282598ef5f14facb3de68cf8195c2f23e1454b2b74e906060015b60405180910390a15050600180555050565b610a7461173e565b801515600560019054906101000a900460ff16151503610ad65760405162461bcd60e51b815260206004820152601a60248201527f53616d652073746174757320616c726561647920616374697665000000000000604482015260640161062f565b6005805461ff0019166101008315158102919091179182905560ff9104168015610b0157505f600454115b15610b1657610b116004546117ff565b5f6004555b60405181151581527f6bf933b9b99d6af219991adbaeb2c0bbb39c01a46ad1d7ed6b1c90dfedfcb3a9906020016107c4565b610b5061173e565b803515801590610b635750602081013515155b8015610b725750604081013515155b610bbe5760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e67206475726174696f6e206973206e6f7420636f727265637400604482015260640161062f565b8035600655602081013560075560408101356008557f42ad919de131754c2af2184a905ec43d32cbc98256846539b68165c7e945c079815f5b60408051602092830293909301358352848201359183019190915280840135908201526060016107c4565b6006816003811061071e575f80fd5b6015816003811061071e575f80fd5b610c4861173e565b610c515f6119ce565b565b610c5b61173e565b6001600160a01b038216610ca05760405162461bcd60e51b815260206004820152600c60248201526b5a65726f206164647265737360a01b604482015260640161062f565b6001600160a01b0382165f908152601a602052604090205481151560ff909116151503610d1f5760405162461bcd60e51b815260206004820152602760248201527f57616c6c657420697320616c7265616479207468652076616c7565206f6620276044820152667374617475732760c81b606482015260840161062f565b6001600160a01b0382165f818152601a6020908152604091829020805460ff19168515159081179091558251938452908301527f49081ac6f68c0541ea8f82b948be21b0f16d1d550ad509a8324fec504e2744179101610703565b600f816003811061071e575f80fd5b60055460ff16610dab5760405162461bcd60e51b815260040161062f90611df6565b6002546040516370a0823160e01b815233600482015283916001600160a01b0316906370a0823190602401602060405180830381865afa158015610df1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e159190611ea6565b1015610e6d5760405162461bcd60e51b815260206004820152602160248201527f42616c616e6365206e6f7420617661696c61626c6520666f72207374616b696e6044820152606760f81b606482015260840161062f565b80600311610ebd5760405162461bcd60e51b815260206004820152601b60248201527f5374616b696e6720706f6f6c206973206e6f7420636f72726563740000000000604482015260640161062f565b600f8160038110610ed057610ed0611e58565b0154821015610f335760405162461bcd60e51b815260206004820152602960248201527f5374616b6520616d6f756e74206973206c657373207468616e20726571756972604482015268195908185b5bdd5b9d60ba1b606482015260840161062f565b335f818152601960205260409020546002549091610f5c916001600160a01b0316903086611a1d565b82600c8360038110610f7057610f70611e58565b015f828254610f7f9190611e93565b9091555050335f908152601960205260408120805460019290610fa3908490611e93565b9091555050335f90815260186020908152604080832084845290915290208381554260019091015560068260038110610fde57610fde611e58565b0154610fea9042611e93565b335f9081526018602090815260408083208584529091529020600281019190915560040182905560038054906012908490811061102957611029611e58565b01546110359085611ebd565b61103f9190611ed4565b335f8181526018602090815260408083208684528252918290206005019390935580519182529181018590527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910160405180910390a1505050565b6110a361173e565b8035158015906110b65750602081013515155b80156110c55750604081013515155b61111f5760405162461bcd60e51b815260206004820152602560248201527f506f6f6c206d756c7469706c69657220616d6f756e74206973206e6f7420636f6044820152641c9c9958dd60da1b606482015260840161062f565b80356009556020810135600a556040810135600b557fceb1a4c136d70883dee813abf89d23aaf182180e4cc8901ae525cdf394d5dcee815f610bf7565b60026001540361117e5760405162461bcd60e51b815260040161062f90611dbf565b6002600155335f9081526019602052604090205481106111b05760405162461bcd60e51b815260040161062f90611e2d565b60055460ff166111d25760405162461bcd60e51b815260040161062f90611df6565b5f6111dd3383611630565b90505f811180156111ee5750804710155b156112dd57604051339082156108fc029083905f818181858888f1935050505015801561121d573d5f803e3d5ffd5b50335f90815260186020908152604080832085845290915290206004810154905460038054906012908490811061125657611256611e58565b01546112629083611ebd565b61126c9190611ed4565b335f90815260186020908152604080832088845290915281206005810192909255600690910180548592906112a2908490611e93565b909155505060408051338152602081018590527f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f72419101610a5a565b505060018055565b6112ed61173e565b60026001540361130f5760405162461bcd60e51b815260040161062f90611dbf565b60026001556001600160a01b0382165f90815260186020908152604080832084845290915290206003015460ff16156113855760405162461bcd60e51b815260206004820152601860248201527714dd185ada5b99c8185b1c9958591e481d5b9cdd185ad95960421b604482015260640161062f565b6001600160a01b0382165f9081526019602052604090205481106113bb5760405162461bcd60e51b815260040161062f90611e2d565b5f6113c63383611630565b335f908152601860209081526040808320868452909152902080546004909101549192509081600c82600381106113ff576113ff611e58565b015f82825461140e9190611e80565b9091555050335f818152601860209081526040808320888452909152902060038101805460ff1916600117905560070184905560025461145a916001600160a01b039091169084611797565b60408051338152602081018490529081018490527f7fc4727e062e336010f2c282598ef5f14facb3de68cf8195c2f23e1454b2b74e9060600160405180910390a1505060018055505050565b6012816003811061071e575f80fd5b6002600154036114d75760405162461bcd60e51b815260040161062f90611dbf565b6002600155335f908152601a602052604090205460ff166115495760405162461bcd60e51b815260206004820152602660248201527f53656e646572206973206e6f742077686974656c697374656420666f722061646044820152651908199d5b9960d21b606482015260840161062f565b600554610100900460ff161561156757611562346117ff565b61157e565b3460045f8282546115789190611e93565b90915550505b6040513481527f141d729c29cc848b27c53f7dbe9f9542cedc4ed2efa7bd2aeb2a4bdce06a407f9060200160405180910390a160018055565b6115bf61173e565b6001600160a01b0381166116245760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161062f565b61162d816119ce565b50565b6001600160a01b0382165f9081526018602090815260408083208484529091528120541580159061168757506001600160a01b0383165f90815260186020908152604080832085845290915290206003015460ff16155b80156116a957506001600160a01b0383165f9081526019602052604090205482105b15611726576001600160a01b0383165f90815260186020908152604080832085845290915281206004810154815460059092015460038054929491928391601290879081106116fa576116fa611e58565b01546117069086611ebd565b6117109190611ed4565b61171a9190611e80565b94506117299350505050565b505f5b92915050565b6009816003811061071e575f80fd5b5f546001600160a01b03163314610c515760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161062f565b6040516001600160a01b0383166024820152604481018290526117fa90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611a5b565b505050565b600954600c545f916064916118149190611ebd565b61181e9190611ed4565b600a54600d549192505f9160649161183591611ebd565b61183f9190611ed4565b600b54600e549192505f9160649161185691611ebd565b6118609190611ed4565b90505f8161186e8486611e93565b6118789190611e93565b905080156119b0575f8161188c8688611ebd565b6118969190611ed4565b90505f826118a48689611ebd565b6118ae9190611ed4565b90505f816118bc848a611e80565b6118c69190611e80565b9050600c5f01546003546118da9085611ebd565b6118e49190611ed4565b601280545f906118f5908490611e93565b9091555050600d5460035461190a9084611ebd565b6119149190611ed4565b601380545f90611925908490611e93565b9091555050600e5460035461193a9083611ebd565b6119449190611ed4565b601480545f90611955908490611e93565b9091555083905060155f015f82825461196e9190611e93565b9091555082905060156001015f8282546119889190611e93565b9091555081905060156002015f8282546119a29190611e93565b909155506119c79350505050565b8460045f8282546119c19190611e93565b90915550505b5050505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052611a559085906323b872dd60e01b906084016117c3565b50505050565b5f611aaf826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b2c9092919063ffffffff16565b8051909150156117fa5780806020019051810190611acd9190611ef3565b6117fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161062f565b6060611b3a84845f85611b44565b90505b9392505050565b606082471015611ba55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161062f565b6001600160a01b0385163b611bfc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161062f565b5f80866001600160a01b03168587604051611c179190611f30565b5f6040518083038185875af1925050503d805f8114611c51576040519150601f19603f3d011682016040523d82523d5f602084013e611c56565b606091505b5091509150611c66828286611c71565b979650505050505050565b60608315611c80575081611b3d565b825115611c905782518084602001fd5b8160405162461bcd60e51b815260040161062f9190611f4b565b80356001600160a01b0381168114611cc0575f80fd5b919050565b5f8060408385031215611cd6575f80fd5b611cdf83611caa565b946020939093013593505050565b5f60208284031215611cfd575f80fd5b5035919050565b801515811461162d575f80fd5b5f60208284031215611d21575f80fd5b8135611b3d81611d04565b5f60208284031215611d3c575f80fd5b611b3d82611caa565b5f60608284031215611d55575f80fd5b82606083011115611d64575f80fd5b50919050565b5f8060408385031215611d7b575f80fd5b611d8483611caa565b91506020830135611d9481611d04565b809150509250929050565b5f8060408385031215611db0575f80fd5b50508035926020909101359150565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526017908201527f436f6e7472616374206973206e6f7420656e61626c6564000000000000000000604082015260600190565b60208082526011908201527014dd185ada5b99c81b9bdd08199bdd5b99607a1b604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561172957611729611e6c565b8082018082111561172957611729611e6c565b5f60208284031215611eb6575f80fd5b5051919050565b808202811582820484141761172957611729611e6c565b5f82611eee57634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215611f03575f80fd5b8151611b3d81611d04565b5f5b83811015611f28578181015183820152602001611f10565b50505f910152565b5f8251611f41818460208701611f0e565b9190910192915050565b602081525f8251806020840152611f69816040850160208701611f0e565b601f01601f1916919091016040019291505056fea264697066735822122090e654b52c8e37d7320d7b6da39e1ad8d317e764d4a0d08b2883e17b636d572e64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
BubsyStaking.sol 271 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
contract BubsyStaking is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
address public BUBSY;
uint256 public precisionFactor;
uint256 public undistributedReward;
bool public contractStatus;
bool public rewardStatus;
uint256[3] public poolDuration;
uint256[3] public poolMultiplier;
uint256[3] public BUBSYStaked;
uint256[3] public minStaking;
uint256[3] public rewardPerShare;
uint256[3] public rewardDistributedPerPool;
struct StakingInfo {
uint256 stakedBUBSY;
uint256 startTime;
uint256 endTime;
bool unstaked;
uint256 pool;
uint256 rewardClaimed;
uint256 claimedETH;
uint256 rewardUnclaimed;
}
mapping(address => mapping(uint256 => StakingInfo)) public mapStakingInfo;
mapping(address => uint256) public stakingCount;
mapping(address => bool) public isWhitelistForSendFund;
event Staked(address staker, uint256 amount);
event Unstaked(address staker, uint256 amount, uint256 reward);
event PoolUpdated(uint256 amount);
event RewardClaimed(address staker, uint256 amount);
event ContractStatusUpdated(bool status);
event RewardStatusUpdated(bool status);
event PoolDurationUpdated(uint256 pool1, uint256 pool2, uint256 pool3);
event PoolMultiplierUpdated(uint256 pool1Multiplier, uint256 pool2Multiplier, uint256 pool3Multiplier);
event WhitelistStatusUpdated(address wallet, bool status);
event ETHRescueFromContract(address receiver, uint256 amount);
constructor(address _owner) {
require(_owner != address(0), "Owner:: zero address");
minStaking = [1 * 10**18, 1 * 10**18, 1 * 10**18];
poolDuration = [15 days, 90 days, 365 days];
poolMultiplier = [100, 125, 200];
BUBSY = address(0xD699B83e43415B774B6ed4ce9999680F049aF2ab);
precisionFactor = 1 * 10**18;
_transferOwnership(address(_owner));
}
receive() external payable {}
function updateContractStatus(bool status) external onlyOwner {
require(contractStatus != status, "Same status already active");
contractStatus = status;
emit ContractStatusUpdated(status);
}
function updateRewardStatus(bool status) external onlyOwner {
require(rewardStatus != status, "Same status already active");
rewardStatus = status;
if(rewardStatus && undistributedReward > 0)
{
_distributeReward(undistributedReward);
undistributedReward = 0;
}
emit RewardStatusUpdated(status);
}
function updatePoolDuration(uint256[3] calldata newPoolDuration) external onlyOwner {
require(newPoolDuration[0] > 0 && newPoolDuration[1] > 0 && newPoolDuration[2] > 0, "Staking duration is not correct");
poolDuration[0] = newPoolDuration[0];
poolDuration[1] = newPoolDuration[1];
poolDuration[2] = newPoolDuration[2];
emit PoolDurationUpdated(newPoolDuration[0], newPoolDuration[1], newPoolDuration[2]);
}
function updatePoolMultiplier(uint256[3] calldata newMultiplier) external onlyOwner {
require(newMultiplier[0] > 0 && newMultiplier[1] > 0 && newMultiplier[2] > 0, "Pool multiplier amount is not correct");
poolMultiplier[0] = newMultiplier[0];
poolMultiplier[1] = newMultiplier[1];
poolMultiplier[2] = newMultiplier[2];
emit PoolMultiplierUpdated(newMultiplier[0], newMultiplier[1], newMultiplier[2]);
}
function whitelistFundWallet(address wallet, bool status) external onlyOwner {
require(address(wallet) != address(0), "Zero address");
require(isWhitelistForSendFund[address(wallet)] != status, "Wallet is already the value of 'status'");
isWhitelistForSendFund[address(wallet)] = status;
emit WhitelistStatusUpdated(address(wallet), status);
}
function rescueETH(address receiver, uint256 amount) external onlyOwner {
require(address(receiver) != address(0), "Zero address");
require(address(this).balance >= amount, "Insufficient ETH balance in contract");
payable(address(receiver)).transfer(amount);
emit ETHRescueFromContract(address(receiver), amount);
}
function stake(uint256 amount, uint256 pool) external {
require(contractStatus, "Contract is not enabled");
require(IERC20(BUBSY).balanceOf(address(msg.sender)) >= amount, "Balance not available for staking");
require(poolDuration.length > pool, "Staking pool is not correct");
require(amount >= minStaking[pool], "Stake amount is less than required amount");
uint256 count = stakingCount[address(msg.sender)];
IERC20(BUBSY).safeTransferFrom(address(msg.sender), address(this), amount);
BUBSYStaked[pool] += amount;
stakingCount[address(msg.sender)] += 1;
mapStakingInfo[address(msg.sender)][count].stakedBUBSY = amount;
mapStakingInfo[address(msg.sender)][count].startTime = block.timestamp;
mapStakingInfo[address(msg.sender)][count].endTime = block.timestamp + poolDuration[pool];
mapStakingInfo[address(msg.sender)][count].pool = pool;
mapStakingInfo[address(msg.sender)][count].rewardClaimed = (amount * rewardPerShare[pool]) / precisionFactor;
emit Staked(address(msg.sender), amount);
}
function unstake(address staker, uint256 count) external onlyOwner nonReentrant {
require(mapStakingInfo[address(staker)][count].unstaked == false, "Staking already unstaked");
require(stakingCount[address(staker)] > count, "Staking not found");
uint256 pending = pendingReward(address(msg.sender), count);
uint256 amount = mapStakingInfo[address(msg.sender)][count].stakedBUBSY;
uint256 pool = mapStakingInfo[address(msg.sender)][count].pool;
BUBSYStaked[pool] -= amount;
mapStakingInfo[address(msg.sender)][count].unstaked = true;
mapStakingInfo[address(msg.sender)][count].rewardUnclaimed = pending;
IERC20(BUBSY).safeTransfer(address(msg.sender), amount);
emit Unstaked(address(msg.sender), amount, pending);
}
function unstake(uint256 count) external nonReentrant {
require(contractStatus, "Contract is not enabled");
require(mapStakingInfo[address(msg.sender)][count].unstaked == false, "Staking already unstaked");
require(mapStakingInfo[address(msg.sender)][count].endTime <= block.timestamp, "Staking time is not over");
require(stakingCount[address(msg.sender)] > count, "Staking not found");
uint256 pending = pendingReward(address(msg.sender), count);
uint256 amount = mapStakingInfo[address(msg.sender)][count].stakedBUBSY;
uint256 pool = mapStakingInfo[address(msg.sender)][count].pool;
BUBSYStaked[pool] -= amount;
mapStakingInfo[address(msg.sender)][count].unstaked = true;
if(pending > 0 && address(this).balance >= pending)
{
payable(address(msg.sender)).transfer(pending);
mapStakingInfo[address(msg.sender)][count].claimedETH += pending;
}
IERC20(BUBSY).safeTransfer(address(msg.sender), amount);
emit Unstaked(address(msg.sender), amount, pending);
}
function claimReward(uint256 count) external nonReentrant{
require(stakingCount[address(msg.sender)] > count, "Staking not found");
require(contractStatus, "Contract is not enabled");
uint256 pending = pendingReward(address(msg.sender), count);
if(pending > 0 && address(this).balance >= pending)
{
payable(address(msg.sender)).transfer(pending);
uint256 pool = mapStakingInfo[address(msg.sender)][count].pool;
uint256 amount = mapStakingInfo[address(msg.sender)][count].stakedBUBSY;
mapStakingInfo[address(msg.sender)][count].rewardClaimed = (amount * rewardPerShare[pool]) / precisionFactor;
mapStakingInfo[address(msg.sender)][count].claimedETH += pending;
emit RewardClaimed(address(msg.sender), pending);
}
}
function pendingReward(address staker, uint256 count) public view returns (uint256) {
if(mapStakingInfo[address(staker)][count].stakedBUBSY > 0 && !mapStakingInfo[address(staker)][count].unstaked && stakingCount[address(staker)] > count)
{
uint256 pool = mapStakingInfo[address(staker)][count].pool;
uint256 amount = mapStakingInfo[address(staker)][count].stakedBUBSY;
uint256 claimed = mapStakingInfo[address(staker)][count].rewardClaimed;
uint256 pending = ((amount * rewardPerShare[pool]) / precisionFactor) - (claimed);
return pending;
}
else
{
return 0;
}
}
function updatePool() external payable nonReentrant {
require(isWhitelistForSendFund[address(msg.sender)], "Sender is not whitelisted for add fund");
if(rewardStatus)
{
_distributeReward(msg.value);
}
else
{
undistributedReward += msg.value;
}
emit PoolUpdated(msg.value);
}
function _distributeReward(uint256 amount) internal {
uint256 pool0StakedBUBSY = ((BUBSYStaked[0] * poolMultiplier[0]) / 100);
uint256 pool1StakedBUBSY = ((BUBSYStaked[1] * poolMultiplier[1]) / 100);
uint256 pool2StakedBUBSY = ((BUBSYStaked[2] * poolMultiplier[2]) / 100);
uint256 totalStakedBUBSY = (pool0StakedBUBSY + pool1StakedBUBSY + pool2StakedBUBSY);
if(totalStakedBUBSY > 0)
{
uint256 pool0Share = ((amount * pool0StakedBUBSY) / totalStakedBUBSY);
uint256 pool1Share = ((amount * pool1StakedBUBSY) / totalStakedBUBSY);
uint256 pool2Share = amount - pool0Share - pool1Share;
rewardPerShare[0] += ((pool0Share * precisionFactor) / BUBSYStaked[0]);
rewardPerShare[1] += ((pool1Share * precisionFactor) / BUBSYStaked[1]);
rewardPerShare[2] += ((pool2Share * precisionFactor) / BUBSYStaked[2]);
rewardDistributedPerPool[0] += pool0Share;
rewardDistributedPerPool[1] += pool1Share;
rewardDistributedPerPool[2] += pool2Share;
}
else
{
undistributedReward += amount;
}
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Read Contract
BUBSY 0xab9e91b8 → address
BUBSYStaked 0x1185aad7 → uint256
contractStatus 0xc6ee20d2 → bool
isWhitelistForSendFund 0x6fa8dd4e → bool
mapStakingInfo 0x5981e00b → uint256, uint256, uint256, bool, uint256, uint256, uint256, uint256
minStaking 0x7aa33543 → uint256
owner 0x8da5cb5b → address
pendingReward 0xf430cf0d → uint256
poolDuration 0x69377552 → uint256
poolMultiplier 0xfacdc679 → uint256
precisionFactor 0x9d902fc0 → uint256
rewardDistributedPerPool 0x6c2a68be → uint256
rewardPerShare 0xcdd8d69c → uint256
rewardStatus 0x79e186cd → bool
stakingCount 0x1e38ef84 → uint256
undistributedReward 0x16a9313b → uint256
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
claimReward 0xae169a50
uint256 count
renounceOwnership 0x715018a6
No parameters
rescueETH 0x099a04e5
address receiver
uint256 amount
stake 0x7b0472f0
uint256 amount
uint256 pool
transferOwnership 0xf2fde38b
address newOwner
unstake 0x2e17de78
uint256 count
unstake 0xc2a672e0
address staker
uint256 count
updateContractStatus 0x1c557fa2
bool status
updatePool 0xe3161ddd
No parameters
updatePoolDuration 0x68a7d475
uint256[3] newPoolDuration
updatePoolMultiplier 0xa40e5e21
uint256[3] newMultiplier
updateRewardStatus 0x65fd2baa
bool status
whitelistFundWallet 0x7a098727
address wallet
bool status
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address