@gooddollar/goodcontracts
Version:
GoodDollar Contracts
1,020 lines (1,019 loc) • 387 kB
JSON
{
"contractName": "DSMath",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "add",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "sub",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "mul",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "min",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "max",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "x",
"type": "int256"
},
{
"internalType": "int256",
"name": "y",
"type": "int256"
}
],
"name": "imin",
"outputs": [
{
"internalType": "int256",
"name": "z",
"type": "int256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "x",
"type": "int256"
},
{
"internalType": "int256",
"name": "y",
"type": "int256"
}
],
"name": "imax",
"outputs": [
{
"internalType": "int256",
"name": "z",
"type": "int256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "wmul",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "rmul",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "wdiv",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"name": "rdiv",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "n",
"type": "uint256"
}
],
"name": "rpow",
"outputs": [
{
"internalType": "uint256",
"name": "z",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"add\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"y\",\"type\":\"int256\"}],\"name\":\"imax\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"z\",\"type\":\"int256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"y\",\"type\":\"int256\"}],\"name\":\"imin\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"z\",\"type\":\"int256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"max\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"min\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"mul\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"rdiv\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"rmul\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"n\",\"type\":\"uint256\"}],\"name\":\"rpow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"sub\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"wdiv\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"wmul\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"z\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/utils/DSMath.sol\":\"DSMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/utils/DSMath.sol\":{\"keccak256\":\"0x064e3a362de2b979b6afd9d9b00ef9682b61d3a2560f53a18535c36e5dacf57d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d86b2691be131202255756be3509685b4b00b65469577caba7d90d0a54be47f6\",\"dweb:/ipfs/QmP2MBv2YTd257qSv6TJmxmSwTcP4zDC3M51TjmL8Mv7xQ\"]}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b506104ee806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638b9af5c1116100715780638b9af5c11461019d5780638f907195146101c0578063ae94e448146101e3578063b67d77c514610206578063c8a4ac9c14610229578063c8e6c7d91461024c576100b4565b80630e2286d3146100b95780635fde731c146100ee57806367457022146101115780636d5433e614610134578063771602f7146101575780637ae2b5c71461017a575b600080fd5b6100dc600480360360408110156100cf57600080fd5b508035906020013561026f565b60408051918252519081900360200190f35b6100dc6004803603604081101561010457600080fd5b508035906020013561029f565b6100dc6004803603604081101561012757600080fd5b50803590602001356102b1565b6100dc6004803603604081101561014a57600080fd5b50803590602001356102d9565b6100dc6004803603604081101561016d57600080fd5b50803590602001356102f4565b6100dc6004803603604081101561019057600080fd5b5080359060200135610343565b6100dc600480360360408110156101b357600080fd5b5080359060200135610353565b6100dc600480360360408110156101d657600080fd5b5080359060200135610374565b6100dc600480360360408110156101f957600080fd5b50803590602001356103c9565b6100dc6004803603604081101561021c57600080fd5b50803590602001356103d9565b6100dc6004803603604081101561023f57600080fd5b5080359060200135610429565b6100dc6004803603604081101561026257600080fd5b508035906020013561048c565b6000816102906102868561028161049c565b610429565b6002855b046102f4565b8161029757fe5b049392505050565b600081610290610286856102816104ac565b60006102bb61049c565b6102906102c88585610429565b60026102d261049c565b8161028a57fe5b6000818310156102e957816102eb565b825b90505b92915050565b808201828110156102ee576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b6000818311156102e957816102eb565b600061035d6104ac565b61029061036a8585610429565b60026102d26104ac565b60006002820661038b5761038661049c565b61038d565b825b90506002820491505b81156102ee576103a683846102b1565b925060028206156103be576103bb81846102b1565b90505b600282049150610396565b6000818312156102e957816102eb565b808203828111156102ee576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b60008115806104445750508082028282828161044157fe5b04145b6102ee576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b6000818313156102e957816102eb565b6b033b2e3c9fd0803ce800000090565b670de0b6b3a76400009056fea264697066735822122039e8338e029fd64634f8e05506fd4c4d372efd07d3e050e14ab4ad2f39340d7664736f6c634300060c0033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638b9af5c1116100715780638b9af5c11461019d5780638f907195146101c0578063ae94e448146101e3578063b67d77c514610206578063c8a4ac9c14610229578063c8e6c7d91461024c576100b4565b80630e2286d3146100b95780635fde731c146100ee57806367457022146101115780636d5433e614610134578063771602f7146101575780637ae2b5c71461017a575b600080fd5b6100dc600480360360408110156100cf57600080fd5b508035906020013561026f565b60408051918252519081900360200190f35b6100dc6004803603604081101561010457600080fd5b508035906020013561029f565b6100dc6004803603604081101561012757600080fd5b50803590602001356102b1565b6100dc6004803603604081101561014a57600080fd5b50803590602001356102d9565b6100dc6004803603604081101561016d57600080fd5b50803590602001356102f4565b6100dc6004803603604081101561019057600080fd5b5080359060200135610343565b6100dc600480360360408110156101b357600080fd5b5080359060200135610353565b6100dc600480360360408110156101d657600080fd5b5080359060200135610374565b6100dc600480360360408110156101f957600080fd5b50803590602001356103c9565b6100dc6004803603604081101561021c57600080fd5b50803590602001356103d9565b6100dc6004803603604081101561023f57600080fd5b5080359060200135610429565b6100dc6004803603604081101561026257600080fd5b508035906020013561048c565b6000816102906102868561028161049c565b610429565b6002855b046102f4565b8161029757fe5b049392505050565b600081610290610286856102816104ac565b60006102bb61049c565b6102906102c88585610429565b60026102d261049c565b8161028a57fe5b6000818310156102e957816102eb565b825b90505b92915050565b808201828110156102ee576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b6000818311156102e957816102eb565b600061035d6104ac565b61029061036a8585610429565b60026102d26104ac565b60006002820661038b5761038661049c565b61038d565b825b90506002820491505b81156102ee576103a683846102b1565b925060028206156103be576103bb81846102b1565b90505b600282049150610396565b6000818312156102e957816102eb565b808203828111156102ee576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b60008115806104445750508082028282828161044157fe5b04145b6102ee576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b6000818313156102e957816102eb565b6b033b2e3c9fd0803ce800000090565b670de0b6b3a76400009056fea264697066735822122039e8338e029fd64634f8e05506fd4c4d372efd07d3e050e14ab4ad2f39340d7664736f6c634300060c0033",
"immutableReferences": {},
"sourceMap": "755:2125:11:-:0;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "755:2125:11:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2048:109;;;;;;;;;;;;;;;;-1:-1:-1;2048:109:11;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;1936;;;;;;;;;;;;;;;;-1:-1:-1;1936:109:11;;;;;;;:::i;1820:113::-;;;;;;;;;;;;;;;;-1:-1:-1;1820:113:11;;;;;;;:::i;1411:96::-;;;;;;;;;;;;;;;;-1:-1:-1;1411:96:11;;;;;;;:::i;916:124::-;;;;;;;;;;;;;;;;-1:-1:-1;916:124:11;;;;;;;:::i;1312:96::-;;;;;;;;;;;;;;;;-1:-1:-1;1312:96:11;;;;;;;:::i;1704:113::-;;;;;;;;;;;;;;;;-1:-1:-1;1704:113:11;;;;;;;:::i;2672:206::-;;;;;;;;;;;;;;;;-1:-1:-1;2672:206:11;;;;;;;:::i;1607:94::-;;;;;;;;;;;;;;;;-1:-1:-1;1607:94:11;;;;;;;:::i;1043:125::-;;;;;;;;;;;;;;;;-1:-1:-1;1043:125:11;;;;;;;:::i;1171:138::-;;;;;;;;;;;;;;;;-1:-1:-1;1171:138:11;;;;;;;:::i;1510:94::-;;;;;;;;;;;;;;;;-1:-1:-1;1510:94:11;;;;;;;:::i;2048:109::-;2105:9;2152:1;2124:25;2128:13;2132:1;2135:5;:3;:5::i;:::-;2128:3;:13::i;:::-;2147:1;2143;:5;;2124:3;:25::i;:::-;:29;;;;;;;2048:109;-1:-1:-1;;;2048:109:11:o;1936:::-;1993:9;2040:1;2012:25;2016:13;2020:1;2023:5;:3;:5::i;1820:113::-;1877:9;1924:5;:3;:5::i;:::-;1896:25;1900:9;1904:1;1907;1900:3;:9::i;:::-;1919:1;1911:5;:3;:5::i;:::-;:9;;;;1411:96;1467:9;1494:1;1489;:6;;:14;;1502:1;1489:14;;;1498:1;1489:14;1482:21;;1411:96;;;;;:::o;916:124::-;1000:5;;;995:16;;;;987:49;;;;;-1:-1:-1;;;987:49:11;;;;;;;;;;;;-1:-1:-1;;;987:49:11;;;;;;;;;;;;;;1312:96;1368:9;1395:1;1390;:6;;:14;;1403:1;1390:14;;1704:113;1761:9;1808:5;:3;:5::i;:::-;1780:25;1784:9;1788:1;1791;1784:3;:9::i;:::-;1803:1;1795:5;:3;:5::i;2672:206::-;2729:9;2752:1;2748;:5;:22;;2765:5;:3;:5::i;:::-;2748:22;;;2761:1;2748:22;2744:26;-1:-1:-1;2785:1:11;2780:6;;;;2775:100;2788:6;;2775:100;;2813:10;2818:1;2821;2813:4;:10::i;:::-;2809:14;-1:-1:-1;2837:1:11;2833;:5;:10;2829:42;;2855:10;2860:1;2863;2855:4;:10::i;:::-;2851:14;;2829:42;2801:1;2796:6;;;;2775:100;;1607:94;1662:8;1688:1;1683;:6;;:14;;1696:1;1683:14;;1043:125;1127:5;;;1122:16;;;;1114:50;;;;;-1:-1:-1;;;1114:50:11;;;;;;;;;;;;-1:-1:-1;;;1114:50:11;;;;;;;;;;;;;;1171:138;1227:9;1250:6;;;:30;;-1:-1:-1;;1265:5:11;;;1279:1;1274;1265:5;1274:1;1260:15;;;;;:20;1250:30;1242:63;;;;;-1:-1:-1;;;1242:63:11;;;;;;;;;;;;-1:-1:-1;;;1242:63:11;;;;;;;;;;;;;;1510:94;1565:8;1591:1;1586;:6;;:14;;1599:1;1586:14;;845:68;903:6;845:68;:::o;774:::-;832:6;774:68;:::o",
"source": "// SPDX-License-Identifier: MIT\n\n/// math.sol -- mixin for inline numerical wizardry\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >0.4.13;\n\ncontract DSMath {\n\tfunction WAD() internal pure returns (uint256) {\n\t\treturn 10**18;\n\t}\n\n\tfunction RAY() internal pure returns (uint256) {\n\t\treturn 10**27;\n\t}\n\n\tfunction add(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\trequire((z = x + y) >= x, \"ds-math-add-overflow\");\n\t}\n\n\tfunction sub(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\trequire((z = x - y) <= x, \"ds-math-sub-underflow\");\n\t}\n\n\tfunction mul(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\trequire(y == 0 || (z = x * y) / y == x, \"ds-math-mul-overflow\");\n\t}\n\n\tfunction min(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\treturn x <= y ? x : y;\n\t}\n\n\tfunction max(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\treturn x >= y ? x : y;\n\t}\n\n\tfunction imin(int256 x, int256 y) public pure returns (int256 z) {\n\t\treturn x <= y ? x : y;\n\t}\n\n\tfunction imax(int256 x, int256 y) public pure returns (int256 z) {\n\t\treturn x >= y ? x : y;\n\t}\n\n\tfunction wmul(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\tz = add(mul(x, y), WAD() / 2) / WAD();\n\t}\n\n\tfunction rmul(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\tz = add(mul(x, y), RAY() / 2) / RAY();\n\t}\n\n\tfunction wdiv(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\tz = add(mul(x, WAD()), y / 2) / y;\n\t}\n\n\tfunction rdiv(uint256 x, uint256 y) public pure returns (uint256 z) {\n\t\tz = add(mul(x, RAY()), y / 2) / y;\n\t}\n\n\t// This famous algorithm is called \"exponentiation by squaring\"\n\t// and calculates x^n with x as fixed-point and n as regular unsigned.\n\t//\n\t// It's O(log n), instead of O(n) for naive repeated multiplication.\n\t//\n\t// These facts are why it works:\n\t//\n\t// If n is even, then x^n = (x^2)^(n/2).\n\t// If n is odd, then x^n = x * x^(n-1),\n\t// and applying the equation for even x gives\n\t// x^n = x * (x^2)^((n-1) / 2).\n\t//\n\t// Also, EVM division is flooring and\n\t// floor[(n-1) / 2] = floor[n / 2].\n\t//\n\tfunction rpow(uint256 x, uint256 n) public pure returns (uint256 z) {\n\t\tz = n % 2 != 0 ? x : RAY();\n\n\t\tfor (n /= 2; n != 0; n /= 2) {\n\t\t\tx = rmul(x, x);\n\n\t\t\tif (n % 2 != 0) {\n\t\t\t\tz = rmul(z, x);\n\t\t\t}\n\t\t}\n\t}\n}\n",
"sourcePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/utils/DSMath.sol",
"ast": {
"absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/utils/DSMath.sol",
"exportedSymbols": {
"DSMath": [
7698
]
},
"id": 7699,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 7379,
"literals": [
"solidity",
">",
"0.4",
".13"
],
"nodeType": "PragmaDirective",
"src": "729:24:11"
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 7698,
"linearizedBaseContracts": [
7698
],
"name": "DSMath",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 7388,
"nodeType": "Block",
"src": "821:21:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
},
"id": 7386,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "3130",
"id": 7384,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "832:2:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_10_by_1",
"typeString": "int_const 10"
},
"value": "10"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "3138",
"id": 7385,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "836:2:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_18_by_1",
"typeString": "int_const 18"
},
"value": "18"
},
"src": "832:6:11",
"typeDescriptions": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
}
},
"functionReturnParameters": 7383,
"id": 7387,
"nodeType": "Return",
"src": "825:13:11"
}
]
},
"documentation": null,
"id": 7389,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "WAD",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 7380,
"nodeType": "ParameterList",
"parameters": [],
"src": "786:2:11"
},
"returnParameters": {
"id": 7383,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 7382,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 7389,
"src": "812:7:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 7381,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "812:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "811:9:11"
},
"scope": 7698,
"src": "774:68:11",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 7398,
"nodeType": "Block",
"src": "892:21:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_1000000000000000000000000000_by_1",
"typeString": "int_const 1000000000000000000000000000"
},
"id": 7396,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "3130",
"id": 7394,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "903:2:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_10_by_1",
"typeString": "int_const 10"
},
"value": "10"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "3237",
"id": 7395,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "907:2:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_27_by_1",
"typeString": "int_const 27"
},
"value": "27"
},
"src": "903:6:11",
"typeDescriptions": {
"typeIdentifier": "t_rational_1000000000000000000000000000_by_1",
"typeString": "int_const 1000000000000000000000000000"
}
},
"functionReturnParameters": 7393,
"id": 7397,
"nodeType": "Return",
"src": "896:13:11"
}
]
},
"documentation": null,
"id": 7399,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "RAY",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 7390,
"nodeType": "ParameterList",
"parameters": [],
"src": "857:2:11"
},
"returnParameters": {
"id": 7393,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 7392,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 7399,
"src": "883:7:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 7391,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "883:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "882:9:11"
},
"scope": 7698,
"src": "845:68:11",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 7420,
"nodeType": "Block",
"src": "983:57:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 7416,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 7413,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 7409,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7406,
"src": "996:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 7412,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 7410,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7401,
"src": "1000:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "+",
"rightExpression": {
"argumentTypes": null,
"id": 7411,
"name": "y",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7403,
"src": "1004:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1000:5:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "996:9:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 7414,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "995:11:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">=",
"rightExpression": {
"argumentTypes": null,
"id": 7415,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7401,
"src": "1010:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "995:16:11",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "64732d6d6174682d6164642d6f766572666c6f77",
"id": 7417,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1013:22:11",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_3903056b84ed2aba2be78662dc6c5c99b160cebe9af9bd9493d0fc28ff16f6db",
"typeString": "literal_string \"ds-math-add-overflow\""
},
"value": "ds-math-add-overflow"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_3903056b84ed2aba2be78662dc6c5c99b160cebe9af9bd9493d0fc28ff16f6db",
"typeString": "literal_string \"ds-math-add-overflow\""
}
],
"id": 7408,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
-18,
-18
],
"referencedDeclaration": -18,
"src": "987:7:11",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$",
"typeString": "function (bool,string memory) pure"
}
},
"id": 7418,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "987:49:11",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 7419,
"nodeType": "ExpressionStatement",
"src": "987:49:11"
}
]
},
"documentation": null,
"functionSelector": "771602f7",
"id": 7421,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "add",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 7404,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 7401,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 7421,
"src": "929:9:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 7400,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "929:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 7403,
"mutability": "mutable",
"name": "y",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 7421,
"src": "940:9:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 7402,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "940:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "928:22:11"
},
"returnParameters": {
"id": 7407,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 7406,
"mutability": "mutable",
"name": "z",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 7421,
"src": "972:9:11",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 7405,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "972:7:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "971:11:11"
},
"scope": 7698,
"src": "916:124:11",
"stateMutability": "pure",
"virtual": false,
"visibility": "public"
},
{
"body": {
"id": 7442,
"nodeType": "Block",
"src": "1110:58:11",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 7438,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"id": 7435,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 7431,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7428,
"src": "1123:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 7434,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 7432,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7423,
"src": "1127:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "-",
"rightExpression": {
"argumentTypes": null,
"id": 7433,
"name": "y",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7425,
"src": "1131:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1127:5:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1123:9:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 7436,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "1122:11:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<=",
"rightExpression": {
"argumentTypes": null,
"id": 7437,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 7423,
"src": "1137:1:11",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}