ERC-20
Overview
Max Total Supply
3,239,508.669924768710946996 esAGI
Holders
566
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
ESAGIToken
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./interfaces/tokens/IAGIToken.sol"; import "./interfaces/tokens/IESAGIToken.sol"; import "./interfaces/IESAGITokenUsage.sol"; /* * ESAGI is AGILITY's escrowed governance token obtainable by converting AGI to it * It's non-transferable, except from/to whitelisted addresses * It can be converted back to AGI through a vesting process * This contract is made to receive esAGI deposits from users in order to allocate them to Usages (plugins) contracts */ contract ESAGIToken is Ownable, ReentrancyGuard, ERC20("AGILITY escrowed token", "esAGI"), IESAGIToken { using Address for address; using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; using SafeERC20 for IAGIToken; struct ESAGIBalance { uint256 allocatedAmount; // Amount of ESAGI allocated to a Usage uint256 redeemingAmount; // Total amount of ESAGI currently being redeemed } struct RedeemInfo { uint256 agiAmount; // AGI amount to receive when vesting has ended uint256 ESAGIAmount; // ESAGI amount to redeem uint256 endTime; IESAGITokenUsage dividendsAddress; uint256 dividendsAllocation; // Share of redeeming ESAGI to allocate to the Dividends Usage contract } IAGIToken public immutable agiToken; // AGI token to convert to/from IESAGITokenUsage public dividendsAddress; // AGILITY dividends contract EnumerableSet.AddressSet private _transferWhitelist; // addresses allowed to send/receive ESAGI mapping(address => mapping(address => uint256)) public usageApprovals; // Usage approvals to allocate ESAGI mapping(address => mapping(address => uint256)) public override usageAllocations; // Active ESAGI allocations to usages uint256 public constant MAX_DEALLOCATION_FEE = 200; // 2% mapping(address => uint256) public usagesDeallocationFee; // Fee paid when deallocating ESAGI uint256 public constant MAX_FIXED_RATIO = 100; // 100% // Redeeming min/max settings uint256 public minRedeemRatio = 50; // 1:0.5 uint256 public maxRedeemRatio = 100; // 1:1 uint256 public minRedeemDuration = 3 days; // 1296000s uint256 public maxRedeemDuration = 14 days; // 7776000s // Adjusted dividends rewards for redeeming ESAGI uint256 public redeemDividendsAdjustment = 0; // 50% mapping(address => ESAGIBalance) public ESAGIBalances; // User's ESAGI balances mapping(address => RedeemInfo[]) public userRedeems; // User's redeeming instances constructor(IAGIToken agiToken_) { agiToken = agiToken_; _transferWhitelist.add(address(this)); } /********************************************/ /****************** EVENTS ******************/ /********************************************/ event ApproveUsage(address indexed userAddress, address indexed usageAddress, uint256 amount); event Convert(address indexed from, address to, uint256 amount); event UpdateRedeemSettings(uint256 minRedeemRatio, uint256 maxRedeemRatio, uint256 minRedeemDuration, uint256 maxRedeemDuration, uint256 redeemDividendsAdjustment); event UpdateDividendsAddress(address previousDividendsAddress, address newDividendsAddress); event UpdateDeallocationFee(address indexed usageAddress, uint256 fee); event SetTransferWhitelist(address account, bool add); event Redeem(address indexed userAddress, uint256 ESAGIAmount, uint256 agiAmount, uint256 duration); event FinalizeRedeem(address indexed userAddress, uint256 ESAGIAmount, uint256 agiAmount); event CancelRedeem(address indexed userAddress, uint256 ESAGIAmount); event UpdateRedeemDividendsAddress(address indexed userAddress, uint256 redeemIndex, address previousDividendsAddress, address newDividendsAddress); event Allocate(address indexed userAddress, address indexed usageAddress, uint256 amount); event Deallocate(address indexed userAddress, address indexed usageAddress, uint256 amount, uint256 fee); /***********************************************/ /****************** MODIFIERS ******************/ /***********************************************/ /* * @dev Check if a redeem entry exists */ modifier validateRedeem(address userAddress, uint256 redeemIndex) { require(redeemIndex < userRedeems[userAddress].length, "validateRedeem: redeem entry does not exist"); _; } /**************************************************/ /****************** PUBLIC VIEWS ******************/ /**************************************************/ /* * @dev Returns user's ESAGI balances */ function getESAGIBalance(address userAddress) external view returns (uint256 allocatedAmount, uint256 redeemingAmount) { ESAGIBalance storage balance = ESAGIBalances[userAddress]; return (balance.allocatedAmount, balance.redeemingAmount); } /* * @dev returns redeemable agi for "amount" of ESAGI vested for "duration" seconds */ function getagiByVestingDuration(uint256 amount, uint256 duration) public view returns (uint256) { if(duration < minRedeemDuration) { return 0; } // capped to maxRedeemDuration if (duration > maxRedeemDuration) { return amount.mul(maxRedeemRatio).div(100); } uint256 ratio = minRedeemRatio.add( (duration.sub(minRedeemDuration)).mul(maxRedeemRatio.sub(minRedeemRatio)) .div(maxRedeemDuration.sub(minRedeemDuration)) ); return amount.mul(ratio).div(100); } /** * @dev returns quantity of "userAddress" pending redeems */ function getUserRedeemsLength(address userAddress) external view returns (uint256) { return userRedeems[userAddress].length; } /** * @dev returns "userAddress" info for a pending redeem identified by "redeemIndex" */ function getUserRedeem(address userAddress, uint256 redeemIndex) external view validateRedeem(userAddress, redeemIndex) returns (uint256 agiAmount, uint256 ESAGIAmount, uint256 endTime, address dividendsContract, uint256 dividendsAllocation) { RedeemInfo storage _redeem = userRedeems[userAddress][redeemIndex]; return (_redeem.agiAmount, _redeem.ESAGIAmount, _redeem.endTime, address(_redeem.dividendsAddress), _redeem.dividendsAllocation); } /** * @dev returns approved ESAGI to allocate from "userAddress" to "usageAddress" */ function getUsageApproval(address userAddress, address usageAddress) external view returns (uint256) { return usageApprovals[userAddress][usageAddress]; } /** * @dev returns allocated ESAGI from "userAddress" to "usageAddress" */ function getUsageAllocation(address userAddress, address usageAddress) external view returns (uint256) { return usageAllocations[userAddress][usageAddress]; } /** * @dev returns length of transferWhitelist array */ function transferWhitelistLength() external view returns (uint256) { return _transferWhitelist.length(); } /** * @dev returns transferWhitelist array item's address for "index" */ function transferWhitelist(uint256 index) external view returns (address) { return _transferWhitelist.at(index); } /** * @dev returns if "account" is allowed to send/receive ESAGI */ function isTransferWhitelisted(address account) external override view returns (bool) { return _transferWhitelist.contains(account); } /*******************************************************/ /****************** OWNABLE FUNCTIONS ******************/ /*******************************************************/ /** * @dev Updates all redeem ratios and durations * * Must only be called by owner */ function updateRedeemSettings(uint256 minRedeemRatio_, uint256 maxRedeemRatio_, uint256 minRedeemDuration_, uint256 maxRedeemDuration_, uint256 redeemDividendsAdjustment_) external onlyOwner { require(minRedeemRatio_ <= maxRedeemRatio_, "updateRedeemSettings: wrong ratio values"); require(minRedeemDuration_ < maxRedeemDuration_, "updateRedeemSettings: wrong duration values"); // should never exceed 100% require(maxRedeemRatio_ <= MAX_FIXED_RATIO && redeemDividendsAdjustment_ <= MAX_FIXED_RATIO, "updateRedeemSettings: wrong ratio values"); minRedeemRatio = minRedeemRatio_; maxRedeemRatio = maxRedeemRatio_; minRedeemDuration = minRedeemDuration_; maxRedeemDuration = maxRedeemDuration_; redeemDividendsAdjustment = redeemDividendsAdjustment_; emit UpdateRedeemSettings(minRedeemRatio_, maxRedeemRatio_, minRedeemDuration_, maxRedeemDuration_, redeemDividendsAdjustment_); } /** * @dev Updates dividends contract address * * Must only be called by owner */ function updateDividendsAddress(IESAGITokenUsage dividendsAddress_) external onlyOwner { // if set to 0, also set divs earnings while redeeming to 0 if(address(dividendsAddress_) == address(0)) { redeemDividendsAdjustment = 0; } emit UpdateDividendsAddress(address(dividendsAddress), address(dividendsAddress_)); dividendsAddress = dividendsAddress_; } /** * @dev Updates fee paid by users when deallocating from "usageAddress" */ function updateDeallocationFee(address usageAddress, uint256 fee) external onlyOwner { require(fee <= MAX_DEALLOCATION_FEE, "updateDeallocationFee: too high"); usagesDeallocationFee[usageAddress] = fee; emit UpdateDeallocationFee(usageAddress, fee); } /** * @dev Adds or removes addresses from the transferWhitelist */ function updateTransferWhitelist(address account, bool add) external onlyOwner { require(account != address(this), "updateTransferWhitelist: Cannot remove ESAGI from whitelist"); if(add) _transferWhitelist.add(account); else _transferWhitelist.remove(account); emit SetTransferWhitelist(account, add); } /*****************************************************************/ /****************** EXTERNAL PUBLIC FUNCTIONS ******************/ /*****************************************************************/ /** * @dev Approves "usage" address to get allocations up to "amount" of ESAGI from msg.sender */ function approveUsage(IESAGITokenUsage usage, uint256 amount) external nonReentrant { require(address(usage) != address(0), "approveUsage: approve to the zero address"); usageApprovals[msg.sender][address(usage)] = amount; emit ApproveUsage(msg.sender, address(usage), amount); } /** * @dev Convert caller's "amount" of agi to ESAGI */ function convert(uint256 amount) external nonReentrant { _convert(amount, msg.sender); } /** * @dev Convert caller's "amount" of agi to ESAGI to "to" address */ function convertTo(uint256 amount, address to) external override nonReentrant { require(address(msg.sender).isContract(), "convertTo: not allowed"); _convert(amount, to); } /** * @dev Initiates redeem process (ESAGI to agi) * * Handles dividends' compensation allocation during the vesting process if needed */ function redeem(uint256 ESAGIAmount, uint256 duration) external nonReentrant { require(ESAGIAmount > 0, "redeem: ESAGIAmount cannot be null"); require(duration >= minRedeemDuration, "redeem: duration too low"); _transfer(msg.sender, address(this), ESAGIAmount); ESAGIBalance storage balance = ESAGIBalances[msg.sender]; // get corresponding agi amount uint256 agiAmount = getagiByVestingDuration(ESAGIAmount, duration); emit Redeem(msg.sender, ESAGIAmount, agiAmount, duration); // if redeeming is not immediate, go through vesting process if(duration > 0) { // add to SBT total balance.redeemingAmount = balance.redeemingAmount.add(ESAGIAmount); // handle dividends during the vesting process uint256 dividendsAllocation = ESAGIAmount.mul(redeemDividendsAdjustment).div(100); // only if compensation is active if(dividendsAllocation > 0) { // allocate to dividends dividendsAddress.allocate(msg.sender, dividendsAllocation, new bytes(0)); } // add redeeming entry userRedeems[msg.sender].push(RedeemInfo(agiAmount, ESAGIAmount, _currentBlockTimestamp().add(duration), dividendsAddress, dividendsAllocation)); } else { // immediately redeem for agi _finalizeRedeem(msg.sender, ESAGIAmount, agiAmount); } } /** * @dev Finalizes redeem process when vesting duration has been reached * * Can only be called by the redeem entry owner */ function finalizeRedeem(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) { ESAGIBalance storage balance = ESAGIBalances[msg.sender]; RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex]; require(_currentBlockTimestamp() >= _redeem.endTime, "finalizeRedeem: vesting duration has not ended yet"); // remove from SBT total balance.redeemingAmount = balance.redeemingAmount.sub(_redeem.ESAGIAmount); _finalizeRedeem(msg.sender, _redeem.ESAGIAmount, _redeem.agiAmount); // handle dividends compensation if any was active if(_redeem.dividendsAllocation > 0) { // deallocate from dividends IESAGITokenUsage(_redeem.dividendsAddress).deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0)); } // remove redeem entry _deleteRedeemEntry(redeemIndex); } /** * @dev Updates dividends address for an existing active redeeming process * * Can only be called by the involved user * Should only be used if dividends contract was to be migrated */ function updateRedeemDividendsAddress(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) { RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex]; // only if the active dividends contract is not the same anymore if(dividendsAddress != _redeem.dividendsAddress && address(dividendsAddress) != address(0)) { if(_redeem.dividendsAllocation > 0) { // deallocate from old dividends contract _redeem.dividendsAddress.deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0)); // allocate to new used dividends contract dividendsAddress.allocate(msg.sender, _redeem.dividendsAllocation, new bytes(0)); } emit UpdateRedeemDividendsAddress(msg.sender, redeemIndex, address(_redeem.dividendsAddress), address(dividendsAddress)); _redeem.dividendsAddress = dividendsAddress; } } /** * @dev Cancels an ongoing redeem entry * * Can only be called by its owner */ function cancelRedeem(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) { ESAGIBalance storage balance = ESAGIBalances[msg.sender]; RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex]; // make redeeming ESAGI available again balance.redeemingAmount = balance.redeemingAmount.sub(_redeem.ESAGIAmount); _transfer(address(this), msg.sender, _redeem.ESAGIAmount); // handle dividends compensation if any was active if(_redeem.dividendsAllocation > 0) { // deallocate from dividends IESAGITokenUsage(_redeem.dividendsAddress).deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0)); } emit CancelRedeem(msg.sender, _redeem.ESAGIAmount); // remove redeem entry _deleteRedeemEntry(redeemIndex); } /** * @dev Allocates caller's "amount" of available ESAGI to "usageAddress" contract * * args specific to usage contract must be passed into "usageData" */ function allocate(address usageAddress, uint256 amount, bytes calldata usageData) external nonReentrant { _allocate(msg.sender, usageAddress, amount); // allocates ESAGI to usageContract IESAGITokenUsage(usageAddress).allocate(msg.sender, amount, usageData); } /** * @dev Allocates "amount" of available ESAGI from "userAddress" to caller (ie usage contract) * * Caller must have an allocation approval for the required ESAGI ESAGI from "userAddress" */ function allocateFromUsage(address userAddress, uint256 amount) external override nonReentrant { _allocate(userAddress, msg.sender, amount); } /** * @dev Deallocates caller's "amount" of available ESAGI from "usageAddress" contract * * args specific to usage contract must be passed into "usageData" */ function deallocate(address usageAddress, uint256 amount, bytes calldata usageData) external nonReentrant { _deallocate(msg.sender, usageAddress, amount); // deallocate ESAGI into usageContract IESAGITokenUsage(usageAddress).deallocate(msg.sender, amount, usageData); } /** * @dev Deallocates "amount" of allocated ESAGI belonging to "userAddress" from caller (ie usage contract) * * Caller can only deallocate ESAGI from itself */ function deallocateFromUsage(address userAddress, uint256 amount) external override nonReentrant { _deallocate(userAddress, msg.sender, amount); } /********************************************************/ /****************** INTERNAL FUNCTIONS ******************/ /********************************************************/ /** * @dev Convert caller's "amount" of agi into ESAGI to "to" */ function _convert(uint256 amount, address to) internal { require(amount != 0, "convert: amount cannot be null"); // mint new ESAGI _mint(to, amount); emit Convert(msg.sender, to, amount); agiToken.safeTransferFrom(msg.sender, address(this), amount); } /** * @dev Finalizes the redeeming process for "userAddress" by transferring him "AGIAmount" and removing "ESAGIAmount" from supply * * Any vesting check should be ran before calling this * agi excess is automatically burnt */ function _finalizeRedeem(address userAddress, uint256 ESAGIAmount, uint256 AGIAmount) internal { uint256 agiExcess = ESAGIAmount.sub(AGIAmount); // sends due agi tokens agiToken.safeTransfer(userAddress, AGIAmount); // burns agi excess if any agiToken.burn(agiExcess); _burn(address(this), ESAGIAmount); emit FinalizeRedeem(userAddress, ESAGIAmount, AGIAmount); } /** * @dev Allocates "userAddress" user's "amount" of available ESAGI to "usageAddress" contract * */ function _allocate(address userAddress, address usageAddress, uint256 amount) internal { require(amount > 0, "allocate: amount cannot be null"); ESAGIBalance storage balance = ESAGIBalances[userAddress]; // approval checks if allocation request amount has been approved by userAddress to be allocated to this usageAddress uint256 approvedESAGI = usageApprovals[userAddress][usageAddress]; require(approvedESAGI >= amount, "allocate: non authorized amount"); // remove allocated amount from usage's approved amount usageApprovals[userAddress][usageAddress] = approvedESAGI.sub(amount); // update usage's allocatedAmount for userAddress usageAllocations[userAddress][usageAddress] = usageAllocations[userAddress][usageAddress].add(amount); // adjust user's ESAGI balances balance.allocatedAmount = balance.allocatedAmount.add(amount); _transfer(userAddress, address(this), amount); emit Allocate(userAddress, usageAddress, amount); } /** * @dev Deallocates "amount" of available ESAGI to "usageAddress" contract * * args specific to usage contract must be passed into "usageData" */ function _deallocate(address userAddress, address usageAddress, uint256 amount) internal { require(amount > 0, "deallocate: amount cannot be null"); // check if there is enough allocated ESAGI to this usage to deallocate uint256 allocatedAmount = usageAllocations[userAddress][usageAddress]; require(allocatedAmount >= amount, "deallocate: non authorized amount"); // remove deallocated amount from usage's allocation usageAllocations[userAddress][usageAddress] = allocatedAmount.sub(amount); uint256 deallocationFeeAmount = amount.mul(usagesDeallocationFee[usageAddress]).div(10000); // adjust user's ESAGI balances ESAGIBalance storage balance = ESAGIBalances[userAddress]; balance.allocatedAmount = balance.allocatedAmount.sub(amount); _transfer(address(this), userAddress, amount.sub(deallocationFeeAmount)); // burn corresponding agi and ESAGI agiToken.burn(deallocationFeeAmount); _burn(address(this), deallocationFeeAmount); emit Deallocate(userAddress, usageAddress, amount, deallocationFeeAmount); } function _deleteRedeemEntry(uint256 index) internal { userRedeems[msg.sender][index] = userRedeems[msg.sender][userRedeems[msg.sender].length - 1]; userRedeems[msg.sender].pop(); } /** * @dev Hook override to forbid transfers except from whitelisted addresses and minting */ function _beforeTokenTransfer(address from, address to, uint256 /*amount*/) internal view override { require(from == address(0) || _transferWhitelist.contains(from) || _transferWhitelist.contains(to), "transfer: not allowed"); } /** * @dev Utility function to get the current block timestamp */ function _currentBlockTimestamp() internal view virtual returns (uint256) { /* solhint-disable not-rely-on-time */ return block.timestamp; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev 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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 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 functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @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 a - b; } /** * @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) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; interface IESAGITokenUsage { function allocate(address userAddress, uint256 amount, bytes calldata data) external; function deallocate(address userAddress, uint256 amount, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IAGIToken is IERC20{ function lastEmissionTime() external view returns (uint256); function claimMasterRewards(uint256 amount) external returns (uint256 effectiveAmount); function masterEmissionRate() external view returns (uint256); function burn(uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IESAGIToken is IERC20 { function usageAllocations(address userAddress, address usageAddress) external view returns (uint256 allocation); function allocateFromUsage(address userAddress, uint256 amount) external; function convertTo(uint256 amount, address to) external; function deallocateFromUsage(address userAddress, uint256 amount) external; function isTransferWhitelisted(address account) external view returns (bool); }
{ "metadata": { "bytecodeHash": "ipfs" }, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IAGIToken","name":"agiToken_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Allocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ApproveUsage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"ESAGIAmount","type":"uint256"}],"name":"CancelRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Convert","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Deallocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"ESAGIAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"agiAmount","type":"uint256"}],"name":"FinalizeRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"ESAGIAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"agiAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"add","type":"bool"}],"name":"SetTransferWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"UpdateDeallocationFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateRedeemDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemDividendsAdjustment","type":"uint256"}],"name":"UpdateRedeemSettings","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ESAGIBalances","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DEALLOCATION_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FIXED_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"agiToken","outputs":[{"internalType":"contract IAGIToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"allocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"allocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IESAGITokenUsage","name":"usage","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"cancelRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"convert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"convertTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"deallocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deallocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dividendsAddress","outputs":[{"internalType":"contract IESAGITokenUsage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"finalizeRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getESAGIBalance","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageApproval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"getUserRedeem","outputs":[{"internalType":"uint256","name":"agiAmount","type":"uint256"},{"internalType":"uint256","name":"ESAGIAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"address","name":"dividendsContract","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserRedeemsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"getagiByVestingDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isTransferWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ESAGIAmount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemDividendsAdjustment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"transferWhitelist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferWhitelistLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"updateDeallocationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IESAGITokenUsage","name":"dividendsAddress_","type":"address"}],"name":"updateDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"updateRedeemDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"minRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"redeemDividendsAdjustment_","type":"uint256"}],"name":"updateRedeemSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTransferWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageAllocations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageApprovals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"usagesDeallocationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userRedeems","outputs":[{"internalType":"uint256","name":"agiAmount","type":"uint256"},{"internalType":"uint256","name":"ESAGIAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"contract IESAGITokenUsage","name":"dividendsAddress","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040526032600d556064600e556203f480600f556212750060105560006011553480156200002e57600080fd5b5060405162003498380380620034988339810160408190526200005191620001cb565b6040518060400160405280601681526020017f4147494c49545920657363726f77656420746f6b656e0000000000000000000081525060405180604001604052806005815260200164657341474960d81b815250620000bf620000b96200010560201b60201c565b62000109565b600180556005620000d18382620002a2565b506006620000e08282620002a2565b5050506001600160a01b038116608052620000fd60083062000159565b50506200036e565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600062000170836001600160a01b03841662000179565b90505b92915050565b6000818152600183016020526040812054620001c25750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000173565b50600062000173565b600060208284031215620001de57600080fd5b81516001600160a01b0381168114620001f657600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200022857607f821691505b6020821081036200024957634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200029d57600081815260208120601f850160051c81016020861015620002785750805b601f850160051c820191505b81811015620002995782815560010162000284565b5050505b505050565b81516001600160401b03811115620002be57620002be620001fd565b620002d681620002cf845462000213565b846200024f565b602080601f8311600181146200030e5760008415620002f55750858301515b600019600386901b1c1916600185901b17855562000299565b600085815260208120601f198616915b828110156200033f578886015182559484019460019091019084016200031e565b50858210156200035e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080516130f2620003a6600039600081816105d201528181612236015281816123ad0152818161246401526124a101526130f26000f3fe608060405234801561001057600080fd5b506004361061030c5760003560e01c80635a1d34dc1161019d578063a9059cbb116100e9578063d3b48655116100a2578063e9ed87f81161007c578063e9ed87f81461079d578063ee1cb30f146107a6578063f2fde38b146107cd578063f4bdd978146107e057600080fd5b8063d3b486551461073b578063dd62ed3e14610781578063e3a2950b1461079457600080fd5b8063a9059cbb146106bd578063aff6cbf1146106d0578063b90c2b52146106e3578063c360ed1c1461070c578063c4b107661461071f578063cc6c54231461072857600080fd5b8063890836541161015657806395d89b411161013057806395d89b411461067c578063a0bdc7cb14610684578063a3908e1b14610697578063a457c2d7146106aa57600080fd5b806389083654146106385780638975f9181461064b5780638da5cb5b1461066b57600080fd5b80635a1d34dc146105b2578063619ac95b146105c5578063658bb543146105cd57806370a08231146105f4578063715018a61461061d5780637cbc23731461062557600080fd5b80632cc2f5ce1161025c578063488c8303116102155780634b359d38116101ef5780634b359d38146105355780634f62b7ec14610548578063539ffb771461058c578063549230c91461059f57600080fd5b8063488c8303146104d6578063497965ee146105015780634a5b406e1461052c57600080fd5b80632cc2f5ce1461042a5780632e9a76e41461045557806331124ce31461048e578063313ce567146104a157806339509351146104b05780633b90f9a0146104c357600080fd5b8063161aab43116102c95780631c75e369116102a35780631c75e369146103b85780631eee7e60146103cb57806323b872dd146103de5780632b489679146103f157600080fd5b8063161aab431461039f57806318160ddd146103a75780631c352679146103af57600080fd5b806302f91e551461031157806306045a211461032c57806306fdde0314610341578063093220b714610356578063095ea7b3146103695780630f7d3a691461038c575b600080fd5b61031960c881565b6040519081526020015b60405180910390f35b61033f61033a366004612c17565b6107f3565b005b610349610878565b6040516103239190612c84565b61033f610364366004612c97565b61090a565b61037c610377366004612cd2565b610a3b565b6040519015158152602001610323565b61033f61039a366004612cd2565b610a55565b610319610b07565b600454610319565b610319600d5481565b61033f6103c6366004612cfe565b610b18565b61037c6103d9366004612c17565b610b9e565b61037c6103ec366004612d87565b610bab565b6103196103ff366004612dc8565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b610319610438366004612dc8565b600b60209081526000928352604080842090915290825290205481565b610319610463366004612dc8565b6001600160a01b039182166000908152600b6020908152604080832093909416825291909152205490565b61033f61049c366004612e01565b610bcf565b60405160128152602001610323565b61037c6104be366004612cd2565b610df2565b61033f6104d1366004612cd2565b610e14565b6103196104e4366004612dc8565b600a60209081526000928352604080842090915290825290205481565b600754610514906001600160a01b031681565b6040516001600160a01b039091168152602001610323565b61031960115481565b610514610543366004612e01565b610e34565b61055b610556366004612cd2565b610e41565b604080519586526020860194909452928401919091526001600160a01b03166060830152608082015260a001610323565b61033f61059a366004612e01565b610e98565b61033f6105ad366004612cfe565b611014565b61033f6105c0366004612e1a565b611059565b610319606481565b6105147f000000000000000000000000000000000000000000000000000000000000000081565b610319610602366004612c17565b6001600160a01b031660009081526002602052604090205490565b61033f6110b2565b61033f610633366004612e3f565b6110c6565b61033f610646366004612e6f565b61135f565b610319610659366004612c17565b600c6020526000908152604090205481565b6000546001600160a01b0316610514565b610349611450565b61033f610692366004612cd2565b61145f565b61033f6106a5366004612e01565b611472565b61037c6106b8366004612cd2565b61148d565b61037c6106cb366004612cd2565b611508565b61033f6106de366004612e01565b611516565b6103196106f1366004612c17565b6001600160a01b031660009081526013602052604090205490565b61033f61071a366004612cd2565b6116bc565b610319600f5481565b61055b610736366004612cd2565b611790565b61076c610749366004612c17565b6001600160a01b0316600090815260126020526040902080546001909101549091565b60408051928352602083019190915201610323565b61031961078f366004612dc8565b611843565b610319600e5481565b61031960105481565b61076c6107b4366004612c17565b6012602052600090815260409020805460019091015482565b61033f6107db366004612c17565b61186e565b6103196107ee366004612e3f565b6118e4565b6107fb611992565b6001600160a01b03811661080f5760006011555b600754604080516001600160a01b03928316815291831660208301527f044c75b8fa43ce72364b4c23fdb8451beafbda46505bf44c76f0853a01ed4ade910160405180910390a1600780546001600160a01b0319166001600160a01b0392909216919091179055565b60606005805461088790612e9d565b80601f01602080910402602001604051908101604052809291908181526020018280546108b390612e9d565b80156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b5050505050905090565b610912611992565b8385111561093b5760405162461bcd60e51b815260040161093290612ed7565b60405180910390fd5b81831061099e5760405162461bcd60e51b815260206004820152602b60248201527f75706461746552656465656d53657474696e67733a2077726f6e67206475726160448201526a74696f6e2076616c75657360a81b6064820152608401610932565b606484111580156109b0575060648111155b6109cc5760405162461bcd60e51b815260040161093290612ed7565b600d859055600e849055600f83905560108290556011819055604080518681526020810186905290810184905260608101839052608081018290527f5b37d10782e41a6539b50d59366d4112a880236e4187e85b6d1514d20e07d9b89060a00160405180910390a15050505050565b600033610a498185856119ec565b60019150505b92915050565b610a5d611992565b60c8811115610aae5760405162461bcd60e51b815260206004820152601f60248201527f7570646174654465616c6c6f636174696f6e4665653a20746f6f2068696768006044820152606401610932565b6001600160a01b0382166000818152600c602052604090819020839055517f6ff024152fc2cd8071bc701f966036513eb03e243863f21d8218646faac0eaef90610afb9084815260200190565b60405180910390a25050565b6000610b136008611b10565b905090565b610b20611b1a565b610b2b338585611b73565b604051631c75e36960e01b81526001600160a01b03851690631c75e36990610b5d903390879087908790600401612f1f565b600060405180830381600087803b158015610b7757600080fd5b505af1158015610b8b573d6000803e3d6000fd5b50505050610b9860018055565b50505050565b6000610a4f600883611d27565b600033610bb9858285611d4c565b610bc4858585611dc0565b506001949350505050565b610bd7611b1a565b3360008181526013602052604090205482908110610c075760405162461bcd60e51b815260040161093290612f67565b336000908152601360205260408120805485908110610c2857610c28612fb2565b6000918252602090912060059091020160038101546007549192506001600160a01b03908116911614801590610c6857506007546001600160a01b031615155b15610de357600481015415610d6857600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c991610cbe9133919060248101612fc8565b600060405180830381600087803b158015610cd857600080fd5b505af1158015610cec573d6000803e3d6000fd5b5050600754600484015460408051600081526020810191829052631c75e36960e01b9091526001600160a01b039092169350631c75e3699250610d359133919060248101612fc8565b600060405180830381600087803b158015610d4f57600080fd5b505af1158015610d63573d6000803e3d6000fd5b505050505b6003810154600754604080518781526001600160a01b039384166020820152929091169082015233907fa60c8f9118be22c9277a8129333d64ffda3de44ca7a5831d077a3127f1237a189060600160405180910390a26007546003820180546001600160a01b0319166001600160a01b039092169190911790555b505050610def60018055565b50565b600033610a49818585610e058383611843565b610e0f919061300e565b6119ec565b610e1c611b1a565b610e27823383611b73565b610e3060018055565b5050565b6000610a4f600883611f76565b60136020528160005260406000208181548110610e5d57600080fd5b600091825260209091206005909102018054600182015460028301546003840154600490940154929550909350916001600160a01b03169085565b610ea0611b1a565b3360008181526013602052604090205482908110610ed05760405162461bcd60e51b815260040161093290612f67565b33600090815260126020908152604080832060139092528220805491929186908110610efe57610efe612fb2565b90600052602060002090600502019050610f2981600101548360010154611f8290919063ffffffff16565b8260010181905550610f4030338360010154611dc0565b600481015415610fc457600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c991610f919133919060248101612fc8565b600060405180830381600087803b158015610fab57600080fd5b505af1158015610fbf573d6000803e3d6000fd5b505050505b600181015460405190815233907f56d7520e387607a8daa892e3fed116badc2a636307bdc794b1c1aed97ae203f49060200160405180910390a261100785611f8e565b50505050610def60018055565b61101c611b1a565b6110273385856120b8565b60405163549230c960e01b81526001600160a01b0385169063549230c990610b5d903390879087908790600401612f1f565b611061611b1a565b333b6110a85760405162461bcd60e51b815260206004820152601660248201527518dbdb9d995c9d151bce881b9bdd08185b1b1bddd95960521b6044820152606401610932565b610e278282612302565b6110ba611992565b6110c460006123d5565b565b6110ce611b1a565b600082116111295760405162461bcd60e51b815260206004820152602260248201527f72656465656d3a204553414749416d6f756e742063616e6e6f74206265206e756044820152611b1b60f21b6064820152608401610932565b600f5481101561117b5760405162461bcd60e51b815260206004820152601860248201527f72656465656d3a206475726174696f6e20746f6f206c6f7700000000000000006044820152606401610932565b611186333084611dc0565b336000908152601260205260408120906111a084846118e4565b604080518681526020810183905290810185905290915033907fbd5034ffbd47e4e72a94baa2cdb74c6fad73cb3bcdc13036b72ec8306f5a76469060600160405180910390a282156113495760018201546111fb9085612425565b600183015560115460009061121e90606490611218908890612431565b9061243d565b9050801561129a5760075460408051600081526020810191829052631c75e36960e01b9091526001600160a01b0390911690631c75e36990611267903390859060248101612fc8565b600060405180830381600087803b15801561128157600080fd5b505af1158015611295573d6000803e3d6000fd5b505050505b33600090815260136020908152604091829020825160a0810184528581529182018890529181016112cb4288612425565b81526007546001600160a01b0390811660208084019190915260409283019590955283546001808201865560009586529486902084516005909202019081559483015193850193909355810151600284015560608101516003840180546001600160a01b031916919093161790915560800151600490910155611354565b611354338583612449565b5050610e3060018055565b611367611992565b306001600160a01b038316036113e55760405162461bcd60e51b815260206004820152603b60248201527f7570646174655472616e7366657257686974656c6973743a2043616e6e6f742060448201527f72656d6f76652045534147492066726f6d2077686974656c69737400000000006064820152608401610932565b80156113fc576113f6600883612559565b50611409565b61140760088361256e565b505b604080516001600160a01b038416815282151560208201527f3a34209cb941a5d23a56dea730a13738454bc7daefd4bb32e8d7df58c1bd920d910160405180910390a15050565b60606006805461088790612e9d565b611467611b1a565b610e278233836120b8565b61147a611b1a565b6114848133612302565b610def60018055565b6000338161149b8286611843565b9050838110156114fb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610932565b610bc482868684036119ec565b600033610a49818585611dc0565b61151e611b1a565b336000818152601360205260409020548290811061154e5760405162461bcd60e51b815260040161093290612f67565b3360009081526012602090815260408083206013909252822080549192918690811061157c5761157c612fb2565b9060005260206000209060050201905080600201546115984290565b10156116015760405162461bcd60e51b815260206004820152603260248201527f66696e616c697a6552656465656d3a2076657374696e67206475726174696f6e604482015271081a185cc81b9bdd08195b991959081e595d60721b6064820152608401610932565b6001808201549083015461161491611f82565b826001018190555061162f3382600101548360000154612449565b6004810154156116b357600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c9916116809133919060248101612fc8565b600060405180830381600087803b15801561169a57600080fd5b505af11580156116ae573d6000803e3d6000fd5b505050505b61100785611f8e565b6116c4611b1a565b6001600160a01b03821661172c5760405162461bcd60e51b815260206004820152602960248201527f617070726f766555736167653a20617070726f766520746f20746865207a65726044820152686f206164647265737360b81b6064820152608401610932565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020859055518481529192917fe75ec259c38e4601f24580968665ec00b21cca4f996689b260ec598aec5c08db910160405180910390a3610e3060018055565b6001600160a01b03821660009081526013602052604081205481908190819081908790879081106117d35760405162461bcd60e51b815260040161093290612f67565b6001600160a01b038916600090815260136020526040812080548a9081106117fd576117fd612fb2565b600091825260209091206005909102018054600182015460028301546003840154600490940154929e919d509b506001600160a01b039092169950975095505050505050565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b611876611992565b6001600160a01b0381166118db5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610932565b610def816123d5565b6000600f548210156118f857506000610a4f565b6010548211156119235761191c6064611218600e548661243190919063ffffffff16565b9050610a4f565b6000611979611970611942600f54601054611f8290919063ffffffff16565b61121861195c600d54600e54611f8290919063ffffffff16565b600f5461196a908990611f82565b90612431565b600d5490612425565b905061198a60646112188684612431565b949350505050565b6000546001600160a01b031633146110c45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610932565b6001600160a01b038316611a4e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610932565b6001600160a01b038216611aaf5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610932565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610a4f825490565b600260015403611b6c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610932565b6002600155565b60008111611bc35760405162461bcd60e51b815260206004820152601f60248201527f616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6c006044820152606401610932565b6001600160a01b038084166000908152601260209081526040808320600a835281842094871684529390915290205482811015611c425760405162461bcd60e51b815260206004820152601f60248201527f616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e74006044820152606401610932565b611c4c8184611f82565b6001600160a01b038087166000818152600a60209081526040808320948a1680845294825280832095909555918152600b82528381209281529190522054611c949084612425565b6001600160a01b038087166000908152600b60209081526040808320938916835292905220558154611cc69084612425565b8255611cd3853085611dc0565b836001600160a01b0316856001600160a01b03167f5168bfb88d6125d4580e2b91ecb103a730312c3e8b0be9c4031a0fc794e2cd5f85604051611d1891815260200190565b60405180910390a35050505050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000611d588484611843565b90506000198114610b985781811015611db35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610932565b610b9884848484036119ec565b6001600160a01b038316611e245760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610932565b6001600160a01b038216611e865760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610932565b611e91838383612583565b6001600160a01b03831660009081526002602052604090205481811015611f095760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610932565b6001600160a01b0380851660008181526002602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611f699086815260200190565b60405180910390a3610b98565b6000611d4583836125f9565b6000611d458284613021565b3360009081526013602052604090208054611fab90600190613021565b81548110611fbb57611fbb612fb2565b906000526020600020906005020160136000336001600160a01b03166001600160a01b031681526020019081526020016000208281548110611fff57611fff612fb2565b600091825260208083208454600590930201918255600180850154908301556002808501549083015560038085015490830180546001600160a01b0319166001600160a01b03909216919091179055600493840154939091019290925533815260139091526040902080548061207757612077613034565b60008281526020812060056000199093019283020181815560018101829055600281018290556003810180546001600160a01b031916905560040155905550565b600081116121125760405162461bcd60e51b815260206004820152602160248201527f6465616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6044820152601b60fa1b6064820152608401610932565b6001600160a01b038084166000908152600b6020908152604080832093861683529290522054818110156121925760405162461bcd60e51b815260206004820152602160248201527f6465616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e6044820152601d60fa1b6064820152608401610932565b61219c8183611f82565b6001600160a01b038086166000908152600b60209081526040808320938816835292815282822093909355600c9092528120546121e29061271090611218908690612431565b6001600160a01b038616600090815260126020526040902080549192509061220a9085611f82565b8155612220308761221b8786611f82565b611dc0565b604051630852cd8d60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b15801561228257600080fd5b505af1158015612296573d6000803e3d6000fd5b505050506122a43083612623565b846001600160a01b0316866001600160a01b03167f7d613f7bd1a777aeeefdd38ae61201003086575188df50618d02482220f5c14786856040516122f2929190918252602082015260400190565b60405180910390a3505050505050565b816000036123525760405162461bcd60e51b815260206004820152601e60248201527f636f6e766572743a20616d6f756e742063616e6e6f74206265206e756c6c00006044820152606401610932565b61235c8183612763565b604080516001600160a01b03831681526020810184905233917fccfaeb3043a96a967dc036ab72e078a9632af809671bc2a1ac30a8043645f89e910160405180910390a2610e306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333085612830565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611d45828461300e565b6000611d45828461304a565b6000611d458284613061565b60006124558383611f82565b905061248b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461289b565b604051630852cd8d60e31b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b1580156124ed57600080fd5b505af1158015612501573d6000803e3d6000fd5b5050505061250f3084612623565b60408051848152602081018490526001600160a01b038616917f0da072ebd7a5649099f43a3776eb0cda17aca79426ee9f28aae203f5dfa04eda910160405180910390a250505050565b6000611d45836001600160a01b0384166128cb565b6000611d45836001600160a01b03841661291a565b6001600160a01b038316158061259f575061259f600884611d27565b806125b057506125b0600883611d27565b6125f45760405162461bcd60e51b81526020600482015260156024820152741d1c985b9cd9995c8e881b9bdd08185b1b1bddd959605a1b6044820152606401610932565b505050565b600082600001828154811061261057612610612fb2565b9060005260206000200154905092915050565b6001600160a01b0382166126835760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610932565b61268f82600083612583565b6001600160a01b038216600090815260026020526040902054818110156127035760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610932565b6001600160a01b03831660008181526002602090815260408083208686039055600480548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6001600160a01b0382166127b95760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610932565b6127c560008383612583565b80600460008282546127d7919061300e565b90915550506001600160a01b0382166000818152600260209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052610b989085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a0d565b6040516001600160a01b0383166024820152604481018290526125f490849063a9059cbb60e01b90606401612864565b600081815260018301602052604081205461291257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a4f565b506000610a4f565b60008181526001830160205260408120548015612a0357600061293e600183613021565b855490915060009061295290600190613021565b90508181146129b757600086600001828154811061297257612972612fb2565b906000526020600020015490508087600001848154811061299557612995612fb2565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806129c8576129c8613034565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a4f565b6000915050610a4f565b6000612a62826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612adf9092919063ffffffff16565b8051909150156125f45780806020019051810190612a809190613083565b6125f45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610932565b606061198a848460008585600080866001600160a01b03168587604051612b0691906130a0565b60006040518083038185875af1925050503d8060008114612b43576040519150601f19603f3d011682016040523d82523d6000602084013e612b48565b606091505b5091509150612b5987838387612b64565b979650505050505050565b60608315612bd3578251600003612bcc576001600160a01b0385163b612bcc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610932565b508161198a565b61198a8383815115612be85781518083602001fd5b8060405162461bcd60e51b81526004016109329190612c84565b6001600160a01b0381168114610def57600080fd5b600060208284031215612c2957600080fd5b8135611d4581612c02565b60005b83811015612c4f578181015183820152602001612c37565b50506000910152565b60008151808452612c70816020860160208601612c34565b601f01601f19169290920160200192915050565b602081526000611d456020830184612c58565b600080600080600060a08688031215612caf57600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b60008060408385031215612ce557600080fd5b8235612cf081612c02565b946020939093013593505050565b60008060008060608587031215612d1457600080fd5b8435612d1f81612c02565b935060208501359250604085013567ffffffffffffffff80821115612d4357600080fd5b818701915087601f830112612d5757600080fd5b813581811115612d6657600080fd5b886020828501011115612d7857600080fd5b95989497505060200194505050565b600080600060608486031215612d9c57600080fd5b8335612da781612c02565b92506020840135612db781612c02565b929592945050506040919091013590565b60008060408385031215612ddb57600080fd5b8235612de681612c02565b91506020830135612df681612c02565b809150509250929050565b600060208284031215612e1357600080fd5b5035919050565b60008060408385031215612e2d57600080fd5b823591506020830135612df681612c02565b60008060408385031215612e5257600080fd5b50508035926020909101359150565b8015158114610def57600080fd5b60008060408385031215612e8257600080fd5b8235612e8d81612c02565b91506020830135612df681612e61565b600181811c90821680612eb157607f821691505b602082108103612ed157634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526028908201527f75706461746552656465656d53657474696e67733a2077726f6e6720726174696040820152676f2076616c75657360c01b606082015260800190565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b6020808252602b908201527f76616c696461746552656465656d3a2072656465656d20656e74727920646f6560408201526a1cc81b9bdd08195e1a5cdd60aa1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60018060a01b0384168152826020820152606060408201526000612fef6060830184612c58565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610a4f57610a4f612ff8565b81810381811115610a4f57610a4f612ff8565b634e487b7160e01b600052603160045260246000fd5b8082028115828204841417610a4f57610a4f612ff8565b60008261307e57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561309557600080fd5b8151611d4581612e61565b600082516130b2818460208701612c34565b919091019291505056fea2646970667358221220b281b321e00b1870484754a2525eb5b302bd1bc64bc0a75ec35c1b2e47ad7d4864736f6c634300081300330000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce85
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061030c5760003560e01c80635a1d34dc1161019d578063a9059cbb116100e9578063d3b48655116100a2578063e9ed87f81161007c578063e9ed87f81461079d578063ee1cb30f146107a6578063f2fde38b146107cd578063f4bdd978146107e057600080fd5b8063d3b486551461073b578063dd62ed3e14610781578063e3a2950b1461079457600080fd5b8063a9059cbb146106bd578063aff6cbf1146106d0578063b90c2b52146106e3578063c360ed1c1461070c578063c4b107661461071f578063cc6c54231461072857600080fd5b8063890836541161015657806395d89b411161013057806395d89b411461067c578063a0bdc7cb14610684578063a3908e1b14610697578063a457c2d7146106aa57600080fd5b806389083654146106385780638975f9181461064b5780638da5cb5b1461066b57600080fd5b80635a1d34dc146105b2578063619ac95b146105c5578063658bb543146105cd57806370a08231146105f4578063715018a61461061d5780637cbc23731461062557600080fd5b80632cc2f5ce1161025c578063488c8303116102155780634b359d38116101ef5780634b359d38146105355780634f62b7ec14610548578063539ffb771461058c578063549230c91461059f57600080fd5b8063488c8303146104d6578063497965ee146105015780634a5b406e1461052c57600080fd5b80632cc2f5ce1461042a5780632e9a76e41461045557806331124ce31461048e578063313ce567146104a157806339509351146104b05780633b90f9a0146104c357600080fd5b8063161aab43116102c95780631c75e369116102a35780631c75e369146103b85780631eee7e60146103cb57806323b872dd146103de5780632b489679146103f157600080fd5b8063161aab431461039f57806318160ddd146103a75780631c352679146103af57600080fd5b806302f91e551461031157806306045a211461032c57806306fdde0314610341578063093220b714610356578063095ea7b3146103695780630f7d3a691461038c575b600080fd5b61031960c881565b6040519081526020015b60405180910390f35b61033f61033a366004612c17565b6107f3565b005b610349610878565b6040516103239190612c84565b61033f610364366004612c97565b61090a565b61037c610377366004612cd2565b610a3b565b6040519015158152602001610323565b61033f61039a366004612cd2565b610a55565b610319610b07565b600454610319565b610319600d5481565b61033f6103c6366004612cfe565b610b18565b61037c6103d9366004612c17565b610b9e565b61037c6103ec366004612d87565b610bab565b6103196103ff366004612dc8565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b610319610438366004612dc8565b600b60209081526000928352604080842090915290825290205481565b610319610463366004612dc8565b6001600160a01b039182166000908152600b6020908152604080832093909416825291909152205490565b61033f61049c366004612e01565b610bcf565b60405160128152602001610323565b61037c6104be366004612cd2565b610df2565b61033f6104d1366004612cd2565b610e14565b6103196104e4366004612dc8565b600a60209081526000928352604080842090915290825290205481565b600754610514906001600160a01b031681565b6040516001600160a01b039091168152602001610323565b61031960115481565b610514610543366004612e01565b610e34565b61055b610556366004612cd2565b610e41565b604080519586526020860194909452928401919091526001600160a01b03166060830152608082015260a001610323565b61033f61059a366004612e01565b610e98565b61033f6105ad366004612cfe565b611014565b61033f6105c0366004612e1a565b611059565b610319606481565b6105147f0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce8581565b610319610602366004612c17565b6001600160a01b031660009081526002602052604090205490565b61033f6110b2565b61033f610633366004612e3f565b6110c6565b61033f610646366004612e6f565b61135f565b610319610659366004612c17565b600c6020526000908152604090205481565b6000546001600160a01b0316610514565b610349611450565b61033f610692366004612cd2565b61145f565b61033f6106a5366004612e01565b611472565b61037c6106b8366004612cd2565b61148d565b61037c6106cb366004612cd2565b611508565b61033f6106de366004612e01565b611516565b6103196106f1366004612c17565b6001600160a01b031660009081526013602052604090205490565b61033f61071a366004612cd2565b6116bc565b610319600f5481565b61055b610736366004612cd2565b611790565b61076c610749366004612c17565b6001600160a01b0316600090815260126020526040902080546001909101549091565b60408051928352602083019190915201610323565b61031961078f366004612dc8565b611843565b610319600e5481565b61031960105481565b61076c6107b4366004612c17565b6012602052600090815260409020805460019091015482565b61033f6107db366004612c17565b61186e565b6103196107ee366004612e3f565b6118e4565b6107fb611992565b6001600160a01b03811661080f5760006011555b600754604080516001600160a01b03928316815291831660208301527f044c75b8fa43ce72364b4c23fdb8451beafbda46505bf44c76f0853a01ed4ade910160405180910390a1600780546001600160a01b0319166001600160a01b0392909216919091179055565b60606005805461088790612e9d565b80601f01602080910402602001604051908101604052809291908181526020018280546108b390612e9d565b80156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b5050505050905090565b610912611992565b8385111561093b5760405162461bcd60e51b815260040161093290612ed7565b60405180910390fd5b81831061099e5760405162461bcd60e51b815260206004820152602b60248201527f75706461746552656465656d53657474696e67733a2077726f6e67206475726160448201526a74696f6e2076616c75657360a81b6064820152608401610932565b606484111580156109b0575060648111155b6109cc5760405162461bcd60e51b815260040161093290612ed7565b600d859055600e849055600f83905560108290556011819055604080518681526020810186905290810184905260608101839052608081018290527f5b37d10782e41a6539b50d59366d4112a880236e4187e85b6d1514d20e07d9b89060a00160405180910390a15050505050565b600033610a498185856119ec565b60019150505b92915050565b610a5d611992565b60c8811115610aae5760405162461bcd60e51b815260206004820152601f60248201527f7570646174654465616c6c6f636174696f6e4665653a20746f6f2068696768006044820152606401610932565b6001600160a01b0382166000818152600c602052604090819020839055517f6ff024152fc2cd8071bc701f966036513eb03e243863f21d8218646faac0eaef90610afb9084815260200190565b60405180910390a25050565b6000610b136008611b10565b905090565b610b20611b1a565b610b2b338585611b73565b604051631c75e36960e01b81526001600160a01b03851690631c75e36990610b5d903390879087908790600401612f1f565b600060405180830381600087803b158015610b7757600080fd5b505af1158015610b8b573d6000803e3d6000fd5b50505050610b9860018055565b50505050565b6000610a4f600883611d27565b600033610bb9858285611d4c565b610bc4858585611dc0565b506001949350505050565b610bd7611b1a565b3360008181526013602052604090205482908110610c075760405162461bcd60e51b815260040161093290612f67565b336000908152601360205260408120805485908110610c2857610c28612fb2565b6000918252602090912060059091020160038101546007549192506001600160a01b03908116911614801590610c6857506007546001600160a01b031615155b15610de357600481015415610d6857600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c991610cbe9133919060248101612fc8565b600060405180830381600087803b158015610cd857600080fd5b505af1158015610cec573d6000803e3d6000fd5b5050600754600484015460408051600081526020810191829052631c75e36960e01b9091526001600160a01b039092169350631c75e3699250610d359133919060248101612fc8565b600060405180830381600087803b158015610d4f57600080fd5b505af1158015610d63573d6000803e3d6000fd5b505050505b6003810154600754604080518781526001600160a01b039384166020820152929091169082015233907fa60c8f9118be22c9277a8129333d64ffda3de44ca7a5831d077a3127f1237a189060600160405180910390a26007546003820180546001600160a01b0319166001600160a01b039092169190911790555b505050610def60018055565b50565b600033610a49818585610e058383611843565b610e0f919061300e565b6119ec565b610e1c611b1a565b610e27823383611b73565b610e3060018055565b5050565b6000610a4f600883611f76565b60136020528160005260406000208181548110610e5d57600080fd5b600091825260209091206005909102018054600182015460028301546003840154600490940154929550909350916001600160a01b03169085565b610ea0611b1a565b3360008181526013602052604090205482908110610ed05760405162461bcd60e51b815260040161093290612f67565b33600090815260126020908152604080832060139092528220805491929186908110610efe57610efe612fb2565b90600052602060002090600502019050610f2981600101548360010154611f8290919063ffffffff16565b8260010181905550610f4030338360010154611dc0565b600481015415610fc457600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c991610f919133919060248101612fc8565b600060405180830381600087803b158015610fab57600080fd5b505af1158015610fbf573d6000803e3d6000fd5b505050505b600181015460405190815233907f56d7520e387607a8daa892e3fed116badc2a636307bdc794b1c1aed97ae203f49060200160405180910390a261100785611f8e565b50505050610def60018055565b61101c611b1a565b6110273385856120b8565b60405163549230c960e01b81526001600160a01b0385169063549230c990610b5d903390879087908790600401612f1f565b611061611b1a565b333b6110a85760405162461bcd60e51b815260206004820152601660248201527518dbdb9d995c9d151bce881b9bdd08185b1b1bddd95960521b6044820152606401610932565b610e278282612302565b6110ba611992565b6110c460006123d5565b565b6110ce611b1a565b600082116111295760405162461bcd60e51b815260206004820152602260248201527f72656465656d3a204553414749416d6f756e742063616e6e6f74206265206e756044820152611b1b60f21b6064820152608401610932565b600f5481101561117b5760405162461bcd60e51b815260206004820152601860248201527f72656465656d3a206475726174696f6e20746f6f206c6f7700000000000000006044820152606401610932565b611186333084611dc0565b336000908152601260205260408120906111a084846118e4565b604080518681526020810183905290810185905290915033907fbd5034ffbd47e4e72a94baa2cdb74c6fad73cb3bcdc13036b72ec8306f5a76469060600160405180910390a282156113495760018201546111fb9085612425565b600183015560115460009061121e90606490611218908890612431565b9061243d565b9050801561129a5760075460408051600081526020810191829052631c75e36960e01b9091526001600160a01b0390911690631c75e36990611267903390859060248101612fc8565b600060405180830381600087803b15801561128157600080fd5b505af1158015611295573d6000803e3d6000fd5b505050505b33600090815260136020908152604091829020825160a0810184528581529182018890529181016112cb4288612425565b81526007546001600160a01b0390811660208084019190915260409283019590955283546001808201865560009586529486902084516005909202019081559483015193850193909355810151600284015560608101516003840180546001600160a01b031916919093161790915560800151600490910155611354565b611354338583612449565b5050610e3060018055565b611367611992565b306001600160a01b038316036113e55760405162461bcd60e51b815260206004820152603b60248201527f7570646174655472616e7366657257686974656c6973743a2043616e6e6f742060448201527f72656d6f76652045534147492066726f6d2077686974656c69737400000000006064820152608401610932565b80156113fc576113f6600883612559565b50611409565b61140760088361256e565b505b604080516001600160a01b038416815282151560208201527f3a34209cb941a5d23a56dea730a13738454bc7daefd4bb32e8d7df58c1bd920d910160405180910390a15050565b60606006805461088790612e9d565b611467611b1a565b610e278233836120b8565b61147a611b1a565b6114848133612302565b610def60018055565b6000338161149b8286611843565b9050838110156114fb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610932565b610bc482868684036119ec565b600033610a49818585611dc0565b61151e611b1a565b336000818152601360205260409020548290811061154e5760405162461bcd60e51b815260040161093290612f67565b3360009081526012602090815260408083206013909252822080549192918690811061157c5761157c612fb2565b9060005260206000209060050201905080600201546115984290565b10156116015760405162461bcd60e51b815260206004820152603260248201527f66696e616c697a6552656465656d3a2076657374696e67206475726174696f6e604482015271081a185cc81b9bdd08195b991959081e595d60721b6064820152608401610932565b6001808201549083015461161491611f82565b826001018190555061162f3382600101548360000154612449565b6004810154156116b357600381015460048201546040805160008152602081019182905263549230c960e01b9091526001600160a01b039092169163549230c9916116809133919060248101612fc8565b600060405180830381600087803b15801561169a57600080fd5b505af11580156116ae573d6000803e3d6000fd5b505050505b61100785611f8e565b6116c4611b1a565b6001600160a01b03821661172c5760405162461bcd60e51b815260206004820152602960248201527f617070726f766555736167653a20617070726f766520746f20746865207a65726044820152686f206164647265737360b81b6064820152608401610932565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020859055518481529192917fe75ec259c38e4601f24580968665ec00b21cca4f996689b260ec598aec5c08db910160405180910390a3610e3060018055565b6001600160a01b03821660009081526013602052604081205481908190819081908790879081106117d35760405162461bcd60e51b815260040161093290612f67565b6001600160a01b038916600090815260136020526040812080548a9081106117fd576117fd612fb2565b600091825260209091206005909102018054600182015460028301546003840154600490940154929e919d509b506001600160a01b039092169950975095505050505050565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b611876611992565b6001600160a01b0381166118db5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610932565b610def816123d5565b6000600f548210156118f857506000610a4f565b6010548211156119235761191c6064611218600e548661243190919063ffffffff16565b9050610a4f565b6000611979611970611942600f54601054611f8290919063ffffffff16565b61121861195c600d54600e54611f8290919063ffffffff16565b600f5461196a908990611f82565b90612431565b600d5490612425565b905061198a60646112188684612431565b949350505050565b6000546001600160a01b031633146110c45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610932565b6001600160a01b038316611a4e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610932565b6001600160a01b038216611aaf5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610932565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610a4f825490565b600260015403611b6c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610932565b6002600155565b60008111611bc35760405162461bcd60e51b815260206004820152601f60248201527f616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6c006044820152606401610932565b6001600160a01b038084166000908152601260209081526040808320600a835281842094871684529390915290205482811015611c425760405162461bcd60e51b815260206004820152601f60248201527f616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e74006044820152606401610932565b611c4c8184611f82565b6001600160a01b038087166000818152600a60209081526040808320948a1680845294825280832095909555918152600b82528381209281529190522054611c949084612425565b6001600160a01b038087166000908152600b60209081526040808320938916835292905220558154611cc69084612425565b8255611cd3853085611dc0565b836001600160a01b0316856001600160a01b03167f5168bfb88d6125d4580e2b91ecb103a730312c3e8b0be9c4031a0fc794e2cd5f85604051611d1891815260200190565b60405180910390a35050505050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000611d588484611843565b90506000198114610b985781811015611db35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610932565b610b9884848484036119ec565b6001600160a01b038316611e245760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610932565b6001600160a01b038216611e865760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610932565b611e91838383612583565b6001600160a01b03831660009081526002602052604090205481811015611f095760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610932565b6001600160a01b0380851660008181526002602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611f699086815260200190565b60405180910390a3610b98565b6000611d4583836125f9565b6000611d458284613021565b3360009081526013602052604090208054611fab90600190613021565b81548110611fbb57611fbb612fb2565b906000526020600020906005020160136000336001600160a01b03166001600160a01b031681526020019081526020016000208281548110611fff57611fff612fb2565b600091825260208083208454600590930201918255600180850154908301556002808501549083015560038085015490830180546001600160a01b0319166001600160a01b03909216919091179055600493840154939091019290925533815260139091526040902080548061207757612077613034565b60008281526020812060056000199093019283020181815560018101829055600281018290556003810180546001600160a01b031916905560040155905550565b600081116121125760405162461bcd60e51b815260206004820152602160248201527f6465616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6044820152601b60fa1b6064820152608401610932565b6001600160a01b038084166000908152600b6020908152604080832093861683529290522054818110156121925760405162461bcd60e51b815260206004820152602160248201527f6465616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e6044820152601d60fa1b6064820152608401610932565b61219c8183611f82565b6001600160a01b038086166000908152600b60209081526040808320938816835292815282822093909355600c9092528120546121e29061271090611218908690612431565b6001600160a01b038616600090815260126020526040902080549192509061220a9085611f82565b8155612220308761221b8786611f82565b611dc0565b604051630852cd8d60e31b8152600481018390527f0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce856001600160a01b0316906342966c6890602401600060405180830381600087803b15801561228257600080fd5b505af1158015612296573d6000803e3d6000fd5b505050506122a43083612623565b846001600160a01b0316866001600160a01b03167f7d613f7bd1a777aeeefdd38ae61201003086575188df50618d02482220f5c14786856040516122f2929190918252602082015260400190565b60405180910390a3505050505050565b816000036123525760405162461bcd60e51b815260206004820152601e60248201527f636f6e766572743a20616d6f756e742063616e6e6f74206265206e756c6c00006044820152606401610932565b61235c8183612763565b604080516001600160a01b03831681526020810184905233917fccfaeb3043a96a967dc036ab72e078a9632af809671bc2a1ac30a8043645f89e910160405180910390a2610e306001600160a01b037f0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce8516333085612830565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611d45828461300e565b6000611d45828461304a565b6000611d458284613061565b60006124558383611f82565b905061248b6001600160a01b037f0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce8516858461289b565b604051630852cd8d60e31b8152600481018290527f0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce856001600160a01b0316906342966c6890602401600060405180830381600087803b1580156124ed57600080fd5b505af1158015612501573d6000803e3d6000fd5b5050505061250f3084612623565b60408051848152602081018490526001600160a01b038616917f0da072ebd7a5649099f43a3776eb0cda17aca79426ee9f28aae203f5dfa04eda910160405180910390a250505050565b6000611d45836001600160a01b0384166128cb565b6000611d45836001600160a01b03841661291a565b6001600160a01b038316158061259f575061259f600884611d27565b806125b057506125b0600883611d27565b6125f45760405162461bcd60e51b81526020600482015260156024820152741d1c985b9cd9995c8e881b9bdd08185b1b1bddd959605a1b6044820152606401610932565b505050565b600082600001828154811061261057612610612fb2565b9060005260206000200154905092915050565b6001600160a01b0382166126835760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610932565b61268f82600083612583565b6001600160a01b038216600090815260026020526040902054818110156127035760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610932565b6001600160a01b03831660008181526002602090815260408083208686039055600480548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6001600160a01b0382166127b95760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610932565b6127c560008383612583565b80600460008282546127d7919061300e565b90915550506001600160a01b0382166000818152600260209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052610b989085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a0d565b6040516001600160a01b0383166024820152604481018290526125f490849063a9059cbb60e01b90606401612864565b600081815260018301602052604081205461291257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a4f565b506000610a4f565b60008181526001830160205260408120548015612a0357600061293e600183613021565b855490915060009061295290600190613021565b90508181146129b757600086600001828154811061297257612972612fb2565b906000526020600020015490508087600001848154811061299557612995612fb2565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806129c8576129c8613034565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a4f565b6000915050610a4f565b6000612a62826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612adf9092919063ffffffff16565b8051909150156125f45780806020019051810190612a809190613083565b6125f45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610932565b606061198a848460008585600080866001600160a01b03168587604051612b0691906130a0565b60006040518083038185875af1925050503d8060008114612b43576040519150601f19603f3d011682016040523d82523d6000602084013e612b48565b606091505b5091509150612b5987838387612b64565b979650505050505050565b60608315612bd3578251600003612bcc576001600160a01b0385163b612bcc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610932565b508161198a565b61198a8383815115612be85781518083602001fd5b8060405162461bcd60e51b81526004016109329190612c84565b6001600160a01b0381168114610def57600080fd5b600060208284031215612c2957600080fd5b8135611d4581612c02565b60005b83811015612c4f578181015183820152602001612c37565b50506000910152565b60008151808452612c70816020860160208601612c34565b601f01601f19169290920160200192915050565b602081526000611d456020830184612c58565b600080600080600060a08688031215612caf57600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b60008060408385031215612ce557600080fd5b8235612cf081612c02565b946020939093013593505050565b60008060008060608587031215612d1457600080fd5b8435612d1f81612c02565b935060208501359250604085013567ffffffffffffffff80821115612d4357600080fd5b818701915087601f830112612d5757600080fd5b813581811115612d6657600080fd5b886020828501011115612d7857600080fd5b95989497505060200194505050565b600080600060608486031215612d9c57600080fd5b8335612da781612c02565b92506020840135612db781612c02565b929592945050506040919091013590565b60008060408385031215612ddb57600080fd5b8235612de681612c02565b91506020830135612df681612c02565b809150509250929050565b600060208284031215612e1357600080fd5b5035919050565b60008060408385031215612e2d57600080fd5b823591506020830135612df681612c02565b60008060408385031215612e5257600080fd5b50508035926020909101359150565b8015158114610def57600080fd5b60008060408385031215612e8257600080fd5b8235612e8d81612c02565b91506020830135612df681612e61565b600181811c90821680612eb157607f821691505b602082108103612ed157634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526028908201527f75706461746552656465656d53657474696e67733a2077726f6e6720726174696040820152676f2076616c75657360c01b606082015260800190565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b6020808252602b908201527f76616c696461746552656465656d3a2072656465656d20656e74727920646f6560408201526a1cc81b9bdd08195e1a5cdd60aa1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60018060a01b0384168152826020820152606060408201526000612fef6060830184612c58565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610a4f57610a4f612ff8565b81810381811115610a4f57610a4f612ff8565b634e487b7160e01b600052603160045260246000fd5b8082028115828204841417610a4f57610a4f612ff8565b60008261307e57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561309557600080fd5b8151611d4581612e61565b600082516130b2818460208701612c34565b919091019291505056fea2646970667358221220b281b321e00b1870484754a2525eb5b302bd1bc64bc0a75ec35c1b2e47ad7d4864736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce85
-----Decoded View---------------
Arg [0] : agiToken_ (address): 0x5F18ea482ad5cc6BC65803817C99f477043DcE85
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000005f18ea482ad5cc6bc65803817c99f477043dce85
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.