Verified contractPartialMIT
Trig256
Address0x9905c8152a46fddd62e935cf496dbff3b65124d8
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,550,100
- Creation transaction
- 0xa0b17d2062…88f50d10e4
4 files
- src/Trig256.solmain23.96 KB
- src/Errors.sol1.37 KB
- src/Fix64.sol13.15 KB
- src/SinLut256.sol20.7 KB
src/Trig256.sol
// SPDX-License-Identifier: MIT
/* Copyright (c) Kohi Art Community, Inc. All rights reserved. */
/*
/*
///////////////////////////////////////////////////////////////////////////////////
// //
// @@@@@@@@@@@@@@ @@@@ //
// @@@@ @@@@ @@@@@@@@ //
// @@@@ @@@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@@@@@@ //
// @@@@ @@@@ //
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@ //
// @@@@ @@@@@@@@@@@ //
// //
///////////////////////////////////////////////////////////////////////////////////
*/
pragma solidity ^0.8.13;
import "./Fix64.sol";
import "./SinLut256.sol";
/*
Trig256: trigonometric, logarithmic, and exponential functions over the
Fix64 Q31.32 fixed-point format. sin/cos are computed via range reduction
plus a 256-entry lookup table with linear interpolation (see SinLut256.sol);
log2/log/exp use the power-series and binary-logarithm algorithms below;
acos/atan/atan2 are series approximations adapted from FixedMath.NET.
exp: Adapted from Petteri Aimonen's libfixmath
See: https://github.com/PetteriAimonen/libfixmath
https://github.com/PetteriAimonen/libfixmath/blob/master/LICENSE
other functions: Adapted from Andre Slupik's FixedMath.NET
https://github.com/asik/FixedMath.Net/blob/master/LICENSE.txt
THIRD PARTY NOTICES:
====================
libfixmath is Copyright (c) 2011-2021 Flatmush <[email protected]>,
Petteri Aimonen <[email protected]>, & libfixmath AUTHORS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright 2012 André Slupik
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This project uses code from the log2fix library, which is under the following license:
The MIT License (MIT)
Copyright (c) 2015 Dan Moulding
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
/*
sin/cos/sqrt/clamp bodies below run inside `unchecked` blocks so
int64/uint64 arithmetic wraps on overflow, matching the original
reference implementation. See Fix64.sol for the same convention.
*/
/// @notice Trigonometric, logarithmic, and exponential functions over Fix64.
library Trig256 {
int64 private constant LARGE_PI = 7244019458077122842;
/// @dev ln(2) in Q31.32, used to convert log2() results to natural log.
int64 private constant LN2 = 0xB17217F7;
/// @dev Largest input to exp() that does not saturate the Q31.32 range.
int64 private constant LN_MAX = 0x157CD0E702;
/// @dev Smallest input to exp() before the result underflows to zero.
int64 private constant LN_MIN = -0x162E42FEFA;
/// @dev The value exp() returns as a fast-path shortcut for x == ONE,
/// preserved bit-for-bit from the reference implementation.
int64 private constant E = -0x2B7E15162;
// Fix64.div((256 - 1) * Fix64.ONE, Fix64.PI_OVER_2), precomputed: the
// long-division routine is far too expensive to rerun per sin() call.
int64 private constant LUT_INTERVAL = 697236581115;
/// @notice Sine of x, computed via range reduction into [0, PI/2] and a
/// 256-entry lookup table with linear interpolation between entries.
/// @param x Angle in radians, Q31.32.
/// @return Sine of x, Q31.32, in [-ONE, ONE].
function sin(int64 x) internal pure returns (int64) {
unchecked {
(int64 clamped, bool flipHorizontal, bool flipVertical) = clamp(x);
int64 lutInterval = LUT_INTERVAL;
int256 rawIndex = Fix64.mul_256(clamped, lutInterval);
int64 roundedIndex = int64(Fix64.round(rawIndex));
int64 indexError = Fix64.sub(int64(rawIndex), roundedIndex);
roundedIndex = roundedIndex >> 32; /* FRACTIONAL_PLACES */
int64 nearestValueIndex = flipHorizontal
? (256 - 1) - roundedIndex
: roundedIndex;
int64 nearestValue = SinLut256.sinlut(nearestValueIndex);
int64 secondNearestValue = SinLut256.sinlut(
flipHorizontal
? (256 - 1) - roundedIndex - Fix64.sign(indexError)
: roundedIndex + Fix64.sign(indexError)
);
int64 delta = Fix64.mul(
indexError,
Fix64.abs(Fix64.sub(nearestValue, secondNearestValue))
);
int64 interpolatedValue = nearestValue +
(flipHorizontal ? -delta : delta);
int64 finalValue = flipVertical
? -interpolatedValue
: interpolatedValue;
return finalValue;
}
}
/// @notice Cosine of x, via a phase shift into sin().
/// @param x Angle in radians, Q31.32.
/// @return Cosine of x, Q31.32, in [-ONE, ONE].
function cos(int64 x) internal pure returns (int64) {
unchecked {
int64 xl = x;
int64 angle;
if (xl > 0) {
angle = Fix64.add(xl, Fix64.sub(0 - Fix64.PI, Fix64.PI_OVER_2));
} else {
angle = Fix64.add(xl, Fix64.PI_OVER_2);
}
return sin(angle);
}
}
/*
* sin/cos against a memory-resident copy of the SinLut256 table (see
* SinLut256.table()), for callers that cannot afford the ~2.6 KB inlined
* selection tree that sinlut(int256) compiles to, e.g. contracts close to
* the EIP-170 runtime size limit. Statement-for-statement identical to
* sin(x)/cos(x) above; only the LUT access differs, and results are
* bit-identical. If you change one variant, mirror the other.
*/
/// @notice Sine of x, reading the sine table from memory at lutPtr instead
/// of the inlined selection tree (see SinLut256.table()).
/// @param x Angle in radians, Q31.32.
/// @param lutPtr Pointer to a 256*8-byte, big-endian copy of the sine table.
/// @return Sine of x, Q31.32, bit-identical to sin(x).
function sin(int64 x, uint256 lutPtr) internal pure returns (int64) {
unchecked {
(int64 clamped, bool flipHorizontal, bool flipVertical) = clamp(x);
int64 lutInterval = LUT_INTERVAL;
int256 rawIndex = Fix64.mul_256(clamped, lutInterval);
int64 roundedIndex = int64(Fix64.round(rawIndex));
int64 indexError = Fix64.sub(int64(rawIndex), roundedIndex);
roundedIndex = roundedIndex >> 32; /* FRACTIONAL_PLACES */
int64 nearestValueIndex = flipHorizontal
? (256 - 1) - roundedIndex
: roundedIndex;
int64 nearestValue = SinLut256.sinlut(lutPtr, nearestValueIndex);
int64 secondNearestValue = SinLut256.sinlut(
lutPtr,
flipHorizontal
? (256 - 1) - roundedIndex - Fix64.sign(indexError)
: roundedIndex + Fix64.sign(indexError)
);
int64 delta = Fix64.mul(
indexError,
Fix64.abs(Fix64.sub(nearestValue, secondNearestValue))
);
int64 interpolatedValue = nearestValue +
(flipHorizontal ? -delta : delta);
int64 finalValue = flipVertical
? -interpolatedValue
: interpolatedValue;
return finalValue;
}
}
/// @notice Cosine of x, reading the sine table from memory at lutPtr.
/// @param x Angle in radians, Q31.32.
/// @param lutPtr Pointer to a 256*8-byte, big-endian copy of the sine table.
/// @return Cosine of x, Q31.32, bit-identical to cos(x).
function cos(int64 x, uint256 lutPtr) internal pure returns (int64) {
unchecked {
int64 xl = x;
int64 angle;
if (xl > 0) {
angle = Fix64.add(xl, Fix64.sub(0 - Fix64.PI, Fix64.PI_OVER_2));
} else {
angle = Fix64.add(xl, Fix64.PI_OVER_2);
}
return sin(angle, lutPtr);
}
}
/// @notice Square root of a Q31.32 value.
/// @dev Digit-by-digit binary square root, run twice over the 64-bit
/// word (once per 32-bit half) so the result comes out correctly
/// scaled in Q31.32 rather than needing a separate rescale step.
/// @custom:reverts NegativeValuePassed if x < 0.
function sqrt(int64 x) internal pure returns (int64) {
unchecked {
int64 xl = x;
if (xl < 0) revert NegativeValuePassed();
uint64 num = uint64(xl);
uint64 result = uint64(0);
uint64 bit = uint64(1) << (64 - 2);
while (bit > num) bit >>= 2;
for (uint8 i = 0; i < 2; ++i) {
while (bit != 0) {
if (num >= result + bit) {
num -= result + bit;
result = (result >> 1) + bit;
} else {
result = result >> 1;
}
bit >>= 2;
}
if (i == 0) {
if (num > (uint64(1) << (64 / 2)) - 1) {
num -= result;
num = (num << (64 / 2)) - uint64(0x80000000);
result = (result << (64 / 2)) + uint64(0x80000000);
} else {
num <<= 64 / 2;
result <<= 64 / 2;
}
bit = uint64(1) << (64 / 2 - 2);
}
}
if (num > result) ++result;
return int64(result);
}
}
/// @notice Base-2 logarithm of x, computed at int256 precision.
/// @param x A positive Q31.32 value.
/// @return log2(x) in Q31.32.
/// @custom:reverts NegativeValuePassed if x <= 0.
function log2_256(int256 x) public pure returns (int256) {
if (x <= 0) {
revert NegativeValuePassed();
}
// This implementation is based on Clay. S. Turner's fast binary logarithm
// algorithm (C. S. Turner, "A Fast Binary Logarithm Algorithm", IEEE Signal
// Processing Mag., pp. 124,140, Sep. 2010.)
int256 b = 1 << 31; // FRACTIONAL_PLACES - 1
int256 y = 0;
int256 rawX = x;
while (rawX < Fix64.ONE) {
rawX <<= 1;
y -= Fix64.ONE;
}
while (rawX >= Fix64.ONE << 1) {
rawX >>= 1;
y += Fix64.ONE;
}
int256 z = rawX;
for (uint8 i = 0; i < 32 /* FRACTIONAL_PLACES */; i++) {
z = Fix64.mul_256(z, z);
if (z >= Fix64.ONE << 1) {
z = z >> 1;
y += b;
}
b >>= 1;
}
return y;
}
/// @notice Natural logarithm of x, computed at int256 precision.
/// @param x A positive Q31.32 value.
/// @return ln(x) in Q31.32.
/// @custom:reverts NegativeValuePassed if x <= 0.
function log_256(int256 x) public pure returns (int256) {
return Fix64.mul_256(log2_256(x), LN2);
}
/// @notice Base-2 logarithm of x.
/// @param x A positive Q31.32 value.
/// @return log2(x) in Q31.32.
/// @custom:reverts NegativeValuePassed if x <= 0.
function log2(int64 x) public pure returns (int64) {
if (x <= 0) revert NegativeValuePassed();
// This implementation is based on Clay. S. Turner's fast binary logarithm
// algorithm (C. S. Turner, "A Fast Binary Logarithm Algorithm", IEEE Signal
// Processing Mag., pp. 124,140, Sep. 2010.)
int64 b = 1 << 31; // FRACTIONAL_PLACES - 1
int64 y = 0;
int64 rawX = x;
while (rawX < Fix64.ONE) {
rawX <<= 1;
y -= Fix64.ONE;
}
while (rawX >= Fix64.ONE << 1) {
rawX >>= 1;
y += Fix64.ONE;
}
int64 z = rawX;
for (int32 i = 0; i < Fix64.FRACTIONAL_PLACES; i++) {
z = Fix64.mul(z, z);
if (z >= Fix64.ONE << 1) {
z = z >> 1;
y += b;
}
b >>= 1;
}
return y;
}
/// @notice Natural logarithm of x.
/// @param x A positive Q31.32 value.
/// @return ln(x) in Q31.32.
/// @custom:reverts NegativeValuePassed if x <= 0.
function log(int64 x) public pure returns (int64) {
return Fix64.mul(log2(x), LN2);
}
/// @notice e raised to the power of x.
/// @param x Exponent, Q31.32.
/// @return exp(x) in Q31.32; MAX_VALUE if x is large enough to overflow,
/// 0 if x is small enough to underflow.
function exp(int64 x) public pure returns (int64) {
if (x == 0) return Fix64.ONE;
if (x == Fix64.ONE) return E;
if (x >= LN_MAX) return Fix64.MAX_VALUE;
if (x <= LN_MIN) return 0;
/* The algorithm is based on the power series for exp(x):
* http://en.wikipedia.org/wiki/Exponential_function#Formal_definition
*
* From term n, we get term n+1 by multiplying with x/n.
* When the sum term drops to zero, we can stop summing.
*/
// The power-series converges much faster on positive values
// and exp(-x) = 1/exp(x).
bool neg = (x < 0);
if (neg) x = -x;
int64 result = Fix64.add(int64(x), Fix64.ONE);
int64 term = x;
for (uint32 i = 2; i < 40; i++) {
term = Fix64.mul(x, Fix64.div(term, int32(i) * Fix64.ONE));
result = Fix64.add(result, int64(term));
if (term == 0) break;
}
if (neg) {
result = Fix64.div(Fix64.ONE, result);
}
return result;
}
/*
* Compact cross-contract stubs for this library's cold `public` fns.
* The functions stay public (deployed once in the linked Trig256
* library); these wrappers replace solc's per-site delegatecall stubs
* with one shared staticcall sequence: the callees are pure, so a
* direct staticcall against the library address returns identical
* bytes with none of the generated ABI ceremony. The fixed callees
* always return exactly 32 bytes on success, so returndata length
* needs no validation; failures bubble verbatim.
*/
/// @dev Calls a single-int-argument public function on this library's own
/// deployed code via staticcall, bypassing the ABI-encoded delegatecall
/// stub solc would otherwise generate at each call site.
function _ext1(bytes4 sel, int256 x) private view returns (int256 r) {
address a = address(Trig256);
assembly {
let p := mload(0x40)
mstore(p, sel)
mstore(add(p, 4), x)
if iszero(staticcall(gas(), a, p, 36, p, 32)) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
r := mload(p)
}
}
/// @dev Cross-contract call to log(), see _ext1.
function extLog(int64 x) internal view returns (int64) {
return int64(_ext1(Trig256.log.selector, x));
}
/// @dev Cross-contract call to exp(), see _ext1.
function extExp(int64 x) internal view returns (int64) {
return int64(_ext1(Trig256.exp.selector, x));
}
/// @dev Cross-contract call to acos(), see _ext1.
function extAcos(int64 x) internal view returns (int64) {
return int64(_ext1(Trig256.acos.selector, x));
}
/// @dev Cross-contract call to log_256(), see _ext1.
function extLog256(int256 x) internal view returns (int256) {
return _ext1(Trig256.log_256.selector, x);
}
/// @dev Cross-contract call to atan2(), same staticcall approach as
/// _ext1 but inlined for the two-argument signature.
function extAtan2(int64 y, int64 x) internal view returns (int64 r) {
address a = address(Trig256);
bytes4 sel = Trig256.atan2.selector;
assembly {
let p := mload(0x40)
mstore(p, sel)
mstore(add(p, 4), y)
mstore(add(p, 36), x)
if iszero(staticcall(gas(), a, p, 68, p, 32)) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
r := mload(p)
}
}
/// @dev Range-reduces x into [0, PI/2], the domain the sine lookup table
/// covers, and records which reflections are needed to reconstruct the
/// value in the original quadrant.
/// @return clamped x reduced into [0, PI/2].
/// @return flipHorizontal True if x fell in the second half of [0, PI].
/// @return flipVertical True if x fell in [PI, 2*PI).
function clamp(int64 x) internal pure returns (int64, bool, bool) {
unchecked {
int64 clamped2Pi = x;
for (uint8 i = 0; i < 29; ++i) {
clamped2Pi %= LARGE_PI >> i;
}
if (x < 0) {
clamped2Pi += Fix64.TWO_PI;
}
bool flipVertical = clamped2Pi >= Fix64.PI;
int64 clampedPi = clamped2Pi;
while (clampedPi >= Fix64.PI) {
clampedPi -= Fix64.PI;
}
bool flipHorizontal = clampedPi >= Fix64.PI_OVER_2;
int64 clampedPiOver2 = clampedPi;
if (clampedPiOver2 >= Fix64.PI_OVER_2)
clampedPiOver2 -= Fix64.PI_OVER_2;
return (clampedPiOver2, flipHorizontal, flipVertical);
}
}
/// @notice Arc cosine of x, via atan(sqrt(1 - x^2) / x).
/// @param x A Q31.32 value in [-ONE, ONE].
/// @return result Angle in radians, Q31.32, in [0, PI].
/// @custom:reverts "invalid range for x" if x is outside [-ONE, ONE].
function acos(int64 x) public pure returns (int64 result) {
if (x < -Fix64.ONE || x > Fix64.ONE) revert("invalid range for x");
if (x == 0) return Fix64.PI_OVER_2;
int64 t1 = Fix64.ONE - Fix64.mul(x, x);
int64 t2 = Fix64.div(sqrt(t1), x);
result = atan(t2);
return x < 0 ? result + Fix64.PI : result;
}
/// @notice Arc tangent of z, via a continued-fraction series. Values
/// with |z| > 1 are computed as PI/2 - atan(1/z) for faster convergence.
/// @param z Q31.32.
/// @return result Angle in radians, Q31.32, in (-PI/2, PI/2).
function atan(int64 z) public pure returns (int64 result) {
if (z == 0) return 0;
bool neg = z < 0;
if (neg) z = -z;
int64 two = Fix64.TWO;
int64 three = Fix64.THREE;
bool invert = z > Fix64.ONE;
if (invert) z = Fix64.div(Fix64.ONE, z);
result = Fix64.ONE;
int64 term = Fix64.ONE;
int64 zSq = Fix64.mul(z, z);
int64 zSq2 = Fix64.mul(zSq, two);
int64 zSqPlusOne = Fix64.add(zSq, Fix64.ONE);
int64 zSq12 = Fix64.mul(zSqPlusOne, two);
int64 dividend = zSq2;
int64 divisor = Fix64.mul(zSqPlusOne, three);
for (uint8 i = 2; i < 30; ++i) {
term = Fix64.mul(term, Fix64.div(dividend, divisor));
result = Fix64.add(result, term);
dividend = Fix64.add(dividend, zSq2);
divisor = Fix64.add(divisor, zSq12);
if (term == 0) break;
}
result = Fix64.mul(result, Fix64.div(z, zSqPlusOne));
if (invert) {
result = Fix64.sub(Fix64.PI_OVER_2, result);
}
if (neg) {
result = -result;
}
return result;
}
/// @notice Angle of the point (x, y) from the positive x-axis, via a
/// rational polynomial approximation (a separate algorithm from atan()).
/// @param y Q31.32.
/// @param x Q31.32.
/// @return result Angle in radians, Q31.32, in (-PI, PI].
function atan2(int64 y, int64 x) public pure returns (int64 result) {
int64 e = 1202590848; /* 0.28 */
int64 yl = y;
int64 xl = x;
if (xl == 0) {
if (yl > 0) {
return Fix64.PI_OVER_2;
}
if (yl == 0) {
return 0;
}
return -Fix64.PI_OVER_2;
}
int64 z = Fix64.div(y, x);
if (
Fix64.add(Fix64.ONE, Fix64.mul(e, Fix64.mul(z, z))) ==
type(int64).max
) {
return y < 0 ? -Fix64.PI_OVER_2 : Fix64.PI_OVER_2;
}
if (Fix64.abs(z) < Fix64.ONE) {
result = Fix64.div(
z,
Fix64.add(Fix64.ONE, Fix64.mul(e, Fix64.mul(z, z)))
);
if (xl < 0) {
if (yl < 0) {
return Fix64.sub(result, Fix64.PI);
}
return Fix64.add(result, Fix64.PI);
}
} else {
result = Fix64.sub(
Fix64.PI_OVER_2,
Fix64.div(z, Fix64.add(Fix64.mul(z, z), e))
);
if (yl < 0) {
return Fix64.sub(result, Fix64.PI);
}
}
}
}
src/Errors.sol
// SPDX-License-Identifier: MIT
/* Copyright (c) Kohi Art Community, Inc. All rights reserved. */
/*
/*
///////////////////////////////////////////////////////////////////////////////////
// //
// @@@@@@@@@@@@@@ @@@@ //
// @@@@ @@@@ @@@@@@@@ //
// @@@@ @@@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@@@@@@ //
// @@@@ @@@@ //
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@ //
// @@@@ @@@@@@@@@@@ //
// //
///////////////////////////////////////////////////////////////////////////////////
*/
pragma solidity ^0.8.13;
/// @notice Custom errors shared by the Fix64 / Trig256 fixed-point library.
/// @notice An index or argument fell outside the range a function accepts.
error ArgumentOutOfRange();
/// @notice A division was attempted with a zero divisor.
error AttemptedToDivideByZero();
/// @notice A function that requires a non-negative input received a negative one.
error NegativeValuePassed();
src/Fix64.sol
// SPDX-License-Identifier: MIT
/* Copyright (c) Kohi Art Community, Inc. All rights reserved. */
/*
/*
///////////////////////////////////////////////////////////////////////////////////
// //
// @@@@@@@@@@@@@@ @@@@ //
// @@@@ @@@@ @@@@@@@@ //
// @@@@ @@@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@@@@@@ //
// @@@@ @@@@ //
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@ //
// @@@@ @@@@@@@@@@@ //
// //
///////////////////////////////////////////////////////////////////////////////////
*/
pragma solidity ^0.8.13;
/*
Fix64: signed fixed-point arithmetic in Q31.32 format (a 64-bit two's
complement integer with 32 fractional bits, so 1.0 is represented as
1 << 32). This library provides the core operators, add/sub/mul/div,
floor/round, sign/abs, min/max, and clamping/mapping helpers, that the
rest of this codebase's trigonometric and logarithmic functions build on.
exp: Adapted from Petteri Aimonen's libfixmath
See: https://github.com/PetteriAimonen/libfixmath
https://github.com/PetteriAimonen/libfixmath/blob/master/LICENSE
other functions: Adapted from Andre Slupik's FixedMath.NET
https://github.com/asik/FixedMath.Net/blob/master/LICENSE.txt
THIRD PARTY NOTICES:
====================
libfixmath is Copyright (c) 2011-2021 Flatmush <[email protected]>,
Petteri Aimonen <[email protected]>, & libfixmath AUTHORS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright 2012 André Slupik
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This project uses code from the log2fix library, which is under the following license:
The MIT License (MIT)
Copyright (c) 2015 Dan Moulding
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
/*
The arithmetic below runs inside `unchecked` blocks so that int64/uint64
operations wrap on overflow (two's complement), matching the original
FixedMath.NET reference behavior. Solidity's default checked arithmetic
would revert on exactly the wraps and saturations this format relies on.
*/
import "./Errors.sol";
/// @notice Signed fixed-point arithmetic in Q31.32 format (32 fractional bits).
library Fix64 {
/// @notice Number of fractional bits in the Q31.32 representation.
int64 public constant FRACTIONAL_PLACES = 32;
/// @notice The fixed-point representation of 1.0 (1 << FRACTIONAL_PLACES).
int64 public constant ONE = 4294967296; // 1 << FRACTIONAL_PLACES
int64 public constant TWO = ONE * 2;
int64 public constant THREE = ONE * 3;
/// @notice Pi, in Q31.32.
int64 public constant PI = 0x3243F6A88;
/// @notice 2*Pi, in Q31.32.
int64 public constant TWO_PI = 0x6487ED511;
/// @notice The largest representable Fix64 value.
int64 public constant MAX_VALUE = type(int64).max;
/// @notice The smallest representable Fix64 value.
int64 public constant MIN_VALUE = type(int64).min;
/// @notice Pi / 2, in Q31.32.
int64 public constant PI_OVER_2 = 0x1921FB544;
/// @dev Counts leading zero bits in a 64-bit word, for bit-scan style
/// routines. Does not handle x == 0 (the scan never terminates).
function countLeadingZeros(uint64 x) internal pure returns (int64) {
unchecked {
int64 result = 0;
while ((x & 0xF000000000000000) == 0) {
result += 4;
x <<= 4;
}
while ((x & 0x8000000000000000) == 0) {
result += 1;
x <<= 1;
}
return result;
}
}
/*
* div() and mul() are closed forms of the original FixedMath.NET
* loop/decomposition implementations, bit-identical for every input:
* the long division computes exactly floor(|x|*2^33/|y|) with
* saturation and half-up rounding of the extra bit, and mul_256's
* four-part decomposition absorbs its intermediate wraps mod 2^64.
*/
/// @notice Divides x by y in Q31.32, rounding the result half up.
/// @dev Saturates to MAX_VALUE/MIN_VALUE on overflow.
/// @return The fixed-point quotient x / y.
/// @custom:reverts AttemptedToDivideByZero if y == 0.
function div(int64 x, int64 y) internal pure returns (int64) {
unchecked {
if (y == 0) {
revert AttemptedToDivideByZero();
}
uint256 ax = uint64(x >= 0 ? x : -x);
uint256 ay = uint64(y >= 0 ? y : -y);
uint256 q = (ax << 33) / ay;
if (q > type(uint64).max) {
return ((x ^ y) & MIN_VALUE) == 0 ? MAX_VALUE : MIN_VALUE;
}
int64 result = int64(uint64((q + 1) >> 1));
if (((x ^ y) & MIN_VALUE) != 0) {
result = -result;
}
return result;
}
}
/// @notice Multiplies x by y in Q31.32.
/// @dev Widens to int256 for the multiply, then rescales; wraps on
/// overflow rather than saturating (matches the original reference).
/// @return The fixed-point product x * y.
function mul(int64 x, int64 y) internal pure returns (int64) {
unchecked {
return int64(int256((int256(x) * int256(y)) >> 32));
}
}
/// @notice Multiplies two Q31.32 values without truncating to int64.
/// @dev Splits each operand into high/low 32-bit halves and sums the
/// four partial products, so the result stays exact in int256 instead
/// of wrapping the way mul() does. Used where intermediate precision
/// matters, e.g. squaring a value repeatedly in log2().
/// @return The fixed-point product x * y as an int256.
function mul_256(int256 x, int256 y) internal pure returns (int256) {
unchecked {
int256 xl = x;
int256 yl = y;
uint256 xlo = uint256((xl & int256(0x00000000FFFFFFFF)));
int256 xhi = xl >> 32; // FRACTIONAL_PLACES
uint256 ylo = uint256(yl & int256(0x00000000FFFFFFFF));
int256 yhi = yl >> 32; // FRACTIONAL_PLACES
uint256 lolo = xlo * ylo;
int256 lohi = int256(xlo) * yhi;
int256 hilo = xhi * int256(ylo);
int256 hihi = xhi * yhi;
uint256 loResult = lolo >> 32; // FRACTIONAL_PLACES
int256 midResult1 = lohi;
int256 midResult2 = hilo;
int256 hiResult = hihi << 32; // FRACTIONAL_PLACES
int256 sum = int256(loResult) + midResult1 + midResult2 + hiResult;
return sum;
}
}
/// @notice Truncates a Q31.32 value down to the nearest whole number.
/// @dev Zeroes the fractional bits; rounds toward negative infinity.
function floor(int256 x) internal pure returns (int64) {
unchecked {
return int64(x & 0xFFFFFFFF00000000);
}
}
/// @notice Rounds a Q31.32 value to the nearest whole number.
/// @dev Ties (fractional part exactly 0.5) round to even, matching
/// IEEE-754 banker's rounding.
function round(int256 x) internal pure returns (int256) {
unchecked {
int256 fractionalPart = x & 0x00000000FFFFFFFF;
int256 integralPart = floor(x);
if (fractionalPart < 0x80000000) return integralPart;
if (fractionalPart > 0x80000000) return integralPart + ONE;
if ((integralPart & ONE) == 0) return integralPart;
return integralPart + ONE;
}
}
/// @notice Subtracts y from x, saturating instead of wrapping on overflow.
/// @return x - y, clamped to [MIN_VALUE, MAX_VALUE].
function sub(int64 x, int64 y) internal pure returns (int64) {
unchecked {
int64 xl = x;
int64 yl = y;
int64 diff = xl - yl;
if (((xl ^ yl) & (xl ^ diff) & MIN_VALUE) != 0)
diff = xl < 0 ? MIN_VALUE : MAX_VALUE;
return diff;
}
}
/// @notice Adds x and y, saturating instead of wrapping on overflow.
/// @return x + y, clamped to [MIN_VALUE, MAX_VALUE].
function add(int64 x, int64 y) internal pure returns (int64) {
unchecked {
int64 xl = x;
int64 yl = y;
int64 sum = xl + yl;
if ((~(xl ^ yl) & (xl ^ sum) & MIN_VALUE) != 0)
sum = xl > 0 ? MAX_VALUE : MIN_VALUE;
return sum;
}
}
/// @notice The sign of x.
/// @return -1, 0, or 1.
function sign(int64 x) internal pure returns (int8) {
return x == int8(0) ? int8(0) : x > int8(0) ? int8(1) : int8(-1);
}
/// @notice The absolute value of x.
/// @dev Branchless via the sign-mask trick; MIN_VALUE has no positive
/// counterpart and wraps back to itself under the unchecked negation.
function abs(int64 x) internal pure returns (int64) {
unchecked {
int64 mask = x >> 63;
return (x + mask) ^ mask;
}
}
/// @notice The larger of a and b.
function max(int64 a, int64 b) internal pure returns (int64) {
return a >= b ? a : b;
}
/// @notice The smaller of a and b.
function min(int64 a, int64 b) internal pure returns (int64) {
return a < b ? a : b;
}
/// @notice Linearly maps n from the range [start1, stop1] to [start2, stop2],
/// then clamps the result to that output range.
/// @return The mapped and clamped value.
/// @custom:reverts AttemptedToDivideByZero if start1 == stop1.
function map(
int64 n,
int64 start1,
int64 stop1,
int64 start2,
int64 stop2
) internal pure returns (int64) {
int64 value = mul(
div(sub(n, start1), sub(stop1, start1)),
add(sub(stop2, start2), start2)
);
return
start2 < stop2
? constrain(value, start2, stop2)
: constrain(value, stop2, start2);
}
/// @notice Clamps n to the inclusive range [low, high].
function constrain(
int64 n,
int64 low,
int64 high
) internal pure returns (int64) {
return max(min(n, high), low);
}
}
src/SinLut256.sol
// SPDX-License-Identifier: MIT
/* Copyright (c) wattsy. Portions Copyright (c) Kohi Art Community, Inc. (MIT). */
/*
* This is a generated Solidity artifact of Kohi's MIT SinLut256: a 256-entry
* Q31.32 sine table over [0, PI/2]. The table values are Kohi's MIT-licensed
* work; this generated file is released under MIT, retaining the original Kohi
* MIT notice as MIT requires.
*/
/*
/*
///////////////////////////////////////////////////////////////////////////////////
// //
// @@@@@@@@@@@@@@ @@@@ //
// @@@@ @@@@ @@@@@@@@ //
// @@@@ @@@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@@@@@@ //
// @@@@ @@@@ //
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@ //
// @@@@ @@@@@@@@@@@ //
// //
///////////////////////////////////////////////////////////////////////////////////
*/
pragma solidity ^0.8.13;
/*
* Generated: do not hand-edit. Value-identical to the original Kohi
* SinLut256 table (256-entry Q31.32 sine LUT over [0, PI/2]), repacked
* 4 entries per uint256 word so it inlines compactly. Boundary behavior
* matches the original table's fallthrough: a negative index reads entry 1,
* an index above 255 reads entry 255.
*/
library SinLut256 {
/**
* @notice Lookup table for computing the sine value for a given angle.
* @param i The clamped and rounded angle integral to index into the table.
* @return The sine value in fixed-point (Q31.32) space.
*/
function sinlut(int256 i) internal pure returns (int64) {
unchecked {
if (i < 0) i = 1; // original tree fallthrough for negatives
if (i > 255) i = 255; // and for overflow
uint256 w = uint256(i) >> 2;
uint256 lane = uint256(i) & 3;
return int64(uint64(_word(w) >> ((3 - lane) << 6)));
}
}
function _word(uint256 w) private pure returns (uint256) {
if (w <= 31) {
if (w <= 15) {
if (w <= 7) {
if (w <= 3) {
if (w <= 1) {
if (w <= 0) {
return 0x0000000000000000000000000193b2c100000000032761960000000004bb0894;
} else {
return 0x00000000064ea3ce0000000007e22f59000000000975a749000000000b0907b3;
}
} else {
if (w <= 2) {
return 0x000000000c9c4cab000000000e2f7248000000000fc2749e0000000011554fc3;
} else {
return 0x0000000012e7ffce00000000147a80d400000000160cceee00000000179ee632;
}
}
} else {
if (w <= 5) {
if (w <= 4) {
return 0x000000001930c2b9000000001ac2609b000000001c53bbf1000000001de4d0d7;
} else {
return 0x000000001f759b6500000000210617b800000000229641eb000000002426161c;
}
} else {
if (w <= 6) {
return 0x0000000025b59067000000002744aced0000000028d367cb000000002a61bd23;
} else {
return 0x000000002befa917000000002d7d27c7000000002f0a3559000000003096cdf1;
}
}
}
} else {
if (w <= 11) {
if (w <= 9) {
if (w <= 8) {
return 0x000000003222edb30000000033ae90c8000000003539b3580000000036c4518b;
} else {
return 0x00000000384e678d0000000039d7f18a000000003b60ebae000000003ce95229;
}
} else {
if (w <= 10) {
return 0x000000003e71212a000000003ff854e400000000417ee98a000000004304db50;
} else {
return 0x00000000448a266d00000000460ec718000000004792b98b000000004915fa02;
}
}
} else {
if (w <= 13) {
if (w <= 12) {
return 0x000000004a9884b9000000004c1a55ef000000004d9b69e5000000004f1bbcdc;
} else {
return 0x00000000509b4b1a00000000521a10e50000000053980a840000000055153442;
}
} else {
if (w <= 14) {
return 0x0000000056918a6b00000000580d094d000000005987ad38000000005b01727f;
} else {
return 0x000000005c7a5576000000005df25274000000005f6965d20000000060df8bec;
}
}
}
}
} else {
if (w <= 23) {
if (w <= 19) {
if (w <= 17) {
if (w <= 16) {
return 0x000000006254c11e0000000063c901ca00000000653c4a500000000066ae9716;
} else {
return 0x00000000681fe4840000000069902f01000000006aff72fc000000006c6dace2;
}
} else {
if (w <= 18) {
return 0x000000006ddad924000000006f46f4370000000070b1fa9200000000721be8ac;
} else {
return 0x000000007384bb030000000074ec6e15000000007652fe630000000077b86873;
}
}
} else {
if (w <= 21) {
if (w <= 20) {
return 0x00000000791ca8ca000000007a7fbbf4000000007be19e7c000000007d424cf4;
} else {
return 0x000000007ea1c3ee000000007fffffff00000000815cfdc20000000082b8b9d3;
}
} else {
if (w <= 22) {
return 0x00000000841330cf00000000856c5f5b0000000086c4421b00000000881ad5b8;
} else {
return 0x00000000897016df000000008ac4023e000000008c169489000000008d67ca76;
}
}
}
} else {
if (w <= 27) {
if (w <= 25) {
if (w <= 24) {
return 0x000000008eb7a0bd000000009006141d000000009153215400000000929ec527;
} else {
return 0x0000000093e8fc5e000000009531c3c200000000967918230000000097bef652;
}
} else {
if (w <= 26) {
return 0x0000000099035b26000000009a464376000000009b87ac21000000009cc79207;
} else {
return 0x000000009e05f20c000000009f42c91a00000000a07e141b00000000a1b7d000;
}
}
} else {
if (w <= 29) {
if (w <= 28) {
return 0x00000000a2eff9bc00000000a4268e4800000000a55b8a9f00000000a68eebc1;
} else {
return 0x00000000a7c0aeb100000000a8f0d07700000000aa1f4e1e00000000ab4c24b7;
}
} else {
if (w <= 30) {
return 0x00000000ac77515400000000ada0d11000000000aec8a10400000000afeebe52;
} else {
return 0x00000000b113261f00000000b235d59300000000b356c9db00000000b476002a;
}
}
}
}
}
} else {
if (w <= 47) {
if (w <= 39) {
if (w <= 35) {
if (w <= 33) {
if (w <= 32) {
return 0x00000000b59375b300000000b6af27b300000000b7c9136600000000b8e13611;
} else {
return 0x00000000b9f78cfb00000000bb0c156e00000000bc1eccbd00000000bd2fb03a;
}
} else {
if (w <= 34) {
return 0x00000000be3ebd4100000000bf4bf12f00000000c057496600000000c160c34d;
} else {
return 0x00000000c2685c5100000000c36e11e200000000c471e17400000000c573c883;
}
}
} else {
if (w <= 37) {
if (w <= 36) {
return 0x00000000c673c48d00000000c771d31400000000c86df1a200000000c9681dc3;
} else {
return 0x00000000ca60550900000000cb56950b00000000cc4adb6400000000cd3d25b6;
}
} else {
if (w <= 38) {
return 0x00000000ce2d71a500000000cf1bbcdc00000000d008050b00000000d0f247e5;
} else {
return 0x00000000d1da832500000000d2c0b48800000000d3a4d9d300000000d486f0ce;
}
}
}
} else {
if (w <= 43) {
if (w <= 41) {
if (w <= 40) {
return 0x00000000d566f74600000000d644eb0f00000000d720ca0100000000d7fa91f8;
} else {
return 0x00000000d8d240d800000000d9a7d48800000000da7b4af500000000db4ca210;
}
} else {
if (w <= 42) {
return 0x00000000dc1bd7d300000000dce8ea3800000000ddb3d74200000000de7c9cf9;
} else {
return 0x00000000df43396900000000e007aaa500000000e0c9eec300000000e18a03e1;
}
}
} else {
if (w <= 45) {
if (w <= 44) {
return 0x00000000e247e82100000000e30399ab00000000e3bd16ad00000000e4745d57;
} else {
return 0x00000000e5296be400000000e5dc409100000000e68cd9a100000000e73b355d;
}
} else {
if (w <= 46) {
return 0x00000000e7e7521300000000e8912e1800000000e938c7c400000000e9de1d77;
} else {
return 0x00000000ea812d9700000000eb21f68d00000000ebc076ca00000000ec5cacc3;
}
}
}
}
} else {
if (w <= 55) {
if (w <= 51) {
if (w <= 49) {
if (w <= 48) {
return 0x00000000ecf696f400000000ed8e33df00000000ee23820900000000eeb68001;
} else {
return 0x00000000ef472c5800000000efd585a700000000f0618a8c00000000f0eb39aa;
}
} else {
if (w <= 50) {
return 0x00000000f17291ab00000000f1f7913e00000000f27a371900000000f2fa81f8;
} else {
return 0x00000000f378709a00000000f3f401c600000000f46d344a00000000f4e406f8;
}
}
} else {
if (w <= 53) {
if (w <= 52) {
return 0x00000000f55878a900000000f5ca883b00000000f63a349100000000f6a77c98;
} else {
return 0x00000000f7125f3e00000000f77adb7a00000000f7e0f04900000000f8449cac;
}
} else {
if (w <= 54) {
return 0x00000000f8a5dfab00000000f904b85500000000f96125bd00000000f9bb26ff;
} else {
return 0x00000000fa12bb3900000000fa67e19300000000faba993900000000fb0ae15c;
}
}
}
} else {
if (w <= 59) {
if (w <= 57) {
if (w <= 56) {
return 0x00000000fb58b93500000000fba4200300000000fbed150b00000000fc339795;
} else {
return 0x00000000fc77a6f500000000fcb9427f00000000fcf8699100000000fd351b8e;
}
} else {
if (w <= 58) {
return 0x00000000fd6f57df00000000fda71df300000000fddc6d4000000000fe0f4540;
} else {
return 0x00000000fe3fa57600000000fe6d8d6900000000fe98fca700000000fec1f2c4;
}
}
} else {
if (w <= 61) {
if (w <= 60) {
return 0x00000000fee86f5a00000000ff0c720a00000000ff2dfa7900000000ff4d0855;
} else {
return 0x00000000ff699b4f00000000ff83b32200000000ff9b4f8d00000000ffb07054;
}
} else {
if (w <= 62) {
return 0x00000000ffc3154300000000ffd33e2b00000000ffe0eae500000000ffec1b4f;
} else {
return 0x00000000fff4cf4c00000000fffb06c700000000fffec1b10000000100000000;
}
}
}
}
}
}
}
/**
* @notice sinlut() against a memory-resident copy of the table (entry i
* at lutPtr + i*8, big-endian: the table() blob staged verbatim,
* with >= 24 bytes of readable slack after it for the tail mload).
* Value- and boundary-identical to sinlut(i); costs one mload
* instead of the ~2.6 KB selection tree, for callers that need
* to stay under a contract size limit such as EIP-170.
*/
function sinlut(uint256 lutPtr, int256 i) internal pure returns (int64 v) {
unchecked {
if (i < 0) i = 1; // original tree fallthrough for negatives
if (i > 255) i = 255; // and for overflow
assembly {
v := shr(192, mload(add(lutPtr, shl(3, i))))
}
}
}
/// @notice The full table as one blob (entry i at byte i*8, big-endian),
/// for staging into an SSTORE2 data contract at deploy time.
/// Reference it from constructors only, so the 2 KB rides in
/// initcode and never counts against the runtime size limit.
function table() internal pure returns (bytes memory) {
return
hex"0000000000000000000000000193b2c100000000032761960000000004bb089400000000064ea3ce0000000007e22f59000000000975a749000000000b0907b3000000000c9c4cab000000000e2f7248000000000fc2749e0000000011554fc30000000012e7ffce00000000147a80d400000000160cceee00000000179ee632000000001930c2b9000000001ac2609b000000001c53bbf1000000001de4d0d7000000001f759b6500000000210617b800000000229641eb000000002426161c0000000025b59067000000002744aced0000000028d367cb000000002a61bd23000000002befa917000000002d7d27c7000000002f0a3559000000003096cdf1000000003222edb30000000033ae90c8000000003539b3580000000036c4518b00000000384e678d0000000039d7f18a000000003b60ebae000000003ce95229000000003e71212a000000003ff854e400000000417ee98a000000004304db5000000000448a266d00000000460ec718000000004792b98b000000004915fa02000000004a9884b9000000004c1a55ef000000004d9b69e5000000004f1bbcdc00000000509b4b1a00000000521a10e50000000053980a8400000000551534420000000056918a6b00000000580d094d000000005987ad38000000005b01727f000000005c7a5576000000005df25274000000005f6965d20000000060df8bec000000006254c11e0000000063c901ca00000000653c4a500000000066ae971600000000681fe4840000000069902f01000000006aff72fc000000006c6dace2000000006ddad924000000006f46f4370000000070b1fa9200000000721be8ac000000007384bb030000000074ec6e15000000007652fe630000000077b8687300000000791ca8ca000000007a7fbbf4000000007be19e7c000000007d424cf4000000007ea1c3ee000000007fffffff00000000815cfdc20000000082b8b9d300000000841330cf00000000856c5f5b0000000086c4421b00000000881ad5b800000000897016df000000008ac4023e000000008c169489000000008d67ca76000000008eb7a0bd000000009006141d000000009153215400000000929ec5270000000093e8fc5e000000009531c3c200000000967918230000000097bef6520000000099035b26000000009a464376000000009b87ac21000000009cc79207000000009e05f20c000000009f42c91a00000000a07e141b00000000a1b7d00000000000a2eff9bc00000000a4268e4800000000a55b8a9f00000000a68eebc100000000a7c0aeb100000000a8f0d07700000000aa1f4e1e00000000ab4c24b700000000ac77515400000000ada0d11000000000aec8a10400000000afeebe5200000000b113261f00000000b235d59300000000b356c9db00000000b476002a00000000b59375b300000000b6af27b300000000b7c9136600000000b8e1361100000000b9f78cfb00000000bb0c156e00000000bc1eccbd00000000bd2fb03a00000000be3ebd4100000000bf4bf12f00000000c057496600000000c160c34d00000000c2685c5100000000c36e11e200000000c471e17400000000c573c88300000000c673c48d00000000c771d31400000000c86df1a200000000c9681dc300000000ca60550900000000cb56950b00000000cc4adb6400000000cd3d25b600000000ce2d71a500000000cf1bbcdc00000000d008050b00000000d0f247e500000000d1da832500000000d2c0b48800000000d3a4d9d300000000d486f0ce00000000d566f74600000000d644eb0f00000000d720ca0100000000d7fa91f800000000d8d240d800000000d9a7d48800000000da7b4af500000000db4ca21000000000dc1bd7d300000000dce8ea3800000000ddb3d74200000000de7c9cf900000000df43396900000000e007aaa500000000e0c9eec300000000e18a03e100000000e247e82100000000e30399ab00000000e3bd16ad00000000e4745d5700000000e5296be400000000e5dc409100000000e68cd9a100000000e73b355d00000000e7e7521300000000e8912e1800000000e938c7c400000000e9de1d7700000000ea812d9700000000eb21f68d00000000ebc076ca00000000ec5cacc300000000ecf696f400000000ed8e33df00000000ee23820900000000eeb6800100000000ef472c5800000000efd585a700000000f0618a8c00000000f0eb39aa00000000f17291ab00000000f1f7913e00000000f27a371900000000f2fa81f800000000f378709a00000000f3f401c600000000f46d344a00000000f4e406f800000000f55878a900000000f5ca883b00000000f63a349100000000f6a77c9800000000f7125f3e00000000f77adb7a00000000f7e0f04900000000f8449cac00000000f8a5dfab00000000f904b85500000000f96125bd00000000f9bb26ff00000000fa12bb3900000000fa67e19300000000faba993900000000fb0ae15c00000000fb58b93500000000fba4200300000000fbed150b00000000fc33979500000000fc77a6f500000000fcb9427f00000000fcf8699100000000fd351b8e00000000fd6f57df00000000fda71df300000000fddc6d4000000000fe0f454000000000fe3fa57600000000fe6d8d6900000000fe98fca700000000fec1f2c400000000fee86f5a00000000ff0c720a00000000ff2dfa7900000000ff4d085500000000ff699b4f00000000ff83b32200000000ff9b4f8d00000000ffb0705400000000ffc3154300000000ffd33e2b00000000ffe0eae500000000ffec1b4f00000000fff4cf4c00000000fffb06c700000000fffec1b10000000100000000";
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.