Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x3f787B52E797Ec1bA91e82fF4e1f1321670ddeCE
Balance 0 ETH
Nonce 1
Code Size 3712 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3712 bytes
0x608060405234801561001057600080fd5b506004361061012b5760003560e01c806369c18e12116100ad578063b333de2411610071578063b333de24146102da578063b821b6bf146102e2578063c8910913146102ea578063e0287b3e1461033b578063f53d0a8e146103585761012b565b806369c18e12146102525780636b6b6aa41461025a5780637640cb9e14610277578063a43fc87114610294578063aa9a0912146102b15761012b565b80631e7f87bc116100f45780631e7f87bc146101d15780632bdcd691146101d9578063376edab6146101f857806342d41964146102265780636387c9491461024a5761012b565b806265318b1461013057806308dbbb03146101685780631495bf9a146101705780631bf6e00d1461018f5780631cfff51b146101b5575b600080fd5b6101566004803603602081101561014657600080fd5b50356001600160a01b0316610360565b60408051918252519081900360200190f35b6101566103c7565b61018d6004803603602081101561018657600080fd5b50356103cd565b005b610156600480360360208110156101a557600080fd5b50356001600160a01b03166103d9565b6101bd6103f7565b604080519115158252519081900360200190f35b610156610407565b61018d600480360360208110156101ef57600080fd5b5035151561040d565b6101bd6004803603604081101561020e57600080fd5b506001600160a01b0381358116916020013516610474565b61022e6104f0565b604080516001600160a01b039092168252519081900360200190f35b61022e6104ff565b61015661050e565b61018d6004803603602081101561027057600080fd5b5035610514565b6101bd6004803603602081101561028d57600080fd5b503561051d565b61018d600480360360208110156102aa57600080fd5b5035610592565b610156600480360360608110156102c757600080fd5b50803590602081013590604001356105ea565b61015661069e565b6101566107c8565b6103106004803603602081101561030057600080fd5b50356001600160a01b03166107ce565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b61018d6004803603602081101561035157600080fd5b5035610825565b61022e610873565b6004546001600160a01b0382166000908152600860205260408120600301549091111561038f575060006103c2565b6001600160a01b03821660009081526008602052604090206002810154600190910154600954600160401b929102030490505b919050565b60035481565b6103d681610882565b50565b6001600160a01b031660009081526008602052604090206001015490565b600254600160a01b900460ff1681565b60075490565b600a546001600160a01b031633146104565760405162461bcd60e51b8152600401808060200182810382526028815260200180610e236028913960400191505060405180910390fd5b60028054911515600160a01b0260ff60a01b19909216919091179055565b600a546000906001600160a01b031633146104c05760405162461bcd60e51b8152600401808060200182810382526028815260200180610e236028913960400191505060405180910390fd5b50600080546001600160a01b039384166001600160a01b0319918216179091556001805492909316911617815590565b6001546001600160a01b031681565b6000546001600160a01b031681565b60055481565b6103d681610ba5565b600080546001600160a01b031633146105675760405162461bcd60e51b815260040180806020018281038252602b815260200180610d80602b913960400191505060405180910390fd5b600754600160401b83028161057857fe5b600980549290910490910190819055600555506001919050565b600a546001600160a01b031633146105db5760405162461bcd60e51b8152600401808060200182810382526028815260200180610e236028913960400191505060405180910390fd5b670de0b6b3a764000002600355565b60008060006105f98686610d20565b9150915083811061060657fe5b6000848061061057fe5b868809905082811115610624576001820391505b91829003916000859003851680868161063957fe5b04955080848161064557fe5b04935080816000038161065457fe5b046001019290920292909201600285810380870282030280870282030280870282030280870282030280870282030280870282030295860290039094029390930295945050505050565b6000806106aa33610360565b3360008181526008602090815260408083206002018054600160401b87020190558254815163a9059cbb60e01b815260048101959095526024850186905290519495506001600160a01b03169363a9059cbb93604480820194918390030190829087803b15801561071a57600080fd5b505af115801561072e573d6000803e3d6000fd5b505050506040513d602081101561074457600080fd5b505161078c576040805162461bcd60e51b8152602060048201526012602482015271151c985b9cd858dd1a5bdb8811985a5b195960721b604482015290519081900360640190fd5b604080518281529051309133917f8c998377165b6abd6e99f8b84a86ed2c92d0055aeef42626fedea45c2909f6eb9181900360200190a3905090565b60045481565b60008060008060006107de610407565b6107e7876103d9565b6107f088610360565b6001600160a01b0398909816600090815260086020526040902060038101546002909101549299919897509550909350915050565b600a546001600160a01b0316331461086e5760405162461bcd60e51b8152600401808060200182810382526028815260200180610e236028913960400191505060405180910390fd5b600455565b6002546001600160a01b031681565b600254600160a01b900460ff166108e0576040805162461bcd60e51b815260206004820152601b60248201527f5374616b696e67206e6f742079657420696e697469616c697a65640000000000604482015290519081900360640190fd5b600154604080516370a0823160e01b8152336004820152905183926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561092a57600080fd5b505afa15801561093e573d6000803e3d6000fd5b505050506040513d602081101561095457600080fd5b505110156109a9576040805162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e742044654669204146542062616c616e6365000000604482015290519081900360640190fd5b600354816109b6336103d9565b0110156109f45760405162461bcd60e51b815260040180806020018281038252603d815260200180610de6603d913960400191505060405180910390fd5b60015460408051636eb1769f60e11b8152336004820152306024820152905183926001600160a01b03169163dd62ed3e916044808301926020929190829003018186803b158015610a4457600080fd5b505afa158015610a58573d6000803e3d6000fd5b505050506040513d6020811015610a6e57600080fd5b50511015610aad5760405162461bcd60e51b815260040180806020018281038252603b815260200180610dab603b913960400191505060405180910390fd5b33600081815260086020908152604080832042600382015560078054870190556001808201805488019055600954600290920180549288029092019091555481516323b872dd60e01b815260048101959095523060248601526044850186905290516001600160a01b03909116936323b872dd9360648083019493928390030190829087803b158015610b3f57600080fd5b505af1158015610b53573d6000803e3d6000fd5b505050506040513d6020811015610b6957600080fd5b5050604080518281529051309133917f160ffcaa807f78c8b4983836e2396338d073e75695ac448aa0b5e4a75b210b1d9181900360200190a350565b80610baf336103d9565b1015610bec5760405162461bcd60e51b8152600401808060200182810382526032815260200180610d4e6032913960400191505060405180910390fd5b6007805482900390553360008181526008602090815260408083206001818101805488900390556009546002909201805492880290920390915554815163a9059cbb60e01b815260048101959095526024850186905290516001600160a01b039091169363a9059cbb9360448083019493928390030190829087803b158015610c7457600080fd5b505af1158015610c88573d6000803e3d6000fd5b505050506040513d6020811015610c9e57600080fd5b5051610ce6576040805162461bcd60e51b8152602060048201526012602482015271151c985b9cd858dd1a5bdb8819985a5b195960721b604482015290519081900360640190fd5b604080518281529051339130917f15fba2c381f32b0e84d073dd1adb9edbcfd33a033ee48aaea415ac61ca7d448d9181900360200190a350565b6000808060001984860990508385029250828103915082811015610d45576001820391505b50925092905056fe596f752063757272656e746c7920646f206e6f74206861766520757020746f207468617420616d6f756e74207374616b6564417574686f72697a6174696f6e3a206f6e6c7920746f6b656e20636f6e74726163742063616e2063616c6c4e6f7420656e6f75676820616c6c6f77616e636520676976656e20746f20636f6e74726163742079657420746f207370656e642062792075736572596f757220616d6f756e74206973206c6f776572207468616e20746865206d696e696d756d20616d6f756e7420616c6c6f77656420746f207374616b654f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e6973747261746f72a264697066735822122062f575d06a58d2fadf64ba553664ee4ecc61cb95acbe15345a3e9a7af37e9e2a64736f6c63430006040033

