Contract 0xb7a2B914ffd11C2Ddf79380FbE5F79e2eD52FE9D

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x0eb804802ed2e768ac2d2eeb694faf2f697143c2433bbe601ad63ebfe81a8eae0x60a0604015297532022-08-09 8:37:3055 days 22 hrs ago0xe395605bd95b3a641b9d1266cdb256176419161a IN  Create: AllocKafraV20 CLV0.0379311975
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AllocKafraV2

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 6 : AllocKafraV2.sol
//SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./interfaces/IAllocKafraV2.sol";

contract AllocKafraV2 is Ownable, IAllocKafraV2 {
    uint16 public constant override MAX_ALLOCATION = 10000;
    uint16 public override limitAllocation;
    uint256 public holdingKSW;
    uint16 public holdingKSWAllocationIncrease;
    address public immutable ksw;

    event SetLimitAllocation(uint16 limitAllocation);
    event SetHoldingKSW(uint256 amount, uint16 increase);

    constructor(
        address _ksw,
        uint16 _limitAllocation,
        uint256 _holdingKSW,
        uint16 _holdingKSWAllocationIncrease
    ) {
        ksw = _ksw;
        limitAllocation = _limitAllocation;
        holdingKSW = _holdingKSW;
        holdingKSWAllocationIncrease = _holdingKSWAllocationIncrease;
    }

    function isHoldingKSW(address user) public view returns (bool) {
        if (holdingKSW == 0) {
            return false;
        }

        uint256 bal = IERC20(ksw).balanceOf(user);
        return bal >= holdingKSW;
    }

    function canAllocate(
        uint256,
        uint256 _balanceOfWant,
        uint256 _balanceOfMasterChef,
        address user
    ) external view override returns (bool) {
        if (limitAllocation == 0) {
            return true;
        }
        uint256 percentage = (_balanceOfWant * MAX_ALLOCATION) / _balanceOfMasterChef;
        if (isHoldingKSW(user)) {
            return percentage <= limitAllocation + holdingKSWAllocationIncrease;
        }
        return percentage <= limitAllocation;
    }

    function setLimitAllocation(uint16 _limitAllocation) external onlyOwner {
        require(_limitAllocation <= MAX_ALLOCATION, "invalid limit");

        limitAllocation = _limitAllocation;
        emit SetLimitAllocation(_limitAllocation);
    }

    function setHoldingKSW(uint256 amount, uint16 increase) external onlyOwner {
        holdingKSW = amount;
        holdingKSWAllocationIncrease = increase;
        emit SetHoldingKSW(amount, increase);
    }

    function userLimitAllocation(address user) external view override returns (uint16) {
        if (isHoldingKSW(user)) {
            return limitAllocation + holdingKSWAllocationIncrease;
        }
        return limitAllocation;
    }
}

File 2 of 6 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 6 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.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);
}

File 4 of 6 : IAllocKafraV2.sol
//SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IAllocKafra.sol";

interface IAllocKafraV2 is IAllocKafra {
    function MAX_ALLOCATION() external view returns (uint16);

    function limitAllocation() external view returns (uint16);

    function userLimitAllocation(address user) external view returns (uint16);

    function canAllocate(
        uint256 _amount,
        uint256 _balanceOfWant,
        uint256 _balanceOfMasterChef,
        address _user
    ) external view returns (bool);
}

