UNPKG

@kollateral/kollateral-contracts

Version:

1,102 lines 551 kB
{ "contractName": "KToken", "abi": [ { "inputs": [ { "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "invokerAddress", "type": "address" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "uint8", "name": "decimals", "type": "uint8" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "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": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "OwnershipTransferred", "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" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "approve", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "account", "type": "address" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } ], "name": "decreaseAllowance", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "addedValue", "type": "uint256" } ], "name": "increaseAllowance", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "isOwner", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "renounceOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transfer", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "uint256", "name": "kTokenAmount", "type": "uint256" } ], "name": "redeem", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" } ], "name": "redeemUnderlying", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transferUnderlying", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "lock", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "unlock", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "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" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" }, { "internalType": "bool", "name": "ceiling", "type": "bool" } ], "name": "tokenAmountToKTokenAmount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "uint256", "name": "kTokenAmount", "type": "uint256" } ], "name": "kTokenAmountToTokenAmount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "isKEther", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalReserve", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "owner", "type": "address" } ], "name": "balanceOfUnderlying", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "tokenAddress", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "invokerAddress", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "invokerAddress", "type": "address" } ], "name": "setInvokerAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"invokerAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"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\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"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\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOfUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"invokerAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isKEther\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"kTokenAmount\",\"type\":\"uint256\"}],\"name\":\"kTokenAmountToTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"lock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"kTokenAmount\",\"type\":\"uint256\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"redeemUnderlying\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"invokerAddress\",\"type\":\"address\"}],\"name\":\"setInvokerAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"ceiling\",\"type\":\"bool\"}],\"name\":\"tokenAmountToKTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalReserve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"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\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferUnderlying\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unlock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"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. * 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.\"},\"isOwner()\":{\"details\":\"Returns true if the caller is the current owner.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. * NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"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`.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/kbrizzle/code/kollateral/protocol/contracts/Ktoken.sol\":\"KToken\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/kbrizzle/code/kollateral/protocol/contracts/ExtendedMath.sol\":{\"keccak256\":\"0x9b4a67b1242134b64f557613259bfb51268d488cbc7b27cb2bc72c2f21f2b71f\",\"urls\":[\"bzz-raw://47bc3f04cddcbbe7a0373a074d50bbc1720ef7d73266532aab07474ea426ab43\",\"dweb:/ipfs/QmdPdivc8yXbmvDL1nG8xXHJF7qcfx6JqQoCFBv1ohDmdP\"]},\"/Users/kbrizzle/code/kollateral/protocol/contracts/Ktoken.sol\":{\"keccak256\":\"0x748a3edca97018638a9ed18f3484977c124517f2261af8a7be3e1b8ee2fbe8a8\",\"urls\":[\"bzz-raw://9b5d42beda89cdf788e79cec733d96c4c4eaf896694948ee2c0fa5bb46d3972c\",\"dweb:/ipfs/Qmc9sGpHe3CTiEG9gzrdHtCgsuHBfAToTBGYmL8a4JL3J1\"]},\"/Users/kbrizzle/code/kollateral/protocol/contracts/interfaces/IKToken.sol\":{\"keccak256\":\"0x5b03d279a41856eef739da4ee50155425bbd95d99d80e4b910ec5abb91a99e40\",\"urls\":[\"bzz-raw://4ef7259b5604ef20e62b2503bc34d4052f99b85a18a80b072b8883bb7f9559de\",\"dweb:/ipfs/QmUsVQH9M3FoB4rpJGZJpZrbk2kcDFyRg5E5WfAKqHYkok\"]},\"@openzeppelin/contracts/GSN/Context.sol\":{\"keccak256\":\"0x90a3995645af7562d84b9d69363ffa5ae7217714ab61e951bf7bc450f40e4061\",\"urls\":[\"bzz-raw://216ef9d6b614db4eb46970b4e84903f2534a45572dd30a79f0041f1a5830f436\",\"dweb:/ipfs/QmNPrJ4MWKUAWzKXpUqeyKRUfosaoANZAqXgvepdrCwZAG\"]},\"@openzeppelin/contracts/access/Roles.sol\":{\"keccak256\":\"0xb002c378d7b82a101bd659c341518953ca0919d342c0a400196982c0e7e7bcdb\",\"urls\":[\"bzz-raw://00a788c4631466c220b385bdd100c571d24b2deccd657615cfbcef6cadf669a4\",\"dweb:/ipfs/QmTEwDbjJNxmMNCDMqtuou3dyM8Wtp8Q9NFvn7SAVM7Jf3\"]},\"@openzeppelin/contracts/access/roles/PauserRole.sol\":{\"keccak256\":\"0xd1b5c934bab36d753c22987ad98c7614cb50ebf641371a83c96f8138619d7c30\",\"urls\":[\"bzz-raw://69c4bb822caae3d1bfd38e81f03b6d618d4d83cbb8e9f8236d28e1c4fe1d0d81\",\"dweb:/ipfs/QmWamstbFhdySmocF2TSKYVLLZF24JG4aXMvHiRdWKv3RA\"]},\"@openzeppelin/contracts/lifecycle/Pausable.sol\":{\"keccak256\":\"0xd3e5a49edfb74654d122962cc60b917d1c60461e669a7262fd7aba201fac1260\",\"urls\":[\"bzz-raw://0307a3cae4df037aee16fb0b0d94849cb4d9b20d7d7182c185f3efac6d2caec0\",\"dweb:/ipfs/QmezTANBfrJmCvxfmfyfcfFGtbcUEUtoJCjfxKnAePiNoE\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]},\"@openzeppelin/contracts/ownership/Ownable.sol\":{\"keccak256\":\"0xecd8ab29d9a5771c3964d0cd1788c4a5098a0081b20fb275da850a22b1c59806\",\"urls\":[\"bzz-raw://696a75bc2c55407ce8251ccc7d19ecb1b7b2be1796a160a6524312babcc7e3d4\",\"dweb:/ipfs/QmQViKEp3y99h9uhRssE29TmjBKRnFMaoz3eJZ4eggggg2\"]},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x65a4078c03875c25413a068ce9cfdd7e68a90f8786612d1189c89341e6e3b802\",\"urls\":[\"bzz-raw://45c0d95495b944fbb1aa09d900b0ab530903a432125ab8fddfa05064a7988991\",\"dweb:/ipfs/Qma2VeknkKA1THeubGzshWFk44BktXkXP1UKp9Un2uDSsu\"]},\"@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol\":{\"keccak256\":\"0x4a3a810b7ebe742e897e1fd428b3eeed2196d3acea58eaf9c566ed10d545d2ed\",\"urls\":[\"bzz-raw://28d03f328e19e4099d5013de0649afaeaabac1a614e130767ab1cb4aca9775b6\",\"dweb:/ipfs/Qmb9iW7yNuYehB2NfhRMs9TakqbLVQhBhmGMkaDZ5g1Eb4\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe5bb0f57cff3e299f360052ba50f1ea0fff046df2be070b6943e0e3c3fdad8a9\",\"urls\":[\"bzz-raw://59fd025151435da35faa8093a5c7a17de02de9d08ad27275c5cdf05050820d91\",\"dweb:/ipfs/QmQMvwEcPhoRXzbXyrdoeRtvLoifUW9Qh7Luho7bmUPRkc\"]},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"keccak256\":\"0xe86fdc15fbc379ecf14d6aa4f51b87c0be8476e114e23c171b790a6717230655\",\"urls\":[\"bzz-raw://81905037f66d37ed211a4e3430af74f36e18b3a5d5b688e6d7d5ee199824a41a\",\"dweb:/ipfs/QmTcpgNKqLVRbcgNSUHazAbVf2bz5uh5mPkAijGeYW7Sqb\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "sourceMap": "", "deployedSourceMap": "", "source": "pragma solidity ^0.5.0;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol\";\nimport \"@openzeppelin/contracts/lifecycle/Pausable.sol\";\nimport \"@openzeppelin/contracts/ownership/Ownable.sol\";\nimport \"./ExtendedMath.sol\";\nimport \"./interfaces/IKToken.sol\";\n\ncontract KToken is IKToken, ERC20, ERC20Detailed, ReentrancyGuard, ExtendedMath, Ownable {\n using SafeMath for uint256;\n\n event Mint(address minter, uint256 tokenAmount, uint256 kTokenAmount);\n event Redeem(address redeemer, uint256 tokenAmount, uint256 kTokenAmount);\n\n address internal _tokenAddress;\n address internal _invokerAddress;\n uint256 internal _lock;\n\n constructor (address tokenAddress, address invokerAddress, string memory name, string memory symbol, uint8 decimals)\n internal\n ERC20Detailed(name, symbol, decimals)\n {\n _tokenAddress = tokenAddress;\n _invokerAddress = invokerAddress;\n _lock = 0;\n }\n\n /*\n * PUBLIC STATE CHANGING\n */\n\n function redeem(uint256 kTokenAmount)\n external\n returns (bool)\n {\n require(totalSupply() > 0, \"KToken: no supply\");\n return redeemInternal(kTokenAmountToTokenAmount(kTokenAmount), kTokenAmount);\n }\n\n function redeemUnderlying(uint256 tokenAmount)\n external\n returns (bool)\n {\n require(totalReserve() > 0, \"KToken: no reserve\");\n return redeemInternal(tokenAmount, tokenAmountToKTokenAmountInternal(tokenAmount, true, false));\n }\n\n function mintInternal(uint256 amount)\n internal\n whenUnlocked\n nonReentrant\n returns (bool)\n {\n uint256 kTokenAmount;\n if (totalReserve().sub(amount) > 0) {\n kTokenAmount = tokenAmountToKTokenAmountInternal(amount, false, true);\n } else {\n kTokenAmount = amount;\n }\n _mint(msg.sender, kTokenAmount);\n emit Mint(msg.sender, amount, kTokenAmount);\n\n return true;\n }\n\n function redeemInternal(uint256 tokenAmount, uint256 kTokenAmount)\n internal\n whenUnlocked\n nonReentrant\n returns (bool)\n {\n _burn(msg.sender, kTokenAmount);\n require(transferUnderlyingInternal(msg.sender, tokenAmount), \"KToken: token transfer failed\");\n emit Redeem(msg.sender, tokenAmount, kTokenAmount);\n\n return true;\n }\n\n /*\n * INVOKER STATE-CHANGING HOOKS\n */\n\n function transferUnderlying(address to, uint256 amount)\n external\n onlyInvoker\n whenUnlocked\n nonReentrant\n returns (bool)\n {\n return transferUnderlyingInternal(to, amount);\n }\n\n function transferUnderlyingInternal(address to, uint256 amount) internal returns (bool);\n\n /* Lock automatically clears after block in case of any unintended locking attacks */\n function lock()\n external\n onlyInvoker\n whenUnlocked\n {\n _lock = block.number;\n }\n\n function unlock()\n external\n onlyInvoker\n whenLocked\n {\n _lock = 0;\n }\n\n /* Adds unlimited allowance functionality to standard transferFrom implementation */\n function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {\n _transfer(sender, recipient, amount);\n if (allowance(sender, _msgSender()) != uint256(-1)) {\n _approve(sender, _msgSender(), allowance(sender, _msgSender()).sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n }\n return true;\n }\n\n /*\n * VIEWS\n */\n\n function tokenAmountToKTokenAmount(uint256 tokenAmount, bool ceiling) public view returns (uint256) {\n return tokenAmountToKTokenAmountInternal(tokenAmount, ceiling, false);\n }\n\n function tokenAmountToKTokenAmountInternal(uint256 tokenAmount, bool ceiling, bool alreadyDeposited)\n internal\n view\n returns (uint256)\n {\n if (totalReserve() == 0) {\n return 0;\n }\n\n /* mint() pulls in funds before calling mintInternal() - normalize for pre-funding amount */\n uint256 adjustedTotalReserve = alreadyDeposited ? totalReserve() - tokenAmount: totalReserve();\n\n /* round mint() down and redeemUnderlying() up to avoid over-ownership exploits */\n return divAndRound(tokenAmount.mul(totalSupply()), adjustedTotalReserve, ceiling);\n }\n\n function kTokenAmountToTokenAmount(uint256 kTokenAmount) public view returns (uint256) {\n if (totalSupply() == 0) {\n return 0;\n }\n\n return kTokenAmount.mul(totalReserve()).div(totalSupply());\n }\n\n function isKEther() public view returns (bool);\n\n function totalReserve() public view returns (uint256);\n\n function balanceOfUnderlying(address owner) public view returns (uint256) {\n return kTokenAmountToTokenAmount(balanceOf(owner));\n }\n\n function tokenAddress() external view returns (address) {\n return _tokenAddress;\n }\n\n function invokerAddress() external view returns (address) {\n return _invokerAddress;\n }\n\n /*\n * MODIFIERS\n */\n\n modifier onlyInvoker() {\n require(\n msg.sender == _invokerAddress && !Pausable(_invokerAddress).paused(),\n \"KToken: only can be called by unpaused invoker\");\n _;\n }\n\n modifier whenLocked() {\n require(_lock >= block.number, \"KToken: not locked\");\n _;\n }\n\n modifier whenUnlocked() {\n require(_lock < block.number, \"KToken: locked\");\n _;\n }\n\n /*\n * ADMIN FUNCTIONS\n */\n\n /* KToken ownership will be relinquished before public launch. */\n function setInvokerAddress(address invokerAddress) external onlyOwner {\n _invokerAddress = invokerAddress;\n }\n}\n", "sourcePath": "/Users/kbrizzle/code/kollateral/protocol/contracts/Ktoken.sol", "ast": { "absolutePath": "/Users/kbrizzle/code/kollateral/protocol/contracts/Ktoken.sol", "exportedSymbols": { "KToken": [ 1613 ] }, "id": 1614, "nodeType": "SourceUnit", "nodes": [ { "id": 1118, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:5" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 1119, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 2904, "src": "25:51:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "file": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "id": 1120, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 3582, "src": "77:59:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "id": 1121, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 3423, "src": "137:55:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol", "file": "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol", "id": 1122, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 3481, "src": "193:63:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@openzeppelin/contracts/lifecycle/Pausable.sol", "file": "@openzeppelin/contracts/lifecycle/Pausable.sol", "id": 1123, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 2717, "src": "257:56:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@openzeppelin/contracts/ownership/Ownable.sol", "file": "@openzeppelin/contracts/ownership/Ownable.sol", "id": 1124, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 3018, "src": "314:55:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/kbrizzle/code/kollateral/protocol/contracts/ExtendedMath.sol", "file": "./ExtendedMath.sol", "id": 1125, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 42, "src": "370:28:5", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/kbrizzle/code/kollateral/protocol/contracts/interfaces/IKToken.sol", "file": "./interfaces/IKToken.sol", "id": 1126, "nodeType": "ImportDirective", "scope": 1614, "sourceUnit": 2075, "src": "399:34:5", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 1127, "name": "IKToken", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2074, "src": "454:7:5", "typeDescriptions": { "typeIdentifier": "t_contract$_IKToken_$2074", "typeString": "contract IKToken" } }, "id": 1128, "nodeType": "InheritanceSpecifier", "src": "454:7:5" }, { "arguments": null, "baseName": { "contractScope": null, "id": 1129, "name": "ERC20", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3422, "src": "463:5:5", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$3422", "typeString": "contract ERC20" } }, "id": 1130, "nodeType": "InheritanceSpecifier", "src": "463:5:5" }, { "arguments": null, "baseName": { "contractScope": null, "id": 1131, "name": "ERC20Detailed", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3480, "src": "470:13:5", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20Detailed_$3480", "typeString": "contract ERC20Detailed" } }, "id": 1132, "nodeType": "InheritanceSpecifier", "src": "470:13:5" }, { "arguments": null, "baseName": { "contractScope": null, "id": 1133, "name": "ReentrancyGuard", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3581, "src": "485:15:5", "typeDescriptions": { "typeIdentifier": "t_contract$_ReentrancyGuard_$3581", "typeString": "contract ReentrancyGuard" } }, "id": 1134, "nodeType": "InheritanceSpecifier", "src": "485:15:5" }, { "arguments": null, "baseName": { "contractScope": null, "id": 1135, "name": "ExtendedMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 41, "src": "502:12:5", "typeDescriptions": { "typeIdentifier": "t_contract$_ExtendedMath_$41", "typeString": "contract ExtendedMath" } }, "id": 1136, "nodeType": "InheritanceSpecifier", "src": "502:12:5" }, { "arguments": null, "baseName": { "contractScope": null, "id": 1137, "name": "Ownable", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3017, "src": "516:7:5", "typeDescriptions": { "typeIdentifier": "t_contract$_Ownable_$3017", "typeString": "contract Ownable" } }, "id": 1138, "nodeType": "InheritanceSpecifier", "src": "516:7:5" } ], "contractDependencies": [ 41, 2074, 2440, 3017, 3422, 3480, 3549, 3581 ], "contractKind": "contract", "documentation": null, "fullyImplemented": false, "id": 1613, "linearizedBaseContracts": [ 1613, 3017, 41, 3581, 3480, 3422, 2074, 3549, 2440 ], "name": "KToken", "nodeType": "ContractDefinition", "nodes": [ { "id": 1141, "libraryName": { "contractScope": null, "id": 1139, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2903, "src": "536:8:5", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$2903", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "530:27:5", "typeName": { "id": 1140, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "549:7:5", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "anonymous": false, "documentation": null, "id": 1149, "name": "Mint", "nodeType": "EventDefinition", "parameters": { "id": 1148, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1143, "indexed": false, "name": "minter", "nodeType": "VariableDeclaration", "scope": 1149, "src": "574:14:5", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1142, "name": "address", "nodeType": "ElementaryTypeName", "src": "574:7:5", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1145, "indexed": false, "name": "tokenAmount", "nodeType": "VariableDeclaration", "scope": 1149, "src": "590:19:5", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1144, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "590:7:5", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1147, "indexed": false, "name": "kTokenAmount", "nodeType": "VariableDeclaration", "scope": 1149, "src": "611:20:5", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1146, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "611:7:5", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "573:59:5" }, "src": "563:70:5" }, { "anonymous": false, "documentation": null, "id": 1157, "name": "Redeem", "nodeType": "EventDefinition", "parameters": { "id": 1156, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1151, "indexed": false, "name": "redeemer", "nodeType": "VariableDeclaration", "scope": 1157, "src": "651:16:5", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1150, "name": "address", "nodeType": "ElementaryTypeName", "src": "651:7:5", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 1153, "indexed": false, "name": "token