Verified Source Code Full Match

Compiler: v0.6.4+commit.1dca32f3 EVM: istanbul Optimization: Yes (200 runs)
DSP.sol 402 lines
/*

* @dev This is the Axia Protocol Staking pool 2 contract (Defi Fund Pool), 
* a part of the protocol where stakers are rewarded in AXIA tokens 
* when they make stakes of liquidity tokens from the oracle pool.

* stakers reward come from the daily emission from the total supply into circulation,
* this happens daily and upon the reach of a new epoch each made of 180 days, 
* halvings are experienced on the emitting amount of tokens.

* on the 11th epoch all the tokens would have been completed emitted into circulation,
* from here on, the stakers will still be earning from daily emissions
* which would now be coming from the accumulated basis points over the epochs.

* stakers are not charged any fee for unstaking.


*/
pragma solidity 0.6.4;

interface IERC20 {

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount) external returns (bool);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);

    event Approval(address indexed owner, address indexed spender, uint256 value);
}

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;
    }
}



contract DSP{
    
    using SafeMath for uint256;
    
//======================================EVENTS=========================================//
    event StakeEvent(address indexed staker, address indexed pool, uint amount);
    event UnstakeEvent(address indexed unstaker, address indexed pool, uint amount);
    event RewardEvent(address indexed staker, address indexed pool, uint amount);
    event RewardStake(address indexed staker, address indexed pool, uint amount);
    
    
//======================================STAKING POOLS=========================================//
    address public Axiatoken;
    address public DefiIndexFunds;
    
    address public administrator;
    
    bool public stakingEnabled;
    
    uint256 constant private FLOAT_SCALAR = 2**64;
    uint256 public MINIMUM_STAKE = 1000000000000000000; // 1 minimum
	uint256 public MIN_DIVIDENDS_DUR = 86400;
	
	uint public infocheck;
    
    struct User {
		uint256 balance;
		uint256 frozen;
		int256 scaledPayout;  
		uint256 staketime;
	}

	struct Info {
		uint256 totalSupply;
		uint256 totalFrozen;
		mapping(address => User) users;
		uint256 scaledPayoutPerToken; //pool balance 
		address admin;
	}
	
	Info private info;
	
	
	constructor() public {
	    
        info.admin = msg.sender;
        stakingEnabled = false;
	}

//======================================ADMINSTRATION=========================================//

	modifier onlyCreator() {
        require(msg.sender == info.admin, "Ownable: caller is not the administrator");
        _;
    }
    
    modifier onlyAxiaToken() {
        require(msg.sender == Axiatoken, "Authorization: only token contract can call");
        _;
    }
    
	 function tokenconfigs(address _axiatoken, address _defiindex) public onlyCreator returns (bool success) {
        Axiatoken = _axiatoken;
        DefiIndexFunds = _defiindex;
        return true;
    }
	
	function _minStakeAmount(uint256 _number) onlyCreator public {
		
		MINIMUM_STAKE = _number*1000000000000000000;
		
	}
	
	function stakaingStatus(bool _status) public onlyCreator {
	stakingEnabled = _status;
    }
    
    
    function MIN_DIVIDENDS_DUR_TIME(uint256 _minDuration) public onlyCreator {
        
	MIN_DIVIDENDS_DUR = _minDuration;
	
    }
    
//======================================USER WRITE=========================================//

	function StakeAxiaTokens(uint256 _tokens) external {
		_stake(_tokens);
	}
	
	function UnstakeAxiaTokens(uint256 _tokens) external {
		_unstake(_tokens);
	}
    

//======================================USER READ=========================================//

	function totalFrozen() public view returns (uint256) {
		return info.totalFrozen;
	}
	
    function frozenOf(address _user) public view returns (uint256) {
		return info.users[_user].frozen;
	}

	function dividendsOf(address _user) public view returns (uint256) {
	    
	    if(info.users[_user].staketime < MIN_DIVIDENDS_DUR){
	        return 0;
	    }else{
	     return uint256(int256(info.scaledPayoutPerToken * info.users[_user].frozen) - info.users[_user].scaledPayout) / FLOAT_SCALAR;   
	    }
	    
	}
	

	function userData(address _user) public view 
	returns (uint256 totalTokensFrozen, uint256 userFrozen, 
	uint256 userDividends, uint256 userStaketime, int256 scaledPayout) {
	    
		return (totalFrozen(), frozenOf(_user), dividendsOf(_user), info.users[_user].staketime, info.users[_user].scaledPayout);
	
	    
	}
	

//======================================ACTION CALLS=========================================//	
	
	function _stake(uint256 _amount) internal {
	    
	    require(stakingEnabled, "Staking not yet initialized");
	    
		require(IERC20(DefiIndexFunds).balanceOf(msg.sender) >= _amount, "Insufficient DeFi AFT balance");
		require(frozenOf(msg.sender) + _amount >= MINIMUM_STAKE, "Your amount is lower than the minimum amount allowed to stake");
		require(IERC20(DefiIndexFunds).allowance(msg.sender, address(this)) >= _amount, "Not enough allowance given to contract yet to spend by user");
		
		info.users[msg.sender].staketime = now;
		info.totalFrozen += _amount;
		info.users[msg.sender].frozen += _amount;
		
		info.users[msg.sender].scaledPayout += int256(_amount * info.scaledPayoutPerToken); 
		IERC20(DefiIndexFunds).transferFrom(msg.sender, address(this), _amount);      // Transfer liquidity tokens from the sender to this contract
		
        emit StakeEvent(msg.sender, address(this), _amount);
	}
	
    
    
 
	function _unstake(uint256 _amount) internal {
	    
		require(frozenOf(msg.sender) >= _amount, "You currently do not have up to that amount staked");
		
		info.totalFrozen -= _amount;
		info.users[msg.sender].frozen -= _amount;
		info.users[msg.sender].scaledPayout -= int256(_amount * info.scaledPayoutPerToken);
		
		require(IERC20(DefiIndexFunds).transfer(msg.sender, _amount), "Transaction failed");
        emit UnstakeEvent(address(this), msg.sender, _amount);
		
	}
	
		
	function TakeDividends() external returns (uint256) {
		    
		uint256 _dividends = dividendsOf(msg.sender);
		require(_dividends >= 0, "you do not have any dividend yet");
		info.users[msg.sender].scaledPayout += int256(_dividends * FLOAT_SCALAR);
		
		require(IERC20(Axiatoken).transfer(msg.sender, _dividends), "Transaction Failed");    // Transfer dividends to msg.sender
		emit RewardEvent(msg.sender, address(this), _dividends);
		
		return _dividends;
	    
		    
	}
 
    function scaledToken(uint _amount) external onlyAxiaToken returns(bool){
            
    		info.scaledPayoutPerToken += _amount * FLOAT_SCALAR / info.totalFrozen;
    		infocheck = info.scaledPayoutPerToken;
    		return true;
            
    }
 
        
    function mulDiv (uint x, uint y, uint z) public pure returns (uint) {
          (uint l, uint h) = fullMul (x, y);
          assert (h < z);
          uint mm = mulmod (x, y, z);
          if (mm > l) h -= 1;
          l -= mm;
          uint pow2 = z & -z;
          z /= pow2;
          l /= pow2;
          l += h * ((-pow2) / pow2 + 1);
          uint r = 1;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          r *= 2 - z * r;
          return l * r;
    }
    
     function fullMul (uint x, uint y) private pure returns (uint l, uint h) {
          uint mm = mulmod (x, y, uint (-1));
          l = x * y;
          h = mm - l;
          if (mm < l) h -= 1;
    }
 
    
}

