Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Cross-Chain Transactions
Loading...
Loading
Contract Name:
UsdcPool
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: 5ec1894d31c2b378fec21fa1613df34e7438169c;
pragma solidity 0.8.17;
import "../../Pool.sol";
/**
* @title UsdcPool
* @dev Contract allowing user to deposit to and borrow USDC from a dedicated user account
*/
contract UsdcPool is Pool {
function name() public virtual override pure returns(string memory _name){
_name = "DeltaPrimeUSDCoin";
}
function symbol() public virtual override pure returns(string memory _symbol){
_symbol = "DPUSDC";
}
function decimals() public virtual override pure returns(uint8 decimals){
decimals = 6;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.0;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
abstract 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 protect an initializer function from being invoked twice.
*/
modifier initializer() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/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].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/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 meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)
pragma solidity ^0.8.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.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a / b + (a % b == 0 ? 0 : 1);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.0;
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: ;
pragma solidity 0.8.17;
/**
* @title IBorrowersRegistry
* Keeps a registry of created trading accounts to verify their borrowing rights
*/
interface IBorrowersRegistry {
function canBorrow(address _account) external view returns (bool);
function getLoanForOwner(address _owner) external view returns (address);
function getOwnerOfLoan(address _loan) external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: c5c938a0524b45376dd482cd5c8fb83fa94c2fcc;
pragma solidity 0.8.17;
interface IIndex {
function setRate(uint256 _rate) external;
function updateUser(address user) external;
function getIndex() external view returns (uint256);
function getIndexedValue(uint256 value, address user) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: ;
pragma solidity ^0.8.17;
interface IPoolRewarder {
function stakeFor(uint _amount, address _stakeFor) external;
function withdrawFor(uint _amount, address _unstakeFor) external returns (uint);
function getRewardsFor(address _user) external;
function earned(address _account) external view returns (uint);
function balanceOf(address _account) external view returns (uint);
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: ;
pragma solidity 0.8.17;
/**
* @title IRatesCalculator
* @dev Interface defining base method for contracts implementing interest rates calculation.
* The calculated value could be based on the relation between funds borrowed and deposited.
*/
interface IRatesCalculator {
function calculateBorrowingRate(uint256 totalLoans, uint256 totalDeposits) external view returns (uint256);
function calculateDepositRate(uint256 totalLoans, uint256 totalDeposits) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: 5ec1894d31c2b378fec21fa1613df34e7438169c;
pragma solidity 0.8.17;
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@uniswap/lib/contracts/libraries/TransferHelper.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./interfaces/IIndex.sol";
import "./interfaces/IRatesCalculator.sol";
import "./interfaces/IBorrowersRegistry.sol";
import "./interfaces/IPoolRewarder.sol";
import "./VestingDistributor.sol";
/**
* @title Pool
* @dev Contract allowing user to deposit to and borrow from a dedicated user account
* Depositors are rewarded with the interest rates collected from borrowers.
* The interest rates calculation is delegated to an external calculator contract.
*/
contract Pool is OwnableUpgradeable, ReentrancyGuardUpgradeable, IERC20 {
using TransferHelper for address payable;
uint256 public totalSupplyCap;
mapping(address => mapping(address => uint256)) private _allowed;
mapping(address => uint256) internal _deposited;
mapping(address => uint256) public borrowed;
IRatesCalculator public ratesCalculator;
IBorrowersRegistry public borrowersRegistry;
IPoolRewarder public poolRewarder;
IIndex public depositIndex;
IIndex public borrowIndex;
address payable public tokenAddress;
VestingDistributor public vestingDistributor;
uint8 internal _decimals;
function initialize(IRatesCalculator ratesCalculator_, IBorrowersRegistry borrowersRegistry_, IIndex depositIndex_, IIndex borrowIndex_, address payable tokenAddress_, IPoolRewarder poolRewarder_, uint256 _totalSupplyCap) public initializer {
require(AddressUpgradeable.isContract(address(ratesCalculator_))
&& AddressUpgradeable.isContract(address(borrowersRegistry_))
&& AddressUpgradeable.isContract(address(depositIndex_))
&& AddressUpgradeable.isContract(address(borrowIndex_))
&& (AddressUpgradeable.isContract(address(poolRewarder_)) || address(poolRewarder_) == address(0)), "Wrong init arguments");
borrowersRegistry = borrowersRegistry_;
ratesCalculator = ratesCalculator_;
depositIndex = depositIndex_;
borrowIndex = borrowIndex_;
poolRewarder = poolRewarder_;
tokenAddress = tokenAddress_;
totalSupplyCap = _totalSupplyCap;
_decimals = IERC20Metadata(tokenAddress_).decimals();
__Ownable_init();
__ReentrancyGuard_init();
_updateRates();
}
/* ========== SETTERS ========== */
/**
* Sets new totalSupplyCap limiting how much in total can be deposited to the Pool.
* Only the owner of the Contract can execute this function.
* @dev _newTotalSupplyCap new deposit cap
**/
function setTotalSupplyCap(uint256 _newTotalSupplyCap) external onlyOwner {
totalSupplyCap = _newTotalSupplyCap;
}
/**
* Sets the new Pool Rewarder.
* The IPoolRewarder that distributes additional token rewards to people having a stake in this pool proportionally to their stake and time of participance.
* Only the owner of the Contract can execute this function.
* @dev _poolRewarder the address of PoolRewarder
**/
function setPoolRewarder(IPoolRewarder _poolRewarder) external onlyOwner {
if(!AddressUpgradeable.isContract(address(_poolRewarder)) && address(_poolRewarder) != address(0)) revert NotAContract(address(poolRewarder));
poolRewarder = _poolRewarder;
emit PoolRewarderChanged(address(_poolRewarder), block.timestamp);
}
/**
* Sets the new rate calculator.
* The calculator is an external contract that contains the logic for calculating deposit and borrowing rates.
* Only the owner of the Contract can execute this function.
* @dev ratesCalculator the address of rates calculator
**/
function setRatesCalculator(IRatesCalculator ratesCalculator_) external onlyOwner {
// setting address(0) ratesCalculator_ freezes the pool
if(!AddressUpgradeable.isContract(address(ratesCalculator_)) && address(ratesCalculator_) != address(0)) revert NotAContract(address(ratesCalculator_));
ratesCalculator = ratesCalculator_;
if (address(ratesCalculator_) != address(0)) {
_updateRates();
}
emit RatesCalculatorChanged(address(ratesCalculator_), block.timestamp);
}
/**
* Sets the new borrowers registry contract.
* The borrowers registry decides if an account can borrow funds.
* Only the owner of the Contract can execute this function.
* @dev borrowersRegistry the address of borrowers registry
**/
function setBorrowersRegistry(IBorrowersRegistry borrowersRegistry_) external onlyOwner {
if(!AddressUpgradeable.isContract(address(borrowersRegistry_))) revert NotAContract(address(borrowersRegistry_));
borrowersRegistry = borrowersRegistry_;
emit BorrowersRegistryChanged(address(borrowersRegistry_), block.timestamp);
}
/**
* Sets the new Pool Rewarder.
* The IPoolRewarder that distributes additional token rewards to people having a stake in this pool proportionally to their stake and time of participance.
* Only the owner of the Contract can execute this function.
* @dev _poolRewarder the address of PoolRewarder
**/
function setVestingDistributor(address _distributor) external onlyOwner {
if(!AddressUpgradeable.isContract(_distributor) && _distributor != address(0)) revert NotAContract(_distributor);
vestingDistributor = VestingDistributor(_distributor);
emit VestingDistributorChanged(_distributor, block.timestamp);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function transfer(address recipient, uint256 amount) external override nonReentrant returns (bool) {
if(recipient == address(0)) revert TransferToZeroAddress();
if(recipient == address(this)) revert TransferToPoolAddress();
address account = msg.sender;
_accumulateDepositInterest(account);
(uint256 lockedAmount, uint256 transferrableAmount) = _getAmounts(account);
if(amount > transferrableAmount) revert TransferAmountExceedsBalance(amount, transferrableAmount);
_updateWithdrawn(account, amount, lockedAmount);
// (this is verified in "require" above)
unchecked {
_deposited[account] -= amount;
}
_accumulateDepositInterest(recipient);
_deposited[recipient] += amount;
// Handle rewards
if(address(poolRewarder) != address(0) && amount != 0){
uint256 unstaked = poolRewarder.withdrawFor(amount, account);
if(unstaked > 0) {
poolRewarder.stakeFor(unstaked, recipient);
}
}
emit Transfer(account, recipient, amount);
return true;
}
function allowance(address owner, address spender) external view override returns (uint256) {
return _allowed[owner][spender];
}
function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
if(spender == address(0)) revert SpenderZeroAddress();
uint256 newAllowance = _allowed[msg.sender][spender] + addedValue;
_allowed[msg.sender][spender] = newAllowance;
emit Approval(msg.sender, spender, newAllowance);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
if(spender == address(0)) revert SpenderZeroAddress();
uint256 currentAllowance = _allowed[msg.sender][spender];
if(currentAllowance < subtractedValue) revert InsufficientAllowance(subtractedValue, currentAllowance);
uint256 newAllowance = currentAllowance - subtractedValue;
_allowed[msg.sender][spender] = newAllowance;
emit Approval(msg.sender, spender, newAllowance);
return true;
}
function approve(address spender, uint256 amount) external override returns (bool) {
if(spender == address(0)) revert SpenderZeroAddress();
_allowed[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) external override nonReentrant returns (bool) {
if(_allowed[sender][msg.sender] < amount) revert InsufficientAllowance(amount, _allowed[sender][msg.sender]);
if(recipient == address(0)) revert TransferToZeroAddress();
if(recipient == address(this)) revert TransferToPoolAddress();
_accumulateDepositInterest(sender);
(uint256 lockedAmount, uint256 transferrableAmount) = _getAmounts(sender);
if(amount > transferrableAmount) revert TransferAmountExceedsBalance(amount, transferrableAmount);
_updateWithdrawn(sender, amount, lockedAmount);
_deposited[sender] -= amount;
_allowed[sender][msg.sender] -= amount;
_accumulateDepositInterest(recipient);
_deposited[recipient] += amount;
// Handle rewards
if(address(poolRewarder) != address(0) && amount != 0){
uint256 unstaked = poolRewarder.withdrawFor(amount, sender);
if(unstaked > 0) {
poolRewarder.stakeFor(unstaked, recipient);
}
}
emit Transfer(sender, recipient, amount);
return true;
}
/**
* Deposits the amount
* It updates user deposited balance, total deposited and rates
**/
function deposit(uint256 _amount) public virtual {
depositOnBehalf(_amount, msg.sender);
}
/**
* Deposits the amount on behalf of `_of` user.
* It updates `_of` user deposited balance, total deposited and rates
**/
function depositOnBehalf(uint256 _amount, address _of) public virtual nonReentrant {
if(_amount == 0) revert ZeroDepositAmount();
require(_of != address(0), "Address zero");
require(_of != address(this), "Cannot deposit on behalf of pool");
_amount = Math.min(_amount, IERC20(tokenAddress).balanceOf(msg.sender));
_accumulateDepositInterest(_of);
if(totalSupplyCap != 0){
if(_deposited[address(this)] + _amount > totalSupplyCap) revert TotalSupplyCapBreached();
}
_transferToPool(msg.sender, _amount);
_mint(_of, _amount);
_deposited[address(this)] += _amount;
_updateRates();
if (address(poolRewarder) != address(0)) {
poolRewarder.stakeFor(_amount, _of);
}
emit DepositOnBehalfOf(msg.sender, _of, _amount, block.timestamp);
}
function _transferToPool(address from, uint256 amount) internal virtual {
tokenAddress.safeTransferFrom(from, address(this), amount);
}
function _transferFromPool(address to, uint256 amount) internal virtual {
tokenAddress.safeTransfer(to, amount);
}
/**
* Withdraws selected amount from the user deposits
* @dev _amount the amount to be withdrawn
**/
function withdraw(uint256 _amount) external nonReentrant {
_accumulateDepositInterest(msg.sender);
_amount = Math.min(_amount, _deposited[msg.sender]);
if(_amount > IERC20(tokenAddress).balanceOf(address(this))) revert InsufficientPoolFunds();
if(_amount > _deposited[address(this)]) revert BurnAmountExceedsBalance();
// verified in "require" above
unchecked {
_deposited[address(this)] -= _amount;
}
_burn(msg.sender, _amount);
_updateRates();
_transferFromPool(msg.sender, _amount);
if (address(poolRewarder) != address(0)) {
poolRewarder.withdrawFor(_amount, msg.sender);
}
emit Withdrawal(msg.sender, _amount, block.timestamp);
}
/**
* Borrows the specified amount
* It updates user borrowed balance, total borrowed amount and rates
* @dev _amount the amount to be borrowed
* @dev It is only meant to be used by a SmartLoanDiamondProxy
**/
function borrow(uint256 _amount) public virtual canBorrow nonReentrant {
if (_amount > IERC20(tokenAddress).balanceOf(address(this))) revert InsufficientPoolFunds();
_accumulateBorrowingInterest(msg.sender);
borrowed[msg.sender] += _amount;
borrowed[address(this)] += _amount;
_transferFromPool(msg.sender, _amount);
_updateRates();
emit Borrowing(msg.sender, _amount, block.timestamp);
}
/**
* Repays the amount
* It updates user borrowed balance, total borrowed amount and rates
* @dev It is only meant to be used by a SmartLoanDiamondProxy
**/
function repay(uint256 amount) external nonReentrant {
_accumulateBorrowingInterest(msg.sender);
if(amount > borrowed[msg.sender]) revert RepayingMoreThanWasBorrowed();
_transferToPool(msg.sender, amount);
borrowed[msg.sender] -= amount;
borrowed[address(this)] -= amount;
_updateRates();
emit Repayment(msg.sender, amount, block.timestamp);
}
/* =========
/**
* Returns the current borrowed amount for the given user
* The value includes the interest rates owned at the current moment
* @dev _user the address of queried borrower
**/
function getBorrowed(address _user) public view returns (uint256) {
return borrowIndex.getIndexedValue(borrowed[_user], _user);
}
function name() public virtual pure returns(string memory _name){
_name = "";
}
function symbol() public virtual pure returns(string memory _symbol){
_symbol = "";
}
function decimals() public virtual view returns(uint8){
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return balanceOf(address(this));
}
function totalBorrowed() public view returns (uint256) {
return getBorrowed(address(this));
}
// Calls the IPoolRewarder.getRewardsFor() that sends pending rewards to msg.sender
function getRewards() external {
poolRewarder.getRewardsFor(msg.sender);
}
// Returns number of pending rewards for msg.sender
function checkRewards() external view returns (uint256) {
return poolRewarder.earned(msg.sender);
}
// Returns max. acceptable pool utilisation after borrow action
function getMaxPoolUtilisationForBorrowing() virtual public view returns (uint256) {
return 0.9e18;
}
/**
* Returns the current deposited amount for the given user
* The value includes the interest rates earned at the current moment
* @dev _user the address of queried depositor
**/
function balanceOf(address user) public view override returns (uint256) {
return depositIndex.getIndexedValue(_deposited[user], user);
}
/**
* Returns the current interest rate for deposits
**/
function getDepositRate() public view returns (uint256) {
return ratesCalculator.calculateDepositRate(totalBorrowed(), totalSupply());
}
/**
* Returns the current interest rate for borrowings
**/
function getBorrowingRate() public view returns (uint256) {
return ratesCalculator.calculateBorrowingRate(totalBorrowed(), totalSupply());
}
/**
* Returns full pool status
*/
function getFullPoolStatus() public view returns (uint256[5] memory) {
return [
totalSupply(),
getDepositRate(),
getBorrowingRate(),
totalBorrowed(),
getMaxPoolUtilisationForBorrowing()
];
}
/**
* Recovers the surplus funds resultant from difference between deposit and borrowing rates
**/
function recoverSurplus(uint256 amount, address account) public onlyOwner nonReentrant {
uint256 balance = IERC20(tokenAddress).balanceOf(address(this));
uint256 surplus = balance + totalBorrowed() - totalSupply();
if(amount > balance) revert InsufficientPoolFunds();
if(surplus < amount) revert InsufficientSurplus();
_transferFromPool(account, amount);
}
/* ========== INTERNAL FUNCTIONS ========== */
function _mint(address to, uint256 amount) internal {
if(to == address(0)) revert MintToAddressZero();
_deposited[to] += amount;
emit Transfer(address(0), to, amount);
}
function _burn(address account, uint256 amount) internal {
if(amount > _deposited[account]) revert BurnAmountExceedsBalance();
(uint256 lockedAmount, uint256 transferrableAmount) = _getAmounts(account);
if(amount > transferrableAmount) revert BurnAmountExceedsAvailableForUser();
_updateWithdrawn(account, amount, lockedAmount);
// verified in "require" above
unchecked {
_deposited[account] -= amount;
}
emit Transfer(account, address(0), amount);
}
function _getAmounts(address account) internal view returns (uint256 lockedAmount, uint256 transferrableAmount) {
if (address(vestingDistributor) != address(0)) {
lockedAmount = vestingDistributor.locked(account);
transferrableAmount = _deposited[account] - (lockedAmount - vestingDistributor.availableToWithdraw(account));
} else {
transferrableAmount = _deposited[account];
}
}
function _updateWithdrawn(address account, uint256 amount, uint256 lockedAmount) internal {
uint256 availableUnvested = _deposited[account] - lockedAmount;
if (amount > availableUnvested && address(vestingDistributor) != address(0)) {
vestingDistributor.updateWithdrawn(account, amount - availableUnvested);
}
}
function _updateRates() internal {
uint256 _totalBorrowed = totalBorrowed();
uint256 _totalSupply = totalSupply();
if(address(ratesCalculator) == address(0)) revert PoolFrozen();
depositIndex.setRate(ratesCalculator.calculateDepositRate(_totalBorrowed, _totalSupply));
borrowIndex.setRate(ratesCalculator.calculateBorrowingRate(_totalBorrowed, _totalSupply));
}
function _accumulateDepositInterest(address user) internal {
uint256 interest = balanceOf(user) - _deposited[user];
_mint(user, interest);
_deposited[address(this)] = balanceOf(address(this));
emit InterestCollected(user, interest, block.timestamp);
depositIndex.updateUser(user);
depositIndex.updateUser(address(this));
}
function _accumulateBorrowingInterest(address user) internal {
borrowed[user] = getBorrowed(user);
borrowed[address(this)] = getBorrowed(address(this));
borrowIndex.updateUser(user);
borrowIndex.updateUser(address(this));
}
/* ========== OVERRIDDEN FUNCTIONS ========== */
function renounceOwnership() public virtual override {}
/* ========== MODIFIERS ========== */
modifier canBorrow() {
if(address(borrowersRegistry) == address(0)) revert BorrowersRegistryNotConfigured();
if(!borrowersRegistry.canBorrow(msg.sender)) revert NotAuthorizedToBorrow();
if(totalSupply() == 0) revert InsufficientPoolFunds();
_;
if((totalBorrowed() * 1e18) / totalSupply() > getMaxPoolUtilisationForBorrowing()) revert MaxPoolUtilisationBreached();
}
/* ========== EVENTS ========== */
/**
* @dev emitted after the user deposits funds
* @param user the address performing the deposit
* @param value the amount deposited
* @param timestamp of the deposit
**/
event Deposit(address indexed user, uint256 value, uint256 timestamp);
/**
* @dev emitted after the user deposits funds on behalf of other user
* @param user the address performing the deposit
* @param _of the address on behalf of which the deposit is being performed
* @param value the amount deposited
* @param timestamp of the deposit
**/
event DepositOnBehalfOf(address indexed user, address indexed _of, uint256 value, uint256 timestamp);
/**
* @dev emitted after the user withdraws funds
* @param user the address performing the withdrawal
* @param value the amount withdrawn
* @param timestamp of the withdrawal
**/
event Withdrawal(address indexed user, uint256 value, uint256 timestamp);
/**
* @dev emitted after the user borrows funds
* @param user the address that borrows
* @param value the amount borrowed
* @param timestamp time of the borrowing
**/
event Borrowing(address indexed user, uint256 value, uint256 timestamp);
/**
* @dev emitted after the user repays debt
* @param user the address that repays debt
* @param value the amount repaid
* @param timestamp of the repayment
**/
event Repayment(address indexed user, uint256 value, uint256 timestamp);
/**
* @dev emitted after accumulating deposit interest
* @param user the address that the deposit interest is accumulated for
* @param value the amount that interest is calculated from
* @param timestamp of the interest accumulation
**/
event InterestCollected(address indexed user, uint256 value, uint256 timestamp);
/**
* @dev emitted after changing borrowers registry
* @param registry an address of the newly set borrowers registry
* @param timestamp of the borrowers registry change
**/
event BorrowersRegistryChanged(address indexed registry, uint256 timestamp);
/**
* @dev emitted after changing rates calculator
* @param calculator an address of the newly set rates calculator
* @param timestamp of the borrowers registry change
**/
event RatesCalculatorChanged(address indexed calculator, uint256 timestamp);
/**
* @dev emitted after changing pool rewarder
* @param poolRewarder an address of the newly set pool rewarder
* @param timestamp of the pool rewarder change
**/
event PoolRewarderChanged(address indexed poolRewarder, uint256 timestamp);
/**
* @dev emitted after changing vesting distributor
* @param distributor an address of the newly set distributor
* @param timestamp of the distributor change
**/
event VestingDistributorChanged(address indexed distributor, uint256 timestamp);
/* ========== ERRORS ========== */
// Only authorized accounts may borrow
error NotAuthorizedToBorrow();
// Borrowers registry is not configured
error BorrowersRegistryNotConfigured();
// Pool is frozen
error PoolFrozen();
// Not enough funds in the pool.
error InsufficientPoolFunds();
// Insufficient pool surplus to cover the requested recover amount
error InsufficientSurplus();
// Address (`target`) must be a contract
// @param target target address that must be a contract
error NotAContract(address target);
// ERC20: Spender cannot be a zero address
error SpenderZeroAddress();
// ERC20: cannot transfer to the zero address
error TransferToZeroAddress();
// ERC20: cannot transfer to the pool address
error TransferToPoolAddress();
// ERC20: transfer amount (`amount`) exceeds balance (`balance`)
/// @param amount transfer amount
/// @param balance available balance
error TransferAmountExceedsBalance(uint256 amount, uint256 balance);
// ERC20: requested transfer amount (`requested`) exceeds current allowance (`allowance`)
/// @param requested requested transfer amount
/// @param allowance current allowance
error InsufficientAllowance(uint256 requested, uint256 allowance);
// This deposit operation would result in a breach of the totalSupplyCap
error TotalSupplyCapBreached();
// The deposit amount must be > 0
error ZeroDepositAmount();
// ERC20: cannot mint to the zero address
error MintToAddressZero();
// ERC20: burn amount exceeds current pool indexed balance
error BurnAmountExceedsBalance();
// ERC20: burn amount exceeds current amount available (including vesting)
error BurnAmountExceedsAvailableForUser();
// Trying to repay more than was borrowed
error RepayingMoreThanWasBorrowed();
// getMaxPoolUtilisationForBorrowing was breached
error MaxPoolUtilisationBreached();
}// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: 9f1e1bba11316303810f35a4440e20bc5ad0ef86;
pragma solidity 0.8.17;
import "./Pool.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
/**
* @title VestingDistributor
* @dev Contract distributing pool's spread among vesting participants.
*/
contract VestingDistributor {
Pool pool;
IERC20Metadata poolToken;
address keeper;
address pendingKeeper;
uint256 totalLockedMultiplied;
address[] public participants;
mapping(address => uint256) public locked;
mapping(address => uint256) public withdrawn;
mapping(address => uint256) public unvestingTime;
mapping(address => uint256) public unlockTimestamp;
mapping(address => uint256) public multiplier;
mapping(uint256 => uint256) rewardAmount;
mapping(uint256 => mapping(address => bool)) rewardDistributed;
mapping(uint256 => uint256) numRewardDistributed;
uint256 lastUpdated;
uint256 updateInterval = 6 hours;
uint256 public constant ONE_DAY = 24 * 3600; // 24 hours * 3600 seconds
uint256 public constant MIN_VESTING_TIME = ONE_DAY; // 1 day * 24 hours * 3600 seconds
uint256 public constant MAX_VESTING_TIME = 30 * ONE_DAY; // 30 days * 24 hours * 3600 seconds
modifier onlyPool() {
require(msg.sender == address(pool), "Unauthorized: onlyPool");
_;
}
modifier onlyKeeper() {
require(msg.sender == keeper, "Unauthorized: onlyKeeper");
_;
}
modifier onlyPendingKeeper() {
require(msg.sender == pendingKeeper, "Unauthorized: onlyPendingKeeper");
_;
}
constructor(address poolAddress, address keeperAddress) {
pool = Pool(poolAddress);
poolToken = IERC20Metadata(pool.tokenAddress());
keeper = keeperAddress;
lastUpdated = block.timestamp;
}
function transferKeeper(address keeperAddress) external onlyKeeper {
pendingKeeper = keeperAddress;
}
function acceptKeeper() external onlyPendingKeeper {
keeper = pendingKeeper;
pendingKeeper = address(0);
}
/**
* Add vesting participant (msg.sender)
**/
function startVesting(uint256 amount, uint256 time) public {
if (time < MIN_VESTING_TIME || time > MAX_VESTING_TIME) revert InvalidVestingTime();
if (pool.balanceOf(msg.sender) < amount) revert InsufficientPoolBalance();
if (locked[msg.sender] > 0 || unvestingTime[msg.sender] > 0) revert AlreadyLocked();
participants.push(msg.sender);
locked[msg.sender] = amount;
unvestingTime[msg.sender] = time;
multiplier[msg.sender] = getMultiplier(time);
totalLockedMultiplied += amount * multiplier[msg.sender] / 1e18;
}
/**
* Increase vesting of msg.sender
**/
function increaseVesting(uint256 amount) public {
if (locked[msg.sender] == 0 || unvestingTime[msg.sender] == 0) revert UserNotLocked();
if (pool.balanceOf(msg.sender) < locked[msg.sender] + amount) revert InsufficientPoolBalance();
if (unlockTimestamp[msg.sender] > 0) revert TooLate();
locked[msg.sender] += amount;
totalLockedMultiplied += amount * multiplier[msg.sender] / 1e18;
}
/**
* Unlock funds - start of unvesting
**/
function unlock() public {
if (locked[msg.sender] == 0 || unvestingTime[msg.sender] == 0) revert UserNotLocked();
unlockTimestamp[msg.sender] = block.timestamp;
}
/**
* Check how much user can withdraw
**/
function availableToWithdraw(address account) public view returns (uint256) {
if (locked[account] == 0 || unvestingTime[account] == 0) revert UserNotLocked();
if (unlockTimestamp[account] == 0) revert UserLocked();
uint256 timeFromUnlock = block.timestamp - unlockTimestamp[account];
if (timeFromUnlock > unvestingTime[account]) timeFromUnlock = unvestingTime[account];
uint256 initialUnlock = ONE_DAY * locked[account] / (unvestingTime[account] + ONE_DAY); // 1D / vesting days * locked amount
return initialUnlock + timeFromUnlock * (locked[account] - initialUnlock) / unvestingTime[account];
}
/**
* Gets pool's spread and distributes among vesting participants.
* @dev _totalLoans total value of loans
* @dev _totalDeposits total value of deposits
**/
//TODO: run periodically by bots
function distributeRewards(uint256 fromIndex, uint256 toIndex) public onlyKeeper {
if (block.timestamp < lastUpdated + updateInterval) revert DistributeTooEarly();
(fromIndex, toIndex) = fromIndex < toIndex ? (fromIndex, toIndex) : (toIndex, fromIndex);
toIndex = toIndex < participants.length ? toIndex : participants.length - 1;
if (rewardAmount[lastUpdated] == 0) {
rewardAmount[lastUpdated] = pool.balanceOf(address(this));
}
uint256 rewards = rewardAmount[lastUpdated];
for (uint256 i = fromIndex; i <= toIndex; i++) {
address participant = participants[i];
if (rewardDistributed[lastUpdated][participant]) {
continue;
}
//TODO: right now we distribute rewards even when someone start withdrawing. The rewards should depend on the amount which is still locked.
uint256 participantReward = rewards * (locked[participant] - withdrawn[participant]) * multiplier[participant] / 1e18 / totalLockedMultiplied;
pool.transfer(participant, participantReward);
rewardDistributed[lastUpdated][participant] = true;
++numRewardDistributed[lastUpdated];
if (numRewardDistributed[lastUpdated] == participants.length) {
lastUpdated = block.timestamp;
}
}
}
//TODO: run periodically by bots
function updateParticipants(uint256 fromIndex, uint256 toIndex) public onlyKeeper {
(fromIndex, toIndex) = fromIndex < toIndex ? (fromIndex, toIndex) : (toIndex, fromIndex);
toIndex = toIndex < participants.length ? toIndex : participants.length - 1;
for (uint256 i = fromIndex; i <= toIndex;) {
address participant = participants[i];
if (unlockTimestamp[participant] > 0 && (block.timestamp - unlockTimestamp[participant]) > unvestingTime[participant]) {
totalLockedMultiplied -= (locked[participant] - withdrawn[participant]) * multiplier[participant] / 1e18;
unvestingTime[participant] = 0;
locked[participant] = 0;
unlockTimestamp[participant] = 0;
withdrawn[participant] = 0;
multiplier[participant] = 0;
participants[i] = participants[participants.length - 1];
participants.pop();
--toIndex;
} else {
++i;
}
}
}
function updateWithdrawn(address account, uint256 amount) public onlyPool {
withdrawn[account] += amount;
if (withdrawn[account] > locked[account]) {
revert WithdrawMoreThanLocked();
}
totalLockedMultiplied -= amount * multiplier[account] / 1e18;
}
function getMultiplier(uint256 time) public pure returns (uint256){
if (time >= 30 * ONE_DAY) return 2e18; // min. 30 days
if (time >= 29 * ONE_DAY) return 1.99e18; // min. 29 days
if (time >= 28 * ONE_DAY) return 1.98e18; // min. 28 days
if (time >= 27 * ONE_DAY) return 1.97e18; // min. 27 days
if (time >= 26 * ONE_DAY) return 1.96e18; // min. 26 days
if (time >= 25 * ONE_DAY) return 1.948e18; // min. 25 days
if (time >= 24 * ONE_DAY) return 1.936e18; // min. 24 days
if (time >= 23 * ONE_DAY) return 1.924e18; // min. 23 days
if (time >= 22 * ONE_DAY) return 1.912e18; // min. 22 days
if (time >= 21 * ONE_DAY) return 1.9e18; // min. 21 days
if (time >= 20 * ONE_DAY) return 1.885e18; // min. 20 days
if (time >= 19 * ONE_DAY) return 1.871e18; // min. 19 days
if (time >= 18 * ONE_DAY) return 1.856e18; // min. 18 days
if (time >= 17 * ONE_DAY) return 1.841e18; // min. 17 days
if (time >= 16 * ONE_DAY) return 1.824e18; // min. 16 days
if (time >= 15 * ONE_DAY) return 1.806e18; // min. 15 days
if (time >= 14 * ONE_DAY) return 1.788e18; // min. 14 days
if (time >= 13 * ONE_DAY) return 1.768e18; // min. 13 days
if (time >= 12 * ONE_DAY) return 1.746e18; // min. 12 days
if (time >= 11 * ONE_DAY) return 1.723e18; // min. 11 days
if (time >= 10 * ONE_DAY) return 1.698e18; // min. 10 days
if (time >= 9 * ONE_DAY) return 1.67e18; // min. 9 days
if (time >= 8 * ONE_DAY) return 1.64e18; // min. 8 days
if (time >= 7 * ONE_DAY) return 1.605e18; // min. 7 days
if (time >= 6 * ONE_DAY) return 1.566e18; // min. 6 days
if (time >= 5 * ONE_DAY) return 1.521e18; // min. 5 days
if (time >= 4 * ONE_DAY) return 1.468e18; // min. 4 days
if (time >= 3 * ONE_DAY) return 1.4e18; // min. 3 days
if (time >= 2 * ONE_DAY) return 1.32e18; // min. 2 days
if (time >= 1 * ONE_DAY) return 1.2e18; // min. 1 day
return 1;
}
// Trying to distribute before the update interval has been reached
error DistributeTooEarly();
// Already participates in vesting
error AlreadyLocked();
// Vesting time is out of range
error InvalidVestingTime();
// Insufficient user balance of pool's tokens
error InsufficientPoolBalance();
// User not locked
error UserNotLocked();
// User funds are locked
error UserLocked();
// Too late
error TooLate();
// Withdraw amount is more than locked
error WithdrawMoreThanLocked();
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"BorrowersRegistryNotConfigured","type":"error"},{"inputs":[],"name":"BurnAmountExceedsAvailableForUser","type":"error"},{"inputs":[],"name":"BurnAmountExceedsBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"requested","type":"uint256"},{"internalType":"uint256","name":"allowance","type":"uint256"}],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientPoolFunds","type":"error"},{"inputs":[],"name":"InsufficientSurplus","type":"error"},{"inputs":[],"name":"MaxPoolUtilisationBreached","type":"error"},{"inputs":[],"name":"MintToAddressZero","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"NotAContract","type":"error"},{"inputs":[],"name":"NotAuthorizedToBorrow","type":"error"},{"inputs":[],"name":"PoolFrozen","type":"error"},{"inputs":[],"name":"RepayingMoreThanWasBorrowed","type":"error"},{"inputs":[],"name":"SpenderZeroAddress","type":"error"},{"inputs":[],"name":"TotalSupplyCapBreached","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"TransferAmountExceedsBalance","type":"error"},{"inputs":[],"name":"TransferToPoolAddress","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"ZeroDepositAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"registry","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"BorrowersRegistryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Borrowing","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"_of","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"DepositOnBehalfOf","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"InterestCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"poolRewarder","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PoolRewarderChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"calculator","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RatesCalculatorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Repayment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"distributor","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"VestingDistributorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"contract IIndex","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowersRegistry","outputs":[{"internalType":"contract IBorrowersRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositIndex","outputs":[{"internalType":"contract IIndex","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_of","type":"address"}],"name":"depositOnBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getBorrowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBorrowingRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDepositRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFullPoolStatus","outputs":[{"internalType":"uint256[5]","name":"","type":"uint256[5]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxPoolUtilisationForBorrowing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IRatesCalculator","name":"ratesCalculator_","type":"address"},{"internalType":"contract IBorrowersRegistry","name":"borrowersRegistry_","type":"address"},{"internalType":"contract IIndex","name":"depositIndex_","type":"address"},{"internalType":"contract IIndex","name":"borrowIndex_","type":"address"},{"internalType":"address payable","name":"tokenAddress_","type":"address"},{"internalType":"contract IPoolRewarder","name":"poolRewarder_","type":"address"},{"internalType":"uint256","name":"_totalSupplyCap","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolRewarder","outputs":[{"internalType":"contract IPoolRewarder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ratesCalculator","outputs":[{"internalType":"contract IRatesCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"recoverSurplus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IBorrowersRegistry","name":"borrowersRegistry_","type":"address"}],"name":"setBorrowersRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPoolRewarder","name":"_poolRewarder","type":"address"}],"name":"setPoolRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IRatesCalculator","name":"ratesCalculator_","type":"address"}],"name":"setRatesCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTotalSupplyCap","type":"uint256"}],"name":"setTotalSupplyCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_distributor","type":"address"}],"name":"setVestingDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vestingDistributor","outputs":[{"internalType":"contract VestingDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b50612f50806100206000396000f3fe608060405234801561001057600080fd5b50600436106102695760003560e01c806370a0823111610151578063b6b55f25116100c3578063d06dca8911610087578063d06dca8914610550578063dd62ed3e14610563578063ee61bd6e1461059c578063f2fde38b146105af578063f36b2425146105c2578063fc68f661146105ca57600080fd5b8063b6b55f2514610504578063b75c42bd14610517578063b790634e1461052c578063bb102aea14610534578063c5ebeaec1461053d57600080fd5b80638da5cb5b116101155780638da5cb5b1461048557806395d89b41146104965780639d76ea58146104b8578063a457c2d7146104cb578063a9059cbb146104de578063aa5af0fd146104f157600080fd5b806370a082311461043957806370d4cea01461044c578063715018a6146102765780637b8989391461045f5780638c1a38111461047257600080fd5b80632aeaa291116101ea57806339509351116101ae57806339509351146103d75780634c19386c146103ea5780636011163e146103f257806361215aa8146104055780636ca6d5d0146104135780636cf55ea21461042657600080fd5b80632aeaa291146103875780632e1a7d4d1461038f578063313ce567146103a257806331d05b11146103b1578063371fd8e6146103c457600080fd5b8063095ea7b311610231578063095ea7b3146103235780631457db34146103465780631460e3901461035957806318160ddd1461036c57806323b872dd1461037457600080fd5b80630572b0cc1461026e57806306fdde03146102785780630790ef9a146102b757806307bbebdd146102ca5780630941cb3d146102f5575b600080fd5b6102766105dd565b005b6040805180820190915260118152702232b63a30a83934b6b2aaa9a221b7b4b760791b60208201525b6040516102ae9190612b4d565b60405180910390f35b6102766102c5366004612b95565b61063c565b60a1546102dd906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b610315610303366004612bc5565b609a6020526000908152604090205481565b6040519081526020016102ae565b610336610331366004612be2565b610784565b60405190151581526020016102ae565b610276610354366004612bc5565b610812565b610276610367366004612c0e565b6108de565b610315610b4a565b610336610382366004612c9b565b610b5a565b610315610e86565b61027661039d366004612cdc565b610ef2565b604051600681526020016102ae565b6102766103bf366004612cdc565b6110f7565b6102766103d2366004612cdc565b611126565b6103366103e5366004612be2565b611218565b6103156112d7565b610315610400366004612bc5565b6112de565b670c7d713b49da0000610315565b609d546102dd906001600160a01b031681565b610276610434366004612b95565b611369565b610315610447366004612bc5565b61161d565b61027661045a366004612bc5565b61166b565b609e546102dd906001600160a01b031681565b610276610480366004612bc5565b611746565b6033546001600160a01b03166102dd565b60408051808201909152600681526544505553444360d01b60208201526102a1565b60a0546102dd906001600160a01b031681565b6103366104d9366004612be2565b611807565b6103366104ec366004612be2565b6118f3565b609f546102dd906001600160a01b031681565b610276610512366004612cdc565b611b65565b61051f611b72565b6040516102ae9190612cf5565b610315611bc9565b61031560975481565b61027661054b366004612cdc565b611c16565b609c546102dd906001600160a01b031681565b610315610571366004612d26565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205490565b609b546102dd906001600160a01b031681565b6102766105bd366004612bc5565b611e9a565b610315611f32565b6102766105d8366004612bc5565b611f4e565b609d546040516311305c1f60e11b81523360048201526001600160a01b0390911690632260b83e90602401600060405180830381600087803b15801561062257600080fd5b505af1158015610636573d6000803e3d6000fd5b50505050565b6033546001600160a01b0316331461066f5760405162461bcd60e51b815260040161066690612d54565b60405180910390fd5b6002606554036106915760405162461bcd60e51b815260040161066690612d89565b600260655560a0546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156106df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107039190612dc0565b9050600061070f610b4a565b6107176112d7565b6107219084612def565b61072b9190612e02565b90508184111561074e576040516316d5c93f60e21b815260040160405180910390fd5b8381101561076f576040516394290ab960e01b815260040160405180910390fd5b6107798385611ff9565b505060016065555050565b60006001600160a01b0383166107ad57604051633d6601c760e11b815260040160405180910390fd5b3360008181526098602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a35060015b92915050565b6033546001600160a01b0316331461083c5760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b15801561085c57506001600160a01b03811615155b1561088957609d546040516322a2d07b60e21b81526001600160a01b039091166004820152602401610666565b609d80546001600160a01b0319166001600160a01b0383169081179091556040514281527f85796821ee1d670b0fdb986f256b5c1a29b9019038831c7f09df2061879cf9e5906020015b60405180910390a250565b600054610100900460ff166108f95760005460ff16156108fd565b303b155b6109605760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610666565b600054610100900460ff16158015610982576000805461ffff19166101011790555b6001600160a01b0388163b151580156109a457506001600160a01b0387163b15155b80156109b957506001600160a01b0386163b15155b80156109ce57506001600160a01b0385163b15155b80156109f457506001600160a01b0383163b1515806109f457506001600160a01b038316155b610a375760405162461bcd60e51b815260206004820152601460248201527357726f6e6720696e697420617267756d656e747360601b6044820152606401610666565b609c80546001600160a01b03199081166001600160a01b038a811691909117909255609b805482168b8416179055609e80548216898416179055609f80548216888416179055609d8054821686841617905560a08054909116918616918217905560978390556040805163313ce56760e01b8152905163313ce567916004818101926020929091908290030181865afa158015610ad8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afc9190612e15565b60a160146101000a81548160ff021916908360ff160217905550610b1e612014565b610b26612043565b610b2e612072565b8015610b40576000805461ff00191690555b5050505050505050565b6000610b553061161d565b905090565b6000600260655403610b7e5760405162461bcd60e51b815260040161066690612d89565b60026065556001600160a01b0384166000908152609860209081526040808320338452909152902054821115610bf7576001600160a01b03841660009081526098602090815260408083203384529091529081902054905163054365bb60e31b8152610666918491600401918252602082015260400190565b6001600160a01b038316610c1e57604051633a954ecd60e21b815260040160405180910390fd5b306001600160a01b03841603610c475760405163ed728e5760e01b815260040160405180910390fd5b610c5084612257565b600080610c5c86612388565b9150915080841115610c8b576040516350d2479d60e11b81526004810185905260248101829052604401610666565b610c968685846124cf565b6001600160a01b03861660009081526099602052604081208054869290610cbe908490612e02565b90915550506001600160a01b038616600090815260986020908152604080832033845290915281208054869290610cf6908490612e02565b90915550610d05905085612257565b6001600160a01b03851660009081526099602052604081208054869290610d2d908490612def565b9091555050609d546001600160a01b031615801590610d4b57508315155b15610e3957609d54604051630d5dbdb360e21b8152600481018690526001600160a01b0388811660248301526000921690633576f6cc906044016020604051808303816000875af1158015610da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc89190612dc0565b90508015610e3757609d546040516328ba35d960e11b8152600481018390526001600160a01b038881166024830152909116906351746bb290604401600060405180830381600087803b158015610e1e57600080fd5b505af1158015610e32573d6000803e3d6000fd5b505050505b505b846001600160a01b0316866001600160a01b0316600080516020612efb83398151915286604051610e6c91815260200190565b60405180910390a360019250505060016065559392505050565b609d546040516246613160e11b81523360048201526000916001600160a01b031690628cc262906024015b602060405180830381865afa158015610ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b559190612dc0565b600260655403610f145760405162461bcd60e51b815260040161066690612d89565b6002606555610f2233612257565b33600090815260996020526040902054610f3d908290612589565b60a0546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa9190612dc0565b811115610fca576040516316d5c93f60e21b815260040160405180910390fd5b30600090815260996020526040902054811115610ffa57604051630bba337f60e11b815260040160405180910390fd5b3060009081526099602052604090208054829003905561101a33826125a1565b611022612072565b61102c3382611ff9565b609d546001600160a01b0316156110b457609d54604051630d5dbdb360e21b8152600481018390523360248201526001600160a01b0390911690633576f6cc906044016020604051808303816000875af115801561108e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b29190612dc0565b505b6040805182815242602082015233917fdf273cb619d95419a9cd0ec88123a0538c85064229baa6363788f743fff90deb91015b60405180910390a2506001606555565b6033546001600160a01b031633146111215760405162461bcd60e51b815260040161066690612d54565b609755565b6002606554036111485760405162461bcd60e51b815260040161066690612d89565b60026065556111563361265e565b336000908152609a602052604090205481111561118657604051630dcad43360e11b815260040160405180910390fd5b611190338261275c565b336000908152609a6020526040812080548392906111af908490612e02565b9091555050306000908152609a6020526040812080548392906111d3908490612e02565b909155506111e19050612072565b6040805182815242602082015233917f24fcca58a997b1b2eff6db8107e860458544c09ddd3693b3b779e1df6c0d6c5d91016110e7565b60006001600160a01b03831661124157604051633d6601c760e11b815260040160405180910390fd5b3360009081526098602090815260408083206001600160a01b0387168452909152812054611270908490612def565b3360008181526098602090815260408083206001600160a01b038a16808552908352928190208590555184815293945090927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a35060019392505050565b6000610b55305b609f546001600160a01b038281166000818152609a602052604080822054905163966da88960e01b81526004810191909152602481019290925292919091169063966da889906044015b602060405180830381865afa158015611345573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080c9190612dc0565b60026065540361138b5760405162461bcd60e51b815260040161066690612d89565b600260655560008290036113b25760405163078e1d8560e01b815260040160405180910390fd5b6001600160a01b0381166113f75760405162461bcd60e51b815260206004820152600c60248201526b41646472657373207a65726f60a01b6044820152606401610666565b306001600160a01b0382160361144f5760405162461bcd60e51b815260206004820181905260248201527f43616e6e6f74206465706f736974206f6e20626568616c66206f6620706f6f6c6044820152606401610666565b60a0546040516370a0823160e01b81523360048201526114c69184916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561149d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c19190612dc0565b612589565b91506114d181612257565b6097541561151657609754306000908152609960205260409020546114f7908490612def565b111561151657604051633f27d61760e01b815260040160405180910390fd5b611520338361275c565b61152a8183612774565b3060009081526099602052604081208054849290611549908490612def565b909155506115579050612072565b609d546001600160a01b0316156115cf57609d546040516328ba35d960e11b8152600481018490526001600160a01b038381166024830152909116906351746bb290604401600060405180830381600087803b1580156115b657600080fd5b505af11580156115ca573d6000803e3d6000fd5b505050505b604080518381524260208201526001600160a01b0383169133917fef0ada5ca19bede6a40b575865a6ce451938d26835b7215e6a5e03bb2c439212910160405180910390a350506001606555565b609e546001600160a01b0382811660008181526099602052604080822054905163966da88960e01b81526004810191909152602481019290925292919091169063966da88990604401611328565b6033546001600160a01b031633146116955760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b1580156116b557506001600160a01b03811615155b156116de576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b609b80546001600160a01b0319166001600160a01b0383169081179091551561170957611709612072565b806001600160a01b03167fef1b7e9216e08b283cc613824ccb26ea505227777839a4f3c6810d64594e0182426040516108d391815260200190565b565b6033546001600160a01b031633146117705760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b15801561179057506001600160a01b03811615155b156117b9576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b60a180546001600160a01b0319166001600160a01b0383169081179091556040514281527f8e6481d1924c9bb8cdfd9d6140f3e5570c34c6c580d915144728bbbf394eed0a906020016108d3565b60006001600160a01b03831661183057604051633d6601c760e11b815260040160405180910390fd5b3360009081526098602090815260408083206001600160a01b03871684529091529020548281101561187f5760405163054365bb60e31b81526004810184905260248101829052604401610666565b600061188b8483612e02565b3360008181526098602090815260408083206001600160a01b038b16808552908352928190208590555184815293945090927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3506001949350505050565b60006002606554036119175760405162461bcd60e51b815260040161066690612d89565b60026065556001600160a01b03831661194357604051633a954ecd60e21b815260040160405180910390fd5b306001600160a01b0384160361196c5760405163ed728e5760e01b815260040160405180910390fd5b3361197681612257565b60008061198283612388565b91509150808511156119b1576040516350d2479d60e11b81526004810186905260248101829052604401610666565b6119bc8386846124cf565b6001600160a01b0383166000908152609960205260409020805486900390556119e486612257565b6001600160a01b03861660009081526099602052604081208054879290611a0c908490612def565b9091555050609d546001600160a01b031615801590611a2a57508415155b15611b1857609d54604051630d5dbdb360e21b8152600481018790526001600160a01b0385811660248301526000921690633576f6cc906044016020604051808303816000875af1158015611a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa79190612dc0565b90508015611b1657609d546040516328ba35d960e11b8152600481018390526001600160a01b038981166024830152909116906351746bb290604401600060405180830381600087803b158015611afd57600080fd5b505af1158015611b11573d6000803e3d6000fd5b505050505b505b856001600160a01b0316836001600160a01b0316600080516020612efb83398151915287604051611b4b91815260200190565b60405180910390a360019350505050600160655592915050565b611b6f8133611369565b50565b611b7a612b0b565b6040518060a00160405280611b8d610b4a565b8152602001611b9a611bc9565b8152602001611ba7611f32565b8152602001611bb46112d7565b8152602001670c7d713b49da00009052919050565b609b546000906001600160a01b0316637cd08331611be56112d7565b611bed610b4a565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401610eb1565b609c546001600160a01b0316611c3f57604051631c038dab60e21b815260040160405180910390fd5b609c5460405163039ff21960e21b81523360048201526001600160a01b0390911690630e7fc86490602401602060405180830381865afa158015611c87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cab9190612e38565b611cc857604051637582fa9b60e11b815260040160405180910390fd5b611cd0610b4a565b600003611cf0576040516316d5c93f60e21b815260040160405180910390fd5b600260655403611d125760405162461bcd60e51b815260040161066690612d89565b600260655560a0546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d839190612dc0565b811115611da3576040516316d5c93f60e21b815260040160405180910390fd5b611dac3361265e565b336000908152609a602052604081208054839290611dcb908490612def565b9091555050306000908152609a602052604081208054839290611def908490612def565b90915550611dff90503382611ff9565b611e07612072565b6040805182815242602082015233917fd6b37be10b58108f696d9ed067fedad0bff7cb417ef4c28d2f8a25d6d83c98d5910160405180910390a26001606555670c7d713b49da0000611e57610b4a565b611e5f6112d7565b611e7190670de0b6b3a7640000612e5a565b611e7b9190612e71565b1115611b6f576040516372b9ce3f60e11b815260040160405180910390fd5b6033546001600160a01b03163314611ec45760405162461bcd60e51b815260040161066690612d54565b6001600160a01b038116611f295760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610666565b611b6f816127fb565b609b546000906001600160a01b031663df841eec611be56112d7565b6033546001600160a01b03163314611f785760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b611fab576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b609c80546001600160a01b0319166001600160a01b0383169081179091556040514281527f04dce7d074f7e287a2e6e3516c802271d58d5c14e0dede83a49719eb6b920469906020016108d3565b60a054612010906001600160a01b0316838361284d565b5050565b600054610100900460ff1661203b5760405162461bcd60e51b815260040161066690612e93565b611744612977565b600054610100900460ff1661206a5760405162461bcd60e51b815260040161066690612e93565b6117446129a7565b600061207c6112d7565b90506000612088610b4a565b609b549091506001600160a01b03166120b45760405163fd4851e960e01b815260040160405180910390fd5b609e54609b54604051637cd0833160e01b815260048101859052602481018490526001600160a01b03928316926334fcf437921690637cd0833190604401602060405180830381865afa15801561210f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121339190612dc0565b6040518263ffffffff1660e01b815260040161215191815260200190565b600060405180830381600087803b15801561216b57600080fd5b505af115801561217f573d6000803e3d6000fd5b5050609f54609b546040516337e107bb60e21b815260048101879052602481018690526001600160a01b0392831694506334fcf437935091169063df841eec90604401602060405180830381865afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122039190612dc0565b6040518263ffffffff1660e01b815260040161222191815260200190565b600060405180830381600087803b15801561223b57600080fd5b505af115801561224f573d6000803e3d6000fd5b505050505050565b6001600160a01b0381166000908152609960205260408120546122798361161d565b6122839190612e02565b905061228f8282612774565b6122983061161d565b306000908152609960205260409081902091909155516001600160a01b038316907f9bbd517758fbae61197f1c1c04c8614064e89512dbaf4350dcdf76fcaa5e2161906122f19084904290918252602082015260400190565b60405180910390a2609e54604051637681d99b60e11b81526001600160a01b0384811660048301529091169063ed03b33690602401600060405180830381600087803b15801561234057600080fd5b505af1158015612354573d6000803e3d6000fd5b5050609e54604051637681d99b60e11b81523060048201526001600160a01b03909116925063ed03b3369150602401612221565b60a15460009081906001600160a01b0316156124b05760a15460405163cbf9fe5f60e01b81526001600160a01b0385811660048301529091169063cbf9fe5f90602401602060405180830381865afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190612dc0565b60a15460405163512edc6760e11b81526001600160a01b03868116600483015292945091169063a25db8ce90602401602060405180830381865afa158015612458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247c9190612dc0565b6124869083612e02565b6001600160a01b0384166000908152609960205260409020546124a99190612e02565b9050915091565b506001600160a01b038216600090815260996020526040902054915091565b6001600160a01b0383166000908152609960205260408120546124f3908390612e02565b9050808311801561250e575060a1546001600160a01b031615155b156106365760a1546001600160a01b03166349c1de3f8561252f8487612e02565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561257557600080fd5b505af1158015610b40573d6000803e3d6000fd5b6000818310612598578161259a565b825b9392505050565b6001600160a01b0382166000908152609960205260409020548111156125da57604051630bba337f60e11b815260040160405180910390fd5b6000806125e684612388565b915091508083111561260b5760405163a06a83a160e01b815260040160405180910390fd5b6126168484846124cf565b6001600160a01b03841660008181526099602090815260408083208054889003905551868152919291600080516020612efb833981519152910160405180910390a350505050565b612667816112de565b6001600160a01b0382166000908152609a6020526040902055612689306112de565b306000908152609a60205260409081902091909155609f549051637681d99b60e11b81526001600160a01b0383811660048301529091169063ed03b33690602401600060405180830381600087803b1580156126e457600080fd5b505af11580156126f8573d6000803e3d6000fd5b5050609f54604051637681d99b60e11b81523060048201526001600160a01b03909116925063ed03b3369150602401600060405180830381600087803b15801561274157600080fd5b505af1158015612755573d6000803e3d6000fd5b5050505050565b60a054612010906001600160a01b03168330846129d5565b6001600160a01b03821661279b576040516346dbfb6d60e11b815260040160405180910390fd5b6001600160a01b038216600090815260996020526040812080548392906127c3908490612def565b90915550506040518181526001600160a01b03831690600090600080516020612efb8339815191529060200160405180910390a35050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916128a99190612ede565b6000604051808303816000865af19150503d80600081146128e6576040519150601f19603f3d011682016040523d82523d6000602084013e6128eb565b606091505b50915091508180156129155750805115806129155750808060200190518101906129159190612e38565b6127555760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608401610666565b600054610100900460ff1661299e5760405162461bcd60e51b815260040161066690612e93565b611744336127fb565b600054610100900460ff166129ce5760405162461bcd60e51b815260040161066690612e93565b6001606555565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691612a399190612ede565b6000604051808303816000865af19150503d8060008114612a76576040519150601f19603f3d011682016040523d82523d6000602084013e612a7b565b606091505b5091509150818015612aa5575080511580612aa5575080806020019051810190612aa59190612e38565b61224f5760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610666565b6040518060a001604052806005906020820280368337509192915050565b60005b83811015612b44578181015183820152602001612b2c565b50506000910152565b6020815260008251806020840152612b6c816040850160208701612b29565b601f01601f19169190910160400192915050565b6001600160a01b0381168114611b6f57600080fd5b60008060408385031215612ba857600080fd5b823591506020830135612bba81612b80565b809150509250929050565b600060208284031215612bd757600080fd5b813561259a81612b80565b60008060408385031215612bf557600080fd5b8235612c0081612b80565b946020939093013593505050565b600080600080600080600060e0888a031215612c2957600080fd5b8735612c3481612b80565b96506020880135612c4481612b80565b95506040880135612c5481612b80565b94506060880135612c6481612b80565b93506080880135612c7481612b80565b925060a0880135612c8481612b80565b8092505060c0880135905092959891949750929550565b600080600060608486031215612cb057600080fd5b8335612cbb81612b80565b92506020840135612ccb81612b80565b929592945050506040919091013590565b600060208284031215612cee57600080fd5b5035919050565b60a08101818360005b6005811015612d1d578151835260209283019290910190600101612cfe565b50505092915050565b60008060408385031215612d3957600080fd5b8235612d4481612b80565b91506020830135612bba81612b80565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060208284031215612dd257600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561080c5761080c612dd9565b8181038181111561080c5761080c612dd9565b600060208284031215612e2757600080fd5b815160ff8116811461259a57600080fd5b600060208284031215612e4a57600080fd5b8151801515811461259a57600080fd5b808202811582820484141761080c5761080c612dd9565b600082612e8e57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251612ef0818460208701612b29565b919091019291505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220693aafaae6b99d1d371ad9374d8385122c2ab7f617cfae704e37afd09dfb3ebd64736f6c63430008110033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102695760003560e01c806370a0823111610151578063b6b55f25116100c3578063d06dca8911610087578063d06dca8914610550578063dd62ed3e14610563578063ee61bd6e1461059c578063f2fde38b146105af578063f36b2425146105c2578063fc68f661146105ca57600080fd5b8063b6b55f2514610504578063b75c42bd14610517578063b790634e1461052c578063bb102aea14610534578063c5ebeaec1461053d57600080fd5b80638da5cb5b116101155780638da5cb5b1461048557806395d89b41146104965780639d76ea58146104b8578063a457c2d7146104cb578063a9059cbb146104de578063aa5af0fd146104f157600080fd5b806370a082311461043957806370d4cea01461044c578063715018a6146102765780637b8989391461045f5780638c1a38111461047257600080fd5b80632aeaa291116101ea57806339509351116101ae57806339509351146103d75780634c19386c146103ea5780636011163e146103f257806361215aa8146104055780636ca6d5d0146104135780636cf55ea21461042657600080fd5b80632aeaa291146103875780632e1a7d4d1461038f578063313ce567146103a257806331d05b11146103b1578063371fd8e6146103c457600080fd5b8063095ea7b311610231578063095ea7b3146103235780631457db34146103465780631460e3901461035957806318160ddd1461036c57806323b872dd1461037457600080fd5b80630572b0cc1461026e57806306fdde03146102785780630790ef9a146102b757806307bbebdd146102ca5780630941cb3d146102f5575b600080fd5b6102766105dd565b005b6040805180820190915260118152702232b63a30a83934b6b2aaa9a221b7b4b760791b60208201525b6040516102ae9190612b4d565b60405180910390f35b6102766102c5366004612b95565b61063c565b60a1546102dd906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b610315610303366004612bc5565b609a6020526000908152604090205481565b6040519081526020016102ae565b610336610331366004612be2565b610784565b60405190151581526020016102ae565b610276610354366004612bc5565b610812565b610276610367366004612c0e565b6108de565b610315610b4a565b610336610382366004612c9b565b610b5a565b610315610e86565b61027661039d366004612cdc565b610ef2565b604051600681526020016102ae565b6102766103bf366004612cdc565b6110f7565b6102766103d2366004612cdc565b611126565b6103366103e5366004612be2565b611218565b6103156112d7565b610315610400366004612bc5565b6112de565b670c7d713b49da0000610315565b609d546102dd906001600160a01b031681565b610276610434366004612b95565b611369565b610315610447366004612bc5565b61161d565b61027661045a366004612bc5565b61166b565b609e546102dd906001600160a01b031681565b610276610480366004612bc5565b611746565b6033546001600160a01b03166102dd565b60408051808201909152600681526544505553444360d01b60208201526102a1565b60a0546102dd906001600160a01b031681565b6103366104d9366004612be2565b611807565b6103366104ec366004612be2565b6118f3565b609f546102dd906001600160a01b031681565b610276610512366004612cdc565b611b65565b61051f611b72565b6040516102ae9190612cf5565b610315611bc9565b61031560975481565b61027661054b366004612cdc565b611c16565b609c546102dd906001600160a01b031681565b610315610571366004612d26565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205490565b609b546102dd906001600160a01b031681565b6102766105bd366004612bc5565b611e9a565b610315611f32565b6102766105d8366004612bc5565b611f4e565b609d546040516311305c1f60e11b81523360048201526001600160a01b0390911690632260b83e90602401600060405180830381600087803b15801561062257600080fd5b505af1158015610636573d6000803e3d6000fd5b50505050565b6033546001600160a01b0316331461066f5760405162461bcd60e51b815260040161066690612d54565b60405180910390fd5b6002606554036106915760405162461bcd60e51b815260040161066690612d89565b600260655560a0546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156106df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107039190612dc0565b9050600061070f610b4a565b6107176112d7565b6107219084612def565b61072b9190612e02565b90508184111561074e576040516316d5c93f60e21b815260040160405180910390fd5b8381101561076f576040516394290ab960e01b815260040160405180910390fd5b6107798385611ff9565b505060016065555050565b60006001600160a01b0383166107ad57604051633d6601c760e11b815260040160405180910390fd5b3360008181526098602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a35060015b92915050565b6033546001600160a01b0316331461083c5760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b15801561085c57506001600160a01b03811615155b1561088957609d546040516322a2d07b60e21b81526001600160a01b039091166004820152602401610666565b609d80546001600160a01b0319166001600160a01b0383169081179091556040514281527f85796821ee1d670b0fdb986f256b5c1a29b9019038831c7f09df2061879cf9e5906020015b60405180910390a250565b600054610100900460ff166108f95760005460ff16156108fd565b303b155b6109605760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610666565b600054610100900460ff16158015610982576000805461ffff19166101011790555b6001600160a01b0388163b151580156109a457506001600160a01b0387163b15155b80156109b957506001600160a01b0386163b15155b80156109ce57506001600160a01b0385163b15155b80156109f457506001600160a01b0383163b1515806109f457506001600160a01b038316155b610a375760405162461bcd60e51b815260206004820152601460248201527357726f6e6720696e697420617267756d656e747360601b6044820152606401610666565b609c80546001600160a01b03199081166001600160a01b038a811691909117909255609b805482168b8416179055609e80548216898416179055609f80548216888416179055609d8054821686841617905560a08054909116918616918217905560978390556040805163313ce56760e01b8152905163313ce567916004818101926020929091908290030181865afa158015610ad8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afc9190612e15565b60a160146101000a81548160ff021916908360ff160217905550610b1e612014565b610b26612043565b610b2e612072565b8015610b40576000805461ff00191690555b5050505050505050565b6000610b553061161d565b905090565b6000600260655403610b7e5760405162461bcd60e51b815260040161066690612d89565b60026065556001600160a01b0384166000908152609860209081526040808320338452909152902054821115610bf7576001600160a01b03841660009081526098602090815260408083203384529091529081902054905163054365bb60e31b8152610666918491600401918252602082015260400190565b6001600160a01b038316610c1e57604051633a954ecd60e21b815260040160405180910390fd5b306001600160a01b03841603610c475760405163ed728e5760e01b815260040160405180910390fd5b610c5084612257565b600080610c5c86612388565b9150915080841115610c8b576040516350d2479d60e11b81526004810185905260248101829052604401610666565b610c968685846124cf565b6001600160a01b03861660009081526099602052604081208054869290610cbe908490612e02565b90915550506001600160a01b038616600090815260986020908152604080832033845290915281208054869290610cf6908490612e02565b90915550610d05905085612257565b6001600160a01b03851660009081526099602052604081208054869290610d2d908490612def565b9091555050609d546001600160a01b031615801590610d4b57508315155b15610e3957609d54604051630d5dbdb360e21b8152600481018690526001600160a01b0388811660248301526000921690633576f6cc906044016020604051808303816000875af1158015610da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc89190612dc0565b90508015610e3757609d546040516328ba35d960e11b8152600481018390526001600160a01b038881166024830152909116906351746bb290604401600060405180830381600087803b158015610e1e57600080fd5b505af1158015610e32573d6000803e3d6000fd5b505050505b505b846001600160a01b0316866001600160a01b0316600080516020612efb83398151915286604051610e6c91815260200190565b60405180910390a360019250505060016065559392505050565b609d546040516246613160e11b81523360048201526000916001600160a01b031690628cc262906024015b602060405180830381865afa158015610ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b559190612dc0565b600260655403610f145760405162461bcd60e51b815260040161066690612d89565b6002606555610f2233612257565b33600090815260996020526040902054610f3d908290612589565b60a0546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa9190612dc0565b811115610fca576040516316d5c93f60e21b815260040160405180910390fd5b30600090815260996020526040902054811115610ffa57604051630bba337f60e11b815260040160405180910390fd5b3060009081526099602052604090208054829003905561101a33826125a1565b611022612072565b61102c3382611ff9565b609d546001600160a01b0316156110b457609d54604051630d5dbdb360e21b8152600481018390523360248201526001600160a01b0390911690633576f6cc906044016020604051808303816000875af115801561108e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b29190612dc0565b505b6040805182815242602082015233917fdf273cb619d95419a9cd0ec88123a0538c85064229baa6363788f743fff90deb91015b60405180910390a2506001606555565b6033546001600160a01b031633146111215760405162461bcd60e51b815260040161066690612d54565b609755565b6002606554036111485760405162461bcd60e51b815260040161066690612d89565b60026065556111563361265e565b336000908152609a602052604090205481111561118657604051630dcad43360e11b815260040160405180910390fd5b611190338261275c565b336000908152609a6020526040812080548392906111af908490612e02565b9091555050306000908152609a6020526040812080548392906111d3908490612e02565b909155506111e19050612072565b6040805182815242602082015233917f24fcca58a997b1b2eff6db8107e860458544c09ddd3693b3b779e1df6c0d6c5d91016110e7565b60006001600160a01b03831661124157604051633d6601c760e11b815260040160405180910390fd5b3360009081526098602090815260408083206001600160a01b0387168452909152812054611270908490612def565b3360008181526098602090815260408083206001600160a01b038a16808552908352928190208590555184815293945090927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a35060019392505050565b6000610b55305b609f546001600160a01b038281166000818152609a602052604080822054905163966da88960e01b81526004810191909152602481019290925292919091169063966da889906044015b602060405180830381865afa158015611345573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080c9190612dc0565b60026065540361138b5760405162461bcd60e51b815260040161066690612d89565b600260655560008290036113b25760405163078e1d8560e01b815260040160405180910390fd5b6001600160a01b0381166113f75760405162461bcd60e51b815260206004820152600c60248201526b41646472657373207a65726f60a01b6044820152606401610666565b306001600160a01b0382160361144f5760405162461bcd60e51b815260206004820181905260248201527f43616e6e6f74206465706f736974206f6e20626568616c66206f6620706f6f6c6044820152606401610666565b60a0546040516370a0823160e01b81523360048201526114c69184916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561149d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c19190612dc0565b612589565b91506114d181612257565b6097541561151657609754306000908152609960205260409020546114f7908490612def565b111561151657604051633f27d61760e01b815260040160405180910390fd5b611520338361275c565b61152a8183612774565b3060009081526099602052604081208054849290611549908490612def565b909155506115579050612072565b609d546001600160a01b0316156115cf57609d546040516328ba35d960e11b8152600481018490526001600160a01b038381166024830152909116906351746bb290604401600060405180830381600087803b1580156115b657600080fd5b505af11580156115ca573d6000803e3d6000fd5b505050505b604080518381524260208201526001600160a01b0383169133917fef0ada5ca19bede6a40b575865a6ce451938d26835b7215e6a5e03bb2c439212910160405180910390a350506001606555565b609e546001600160a01b0382811660008181526099602052604080822054905163966da88960e01b81526004810191909152602481019290925292919091169063966da88990604401611328565b6033546001600160a01b031633146116955760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b1580156116b557506001600160a01b03811615155b156116de576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b609b80546001600160a01b0319166001600160a01b0383169081179091551561170957611709612072565b806001600160a01b03167fef1b7e9216e08b283cc613824ccb26ea505227777839a4f3c6810d64594e0182426040516108d391815260200190565b565b6033546001600160a01b031633146117705760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b15801561179057506001600160a01b03811615155b156117b9576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b60a180546001600160a01b0319166001600160a01b0383169081179091556040514281527f8e6481d1924c9bb8cdfd9d6140f3e5570c34c6c580d915144728bbbf394eed0a906020016108d3565b60006001600160a01b03831661183057604051633d6601c760e11b815260040160405180910390fd5b3360009081526098602090815260408083206001600160a01b03871684529091529020548281101561187f5760405163054365bb60e31b81526004810184905260248101829052604401610666565b600061188b8483612e02565b3360008181526098602090815260408083206001600160a01b038b16808552908352928190208590555184815293945090927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3506001949350505050565b60006002606554036119175760405162461bcd60e51b815260040161066690612d89565b60026065556001600160a01b03831661194357604051633a954ecd60e21b815260040160405180910390fd5b306001600160a01b0384160361196c5760405163ed728e5760e01b815260040160405180910390fd5b3361197681612257565b60008061198283612388565b91509150808511156119b1576040516350d2479d60e11b81526004810186905260248101829052604401610666565b6119bc8386846124cf565b6001600160a01b0383166000908152609960205260409020805486900390556119e486612257565b6001600160a01b03861660009081526099602052604081208054879290611a0c908490612def565b9091555050609d546001600160a01b031615801590611a2a57508415155b15611b1857609d54604051630d5dbdb360e21b8152600481018790526001600160a01b0385811660248301526000921690633576f6cc906044016020604051808303816000875af1158015611a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa79190612dc0565b90508015611b1657609d546040516328ba35d960e11b8152600481018390526001600160a01b038981166024830152909116906351746bb290604401600060405180830381600087803b158015611afd57600080fd5b505af1158015611b11573d6000803e3d6000fd5b505050505b505b856001600160a01b0316836001600160a01b0316600080516020612efb83398151915287604051611b4b91815260200190565b60405180910390a360019350505050600160655592915050565b611b6f8133611369565b50565b611b7a612b0b565b6040518060a00160405280611b8d610b4a565b8152602001611b9a611bc9565b8152602001611ba7611f32565b8152602001611bb46112d7565b8152602001670c7d713b49da00009052919050565b609b546000906001600160a01b0316637cd08331611be56112d7565b611bed610b4a565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401610eb1565b609c546001600160a01b0316611c3f57604051631c038dab60e21b815260040160405180910390fd5b609c5460405163039ff21960e21b81523360048201526001600160a01b0390911690630e7fc86490602401602060405180830381865afa158015611c87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cab9190612e38565b611cc857604051637582fa9b60e11b815260040160405180910390fd5b611cd0610b4a565b600003611cf0576040516316d5c93f60e21b815260040160405180910390fd5b600260655403611d125760405162461bcd60e51b815260040161066690612d89565b600260655560a0546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d839190612dc0565b811115611da3576040516316d5c93f60e21b815260040160405180910390fd5b611dac3361265e565b336000908152609a602052604081208054839290611dcb908490612def565b9091555050306000908152609a602052604081208054839290611def908490612def565b90915550611dff90503382611ff9565b611e07612072565b6040805182815242602082015233917fd6b37be10b58108f696d9ed067fedad0bff7cb417ef4c28d2f8a25d6d83c98d5910160405180910390a26001606555670c7d713b49da0000611e57610b4a565b611e5f6112d7565b611e7190670de0b6b3a7640000612e5a565b611e7b9190612e71565b1115611b6f576040516372b9ce3f60e11b815260040160405180910390fd5b6033546001600160a01b03163314611ec45760405162461bcd60e51b815260040161066690612d54565b6001600160a01b038116611f295760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610666565b611b6f816127fb565b609b546000906001600160a01b031663df841eec611be56112d7565b6033546001600160a01b03163314611f785760405162461bcd60e51b815260040161066690612d54565b6001600160a01b0381163b611fab576040516322a2d07b60e21b81526001600160a01b0382166004820152602401610666565b609c80546001600160a01b0319166001600160a01b0383169081179091556040514281527f04dce7d074f7e287a2e6e3516c802271d58d5c14e0dede83a49719eb6b920469906020016108d3565b60a054612010906001600160a01b0316838361284d565b5050565b600054610100900460ff1661203b5760405162461bcd60e51b815260040161066690612e93565b611744612977565b600054610100900460ff1661206a5760405162461bcd60e51b815260040161066690612e93565b6117446129a7565b600061207c6112d7565b90506000612088610b4a565b609b549091506001600160a01b03166120b45760405163fd4851e960e01b815260040160405180910390fd5b609e54609b54604051637cd0833160e01b815260048101859052602481018490526001600160a01b03928316926334fcf437921690637cd0833190604401602060405180830381865afa15801561210f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121339190612dc0565b6040518263ffffffff1660e01b815260040161215191815260200190565b600060405180830381600087803b15801561216b57600080fd5b505af115801561217f573d6000803e3d6000fd5b5050609f54609b546040516337e107bb60e21b815260048101879052602481018690526001600160a01b0392831694506334fcf437935091169063df841eec90604401602060405180830381865afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122039190612dc0565b6040518263ffffffff1660e01b815260040161222191815260200190565b600060405180830381600087803b15801561223b57600080fd5b505af115801561224f573d6000803e3d6000fd5b505050505050565b6001600160a01b0381166000908152609960205260408120546122798361161d565b6122839190612e02565b905061228f8282612774565b6122983061161d565b306000908152609960205260409081902091909155516001600160a01b038316907f9bbd517758fbae61197f1c1c04c8614064e89512dbaf4350dcdf76fcaa5e2161906122f19084904290918252602082015260400190565b60405180910390a2609e54604051637681d99b60e11b81526001600160a01b0384811660048301529091169063ed03b33690602401600060405180830381600087803b15801561234057600080fd5b505af1158015612354573d6000803e3d6000fd5b5050609e54604051637681d99b60e11b81523060048201526001600160a01b03909116925063ed03b3369150602401612221565b60a15460009081906001600160a01b0316156124b05760a15460405163cbf9fe5f60e01b81526001600160a01b0385811660048301529091169063cbf9fe5f90602401602060405180830381865afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190612dc0565b60a15460405163512edc6760e11b81526001600160a01b03868116600483015292945091169063a25db8ce90602401602060405180830381865afa158015612458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247c9190612dc0565b6124869083612e02565b6001600160a01b0384166000908152609960205260409020546124a99190612e02565b9050915091565b506001600160a01b038216600090815260996020526040902054915091565b6001600160a01b0383166000908152609960205260408120546124f3908390612e02565b9050808311801561250e575060a1546001600160a01b031615155b156106365760a1546001600160a01b03166349c1de3f8561252f8487612e02565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561257557600080fd5b505af1158015610b40573d6000803e3d6000fd5b6000818310612598578161259a565b825b9392505050565b6001600160a01b0382166000908152609960205260409020548111156125da57604051630bba337f60e11b815260040160405180910390fd5b6000806125e684612388565b915091508083111561260b5760405163a06a83a160e01b815260040160405180910390fd5b6126168484846124cf565b6001600160a01b03841660008181526099602090815260408083208054889003905551868152919291600080516020612efb833981519152910160405180910390a350505050565b612667816112de565b6001600160a01b0382166000908152609a6020526040902055612689306112de565b306000908152609a60205260409081902091909155609f549051637681d99b60e11b81526001600160a01b0383811660048301529091169063ed03b33690602401600060405180830381600087803b1580156126e457600080fd5b505af11580156126f8573d6000803e3d6000fd5b5050609f54604051637681d99b60e11b81523060048201526001600160a01b03909116925063ed03b3369150602401600060405180830381600087803b15801561274157600080fd5b505af1158015612755573d6000803e3d6000fd5b5050505050565b60a054612010906001600160a01b03168330846129d5565b6001600160a01b03821661279b576040516346dbfb6d60e11b815260040160405180910390fd5b6001600160a01b038216600090815260996020526040812080548392906127c3908490612def565b90915550506040518181526001600160a01b03831690600090600080516020612efb8339815191529060200160405180910390a35050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916128a99190612ede565b6000604051808303816000865af19150503d80600081146128e6576040519150601f19603f3d011682016040523d82523d6000602084013e6128eb565b606091505b50915091508180156129155750805115806129155750808060200190518101906129159190612e38565b6127555760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608401610666565b600054610100900460ff1661299e5760405162461bcd60e51b815260040161066690612e93565b611744336127fb565b600054610100900460ff166129ce5760405162461bcd60e51b815260040161066690612e93565b6001606555565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691612a399190612ede565b6000604051808303816000865af19150503d8060008114612a76576040519150601f19603f3d011682016040523d82523d6000602084013e612a7b565b606091505b5091509150818015612aa5575080511580612aa5575080806020019051810190612aa59190612e38565b61224f5760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610666565b6040518060a001604052806005906020820280368337509192915050565b60005b83811015612b44578181015183820152602001612b2c565b50506000910152565b6020815260008251806020840152612b6c816040850160208701612b29565b601f01601f19169190910160400192915050565b6001600160a01b0381168114611b6f57600080fd5b60008060408385031215612ba857600080fd5b823591506020830135612bba81612b80565b809150509250929050565b600060208284031215612bd757600080fd5b813561259a81612b80565b60008060408385031215612bf557600080fd5b8235612c0081612b80565b946020939093013593505050565b600080600080600080600060e0888a031215612c2957600080fd5b8735612c3481612b80565b96506020880135612c4481612b80565b95506040880135612c5481612b80565b94506060880135612c6481612b80565b93506080880135612c7481612b80565b925060a0880135612c8481612b80565b8092505060c0880135905092959891949750929550565b600080600060608486031215612cb057600080fd5b8335612cbb81612b80565b92506020840135612ccb81612b80565b929592945050506040919091013590565b600060208284031215612cee57600080fd5b5035919050565b60a08101818360005b6005811015612d1d578151835260209283019290910190600101612cfe565b50505092915050565b60008060408385031215612d3957600080fd5b8235612d4481612b80565b91506020830135612bba81612b80565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060208284031215612dd257600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561080c5761080c612dd9565b8181038181111561080c5761080c612dd9565b600060208284031215612e2757600080fd5b815160ff8116811461259a57600080fd5b600060208284031215612e4a57600080fd5b8151801515811461259a57600080fd5b808202811582820484141761080c5761080c612dd9565b600082612e8e57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251612ef0818460208701612b29565b919091019291505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220693aafaae6b99d1d371ad9374d8385122c2ab7f617cfae704e37afd09dfb3ebd64736f6c63430008110033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.