"Median.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"./vendor/SafeMathChainlink.sol\";\nimport \"./SignedSafeMath.sol\";\n\nlibrary Median {\n using SignedSafeMath for int256;\n\n int256 constant INT_MAX = 2**255-1;\n\n /**\n * @notice Returns the sorted middle, or the average of the two middle indexed items if the\n * array has an even number of elements.\n * @dev The list passed as an argument isn't modified.\n * @dev This algorithm has expected runtime O(n), but for adversarially chosen inputs\n * the runtime is O(n^2).\n * @param list The list of elements to compare\n */\n function calculate(int256[] memory list)\n internal\n pure\n returns (int256)\n {\n return calculateInplace(copy(list));\n }\n\n /**\n * @notice See documentation for function calculate.\n * @dev The list passed as an argument may be permuted.\n */\n function calculateInplace(int256[] memory list)\n internal\n pure\n returns (int256)\n {\n require(0 < list.length, \"list must not be empty\");\n uint256 len = list.length;\n uint256 middleIndex = len / 2;\n if (len % 2 == 0) {\n int256 median1;\n int256 median2;\n (median1, median2) = quickselectTwo(list, 0, len - 1, middleIndex - 1, middleIndex);\n return SignedSafeMath.avg(median1, median2);\n } else {\n return quickselect(list, 0, len - 1, middleIndex);\n }\n }\n\n /**\n * @notice Maximum length of list that shortSelectTwo can handle\n */\n uint256 constant SHORTSELECTTWO_MAX_LENGTH = 7;\n\n /**\n * @notice Select the k1-th and k2-th element from list of length at most 7\n * @dev Uses an optimal sorting network\n */\n function shortSelectTwo(\n int256[] memory list,\n uint256 lo,\n uint256 hi,\n uint256 k1,\n uint256 k2\n )\n private\n pure\n returns (int256 k1th, int256 k2th)\n {\n // Uses an optimal sorting network (https://en.wikipedia.org/wiki/Sorting_network)\n // for lists of length 7. Network layout is taken from\n // http://jgamble.ripco.net/cgi-bin/nw.cgi?inputs=7&algorithm=hibbard&output=svg\n\n uint256 len = hi + 1 - lo;\n int256 x0 = list[lo + 0];\n int256 x1 = 1 < len ? list[lo + 1] : INT_MAX;\n int256 x2 = 2 < len ? list[lo + 2] : INT_MAX;\n int256 x3 = 3 < len ? list[lo + 3] : INT_MAX;\n int256 x4 = 4 < len ? list[lo + 4] : INT_MAX;\n int256 x5 = 5 < len ? list[lo + 5] : INT_MAX;\n int256 x6 = 6 < len ? list[lo + 6] : INT_MAX;\n\n if (x0 > x1) {(x0, x1) = (x1, x0);}\n if (x2 > x3) {(x2, x3) = (x3, x2);}\n if (x4 > x5) {(x4, x5) = (x5, x4);}\n if (x0 > x2) {(x0, x2) = (x2, x0);}\n if (x1 > x3) {(x1, x3) = (x3, x1);}\n if (x4 > x6) {(x4, x6) = (x6, x4);}\n if (x1 > x2) {(x1, x2) = (x2, x1);}\n if (x5 > x6) {(x5, x6) = (x6, x5);}\n if (x0 > x4) {(x0, x4) = (x4, x0);}\n if (x1 > x5) {(x1, x5) = (x5, x1);}\n if (x2 > x6) {(x2, x6) = (x6, x2);}\n if (x1 > x4) {(x1, x4) = (x4, x1);}\n if (x3 > x6) {(x3, x6) = (x6, x3);}\n if (x2 > x4) {(x2, x4) = (x4, x2);}\n if (x3 > x5) {(x3, x5) = (x5, x3);}\n if (x3 > x4) {(x3, x4) = (x4, x3);}\n\n uint256 index1 = k1 - lo;\n if (index1 == 0) {k1th = x0;}\n else if (index1 == 1) {k1th = x1;}\n else if (index1 == 2) {k1th = x2;}\n else if (index1 == 3) {k1th = x3;}\n else if (index1 == 4) {k1th = x4;}\n else if (index1 == 5) {k1th = x5;}\n else if (index1 == 6) {k1th = x6;}\n else {revert(\"k1 out of bounds\");}\n\n uint256 index2 = k2 - lo;\n if (k1 == k2) {return (k1th, k1th);}\n else if (index2 == 0) {return (k1th, x0);}\n else if (index2 == 1) {return (k1th, x1);}\n else if (index2 == 2) {return (k1th, x2);}\n else if (index2 == 3) {return (k1th, x3);}\n else if (index2 == 4) {return (k1th, x4);}\n else if (index2 == 5) {return (k1th, x5);}\n else if (index2 == 6) {return (k1th, x6);}\n else {revert(\"k2 out of bounds\");}\n }\n\n /**\n * @notice Selects the k-th ranked element from list, looking only at indices between lo and hi\n * (inclusive). Modifies list in-place.\n */\n function quickselect(int256[] memory list, uint256 lo, uint256 hi, uint256 k)\n private\n pure\n returns (int256 kth)\n {\n require(lo <= k);\n require(k <= hi);\n while (lo < hi) {\n if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) {\n int256 ignore;\n (kth, ignore) = shortSelectTwo(list, lo, hi, k, k);\n return kth;\n }\n uint256 pivotIndex = partition(list, lo, hi);\n if (k <= pivotIndex) {\n // since pivotIndex < (original hi passed to partition),\n // termination is guaranteed in this case\n hi = pivotIndex;\n } else {\n // since (original lo passed to partition) <= pivotIndex,\n // termination is guaranteed in this case\n lo = pivotIndex + 1;\n }\n }\n return list[lo];\n }\n\n /**\n * @notice Selects the k1-th and k2-th ranked elements from list, looking only at indices between\n * lo and hi (inclusive). Modifies list in-place.\n */\n function quickselectTwo(\n int256[] memory list,\n uint256 lo,\n uint256 hi,\n uint256 k1,\n uint256 k2\n )\n internal // for testing\n pure\n returns (int256 k1th, int256 k2th)\n {\n require(k1 < k2);\n require(lo <= k1 && k1 <= hi);\n require(lo <= k2 && k2 <= hi);\n\n while (true) {\n if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) {\n return shortSelectTwo(list, lo, hi, k1, k2);\n }\n uint256 pivotIdx = partition(list, lo, hi);\n if (k2 <= pivotIdx) {\n hi = pivotIdx;\n } else if (pivotIdx < k1) {\n lo = pivotIdx + 1;\n } else {\n assert(k1 <= pivotIdx && pivotIdx < k2);\n k1th = quickselect(list, lo, pivotIdx, k1);\n k2th = quickselect(list, pivotIdx + 1, hi, k2);\n return (k1th, k2th);\n }\n }\n }\n\n /**\n * @notice Partitions list in-place using Hoare's partitioning scheme.\n * Only elements of list between indices lo and hi (inclusive) will be modified.\n * Returns an index i, such that:\n * - lo <= i < hi\n * - forall j in [lo, i]. list[j] <= list[i]\n * - forall j in [i, hi]. list[i] <= list[j]\n */\n function partition(int256[] memory list, uint256 lo, uint256 hi)\n private\n pure\n returns (uint256)\n {\n // We don't care about overflow of the addition, because it would require a list\n // larger than any feasible computer's memory.\n int256 pivot = list[(lo + hi) / 2];\n lo -= 1; // this can underflow. that's intentional.\n hi += 1;\n while (true) {\n do {\n lo += 1;\n } while (list[lo] < pivot);\n do {\n hi -= 1;\n } while (list[hi] > pivot);\n if (lo < hi) {\n (list[lo], list[hi]) = (list[hi], list[lo]);\n } else {\n // Let orig_lo and orig_hi be the original values of lo and hi passed to partition.\n // Then, hi < orig_hi, because hi decreases *strictly* monotonically\n // in each loop iteration and\n // - either list[orig_hi] > pivot, in which case the first loop iteration\n // will achieve hi < orig_hi;\n // - or list[orig_hi] <= pivot, in which case at least two loop iterations are\n // needed:\n // - lo will have to stop at least once in the interval\n // [orig_lo, (orig_lo + orig_hi)/2]\n // - (orig_lo + orig_hi)/2 < orig_hi\n return hi;\n }\n }\n }\n\n /**\n * @notice Makes an in-memory copy of the array passed in\n * @param list Reference to the array to be copied\n */\n function copy(int256[] memory list)\n private\n pure\n returns(int256[] memory)\n {\n int256[] memory list2 = new int256[](list.length);\n for (uint256 i = 0; i < list.length; i++) {\n list2[i] = list[i];\n }\n return list2;\n }\n}\n",
"vendor/SafeMathChainlink.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathChainlink {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, \"SafeMath: division by zero\");\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n}\n",
"SignedSafeMath.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nlibrary SignedSafeMath {\n int256 constant private _INT256_MIN = -2**255;\n\n /**\n * @dev Multiplies two signed integers, reverts on overflow.\n */\n function mul(int256 a, int256 b) internal pure returns (int256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n require(!(a == -1 && b == _INT256_MIN), \"SignedSafeMath: multiplication overflow\");\n\n int256 c = a * b;\n require(c / a == b, \"SignedSafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.\n */\n function div(int256 a, int256 b) internal pure returns (int256) {\n require(b != 0, \"SignedSafeMath: division by zero\");\n require(!(b == -1 && a == _INT256_MIN), \"SignedSafeMath: division overflow\");\n\n int256 c = a / b;\n\n return c;\n }\n\n /**\n * @dev Subtracts two signed integers, reverts on overflow.\n */\n function sub(int256 a, int256 b) internal pure returns (int256) {\n int256 c = a - b;\n require((b >= 0 && c <= a) || (b < 0 && c > a), \"SignedSafeMath: subtraction overflow\");\n\n return c;\n }\n\n /**\n * @dev Adds two signed integers, reverts on overflow.\n */\n function add(int256 a, int256 b) internal pure returns (int256) {\n int256 c = a + b;\n require((b >= 0 && c >= a) || (b < 0 && c < a), \"SignedSafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @notice Computes average of two signed integers, ensuring that the computation\n * doesn't overflow.\n * @dev If the result is not an integer, it is rounded towards zero. For example,\n * avg(-3, -4) = -3\n */\n function avg(int256 _a, int256 _b)\n internal\n pure\n returns (int256)\n {\n if ((_a < 0 && _b > 0) || (_a > 0 && _b < 0)) {\n return add(_a, _b) / 2;\n }\n int256 remainder = (_a % 2 + _b % 2) / 2;\n return add(add(_a / 2, _b / 2), remainder);\n }\n}\n"
"Median.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"./vendor/SafeMathChainlink.sol\";\nimport \"./SignedSafeMath.sol\";\n\nlibrary Median {\n using SignedSafeMath for int256;\n\n int256 constant INT_MAX = 2**255-1;\n\n /**\n * @notice Returns the sorted middle, or the average of the two middle indexed items if the\n * array has an even number of elements.\n * @dev The list passed as an argument isn't modified.\n * @dev This algorithm has expected runtime O(n), but for adversarially chosen inputs\n * the runtime is O(n^2).\n * @param list The list of elements to compare\n */\n function calculate(int256[] memory list)\n internal\n pure\n returns (int256)\n {\n return calculateInplace(copy(list));\n }\n\n /**\n * @notice See documentation for function calculate.\n * @dev The list passed as an argument may be permuted.\n */\n function calculateInplace(int256[] memory list)\n internal\n pure\n returns (int256)\n {\n require(0 < list.length, \"list must not be empty\");\n uint256 len = list.length;\n uint256 middleIndex = len / 2;\n if (len % 2 == 0) {\n int256 median1;\n int256 median2;\n (median1, median2) = quickselectTwo(list, 0, len - 1, middleIndex - 1, middleIndex);\n return SignedSafeMath.avg(median1, median2);\n } else {\n return quickselect(list, 0, len - 1, middleIndex);\n }\n }\n\n /**\n * @notice Maximum length of list that shortSelectTwo can handle\n */\n uint256 constant SHORTSELECTTWO_MAX_LENGTH = 7;\n\n /**\n * @notice Select the k1-th and k2-th element from list of length at most 7\n * @dev Uses an optimal sorting network\n */\n function shortSelectTwo(\n int256[] memory list,\n uint256 lo,\n uint256 hi,\n uint256 k1,\n uint256 k2\n )\n private\n pure\n returns (int256 k1th, int256 k2th)\n {\n // Uses an optimal sorting network (https://en.wikipedia.org/wiki/Sorting_network)\n // for lists of length 7. Network layout is taken from\n // http://jgamble.ripco.net/cgi-bin/nw.cgi?inputs=7&algorithm=hibbard&output=svg\n\n uint256 len = hi + 1 - lo;\n int256 x0 = list[lo + 0];\n int256 x1 = 1 < len ? list[lo + 1] : INT_MAX;\n int256 x2 = 2 < len ? list[lo + 2] : INT_MAX;\n int256 x3 = 3 < len ? list[lo + 3] : INT_MAX;\n int256 x4 = 4 < len ? list[lo + 4] : INT_MAX;\n int256 x5 = 5 < len ? list[lo + 5] : INT_MAX;\n int256 x6 = 6 < len ? list[lo + 6] : INT_MAX;\n\n if (x0 > x1) {(x0, x1) = (x1, x0);}\n if (x2 > x3) {(x2, x3) = (x3, x2);}\n if (x4 > x5) {(x4, x5) = (x5, x4);}\n if (x0 > x2) {(x0, x2) = (x2, x0);}\n if (x1 > x3) {(x1, x3) = (x3, x1);}\n if (x4 > x6) {(x4, x6) = (x6, x4);}\n if (x1 > x2) {(x1, x2) = (x2, x1);}\n if (x5 > x6) {(x5, x6) = (x6, x5);}\n if (x0 > x4) {(x0, x4) = (x4, x0);}\n if (x1 > x5) {(x1, x5) = (x5, x1);}\n if (x2 > x6) {(x2, x6) = (x6, x2);}\n if (x1 > x4) {(x1, x4) = (x4, x1);}\n if (x3 > x6) {(x3, x6) = (x6, x3);}\n if (x2 > x4) {(x2, x4) = (x4, x2);}\n if (x3 > x5) {(x3, x5) = (x5, x3);}\n if (x3 > x4) {(x3, x4) = (x4, x3);}\n\n uint256 index1 = k1 - lo;\n if (index1 == 0) {k1th = x0;}\n else if (index1 == 1) {k1th = x1;}\n else if (index1 == 2) {k1th = x2;}\n else if (index1 == 3) {k1th = x3;}\n else if (index1 == 4) {k1th = x4;}\n else if (index1 == 5) {k1th = x5;}\n else if (index1 == 6) {k1th = x6;}\n else {revert(\"k1 out of bounds\");}\n\n uint256 index2 = k2 - lo;\n if (k1 == k2) {return (k1th, k1th);}\n else if (index2 == 0) {return (k1th, x0);}\n else if (index2 == 1) {return (k1th, x1);}\n else if (index2 == 2) {return (k1th, x2);}\n else if (index2 == 3) {return (k1th, x3);}\n else if (index2 == 4) {return (k1th, x4);}\n else if (index2 == 5) {return (k1th, x5);}\n else if (index2 == 6) {return (k1th, x6);}\n else {revert(\"k2 out of bounds\");}\n }\n\n /**\n * @notice Selects the k-th ranked element from list, looking only at indices between lo and hi\n * (inclusive). Modifies list in-place.\n */\n function quickselect(int256[] memory list, uint256 lo, uint256 hi, uint256 k)\n private\n pure\n returns (int256 kth)\n {\n require(lo <= k);\n require(k <= hi);\n while (lo < hi) {\n if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) {\n int256 ignore;\n (kth, ignore) = shortSelectTwo(list, lo, hi, k, k);\n return kth;\n }\n uint256 pivotIndex = partition(list, lo, hi);\n if (k <= pivotIndex) {\n // since pivotIndex < (original hi passed to partition),\n // termination is guaranteed in this case\n hi = pivotIndex;\n } else {\n // since (original lo passed to partition) <= pivotIndex,\n // termination is guaranteed in this case\n lo = pivotIndex + 1;\n }\n }\n return list[lo];\n }\n\n /**\n * @notice Selects the k1-th and k2-th ranked elements from list, looking only at indices between\n * lo and hi (inclusive). Modifies list in-place.\n */\n function quickselectTwo(\n int256[] memory list,\n uint256 lo,\n uint256 hi,\n uint256 k1,\n uint256 k2\n )\n internal // for testing\n pure\n returns (int256 k1th, int256 k2th)\n {\n require(k1 < k2);\n require(lo <= k1 && k1 <= hi);\n require(lo <= k2 && k2 <= hi);\n\n while (true) {\n if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) {\n return shortSelectTwo(list, lo, hi, k1, k2);\n }\n uint256 pivotIdx = partition(list, lo, hi);\n if (k2 <= pivotIdx) {\n hi = pivotIdx;\n } else if (pivotIdx < k1) {\n lo = pivotIdx + 1;\n } else {\n assert(k1 <= pivotIdx && pivotIdx < k2);\n k1th = quickselect(list, lo, pivotIdx, k1);\n k2th = quickselect(list, pivotIdx + 1, hi, k2);\n return (k1th, k2th);\n }\n }\n }\n\n /**\n * @notice Partitions list in-place using Hoare's partitioning scheme.\n * Only elements of list between indices lo and hi (inclusive) will be modified.\n * Returns an index i, such that:\n * - lo <= i < hi\n * - forall j in [lo, i]. list[j] <= list[i]\n * - forall j in [i, hi]. list[i] <= list[j]\n */\n function partition(int256[] memory list, uint256 lo, uint256 hi)\n private\n pure\n returns (uint256)\n {\n // We don't care about overflow of the addition, because it would require a list\n // larger than any feasible computer's memory.\n int256 pivot = list[(lo + hi) / 2];\n lo -= 1; // this can underflow. that's intentional.\n hi += 1;\n while (true) {\n do {\n lo += 1;\n } while (list[lo] < pivot);\n do {\n hi -= 1;\n } while (list[hi] > pivot);\n if (lo < hi) {\n (list[lo], list[hi]) = (list[hi], list[lo]);\n } else {\n // Let orig_lo and orig_hi be the original values of lo and hi passed to partition.\n // Then, hi < orig_hi, because hi decreases *strictly* monotonically\n // in each loop iteration and\n // - either list[orig_hi] > pivot, in which case the first loop iteration\n // will achieve hi < orig_hi;\n // - or list[orig_hi] <= pivot, in which case at least two loop iterations are\n // needed:\n // - lo will have to stop at least once in the interval\n // [orig_lo, (orig_lo + orig_hi)/2]\n // - (orig_lo + orig_hi)/2 < orig_hi\n return hi;\n }\n }\n }\n\n /**\n * @notice Makes an in-memory copy of the array passed in\n * @param list Reference to the array to be copied\n */\n function copy(int256[] memory list)\n private\n pure\n returns(int256[] memory)\n {\n int256[] memory list2 = new int256[](list.length);\n for (uint256 i = 0; i < list.length; i++) {\n list2[i] = list[i];\n }\n return list2;\n }\n}\n",
"vendor/SafeMathChainlink.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathChainlink {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, \"SafeMath: division by zero\");\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n}\n",
"SignedSafeMath.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nlibrary SignedSafeMath {\n int256 constant private _INT256_MIN = -2**255;\n\n /**\n * @dev Multiplies two signed integers, reverts on overflow.\n */\n function mul(int256 a, int256 b) internal pure returns (int256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n require(!(a == -1 && b == _INT256_MIN), \"SignedSafeMath: multiplication overflow\");\n\n int256 c = a * b;\n require(c / a == b, \"SignedSafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.\n */\n function div(int256 a, int256 b) internal pure returns (int256) {\n require(b != 0, \"SignedSafeMath: division by zero\");\n require(!(b == -1 && a == _INT256_MIN), \"SignedSafeMath: division overflow\");\n\n int256 c = a / b;\n\n return c;\n }\n\n /**\n * @dev Subtracts two signed integers, reverts on overflow.\n */\n function sub(int256 a, int256 b) internal pure returns (int256) {\n int256 c = a - b;\n require((b >= 0 && c <= a) || (b < 0 && c > a), \"SignedSafeMath: subtraction overflow\");\n\n return c;\n }\n\n /**\n * @dev Adds two signed integers, reverts on overflow.\n */\n function add(int256 a, int256 b) internal pure returns (int256) {\n int256 c = a + b;\n require((b >= 0 && c >= a) || (b < 0 && c < a), \"SignedSafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @notice Computes average of two signed integers, ensuring that the computation\n * doesn't overflow.\n * @dev If the result is not an integer, it is rounded towards zero. For example,\n * avg(-3, -4) = -3\n */\n function avg(int256 _a, int256 _b)\n internal\n pure\n returns (int256)\n {\n if ((_a < 0 && _b > 0) || (_a > 0 && _b < 0)) {\n return add(_a, _b) / 2;\n }\n int256 remainder = (_a % 2 + _b % 2) / 2;\n return add(add(_a / 2, _b / 2), remainder);\n }\n}\n"
"details":"Given params must hash to a commitment stored on the contract in order for the request to be valid Emits CancelOracleRequest event.",
"params":{
"_expiration":"The time of the expiration for the request",
"_payment":"The amount of payment given (specified in wei)",
"_requestId":"The request ID"
}
},
"constructor":{
"details":"Sets the LinkToken address for the imported LinkTokenInterface",
"params":{
"_link":"The address of the LINK token"
}
},
"fulfillOracleRequest(bytes32,bytes32)":{
"details":"Given params must hash back to the commitment stored from `oracleRequest`. Will call the callback address' callback function without bubbling up error checking in a `require` so that the node can get paid.",
"params":{
"_data":"The data to return to the consuming contract",
"_requestId":"The fulfillment request ID that must match the requester's"
},
"returns":{
"_0":"Status if the external call was successful"
}
},
"getChainlinkToken()":{
"details":"This is the public implementation for chainlinkTokenAddress, which is an internal method of the ChainlinkClient contract"
},
"onTokenTransfer(address,uint256,bytes)":{
"details":"The data payload's first 2 words will be overwritten by the `_sender` and `_amount` values to ensure correctness. Calls oracleRequest.",
"params":{
"_amount":"Amount of LINK sent (specified in wei)",
"metadata":"{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_link\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"requestId\",\"type\":\"bytes32\"}],\"name\":\"CancelOracleRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"specId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"requester\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"requestId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"payment\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"callbackAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"callbackFunctionId\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cancelExpiration\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dataVersion\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"OracleRequest\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"EXPIRY_TIME\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_requestId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"_payment\",\"type\":\"uint256\"},{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"_expiration\",\"type\":\"uint256\"}],\"name\":\"cancelOracleRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_requestId\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_data\",\"type\":\"bytes32\"}],\"name\":\"fulfillOracleRequest\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChainlinkToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"onTokenTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_payment\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_specId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"_callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"_callbackFunctionId\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_dataVersion\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"oracleRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{\"cancelOracleRequest(bytes32,uint256,bytes4,uint256)\":{\"details\":\"Given params must hash to a commitment stored on the contract in order for the request to be valid Emits CancelOracleRequest event.\",\"params\":{\"_expiration\":\"The time of the expiration for the request\",\"_payment\":\"The amount of payment given (specified in wei)\",\"_requestId\":\"The request ID\"}},\"constructor\":{\"details\":\"Sets the LinkToken address for the imported LinkTokenInterface\",\"params\":{\"_link\":\"The address of the LINK token\"}},\"fulfillOracleRequest(bytes32,bytes32)\":{\"details\":\"Given params must hash back to the commitment stored from `oracleRequest`. Will call the callback address' callback function without bubbling up error checking in a `require` so that the node can get paid.\",\"params\":{\"_data\":\"The data to return to the consuming contract\",\"_requestId\":\"The fulfillment request ID that must match the requester's\"},\"returns\":{\"_0\":\"Status if the external call was successful\"}},\"getChainlinkToken()\":{\"details\":\"This is the public implementation for chainlinkTokenAddress, which is an internal method of the ChainlinkClient contract\"},\"onTokenTransfer(address,uint256,bytes)\":{\"details\":\"The data payload's first 2 words will be overwritten by the `_sender` and `_amount` values to ensure correctness. Calls oracleRequest.\",\"params\":{\"_amount\":\"Amount of LINK sent (specified in wei)\",\"_data\":\"Payload of the transaction\",\"_sender\":\"Address of the sender\"}},\"oracleRequest(address,uint256,bytes32,address,bytes4,uint256,uint256,bytes)\":{\"details\":\"Stores the hash of the params as the on-chain commitment for the request. Emits OracleRequest event for the Chainlink node to detect.\",\"params\":{\"_callbackAddress\":\"The callback address for the response\",\"_callbackFunctionId\":\"The callback function ID for the response\",\"_data\":\"The CBOR payload of the request\",\"_dataVersion\":\"The specified data version\",\"_nonce\":\"The nonce sent by the requester\",\"_payment\":\"The amount of payment given (specified in wei)\",\"_sender\":\"The sender of the request\",\"_specId\":\"The Job Specification ID\"}}},\"title\":\"The Chainlink Mock Oracle contract\"},\"userdoc\":{\"methods\":{\"cancelOracleRequest(bytes32,uint256,bytes4,uint256)\":{\"notice\":\"Allows requesters to cancel requests sent to this oracle contract. Will transfer the LINK sent for the request back to the requester's address.\"},\"constructor\":\"Deploy with the address of the LINK token\",\"fulfillOracleRequest(bytes32,bytes32)\":{\"notice\":\"Called by the Chainlink node to fulfill requests\"},\"getChainlinkToken()\":{\"notice\":\"Returns the address of the LINK token\"},\"onTokenTransfer(address,uint256,bytes)\":{\"notice\":\"Called when LINK is sent to the contract via `transferAndCall`\"},\"oracleRequest(address,uint256,bytes32,address,bytes4,uint256,uint256,bytes)\":{\"notice\":\"Creates the Chainlink request\"}},\"notice\":\"Chainlink smart contract developers can use this to test their contracts\"}},\"settings\":{\"compilationTarget\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockOracle.sol\":\"MockOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/LinkTokenReceiver.sol\":{\"keccak256\":\"0xcbde7153731a1cd229fbef4dcbb0b5a7a3ff4782bca40cbc12f836c39e054769\",\"urls\":[\"bzz-raw://83a7d0e4f1704c3b5474eb98342fbeee00782232d797f4446d7413463d17e58c\",\"dweb:/ipfs/QmTWtHy88hXLaX1K3EzuEN11F2aAT3G2QjL2WnDwPg7Mqa\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/ChainlinkRequestInterface.sol\":{\"keccak256\":\"0xe513c0f60edf13da7d82625489cf2008c7b66170f3b1ed1606b84c73f95b17ad\",\"urls\":[\"bzz-raw://78e083ef252b80bb63a5aa126bc7283cd9b88767dfdf0190d46802bc32756ecf\",\"dweb:/ipfs/QmdTyEQwX5ecoXR1rBh8DLDJpCYVDM85JjjR2sEJdE9wAA\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/LinkTokenInterface.sol\":{\"keccak256\":\"0xe245a7be950c94d87bb775ae9ee9fbd693fbe2987778e6ce0b04605ea44b7b68\",\"urls\":[\"bzz-raw://bd2c3165d949fc66fe407b96eb3dc2092c7e800f4c073b411bf7b96de3e156c9\",\"dweb:/ipfs/QmcfJhR1Np4GsLWnww2Duqks2wEzYk8VDTvCAYy7MisG1r\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockOracle.sol\":{\"keccak256\":\"0xfc10b0f8b30f95bd64d1fd2e4787a8c63571f651c13bd8eaee6e1faf0735c5a6\",\"urls\":[\"bzz-raw://9f22194f08b9cd2ca072026f45f1ae67a61b06625389014596cd651c7a05a6e1\",\"dweb:/ipfs/QmddjLP1u3eeS7ac2CsdZVpdyyKdjnsL14GBSPFcAeHatP\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/vendor/SafeMathChainlink.sol\":{\"keccak256\":\"0x105f5e9491f3d0bbdd4f1c7627eb839d69b944bfd803028a01cc083597692c1f\",\"urls\":[\"bzz-raw://ec45a2748a024a947a921183d4102d5e206808588501d85ddc4f5668a009bc73\",\"dweb:/ipfs/QmRNAMpq7LdWFnJ7wWKGbUuAcURaGSS42PMxtQ4vjrHmp9\"]}},\"version\":1}",
"notice":"Allows requesters to cancel requests sent to this oracle contract. Will transfer the LINK sent for the request back to the requester's address."
},
"constructor":"Deploy with the address of the LINK token",
"fulfillOracleRequest(bytes32,bytes32)":{
"notice":"Called by the Chainlink node to fulfill requests"
},
"getChainlinkToken()":{
"notice":"Returns the address of the LINK token"
},
"onTokenTransfer(address,uint256,bytes)":{
"notice":"Called when LINK is sent to the contract via `transferAndCall`"
"notice":"Chainlink smart contract developers can use this to test their contracts"
}
},
"sources":{
"tests/MockOracle.sol":{
"id":53
},
"LinkTokenReceiver.sol":{
"id":10
},
"interfaces/ChainlinkRequestInterface.sol":{
"id":33
},
"interfaces/LinkTokenInterface.sol":{
"id":36
},
"vendor/SafeMathChainlink.sol":{
"id":67
}
},
"sourceCodes":{
"tests/MockOracle.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"../LinkTokenReceiver.sol\";\nimport \"../interfaces/ChainlinkRequestInterface.sol\";\nimport \"../interfaces/LinkTokenInterface.sol\";\nimport \"../vendor/SafeMathChainlink.sol\";\n\n/**\n * @title The Chainlink Mock Oracle contract\n * @notice Chainlink smart contract developers can use this to test their contracts\n */\ncontract MockOracle is ChainlinkRequestInterface, LinkTokenReceiver {\n using SafeMathChainlink for uint256;\n\n uint256 constant public EXPIRY_TIME = 5 minutes;\n uint256 constant private MINIMUM_CONSUMER_GAS_LIMIT = 400000;\n\n struct Request {\n address callbackAddr;\n bytes4 callbackFunctionId;\n }\n\n LinkTokenInterface internal LinkToken;\n mapping(bytes32 => Request) private commitments;\n\n event OracleRequest(\n bytes32 indexed specId,\n address requester,\n bytes32 requestId,\n uint256 payment,\n address callbackAddr,\n bytes4 callbackFunctionId,\n uint256 cancelExpiration,\n uint256 dataVersion,\n bytes data\n );\n\n event CancelOracleRequest(\n bytes32 indexed requestId\n );\n\n /**\n * @notice Deploy with the address of the LINK token\n * @dev Sets the LinkToken address for the imported LinkTokenInterface\n * @param _link The address of the LINK token\n */\n constructor(\n address _link\n )\n public\n {\n LinkToken = LinkTokenInterface(_link); // external but already deployed and unalterable\n }\n\n /**\n * @notice Creates the Chainlink request\n * @dev Stores the hash of the params as the on-chain commitment for the request.\n * Emits OracleRequest event for the Chainlink node to detect.\n * @param _sender The sender of the request\n * @param _payment The amount of payment given (specified in wei)\n * @param _specId The Job Specification ID\n * @param _callbackAddress The callback address for the response\n * @param _callbackFunctionId The callback function ID for the response\n * @param _nonce The nonce sent by the requester\n * @param _dataVersion The specified data version\n * @param _data The CBOR payload of the request\n */\n function oracleRequest(\n address _sender,\n uint256 _payment,\n bytes32 _specId,\n address _callbackAddress,\n bytes4 _callbackFunctionId,\n uint256 _nonce,\n uint256 _dataVersion,\n bytes calldata _data\n )\n external\n override\n onlyLINK()\n checkCallbackAddress(_callbackAddress)\n {\n bytes32 requestId = keccak256(abi.encodePacked(_sender, _nonce));\n require(commitments[requestId].callbackAddr == address(0), \"Must use a unique ID\");\n // solhint-disable-next-line not-rely-on-time\n uint256 expiration = now.add(EXPIRY_TIME);\n\n commitments[requestId] = Request(\n _callbackAddress,\n _callbackFunctionId\n );\n\n emit OracleRequest(\n _specId,\n _sender,\n requestId,\n _payment,\n _callbackAddress,\n _callbackFunctionId,\n expiration,\n _dataVersion,\n _data);\n }\n\n /**\n * @notice Called by the Chainlink node to fulfill requests\n * @dev Given params must hash back to the commitment stored from `oracleRequest`.\n * Will call the callback address' callback function without bubbling up error\n * checking in a `require` so that the node can get paid.\n * @param _requestId The fulfillment request ID that must match the requester's\n * @param _data The data to return to the consuming contract\n * @return Status if the external call was successful\n */\n function fulfillOracleRequest(\n bytes32 _requestId,\n bytes32 _data\n )\n external\n isValidRequest(_requestId)\n returns (\n bool\n )\n {\n Request memory req = commitments[_requestId];\n delete commitments[_requestId];\n require(gasleft() >= MINIMUM_CONSUMER_GAS_LIMIT, \"Must provide consumer enough gas\");\n // All updates to the oracle's fulfillment should come before calling the\n // callback(addr+functionId) as it is untrusted.\n // See: https://solidity.readthedocs.io/en/develop/security-considerations.html#use-the-checks-effects-interactions-pattern\n (bool success, ) = req.callbackAddr.call(abi.encodeWithSelector(req.callbackFunctionId, _requestId, _data)); // solhint-disable-line avoid-low-level-calls\n return success;\n }\n\n /**\n * @notice Allows requesters to cancel requests sent to this oracle contract. Will transfer the LINK\n * sent for the request back to the requester's address.\n * @dev Given params must hash to a commitment stored on the contract in order for the request to be valid\n * Emits CancelOracleRequest event.\n * @param _requestId The request ID\n * @param _payment The amount of payment given (specified in wei)\n * @param _expiration The time of the expiration for the request\n */\n function cancelOracleRequest(\n bytes32 _requestId,\n uint256 _payment,\n bytes4,\n uint256 _expiration\n )\n external\n override\n {\n require(commitments[_requestId].callbackAddr != address(0), \"Must use a unique ID\");\n // solhint-disable-next-line not-rely-on-time\n require(_expiration <= now, \"Request is not expired\");\n\n delete commitments[_requestId];\n emit CancelOracleRequest(_requestId);\n\n assert(LinkToken.transfer(msg.sender, _payment));\n }\n\n /**\n * @notice Returns the address of the LINK token\n * @dev This is the public implementation for chainlinkTokenAddress, which is\n * an internal method of the ChainlinkClient contract\n */\n function getChainlinkToken()\n public\n view\n override\n returns (\n address\n )\n {\n return address(LinkToken);\n }\n\n // MODIFIERS\n\n /**\n * @dev Reverts if request ID does not exist\n * @param _requestId The given request ID to check in stored `commitments`\n */\n modifier isValidRequest(\n bytes32 _requestId\n ) {\n require(commitments[_requestId].callbackAddr != address(0), \"Must have a valid requestId\");\n _;\n }\n\n\n /**\n * @dev Reverts if the callback address is the LINK token\n * @param _to The callback address\n */\n modifier checkCallbackAddress(\n address _to\n ) {\n require(_to != address(LinkToken), \"Cannot callback to LINK\");\n _;\n }\n\n}\n",
"LinkTokenReceiver.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nabstract contract LinkTokenReceiver {\n\n bytes4 constant private ORACLE_REQUEST_SELECTOR = 0x40429946;\n uint256 constant private SELECTOR_LENGTH = 4;\n uint256 constant private EXPECTED_REQUEST_WORDS = 2;\n uint256 constant private MINIMUM_REQUEST_LENGTH = SELECTOR_LENGTH + (32 * EXPECTED_REQUEST_WORDS);\n /**\n * @notice Called when LINK is sent to the contract via `transferAndCall`\n * @dev The data payload's first 2 words will be overwritten by the `_sender` and `_amount`\n * values to ensure correctness. Calls oracleRequest.\n * @param _sender Address of the sender\n * @param _amount Amount of LINK sent (specified in wei)\n * @param _data Payload of the transaction\n */\n function onTokenTransfer(\n address _sender,\n uint256 _amount,\n bytes memory _data\n )\n public\n onlyLINK\n validRequestLength(_data)\n permittedFunctionsForLINK(_data)\n {\n assembly {\n // solhint-disable-next-line avoid-low-level-calls\n mstore(add(_data, 36), _sender) // ensure correct sender is passed\n // solhint-disable-next-line avoid-low-level-calls\n mstore(add(_data, 68), _amount) // ensure correct amount is passed\n }\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, ) = address(this).delegatecall(_data); // calls oracleRequest\n require(success, \"Unable to create request\");\n }\n\n function getChainlinkToken() public view virtual returns (address);\n\n /**\n * @dev Reverts if not sent from the LINK token\n */\n modifier onlyLINK() {\n require(msg.sender == getChainlinkToken(), \"Must use LINK token\");\n _;\n }\n\n /**\n * @dev Reverts if the given data does not begin with the `oracleRequest` function selector\n * @param _data The data payload of the request\n */\n modifier permittedFunctionsForLINK(bytes memory _data) {\n bytes4 funcSelector;\n assembly {\n // solhint-disable-next-line avoid-low-level-calls\n funcSelector := mload(add(_data, 32))\n }\n require(funcSelector == ORACLE_REQUEST_SELECTOR, \"Must use whitelisted functions\");\n _;\n }\n\n /**\n * @dev Reverts if the given payload is less than needed to create a request\n * @param _data The request payload\n */\n modifier validRequestLength(bytes memory _data) {\n require(_data.length >= MINIMUM_REQUEST_LENGTH, \"Invalid request length\");\n _;\n }\n}\n",
"interfaces/LinkTokenInterface.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\ninterface LinkTokenInterface {\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n function approve(address spender, uint256 value) external returns (bool success);\n function balanceOf(address owner) external view returns (uint256 balance);\n function decimals() external view returns (uint8 decimalPlaces);\n function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);\n function increaseApproval(address spender, uint256 subtractedValue) external;\n function name() external view returns (string memory tokenName);\n function symbol() external view returns (string memory tokenSymbol);\n function totalSupply() external view returns (uint256 totalTokensIssued);\n function transfer(address to, uint256 value) external returns (bool success);\n function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);\n function transferFrom(address from, address to, uint256 value) external returns (bool success);\n}\n",
"vendor/SafeMathChainlink.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathChainlink {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, \"SafeMath: division by zero\");\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n}\n"
"metadata":"{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"_initialAnswer\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"int256\",\"name\":\"current\",\"type\":\"int256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"roundId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"}],\"name\":\"AnswerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"roundId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"startedBy\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"}],\"name\":\"NewRound\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"getAnswer\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"getTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestAnswer\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestRound\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"_answer\",\"type\":\"int256\"}],\"name\":\"updateAnswer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_roundId\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"_answer\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"_timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_startedAt\",\"type\":\"uint256\"}],\"name\":\"updateRoundData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{},\"title\":\"MockV2Aggregator\"},\"userdoc\":{\"methods\":{},\"notice\":\"Based on the HistoricAggregator contractUse this contract when you need to test other contract's ability to read data from an aggregator contract, but how the aggregator got its answer is unimportant\"}},\"settings\":{\"compilationTarget\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockV2Aggregator.sol\":\"MockV2Aggregator\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol\":{\"keccak256\":\"0xbd2b9524ed06f150fefaf4ea600fa8b426d644f17c9f7ddd6d793c19557c23ca\",\"urls\":[\"bzz-raw://32e224693884f94929ab3128a1f780c517c8c294634f7f0ef56b411131fa9858\",\"dweb:/ipfs/QmYC99ZwJoPRSmBGV69uwQwdotVcGYC2AMUjLnS48PYiXq\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockV2Aggregator.sol\":{\"keccak256\":\"0x36923274b53280eaf631df1ded24d01f450a3486bf110ea300831885929bf5f7\",\"urls\":[\"bzz-raw://f8508e1613eccd4bf21b817d7c7765dd90d08f28b62cf210e55ee8bb12156810\",\"dweb:/ipfs/QmXqUD7dgiLrMDatMuXTjXQrs786MAgByth1MAYtfWn387\"]}},\"version\":1}",
"userdoc":{
"methods":{},
"notice":"Based on the HistoricAggregator contractUse this contract when you need to test other contract's ability to read data from an aggregator contract, but how the aggregator got its answer is unimportant"
}
},
"sources":{
"tests/MockV2Aggregator.sol":{
"id":54
},
"interfaces/AggregatorInterface.sol":{
"id":28
}
},
"sourceCodes":{
"tests/MockV2Aggregator.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"../interfaces/AggregatorInterface.sol\";\n\n/**\n * @title MockV2Aggregator\n * @notice Based on the HistoricAggregator contract\n * @notice Use this contract when you need to test\n * other contract's ability to read data from an\n * aggregator contract, but how the aggregator got\n * its answer is unimportant\n */\ncontract MockV2Aggregator is AggregatorInterface {\n int256 public override latestAnswer;\n uint256 public override latestTimestamp;\n uint256 public override latestRound;\n\n mapping(uint256 => int256) public override getAnswer;\n mapping(uint256 => uint256) public override getTimestamp;\n mapping(uint256 => uint256) private getStartedAt;\n\n constructor(\n int256 _initialAnswer\n ) public {\n updateAnswer(_initialAnswer);\n }\n\n function updateAnswer(\n int256 _answer\n ) public {\n latestAnswer = _answer;\n latestTimestamp = block.timestamp;\n latestRound++;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = block.timestamp;\n }\n\n function updateRoundData(\n uint256 _roundId,\n int256 _answer,\n uint256 _timestamp,\n uint256 _startedAt\n ) public {\n latestRound = _roundId;\n latestAnswer = _answer;\n latestTimestamp = _timestamp;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = _timestamp;\n getStartedAt[latestRound] = _startedAt;\n }\n}\n",
"metadata":"{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_decimals\",\"type\":\"uint8\"},{\"internalType\":\"int256\",\"name\":\"_initialAnswer\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"int256\",\"name\":\"current\",\"type\":\"int256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"roundId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"}],\"name\":\"AnswerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"roundId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"startedBy\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"}],\"name\":\"NewRound\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"description\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"getAnswer\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint80\",\"name\":\"_roundId\",\"type\":\"uint80\"}],\"name\":\"getRoundData\",\"outputs\":[{\"internalType\":\"uint80\",\"name\":\"roundId\",\"type\":\"uint80\"},{\"internalType\":\"int256\",\"name\":\"answer\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint80\",\"name\":\"answeredInRound\",\"type\":\"uint80\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"getTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestAnswer\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestRound\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestRoundData\",\"outputs\":[{\"internalType\":\"uint80\",\"name\":\"roundId\",\"type\":\"uint80\"},{\"internalType\":\"int256\",\"name\":\"answer\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint80\",\"name\":\"answeredInRound\",\"type\":\"uint80\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"_answer\",\"type\":\"int256\"}],\"name\":\"updateAnswer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint80\",\"name\":\"_roundId\",\"type\":\"uint80\"},{\"internalType\":\"int256\",\"name\":\"_answer\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"_timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_startedAt\",\"type\":\"uint256\"}],\"name\":\"updateRoundData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{},\"title\":\"MockV3Aggregator\"},\"userdoc\":{\"methods\":{},\"notice\":\"Based on the FluxAggregator contractUse this contract when you need to test other contract's ability to read data from an aggregator contract, but how the aggregator got its answer is unimportant\"}},\"settings\":{\"compilationTarget\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockV3Aggregator.sol\":\"MockV3Aggregator\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol\":{\"keccak256\":\"0xbd2b9524ed06f150fefaf4ea600fa8b426d644f17c9f7ddd6d793c19557c23ca\",\"urls\":[\"bzz-raw://32e224693884f94929ab3128a1f780c517c8c294634f7f0ef56b411131fa9858\",\"dweb:/ipfs/QmYC99ZwJoPRSmBGV69uwQwdotVcGYC2AMUjLnS48PYiXq\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol\":{\"keccak256\":\"0xb2e32f1292bd9c3bc2f4823ae6457bb81a6497138a9bf454c46dae73553097d4\",\"urls\":[\"bzz-raw://7c43cffc680e119f38fa16950d57c29705f6351522fa0a2f3ac20cc0bfa5416c\",\"dweb:/ipfs/QmZtPBiuFkZfoCSx2M98HHbmCSY12VFHKZdtwFN1K1R5qD\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol\":{\"keccak256\":\"0x1862840d741dedb36e774534b877a13b5187555e3b78b8d2815f898b0dc02268\",\"urls\":[\"bzz-raw://64a15f4349aea6e60703f581a6280b71d6adb35ee74d2f3c4f130a2adc3efee3\",\"dweb:/ipfs/QmdVoSQvGfJNPnjQsAs7ZN3ueWghzTa72jSqzhGiQNDpkL\"]},\"/home/thomas/workspace/chainlink/evm-contracts/src/v0.6/tests/MockV3Aggregator.sol\":{\"keccak256\":\"0x4cc3414cc680d73629043e68ddd298ef79a32775de0d6753b475e97567a28919\",\"urls\":[\"bzz-raw://22e76b1bb0e786a0db542f451092486562876c75d2b7ef897aada76940e65cef\",\"dweb:/ipfs/QmPEspBKftJtA1e3Z3KTrrrLeXS6obCdksE9RWMMoqvweS\"]}},\"version\":1}",
"userdoc":{
"methods":{},
"notice":"Based on the FluxAggregator contractUse this contract when you need to test other contract's ability to read data from an aggregator contract, but how the aggregator got its answer is unimportant"
}
},
"sources":{
"tests/MockV3Aggregator.sol":{
"id":55
},
"interfaces/AggregatorV2V3Interface.sol":{
"id":29
},
"interfaces/AggregatorInterface.sol":{
"id":28
},
"interfaces/AggregatorV3Interface.sol":{
"id":30
}
},
"sourceCodes":{
"tests/MockV3Aggregator.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"../interfaces/AggregatorV2V3Interface.sol\";\n\n/**\n * @title MockV3Aggregator\n * @notice Based on the FluxAggregator contract\n * @notice Use this contract when you need to test\n * other contract's ability to read data from an\n * aggregator contract, but how the aggregator got\n * its answer is unimportant\n */\ncontract MockV3Aggregator is AggregatorV2V3Interface {\n uint256 constant public override version = 0;\n\n uint8 public override decimals;\n int256 public override latestAnswer;\n uint256 public override latestTimestamp;\n uint256 public override latestRound;\n\n mapping(uint256 => int256) public override getAnswer;\n mapping(uint256 => uint256) public override getTimestamp;\n mapping(uint256 => uint256) private getStartedAt;\n\n constructor(\n uint8 _decimals,\n int256 _initialAnswer\n ) public {\n decimals = _decimals;\n updateAnswer(_initialAnswer);\n }\n\n function updateAnswer(\n int256 _answer\n ) public {\n latestAnswer = _answer;\n latestTimestamp = block.timestamp;\n latestRound++;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = block.timestamp;\n getStartedAt[latestRound] = block.timestamp;\n }\n\n function updateRoundData(\n uint80 _roundId,\n int256 _answer,\n uint256 _timestamp,\n uint256 _startedAt\n ) public {\n latestRound = _roundId;\n latestAnswer = _answer;\n latestTimestamp = _timestamp;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = _timestamp;\n getStartedAt[latestRound] = _startedAt;\n }\n\n function getRoundData(uint80 _roundId)\n external\n view\n override\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n )\n {\n return (\n _roundId,\n getAnswer[_roundId],\n getStartedAt[_roundId],\n getTimestamp[_roundId],\n _roundId\n );\n }\n\n function latestRoundData()\n external\n view\n override\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n )\n {\n return (\n uint80(latestRound),\n getAnswer[latestRound],\n getStartedAt[latestRound],\n getTimestamp[latestRound],\n uint80(latestRound)\n );\n }\n\n function description()\n external\n view\n override\n returns (string memory)\n {\n return \"v0.6/tests/MockV3Aggregator.sol\";\n }\n}\n",
"interfaces/AggregatorV3Interface.sol":"// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0;\n\ninterface AggregatorV3Interface {\n\n function decimals() external view returns (uint8);\n function description() external view returns (string memory);\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n}\n"
"tests/MultiWordConsumer.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"../ChainlinkClient.sol\";\n\ncontract MultiWordConsumer is ChainlinkClient{\n bytes32 internal specId;\n bytes public currentPrice;\n\n bytes32 public first;\n bytes32 public second;\n\n event RequestFulfilled(\n bytes32 indexed requestId, // User-defined ID\n bytes indexed price\n );\n\n event RequestMultipleFulfilled(\n bytes32 indexed requestId,\n bytes32 indexed first,\n bytes32 indexed second\n );\n\n constructor(address _link, address _oracle, bytes32 _specId) public {\n setChainlinkToken(_link);\n setChainlinkOracle(_oracle);\n specId = _specId;\n }\n\n function requestEthereumPrice(string memory _currency, uint256 _payment) public {\n requestEthereumPriceByCallback(_currency, _payment, address(this));\n }\n\n function requestEthereumPriceByCallback(string memory _currency, uint256 _payment, address _callback) public {\n Chainlink.Request memory req = buildChainlinkRequest(specId, _callback, this.fulfillBytes.selector);\n req.add(\"get\", \"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR,JPY\");\n string[] memory path = new string[](1);\n path[0] = _currency;\n req.addStringArray(\"path\", path);\n sendChainlinkRequest(req, _payment);\n }\n\n function requestMultipleParameters(string memory _currency, uint256 _payment) public {\n Chainlink.Request memory req = buildChainlinkRequest(specId, address(this), this.fulfillMultipleParameters.selector);\n req.add(\"get\", \"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR,JPY\");\n string[] memory path = new string[](1);\n path[0] = _currency;\n req.addStringArray(\"path\", path);\n sendChainlinkRequest(req, _payment);\n }\n\n function cancelRequest(\n address _oracle,\n bytes32 _requestId,\n uint256 _payment,\n bytes4 _callbackFunctionId,\n uint256 _expiration\n ) public {\n ChainlinkRequestInterface requested = ChainlinkRequestInterface(_oracle);\n requested.cancelOracleRequest(_requestId, _payment, _callbackFunctionId, _expiration);\n }\n\n function withdrawLink() public {\n LinkTokenInterface _link = LinkTokenInterface(chainlinkTokenAddress());\n require(_link.transfer(msg.sender, _link.balanceOf(address(this))), \"Unable to transfer\");\n }\n\n function addExternalRequest(address _oracle, bytes32 _requestId) external {\n addChainlinkExternalRequest(_oracle, _requestId);\n }\n\n function fulfillMultipleParameters(bytes32 _requestId, bytes32 _first, bytes32 _second)\n public\n recordChainlinkFulfillment(_requestId)\n {\n emit RequestMultipleFulfilled(_requestId, _first, _second);\n first = _first;\n second = _second;\n }\n\n function fulfillBytes(bytes32 _requestId, bytes memory _price)\n public\n recordChainlinkFulfillment(_requestId)\n {\n emit RequestFulfilled(_requestId, _price);\n currentPrice = _price;\n }\n}",
"ChainlinkClient.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport \"./Chainlink.sol\";\nimport \"./interfaces/ENSInterface.sol\";\nimport \"./interfaces/LinkTokenInterface.sol\";\nimport \"./interfaces/ChainlinkRequestInterface.sol\";\nimport \"./interfaces/PointerInterface.sol\";\nimport { ENSResolver as ENSResolver_Chainlink } from \"./vendor/ENSResolver.sol\";\n\n/**\n * @title The ChainlinkClient contract\n * @notice Contract writers can inherit this contract in order to create requests for the\n * Chainlink network\n */\ncontract ChainlinkClient {\n using Chainlink for Chainlink.Request;\n\n uint256 constant internal LINK = 10**18;\n uint256 constant private AMOUNT_OVERRIDE = 0;\n address constant private SENDER_OVERRIDE = address(0);\n uint256 constant private ARGS_VERSION = 1;\n bytes32 constant private ENS_TOKEN_SUBNAME = keccak256(\"link\");\n bytes32 constant private ENS_ORACLE_SUBNAME = keccak256(\"oracle\");\n address constant private LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571;\n\n ENSInterface private ens;\n bytes32 private ensNode;\n LinkTokenInterface private link;\n ChainlinkRequestInterface private oracle;\n uint256 private requestCount = 1;\n mapping(bytes32 => address) private pendingRequests;\n\n event ChainlinkRequested(bytes32 indexed id);\n event ChainlinkFulfilled(bytes32 indexed id);\n event ChainlinkCancelled(bytes32 indexed id);\n\n /**\n * @notice Creates a request that can hold additional parameters\n * @param _specId The Job Specification ID that the request will be created for\n * @param _callbackAddress The callback address that the response will be sent to\n * @param _callbackFunctionSignature The callback function signature to use for the callback address\n * @return A Chainlink Request struct in memory\n */\n function buildChainlinkRequest(\n bytes32 _specId,\n address _callbackAddress,\n bytes4 _callbackFunctionSignature\n ) internal pure returns (Chainlink.Request memory) {\n Chainlink.Request memory req;\n return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature);\n }\n\n /**\n * @notice Creates a Chainlink request to the stored oracle address\n * @dev Calls `chainlinkRequestTo` with the stored oracle address\n * @param _req The initialized Chainlink Request\n * @param _payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequest(Chainlink.Request memory _req, uint256 _payment)\n internal\n returns (bytes32)\n {\n return sendChainlinkRequestTo(address(oracle), _req, _payment);\n }\n\n /**\n * @notice Creates a Chainlink request to the specified oracle address\n * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to\n * send LINK which creates a request on the target oracle contract.\n * Emits ChainlinkRequested event.\n * @param _oracle The address of the oracle for the request\n * @param _req The initialized Chainlink Request\n * @param _payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequestTo(address _oracle, Chainlink.Request memory _req, uint256 _payment)\n internal\n returns (bytes32 requestId)\n {\n requestId = keccak256(abi.encodePacked(this, requestCount));\n _req.nonce = requestCount;\n pendingRequests[requestId] = _oracle;\n emit ChainlinkRequested(requestId);\n require(link.transferAndCall(_oracle, _payment, encodeRequest(_req)), \"unable to transferAndCall to oracle\");\n requestCount += 1;\n\n return requestId;\n }\n\n /**\n * @notice Allows a request to be cancelled if it has not been fulfilled\n * @dev Requires keeping track of the expiration value emitted from the oracle contract.\n * Deletes the request from the `pendingRequests` mapping.\n * Emits ChainlinkCancelled event.\n * @param _requestId The request ID\n * @param _payment The amount of LINK sent for the request\n * @param _callbackFunc The callback function specified for the request\n * @param _expiration The time of the expiration for the request\n */\n function cancelChainlinkRequest(\n bytes32 _requestId,\n uint256 _payment,\n bytes4 _callbackFunc,\n uint256 _expiration\n )\n internal\n {\n ChainlinkRequestInterface requested = ChainlinkRequestInterface(pendingRequests[_requestId]);\n delete pendingRequests[_requestId];\n emit ChainlinkCancelled(_requestId);\n requested.cancelOracleRequest(_requestId, _payment, _callbackFunc, _expiration);\n }\n\n /**\n * @notice Sets the stored oracle address\n * @param _oracle The address of the oracle contract\n */\n function setChainlinkOracle(address _oracle) internal {\n oracle = ChainlinkRequestInterface(_oracle);\n }\n\n /**\n * @notice Sets the LINK token address\n * @param _link The address of the LINK token contract\n */\n function setChainlinkToken(address _link) internal {\n link = LinkTokenInterface(_link);\n }\n\n /**\n * @notice Sets the Chainlink token address for the public\n * network as given by the Pointer contract\n */\n function setPublicChainlinkToken() internal {\n setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress());\n }\n\n /**\n * @notice Retrieves the stored address of the LINK token\n * @return The address of the LINK token\n */\n function chainlinkTokenAddress()\n internal\n view\n returns (address)\n {\n return address(link);\n }\n\n /**\n * @notice Retrieves the stored address of the oracle contract\n * @return The address of the oracle contract\n */\n function chainlinkOracleAddress()\n internal\n view\n returns (address)\n {\n return address(oracle);\n }\n\n /**\n * @notice Allows for a request which was created on another contract to be fulfilled\n * on this contract\n * @param _oracle The address of the oracle contract that will fulfill the request\n * @param _requestId The request ID used for the response\n */\n function addChainlinkExternalRequest(address _oracle, bytes32 _requestId)\n internal\n notPendingRequest(_requestId)\n {\n pendingRequests[_requestId] = _oracle;\n }\n\n /**\n * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS\n * @dev Accounts for subnodes having different resolvers\n * @param _ens The address of the ENS contract\n * @param _node The ENS node hash\n */\n function useChainlinkWithENS(address _ens, bytes32 _node)\n internal\n {\n ens = ENSInterface(_ens);\n ensNode = _node;\n bytes32 linkSubnode = keccak256(abi.encodePacked(ensNode, ENS_TOKEN_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(linkSubnode));\n setChainlinkToken(resolver.addr(linkSubnode));\n updateChainlinkOracleWithENS();\n }\n\n /**\n * @notice Sets the stored oracle contract with the address resolved by ENS\n * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously\n */\n function updateChainlinkOracleWithENS()\n internal\n {\n bytes32 oracleSubnode = keccak256(abi.encodePacked(ensNode, ENS_ORACLE_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(oracleSubnode));\n setChainlinkOracle(resolver.addr(oracleSubnode));\n }\n\n /**\n * @notice Encodes the request to be sent to the oracle contract\n * @dev The Chainlink node expects values to be in order for the request to be picked up. Order of types\n * will be validated in the oracle contract.\n * @param _req The initialized Chainlink Request\n * @return The bytes payload for the `transferAndCall` method\n */\n function encodeRequest(Chainlink.Request memory _req)\n private\n view\n returns (bytes memory)\n {\n return abi.encodeWithSelector(\n oracle.oracleRequest.selector,\n SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address\n AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent\n _req.id,\n _req.callbackAddress,\n _req.callbackFunctionId,\n _req.nonce,\n ARGS_VERSION,\n _req.buf.buf);\n }\n\n /**\n * @notice Ensures that the fulfillment is valid for this contract\n * @dev Use if the contract developer prefers methods instead of modifiers for validation\n * @param _requestId The request ID for fulfillment\n */\n function validateChainlinkCallback(bytes32 _requestId)\n internal\n recordChainlinkFulfillment(_requestId)\n // solhint-disable-next-line no-empty-blocks\n {}\n\n /**\n * @dev Reverts if the sender is not the oracle of the request.\n * Emits ChainlinkFulfilled event.\n * @param _requestId The request ID for fulfillment\n */\n modifier recordChainlinkFulfillment(bytes32 _requestId) {\n require(msg.sender == pendingRequests[_requestId],\n\"Source must be the oracle of the request\");\n delete pendingRequests[_requestId];\n emit ChainlinkFulfilled(_requestId);\n _;\n }\n\n /**\n * @dev Reverts if the request is already pending\n * @param _requestId The request ID for fulfillment\n */\n modifier notPendingRequest(bytes32 _requestId) {\n require(pendingRequests[_requestId] == address(0), \"Request is already pending\");\n _;\n }\n}\n",
"Chainlink.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport { CBORChainlink } from \"./vendor/CBORChainlink.sol\";\nimport { BufferChainlink } from \"./vendor/BufferChainlink.sol\";\n\n/**\n * @title Library for common Chainlink functions\n * @dev Uses imported CBOR library for encoding to buffer\n */\nlibrary Chainlink {\n uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase\n\n using CBORChainlink for BufferChainlink.buffer;\n\n struct Request {\n bytes32 id;\n address callbackAddress;\n bytes4 callbackFunctionId;\n uint256 nonce;\n BufferChainlink.buffer buf;\n }\n\n /**\n * @notice Initializes a Chainlink request\n * @dev Sets the ID, callback address, and callback function signature on the request\n * @param self The uninitialized request\n * @param _id The Job Specification ID\n * @param _callbackAddress The callback address\n * @param _callbackFunction The callback function signature\n * @return The initialized request\n */\n function initialize(\n Request memory self,\n bytes32 _id,\n address _callbackAddress,\n bytes4 _callbackFunction\n ) internal pure returns (Chainlink.Request memory) {\n BufferChainlink.init(self.buf, defaultBufferSize);\n self.id = _id;\n self.callbackAddress = _callbackAddress;\n self.callbackFunctionId = _callbackFunction;\n return self;\n }\n\n /**\n * @notice Sets the data for the buffer without encoding CBOR on-chain\n * @dev CBOR can be closed with curly-brackets {} or they can be left off\n * @param self The initialized request\n * @param _data The CBOR data\n */\n function setBuffer(Request memory self, bytes memory _data)\n internal pure\n {\n BufferChainlink.init(self.buf, _data.length);\n BufferChainlink.append(self.buf, _data);\n }\n\n /**\n * @notice Adds a string value to the request with a given key name\n * @param self The initialized request\n * @param _key The name of the key\n * @param _value The string value to add\n */\n function add(Request memory self, string memory _key, string memory _value)\n internal pure\n {\n self.buf.encodeString(_key);\n self.buf.encodeString(_value);\n }\n\n /**\n * @notice Adds a bytes value to the request with a given key name\n * @param self The initialized request\n * @param _key The name of the key\n * @param _value The bytes value to add\n */\n function addBytes(Request memory self, string memory _key, bytes memory _value)\n internal pure\n {\n self.buf.encodeString(_key);\n self.buf.encodeBytes(_value);\n }\n\n /**\n * @notice Adds a int256 value to the request with a given key name\n * @param self The initialized request\n * @param _key The name of the key\n * @param _value The int256 value to add\n */\n function addInt(Request memory self, string memory _key, int256 _value)\n internal pure\n {\n self.buf.encodeString(_key);\n self.buf.encodeInt(_value);\n }\n\n /**\n * @notice Adds a uint256 value to the request with a given key name\n * @param self The initialized request\n * @param _key The name of the key\n * @param _value The uint256 value to add\n */\n function addUint(Request memory self, string memory _key, uint256 _value)\n internal pure\n {\n self.buf.encodeString(_key);\n self.buf.encodeUInt(_value);\n }\n\n /**\n * @notice Adds an array of strings to the request with a given key name\n * @param self The initialized request\n * @param _key The name of the key\n * @param _values The array of string values to add\n */\n function addStringArray(Request memory self, string memory _key, string[] memory _values)\n internal pure\n {\n self.buf.encodeString(_key);\n self.buf.startArray();\n for (uint256 i = 0; i < _values.length; i++) {\n self.buf.encodeString(_values[i]);\n }\n self.buf.endSequence();\n }\n}\n",
"vendor/BufferChainlink.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\n/**\n* @dev A library for working with mutable byte buffers in Solidity.\n*\n* Byte buffers are mutable and expandable, and provide a variety of primitives\n* for writing to them. At any time you can fetch a bytes object containing the\n* current contents of the buffer. The bytes object should not be stored between\n* operations, as it may change due to resizing of the buffer.\n*/\nlibrary BufferChainlink {\n /**\n * @dev Represents a mutable buffer. Buffers have a current value (buf) and\n * a capacity. The capacity may be longer than the current value, in\n * which case it can be extended without the need to allocate more memory.\n */\n struct buffer {\n bytes buf;\n uint capacity;\n }\n\n /**\n * @dev Initializes a buffer with an initial capacity.\n * @param buf The buffer to initialize.\n * @param capacity The number of bytes of space to allocate the buffer.\n * @return The buffer, for chaining.\n */\n function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {\n if (capacity % 32 != 0) {\n capacity += 32 - (capacity % 32);\n }\n // Allocate space for the buffer data\n buf.capacity = capacity;\n assembly {\n let ptr := mload(0x40)\n mstore(buf, ptr)\n mstore(ptr, 0)\n mstore(0x40, add(32, add(ptr, capacity)))\n }\n return buf;\n }\n\n /**\n * @dev Initializes a new buffer from an existing bytes object.\n * Changes to the buffer may mutate the original value.\n * @param b The bytes object to initialize the buffer with.\n * @return A new buffer.\n */\n function fromBytes(bytes memory b) internal pure returns(buffer memory) {\n buffer memory buf;\n buf.buf = b;\n buf.capacity = b.length;\n return buf;\n }\n\n function resize(buffer memory buf, uint capacity) private pure {\n bytes memory oldbuf = buf.buf;\n init(buf, capacity);\n append(buf, oldbuf);\n }\n\n function max(uint a, uint b) private pure returns(uint) {\n if (a > b) {\n return a;\n }\n return b;\n }\n\n /**\n * @dev Sets buffer length to 0.\n * @param buf The buffer to truncate.\n * @return The original buffer, for chaining..\n */\n function truncate(buffer memory buf) internal pure returns (buffer memory) {\n assembly {\n let bufptr := mload(buf)\n mstore(bufptr, 0)\n }\n return buf;\n }\n\n /**\n * @dev Writes a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The start offset to write to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function write(buffer memory buf, uint off, bytes memory data, uint len) internal pure returns(buffer memory) {\n require(len <= data.length);\n\n if (off + len > buf.capacity) {\n resize(buf, max(buf.capacity, len + off) * 2);\n }\n\n uint dest;\n uint src;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Start address = buffer address + offset + sizeof(buffer length)\n dest := add(add(bufptr, 32), off)\n // Update buffer length if we're extending it\n if gt(add(len, off), buflen) {\n mstore(bufptr, add(len, off))\n }\n src := add(data, 32)\n }\n\n // Copy word-length chunks while possible\n for (; len >= 32; len -= 32) {\n assembly {\n mstore(dest, mload(src))\n }\n dest += 32;\n src += 32;\n }\n\n // Copy remaining bytes\n uint mask = 256 ** (32 - len) - 1;\n assembly {\n let srcpart := and(mload(src), not(mask))\n let destpart := and(mload(dest), mask)\n mstore(dest, or(destpart, srcpart))\n }\n\n return buf;\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data, uint len) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, len);\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, data.length);\n }\n\n /**\n * @dev Writes a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write the byte at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeUint8(buffer memory buf, uint off, uint8 data) internal pure returns(buffer memory) {\n if (off >= buf.capacity) {\n resize(buf, buf.capacity * 2);\n }\n\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Address = buffer address + sizeof(buffer length) + off\n let dest := add(add(bufptr, off), 32)\n mstore8(dest, data)\n // Update buffer length if we extended it\n if eq(off, buflen) {\n mstore(bufptr, add(buflen, 1))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) {\n return writeUint8(buf, buf.buf.length, data);\n }\n\n /**\n * @dev Writes up to 32 bytes to the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (left-aligned).\n * @return The original buffer, for chaining.\n */\n function write(buffer memory buf, uint off, bytes32 data, uint len) private pure returns(buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n uint mask = 256 ** len - 1;\n // Right-align data\n data = data >> (8 * (32 - len));\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + off + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n return buf;\n }\n\n /**\n * @dev Writes a bytes20 to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeBytes20(buffer memory buf, uint off, bytes20 data) internal pure returns (buffer memory) {\n return write(buf, off, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chhaining.\n */\n function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, 32);\n }\n\n /**\n * @dev Writes an integer to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (right-aligned).\n * @return The original buffer, for chaining.\n */\n function writeInt(buffer memory buf, uint off, uint data, uint len) private pure returns(buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n uint mask = 256 ** len - 1;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + off + sizeof(buffer length) + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the end of the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer.\n */\n function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) {\n return writeInt(buf, buf.buf.length, data, len);\n }\n}\n",
"interfaces/ENSInterface.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\ninterface ENSInterface {\n\n // Logged when the owner of a node assigns a new owner to a subnode.\n event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);\n\n // Logged when the owner of a node transfers ownership to a new account.\n event Transfer(bytes32 indexed node, address owner);\n\n // Logged when the resolver for a node changes.\n event NewResolver(bytes32 indexed node, address resolver);\n\n // Logged when the TTL of a node changes\n event NewTTL(bytes32 indexed node, uint64 ttl);\n\n\n function setSubnodeOwner(bytes32 node, bytes32 label, address _owner) external;\n function setResolver(bytes32 node, address _resolver) external;\n function setOwner(bytes32 node, address _owner) external;\n function setTTL(bytes32 node, uint64 _ttl) external;\n function owner(bytes32 node) external view returns (address);\n function resolver(bytes32 node) external view returns (address);\n function ttl(bytes32 node) external view returns (uint64);\n\n}\n",
"interfaces/LinkTokenInterface.sol":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\ninterface LinkTokenInterface {\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n function approve(address spender, uint256 value) external returns (bool success);\n function balanceOf(address owner) external view returns (uint256 balance);\n function decimals() external view returns (uint8 decimalPlaces);\n function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);\n function increaseApproval(address spender, uint256 subtractedValue) external;\n function name() external view returns (string memory tokenName);\n function symbol() external view returns (string memory tokenSymbol);\n function totalSupply() external view returns (uint256 totalTokensIssued);\n function transfer(address to, uint256 value) external returns (bool success);\n function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);\n function transferFrom(address from, address to, uint256 value) external returns (bool success);\n}\n",