ERC-20
Overview
Max Total Supply
5,848.319932942200342546 JDFI/S
Holders
218
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
JDFIStakingPool
Compiler Version
v0.7.4+commit.3f05b770
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IWETH.sol'; import './interfaces/IJusDeFi.sol'; import './interfaces/IJDFIStakingPool.sol'; import './StakingPool.sol'; contract JDFIStakingPool is IJDFIStakingPool, StakingPool { using Address for address payable; address private immutable _jusdefi; // _airdropToken cannot be immutable because it is referenced in _beforeTokenTransfer address private _airdropToken; address private immutable _weth; address private immutable _devStakingPool; mapping (address => uint) private _lockedBalances; uint private constant JDFI_PER_ETH = 4; constructor ( address airdropToken, uint initialSupply, address weth, address devStakingPool ) ERC20('Staked JDFI', 'JDFI/S') { _jusdefi = msg.sender; _airdropToken = airdropToken; _weth = weth; _devStakingPool = devStakingPool; _addToWhitelist(airdropToken); _addToWhitelist(msg.sender); // initialSupply is minted before receipt of JDFI; see JusDeFi constructor _mint(msg.sender, initialSupply); // approve devStakingPool to spend WETH IERC20(weth).approve(devStakingPool, type(uint).max); } /** * @notice query locked balance of an address * @param account address to query * @return uint locked balance of account */ function lockedBalanceOf (address account) public view returns (uint) { return _lockedBalances[account]; } /** * @notice stake earned rewards without incurring burns */ function compound () external { uint amount = rewardsOf(msg.sender); _clearRewards(msg.sender); _mint(msg.sender, amount); } /** * @notice deposit and stake JDFI * @param amount quantity of JDFI to stake */ function stake (uint amount) override external { IJusDeFi(_jusdefi).transferFrom(msg.sender, address(this), amount); _mint(msg.sender, amount); } /** * @notice unstake and withdraw JDFI * @param amount quantity of tokens to unstake */ function unstake (uint amount) override external { _burn(msg.sender, amount); IJusDeFi(_jusdefi).burnAndTransfer(msg.sender, amount); } /** * @notice withdraw earned JDFI rewards */ function withdraw () external { IJusDeFi(_jusdefi).burnAndTransfer(msg.sender, rewardsOf(msg.sender)); _clearRewards(msg.sender); } /** * @notice deposit ETH to free locked token balance, at a rate of 1:4 */ function unlock () external payable { // fee pool address not available at deployment time, so fetch dynamically address payable feePool = IJusDeFi(_jusdefi)._feePool(); require(feePool != address(0), 'JusDeFi: liquidity event still in progress'); uint amount = msg.value * JDFI_PER_ETH; require(_lockedBalances[msg.sender] >= amount, 'JusDeFi: insufficient locked balance'); _lockedBalances[msg.sender] -= amount; uint dev = msg.value / 2; // staking pool contract designed to work with ERC20, so convert to WETH IWETH(_weth).deposit{ value: dev }(); IStakingPool(_devStakingPool).distributeRewards(dev); feePool.sendValue(address(this).balance); } /** * @notice distribute rewards to stakers * @param amount quantity to distribute */ function distributeRewards (uint amount) override external { IJusDeFi(_jusdefi).transferFrom(msg.sender, address(this), amount); _distributeRewards(amount); } /** * @notice OpenZeppelin ERC20 hook: prevent transfer of locked tokens * @param from sender * @param to recipient * @param amount quantity transferred */ function _beforeTokenTransfer (address from, address to, uint amount) override internal { super._beforeTokenTransfer(from, to, amount); uint locked = lockedBalanceOf(from); require( locked == 0 || balanceOf(from) - locked >= amount, 'JusDeFi: amount exceeds unlocked balance' ); if (from == _airdropToken) { _lockedBalances[to] += amount; } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.4; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import './interfaces/IJDFIStakingPool.sol'; contract AirdropToken is ERC20 { address private immutable _deployer; address private _jdfiStakingPool; constructor () ERC20('JusDeFi Airdrop', 'JDFI/A') { _deployer = msg.sender; _mint(msg.sender, 10020 ether); } /** * @notice set the JDFIStakingPool address once it is deployed * @param jdfiStakingPool JDFIStakingPool address */ function setJDFIStakingPool (address jdfiStakingPool) external { require(msg.sender == _deployer, 'JusDeFi: sender must be deployer'); require(_jdfiStakingPool == address(0), 'JusDeFi: JDFI Staking Pool contract has already been set'); _jdfiStakingPool = jdfiStakingPool; } /** * @notice airdrop tokens to given accounts in given quantities * @dev _mint and _burn are used in place of _transfer due to gas considerations * @param accounts airdrop recipients * @param amounts airdrop quantities */ function airdrop (address[] calldata accounts, uint[] calldata amounts) external { require(accounts.length == amounts.length, 'JusDeFi: array lengths do not match'); uint length = accounts.length; uint initialSupply = totalSupply(); for (uint i; i < length; i++) { _mint(accounts[i], amounts[i]); } _burn(msg.sender, totalSupply() - initialSupply); } /** * @notice exchange tokens for locked JDFI/S * @dev JDFI/S is locked in JDFIStakingPool _beforeTokenTransfer hook */ function exchange () external { uint amount = balanceOf(msg.sender); _burn(msg.sender, amount); IJDFIStakingPool(_jdfiStakingPool).stake(amount); IJDFIStakingPool(_jdfiStakingPool).transfer(msg.sender, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import './IStakingPool.sol'; interface IJDFIStakingPool is IStakingPool { function stake (uint amount) external; function unstake (uint amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; interface IStakingPool is IERC20 { function distributeRewards (uint amount) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import '@openzeppelin/contracts/math/SafeMath.sol'; import '@uniswap/lib/contracts/libraries/FixedPoint.sol'; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IWETH.sol'; import '@uniswap/v2-periphery/contracts/libraries/UniswapV2OracleLibrary.sol'; import './interfaces/IJusDeFi.sol'; import './interfaces/IStakingPool.sol'; import './interfaces/IJDFIStakingPool.sol'; import './FeePool.sol'; import './DevStakingPool.sol'; import './JDFIStakingPool.sol'; import './UNIV2StakingPool.sol'; contract JusDeFi is IJusDeFi, ERC20 { using FixedPoint for FixedPoint.uq112x112; using FixedPoint for FixedPoint.uq144x112; using SafeMath for uint; // _weth and _uniswapPair cannot be immutable because they are referenced in _beforeTokenTransfer address private _weth; address private immutable _uniswapRouter; address public _uniswapPair; address payable override public _feePool; address public immutable _devStakingPool; address public immutable _jdfiStakingPool; address public immutable _univ2StakingPool; uint private constant LIQUIDITY_EVENT_PERIOD = 3 days; bool public _liquidityEventOpen; uint public immutable _liquidityEventClosedAt; mapping (address => bool) private _implicitApprovalWhitelist; uint private constant RESERVE_TEAM = 1980 ether; uint private constant RESERVE_JUSTICE = 10020 ether; uint private constant RESERVE_LIQUIDITY_EVENT = 10000 ether; uint private constant REWARDS_SEED = 2000 ether; uint private constant JDFI_PER_ETH = 4; uint private constant ORACLE_PERIOD = 5 minutes; FixedPoint.uq112x112 private _priceAverage; uint private _priceCumulativeLast; uint32 private _blockTimestampLast; constructor ( address airdropToken, address uniswapRouter ) ERC20('JusDeFi', 'JDFI') { address weth = IUniswapV2Router02(uniswapRouter).WETH(); _weth = weth; address uniswapPair = IUniswapV2Factory( IUniswapV2Router02(uniswapRouter).factory() ).createPair(weth, address(this)); _uniswapRouter = uniswapRouter; _uniswapPair = uniswapPair; address devStakingPool = address(new DevStakingPool(weth)); _devStakingPool = devStakingPool; address jdfiStakingPool = address(new JDFIStakingPool(airdropToken, RESERVE_LIQUIDITY_EVENT, weth, devStakingPool)); _jdfiStakingPool = jdfiStakingPool; address univ2StakingPool = address(new UNIV2StakingPool(uniswapPair, uniswapRouter)); _univ2StakingPool = univ2StakingPool; // mint staked JDFI after-the-fact to match minted JDFI/S _mint(jdfiStakingPool, RESERVE_LIQUIDITY_EVENT); // mint JDFI for conversion to locked JDFI/S _mint(airdropToken, RESERVE_JUSTICE); // mint team JDFI _mint(msg.sender, RESERVE_TEAM); // transfer all minted JDFI/E to sender IStakingPool(devStakingPool).transfer(msg.sender, IStakingPool(devStakingPool).balanceOf(address(this))); _liquidityEventClosedAt = block.timestamp + LIQUIDITY_EVENT_PERIOD; _liquidityEventOpen = true; // enable trusted addresses to transfer tokens without approval _implicitApprovalWhitelist[jdfiStakingPool] = true; _implicitApprovalWhitelist[univ2StakingPool] = true; _implicitApprovalWhitelist[uniswapRouter] = true; } /** * @notice get average JDFI price over the last ORACLE_PERIOD * @dev adapted from https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleOracleSimple.sol * @param amount quantity of ETH used for purchase * @return uint quantity of JDFI purchased, or zero if ORACLE_PERIOD has passed since las tupdate */ function consult (uint amount) override external view returns (uint) { if (block.timestamp - uint(_blockTimestampLast) > ORACLE_PERIOD) { return 0; } else { return _priceAverage.mul(amount).decode144(); } } /** * @notice OpenZeppelin ERC20#transferFrom: enable transfers by staking pools without allowance * @param from sender * @param to recipient * @param amount quantity transferred */ function transferFrom (address from, address to, uint amount) override(IERC20, ERC20) public returns (bool) { if (_implicitApprovalWhitelist[msg.sender]) { _transfer(from, to, amount); return true; } else { return super.transferFrom(from, to, amount); } } /** * @notice burn tokens held by sender * @param amount quantity of tokens to burn */ function burn (uint amount) override external { _burn(msg.sender, amount); } /** * @notice transfer tokens, deducting fee * @param account recipient of transfer * @param amount quantity of tokens to transfer, before deduction */ function burnAndTransfer (address account, uint amount) override external { uint withheld = FeePool(_feePool).calculateWithholding(amount); _transfer(msg.sender, _feePool, withheld); _burn(_feePool, withheld / 2); _transfer(msg.sender, account, amount - withheld); } /** * @notice deposit ETH to receive JDFI/S at rate of 1:4 */ function liquidityEventDeposit () external payable { require(_liquidityEventOpen, 'JusDeFi: liquidity event has closed'); try IStakingPool(_jdfiStakingPool).transfer(msg.sender, msg.value * JDFI_PER_ETH) returns (bool) {} catch { revert('JusDeFi: deposit amount surpasses available supply'); } } /** * @notice close liquidity event, add Uniswap liquidity, burn undistributed JDFI */ function liquidityEventClose () external { require(block.timestamp >= _liquidityEventClosedAt, 'JusDeFi: liquidity event still in progress'); require(_liquidityEventOpen, 'JusDeFi: liquidity event has already ended'); _liquidityEventOpen = false; uint remaining = IStakingPool(_jdfiStakingPool).balanceOf(address(this)); uint distributed = RESERVE_LIQUIDITY_EVENT - remaining; // require minimum deposit to avoid nonspecific Uniswap error: ds-math-sub-underflow require(distributed >= 1 ether, 'JusDeFi: insufficient liquidity added'); // prepare Uniswap for minting my FeePool IUniswapV2Pair pair = IUniswapV2Pair(_uniswapPair); address weth = _weth; IWETH(weth).deposit{ value: distributed / JDFI_PER_ETH }(); IWETH(weth).transfer(address(pair), distributed / JDFI_PER_ETH); _mint(address(pair), distributed); _feePool = payable(new FeePool( _jdfiStakingPool, _univ2StakingPool, _uniswapRouter, _uniswapPair )); // UNI-V2 has been minted, so price is available _priceCumulativeLast = address(this) > _weth ? pair.price0CumulativeLast() : pair.price1CumulativeLast(); _blockTimestampLast = UniswapV2OracleLibrary.currentBlockTimestamp(); // unstake and burn (including fee accrued on unstaking) IJDFIStakingPool(_jdfiStakingPool).unstake(remaining); _burn(address(this), balanceOf(address(this))); _burn(_feePool, balanceOf(_feePool)); // seed staking pools _mint(_feePool, REWARDS_SEED); } /** * @notice OpenZeppelin ERC20 hook: prevent transfers during liquidity event, update oracle price * @dev adapted from https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleOracleSimple.sol * @param from sender * @param to recipient * @param amount quantity transferred */ function _beforeTokenTransfer (address from, address to, uint amount) override internal { require(!_liquidityEventOpen, 'JusDeFi: liquidity event still in progress'); super._beforeTokenTransfer(from, to, amount); address pair = _uniswapPair; if (from == pair || (to == pair && from != address(0))) { ( uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp ) = UniswapV2OracleLibrary.currentCumulativePrices(pair); uint32 timeElapsed = blockTimestamp - _blockTimestampLast; // overflow is desired // only store the ETH -> JDFI price uint priceCumulative = address(this) > _weth ? price0Cumulative : price1Cumulative; if (timeElapsed >= ORACLE_PERIOD) { // overflow is desired, casting never truncates // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed _priceAverage = FixedPoint.uq112x112(uint224((priceCumulative - _priceCumulativeLast) / timeElapsed)); _priceCumulativeLast = priceCumulative; _blockTimestampLast = blockTimestamp; } } } }
pragma solidity >=0.4.0; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } }
pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
pragma solidity >=0.6.2; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; }
pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; }
pragma solidity >=0.5.0; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/lib/contracts/libraries/FixedPoint.sol'; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; interface IJusDeFi is IERC20 { function consult (uint amount) external view returns (uint); function burn (uint amount) external; function burnAndTransfer (address account, uint amount) external; function _feePool () external view returns (address payable); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/math/Math.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol'; import './interfaces/IJusDeFi.sol'; import './interfaces/IStakingPool.sol'; contract FeePool { address private immutable _jusdefi; address private immutable _uniswapRouter; address private immutable _uniswapPair; address public immutable _jdfiStakingPool; address public immutable _univ2StakingPool; // fee specified in basis points uint public _fee; // initialized at 0; not set until #liquidityEventClose uint private constant FEE_BASE = 1000; uint private constant BP_DIVISOR = 10000; // allow slippage of 0.6% uint private constant BUYBACK_SLIPPAGE = 60; uint private constant UNIV2_STAKING_MULTIPLIER = 3; uint private immutable _initialUniTotalSupply; uint public _votesIncrease; uint public _votesDecrease; uint private _lastBuybackAt; uint private _lastRebaseAt; constructor ( address jdfiStakingPool, address univ2StakingPool, address uniswapRouter, address uniswapPair ) { _jusdefi = msg.sender; _jdfiStakingPool = jdfiStakingPool; _univ2StakingPool = univ2StakingPool; _uniswapRouter = uniswapRouter; _uniswapPair = uniswapPair; // approve router to handle UNI-V2 for buybacks IUniswapV2Pair(uniswapPair).approve(uniswapRouter, type(uint).max); _initialUniTotalSupply = IUniswapV2Pair(uniswapPair).mint(address(this)) + IUniswapV2Pair(uniswapPair).MINIMUM_LIQUIDITY(); _fee = FEE_BASE; } receive () external payable { require(msg.sender == _uniswapRouter || msg.sender == _jdfiStakingPool, 'JusDeFi: invalid ETH deposit'); } /** * @notice calculate quantity of JDFI to withhold (burned and as rewards) on unstake * @param amount quantity untsaked * @return unt quantity withheld */ function calculateWithholding (uint amount) external view returns (uint) { return amount * _fee / BP_DIVISOR; } /** * @notice vote for weekly fee changes by sending ETH * @param increase whether vote is to increase or decrease the fee */ function vote (bool increase) external payable { if (increase) { _votesIncrease += msg.value; } else { _votesDecrease += msg.value; } } /** * @notice withdraw Uniswap liquidity in excess of initial amount, purchase and burn JDFI */ function buyback () external { require(block.timestamp / (1 days) % 7 == 1, 'JusDeFi: buyback must take place on Friday (UTC)'); require(block.timestamp - _lastBuybackAt > 1 days, 'JusDeFi: buyback already called this week'); _lastBuybackAt = block.timestamp; address[] memory path = new address[](2); path[0] = IUniswapV2Router02(_uniswapRouter).WETH(); path[1] = _jusdefi; // check output to fail fast if price has changed beyond allowed limits uint[] memory outputs = IUniswapV2Router02(_uniswapRouter).getAmountsOut( 1e9, path ); uint requiredOutput = IJusDeFi(_jusdefi).consult(1e9); require(outputs[1] * (BP_DIVISOR + BUYBACK_SLIPPAGE) / BP_DIVISOR >= requiredOutput, 'JusDeFi: buyback price slippage too high'); uint initialBalance = IJusDeFi(_jusdefi).balanceOf(address(this)); // remove liquidity in excess of original amount uint initialUniTotalSupply = _initialUniTotalSupply; uint uniTotalSupply = IUniswapV2Pair(_uniswapPair).totalSupply(); if (uniTotalSupply > initialUniTotalSupply) { uint delta = Math.min( IUniswapV2Pair(_uniswapPair).balanceOf(address(this)), uniTotalSupply - initialUniTotalSupply ); if (delta > 0) { // minimum output not relevant due to earlier check IUniswapV2Router02(_uniswapRouter).removeLiquidityETH( _jusdefi, delta, 0, 0, address(this), block.timestamp ); } } // buyback JDFI using ETH from withdrawn liquidity and fee votes if (address(this).balance > 0) { // minimum output not relevant due to earlier check IUniswapV2Router02(_uniswapRouter).swapExactETHForTokens{ value: address(this).balance }( 0, path, address(this), block.timestamp ); } IJusDeFi(_jusdefi).burn(IJusDeFi(_jusdefi).balanceOf(address(this)) - initialBalance); } /** * @notice distribute collected fees to staking pools */ function rebase () external { require(block.timestamp / (1 days) % 7 == 3, 'JusDeFi: rebase must take place on Sunday (UTC)'); require(block.timestamp - _lastRebaseAt > 1 days, 'JusDeFi: rebase already called this week'); _lastRebaseAt = block.timestamp; // skim to prevent manipulation of JDFI reserve IUniswapV2Pair(_uniswapPair).skim(address(this)); uint rewards = IJusDeFi(_jusdefi).balanceOf(address(this)); uint jdfiStakingPoolStaked = IERC20(_jdfiStakingPool).totalSupply(); uint univ2StakingPoolStaked = IJusDeFi(_jusdefi).balanceOf(_uniswapPair) * IERC20(_univ2StakingPool).totalSupply() / IUniswapV2Pair(_uniswapPair).totalSupply(); uint weight = jdfiStakingPoolStaked + univ2StakingPoolStaked * UNIV2_STAKING_MULTIPLIER; // if weight is zero, staked amounts are also zero, avoiding zero-division error if (jdfiStakingPoolStaked > 0) { IStakingPool(_jdfiStakingPool).distributeRewards( rewards * jdfiStakingPoolStaked / weight ); } if (univ2StakingPoolStaked > 0) { IStakingPool(_univ2StakingPool).distributeRewards( rewards * univ2StakingPoolStaked * UNIV2_STAKING_MULTIPLIER / weight ); } // set fee for the next week uint increase = _votesIncrease; uint decrease = _votesDecrease; if (increase > decrease) { _fee = FEE_BASE + _sigmoid(increase - decrease); } else if (increase < decrease) { _fee = FEE_BASE - _sigmoid(decrease - increase); } else { _fee = FEE_BASE; } _votesIncrease = 0; _votesDecrease = 0; } /** * @notice calculate fee offset based on net votes * @dev input is a uint, therefore sigmoid is only implemented for positive values * @return uint fee offset from FEE_BASE */ function _sigmoid (uint net) private pure returns (uint) { return FEE_BASE * net / (3 ether + net); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import './StakingPool.sol'; contract DevStakingPool is StakingPool { address private immutable _weth; constructor (address weth) ERC20('JDFI ETH Fund', 'JDFI/E') { _weth = weth; _ignoreWhitelist(); _mint(msg.sender, 10000 ether); } /** * @notice withdraw earned WETH rewards */ function withdraw () external { IERC20(_weth).transfer(msg.sender, rewardsOf(msg.sender)); _clearRewards(msg.sender); } /** * @notice distribute rewards to stakers * @param amount quantity to distribute */ function distributeRewards (uint amount) override external { IERC20(_weth).transferFrom(msg.sender, address(this), amount); _distributeRewards(amount); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol'; import './interfaces/IJusDeFi.sol'; import './StakingPool.sol'; contract UNIV2StakingPool is StakingPool { using Address for address payable; address private immutable _jusdefi; address private immutable _uniswapPair; address private immutable _uniswapRouter; constructor ( address uniswapPair, address uniswapRouter ) ERC20('Staked JDFI/WETH UNI-V2', 'JDFI-WETH-UNI-V2/S') { _jusdefi = msg.sender; _uniswapPair = uniswapPair; _uniswapRouter = uniswapRouter; IERC20(uniswapPair).approve(uniswapRouter, type(uint).max); _addToWhitelist(msg.sender); } receive () external payable { require(msg.sender == _uniswapRouter, 'JusDeFi: invalid ETH deposit'); } /** * @notice deposit earned JDFI and sent ETH to Uniswap and stake without incurring burns * @param amountETHMin minimum quantity of ETH to stake, despite price depreciation */ function compound (uint amountETHMin) external payable { uint rewards = rewardsOf(msg.sender); _clearRewards(msg.sender); ( , uint amountETH, uint liquidity ) = IUniswapV2Router02(_uniswapRouter).addLiquidityETH{ value: msg.value }( _jusdefi, rewards, rewards, amountETHMin, address(this), block.timestamp ); // return remaining ETH to sender msg.sender.sendValue(msg.value - amountETH); _mint(msg.sender, liquidity); } /** * @notice deposit and stake preexisting Uniswap liquidity tokens * @param amount quantity of Uniswap liquidity tokens to stake */ function stake (uint amount) external { IERC20(_uniswapPair).transferFrom(msg.sender, address(this), amount); _mint(msg.sender, amount); } /** * @notice deposit JDFI and ETH to Uniswap and stake * @dev params passed directly to IUniswapV2Router02#addLiquidityETH * @param amountJDFIDesired quantity of JDFI to stake if price depreciates * @param amountJDFIMin minimum quantity of JDFI to stake, despite price appreciation * @param amountETHMin minimum quantity of ETH to stake, despite price depreciation */ function stake ( uint amountJDFIDesired, uint amountJDFIMin, uint amountETHMin ) external payable { IERC20(_jusdefi).transferFrom(msg.sender, address(this), amountJDFIDesired); // prevent possible theft of rounding error require(amountJDFIDesired >= amountJDFIMin, 'JusDeFi: minimum JDFI must not exceed desired JDFI'); require(msg.value >= amountETHMin, 'JusDeFi: minimum ETH must not exceed message value'); ( uint amountJDFI, uint amountETH, uint liquidity ) = IUniswapV2Router02(_uniswapRouter).addLiquidityETH{ value: msg.value }( _jusdefi, amountJDFIDesired, amountJDFIMin, amountETHMin, address(this), block.timestamp ); // return remaining JDFI and ETH to sender IERC20(_jusdefi).transfer(msg.sender, amountJDFIDesired - amountJDFI); msg.sender.sendValue(msg.value - amountETH); _mint(msg.sender, liquidity); } /** * @notice remove Uniswap liquidity and withdraw and unstake underlying JDFI and ETH * @param amount quantity of tokens to unstake * @param amountJDFIMin minimum quantity of JDFI to unstake, despite price appreciate * @param amountETHMin minimum quantity of ETH to unstake, despite price depreciation */ function unstake ( uint amount, uint amountJDFIMin, uint amountETHMin ) external { _burn(msg.sender, amount); ( uint amountJDFI, uint amountETH ) = IUniswapV2Router02(_uniswapRouter).removeLiquidityETH( _jusdefi, amount, amountJDFIMin, amountETHMin, address(this), block.timestamp ); IJusDeFi(_jusdefi).burnAndTransfer(msg.sender, amountJDFI); msg.sender.sendValue(amountETH); } /** * @notice withdraw earned JDFI rewards */ function withdraw () external { IJusDeFi(_jusdefi).burnAndTransfer(msg.sender, rewardsOf(msg.sender)); _clearRewards(msg.sender); } /** * @notice distribute rewards to stakers * @param amount quantity to distribute */ function distributeRewards (uint amount) override external { IJusDeFi(_jusdefi).transferFrom(msg.sender, address(this), amount); _distributeRewards(amount); } }
pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import './interfaces/IStakingPool.sol'; abstract contract StakingPool is IStakingPool, ERC20 { uint private constant REWARD_SCALAR = 1e18; // values scaled by REWARD_SCALAR uint private _cumulativeRewardPerToken; mapping (address => uint) private _rewardsExcluded; mapping (address => uint) private _rewardsReserved; mapping (address => bool) private _transferWhitelist; bool private _skipWhitelist; /** * @notice get rewards of given account available for withdrawal * @param account owner of rewards * @return uint quantity of rewards available */ function rewardsOf (address account) public view returns (uint) { return ( balanceOf(account) * _cumulativeRewardPerToken + _rewardsReserved[account] - _rewardsExcluded[account] ) / REWARD_SCALAR; } /** * @notice distribute rewards proportionally to stake holders * @param amount quantity of rewards to distribute */ function _distributeRewards (uint amount) internal { uint supply = totalSupply(); require(supply > 0, 'StakingPool: supply must be greater than zero'); _cumulativeRewardPerToken += amount * REWARD_SCALAR / supply; } /** * @notice remove pending rewards associated with account * @param account owner of rewards */ function _clearRewards (address account) internal { _rewardsExcluded[account] = balanceOf(account) * _cumulativeRewardPerToken; delete _rewardsReserved[account]; } /** * @notice add address to transfer whitelist to allow it to execute transfers * @param account address to add to whitelist */ function _addToWhitelist (address account) internal { _transferWhitelist[account] = true; } /** * @notice disregard transfer whitelist */ function _ignoreWhitelist () internal { _skipWhitelist = true; } /** * @notice OpenZeppelin ERC20 hook: prevent manual transfers, maintain reward distribution when tokens are transferred * @param from sender * @param to recipient * @param amount quantity transferred */ function _beforeTokenTransfer (address from, address to, uint amount) virtual override internal { super._beforeTokenTransfer(from, to, amount); if (from != address(0) && to != address(0)) { require(_transferWhitelist[msg.sender] || _skipWhitelist, 'JusDeFi: staked tokens are non-transferrable'); } uint delta = amount * _cumulativeRewardPerToken; if (from != address(0)) { uint excluded = balanceOf(from) * _cumulativeRewardPerToken; _rewardsReserved[from] += excluded - _rewardsExcluded[from]; _rewardsExcluded[from] = excluded - delta; } if (to != address(0)) { _rewardsExcluded[to] += delta; } } }
pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '../JusDeFi.sol'; import '../interfaces/IStakingPool.sol'; contract JusDeFiMock is JusDeFi { constructor (address airdropToken, address uniswapRouter) JusDeFi(airdropToken, uniswapRouter) {} function mint (address account, uint amount) external { _mint(account, amount); } function distributeJDFIStakingPoolRewards (uint amount) external { _mint(address(this), amount); IStakingPool(_jdfiStakingPool).distributeRewards(amount); } function distributeUNIV2StakingPoolRewards (uint amount) external { _mint(address(this), amount); IStakingPool(_univ2StakingPool).distributeRewards(amount); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; import '../StakingPool.sol'; contract StakingPoolMock is StakingPool { constructor () ERC20('', '') {} function mint (address account, uint amount) external { _mint(account, amount); } // override needed for IStakingPool interface function distributeRewards (uint amount) override external { _distributeRewards(amount); } function clearRewards (address account) external { _clearRewards(account); } function addToWhitelist (address account) external { _addToWhitelist(account); } function ignoreWhitelist () external { _ignoreWhitelist(); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"airdropToken","type":"address"},{"internalType":"uint256","name":"initialSupply","type":"uint256"},{"internalType":"address","name":"weth","type":"address"},{"internalType":"address","name":"devStakingPool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"distributeRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"lockedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"rewardsOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlock","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e06040523480156200001157600080fd5b5060405162001f0038038062001f00833981810160405260808110156200003757600080fd5b50805160208083015160408085015160609095015181518083018352600b81526a5374616b6564204a44464960a81b818601908152835180850190945260068452654a4446492f5360d01b9584019590955280519596939593949193909291620000a5916003919062000588565b508051620000bb90600490602084019062000588565b50506005805460ff191660121790555033606090811b608052600a80546001600160a01b03871661010002610100600160a81b03199091161790556001600160601b031983821b811660a0529082901b1660c0526200011a84620001c4565b6200012533620001c4565b620001313384620001e8565b816001600160a01b031663095ea7b3826000196040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156200018b57600080fd5b505af1158015620001a0573d6000803e3d6000fd5b505050506040513d6020811015620001b757600080fd5b5062000634945050505050565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6001600160a01b03821662000244576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6200025260008383620002f7565b6200026e81600254620003b660201b62000ce41790919060201c565b6002556001600160a01b03821660009081526020818152604090912054620002a191839062000ce4620003b6821b17901c565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6200030f8383836200041860201b62000d451760201c565b60006200031c846200054d565b90508015806200033857508181620003348662000568565b0310155b620003755760405162461bcd60e51b815260040180806020018281038252602881526020018062001eac6028913960400191505060405180910390fd5b600a546001600160a01b03858116610100909204161415620003b0576001600160a01b0383166000908152600b602052604090208054830190555b50505050565b60008282018381101562000411576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b620004308383836200058360201b62000c801760201c565b6001600160a01b038316158015906200045157506001600160a01b03821615155b15620004b5573360009081526009602052604090205460ff1680620004785750600a5460ff165b620004b55760405162461bcd60e51b815260040180806020018281038252602c81526020018062001ed4602c913960400191505060405180910390fd5b60065481026001600160a01b038416156200051957600654600090620004db8662000568565b6001600160a01b0387166000908152600760208181526040808420805460088452919094208054959096029081039094019094559092528390039055505b6001600160a01b03831615620003b0576001600160a01b038316600090815260076020526040902080548201905550505050565b6001600160a01b03166000908152600b602052604090205490565b6001600160a01b031660009081526020819052604090205490565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620005c057600085556200060b565b82601f10620005db57805160ff19168380011785556200060b565b828001600101855582156200060b579182015b828111156200060b578251825591602001919060010190620005ee565b50620006199291506200061d565b5090565b5b808211156200061957600081556001016200061e565b60805160601c60a05160601c60c05160601c61182e6200067e60003980610bf0525080610b7c52508061063c52806106f7528061082c52806109be5280610a41525061182e6000f3fe6080604052600436106101145760003560e01c806359355736116100a0578063a694fc3a11610064578063a694fc3a14610410578063a69df4b51461043a578063a9059cbb14610442578063dd62ed3e1461047b578063f69e2046146104b657610114565b8063593557361461033257806359974e381461036557806370a082311461038f57806395d89b41146103c2578063a457c2d7146103d757610114565b80632e17de78116100e75780632e17de781461025a578063313ce5671461028657806339509351146102b15780633ccfd60b146102ea578063479ba7ae146102ff57610114565b806306fdde0314610119578063095ea7b3146101a357806318160ddd146101f057806323b872dd14610217575b600080fd5b34801561012557600080fd5b5061012e6104cb565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610168578181015183820152602001610150565b50505050905090810190601f1680156101955780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101af57600080fd5b506101dc600480360360408110156101c657600080fd5b506001600160a01b038135169060200135610561565b604080519115158252519081900360200190f35b3480156101fc57600080fd5b5061020561057e565b60408051918252519081900360200190f35b34801561022357600080fd5b506101dc6004803603606081101561023a57600080fd5b506001600160a01b03813581169160208101359091169060400135610584565b34801561026657600080fd5b506102846004803603602081101561027d57600080fd5b503561060b565b005b34801561029257600080fd5b5061029b61069e565b6040805160ff9092168252519081900360200190f35b3480156102bd57600080fd5b506101dc600480360360408110156102d457600080fd5b506001600160a01b0381351690602001356106a7565b3480156102f657600080fd5b506102846106f5565b34801561030b57600080fd5b506102056004803603602081101561032257600080fd5b50356001600160a01b0316610797565b34801561033e57600080fd5b506102056004803603602081101561035557600080fd5b50356001600160a01b03166107e4565b34801561037157600080fd5b506102846004803603602081101561038857600080fd5b50356107ff565b34801561039b57600080fd5b50610205600480360360208110156103b257600080fd5b50356001600160a01b03166108ad565b3480156103ce57600080fd5b5061012e6108c8565b3480156103e357600080fd5b506101dc600480360360408110156103fa57600080fd5b506001600160a01b038135169060200135610929565b34801561041c57600080fd5b506102846004803603602081101561043357600080fd5b5035610991565b610284610a3d565b34801561044e57600080fd5b506101dc6004803603604081101561046557600080fd5b506001600160a01b038135169060200135610c85565b34801561048757600080fd5b506102056004803603604081101561049e57600080fd5b506001600160a01b0381358116916020013516610c99565b3480156104c257600080fd5b50610284610cc4565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105575780601f1061052c57610100808354040283529160200191610557565b820191906000526020600020905b81548152906001019060200180831161053a57829003601f168201915b5050505050905090565b600061057561056e610e64565b8484610e68565b50600192915050565b60025490565b6000610591848484610f54565b6106018461059d610e64565b6105fc85604051806060016040528060288152602001611718602891396001600160a01b038a166000908152600160205260408120906105db610e64565b6001600160a01b0316815260208101919091526040016000205491906110af565b610e68565b5060019392505050565b6106153382611146565b60408051633a1528c960e11b81523360048201526024810183905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163742a519291604480830192600092919082900301818387803b15801561068357600080fd5b505af1158015610697573d6000803e3d6000fd5b5050505050565b60055460ff1690565b60006105756106b4610e64565b846105fc85600160006106c5610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610ce4565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663742a51923361072e33610797565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561077457600080fd5b505af1158015610788573d6000803e3d6000fd5b5050505061079533611242565b565b6001600160a01b0381166000908152600760209081526040808320546008909252822054600654670de0b6b3a76400009291906107d3866108ad565b020103816107dd57fe5b0492915050565b6001600160a01b03166000908152600b602052604090205490565b604080516323b872dd60e01b81523360048201523060248201526044810183905290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916323b872dd9160648083019260209291908290030181600087803b15801561087457600080fd5b505af1158015610888573d6000803e3d6000fd5b505050506040513d602081101561089e57600080fd5b506108aa90508161127c565b50565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105575780601f1061052c57610100808354040283529160200191610557565b6000610575610936610e64565b846105fc856040518060600160405280602581526020016117d46025913960016000610960610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906110af565b604080516323b872dd60e01b81523360048201523060248201526044810183905290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916323b872dd9160648083019260209291908290030181600087803b158015610a0657600080fd5b505af1158015610a1a573d6000803e3d6000fd5b505050506040513d6020811015610a3057600080fd5b506108aa905033826112eb565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663614bfe2e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9857600080fd5b505afa158015610aac573d6000803e3d6000fd5b505050506040513d6020811015610ac257600080fd5b505190506001600160a01b038116610b0b5760405162461bcd60e51b815260040180806020018281038252602a8152602001806117aa602a913960400191505060405180910390fd5b336000908152600b60205260409020543460040290811115610b5e5760405162461bcd60e51b815260040180806020018281038252602481526020018061169b6024913960400191505060405180910390fd5b336000908152600b60205260408120805483900390556002340490507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015610bd557600080fd5b505af1158015610be9573d6000803e3d6000fd5b50505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166359974e38826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610c5457600080fd5b505af1158015610c68573d6000803e3d6000fd5b50610c80925050506001600160a01b038416476113db565b505050565b6000610575610c92610e64565b8484610f54565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000610ccf33610797565b9050610cda33611242565b6108aa33826112eb565b600082820183811015610d3e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b610d50838383610c80565b6001600160a01b03831615801590610d7057506001600160a01b03821615155b15610dd0573360009081526009602052604090205460ff1680610d955750600a5460ff165b610dd05760405162461bcd60e51b815260040180806020018281038252602c8152602001806116bf602c913960400191505060405180910390fd5b60065481026001600160a01b03841615610e30576000600654610df2866108ad565b6001600160a01b0387166000908152600760208181526040808420805460088452919094208054959096029081039094019094559092528390039055505b6001600160a01b03831615610e5e576001600160a01b03831660009081526007602052604090208054820190555b50505050565b3390565b6001600160a01b038316610ead5760405162461bcd60e51b81526004018080602001828103825260248152602001806117866024913960400191505060405180910390fd5b6001600160a01b038216610ef25760405162461bcd60e51b81526004018080602001828103825260228152602001806115f16022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610f995760405162461bcd60e51b81526004018080602001828103825260258152602001806117616025913960400191505060405180910390fd5b6001600160a01b038216610fde5760405162461bcd60e51b81526004018080602001828103825260238152602001806115ac6023913960400191505060405180910390fd5b610fe98383836114c0565b61102681604051806060016040528060268152602001611613602691396001600160a01b03861660009081526020819052604090205491906110af565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546110559082610ce4565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561113e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156111035781810151838201526020016110eb565b50505050905090810190601f1680156111305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b03821661118b5760405162461bcd60e51b81526004018080602001828103825260218152602001806117406021913960400191505060405180910390fd5b611197826000836114c0565b6111d4816040518060600160405280602281526020016115cf602291396001600160a01b03851660009081526020819052604090205491906110af565b6001600160a01b0383166000908152602081905260409020556002546111fa9082611569565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60065461124e826108ad565b6001600160a01b03909216600090815260076020908152604080832093909402909255600890915290812055565b600061128661057e565b9050600081116112c75760405162461bcd60e51b815260040180806020018281038252602d8152602001806116eb602d913960400191505060405180910390fd5b80670de0b6b3a76400008302816112da57fe5b600680549290910490910190555050565b6001600160a01b038216611346576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611352600083836114c0565b60025461135f9082610ce4565b6002556001600160a01b0382166000908152602081905260409020546113859082610ce4565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b80471015611430576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461147b576040519150601f19603f3d011682016040523d82523d6000602084013e611480565b606091505b5050905080610c805760405162461bcd60e51b815260040180806020018281038252603a815260200180611639603a913960400191505060405180910390fd5b6114cb838383610d45565b60006114d6846107e4565b90508015806114ef575081816114eb866108ad565b0310155b61152a5760405162461bcd60e51b81526004018080602001828103825260288152602001806116736028913960400191505060405180910390fd5b600a546001600160a01b03858116610100909204161415610e5e576001600160a01b0383166000908152600b6020526040902080548301905550505050565b6000610d3e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506110af56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644a7573446546693a20616d6f756e74206578636565647320756e6c6f636b65642062616c616e63654a7573446546693a20696e73756666696369656e74206c6f636b65642062616c616e63654a7573446546693a207374616b656420746f6b656e7320617265206e6f6e2d7472616e736665727261626c655374616b696e67506f6f6c3a20737570706c79206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734a7573446546693a206c6971756964697479206576656e74207374696c6c20696e2070726f677265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220530ec26d67c90825a3c276c7d3dd124b94cbdf84d820d1119eec984cfb240cdc64736f6c634300070400334a7573446546693a20616d6f756e74206578636565647320756e6c6f636b65642062616c616e63654a7573446546693a207374616b656420746f6b656e7320617265206e6f6e2d7472616e736665727261626c650000000000000000000000001f89abfc1a80eae67b8036a49204823e8861eaf600000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000001a23f34c29187e48b5e63246a743a46cf45d067c
Deployed Bytecode
0x6080604052600436106101145760003560e01c806359355736116100a0578063a694fc3a11610064578063a694fc3a14610410578063a69df4b51461043a578063a9059cbb14610442578063dd62ed3e1461047b578063f69e2046146104b657610114565b8063593557361461033257806359974e381461036557806370a082311461038f57806395d89b41146103c2578063a457c2d7146103d757610114565b80632e17de78116100e75780632e17de781461025a578063313ce5671461028657806339509351146102b15780633ccfd60b146102ea578063479ba7ae146102ff57610114565b806306fdde0314610119578063095ea7b3146101a357806318160ddd146101f057806323b872dd14610217575b600080fd5b34801561012557600080fd5b5061012e6104cb565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610168578181015183820152602001610150565b50505050905090810190601f1680156101955780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101af57600080fd5b506101dc600480360360408110156101c657600080fd5b506001600160a01b038135169060200135610561565b604080519115158252519081900360200190f35b3480156101fc57600080fd5b5061020561057e565b60408051918252519081900360200190f35b34801561022357600080fd5b506101dc6004803603606081101561023a57600080fd5b506001600160a01b03813581169160208101359091169060400135610584565b34801561026657600080fd5b506102846004803603602081101561027d57600080fd5b503561060b565b005b34801561029257600080fd5b5061029b61069e565b6040805160ff9092168252519081900360200190f35b3480156102bd57600080fd5b506101dc600480360360408110156102d457600080fd5b506001600160a01b0381351690602001356106a7565b3480156102f657600080fd5b506102846106f5565b34801561030b57600080fd5b506102056004803603602081101561032257600080fd5b50356001600160a01b0316610797565b34801561033e57600080fd5b506102056004803603602081101561035557600080fd5b50356001600160a01b03166107e4565b34801561037157600080fd5b506102846004803603602081101561038857600080fd5b50356107ff565b34801561039b57600080fd5b50610205600480360360208110156103b257600080fd5b50356001600160a01b03166108ad565b3480156103ce57600080fd5b5061012e6108c8565b3480156103e357600080fd5b506101dc600480360360408110156103fa57600080fd5b506001600160a01b038135169060200135610929565b34801561041c57600080fd5b506102846004803603602081101561043357600080fd5b5035610991565b610284610a3d565b34801561044e57600080fd5b506101dc6004803603604081101561046557600080fd5b506001600160a01b038135169060200135610c85565b34801561048757600080fd5b506102056004803603604081101561049e57600080fd5b506001600160a01b0381358116916020013516610c99565b3480156104c257600080fd5b50610284610cc4565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105575780601f1061052c57610100808354040283529160200191610557565b820191906000526020600020905b81548152906001019060200180831161053a57829003601f168201915b5050505050905090565b600061057561056e610e64565b8484610e68565b50600192915050565b60025490565b6000610591848484610f54565b6106018461059d610e64565b6105fc85604051806060016040528060288152602001611718602891396001600160a01b038a166000908152600160205260408120906105db610e64565b6001600160a01b0316815260208101919091526040016000205491906110af565b610e68565b5060019392505050565b6106153382611146565b60408051633a1528c960e11b81523360048201526024810183905290516001600160a01b037f00000000000000000000000075cdc4f6be18dc003dc2ae424f85d1243f0fb781169163742a519291604480830192600092919082900301818387803b15801561068357600080fd5b505af1158015610697573d6000803e3d6000fd5b5050505050565b60055460ff1690565b60006105756106b4610e64565b846105fc85600160006106c5610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610ce4565b7f00000000000000000000000075cdc4f6be18dc003dc2ae424f85d1243f0fb7816001600160a01b031663742a51923361072e33610797565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561077457600080fd5b505af1158015610788573d6000803e3d6000fd5b5050505061079533611242565b565b6001600160a01b0381166000908152600760209081526040808320546008909252822054600654670de0b6b3a76400009291906107d3866108ad565b020103816107dd57fe5b0492915050565b6001600160a01b03166000908152600b602052604090205490565b604080516323b872dd60e01b81523360048201523060248201526044810183905290516001600160a01b037f00000000000000000000000075cdc4f6be18dc003dc2ae424f85d1243f0fb78116916323b872dd9160648083019260209291908290030181600087803b15801561087457600080fd5b505af1158015610888573d6000803e3d6000fd5b505050506040513d602081101561089e57600080fd5b506108aa90508161127c565b50565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105575780601f1061052c57610100808354040283529160200191610557565b6000610575610936610e64565b846105fc856040518060600160405280602581526020016117d46025913960016000610960610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906110af565b604080516323b872dd60e01b81523360048201523060248201526044810183905290516001600160a01b037f00000000000000000000000075cdc4f6be18dc003dc2ae424f85d1243f0fb78116916323b872dd9160648083019260209291908290030181600087803b158015610a0657600080fd5b505af1158015610a1a573d6000803e3d6000fd5b505050506040513d6020811015610a3057600080fd5b506108aa905033826112eb565b60007f00000000000000000000000075cdc4f6be18dc003dc2ae424f85d1243f0fb7816001600160a01b031663614bfe2e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9857600080fd5b505afa158015610aac573d6000803e3d6000fd5b505050506040513d6020811015610ac257600080fd5b505190506001600160a01b038116610b0b5760405162461bcd60e51b815260040180806020018281038252602a8152602001806117aa602a913960400191505060405180910390fd5b336000908152600b60205260409020543460040290811115610b5e5760405162461bcd60e51b815260040180806020018281038252602481526020018061169b6024913960400191505060405180910390fd5b336000908152600b60205260408120805483900390556002340490507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015610bd557600080fd5b505af1158015610be9573d6000803e3d6000fd5b50505050507f0000000000000000000000001a23f34c29187e48b5e63246a743a46cf45d067c6001600160a01b03166359974e38826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610c5457600080fd5b505af1158015610c68573d6000803e3d6000fd5b50610c80925050506001600160a01b038416476113db565b505050565b6000610575610c92610e64565b8484610f54565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000610ccf33610797565b9050610cda33611242565b6108aa33826112eb565b600082820183811015610d3e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b610d50838383610c80565b6001600160a01b03831615801590610d7057506001600160a01b03821615155b15610dd0573360009081526009602052604090205460ff1680610d955750600a5460ff165b610dd05760405162461bcd60e51b815260040180806020018281038252602c8152602001806116bf602c913960400191505060405180910390fd5b60065481026001600160a01b03841615610e30576000600654610df2866108ad565b6001600160a01b0387166000908152600760208181526040808420805460088452919094208054959096029081039094019094559092528390039055505b6001600160a01b03831615610e5e576001600160a01b03831660009081526007602052604090208054820190555b50505050565b3390565b6001600160a01b038316610ead5760405162461bcd60e51b81526004018080602001828103825260248152602001806117866024913960400191505060405180910390fd5b6001600160a01b038216610ef25760405162461bcd60e51b81526004018080602001828103825260228152602001806115f16022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610f995760405162461bcd60e51b81526004018080602001828103825260258152602001806117616025913960400191505060405180910390fd5b6001600160a01b038216610fde5760405162461bcd60e51b81526004018080602001828103825260238152602001806115ac6023913960400191505060405180910390fd5b610fe98383836114c0565b61102681604051806060016040528060268152602001611613602691396001600160a01b03861660009081526020819052604090205491906110af565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546110559082610ce4565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561113e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156111035781810151838201526020016110eb565b50505050905090810190601f1680156111305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b03821661118b5760405162461bcd60e51b81526004018080602001828103825260218152602001806117406021913960400191505060405180910390fd5b611197826000836114c0565b6111d4816040518060600160405280602281526020016115cf602291396001600160a01b03851660009081526020819052604090205491906110af565b6001600160a01b0383166000908152602081905260409020556002546111fa9082611569565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60065461124e826108ad565b6001600160a01b03909216600090815260076020908152604080832093909402909255600890915290812055565b600061128661057e565b9050600081116112c75760405162461bcd60e51b815260040180806020018281038252602d8152602001806116eb602d913960400191505060405180910390fd5b80670de0b6b3a76400008302816112da57fe5b600680549290910490910190555050565b6001600160a01b038216611346576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611352600083836114c0565b60025461135f9082610ce4565b6002556001600160a01b0382166000908152602081905260409020546113859082610ce4565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b80471015611430576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461147b576040519150601f19603f3d011682016040523d82523d6000602084013e611480565b606091505b5050905080610c805760405162461bcd60e51b815260040180806020018281038252603a815260200180611639603a913960400191505060405180910390fd5b6114cb838383610d45565b60006114d6846107e4565b90508015806114ef575081816114eb866108ad565b0310155b61152a5760405162461bcd60e51b81526004018080602001828103825260288152602001806116736028913960400191505060405180910390fd5b600a546001600160a01b03858116610100909204161415610e5e576001600160a01b0383166000908152600b6020526040902080548301905550505050565b6000610d3e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506110af56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644a7573446546693a20616d6f756e74206578636565647320756e6c6f636b65642062616c616e63654a7573446546693a20696e73756666696369656e74206c6f636b65642062616c616e63654a7573446546693a207374616b656420746f6b656e7320617265206e6f6e2d7472616e736665727261626c655374616b696e67506f6f6c3a20737570706c79206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734a7573446546693a206c6971756964697479206576656e74207374696c6c20696e2070726f677265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220530ec26d67c90825a3c276c7d3dd124b94cbdf84d820d1119eec984cfb240cdc64736f6c63430007040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001f89abfc1a80eae67b8036a49204823e8861eaf600000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000001a23f34c29187e48b5e63246a743a46cf45d067c
-----Decoded View---------------
Arg [0] : airdropToken (address): 0x1F89ABfc1A80EAe67b8036a49204823e8861eAF6
Arg [1] : initialSupply (uint256): 10000000000000000000000
Arg [2] : weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : devStakingPool (address): 0x1a23F34C29187E48B5E63246a743A46cf45D067c
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000001f89abfc1a80eae67b8036a49204823e8861eaf6
Arg [1] : 00000000000000000000000000000000000000000000021e19e0c9bab2400000
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 0000000000000000000000001a23f34c29187e48b5e63246a743a46cf45d067c
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.