Skip to content

Instantly share code, notes, and snippets.

@wilsoncusack
wilsoncusack / config.ts
Last active September 27, 2023 14:27
possible opstack configs
import type { Chain, Address, ChainContract } from 'viem'
export enum OpStackL1Contract {
L1CrossDomainMessenger = 'l1CrossDomainMessenger',
L1Erc721Bridge = 'l1Erc721Bridge',
L1StandardBridge = 'l1StandardBridge',
L2OutputOracle = 'l2OutputOracle',
OptimismPortal = 'optimismPortal',
}
Toadz
top bid $1969.94185
bid count > 50% top bid 57
bid count > 50% top bid as % of total supply: 0.81%
DickButts
top bid $3254.2281
bid count > 50% top bid 49
bid count > 50% top bid as % of total supply: 0.94%
@wilsoncusack
wilsoncusack / Anonymice.sol
Last active September 3, 2022 13:36
Anonymice Contract
// from https://etherscan.io/token/0xbad6186E92002E312078b5a1dAfd5ddf63d3f731#code
// contracts/Anonymice.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "./ICheeth.sol";
import "./AnonymiceLibrary.sol";
contract Anonymice is ERC721Enumerable {
@wilsoncusack
wilsoncusack / typedGraphqlQuery.ts
Last active January 13, 2022 17:01
Passing Objects as Document Variables using URQL
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Loan_Filter = {
closed?: InputMaybe<Scalars['Boolean']>;
closed_in?: InputMaybe<Array<Scalars['Boolean']>>;
closed_not?: InputMaybe<Scalars['Boolean']>;
closed_not_in?: InputMaybe<Array<Scalars['Boolean']>>;
};
@wilsoncusack
wilsoncusack / main.rs
Last active December 29, 2021 18:30
Rust Ethereum Vanity Address Generation
use ethers::{
signers::{LocalWallet, Signer},
};
fn main() {
let vanity_hex = "01";
// OR pass as input
// let mut args: Args = args();
// let vanity_hex = args.nth(1).unwrap();
let bytes_to_match = hex::decode(vanity_hex).expect("invalid hex");
@wilsoncusack
wilsoncusack / query.graphql
Created December 25, 2021 03:58
NFT Sales Indexer Query
{
sales(where: {nftContractAddress: "0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63", nftTokenId: "606"} orderBy: timestamp, orderDirection: desc)
{
id
nftTokenId
price
}
}
@wilsoncusack
wilsoncusack / testPrankPayable.sol
Created December 21, 2021 12:19
Prank Payable
interface Vm {
function prank(address) external;
}
contract Foo {
function bar() public {
require(msg.sender == address(1), 'wrong sender');
}
function barPayable() public payable {
@wilsoncusack
wilsoncusack / LendVault.sol
Created November 16, 2021 20:00
NFT-Loan Lending Vault Sketch
pragma solidity 0.8.6;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../interfaces/INFTLoanFacilitator.sol";
struct LendValues {
uint256 loanAmount;
uint256 perSecondInterestRate;
@wilsoncusack
wilsoncusack / schema.graphql
Created November 9, 2021 15:58
nft-backed loans subgraph entities
type Loan @entity {
id: ID!
closed: Boolean!
perSecondInterestRate: BigInt!
accumulatedInterest: BigInt!
lastAccumulatedTimestamp: BigInt!
durationSeconds: BigInt!
loanAmount: BigInt!
collateralTokenId: BigInt!
collateralContractAddress: Bytes!
@wilsoncusack
wilsoncusack / DecimalStrings.sol
Last active February 28, 2023 06:24
Solidity Decimal String Helpers
function decimalString(uint256 number, uint8 decimals, bool isPercent) private pure returns(string memory){
uint8 percentBufferOffset = isPercent ? 1 : 0;
uint256 tenPowDecimals = 10 ** decimals;
uint256 temp = number;
uint8 digits;
uint8 numSigfigs;
while (temp != 0) {
if (numSigfigs > 0) {
// count all digits preceding least significant figure