Single Token Farm Contracts
Fully Audited: All smart contracts used by Liquidus are fully audited by reputational auditing companies.
Farm | Blockchain | Contract | Lock Duration |
---|---|---|---|
LIQ - 1 Month | BNB Smart Chain | N/A | 1 Month |
LIQ - 3 Months | BNB Smart Chain | 0x03c5D2Cf0b79822eDB2B60d9F5aF290Facf190DD | 3 Months |
LIQ - 6 Months | BNB Smart Chain | 0x7b00f1084B0C70089e569c41451E34E477ecb184 | 6 Months |
LIQ - 12 Months | BNB Smart Chain | 0x89c0e71A3109311aD82ea786a76c074Ef82e91d7 | 12 Months |
LIQ - 3 Months | Cronos | 0xB67640F6D742d35650F95E4C0294670E8824adaa | 3 Months |
1
// File: @openzeppelin/contracts/utils/Context.sol
2
3
pragma solidity >=0.6.0 <0.8.0;
4
5
/* use 0.6.12 compiler version
6
* @dev Provides information about the current execution context, including the
7
* sender of the transaction and its data. While these are generally available
8
* via msg.sender and msg.data, they should not be accessed in such a direct
9
* manner, since when dealing with GSN meta-transactions the account sending and
10
* paying for execution may not be the actual sender (as far as an application
11
* is concerned).
12
*
13
* This contract is only required for intermediate, library-like contracts.
14
*/
15
abstract contract Context {
16
function _msgSender() internal view virtual returns (address payable) {
17
return msg.sender;
18
}
19
20
function _msgData() internal view virtual returns (bytes memory) {
21
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
22
return msg.data;
23
}
24
}
25
26
// File: @openzeppelin/contracts/access/Ownable.sol
27
28
pragma solidity >=0.6.0 <0.8.0;
29
30
/**
31
* @dev Contract module which provides a basic access control mechanism, where
32
* there is an account (an owner) that can be granted exclusive access to
33
* specific functions.
34
*
35
* By default, the owner account will be the one that deploys the contract. This
36
* can later be changed with {transferOwnership}.
37
*
38
* This module is used through inheritance. It will make available the modifier
39
* `onlyOwner`, which can be applied to your functions to restrict their use to
40
* the owner.
41
*/
42
abstract contract Ownable is Context {
43
address private _owner;
44
45
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
46
47
/**
48
* @dev Initializes the contract setting the deployer as the initial owner.
49
*/
50
constructor() internal {
51
address msgSender = _msgSender();
52
_owner = msgSender;
53
emit OwnershipTransferred(address(0), msgSender);
54
}
55
56
/**
57
* @dev Returns the address of the current owner.
58
*/
59
function owner() public view virtual returns (address) {
60
return _owner;
61
}
62
63
/**
64
* @dev Throws if called by any account other than the owner.
65
*/
66
modifier onlyOwner() {
67
require(owner() == _msgSender(), "Ownable: caller is not the owner");
68
_;
69
}
70
71
/**
72
* @dev Leaves the contract without owner. It will not be possible to call
73
* `onlyOwner` functions anymore. Can only be called by the current owner.
74
*
75
* NOTE: Renouncing ownership will leave the contract without an owner,
76
* thereby removing any functionality that is only available to the owner.
77
*/
78
function renounceOwnership() public virtual onlyOwner {
79
emit OwnershipTransferred(_owner, address(0));
80
_owner = address(0);
81
}
82
83
/**
84
* @dev Transfers ownership of the contract to a new account (`newOwner`).
85
* Can only be called by the current owner.
86
*/
87
function transferOwnership(address newOwner) public virtual onlyOwner {
88
require(newOwner != address(0), "Ownable: new owner is the zero address");
89
emit OwnershipTransferred(_owner, newOwner);
90
_owner = newOwner;
91
}
92
}
93
94
// File: @openzeppelin/contracts/math/SafeMath.sol
95
96
pragma solidity >=0.6.0 <0.8.0;
97
98
/**
99
* @dev Wrappers over Solidity's arithmetic operations with added overflow
100
* checks.
101
*
102
* Arithmetic operations in Solidity wrap on overflow. This can easily result
103
* in bugs, because programmers usually assume that an overflow raises an
104
* error, which is the standard behavior in high level programming languages.
105
* `SafeMath` restores this intuition by reverting the transaction when an
106
* operation overflows.
107
*
108
* Using this library instead of the unchecked operations eliminates an entire
109
* class of bugs, so it's recommended to use it always.
110
*/
111
library SafeMath {
112
/**
113
* @dev Returns the addition of two unsigned integers, with an overflow flag.
114
*
115
* _Available since v3.4._
116
*/
117
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
118
uint256 c = a + b;
119
if (c < a) return (false, 0);
120
return (true, c);
121
}
122
123
/**
124
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
125
*
126
* _Available since v3.4._
127
*/
128
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
129
if (b > a) return (false, 0);
130
return (true, a - b);
131
}
132
133
/**
134
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
135
*
136
* _Available since v3.4._
137
*/
138
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
139
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
140
// benefit is lost if 'b' is also tested.
141
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
142
if (a == 0) return (true, 0);
143
uint256 c = a * b;
144
if (c / a != b) return (false, 0);
145
return (true, c);
146
}
147
148
/**
149
* @dev Returns the division of two unsigned integers, with a division by zero flag.
150
*
151
* _Available since v3.4._
152
*/
153
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
154
if (b == 0) return (false, 0);
155
return (true, a / b);
156
}
157
158
/**
159
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
160
*
161
* _Available since v3.4._
162
*/
163
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
164
if (b == 0) return (false, 0);
165
return (true, a % b);
166
}
167
168
/**
169
* @dev Returns the addition of two unsigned integers, reverting on
170
* overflow.
171
*
172
* Counterpart to Solidity's `+` operator.
173
*
174
* Requirements:
175
*
176
* - Addition cannot overflow.
177
*/
178
function add(uint256 a, uint256 b) internal pure returns (uint256) {
179
uint256 c = a + b;
180
require(c >= a, "SafeMath: addition overflow");
181
return c;
182
}
183
184
/**
185
* @dev Returns the subtraction of two unsigned integers, reverting on
186
* overflow (when the result is negative).
187
*
188
* Counterpart to Solidity's `-` operator.
189
*
190
* Requirements:
191
*
192
* - Subtraction cannot overflow.
193
*/
194
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
195
require(b <= a, "SafeMath: subtraction overflow");
196
return a - b;
197
}
198
199
/**
200
* @dev Returns the multiplication of two unsigned integers, reverting on
201
* overflow.
202
*
203
* Counterpart to Solidity's `*` operator.
204
*
205
* Requirements:
206
*
207
* - Multiplication cannot overflow.
208
*/
209
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
210
if (a == 0) return 0;
211
uint256 c = a * b;
212
require(c / a == b, "SafeMath: multiplication overflow");
213
return c;
214
}
215
216
/**
217
* @dev Returns the integer division of two unsigned integers, reverting on
218
* division by zero. The result is rounded towards zero.
219
*
220
* Counterpart to Solidity's `/` operator. Note: this function uses a
221
* `revert` opcode (which leaves remaining gas untouched) while Solidity
222
* uses an invalid opcode to revert (consuming all remaining gas).
223
*
224
* Requirements:
225
*
226
* - The divisor cannot be zero.
227
*/
228
function div(uint256 a, uint256 b) internal pure returns (uint256) {
229
require(b > 0, "SafeMath: division by zero");
230
return a / b;
231
}
232
233
/**
234
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
235
* reverting when dividing by zero.
236
*
237
* Counterpart to Solidity's `%` operator. This function uses a `revert`
238
* opcode (which leaves remaining gas untouched) while Solidity uses an
239
* invalid opcode to revert (consuming all remaining gas).
240
*
241
* Requirements:
242
*
243
* - The divisor cannot be zero.
244
*/
245
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
246
require(b > 0, "SafeMath: modulo by zero");
247
return a % b;
248
}
249
250
/**
251
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
252
* overflow (when the result is negative).
253
*
254
* CAUTION: This function is deprecated because it requires allocating memory for the error
255
* message unnecessarily. For custom revert reasons use {trySub}.
256
*
257
* Counterpart to Solidity's `-` operator.
258
*
259
* Requirements:
260
*
261
* - Subtraction cannot overflow.
262
*/
263
function sub(
264
uint256 a,
265
uint256 b,
266
string memory errorMessage
267
) internal pure returns (uint256) {
268
require(b <= a, errorMessage);
269
return a - b;
270
}
271
272
/**
273
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
274
* division by zero. The result is rounded towards zero.
275
*
276
* CAUTION: This function is deprecated because it requires allocating memory for the error
277
* message unnecessarily. For custom revert reasons use {tryDiv}.
278
*
279
* Counterpart to Solidity's `/` operator. Note: this function uses a
280
* `revert` opcode (which leaves remaining gas untouched) while Solidity
281
* uses an invalid opcode to revert (consuming all remaining gas).
282
*
283
* Requirements:
284
*
285
* - The divisor cannot be zero.
286
*/
287
function div(
288
uint256 a,
289
uint256 b,
290
string memory errorMessage
291
) internal pure returns (uint256) {
292
require(b > 0, errorMessage);
293
return a / b;
294
}
295
296
/**
297
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
298
* reverting with custom message when dividing by zero.
299
*
300
* CAUTION: This function is deprecated because it requires allocating memory for the error
301
* message unnecessarily. For custom revert reasons use {tryMod}.
302
*
303
* Counterpart to Solidity's `%` operator. This function uses a `revert`
304
* opcode (which leaves remaining gas untouched) while Solidity uses an
305
* invalid opcode to revert (consuming all remaining gas).
306
*
307
* Requirements:
308
*
309
* - The divisor cannot be zero.
310
*/
311
function mod(
312
uint256 a,
313
uint256 b,
314
string memory errorMessage
315
) internal pure returns (uint256) {
316
require(b > 0, errorMessage);
317
return a % b;
318
}
319
}
320
321
// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol
322
323
pragma solidity >=0.6.0 <0.8.0;
324
325
/**
326
* @dev Contract module that helps prevent reentrant calls to a function.
327
*
328
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
329
* available, which can be applied to functions to make sure there are no nested
330
* (reentrant) calls to them.
331
*
332
* Note that because there is a single `nonReentrant` guard, functions marked as
333
* `nonReentrant` may not call one another. This can be worked around by making
334
* those functions `private`, and then adding `external` `nonReentrant` entry
335
* points to them.
336
*
337
* TIP: If you would like to learn more about reentrancy and alternative ways
338
* to protect against it, check out our blog post
339
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
340
*/
341
abstract contract ReentrancyGuard {
342
// Booleans are more expensive than uint256 or any type that takes up a full
343
// word because each write operation emits an extra SLOAD to first read the
344
// slot's contents, replace the bits taken up by the boolean, and then write
345
// back. This is the compiler's defense against contract upgrades and
346
// pointer aliasing, and it cannot be disabled.
347
348
// The values being non-zero value makes deployment a bit more expensive,
349
// but in exchange the refund on every call to nonReentrant will be lower in
350
// amount. Since refunds are capped to a percentage of the total
351
// transaction's gas, it is best to keep them low in cases like this one, to
352
// increase the likelihood of the full refund coming into effect.
353
uint256 private constant _NOT_ENTERED = 1;
354
uint256 private constant _ENTERED = 2;
355
356
uint256 private _status;
357
358
constructor() internal {
359
_status = _NOT_ENTERED;
360
}
361
362
/**
363
* @dev Prevents a contract from calling itself, directly or indirectly.
364
* Calling a `nonReentrant` function from another `nonReentrant`
365
* function is not supported. It is possible to prevent this from happening
366
* by making the `nonReentrant` function external, and make it call a
367
* `private` function that does the actual work.
368
*/
369
modifier nonReentrant() {
370
// On the first call to nonReentrant, _notEntered will be true
371
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
372
373
// Any calls to nonReentrant after this point will fail
374
_status = _ENTERED;
375
376
_;
377
378
// By storing the original value once again, a refund is triggered (see
379
// https://eips.ethereum.org/EIPS/eip-2200)
380
_status = _NOT_ENTERED;
381
}
382
}
383
384
// File: bsc-library/contracts/IBEP20.sol
385
386
pragma solidity >=0.4.0;
387
388
interface IBEP20 {
389
/**
390
* @dev Returns the amount of tokens in existence.
391
*/
392
function totalSupply() external view returns (uint256);
393
394
/**
395
* @dev Returns the token decimals.
396
*/
397
function decimals() external view returns (uint8);
398
399
/**
400
* @dev Returns the token symbol.
401
*/
402
function symbol() external view returns (string memory);
403
404
/**
405
* @dev Returns the token name.
406
*/
407
function name() external view returns (string memory);
408
409
/**
410
* @dev Returns the bep token owner.
411
*/
412
function getOwner() external view returns (address);
413
414
/**
415
* @dev Returns the amount of tokens owned by `account`.
416
*/
417
function balanceOf(address account) external view returns (uint256);
418
419
/**
420
* @dev Moves `amount` tokens from the caller's account to `recipient`.
421
*
422
* Returns a boolean value indicating whether the operation succeeded.
423
*
424
* Emits a {Transfer} event.
425
*/
426
function transfer(address recipient, uint256 amount) external returns (bool);
427
428
/**
429
* @dev Returns the remaining number of tokens that `spender` will be
430
* allowed to spend on behalf of `owner` through {transferFrom}. This is
431
* zero by default.
432
*
433
* This value changes when {approve} or {transferFrom} are called.
434
*/
435
function allowance(address _owner, address spender) external view returns (uint256);
436
437
/**
438
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
439
*
440
* Returns a boolean value indicating whether the operation succeeded.
441
*
442
* IMPORTANT: Beware that changing an allowance with this method brings the risk
443
* that someone may use both the old and the new allowance by unfortunate
444
* transaction ordering. One possible solution to mitigate this race
445
* condition is to first reduce the spender's allowance to 0 and set the
446
* desired value afterwards:
447
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
448
*
449
* Emits an {Approval} event.
450
*/
451
function approve(address spender, uint256 amount) external returns (bool);
452
453
/**
454
* @dev Moves `amount` tokens from `sender` to `recipient` using the
455
* allowance mechanism. `amount` is then deducted from the caller's
456
* allowance.
457
*
458
* Returns a boolean value indicating whether the operation succeeded.
459
*
460
* Emits a {Transfer} event.
461
*/
462
function transferFrom(
463
address sender,
464
address recipient,
465
uint256 amount
466
) external returns (bool);
467
468
/**
469
* @dev Emitted when `value` tokens are moved from one account (`from`) to
470
* another (`to`).
471
*
472
* Note that `value` may be zero.
473
*/
474
event Transfer(address indexed from, address indexed to, uint256 value);
475
476
/**
477
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
478
* a call to {approve}. `value` is the new allowance.
479
*/
480
event Approval(address indexed owner, address indexed spender, uint256 value);
481
}
482
483
// File: @openzeppelin/contracts/utils/Address.sol
484
485
pragma solidity >=0.6.2 <0.8.0;
486
487
/**
488
* @dev Collection of functions related to the address type
489
*/
490
library Address {
491
/**
492
* @dev Returns true if `account` is a contract.
493
*
494
* [IMPORTANT]
495
* ====
496
* It is unsafe to assume that an address for which this function returns
497
* false is an externally-owned account (EOA) and not a contract.
498
*
499
* Among others, `isContract` will return false for the following
500
* types of addresses:
501
*
502
* - an externally-owned account
503
* - a contract in construction
504
* - an address where a contract will be created
505
* - an address where a contract lived, but was destroyed
506
* ====
507
*/
508
function isContract(address account) internal view returns (bool) {
509
// This method relies on extcodesize, which returns 0 for contracts in
510
// construction, since the code is only stored at the end of the
511
// constructor execution.
512
513
uint256 size;
514
// solhint-disable-next-line no-inline-assembly
515
assembly {
516
size := extcodesize(account)
517
}
518
return size > 0;
519
}
520
521
/**
522
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
523
* `recipient`, forwarding all available gas and reverting on errors.
524
*
525
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
526
* of certain opcodes, possibly making contracts go over the 2300 gas limit
527
* imposed by `transfer`, making them unable to receive funds via
528
* `transfer`. {sendValue} removes this limitation.
529
*
530
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
531
*
532
* IMPORTANT: because control is transferred to `recipient`, care must be
533
* taken to not create reentrancy vulnerabilities. Consider using
534
* {ReentrancyGuard} or the
535
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
536
*/
537
function sendValue(address payable recipient, uint256 amount) internal {
538
require(address(this).balance >= amount, "Address: insufficient balance");
539
540
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
541
(bool success, ) = recipient.call{value: amount}("");
542
require(success, "Address: unable to send value, recipient may have reverted");
543
}
544
545
/**
546
* @dev Performs a Solidity function call using a low level `call`. A
547
* plain`call` is an unsafe replacement for a function call: use this
548
* function instead.
549
*
550
* If `target` reverts with a revert reason, it is bubbled up by this
551
* function (like regular Solidity function calls).
552
*
553
* Returns the raw returned data. To convert to the expected return value,
554
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
555
*
556
* Requirements:
557
*
558
* - `target` must be a contract.
559
* - calling `target` with `data` must not revert.
560
*
561
* _Available since v3.1._
562
*/
563
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
564
return functionCall(target, data, "Address: low-level call failed");
565
}
566
567
/**
568
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
569
* `errorMessage` as a fallback revert reason when `target` reverts.
570
*
571
* _Available since v3.1._
572
*/
573
function functionCall(
574
address target,
575
bytes memory data,
576
string memory errorMessage
577
) internal returns (bytes memory) {
578
return functionCallWithValue(target, data, 0, errorMessage);
579
}
580
581
/**
582
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
583
* but also transferring `value` wei to `target`.
584
*
585
* Requirements:
586
*
587
* - the calling contract must have an ETH balance of at least `value`.
588
* - the called Solidity function must be `payable`.
589
*
590
* _Available since v3.1._
591
*/
592
function functionCallWithValue(
593
address target,
594
bytes memory data,
595
uint256 value
596
) internal returns (bytes memory) {
597
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
598
}
599
600
/**
601
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
602
* with `errorMessage` as a fallback revert reason when `target` reverts.
603
*
604
* _Available since v3.1._
605
*/
606
function functionCallWithValue(
607
address target,
608
bytes memory data,
609
uint256 value,
610
string memory errorMessage
611
) internal returns (bytes memory) {
612
require(address(this).balance >= value, "Address: insufficient balance for call");
613
require(isContract(target), "Address: call to non-contract");
614
615
// solhint-disable-next-line avoid-low-level-calls
616
(bool success, bytes memory returndata) = target.call{value: value}(data);
617
return _verifyCallResult(success, returndata, errorMessage);
618
}
619
620
/**
621
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
622
* but performing a static call.
623
*
624
* _Available since v3.3._
625
*/
626
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
627
return functionStaticCall(target, data, "Address: low-level static call failed");
628
}
629
630
/**
631
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
632
* but performing a static call.
633
*
634
* _Available since v3.3._
635
*/
636
function functionStaticCall(
637
address target,
638
bytes memory data,
639
string memory errorMessage
640
) internal view returns (bytes memory) {
641
require(isContract(target), "Address: static call to non-contract");
642
643
// solhint-disable-next-line avoid-low-level-calls
644
(bool success, bytes memory returndata) = target.staticcall(data);
645
return _verifyCallResult(success, returndata, errorMessage);
646
}
647
648
/**
649
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
650
* but performing a delegate call.
651
*
652
* _Available since v3.4._
653
*/
654
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
655
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
656
}
657
658
/**
659
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
660
* but performing a delegate call.
661
*
662
* _Available since v3.4._
663
*/
664
function functionDelegateCall(
665
address target,
666
bytes memory data,
667
string memory errorMessage
668
) internal returns (bytes memory) {
669
require(isContract(target), "Address: delegate call to non-contract");
670
671
// solhint-disable-next-line avoid-low-level-calls
672
(bool success, bytes memory returndata) = target.delegatecall(data);
673
return _verifyCallResult(success, returndata, errorMessage);
674
}
675
676
function _verifyCallResult(
677
bool success,
678
bytes memory returndata,
679
string memory errorMessage
680
) private pure returns (bytes memory) {
681
if (success) {
682
return returndata;
683
} else {
684
// Look for revert reason and bubble it up if present
685
if (returndata.length > 0) {
686
// The easiest way to bubble the revert reason is using memory via assembly
687
688
// solhint-disable-next-line no-inline-assembly
689
assembly {
690
let returndata_size := mload(returndata)
691
revert(add(32, returndata), returndata_size)
692
}
693
} else {
694
revert(errorMessage);
695
}
696
}
697
}
698
}
699
700
// File: bsc-library/contracts/SafeBEP20.sol
701
702
pragma solidity ^0.6.0;
703
704
/**
705
* @title SafeBEP20
706
* @dev Wrappers around BEP20 operations that throw on failure (when the token
707
* contract returns false). Tokens that return no value (and instead revert or
708
* throw on failure) are also supported, non-reverting calls are assumed to be
709
* successful.
710
* To use this library you can add a `using SafeBEP20 for IBEP20;` statement to your contract,
711
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
712
*/
713
library SafeBEP20 {
714
using SafeMath for uint256;
715
using Address for address;
716
717
function safeTransfer(
718
IBEP20 token,
719
address to,
720
uint256 value
721
) internal {
722
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
723
}
724
725
function safeTransferFrom(
726
IBEP20 token,
727
address from,
728
address to,
729
uint256 value
730
) internal {
731
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
732
}
733
734
/**
735
* @dev Deprecated. This function has issues similar to the ones found in
736
* {IBEP20-approve}, and its usage is discouraged.
737
*
738
* Whenever possible, use {safeIncreaseAllowance} and
739
* {safeDecreaseAllowance} instead.
740
*/
741
function safeApprove(
742
IBEP20 token,
743
address spender,
744
uint256 value
745
) internal {
746
// safeApprove should only be called when setting an initial allowance,
747
// or when resetting it to zero. To increase and decrease it, use
748
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
749
// solhint-disable-next-line max-line-length
750
require(
751
(value == 0) || (token.allowance(address(this), spender) == 0),
752
"SafeBEP20: approve from non-zero to non-zero allowance"
753
);
754
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
755
}
756
757
function safeIncreaseAllowance(
758
IBEP20 token,
759
address spender,
760
uint256 value
761
) internal {
762
uint256 newAllowance = token.allowance(address(this), spender).add(value);
763
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
764
}
765
766
function safeDecreaseAllowance(
767
IBEP20 token,
768
address spender,
769
uint256 value
770
) internal {
771
uint256 newAllowance =
772
token.allowance(address(this), spender).sub(value, "SafeBEP20: decreased allowance below zero");
773
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
774
}
775
776
/**
777
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
778
* on the return value: the return value is optional (but if data is returned, it must not be false).
779
* @param token The token targeted by the call.
780
* @param data The call data (encoded using abi.encode or one of its variants).
781
*/
782
function _callOptionalReturn(IBEP20 token, bytes memory data) private {
783
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
784
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
785
// the target address contains contract code and also asserts for success in the low-level call.
786
787
bytes memory returndata = address(token).functionCall(data, "SafeBEP20: low-level call failed");
788
if (returndata.length > 0) {
789
// Return data is optional
790
// solhint-disable-next-line max-line-length
791
require(abi.decode(returndata, (bool)), "SafeBEP20: BEP20 operation did not succeed");
792
}
793
}
794
}
795
796
// File: contracts/SmartChefInitializable.sol
797
798
pragma solidity 0.6.12;
799
800
contract CodiStake is Ownable, ReentrancyGuard {
801
using SafeMath for uint256;
802
using SafeBEP20 for IBEP20;
803
804
// Accrued token per share
805
uint256 public accTokenPerShare;
806
807
// The block number when mining ends.
808
uint256 public bonusEndBlock;
809
810
// The block number when mining starts.
811
uint256 public startBlock;
812
813
// The block number of the last pool update
814
uint256 public lastRewardBlock;
815
816
// tokens created per block.
817
uint256 public rewardPerBlock;
818
819
// The precision factor
820
uint256 public PRECISION_FACTOR;
821
822
// The staked & reward token same
823
IBEP20 public stakedToken;
824
825
uint256 public stakedTokenSupply;
826
uint256 public rewardTokenSupplyRemaining;
827
828
uint256 public vestingTime;
829
// Info of each user that stakes tokens (stakedToken)
830
mapping(address => UserInfo) public userInfo;
831
832
struct UserInfo {
833
uint256 amount; // How many staked tokens the user has provided
834
uint256 rewardDebt; // Reward debt
835
uint256 lastDepositedAt;
836
}
837
838
event AdminTokenRecovery(address tokenRecovered, uint256 amount);
839
event Deposit(address indexed user, uint256 amount);
840
event EmergencyWithdraw(address indexed user, uint256 amount);
841
event NewStartAndEndBlocks(uint256 startBlock, uint256 endBlock);
842
event NewRewardPerBlock(uint256 rewardPerBlock);
843
event RewardsStop(uint256 blockNumber);
844
event Withdraw(address indexed user, uint256 amount);
845
846
constructor() public {
847
stakedToken = IBEP20(0xc7981767f644C7F8e483DAbDc413e8a371b83079);
848
rewardPerBlock = 10**18 / 100; // 0.01 token per block
849
startBlock = block.number;
850
bonusEndBlock = block.number.add(10512000); // One year
851
852
PRECISION_FACTOR = uint256(10**12);
853
854
lastRewardBlock = startBlock;
855
}
856
857
/*
858
* @notice Deposit staked tokens and collect reward tokens (if any)