@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
1,033 lines • 246 kB
JSON
{
"contractName": "Exchange",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library for transferring tokens and interacting with ExchangeWrappers by using the Wei struct\",\"methods\":{},\"title\":\"Exchange\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Exchange.sol\":\"Exchange\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IERC20Detailed.sol\":{\"keccak256\":\"0x22a62e2a8155e70300773721902f4b9118e17aa0bb5d9d1b046050a014cfb223\",\"urls\":[\"bzz-raw://03af737a33c552fbe58f6f1fbd5496854fdc28dd57be4365d56663725c083a18\",\"dweb:/ipfs/QmbgLqGAQEd6tXsZB8QaPNCAMiU6nNzP75wNbKdS65BuUF\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExchangeWrapper.sol\":{\"keccak256\":\"0x74799c3fac16738be41e270a70d3f7ad4f75d1dc7e5d8c58f0fe4c6128345112\",\"urls\":[\"bzz-raw://d9602af1001189d199736d17266d5fb34a32f71cd05fbcf4c0f97c0b3a642eee\",\"dweb:/ipfs/QmPto2DkZ1nKqicBMdMkaek7kGSSXqSKnf697h5zuthvsy\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":{\"keccak256\":\"0x53f205f6a779d579be29faa9412c806a892b3e605fff092dfd9d14d936fa019f\",\"urls\":[\"bzz-raw://0ff936f89602a63b8e6a4eb4ce8f87673c0f45b7ce29694920905a3f0b5a6a69\",\"dweb:/ipfs/QmbYME9BeEvPC1ndV8EaUDX5fDMghLc3rocNUxFtgHmg8m\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Exchange.sol\":{\"keccak256\":\"0x5952f2f78aa0adb88980d9eeec5626fecbec79103038841c3ad9e4f2c4ac556b\",\"urls\":[\"bzz-raw://2a358a8370fa8abba24db2a3337f5b397e51a686d84facaf70ced9cc32d65235\",\"dweb:/ipfs/QmY4vPNq3SMu176LL4XRxFPtDQf8QEztQNxerWvmoEALsR\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Require.sol\":{\"keccak256\":\"0x05a2a90b41b6a5f42f0a72da63d015fb0b406a9ba2172823352e522e8bf3a606\",\"urls\":[\"bzz-raw://19883f0c6d33266f756ec5c3d17539524aa24b993c46c33f8400801d09373a6c\",\"dweb:/ipfs/QmYX2fwK3vQQDSZLMrc5wMfeb8RWrcC9CGX8XECLty8QDk\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Token.sol\":{\"keccak256\":\"0x095b5f8eb3665f6e246200311efc8a654fa3e90f9a1a522e27a4d089e8ab3917\",\"urls\":[\"bzz-raw://5db812b752a03d601d424e6e21be38153477082af0acf51b5c98eefa5553ed18\",\"dweb:/ipfs/QmbE549QUXYTurpx8hSMLBJvuBpfYqyNE6FBCgHJDY8PLf\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":{\"keccak256\":\"0xe1bab8c8799d83e86c7a49aaf815d8e3bc8d09562d46d44d921500db5e98de0e\",\"urls\":[\"bzz-raw://8ea3d0cc4fdab6dd9bba545a792170f939b342d8d1a7051c1c6365009af72658\",\"dweb:/ipfs/QmaLJgbavu88eEit6JPqfWnw6NmGBDZfveMXxumgWywBFG\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe5bb0f57cff3e299f360052ba50f1ea0fff046df2be070b6943e0e3c3fdad8a9\",\"urls\":[\"bzz-raw://59fd025151435da35faa8093a5c7a17de02de9d08ad27275c5cdf05050820d91\",\"dweb:/ipfs/QmQMvwEcPhoRXzbXyrdoeRtvLoifUW9Qh7Luho7bmUPRkc\"]}},\"version\":1}",
"bytecode": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158202eee24c768ba1b25473f3d67193202a25b27c6b455929ba9f5fea2f28896f6606c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a723158202eee24c768ba1b25473f3d67193202a25b27c6b455929ba9f5fea2f28896f6606c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "993:2653:96:-;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24",
"deployedSourceMap": "993:2653:96:-;;;;;;;;",
"source": "/*\n\n Copyright 2019 dYdX Trading Inc.\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\npragma solidity ^0.5.7;\npragma experimental ABIEncoderV2;\n\nimport { Require } from \"./Require.sol\";\nimport { Token } from \"./Token.sol\";\nimport { Types } from \"./Types.sol\";\nimport { IExchangeWrapper } from \"../interfaces/IExchangeWrapper.sol\";\n\n\n/**\n * @title Exchange\n * @author dYdX\n *\n * Library for transferring tokens and interacting with ExchangeWrappers by using the Wei struct\n */\nlibrary Exchange {\n using Types for Types.Wei;\n\n // ============ Constants ============\n\n bytes32 private constant FILE = \"Exchange\";\n\n // ============ Library Functions ============\n\n function transferOut(\n address token,\n address to,\n Types.Wei memory deltaWei\n )\n internal\n {\n Require.that(\n !deltaWei.isPositive(),\n FILE,\n \"Cannot transferOut positive\",\n deltaWei.value\n );\n\n Token.transfer(\n token,\n to,\n deltaWei.value\n );\n }\n\n function transferIn(\n address token,\n address from,\n Types.Wei memory deltaWei\n )\n internal\n {\n Require.that(\n !deltaWei.isNegative(),\n FILE,\n \"Cannot transferIn negative\",\n deltaWei.value\n );\n\n Token.transferFrom(\n token,\n from,\n address(this),\n deltaWei.value\n );\n }\n\n function getCost(\n address exchangeWrapper,\n address supplyToken,\n address borrowToken,\n Types.Wei memory desiredAmount,\n bytes memory orderData\n )\n internal\n view\n returns (Types.Wei memory)\n {\n Require.that(\n !desiredAmount.isNegative(),\n FILE,\n \"Cannot getCost negative\",\n desiredAmount.value\n );\n\n Types.Wei memory result;\n result.sign = false;\n result.value = IExchangeWrapper(exchangeWrapper).getExchangeCost(\n supplyToken,\n borrowToken,\n desiredAmount.value,\n orderData\n );\n\n return result;\n }\n\n function exchange(\n address exchangeWrapper,\n address accountOwner,\n address supplyToken,\n address borrowToken,\n Types.Wei memory requestedFillAmount,\n bytes memory orderData\n )\n internal\n returns (Types.Wei memory)\n {\n Require.that(\n !requestedFillAmount.isPositive(),\n FILE,\n \"Cannot exchange positive\",\n requestedFillAmount.value\n );\n\n transferOut(borrowToken, exchangeWrapper, requestedFillAmount);\n\n Types.Wei memory result;\n result.sign = true;\n result.value = IExchangeWrapper(exchangeWrapper).exchange(\n accountOwner,\n address(this),\n supplyToken,\n borrowToken,\n requestedFillAmount.value,\n orderData\n );\n\n transferIn(supplyToken, exchangeWrapper, result);\n\n return result;\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Exchange.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Exchange.sol",
"exportedSymbols": {
"Exchange": [
27434
]
},
"id": 27435,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 27219,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:96"
},
{
"id": 27220,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:96"
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Require.sol",
"file": "./Require.sol",
"id": 27222,
"nodeType": "ImportDirective",
"scope": 27435,
"sourceUnit": 28453,
"src": "662:40:96",
"symbolAliases": [
{
"foreign": 27221,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Token.sol",
"file": "./Token.sol",
"id": 27224,
"nodeType": "ImportDirective",
"scope": 27435,
"sourceUnit": 30851,
"src": "703:36:96",
"symbolAliases": [
{
"foreign": 27223,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol",
"file": "./Types.sol",
"id": 27226,
"nodeType": "ImportDirective",
"scope": 27435,
"sourceUnit": 31362,
"src": "740:36:96",
"symbolAliases": [
{
"foreign": 27225,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExchangeWrapper.sol",
"file": "../interfaces/IExchangeWrapper.sol",
"id": 27228,
"nodeType": "ImportDirective",
"scope": 27435,
"sourceUnit": 24750,
"src": "777:70:96",
"symbolAliases": [
{
"foreign": 27227,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Exchange\n@author dYdX\n * Library for transferring tokens and interacting with ExchangeWrappers by using the Wei struct",
"fullyImplemented": true,
"id": 27434,
"linearizedBaseContracts": [
27434
],
"name": "Exchange",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 27231,
"libraryName": {
"contractScope": null,
"id": 27229,
"name": "Types",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 31361,
"src": "1022:5:96",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Types_$31361",
"typeString": "library Types"
}
},
"nodeType": "UsingForDirective",
"src": "1016:26:96",
"typeName": {
"contractScope": null,
"id": 27230,
"name": "Types.Wei",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 31149,
"src": "1032:9:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_storage_ptr",
"typeString": "struct Types.Wei"
}
}
},
{
"constant": true,
"id": 27234,
"name": "FILE",
"nodeType": "VariableDeclaration",
"scope": 27434,
"src": "1092:42:96",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 27232,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1092:7:96",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "45786368616e6765",
"id": 27233,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1124:10:96",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_ddd112a261429abc594f5771eb08d7fa47bff456b2e5f1a47907b78573e33d96",
"typeString": "literal_string \"Exchange\""
},
"value": "Exchange"
},
"visibility": "private"
},
{
"body": {
"id": 27265,
"nodeType": "Block",
"src": "1319:262:96",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27249,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "!",
"prefix": true,
"src": "1355:22:96",
"subExpression": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"id": 27246,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27240,
"src": "1356:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27247,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "isPositive",
"nodeType": "MemberAccess",
"referencedDeclaration": 31347,
"src": "1356:19:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_struct$_Wei_$31149_memory_ptr_$returns$_t_bool_$bound_to$_t_struct$_Wei_$31149_memory_ptr_$",
"typeString": "function (struct Types.Wei memory) pure returns (bool)"
}
},
"id": 27248,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1356:21:96",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"id": 27250,
"name": "FILE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27234,
"src": "1391:4:96",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"hexValue": "43616e6e6f74207472616e736665724f757420706f736974697665",
"id": 27251,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1409:29:96",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_6313e36f59db0696431488501ed66b6af7c37dd90e338d754fd158b2cb9a686b",
"typeString": "literal_string \"Cannot transferOut positive\""
},
"value": "Cannot transferOut positive"
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27252,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27240,
"src": "1452:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27253,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 31148,
"src": "1452:14:96",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_stringliteral_6313e36f59db0696431488501ed66b6af7c37dd90e338d754fd158b2cb9a686b",
"typeString": "literal_string \"Cannot transferOut positive\""
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 27243,
"name": "Require",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28452,
"src": "1329:7:96",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Require_$28452_$",
"typeString": "type(library Require)"
}
},
"id": 27245,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "that",
"nodeType": "MemberAccess",
"referencedDeclaration": 27852,
"src": "1329:12:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bool_$_t_bytes32_$_t_bytes32_$_t_uint256_$returns$__$",
"typeString": "function (bool,bytes32,bytes32,uint256) pure"
}
},
"id": 27254,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1329:147:96",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 27255,
"nodeType": "ExpressionStatement",
"src": "1329:147:96"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27259,
"name": "token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27236,
"src": "1515:5:96",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 27260,
"name": "to",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27238,
"src": "1534:2:96",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27261,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27240,
"src": "1550:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27262,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 31148,
"src": "1550:14:96",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 27256,
"name": "Token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 30850,
"src": "1487:5:96",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Token_$30850_$",
"typeString": "type(library Token)"
}
},
"id": 27258,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "transfer",
"nodeType": "MemberAccess",
"referencedDeclaration": 30771,
"src": "1487:14:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$",
"typeString": "function (address,address,uint256)"
}
},
"id": 27263,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1487:87:96",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 27264,
"nodeType": "ExpressionStatement",
"src": "1487:87:96"
}
]
},
"documentation": null,
"id": 27266,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "transferOut",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 27241,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 27236,
"name": "token",
"nodeType": "VariableDeclaration",
"scope": 27266,
"src": "1223:13:96",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 27235,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1223:7:96",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27238,
"name": "to",
"nodeType": "VariableDeclaration",
"scope": 27266,
"src": "1246:10:96",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 27237,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1246:7:96",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27240,
"name": "deltaWei",
"nodeType": "VariableDeclaration",
"scope": 27266,
"src": "1266:25:96",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei"
},
"typeName": {
"contractScope": null,
"id": 27239,
"name": "Types.Wei",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 31149,
"src": "1266:9:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_storage_ptr",
"typeString": "struct Types.Wei"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1213:84:96"
},
"returnParameters": {
"id": 27242,
"nodeType": "ParameterList",
"parameters": [],
"src": "1319:0:96"
},
"scope": 27434,
"src": "1193:388:96",
"stateMutability": "nonpayable",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 27300,
"nodeType": "Block",
"src": "1714:294:96",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27281,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "!",
"prefix": true,
"src": "1750:22:96",
"subExpression": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"id": 27278,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27272,
"src": "1751:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27279,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "isNegative",
"nodeType": "MemberAccess",
"referencedDeclaration": 31331,
"src": "1751:19:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_struct$_Wei_$31149_memory_ptr_$returns$_t_bool_$bound_to$_t_struct$_Wei_$31149_memory_ptr_$",
"typeString": "function (struct Types.Wei memory) pure returns (bool)"
}
},
"id": 27280,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1751:21:96",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"id": 27282,
"name": "FILE",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27234,
"src": "1786:4:96",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"hexValue": "43616e6e6f74207472616e73666572496e206e65676174697665",
"id": 27283,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1804:28:96",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_7d6fa90b55967e0c28ffe86ae31cec5897a9bfb0739a3d4bece2ebf483e76086",
"typeString": "literal_string \"Cannot transferIn negative\""
},
"value": "Cannot transferIn negative"
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27284,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27272,
"src": "1846:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27285,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 31148,
"src": "1846:14:96",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_stringliteral_7d6fa90b55967e0c28ffe86ae31cec5897a9bfb0739a3d4bece2ebf483e76086",
"typeString": "literal_string \"Cannot transferIn negative\""
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 27275,
"name": "Require",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28452,
"src": "1724:7:96",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Require_$28452_$",
"typeString": "type(library Require)"
}
},
"id": 27277,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "that",
"nodeType": "MemberAccess",
"referencedDeclaration": 27852,
"src": "1724:12:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bool_$_t_bytes32_$_t_bytes32_$_t_uint256_$returns$__$",
"typeString": "function (bool,bytes32,bytes32,uint256) pure"
}
},
"id": 27286,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1724:146:96",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 27287,
"nodeType": "ExpressionStatement",
"src": "1724:146:96"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27291,
"name": "token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27268,
"src": "1913:5:96",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 27292,
"name": "from",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27270,
"src": "1932:4:96",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27294,
"name": "this",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 38323,
"src": "1958:4:96",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Exchange_$27434",
"typeString": "library Exchange"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_contract$_Exchange_$27434",
"typeString": "library Exchange"
}
],
"id": 27293,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1950:7:96",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 27295,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1950:13:96",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27296,
"name": "deltaWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27272,
"src": "1977:8:96",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
},
"id": 27297,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 31148,
"src": "1977:14:96",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_address",
"typeString": "address"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 27288,
"name": "Token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 30850,
"src": "1881:5:96",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Token_$30850_$",
"typeString": "type(library Token)"
}
},
"id": 27290,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "transferFrom",
"nodeType": "MemberAccess",
"referencedDeclaration": 30809,
"src": "1881:18:96",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_address_$_t_uint256_$returns$__$",
"typeString": "function (address,address,address,uint256)"
}
},
"id": 27298,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1881:120:96",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 27299,
"nodeType": "ExpressionStatement",
"src": "1881:120:96"
}
]
},
"documentation": null,
"id": 27301,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "transferIn",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 27273,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 27268,
"name": "token",
"nodeType": "VariableDeclaration",
"scope": 27301,
"src": "1616:13:96",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 27267,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1616:7:96",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27270,
"name": "from",
"nodeType": "Variab