Address Contract Partially Verified
Address
0xcd60e6F0f05E7091BA231CcaF20088B43FbfbD8B
Balance
0 ETH
Nonce
1
Code Size
8142 bytes
Creator
0x6465F125...0a7B at tx 0x225be429...b114fe
Indexed Transactions
0 (1 on-chain, 0.7% indexed)
Contract Bytecode
8142 bytes
0x608060405234801561001057600080fd5b506004361061018d5760003560e01c80638b876347116100de578063ce5c165511610097578063df136d6511610071578063df136d65146105f0578063e9fad8ee1461060e578063ebe2b12b14610618578063ffab0420146106365761018d565b8063ce5c165514610536578063d17be1c81461058e578063dab9c5dd146105c25761018d565b80638b87634714610422578063a694fc3a1461047a578063b21c74e1146104a8578063b8f6c09c146104c6578063c8f33c91146104fa578063cd3daf9d146105185761018d565b80633eaaf86b1161014b5780636ebcf607116101255780636ebcf6071461033657806370a082311461038e5780637b0a47ee146103e657806380faa57d146104045761018d565b80633eaaf86b146102b65780634e71d92d146102d45780635f25050a146102de5761018d565b80628cc262146101925780630700037d146101ea57806318160ddd146102425780631be05289146102605780632e1a7d4d1461027e5780633d18b912146102ac575b600080fd5b6101d4600480360360208110156101a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061068e565b6040518082815260200191505060405180910390f35b61022c6004803603602081101561020057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610775565b6040518082815260200191505060405180910390f35b61024a61078d565b6040518082815260200191505060405180910390f35b610268610796565b6040518082815260200191505060405180910390f35b6102aa6004803603602081101561029457600080fd5b810190808035906020019092919050505061079c565b005b6102b4610952565b005b6102be610b22565b6040518082815260200191505060405180910390f35b6102dc610b28565b005b610320600480360360208110156102f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d13565b6040518082815260200191505060405180910390f35b6103786004803603602081101561034c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d2b565b6040518082815260200191505060405180910390f35b6103d0600480360360208110156103a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d43565b6040518082815260200191505060405180910390f35b6103ee610d8c565b6040518082815260200191505060405180910390f35b61040c610d92565b6040518082815260200191505060405180910390f35b6104646004803603602081101561043857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da5565b6040518082815260200191505060405180910390f35b6104a66004803603602081101561049057600080fd5b8101908080359060200190929190505050610dbd565b005b6104b0610f73565b6040518082815260200191505060405180910390f35b6104ce610f79565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610502610f91565b6040518082815260200191505060405180910390f35b610520610f97565b6040518082815260200191505060405180910390f35b6105786004803603602081101561054c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611015565b6040518082815260200191505060405180910390f35b61059661112e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105ee600480360360208110156105d857600080fd5b8101908080359060200190929190505050611146565b005b6105f86113cb565b6040518082815260200191505060405180910390f35b6106166113d1565b005b6106206113f4565b6040518082815260200191505060405180910390f35b6106786004803603602081101561064c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113fa565b6040518082815260200191505060405180910390f35b600061076e600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610760670de0b6b3a764000061075261073b600a60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461072d610f97565b61141290919063ffffffff16565b61074488610d43565b61145c90919063ffffffff16565b6114e290919063ffffffff16565b61152c90919063ffffffff16565b9050919050565b600b6020528060005260406000206000915090505481565b60008054905090565b60055481565b336107a5610f97565b6009819055506107b3610d92565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610880576107f68161068e565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008214156108f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f43616e6e6f74207769746864726177203000000000000000000000000000000081525060200191505060405180910390fd5b610900826115b4565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b3361095b610f97565b600981905550610969610d92565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a36576109ac8161068e565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000610a413361068e565b905060008114610b1e576000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610acf338273c7fd9ae2cf8542d71186877e21107e1f3a0b55ef73ffffffffffffffffffffffffffffffffffffffff166117a69092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b5050565b60005481565b33600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610bf057610b6681611015565b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600254600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008114610d0f576000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cc0338273cd4079b9713cdd1e629492b9c07ebd0dbd9f520273ffffffffffffffffffffffffffffffffffffffff166117a69092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167ff04b41893429a2707819cc29ddcc7e5f8b5f0b3d7f613136dc82f60ffd0d8aa3826040518082815260200191505060405180910390a25b5050565b60046020528060005260406000206000915090505481565b60016020528060005260406000206000915090505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60075481565b6000610da042600654611848565b905090565b600a6020528060005260406000206000915090505481565b33610dc6610f97565b600981905550610dd4610d92565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610ea157610e178161068e565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000821415610f18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b610f2182611861565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d836040518082815260200191505060405180910390a25050565b60025481565b73cd4079b9713cdd1e629492b9c07ebd0dbd9f520281565b60085481565b6000611010610fff610fa761078d565b610ff1670de0b6b3a7640000610fe3600754610fd5600854610fc7610d92565b61141290919063ffffffff16565b61145c90919063ffffffff16565b61145c90919063ffffffff16565b6114e290919063ffffffff16565b60095461152c90919063ffffffff16565b905090565b60006111276110d9670de0b6b3a76400006110cb61107d600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460025461141290919063ffffffff16565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461145c90919063ffffffff16565b6114e290919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461152c90919063ffffffff16565b9050919050565b73c7fd9ae2cf8542d71186877e21107e1f3a0b55ef81565b6000611150610f97565b60098190555061115e610d92565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461122b576111a18161068e565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008214156112a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f43616e6e6f7420617070726f766520300000000000000000000000000000000081525060200191505060405180910390fd5b60065442106112cb576112c0600554836114e290919063ffffffff16565b60078190555061132d565b60006112e24260065461141290919063ffffffff16565b905060006112fb6007548361145c90919063ffffffff16565b9050611324600554611316838761152c90919063ffffffff16565b6114e290919063ffffffff16565b60078190555050505b426008819055506113496005544261152c90919063ffffffff16565b60068190555061139033308473c7fd9ae2cf8542d71186877e21107e1f3a0b55ef73ffffffffffffffffffffffffffffffffffffffff16611a1e909392919063ffffffff16565b7fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a15050565b60095481565b6113e26113dd33610d43565b61079c565b6113ea610952565b6113f2610b28565b565b60065481565b60036020528060005260406000206000915090505481565b600061145483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611adf565b905092915050565b60008083141561146f57600090506114dc565b600082840290508284828161148057fe5b04146114d7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611f4e6021913960400191505060405180910390fd5b809150505b92915050565b600061152483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611b9f565b905092915050565b6000808284019050838110156115aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b33600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461167c576115f281611015565b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600254600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6116918260005461141290919063ffffffff16565b6000819055506116e982600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461141290919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006117426014846114e290919063ffffffff16565b9050611757818461141290919063ffffffff16565b9250611798338473cd4079b9713cdd1e629492b9c07ebd0dbd9f520273ffffffffffffffffffffffffffffffffffffffff166117a69092919063ffffffff16565b6117a181611c66565b505050565b6118438363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611cb7565b505050565b60008183106118575781611859565b825b905092915050565b33600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146119295761189f81611015565b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600254600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b61193e8260005461152c90919063ffffffff16565b60008190555061199682600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461152c90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a1a33308473cd4079b9713cdd1e629492b9c07ebd0dbd9f520273ffffffffffffffffffffffffffffffffffffffff16611a1e909392919063ffffffff16565b5050565b611ad9846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611cb7565b50505050565b6000838311158290611b8c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b51578082015181840152602081019050611b36565b50505050905090810190601f168015611b7e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808314158290611c4c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c11578082015181840152602081019050611bf6565b50505050905090810190601f168015611c3e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611c5857fe5b049050809150509392505050565b611cae611c9d611c7461078d565b611c8f670de0b6b3a76400008561145c90919063ffffffff16565b6114e290919063ffffffff16565b60025461152c90919063ffffffff16565b60028190555050565b611cd68273ffffffffffffffffffffffffffffffffffffffff16611f02565b611d48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310611d975780518252602082019150602081019050602083039250611d74565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611df9576040519150601f19603f3d011682016040523d82523d6000602084013e611dfe565b606091505b509150915081611e76576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115611efc57808060200190516020811015611e9557600080fd5b8101908080519060200190929190505050611efb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611f6f602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f9150808214158015611f4457506000801b8214155b9250505091905056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220597318d26a92243c9f86e94c7501bc8091736a379279da7dcc75a538d28ac9fc64736f6c634300060c0033
Verified Source Code Partial Match
Compiler: v0.6.12+commit.27d51765
EVM: istanbul
Optimization: No
y3dUniPool.sol 576 lines
pragma solidity ^0.6.0;
/*
___ ___ ________ ________
|\ \ / /|\_____ \|\ ___ \
\ \ \/ / \|____|\ /\ \ \_|\ \
\ \ / / \|\ \ \ \ \\ \
\/ / / __\_\ \ \ \_\\ \
__/ / / |\_______\ \_______\
|\___/ / \|_______|\|_______|
\|___|/
*/
// Unipool Contract Fork from Aragon
// https://etherscan.io/address/0xEA4D68CF86BcE59Bf2bFA039B97794ce2c43dEBC#code
/**
* @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 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
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);
}
/**
* @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 Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*
* _Available since v2.4.0._
*/
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
/**
* @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].
*
* _Available since v2.4.0._
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract LPTokenWrapper {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public constant LPT = IERC20(0xCd4079b9713CdD1e629492B9c07Ebd0dbD9F5202); // Uniswap y3d-yyCrv LP Token
uint256 public _totalSupply;
mapping(address => uint256) public _balances;
uint256 public _profitPerShare; // x 1e18, monotonically increasing.
mapping(address => uint256) public _unrealized; // x 1e18
mapping(address => uint256) public _realized; // last paid _profitPerShare
event LPTPaid(address indexed user, uint256 profit);
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function unrealizedProfit(address account) public view returns (uint256) {
return _unrealized[account].add(_balances[account].mul(_profitPerShare.sub(_realized[account])).div(1e18));
}
function make_profit(uint256 amount) internal {
_profitPerShare = _profitPerShare.add(amount.mul(1e18).div(totalSupply()));
}
modifier update(address account) {
// Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;
// really i know you think you do but you don't
// https://etherscan.io/address/0xb3775fb83f7d12a36e0475abdd1fca35c091efbe#code
if (account != address(0)) {
_unrealized[account] = unrealizedProfit(account);
_realized[account] = _profitPerShare;
}
_;
}
function stake(uint256 amount) update(msg.sender) public virtual {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
LPT.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) update(msg.sender) public virtual {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
uint256 tax = amount.div(20);
amount = amount.sub(tax);
LPT.safeTransfer(msg.sender, amount);
make_profit(tax);
}
function claim() update(msg.sender) public {
uint256 profit = _unrealized[msg.sender];
if (profit != 0) {
_unrealized[msg.sender] = 0;
LPT.safeTransfer(msg.sender, profit);
emit LPTPaid(msg.sender, profit);
}
}
}
contract y3dUniPool is LPTokenWrapper {
uint256 public DURATION = 30 days;
uint256 public periodFinish;
uint256 public rewardRate;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
IERC20 constant public Y3D = IERC20(0xc7fD9aE2cf8542D71186877e21107E1F3A0b55ef);
constructor() public {
_balances[msg.sender] = 1; // avoid divided by 0
_totalSupply = 1;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account])
;
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public override updateReward(msg.sender) {
require(amount != 0, "Cannot stake 0");
super.stake(amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public override updateReward(msg.sender) {
require(amount != 0, "Cannot withdraw 0");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
claim();
}
function getReward() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward != 0) {
rewards[msg.sender] = 0;
Y3D.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
/**
* @dev This function must be triggered by the contribution token approve-and-call fallback.
* It will update reward rate and time.
* @param _amount Amount of reward tokens added to the pool
*/
function receiveApproval(uint256 _amount) external updateReward(address(0)) {
require(_amount != 0, "Cannot approve 0");
if (block.timestamp >= periodFinish) {
rewardRate = _amount.div(DURATION);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = _amount.add(leftover).div(DURATION);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(DURATION);
Y3D.safeTransferFrom(msg.sender, address(this), _amount);
emit RewardAdded(_amount);
}
}
Read Contract
DURATION 0x1be05289 → uint256
LPT 0xb8f6c09c → address
Y3D 0xd17be1c8 → address
_balances 0x6ebcf607 → uint256
_profitPerShare 0xb21c74e1 → uint256
_realized 0x5f25050a → uint256
_totalSupply 0x3eaaf86b → uint256
_unrealized 0xffab0420 → uint256
balanceOf 0x70a08231 → uint256
earned 0x008cc262 → uint256
lastTimeRewardApplicable 0x80faa57d → uint256
lastUpdateTime 0xc8f33c91 → uint256
periodFinish 0xebe2b12b → uint256
rewardPerToken 0xcd3daf9d → uint256
rewardPerTokenStored 0xdf136d65 → uint256
rewardRate 0x7b0a47ee → uint256
rewards 0x0700037d → uint256
totalSupply 0x18160ddd → uint256
unrealizedProfit 0xce5c1655 → uint256
userRewardPerTokenPaid 0x8b876347 → uint256
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
claim 0x4e71d92d
No parameters
exit 0xe9fad8ee
No parameters
getReward 0x3d18b912
No parameters
receiveApproval 0xdab9c5dd
uint256 _amount
stake 0xa694fc3a
uint256 amount
withdraw 0x2e1a7d4d
uint256 amount
Recent Transactions
This address has 1 on-chain transactions, but only 0.7% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →