Skip to content

Instantly share code, notes, and snippets.

View z0r0z's full-sized avatar
💭
codin qualia 🪄

ross z0r0z

💭
codin qualia 🪄
View GitHub Profile
@z0r0z
z0r0z / CTX.sol
Created January 15, 2024 09:30
Dollars-to-donuts exchange. Demo: Circle <> Tether. Smol Swap Lego.
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
/// @notice Dollars-to-donuts exchange.
/// Put in one thing for another thing.
contract CTX {
IERC20 constant C = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // Circle dollars.
IERC20 constant T = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7); // Tether dollars.
uint256 constant F = 1; // Fee is just a lil bit. Placeholder. Someone should do the math.
@z0r0z
z0r0z / Account.sol
Last active November 10, 2023 21:04
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
/// @notice Receiver mixin for ETH and safe-transferred ERC721 and ERC1155 tokens.
/// @author Solady (https://github.com/Vectorized/solady/blob/main/src/accounts/Receiver.sol)
///
/// @dev Note:
/// - Handles all ERC721 and ERC1155 token safety callbacks.
/// - Collapses function table gas overhead and code size.
/// - Utilizes fallback so unknown calldata will pass on.
@z0r0z
z0r0z / AssetContractShared.sol
Last active July 12, 2023 14:05
Let us verify the contract source code of the most popular ERC1155 - OpenSea Shared Storefront (OPENSTORE) - 0x495f947276749ce646f68ac8c248420045cb7b5e
pragma solidity ^0.5.12;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
@z0r0z
z0r0z / ERC223ish.sol
Last active July 10, 2023 14:48
ERC223-like token for discussion in Final standard process.
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @dev ERC223ish
/// @author z0r0z
contract ERC223ish {
event Approval(address indexed from, address indexed to, uint amt);
event Transfer(address indexed from, address indexed to, uint amt);
event Transfer(address indexed from, address indexed to, uint amt, bytes data);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol";
import "https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol";
struct OTC {
address to;
ERC20 tkn0;
uint256 tkn0amt;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
error DeploymentFailed();
address constant TURNSTILE = 0xEcf044C5B4b867CFda001101c617eCd347095B44;
/// @notice Minimal proxy library.
/// @author Modified from Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibClone.sol)
library LibClone {
@z0r0z
z0r0z / TheGame.sol
Created December 22, 2022 17:49
Solidity implementation of The Game.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract TheGame {
// Nothing to see here yet.
}
@z0r0z
z0r0z / OwnedWithTimer.sol
Last active December 1, 2022 03:59
Simple single owner authorization mixin with timer for guardianship. 👍
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Simple single owner authorization mixin with timer for guardianship.
/// @author Zolidity (https://github.com/z0r0z/zolidity/blob/main/src/auth/OwnedWithTimer.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
contract OwnedWithTimer {
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
@z0r0z
z0r0z / Escrow.sol
Created November 3, 2022 00:51
based on zora pumpkin spice
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
/// @dev The ETH transfer has failed.
error ETHTransferFailed();
/// @dev Sends `amount` (in wei) ETH to `to`.
/// Reverts upon failure.
function safeTransferETH(address to, uint256 amount) {
assembly {
@z0r0z
z0r0z / UniversalWrapper.sol
Created August 18, 2022 05:06
Turns any token into a permittable ERC-1155 token.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol";
import "@openzeppelin/contracts/interfaces/IERC1155.sol";
import "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";