contract_name
stringlengths
1
61
file_path
stringlengths
5
50.4k
contract_address
stringlengths
42
42
language
stringclasses
1 value
class_name
stringlengths
1
61
class_code
stringlengths
4
330k
class_documentation
stringlengths
0
29.1k
class_documentation_type
stringclasses
6 values
func_name
stringlengths
0
62
func_code
stringlengths
1
303k
func_documentation
stringlengths
2
14.9k
func_documentation_type
stringclasses
4 values
compiler_version
stringlengths
15
42
license_type
stringclasses
14 values
swarm_source
stringlengths
0
71
meta
dict
__index_level_0__
int64
0
60.4k
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
updateDefaultExtensionAddress
function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); }
/** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 3196, 3437 ] }
58,861
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
updateLiquidityFarmTokenCollectionURI
function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; }
/** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 3627, 3825 ] }
58,862
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
updateLiquidityFarmTokenURI
function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; }
/** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 4005, 4163 ] }
58,863
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
getLiquidityFarmTokenCollectionURI
function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; }
/** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 4292, 4445 ] }
58,864
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
getLiquidityFarmTokenURI
function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; }
/** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 4552, 4685 ] }
58,865
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
cloneLiquidityMiningDefaultExtension
function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); }
/** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 4846, 5046 ] }
58,866
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
deploy
function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); }
/** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 5438, 5743 ] }
58,867
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
_clone
function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } }
/** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 5978, 6482 ] }
58,868
LiquidityMiningFactory
contracts\liquidity-mining\LiquidityMiningFactory.sol
0x9df4e915d093f03169270857cf9a0a5d1ef26388
Solidity
LiquidityMiningFactory
contract LiquidityMiningFactory is ILiquidityMiningFactory { // liquidity mining contract implementation address address public liquidityMiningImplementationAddress; // liquidity mining default extension address public override liquidityMiningDefaultExtension; // double proxy address of the linked DFO address public _doubleProxy; // linked DFO exit fee uint256 private _feePercentage; // liquidity mining collection uri string public liquidityFarmTokenCollectionURI; // liquidity mining farm token uri string public liquidityFarmTokenURI; // event that tracks liquidity mining contracts deployed event LiquidityMiningDeployed(address indexed liquidityMiningAddress, address indexed sender, bytes liquidityMiningInitResultData); // event that tracks logic contract address change event LiquidityMiningLogicSet(address indexed newAddress); // event that tracks default extension contract address change event LiquidityMiningDefaultExtensionSet(address indexed newAddress); // event that tracks wallet changes event FeePercentageSet(uint256 newFeePercentage); constructor(address doubleProxy, address _liquidityMiningImplementationAddress, address _liquidityMiningDefaultExtension, uint256 feePercentage, string memory liquidityFarmTokenCollectionUri, string memory liquidityFarmTokenUri) { _doubleProxy = doubleProxy; liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; liquidityFarmTokenURI = liquidityFarmTokenUri; emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtension); emit FeePercentageSet(_feePercentage = feePercentage); } /** PUBLIC METHODS */ function feePercentageInfo() public override view returns (uint256, address) { return (_feePercentage, IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress()); } /** @dev allows the DFO to update the double proxy address. * @param newDoubleProxy new double proxy address. */ function setDoubleProxy(address newDoubleProxy) public onlyDFO { _doubleProxy = newDoubleProxy; } /** @dev change the fee percentage * @param feePercentage new fee percentage. */ function updateFeePercentage(uint256 feePercentage) public onlyDFO { emit FeePercentageSet(_feePercentage = feePercentage); } /** @dev allows the factory owner to update the logic contract address. * @param _liquidityMiningImplementationAddress new liquidity mining implementation address. */ function updateLogicAddress(address _liquidityMiningImplementationAddress) public onlyDFO { emit LiquidityMiningLogicSet(liquidityMiningImplementationAddress = _liquidityMiningImplementationAddress); } /** @dev allows the factory owner to update the default extension contract address. * @param _liquidityMiningDefaultExtensionAddress new liquidity mining extension address. */ function updateDefaultExtensionAddress(address _liquidityMiningDefaultExtensionAddress) public onlyDFO { emit LiquidityMiningDefaultExtensionSet(liquidityMiningDefaultExtension = _liquidityMiningDefaultExtensionAddress); } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenCollectionUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenCollectionURI(string memory liquidityFarmTokenCollectionUri) public onlyDFO { liquidityFarmTokenCollectionURI = liquidityFarmTokenCollectionUri; } /** @dev allows the factory owner to update the liquidity farm token collection uri. * @param liquidityFarmTokenUri new liquidity farm token collection uri. */ function updateLiquidityFarmTokenURI(string memory liquidityFarmTokenUri) public onlyDFO { liquidityFarmTokenURI = liquidityFarmTokenUri; } /** @dev returns the liquidity farm token collection uri. * @return liquidity farm token collection uri. */ function getLiquidityFarmTokenCollectionURI() public override view returns (string memory) { return liquidityFarmTokenCollectionURI; } /** @dev returns the liquidity farm token uri. * @return liquidity farm token uri. */ function getLiquidityFarmTokenURI() public override view returns (string memory) { return liquidityFarmTokenURI; } /** @dev utlity method to clone default extension * @return clonedExtension the address of the actually-cloned liquidity mining extension */ function cloneLiquidityMiningDefaultExtension() public override returns(address clonedExtension) { emit ExtensionCloned(clonedExtension = _clone(liquidityMiningDefaultExtension)); } /** @dev this function deploys a new LiquidityMining contract and calls the encoded function passed as data. * @param data encoded initialize function for the liquidity mining contract (check LiquidityMining contract code). * @return contractAddress new liquidity mining contract address. * @return initResultData new liquidity mining contract call result. */ function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) { initResultData = _call(contractAddress = _clone(liquidityMiningImplementationAddress), data); emit LiquidityMiningDeployed(contractAddress, msg.sender, initResultData); } /** PRIVATE METHODS */ /** @dev clones the input contract address and returns the copied contract address. * @param original address of the original contract. * @return copy copied contract address. */ function _clone(address original) private returns (address copy) { assembly { mstore( 0, or( 0x5880730000000000000000000000000000000000000000803b80938091923cF3, mul(original, 0x1000000000000000000) ) ) copy := create(0, 0, 32) switch extcodesize(copy) case 0 { invalid() } } } /** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */ function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } } /** @dev onlyDFO modifier used to check for unauthorized accesses. */ modifier onlyDFO() { require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized."); _; } }
_call
function _call(address location, bytes memory payload) private returns(bytes memory returnData) { assembly { let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) let returnDataPayloadStart := add(returnData, 0x20) returndatacopy(returnDataPayloadStart, 0, size) mstore(0x40, add(returnDataPayloadStart, size)) switch result case 0 {revert(returnDataPayloadStart, size)} } }
/** @dev calls the contract at the given location using the given payload and returns the returnData. * @param location location to call. * @param payload call payload. * @return returnData call return data. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://f058c01d1a28d1984b20f4a56b451c5333cbb324fde2ceba602ca7e5b331c64a
{ "func_code_index": [ 6728, 7341 ] }
58,869
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
IOwned
contract IOwned { // this function isn't abstract since the compiler emits automatically generated getter functions as external function owner() public constant returns (address owner) { owner; } function transferOwnership(address _newOwner) public; function acceptOwnership() public; }
/* Owned contract interface */
Comment
owner
function owner() public constant returns (address owner) { owner; }
// this function isn't abstract since the compiler emits automatically generated getter functions as external
LineComment
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 134, 206 ] }
58,870
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
Owned
contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address _prevOwner, address _newOwner); /** @dev constructor */ function Owned() { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { assert(msg.sender == owner); _; } /** @dev allows transferring the contract ownership the new owner still need to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } /** @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; } }
/* Provides support and utilities for contract ownership */
Comment
Owned
function Owned() { owner = msg.sender; }
/** @dev constructor */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 195, 254 ] }
58,871
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
Owned
contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address _prevOwner, address _newOwner); /** @dev constructor */ function Owned() { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { assert(msg.sender == owner); _; } /** @dev allows transferring the contract ownership the new owner still need to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } /** @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; } }
/* Provides support and utilities for contract ownership */
Comment
transferOwnership
function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; }
/** @dev allows transferring the contract ownership the new owner still need to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 616, 761 ] }
58,872
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
Owned
contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address _prevOwner, address _newOwner); /** @dev constructor */ function Owned() { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { assert(msg.sender == owner); _; } /** @dev allows transferring the contract ownership the new owner still need to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } /** @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; } }
/* Provides support and utilities for contract ownership */
Comment
acceptOwnership
function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; }
/** @dev used by a new owner to accept an ownership transfer */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 847, 1027 ] }
58,873
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SafeMath
contract SafeMath { /** constructor */ function SafeMath() { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } }
/* Overflow protected math functions */
Comment
SafeMath
function SafeMath() { }
/** constructor */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 59, 92 ] }
58,874
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SafeMath
contract SafeMath { /** constructor */ function SafeMath() { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } }
/* Overflow protected math functions */
Comment
safeAdd
function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; }
/** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 276, 432 ] }
58,875
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SafeMath
contract SafeMath { /** constructor */ function SafeMath() { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } }
/* Overflow protected math functions */
Comment
safeSub
function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; }
/** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 654, 787 ] }
58,876
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SafeMath
contract SafeMath { /** constructor */ function SafeMath() { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } }
/* Overflow protected math functions */
Comment
safeMul
function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; }
/** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 992, 1164 ] }
58,877
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
IERC20Token
contract IERC20Token { // these functions aren't abstract since the compiler emits automatically generated getter functions as external function name() public constant returns (string name) { name; } function symbol() public constant returns (string symbol) { symbol; } function decimals() public constant returns (uint8 decimals) { decimals; } function totalSupply() public constant returns (uint256 totalSupply) { totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { _owner; balance; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { _owner; _spender; remaining; } function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); }
/* ERC20 Standard Token interface */
Comment
name
function name() public constant returns (string name) { name; }
// these functions aren't abstract since the compiler emits automatically generated getter functions as external
LineComment
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 142, 210 ] }
58,878
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
ERC20Token
contract ERC20Token is IERC20Token, SafeMath { string public standard = 'Token 0.1'; string public name = ''; string public symbol = ''; uint8 public decimals = 0; uint256 public totalSupply = 0; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** @dev constructor @param _name token name @param _symbol token symbol @param _decimals decimal points, for display purposes */ function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); // validate input name = _name; symbol = _symbol; decimals = _decimals; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } /** @dev send coins throws on any error rather then return a false flag to minimize user errors @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } /** @dev allow another account/contract to spend some tokens on your behalf throws on any error rather then return a false flag to minimize user errors also, to minimize the risk of the approve/transferFrom attack vector (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value @param _spender approved address @param _value allowance amount @return true if the approval was successful, false if it wasn't */ function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
/** ERC20 Standard Token implementation */
NatSpecMultiLine
ERC20Token
function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); // validate input name = _name; symbol = _symbol; decimals = _decimals; }
/** @dev constructor @param _name token name @param _symbol token symbol @param _decimals decimal points, for display purposes */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 712, 965 ] }
58,879
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
ERC20Token
contract ERC20Token is IERC20Token, SafeMath { string public standard = 'Token 0.1'; string public name = ''; string public symbol = ''; uint8 public decimals = 0; uint256 public totalSupply = 0; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** @dev constructor @param _name token name @param _symbol token symbol @param _decimals decimal points, for display purposes */ function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); // validate input name = _name; symbol = _symbol; decimals = _decimals; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } /** @dev send coins throws on any error rather then return a false flag to minimize user errors @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } /** @dev allow another account/contract to spend some tokens on your behalf throws on any error rather then return a false flag to minimize user errors also, to minimize the risk of the approve/transferFrom attack vector (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value @param _spender approved address @param _value allowance amount @return true if the approval was successful, false if it wasn't */ function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
/** ERC20 Standard Token implementation */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; }
/** @dev send coins throws on any error rather then return a false flag to minimize user errors @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 1428, 1766 ] }
58,880
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
ERC20Token
contract ERC20Token is IERC20Token, SafeMath { string public standard = 'Token 0.1'; string public name = ''; string public symbol = ''; uint8 public decimals = 0; uint256 public totalSupply = 0; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** @dev constructor @param _name token name @param _symbol token symbol @param _decimals decimal points, for display purposes */ function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); // validate input name = _name; symbol = _symbol; decimals = _decimals; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } /** @dev send coins throws on any error rather then return a false flag to minimize user errors @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } /** @dev allow another account/contract to spend some tokens on your behalf throws on any error rather then return a false flag to minimize user errors also, to minimize the risk of the approve/transferFrom attack vector (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value @param _spender approved address @param _value allowance amount @return true if the approval was successful, false if it wasn't */ function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
/** ERC20 Standard Token implementation */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; }
/** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 2129, 2587 ] }
58,881
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
ERC20Token
contract ERC20Token is IERC20Token, SafeMath { string public standard = 'Token 0.1'; string public name = ''; string public symbol = ''; uint8 public decimals = 0; uint256 public totalSupply = 0; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** @dev constructor @param _name token name @param _symbol token symbol @param _decimals decimal points, for display purposes */ function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); // validate input name = _name; symbol = _symbol; decimals = _decimals; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } /** @dev send coins throws on any error rather then return a false flag to minimize user errors @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } /** @dev allow another account/contract to spend some tokens on your behalf throws on any error rather then return a false flag to minimize user errors also, to minimize the risk of the approve/transferFrom attack vector (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value @param _spender approved address @param _value allowance amount @return true if the approval was successful, false if it wasn't */ function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
/** ERC20 Standard Token implementation */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
/** @dev allow another account/contract to spend some tokens on your behalf throws on any error rather then return a false flag to minimize user errors also, to minimize the risk of the approve/transferFrom attack vector (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value @param _spender approved address @param _value allowance amount @return true if the approval was successful, false if it wasn't */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 3267, 3737 ] }
58,882
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
TokenHolder
contract TokenHolder is ITokenHolder, Owned { /** @dev constructor */ function TokenHolder() { } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } // verifies that the address is different than this contract address modifier notThis(address _address) { require(_address != address(this)); _; } /** @dev withdraws tokens held by the contract and sends them to an account can only be called by the owner @param _token ERC20 token contract address @param _to account to receive the new amount @param _amount amount to withdraw */ function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); } }
/* We consider every contract to be a 'token holder' since it's currently not possible for a contract to deny receiving tokens. The TokenHolder's contract sole purpose is to provide a safety mechanism that allows the owner to send tokens that were sent to the contract by mistake back to their sender. */
Comment
TokenHolder
function TokenHolder() { }
/** @dev constructor */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 90, 126 ] }
58,883
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
TokenHolder
contract TokenHolder is ITokenHolder, Owned { /** @dev constructor */ function TokenHolder() { } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != 0x0); _; } // verifies that the address is different than this contract address modifier notThis(address _address) { require(_address != address(this)); _; } /** @dev withdraws tokens held by the contract and sends them to an account can only be called by the owner @param _token ERC20 token contract address @param _to account to receive the new amount @param _amount amount to withdraw */ function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); } }
/* We consider every contract to be a 'token holder' since it's currently not possible for a contract to deny receiving tokens. The TokenHolder's contract sole purpose is to provide a safety mechanism that allows the owner to send tokens that were sent to the contract by mistake back to their sender. */
Comment
withdrawTokens
function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); }
/** @dev withdraws tokens held by the contract and sends them to an account can only be called by the owner @param _token ERC20 token contract address @param _to account to receive the new amount @param _amount amount to withdraw */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 784, 1038 ] }
58,884
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
SmartToken
function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); }
/** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 804, 1039 ] }
58,885
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
disableTransfers
function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; }
/** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 1378, 1488 ] }
58,886
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
issue
function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); }
/** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 1763, 2093 ] }
58,887
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
destroy
function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); }
/** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 2364, 2658 ] }
58,888
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
transfer
function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; }
/** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 3118, 3519 ] }
58,889
SmartToken
SmartToken.sol
0x970d48531bd6da34dfa5f867c3bc0afe17c0c4dd
Solidity
SmartToken
contract SmartToken is ISmartToken, ERC20Token, Owned, TokenHolder { string public version = '0.2'; bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false if not // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory event NewSmartToken(address _token); // triggered when the total supply is increased event Issuance(uint256 _amount); // triggered when the total supply is decreased event Destruction(uint256 _amount); /** @dev constructor @param _name token name @param _symbol token short symbol, 1-6 characters @param _decimals for display purposes only */ function SmartToken(string _name, string _symbol, uint8 _decimals) ERC20Token(_name, _symbol, _decimals) { require(bytes(_symbol).length <= 6); // validate input NewSmartToken(address(this)); } // allows execution only when transfers aren't disabled modifier transfersAllowed { assert(transfersEnabled); _; } /** @dev disables/enables transfers can only be called by the contract owner @param _disable true to disable transfers, false to enable them */ function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } /** @dev increases the token supply and sends the new tokens to an account can only be called by the contract owner @param _to account to receive the new amount @param _amount amount to increase the supply by */ function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } /** @dev removes tokens from an account and decreases the token supply can only be called by the contract owner @param _from account to remove the amount from @param _amount amount to decrease the supply by */ function destroy(address _from, uint256 _amount) public ownerOnly { balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } // ERC20 standard method overrides with some extra functionality /** @dev send coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } /** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; } }
/* Smart Token v0.2 'Owned' is specified here for readability reasons */
Comment
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); // transferring to the contract address destroys tokens if (_to == address(this)) { balanceOf[_to] -= _value; totalSupply -= _value; Destruction(_value); } return true; }
/** @dev an account/contract attempts to get the coins throws on any error rather then return a false flag to minimize user errors note that when transferring to the smart token's address, the coins are actually destroyed @param _from source address @param _to target address @param _value transfer amount @return true if the transfer was successful, false if it wasn't */
NatSpecMultiLine
v0.4.11+commit.68ef5810
bzzr://40d25660566fc33574f228a6e19b4632cbb9914574a1dd90deff088a9e5f717a
{ "func_code_index": [ 3982, 4413 ] }
58,890
Token
Token.sol
0x6343e78969b2e497b3b0c5a1c38ac78c32443a13
Solidity
ERC20
interface ERC20 { //Methods function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); //Events event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
totalSupply
function totalSupply() external view returns (uint256);
//Methods
LineComment
v0.8.4+commit.c7e474f2
None
ipfs://588f2542692d6f6c0d43b389c917b5c55fb9114e895e0adb2c3b4361c2bb8807
{ "func_code_index": [ 38, 98 ] }
58,891
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 89, 272 ] }
58,892
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 356, 629 ] }
58,893
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 744, 860 ] }
58,894
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 924, 1060 ] }
58,895
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
totalSupply
function totalSupply() public view returns (uint256) { return totalSupply_; }
/** * @dev total number of tokens in existence */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 199, 287 ] }
58,896
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; }
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 445, 836 ] }
58,897
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 1042, 1154 ] }
58,898
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 401, 853 ] }
58,899
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 1485, 1675 ] }
58,900
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
allowance
function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 1999, 2130 ] }
58,901
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
increaseApproval
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 2596, 2860 ] }
58,902
JippiToken
JippiToken.sol
0x261a8a50e28e3f3faee5185da626ac54699fc494
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
decreaseApproval
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3771161ea3c5601e869ca8152fedd96144cc5031b4aa14ff215b6635e87d5a18
{ "func_code_index": [ 3331, 3741 ] }
58,903
metaaniGEN
metaaniGen1002.sol
0xa467ab9447afa5db0c70325348d810d2058dde18
Solidity
metaaniGEN
contract metaaniGEN is ERC721URIStorage , ERC721Enumerable { address public owner; string ipfs_base; bool mint_started = false; address storeAddress; bool storeOpened; mapping(uint => bool) public minted; bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; uint public price = 0.15 ether; address mekezzo = 0xcc344De89bB3CB8F6c6134dDb338847cE58f64cA; address misoshita = 0xd9a126b386455925E7a464eAC06Ab603c5043b2f; address nandemotoken = 0xE35B827177398D8d2FBA304d9cF53bc8fC1573B7; address metawallet = 0x60a89BB4C35A62DE53e4E1852E2d4037a008aC5b; mapping(address => uint) priceCandidates; function setPrice(uint _priceCandidate) public { require(msg.sender == mekezzo || msg.sender == misoshita || msg.sender == nandemotoken); priceCandidates[msg.sender] = _priceCandidate; } function getPrice() internal view returns (uint) { if (priceCandidates[mekezzo] == priceCandidates[misoshita] && priceCandidates[misoshita] == priceCandidates[nandemotoken] && priceCandidates[nandemotoken] != 0 ){ return priceCandidates[mekezzo];} return price; } function mintNFT(uint256 _nftid) public payable { require(msg.value == getPrice() ); require( mint_started ); require( _nftid <= 10000); _safeMint( msg.sender , _nftid); minted[_nftid] = true; } //args example ["20","40","60","80","100","120","140","160","180","200"] function mint10(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 10 - 0.1 ether ); require( mint_started ); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); _safeMint( msg.sender , _nftids[i]); minted[_nftids[i]] = true; } } function setStoreAddress( address _storeAddress ) public { require(msg.sender == metawallet); storeAddress = _storeAddress; } function storeOpen() public { require(msg.sender == metawallet); storeOpened = true; } //args example ["20","40","60","80","100","120","140","160","180","200"] function mint100(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 90 ); require( mint_started ); require( storeOpened ); store(storeAddress).buildstore(msg.sender); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); uint adj = 0; for (uint j = 0 ; j < 10 ; j++ ){ while (minted[_nftids[i]+j+adj]){ adj = adj + 1; } _safeMint( msg.sender , _nftids[i]+j + adj); minted[_nftids[i]+j + adj] = true; } } } function gift(uint256 _nftid , address _friend ) public payable { require(msg.value == getPrice() ); require( mint_started ); require( _nftid <= 10000); _safeMint( _friend , _nftid); minted[_nftid] = true; } function mintStart() public { require(msg.sender == metawallet); mint_started = true; } function mintStop() public { require(msg.sender == metawallet); mint_started = false; } function withdraw() public { require(msg.sender == metawallet); uint balance = address(this).balance; payable(metawallet).transfer(balance); } function withdrawSpare() public { require(msg.sender == misoshita); uint balance = address(this).balance; payable(mekezzo).transfer(balance); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function burn(uint256 _id) public { require( msg.sender == ownerOf(_id)); _burn(_id); } function _baseURI() internal view override returns (string memory) { return ipfs_base; } function setbaseURI(string memory _ipfs_base) public { require(msg.sender == metawallet ); ipfs_base = _ipfs_base; } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } struct Part_ { address payable account; uint96 value; } function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view returns (address receiver, uint256 royaltyAmount) { _tokenId; //---------------------------------------- return (metawallet, (_salePrice * 1000)/10000); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { if(interfaceId == _INTERFACE_ID_ERC2981) { return true; } return super.supportsInterface(interfaceId); } constructor() ERC721("MetaaniGEN" , "MTANG" ) { owner = msg.sender; //MetaaniGEN ipfs_base = "ipfs://QmTiW6V5AG3tVJuewTV2NX1yqFJzLb28MpS7ctTHnPzKXT/"; _safeMint( msg.sender , 7); minted[7] = true; } }
mint10
function mint10(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 10 - 0.1 ether ); require( mint_started ); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); _safeMint( msg.sender , _nftids[i]); minted[_nftids[i]] = true; } }
//args example ["20","40","60","80","100","120","140","160","180","200"]
LineComment
v0.8.7+commit.e28d00a7
None
ipfs://3b6be409b370e910973d69ac0bd721b393fce022590c23a1d7974c5047565024
{ "func_code_index": [ 1572, 1927 ] }
58,904
metaaniGEN
metaaniGen1002.sol
0xa467ab9447afa5db0c70325348d810d2058dde18
Solidity
metaaniGEN
contract metaaniGEN is ERC721URIStorage , ERC721Enumerable { address public owner; string ipfs_base; bool mint_started = false; address storeAddress; bool storeOpened; mapping(uint => bool) public minted; bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; uint public price = 0.15 ether; address mekezzo = 0xcc344De89bB3CB8F6c6134dDb338847cE58f64cA; address misoshita = 0xd9a126b386455925E7a464eAC06Ab603c5043b2f; address nandemotoken = 0xE35B827177398D8d2FBA304d9cF53bc8fC1573B7; address metawallet = 0x60a89BB4C35A62DE53e4E1852E2d4037a008aC5b; mapping(address => uint) priceCandidates; function setPrice(uint _priceCandidate) public { require(msg.sender == mekezzo || msg.sender == misoshita || msg.sender == nandemotoken); priceCandidates[msg.sender] = _priceCandidate; } function getPrice() internal view returns (uint) { if (priceCandidates[mekezzo] == priceCandidates[misoshita] && priceCandidates[misoshita] == priceCandidates[nandemotoken] && priceCandidates[nandemotoken] != 0 ){ return priceCandidates[mekezzo];} return price; } function mintNFT(uint256 _nftid) public payable { require(msg.value == getPrice() ); require( mint_started ); require( _nftid <= 10000); _safeMint( msg.sender , _nftid); minted[_nftid] = true; } //args example ["20","40","60","80","100","120","140","160","180","200"] function mint10(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 10 - 0.1 ether ); require( mint_started ); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); _safeMint( msg.sender , _nftids[i]); minted[_nftids[i]] = true; } } function setStoreAddress( address _storeAddress ) public { require(msg.sender == metawallet); storeAddress = _storeAddress; } function storeOpen() public { require(msg.sender == metawallet); storeOpened = true; } //args example ["20","40","60","80","100","120","140","160","180","200"] function mint100(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 90 ); require( mint_started ); require( storeOpened ); store(storeAddress).buildstore(msg.sender); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); uint adj = 0; for (uint j = 0 ; j < 10 ; j++ ){ while (minted[_nftids[i]+j+adj]){ adj = adj + 1; } _safeMint( msg.sender , _nftids[i]+j + adj); minted[_nftids[i]+j + adj] = true; } } } function gift(uint256 _nftid , address _friend ) public payable { require(msg.value == getPrice() ); require( mint_started ); require( _nftid <= 10000); _safeMint( _friend , _nftid); minted[_nftid] = true; } function mintStart() public { require(msg.sender == metawallet); mint_started = true; } function mintStop() public { require(msg.sender == metawallet); mint_started = false; } function withdraw() public { require(msg.sender == metawallet); uint balance = address(this).balance; payable(metawallet).transfer(balance); } function withdrawSpare() public { require(msg.sender == misoshita); uint balance = address(this).balance; payable(mekezzo).transfer(balance); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function burn(uint256 _id) public { require( msg.sender == ownerOf(_id)); _burn(_id); } function _baseURI() internal view override returns (string memory) { return ipfs_base; } function setbaseURI(string memory _ipfs_base) public { require(msg.sender == metawallet ); ipfs_base = _ipfs_base; } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } struct Part_ { address payable account; uint96 value; } function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view returns (address receiver, uint256 royaltyAmount) { _tokenId; //---------------------------------------- return (metawallet, (_salePrice * 1000)/10000); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { if(interfaceId == _INTERFACE_ID_ERC2981) { return true; } return super.supportsInterface(interfaceId); } constructor() ERC721("MetaaniGEN" , "MTANG" ) { owner = msg.sender; //MetaaniGEN ipfs_base = "ipfs://QmTiW6V5AG3tVJuewTV2NX1yqFJzLb28MpS7ctTHnPzKXT/"; _safeMint( msg.sender , 7); minted[7] = true; } }
mint100
function mint100(uint256[10] memory _nftids) public payable { require(msg.value == getPrice() * 90 ); require( mint_started ); require( storeOpened ); store(storeAddress).buildstore(msg.sender); for (uint i = 0 ; i < 10 ; i++ ){ require( _nftids[i] <= 10000); uint adj = 0; for (uint j = 0 ; j < 10 ; j++ ){ while (minted[_nftids[i]+j+adj]){ adj = adj + 1; } _safeMint( msg.sender , _nftids[i]+j + adj); minted[_nftids[i]+j + adj] = true; } } }
//args example ["20","40","60","80","100","120","140","160","180","200"]
LineComment
v0.8.7+commit.e28d00a7
None
ipfs://3b6be409b370e910973d69ac0bd721b393fce022590c23a1d7974c5047565024
{ "func_code_index": [ 2291, 2920 ] }
58,905
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
TokenERC20
function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes }
/** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 840, 1385 ] }
58,906
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); }
/** * Internal transfer, only can be called by this contract */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 1469, 2312 ] }
58,907
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transfer
function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); }
/** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 2520, 2632 ] }
58,908
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 2907, 3208 ] }
58,909
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; }
/** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 3472, 3648 ] }
58,910
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
/** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 4042, 4394 ] }
58,911
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
burn
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; }
/** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 4564, 4938 ] }
58,912
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
burnFrom
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; }
/** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 5196, 5808 ] }
58,913
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
GEOSToken
contract GEOSToken is owned, TokenERC20 { event mylog(uint code); /* Initializes contract with initial supply tokens to the creator of the contract */ function GEOSToken ( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) payable public {} function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require(balanceOf[_from] >= _value); // Check if the sender has enough require(balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); mylog(0); } //Destroy tokens function destroyToken(address target,uint256 mintedAmount ) onlyOwner public returns(bool) { require(balanceOf[target] >= mintedAmount); balanceOf[target] -=mintedAmount; //balanceOf[target] += mintedAmount; totalSupply -= mintedAmount; //Transfer(0, this, mintedAmount); Transfer(target, 0, mintedAmount); mylog(0); return true; } }
/******************************************/
NatSpecMultiLine
GEOSToken
function GEOSToken ( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) payable public {}
/* Initializes contract with initial supply tokens to the creator of the contract */
Comment
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 170, 357 ] }
58,914
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
GEOSToken
contract GEOSToken is owned, TokenERC20 { event mylog(uint code); /* Initializes contract with initial supply tokens to the creator of the contract */ function GEOSToken ( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) payable public {} function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require(balanceOf[_from] >= _value); // Check if the sender has enough require(balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); mylog(0); } //Destroy tokens function destroyToken(address target,uint256 mintedAmount ) onlyOwner public returns(bool) { require(balanceOf[target] >= mintedAmount); balanceOf[target] -=mintedAmount; //balanceOf[target] += mintedAmount; totalSupply -= mintedAmount; //Transfer(0, this, mintedAmount); Transfer(target, 0, mintedAmount); mylog(0); return true; } }
/******************************************/
NatSpecMultiLine
_transfer
function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require(balanceOf[_from] >= _value); // Check if the sender has enough require(balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); mylog(0); }
/* Internal transfer, only can be called by this contract */
Comment
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 548, 1169 ] }
58,915
GEOSToken
GEOSToken.sol
0xc378bb8f3e155e5e561eb4caa337c4a35c34c2ba
Solidity
GEOSToken
contract GEOSToken is owned, TokenERC20 { event mylog(uint code); /* Initializes contract with initial supply tokens to the creator of the contract */ function GEOSToken ( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) payable public {} function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require(balanceOf[_from] >= _value); // Check if the sender has enough require(balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); mylog(0); } //Destroy tokens function destroyToken(address target,uint256 mintedAmount ) onlyOwner public returns(bool) { require(balanceOf[target] >= mintedAmount); balanceOf[target] -=mintedAmount; //balanceOf[target] += mintedAmount; totalSupply -= mintedAmount; //Transfer(0, this, mintedAmount); Transfer(target, 0, mintedAmount); mylog(0); return true; } }
/******************************************/
NatSpecMultiLine
destroyToken
function destroyToken(address target,uint256 mintedAmount ) onlyOwner public returns(bool) { require(balanceOf[target] >= mintedAmount); balanceOf[target] -=mintedAmount; //balanceOf[target] += mintedAmount; totalSupply -= mintedAmount; //Transfer(0, this, mintedAmount); Transfer(target, 0, mintedAmount); mylog(0); return true; }
//Destroy tokens
LineComment
v0.4.19+commit.c4cbbb05
None
bzzr://99d163fd83d96fcbf3af2a7ce4ea20c94b24a7d31f7519ccb3a201171b44833d
{ "func_code_index": [ 1204, 1625 ] }
58,916
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
SafeMath
library SafeMath { 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"); } 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"); } 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
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 on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 490, 631 ] }
58,917
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
SafeMath
library SafeMath { 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"); } 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"); } 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mul
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 multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1085, 1561 ] }
58,918
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
SafeMath
library SafeMath { 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"); } 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"); } 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
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 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. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 2032, 2169 ] }
58,919
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
Address
library Address { function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } 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"); } 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); } 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"); } 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
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 with * `errorMessage` as a fallback revert reason when `target` reverts. * * Available since v3.1. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1257, 1458 ] }
58,920
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
IERC20
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); 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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 94, 154 ] }
58,921
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
IERC20
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); 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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 237, 310 ] }
58,922
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
IERC20
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); 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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 534, 616 ] }
58,923
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
IERC20
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); 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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @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. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 895, 983 ] }
58,924
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1051, 1139 ] }
58,925
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
symbol
function symbol() public view returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1253, 1345 ] }
58,926
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
totalSupply
function totalSupply() public view override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1496, 1601 ] }
58,927
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
balanceOf
function balanceOf(address account) public view override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1659, 1783 ] }
58,928
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
transfer
function transfer(address recipient, uint256 amount) public virtual onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 1991, 2285 ] }
58,929
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 2343, 2499 ] }
58,930
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
approve
function approve(address spender, uint256 amount) public virtual onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 2641, 2827 ] }
58,931
ERC20
ERC20.sol
0x731c56d0971c021d6331a2700849984e4c3ad2e2
Solidity
ERC20
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "DRIA "; //_symbol = "DRIA "; _name = "DRIA"; _symbol = "DRIA"; _decimals = 18; _totalSupply = 210000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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); } }
_approve
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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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. */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
ipfs://9ca94d43b03077eb141b90282d6301b6a1fd24bda9186adfeb57ceb0e665888f
{ "func_code_index": [ 4803, 5154 ] }
58,932
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
init
function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); }
/** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 2255, 3162 ] }
58,933
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
deposit
function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); }
/** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 3417, 5253 ] }
58,934
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
withdraw
function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } }
/** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 5420, 6130 ] }
58,935
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
refund
function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } }
/** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 6390, 7020 ] }
58,936
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setNetworkFeeTier2
function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); }
/** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 7831, 8677 ] }
58,937
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setCustomNetworkFeeTier
function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); }
/** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 8951, 9451 ] }
58,938
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setNetworkFeePercentage
function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); }
/** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 9834, 10728 ] }
58,939
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setCustomNetworkFeePercentage
function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); }
/** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 10979, 11486 ] }
58,940
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setTreasuryWallet
function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); }
/** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 11705, 11949 ] }
58,941
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setCommunityWallet
function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); }
/** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 12171, 12424 ] }
58,942
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setAdmin
function setAdmin(address _admin) external onlyOwner { admin = _admin; }
/// @notice Function to set new admin address /// @param _admin Address of new admin
NatSpecSingleLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 12519, 12607 ] }
58,943
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
setPendingStrategy
function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; }
/** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 12842, 13126 ] }
58,944
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
unlockMigrateFunds
function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; }
/** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 13267, 13429 ] }
58,945
DAOVault
contracts/vaults/DAOVault.sol
0xd0f0858578c7780f2d65f6d81bc7ddbe166367cc
Solidity
DAOVault
contract DAOVault is Initializable, ERC20Upgradeable, OwnableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; bytes32 public vaultName; IERC20Upgradeable public token; uint256 private _fees; IStrategy2 public strategy; address public pendingStrategy; bool public canSetPendingStrategy; uint256 public unlockTime; // Calculation for fees uint256[] public networkFeeTier2; uint256 public customNetworkFeeTier; uint256[] public networkFeePercentage; uint256 public customNetworkFeePercentage; // Address to collect fees address public treasuryWallet; address public communityWallet; address public admin; event SetNetworkFeeTier2( uint256[] oldNetworkFeeTier2, uint256[] newNetworkFeeTier2 ); event SetNetworkFeePercentage( uint256[] oldNetworkFeePercentage, uint256[] newNetworkFeePercentage ); event SetCustomNetworkFeeTier( uint256 indexed oldCustomNetworkFeeTier, uint256 indexed newCustomNetworkFeeTier ); event SetCustomNetworkFeePercentage( uint256 oldCustomNetworkFeePercentage, uint256 newCustomNetworkFeePercentage ); event SetTreasuryWallet( address indexed oldTreasuryWallet, address indexed newTreasuryWallet ); event SetCommunityWallet( address indexed oldCommunityWallet, address indexed newCommunityWallet ); event MigrateFunds( address indexed fromStrategy, address indexed toStrategy, uint256 amount ); modifier onlyAdmin { require(msg.sender == address(admin), "Only admin"); _; } modifier onlyEOA { require(msg.sender == tx.origin, "Only EOA"); _; } /** * @notice Replace constructor function in clone contract * @dev modifier initializer: only allow run this function once * @param _vaultName Name of this vault contract * @param _token Token that vault accept and interact with strategy * @param _strategy Strategy contract that vault interact with * @param _owner Owner of this vault contract */ function init( bytes32 _vaultName, address _token, address _strategy, address _owner ) external initializer { __ERC20_init("DAO Vault Harvest", "daoHAR"); __Ownable_init(_owner); vaultName = _vaultName; token = IERC20Upgradeable(_token); strategy = IStrategy2(_strategy); admin = _owner; canSetPendingStrategy = true; uint8 decimals = ERC20Upgradeable(_token).decimals(); networkFeeTier2 = [50000 * 10**decimals + 1, 100000 * 10**decimals]; customNetworkFeeTier = 1000000 * 10**decimals; networkFeePercentage = [100, 75, 50]; customNetworkFeePercentage = 25; treasuryWallet = 0x59E83877bD248cBFe392dbB5A8a29959bcb48592; communityWallet = 0xdd6c35aFF646B2fB7d8A8955Ccbe0994409348d0; token.safeApprove(address(strategy), type(uint256).max); } /** * @notice Deposit into strategy * @param _amount amount to deposit * Requirements: * - Sender must approve this contract to transfer token from sender to this contract * - Only EOA account can call this function */ function deposit(uint256 _amount) external onlyEOA { require(_amount > 0, "Amount must > 0"); uint256 _pool = strategy.getPseudoPool().add(token.balanceOf(address(this))).sub(_fees); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _networkFeePercentage; /** * Network fees * networkFeeTier2 is used to set each tier minimun and maximun * For example networkFeeTier2 is [50000, 100000], * Tier 1 = _depositAmount < 50001 * Tier 2 = 50001 <= _depositAmount <= 100000 * Tier 3 = _depositAmount > 100000 * * networkFeePercentage is used to set each tier network fee percentage * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75%, Tier 3 = 0.5% * * customNetworkFeeTier is treat as tier 4 * customNetworkFeePercentage will be used in customNetworkFeeTier */ if (_amount < networkFeeTier2[0]) { // Tier 1 _networkFeePercentage = networkFeePercentage[0]; } else if (_amount <= networkFeeTier2[1]) { // Tier 2 _networkFeePercentage = networkFeePercentage[1]; } else if (_amount < customNetworkFeeTier) { // Tier 3 _networkFeePercentage = networkFeePercentage[2]; } else { // Custom Tier _networkFeePercentage = customNetworkFeePercentage; } uint256 _fee = _amount.mul(_networkFeePercentage).div(10000 /*DENOMINATOR*/); _amount = _amount.sub(_fee); _fees = _fees.add(_fee); uint256 _shares = totalSupply() == 0 ? _amount : _amount.mul(totalSupply()).div(_pool); _mint(msg.sender, _shares); } /** * @notice Withdraw from strategy * @param _shares shares to withdraw * Requirements: * - Only EOA account can call this function */ function withdraw(uint256 _shares) external onlyEOA { uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _withdrawAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); // USDT.transfer doesn't check if amount is 0. Therefor we will check it here. require(0 < _withdrawAmt, "Amount must > 0"); _burn(msg.sender, _shares); if (_withdrawAmt > _balanceOfVault) { uint256 _diff = strategy.withdraw(_withdrawAmt.sub(_balanceOfVault)); token.safeTransfer(msg.sender, _balanceOfVault.add(_diff)); } else { token.safeTransfer(msg.sender, _withdrawAmt); } } /** * @notice Refund from strategy * @notice This function usually only available when strategy in vesting state * Requirements: * - Only EOA account can call this function * - Amount daoToken of user must greater than 0 */ function refund() external onlyEOA { require(balanceOf(msg.sender) > 0, "No balance to refund"); uint256 _shares = balanceOf(msg.sender); uint256 _balanceOfVault = (token.balanceOf(address(this))).sub(_fees); uint256 _refundAmt = (_balanceOfVault.add(strategy.pool()).mul(_shares).div(totalSupply())); _burn(msg.sender, _shares); if (_balanceOfVault < _refundAmt) { strategy.refund(_refundAmt.sub(_balanceOfVault)); token.safeTransfer(tx.origin, _balanceOfVault); } else { token.safeTransfer(tx.origin, _refundAmt); } } function invest() external onlyAdmin { if (_fees > 0) { uint256 _treasuryFee = _fees.div(2); token.safeTransfer(treasuryWallet, _treasuryFee); token.safeTransfer(communityWallet, _fees.sub(_treasuryFee)); _fees = 0; } uint256 _toInvest = token.balanceOf(address(this)); strategy.invest(_toInvest); } /** * @notice Set network fee tier * @notice Details for network fee tier can view at deposit() function above * @param _networkFeeTier2 Array [tier2 minimun, tier2 maximun], view additional info below * Requirements: * - Only owner of this contract can call this function * - First element in array must greater than 0 * - Second element must greater than first element */ function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner { require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0"); require( _networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount" ); /** * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2 * Tier 1: deposit amount < minimun amount of tier 2 * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2 * Tier 3: amount > maximun amount of tier 2 */ uint256[] memory oldNetworkFeeTier2 = networkFeeTier2; networkFeeTier2 = _networkFeeTier2; emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2); } /** * @notice Set custom network fee tier * @param _customNetworkFeeTier Integar * Requirements: * - Only owner of this contract can call this function * - Custom network fee tier must greater than maximun amount of network fee tier 2 */ function setCustomNetworkFeeTier(uint256 _customNetworkFeeTier) external onlyOwner { require( _customNetworkFeeTier > networkFeeTier2[1], "Custom network fee tier must greater than tier 2" ); uint256 oldCustomNetworkFeeTier = customNetworkFeeTier; customNetworkFeeTier = _customNetworkFeeTier; emit SetCustomNetworkFeeTier( oldCustomNetworkFeeTier, _customNetworkFeeTier ); } /** * @notice Set network fee in percentage * @notice Details for network fee percentage can view at deposit() function above * @param _networkFeePercentage An array of integer, view additional info below * Requirements: * - Only owner of this contract can call this function * - Each of the element in the array must less than 3000 (30%) */ function setNetworkFeePercentage(uint256[] calldata _networkFeePercentage) external onlyOwner { require( _networkFeePercentage[0] < 3000 && _networkFeePercentage[1] < 3000 && _networkFeePercentage[2] < 3000, "Network fee percentage cannot be more than 30%" ); /** * _networkFeePercentage content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3 * For example networkFeePercentage is [100, 75, 50] * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5% */ uint256[] memory oldNetworkFeePercentage = networkFeePercentage; networkFeePercentage = _networkFeePercentage; emit SetNetworkFeePercentage( oldNetworkFeePercentage, _networkFeePercentage ); } /** * @notice Set custom network fee percentage * @param _percentage Integar (100 = 1%) * Requirements: * - Only owner of this contract can call this function * - Amount set must less than network fee for tier 3 */ function setCustomNetworkFeePercentage(uint256 _percentage) public onlyOwner { require( _percentage < networkFeePercentage[2], "Custom network fee percentage cannot be more than tier 2" ); uint256 oldCustomNetworkFeePercentage = customNetworkFeePercentage; customNetworkFeePercentage = _percentage; emit SetCustomNetworkFeePercentage( oldCustomNetworkFeePercentage, _percentage ); } /** * @notice Set new treasury wallet address in contract * @param _treasuryWallet Address of new treasury wallet * Requirements: * - Only owner of this contract can call this function */ function setTreasuryWallet(address _treasuryWallet) external onlyOwner { address oldTreasuryWallet = treasuryWallet; treasuryWallet = _treasuryWallet; emit SetTreasuryWallet(oldTreasuryWallet, _treasuryWallet); } /** * @notice Set new community wallet address in contract * @param _communityWallet Address of new community wallet * Requirements: * - Only owner of this contract can call this function */ function setCommunityWallet(address _communityWallet) external onlyOwner { address oldCommunityWallet = communityWallet; communityWallet = _communityWallet; emit SetCommunityWallet(oldCommunityWallet, _communityWallet); } /// @notice Function to set new admin address /// @param _admin Address of new admin function setAdmin(address _admin) external onlyOwner { admin = _admin; } /** * @notice Set pending strategy * @param _pendingStrategy Address of pending strategy * Requirements: * - Only owner of this contract call this function * - Pending strategy must be a contract */ function setPendingStrategy(address _pendingStrategy) external onlyOwner { require(canSetPendingStrategy, "Cannot set pending strategy now"); require(_pendingStrategy.isContract(), "New strategy is not contract"); pendingStrategy = _pendingStrategy; } /** * @notice Unlock function migrateFunds() * Requirements: * - Only owner of this contract call this function */ function unlockMigrateFunds() external onlyOwner { unlockTime = block.timestamp.add(2 days /*LOCKTIME*/); canSetPendingStrategy = false; } /** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */ function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); } }
/// @title Contract to interact between user and strategy, and distribute daoToken
NatSpecSingleLine
migrateFunds
function migrateFunds() external onlyOwner { require( unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked" ); require( token.balanceOf(address(strategy)) > 0, "No balance to migrate" ); require(pendingStrategy != address(0), "No pendingStrategy"); uint256 _amount = token.balanceOf(address(strategy)); token.safeTransferFrom(address(strategy), pendingStrategy, _amount); // Set new strategy address oldStrategy = address(strategy); strategy = IStrategy2(pendingStrategy); pendingStrategy = address(0); canSetPendingStrategy = true; token.safeApprove(address(oldStrategy), 0); token.safeApprove(address(strategy), type(uint256).max); unlockTime = 0; // Lock back this function emit MigrateFunds(oldStrategy, address(strategy), _amount); }
/** * @notice Migrate all funds from old strategy to new strategy * Requirements: * - Only owner of this contract call this function * - This contract is not locked * - Pending strategy is set */
NatSpecMultiLine
v0.7.6+commit.7338295f
{ "func_code_index": [ 13661, 14643 ] }
58,946
ERC20
ERC20.sol
0x5c14584436d3a4533abbf5c2f87622cb009ad67e
Solidity
ERC20
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; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } 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; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } 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; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) 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); } 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); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} 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); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } 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); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_GAINS(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from 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); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
_transfer_GAINS
function _transfer_GAINS(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from 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); }
//transfer
LineComment
v0.6.6+commit.6c089d02
None
ipfs://e15798efe4213dd4f48d66cc36940fde9f6370754da384442e52a8aa5b0f6235
{ "func_code_index": [ 5972, 6517 ] }
58,947
AssetBurnStrategy
AssetBurnStrategy.sol
0xf2eefca91a179c5eb38caa0ea2bcb79ad1e46a79
Solidity
AssetBurnStrategy
contract AssetBurnStrategy is BaseStrategyInitializable { using SafeERC20 for ERC20; using Address for address; using SafeMath for uint256; VaultAPI public underlyingVault; address public asset; address public weth; address public uniswapRouterV2; address public uniswapFactory; address[] internal _path; uint256 constant MAX_BPS = 10000; uint256 public burningProfitRatio; uint256 public targetSupply; modifier onlyGovernanceOrManagement() { require( msg.sender == governance() || msg.sender == vault.management(), "!authorized" ); _; } constructor( address _vault, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) public BaseStrategyInitializable(_vault) { _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function init( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external { super._initialize(_vault, _onBehalfOf, _onBehalfOf, _onBehalfOf); _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function _init( address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) internal { require( address(want) == VaultAPI(_underlyingVault).token(), "Vault want is different from the underlying vault token" ); underlyingVault = VaultAPI(_underlyingVault); asset = _asset; weth = _weth; uniswapRouterV2 = _uniswapRouterV2; uniswapFactory = _uniswapFactory; if ( address(want) == weth || address(want) == 0x6B175474E89094C44Da98b954EedeAC495271d0F ) { _path = new address[](2); _path[0] = address(want); _path[1] = asset; } else { _path = new address[](3); _path[0] = address(want); _path[1] = weth; _path[2] = asset; } ERC20(address(want)).safeApprove(_uniswapRouterV2, type(uint256).max); // initial burning profit ratio 50% burningProfitRatio = 5000; // initial target supply equal to constructor initial supply targetSupply = ERC20(asset).totalSupply(); want.safeApprove(_underlyingVault, type(uint256).max); } // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); } function estimatedTotalAssets() public view override returns (uint256) { return _balanceOfWant().add(_balanceOnUnderlyingVault()); } function _balanceOfWant() internal view returns (uint256) { return ERC20(address(want)).balanceOf(address(this)); } function _balanceOnUnderlyingVault() internal view returns (uint256) { return underlyingVault .balanceOf(address(this)) .mul(underlyingVault.pricePerShare()) .div(10**underlyingVault.decimals()); } function ethToWant(uint256 _amount) internal view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = address(weth); path[1] = address(want); uint256[] memory amounts = IUniswapRouter(uniswapRouterV2).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 debt = vault.strategies(address(this)).totalDebt; uint256 currentValue = estimatedTotalAssets(); uint256 wantBalance = _balanceOfWant(); // Calculate total profit w/o farming if (debt < currentValue) { _profit = currentValue.sub(debt); } else { _loss = debt.sub(currentValue); } // To withdraw = profit from lending + _debtOutstanding uint256 toFree = _debtOutstanding.add(_profit); // In the case want is not enough, divest from idle if (toFree > wantBalance) { // Divest only the missing part = toFree-wantBalance toFree = toFree.sub(wantBalance); (uint256 _liquidatedAmount, ) = liquidatePosition(toFree); // loss in the case freedAmount less to be freed uint256 withdrawalLoss = _liquidatedAmount < toFree ? toFree.sub(_liquidatedAmount) : 0; // profit recalc if (withdrawalLoss < _profit) { _profit = _profit.sub(withdrawalLoss); } else { _loss = _loss.add(withdrawalLoss.sub(_profit)); _profit = 0; } } if (_profit > 0) { ERC20Burnable assetToken = ERC20Burnable(asset); uint256 currentTotalSupply = assetToken.totalSupply(); uint256 targetAssetToBurn = currentTotalSupply > targetSupply ? currentTotalSupply.sub(targetSupply) : 0; // supply <= targetSupply nothing to burn if (targetAssetToBurn > 0) { // Check we have sufficient liquidity IUniswapV2Factory factory = IUniswapV2Factory(uniswapFactory); address pair = factory.getPair( _path[_path.length - 2], _path[_path.length - 1] ); require(pair != address(0), "Pair must exist to swap"); // Buy at most to empty the pool uint256 pairAssetBalance = assetToken.balanceOf(pair); targetAssetToBurn = Math.min( pairAssetBalance > 0 ? pairAssetBalance.mul(50).div(100) : 0, targetAssetToBurn ); } if (targetAssetToBurn > 0) { uint256 profitToConvert = _profit.mul(burningProfitRatio).div(MAX_BPS); IUniswapRouter router = IUniswapRouter(uniswapRouterV2); uint256 expectedProfitToUse = (router.getAmountsIn(targetAssetToBurn, _path))[0]; // In the case profitToConvert > expected to use for burning target asset use the latter // On the contrary use profitToConvert uint256 exchangedAmount = ( router.swapExactTokensForTokens( Math.min(profitToConvert, expectedProfitToUse), 1, _path, address(this), now.add(1800) ) )[0]; // TOBE CHECKED leverage uniswap returns want amount _profit = _profit.sub(exchangedAmount); // burn assetToken.burn(assetToken.balanceOf(address(this))); } } // Recalculate profit wantBalance = want.balanceOf(address(this)); if (wantBalance < _profit) { _profit = wantBalance; _debtPayment = 0; } else if (wantBalance < _debtOutstanding.add(_profit)) { _debtPayment = wantBalance.sub(_profit); } else { _debtPayment = _debtOutstanding; } } function adjustPosition(uint256 _debtOutstanding) internal override { // TODO: Do something to invest excess `want` tokens (from the Vault) into your positions // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant > _debtOutstanding) { underlyingVault.deposit(balanceOfWant.sub(_debtOutstanding)); } } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { // TODO: Do stuff here to free up to `_amountNeeded` from all positions back into `want` uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant < _amountNeeded) { uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant); uint256 valueToRedeemApprox = amountToRedeem.mul(10**underlyingVault.decimals()).div( underlyingVault.pricePerShare() ); uint256 valueToRedeem = Math.min( valueToRedeemApprox, underlyingVault.balanceOf(address(this)) ); underlyingVault.withdraw(valueToRedeem); } // _liquidatedAmount min(_amountNeeded, balanceOfWant), otw vault accounting breaks balanceOfWant = _balanceOfWant(); if (balanceOfWant >= _amountNeeded) { _liquidatedAmount = _amountNeeded; } else { _liquidatedAmount = balanceOfWant; _loss = _amountNeeded.sub(balanceOfWant); } } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } function prepareMigration(address _newStrategy) internal override { // TODO: Transfer any non-`want` tokens to the new strategy // NOTE: `migrate` will automatically forward all `want` in this strategy to the new one underlyingVault.withdraw(); ERC20 assetToken = ERC20(asset); assetToken.safeTransfer( _newStrategy, assetToken.balanceOf(address(this)) ); } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; } function setBurningProfitRatio(uint256 _burningProfitRatio) external onlyGovernanceOrManagement { require( _burningProfitRatio <= MAX_BPS, "Burning profit ratio should be less than 10000" ); burningProfitRatio = _burningProfitRatio; } function setTargetSupply(uint256 _targetSuplly) external onlyGovernanceOrManagement { targetSupply = _targetSuplly; } function clone( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore( clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000 ) mstore(add(clone_code, 0x14), addressBytes) mstore( add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000 ) newStrategy := create(0, clone_code, 0x37) } AssetBurnStrategy(newStrategy).init( _vault, _onBehalfOf, _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); emit Cloned(newStrategy); } }
name
function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); }
// ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 2877, 3150 ] }
58,948
AssetBurnStrategy
AssetBurnStrategy.sol
0xf2eefca91a179c5eb38caa0ea2bcb79ad1e46a79
Solidity
AssetBurnStrategy
contract AssetBurnStrategy is BaseStrategyInitializable { using SafeERC20 for ERC20; using Address for address; using SafeMath for uint256; VaultAPI public underlyingVault; address public asset; address public weth; address public uniswapRouterV2; address public uniswapFactory; address[] internal _path; uint256 constant MAX_BPS = 10000; uint256 public burningProfitRatio; uint256 public targetSupply; modifier onlyGovernanceOrManagement() { require( msg.sender == governance() || msg.sender == vault.management(), "!authorized" ); _; } constructor( address _vault, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) public BaseStrategyInitializable(_vault) { _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function init( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external { super._initialize(_vault, _onBehalfOf, _onBehalfOf, _onBehalfOf); _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function _init( address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) internal { require( address(want) == VaultAPI(_underlyingVault).token(), "Vault want is different from the underlying vault token" ); underlyingVault = VaultAPI(_underlyingVault); asset = _asset; weth = _weth; uniswapRouterV2 = _uniswapRouterV2; uniswapFactory = _uniswapFactory; if ( address(want) == weth || address(want) == 0x6B175474E89094C44Da98b954EedeAC495271d0F ) { _path = new address[](2); _path[0] = address(want); _path[1] = asset; } else { _path = new address[](3); _path[0] = address(want); _path[1] = weth; _path[2] = asset; } ERC20(address(want)).safeApprove(_uniswapRouterV2, type(uint256).max); // initial burning profit ratio 50% burningProfitRatio = 5000; // initial target supply equal to constructor initial supply targetSupply = ERC20(asset).totalSupply(); want.safeApprove(_underlyingVault, type(uint256).max); } // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); } function estimatedTotalAssets() public view override returns (uint256) { return _balanceOfWant().add(_balanceOnUnderlyingVault()); } function _balanceOfWant() internal view returns (uint256) { return ERC20(address(want)).balanceOf(address(this)); } function _balanceOnUnderlyingVault() internal view returns (uint256) { return underlyingVault .balanceOf(address(this)) .mul(underlyingVault.pricePerShare()) .div(10**underlyingVault.decimals()); } function ethToWant(uint256 _amount) internal view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = address(weth); path[1] = address(want); uint256[] memory amounts = IUniswapRouter(uniswapRouterV2).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 debt = vault.strategies(address(this)).totalDebt; uint256 currentValue = estimatedTotalAssets(); uint256 wantBalance = _balanceOfWant(); // Calculate total profit w/o farming if (debt < currentValue) { _profit = currentValue.sub(debt); } else { _loss = debt.sub(currentValue); } // To withdraw = profit from lending + _debtOutstanding uint256 toFree = _debtOutstanding.add(_profit); // In the case want is not enough, divest from idle if (toFree > wantBalance) { // Divest only the missing part = toFree-wantBalance toFree = toFree.sub(wantBalance); (uint256 _liquidatedAmount, ) = liquidatePosition(toFree); // loss in the case freedAmount less to be freed uint256 withdrawalLoss = _liquidatedAmount < toFree ? toFree.sub(_liquidatedAmount) : 0; // profit recalc if (withdrawalLoss < _profit) { _profit = _profit.sub(withdrawalLoss); } else { _loss = _loss.add(withdrawalLoss.sub(_profit)); _profit = 0; } } if (_profit > 0) { ERC20Burnable assetToken = ERC20Burnable(asset); uint256 currentTotalSupply = assetToken.totalSupply(); uint256 targetAssetToBurn = currentTotalSupply > targetSupply ? currentTotalSupply.sub(targetSupply) : 0; // supply <= targetSupply nothing to burn if (targetAssetToBurn > 0) { // Check we have sufficient liquidity IUniswapV2Factory factory = IUniswapV2Factory(uniswapFactory); address pair = factory.getPair( _path[_path.length - 2], _path[_path.length - 1] ); require(pair != address(0), "Pair must exist to swap"); // Buy at most to empty the pool uint256 pairAssetBalance = assetToken.balanceOf(pair); targetAssetToBurn = Math.min( pairAssetBalance > 0 ? pairAssetBalance.mul(50).div(100) : 0, targetAssetToBurn ); } if (targetAssetToBurn > 0) { uint256 profitToConvert = _profit.mul(burningProfitRatio).div(MAX_BPS); IUniswapRouter router = IUniswapRouter(uniswapRouterV2); uint256 expectedProfitToUse = (router.getAmountsIn(targetAssetToBurn, _path))[0]; // In the case profitToConvert > expected to use for burning target asset use the latter // On the contrary use profitToConvert uint256 exchangedAmount = ( router.swapExactTokensForTokens( Math.min(profitToConvert, expectedProfitToUse), 1, _path, address(this), now.add(1800) ) )[0]; // TOBE CHECKED leverage uniswap returns want amount _profit = _profit.sub(exchangedAmount); // burn assetToken.burn(assetToken.balanceOf(address(this))); } } // Recalculate profit wantBalance = want.balanceOf(address(this)); if (wantBalance < _profit) { _profit = wantBalance; _debtPayment = 0; } else if (wantBalance < _debtOutstanding.add(_profit)) { _debtPayment = wantBalance.sub(_profit); } else { _debtPayment = _debtOutstanding; } } function adjustPosition(uint256 _debtOutstanding) internal override { // TODO: Do something to invest excess `want` tokens (from the Vault) into your positions // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant > _debtOutstanding) { underlyingVault.deposit(balanceOfWant.sub(_debtOutstanding)); } } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { // TODO: Do stuff here to free up to `_amountNeeded` from all positions back into `want` uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant < _amountNeeded) { uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant); uint256 valueToRedeemApprox = amountToRedeem.mul(10**underlyingVault.decimals()).div( underlyingVault.pricePerShare() ); uint256 valueToRedeem = Math.min( valueToRedeemApprox, underlyingVault.balanceOf(address(this)) ); underlyingVault.withdraw(valueToRedeem); } // _liquidatedAmount min(_amountNeeded, balanceOfWant), otw vault accounting breaks balanceOfWant = _balanceOfWant(); if (balanceOfWant >= _amountNeeded) { _liquidatedAmount = _amountNeeded; } else { _liquidatedAmount = balanceOfWant; _loss = _amountNeeded.sub(balanceOfWant); } } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } function prepareMigration(address _newStrategy) internal override { // TODO: Transfer any non-`want` tokens to the new strategy // NOTE: `migrate` will automatically forward all `want` in this strategy to the new one underlyingVault.withdraw(); ERC20 assetToken = ERC20(asset); assetToken.safeTransfer( _newStrategy, assetToken.balanceOf(address(this)) ); } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; } function setBurningProfitRatio(uint256 _burningProfitRatio) external onlyGovernanceOrManagement { require( _burningProfitRatio <= MAX_BPS, "Burning profit ratio should be less than 10000" ); burningProfitRatio = _burningProfitRatio; } function setTargetSupply(uint256 _targetSuplly) external onlyGovernanceOrManagement { targetSupply = _targetSuplly; } function clone( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore( clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000 ) mstore(add(clone_code, 0x14), addressBytes) mstore( add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000 ) newStrategy := create(0, clone_code, 0x37) } AssetBurnStrategy(newStrategy).init( _vault, _onBehalfOf, _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); emit Cloned(newStrategy); } }
delegatedAssets
function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); }
/** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 4073, 4296 ] }
58,949
AssetBurnStrategy
AssetBurnStrategy.sol
0xf2eefca91a179c5eb38caa0ea2bcb79ad1e46a79
Solidity
AssetBurnStrategy
contract AssetBurnStrategy is BaseStrategyInitializable { using SafeERC20 for ERC20; using Address for address; using SafeMath for uint256; VaultAPI public underlyingVault; address public asset; address public weth; address public uniswapRouterV2; address public uniswapFactory; address[] internal _path; uint256 constant MAX_BPS = 10000; uint256 public burningProfitRatio; uint256 public targetSupply; modifier onlyGovernanceOrManagement() { require( msg.sender == governance() || msg.sender == vault.management(), "!authorized" ); _; } constructor( address _vault, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) public BaseStrategyInitializable(_vault) { _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function init( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external { super._initialize(_vault, _onBehalfOf, _onBehalfOf, _onBehalfOf); _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function _init( address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) internal { require( address(want) == VaultAPI(_underlyingVault).token(), "Vault want is different from the underlying vault token" ); underlyingVault = VaultAPI(_underlyingVault); asset = _asset; weth = _weth; uniswapRouterV2 = _uniswapRouterV2; uniswapFactory = _uniswapFactory; if ( address(want) == weth || address(want) == 0x6B175474E89094C44Da98b954EedeAC495271d0F ) { _path = new address[](2); _path[0] = address(want); _path[1] = asset; } else { _path = new address[](3); _path[0] = address(want); _path[1] = weth; _path[2] = asset; } ERC20(address(want)).safeApprove(_uniswapRouterV2, type(uint256).max); // initial burning profit ratio 50% burningProfitRatio = 5000; // initial target supply equal to constructor initial supply targetSupply = ERC20(asset).totalSupply(); want.safeApprove(_underlyingVault, type(uint256).max); } // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); } function estimatedTotalAssets() public view override returns (uint256) { return _balanceOfWant().add(_balanceOnUnderlyingVault()); } function _balanceOfWant() internal view returns (uint256) { return ERC20(address(want)).balanceOf(address(this)); } function _balanceOnUnderlyingVault() internal view returns (uint256) { return underlyingVault .balanceOf(address(this)) .mul(underlyingVault.pricePerShare()) .div(10**underlyingVault.decimals()); } function ethToWant(uint256 _amount) internal view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = address(weth); path[1] = address(want); uint256[] memory amounts = IUniswapRouter(uniswapRouterV2).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 debt = vault.strategies(address(this)).totalDebt; uint256 currentValue = estimatedTotalAssets(); uint256 wantBalance = _balanceOfWant(); // Calculate total profit w/o farming if (debt < currentValue) { _profit = currentValue.sub(debt); } else { _loss = debt.sub(currentValue); } // To withdraw = profit from lending + _debtOutstanding uint256 toFree = _debtOutstanding.add(_profit); // In the case want is not enough, divest from idle if (toFree > wantBalance) { // Divest only the missing part = toFree-wantBalance toFree = toFree.sub(wantBalance); (uint256 _liquidatedAmount, ) = liquidatePosition(toFree); // loss in the case freedAmount less to be freed uint256 withdrawalLoss = _liquidatedAmount < toFree ? toFree.sub(_liquidatedAmount) : 0; // profit recalc if (withdrawalLoss < _profit) { _profit = _profit.sub(withdrawalLoss); } else { _loss = _loss.add(withdrawalLoss.sub(_profit)); _profit = 0; } } if (_profit > 0) { ERC20Burnable assetToken = ERC20Burnable(asset); uint256 currentTotalSupply = assetToken.totalSupply(); uint256 targetAssetToBurn = currentTotalSupply > targetSupply ? currentTotalSupply.sub(targetSupply) : 0; // supply <= targetSupply nothing to burn if (targetAssetToBurn > 0) { // Check we have sufficient liquidity IUniswapV2Factory factory = IUniswapV2Factory(uniswapFactory); address pair = factory.getPair( _path[_path.length - 2], _path[_path.length - 1] ); require(pair != address(0), "Pair must exist to swap"); // Buy at most to empty the pool uint256 pairAssetBalance = assetToken.balanceOf(pair); targetAssetToBurn = Math.min( pairAssetBalance > 0 ? pairAssetBalance.mul(50).div(100) : 0, targetAssetToBurn ); } if (targetAssetToBurn > 0) { uint256 profitToConvert = _profit.mul(burningProfitRatio).div(MAX_BPS); IUniswapRouter router = IUniswapRouter(uniswapRouterV2); uint256 expectedProfitToUse = (router.getAmountsIn(targetAssetToBurn, _path))[0]; // In the case profitToConvert > expected to use for burning target asset use the latter // On the contrary use profitToConvert uint256 exchangedAmount = ( router.swapExactTokensForTokens( Math.min(profitToConvert, expectedProfitToUse), 1, _path, address(this), now.add(1800) ) )[0]; // TOBE CHECKED leverage uniswap returns want amount _profit = _profit.sub(exchangedAmount); // burn assetToken.burn(assetToken.balanceOf(address(this))); } } // Recalculate profit wantBalance = want.balanceOf(address(this)); if (wantBalance < _profit) { _profit = wantBalance; _debtPayment = 0; } else if (wantBalance < _debtOutstanding.add(_profit)) { _debtPayment = wantBalance.sub(_profit); } else { _debtPayment = _debtOutstanding; } } function adjustPosition(uint256 _debtOutstanding) internal override { // TODO: Do something to invest excess `want` tokens (from the Vault) into your positions // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant > _debtOutstanding) { underlyingVault.deposit(balanceOfWant.sub(_debtOutstanding)); } } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { // TODO: Do stuff here to free up to `_amountNeeded` from all positions back into `want` uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant < _amountNeeded) { uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant); uint256 valueToRedeemApprox = amountToRedeem.mul(10**underlyingVault.decimals()).div( underlyingVault.pricePerShare() ); uint256 valueToRedeem = Math.min( valueToRedeemApprox, underlyingVault.balanceOf(address(this)) ); underlyingVault.withdraw(valueToRedeem); } // _liquidatedAmount min(_amountNeeded, balanceOfWant), otw vault accounting breaks balanceOfWant = _balanceOfWant(); if (balanceOfWant >= _amountNeeded) { _liquidatedAmount = _amountNeeded; } else { _liquidatedAmount = balanceOfWant; _loss = _amountNeeded.sub(balanceOfWant); } } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } function prepareMigration(address _newStrategy) internal override { // TODO: Transfer any non-`want` tokens to the new strategy // NOTE: `migrate` will automatically forward all `want` in this strategy to the new one underlyingVault.withdraw(); ERC20 assetToken = ERC20(asset); assetToken.safeTransfer( _newStrategy, assetToken.balanceOf(address(this)) ); } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; } function setBurningProfitRatio(uint256 _burningProfitRatio) external onlyGovernanceOrManagement { require( _burningProfitRatio <= MAX_BPS, "Burning profit ratio should be less than 10000" ); burningProfitRatio = _burningProfitRatio; } function setTargetSupply(uint256 _targetSuplly) external onlyGovernanceOrManagement { targetSupply = _targetSuplly; } function clone( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore( clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000 ) mstore(add(clone_code, 0x14), addressBytes) mstore( add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000 ) newStrategy := create(0, clone_code, 0x37) } AssetBurnStrategy(newStrategy).init( _vault, _onBehalfOf, _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); emit Cloned(newStrategy); } }
harvestTrigger
function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); }
// NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 11547, 11730 ] }
58,950
AssetBurnStrategy
AssetBurnStrategy.sol
0xf2eefca91a179c5eb38caa0ea2bcb79ad1e46a79
Solidity
AssetBurnStrategy
contract AssetBurnStrategy is BaseStrategyInitializable { using SafeERC20 for ERC20; using Address for address; using SafeMath for uint256; VaultAPI public underlyingVault; address public asset; address public weth; address public uniswapRouterV2; address public uniswapFactory; address[] internal _path; uint256 constant MAX_BPS = 10000; uint256 public burningProfitRatio; uint256 public targetSupply; modifier onlyGovernanceOrManagement() { require( msg.sender == governance() || msg.sender == vault.management(), "!authorized" ); _; } constructor( address _vault, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) public BaseStrategyInitializable(_vault) { _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function init( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external { super._initialize(_vault, _onBehalfOf, _onBehalfOf, _onBehalfOf); _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function _init( address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) internal { require( address(want) == VaultAPI(_underlyingVault).token(), "Vault want is different from the underlying vault token" ); underlyingVault = VaultAPI(_underlyingVault); asset = _asset; weth = _weth; uniswapRouterV2 = _uniswapRouterV2; uniswapFactory = _uniswapFactory; if ( address(want) == weth || address(want) == 0x6B175474E89094C44Da98b954EedeAC495271d0F ) { _path = new address[](2); _path[0] = address(want); _path[1] = asset; } else { _path = new address[](3); _path[0] = address(want); _path[1] = weth; _path[2] = asset; } ERC20(address(want)).safeApprove(_uniswapRouterV2, type(uint256).max); // initial burning profit ratio 50% burningProfitRatio = 5000; // initial target supply equal to constructor initial supply targetSupply = ERC20(asset).totalSupply(); want.safeApprove(_underlyingVault, type(uint256).max); } // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); } function estimatedTotalAssets() public view override returns (uint256) { return _balanceOfWant().add(_balanceOnUnderlyingVault()); } function _balanceOfWant() internal view returns (uint256) { return ERC20(address(want)).balanceOf(address(this)); } function _balanceOnUnderlyingVault() internal view returns (uint256) { return underlyingVault .balanceOf(address(this)) .mul(underlyingVault.pricePerShare()) .div(10**underlyingVault.decimals()); } function ethToWant(uint256 _amount) internal view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = address(weth); path[1] = address(want); uint256[] memory amounts = IUniswapRouter(uniswapRouterV2).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 debt = vault.strategies(address(this)).totalDebt; uint256 currentValue = estimatedTotalAssets(); uint256 wantBalance = _balanceOfWant(); // Calculate total profit w/o farming if (debt < currentValue) { _profit = currentValue.sub(debt); } else { _loss = debt.sub(currentValue); } // To withdraw = profit from lending + _debtOutstanding uint256 toFree = _debtOutstanding.add(_profit); // In the case want is not enough, divest from idle if (toFree > wantBalance) { // Divest only the missing part = toFree-wantBalance toFree = toFree.sub(wantBalance); (uint256 _liquidatedAmount, ) = liquidatePosition(toFree); // loss in the case freedAmount less to be freed uint256 withdrawalLoss = _liquidatedAmount < toFree ? toFree.sub(_liquidatedAmount) : 0; // profit recalc if (withdrawalLoss < _profit) { _profit = _profit.sub(withdrawalLoss); } else { _loss = _loss.add(withdrawalLoss.sub(_profit)); _profit = 0; } } if (_profit > 0) { ERC20Burnable assetToken = ERC20Burnable(asset); uint256 currentTotalSupply = assetToken.totalSupply(); uint256 targetAssetToBurn = currentTotalSupply > targetSupply ? currentTotalSupply.sub(targetSupply) : 0; // supply <= targetSupply nothing to burn if (targetAssetToBurn > 0) { // Check we have sufficient liquidity IUniswapV2Factory factory = IUniswapV2Factory(uniswapFactory); address pair = factory.getPair( _path[_path.length - 2], _path[_path.length - 1] ); require(pair != address(0), "Pair must exist to swap"); // Buy at most to empty the pool uint256 pairAssetBalance = assetToken.balanceOf(pair); targetAssetToBurn = Math.min( pairAssetBalance > 0 ? pairAssetBalance.mul(50).div(100) : 0, targetAssetToBurn ); } if (targetAssetToBurn > 0) { uint256 profitToConvert = _profit.mul(burningProfitRatio).div(MAX_BPS); IUniswapRouter router = IUniswapRouter(uniswapRouterV2); uint256 expectedProfitToUse = (router.getAmountsIn(targetAssetToBurn, _path))[0]; // In the case profitToConvert > expected to use for burning target asset use the latter // On the contrary use profitToConvert uint256 exchangedAmount = ( router.swapExactTokensForTokens( Math.min(profitToConvert, expectedProfitToUse), 1, _path, address(this), now.add(1800) ) )[0]; // TOBE CHECKED leverage uniswap returns want amount _profit = _profit.sub(exchangedAmount); // burn assetToken.burn(assetToken.balanceOf(address(this))); } } // Recalculate profit wantBalance = want.balanceOf(address(this)); if (wantBalance < _profit) { _profit = wantBalance; _debtPayment = 0; } else if (wantBalance < _debtOutstanding.add(_profit)) { _debtPayment = wantBalance.sub(_profit); } else { _debtPayment = _debtOutstanding; } } function adjustPosition(uint256 _debtOutstanding) internal override { // TODO: Do something to invest excess `want` tokens (from the Vault) into your positions // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant > _debtOutstanding) { underlyingVault.deposit(balanceOfWant.sub(_debtOutstanding)); } } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { // TODO: Do stuff here to free up to `_amountNeeded` from all positions back into `want` uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant < _amountNeeded) { uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant); uint256 valueToRedeemApprox = amountToRedeem.mul(10**underlyingVault.decimals()).div( underlyingVault.pricePerShare() ); uint256 valueToRedeem = Math.min( valueToRedeemApprox, underlyingVault.balanceOf(address(this)) ); underlyingVault.withdraw(valueToRedeem); } // _liquidatedAmount min(_amountNeeded, balanceOfWant), otw vault accounting breaks balanceOfWant = _balanceOfWant(); if (balanceOfWant >= _amountNeeded) { _liquidatedAmount = _amountNeeded; } else { _liquidatedAmount = balanceOfWant; _loss = _amountNeeded.sub(balanceOfWant); } } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } function prepareMigration(address _newStrategy) internal override { // TODO: Transfer any non-`want` tokens to the new strategy // NOTE: `migrate` will automatically forward all `want` in this strategy to the new one underlyingVault.withdraw(); ERC20 assetToken = ERC20(asset); assetToken.safeTransfer( _newStrategy, assetToken.balanceOf(address(this)) ); } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; } function setBurningProfitRatio(uint256 _burningProfitRatio) external onlyGovernanceOrManagement { require( _burningProfitRatio <= MAX_BPS, "Burning profit ratio should be less than 10000" ); burningProfitRatio = _burningProfitRatio; } function setTargetSupply(uint256 _targetSuplly) external onlyGovernanceOrManagement { targetSupply = _targetSuplly; } function clone( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore( clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000 ) mstore(add(clone_code, 0x14), addressBytes) mstore( add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000 ) newStrategy := create(0, clone_code, 0x37) } AssetBurnStrategy(newStrategy).init( _vault, _onBehalfOf, _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); emit Cloned(newStrategy); } }
protectedTokens
function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; }
// Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // }
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 12736, 12973 ] }
58,951
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
toString
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 184, 912 ] }
58,952
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
toHexString
function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 1017, 1362 ] }
58,953
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
toHexString
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 1485, 1941 ] }
58,954
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
isContract
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; }
/** * @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 * ==== */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 606, 998 ] }
58,955
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
sendValue
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); }
/** * @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]. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 1928, 2250 ] }
58,956
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @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._ */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 3007, 3187 ] }
58,957
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCall
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 with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 3412, 3646 ] }
58,958
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCallWithValue
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-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._ */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 4016, 4281 ] }
58,959
FishTankNFT
@openzeppelin/contracts/utils/Strings.sol
0x31b94da59767a9bc1c2bed8236ccb6f15b794d8b
Solidity
Address
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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"); (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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCallWithValue
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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); }
/** * @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._ */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
None
ipfs://236d001cf64d6155763c65a9c7f57925bcfd40f6b997f2c347b1bed579227211
{ "func_code_index": [ 4532, 5047 ] }
58,960