UNPKG

@andrekorol/kollateral

Version:

Typescript library for Kollateral, the flash loan building block

1,187 lines (1,186 loc) 111 kB
{ "contractName": "CollateralizedEther", "abi": [ { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address", "name": "minter", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "tokenAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "kTokenAmount", "type": "uint256" } ], "name": "Mint", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address", "name": "redeemer", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "tokenAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "kTokenAmount", "type": "uint256" } ], "name": "Redeem", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, { "stateMutability": "payable", "type": "fallback" }, { "inputs": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "approve", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "account", "type": "address" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "owner", "type": "address" } ], "name": "balanceOfUnderlying", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } ], "name": "decreaseAllowance", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "addedValue", "type": "uint256" } ], "name": "increaseAllowance", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "nativeAmount", "type": "uint256" } ], "name": "nativeAmountToUnderlyingAmount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "kTokenAmount", "type": "uint256" } ], "name": "redeem", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" } ], "name": "redeemUnderlying", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalSupply", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transfer", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "sender", "type": "address" }, { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "underlying", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "underlyingAmount", "type": "uint256" }, { "internalType": "bool", "name": "ceil", "type": "bool" } ], "name": "underlyingAmountToNativeAmount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "stateMutability": "payable", "type": "receive" }, { "inputs": [], "name": "mint", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "payable", "type": "function" }, { "inputs": [], "name": "isUnderlyingEther", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "totalReserve", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.7.3+commit.9bfce1f6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"kTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"kTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Redeem\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOfUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isUnderlyingEther\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nativeAmount\",\"type\":\"uint256\"}],\"name\":\"nativeAmountToUnderlyingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"kTokenAmount\",\"type\":\"uint256\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"redeemUnderlying\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalReserve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underlying\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"underlyingAmount\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"ceil\",\"type\":\"bool\"}],\"name\":\"underlyingAmountToNativeAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is called. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedEther.sol\":\"CollateralizedEther\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/andrekorol/src/kollateral/protocol/contracts/common/utils/ExtendedMath.sol\":{\"keccak256\":\"0x5ced249631b5dfe431f449d725d9f318b01ab0785306ca5e73cdf43760ab271a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://3f3aef65abfcc02e451ad27a849caba0e6375abb26e28e7605928d19d561c3dd\",\"dweb:/ipfs/QmY5zMeH5x3QMS5xkxkY3DH4SDPWLGJyfPk1R8wPJXH9vr\"]},\"/Users/andrekorol/src/kollateral/protocol/contracts/common/utils/ExternalCaller.sol\":{\"keccak256\":\"0x54f88a1f0ac5dd7ab99a0519124cb09f1e19b4efb9baf240bc2500f8caa0b4ff\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://3170671378d20b47498224d065e33fccc223ae772d7f0af2c5ef314f94b75c98\",\"dweb:/ipfs/Qme8ZEEBnBG5Vvj8uyJCD2YVPcLx6funKsSSCpGkTyn1zi\"]},\"/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedEther.sol\":{\"keccak256\":\"0x2a74a69e11a8a843f818b3a9834dca858a44519471d23e136a535937f099a521\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://bf6103f0cb1efa175fd4a8417c61a0c27e42781b7f46aadf2ea8ad6c754232df\",\"dweb:/ipfs/QmPz9NJNvroLUAsPzeaUSN8vq7ZGz18DjBaLWiA9gjqsXb\"]},\"/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedToken.sol\":{\"keccak256\":\"0xfaaaa4324c6cc78d9d1268426eb04fe41d8584ade05bbf22eac4875ecdf174d7\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://1e4149a0ecd14003c261b2243adfc19d7a009c83c32341ebdd6a8929c0bdd14d\",\"dweb:/ipfs/QmQbySda22WBU4oycYfrTye1RsJuz1Ub74ksoST7PeegHW\"]},\"/Users/andrekorol/src/kollateral/protocol/contracts/token/UnlimitedApprovalErc20.sol\":{\"keccak256\":\"0x407178fcd78f0a19d705e64aaaa26ae997d228f077f3cf6833f9f3eb31c72308\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://097906cbe6f8f35ba1763bd122d551ec302f45cf677021bbcdb8a55c706940d9\",\"dweb:/ipfs/QmVh7kcUWsXt3QApppB1njhGHfzdP813KSTUF6bh3VCmMM\"]},\"@openzeppelin/contracts/GSN/Context.sol\":{\"keccak256\":\"0x910a2e625b71168563edf9eeef55a50d6d699acfe27ceba3921f291829a8f938\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://248246ac66e6479dce1ad7d4945ec5540c98ceb09881e93c93f7c48d5772925c\",\"dweb:/ipfs/QmXr8tmUiZgEYid6ixeeBRmTdUnASWjKzhP3KRxMPy8fRt\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0xba96bc371ba999f452985a98717cca1e4c4abb598dc038a9a9c3db08129b1ba4\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://26e50e3f7b6482fb6f598f2e006994a74aa492687daa4b3eee7fd4fb5398ce7f\",\"dweb:/ipfs/QmZudqoPSkA4USLMFsBBmt19dDPZFS8aaAmL5R7pECXu6t\"]},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x482b6d82ba1c9c73758ae15068a438361d4187b7a4e342db17ef0f828cb5e21a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://89725e56bc9c6cfb69521ceaa4a489561b928e930b71e30db85b24024c1c2c03\",\"dweb:/ipfs/QmNvpotZA1Fe48msV6TShSTVxeQ2dkaDS9MTKP4bNxyUG3\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://2d0913dfbfce90d170df0d496ad7596c0778518e5fa7aba6c32562522546f66b\",\"dweb:/ipfs/QmR6B8nLj2PJf5e1JWD9Nk7ErkAwkqUwadCnvE82FJr1RU\"]},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"keccak256\":\"0x1153f6dd334c01566417b8c551122450542a2b75a2bbb379d59a8c320ed6da28\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://002b4e5c26a2a069ba42486b83bf9c4b5461f3d5def32f9ef52b0aef8905d6d2\",\"dweb:/ipfs/QmPG44XDF4npiqRzzGvqJroDtUKfcR78wcreQ9bXa6guW6\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "", "deployedSourceMap": "", "source": "/*\n\n Copyright 2020 Kollateral LLC.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.7.0;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"./CollateralizedToken.sol\";\nimport \"../common/utils/ExternalCaller.sol\";\n\nabstract contract CollateralizedEther is CollateralizedToken, ExternalCaller {\n using SafeMath for uint256;\n\n constructor() CollateralizedToken(address(1)) {}\n\n function mint() external payable returns (bool) {\n return mintInternal(msg.value);\n }\n\n function transferUnderlying(address to, uint256 amount)\n internal\n override\n returns (bool)\n {\n require(\n address(this).balance >= amount,\n \"KEther: not enough ether balance\"\n );\n externalTransfer(to, amount);\n return true;\n }\n\n function isUnderlyingEther() public pure override returns (bool) {\n return true;\n }\n\n function totalReserve() public view override returns (uint256) {\n return address(this).balance;\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n}\n", "sourcePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedEther.sol", "ast": { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedEther.sol", "exportedSymbols": { "CollateralizedEther": [ 4894 ], "CollateralizedToken": [ 5197 ], "Context": [ 5279 ], "ERC20": [ 6087 ], "ExtendedMath": [ 1506 ], "ExternalCaller": [ 1563 ], "IERC20": [ 6165 ], "ReentrancyGuard": [ 6295 ], "SafeMath": [ 5584 ], "UnlimitedApprovalErc20": [ 5256 ] }, "id": 4895, "license": "Apache-2.0", "nodeType": "SourceUnit", "nodes": [ { "id": 4803, "literals": [ "solidity", "^", "0.7", ".0" ], "nodeType": "PragmaDirective", "src": "640:23:35" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 4804, "nodeType": "ImportDirective", "scope": 4895, "sourceUnit": 5585, "src": "665:51:35", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedToken.sol", "file": "./CollateralizedToken.sol", "id": 4805, "nodeType": "ImportDirective", "scope": 4895, "sourceUnit": 5198, "src": "717:35:35", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/common/utils/ExternalCaller.sol", "file": "../common/utils/ExternalCaller.sol", "id": 4806, "nodeType": "ImportDirective", "scope": 4895, "sourceUnit": 1564, "src": "753:44:35", "symbolAliases": [], "unitAlias": "" }, { "abstract": true, "baseContracts": [ { "baseName": { "id": 4807, "name": "CollateralizedToken", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5197, "src": "840:19:35", "typeDescriptions": { "typeIdentifier": "t_contract$_CollateralizedToken_$5197", "typeString": "contract CollateralizedToken" } }, "id": 4808, "nodeType": "InheritanceSpecifier", "src": "840:19:35" }, { "baseName": { "id": 4809, "name": "ExternalCaller", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1563, "src": "861:14:35", "typeDescriptions": { "typeIdentifier": "t_contract$_ExternalCaller_$1563", "typeString": "contract ExternalCaller" } }, "id": 4810, "nodeType": "InheritanceSpecifier", "src": "861:14:35" } ], "contractDependencies": [ 1506, 1563, 5197, 5256, 5279, 6087, 6165, 6295 ], "contractKind": "contract", "fullyImplemented": false, "id": 4894, "linearizedBaseContracts": [ 4894, 1563, 5197, 1506, 6295, 5256, 6087, 6165, 5279 ], "name": "CollateralizedEther", "nodeType": "ContractDefinition", "nodes": [ { "id": 4813, "libraryName": { "id": 4811, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5584, "src": "888:8:35", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$5584", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "882:27:35", "typeName": { "id": 4812, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "901:7:35", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "body": { "id": 4822, "nodeType": "Block", "src": "961:2:35", "statements": [] }, "id": 4823, "implemented": true, "kind": "constructor", "modifiers": [ { "arguments": [ { "arguments": [ { "hexValue": "31", "id": 4818, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "957:1:35", "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" } ], "id": 4817, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "949:7:35", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 4816, "name": "address", "nodeType": "ElementaryTypeName", "src": "949:7:35", "typeDescriptions": {} } }, "id": 4819, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "949:10:35", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } } ], "id": 4820, "modifierName": { "id": 4815, "name": "CollateralizedToken", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5197, "src": "929:19:35", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_CollateralizedToken_$5197_$", "typeString": "type(contract CollateralizedToken)" } }, "nodeType": "ModifierInvocation", "src": "929:31:35" } ], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 4814, "nodeType": "ParameterList", "parameters": [], "src": "926:2:35" }, "returnParameters": { "id": 4821, "nodeType": "ParameterList", "parameters": [], "src": "961:0:35" }, "scope": 4894, "src": "915:48:35", "stateMutability": "nonpayable", "virtual": false, "visibility": "internal" }, { "body": { "id": 4833, "nodeType": "Block", "src": "1017:47:35", "statements": [ { "expression": { "arguments": [ { "expression": { "id": 4829, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "1047:3:35", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 4830, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "src": "1047:9:35", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 4828, "name": "mintInternal", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5035, "src": "1034:12:35", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_uint256_$returns$_t_bool_$", "typeString": "function (uint256) returns (bool)" } }, "id": 4831, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1034:23:35", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "functionReturnParameters": 4827, "id": 4832, "nodeType": "Return", "src": "1027:30:35" } ] }, "functionSelector": "1249c58b", "id": 4834, "implemented": true, "kind": "function", "modifiers": [], "name": "mint", "nodeType": "FunctionDefinition", "parameters": { "id": 4824, "nodeType": "ParameterList", "parameters": [], "src": "982:2:35" }, "returnParameters": { "id": 4827, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4826, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "scope": 4834, "src": "1011:4:35", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 4825, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1011:4:35", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "visibility": "internal" } ], "src": "1010:6:35" }, "scope": 4894, "src": "969:95:35", "stateMutability": "payable", "virtual": false, "visibility": "external" }, { "baseFunctions": [ 5080 ], "body": { "id": 4862, "nodeType": "Block", "src": "1187:186:35", "statements": [ { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 4851, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "arguments": [ { "id": 4847, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "1226:4:35", "typeDescriptions": { "typeIdentifier": "t_contract$_CollateralizedEther_$4894", "typeString": "contract CollateralizedEther" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_CollateralizedEther_$4894", "typeString": "contract CollateralizedEther" } ], "id": 4846, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1218:7:35", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 4845, "name": "address", "nodeType": "ElementaryTypeName", "src": "1218:7:35", "typeDescriptions": {} } }, "id": 4848, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1218:13:35", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "id": 4849, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "balance", "nodeType": "MemberAccess", "src": "1218:21:35", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">=", "rightExpression": { "id": 4850, "name": "amount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4838, "src": "1243:6:35", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1218:31:35", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "4b45746865723a206e6f7420656e6f7567682065746865722062616c616e6365", "id": 4852, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "1263:34:35", "typeDescriptions": { "typeIdentifier": "t_stringliteral_135fefc6a2f3c8a79380d40a5a7b14ffcc371935702b534c2ea1865641781233", "typeString": "literal_string \"KEther: not enough ether balance\"" }, "value": "KEther: not enough ether balance" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_135fefc6a2f3c8a79380d40a5a7b14ffcc371935702b534c2ea1865641781233", "typeString": "literal_string \"KEther: not enough ether balance\"" } ], "id": 4844, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "1197:7:35", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 4853, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1197:110:35", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4854, "nodeType": "ExpressionStatement", "src": "1197:110:35" }, { "expression": { "arguments": [ { "id": 4856, "name": "to", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4836, "src": "1334:2:35", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "id": 4857, "name": "amount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4838, "src": "1338:6:35", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 4855, "name": "externalTransfer", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1533, "src": "1317:16:35", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_uint256_$returns$__$", "typeString": "function (address,uint256)" } }, "id": 4858, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1317:28:35", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4859, "nodeType": "ExpressionStatement", "src": "1317:28:35" }, { "expression": { "hexValue": "74727565", "id": 4860, "isConstant": false, "isLValue": false, "isPure": true, "kind": "bool", "lValueRequested": false, "nodeType": "Literal", "src": "1362:4:35", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "value": "true" }, "functionReturnParameters": 4843, "id": 4861, "nodeType": "Return", "src": "1355:11:35" } ] }, "id": 4863, "implemented": true, "kind": "function", "modifiers": [], "name": "transferUnderlying", "nodeType": "FunctionDefinition", "overrides": { "id": 4840, "nodeType": "OverrideSpecifier", "overrides": [], "src": "1151:8:35" }, "parameters": { "id": 4839, "nodeType": "ParameterList", "parameters": [