Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x6671d410...65ADCE915 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
CreateKToken
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "../tokens/KToken.sol"; import "../interfaces/IKyokoPoolAddressesProvider.sol"; import "../interfaces/ICreateKToken.sol"; import "../interfaces/IKToken.sol"; contract CreateKToken is ICreateKToken { function createKToken( address _weth, address _provider, address _treasury, uint256 _reserveId, string memory symbol, string memory s1, string memory s2 ) external override returns (address kTokenAddress) { address weth = _weth; IKyokoPoolAddressesProvider provider = IKyokoPoolAddressesProvider(_provider); address treasury = _treasury; uint256 reserveId = _reserveId; string memory s3 = "Kyoko interest bearing "; string memory s4 = "k"; string memory kTokenName = string(abi.encodePacked(s3, symbol, s1, s2)); string memory kTokenSymbol = string(abi.encodePacked(s4, symbol, s2)); KToken kToken = new KToken(provider, reserveId, treasury, weth, 18, kTokenName, kTokenSymbol); kTokenAddress = address(kToken); emit CreateKToken(msg.sender, kTokenAddress); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; 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. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * 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 prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @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.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal onlyInitializing { } function __ERC721Holder_init_unchained() internal onlyInitializing { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } /** * @dev 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 (last updated v4.9.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 * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [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://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; 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; } /** * @dev 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 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "./IKyokoPool.sol"; interface ICreateKToken { event CreateKToken(address user, address kToken); function createKToken( address weth, address provider, address treasury, uint256 reserveId, string memory symbol, string memory s1, string memory s2 ) external returns (address stableDebtAddress); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "./IScaledBalanceToken.sol"; import "./IKyokoPoolAddressesProvider.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface IKToken is IERC20Upgradeable, IScaledBalanceToken { /** * @dev Emitted when an kToken is initialized * @param underlyingAsset The address of the underlying asset * @param pool The address of the associated lending pool * @param reserveId The id of the reserves * @param treasury The address of the treasury * @param kTokenDecimals the decimals of the underlying * @param kTokenName the name of the kToken * @param kTokenSymbol the symbol of the kToken **/ event Initialize( address indexed underlyingAsset, address indexed pool, uint256 indexed reserveId, address treasury, uint8 kTokenDecimals, string kTokenName, string kTokenSymbol ); /** * @dev Initializes the kToken * @param pool The address of the lending pool where this kToken will be used * @param reserveId The id of the reserves * @param treasury The address of the Kyoko treasury, receiving the fees on this kToken * @param underlyingAsset The address of the underlying asset of this kToken (E.g. WETH for kWETH) * @param kTokenDecimals The decimals of the kToken, same as the underlying asset's * @param kTokenName The name of the kToken * @param kTokenSymbol The symbol of the kToken */ function initialize( IKyokoPoolAddressesProvider pool, uint256 reserveId, address treasury, address underlyingAsset, uint8 kTokenDecimals, string calldata kTokenName, string calldata kTokenSymbol ) external; /** * @dev Emitted after the mint action * @param from The address performing the mint * @param value The amount being * @param index The new liquidity index of the reserve **/ event Mint(address indexed from, uint256 value, uint256 index); /** * @dev Mints `amount` kTokens to `user` * @param user The address receiving the minted tokens * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve * @return `true` if the the previous balance of the user was 0 */ function mint( address user, uint256 amount, uint256 index ) external returns (bool); /** * @dev Emitted after kTokens are burned * @param from The owner of the kTokens, getting them burned * @param target The address that will receive the underlying * @param value The amount being burned * @param index The new liquidity index of the reserve **/ event Burn( address indexed from, address indexed target, uint256 value, uint256 index ); /** * @dev Emitted during the transfer action * @param from The user whose tokens are being transferred * @param to The recipient * @param value The amount being transferred * @param index The new liquidity index of the reserve **/ event BalanceTransfer( address indexed from, address indexed to, uint256 value, uint256 index ); /** * @dev Burns kTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * @param user The owner of the kTokens, getting them burned * @param receiverOfUnderlying The address that will receive the underlying * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn( address user, address receiverOfUnderlying, uint256 amount, uint256 index ) external; /** * @dev Burns kTokens from `user` * @param user The owner of the kTokens, getting them burned * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn(address user, uint256 amount, uint256 index) external; /** * @dev Mints kTokens to the reserve treasury * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve */ function mintToTreasury(uint256 amount, uint256 index) external; /** * @dev Transfers kTokens in the event of a borrow being liquidated, in case the liquidators reclaims the kToken * @param from The address getting liquidated, current owner of the kTokens * @param to The recipient * @param value The amount of tokens getting transferred **/ function transferOnLiquidation( address from, address to, uint256 value ) external; /** * @dev Transfers the underlying asset to `target`. Used by the KyokoPool to transfer * assets in borrow(), withdraw() and flashLoan() * @param user The recipient of the underlying * @param amount The amount getting transferred * @return The amount transferred **/ function transferUnderlyingTo( address user, uint256 amount ) external returns (uint256); function transferUnderlyingNFTTo( address nft, address target, uint256 nftId ) external returns (uint256); /** * @dev Invoked to execute actions on the kToken side after a repayment. * @param user The user executing the repayment * @param amount The amount getting repaid **/ function handleRepayment(address user, uint256 amount) external; /** * @dev Returns the address of the underlying asset of this kToken (E.g. WETH for aWETH) **/ function UNDERLYING_ASSET_ADDRESS() external view returns (address); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "../libraries/utils/DataTypes.sol"; interface IKyokoPool { /** * @dev Emitted on deposit() * @param reserveId The id of the reserve * @param user The beneficiary of the deposit, receiving the kTokens * @param onBehalfOf The beneficiary of the deposit, receiving the kTokens * @param amount The amount deposited **/ event Deposit( uint256 indexed reserveId, address indexed user, address indexed onBehalfOf, uint256 amount ); /** * @dev Emitted on withdraw() * @param reserveId The id of the reserve * @param user The address initiating the withdrawal, owner of kTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw( uint256 indexed reserveId, address indexed user, address indexed to, uint256 amount ); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserveId The id of the reserve * @param borrowId The id of the borrow info * @param asset The address of the borrowed nft * @param nftId The tokenId of the borrowed nft * @param borrowMode The rate mode: 1 for Stable, 2 for Variable * @param amount The amount of the borrow * @param borrowRate The numeric rate at which the user has borrowed **/ event Borrow( uint256 indexed reserveId, uint256 indexed borrowId, address indexed asset, uint256 nftId, uint256 borrowMode, uint256 amount, uint256 borrowRate ); /** * @dev Emitted on repay() * @param reserveId The id of the reserve * @param borrowId The id of the borrow info * @param user The beneficiary of the repayment, getting his debt reduced * @param nft The nft corresponding to repayment * @param nftId The tokenId of the borrowed nft * @param amount The amount repaid **/ event Repay( uint256 indexed reserveId, uint256 indexed borrowId, address user, address indexed nft, uint256 nftId, uint256 amount ); event LiquidationCall( uint256 indexed reserveId, uint256 indexed borrowId, address indexed user, address nft, uint256 id, uint256 amount, uint256 time ); event BidCall( uint256 indexed reserveId, uint256 indexed borrowId, address indexed user, uint256 amount, uint256 time ); event ClaimCall( uint256 indexed reserveId, uint256 indexed borrowId, address indexed user, uint256 time ); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserveId The id of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate( uint256 indexed reserveId, address indexed user ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when new stable debt is increased * @param reserveId The id of the reserve * @param asset The address of nft * @param user The address of the user who triggered the minting * @param amount The amount minted * @param currentBalance The current balance of the user * @param balanceIncrease The increase in balance since the last action of the user * @param newRate The rate of the debt after the minting * @param newTotalSupply The new total supply of the stable debt token after the action **/ event StableDebtIncrease( uint256 indexed reserveId, address indexed asset, address indexed user, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 newRate, uint256 avgStableRate, uint256 newTotalSupply ); /** * @dev Emitted when new stable debt is decreased * @param reserveId The id of the reserve * @param user The address of the user * @param amount The amount being burned * @param currentBalance The current balance of the user * @param balanceIncrease The the increase in balance since the last action of the user * @param avgStableRate The new average stable rate after the burning * @param newTotalSupply The new total supply of the stable debt token after the action **/ event StableDebtDecrease( uint256 indexed reserveId, address indexed asset, address indexed user, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 avgStableRate, uint256 newTotalSupply ); /** * @dev Emitted when new varibale debt is increased * @param reserveId The id of the reserve * @param asset The address performing the nft * @param user The address of the user on which behalf minting has been performed * @param value The amount to be minted * @param index The last index of the reserve **/ event VariableDebtIncrease( uint256 indexed reserveId, address indexed asset, address indexed user, uint256 value, uint256 index ); /** * @dev Emitted when variable debt is decreased * @param reserveId The id of the reserve * @param asset The address of the nft * @param user The user which debt has been burned * @param amount The amount of debt being burned * @param index The index of the user **/ event VariableDebtDecrease( uint256 indexed reserveId, address indexed asset, address indexed user, uint256 amount, uint256 index ); event SetMinBorrowTime(uint40 time); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying kTokens. * @param reserveId The id of the reserve * @param onBehalfOf The beneficiary of the deposit, receiving the kTokens **/ function deposit(uint256 reserveId, address onBehalfOf) external payable; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent kTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param reserveId The id of the reserve * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole kToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( uint256 reserveId, uint256 amount, address to ) external returns (uint256); /** * @dev Allows users to borrow an estimate `amount` of the reserve underlying asset according to the value of the nft * @param reserveId The id of the reserve * @param asset The address of the nft to be borrowed * @param nftId The tokenId of the nft to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param onBehalfOf The address that will recieve the borrow asset and debt token (must be msg.sender or the msg.sender must be punkGateway) **/ function borrow( uint256 reserveId, address asset, uint256 nftId, uint256 interestRateMode, address onBehalfOf ) external returns (uint256); /** * @notice Repays a borrowed `amount` on a specific reserve * @param borrowId The id of the borrow to repay * @param onBehalfOf The address that will burn the debt token (must be msg.sender or the msg.sender must be punkGateway) * @return The final amount repaid **/ function repay( uint256 borrowId, address onBehalfOf ) external payable returns (uint256); /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param reserveId The id of the reserve * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate( uint256 reserveId, address user ) external; /** * @dev Function to liquidate an expired borrow info. * @param borrowId The id of liquidate borrow target **/ function liquidationCall( uint256 borrowId ) external payable; /** * @dev Function to bid for the liquidate auction. * @param borrowId The id of liquidate borrow target **/ function bidCall(uint256 borrowId) external payable; /** * @dev Function to claim the liquidate NFT. * @param borrowId The id of liquidate borrow target **/ function claimCall(uint256 borrowId) external; function claimCall( uint256 borrowId, address onBehalfOf ) external; /** * @dev Returns the list of user's borrowId * @param user The address of the user **/ function getUserBorrowList( address user ) external view returns (uint256[] memory borrowIds); /** * @dev Returns the list of borrowId in auction **/ function getAuctions() external view returns (uint256[] memory); /** * @dev Returns the list of user's borrowId * @param borrowId The id of the borrow info **/ function getDebt(uint256 borrowId) external view returns (uint256 debt); function getInitialLockTime( uint256 reserveId ) external view returns (uint256); function enabledLiquidation(uint256 borrowId) external view returns (bool); function initReserve( address asset, address kTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function updateReserveNFT( uint256 reserveId, address asset, bool flag ) external; function setReserveInterestRateStrategyAddress( uint256 reserveId, address rateStrategyAddress ) external; function burnLiquidity(uint256 reserveId, uint256 amount) external; function setConfiguration( uint256 reserveId, uint256 configuration ) external; /** * @dev Returns the configuration of the reserve * @param reserveId The id of the reserve * @return The configuration of the reserve **/ function getConfiguration( uint256 reserveId ) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param reserveId The id of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome( uint256 reserveId ) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param reserveId The id of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt( uint256 reserveId ) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param reserveId The id of the reserve * @return The state of the reserve **/ function getReserveData( uint256 reserveId ) external view returns (DataTypes.ReserveData memory); function getReservesList() external view returns (address[] memory); function getBorrowInfo( uint256 borrowId ) external view returns (DataTypes.BorrowInfo memory); function setPause(bool val) external; function paused() external view returns (bool); function getReservesCount() external view returns (uint256); } interface IPriceOracle { function getPrice(address _nft) external returns (int); function getPrice_view(address _nft) external view returns (int); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Kyoko Governance * @author Kyoko **/ interface IKyokoPoolAddressesProvider { event MarketIdSet(string newMarketId); event KyokoPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event KyokoPoolLiquidatorUpdated(address indexed newAddress); event KyokoPoolConfiguratorUpdated(address indexed newAddress); event KyokoPoolFactoryUpdated(address indexed newAddress); event RateStrategyUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress); event AddressRevoke(bytes32 id, address indexed oldAddress); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external; function setAddress(bytes32 id, address newAddress) external; function revokeAddress(bytes32 id, address oldAddress) external; function getAddress(bytes32 id) external view returns (address[] memory); function hasRole(bytes32 id, address account) external view returns (bool); function getKyokoPool() external view returns (address[] memory); function isKyokoPool(address account) external view returns (bool); function setKyokoPool(address pool) external; function getKyokoPoolLiquidator() external view returns (address[] memory); function isLiquidator(address account) external view returns (bool); function setKyokoPoolLiquidator(address liquidator) external; function getKyokoPoolConfigurator() external view returns (address[] memory); function isConfigurator(address account) external view returns (bool); function setKyokoPoolConfigurator(address configurator) external; function getKyokoPoolFactory() external view returns (address[] memory); function isFactory(address account) external view returns (bool); function setKyokoPoolFactory(address factory) external; function getPoolAdmin() external view returns (address[] memory); function isAdmin(address account) external view returns (bool); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address[] memory); function isEmergencyAdmin(address account) external view returns (bool); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address[] memory); function isOracle(address account) external view returns (bool); function setPriceOracle(address priceOracle) external; function getRateStrategy() external view returns (address[] memory); function isStrategy(address account) external view returns (bool); function setRateStrategy(address rateStrategy) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; interface IScaledBalanceToken { /** * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the * updated stored balance divided by the reserve's liquidity index at the moment of the update * @param user The user whose balance is calculated * @return The scaled balance of the user **/ function scaledBalanceOf(address user) external view returns (uint256); /** * @dev Returns the scaled balance of the user and the scaled total supply. * @param user The address of the user * @return The scaled balance of the user * @return The scaled balance and the scaled total supply **/ function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256); /** * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) * @return The scaled total supply **/ function scaledTotalSupply() external view returns (uint256); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; library DataTypes { struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; // variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; // the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address kTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint256 id; } struct ReserveConfigurationMap { // bit 0-15: factor // bit 16-31: borrow ratio // bit 32-71: period // bit 72-111: min borrow time // bit 112: reserve is active // bit 113-128: Liq. threshold // bit 129: borrowing is enabled // bit 130: stable rate borrowing enabled // bit 131-154: liquidation duration // bit 155-178: auction duration // bit 179: reserve is frozen // bit 180-211: initial liquidity lock period // bit 212-219: reserve type uint256 data; } struct Request { address user; address nft; uint256 id; InterestRateMode rateMode; uint256 reserveId; } enum Status { BORROW, REPAY, AUCTION, WITHDRAW } enum InterestRateMode { NONE, STABLE, VARIABLE } struct BorrowInfo { uint256 reserveId; address nft; uint256 nftId; address user; uint64 startTime; uint256 principal; uint256 borrowId; uint64 liquidateTime; Status status; InterestRateMode rateMode; } struct Auction { // ID for the Noun (ERC721 token ID) uint256 borrowId; // The current highest bid amount uint256 amount; // The time that the auction started uint256 startTime; // The time that the auction is scheduled to end uint256 endTime; // The address of the current highest bid address payable bidder; // Whether or not the auction has been settled bool settled; } struct InitReserveInput { uint256 reserveId; address kTokenImpl; address stableDebtTokenImpl; address variableDebtTokenImpl; address interestRateStrategyAddress; address underlyingAsset; address treasury; uint16 factor; uint16 borrowRatio; uint40 period; uint40 minBorrowTime; uint16 liqThreshold; uint24 liqDuration; uint24 bidDuration; uint32 lockTime; bool stableBorrowed; } struct RateStrategyInput { uint256 reserveId; uint256 optimalUtilizationRate; uint256 baseVariableBorrowRate; uint256 variableSlope1; uint256 variableSlope2; uint256 baseStableBorrowRate; uint256 stableSlope1; uint256 stableSlope2; } struct Rate { /** * @dev this constant represents the utilization rate at which the pool aims to obtain most competitive borrow rates. * Expressed in ray **/ uint256 optimalUtilizationRate; /** * @dev This constant represents the excess utilization rate above the optimal. It's always equal to * 1-optimal utilization rate. Added as a constant here for gas optimizations. * Expressed in ray **/ uint256 excessUtilizationRate; // Base variable borrow rate when Utilization rate = 0. Expressed in ray uint256 baseVariableBorrowRate; // Slope of the variable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray uint256 variableRateSlope1; // Slope of the variable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray uint256 variableRateSlope2; // Base stable borrow rate when Utilization rate = 0. Expressed in ray uint256 baseStableBorrowRate; // Slope of the stable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray uint256 stableRateSlope1; // Slope of the stable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray uint256 stableRateSlope2; } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; /** * @title Errors library * @author Kyoko * @notice Defines the error messages emitted by the different contracts of the Kyoko protocol * @dev Error messages prefix glossary: * - VL = ValidationLogic * - MATH = Math libraries * - CT = Common errors between tokens (KToken, VariableDebtToken and StableDebtToken) * - KT = KToken * - SDT = StableDebtToken * - VDT = VariableDebtToken * - KP = KyokoPool * - KF = KyokoFactory * - KPC = KyokoPoolConfiguration * - RL = ReserveLogic * - KPCM = KyokoPoolCollateralManager * - P = Pausable */ library Errors { //common errors string public constant CALLER_NOT_POOL_ADMIN = '25'; // 'The caller must be the pool admin' string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '26'; // User borrows on behalf, but allowance are too small string public constant ERROR = '27'; // User borrows on behalf, but allowance are too small //contract specific errors string public constant VL_INVALID_AMOUNT = '1'; // 'Amount must be greater than 0' string public constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve' string public constant VL_RESERVE_FROZEN = '3'; // 'Action cannot be performed because the reserve is frozen' string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '4'; // 'User cannot withdraw more than the available balance' string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '5'; // 'Invalid interest rate mode selected' string public constant VL_BORROWING_NOT_ENABLED = '6'; // 'Borrowing is not enabled' string public constant VL_STABLE_BORROWING_NOT_ENABLED = '7'; // stable borrowing not enabled string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '8'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string public constant VL_NOT_NFT_OWNER = '9'; // 'User is not the owner of the nft' string public constant VL_NOT_SUPPORT = '10'; // 'User's nft for borrow is not support' string public constant VL_TOO_EARLY = '11'; // 'Action is earlier than requested' string public constant VL_TOO_LATE = '12'; // 'Action is later than requested' string public constant VL_BAD_STATUS = '13'; // 'Action with wrong borrow status' string public constant VL_INVALID_USER = '14'; // 'User is not borrow owner' string public constant VL_AUCTION_ALREADY_SETTLED = '15'; // 'Auction is already done' string public constant VL_BAD_PRICE_TO_REPAY = '16'; // 'The floor price below liquidation price' string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '31'; // 'User does not have any stable rate loan for this reserve' string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '32'; // 'Interest rate rebalance conditions were not met' string public constant LP_LIQUIDATION_CALL_FAILED = '33'; // 'Liquidation call failed' string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '34'; // 'The requested amount is too small for an action.' string public constant LP_CALLER_NOT_KYOKO_POOL_CONFIGURATOR = '35'; // 'The caller of the function is Kyoko pool configurator' string public constant LP_CALLER_NOT_KYOKO_POOL_ORACLE = '36'; // 'The caller of the function is not the Kyoko pool oracle' string public constant LP_CALLER_NOT_KYOKO_POOL_FACTORY = '37'; // 'The caller of the function is not the Kyoko pool factory' string public constant LP_NFT_ALREADY_EXIST = '38'; // 'The initial reserve nft is already exist' string public constant LP_WETH_TRANSFER_FAILED = '39'; // 'Failed to transfer eth and weth' string public constant LP_BORROW_FAILED = '41'; // 'Can't be borrowed' string public constant LP_LIQUIDITY_INSUFFICIENT = '42'; // 'Insufficient pool balance' string public constant LP_IS_PAUSED = '43'; // 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = '44'; string public constant LP_NOT_CONTRACT = '45'; string public constant LP_NFT_NOT_SUPPORT = '46'; string public constant CT_CALLER_MUST_BE_KYOKO_POOL = '51'; // 'The caller of this function must be a Kyoko pool' string public constant RL_RESERVE_ALREADY_INITIALIZED = '52'; // 'Reserve has already been initialized' string public constant KPC_RESERVE_LIQUIDITY_NOT_0 = '53'; // 'The liquidity of the reserve needs to be 0' string public constant KPC_CALLER_NOT_EMERGENCY_ADMIN = '54'; // 'The caller must be the emergency admin' string public constant KPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '55'; // 'Health factor is not below the threshold' string public constant KPCM_LIQUIDATION_DISABLED = '56'; // 'Health factor is not below the threshold' string public constant KPCM_NO_ERRORS = '57'; // 'No errors' string public constant MATH_MULTIPLICATION_OVERFLOW = '58'; string public constant MATH_ADDITION_OVERFLOW = '59'; string public constant MATH_DIVISION_BY_ZERO = '60'; string public constant RL_LIQUIDITY_INDEX_OVERFLOW = '61'; // Liquidity index overflows uint128 string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '62'; // Variable borrow index overflows uint128 string public constant RL_LIQUIDITY_RATE_OVERFLOW = '63'; // Liquidity rate overflows uint128 string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '64'; // Variable borrow rate overflows uint128 string public constant RL_STABLE_BORROW_RATE_OVERFLOW = '65'; // Stable borrow rate overflows uint128 string public constant CT_INVALID_MINT_AMOUNT = '66'; //invalid amount to mint string public constant CT_INVALID_BURN_AMOUNT = '67'; //invalid amount to burn string public constant RC_INVALID_RESERVE_FACTOR = '71'; string public constant RC_INVALID_BORROW_RATIO = '72'; string public constant RC_INVALID_PERIOD = '73'; string public constant RC_INVALID_MIN_BORROW_TIME = '74'; string public constant RC_INVALID_LIQ_THRESHOLD = '75'; string public constant RC_INVALID_LIQ_TIME = '76'; string public constant RC_INVALID_BID_TIME = '77'; string public constant SDT_STABLE_DEBT_OVERFLOW = '81'; string public constant SDT_BURN_EXCEEDS_BALANCE = '82'; string public constant SDT_CREATION_FAILED = '83'; string public constant VDT_CREATION_FAILED = '84'; string public constant KF_LIQUIDITY_INSUFFICIENT = '85'; string public constant KT_CREATION_FAILED = '86'; string public constant KT_ERROR_CREATOR = '87'; string public constant KT_INITIAL_LIQUIDITY_LOCK = '88'; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "./Errors.sol"; /** * @title WadRayMath library * @author Kyoko * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits) **/ library WadRayMath { uint256 internal constant WAD = 1e18; uint256 internal constant halfWAD = WAD / 2; uint256 internal constant RAY = 1e27; uint256 internal constant halfRAY = RAY / 2; uint256 internal constant WAD_RAY_RATIO = 1e9; /** * @return One ray, 1e27 **/ function ray() internal pure returns (uint256) { return RAY; } /** * @return One wad, 1e18 **/ function wad() internal pure returns (uint256) { return WAD; } /** * @return Half ray, 1e27/2 **/ function halfRay() internal pure returns (uint256) { return halfRAY; } /** * @return Half ray, 1e18/2 **/ function halfWad() internal pure returns (uint256) { return halfWAD; } /** * @dev Multiplies two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a*b, in wad **/ function wadMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - halfWAD) / b, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * b + halfWAD) / WAD; } /** * @dev Divides two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a/b, in wad **/ function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, Errors.MATH_DIVISION_BY_ZERO); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / WAD, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * WAD + halfB) / b; } /** * @dev Multiplies two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a*b, in ray **/ function rayMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - halfRAY) / b, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * b + halfRAY) / RAY; } /** * @dev Divides two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a/b, in ray **/ function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, Errors.MATH_DIVISION_BY_ZERO); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / RAY, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * RAY + halfB) / b; } /** * @dev Casts ray down to wad * @param a Ray * @return a casted to wad, rounded half up to the nearest wad **/ function rayToWad(uint256 a) internal pure returns (uint256) { uint256 halfRatio = WAD_RAY_RATIO / 2; uint256 result = halfRatio + a; require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW); return result / WAD_RAY_RATIO; } /** * @dev Converts wad up to ray * @param a Wad * @return a converted in ray **/ function wadToRay(uint256 a) internal pure returns (uint256) { uint256 result = a * WAD_RAY_RATIO; require(result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW); return result; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.18; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; /** * @title ERC20 * @notice Basic ERC20 implementation **/ abstract contract BasicERC20 is ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) internal _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 internal _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor( string memory name, string memory symbol, uint8 decimals ) internal { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return The name of the token **/ function name() public view override returns (string memory) { return _name; } /** * @return The symbol of the token **/ function symbol() public view override returns (string memory) { return _symbol; } /** * @return The decimals of the token **/ function decimals() public view override returns (uint8) { return _decimals; } /** * @return The total supply of the token **/ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @return The balance of the token **/ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev Executes a transfer of tokens from _msgSender() to recipient * @param recipient The recipient of the tokens * @param amount The amount of tokens being transferred * @return `true` if the transfer succeeds, `false` otherwise **/ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); emit Transfer(_msgSender(), recipient, amount); return true; } /** * @dev Returns the allowance of spender on the tokens owned by owner * @param owner The owner of the tokens * @param spender The user allowed to spend the owner's tokens * @return The amount of owner's tokens spender is allowed to spend **/ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev Allows `spender` to spend the tokens owned by _msgSender() * @param spender The user allowed to spend _msgSender() tokens * @return `true` **/ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev Executes a transfer of token from sender to recipient, if _msgSender() is allowed to do so * @param sender The owner of the tokens * @param recipient The recipient of the tokens * @param amount The amount of tokens being transferred * @return `true` if the transfer succeeds, `false` otherwise **/ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); require(_allowances[sender][_msgSender()] >= amount, "ERC20: transfer amount exceeds allowance"); _approve( sender, _msgSender(), _allowances[sender][_msgSender()] - amount ); emit Transfer(sender, recipient, amount); return true; } /** * @dev Increases the allowance of spender to spend _msgSender() tokens * @param spender The user allowed to spend on behalf of _msgSender() * @param addedValue The amount being added to the allowance * @return `true` **/ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } /** * @dev Decreases the allowance of spender to spend _msgSender() tokens * @param spender The user allowed to spend on behalf of _msgSender() * @param subtractedValue The amount being subtracted to the allowance * @return `true` **/ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { require(_allowances[_msgSender()][spender] >= subtractedValue, "ERC20: decreased allowance below zero"); _approve( _msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue ); return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 oldSenderBalance = _balances[sender]; require(oldSenderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = oldSenderBalance - amount; _balances[recipient] = _balances[recipient] + amount; } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); uint256 oldTotalSupply = _totalSupply; _totalSupply = oldTotalSupply + amount; uint256 oldAccountBalance = _balances[account]; _balances[account] = oldAccountBalance + amount; } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 oldTotalSupply = _totalSupply; _totalSupply = oldTotalSupply - amount; uint256 oldAccountBalance = _balances[account]; require(oldAccountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = oldAccountBalance - amount; } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setName(string memory newName) internal { _name = newName; } function _setSymbol(string memory newSymbol) internal { _symbol = newSymbol; } function _setDecimals(uint8 newDecimals) internal { _decimals = newDecimals; } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.18; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "../libraries/utils/WadRayMath.sol"; import "../libraries/utils/Errors.sol"; import "../interfaces/IKyokoPool.sol"; import "../interfaces/IKToken.sol"; import "../interfaces/IKyokoPoolAddressesProvider.sol"; import "./BasicERC20.sol"; /** * @title Kyoko ERC20 KToken * @dev Implementation of the interest bearing token for the Kyoko protocol * @author Kyoko */ contract KToken is Initializable, BasicERC20("KTOKEN_IMPL", "KTOKEN_IMPL", 0), IKToken, ERC721HolderUpgradeable { using WadRayMath for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; IKyokoPoolAddressesProvider internal _addressesProvider; address internal _treasury; address internal _underlyingAsset; uint256 internal _reserveId; modifier onlyKyokoPool() { require( _msgSender() == address(_getKyokoPool()), Errors.CT_CALLER_MUST_BE_KYOKO_POOL ); _; } constructor( IKyokoPoolAddressesProvider provider, uint256 reserveId, address treasury, address underlyingAsset, uint8 kTokenDecimals, string memory kTokenName, string memory kTokenSymbol ) initializer { _setName(kTokenName); _setSymbol(kTokenSymbol); _setDecimals(kTokenDecimals); _addressesProvider = provider; _reserveId = reserveId; _treasury = treasury; _underlyingAsset = underlyingAsset; emit Initialize( underlyingAsset, _addressesProvider.getKyokoPool()[0], reserveId, treasury, kTokenDecimals, kTokenName, kTokenSymbol ); } /** * @dev Initializes the kToken * @param provider The address of the address provider where this kToken will be used * @param reserveId The id of the reserves * @param treasury The address of the Kyoko treasury, receiving the fees on this kToken * @param underlyingAsset The address of the underlying asset of this kToken (E.g. WETH for aWETH) * @param kTokenDecimals The decimals of the kToken, same as the underlying asset's * @param kTokenName The name of the kToken * @param kTokenSymbol The symbol of the kToken */ function initialize( IKyokoPoolAddressesProvider provider, uint256 reserveId, address treasury, address underlyingAsset, uint8 kTokenDecimals, string calldata kTokenName, string calldata kTokenSymbol ) external override initializer { _setName(kTokenName); _setSymbol(kTokenSymbol); _setDecimals(kTokenDecimals); _addressesProvider = provider; _reserveId = reserveId; _treasury = treasury; _underlyingAsset = underlyingAsset; emit Initialize( underlyingAsset, _addressesProvider.getKyokoPool()[0], reserveId, treasury, kTokenDecimals, kTokenName, kTokenSymbol ); } /** * @dev Burns kTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * - Only callable by the KyokoPool, as extra state updates there need to be managed * @param user The owner of the kTokens, getting them burned * @param receiverOfUnderlying The address that will receive the underlying * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn( address user, address receiverOfUnderlying, uint256 amount, uint256 index ) external override onlyKyokoPool { uint256 amountScaled = amount.rayDiv(index); require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT); _burn(user, amountScaled); IERC20Upgradeable(_underlyingAsset).safeTransfer( receiverOfUnderlying, amount ); emit Transfer(user, address(0), amount); emit Burn(user, receiverOfUnderlying, amount, index); } /** * @dev Burns kTokens from `user` * - Only callable by the KyokoPool, as extra state updates there need to be managed * @param user The owner of the kTokens, getting them burned * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn( address user, uint256 amount, uint256 index ) external override onlyKyokoPool { uint256 amountScaled = amount.rayDiv(index); require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT); _burn(user, amountScaled); emit Transfer(user, address(0), amount); } /** * @dev Mints `amount` kTokens to `user` * - Only callable by the KyokoPool, as extra state updates there need to be managed * @param user The address receiving the minted tokens * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve * @return `true` if the the previous balance of the user was 0 */ function mint( address user, uint256 amount, uint256 index ) external override onlyKyokoPool returns (bool) { uint256 previousBalance = super.balanceOf(user); uint256 amountScaled = amount.rayDiv(index); require(amountScaled != 0, Errors.CT_INVALID_MINT_AMOUNT); _mint(user, amountScaled); emit Transfer(address(0), user, amount); emit Mint(user, amount, index); return previousBalance == 0; } /** * @dev Mints kTokens to the reserve treasury * - Only callable by the KyokoPool * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve */ function mintToTreasury( uint256 amount, uint256 index ) external override onlyKyokoPool { if (amount == 0) { return; } address treasury = _treasury; // Compared to the normal mint, we don't check for rounding errors. // The amount to mint can easily be very small since it is a fraction of the interest ccrued. // In that case, the treasury will experience a (very small) loss, but it // wont cause potentially valid transactions to fail. _mint(treasury, amount.rayDiv(index)); emit Transfer(address(0), treasury, amount); emit Mint(treasury, amount, index); } /** * @dev Transfers kTokens in the event of a borrow being liquidated, in case the liquidators reclaims the kToken * - Only callable by the KyokoPool * @param from The address getting liquidated, current owner of the kTokens * @param to The recipient * @param value The amount of tokens getting transferred **/ function transferOnLiquidation( address from, address to, uint256 value ) external override onlyKyokoPool { // Being a normal transfer, the Transfer() and BalanceTransfer() are emitted // so no need to emit a specific event here _transfer(from, to, value); emit Transfer(from, to, value); } /** * @dev Calculates the balance of the user: principal balance + interest generated by the principal * @param user The user whose balance is calculated * @return The balance of the user **/ function balanceOf( address user ) public view override(BasicERC20, IERC20Upgradeable) returns (uint256) { IKyokoPool pool = _getKyokoPool(); return super.balanceOf(user).rayMul( pool.getReserveNormalizedIncome(_reserveId) ); } /** * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the * updated stored balance divided by the reserve's liquidity index at the moment of the update * @param user The user whose balance is calculated * @return The scaled balance of the user **/ function scaledBalanceOf( address user ) external view override returns (uint256) { return super.balanceOf(user); } /** * @dev Returns the scaled balance of the user and the scaled total supply. * @param user The address of the user * @return The scaled balance of the user * @return The scaled balance and the scaled total supply **/ function getScaledUserBalanceAndSupply( address user ) external view override returns (uint256, uint256) { return (super.balanceOf(user), super.totalSupply()); } /** * @dev calculates the total supply of the specific kToken * since the balance of every single user increases over time, the total supply * does that too. * @return the current total supply **/ function totalSupply() public view override(BasicERC20, IERC20Upgradeable) returns (uint256) { uint256 currentSupplyScaled = super.totalSupply(); if (currentSupplyScaled == 0) { return 0; } IKyokoPool pool = _getKyokoPool(); return currentSupplyScaled.rayMul( pool.getReserveNormalizedIncome(_reserveId) ); } // TODO wrong Annotate /** * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) * @return the scaled total supply **/ function scaledTotalSupply() public view virtual override returns (uint256) { return super.totalSupply(); } /** * @dev Returns the address of the Kyoko treasury, receiving the fees on this kToken **/ function RESERVE_TREASURY_ADDRESS() public view returns (address) { return _treasury; } /** * @dev Returns the address of the underlying asset of this kToken (E.g. WETH for aWETH) **/ function UNDERLYING_ASSET_ADDRESS() public view override returns (address) { return _underlyingAsset; } /** * @dev Returns the address of the lending pool where this kToken is used **/ function POOL() public view returns (IKyokoPool) { return _getKyokoPool(); } /** * @dev Transfers the underlying asset to `target`. Used by the KyokoPool to transfer * assets in borrow(), withdraw() and flashLoan() * @param target The recipient of the kTokens * @param amount The amount getting transferred * @return The amount transferred **/ function transferUnderlyingTo( address target, uint256 amount ) external override onlyKyokoPool returns (uint256) { IERC20Upgradeable(_underlyingAsset).safeTransfer(target, amount); return amount; } /** * @dev Transfers the underlying asset to `target`. Used by the KyokoPool to transfer * assets in borrow(), withdraw() and flashLoan() * @param nft The nft address * @param target The recipient of the kTokens * @param nftId The token id of nft * @return The amount transferred **/ function transferUnderlyingNFTTo( address nft, address target, uint256 nftId ) external override onlyKyokoPool returns (uint256) { IERC721Upgradeable(nft).safeTransferFrom(address(this), target, nftId); return nftId; } function _getKyokoPool() internal view returns (IKyokoPool) { return IKyokoPool(_addressesProvider.getKyokoPool()[0]); } /** * @dev Invoked to execute actions on the kToken side after a repayment. * @param user The user executing the repayment * @param amount The amount getting repaid **/ function handleRepayment( address user, uint256 amount ) external override onlyKyokoPool {} /** * @dev Overrides the parent _transfer to force validated transfer() and transferFrom() * @param from The source address * @param to The destination address * @param amount The amount getting transferred **/ function _transfer( address from, address to, uint256 amount ) internal override { IKyokoPool pool = _getKyokoPool(); uint256 index = pool.getReserveNormalizedIncome(_reserveId); super._transfer(from, to, amount.rayDiv(index)); emit BalanceTransfer(from, to, amount, index); } event NFTReceived( address indexed operator, address indexed from, uint256 indexed tokenId, bytes data ); function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public override(ERC721HolderUpgradeable) returns (bytes4) { emit NFTReceived(operator, from, tokenId, data); return bytes4( keccak256("onERC721Received(address,address,uint256,bytes)") ); } }
{ "optimizer": { "enabled": true, "runs": 10 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"kToken","type":"address"}],"name":"CreateKToken","type":"event"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_provider","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"s1","type":"string"},{"internalType":"string","name":"s2","type":"string"}],"name":"createKToken","outputs":[{"internalType":"address","name":"kTokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x60806040523480156200001157600080fd5b50600436106200002e5760003560e01c80634780fa7e1462000033575b600080fd5b6200004a6200004436600462000282565b62000066565b6040516001600160a01b03909116815260200160405180910390f35b6040805180820182526017815276025bcb7b5b79034b73a32b932b9ba103132b0b934b7339604d1b6020808301919091528251808401845260018152606b60f81b8183015292516000938b938b938b938b93918891620000cf9185918e918e918e91016200037b565b60405160208183030381529060405290506000828c8b604051602001620000f993929190620003da565b604051602081830303815290604052905060008786888b601287876040516200012290620001ad565b62000134979695949392919062000451565b604051809103906000f08015801562000151573d6000803e3d6000fd5b50604080513381526001600160a01b0383166020820152919b508b92507f71c7d03c00af45a18b2bd71849b30d0d88c6ad5fc00988120bcea71df7ec8633910160405180910390a1505050505050505050979650505050505050565b612b1180620004ba83390190565b80356001600160a01b0381168114620001d357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200020057600080fd5b81356001600160401b03808211156200021d576200021d620001d8565b604051601f8301601f19908116603f01168101908282118183101715620002485762000248620001d8565b816040528381528660208588010111156200026257600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600060e0888a0312156200029e57600080fd5b620002a988620001bb565b9650620002b960208901620001bb565b9550620002c960408901620001bb565b94506060880135935060808801356001600160401b0380821115620002ed57600080fd5b620002fb8b838c01620001ee565b945060a08a01359150808211156200031257600080fd5b620003208b838c01620001ee565b935060c08a01359150808211156200033757600080fd5b50620003468a828b01620001ee565b91505092959891949750929550565b60005b838110156200037257818101518382015260200162000358565b50506000910152565b600085516200038f818460208a0162000355565b855190830190620003a5818360208a0162000355565b8551910190620003ba81836020890162000355565b8451910190620003cf81836020880162000355565b019695505050505050565b60008451620003ee81846020890162000355565b8451908301906200040481836020890162000355565b84519101906200041981836020880162000355565b0195945050505050565b600081518084526200043d81602086016020860162000355565b601f01601f19169290920160200192915050565b6001600160a01b0388811682526020820188905286811660408301528516606082015260ff8416608082015260e060a08201819052600090620004979083018562000423565b82810360c0840152620004ab818562000423565b9a995050505050505050505056fe60806040523480156200001157600080fd5b5060405162002b1138038062002b11833981016040819052620000349162000434565b604080518082018252600b8082526a12d513d2d15397d253541360aa1b6020808401829052845180860190955291845290830152906000603662000079848262000592565b50603762000088838262000592565b506038805460ff191660ff9283161790556000546101009004161591508190508015620000bc5750600054600160ff909116105b80620000ec5750620000d9306200030960201b620011bd1760201c565b158015620000ec575060005460ff166001145b620001545760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff19166001179055801562000178576000805461ff0019166101001790555b620001838362000318565b6200018e826200032a565b6038805460ff191660ff8616179055606b80546001600160a01b03808b166001600160a01b03199283168117909355606e8a9055606c80548a8316908416179055606d805491891691909216179055604080516330ed38ad60e01b815290518992916330ed38ad9160048083019260009291908290030181865afa1580156200021b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200024591908101906200065e565b6000815181106200025a576200025a6200071c565b60200260200101516001600160a01b0316866001600160a01b03167f494fa12ba95bab69c92c49b56520f4ddf8b44104b16d569aedccfe88b3af24a189888888604051620002ac949392919062000760565b60405180910390a48015620002fb576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050620007ae565b6001600160a01b03163b151590565b603662000326828262000592565b5050565b603762000326828262000592565b6001600160a01b03811681146200034e57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000392576200039262000351565b604052919050565b60005b83811015620003b75781810151838201526020016200039d565b50506000910152565b600082601f830112620003d257600080fd5b81516001600160401b03811115620003ee57620003ee62000351565b62000403601f8201601f191660200162000367565b8181528460208386010111156200041957600080fd5b6200042c8260208301602087016200039a565b949350505050565b600080600080600080600060e0888a0312156200045057600080fd5b87516200045d8162000338565b602089015160408a01519198509650620004778162000338565b60608901519095506200048a8162000338565b608089015190945060ff81168114620004a257600080fd5b60a08901519093506001600160401b0380821115620004c057600080fd5b620004ce8b838c01620003c0565b935060c08a0151915080821115620004e557600080fd5b50620004f48a828b01620003c0565b91505092959891949750929550565b600181811c908216806200051857607f821691505b6020821081036200053957634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200058d57600081815260208120601f850160051c81016020861015620005685750805b601f850160051c820191505b81811015620005895782815560010162000574565b5050505b505050565b81516001600160401b03811115620005ae57620005ae62000351565b620005c681620005bf845462000503565b846200053f565b602080601f831160018114620005fe5760008415620005e55750858301515b600019600386901b1c1916600185901b17855562000589565b600085815260208120601f198616915b828110156200062f578886015182559484019460019091019084016200060e565b50858210156200064e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083850312156200067257600080fd5b82516001600160401b03808211156200068a57600080fd5b818501915085601f8301126200069f57600080fd5b815181811115620006b457620006b462000351565b8060051b9150620006c784830162000367565b8181529183018401918481019088841115620006e257600080fd5b938501935b83851015620007105784519250620006ff8362000338565b8282529385019390850190620006e7565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b600081518084526200074c8160208601602086016200039a565b601f01601f19169290920160200192915050565b6001600160a01b038516815260ff841660208201526080604082018190526000906200078f9083018562000732565b8281036060840152620007a3818562000732565b979650505050505050565b61235380620007be6000396000f3fe608060405234801561001057600080fd5b50600436106101495760003560e01c806306fdde031461014e578063095ea7b31461016c5780630afbcdc91461018f578063150b7a02146101b0578063156e29f6146101dc57806318160ddd146101ef5780631c3b7872146102055780631da24f3e1461021a57806323b872dd1461022d578063313ce5671461024057806339509351146102555780634efecaa51461026857806370a082311461027b5780637535d2461461028e5780637df5bd3b146102ae57806388dd91a1146102c157806395d89b41146102d45780639a97114f146102dc578063a457c2d7146102ef578063a9059cbb14610302578063ae16733514610315578063b16a19de14610326578063b1bf962d14610337578063d7020d0a1461033f578063dd62ed3e14610352578063f5298aca1461038b578063f866c3191461039e575b600080fd5b6101566103b1565b6040516101639190611bdd565b60405180910390f35b61017f61017a366004611c08565b610443565b6040519015158152602001610163565b6101a261019d366004611c34565b61045a565b604051610163929190611c51565b6101c36101be366004611ca5565b610472565b6040516001600160e01b03199091168152602001610163565b61017f6101ea366004611d68565b6104eb565b6101f7610614565b604051908152602001610163565b610218610213366004611de5565b6106c0565b005b6101f7610228366004611c34565b610979565b61017f61023b366004611eb0565b610984565b60385460405160ff9091168152602001610163565b61017f610263366004611c08565b610a95565b6101f7610276366004611c08565b610acc565b6101f7610289366004611c34565b610b41565b610296610bd8565b6040516001600160a01b039091168152602001610163565b6102186102bc366004611ef1565b610be7565b6102186102cf366004611c08565b610cc8565b610156610d22565b6101f76102ea366004611eb0565b610d31565b61017f6102fd366004611c08565b610df9565b61017f610310366004611c08565b610eb0565b606c546001600160a01b0316610296565b606d546001600160a01b0316610296565b6101f7610ef4565b61021861034d366004611f13565b610eff565b6101f7610360366004611f59565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b610218610399366004611d68565b611040565b6102186103ac366004611eb0565b61111c565b6060603680546103c090611f92565b80601f01602080910402602001604051908101604052809291908181526020018280546103ec90611f92565b80156104395780601f1061040e57610100808354040283529160200191610439565b820191906000526020600020905b81548152906001019060200180831161041c57829003601f168201915b5050505050905090565b60006104503384846111cc565b5060015b92915050565b600080610466836112e8565b60355491509150915091565b600082846001600160a01b0316866001600160a01b03167f1d823cdc8f0514a95b53538df2d2f3deaf98d1c534c6e750daa593173c27f8f0856040516104b89190611bdd565b60405180910390a4507f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f5b949350505050565b60006104f5611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b8152509061054b5760405162461bcd60e51b81526004016105429190611bdd565b60405180910390fd5b506000610557856112e8565b905060006105658585611393565b6040805180820190915260028152611b1b60f11b60208201529091508161059f5760405162461bcd60e51b81526004016105429190611bdd565b506105aa8682611467565b6040518581526001600160a01b038716906000906000805160206122fe8339815191529060200160405180910390a3856001600160a01b03166000805160206122de8339815191528686604051610602929190611c51565b60405180910390a25015949350505050565b60008061062060355490565b90508060000361063257600091505090565b600061063c611303565b90506106b9816001600160a01b031663dcc5cded606e546040518263ffffffff1660e01b815260040161067191815260200190565b602060405180830381865afa15801561068e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b29190611fc6565b8390611512565b9250505090565b600054610100900460ff16158080156106e05750600054600160ff909116105b8061070157506106ef306111bd565b158015610701575060005460ff166001145b6107645760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610542565b6000805460ff191660011790558015610787576000805461ff0019166101001790555b6107c685858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115cb92505050565b61080583838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115d792505050565b6038805460ff191660ff8816179055606b80546001600160a01b03808d166001600160a01b03199283168117909355606e8c9055606c80548c8316908416179055606d8054918b1691909216179055604080516330ed38ad60e01b815290518b92916330ed38ad9160048083019260009291908290030181865afa158015610891573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108b99190810190611fdf565b6000815181106108cb576108cb612090565b60200260200101516001600160a01b0316886001600160a01b03167f494fa12ba95bab69c92c49b56520f4ddf8b44104b16d569aedccfe88b3af24a18b8a8a8a8a8a60405161091f969594939291906120cf565b60405180910390a4801561096d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6000610454826112e8565b60006109918484846115e3565b6001600160a01b0384166000908152603460209081526040808320338452909152902054821115610a155760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610542565b6001600160a01b038416600090815260346020908152604080832033808552925290912054610a50918691610a4b908690612133565b6111cc565b826001600160a01b0316846001600160a01b03166000805160206122fe83398151915284604051610a8391815260200190565b60405180910390a35060019392505050565b3360008181526034602090815260408083206001600160a01b03871684529091528120549091610450918590610a4b908690612146565b6000610ad6611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b81525090610b235760405162461bcd60e51b81526004016105429190611bdd565b50606d54610b3b906001600160a01b031684846116bd565b50919050565b600080610b4c611303565b9050610bd1816001600160a01b031663dcc5cded606e546040518263ffffffff1660e01b8152600401610b8191815260200190565b602060405180830381865afa158015610b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc29190611fc6565b610bcb856112e8565b90611512565b9392505050565b6000610be2611303565b905090565b610bef611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b81525090610c3c5760405162461bcd60e51b81526004016105429190611bdd565b508115610cc457606c546001600160a01b0316610c6281610c5d8585611393565b611467565b6040518381526001600160a01b038216906000906000805160206122fe8339815191529060200160405180910390a3806001600160a01b03166000805160206122de8339815191528484604051610cba929190611c51565b60405180910390a2505b5050565b610cd0611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b81525090610d1d5760405162461bcd60e51b81526004016105429190611bdd565b505050565b6060603780546103c090611f92565b6000610d3b611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b81525090610d885760405162461bcd60e51b81526004016105429190611bdd565b50604051632142170760e11b81523060048201526001600160a01b038481166024830152604482018490528516906342842e0e90606401600060405180830381600087803b158015610dd957600080fd5b505af1158015610ded573d6000803e3d6000fd5b50939695505050505050565b3360009081526034602090815260408083206001600160a01b0386168452909152812054821115610e7a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610542565b3360008181526034602090815260408083206001600160a01b038816845290915290205461045091908590610a4b908690612133565b6000610ebd3384846115e3565b6040518281526001600160a01b0384169033906000805160206122fe8339815191529060200160405180910390a350600192915050565b6000610be260355490565b610f07611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b81525090610f545760405162461bcd60e51b81526004016105429190611bdd565b506000610f618383611393565b604080518082019091526002815261363760f01b602082015290915081610f9b5760405162461bcd60e51b81526004016105429190611bdd565b50610fa6858261170f565b606d54610fbd906001600160a01b031685856116bd565b6040518381526000906001600160a01b038716906000805160206122fe8339815191529060200160405180910390a3836001600160a01b0316856001600160a01b03167f5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa28585604051611031929190611c51565b60405180910390a35050505050565b611048611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b815250906110955760405162461bcd60e51b81526004016105429190611bdd565b5060006110a28383611393565b604080518082019091526002815261363760f01b6020820152909150816110dc5760405162461bcd60e51b81526004016105429190611bdd565b506110e7848261170f565b6040518381526000906001600160a01b038616906000805160206122fe8339815191529060200160405180910390a350505050565b611124611303565b6001600160a01b0316336001600160a01b03161460405180604001604052806002815260200161353160f01b815250906111715760405162461bcd60e51b81526004016105429190611bdd565b5061117d8383836115e3565b816001600160a01b0316836001600160a01b03166000805160206122fe833981519152836040516111b091815260200190565b60405180910390a3505050565b6001600160a01b03163b151590565b6001600160a01b03831661122e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610542565b6001600160a01b03821661128f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610542565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016111b0565b6001600160a01b031660009081526033602052604090205490565b606b54604080516330ed38ad60e01b815290516000926001600160a01b0316916330ed38ad91600480830192869291908290030181865afa15801561134c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113749190810190611fdf565b60008151811061138657611386612090565b6020026020010151905090565b604080518082019091526002815261036360f41b6020820152600090826113cd5760405162461bcd60e51b81526004016105429190611bdd565b5060006113db600284612159565b9050676765c793fa10079d601b1b6113f582600019612133565b6113ff9190612159565b8411156040518060400160405280600281526020016106a760f31b8152509061143b5760405162461bcd60e51b81526004016105429190611bdd565b508281611453676765c793fa10079d601b1b8761217b565b61145d9190612146565b6104e39190612159565b6001600160a01b0382166114bd5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610542565b6035546114ca8282612146565b6035556001600160a01b0383166000908152603360205260409020546114f08382612146565b6001600160a01b03909416600090815260336020526040902093909355505050565b600082158061151f575081155b1561152c57506000610454565b816115436002676765c793fa10079d601b1b612159565b61154f90600019612133565b6115599190612159565b8311156040518060400160405280600281526020016106a760f31b815250906115955760405162461bcd60e51b81526004016105429190611bdd565b50676765c793fa10079d601b1b6115ad600282612159565b6115b7848661217b565b6115c19190612146565b610bd19190612159565b6036610cc482826121e0565b6037610cc482826121e0565b60006115ed611303565b90506000816001600160a01b031663dcc5cded606e546040518263ffffffff1660e01b815260040161162191815260200190565b602060405180830381865afa15801561163e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116629190611fc6565b905061167885856116738685611393565b6117fd565b836001600160a01b0316856001600160a01b03167f4beccb90f994c31aced7a23b5611020728a23d8ec5cddd1a3e9d97b96fda86668584604051611031929190611c51565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d1d908490611997565b6001600160a01b03821661176f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610542565b60355461177c8282612133565b6035556001600160a01b038316600090815260336020526040902054828110156117f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610542565b6114f08382612133565b6001600160a01b0383166118615760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610542565b6001600160a01b0382166118c35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610542565b6001600160a01b0383166000908152603360205260409020548181101561193b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610542565b6119458282612133565b6001600160a01b038086166000908152603360205260408082209390935590851681522054611975908390612146565b6001600160a01b03909316600090815260336020526040902092909255505050565b60006119ec826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a6c9092919063ffffffff16565b9050805160001480611a0d575080806020019051810190611a0d919061229f565b610d1d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610542565b60606104e3848460008585600080866001600160a01b03168587604051611a9391906122c1565b60006040518083038185875af1925050503d8060008114611ad0576040519150601f19603f3d011682016040523d82523d6000602084013e611ad5565b606091505b5091509150611ae687838387611af1565b979650505050505050565b60608315611b5e578251600003611b5757611b0b856111bd565b611b575760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610542565b50816104e3565b6104e38383815115611b735781518083602001fd5b8060405162461bcd60e51b81526004016105429190611bdd565b60005b83811015611ba8578181015183820152602001611b90565b50506000910152565b60008151808452611bc9816020860160208601611b8d565b601f01601f19169290920160200192915050565b602081526000610bd16020830184611bb1565b6001600160a01b0381168114611c0557600080fd5b50565b60008060408385031215611c1b57600080fd5b8235611c2681611bf0565b946020939093013593505050565b600060208284031215611c4657600080fd5b8135610bd181611bf0565b918252602082015260400190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611c9d57611c9d611c5f565b604052919050565b60008060008060808587031215611cbb57600080fd5b8435611cc681611bf0565b9350602085810135611cd781611bf0565b93506040860135925060608601356001600160401b0380821115611cfa57600080fd5b818801915088601f830112611d0e57600080fd5b813581811115611d2057611d20611c5f565b611d32601f8201601f19168501611c75565b91508082528984828501011115611d4857600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080600060608486031215611d7d57600080fd5b8335611d8881611bf0565b95602085013595506040909401359392505050565b60008083601f840112611daf57600080fd5b5081356001600160401b03811115611dc657600080fd5b602083019150836020828501011115611dde57600080fd5b9250929050565b600080600080600080600080600060e08a8c031215611e0357600080fd5b8935611e0e81611bf0565b985060208a0135975060408a0135611e2581611bf0565b965060608a0135611e3581611bf0565b955060808a013560ff81168114611e4b57600080fd5b945060a08a01356001600160401b0380821115611e6757600080fd5b611e738d838e01611d9d565b909650945060c08c0135915080821115611e8c57600080fd5b50611e998c828d01611d9d565b915080935050809150509295985092959850929598565b600080600060608486031215611ec557600080fd5b8335611ed081611bf0565b92506020840135611ee081611bf0565b929592945050506040919091013590565b60008060408385031215611f0457600080fd5b50508035926020909101359150565b60008060008060808587031215611f2957600080fd5b8435611f3481611bf0565b93506020850135611f4481611bf0565b93969395505050506040820135916060013590565b60008060408385031215611f6c57600080fd5b8235611f7781611bf0565b91506020830135611f8781611bf0565b809150509250929050565b600181811c90821680611fa657607f821691505b602082108103610b3b57634e487b7160e01b600052602260045260246000fd5b600060208284031215611fd857600080fd5b5051919050565b60006020808385031215611ff257600080fd5b82516001600160401b038082111561200957600080fd5b818501915085601f83011261201d57600080fd5b81518181111561202f5761202f611c5f565b8060051b9150612040848301611c75565b818152918301840191848101908884111561205a57600080fd5b938501935b83851015612084578451925061207483611bf0565b828252938501939085019061205f565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038716815260ff861660208201526080604082018190526000906120fd90830186886120a6565b82810360608401526121108185876120a6565b9998505050505050505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156104545761045461211d565b808201808211156104545761045461211d565b60008261217657634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176104545761045461211d565b601f821115610d1d57600081815260208120601f850160051c810160208610156121b95750805b601f850160051c820191505b818110156121d8578281556001016121c5565b505050505050565b81516001600160401b038111156121f9576121f9611c5f565b61220d816122078454611f92565b84612192565b602080601f831160018114612242576000841561222a5750858301515b600019600386901b1c1916600185901b1785556121d8565b600085815260208120601f198616915b8281101561227157888601518255948401946001909101908401612252565b508582101561228f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156122b157600080fd5b81518015158114610bd157600080fd5b600082516122d3818460208701611b8d565b919091019291505056fe4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212204bcfe67a74a58a89495f1b8e104413d40ff2cee6865f71b1f93f9d095d5aec4e64736f6c63430008120033a2646970667358221220dd3751e3b1fef244403591df7a07ccb44ccd5e11e2852196e3245fc32c3147a764736f6c63430008120033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.