This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity =0.8.17; | |
function quickSort(uint40[] memory arr, uint40 left, uint40 right) internal pure { | |
if (left >= right) { | |
return; | |
} | |
unchecked { | |
// p = the pivot element | |
uint40 p = arr[(left + right) / 2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "Cache RPC Responses" | |
uses: "actions/cache@v3" | |
with: | |
path: "~/.foundry/cache/rpc/mainnet/16183456" | |
key: "${{ runner.os }}-mainnet-16183456" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.13; | |
import "@prb/math/SD59x18.sol"; | |
function allMathFunctions(SD59x18 x, SD59x18 y) pure { | |
abs(x); | |
avg(x, y); | |
ceil(x); | |
div(x, y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @notice Finds the zero-based index of the first 1 in the binary representation of x. | |
/// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set | |
/// @param x The uint256 number for which to find the index of the most significant bit. | |
/// @return result The index of the most significant bit as an uint256. | |
function msb(uint256 x) pure returns (uint256 result) { | |
unchecked { | |
if (x >= 2 ** 128) { | |
x >>= 128; | |
result += 128; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.15; | |
function checkSameSign(int256 a, int256 b) pure returns (bool sameSign) { | |
// Get the signs of a and b. | |
uint256 sa; | |
uint256 sb; | |
assembly { | |
// This works due to two's complement representation. | |
// "sgt" stamds for "signed greater than". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.15; | |
contract StructMemberGetter { | |
error NotAuthorized(address caller); | |
struct MyStruct { | |
address owner; | |
} |
0x0d5aaf2f3cb80039dc489378a620f78034fdb30ba46d721c3191c92e9f56a06f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: Unlicense | |
pragma solidity >=0.8.4; | |
/// @title Create2Utility | |
/// @author Paul Razvan Berg | |
/// @dev Forked from OpenZeppelin | |
/// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.5.0/contracts/utils/Create2.sol | |
contract Create2Utility { | |
/// @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the | |
/// `bytecodeHash` or `salt` will result in a new destination address. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Echo GitHub secret" | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
print-github-secret: | |
runs-on: "ubuntu-latest" |