Source Code
Overview
MATIC Balance
0 MATIC
More Info
ContractCreator:
Multichain Info
N/A
Latest 1 internal transaction
Parent Txn Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
29684214 | 470 days ago | Contract Creation | 0 MATIC |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x4386Cca1...DC83e85aE The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
CollateralPoolFactory
Compiler Version
v0.8.2+commit.661d1103
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.8.4; import "./interfaces/ICollateralPoolFactory.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./CollateralPool.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract CollateralPoolFactory is ICollateralPoolFactory, Ownable, ReentrancyGuard { modifier nonZeroAddress(address _address) { require(_address != address(0), "CollateralPoolFactory: zero address"); _; } modifier nonZeroValue(uint _value) { require(_value > 0, "CollateralPoolFactory: zero value"); _; } // Public variables mapping(address => address) public override getCollateralPoolByToken; // collateral token => collateral pool address[] public override allCollateralPools; // List of all collateral pools /// @notice This contract creates collateral pool for tokens constructor() {} function renounceOwnership() public virtual override onlyOwner {} /// @return Total number of collateral pools function allCollateralPoolsLength() public override view returns (uint) { return allCollateralPools.length; } /// @notice Checks whether the token is accepted as collateral or not /// @param _collateralToken Address of collateral token /// @return True if the corresponding collateral pool exists function isCollateral(address _collateralToken) external override view returns (bool) { return getCollateralPoolByToken[_collateralToken] == address(0) ? false : true; } /// @notice Creates a new collateral pool /// @dev Only owner can call this /// @param _collateralToken Address of underlying collateral token /// @param _collateralizationRatio The ratio of over collateralization /// @return Address of newly created collateral pool function createCollateralPool( address _collateralToken, uint _collateralizationRatio ) external nonZeroAddress(_collateralToken) nonZeroValue(_collateralizationRatio) nonReentrant onlyOwner override returns (address) { // Checks that collateral pool for the token doesn't exist require( getCollateralPoolByToken[_collateralToken] == address(0), "CollateralPoolFactory: collateral pool already exists" ); require( _collateralizationRatio >= 10000, "CollateralPoolFactory: low amount" ); // Creates collateral pool CollateralPool pool; string memory name; string memory symbol; name = string(abi.encodePacked(ERC20(_collateralToken).name(), "-", "Collateral-Pool")); symbol = string(abi.encodePacked(ERC20(_collateralToken).symbol(), "CP")); pool = new CollateralPool(name, symbol, _collateralToken, _collateralizationRatio); // Transfers ownership of collateral pool to owner of this contract CollateralPool(address(pool)).transferOwnership(_msgSender()); // Stores collateral pool address getCollateralPoolByToken[_collateralToken] = address(pool); allCollateralPools.push(address(pool)); emit CreateCollateralPool(name, _collateralToken, _collateralizationRatio, address(pool)); return address(pool); } /// @notice Removes an existing collateral pool /// @dev Only owner can call this /// @param _collateralToken Address of underlying collateral token /// @param _index Index of collateral pool in allCollateralPools /// @return True if collateral pool is removed successfully function removeCollateralPool( address _collateralToken, uint _index ) external nonReentrant nonZeroAddress(_collateralToken) onlyOwner override returns (bool) { // Checks that collateral pool exists address collateralPool = getCollateralPoolByToken[_collateralToken]; require(collateralPool != address(0), "CollateralPoolFactory: collateral pool does not exist"); // Removes collateral pool address require(_index < allCollateralPoolsLength(), "CollateralPoolFactory: index is out of range"); require(collateralPool == allCollateralPools[_index], "CollateralPoolFactory: index is not correct"); getCollateralPoolByToken[_collateralToken] = address(0); _removeElement(_index); emit RemoveCollateralPool(_collateralToken, collateralPool); return true; } /// @notice Removes an element of allCollateralPools /// @dev Deletes and shifts the array /// @param _index Index of the element that is deleted function _removeElement(uint _index) private { allCollateralPools[_index] = allCollateralPools[allCollateralPoolsLength() - 1]; allCollateralPools.pop(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.8.4; interface ICollateralPoolFactory { // Events /// @notice Emits when a collateral pool is created /// @param name Name of the collateral token /// @param collateralToken Collateral token address /// @param collateralizationRatio At most (collateral value)/(collateralization ratio) can be moved instantly by the user /// @param collateralPool Collateral pool contract address event CreateCollateralPool( string name, address indexed collateralToken, uint collateralizationRatio, address indexed collateralPool ); /// @notice Emits when a collateral pool is removed /// @param collateralToken Collateral token address /// @param collateralPool Collateral pool contract address event RemoveCollateralPool( address indexed collateralToken, address indexed collateralPool ); // Read-only functions function getCollateralPoolByToken(address _collateralToken) external view returns (address); function allCollateralPools(uint _index) external view returns (address); function allCollateralPoolsLength() external view returns (uint); function isCollateral(address _collateralToken) external view returns (bool); // State-changing functions function createCollateralPool(address _collateralToken, uint _collateralizationRatio) external returns (address); function removeCollateralPool(address _collateralToken, uint _index) external returns (bool); }
// SPDX-License-Identifier: MIT 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.zeppelin.solutions/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: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, 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}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), 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}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][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) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * 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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, 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; _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; } _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 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 pragma solidity >=0.8.0 <0.8.4; import "./interfaces/ICollateralPool.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract CollateralPool is ICollateralPool, ERC20, Ownable, ReentrancyGuard { using SafeERC20 for IERC20; modifier nonZeroAddress(address _address) { require(_address != address(0), "CollateralPool: zero address"); _; } modifier nonZeroValue(uint _value) { require(_value > 0, "CollateralPool: zero value"); _; } // Public variables address public override collateralToken; uint public override collateralizationRatio; // Multiplied by 100 /// @notice This contract is a vault for collateral token /// @dev Users deposit collateral to use TeleportDAO instant feature /// Collateral pool factory creates collateral pool contract /// @param _name Name of collateral pool /// @param _symbol Symbol of collateral pool /// @param _collateralToken Address of underlying collateral token /// @param _collateralizationRatio Over-collateralization ratio of collateral token (e.g. 120 means 1.2) constructor( string memory _name, string memory _symbol, address _collateralToken, uint _collateralizationRatio ) ERC20(_name, _symbol) { collateralToken = _collateralToken; _setCollateralizationRatio(_collateralizationRatio); } function renounceOwnership() public virtual override onlyOwner {} /// @return Amount of total added collateral function totalAddedCollateral() public view override returns (uint) { return IERC20(collateralToken).balanceOf(address(this)); } /// @notice Changes the collateralization ratio /// @dev Only owner can call this /// @param _collateralizationRatio The new collateralization ratio function setCollateralizationRatio( uint _collateralizationRatio ) external override onlyOwner { _setCollateralizationRatio(_collateralizationRatio); } /// @notice Internal setter for collateralization ratio /// @param _collateralizationRatio The new collateralization ratio function _setCollateralizationRatio( uint _collateralizationRatio ) private nonZeroValue(_collateralizationRatio) { emit NewCollateralizationRatio(collateralizationRatio, _collateralizationRatio); require( _collateralizationRatio >= 10000, "CollateralPool: CR is low" ); collateralizationRatio = _collateralizationRatio; } /// @notice Converts collateral pool token to collateral token /// @param _collateralPoolTokenAmount Amount of collateral pool token /// @return Amount of collateral token function equivalentCollateralToken(uint _collateralPoolTokenAmount) external view override returns (uint) { require(totalSupply() > 0, "CollateralPool: collateral pool is empty"); require(totalSupply() >= _collateralPoolTokenAmount, "CollateralPool: liquidity is not sufficient"); return _collateralPoolTokenAmount*totalAddedCollateral()/totalSupply(); } /// @notice Converts collateral token to collateral pool token /// @param _collateralTokenAmount Amount of collateral token /// @return Amount of collateral pool token function equivalentCollateralPoolToken(uint _collateralTokenAmount) external view override returns (uint) { require(totalAddedCollateral() > 0, "CollateralPool: collateral pool is empty"); require(totalAddedCollateral() >= _collateralTokenAmount, "CollateralPool: liquidity is not sufficient"); return _collateralTokenAmount*totalSupply()/totalAddedCollateral(); } /// @notice Adds collateral to collateral pool /// @dev Mints collateral pool token for user /// @param _user Address of user whose collateral balance is increased /// @param _amount Amount of added collateral /// @return True if collateral is added successfully function addCollateral( address _user, uint _amount ) external nonZeroAddress(_user) nonZeroValue(_amount) nonReentrant override returns (bool) { // Calculates collateral pool token amount uint collateralPoolTokenAmount; if (totalSupply() == 0) { collateralPoolTokenAmount = _amount; } else { collateralPoolTokenAmount = _amount*totalSupply()/totalAddedCollateral(); } // Transfers collateral tokens from message sender to contract IERC20(collateralToken).safeTransferFrom(_msgSender(), address(this), _amount); // Mints collateral pool token for _user _mint(_user, collateralPoolTokenAmount); emit AddCollateral(_msgSender(), _user, _amount, collateralPoolTokenAmount); return true; } /// @notice Removes collateral from collateral pool /// @dev Burns collateral pool token of message sender /// @param _collateralPoolTokenAmount Amount of burnt collateral pool token /// @return True if collateral is removed successfully function removeCollateral( uint _collateralPoolTokenAmount ) external nonZeroValue(_collateralPoolTokenAmount) nonReentrant override returns (bool) { // Checks basic requirements require( balanceOf(_msgSender()) >= _collateralPoolTokenAmount, "CollateralPool: balance is not enough" ); // Finds equivalent collateral token amount uint collateralTokenAmount = _collateralPoolTokenAmount*totalAddedCollateral()/totalSupply(); // Burns collateral pool token of user _burn(_msgSender(), _collateralPoolTokenAmount); // Sends collateral token to user IERC20(collateralToken).safeTransfer(_msgSender(), collateralTokenAmount); emit RemoveCollateral(_msgSender(), _msgSender(), collateralTokenAmount, _collateralPoolTokenAmount); return true; } }
// SPDX-License-Identifier: MIT 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() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT 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 make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // 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 pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT 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 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 pragma solidity >=0.8.0 <0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ICollateralPool is IERC20 { // Events event AddCollateral(address indexed doer, address indexed user, uint amount, uint collateralPoolTokenAmount); event RemoveCollateral(address indexed doer, address indexed user, uint amount, uint collateralPoolTokenAmount); event NewCollateralizationRatio(uint oldCollateralizationRatio, uint newCollateralizationRatio); // Read-only functions function collateralToken() external view returns (address); function collateralizationRatio() external view returns(uint); function totalAddedCollateral() external view returns (uint); function equivalentCollateralToken(uint _collateralPoolTokenAmount) external view returns (uint); function equivalentCollateralPoolToken(uint _collateralTokenAmount) external view returns (uint); // State-changing functions function setCollateralizationRatio(uint _collateralizationRatio) external; function addCollateral(address _user, uint _amount) external returns (bool); function removeCollateral(uint _collateralPoolTokenAmount) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.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)); } } /** * @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 pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":true,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralizationRatio","type":"uint256"},{"indexed":true,"internalType":"address","name":"collateralPool","type":"address"}],"name":"CreateCollateralPool","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":"collateralToken","type":"address"},{"indexed":true,"internalType":"address","name":"collateralPool","type":"address"}],"name":"RemoveCollateralPool","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allCollateralPools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allCollateralPoolsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"uint256","name":"_collateralizationRatio","type":"uint256"}],"name":"createCollateralPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"getCollateralPoolByToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"}],"name":"isCollateral","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"removeCollateralPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x60806040523480156200001157600080fd5b5060043610620000a05760003560e01c80638b41c4fe116200006f5780638b41c4fe146200011f5780638da5cb5b1462000136578063dbd248e61462000148578063dc5f013e146200015f578063f2fde38b146200018b57620000a0565b80630ee21e5414620000a55780631b7293cd14620000d15780635df0f55014620000e3578063715018a61462000113575b600080fd5b620000bc620000b636600462000b8d565b620001a2565b60405190151581526020015b60405180910390f35b600354604051908152602001620000c8565b620000fa620000f436600462000c92565b620001d8565b6040516001600160a01b039091168152602001620000c8565b6200011d62000203565b005b620000fa6200013036600462000bb1565b6200023b565b6000546001600160a01b0316620000fa565b620000bc6200015936600462000bb1565b620006ce565b620000fa6200017036600462000b8d565b6002602052600090815260409020546001600160a01b031681565b6200011d6200019c36600462000b8d565b6200098e565b6001600160a01b0381811660009081526002602052604081205490911615620001cd576001620001d0565b60005b90505b919050565b60038181548110620001e957600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b03163314620002395760405162461bcd60e51b8152600401620002309062000ded565b60405180910390fd5b565b6000826001600160a01b038116620002675760405162461bcd60e51b8152600401620002309062000daa565b8260008111620002c45760405162461bcd60e51b815260206004820152602160248201527f436f6c6c61746572616c506f6f6c466163746f72793a207a65726f2076616c756044820152606560f81b606482015260840162000230565b60026001541415620003195760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000230565b60026001556000546001600160a01b031633146200034b5760405162461bcd60e51b8152600401620002309062000ded565b6001600160a01b038581166000908152600260205260409020541615620003d35760405162461bcd60e51b815260206004820152603560248201527f436f6c6c61746572616c506f6f6c466163746f72793a20636f6c6c61746572616044820152746c20706f6f6c20616c72656164792065786973747360581b606482015260840162000230565b612710841015620004315760405162461bcd60e51b815260206004820152602160248201527f436f6c6c61746572616c506f6f6c466163746f72793a206c6f7720616d6f756e6044820152601d60fa1b606482015260840162000230565b6000606080876001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b1580156200047057600080fd5b505afa15801562000485573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620004af919081019062000bdd565b604051602001620004c1919062000d01565b6040516020818303038152906040529150876001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156200050c57600080fd5b505afa15801562000521573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200054b919081019062000bdd565b6040516020016200055d919062000cd9565b604051602081830303815290604052905081818989604051620005809062000b67565b6200058f949392919062000d40565b604051809103906000f080158015620005ac573d6000803e3d6000fd5b5092506001600160a01b03831663f2fde38b336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b1580156200060157600080fd5b505af115801562000616573d6000803e3d6000fd5b505050506001600160a01b0388811660008181526002602052604080822080546001600160a01b03199081169589169586179091556003805460018101825593527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90920180549092168417909155517f6e86e4d8eed057ac88a84132c45db161d6c5a1f32b997ed913edf0bef4fb47c290620006b79086908c9062000d86565b60405180910390a350506001805595945050505050565b600060026001541415620007255760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000230565b6002600155826001600160a01b038116620007545760405162461bcd60e51b8152600401620002309062000daa565b6000546001600160a01b03163314620007815760405162461bcd60e51b8152600401620002309062000ded565b6001600160a01b038085166000908152600260205260409020541680620008095760405162461bcd60e51b815260206004820152603560248201527f436f6c6c61746572616c506f6f6c466163746f72793a20636f6c6c61746572616044820152741b081c1bdbdb08191bd95cc81b9bdd08195e1a5cdd605a1b606482015260840162000230565b6003548410620008715760405162461bcd60e51b815260206004820152602c60248201527f436f6c6c61746572616c506f6f6c466163746f72793a20696e6465782069732060448201526b6f7574206f662072616e676560a01b606482015260840162000230565b600384815481106200089357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b038281169116146200090f5760405162461bcd60e51b815260206004820152602b60248201527f436f6c6c61746572616c506f6f6c466163746f72793a20696e6465782069732060448201526a1b9bdd0818dbdc9c9958dd60aa1b606482015260840162000230565b6001600160a01b038516600090815260026020526040902080546001600160a01b0319169055620009408462000a30565b806001600160a01b0316856001600160a01b03167fc32b19b2496954379b1aca293ceef03a9f78ec6bd7114c2e7a82dfa6c33017a360405160405180910390a3505060018080559392505050565b6000546001600160a01b03163314620009bb5760405162461bcd60e51b8152600401620002309062000ded565b6001600160a01b03811662000a225760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000230565b62000a2d8162000b17565b50565b6003600162000a3e60035490565b62000a4a919062000e22565b8154811062000a6957634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600380546001600160a01b03909216918390811062000aa457634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600380548062000af257634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905550565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611b948062000e9083390190565b80356001600160a01b0381168114620001d357600080fd5b60006020828403121562000b9f578081fd5b62000baa8262000b75565b9392505050565b6000806040838503121562000bc4578081fd5b62000bcf8362000b75565b946020939093013593505050565b60006020828403121562000bef578081fd5b815167ffffffffffffffff8082111562000c07578283fd5b818401915084601f83011262000c1b578283fd5b81518181111562000c305762000c3062000e79565b604051601f8201601f19908116603f0116810190838211818310171562000c5b5762000c5b62000e79565b8160405282815287602084870101111562000c74578586fd5b62000c8783602083016020880162000e46565b979650505050505050565b60006020828403121562000ca4578081fd5b5035919050565b6000815180845262000cc581602086016020860162000e46565b601f01601f19169290920160200192915050565b6000825162000ced81846020870162000e46565b61043560f41b920191825250600201919050565b6000825162000d1581846020870162000e46565b602d60f81b9201918252506e10dbdb1b185d195c985b0b541bdbdb608a1b6001820152601001919050565b60006080825262000d55608083018762000cab565b828103602084015262000d69818762000cab565b6001600160a01b0395909516604084015250506060015292915050565b60006040825262000d9b604083018562000cab565b90508260208301529392505050565b60208082526023908201527f436f6c6c61746572616c506f6f6c466163746f72793a207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008282101562000e4157634e487b7160e01b81526011600452602481fd5b500390565b60005b8381101562000e6357818101518382015260200162000e49565b8381111562000e73576000848401525b50505050565b634e487b7160e01b600052604160045260246000fdfe60806040523480156200001157600080fd5b5060405162001b9438038062001b94833981016040819052620000349162000351565b8351849084906200004d906003906020850190620001f8565b50805162000063906004906020840190620001f8565b505050620000806200007a620000b560201b60201c565b620000b9565b6001600655600780546001600160a01b0319166001600160a01b038416179055620000ab816200010b565b5050505062000433565b3390565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8060008111620001625760405162461bcd60e51b815260206004820152601a60248201527f436f6c6c61746572616c506f6f6c3a207a65726f2076616c756500000000000060448201526064015b60405180910390fd5b60085460408051918252602082018490527f0fab315f9afe740b3379e4b31444de1a4bcd656591a311349a83cd3297434546910160405180910390a1612710821015620001f25760405162461bcd60e51b815260206004820152601960248201527f436f6c6c61746572616c506f6f6c3a204352206973206c6f7700000000000000604482015260640162000159565b50600855565b8280546200020690620003e0565b90600052602060002090601f0160209004810192826200022a576000855562000275565b82601f106200024557805160ff191683800117855562000275565b8280016001018555821562000275579182015b828111156200027557825182559160200191906001019062000258565b506200028392915062000287565b5090565b5b8082111562000283576000815560010162000288565b600082601f830112620002af578081fd5b81516001600160401b0380821115620002cc57620002cc6200041d565b604051601f8301601f19908116603f01168101908282118183101715620002f757620002f76200041d565b8160405283815260209250868385880101111562000313578485fd5b8491505b8382101562000336578582018301518183018401529082019062000317565b838211156200034757848385830101525b9695505050505050565b6000806000806080858703121562000367578384fd5b84516001600160401b03808211156200037e578586fd5b6200038c888389016200029e565b95506020870151915080821115620003a2578485fd5b50620003b1878288016200029e565b604087015190945090506001600160a01b0381168114620003d0578283fd5b6060959095015193969295505050565b600281046001821680620003f557607f821691505b602082108114156200041757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b61175180620004436000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063a9059cbb1161007c578063a9059cbb1461029a578063b2016bd4146102ad578063dcaf9c44146102c0578063dd62ed3e146102c9578063e5829d2014610302578063f2fde38b1461031557610142565b8063715018a6146102485780638da5cb5b1461025257806395d89b41146102775780639840c0511461027f578063a457c2d71461028757610142565b8063313ce5671161010a578063313ce567146101c45780633237c158146101d3578063392f2ddd146101e657806339509351146101f95780636d75b9ee1461020c57806370a082311461021f57610142565b806306fdde0314610147578063095ea7b31461016557806313f5a46e1461018857806318160ddd146101a957806323b872dd146101b1575b600080fd5b61014f610328565b60405161015c91906114fe565b60405180910390f35b610178610173366004611469565b6103ba565b604051901515815260200161015c565b61019b6101963660046114b2565b6103d0565b60405190815260200161015c565b60025461019b565b6101786101bf36600461142e565b610450565b6040516012815260200161015c565b6101786101e13660046114b2565b6104fc565b61019b6101f43660046114b2565b610674565b610178610207366004611469565b6106d0565b61017861021a366004611469565b61070c565b61019b61022d3660046113e2565b6001600160a01b031660009081526020819052604090205490565b610250610890565b005b6005546001600160a01b03165b6040516001600160a01b03909116815260200161015c565b61014f6108bc565b61019b6108cb565b610178610295366004611469565b61094c565b6101786102a8366004611469565b6109e5565b60075461025f906001600160a01b031681565b61019b60085481565b61019b6102d73660046113fc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102506103103660046114b2565b6109f2565b6102506103233660046113e2565b610a28565b606060038054610337906116ca565b80601f0160208091040260200160405190810160405280929190818152602001828054610363906116ca565b80156103b05780601f10610385576101008083540402835291602001916103b0565b820191906000526020600020905b81548152906001019060200180831161039357829003601f168201915b5050505050905090565b60006103c7338484610ac0565b50600192915050565b6000806103db6108cb565b116104015760405162461bcd60e51b81526004016103f890611531565b60405180910390fd5b8161040a6108cb565b10156104285760405162461bcd60e51b81526004016103f890611579565b6104306108cb565b6002545b61043e9084611668565b6104489190611648565b90505b919050565b600061045d848484610be5565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156104e25760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084016103f8565b6104ef8533858403610ac0565b60019150505b9392505050565b6000816000811161051f5760405162461bcd60e51b81526004016103f8906115f9565b600260065414156105725760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103f8565b6002600655826105813361022d565b10156105dd5760405162461bcd60e51b815260206004820152602560248201527f436f6c6c61746572616c506f6f6c3a2062616c616e6365206973206e6f7420656044820152640dcdeeaced60db1b60648201526084016103f8565b60006105e860025490565b6105f06108cb565b6105fa9086611668565b6106049190611648565b90506106103385610db5565b610627336007546001600160a01b03169083610f00565b6040805182815260208101869052339182917f37c4d2e6036e28a1f1ed3eed26620e1e370df577673d4eb2decef5d3ea44a949910160405180910390a36001925050506001600655919050565b60008061068060025490565b1161069d5760405162461bcd60e51b81526004016103f890611531565b816106a760025490565b10156106c55760405162461bcd60e51b81526004016103f890611579565b6002546104346108cb565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916103c7918590610707908690611630565b610ac0565b6000826001600160a01b0381166107655760405162461bcd60e51b815260206004820152601c60248201527f436f6c6c61746572616c506f6f6c3a207a65726f20616464726573730000000060448201526064016103f8565b82600081116107865760405162461bcd60e51b81526004016103f8906115f9565b600260065414156107d95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103f8565b600260065560006107e960025490565b6107f4575083610816565b6107fc6108cb565b6002546108099087611668565b6108139190611648565b90505b61082e336007546001600160a01b0316903088610f63565b6108388682610f9b565b60408051868152602081018390526001600160a01b0388169133917f33a089d94f9a0b7d0fe21e69b40d7dbe1965be652c7382cc778d46963db8c49b910160405180910390a360019350505050600160065592915050565b6005546001600160a01b031633146108ba5760405162461bcd60e51b81526004016103f8906115c4565b565b606060048054610337906116ca565b6007546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561090f57600080fd5b505afa158015610923573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094791906114ca565b905090565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156109ce5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103f8565b6109db3385858403610ac0565b5060019392505050565b60006103c7338484610be5565b6005546001600160a01b03163314610a1c5760405162461bcd60e51b81526004016103f8906115c4565b610a258161107a565b50565b6005546001600160a01b03163314610a525760405162461bcd60e51b81526004016103f8906115c4565b6001600160a01b038116610ab75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103f8565b610a258161112f565b6001600160a01b038316610b225760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103f8565b6001600160a01b038216610b835760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103f8565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c495760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103f8565b6001600160a01b038216610cab5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103f8565b6001600160a01b03831660009081526020819052604090205481811015610d235760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103f8565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610d5a908490611630565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610da691815260200190565b60405180910390a35b50505050565b6001600160a01b038216610e155760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016103f8565b6001600160a01b03821660009081526020819052604090205481811015610e895760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016103f8565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610eb8908490611687565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610bd8565b505050565b6040516001600160a01b038316602482015260448101829052610efb90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611181565b6040516001600160a01b0380851660248301528316604482015260648101829052610daf9085906323b872dd60e01b90608401610f2c565b6001600160a01b038216610ff15760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016103f8565b80600260008282546110039190611630565b90915550506001600160a01b03821660009081526020819052604081208054839290611030908490611630565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b806000811161109b5760405162461bcd60e51b81526004016103f8906115f9565b60085460408051918252602082018490527f0fab315f9afe740b3379e4b31444de1a4bcd656591a311349a83cd3297434546910160405180910390a16127108210156111295760405162461bcd60e51b815260206004820152601960248201527f436f6c6c61746572616c506f6f6c3a204352206973206c6f770000000000000060448201526064016103f8565b50600855565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006111d6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112539092919063ffffffff16565b805190915015610efb57808060200190518101906111f49190611492565b610efb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103f8565b6060611262848460008561126a565b949350505050565b6060824710156112cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103f8565b843b6113195760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103f8565b600080866001600160a01b0316858760405161133591906114e2565b60006040518083038185875af1925050503d8060008114611372576040519150601f19603f3d011682016040523d82523d6000602084013e611377565b606091505b5091509150611387828286611392565b979650505050505050565b606083156113a15750816104f5565b8251156113b15782518084602001fd5b8160405162461bcd60e51b81526004016103f891906114fe565b80356001600160a01b038116811461044b57600080fd5b6000602082840312156113f3578081fd5b6104f5826113cb565b6000806040838503121561140e578081fd5b611417836113cb565b9150611425602084016113cb565b90509250929050565b600080600060608486031215611442578081fd5b61144b846113cb565b9250611459602085016113cb565b9150604084013590509250925092565b6000806040838503121561147b578182fd5b611484836113cb565b946020939093013593505050565b6000602082840312156114a3578081fd5b815180151581146104f5578182fd5b6000602082840312156114c3578081fd5b5035919050565b6000602082840312156114db578081fd5b5051919050565b600082516114f481846020870161169e565b9190910192915050565b600060208252825180602084015261151d81604085016020870161169e565b601f01601f19169190910160400192915050565b60208082526028908201527f436f6c6c61746572616c506f6f6c3a20636f6c6c61746572616c20706f6f6c20604082015267697320656d70747960c01b606082015260800190565b6020808252602b908201527f436f6c6c61746572616c506f6f6c3a206c6971756964697479206973206e6f7460408201526a081cdd59999a58da595b9d60aa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601a908201527f436f6c6c61746572616c506f6f6c3a207a65726f2076616c7565000000000000604082015260600190565b6000821982111561164357611643611705565b500190565b60008261166357634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561168257611682611705565b500290565b60008282101561169957611699611705565b500390565b60005b838110156116b95781810151838201526020016116a1565b83811115610daf5750506000910152565b6002810460018216806116de57607f821691505b602082108114156116ff57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212204017e518134ffbdba334ee379b30e6c86d2fdc4bd6c2ca8e1ca3db7a09d4a9e764736f6c63430008020033a2646970667358221220b7041bae27d1f07d9a8d25eb5446496bc2f495cd34c3e7471406a1d36d1232ef64736f6c63430008020033
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.