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 / MoreUsefulToken.sol
Created January 8, 2022 07:57
Token that passes data to contract fallbacks on transfer
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;
/// @notice Basic ERC20 implementation.
contract TestERC20 {
string public name;
string public symbol;
uint8 constant public decimals = 18;
uint public totalSupply;
@z0r0z
z0r0z / Receivoooooor.sol
Created January 8, 2022 07:58
Accepts data and records sender info
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;
contract Receivoooooor {
mapping(address => uint256) public registry;
fallback(bytes calldata input) external returns (bytes memory) {
(address sender, uint256 amount) = abi.decode(input, (address, uint256));
registry[sender] = amount;
}
@z0r0z
z0r0z / gist:6db3a3ef73a207acb204f7d6aeb107f6
Created January 9, 2022 19:42
programmatically enforce membership doesn't exceed 100 investment club limit
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
/// @notice Modern and gas-optimized ERC-20 + EIP-2612 implementation with COMP-style governance and pausing.
/// @author Modified from RariCapital (https://github.com/Rari-Capital/solmate/blob/main/src/erc20/ERC20.sol)
/// License-Identifier: AGPL-3.0-only
abstract contract KaliDAOtoken {
/*///////////////////////////////////////////////////////////////
EVENTS
@z0r0z
z0r0z / KaliDAOinvestmentClub.sol
Created January 9, 2022 19:43
programmatically enforce membership doesn't exceed 100 investment club limit
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
/// @notice Modern and gas-optimized ERC-20 + EIP-2612 implementation with COMP-style governance and pausing.
/// @author Modified from RariCapital (https://github.com/Rari-Capital/solmate/blob/main/src/erc20/ERC20.sol)
/// License-Identifier: AGPL-3.0-only
abstract contract KaliDAOtoken {
/*///////////////////////////////////////////////////////////////
EVENTS
@z0r0z
z0r0z / ThriftiSwap.sol
Created January 11, 2022 00:57
1155 AMM that swaps between token Id amounts - Modified from UniswapV2
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.5.16;
import "https://github.com/Uniswap/v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol";
import "https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2ERC20.sol";
import "https://github.com/Uniswap/v2-core/blob/master/contracts/libraries/Math.sol";
import "https://github.com/Uniswap/v2-core/blob/master/contracts/libraries/UQ112x112.sol";
import "https://github.com/Uniswap/v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol";
import "https://github.com/Uniswap/v2-core/blob/master/contracts/interfaces/IUniswapV2Callee.sol";
@z0r0z
z0r0z / Payment.sol
Created January 14, 2022 17:24
simple push / pull payment
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
contract Payment {
address public payee = msg.sender;
string public agreement;
uint256 public payment = 0.1 ether;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "https://github.com/lexDAO/Kali/blob/main/contracts/tokens/erc20/ERC20.sol";
interface IERC20 {
function balance(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external;
}
@z0r0z
z0r0z / XYKstrategy.sol
Created January 16, 2022 09:57
uniswap-inspired exchange logic for helios 1155 LPs
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
/// @notice Babylonian method for computing square roots.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)
library SqrtMath {
function sqrt(uint256 x) internal pure returns (uint256 z) {
assembly {
// start off with z at 1
@z0r0z
z0r0z / SingleNFT.sol
Last active June 2, 2022 08:20
1-of-1 NFT built on Solmate
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import "https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol";
/// @notice 1-of-1 NFT.
contract SingleNFT is ERC721 {
string internal URI;
constructor(
@z0r0z
z0r0z / ClubSig.sol
Last active September 24, 2022 19:47
EIP-712-signed multi-signature contract with NFT identifiers for signers and ragequit
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
import "https://github.com/Rari-Capital/solmate/src/tokens/ERC721.sol";
import "https://github.com/kalidao/kali-contracts/blob/main/contracts/utils/NFThelper.sol";
/// @notice Minimal ERC-20 interface.
interface IERC20minimal {
function balanceOf(address account) external view returns (uint256);