UNPKG

@andrekorol/kollateral

Version:

Typescript library for Kollateral, the flash loan building block

883 lines (882 loc) 81.6 kB
{ "contractName": "Migrations", "abi": [ { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "last_completed_migration", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "completed", "type": "uint256" } ], "name": "setCompleted", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "new_address", "type": "address" } ], "name": "upgrade", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.7.3+commit.9bfce1f6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/andrekorol/src/kollateral/protocol/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/andrekorol/src/kollateral/protocol/contracts/Migrations.sol\":{\"keccak256\":\"0x4c01dfe3749880ef4b7d2c2cdc4652bd801413a300566ef06fe4fd8936911231\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e198e062cd2892fa7e23fd245e3212e6f67db0423ab72337d2e4a1fbb01837f9\",\"dweb:/ipfs/QmVTQ33nDswuUDgjJnWGbNNcxHLfsk73sbrWU65xxXt7Es\"]}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061029f806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100e7575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610115565b005b61009d6101e0565b6040518082815260200191505060405180910390f35b6100bb6101e6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610113600480360360208110156100fd57600080fd5b810190808035906020019092919050505061020a565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101dd5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101c357600080fd5b505af11580156101d7573d6000803e3d6000fd5b50505050505b50565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026657806001819055505b5056fea2646970667358221220df9b643a92418f807bc2febbf57134eefd8c87736c0f51eb77bdcdb7581272c164736f6c63430007030033", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100e7575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610115565b005b61009d6101e0565b6040518082815260200191505060405180910390f35b6100bb6101e6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610113600480360360208110156100fd57600080fd5b810190808035906020019092919050505061020a565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101dd5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101c357600080fd5b505af11580156101d7573d6000803e3d6000fd5b50505050505b50565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026657806001819055505b5056fea2646970667358221220df9b643a92418f807bc2febbf57134eefd8c87736c0f51eb77bdcdb7581272c164736f6c63430007030033", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "64:519:1:-:0;;;162:49;;;;;;;;;;194:10;186:5;;:18;;;;;;;;;;;;;;;;;;64:519;;;;;;", "deployedSourceMap": "64:519:1:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;406:175;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;116:39;;;:::i;:::-;;;;;;;;;;;;;;;;;;;90:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;288:112;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;406:175;267:5;;;;;;;;;;253:19;;:10;:19;;;249:26;;;472:19:::1;505:11;472:45;;527:8;:21;;;549:24;;527:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;274:1;249:26:::0;406:175;:::o;116:39::-;;;;:::o;90:20::-;;;;;;;;;;;;:::o;288:112::-;267:5;;;;;;;;;;253:19;;:10;:19;;;249:26;;;384:9:::1;357:24;:36;;;;249:26:::0;288:112;:::o", "source": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.7.0;\n\ncontract Migrations {\n address public owner;\n uint256 public last_completed_migration;\n\n constructor() {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint256 completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", "sourcePath": "/Users/andrekorol/src/kollateral/protocol/contracts/Migrations.sol", "ast": { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ 1147 ] }, "id": 1148, "license": "Apache-2.0", "nodeType": "SourceUnit", "nodes": [ { "id": 1092, "literals": [ "solidity", "^", "0.7", ".0" ], "nodeType": "PragmaDirective", "src": "39:23:1" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "fullyImplemented": true, "id": 1147, "linearizedBaseContracts": [ 1147 ], "name": "Migrations", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "functionSelector": "8da5cb5b", "id": 1094, "mutability": "mutable", "name": "owner", "nodeType": "VariableDeclaration", "scope": 1147, "src": "90:20:1", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1093, "name": "address", "nodeType": "ElementaryTypeName", "src": "90:7:1", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "visibility": "public" }, { "constant": false, "functionSelector": "445df0ac", "id": 1096, "mutability": "mutable", "name": "last_completed_migration", "nodeType": "VariableDeclaration", "scope": 1147, "src": "116:39:1", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1095, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "116:7:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "public" }, { "body": { "id": 1104, "nodeType": "Block", "src": "176:35:1", "statements": [ { "expression": { "id": 1102, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 1099, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1094, "src": "186:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "expression": { "id": 1100, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "194:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 1101, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "src": "194:10:1", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "src": "186:18:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "id": 1103, "nodeType": "ExpressionStatement", "src": "186:18:1" } ] }, "id": 1105, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 1097, "nodeType": "ParameterList", "parameters": [], "src": "173:2:1" }, "returnParameters": { "id": 1098, "nodeType": "ParameterList", "parameters": [], "src": "176:0:1" }, "scope": 1147, "src": "162:49:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" }, { "body": { "id": 1113, "nodeType": "Block", "src": "239:43:1", "statements": [ { "condition": { "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 1110, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "id": 1107, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "253:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 1108, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "src": "253:10:1", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "id": 1109, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1094, "src": "267:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "253:19:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 1112, "nodeType": "IfStatement", "src": "249:26:1", "trueBody": { "id": 1111, "nodeType": "PlaceholderStatement", "src": "274:1:1" } } ] }, "id": 1114, "name": "restricted", "nodeType": "ModifierDefinition", "parameters": { "id": 1106, "nodeType": "ParameterList", "parameters": [], "src": "236:2:1" }, "src": "217:65:1", "virtual": false, "visibility": "internal" }, { "body": { "id": 1125, "nodeType": "Block", "src": "347:53:1", "statements": [ { "expression": { "id": 1123, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 1121, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1096, "src": "357:24:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "id": 1122, "name": "completed", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1116, "src": "384:9:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "357:36:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 1124, "nodeType": "ExpressionStatement", "src": "357:36:1" } ] }, "functionSelector": "fdacd576", "id": 1126, "implemented": true, "kind": "function", "modifiers": [ { "id": 1119, "modifierName": { "id": 1118, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1114, "src": "336:10:1", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", "src": "336:10:1" } ], "name": "setCompleted", "nodeType": "FunctionDefinition", "parameters": { "id": 1117, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1116, "mutability": "mutable", "name": "completed", "nodeType": "VariableDeclaration", "scope": 1126, "src": "310:17:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1115, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "310:7:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "src": "309:19:1" }, "returnParameters": { "id": 1120, "nodeType": "ParameterList", "parameters": [], "src": "347:0:1" }, "scope": 1147, "src": "288:112:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" }, { "body": { "id": 1145, "nodeType": "Block", "src": "462:119:1", "statements": [ { "assignments": [ 1134 ], "declarations": [ { "constant": false, "id": 1134, "mutability": "mutable", "name": "upgraded", "nodeType": "VariableDeclaration", "scope": 1145, "src": "472:19:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$1147", "typeString": "contract Migrations" }, "typeName": { "id": 1133, "name": "Migrations", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1147, "src": "472:10:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$1147", "typeString": "contract Migrations" } }, "visibility": "internal" } ], "id": 1138, "initialValue": { "arguments": [ { "id": 1136, "name": "new_address", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1128, "src": "505:11:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 1135, "name": "Migrations", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1147, "src": "494:10:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Migrations_$1147_$", "typeString": "type(contract Migrations)" } }, "id": 1137, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "494:23:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$1147", "typeString": "contract Migrations" } }, "nodeType": "VariableDeclarationStatement", "src": "472:45:1" }, { "expression": { "arguments": [ { "id": 1142, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1096, "src": "549:24:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "id": 1139, "name": "upgraded", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1134, "src": "527:8:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$1147", "typeString": "contract Migrations" } }, "id": 1141, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "setCompleted", "nodeType": "MemberAccess", "referencedDeclaration": 1126, "src": "527:21:1", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256) external" } }, "id": 1143, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "527:47:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 1144, "nodeType": "ExpressionStatement", "src": "527:47:1" } ] }, "functionSelector": "0900f010", "id": 1146, "implemented": true, "kind": "function", "modifiers": [ { "id": 1131, "modifierName": { "id": 1130, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1114, "src": "451:10:1", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", "src": "451:10:1" } ], "name": "upgrade", "nodeType": "FunctionDefinition", "parameters": { "id": 1129, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1128, "mutability": "mutable", "name": "new_address", "nodeType": "VariableDeclaration", "scope": 1146, "src": "423:19:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1127, "name": "address", "nodeType": "ElementaryTypeName", "src": "423:7:1", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "visibility": "internal" } ], "src": "422:21:1" }, "returnParameters": { "id": 1132, "nodeType": "ParameterList", "parameters": [], "src": "462:0:1" }, "scope": 1147, "src": "406:175:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], "scope": 1148, "src": "64:519:1" } ], "src": "39:545:1" }, "legacyAST": { "attributes": { "absolutePath": "/Users/andrekorol/src/kollateral/protocol/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ 1147 ] }, "license": "Apache-2.0" }, "children": [ { "attributes": { "literals": [ "solidity", "^", "0.7", ".0" ] }, "id": 1092, "name": "PragmaDirective", "src": "39:23:1" }, { "attributes": { "abstract": false, "baseContracts": [ null ], "contractDependencies": [ null ], "contractKind": "contract", "fullyImplemented": true, "linearizedBaseContracts": [ 1147 ], "name": "Migrations", "scope": 1148 }, "children": [ { "attributes": { "constant": false, "functionSelector": "8da5cb5b", "mutability": "mutable", "name": "owner", "scope": 1147, "stateVariable": true, "storageLocation": "default", "type": "address", "visibility": "public" }, "children": [ { "attributes": { "name": "address", "stateMutability": "nonpayable", "type": "address" }, "id": 1093, "name": "ElementaryTypeName", "src": "90:7:1" } ], "id": 1094, "name": "VariableDeclaration", "src": "90:20:1" }, { "attributes": { "constant": false, "functionSelector": "445df0ac", "mutability": "mutable", "name": "last_completed_migration", "scope": 1147, "stateVariable": true, "storageLocation": "default", "type": "uint256", "visibility": "public" }, "children": [ { "attributes": { "name": "uint256", "type": "uint256" }, "id": 1095, "name": "ElementaryTypeName", "src": "116:7:1" } ], "id": 1096, "name": "VariableDeclaration", "src": "116:39:1" }, { "attributes": { "implemented": true, "isConstructor": true, "kind": "constructor", "modifiers": [ null ], "name": "", "scope": 1147, "stateMutability": "nonpayable", "virtual": false, "visibility": "public" }, "children": [ { "attributes": { "parameters": [ null ] }, "children": [], "id": 1097, "name": "ParameterList", "src": "173:2:1" }, { "attributes": { "parameters": [ null ] }, "children": [], "id": 1098, "name": "ParameterList", "src": "176:0:1" }, { "children": [ { "children": [ { "attributes": { "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "address" }, "children": [ { "attributes": { "overloadedDeclarations": [ null ], "referencedDeclaration": 1094, "type": "address", "value": "owner" }, "id": 1099, "name": "Identifier", "src": "186:5:1" }, { "attributes": { "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "member_name": "sender", "type": "address payable" }, "children": [ { "attributes": { "overloadedDeclarations": [ null ], "referencedDeclaration": -15, "type": "msg", "value": "msg" }, "id": 1100, "name": "Identifier", "src": "194:3:1" } ],