-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOld
206 lines (163 loc) · 7.38 KB
/
Old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// // SPDX-License-Identifier: MIT
// pragma solidity ^0.8.20;
// import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
// import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
// import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
// import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
// import "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol";
// /// @author Shola Ayeni
// /// @title BadgerBot NFT Staking Contract
// /// @notice Staking Contract that uses the Openzepellin Staking model to distribute ERC20 token rewards in a dynamic way,
// /// proportionally based on the amount of ERC721 tokens staked by each staker at any given time.
// contract BadgerBotStakingContract is ERC721Holder, ReentrancyGuard, ChainlinkClient, ConfirmedOwner {
// using Chainlink for Chainlink.Request;
// uint256 public profit;
// bytes32 private jobId;
// uint256 private fee;
// IERC721 public nftCollection;
// uint256 public nextDistributionDate;
// uint256 public lastUpdateTime;
// uint256 public totalStakedSupply;
// address[] private users;
// bool private profitDistributed = false;
// uint public totalSupply = 5;
// struct StakedAsset {
// uint256 tokenId;
// uint256 amount;
// uint256 timestamp;
// }
// mapping(address => uint256) private rewards;
// mapping(address => StakedAsset) public stakedAssets;
// constructor(address _nftCollection) payable ConfirmedOwner(msg.sender){
// nftCollection = IERC721(_nftCollection);
// setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
// setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
// jobId = "ca98366cc7314957b8c012c72f05aeeb";
// fee = (1 * LINK_DIVISIBILITY) / 10;
// }
// function userExist(address _address) internal view returns (bool) {
// for (uint256 i = 0; i < users.length; i++) {
// if (users[i] == _address) {
// return true;
// }
// }
// return false;
// }
// function removeUser(address _user) internal {
// for (uint256 i = 0; i < users.length; i++) {
// if (users[i] == _user) {
// users[i] = users[users.length - 1];
// users.pop();
// }
// }
// }
// function stake(uint256 tokenId) external {
// require(userExist(msg.sender) == false, 'user already has staked asset');
// nftCollection.safeTransferFrom(msg.sender, address(this), tokenId);
// totalStakedSupply += amount;
// stakedAssets[msg.sender].tokenId = tokenId;
// stakedAssets[msg.sender].timestamp = block.timestamp;
// users.push(msg.sender);
// emit Staked(msg.sender, tokenId);
// }
// function unstake(uint256 tokenId) public nonReentrant {
// require(userExist(msg.sender) == true, 'user has no staked asset');
// nftCollection.safeTransferFrom(address(this), msg.sender, tokenId);
// totalStakedSupply -= amount;
// stakedAssets[msg.sender].tokenId = 0;
// stakedAssets[msg.sender].timestamp = 0;
// removeUser(msg.sender);
// claimRewards(msg.sender);
// emit Unstaked(msg.sender, tokenId);
// }
// function addFunds(uint256 _amount) public payable {
// require(userExist(msg.sender) == true, 'user has no staked asset');
// uint256 prevAmount = stakedAssets[msg.sender].amount;
// uint256 newAmount = prevAmount + _amount;
// stakedAssets[msg.sender].amount = newAmount;
// stakedAssets[msg.sender].timestamp = block.timestamp;
// emit Deposit(msg.sender, _amount);
// }
// function requestProfitData() public onlyOwner returns (bytes32 requestId) {
// Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
// req.add("get","https://badger-backend-952bd65fee6e.herokuapp.com/profit?period=7");
// req.add("path", "netProfit");
// int256 timesAmount = 10 ** 18;
// req.addInt("times", timesAmount);
// return sendChainlinkRequest(req, fee);
// }
// function fulfill(bytes32 _requestId, uint256 _profit) public recordChainlinkFulfillment(_requestId) {
// emit RequestProfit(_requestId, _profit);
// profit = _profit;
// }
// function withdrawLink() public onlyOwner {
// LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
// require(
// link.transfer(msg.sender, link.balanceOf(address(this))),
// "Unable to transfer"
// );
// }
// function claimRewards(address _to) public nonReentrant updateReward(msg.sender) {
// address to = payable(_to);
// // move to get available rewards
// uint256 reward = getAvailableRewards(_to);
// if (reward > 0) {
// (bool success,) = to.call{value: reward}("");
// require(success, "Failed to send Ether");
// emit RewardPaid(msg.sender, reward);
// }
// }
// function unstakeAll() external {
// claimRewards(msg.sender);
// // unstake here
// }
// function userStakeInfo(address _user)
// public
// view
// returns (uint256[] memory _tokensStaked, uint256 _availableRewards)
// {
// _availableRewards = getAvailableRewards(_user);
// }
// function lastTimeRewardApplicable() public view returns (uint256 _lastRewardsApplicable) {
// return block.timestamp;
// }
// function calculateRewards(address _user) public view returns (uint256 _rewards) {
// }
// function getAvailableRewards(address _user) public view returns (uint256 _rewards) {
// return rewards[_user];
// }
// function distributeRewards() public onlyOwner {
// require(lastUpdateTime == 0 || block.timestamp >= lastUpdateTime + 7 days, "Not enough time has passed");
// requestProfitData();
// for (uint256 i = 0; i < users.length; i++) {
// uint256 userReward = rewards[users[i]];
// uint256 currentReward = calculateRewards(users[i]);
// rewards[users[i]] = userReward + currentReward;
// emit RewardAdded(users[i], currentReward);
// }
// lastUpdateTime = lastTimeRewardApplicable();
// nextDistributionDate = block.timestamp + 7 days;
// emit RewardsDurationUpdated(nextDistributionDate);
// }
// function deposit() public onlyOwner payable {
// }
// function withdraw() public {
// uint amount = address(this).balance;
// address owner = payable(msg.sender);
// (bool success, ) = owner.call{value: amount}("");
// require(success, "Failed to send Ether");
// }
// modifier updateReward(address account) {
// if (account != address(0)) {
// rewards[account] = 0 ;
// }
// _;
// }
// event RewardAdded(address indexed user, uint256 reward);
// event Staked(address indexed user, uint256 tokenId);
// event Unstaked(address indexed user, uint256 tokenId);
// event RewardPaid(address indexed user, uint256 reward);
// event RewardsDurationUpdated(uint256 newDuration);
// event RequestProfit(bytes32 indexed requestId, uint256 volume);
// event Deposit(address indexed user, uint256 amount);
// }