C
C
Coloso.finance
Search…
Contratos Inteligentes

AuditorΓ­as

TechRate Audit
Coloso Full Smart Contract Security Audit.pdf
3MB
PDF
eNebula Audit
Smart Contract Audit Report.pdf
861KB
PDF

Contrato del Token

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

Contrato MasterChef

1
/**
2
*Submitted for verification at BscScan.com on 2021-10-16
3
*/
4
​
5
/**
6
*Submitted for verification at bscscan.com on 2021-09-12
7
*/
8
​
9
// SPDX-License-Identifier: None
10
pragma solidity 0.6.12;
11
​
12
​
13
/**
14
* @dev Contract module that helps prevent reentrant calls to a function.
15
*
16
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
17
* available, which can be applied to functions to make sure there are no nested
18
* (reentrant) calls to them.
19
*
20
* Note that because there is a single `nonReentrant` guard, functions marked as
21
* `nonReentrant` may not call one another. This can be worked around by making
22
* those functions `private`, and then adding `external` `nonReentrant` entry
23
* points to them.
24
*
25
* TIP: If you would like to learn more about reentrancy and alternative ways
26
* to protect against it, check out our blog post
27
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
28
*/
29
abstract contract ReentrancyGuard {
30
// Booleans are more expensive than uint256 or any type that takes up a full
31
// word because each write operation emits an extra SLOAD to first read the
32
// slot's contents, replace the bits taken up by the boolean, and then write
33
// back. This is the compiler's defense against contract upgrades and
34
// pointer aliasing, and it cannot be disabled.
35
​
36
// The values being non-zero value makes deployment a bit more expensive,
37
// but in exchange the refund on every call to nonReentrant will be lower in
38
// amount. Since refunds are capped to a percentage of the total
39
// transaction's gas, it is best to keep them low in cases like this one, to
40
// increase the likelihood of the full refund coming into effect.
41
uint256 private constant _NOT_ENTERED = 1;
42
uint256 private constant _ENTERED = 2;
43
​
44
uint256 private _status;
45
​
46
constructor () internal {
47
_status = _NOT_ENTERED;
48
}
49
​
50
/**
51
* @dev Prevents a contract from calling itself, directly or indirectly.
52
* Calling a `nonReentrant` function from another `nonReentrant`
53
* function is not supported. It is possible to prevent this from happening
54
* by making the `nonReentrant` function external, and make it call a
55
* `private` function that does the actual work.
56
*/
57
modifier nonReentrant() {
58
// On the first call to nonReentrant, _notEntered will be true
59
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
60
​
61
// Any calls to nonReentrant after this point will fail
62
_status = _ENTERED;
63
​
64
_;
65
​
66
// By storing the original value once again, a refund is triggered (see
67
// https://eips.ethereum.org/EIPS/eip-2200)
68
_status = _NOT_ENTERED;
69
}
70
}
71
​
72
/*
73
* @dev Provides information about the current execution context, including the
74
* sender of the transaction and its data. While these are generally available
75
* via msg.sender and msg.data, they should not be accessed in such a direct
76
* manner, since when dealing with GSN meta-transactions the account sending and
77
* paying for execution may not be the actual sender (as far as an application
78
* is concerned).
79
*
80
* This contract is only required for intermediate, library-like contracts.
81
*/
82
abstract contract Context {
83
function _msgSender() internal view virtual returns (address payable) {
84
return msg.sender;
85
}
86
​
87
function _msgData() internal view virtual returns (bytes memory) {
88
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
89
return msg.data;
90
}
91
}
92
​
93
/**
94
* @dev Wrappers over Solidity's arithmetic operations with added overflow
95
* checks.
96
*
97
* Arithmetic operations in Solidity wrap on overflow. This can easily result
98
* in bugs, because programmers usually assume that an overflow raises an
99
* error, which is the standard behavior in high level programming languages.
100
* `SafeMath` restores this intuition by reverting the transaction when an
101
* operation overflows.
102
*
103
* Using this library instead of the unchecked operations eliminates an entire
104
* class of bugs, so it's recommended to use it always.
105
*/
106
library SafeMath {
107
/**
108
* @dev Returns the addition of two unsigned integers, with an overflow flag.
109
*
110
* _Available since v3.4._
111
*/
112
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
113
uint256 c = a + b;
114
if (c < a) return (false, 0);
115
return (true, c);
116
}
117
​
118
/**
119
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
120
*
121
* _Available since v3.4._
122
*/
123
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
124
if (b > a) return (false, 0);
125
return (true, a - b);
126
}
127
​
128
/**
129
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
130
*
131
* _Available since v3.4._
132
*/
133
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
134
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
135
// benefit is lost if 'b' is also tested.
136
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
137
if (a == 0) return (true, 0);
138
uint256 c = a * b;
139
if (c / a != b) return (false, 0);
140
return (true, c);
141
}
142
​
143
/**
144
* @dev Returns the division of two unsigned integers, with a division by zero flag.
145
*
146
* _Available since v3.4._
147
*/
148
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
149
if (b == 0) return (false, 0);
150
return (true, a / b);
151
}
152
​
153
/**
154
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
155
*
156
* _Available since v3.4._
157
*/
158
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
159
if (b == 0) return (false, 0);
160
return (true, a % b);
161
}
162
​
163
/**
164
* @dev Returns the addition of two unsigned integers, reverting on
165
* overflow.
166
*
167
* Counterpart to Solidity's `+` operator.
168
*
169
* Requirements:
170
*
171
* - Addition cannot overflow.
172
*/
173
function add(uint256 a, uint256 b) internal pure returns (uint256) {
174
uint256 c = a + b;
175
require(c >= a, "SafeMath: addition overflow");
176
return c;
177
}
178
​
179
/**
180
* @dev Returns the subtraction of two unsigned integers, reverting on
181
* overflow (when the result is negative).
182
*
183
* Counterpart to Solidity's `-` operator.
184
*
185
* Requirements:
186
*
187
* - Subtraction cannot overflow.
188
*/
189
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
190
require(b <= a, "SafeMath: subtraction overflow");
191
return a - b;
192
}
193
​
194
/**
195
* @dev Returns the multiplication of two unsigned integers, reverting on
196
* overflow.
197
*
198
* Counterpart to Solidity's `*` operator.
199
*
200
* Requirements:
201
*
202
* - Multiplication cannot overflow.
203
*/
204
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
205
if (a == 0) return 0;
206
uint256 c = a * b;
207
require(c / a == b, "SafeMath: multiplication overflow");
208
return c;
209
}
210
​
211
/**
212
* @dev Returns the integer division of two unsigned integers, reverting on
213
* division by zero. The result is rounded towards zero.
214
*
215
* Counterpart to Solidity's `/` operator. Note: this function uses a
216
* `revert` opcode (which leaves remaining gas untouched) while Solidity
217
* uses an invalid opcode to revert (consuming all remaining gas).
218
*
219
* Requirements:
220
*
221
* - The divisor cannot be zero.
222
*/
223
function div(uint256 a, uint256 b) internal pure returns (uint256) {
224
require(b > 0, "SafeMath: division by zero");
225
return a / b;
226
}
227
​
228
/**
229
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
230
* reverting when dividing by zero.
231
*
232
* Counterpart to Solidity's `%` operator. This function uses a `revert`
233
* opcode (which leaves remaining gas untouched) while Solidity uses an
234
* invalid opcode to revert (consuming all remaining gas).
235
*
236
* Requirements:
237
*
238
* - The divisor cannot be zero.
239
*/
240
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
241
require(b > 0, "SafeMath: modulo by zero");
242
return a % b;
243
}
244
​
245
/**
246
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
247
* overflow (when the result is negative).
248
*
249
* CAUTION: This function is deprecated because it requires allocating memory for the error
250
* message unnecessarily. For custom revert reasons use {trySub}.
251
*
252
* Counterpart to Solidity's `-` operator.
253
*
254
* Requirements:
255
*
256
* - Subtraction cannot overflow.
257
*/
258
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
259
require(b <= a, errorMessage);
260
return a - b;
261
}
262
​
263
/**
264
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
265
* division by zero. The result is rounded towards zero.
266
*
267
* CAUTION: This function is deprecated because it requires allocating memory for the error
268
* message unnecessarily. For custom revert reasons use {tryDiv}.
269
*
270
* Counterpart to Solidity's `/` operator. Note: this function uses a
271
* `revert` opcode (which leaves remaining gas untouched) while Solidity
272
* uses an invalid opcode to revert (consuming all remaining gas).
273
*
274
* Requirements:
275
*
276
* - The divisor cannot be zero.
277
*/
278
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
279
require(b > 0, errorMessage);
280
return a / b;
281
}
282
​
283
/**
284
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
285
* reverting with custom message when dividing by zero.
286
*
287
* CAUTION: This function is deprecated because it requires allocating memory for the error
288
* message unnecessarily. For custom revert reasons use {tryMod}.
289
*
290
* Counterpart to Solidity's `%` operator. This function uses a `revert`
291
* opcode (which leaves remaining gas untouched) while Solidity uses an
292
* invalid opcode to revert (consuming all remaining gas).
293
*
294
* Requirements:
295
*
296
* - The divisor cannot be zero.
297
*/
298
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
299
require(b > 0, errorMessage);
300
return a % b;
301
}
302
}
303
​
304
/**
305
* @dev Contract module which provides a basic access control mechanism, where
306
* there is an account (an owner) that can be granted exclusive access to
307
* specific functions.
308
*
309
* By default, the owner account will be the one that deploys the contract. This
310
* can later be changed with {transferOwnership}.
311
*
312
* This module is used through inheritance. It will make available the modifier
313
* `onlyOwner`, which can be applied to your functions to restrict their use to
314
* the owner.
315
*/
316
abstract contract Ownable is Context {
317
address private _owner;
318
​
319
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
320
​
321
/**
322
* @dev Initializes the contract setting the deployer as the initial owner.
323
*/
324
constructor () internal {
325
address msgSender = _msgSender();
326
_owner = msgSender;
327
emit OwnershipTransferred(address(0), msgSender);
328
}
329
​
330
/**
331
* @dev Returns the address of the current owner.
332
*/
333
function owner() public view virtual returns (address) {
334
return _owner;
335
}
336
​
337
/**
338
* @dev Throws if called by any account other than the owner.
339
*/
340
modifier onlyOwner() {
341
require(owner() == _msgSender(), "Ownable: caller is not the owner");
342
_;
343
}
344
​
345
/**
346
* @dev Leaves the contract without owner. It will not be possible to call
347
* `onlyOwner` functions anymore. Can only be called by the current owner.
348
*
349
* NOTE: Renouncing ownership will leave the contract without an owner,
350
* thereby removing any functionality that is only available to the owner.
351
*/
352
function renounceOwnership() public virtual onlyOwner {
353
emit OwnershipTransferred(_owner, address(0));
354
_owner = address(0);
355
}
356
​
357
/**
358
* @dev Transfers ownership of the contract to a new account (`newOwner`).
359
* Can only be called by the current owner.
360
*/
361
function transferOwnership(address newOwner) public virtual onlyOwner {
362
require(newOwner != address(0), "Ownable: new owner is the zero address");
363
emit OwnershipTransferred(_owner, newOwner);
364
_owner = newOwner;
365
}
366
}
367
​
368
/**
369
* @dev Collection of functions related to the address type
370
*/
371
library Address {
372
/**
373
* @dev Returns true if `account` is a contract.
374
*
375
* [IMPORTANT]
376
* ====
377
* It is unsafe to assume that an address for which this function returns
378
* false is an externally-owned account (EOA) and not a contract.
379
*
380
* Among others, `isContract` will return false for the following
381
* types of addresses:
382
*
383
* - an externally-owned account
384
* - a contract in construction
385
* - an address where a contract will be created
386
* - an address where a contract lived, but was destroyed
387
* ====
388
*/
389
function isContract(address account) internal view returns (bool) {
390
// This method relies on extcodesize, which returns 0 for contracts in
391
// construction, since the code is only stored at the end of the
392
// constructor execution.
393
​
394
uint256 size;
395
// solhint-disable-next-line no-inline-assembly
396
assembly { size := extcodesize(account) }
397
return size > 0;
398
}
399
​
400
/**
401
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
402
* `recipient`, forwarding all available gas and reverting on errors.
403
*
404
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
405
* of certain opcodes, possibly making contracts go over the 2300 gas limit
406
* imposed by `transfer`, making them unable to receive funds via
407
* `transfer`. {sendValue} removes this limitation.
408
*
409
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
410
*
411
* IMPORTANT: because control is transferred to `recipient`, care must be
412
* taken to not create reentrancy vulnerabilities. Consider using
413
* {ReentrancyGuard} or the
414
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
415
*/
416
function sendValue(address payable recipient, uint256 amount) internal {
417
require(address(this).balance >= amount, "Address: insufficient balance");
418
​
419
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
420
(bool success, ) = recipient.call{ value: amount }("");
421
require(success, "Address: unable to send value, recipient may have reverted");
422
}
423
​
424
/**
425
* @dev Performs a Solidity function call using a low level `call`. A
426
* plain`call` is an unsafe replacement for a function call: use this
427
* function instead.
428
*
429
* If `target` reverts with a revert reason, it is bubbled up by this
430
* function (like regular Solidity function calls).
431
*
432
* Returns the raw returned data. To convert to the expected return value,
433
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
434
*
435
* Requirements:
436
*
437
* - `target` must be a contract.
438
* - calling `target` with `data` must not revert.
439
*
440
* _Available since v3.1._
441
*/
442
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
443
return functionCall(target, data, "Address: low-level call failed");
444
}
445
​
446
/**
447
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
448
* `errorMessage` as a fallback revert reason when `target` reverts.
449
*
450
* _Available since v3.1._
451
*/
452
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
453
return functionCallWithValue(target, data, 0, errorMessage);
454
}
455
​
456
/**
457
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
458
* but also transferring `value` wei to `target`.
459
*
460
* Requirements:
461
*
462
* - the calling contract must have an ETH balance of at least `value`.
463
* - the called Solidity function must be `payable`.
464
*
465
* _Available since v3.1._
466
*/
467
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
468
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
469
}
470
​
471
/**
472
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
473
* with `errorMessage` as a fallback revert reason when `target` reverts.
474
*
475
* _Available since v3.1._
476
*/
477
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
478
require(address(this).balance >= value, "Address: insufficient balance for call");
479
require(isContract(target), "Address: call to non-contract");
480
​
481
// solhint-disable-next-line avoid-low-level-calls
482
(bool success, bytes memory returndata) = target.call{ value: value }(data);
483
return _verifyCallResult(success, returndata, errorMessage);
484
}
485
​
486
/**
487
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
488
* but performing a static call.
489
*
490
* _Available since v3.3._
491
*/
492
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
493
return functionStaticCall(target, data, "Address: low-level static call failed");
494
}
495
​
496
/**
497
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
498
* but performing a static call.
499
*
500
* _Available since v3.3._
501
*/
502
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
503
require(isContract(target), "Address: static call to non-contract");
504
​
505
// solhint-disable-next-line avoid-low-level-calls
506
(bool success, bytes memory returndata) = target.staticcall(data);
507
return _verifyCallResult(success, returndata, errorMessage);
508
}
509
​
510
/**
511
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
512
* but performing a delegate call.
513
*
514
* _Available since v3.4._
515
*/
516
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
517
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
518
}
519
​
520
/**
521
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
522
* but performing a delegate call.
523
*
524
* _Available since v3.4._
525
*/
526
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
527
require(isContract(target), "Address: delegate call to non-contract");
528
​
529
// solhint-disable-next-line avoid-low-level-calls
530
(bool success, bytes memory returndata) = target.delegatecall(data);
531
return _verifyCallResult(success, returndata, errorMessage);
532
}
533
​
534
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
535
if (success) {
536
return returndata;
537
} else {
538
// Look for revert reason and bubble it up if present
539
if (returndata.length > 0) {
540
// The easiest way to bubble the revert reason is using memory via assembly
541
​
542
// solhint-disable-next-line no-inline-assembly
543
assembly {
544
let returndata_size := mload(returndata)
545
revert(add(32, returndata), returndata_size)
546
}
547
} else {
548
revert(errorMessage);
549
}
550
}
551
}
552
}
553
​
554
​
555
interface IBEP20 {
556
/**
557
* @dev Returns the amount of tokens in existence.
558
*/
559
function totalSupply() external view returns (uint256);
560
​