UNPKG

@andrekorol/kollateral-contracts

Version:

Kollateral protocol, the flash loan building block

1,156 lines (1,155 loc) 126 kB
{ "contractName": "CollateralizedErc20", "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" }, { "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" }, { "inputs": [ { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" } ], "name": "mint", "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": "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\"},{\"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\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"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\":\"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\"}],\"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/CollateralizedErc20.sol\":\"CollateralizedErc20\"},\"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/token/CollateralizedErc20.sol\":{\"keccak256\":\"0xd48c5e41793190f2024f5273abfc93878778c179ea7308aa2585e6c1ff351c8e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://2d0f9a0fe4164b7dc28751091f7932bfca48b29b06eb6d6db441f27d42f89da9\",\"dweb:/ipfs/QmSEd1zGzECLSeML5K52mk4h3T4Z6FxrhqSFua41nSJyht\"]},\"/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\";\n\nabstract contract CollateralizedErc20 is CollateralizedToken {\n using SafeMath for uint256;\n\n function mint(uint256 tokenAmount) external returns (bool) {\n IERC20 token = IERC20(underlying());\n require(\n token.transferFrom(msg.sender, address(this), tokenAmount),\n \"CollateralizedErc20: token transferFrom failed\"\n );\n return mintInternal(tokenAmount);\n }\n\n function transferUnderlying(address to, uint256 amount)\n internal\n override\n returns (bool)\n {\n return IERC20(underlying()).transfer(to, amount);\n }\n\n function isUnderlyingEther() public pure override returns (bool) {\n return false;\n }\n\n function totalReserve() public view override returns (uint256) {\n return IERC20(underlying()).balanceOf(address(this));\n }\n}\n", "sourcePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedErc20.sol", "ast": { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedErc20.sol", "exportedSymbols": { "CollateralizedErc20": [ 4801 ], "CollateralizedToken": [ 5197 ], "Context": [ 5279 ], "ERC20": [ 6087 ], "ExtendedMath": [ 1506 ], "IERC20": [ 6165 ], "ReentrancyGuard": [ 6295 ], "SafeMath": [ 5584 ], "UnlimitedApprovalErc20": [ 5256 ] }, "id": 4802, "license": "Apache-2.0", "nodeType": "SourceUnit", "nodes": [ { "id": 4713, "literals": [ "solidity", "^", "0.7", ".0" ], "nodeType": "PragmaDirective", "src": "640:23:34" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 4714, "nodeType": "ImportDirective", "scope": 4802, "sourceUnit": 5585, "src": "665:51:34", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/token/CollateralizedToken.sol", "file": "./CollateralizedToken.sol", "id": 4715, "nodeType": "ImportDirective", "scope": 4802, "sourceUnit": 5198, "src": "717:35:34", "symbolAliases": [], "unitAlias": "" }, { "abstract": true, "baseContracts": [ { "baseName": { "id": 4716, "name": "CollateralizedToken", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5197, "src": "795:19:34", "typeDescriptions": { "typeIdentifier": "t_contract$_CollateralizedToken_$5197", "typeString": "contract CollateralizedToken" } }, "id": 4717, "nodeType": "InheritanceSpecifier", "src": "795:19:34" } ], "contractDependencies": [ 1506, 5197, 5256, 5279, 6087, 6165, 6295 ], "contractKind": "contract", "fullyImplemented": false, "id": 4801, "linearizedBaseContracts": [ 4801, 5197, 1506, 6295, 5256, 6087, 6165, 5279 ], "name": "CollateralizedErc20", "nodeType": "ContractDefinition", "nodes": [ { "id": 4720, "libraryName": { "id": 4718, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5584, "src": "827:8:34", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$5584", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "821:27:34", "typeName": { "id": 4719, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "840:7:34", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "body": { "id": 4752, "nodeType": "Block", "src": "913:255:34", "statements": [ { "assignments": [ 4728 ], "declarations": [ { "constant": false, "id": 4728, "mutability": "mutable", "name": "token", "nodeType": "VariableDeclaration", "scope": 4752, "src": "923:12:34", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$6165", "typeString": "contract IERC20" }, "typeName": { "id": 4727, "name": "IERC20", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 6165, "src": "923:6:34", "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$6165", "typeString": "contract IERC20" } }, "visibility": "internal" } ], "id": 4733, "initialValue": { "arguments": [ { "arguments": [], "expression": { "argumentTypes": [], "id": 4730, "name": "underlying", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5196, "src": "945:10:34", "typeDescriptions": { "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", "typeString": "function () view returns (address)" } }, "id": 4731, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "945:12:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4729, "name": "IERC20", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6165, "src": "938:6:34", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IERC20_$6165_$", "typeString": "type(contract IERC20)" } }, "id": 4732, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "938:20:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$6165", "typeString": "contract IERC20" } }, "nodeType": "VariableDeclarationStatement", "src": "923:35:34" }, { "expression": { "arguments": [ { "arguments": [ { "expression": { "id": 4737, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "1008:3:34", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 4738, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "src": "1008:10:34", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, { "arguments": [ { "id": 4741, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "1028:4:34", "typeDescriptions": { "typeIdentifier": "t_contract$_CollateralizedErc20_$4801", "typeString": "contract CollateralizedErc20" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_CollateralizedErc20_$4801", "typeString": "contract CollateralizedErc20" } ], "id": 4740, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1020:7:34", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 4739, "name": "address", "nodeType": "ElementaryTypeName", "src": "1020:7:34", "typeDescriptions": {} } }, "id": 4742, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1020:13:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "id": 4743, "name": "tokenAmount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4722, "src": "1035:11:34", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "id": 4735, "name": "token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4728, "src": "989:5:34", "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$6165", "typeString": "contract IERC20" } }, "id": 4736, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "transferFrom", "nodeType": "MemberAccess", "referencedDeclaration": 6146, "src": "989:18:34", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$", "typeString": "function (address,address,uint256) external returns (bool)" } }, "id": 4744, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "989:58:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "436f6c6c61746572616c697a656445726332303a20746f6b656e207472616e7366657246726f6d206661696c6564", "id": 4745, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "1061:48:34", "typeDescriptions": { "typeIdentifier": "t_stringliteral_fe5c1bfa546383f3f2d4947716f5a9c0901f9252fab8149422c1559f62dc9b83", "typeString": "literal_string \"CollateralizedErc20: token transferFrom failed\"" }, "value": "CollateralizedErc20: token transferFrom failed" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_fe5c1bfa546383f3f2d4947716f5a9c0901f9252fab8149422c1559f62dc9b83", "typeString": "literal_string \"CollateralizedErc20: token transferFrom failed\"" } ], "id": 4734, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "968:7:34", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 4746, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "968:151:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4747, "nodeType": "ExpressionStatement", "src": "968:151:34" }, { "expression": { "arguments": [ { "id": 4749, "name": "tokenAmount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4722, "src": "1149:11:34", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 4748, "name": "mintInternal", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5035, "src": "1136:12:34", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_uint256_$returns$_t_bool_$", "typeString": "function (uint256) returns (bool)" } }, "id": 4750, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1136:25:34", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "functionReturnParameters": 4726, "id": 4751, "nodeType": "Return", "src": "1129:32:34" } ] }, "functionSelector": "a0712d68", "id": 4753, "implemented": true, "kind": "function", "modifiers": [], "name": "mint", "nodeType": "FunctionDefinition", "parameters": { "id": 4723, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4722, "mutability": "mutable", "name": "tokenAmount", "nodeType": "VariableDeclaration", "scope": 4753, "src": "868:19:34", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4721, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "868:7:34", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "src": "867:21:34" }, "returnParameters": { "id": 4726, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4725, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "scope": 4753, "src": "907:4:34", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 4724, "name": "bool", "nodeType": "ElementaryTypeName", "src": "907:4:34", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "visibility": "internal" } ], "src": "906:6:34" }, "scope": 4801, "src": "854:314:34", "stateMutability": "nonpayable", "virtual": false, "visibility": "external" }, { "baseFunctions": [ 5080 ], "body": { "id": 4772, "nodeType": "Block", "src": "1291:65:34", "statements": [ { "expression": { "arguments": [ { "id": 4768, "name": "to", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4755, "src": "1338:2:34", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "id": 4769, "name": "amount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4757, "src": "1342:6:34", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "arguments": [ { "arguments": [], "expression": { "argumentTypes": [], "id": 4764, "name": "underlying", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5196, "src": "1315:10:34", "typeDescriptions": { "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", "typeString": "function () view returns (address)"