feat: expand non-evm relay and route planning support
This commit is contained in:
23
contracts/vendor/uniswap-v2-core/libraries/Math.sol
vendored
Normal file
23
contracts/vendor/uniswap-v2-core/libraries/Math.sol
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
pragma solidity =0.5.16;
|
||||
|
||||
// a library for performing various math operations
|
||||
|
||||
library Math {
|
||||
function min(uint x, uint y) internal pure returns (uint z) {
|
||||
z = x < y ? x : y;
|
||||
}
|
||||
|
||||
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
|
||||
function sqrt(uint y) internal pure returns (uint z) {
|
||||
if (y > 3) {
|
||||
z = y;
|
||||
uint x = y / 2 + 1;
|
||||
while (x < z) {
|
||||
z = x;
|
||||
x = (y / x + x) / 2;
|
||||
}
|
||||
} else if (y != 0) {
|
||||
z = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
contracts/vendor/uniswap-v2-core/libraries/SafeMath.sol
vendored
Normal file
17
contracts/vendor/uniswap-v2-core/libraries/SafeMath.sol
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
pragma solidity =0.5.16;
|
||||
|
||||
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
|
||||
|
||||
library SafeMath {
|
||||
function add(uint x, uint y) internal pure returns (uint z) {
|
||||
require((z = x + y) >= x, 'ds-math-add-overflow');
|
||||
}
|
||||
|
||||
function sub(uint x, uint y) internal pure returns (uint z) {
|
||||
require((z = x - y) <= x, 'ds-math-sub-underflow');
|
||||
}
|
||||
|
||||
function mul(uint x, uint y) internal pure returns (uint z) {
|
||||
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
|
||||
}
|
||||
}
|
||||
20
contracts/vendor/uniswap-v2-core/libraries/UQ112x112.sol
vendored
Normal file
20
contracts/vendor/uniswap-v2-core/libraries/UQ112x112.sol
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
pragma solidity =0.5.16;
|
||||
|
||||
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
|
||||
|
||||
// range: [0, 2**112 - 1]
|
||||
// resolution: 1 / 2**112
|
||||
|
||||
library UQ112x112 {
|
||||
uint224 constant Q112 = 2**112;
|
||||
|
||||
// encode a uint112 as a UQ112x112
|
||||
function encode(uint112 y) internal pure returns (uint224 z) {
|
||||
z = uint224(y) * Q112; // never overflows
|
||||
}
|
||||
|
||||
// divide a UQ112x112 by a uint112, returning a UQ112x112
|
||||
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
|
||||
z = x / uint224(y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user