File 5 of 6 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 6 of 6 : IAllocKafra.sol
//SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IAllocKafra {
    function MAX_ALLOCATION() external view returns (uint16);

    function limitAllocation() external view returns (uint16);

    function canAllocate(
        uint256 _amount,
        uint256 _balanceOfWant,
        uint256 _balanceOfMasterChef,
        address _user
    ) external view returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_ksw","type":"address"},{"internalType":"uint16","name":"_limitAllocation","type":"uint16"},{"internalType":"uint256","name":"_holdingKSW","type":"uint256"},{"internalType":"uint16","name":"_holdingKSWAllocationIncrease","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"increase","type":"uint16"}],"name":"SetHoldingKSW","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"limitAllocation","type":"uint16"}],"name":"SetLimitAllocation","type":"event"},{"inputs":[],"name":"MAX_ALLOCATION","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"_balanceOfWant","type":"uint256"},{"internalType":"uint256","name":"_balanceOfMasterChef","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"canAllocate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holdingKSW","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holdingKSWAllocationIncrease","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isHoldingKSW","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ksw","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitAllocation","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint16","name":"increase","type":"uint16"}],"name":"setHoldingKSW","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_limitAllocation","type":"uint16"}],"name":"setLimitAllocation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userLimitAllocation","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b50604051610c4c380380610c4c83398101604081905261002f916100e1565b6100383361007a565b6001600160a01b03939093166080526000805461ffff60a01b1916600160a01b61ffff948516021790556001556002805461ffff19169190921617905561013c565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b805161ffff811681146100dc57600080fd5b919050565b600080600080608085870312156100f757600080fd5b84516001600160a01b038116811461010e57600080fd5b935061011c602086016100ca565b925060408501519150610131606086016100ca565b905092959194509250565b608051610aee61015e6000396000818161015c015261041a0152610aee6000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c80636d034d2b1161008c5780638da5cb5b116100665780638da5cb5b146101ef578063d9ea4c4a1461020d578063f2fde38b14610220578063fdd9a6ac1461023357600080fd5b80636d034d2b146101c6578063715018a6146101d45780637a96a85d146101dc57600080fd5b806356637e23116100bd57806356637e2314610131578063615e597814610157578063623ac6a7146101a357600080fd5b8063298f2ac4146100e457806332352d0b14610105578063535b53611461011a575b600080fd5b6100ed61271081565b60405161ffff90911681526020015b60405180910390f35b610118610113366004610906565b610246565b005b61012360015481565b6040519081526020016100fc565b6000546100ed9074010000000000000000000000000000000000000000900461ffff1681565b61017e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100fc565b6101b66101b136600461094c565b6103bd565b60405190151581526020016100fc565b6002546100ed9061ffff1681565b6101186104a2565b6100ed6101ea36600461094c565b61052f565b60005473ffffffffffffffffffffffffffffffffffffffff1661017e565b6101b661021b366004610967565b610598565b61011861022e36600461094c565b610655565b6101186102413660046109a6565b610785565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61271061ffff8216111561033c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f696e76616c6964206c696d69740000000000000000000000000000000000000060448201526064016102c3565b600080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527fdcf5b8203590c59513d3c479b6dfbef8c9d1f305a0e0efca3113bac5e953450f9060200160405180910390a150565b6000600154600014156103d257506000919050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906370a082319060240160206040518083038186803b15801561045e57600080fd5b505afa158015610472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049691906109d2565b60015411159392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610523576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102c3565b61052d600061087a565b565b600061053a826103bd565b156105745760025460005461056e9161ffff9081169174010000000000000000000000000000000000000000900416610a1a565b92915050565b505060005474010000000000000000000000000000000000000000900461ffff1690565b6000805474010000000000000000000000000000000000000000900461ffff166105c45750600161064d565b6000836105d361271087610a40565b6105dd9190610a7d565b90506105e8836103bd565b156106295760025460005461061c9161ffff9081169174010000000000000000000000000000000000000000900416610a1a565b61ffff161015905061064d565b60005474010000000000000000000000000000000000000000900461ffff16101590505b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102c3565b73ffffffffffffffffffffffffffffffffffffffff8116610779576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102c3565b6107828161087a565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610806576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102c3565b6001829055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff83169081179091556040805184815260208101929092527fe4ac0c7c1461b8bb0eff278e7b05d0ad8e6ae4d1af822a490363b31ef854b552910160405180910390a15050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803561ffff8116811461090157600080fd5b919050565b60006020828403121561091857600080fd5b610921826108ef565b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461090157600080fd5b60006020828403121561095e57600080fd5b61092182610928565b6000806000806080858703121561097d57600080fd5b84359350602085013592506040850135915061099b60608601610928565b905092959194509250565b600080604083850312156109b957600080fd5b823591506109c9602084016108ef565b90509250929050565b6000602082840312156109e457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061ffff808316818516808303821115610a3757610a376109eb565b01949350505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610a7857610a786109eb565b500290565b600082610ab3577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea264697066735822122069dc106703b4ab0a2c91487787bead64c0c080afb72b4305bf58be2efb4eb59764736f6c6343000809003300000000000000000000000034fa09534e411dee1967df183ddbd4f65c65fb460000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000002b5e3af16b1880000000000000000000000000000000000000000000000000000000000000000003e8

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000034fa09534e411dee1967df183ddbd4f65c65fb460000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000002b5e3af16b1880000000000000000000000000000000000000000000000000000000000000000003e8

-----Decoded View---------------
Arg [0] : _ksw (address): 0x34fa09534e411dee1967df183ddbd4f65c65fb46
Arg [1] : _limitAllocation (uint16): 3000
Arg [2] : _holdingKSW (uint256): 800000000000000000000
Arg [3] : _holdingKSWAllocationIncrease (uint16): 1000

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000034fa09534e411dee1967df183ddbd4f65c65fb46
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000bb8
Arg [2] : 00000000000000000000000000000000000000000000002b5e3af16b18800000
Arg [3] : 00000000000000000000000000000000000000000000000000000000000003e8


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.