Read Contract

Axiatoken 0x6387c949 → address
DefiIndexFunds 0x42d41964 → address
MINIMUM_STAKE 0x08dbbb03 → uint256
MIN_DIVIDENDS_DUR 0xb821b6bf → uint256
administrator 0xf53d0a8e → address
dividendsOf 0x0065318b → uint256
frozenOf 0x1bf6e00d → uint256
infocheck 0x69c18e12 → uint256
mulDiv 0xaa9a0912 → uint256
stakingEnabled 0x1cfff51b → bool
totalFrozen 0x1e7f87bc → uint256
userData 0xc8910913 → uint256, uint256, uint256, uint256, int256

Write Contract 8 functions

These functions modify contract state and require a wallet transaction to execute.

MIN_DIVIDENDS_DUR_TIME 0xe0287b3e
uint256 _minDuration
StakeAxiaTokens 0x1495bf9a
uint256 _tokens
TakeDividends 0xb333de24
No parameters
returns: uint256
UnstakeAxiaTokens 0x6b6b6aa4
uint256 _tokens
_minStakeAmount 0xa43fc871
uint256 _number
scaledToken 0x7640cb9e
uint256 _amount
returns: bool
stakaingStatus 0x2bdcd691
bool _status
tokenconfigs 0x376edab6
address _axiatoken
address _defiindex
returns: bool

Recent Transactions

No transactions found for this address