Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Sponsored
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 13097274 | 836 days 20 hrs ago | IN | Create: MigratedTranchedPool | 0 ETH | 0.59343231 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
MigratedTranchedPool
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./TranchedPool.sol"; import "../../interfaces/IV1CreditLine.sol"; import "../../interfaces/IMigratedTranchedPool.sol"; contract MigratedTranchedPool is TranchedPool, IMigratedTranchedPool { bool public migrated; function migrateCreditLineToV2( IV1CreditLine clToMigrate, uint256 termEndTime, uint256 nextDueTime, uint256 interestAccruedAsOf, uint256 lastFullPaymentTime, uint256 totalInterestPaid ) external override returns (IV2CreditLine) { require(msg.sender == config.creditDeskAddress(), "Only credit desk can call this"); require(!migrated, "Already migrated"); // Set accounting state vars. IV2CreditLine newCl = creditLine; newCl.setBalance(clToMigrate.balance()); newCl.setInterestOwed(clToMigrate.interestOwed()); newCl.setPrincipalOwed(clToMigrate.principalOwed()); newCl.setTermEndTime(termEndTime); newCl.setNextDueTime(nextDueTime); newCl.setInterestAccruedAsOf(interestAccruedAsOf); newCl.setLastFullPaymentTime(lastFullPaymentTime); newCl.setTotalInterestAccrued(totalInterestPaid.add(clToMigrate.interestOwed())); migrateDeposits(clToMigrate, totalInterestPaid); migrated = true; return newCl; } function migrateDeposits(IV1CreditLine clToMigrate, uint256 totalInterestPaid) internal { // Mint junior tokens to the SeniorPool, equal to current cl balance; require(!locked(), "Pool has been locked"); // Hardcode to always get the JuniorTranche, since the migration case is when // the senior pool took the entire investment. Which we're expressing as the junior tranche uint256 tranche = uint256(ITranchedPool.Tranches.Junior); TrancheInfo storage trancheInfo = getTrancheInfo(tranche); require(trancheInfo.lockedUntil == 0, "Tranche has been locked"); trancheInfo.principalDeposited = clToMigrate.limit(); IPoolTokens.MintParams memory params = IPoolTokens.MintParams({ tranche: tranche, principalAmount: trancheInfo.principalDeposited }); IPoolTokens poolTokens = config.getPoolTokens(); uint256 tokenId = poolTokens.mint(params, config.seniorPoolAddress()); uint256 balancePaid = creditLine.limit().sub(creditLine.balance()); // Account for the implicit redemptions already made by the Legacy Pool _lockJuniorCapital(); _lockPool(); juniorTranche.lockedUntil = block.timestamp - 1; poolTokens.redeem(tokenId, balancePaid, totalInterestPaid); // Simulate the drawdown juniorTranche.principalSharePrice = 0; seniorTranche.principalSharePrice = 0; // Set junior's sharePrice correctly applyToTrancheByAmount(totalInterestPaid, balancePaid, totalInterestPaid, balancePaid, juniorTranche); } }
pragma solidity ^0.6.0; import "../Initializable.sol"; /* * @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 GSN 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. */ contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; }
pragma solidity ^0.6.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; import "../Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, _msgSender())); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. */ abstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; }
pragma solidity ^0.6.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
pragma solidity ^0.6.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev 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, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
pragma solidity ^0.6.0; /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Multiplies two signed integers, reverts on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Subtracts two signed integers, reverts on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Adds two signed integers, reverts on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } }
pragma solidity ^0.6.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); }
pragma solidity ^0.6.2; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } }
pragma solidity ^0.6.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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */ 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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(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(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(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(uint256(_at(set._inner, index))); } // 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 on 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)); } }
pragma solidity ^0.6.0; import "../GSN/Context.sol"; import "../Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ contract PausableUpgradeSafe is Initializable, ContextUpgradeSafe { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
pragma solidity ^0.6.0; import "../Initializable.sol"; /** * @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]. */ contract ReentrancyGuardUpgradeSafe is Initializable { bool private _notEntered; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { // Storing an initial 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 percetange 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. _notEntered = true; } /** * @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(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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: AGPL-3.0-only // solhint-disable // Imported from https://github.com/UMAprotocol/protocol/blob/4d1c8cc47a4df5e79f978cb05647a7432e111a3d/packages/core/contracts/common/implementation/FixedPoint.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SignedSafeMath.sol"; /** * @title Library for fixed point arithmetic on uints */ library FixedPoint { using SafeMath for uint256; using SignedSafeMath for int256; // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For unsigned values: // This can represent a value up to (2^256 - 1)/10^18 = ~10^59. 10^59 will be stored internally as uint256 10^77. uint256 private constant FP_SCALING_FACTOR = 10**18; // --------------------------------------- UNSIGNED ----------------------------------------------------------------------------- struct Unsigned { uint256 rawValue; } /** * @notice Constructs an `Unsigned` from an unscaled uint, e.g., `b=5` gets stored internally as `5**18`. * @param a uint to convert into a FixedPoint. * @return the converted FixedPoint. */ function fromUnscaledUint(uint256 a) internal pure returns (Unsigned memory) { return Unsigned(a.mul(FP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if equal, or False. */ function isEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if equal, or False. */ function isEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the minimum of `a` and `b`. */ function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the maximum of `a` and `b`. */ function max(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Unsigned` to an unscaled uint, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return add(a, fromUnscaledUint(b)); } /** * @notice Subtracts two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled uint256 from an `Unsigned`, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return sub(a, fromUnscaledUint(b)); } /** * @notice Subtracts an `Unsigned` from an unscaled uint256, reverting on overflow. * @param a a uint256. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return sub(fromUnscaledUint(a), b); } /** * @notice Multiplies two `Unsigned`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as a uint256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because FP_SCALING_FACTOR != 0. return Unsigned(a.rawValue.mul(b.rawValue) / FP_SCALING_FACTOR); } /** * @notice Multiplies an `Unsigned` and an unscaled uint256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a uint256. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.mul(b)); } /** * @notice Multiplies two `Unsigned`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 mulRaw = a.rawValue.mul(b.rawValue); uint256 mulFloor = mulRaw / FP_SCALING_FACTOR; uint256 mod = mulRaw.mod(FP_SCALING_FACTOR); if (mod != 0) { return Unsigned(mulFloor.add(1)); } else { return Unsigned(mulFloor); } } /** * @notice Multiplies an `Unsigned` and an unscaled uint256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Unsigned(a.rawValue.mul(b)); } /** * @notice Divides one `Unsigned` by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as a uint256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Unsigned(a.rawValue.mul(FP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Unsigned` by an unscaled uint256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.div(b)); } /** * @notice Divides one unscaled uint256 by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a uint256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return div(fromUnscaledUint(a), b); } /** * @notice Divides one `Unsigned` by an `Unsigned` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 aScaled = a.rawValue.mul(FP_SCALING_FACTOR); uint256 divFloor = aScaled.div(b.rawValue); uint256 mod = aScaled.mod(b.rawValue); if (mod != 0) { return Unsigned(divFloor.add(1)); } else { return Unsigned(divFloor); } } /** * @notice Divides one `Unsigned` by an unscaled uint256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Because it is possible that a quotient gets truncated, we can't just call "Unsigned(a.rawValue.div(b))" // similarly to mulCeil with a uint256 as the second parameter. Therefore we need to convert b into an Unsigned. // This creates the possibility of overflow if b is very large. return divCeil(a, fromUnscaledUint(b)); } /** * @notice Raises an `Unsigned` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return output is `a` to the power of `b`. */ function pow(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory output) { output = fromUnscaledUint(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } // ------------------------------------------------- SIGNED ------------------------------------------------------------- // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For signed values: // This can represent a value up (or down) to +-(2^255 - 1)/10^18 = ~10^58. 10^58 will be stored internally as int256 10^76. int256 private constant SFP_SCALING_FACTOR = 10**18; struct Signed { int256 rawValue; } function fromSigned(Signed memory a) internal pure returns (Unsigned memory) { require(a.rawValue >= 0, "Negative value provided"); return Unsigned(uint256(a.rawValue)); } function fromUnsigned(Unsigned memory a) internal pure returns (Signed memory) { require(a.rawValue <= uint256(type(int256).max), "Unsigned too large"); return Signed(int256(a.rawValue)); } /** * @notice Constructs a `Signed` from an unscaled int, e.g., `b=5` gets stored internally as `5**18`. * @param a int to convert into a FixedPoint.Signed. * @return the converted FixedPoint.Signed. */ function fromUnscaledInt(int256 a) internal pure returns (Signed memory) { return Signed(a.mul(SFP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a int256. * @return True if equal, or False. */ function isEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if equal, or False. */ function isEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the minimum of `a` and `b`. */ function min(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the maximum of `a` and `b`. */ function max(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the sum of `a` and `b`. */ function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Signed` to an unscaled int, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the sum of `a` and `b`. */ function add(Signed memory a, int256 b) internal pure returns (Signed memory) { return add(a, fromUnscaledInt(b)); } /** * @notice Subtracts two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled int256 from an `Signed`, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the difference of `a` and `b`. */ function sub(Signed memory a, int256 b) internal pure returns (Signed memory) { return sub(a, fromUnscaledInt(b)); } /** * @notice Subtracts an `Signed` from an unscaled int256, reverting on overflow. * @param a an int256. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(int256 a, Signed memory b) internal pure returns (Signed memory) { return sub(fromUnscaledInt(a), b); } /** * @notice Multiplies two `Signed`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mul(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as an int256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because SFP_SCALING_FACTOR != 0. return Signed(a.rawValue.mul(b.rawValue) / SFP_SCALING_FACTOR); } /** * @notice Multiplies an `Signed` and an unscaled int256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b an int256. * @return the product of `a` and `b`. */ function mul(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.mul(b)); } /** * @notice Multiplies two `Signed`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 mulRaw = a.rawValue.mul(b.rawValue); int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR; // Manual mod because SignedSafeMath doesn't support it. int256 mod = mulRaw % SFP_SCALING_FACTOR; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(mulTowardsZero.add(valueToAdd)); } else { return Signed(mulTowardsZero); } } /** * @notice Multiplies an `Signed` and an unscaled int256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Signed(a.rawValue.mul(b)); } /** * @notice Divides one `Signed` by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as an int256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Signed` by an unscaled int256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.div(b)); } /** * @notice Divides one unscaled int256 by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a an int256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(int256 a, Signed memory b) internal pure returns (Signed memory) { return div(fromUnscaledInt(a), b); } /** * @notice Divides one `Signed` by an `Signed` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 aScaled = a.rawValue.mul(SFP_SCALING_FACTOR); int256 divTowardsZero = aScaled.div(b.rawValue); // Manual mod because SignedSafeMath doesn't support it. int256 mod = aScaled % b.rawValue; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(divTowardsZero.add(valueToAdd)); } else { return Signed(divTowardsZero); } } /** * @notice Divides one `Signed` by an unscaled int256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Because it is possible that a quotient gets truncated, we can't just call "Signed(a.rawValue.div(b))" // similarly to mulCeil with an int256 as the second parameter. Therefore we need to convert b into an Signed. // This creates the possibility of overflow if b is very large. return divAwayFromZero(a, fromUnscaledInt(b)); } /** * @notice Raises an `Signed` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint.Signed. * @param b a uint256 (negative exponents are not allowed). * @return output is `a` to the power of `b`. */ function pow(Signed memory a, uint256 b) internal pure returns (Signed memory output) { output = fromUnscaledInt(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } }
// SPDX-License-Identifier: MIT // Taken from https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface ICUSDCContract is IERC20withDec { /*** User Interface ***/ function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, address cTokenCollateral ) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function balanceOfUnderlying(address owner) external returns (uint256); function exchangeRateCurrent() external returns (uint256); /*** Admin Functions ***/ function _addReserves(uint256 addAmount) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract ICreditDesk { uint256 public totalWritedowns; uint256 public totalLoansOutstanding; function setUnderwriterGovernanceLimit(address underwriterAddress, uint256 limit) external virtual; function drawdown(address creditLineAddress, uint256 amount) external virtual; function pay(address creditLineAddress, uint256 amount) external virtual; function assessCreditLine(address creditLineAddress) external virtual; function applyPayment(address creditLineAddress, uint256 amount) external virtual; function getNextPaymentAmount(address creditLineAddress, uint256 asOfBLock) external view virtual returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface ICreditLine { function borrower() external view returns (address); function limit() external view returns (uint256); function interestApr() external view returns (uint256); function paymentPeriodInDays() external view returns (uint256); function termInDays() external view returns (uint256); function lateFeeApr() external view returns (uint256); // Accounting variables function balance() external view returns (uint256); function interestOwed() external view returns (uint256); function principalOwed() external view returns (uint256); function termEndTime() external view returns (uint256); function nextDueTime() external view returns (uint256); function interestAccruedAsOf() external view returns (uint256); function lastFullPaymentTime() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; /* Only addition is the `decimals` function, which we need, and which both our Fidu and USDC use, along with most ERC20's. */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20withDec is IERC20 { /** * @dev Returns the number of decimals used for the token */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface IFidu is IERC20withDec { function mintTo(address to, uint256 amount) external; function burnFrom(address to, uint256 amount) external; function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchConfig { function getNumber(uint256 index) external returns (uint256); function getAddress(uint256 index) external returns (address); function setAddress(uint256 index, address newAddress) external returns (address); function setNumber(uint256 index, uint256 newNumber) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchFactory { function createCreditLine() external returns (address); function createBorrower(address owner) external returns (address); function createPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) external returns (address); function createMigratedPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) external returns (address); function updateGoldfinchConfig() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IV2CreditLine.sol"; import "./IV1CreditLine.sol"; import "./ITranchedPool.sol"; abstract contract IMigratedTranchedPool is ITranchedPool { function migrateCreditLineToV2( IV1CreditLine clToMigrate, uint256 termEndTime, uint256 nextDueTime, uint256 interestAccruedAsOf, uint256 lastFullPaymentTime, uint256 totalInterestPaid ) external virtual returns (IV2CreditLine); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract IPool { uint256 public sharePrice; function deposit(uint256 amount) external virtual; function withdraw(uint256 usdcAmount) external virtual; function withdrawInFidu(uint256 fiduAmount) external virtual; function collectInterestAndPrincipal( address from, uint256 interest, uint256 principal ) public virtual; function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool); function drawdown(address to, uint256 amount) public virtual returns (bool); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function distributeLosses(address creditlineAddress, int256 writedownDelta) external virtual; function assets() public view virtual returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721.sol"; interface IPoolTokens is IERC721 { event TokenMinted( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 amount, uint256 tranche ); event TokenRedeemed( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 principalRedeemed, uint256 interestRedeemed, uint256 tranche ); event TokenBurned(address indexed owner, address indexed pool, uint256 indexed tokenId); struct TokenInfo { address pool; uint256 tranche; uint256 principalAmount; uint256 principalRedeemed; uint256 interestRedeemed; } struct MintParams { uint256 principalAmount; uint256 tranche; } function mint(MintParams calldata params, address to) external returns (uint256); function redeem( uint256 tokenId, uint256 principalRedeemed, uint256 interestRedeemed ) external; function burn(uint256 tokenId) external; function onPoolCreated(address newPool) external; function getTokenInfo(uint256 tokenId) external view returns (TokenInfo memory); function validPool(address sender) external view returns (bool); function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ITranchedPool.sol"; abstract contract ISeniorPool { uint256 public sharePrice; uint256 public totalLoansOutstanding; uint256 public totalWritedowns; function deposit(uint256 amount) external virtual returns (uint256 depositShares); function depositWithPermit( uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 depositShares); function withdraw(uint256 usdcAmount) external virtual returns (uint256 amount); function withdrawInFidu(uint256 fiduAmount) external virtual returns (uint256 amount); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function invest(ITranchedPool pool) public virtual; function estimateInvestment(ITranchedPool pool) public view virtual returns (uint256); function investJunior(ITranchedPool pool, uint256 amount) public virtual; function redeem(uint256 tokenId) public virtual; function writedown(uint256 tokenId) public virtual; function calculateWritedown(uint256 tokenId) public view virtual returns (uint256 writedownAmount); function assets() public view virtual returns (uint256); function getNumShares(uint256 amount) public view virtual returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ISeniorPool.sol"; import "./ITranchedPool.sol"; abstract contract ISeniorPoolStrategy { function invest(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256 amount); function estimateInvestment(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IV2CreditLine.sol"; abstract contract ITranchedPool { IV2CreditLine public creditLine; uint256 public createdAt; enum Tranches {Reserved, Senior, Junior} struct TrancheInfo { uint256 id; uint256 principalDeposited; uint256 principalSharePrice; uint256 interestSharePrice; uint256 lockedUntil; } function initialize( address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public virtual; function getTranche(uint256 tranche) external view virtual returns (TrancheInfo memory); function pay(uint256 amount) external virtual; function lockJuniorCapital() external virtual; function lockPool() external virtual; function drawdown(uint256 amount) external virtual; function deposit(uint256 tranche, uint256 amount) external virtual returns (uint256 tokenId); function assess() external virtual; function depositWithPermit( uint256 tranche, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 tokenId); function availableToWithdraw(uint256 tokenId) external view virtual returns (uint256 interestRedeemable, uint256 principalRedeemable); function withdraw(uint256 tokenId, uint256 amount) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMax(uint256 tokenId) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMultiple(uint256[] calldata tokenIds, uint256[] calldata amounts) external virtual; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract IV1CreditLine { address public borrower; address public underwriter; uint256 public limit; uint256 public interestApr; uint256 public paymentPeriodInDays; uint256 public termInDays; uint256 public lateFeeApr; uint256 public balance; uint256 public interestOwed; uint256 public principalOwed; uint256 public termEndBlock; uint256 public nextDueBlock; uint256 public interestAccruedAsOfBlock; uint256 public writedownAmount; uint256 public lastFullPaymentBlock; function setLimit(uint256 newAmount) external virtual; function setBalance(uint256 newBalance) external virtual; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ICreditLine.sol"; abstract contract IV2CreditLine is ICreditLine { function principal() external view virtual returns (uint256); function totalInterestAccrued() external view virtual returns (uint256); function termStartTime() external view virtual returns (uint256); function setLimit(uint256 newAmount) external virtual; function setBalance(uint256 newBalance) external virtual; function setPrincipal(uint256 _principal) external virtual; function setTotalInterestAccrued(uint256 _interestAccrued) external virtual; function drawdown(uint256 amount) external virtual; function assess() external virtual returns ( uint256, uint256, uint256 ); function initialize( address _config, address owner, address _borrower, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public virtual; function setTermEndTime(uint256 newTermEndTime) external virtual; function setNextDueTime(uint256 newNextDueTime) external virtual; function setInterestOwed(uint256 newInterestOwed) external virtual; function setPrincipalOwed(uint256 newPrincipalOwed) external virtual; function setInterestAccruedAsOf(uint256 newInterestAccruedAsOf) external virtual; function setWritedownAmount(uint256 newWritedownAmount) external virtual; function setLastFullPaymentTime(uint256 newLastFullPaymentTime) external virtual; function setLateFeeApr(uint256 newLateFeeApr) external virtual; function updateGoldfinchConfig() external virtual; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; /** * @title Safe ERC20 Transfer * @notice Reverts when transfer is not successful * @author Goldfinch */ abstract contract SafeERC20Transfer { function safeERC20Transfer( IERC20 erc20, address to, uint256 amount, string memory message ) internal { require(to != address(0), "Can't send to zero address"); bool success = erc20.transfer(to, amount); require(success, message); } function safeERC20Transfer( IERC20 erc20, address to, uint256 amount ) internal { safeERC20Transfer(erc20, to, amount, "Failed to transfer ERC20"); } function safeERC20TransferFrom( IERC20 erc20, address from, address to, uint256 amount, string memory message ) internal { require(to != address(0), "Can't send to zero address"); bool success = erc20.transferFrom(from, to, amount); require(success, message); } function safeERC20TransferFrom( IERC20 erc20, address from, address to, uint256 amount ) internal { string memory message = "Failed to transfer ERC20"; safeERC20TransferFrom(erc20, from, to, amount, message); } function safeERC20Approve( IERC20 erc20, address spender, uint256 allowance, string memory message ) internal { bool success = erc20.approve(spender, allowance); require(success, message); } function safeERC20Approve( IERC20 erc20, address spender, uint256 allowance ) internal { string memory message = "Failed to approve ERC20"; safeERC20Approve(erc20, spender, allowance, message); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./PauserPausable.sol"; /** * @title BaseUpgradeablePausable contract * @notice This is our Base contract that most other contracts inherit from. It includes many standard * useful abilities like ugpradeability, pausability, access control, and re-entrancy guards. * @author Goldfinch */ contract BaseUpgradeablePausable is Initializable, AccessControlUpgradeSafe, PauserPausable, ReentrancyGuardUpgradeSafe { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); using SafeMath for uint256; // Pre-reserving a few slots in the base contract in case we need to add things in the future. // This does not actually take up gas cost or storage cost, but it does reserve the storage slots. // See OpenZeppelin's use of this pattern here: // https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/blob/master/contracts/GSN/Context.sol#L37 uint256[50] private __gap1; uint256[50] private __gap2; uint256[50] private __gap3; uint256[50] private __gap4; // solhint-disable-next-line func-name-mixedcase function __BaseUpgradeablePausable__init(address owner) public initializer { require(owner != address(0), "Owner cannot be the zero address"); __AccessControl_init_unchained(); __Pausable_init_unchained(); __ReentrancyGuard_init_unchained(); _setupRole(OWNER_ROLE, owner); _setupRole(PAUSER_ROLE, owner); _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); } function isAdmin() public view returns (bool) { return hasRole(OWNER_ROLE, _msgSender()); } modifier onlyAdmin() { require(isAdmin(), "Must have admin role to perform this action"); _; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./GoldfinchConfig.sol"; import "../../interfaces/IPool.sol"; import "../../interfaces/IFidu.sol"; import "../../interfaces/ISeniorPool.sol"; import "../../interfaces/ISeniorPoolStrategy.sol"; import "../../interfaces/ICreditDesk.sol"; import "../../interfaces/IERC20withDec.sol"; import "../../interfaces/ICUSDCContract.sol"; import "../../interfaces/IPoolTokens.sol"; import "../../interfaces/IGoldfinchFactory.sol"; /** * @title ConfigHelper * @notice A convenience library for getting easy access to other contracts and constants within the * protocol, through the use of the GoldfinchConfig contract * @author Goldfinch */ library ConfigHelper { function getPool(GoldfinchConfig config) internal view returns (IPool) { return IPool(poolAddress(config)); } function getSeniorPool(GoldfinchConfig config) internal view returns (ISeniorPool) { return ISeniorPool(seniorPoolAddress(config)); } function getSeniorPoolStrategy(GoldfinchConfig config) internal view returns (ISeniorPoolStrategy) { return ISeniorPoolStrategy(seniorPoolStrategyAddress(config)); } function getUSDC(GoldfinchConfig config) internal view returns (IERC20withDec) { return IERC20withDec(usdcAddress(config)); } function getCreditDesk(GoldfinchConfig config) internal view returns (ICreditDesk) { return ICreditDesk(creditDeskAddress(config)); } function getFidu(GoldfinchConfig config) internal view returns (IFidu) { return IFidu(fiduAddress(config)); } function getCUSDCContract(GoldfinchConfig config) internal view returns (ICUSDCContract) { return ICUSDCContract(cusdcContractAddress(config)); } function getPoolTokens(GoldfinchConfig config) internal view returns (IPoolTokens) { return IPoolTokens(poolTokensAddress(config)); } function getGoldfinchFactory(GoldfinchConfig config) internal view returns (IGoldfinchFactory) { return IGoldfinchFactory(goldfinchFactoryAddress(config)); } function oneInchAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.OneInch)); } function creditLineImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditLineImplementation)); } function trustedForwarderAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TrustedForwarder)); } function configAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchConfig)); } function poolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Pool)); } function poolTokensAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.PoolTokens)); } function seniorPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPool)); } function seniorPoolStrategyAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPoolStrategy)); } function creditDeskAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditDesk)); } function goldfinchFactoryAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchFactory)); } function fiduAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Fidu)); } function cusdcContractAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CUSDCContract)); } function usdcAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.USDC)); } function tranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TranchedPoolImplementation)); } function migratedTranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.MigratedTranchedPoolImplementation)); } function reserveAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TreasuryReserve)); } function protocolAdminAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.ProtocolAdmin)); } function borrowerImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.BorrowerImplementation)); } function getReserveDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.ReserveDenominator)); } function getWithdrawFeeDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.WithdrawFeeDenominator)); } function getLatenessGracePeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessGracePeriodInDays)); } function getLatenessMaxDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessMaxDays)); } function getDrawdownPeriodInSeconds(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.DrawdownPeriodInSeconds)); } function getTransferRestrictionPeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.TransferRestrictionPeriodInDays)); } function getLeverageRatio(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LeverageRatio)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; /** * @title ConfigOptions * @notice A central place for enumerating the configurable options of our GoldfinchConfig contract * @author Goldfinch */ library ConfigOptions { // NEVER EVER CHANGE THE ORDER OF THESE! // You can rename or append. But NEVER change the order. enum Numbers { TransactionLimit, TotalFundsLimit, MaxUnderwriterLimit, ReserveDenominator, WithdrawFeeDenominator, LatenessGracePeriodInDays, LatenessMaxDays, DrawdownPeriodInSeconds, TransferRestrictionPeriodInDays, LeverageRatio } enum Addresses { Pool, CreditLineImplementation, GoldfinchFactory, CreditDesk, Fidu, USDC, TreasuryReserve, ProtocolAdmin, OneInch, TrustedForwarder, CUSDCContract, GoldfinchConfig, PoolTokens, TranchedPoolImplementation, SeniorPool, SeniorPoolStrategy, MigratedTranchedPoolImplementation, BorrowerImplementation } function getNumberName(uint256 number) public pure returns (string memory) { Numbers numberName = Numbers(number); if (Numbers.TransactionLimit == numberName) { return "TransactionLimit"; } if (Numbers.TotalFundsLimit == numberName) { return "TotalFundsLimit"; } if (Numbers.MaxUnderwriterLimit == numberName) { return "MaxUnderwriterLimit"; } if (Numbers.ReserveDenominator == numberName) { return "ReserveDenominator"; } if (Numbers.WithdrawFeeDenominator == numberName) { return "WithdrawFeeDenominator"; } if (Numbers.LatenessGracePeriodInDays == numberName) { return "LatenessGracePeriodInDays"; } if (Numbers.LatenessMaxDays == numberName) { return "LatenessMaxDays"; } if (Numbers.DrawdownPeriodInSeconds == numberName) { return "DrawdownPeriodInSeconds"; } if (Numbers.TransferRestrictionPeriodInDays == numberName) { return "TransferRestrictionPeriodInDays"; } if (Numbers.LeverageRatio == numberName) { return "LeverageRatio"; } revert("Unknown value passed to getNumberName"); } function getAddressName(uint256 addressKey) public pure returns (string memory) { Addresses addressName = Addresses(addressKey); if (Addresses.Pool == addressName) { return "Pool"; } if (Addresses.CreditLineImplementation == addressName) { return "CreditLineImplementation"; } if (Addresses.GoldfinchFactory == addressName) { return "GoldfinchFactory"; } if (Addresses.CreditDesk == addressName) { return "CreditDesk"; } if (Addresses.Fidu == addressName) { return "Fidu"; } if (Addresses.USDC == addressName) { return "USDC"; } if (Addresses.TreasuryReserve == addressName) { return "TreasuryReserve"; } if (Addresses.ProtocolAdmin == addressName) { return "ProtocolAdmin"; } if (Addresses.OneInch == addressName) { return "OneInch"; } if (Addresses.TrustedForwarder == addressName) { return "TrustedForwarder"; } if (Addresses.CUSDCContract == addressName) { return "CUSDCContract"; } if (Addresses.PoolTokens == addressName) { return "PoolTokens"; } if (Addresses.TranchedPoolImplementation == addressName) { return "TranchedPoolImplementation"; } if (Addresses.SeniorPool == addressName) { return "SeniorPool"; } if (Addresses.SeniorPoolStrategy == addressName) { return "SeniorPoolStrategy"; } if (Addresses.MigratedTranchedPoolImplementation == addressName) { return "MigratedTranchedPoolImplementation"; } if (Addresses.BorrowerImplementation == addressName) { return "BorrowerImplementation"; } revert("Unknown value passed to getAddressName"); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./BaseUpgradeablePausable.sol"; import "../../interfaces/IGoldfinchConfig.sol"; import "./ConfigOptions.sol"; /** * @title GoldfinchConfig * @notice This contract stores mappings of useful "protocol config state", giving a central place * for all other contracts to access it. For example, the TransactionLimit, or the PoolAddress. These config vars * are enumerated in the `ConfigOptions` library, and can only be changed by admins of the protocol. * Note: While this inherits from BaseUpgradeablePausable, it is not deployed as an upgradeable contract (this * is mostly to save gas costs of having each call go through a proxy) * @author Goldfinch */ contract GoldfinchConfig is BaseUpgradeablePausable { bytes32 public constant GO_LISTER_ROLE = keccak256("GO_LISTER_ROLE"); mapping(uint256 => address) public addresses; mapping(uint256 => uint256) public numbers; mapping(address => bool) public goList; event AddressUpdated(address owner, uint256 index, address oldValue, address newValue); event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue); event GoListed(address indexed member); event NoListed(address indexed member); bool public valuesInitialized; function initialize(address owner) public initializer { require(owner != address(0), "Owner address cannot be empty"); __BaseUpgradeablePausable__init(owner); _setupRole(GO_LISTER_ROLE, owner); _setRoleAdmin(GO_LISTER_ROLE, OWNER_ROLE); } function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin { require(addresses[addressIndex] == address(0), "Address has already been initialized"); emit AddressUpdated(msg.sender, addressIndex, addresses[addressIndex], newAddress); addresses[addressIndex] = newAddress; } function setNumber(uint256 index, uint256 newNumber) public onlyAdmin { emit NumberUpdated(msg.sender, index, numbers[index], newNumber); numbers[index] = newNumber; } function setTreasuryReserve(address newTreasuryReserve) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.TreasuryReserve); emit AddressUpdated(msg.sender, key, addresses[key], newTreasuryReserve); addresses[key] = newTreasuryReserve; } function setSeniorPoolStrategy(address newStrategy) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.SeniorPoolStrategy); emit AddressUpdated(msg.sender, key, addresses[key], newStrategy); addresses[key] = newStrategy; } function setCreditLineImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.CreditLineImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setBorrowerImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.BorrowerImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setGoldfinchConfig(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.GoldfinchConfig); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function initializeFromOtherConfig(address _initialConfig) public onlyAdmin { require(!valuesInitialized, "Already initialized values"); IGoldfinchConfig initialConfig = IGoldfinchConfig(_initialConfig); for (uint256 i = 0; i < 10; i++) { setNumber(i, initialConfig.getNumber(i)); } for (uint256 i = 0; i < 11; i++) { if (getAddress(i) == address(0)) { setAddress(i, initialConfig.getAddress(i)); } } valuesInitialized = true; } /** * @dev Adds a user to go-list * @param _member address to add to go-list */ function addToGoList(address _member) public onlyGoListerRole { goList[_member] = true; emit GoListed(_member); } /** * @dev removes a user from go-list * @param _member address to remove from go-list */ function removeFromGoList(address _member) public onlyGoListerRole { goList[_member] = false; emit NoListed(_member); } /** * @dev adds many users to go-list at once * @param _members addresses to ad to go-list */ function bulkAddToGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { addToGoList(_members[i]); } } /** * @dev removes many users from go-list at once * @param _members addresses to remove from go-list */ function bulkRemoveFromGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { removeFromGoList(_members[i]); } } /* Using custom getters in case we want to change underlying implementation later, or add checks or validations later on. */ function getAddress(uint256 index) public view returns (address) { return addresses[index]; } function getNumber(uint256 index) public view returns (uint256) { return numbers[index]; } modifier onlyGoListerRole() { require(hasRole(GO_LISTER_ROLE, _msgSender()), "Must have go-lister role to perform this action"); _; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; /** * @title PauserPausable * @notice Inheriting from OpenZeppelin's Pausable contract, this does small * augmentations to make it work with a PAUSER_ROLE, leveraging the AccessControl contract. * It is meant to be inherited. * @author Goldfinch */ contract PauserPausable is AccessControlUpgradeSafe, PausableUpgradeSafe { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); // solhint-disable-next-line func-name-mixedcase function __PauserPausable__init() public initializer { __Pausable_init_unchained(); } /** * @dev Pauses all functions guarded by Pause * * See {Pausable-_pause}. * * Requirements: * * - the caller must have the PAUSER_ROLE. */ function pause() public onlyPauserRole { _pause(); } /** * @dev Unpauses the contract * * See {Pausable-_unpause}. * * Requirements: * * - the caller must have the Pauser role */ function unpause() public onlyPauserRole { _unpause(); } modifier onlyPauserRole() { require(hasRole(PAUSER_ROLE, _msgSender()), "Must have pauser role to perform this action"); _; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/drafts/IERC20Permit.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/Math.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "../../interfaces/ITranchedPool.sol"; import "../../interfaces/IERC20withDec.sol"; import "../../interfaces/IV2CreditLine.sol"; import "../../interfaces/IPoolTokens.sol"; import "./GoldfinchConfig.sol"; import "./BaseUpgradeablePausable.sol"; import "./ConfigHelper.sol"; import "../../external/FixedPoint.sol"; import "../../library/SafeERC20Transfer.sol"; contract TranchedPool is BaseUpgradeablePausable, ITranchedPool, SafeERC20Transfer { GoldfinchConfig public config; using ConfigHelper for GoldfinchConfig; using FixedPoint for FixedPoint.Unsigned; using FixedPoint for uint256; bytes32 public constant LOCKER_ROLE = keccak256("LOCKER_ROLE"); uint256 public constant FP_SCALING_FACTOR = 1e18; uint256 public constant SECONDS_PER_DAY = 60 * 60 * 24; uint256 public constant ONE_HUNDRED = 100; // Need this because we cannot call .div on a literal 100 uint256 public juniorFeePercent; bool public drawdownsPaused; TrancheInfo internal seniorTranche; TrancheInfo internal juniorTranche; event DepositMade(address indexed owner, uint256 indexed tranche, uint256 indexed tokenId, uint256 amount); event WithdrawalMade( address indexed owner, uint256 indexed tranche, uint256 indexed tokenId, uint256 interestWithdrawn, uint256 principalWithdrawn ); event PaymentApplied( address indexed payer, address indexed pool, uint256 interestAmount, uint256 principalAmount, uint256 remainingAmount, uint256 reserveAmount ); event SharePriceUpdated( address indexed pool, uint256 indexed tranche, uint256 principalSharePrice, int256 principalDelta, uint256 interestSharePrice, int256 interestDelta ); event ReserveFundsCollected(address indexed from, uint256 amount); event CreditLineMigrated(address indexed oldCreditLine, address indexed newCreditLine); event DrawdownMade(address indexed borrower, uint256 amount); event DrawdownsPaused(address indexed pool); event DrawdownsUnpaused(address indexed pool); event EmergencyShutdown(address indexed pool); function initialize( address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public override initializer { require( address(_config) != address(0) && address(_borrower) != address(0), "Config and borrower addresses cannot be empty" ); config = GoldfinchConfig(_config); address owner = config.protocolAdminAddress(); require(owner != address(0), "Owner address cannot be empty"); __BaseUpgradeablePausable__init(owner); seniorTranche = TrancheInfo({ id: uint256(ITranchedPool.Tranches.Senior), principalSharePrice: usdcToSharePrice(1, 1), interestSharePrice: 0, principalDeposited: 0, lockedUntil: 0 }); juniorTranche = TrancheInfo({ id: uint256(ITranchedPool.Tranches.Junior), principalSharePrice: usdcToSharePrice(1, 1), interestSharePrice: 0, principalDeposited: 0, lockedUntil: 0 }); createAndSetCreditLine(_borrower, _limit, _interestApr, _paymentPeriodInDays, _termInDays, _lateFeeApr); createdAt = block.timestamp; juniorFeePercent = _juniorFeePercent; _setupRole(LOCKER_ROLE, _borrower); _setupRole(LOCKER_ROLE, owner); _setRoleAdmin(LOCKER_ROLE, OWNER_ROLE); // Unlock self for infinite amount bool success = config.getUSDC().approve(address(this), uint256(-1)); require(success, "Failed to approve USDC"); } /** * @notice Deposit a USDC amount into the pool for a tranche. Mints an NFT to the caller representing the position * @param tranche The number representing the tranche to deposit into * @param amount The USDC amount to tranfer from the caller to the pool * @return tokenId The tokenId of the NFT */ function deposit(uint256 tranche, uint256 amount) public override nonReentrant whenNotPaused returns (uint256 tokenId) { TrancheInfo storage trancheInfo = getTrancheInfo(tranche); require(trancheInfo.lockedUntil == 0, "Tranche has been locked"); trancheInfo.principalDeposited = trancheInfo.principalDeposited.add(amount); IPoolTokens.MintParams memory params = IPoolTokens.MintParams({tranche: tranche, principalAmount: amount}); tokenId = config.getPoolTokens().mint(params, msg.sender); safeERC20TransferFrom(config.getUSDC(), msg.sender, address(this), amount); emit DepositMade(msg.sender, tranche, tokenId, amount); return tokenId; } function depositWithPermit( uint256 tranche, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public override returns (uint256 tokenId) { IERC20Permit(config.usdcAddress()).permit(msg.sender, address(this), amount, deadline, v, r, s); return deposit(tranche, amount); } /** * @notice Withdraw an already deposited amount if the funds are available * @param tokenId The NFT representing the position * @param amount The amount to withdraw (must be <= interest+principal currently available to withdraw) * @return interestWithdrawn The interest amount that was withdrawn * @return principalWithdrawn The principal amount that was withdrawn */ function withdraw(uint256 tokenId, uint256 amount) public override onlyTokenHolder(tokenId) nonReentrant whenNotPaused returns (uint256 interestWithdrawn, uint256 principalWithdrawn) { IPoolTokens.TokenInfo memory tokenInfo = config.getPoolTokens().getTokenInfo(tokenId); TrancheInfo storage trancheInfo = getTrancheInfo(tokenInfo.tranche); return _withdraw(trancheInfo, tokenInfo, tokenId, amount); } /** * @notice Withdraw from many tokens (that the sender owns) in a single transaction * @param tokenIds An array of tokens ids representing the position * @param amounts An array of amounts to withdraw from the corresponding tokenIds */ function withdrawMultiple(uint256[] calldata tokenIds, uint256[] calldata amounts) public override { require(tokenIds.length == amounts.length, "TokensIds and Amounts must be the same length"); for (uint256 i = 0; i < amounts.length; i++) { withdraw(tokenIds[i], amounts[i]); } } /** * @notice Similar to withdraw but will withdraw all available funds * @param tokenId The NFT representing the position * @return interestWithdrawn The interest amount that was withdrawn * @return principalWithdrawn The principal amount that was withdrawn */ function withdrawMax(uint256 tokenId) external override onlyTokenHolder(tokenId) nonReentrant whenNotPaused returns (uint256 interestWithdrawn, uint256 principalWithdrawn) { IPoolTokens.TokenInfo memory tokenInfo = config.getPoolTokens().getTokenInfo(tokenId); TrancheInfo storage trancheInfo = getTrancheInfo(tokenInfo.tranche); (uint256 interestRedeemable, uint256 principalRedeemable) = redeemableInterestAndPrincipal(trancheInfo, tokenInfo); uint256 amount = interestRedeemable.add(principalRedeemable); return _withdraw(trancheInfo, tokenInfo, tokenId, amount); } /** * @notice Draws down the funds (and locks the pool) to the borrower address. Can only be called by the borrower * @param amount The amount to drawdown from the creditline (must be < limit) */ function drawdown(uint256 amount) external override onlyLocker whenNotPaused { require(!drawdownsPaused, "Drawdowns are currently paused"); if (!locked()) { // Assumes the senior fund has invested already (saves the borrower a separate transaction to lock the pool) _lockPool(); } creditLine.drawdown(amount); // Update the share price to reflect the amount remaining in the pool uint256 amountRemaining = totalDeposited().sub(creditLine.balance()); uint256 oldJuniorPrincipalSharePrice = juniorTranche.principalSharePrice; uint256 oldSeniorPrincipalSharePrice = seniorTranche.principalSharePrice; juniorTranche.principalSharePrice = calculateExpectedSharePrice(amountRemaining, juniorTranche); seniorTranche.principalSharePrice = calculateExpectedSharePrice(amountRemaining, seniorTranche); address borrower = creditLine.borrower(); safeERC20TransferFrom(config.getUSDC(), address(this), borrower, amount); emit DrawdownMade(borrower, amount); emit SharePriceUpdated( address(this), juniorTranche.id, juniorTranche.principalSharePrice, int256(oldJuniorPrincipalSharePrice.sub(juniorTranche.principalSharePrice)) * -1, juniorTranche.interestSharePrice, 0 ); emit SharePriceUpdated( address(this), seniorTranche.id, seniorTranche.principalSharePrice, int256(oldSeniorPrincipalSharePrice.sub(seniorTranche.principalSharePrice)) * -1, seniorTranche.interestSharePrice, 0 ); } /** * @notice Locks the junior tranche, preventing more junior deposits. Gives time for the senior to determine how * much to invest (ensure leverage ratio cannot change for the period) */ function lockJuniorCapital() external override onlyLocker whenNotPaused { _lockJuniorCapital(); } /** * @notice Locks the pool (locks both senior and junior tranches and starts the drawdown period). Beyond the drawdown * period, any unused capital is available to withdraw by all depositors */ function lockPool() external override onlyLocker whenNotPaused { _lockPool(); } /** * @notice Triggers an assessment of the creditline and the applies the payments according the tranche waterfall */ function assess() external override whenNotPaused { _assess(); } /** * @notice Allows repaying the creditline. Collects the USDC amount from the sender and triggers an assess * @param amount The amount to repay */ function pay(uint256 amount) external override whenNotPaused { require(amount > 0, "Must pay more than zero"); collectPayment(amount); _assess(); } /** * @notice Migrates to a new goldfinch config address */ function updateGoldfinchConfig() external onlyAdmin { config = GoldfinchConfig(config.configAddress()); creditLine.updateGoldfinchConfig(); } /** * @notice Pauses the pool and sweeps any remaining funds to the treasury reserve. */ function emergencyShutdown() public onlyAdmin { if (!paused()) { pause(); } IERC20withDec usdc = config.getUSDC(); address reserveAddress = config.reserveAddress(); // Sweep any funds to community reserve uint256 poolBalance = usdc.balanceOf(address(this)); if (poolBalance > 0) { safeERC20Transfer(usdc, reserveAddress, poolBalance); } uint256 clBalance = usdc.balanceOf(address(creditLine)); if (clBalance > 0) { safeERC20TransferFrom(usdc, address(creditLine), reserveAddress, clBalance); } emit EmergencyShutdown(address(this)); } /** * @notice Pauses all drawdowns (but not deposits/withdraws) */ function pauseDrawdowns() public onlyAdmin { drawdownsPaused = true; emit DrawdownsPaused(address(this)); } /** * @notice Unpause drawdowns */ function unpauseDrawdowns() public onlyAdmin { drawdownsPaused = false; emit DrawdownsUnpaused(address(this)); } /** * @notice Migrates the accounting variables from the current creditline to a brand new one * @param _borrower The borrower address * @param _limit The new limit * @param _interestApr The new interest APR * @param _paymentPeriodInDays The new payment period in days * @param _termInDays The new term in days * @param _lateFeeApr The new late fee APR */ function migrateCreditLine( address _borrower, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public onlyAdmin { require(_borrower != address(0), "Borrower must not be empty"); require(_paymentPeriodInDays != 0, "Payment period must not be empty"); require(_termInDays != 0, "Term must not be empty"); address originalClAddr = address(creditLine); IV2CreditLine originalCl = IV2CreditLine(originalClAddr); createAndSetCreditLine(_borrower, _limit, _interestApr, _paymentPeriodInDays, _termInDays, _lateFeeApr); IV2CreditLine newCl = creditLine; address newClAddr = address(newCl); emit CreditLineMigrated(originalClAddr, newClAddr); // Copy over all accounting variables newCl.setBalance(originalCl.balance()); newCl.setInterestOwed(originalCl.interestOwed()); newCl.setPrincipalOwed(originalCl.principalOwed()); newCl.setTermEndTime(originalCl.termEndTime()); newCl.setNextDueTime(originalCl.nextDueTime()); newCl.setInterestAccruedAsOf(originalCl.interestAccruedAsOf()); newCl.setLastFullPaymentTime(originalCl.lastFullPaymentTime()); newCl.setTotalInterestAccrued(originalCl.totalInterestAccrued()); // Transfer any funds to new CL uint256 clBalance = config.getUSDC().balanceOf(originalClAddr); if (clBalance > 0) { safeERC20TransferFrom(config.getUSDC(), originalClAddr, newClAddr, clBalance); } // Close out old CL originalCl.setBalance(0); originalCl.setLimit(0); } /** * @notice Migrates to a new creditline without copying the accounting variables */ function migrateAndSetNewCreditLine(address newCl) public onlyAdmin { require(newCl != address(0), "Creditline cannot be empty"); address originalClAddr = address(creditLine); // Transfer any funds to new CL uint256 clBalance = config.getUSDC().balanceOf(originalClAddr); if (clBalance > 0) { safeERC20TransferFrom(config.getUSDC(), originalClAddr, newCl, clBalance); } // Close out old CL creditLine.setBalance(0); creditLine.setLimit(0); // set new CL creditLine = IV2CreditLine(newCl); // sanity check that the new address is in fact a creditline creditLine.limit(); emit CreditLineMigrated(originalClAddr, address(creditLine)); } // CreditLine proxy methods, for convenience function limit() public view returns (uint256) { return creditLine.limit(); } function borrower() public view returns (address) { return creditLine.borrower(); } function interestApr() public view returns (uint256) { return creditLine.interestApr(); } function paymentPeriodInDays() public view returns (uint256) { return creditLine.paymentPeriodInDays(); } function termInDays() public view returns (uint256) { return creditLine.termInDays(); } function lateFeeApr() public view returns (uint256) { return creditLine.lateFeeApr(); } function getTranche(uint256 tranche) public view override returns (TrancheInfo memory) { return getTrancheInfo(tranche); } /** * @notice Converts USDC amounts to share price * @param amount The USDC amount to convert * @param totalShares The total shares outstanding * @return The share price of the input amount */ function usdcToSharePrice(uint256 amount, uint256 totalShares) public pure returns (uint256) { return totalShares == 0 ? 0 : amount.mul(FP_SCALING_FACTOR).div(totalShares); } /** * @notice Converts share price to USDC amounts * @param sharePrice The share price to convert * @param totalShares The total shares outstanding * @return The USDC amount of the input share price */ function sharePriceToUsdc(uint256 sharePrice, uint256 totalShares) public pure returns (uint256) { return sharePrice.mul(totalShares).div(FP_SCALING_FACTOR); } /** * @notice Determines the amount of interest and principal redeemable by a particular tokenId * @param tokenId The token representing the position * @return interestRedeemable The interest available to redeem * @return principalRedeemable The principal available to redeem */ function availableToWithdraw(uint256 tokenId) public view override returns (uint256 interestRedeemable, uint256 principalRedeemable) { IPoolTokens.TokenInfo memory tokenInfo = config.getPoolTokens().getTokenInfo(tokenId); TrancheInfo storage trancheInfo = getTrancheInfo(tokenInfo.tranche); if (currentTime() > trancheInfo.lockedUntil) { return redeemableInterestAndPrincipal(trancheInfo, tokenInfo); } else { return (0, 0); } } /* Internal functions */ function _withdraw( TrancheInfo storage trancheInfo, IPoolTokens.TokenInfo memory tokenInfo, uint256 tokenId, uint256 amount ) internal returns (uint256 interestWithdrawn, uint256 principalWithdrawn) { (uint256 interestRedeemable, uint256 principalRedeemable) = redeemableInterestAndPrincipal(trancheInfo, tokenInfo); uint256 netRedeemable = interestRedeemable.add(principalRedeemable); require(amount <= netRedeemable, "Invalid redeem amount"); require(currentTime() > trancheInfo.lockedUntil, "Tranche is locked"); // If the tranche has not been locked, ensure the deposited amount is correct if (trancheInfo.lockedUntil == 0) { trancheInfo.principalDeposited = trancheInfo.principalDeposited.sub(amount); } uint256 interestToRedeem = Math.min(interestRedeemable, amount); uint256 principalToRedeem = Math.min(principalRedeemable, amount.sub(interestToRedeem)); config.getPoolTokens().redeem(tokenId, principalToRedeem, interestToRedeem); safeERC20TransferFrom(config.getUSDC(), address(this), msg.sender, principalToRedeem.add(interestToRedeem)); emit WithdrawalMade(msg.sender, tokenInfo.tranche, tokenId, interestToRedeem, principalToRedeem); return (interestToRedeem, principalToRedeem); } function redeemableInterestAndPrincipal(TrancheInfo storage trancheInfo, IPoolTokens.TokenInfo memory tokenInfo) internal view returns (uint256 interestRedeemable, uint256 principalRedeemable) { // This supports withdrawing before or after locking because principal share price starts at 1 // and is set to 0 on lock. Interest share price is always 0 until interest payments come back, when it increases uint256 maxPrincipalRedeemable = sharePriceToUsdc(trancheInfo.principalSharePrice, tokenInfo.principalAmount); // The principalAmount is used as the totalShares because we want the interestSharePrice to be expressed as a // percent of total loan value e.g. if the interest is 10% APR, the interestSharePrice should approach a max of 0.1. uint256 maxInterestRedeemable = sharePriceToUsdc(trancheInfo.interestSharePrice, tokenInfo.principalAmount); interestRedeemable = maxInterestRedeemable.sub(tokenInfo.interestRedeemed); principalRedeemable = maxPrincipalRedeemable.sub(tokenInfo.principalRedeemed); return (interestRedeemable, principalRedeemable); } function _lockJuniorCapital() internal { require(!locked(), "Pool already locked"); require(juniorTranche.lockedUntil == 0, "Junior tranche already locked"); juniorTranche.lockedUntil = currentTime().add(config.getDrawdownPeriodInSeconds()); } function _lockPool() internal { require(juniorTranche.lockedUntil > 0, "Junior tranche must be locked first"); creditLine.setLimit(Math.min(totalDeposited(), creditLine.limit())); // We start the drawdown period, so backers can withdraw unused capital after borrower draws down uint256 lockPeriod = config.getDrawdownPeriodInSeconds(); seniorTranche.lockedUntil = currentTime().add(lockPeriod); juniorTranche.lockedUntil = currentTime().add(lockPeriod); } function collectInterestAndPrincipal( address from, uint256 interest, uint256 principal ) internal returns (uint256 totalReserveAmount) { safeERC20TransferFrom(config.getUSDC(), from, address(this), principal.add(interest), "Failed to collect payment"); (uint256 interestAccrued, uint256 principalAccrued) = getTotalInterestAndPrincipal(); uint256 reserveFeePercent = ONE_HUNDRED.div(config.getReserveDenominator()); // Convert the denonminator to percent uint256 interestRemaining = interest; uint256 principalRemaining = principal; // First determine the expected share price for the senior tranche. This is the gross amount the senior // tranche should receive. uint256 expectedInterestSharePrice = calculateExpectedSharePrice(interestAccrued, seniorTranche); uint256 expectedPrincipalSharePrice = calculateExpectedSharePrice(principalAccrued, seniorTranche); // Deduct the junior fee and the protocol reserve uint256 desiredNetInterestSharePrice = scaleByFraction( expectedInterestSharePrice, ONE_HUNDRED.sub(juniorFeePercent.add(reserveFeePercent)), ONE_HUNDRED ); // Collect protocol fee interest received (we've subtracted this from the senior portion above) uint256 reserveDeduction = scaleByFraction(interestRemaining, reserveFeePercent, ONE_HUNDRED); totalReserveAmount = totalReserveAmount.add(reserveDeduction); // protocol fee interestRemaining = interestRemaining.sub(reserveDeduction); // Apply the interest remaining so we get up to the netInterestSharePrice (interestRemaining, principalRemaining) = applyToTrancheBySharePrice( interestRemaining, principalRemaining, desiredNetInterestSharePrice, expectedPrincipalSharePrice, seniorTranche ); // Then fill up the junior tranche with all the interest remaining, upto the principal share price expectedInterestSharePrice = juniorTranche.interestSharePrice.add( usdcToSharePrice(interestRemaining, juniorTranche.principalDeposited) ); expectedPrincipalSharePrice = calculateExpectedSharePrice(principalAccrued, juniorTranche); (interestRemaining, principalRemaining) = applyToTrancheBySharePrice( interestRemaining, principalRemaining, expectedInterestSharePrice, expectedPrincipalSharePrice, juniorTranche ); // All remaining interest and principal is applied towards the junior tranche as interest interestRemaining = interestRemaining.add(principalRemaining); // Since any principal remaining is treated as interest (there is "extra" interest to be distributed) // we need to make sure to collect the protocol fee on the additional interest (we only deducted the // fee on the original interest portion) reserveDeduction = scaleByFraction(principalRemaining, reserveFeePercent, ONE_HUNDRED); totalReserveAmount = totalReserveAmount.add(reserveDeduction); interestRemaining = interestRemaining.sub(reserveDeduction); principalRemaining = 0; (interestRemaining, principalRemaining) = applyToTrancheByAmount( interestRemaining.add(principalRemaining), 0, interestRemaining.add(principalRemaining), 0, juniorTranche ); sendToReserve(totalReserveAmount); return totalReserveAmount; } function getTotalInterestAndPrincipal() internal view returns (uint256 interestAccrued, uint256 principalAccrued) { interestAccrued = creditLine.totalInterestAccrued(); principalAccrued = creditLine.principalOwed(); // Add any remaining balance we have to the principal accrued so expected share price will reflect partial // drawdowns appropriately. (e.g. if 300K was drawndown from a 1M loan, current and expected share price should // be 0.7 and not 0) principalAccrued = principalAccrued.add(totalDeposited().sub(creditLine.balance())); return (interestAccrued, principalAccrued); } function calculateExpectedSharePrice(uint256 amount, TrancheInfo memory tranche) internal view returns (uint256) { uint256 sharePrice = usdcToSharePrice(amount, tranche.principalDeposited); return scaleByPercentOwnership(sharePrice, tranche); } // If the senior tranche is locked, then the pool is not open to any more deposits (could throw off leverage ratio) function locked() internal view returns (bool) { return seniorTranche.lockedUntil > 0; } function createAndSetCreditLine( address _borrower, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) internal { address _creditLine = config.getGoldfinchFactory().createCreditLine(); creditLine = IV2CreditLine(_creditLine); creditLine.initialize( address(config), address(this), // Set self as the owner _borrower, _limit, _interestApr, _paymentPeriodInDays, _termInDays, _lateFeeApr ); } function getTrancheInfo(uint256 tranche) internal view returns (TrancheInfo storage) { require( tranche == uint256(ITranchedPool.Tranches.Senior) || tranche == uint256(ITranchedPool.Tranches.Junior), "Unsupported tranche" ); TrancheInfo storage trancheInfo = tranche == uint256(ITranchedPool.Tranches.Senior) ? seniorTranche : juniorTranche; return trancheInfo; } function scaleByPercentOwnership(uint256 amount, TrancheInfo memory tranche) internal view returns (uint256) { uint256 totalDeposited = juniorTranche.principalDeposited.add(seniorTranche.principalDeposited); return scaleByFraction(amount, tranche.principalDeposited, totalDeposited); } function scaleByFraction( uint256 amount, uint256 fraction, uint256 total ) internal pure returns (uint256) { FixedPoint.Unsigned memory totalAsFixedPoint = FixedPoint.fromUnscaledUint(total); FixedPoint.Unsigned memory fractionAsFixedPoint = FixedPoint.fromUnscaledUint(fraction); return fractionAsFixedPoint.div(totalAsFixedPoint).mul(amount).div(FP_SCALING_FACTOR).rawValue; } function totalDeposited() internal view returns (uint256) { return juniorTranche.principalDeposited.add(seniorTranche.principalDeposited); } function currentTime() internal view virtual returns (uint256) { return block.timestamp; } function applyToTrancheBySharePrice( uint256 interestRemaining, uint256 principalRemaining, uint256 desiredInterestSharePrice, uint256 desiredPrincipalSharePrice, TrancheInfo storage tranche ) internal returns (uint256, uint256) { uint256 totalShares = tranche.principalDeposited; // If the desired share price is lower, then ignore it, and leave it unchanged uint256 principalSharePrice = tranche.principalSharePrice; if (desiredPrincipalSharePrice < principalSharePrice) { desiredPrincipalSharePrice = principalSharePrice; } uint256 interestSharePrice = tranche.interestSharePrice; if (desiredInterestSharePrice < interestSharePrice) { desiredInterestSharePrice = interestSharePrice; } uint256 interestSharePriceDifference = desiredInterestSharePrice.sub(interestSharePrice); uint256 desiredInterestAmount = sharePriceToUsdc(interestSharePriceDifference, totalShares); uint256 principalSharePriceDifference = desiredPrincipalSharePrice.sub(principalSharePrice); uint256 desiredPrincipalAmount = sharePriceToUsdc(principalSharePriceDifference, totalShares); (interestRemaining, principalRemaining) = applyToTrancheByAmount( interestRemaining, principalRemaining, desiredInterestAmount, desiredPrincipalAmount, tranche ); return (interestRemaining, principalRemaining); } function applyToTrancheByAmount( uint256 interestRemaining, uint256 principalRemaining, uint256 desiredInterestAmount, uint256 desiredPrincipalAmount, TrancheInfo storage tranche ) internal returns (uint256, uint256) { uint256 totalShares = tranche.principalDeposited; uint256 newSharePrice; (interestRemaining, newSharePrice) = applyToSharePrice( interestRemaining, tranche.interestSharePrice, desiredInterestAmount, totalShares ); uint256 oldInterestSharePrice = tranche.interestSharePrice; tranche.interestSharePrice = newSharePrice; (principalRemaining, newSharePrice) = applyToSharePrice( principalRemaining, tranche.principalSharePrice, desiredPrincipalAmount, totalShares ); uint256 oldPrincipalSharePrice = tranche.principalSharePrice; tranche.principalSharePrice = newSharePrice; emit SharePriceUpdated( address(this), tranche.id, tranche.principalSharePrice, int256(tranche.principalSharePrice.sub(oldPrincipalSharePrice)), tranche.interestSharePrice, int256(tranche.interestSharePrice.sub(oldInterestSharePrice)) ); return (interestRemaining, principalRemaining); } function applyToSharePrice( uint256 amountRemaining, uint256 currentSharePrice, uint256 desiredAmount, uint256 totalShares ) internal pure returns (uint256, uint256) { // If no money left to apply, or don't need any changes, return the original amounts if (amountRemaining == 0 || desiredAmount == 0) { return (amountRemaining, currentSharePrice); } if (amountRemaining < desiredAmount) { // We don't have enough money to adjust share price to the desired level. So just use whatever amount is left desiredAmount = amountRemaining; } uint256 sharePriceDifference = usdcToSharePrice(desiredAmount, totalShares); return (amountRemaining.sub(desiredAmount), currentSharePrice.add(sharePriceDifference)); } function sendToReserve(uint256 amount) internal { emit ReserveFundsCollected(address(this), amount); safeERC20TransferFrom( config.getUSDC(), address(this), config.reserveAddress(), amount, "Failed to send to reserve" ); } function collectPayment(uint256 amount) internal { safeERC20TransferFrom(config.getUSDC(), msg.sender, address(creditLine), amount, "Failed to collect payment"); } function _assess() internal { (uint256 paymentRemaining, uint256 interestPayment, uint256 principalPayment) = creditLine.assess(); if (interestPayment > 0 || principalPayment > 0) { uint256 reserveAmount = collectInterestAndPrincipal( address(creditLine), interestPayment, principalPayment.add(paymentRemaining) ); emit PaymentApplied( creditLine.borrower(), address(this), interestPayment, principalPayment, paymentRemaining, reserveAmount ); } } modifier onlyLocker() { require(hasRole(LOCKER_ROLE, msg.sender), "Must have locker role to perform this action"); _; } modifier onlyTokenHolder(uint256 tokenId) { require( config.getPoolTokens().isApprovedOrOwner(msg.sender, tokenId), "Only the token owner is allowed to call this function" ); _; } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCreditLine","type":"address"},{"indexed":true,"internalType":"address","name":"newCreditLine","type":"address"}],"name":"CreditLineMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"tranche","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositMade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DrawdownMade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"DrawdownsPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"DrawdownsUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"EmergencyShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"payer","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint256","name":"interestAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"principalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"remainingAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"}],"name":"PaymentApplied","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReserveFundsCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":true,"internalType":"uint256","name":"tranche","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"principalSharePrice","type":"uint256"},{"indexed":false,"internalType":"int256","name":"principalDelta","type":"int256"},{"indexed":false,"internalType":"uint256","name":"interestSharePrice","type":"uint256"},{"indexed":false,"internalType":"int256","name":"interestDelta","type":"int256"}],"name":"SharePriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"tranche","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestWithdrawn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"principalWithdrawn","type":"uint256"}],"name":"WithdrawalMade","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FP_SCALING_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOCKER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_HUNDRED","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OWNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECONDS_PER_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"__BaseUpgradeablePausable__init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"__PauserPausable__init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assess","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"availableToWithdraw","outputs":[{"internalType":"uint256","name":"interestRedeemable","type":"uint256"},{"internalType":"uint256","name":"principalRedeemable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrower","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract GoldfinchConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createdAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditLine","outputs":[{"internalType":"contract IV2CreditLine","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tranche","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tranche","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"depositWithPermit","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"drawdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"drawdownsPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyShutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tranche","type":"uint256"}],"name":"getTranche","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"principalDeposited","type":"uint256"},{"internalType":"uint256","name":"principalSharePrice","type":"uint256"},{"internalType":"uint256","name":"interestSharePrice","type":"uint256"},{"internalType":"uint256","name":"lockedUntil","type":"uint256"}],"internalType":"struct ITranchedPool.TrancheInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_config","type":"address"},{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"uint256","name":"_juniorFeePercent","type":"uint256"},{"internalType":"uint256","name":"_limit","type":"uint256"},{"internalType":"uint256","name":"_interestApr","type":"uint256"},{"internalType":"uint256","name":"_paymentPeriodInDays","type":"uint256"},{"internalType":"uint256","name":"_termInDays","type":"uint256"},{"internalType":"uint256","name":"_lateFeeApr","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestApr","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"juniorFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lateFeeApr","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockJuniorCapital","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newCl","type":"address"}],"name":"migrateAndSetNewCreditLine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"uint256","name":"_limit","type":"uint256"},{"internalType":"uint256","name":"_interestApr","type":"uint256"},{"internalType":"uint256","name":"_paymentPeriodInDays","type":"uint256"},{"internalType":"uint256","name":"_termInDays","type":"uint256"},{"internalType":"uint256","name":"_lateFeeApr","type":"uint256"}],"name":"migrateCreditLine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IV1CreditLine","name":"clToMigrate","type":"address"},{"internalType":"uint256","name":"termEndTime","type":"uint256"},{"internalType":"uint256","name":"nextDueTime","type":"uint256"},{"internalType":"uint256","name":"interestAccruedAsOf","type":"uint256"},{"internalType":"uint256","name":"lastFullPaymentTime","type":"uint256"},{"internalType":"uint256","name":"totalInterestPaid","type":"uint256"}],"name":"migrateCreditLineToV2","outputs":[{"internalType":"contract IV2CreditLine","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"migrated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseDrawdowns","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"pay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paymentPeriodInDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sharePrice","type":"uint256"},{"internalType":"uint256","name":"totalShares","type":"uint256"}],"name":"sharePriceToUsdc","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"termInDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseDrawdowns","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateGoldfinchConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"totalShares","type":"uint256"}],"name":"usdcToSharePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"interestWithdrawn","type":"uint256"},{"internalType":"uint256","name":"principalWithdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawMax","outputs":[{"internalType":"uint256","name":"interestWithdrawn","type":"uint256"},{"internalType":"uint256","name":"principalWithdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"withdrawMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615c5480620000216000396000f3fe608060405234801561001057600080fd5b50600436106103425760003560e01c80639010d07c116101b8578063bf6c87c711610104578063d547741f116100a2578063e58378bb1161007c578063e58378bb14610621578063e63ab1e914610629578063f0b25bde14610631578063f36213671461063957610342565b8063d547741f146105db578063d972e8ad146105ee578063e2bbb1581461060e57610342565b8063c77d5698116100de578063c77d5698146105a5578063ca15c873146105ad578063cde88845146105c0578063cf09e0d0146105d357610342565b8063bf6c87c714610582578063bfaa8cca1461058a578063c290d6911461059257610342565b8063a217fddf11610171578063a8f9c4fe1161014b578063a8f9c4fe14610557578063aa2a7c4c1461055f578063b396999214610572578063b6db75a01461057a57610342565b8063a217fddf1461053f578063a4d66daf14610547578063a6a25e881461054f57610342565b80639010d07c146104d857806391d14854146104eb57806399dd8df3146104fe5780639d11053014610506578063a079a4dd14610519578063a18d41761461052c57610342565b806348e6f2961161029257806368dcfdc0116102305780637df1f1b91161020a5780637df1f1b9146104a25780638456cb59146104aa578063895465d1146104b25780638ba796af146104c557610342565b806368dcfdc01461048a57806374f0314f1461049257806379502c551461049a57610342565b8063515bc3231161026c578063515bc32314610454578063526d81f61461046757806356ce15601461046f5780635c975abb1461048257610342565b806348e6f296146104315780634d02fe6f146104395780634f92a7281461044c57610342565b80632f2ff15d116102ff5780633f4ba83a116102d95780633f4ba83a146103eb5780634026478e146103f3578063441a3e70146103fb57806347195e131461041c57610342565b80632f2ff15d146103bd5780633403c2fc146103d057806336568abe146103d857610342565b80630174b449146103475780630881806c14610370578063097616a31461037a57806317f769411461038d578063248a9ca3146103a25780632c678c64146103b5575b600080fd5b61035a61035536600461502b565b610641565b604051610367919061524f565b60405180910390f35b610378610668565b005b610378610388366004614e6e565b6106d2565b610395610802565b6040516103679190615244565b61035a6103b0366004614fe4565b61080c565b610395610821565b6103786103cb366004614ffc565b61082b565b61037861086f565b6103786103e6366004614ffc565b610a46565b610378610a88565b610378610ac6565b61040e61040936600461502b565b610b25565b604051610367929190615b85565b610424610cff565b604051610367919061516b565b61035a610d0f565b61040e610447366004614fe4565b610d92565b610378610e78565b61035a610462366004615105565b610f28565b610378610fbf565b61037861047d366004614e6e565b61104a565b6103956112f9565b61035a611302565b61035a61130e565b610424611315565b610424611325565b6103786113a3565b6104246104c0366004614f10565b6113e1565b6103786104d3366004614ea6565b611947565b6104246104e636600461502b565b611c51565b6103956104f9366004614ffc565b611c69565b61035a611c81565b610378610514366004614f5b565b611cc7565b610378610527366004614fe4565b611d30565b61037861053a366004614f10565b6120e5565b61035a6129be565b61035a6129c3565b610378612a09565b610378612a34565b61040e61056d366004614fe4565b612a93565b61035a612c8e565b610395612cd4565b610378612cf0565b61035a612d4c565b6103786105a0366004614fe4565b612d51565b61035a612da5565b61035a6105bb366004614fe4565b612dac565b61035a6105ce36600461502b565b612dc3565b61035a612def565b6103786105e9366004614ffc565b612df6565b6106016105fc366004614fe4565b612e30565b6040516103679190615b30565b61035a61061c36600461502b565b612e80565b61035a613046565b61035a613058565b61035a61306a565b61035a6130b0565b600061065f670de0b6b3a764000061065985856130c2565b906130fc565b90505b92915050565b610680600080516020615bff83398151915233611c69565b6106a55760405162461bcd60e51b815260040161069c90615728565b60405180910390fd5b60975460ff16156106c85760405162461bcd60e51b815260040161069c906156c9565b6106d061313e565b565b600054610100900460ff16806106eb57506106eb6131b2565b806106f9575060005460ff16155b6107155760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015610740576000805460ff1961ff0019909116610100171660011790555b6001600160a01b0382166107665760405162461bcd60e51b815260040161069c90615774565b61076e6131b8565b610776613239565b61077e6132c5565b610796600080516020615bbf83398151915283610865565b6107ae600080516020615bdf83398151915283610865565b6107d4600080516020615bdf833981519152600080516020615bbf833981519152613354565b6107ec600080516020615bbf83398151915280613354565b80156107fe576000805461ff00191690555b5050565b6101c75460ff1681565b60009081526065602052604090206002015490565b6101d25460ff1681565b600082815260656020526040902060020154610849906104f9613369565b6108655760405162461bcd60e51b815260040161069c906152ed565b6107fe828261336d565b610877612cd4565b6108935760405162461bcd60e51b815260040161069c90615a39565b61089b6112f9565b6108a7576108a76113a3565b6101c5546000906108c0906001600160a01b03166133d6565b6101c5549091506000906108dc906001600160a01b03166133e1565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161090c919061516b565b60206040518083038186803b15801561092457600080fd5b505afa158015610938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095c91906150c0565b9050801561096f5761096f838383613461565b6101c3546040516370a0823160e01b81526000916001600160a01b03808716926370a08231926109a392169060040161516b565b60206040518083038186803b1580156109bb57600080fd5b505afa1580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f391906150c0565b90508015610a15576101c354610a159085906001600160a01b031685846134a2565b60405130907f1fc1e771236d2e93bb9541cdcb4654ba0fd3fb615b48d829b7b365f03998512690600090a250505050565b610a4e613369565b6001600160a01b0316816001600160a01b031614610a7e5760405162461bcd60e51b815260040161069c90615abb565b6107fe82826134de565b610aa2600080516020615bdf8339815191526104f9613369565b610abe5760405162461bcd60e51b815260040161069c9061541e565b6106d0613547565b610ade600080516020615bff83398151915233611c69565b610afa5760405162461bcd60e51b815260040161069c90615728565b60975460ff1615610b1d5760405162461bcd60e51b815260040161069c906156c9565b6106d06135b3565b6101c55460009081908490610b42906001600160a01b0316613708565b6001600160a01b031663430c208133836040518363ffffffff1660e01b8152600401610b6f9291906151c0565b60206040518083038186803b158015610b8757600080fd5b505afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190614fc4565b610bdb5760405162461bcd60e51b815260040161069c90615918565b60c95460ff16610bfd5760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615610c2a5760405162461bcd60e51b815260040161069c906156c9565b610c32614d98565b6101c554610c48906001600160a01b0316613708565b6001600160a01b0316638c7a63ae876040518263ffffffff1660e01b8152600401610c73919061524f565b60a06040518083038186803b158015610c8b57600080fd5b505afa158015610c9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc3919061504c565b90506000610cd48260200151613713565b9050610ce28183898961375d565b9450945050505060c9805460ff1916600117905590939092509050565b6101c3546001600160a01b031681565b6101c35460408051632473794b60e11b815290516000926001600160a01b0316916348e6f296916004808301926020929190829003018186803b158015610d5557600080fd5b505afa158015610d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d91906150c0565b905090565b600080610d9d614d98565b6101c554610db3906001600160a01b0316613708565b6001600160a01b0316638c7a63ae856040518263ffffffff1660e01b8152600401610dde919061524f565b60a06040518083038186803b158015610df657600080fd5b505afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e919061504c565b90506000610e3f8260200151613713565b90508060040154610e4e613906565b1115610e6957610e5e818361390a565b935093505050610e73565b6000809350935050505b915091565b610e80612cd4565b610e9c5760405162461bcd60e51b815260040161069c90615a39565b6101c554610eb2906001600160a01b0316613975565b6101c580546001600160a01b0319166001600160a01b039283161790556101c354604080516309f254e560e31b815290519190921691634f92a72891600480830192600092919082900301818387803b158015610f0e57600080fd5b505af1158015610f22573d6000803e3d6000fd5b50505050565b6101c554600090610f41906001600160a01b031661398d565b6001600160a01b031663d505accf333089898989896040518863ffffffff1660e01b8152600401610f78979695949392919061517f565b600060405180830381600087803b158015610f9257600080fd5b505af1158015610fa6573d6000803e3d6000fd5b50505050610fb48787612e80565b979650505050505050565b600054610100900460ff1680610fd85750610fd86131b2565b80610fe6575060005460ff16155b6110025760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff1615801561102d576000805460ff1961ff0019909116610100171660011790555b611035613239565b8015611047576000805461ff00191690555b50565b611052612cd4565b61106e5760405162461bcd60e51b815260040161069c90615a39565b6001600160a01b0381166110945760405162461bcd60e51b815260040161069c9061546a565b6101c3546101c5546001600160a01b03918216916000916110b591166133d6565b6001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016110e0919061516b565b60206040518083038186803b1580156110f857600080fd5b505afa15801561110c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113091906150c0565b9050801561115a576101c55461115a90611152906001600160a01b03166133d6565b8385846134a2565b6101c354604051637d8b34e560e11b81526001600160a01b039091169063fb1669ca9061118c9060009060040161524f565b600060405180830381600087803b1580156111a657600080fd5b505af11580156111ba573d6000803e3d6000fd5b50506101c3546040516327ea6f2b60e01b81526001600160a01b0390911692506327ea6f2b91506111f09060009060040161524f565b600060405180830381600087803b15801561120a57600080fd5b505af115801561121e573d6000803e3d6000fd5b50506101c380546001600160a01b0319166001600160a01b0387811691909117918290556040805163a4d66daf60e01b8152905192909116935063a4d66daf9250600480820192602092909190829003018186803b15801561127f57600080fd5b505afa158015611293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b791906150c0565b506101c3546040516001600160a01b03918216918416907f987cdba0cba67c68d2c8aba6a4ba6545565eccfb3e2e5ff39579ffd94acaf9bb90600090a3505050565b60975460ff1690565b670de0b6b3a764000081565b6201518081565b6101c5546001600160a01b031681565b6101c35460408051637df1f1b960e01b815290516000926001600160a01b031691637df1f1b9916004808301926020929190829003018186803b15801561136b57600080fd5b505afa15801561137f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d9190614e8a565b6113bd600080516020615bdf8339815191526104f9613369565b6113d95760405162461bcd60e51b815260040161069c9061541e565b6106d06139a5565b6101c5546000906113fa906001600160a01b03166139fe565b6001600160a01b0316336001600160a01b03161461142a5760405162461bcd60e51b815260040161069c90615552565b6101d25460ff161561144e5760405162461bcd60e51b815260040161069c906155f7565b60006101c360009054906101000a90046001600160a01b03169050806001600160a01b031663fb1669ca896001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b1580156114b157600080fd5b505afa1580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e991906150c0565b6040518263ffffffff1660e01b8152600401611505919061524f565b600060405180830381600087803b15801561151f57600080fd5b505af1158015611533573d6000803e3d6000fd5b50505050806001600160a01b03166396c8df37896001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b15801561157f57600080fd5b505afa158015611593573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b791906150c0565b6040518263ffffffff1660e01b81526004016115d3919061524f565b600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505050806001600160a01b031663b3b8a9c7896001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b15801561164d57600080fd5b505afa158015611661573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168591906150c0565b6040518263ffffffff1660e01b81526004016116a1919061524f565b600060405180830381600087803b1580156116bb57600080fd5b505af11580156116cf573d6000803e3d6000fd5b5050604051637ae14b0960e01b81526001600160a01b0384169250637ae14b0991506116ff908a9060040161524f565b600060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b5050604051631352074160e11b81526001600160a01b03841692506326a40e82915061175d90899060040161524f565b600060405180830381600087803b15801561177757600080fd5b505af115801561178b573d6000803e3d6000fd5b505060405163a6b1ae0d60e01b81526001600160a01b038416925063a6b1ae0d91506117bb90889060040161524f565b600060405180830381600087803b1580156117d557600080fd5b505af11580156117e9573d6000803e3d6000fd5b5050604051630db6452560e21b81526001600160a01b03841692506336d91494915061181990879060040161524f565b600060405180830381600087803b15801561183357600080fd5b505af1158015611847573d6000803e3d6000fd5b50505050806001600160a01b031663033669cf6118d58a6001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b15801561189657600080fd5b505afa1580156118aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ce91906150c0565b8690613a16565b6040518263ffffffff1660e01b81526004016118f1919061524f565b600060405180830381600087803b15801561190b57600080fd5b505af115801561191f573d6000803e3d6000fd5b5050505061192d8884613a3b565b6101d2805460ff1916600117905590509695505050505050565b600054610100900460ff168061196057506119606131b2565b8061196e575060005460ff16155b61198a5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff161580156119b5576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038916158015906119d557506001600160a01b03881615155b6119f15760405162461bcd60e51b815260040161069c90615505565b6101c580546001600160a01b0319166001600160a01b038b81169190911791829055600091611a209116613d94565b90506001600160a01b038116611a485760405162461bcd60e51b815260040161069c906155c0565b611a51816106d2565b6040805160a08101909152806001815260200160008152602001611a76600180612dc3565b815260006020808301829052604092830182905283516101c855838101516101c955838301516101ca5560608401516101cb556080909301516101cc55815160a08101835260028152928301528101611ad0600180612dc3565b81526000602080830182905260409283019190915282516101cd558201516101ce558101516101cf5560608101516101d055608001516101d155611b18898888888888613dac565b426101c4556101c6889055611b3b600080516020615bff8339815191528a610865565b611b53600080516020615bff83398151915282610865565b611b79600080516020615bff833981519152600080516020615bbf833981519152613354565b6101c554600090611b92906001600160a01b03166133d6565b6001600160a01b031663095ea7b3306000196040518363ffffffff1660e01b8152600401611bc19291906151c0565b602060405180830381600087803b158015611bdb57600080fd5b505af1158015611bef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c139190614fc4565b905080611c325760405162461bcd60e51b815260040161069c9061536a565b50508015611c46576000805461ff00191690555b505050505050505050565b600082815260656020526040812061065f9083613ece565b600082815260656020526040812061065f9083613eda565b6101c354604080516399dd8df360e01b815290516000926001600160a01b0316916399dd8df3916004808301926020929190829003018186803b158015610d5557600080fd5b828114611ce65760405162461bcd60e51b815260040161069c9061539a565b60005b81811015611d2957611d1f858583818110611d0057fe5b90506020020135848484818110611d1357fe5b90506020020135610b25565b5050600101611ce9565b5050505050565b611d48600080516020615bff83398151915233611c69565b611d645760405162461bcd60e51b815260040161069c90615728565b60975460ff1615611d875760405162461bcd60e51b815260040161069c906156c9565b6101c75460ff1615611dab5760405162461bcd60e51b815260040161069c9061586f565b611db3613eef565b611dbf57611dbf6135b3565b6101c35460405163a079a4dd60e01b81526001600160a01b039091169063a079a4dd90611df090849060040161524f565b600060405180830381600087803b158015611e0a57600080fd5b505af1158015611e1e573d6000803e3d6000fd5b505050506000611ebc6101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015611e7657600080fd5b505afa158015611e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eae91906150c0565b611eb6613ef8565b90613f0d565b6101cf546101ca546040805160a0810182526101cd5481526101ce5460208201529081018390526101d05460608201526101d15460808201529293509091611f05908490613f4f565b6101cf556040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc546080820152611f4a908490613f4f565b6101ca556101c35460408051637df1f1b960e01b815290516000926001600160a01b031691637df1f1b9916004808301926020929190829003018186803b158015611f9457600080fd5b505afa158015611fa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fcc9190614e8a565b6101c554909150611ff190611fe9906001600160a01b03166133d6565b3083886134a2565b806001600160a01b03167f7411b87a3c039bdfd8f3510b21e8bd0736265f53513735e1f4aa7b4f306b728d8660405161202a919061524f565b60405180910390a26101cd546101cf5430907f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687906120688782613f0d565b6101d054604051612080939260009081039291615b6a565b60405180910390a36101c8546101ca5430907f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687906120be8682613f0d565b6101cb546040516120d6939260009081039291615b6a565b60405180910390a35050505050565b6120ed612cd4565b6121095760405162461bcd60e51b815260040161069c90615a39565b6001600160a01b03861661212f5760405162461bcd60e51b815260040161069c90615589565b8261214c5760405162461bcd60e51b815260040161069c906156f3565b816121695760405162461bcd60e51b815260040161069c9061596d565b6101c3546001600160a01b031680612185888888888888613dac565b6101c3546040516001600160a01b0391821691829182918616907f987cdba0cba67c68d2c8aba6a4ba6545565eccfb3e2e5ff39579ffd94acaf9bb90600090a3816001600160a01b031663fb1669ca846001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561220d57600080fd5b505afa158015612221573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224591906150c0565b6040518263ffffffff1660e01b8152600401612261919061524f565b600060405180830381600087803b15801561227b57600080fd5b505af115801561228f573d6000803e3d6000fd5b50505050816001600160a01b03166396c8df37846001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b1580156122db57600080fd5b505afa1580156122ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231391906150c0565b6040518263ffffffff1660e01b815260040161232f919061524f565b600060405180830381600087803b15801561234957600080fd5b505af115801561235d573d6000803e3d6000fd5b50505050816001600160a01b031663b3b8a9c7846001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b1580156123a957600080fd5b505afa1580156123bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e191906150c0565b6040518263ffffffff1660e01b81526004016123fd919061524f565b600060405180830381600087803b15801561241757600080fd5b505af115801561242b573d6000803e3d6000fd5b50505050816001600160a01b0316637ae14b09846001600160a01b03166364fb2d956040518163ffffffff1660e01b815260040160206040518083038186803b15801561247757600080fd5b505afa15801561248b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124af91906150c0565b6040518263ffffffff1660e01b81526004016124cb919061524f565b600060405180830381600087803b1580156124e557600080fd5b505af11580156124f9573d6000803e3d6000fd5b50505050816001600160a01b03166326a40e82846001600160a01b031663d28459776040518163ffffffff1660e01b815260040160206040518083038186803b15801561254557600080fd5b505afa158015612559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257d91906150c0565b6040518263ffffffff1660e01b8152600401612599919061524f565b600060405180830381600087803b1580156125b357600080fd5b505af11580156125c7573d6000803e3d6000fd5b50505050816001600160a01b031663a6b1ae0d846001600160a01b031663bbafcb406040518163ffffffff1660e01b815260040160206040518083038186803b15801561261357600080fd5b505afa158015612627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264b91906150c0565b6040518263ffffffff1660e01b8152600401612667919061524f565b600060405180830381600087803b15801561268157600080fd5b505af1158015612695573d6000803e3d6000fd5b50505050816001600160a01b03166336d91494846001600160a01b031663ce78290d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156126e157600080fd5b505afa1580156126f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271991906150c0565b6040518263ffffffff1660e01b8152600401612735919061524f565b600060405180830381600087803b15801561274f57600080fd5b505af1158015612763573d6000803e3d6000fd5b50505050816001600160a01b031663033669cf846001600160a01b0316631cd724ac6040518163ffffffff1660e01b815260040160206040518083038186803b1580156127af57600080fd5b505afa1580156127c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e791906150c0565b6040518263ffffffff1660e01b8152600401612803919061524f565b600060405180830381600087803b15801561281d57600080fd5b505af1158015612831573d6000803e3d6000fd5b50506101c5546000925061284e91506001600160a01b03166133d6565b6001600160a01b03166370a08231866040518263ffffffff1660e01b8152600401612879919061516b565b60206040518083038186803b15801561289157600080fd5b505afa1580156128a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c991906150c0565b905080156128f3576101c5546128f3906128eb906001600160a01b03166133d6565b8684846134a2565b604051637d8b34e560e11b81526001600160a01b0385169063fb1669ca906129209060009060040161524f565b600060405180830381600087803b15801561293a57600080fd5b505af115801561294e573d6000803e3d6000fd5b50506040516327ea6f2b60e01b81526001600160a01b03871692506327ea6f2b915061297f9060009060040161524f565b600060405180830381600087803b15801561299957600080fd5b505af11580156129ad573d6000803e3d6000fd5b505050505050505050505050505050565b600081565b6101c3546040805163a4d66daf60e01b815290516000926001600160a01b03169163a4d66daf916004808301926020929190829003018186803b158015610d5557600080fd5b60975460ff1615612a2c5760405162461bcd60e51b815260040161069c906156c9565b6106d0613f74565b612a3c612cd4565b612a585760405162461bcd60e51b815260040161069c90615a39565b6101c7805460ff1916600117905560405130907f90d9b09c68a7e1312ce22801552b47265d77db9496383d51374b4058545447d790600090a2565b6101c55460009081908390612ab0906001600160a01b0316613708565b6001600160a01b031663430c208133836040518363ffffffff1660e01b8152600401612add9291906151c0565b60206040518083038186803b158015612af557600080fd5b505afa158015612b09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2d9190614fc4565b612b495760405162461bcd60e51b815260040161069c90615918565b60c95460ff16612b6b5760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615612b985760405162461bcd60e51b815260040161069c906156c9565b612ba0614d98565b6101c554612bb6906001600160a01b0316613708565b6001600160a01b0316638c7a63ae866040518263ffffffff1660e01b8152600401612be1919061524f565b60a06040518083038186803b158015612bf957600080fd5b505afa158015612c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c31919061504c565b90506000612c428260200151613713565b9050600080612c51838561390a565b90925090506000612c628383613a16565b9050612c7084868b8461375d565b9750975050505050505060c9805460ff191660011790559092909150565b6101c354604080516359cb4cc960e11b815290516000926001600160a01b03169163b3969992916004808301926020929190829003018186803b158015610d5557600080fd5b6000610d8d600080516020615bbf8339815191526104f9613369565b612cf8612cd4565b612d145760405162461bcd60e51b815260040161069c90615a39565b6101c7805460ff1916905560405130907f7184039938737267597232635b117c924371ac877d4329f2dfa5ca674c5cc4a590600090a2565b606481565b60975460ff1615612d745760405162461bcd60e51b815260040161069c906156c9565b60008111612d945760405162461bcd60e51b815260040161069c9061599d565b612d9d8161411f565b611047613f74565b6101c65481565b600081815260656020526040812061066290614180565b60008115612de657612de18261065985670de0b6b3a76400006130c2565b61065f565b50600092915050565b6101c45481565b600082815260656020526040902060020154612e14906104f9613369565b610a7e5760405162461bcd60e51b815260040161069c9061564e565b612e38614dd0565b612e4182613713565b6040805160a081018252825481526001830154602082015260028301549181019190915260038201546060820152600490910154608082015292915050565b60c95460009060ff16612ea55760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615612ed25760405162461bcd60e51b815260040161069c906156c9565b6000612edd84613713565b90508060040154600014612f035760405162461bcd60e51b815260040161069c906157ea565b6001810154612f129084613a16565b6001820155612f1f614dff565b5060408051808201909152838152602081018590526101c554612f4a906001600160a01b0316613708565b6001600160a01b0316635be57b6a82336040518363ffffffff1660e01b8152600401612f77929190615b0a565b602060405180830381600087803b158015612f9157600080fd5b505af1158015612fa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc991906150c0565b6101c554909350612fee90612fe6906001600160a01b03166133d6565b3330876134a2565b8285336001600160a01b03167fcb3ef4109dcd006671348924f00aac8398190a5ff283d6e470d74581513e103687604051613029919061524f565b60405180910390a4505060c9805460ff1916600117905592915050565b600080516020615bbf83398151915281565b600080516020615bdf83398151915281565b6101c354604080516378592def60e11b815290516000926001600160a01b03169163f0b25bde916004808301926020929190829003018186803b158015610d5557600080fd5b600080516020615bff83398151915281565b6000826130d157506000610662565b828202828482816130de57fe5b041461065f5760405162461bcd60e51b815260040161069c906157a9565b600061065f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061418b565b613146613eef565b156131635760405162461bcd60e51b815260040161069c90615621565b6101d154156131845760405162461bcd60e51b815260040161069c90615a84565b6101c5546131ac9061319e906001600160a01b03166141c2565b6131a6613906565b90613a16565b6101d155565b303b1590565b600054610100900460ff16806131d157506131d16131b2565b806131df575060005460ff16155b6131fb5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015611035576000805460ff1961ff0019909116610100171660011790558015611047576000805461ff001916905550565b600054610100900460ff168061325257506132526131b2565b80613260575060005460ff16155b61327c5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff161580156132a7576000805460ff1961ff0019909116610100171660011790555b6097805460ff191690558015611047576000805461ff001916905550565b600054610100900460ff16806132de57506132de6131b2565b806132ec575060005460ff16155b6133085760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015613333576000805460ff1961ff0019909116610100171660011790555b60c9805460ff191660011790558015611047576000805461ff001916905550565b60009182526065602052604090912060020155565b3390565b60008281526065602052604090206133859082614242565b156107fe57613392613369565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006106628261398d565b60006001600160a01b03821663b93f9b0a60065b6040518263ffffffff1660e01b8152600401613411919061524f565b60206040518083038186803b15801561342957600080fd5b505afa15801561343d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106629190614e8a565b61349d8383836040518060400160405280601881526020017704661696c656420746f207472616e736665722045524332360441b815250614257565b505050565b60408051808201909152601881527704661696c656420746f207472616e736665722045524332360441b6020820152611d298585858585614329565b60008281526065602052604090206134f690826143fe565b156107fe57613503613369565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60975460ff166135695760405162461bcd60e51b815260040161069c9061533c565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61359c613369565b6040516135a9919061516b565b60405180910390a1565b6101d1546135d35760405162461bcd60e51b815260040161069c906158d5565b6101c3546001600160a01b03166327ea6f2b61367c6135f0613ef8565b6101c360009054906101000a90046001600160a01b03166001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b15801561363f57600080fd5b505afa158015613653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061367791906150c0565b614413565b6040518263ffffffff1660e01b8152600401613698919061524f565b600060405180830381600087803b1580156136b257600080fd5b505af11580156136c6573d6000803e3d6000fd5b50506101c554600092506136e391506001600160a01b03166141c2565b90506136f1816131a6613906565b6101cc55613701816131a6613906565b6101d15550565b600061066282614429565b600060018214806137245750600282145b6137405760405162461bcd60e51b815260040161069c906154d8565b600060018314613752576101cd613756565b6101c85b9392505050565b60008060008061376d888861390a565b9092509050600061377e8383613a16565b9050808611156137a05760405162461bcd60e51b815260040161069c906158a6565b88600401546137ad613906565b116137ca5760405162461bcd60e51b815260040161069c9061569e565b60048901546137e85760018901546137e29087613f0d565b60018a01555b60006137f48488614413565b90506000613806846136778a85613f0d565b6101c55490915061381f906001600160a01b0316613708565b6001600160a01b031663b81922058a83856040518463ffffffff1660e01b815260040161384e93929190615b93565b600060405180830381600087803b15801561386857600080fd5b505af115801561387c573d6000803e3d6000fd5b50506101c5546138ab925061389a91506001600160a01b03166133d6565b30336138a68587613a16565b6134a2565b888a60200151336001600160a01b03167f92f2787b755dae547f1701582fe74c7abf277ec14db316dd01abc69cacf7a25985856040516138ec929190615b85565b60405180910390a490955093505050505b94509492505050565b4290565b600080600061392185600201548560400151610641565b9050600061393786600301548660400151610641565b9050613950856080015182613f0d90919063ffffffff16565b9350613969856060015183613f0d90919063ffffffff16565b925050505b9250929050565b60006001600160a01b03821663b93f9b0a600b6133f5565b60006001600160a01b03821663b93f9b0a60056133f5565b60975460ff16156139c85760405162461bcd60e51b815260040161069c906156c9565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861359c613369565b60006001600160a01b03821663b93f9b0a60036133f5565b60008282018381101561065f5760405162461bcd60e51b815260040161069c906154a1565b613a43613eef565b15613a605760405162461bcd60e51b815260040161069c906159d4565b60026000613a6d82613713565b90508060040154600014613a935760405162461bcd60e51b815260040161069c906157ea565b836001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b158015613acc57600080fd5b505afa158015613ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0491906150c0565b6001820155613b11614dff565b506040805180820190915260018201548152602081018390526101c554600090613b43906001600160a01b0316613708565b6101c5549091506000906001600160a01b0380841691635be57b6a918691613b6b9116614441565b6040518363ffffffff1660e01b8152600401613b88929190615b0a565b602060405180830381600087803b158015613ba257600080fd5b505af1158015613bb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bda91906150c0565b90506000613cef6101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015613c3057600080fd5b505afa158015613c44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c6891906150c0565b6101c360009054906101000a90046001600160a01b03166001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b158015613cb757600080fd5b505afa158015613ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb691906150c0565b9050613cf961313e565b613d016135b3565b60001942016101d15560405163b819220560e01b81526001600160a01b0384169063b819220590613d3a90859085908c90600401615b93565b600060405180830381600087803b158015613d5457600080fd5b505af1158015613d68573d6000803e3d6000fd5b505060006101cf8190556101ca5550613d889050878281816101cd614459565b50505050505050505050565b60006001600160a01b03821663b93f9b0a60076133f5565b6101c554600090613dc5906001600160a01b0316614510565b6001600160a01b03166301b215516040518163ffffffff1660e01b8152600401602060405180830381600087803b158015613dff57600080fd5b505af1158015613e13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e379190614e8a565b6101c380546001600160a01b0319166001600160a01b0383811691909117918290556101c554604051630df8fa4360e41b81529394509181169263df8fa43092613e9392169030908c908c908c908c908c908c906004016151d9565b600060405180830381600087803b158015613ead57600080fd5b505af1158015613ec1573d6000803e3d6000fd5b5050505050505050505050565b600061065f838361451b565b600061065f836001600160a01b038416614560565b6101cc54151590565b6101c9546101ce54600091610d8d9190613a16565b600061065f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614578565b600080613f60848460200151612dc3565b9050613f6c81846145a4565b949350505050565b60008060006101c360009054906101000a90046001600160a01b03166001600160a01b031663a6a25e886040518163ffffffff1660e01b8152600401606060405180830381600087803b158015613fca57600080fd5b505af1158015613fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400291906150d8565b92509250925060008211806140175750600081115b1561349d576101c354600090614040906001600160a01b03168461403b8588613a16565b6145cb565b9050306001600160a01b03166101c360009054906101000a90046001600160a01b03166001600160a01b0316637df1f1b96040518163ffffffff1660e01b815260040160206040518083038186803b15801561409b57600080fd5b505afa1580156140af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d39190614e8a565b6001600160a01b03167fd1055dc2c2a003a83dfacb1c38db776eab5ef89d77a8f05a3512e8cf57f953ce858588866040516141119493929190615b6a565b60405180910390a350505050565b6101c55461104790614139906001600160a01b03166133d6565b6101c35460408051808201909152601981527811985a5b1959081d1bc818dbdb1b1958dd081c185e5b595b9d603a1b602082015233916001600160a01b0316908590614329565b60006106628261484e565b600081836141ac5760405162461bcd60e51b815260040161069c9190615258565b5060008385816141b857fe5b0495945050505050565b60006001600160a01b03821663fc56365860075b6040518263ffffffff1660e01b81526004016141f2919061524f565b60206040518083038186803b15801561420a57600080fd5b505afa15801561421e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066291906150c0565b600061065f836001600160a01b038416614852565b6001600160a01b03831661427d5760405162461bcd60e51b815260040161069c906153e7565b60405163a9059cbb60e01b81526000906001600160a01b0386169063a9059cbb906142ae90879087906004016151c0565b602060405180830381600087803b1580156142c857600080fd5b505af11580156142dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143009190614fc4565b905081816143215760405162461bcd60e51b815260040161069c9190615258565b505050505050565b6001600160a01b03831661434f5760405162461bcd60e51b815260040161069c906153e7565b6040516323b872dd60e01b81526000906001600160a01b038716906323b872dd9061438290889088908890600401615220565b602060405180830381600087803b15801561439c57600080fd5b505af11580156143b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143d49190614fc4565b905081816143f55760405162461bcd60e51b815260040161069c9190615258565b50505050505050565b600061065f836001600160a01b03841661489c565b6000818310614422578161065f565b5090919050565b60006001600160a01b03821663b93f9b0a600c6133f5565b60006001600160a01b03821663b93f9b0a600e6133f5565b60008060008360010154905060006144778986600301548985614962565b600387018054908290556002880154929b509092509061449a908a908986614962565b600288018054908290558854929b5090935090307f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687856144da8186613f0d565b60038c01546144e98189613f0d565b6040516144f99493929190615b6a565b60405180910390a350989997985050505050505050565b6000610662826149bb565b8154600090821061453e5760405162461bcd60e51b815260040161069c906152ab565b82600001828154811061454d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6000818484111561459c5760405162461bcd60e51b815260040161069c9190615258565b505050900390565b6101c9546101ce5460009182916145ba91613a16565b9050613f6c848460200151836149d3565b6101c55460009061462b906145e8906001600160a01b03166133d6565b85306145f48688613a16565b6040518060400160405280601981526020017811985a5b1959081d1bc818dbdb1b1958dd081c185e5b595b9d603a1b815250614329565b600080614636614a2c565b6101c554919350915060009061466090614658906001600160a01b0316614ba3565b6064906130fc565b6040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc546080820152909150869086906000906146ab908790613f4f565b6040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc5460808201529091506000906146f2908790613f4f565b905060006147228361471b614713896101c654613a1690919063ffffffff16565b606490613f0d565b60646149d3565b90506000614732868860646149d3565b905061473e8a82613a16565b995061474a8682613f0d565b955061475b868684866101c8614bbb565b6101ce54919750955061477d90614773908890612dc3565b6101d05490613a16565b6040805160a0810182526101cd5481526101ce5460208201526101cf54918101919091526101d05460608201526101d15460808201529094506147c1908990613f4f565b92506147d2868686866101cd614bbb565b90965094506147e18686613a16565b95506147ef858860646149d3565b90506147fb8a82613a16565b99506148078682613f0d565b95506000945061483061481a8787613a16565b60006148268989613a16565b60006101cd614459565b909650945061483e8a614c41565b5050505050505050509392505050565b5490565b600061485e8383614560565b61489457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610662565b506000610662565b6000818152600183016020526040812054801561495857835460001980830191908101906000908790839081106148cf57fe5b90600052602060002001549050808760000184815481106148ec57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061491c57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610662565b6000915050610662565b600080851580614970575083155b1561497f5750849050836138fd565b8386101561498b578593505b60006149978585612dc3565b90506149a38786613f0d565b6149ad8783613a16565b925092505094509492505050565b60006001600160a01b03821663b93f9b0a60026133f5565b60006149dd614e19565b6149e683614cf0565b90506149f0614e19565b6149f985614cf0565b9050614a21670de0b6b3a7640000614a1b88614a158587614d1e565b90614d56565b90614d77565b519695505050505050565b6000806101c360009054906101000a90046001600160a01b03166001600160a01b0316631cd724ac6040518163ffffffff1660e01b815260040160206040518083038186803b158015614a7e57600080fd5b505afa158015614a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ab691906150c0565b91506101c360009054906101000a90046001600160a01b03166001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b158015614b0757600080fd5b505afa158015614b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b3f91906150c0565b9050614b9d614b966101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015611e7657600080fd5b8290613a16565b90509091565b60006001600160a01b03821663fc56365860036141d6565b60018101546002820154600091829180861015614bd6578095505b600385015480881015614be7578097505b6000614bf38983613f0d565b90506000614c018286610641565b90506000614c0f8a86613f0d565b90506000614c1d8288610641565b9050614c2c8e8e85848e614459565b909f909e509c50505050505050505050505050565b306001600160a01b03167ff3583f178a8d4f8888c3683f8e948faf9b6eb701c4f1fab265a6ecad1a1ddebb82604051614c7a919061524f565b60405180910390a26101c55461104790614c9c906001600160a01b03166133d6565b6101c5543090614cb4906001600160a01b03166133e1565b846040518060400160405280601981526020017f4661696c656420746f2073656e6420746f207265736572766500000000000000815250614329565b614cf8614e19565b604080516020810190915280614d1684670de0b6b3a76400006130c2565b905292915050565b614d26614e19565b6040805160208101909152825184518291614d4d9161065990670de0b6b3a76400006130c2565b90529392505050565b614d5e614e19565b604080516020810190915283518190614d4d90856130c2565b614d7f614e19565b604080516020810190915283518190614d4d90856130fc565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b6040518060200160405280600081525090565b60008083601f840112614e3d578182fd5b50813567ffffffffffffffff811115614e54578182fd5b602083019150836020808302850101111561396e57600080fd5b600060208284031215614e7f578081fd5b813561065f81615ba9565b600060208284031215614e9b578081fd5b815161065f81615ba9565b600080600080600080600080610100898b031215614ec2578384fd5b8835614ecd81615ba9565b97506020890135614edd81615ba9565b979a9799505050506040860135956060810135956080820135955060a0820135945060c0820135935060e0909101359150565b60008060008060008060c08789031215614f28578182fd5b8635614f3381615ba9565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060408587031215614f70578384fd5b843567ffffffffffffffff80821115614f87578586fd5b614f9388838901614e2c565b90965094506020870135915080821115614fab578384fd5b50614fb887828801614e2c565b95989497509550505050565b600060208284031215614fd5578081fd5b8151801515811461065f578182fd5b600060208284031215614ff5578081fd5b5035919050565b6000806040838503121561500e578182fd5b82359150602083013561502081615ba9565b809150509250929050565b6000806040838503121561503d578182fd5b50508035926020909101359150565b600060a0828403121561505d578081fd5b60405160a0810181811067ffffffffffffffff8211171561507c578283fd5b604052825161508a81615ba9565b80825250602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b6000602082840312156150d1578081fd5b5051919050565b6000806000606084860312156150ec578081fd5b8351925060208401519150604084015190509250925092565b60008060008060008060c0878903121561511d578384fd5b863595506020870135945060408701359350606087013560ff81168114615142578283fd5b9598949750929560808101359460a0909101359350915050565b80518252602090810151910152565b6001600160a01b0391909116815260200190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03988916815296881660208801529490961660408601526060850192909252608084015260a083015260c082019290925260e08101919091526101000190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b8181101561528457858101830151858201604001528201615268565b818111156152955783604083870101525b50601f01601f1916929092016040019392505050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b6020808252601690820152754661696c656420746f20617070726f7665205553444360501b604082015260600190565b6020808252602d908201527f546f6b656e7349647320616e6420416d6f756e7473206d75737420626520746860408201526c0ca40e6c2daca40d8cadccee8d609b1b606082015260800190565b6020808252601a908201527f43616e27742073656e6420746f207a65726f2061646472657373000000000000604082015260600190565b6020808252602c908201527f4d75737420686176652070617573657220726f6c6520746f20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b6020808252601a908201527f4372656469746c696e652063616e6e6f7420626520656d707479000000000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b602080825260139082015272556e737570706f72746564207472616e63686560681b604082015260600190565b6020808252602d908201527f436f6e66696720616e6420626f72726f7765722061646472657373657320636160408201526c6e6e6f7420626520656d70747960981b606082015260800190565b6020808252601e908201527f4f6e6c7920637265646974206465736b2063616e2063616c6c20746869730000604082015260600190565b6020808252601a908201527f426f72726f776572206d757374206e6f7420626520656d707479000000000000604082015260600190565b6020808252601d908201527f4f776e657220616464726573732063616e6e6f7420626520656d707479000000604082015260600190565b60208082526010908201526f105b1c9958591e481b5a59dc985d195960821b604082015260600190565b602080825260139082015272141bdbdb08185b1c9958591e481b1bd8dad959606a1b604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b602080825260119082015270151c985b98da19481a5cc81b1bd8dad959607a1b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f5061796d656e7420706572696f64206d757374206e6f7420626520656d707479604082015260600190565b6020808252602c908201527f4d7573742068617665206c6f636b657220726f6c6520746f20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b6020808252818101527f4f776e65722063616e6e6f7420626520746865207a65726f2061646472657373604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f5472616e63686520686173206265656e206c6f636b6564000000000000000000604082015260600190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601e908201527f44726177646f776e73206172652063757272656e746c79207061757365640000604082015260600190565b602080825260159082015274125b9d985b1a59081c995919595b48185b5bdd5b9d605a1b604082015260600190565b60208082526023908201527f4a756e696f72207472616e636865206d757374206265206c6f636b65642066696040820152621c9cdd60ea1b606082015260800190565b60208082526035908201527f4f6e6c792074686520746f6b656e206f776e657220697320616c6c6f776564206040820152743a379031b0b636103a3434b990333ab731ba34b7b760591b606082015260800190565b6020808252601690820152755465726d206d757374206e6f7420626520656d70747960501b604082015260600190565b60208082526017908201527f4d75737420706179206d6f7265207468616e207a65726f000000000000000000604082015260600190565b602080825260149082015273141bdbdb081a185cc81899595b881b1bd8dad95960621b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602b908201527f4d75737420686176652061646d696e20726f6c6520746f20706572666f726d2060408201526a3a3434b99030b1ba34b7b760a91b606082015260800190565b6020808252601d908201527f4a756e696f72207472616e63686520616c7265616479206c6f636b6564000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b60608101615b18828561515c565b6001600160a01b039290921660409190910152919050565b600060a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b93845260208401929092526040830152606082015260800190565b918252602082015260400190565b9283526020830191909152604082015260600190565b6001600160a01b038116811461104757600080fdfeb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aaf9a8bb3cbd6b84fbccefa71ff73e26e798553c6914585a84886212a46a90279a2646970667358221220f21929af0f55a8aa725e56cfb1850a6cb4c754f8f75b561b008df7d80e060e6264736f6c634300060c0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103425760003560e01c80639010d07c116101b8578063bf6c87c711610104578063d547741f116100a2578063e58378bb1161007c578063e58378bb14610621578063e63ab1e914610629578063f0b25bde14610631578063f36213671461063957610342565b8063d547741f146105db578063d972e8ad146105ee578063e2bbb1581461060e57610342565b8063c77d5698116100de578063c77d5698146105a5578063ca15c873146105ad578063cde88845146105c0578063cf09e0d0146105d357610342565b8063bf6c87c714610582578063bfaa8cca1461058a578063c290d6911461059257610342565b8063a217fddf11610171578063a8f9c4fe1161014b578063a8f9c4fe14610557578063aa2a7c4c1461055f578063b396999214610572578063b6db75a01461057a57610342565b8063a217fddf1461053f578063a4d66daf14610547578063a6a25e881461054f57610342565b80639010d07c146104d857806391d14854146104eb57806399dd8df3146104fe5780639d11053014610506578063a079a4dd14610519578063a18d41761461052c57610342565b806348e6f2961161029257806368dcfdc0116102305780637df1f1b91161020a5780637df1f1b9146104a25780638456cb59146104aa578063895465d1146104b25780638ba796af146104c557610342565b806368dcfdc01461048a57806374f0314f1461049257806379502c551461049a57610342565b8063515bc3231161026c578063515bc32314610454578063526d81f61461046757806356ce15601461046f5780635c975abb1461048257610342565b806348e6f296146104315780634d02fe6f146104395780634f92a7281461044c57610342565b80632f2ff15d116102ff5780633f4ba83a116102d95780633f4ba83a146103eb5780634026478e146103f3578063441a3e70146103fb57806347195e131461041c57610342565b80632f2ff15d146103bd5780633403c2fc146103d057806336568abe146103d857610342565b80630174b449146103475780630881806c14610370578063097616a31461037a57806317f769411461038d578063248a9ca3146103a25780632c678c64146103b5575b600080fd5b61035a61035536600461502b565b610641565b604051610367919061524f565b60405180910390f35b610378610668565b005b610378610388366004614e6e565b6106d2565b610395610802565b6040516103679190615244565b61035a6103b0366004614fe4565b61080c565b610395610821565b6103786103cb366004614ffc565b61082b565b61037861086f565b6103786103e6366004614ffc565b610a46565b610378610a88565b610378610ac6565b61040e61040936600461502b565b610b25565b604051610367929190615b85565b610424610cff565b604051610367919061516b565b61035a610d0f565b61040e610447366004614fe4565b610d92565b610378610e78565b61035a610462366004615105565b610f28565b610378610fbf565b61037861047d366004614e6e565b61104a565b6103956112f9565b61035a611302565b61035a61130e565b610424611315565b610424611325565b6103786113a3565b6104246104c0366004614f10565b6113e1565b6103786104d3366004614ea6565b611947565b6104246104e636600461502b565b611c51565b6103956104f9366004614ffc565b611c69565b61035a611c81565b610378610514366004614f5b565b611cc7565b610378610527366004614fe4565b611d30565b61037861053a366004614f10565b6120e5565b61035a6129be565b61035a6129c3565b610378612a09565b610378612a34565b61040e61056d366004614fe4565b612a93565b61035a612c8e565b610395612cd4565b610378612cf0565b61035a612d4c565b6103786105a0366004614fe4565b612d51565b61035a612da5565b61035a6105bb366004614fe4565b612dac565b61035a6105ce36600461502b565b612dc3565b61035a612def565b6103786105e9366004614ffc565b612df6565b6106016105fc366004614fe4565b612e30565b6040516103679190615b30565b61035a61061c36600461502b565b612e80565b61035a613046565b61035a613058565b61035a61306a565b61035a6130b0565b600061065f670de0b6b3a764000061065985856130c2565b906130fc565b90505b92915050565b610680600080516020615bff83398151915233611c69565b6106a55760405162461bcd60e51b815260040161069c90615728565b60405180910390fd5b60975460ff16156106c85760405162461bcd60e51b815260040161069c906156c9565b6106d061313e565b565b600054610100900460ff16806106eb57506106eb6131b2565b806106f9575060005460ff16155b6107155760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015610740576000805460ff1961ff0019909116610100171660011790555b6001600160a01b0382166107665760405162461bcd60e51b815260040161069c90615774565b61076e6131b8565b610776613239565b61077e6132c5565b610796600080516020615bbf83398151915283610865565b6107ae600080516020615bdf83398151915283610865565b6107d4600080516020615bdf833981519152600080516020615bbf833981519152613354565b6107ec600080516020615bbf83398151915280613354565b80156107fe576000805461ff00191690555b5050565b6101c75460ff1681565b60009081526065602052604090206002015490565b6101d25460ff1681565b600082815260656020526040902060020154610849906104f9613369565b6108655760405162461bcd60e51b815260040161069c906152ed565b6107fe828261336d565b610877612cd4565b6108935760405162461bcd60e51b815260040161069c90615a39565b61089b6112f9565b6108a7576108a76113a3565b6101c5546000906108c0906001600160a01b03166133d6565b6101c5549091506000906108dc906001600160a01b03166133e1565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161090c919061516b565b60206040518083038186803b15801561092457600080fd5b505afa158015610938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095c91906150c0565b9050801561096f5761096f838383613461565b6101c3546040516370a0823160e01b81526000916001600160a01b03808716926370a08231926109a392169060040161516b565b60206040518083038186803b1580156109bb57600080fd5b505afa1580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f391906150c0565b90508015610a15576101c354610a159085906001600160a01b031685846134a2565b60405130907f1fc1e771236d2e93bb9541cdcb4654ba0fd3fb615b48d829b7b365f03998512690600090a250505050565b610a4e613369565b6001600160a01b0316816001600160a01b031614610a7e5760405162461bcd60e51b815260040161069c90615abb565b6107fe82826134de565b610aa2600080516020615bdf8339815191526104f9613369565b610abe5760405162461bcd60e51b815260040161069c9061541e565b6106d0613547565b610ade600080516020615bff83398151915233611c69565b610afa5760405162461bcd60e51b815260040161069c90615728565b60975460ff1615610b1d5760405162461bcd60e51b815260040161069c906156c9565b6106d06135b3565b6101c55460009081908490610b42906001600160a01b0316613708565b6001600160a01b031663430c208133836040518363ffffffff1660e01b8152600401610b6f9291906151c0565b60206040518083038186803b158015610b8757600080fd5b505afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190614fc4565b610bdb5760405162461bcd60e51b815260040161069c90615918565b60c95460ff16610bfd5760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615610c2a5760405162461bcd60e51b815260040161069c906156c9565b610c32614d98565b6101c554610c48906001600160a01b0316613708565b6001600160a01b0316638c7a63ae876040518263ffffffff1660e01b8152600401610c73919061524f565b60a06040518083038186803b158015610c8b57600080fd5b505afa158015610c9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc3919061504c565b90506000610cd48260200151613713565b9050610ce28183898961375d565b9450945050505060c9805460ff1916600117905590939092509050565b6101c3546001600160a01b031681565b6101c35460408051632473794b60e11b815290516000926001600160a01b0316916348e6f296916004808301926020929190829003018186803b158015610d5557600080fd5b505afa158015610d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d91906150c0565b905090565b600080610d9d614d98565b6101c554610db3906001600160a01b0316613708565b6001600160a01b0316638c7a63ae856040518263ffffffff1660e01b8152600401610dde919061524f565b60a06040518083038186803b158015610df657600080fd5b505afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e919061504c565b90506000610e3f8260200151613713565b90508060040154610e4e613906565b1115610e6957610e5e818361390a565b935093505050610e73565b6000809350935050505b915091565b610e80612cd4565b610e9c5760405162461bcd60e51b815260040161069c90615a39565b6101c554610eb2906001600160a01b0316613975565b6101c580546001600160a01b0319166001600160a01b039283161790556101c354604080516309f254e560e31b815290519190921691634f92a72891600480830192600092919082900301818387803b158015610f0e57600080fd5b505af1158015610f22573d6000803e3d6000fd5b50505050565b6101c554600090610f41906001600160a01b031661398d565b6001600160a01b031663d505accf333089898989896040518863ffffffff1660e01b8152600401610f78979695949392919061517f565b600060405180830381600087803b158015610f9257600080fd5b505af1158015610fa6573d6000803e3d6000fd5b50505050610fb48787612e80565b979650505050505050565b600054610100900460ff1680610fd85750610fd86131b2565b80610fe6575060005460ff16155b6110025760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff1615801561102d576000805460ff1961ff0019909116610100171660011790555b611035613239565b8015611047576000805461ff00191690555b50565b611052612cd4565b61106e5760405162461bcd60e51b815260040161069c90615a39565b6001600160a01b0381166110945760405162461bcd60e51b815260040161069c9061546a565b6101c3546101c5546001600160a01b03918216916000916110b591166133d6565b6001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016110e0919061516b565b60206040518083038186803b1580156110f857600080fd5b505afa15801561110c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113091906150c0565b9050801561115a576101c55461115a90611152906001600160a01b03166133d6565b8385846134a2565b6101c354604051637d8b34e560e11b81526001600160a01b039091169063fb1669ca9061118c9060009060040161524f565b600060405180830381600087803b1580156111a657600080fd5b505af11580156111ba573d6000803e3d6000fd5b50506101c3546040516327ea6f2b60e01b81526001600160a01b0390911692506327ea6f2b91506111f09060009060040161524f565b600060405180830381600087803b15801561120a57600080fd5b505af115801561121e573d6000803e3d6000fd5b50506101c380546001600160a01b0319166001600160a01b0387811691909117918290556040805163a4d66daf60e01b8152905192909116935063a4d66daf9250600480820192602092909190829003018186803b15801561127f57600080fd5b505afa158015611293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b791906150c0565b506101c3546040516001600160a01b03918216918416907f987cdba0cba67c68d2c8aba6a4ba6545565eccfb3e2e5ff39579ffd94acaf9bb90600090a3505050565b60975460ff1690565b670de0b6b3a764000081565b6201518081565b6101c5546001600160a01b031681565b6101c35460408051637df1f1b960e01b815290516000926001600160a01b031691637df1f1b9916004808301926020929190829003018186803b15801561136b57600080fd5b505afa15801561137f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d9190614e8a565b6113bd600080516020615bdf8339815191526104f9613369565b6113d95760405162461bcd60e51b815260040161069c9061541e565b6106d06139a5565b6101c5546000906113fa906001600160a01b03166139fe565b6001600160a01b0316336001600160a01b03161461142a5760405162461bcd60e51b815260040161069c90615552565b6101d25460ff161561144e5760405162461bcd60e51b815260040161069c906155f7565b60006101c360009054906101000a90046001600160a01b03169050806001600160a01b031663fb1669ca896001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b1580156114b157600080fd5b505afa1580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e991906150c0565b6040518263ffffffff1660e01b8152600401611505919061524f565b600060405180830381600087803b15801561151f57600080fd5b505af1158015611533573d6000803e3d6000fd5b50505050806001600160a01b03166396c8df37896001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b15801561157f57600080fd5b505afa158015611593573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b791906150c0565b6040518263ffffffff1660e01b81526004016115d3919061524f565b600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505050806001600160a01b031663b3b8a9c7896001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b15801561164d57600080fd5b505afa158015611661573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168591906150c0565b6040518263ffffffff1660e01b81526004016116a1919061524f565b600060405180830381600087803b1580156116bb57600080fd5b505af11580156116cf573d6000803e3d6000fd5b5050604051637ae14b0960e01b81526001600160a01b0384169250637ae14b0991506116ff908a9060040161524f565b600060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b5050604051631352074160e11b81526001600160a01b03841692506326a40e82915061175d90899060040161524f565b600060405180830381600087803b15801561177757600080fd5b505af115801561178b573d6000803e3d6000fd5b505060405163a6b1ae0d60e01b81526001600160a01b038416925063a6b1ae0d91506117bb90889060040161524f565b600060405180830381600087803b1580156117d557600080fd5b505af11580156117e9573d6000803e3d6000fd5b5050604051630db6452560e21b81526001600160a01b03841692506336d91494915061181990879060040161524f565b600060405180830381600087803b15801561183357600080fd5b505af1158015611847573d6000803e3d6000fd5b50505050806001600160a01b031663033669cf6118d58a6001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b15801561189657600080fd5b505afa1580156118aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ce91906150c0565b8690613a16565b6040518263ffffffff1660e01b81526004016118f1919061524f565b600060405180830381600087803b15801561190b57600080fd5b505af115801561191f573d6000803e3d6000fd5b5050505061192d8884613a3b565b6101d2805460ff1916600117905590509695505050505050565b600054610100900460ff168061196057506119606131b2565b8061196e575060005460ff16155b61198a5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff161580156119b5576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038916158015906119d557506001600160a01b03881615155b6119f15760405162461bcd60e51b815260040161069c90615505565b6101c580546001600160a01b0319166001600160a01b038b81169190911791829055600091611a209116613d94565b90506001600160a01b038116611a485760405162461bcd60e51b815260040161069c906155c0565b611a51816106d2565b6040805160a08101909152806001815260200160008152602001611a76600180612dc3565b815260006020808301829052604092830182905283516101c855838101516101c955838301516101ca5560608401516101cb556080909301516101cc55815160a08101835260028152928301528101611ad0600180612dc3565b81526000602080830182905260409283019190915282516101cd558201516101ce558101516101cf5560608101516101d055608001516101d155611b18898888888888613dac565b426101c4556101c6889055611b3b600080516020615bff8339815191528a610865565b611b53600080516020615bff83398151915282610865565b611b79600080516020615bff833981519152600080516020615bbf833981519152613354565b6101c554600090611b92906001600160a01b03166133d6565b6001600160a01b031663095ea7b3306000196040518363ffffffff1660e01b8152600401611bc19291906151c0565b602060405180830381600087803b158015611bdb57600080fd5b505af1158015611bef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c139190614fc4565b905080611c325760405162461bcd60e51b815260040161069c9061536a565b50508015611c46576000805461ff00191690555b505050505050505050565b600082815260656020526040812061065f9083613ece565b600082815260656020526040812061065f9083613eda565b6101c354604080516399dd8df360e01b815290516000926001600160a01b0316916399dd8df3916004808301926020929190829003018186803b158015610d5557600080fd5b828114611ce65760405162461bcd60e51b815260040161069c9061539a565b60005b81811015611d2957611d1f858583818110611d0057fe5b90506020020135848484818110611d1357fe5b90506020020135610b25565b5050600101611ce9565b5050505050565b611d48600080516020615bff83398151915233611c69565b611d645760405162461bcd60e51b815260040161069c90615728565b60975460ff1615611d875760405162461bcd60e51b815260040161069c906156c9565b6101c75460ff1615611dab5760405162461bcd60e51b815260040161069c9061586f565b611db3613eef565b611dbf57611dbf6135b3565b6101c35460405163a079a4dd60e01b81526001600160a01b039091169063a079a4dd90611df090849060040161524f565b600060405180830381600087803b158015611e0a57600080fd5b505af1158015611e1e573d6000803e3d6000fd5b505050506000611ebc6101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015611e7657600080fd5b505afa158015611e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eae91906150c0565b611eb6613ef8565b90613f0d565b6101cf546101ca546040805160a0810182526101cd5481526101ce5460208201529081018390526101d05460608201526101d15460808201529293509091611f05908490613f4f565b6101cf556040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc546080820152611f4a908490613f4f565b6101ca556101c35460408051637df1f1b960e01b815290516000926001600160a01b031691637df1f1b9916004808301926020929190829003018186803b158015611f9457600080fd5b505afa158015611fa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fcc9190614e8a565b6101c554909150611ff190611fe9906001600160a01b03166133d6565b3083886134a2565b806001600160a01b03167f7411b87a3c039bdfd8f3510b21e8bd0736265f53513735e1f4aa7b4f306b728d8660405161202a919061524f565b60405180910390a26101cd546101cf5430907f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687906120688782613f0d565b6101d054604051612080939260009081039291615b6a565b60405180910390a36101c8546101ca5430907f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687906120be8682613f0d565b6101cb546040516120d6939260009081039291615b6a565b60405180910390a35050505050565b6120ed612cd4565b6121095760405162461bcd60e51b815260040161069c90615a39565b6001600160a01b03861661212f5760405162461bcd60e51b815260040161069c90615589565b8261214c5760405162461bcd60e51b815260040161069c906156f3565b816121695760405162461bcd60e51b815260040161069c9061596d565b6101c3546001600160a01b031680612185888888888888613dac565b6101c3546040516001600160a01b0391821691829182918616907f987cdba0cba67c68d2c8aba6a4ba6545565eccfb3e2e5ff39579ffd94acaf9bb90600090a3816001600160a01b031663fb1669ca846001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561220d57600080fd5b505afa158015612221573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224591906150c0565b6040518263ffffffff1660e01b8152600401612261919061524f565b600060405180830381600087803b15801561227b57600080fd5b505af115801561228f573d6000803e3d6000fd5b50505050816001600160a01b03166396c8df37846001600160a01b03166321856b366040518163ffffffff1660e01b815260040160206040518083038186803b1580156122db57600080fd5b505afa1580156122ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231391906150c0565b6040518263ffffffff1660e01b815260040161232f919061524f565b600060405180830381600087803b15801561234957600080fd5b505af115801561235d573d6000803e3d6000fd5b50505050816001600160a01b031663b3b8a9c7846001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b1580156123a957600080fd5b505afa1580156123bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e191906150c0565b6040518263ffffffff1660e01b81526004016123fd919061524f565b600060405180830381600087803b15801561241757600080fd5b505af115801561242b573d6000803e3d6000fd5b50505050816001600160a01b0316637ae14b09846001600160a01b03166364fb2d956040518163ffffffff1660e01b815260040160206040518083038186803b15801561247757600080fd5b505afa15801561248b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124af91906150c0565b6040518263ffffffff1660e01b81526004016124cb919061524f565b600060405180830381600087803b1580156124e557600080fd5b505af11580156124f9573d6000803e3d6000fd5b50505050816001600160a01b03166326a40e82846001600160a01b031663d28459776040518163ffffffff1660e01b815260040160206040518083038186803b15801561254557600080fd5b505afa158015612559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257d91906150c0565b6040518263ffffffff1660e01b8152600401612599919061524f565b600060405180830381600087803b1580156125b357600080fd5b505af11580156125c7573d6000803e3d6000fd5b50505050816001600160a01b031663a6b1ae0d846001600160a01b031663bbafcb406040518163ffffffff1660e01b815260040160206040518083038186803b15801561261357600080fd5b505afa158015612627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264b91906150c0565b6040518263ffffffff1660e01b8152600401612667919061524f565b600060405180830381600087803b15801561268157600080fd5b505af1158015612695573d6000803e3d6000fd5b50505050816001600160a01b03166336d91494846001600160a01b031663ce78290d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156126e157600080fd5b505afa1580156126f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271991906150c0565b6040518263ffffffff1660e01b8152600401612735919061524f565b600060405180830381600087803b15801561274f57600080fd5b505af1158015612763573d6000803e3d6000fd5b50505050816001600160a01b031663033669cf846001600160a01b0316631cd724ac6040518163ffffffff1660e01b815260040160206040518083038186803b1580156127af57600080fd5b505afa1580156127c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e791906150c0565b6040518263ffffffff1660e01b8152600401612803919061524f565b600060405180830381600087803b15801561281d57600080fd5b505af1158015612831573d6000803e3d6000fd5b50506101c5546000925061284e91506001600160a01b03166133d6565b6001600160a01b03166370a08231866040518263ffffffff1660e01b8152600401612879919061516b565b60206040518083038186803b15801561289157600080fd5b505afa1580156128a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c991906150c0565b905080156128f3576101c5546128f3906128eb906001600160a01b03166133d6565b8684846134a2565b604051637d8b34e560e11b81526001600160a01b0385169063fb1669ca906129209060009060040161524f565b600060405180830381600087803b15801561293a57600080fd5b505af115801561294e573d6000803e3d6000fd5b50506040516327ea6f2b60e01b81526001600160a01b03871692506327ea6f2b915061297f9060009060040161524f565b600060405180830381600087803b15801561299957600080fd5b505af11580156129ad573d6000803e3d6000fd5b505050505050505050505050505050565b600081565b6101c3546040805163a4d66daf60e01b815290516000926001600160a01b03169163a4d66daf916004808301926020929190829003018186803b158015610d5557600080fd5b60975460ff1615612a2c5760405162461bcd60e51b815260040161069c906156c9565b6106d0613f74565b612a3c612cd4565b612a585760405162461bcd60e51b815260040161069c90615a39565b6101c7805460ff1916600117905560405130907f90d9b09c68a7e1312ce22801552b47265d77db9496383d51374b4058545447d790600090a2565b6101c55460009081908390612ab0906001600160a01b0316613708565b6001600160a01b031663430c208133836040518363ffffffff1660e01b8152600401612add9291906151c0565b60206040518083038186803b158015612af557600080fd5b505afa158015612b09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2d9190614fc4565b612b495760405162461bcd60e51b815260040161069c90615918565b60c95460ff16612b6b5760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615612b985760405162461bcd60e51b815260040161069c906156c9565b612ba0614d98565b6101c554612bb6906001600160a01b0316613708565b6001600160a01b0316638c7a63ae866040518263ffffffff1660e01b8152600401612be1919061524f565b60a06040518083038186803b158015612bf957600080fd5b505afa158015612c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c31919061504c565b90506000612c428260200151613713565b9050600080612c51838561390a565b90925090506000612c628383613a16565b9050612c7084868b8461375d565b9750975050505050505060c9805460ff191660011790559092909150565b6101c354604080516359cb4cc960e11b815290516000926001600160a01b03169163b3969992916004808301926020929190829003018186803b158015610d5557600080fd5b6000610d8d600080516020615bbf8339815191526104f9613369565b612cf8612cd4565b612d145760405162461bcd60e51b815260040161069c90615a39565b6101c7805460ff1916905560405130907f7184039938737267597232635b117c924371ac877d4329f2dfa5ca674c5cc4a590600090a2565b606481565b60975460ff1615612d745760405162461bcd60e51b815260040161069c906156c9565b60008111612d945760405162461bcd60e51b815260040161069c9061599d565b612d9d8161411f565b611047613f74565b6101c65481565b600081815260656020526040812061066290614180565b60008115612de657612de18261065985670de0b6b3a76400006130c2565b61065f565b50600092915050565b6101c45481565b600082815260656020526040902060020154612e14906104f9613369565b610a7e5760405162461bcd60e51b815260040161069c9061564e565b612e38614dd0565b612e4182613713565b6040805160a081018252825481526001830154602082015260028301549181019190915260038201546060820152600490910154608082015292915050565b60c95460009060ff16612ea55760405162461bcd60e51b815260040161069c90615a02565b60c9805460ff1916905560975460ff1615612ed25760405162461bcd60e51b815260040161069c906156c9565b6000612edd84613713565b90508060040154600014612f035760405162461bcd60e51b815260040161069c906157ea565b6001810154612f129084613a16565b6001820155612f1f614dff565b5060408051808201909152838152602081018590526101c554612f4a906001600160a01b0316613708565b6001600160a01b0316635be57b6a82336040518363ffffffff1660e01b8152600401612f77929190615b0a565b602060405180830381600087803b158015612f9157600080fd5b505af1158015612fa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc991906150c0565b6101c554909350612fee90612fe6906001600160a01b03166133d6565b3330876134a2565b8285336001600160a01b03167fcb3ef4109dcd006671348924f00aac8398190a5ff283d6e470d74581513e103687604051613029919061524f565b60405180910390a4505060c9805460ff1916600117905592915050565b600080516020615bbf83398151915281565b600080516020615bdf83398151915281565b6101c354604080516378592def60e11b815290516000926001600160a01b03169163f0b25bde916004808301926020929190829003018186803b158015610d5557600080fd5b600080516020615bff83398151915281565b6000826130d157506000610662565b828202828482816130de57fe5b041461065f5760405162461bcd60e51b815260040161069c906157a9565b600061065f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061418b565b613146613eef565b156131635760405162461bcd60e51b815260040161069c90615621565b6101d154156131845760405162461bcd60e51b815260040161069c90615a84565b6101c5546131ac9061319e906001600160a01b03166141c2565b6131a6613906565b90613a16565b6101d155565b303b1590565b600054610100900460ff16806131d157506131d16131b2565b806131df575060005460ff16155b6131fb5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015611035576000805460ff1961ff0019909116610100171660011790558015611047576000805461ff001916905550565b600054610100900460ff168061325257506132526131b2565b80613260575060005460ff16155b61327c5760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff161580156132a7576000805460ff1961ff0019909116610100171660011790555b6097805460ff191690558015611047576000805461ff001916905550565b600054610100900460ff16806132de57506132de6131b2565b806132ec575060005460ff16155b6133085760405162461bcd60e51b815260040161069c90615821565b600054610100900460ff16158015613333576000805460ff1961ff0019909116610100171660011790555b60c9805460ff191660011790558015611047576000805461ff001916905550565b60009182526065602052604090912060020155565b3390565b60008281526065602052604090206133859082614242565b156107fe57613392613369565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006106628261398d565b60006001600160a01b03821663b93f9b0a60065b6040518263ffffffff1660e01b8152600401613411919061524f565b60206040518083038186803b15801561342957600080fd5b505afa15801561343d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106629190614e8a565b61349d8383836040518060400160405280601881526020017704661696c656420746f207472616e736665722045524332360441b815250614257565b505050565b60408051808201909152601881527704661696c656420746f207472616e736665722045524332360441b6020820152611d298585858585614329565b60008281526065602052604090206134f690826143fe565b156107fe57613503613369565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60975460ff166135695760405162461bcd60e51b815260040161069c9061533c565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61359c613369565b6040516135a9919061516b565b60405180910390a1565b6101d1546135d35760405162461bcd60e51b815260040161069c906158d5565b6101c3546001600160a01b03166327ea6f2b61367c6135f0613ef8565b6101c360009054906101000a90046001600160a01b03166001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b15801561363f57600080fd5b505afa158015613653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061367791906150c0565b614413565b6040518263ffffffff1660e01b8152600401613698919061524f565b600060405180830381600087803b1580156136b257600080fd5b505af11580156136c6573d6000803e3d6000fd5b50506101c554600092506136e391506001600160a01b03166141c2565b90506136f1816131a6613906565b6101cc55613701816131a6613906565b6101d15550565b600061066282614429565b600060018214806137245750600282145b6137405760405162461bcd60e51b815260040161069c906154d8565b600060018314613752576101cd613756565b6101c85b9392505050565b60008060008061376d888861390a565b9092509050600061377e8383613a16565b9050808611156137a05760405162461bcd60e51b815260040161069c906158a6565b88600401546137ad613906565b116137ca5760405162461bcd60e51b815260040161069c9061569e565b60048901546137e85760018901546137e29087613f0d565b60018a01555b60006137f48488614413565b90506000613806846136778a85613f0d565b6101c55490915061381f906001600160a01b0316613708565b6001600160a01b031663b81922058a83856040518463ffffffff1660e01b815260040161384e93929190615b93565b600060405180830381600087803b15801561386857600080fd5b505af115801561387c573d6000803e3d6000fd5b50506101c5546138ab925061389a91506001600160a01b03166133d6565b30336138a68587613a16565b6134a2565b888a60200151336001600160a01b03167f92f2787b755dae547f1701582fe74c7abf277ec14db316dd01abc69cacf7a25985856040516138ec929190615b85565b60405180910390a490955093505050505b94509492505050565b4290565b600080600061392185600201548560400151610641565b9050600061393786600301548660400151610641565b9050613950856080015182613f0d90919063ffffffff16565b9350613969856060015183613f0d90919063ffffffff16565b925050505b9250929050565b60006001600160a01b03821663b93f9b0a600b6133f5565b60006001600160a01b03821663b93f9b0a60056133f5565b60975460ff16156139c85760405162461bcd60e51b815260040161069c906156c9565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861359c613369565b60006001600160a01b03821663b93f9b0a60036133f5565b60008282018381101561065f5760405162461bcd60e51b815260040161069c906154a1565b613a43613eef565b15613a605760405162461bcd60e51b815260040161069c906159d4565b60026000613a6d82613713565b90508060040154600014613a935760405162461bcd60e51b815260040161069c906157ea565b836001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b158015613acc57600080fd5b505afa158015613ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0491906150c0565b6001820155613b11614dff565b506040805180820190915260018201548152602081018390526101c554600090613b43906001600160a01b0316613708565b6101c5549091506000906001600160a01b0380841691635be57b6a918691613b6b9116614441565b6040518363ffffffff1660e01b8152600401613b88929190615b0a565b602060405180830381600087803b158015613ba257600080fd5b505af1158015613bb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bda91906150c0565b90506000613cef6101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015613c3057600080fd5b505afa158015613c44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c6891906150c0565b6101c360009054906101000a90046001600160a01b03166001600160a01b031663a4d66daf6040518163ffffffff1660e01b815260040160206040518083038186803b158015613cb757600080fd5b505afa158015613ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb691906150c0565b9050613cf961313e565b613d016135b3565b60001942016101d15560405163b819220560e01b81526001600160a01b0384169063b819220590613d3a90859085908c90600401615b93565b600060405180830381600087803b158015613d5457600080fd5b505af1158015613d68573d6000803e3d6000fd5b505060006101cf8190556101ca5550613d889050878281816101cd614459565b50505050505050505050565b60006001600160a01b03821663b93f9b0a60076133f5565b6101c554600090613dc5906001600160a01b0316614510565b6001600160a01b03166301b215516040518163ffffffff1660e01b8152600401602060405180830381600087803b158015613dff57600080fd5b505af1158015613e13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e379190614e8a565b6101c380546001600160a01b0319166001600160a01b0383811691909117918290556101c554604051630df8fa4360e41b81529394509181169263df8fa43092613e9392169030908c908c908c908c908c908c906004016151d9565b600060405180830381600087803b158015613ead57600080fd5b505af1158015613ec1573d6000803e3d6000fd5b5050505050505050505050565b600061065f838361451b565b600061065f836001600160a01b038416614560565b6101cc54151590565b6101c9546101ce54600091610d8d9190613a16565b600061065f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614578565b600080613f60848460200151612dc3565b9050613f6c81846145a4565b949350505050565b60008060006101c360009054906101000a90046001600160a01b03166001600160a01b031663a6a25e886040518163ffffffff1660e01b8152600401606060405180830381600087803b158015613fca57600080fd5b505af1158015613fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400291906150d8565b92509250925060008211806140175750600081115b1561349d576101c354600090614040906001600160a01b03168461403b8588613a16565b6145cb565b9050306001600160a01b03166101c360009054906101000a90046001600160a01b03166001600160a01b0316637df1f1b96040518163ffffffff1660e01b815260040160206040518083038186803b15801561409b57600080fd5b505afa1580156140af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d39190614e8a565b6001600160a01b03167fd1055dc2c2a003a83dfacb1c38db776eab5ef89d77a8f05a3512e8cf57f953ce858588866040516141119493929190615b6a565b60405180910390a350505050565b6101c55461104790614139906001600160a01b03166133d6565b6101c35460408051808201909152601981527811985a5b1959081d1bc818dbdb1b1958dd081c185e5b595b9d603a1b602082015233916001600160a01b0316908590614329565b60006106628261484e565b600081836141ac5760405162461bcd60e51b815260040161069c9190615258565b5060008385816141b857fe5b0495945050505050565b60006001600160a01b03821663fc56365860075b6040518263ffffffff1660e01b81526004016141f2919061524f565b60206040518083038186803b15801561420a57600080fd5b505afa15801561421e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066291906150c0565b600061065f836001600160a01b038416614852565b6001600160a01b03831661427d5760405162461bcd60e51b815260040161069c906153e7565b60405163a9059cbb60e01b81526000906001600160a01b0386169063a9059cbb906142ae90879087906004016151c0565b602060405180830381600087803b1580156142c857600080fd5b505af11580156142dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143009190614fc4565b905081816143215760405162461bcd60e51b815260040161069c9190615258565b505050505050565b6001600160a01b03831661434f5760405162461bcd60e51b815260040161069c906153e7565b6040516323b872dd60e01b81526000906001600160a01b038716906323b872dd9061438290889088908890600401615220565b602060405180830381600087803b15801561439c57600080fd5b505af11580156143b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143d49190614fc4565b905081816143f55760405162461bcd60e51b815260040161069c9190615258565b50505050505050565b600061065f836001600160a01b03841661489c565b6000818310614422578161065f565b5090919050565b60006001600160a01b03821663b93f9b0a600c6133f5565b60006001600160a01b03821663b93f9b0a600e6133f5565b60008060008360010154905060006144778986600301548985614962565b600387018054908290556002880154929b509092509061449a908a908986614962565b600288018054908290558854929b5090935090307f42a55d7508b1c40b53524cf7cc2558b0f6bc7c4f262a3e929b65cd48bec2b687856144da8186613f0d565b60038c01546144e98189613f0d565b6040516144f99493929190615b6a565b60405180910390a350989997985050505050505050565b6000610662826149bb565b8154600090821061453e5760405162461bcd60e51b815260040161069c906152ab565b82600001828154811061454d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6000818484111561459c5760405162461bcd60e51b815260040161069c9190615258565b505050900390565b6101c9546101ce5460009182916145ba91613a16565b9050613f6c848460200151836149d3565b6101c55460009061462b906145e8906001600160a01b03166133d6565b85306145f48688613a16565b6040518060400160405280601981526020017811985a5b1959081d1bc818dbdb1b1958dd081c185e5b595b9d603a1b815250614329565b600080614636614a2c565b6101c554919350915060009061466090614658906001600160a01b0316614ba3565b6064906130fc565b6040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc546080820152909150869086906000906146ab908790613f4f565b6040805160a0810182526101c85481526101c95460208201526101ca54918101919091526101cb5460608201526101cc5460808201529091506000906146f2908790613f4f565b905060006147228361471b614713896101c654613a1690919063ffffffff16565b606490613f0d565b60646149d3565b90506000614732868860646149d3565b905061473e8a82613a16565b995061474a8682613f0d565b955061475b868684866101c8614bbb565b6101ce54919750955061477d90614773908890612dc3565b6101d05490613a16565b6040805160a0810182526101cd5481526101ce5460208201526101cf54918101919091526101d05460608201526101d15460808201529094506147c1908990613f4f565b92506147d2868686866101cd614bbb565b90965094506147e18686613a16565b95506147ef858860646149d3565b90506147fb8a82613a16565b99506148078682613f0d565b95506000945061483061481a8787613a16565b60006148268989613a16565b60006101cd614459565b909650945061483e8a614c41565b5050505050505050509392505050565b5490565b600061485e8383614560565b61489457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610662565b506000610662565b6000818152600183016020526040812054801561495857835460001980830191908101906000908790839081106148cf57fe5b90600052602060002001549050808760000184815481106148ec57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061491c57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610662565b6000915050610662565b600080851580614970575083155b1561497f5750849050836138fd565b8386101561498b578593505b60006149978585612dc3565b90506149a38786613f0d565b6149ad8783613a16565b925092505094509492505050565b60006001600160a01b03821663b93f9b0a60026133f5565b60006149dd614e19565b6149e683614cf0565b90506149f0614e19565b6149f985614cf0565b9050614a21670de0b6b3a7640000614a1b88614a158587614d1e565b90614d56565b90614d77565b519695505050505050565b6000806101c360009054906101000a90046001600160a01b03166001600160a01b0316631cd724ac6040518163ffffffff1660e01b815260040160206040518083038186803b158015614a7e57600080fd5b505afa158015614a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ab691906150c0565b91506101c360009054906101000a90046001600160a01b03166001600160a01b031663193501146040518163ffffffff1660e01b815260040160206040518083038186803b158015614b0757600080fd5b505afa158015614b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b3f91906150c0565b9050614b9d614b966101c360009054906101000a90046001600160a01b03166001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015611e7657600080fd5b8290613a16565b90509091565b60006001600160a01b03821663fc56365860036141d6565b60018101546002820154600091829180861015614bd6578095505b600385015480881015614be7578097505b6000614bf38983613f0d565b90506000614c018286610641565b90506000614c0f8a86613f0d565b90506000614c1d8288610641565b9050614c2c8e8e85848e614459565b909f909e509c50505050505050505050505050565b306001600160a01b03167ff3583f178a8d4f8888c3683f8e948faf9b6eb701c4f1fab265a6ecad1a1ddebb82604051614c7a919061524f565b60405180910390a26101c55461104790614c9c906001600160a01b03166133d6565b6101c5543090614cb4906001600160a01b03166133e1565b846040518060400160405280601981526020017f4661696c656420746f2073656e6420746f207265736572766500000000000000815250614329565b614cf8614e19565b604080516020810190915280614d1684670de0b6b3a76400006130c2565b905292915050565b614d26614e19565b6040805160208101909152825184518291614d4d9161065990670de0b6b3a76400006130c2565b90529392505050565b614d5e614e19565b604080516020810190915283518190614d4d90856130c2565b614d7f614e19565b604080516020810190915283518190614d4d90856130fc565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b6040518060200160405280600081525090565b60008083601f840112614e3d578182fd5b50813567ffffffffffffffff811115614e54578182fd5b602083019150836020808302850101111561396e57600080fd5b600060208284031215614e7f578081fd5b813561065f81615ba9565b600060208284031215614e9b578081fd5b815161065f81615ba9565b600080600080600080600080610100898b031215614ec2578384fd5b8835614ecd81615ba9565b97506020890135614edd81615ba9565b979a9799505050506040860135956060810135956080820135955060a0820135945060c0820135935060e0909101359150565b60008060008060008060c08789031215614f28578182fd5b8635614f3381615ba9565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060408587031215614f70578384fd5b843567ffffffffffffffff80821115614f87578586fd5b614f9388838901614e2c565b90965094506020870135915080821115614fab578384fd5b50614fb887828801614e2c565b95989497509550505050565b600060208284031215614fd5578081fd5b8151801515811461065f578182fd5b600060208284031215614ff5578081fd5b5035919050565b6000806040838503121561500e578182fd5b82359150602083013561502081615ba9565b809150509250929050565b6000806040838503121561503d578182fd5b50508035926020909101359150565b600060a0828403121561505d578081fd5b60405160a0810181811067ffffffffffffffff8211171561507c578283fd5b604052825161508a81615ba9565b80825250602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b6000602082840312156150d1578081fd5b5051919050565b6000806000606084860312156150ec578081fd5b8351925060208401519150604084015190509250925092565b60008060008060008060c0878903121561511d578384fd5b863595506020870135945060408701359350606087013560ff81168114615142578283fd5b9598949750929560808101359460a0909101359350915050565b80518252602090810151910152565b6001600160a01b0391909116815260200190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03988916815296881660208801529490961660408601526060850192909252608084015260a083015260c082019290925260e08101919091526101000190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b8181101561528457858101830151858201604001528201615268565b818111156152955783604083870101525b50601f01601f1916929092016040019392505050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b6020808252601690820152754661696c656420746f20617070726f7665205553444360501b604082015260600190565b6020808252602d908201527f546f6b656e7349647320616e6420416d6f756e7473206d75737420626520746860408201526c0ca40e6c2daca40d8cadccee8d609b1b606082015260800190565b6020808252601a908201527f43616e27742073656e6420746f207a65726f2061646472657373000000000000604082015260600190565b6020808252602c908201527f4d75737420686176652070617573657220726f6c6520746f20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b6020808252601a908201527f4372656469746c696e652063616e6e6f7420626520656d707479000000000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b602080825260139082015272556e737570706f72746564207472616e63686560681b604082015260600190565b6020808252602d908201527f436f6e66696720616e6420626f72726f7765722061646472657373657320636160408201526c6e6e6f7420626520656d70747960981b606082015260800190565b6020808252601e908201527f4f6e6c7920637265646974206465736b2063616e2063616c6c20746869730000604082015260600190565b6020808252601a908201527f426f72726f776572206d757374206e6f7420626520656d707479000000000000604082015260600190565b6020808252601d908201527f4f776e657220616464726573732063616e6e6f7420626520656d707479000000604082015260600190565b60208082526010908201526f105b1c9958591e481b5a59dc985d195960821b604082015260600190565b602080825260139082015272141bdbdb08185b1c9958591e481b1bd8dad959606a1b604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b602080825260119082015270151c985b98da19481a5cc81b1bd8dad959607a1b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f5061796d656e7420706572696f64206d757374206e6f7420626520656d707479604082015260600190565b6020808252602c908201527f4d7573742068617665206c6f636b657220726f6c6520746f20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b6020808252818101527f4f776e65722063616e6e6f7420626520746865207a65726f2061646472657373604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f5472616e63686520686173206265656e206c6f636b6564000000000000000000604082015260600190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601e908201527f44726177646f776e73206172652063757272656e746c79207061757365640000604082015260600190565b602080825260159082015274125b9d985b1a59081c995919595b48185b5bdd5b9d605a1b604082015260600190565b60208082526023908201527f4a756e696f72207472616e636865206d757374206265206c6f636b65642066696040820152621c9cdd60ea1b606082015260800190565b60208082526035908201527f4f6e6c792074686520746f6b656e206f776e657220697320616c6c6f776564206040820152743a379031b0b636103a3434b990333ab731ba34b7b760591b606082015260800190565b6020808252601690820152755465726d206d757374206e6f7420626520656d70747960501b604082015260600190565b60208082526017908201527f4d75737420706179206d6f7265207468616e207a65726f000000000000000000604082015260600190565b602080825260149082015273141bdbdb081a185cc81899595b881b1bd8dad95960621b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602b908201527f4d75737420686176652061646d696e20726f6c6520746f20706572666f726d2060408201526a3a3434b99030b1ba34b7b760a91b606082015260800190565b6020808252601d908201527f4a756e696f72207472616e63686520616c7265616479206c6f636b6564000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b60608101615b18828561515c565b6001600160a01b039290921660409190910152919050565b600060a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b93845260208401929092526040830152606082015260800190565b918252602082015260400190565b9283526020830191909152604082015260600190565b6001600160a01b038116811461104757600080fdfeb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aaf9a8bb3cbd6b84fbccefa71ff73e26e798553c6914585a84886212a46a90279a2646970667358221220f21929af0f55a8aa725e56cfb1850a6cb4c754f8f75b561b008df7d80e060e6264736f6c634300060c0033
Loading...
Loading
Loading...
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
[ 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.