@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
957 lines (956 loc) • 214 kB
JSON
{
"contractName": "SafeExternalCallback",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "primaryAccountOwner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "primaryAccountNumber",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "reason",
"type": "string"
}
],
"name": "LogExternalCallbackFailure",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "primaryAccountOwner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "primaryAccountNumber",
"type": "uint256"
}
],
"name": "LogExternalCallbackSuccess",
"type": "event"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"primaryAccountOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"primaryAccountNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"LogExternalCallbackFailure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"primaryAccountOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"primaryAccountNumber\",\"type\":\"uint256\"}],\"name\":\"LogExternalCallbackSuccess\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/SafeExternalCallback.sol\":\"SafeExternalCallback\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExternalCallback.sol\":{\"keccak256\":\"0xd8134eac006b0a59b71cbcca82dfce7ce092a57c13a8383ebf0e8bc90c0df3e7\",\"urls\":[\"bzz-raw://ccead8bdcc71402ae7b1d8fb9bc1527081a5eb14f98a5157f5c6f27f21f8ad31\",\"dweb:/ipfs/QmdnDvTiX3EDm93ahjnZabNNgoyQzGtKpfbQUNtJe7t8Ts\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Account.sol\":{\"keccak256\":\"0x2059276ea5e478bd5ac7f2712e7b1b6c85d291c647a54b264909044844828e67\",\"urls\":[\"bzz-raw://f153777051d12131b13a57e5c3af10a2670927cfc7d22c9519ab20c9b4b9bc89\",\"dweb:/ipfs/QmQMP3qS5xDAVGYKDfNkbkSqBKozQGQsGqX4e8VyjRtxPS\"]},\"/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/EnumerableSet.sol\":{\"keccak256\":\"0x41a3460e34b7b8635d936e35e6568ceb5354b638f53b884530e0d4875fa0f151\",\"urls\":[\"bzz-raw://d1a5ba866ee95d455afe5075dadd91fc71c2806371f2c1b358a1f67c632bb0df\",\"dweb:/ipfs/QmW4qCjmsG8J3UJv97GwDLDM7wt1K4yLDKAwzWMY7TFYi5\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/ExcessivelySafeCall.sol\":{\"keccak256\":\"0x9369468538c371057c907f84d438cec6b47673711fe289cc3779f8671314e06b\",\"urls\":[\"bzz-raw://0f59a670f4bc5cf1bd3dd58bdf6c31723d9d84d9da7d9283d6860cdf5f33b7c5\",\"dweb:/ipfs/QmTGuvD5WQD2z56GH35HoPJivKPeeEpbXidJVcbXZyT23C\"]},\"/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/SafeExternalCallback.sol\":{\"keccak256\":\"0xd308a1ab320de20780f7041ea5efd9568f8692e1ed6cf512b967ab63c791a8ff\",\"urls\":[\"bzz-raw://4a904b056f094be598396a90a5ba5297213934cfc2816848a494469ce249edd4\",\"dweb:/ipfs/QmcmeezMFPntDLNS1EY4j5THgRJUeyscgLv55WwxbFoiaY\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":{\"keccak256\":\"0xe1bab8c8799d83e86c7a49aaf815d8e3bc8d09562d46d44d921500db5e98de0e\",\"urls\":[\"bzz-raw://8ea3d0cc4fdab6dd9bba545a792170f939b342d8d1a7051c1c6365009af72658\",\"dweb:/ipfs/QmaLJgbavu88eEit6JPqfWnw6NmGBDZfveMXxumgWywBFG\"]},\"@openzeppelin/contracts/math/Math.sol\":{\"keccak256\":\"0x4b5aa451e4e8801478708f94b118a7821c0500d676255eaf89fc78c14856ce4e\",\"urls\":[\"bzz-raw://bed15b3f35ed05505efc8fb5cb01d06c52230fbcaadf4ed24a85b1ac2f15f33c\",\"dweb:/ipfs/QmS6tW81u8E4tvzVfVuqEuMCkdwAozQ6pKJPRBR4JEVmQp\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0x1a8e5072509c5ea7365eb1d48030b9be865140c8fb779968da0a459a0e174a11\",\"urls\":[\"bzz-raw://03335b7b07c7c8c8d613cfdd8ec39a0b5ec133ee510bf2fe6cc5a496767bef4b\",\"dweb:/ipfs/Qmebp4nzPja645c9yXSdJkGq96oU3am3LUnG2K3R7XxyKf\"]}},\"version\":1}",
"bytecode": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820eb9d76a0421864c0bb6fdc2565ec0cab7bbc44e8d2575f97d52f74510b95b2d76c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a72315820eb9d76a0421864c0bb6fdc2565ec0cab7bbc44e8d2575f97d52f74510b95b2d76c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "1087:3596:100:-;;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": "1087:3596:100:-;;;;;;;;",
"source": "/*\n\n Copyright 2022 Dolomite.\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 { Math } from \"@openzeppelin/contracts/math/Math.sol\";\nimport { Address } from \"@openzeppelin/contracts/utils/Address.sol\";\n\nimport { IExternalCallback } from \"../interfaces/IExternalCallback.sol\";\nimport { Account } from \"../lib/Account.sol\";\nimport { ExcessivelySafeCall } from \"../lib/ExcessivelySafeCall.sol\";\nimport { DolomiteMarginMath } from \"../lib/DolomiteMarginMath.sol\";\nimport { Types } from \"../lib/Types.sol\";\n\n\nlibrary SafeExternalCallback {\n using Address for address;\n using ExcessivelySafeCall for address;\n\n // ============ Events ============\n\n event LogExternalCallbackSuccess(address indexed primaryAccountOwner, uint primaryAccountNumber);\n\n event LogExternalCallbackFailure(address indexed primaryAccountOwner, uint primaryAccountNumber, string reason);\n\n // ============ Functions ============\n\n function callInternalBalanceChangeIfNecessary(\n Account.Info memory _primaryAccount,\n Account.Info memory _secondaryAccount,\n uint256 _primaryMarket,\n Types.Wei memory _primaryDeltaWei,\n uint256 _secondaryMarket,\n Types.Wei memory _secondaryDeltaWei,\n uint256 _gasLimit\n ) internal {\n if (_gasLimit != 0 && _primaryAccount.owner.isContract()) {\n uint16 maxCopyBytes = 256;\n (bool isCallSuccessful, bytes memory result) = _primaryAccount.owner.excessivelySafeCall(\n /* _gas = */ Math.min(gasleft(), _gasLimit), // send, at most, `_gasLimit` to the callback\n maxCopyBytes, // receive at-most this many bytes worth of return data\n abi.encodeWithSelector(\n IExternalCallback(_primaryAccount.owner).onInternalBalanceChange.selector,\n _primaryAccount.number,\n _secondaryAccount,\n _primaryMarket,\n _primaryDeltaWei,\n _secondaryMarket,\n _secondaryDeltaWei\n )\n );\n\n if (isCallSuccessful) {\n emit LogExternalCallbackSuccess(_primaryAccount.owner, _primaryAccount.number);\n } else {\n // For reversions:\n // - the first 4 bytes is the method ID\n // - the next 32 bytes is the offset (hardcoded 0x20)\n // - the next 32 bytes is the length of the string\n // Here is an example result. The first 68 bytes (136 hexadecimal characters) are the templated\n // 08c379a0 // erroring method ID\n // 0000000000000000000000000000000000000000000000000000000000000020 // offset to where string is\n // 0000000000000000000000000000000000000000000000000000000000000001 // string length\n // 2100000000000000000000000000000000000000000000000000000000000000 // string itself - not templated\n if (result.length < 68) {\n result = bytes(\"\");\n } else {\n // parse the result bytes error message into a human-readable string\n uint length;\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n result := add(result, 0x04)\n length := mload(add(result, 0x40))\n if gt(length, sub(maxCopyBytes, 0x44)) {\n // if the length from `result` is longer than the max length, subtract the 68 bytes\n // from the maxCopyBytes\n mstore(add(result, 0x40), sub(maxCopyBytes, 0x44))\n }\n }\n result = bytes(abi.decode(result, (string)));\n }\n emit LogExternalCallbackFailure(\n _primaryAccount.owner,\n _primaryAccount.number,\n string(result)\n );\n }\n }\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/SafeExternalCallback.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/SafeExternalCallback.sol",
"exportedSymbols": {
"SafeExternalCallback": [
28603
]
},
"id": 28604,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 28454,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "595:23:100"
},
{
"id": 28455,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "619:33:100"
},
{
"absolutePath": "@openzeppelin/contracts/math/Math.sol",
"file": "@openzeppelin/contracts/math/Math.sol",
"id": 28457,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 37179,
"src": "654:61:100",
"symbolAliases": [
{
"foreign": 28456,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "@openzeppelin/contracts/utils/Address.sol",
"file": "@openzeppelin/contracts/utils/Address.sol",
"id": 28459,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 37848,
"src": "716:68:100",
"symbolAliases": [
{
"foreign": 28458,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExternalCallback.sol",
"file": "../interfaces/IExternalCallback.sol",
"id": 28461,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 24773,
"src": "786:72:100",
"symbolAliases": [
{
"foreign": 28460,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Account.sol",
"file": "../lib/Account.sol",
"id": 28463,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 24886,
"src": "859:45:100",
"symbolAliases": [
{
"foreign": 28462,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/ExcessivelySafeCall.sol",
"file": "../lib/ExcessivelySafeCall.sol",
"id": 28465,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 27218,
"src": "905:69:100",
"symbolAliases": [
{
"foreign": 28464,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"file": "../lib/DolomiteMarginMath.sol",
"id": 28467,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 26239,
"src": "975:67:100",
"symbolAliases": [
{
"foreign": 28466,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol",
"file": "../lib/Types.sol",
"id": 28469,
"nodeType": "ImportDirective",
"scope": 28604,
"sourceUnit": 31362,
"src": "1043:41:100",
"symbolAliases": [
{
"foreign": 28468,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": null,
"fullyImplemented": true,
"id": 28603,
"linearizedBaseContracts": [
28603
],
"name": "SafeExternalCallback",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 28472,
"libraryName": {
"contractScope": null,
"id": 28470,
"name": "Address",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37847,
"src": "1128:7:100",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Address_$37847",
"typeString": "library Address"
}
},
"nodeType": "UsingForDirective",
"src": "1122:26:100",
"typeName": {
"id": 28471,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1140:7:100",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
},
{
"id": 28475,
"libraryName": {
"contractScope": null,
"id": 28473,
"name": "ExcessivelySafeCall",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 27217,
"src": "1159:19:100",
"typeDescriptions": {
"typeIdentifier": "t_contract$_ExcessivelySafeCall_$27217",
"typeString": "library ExcessivelySafeCall"
}
},
"nodeType": "UsingForDirective",
"src": "1153:38:100",
"typeName": {
"id": 28474,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1183:7:100",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
},
{
"anonymous": false,
"documentation": null,
"id": 28481,
"name": "LogExternalCallbackSuccess",
"nodeType": "EventDefinition",
"parameters": {
"id": 28480,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 28477,
"indexed": true,
"name": "primaryAccountOwner",
"nodeType": "VariableDeclaration",
"scope": 28481,
"src": "1271:35:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 28476,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1271:7:100",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 28479,
"indexed": false,
"name": "primaryAccountNumber",
"nodeType": "VariableDeclaration",
"scope": 28481,
"src": "1308:25:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 28478,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "1308:4:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1270:64:100"
},
"src": "1238:97:100"
},
{
"anonymous": false,
"documentation": null,
"id": 28489,
"name": "LogExternalCallbackFailure",
"nodeType": "EventDefinition",
"parameters": {
"id": 28488,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 28483,
"indexed": true,
"name": "primaryAccountOwner",
"nodeType": "VariableDeclaration",
"scope": 28489,
"src": "1374:35:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 28482,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1374:7:100",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 28485,
"indexed": false,
"name": "primaryAccountNumber",
"nodeType": "VariableDeclaration",
"scope": 28489,
"src": "1411:25:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 28484,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "1411:4:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 28487,
"indexed": false,
"name": "reason",
"nodeType": "VariableDeclaration",
"scope": 28489,
"src": "1438:13:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_string_memory_ptr",
"typeString": "string"
},
"typeName": {
"id": 28486,
"name": "string",
"nodeType": "ElementaryTypeName",
"src": "1438:6:100",
"typeDescriptions": {
"typeIdentifier": "t_string_storage_ptr",
"typeString": "string"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1373:79:100"
},
"src": "1341:112:100"
},
{
"body": {
"id": 28601,
"nodeType": "Block",
"src": "1837:2844:100",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"id": 28513,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 28508,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 28506,
"name": "_gasLimit",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28503,
"src": "1851:9:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "!=",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 28507,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1864:1:100",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "1851:14:100",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"nodeType": "BinaryOperation",
"operator": "&&",
"rightExpression": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 28509,
"name": "_primaryAccount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28491,
"src": "1869:15:100",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Info_$24851_memory_ptr",
"typeString": "struct Account.Info memory"
}
},
"id": 28510,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "owner",
"nodeType": "MemberAccess",
"referencedDeclaration": 24848,
"src": "1869:21:100",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"id": 28511,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "isContract",
"nodeType": "MemberAccess",
"referencedDeclaration": 37799,
"src": "1869:32:100",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_bool_$bound_to$_t_address_$",
"typeString": "function (address) view returns (bool)"
}
},
"id": 28512,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1869:34:100",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"src": "1851:52:100",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 28600,
"nodeType": "IfStatement",
"src": "1847:2828:100",
"trueBody": {
"id": 28599,
"nodeType": "Block",
"src": "1905:2770:100",
"statements": [
{
"assignments": [
28515
],
"declarations": [
{
"constant": false,
"id": 28515,
"name": "maxCopyBytes",
"nodeType": "VariableDeclaration",
"scope": 28599,
"src": "1919:19:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
},
"typeName": {
"id": 28514,
"name": "uint16",
"nodeType": "ElementaryTypeName",
"src": "1919:6:100",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 28517,
"initialValue": {
"argumentTypes": null,
"hexValue": "323536",
"id": 28516,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1941:3:100",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"nodeType": "VariableDeclarationStatement",
"src": "1919:25:100"
},
{
"assignments": [
28519,
28521
],
"declarations": [
{
"constant": false,
"id": 28519,
"name": "isCallSuccessful",
"nodeType": "VariableDeclaration",
"scope": 28599,
"src": "1959:21:100",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 28518,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1959:4:100",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 28521,
"name": "result",
"nodeType": "VariableDeclaration",
"scope": 28599,
"src": "1982:19:100",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 28520,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "1982:5:100",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 28549,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"id": 28527,
"name": "gasleft",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 38100,
"src": "2086:7:100",
"typeDescriptions": {
"typeIdentifier": "t_function_gasleft_view$__$returns$_t_uint256_$",
"typeString": "function () view returns (uint256)"
}
},
"id": 28528,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2086:9:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 28529,
"name": "_gasLimit",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28503,
"src": "2097:9:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"id": 28525,
"name": "Math",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 37178,
"src": "2077:4:100",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Math_$37178_$",
"typeString": "type(library Math)"
}
},
"id": 28526,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "min",
"nodeType": "MemberAccess",
"referencedDeclaration": 37145,
"src": "2077:8:100",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 28530,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2077:30:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 28531,
"name": "maxCopyBytes",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28515,
"src": "2171:12:100",
"typeDescriptions": {
"typeIdentifier": "t_uint16",
"typeString": "uint16"
}
},
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 28535,
"name": "_primaryAccount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28491,
"src": "2319:15:100",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Info_$24851_memory_ptr",
"typeString": "struct Account.Info memory"
}
},
"id": 28536,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "owner",
"nodeType": "MemberAccess",
"referencedDeclaration": 24848,
"src": "2319:21:100",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 28534,
"name": "IExternalCallback",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 24772,
"src": "2301:17:100",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IExternalCallback_$24772_$",
"typeString": "type(contract IExternalCallback)"
}
},
"id": 28537,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2301:40:100",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IExternalCallback_$24772",
"typeString": "contract IExternalCallback"
}
},
"id": 28538,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "onInternalBalanceChange",
"nodeType": "MemberAccess",
"referencedDeclaration": 24771,
"src": "2301:64:100",
"typeDescriptions": {
"typeIdentifier": "t_function_external_nonpayable$_t_uint256_$_t_struct$_Info_$24851_memory_ptr_$_t_uint256_$_t_struct$_Wei_$31149_memory_ptr_$_t_uint256_$_t_struct$_Wei_$31149_memory_ptr_$returns$__$",
"typeString": "function (uint256,struct Account.Info memory,uint256,struct Types.Wei memory,uint256,struct Types.Wei memory) external"
}
},
"id": 28539,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "selector",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "2301:73:100",
"typeDescriptions": {
"typeIdentifier": "t_bytes4",
"typeString": "bytes4"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 28540,
"name": "_primaryAccount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28491,
"src": "2396:15:100",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Info_$24851_memory_ptr",
"typeString": "struct Account.Info memory"
}
},
"id": 28541,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "number",
"nodeType": "MemberAccess",
"referencedDeclaration": 24850,
"src": "2396:22:100",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,
"id": 28542,
"name": "_secondaryAccount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 28493,
"src": "2440:17:100",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Info_$24851_memory_ptr",
"typeString": "struct Account.Info memory"
}
},
{
"argumentTypes": null,
"id": 28543,
"name": "_primaryMarket",
"nodeType": "Identifier",