Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
@ajb413
ajb413 / getCompAccrued.js
Last active January 20, 2021 01:22
Get COMP accrued for an account on mainnet using Compound.js (https://github.com/compound-finance/compound-js)
const Compound = require('@compound-finance/compound-js');
const provider = 'https://mainnet.infura.io/v3/' + process.env.infuraApiKey;
// mainnet
const CompoundLens = Compound.util.getAddress(Compound.CompoundLens);
const LensAbi = Compound.util.getAbi(Compound.CompoundLens);
const COMP = Compound.util.getAddress(Compound.COMP);
const Comptroller = Compound.util.getAddress(Compound.Comptroller);
const me = '0xa0df350d2637096571F7A701CBc1C5fdE30dF76A';
@ajb413
ajb413 / EIP712.js
Last active September 3, 2023 15:01
Module for creating EIP-712 signatures with Ethers.js as the only dependency. Works in the browser and Node.js (Ethers.js Web3 Provider / JSON RPC Provider).
// Based on https://github.com/ethereum/EIPs/blob/master/assets/eip-712/Example.js
const ethers = require('ethers');
function abiRawEncode(encTypes, encValues) {
const hexStr = ethers.utils.defaultAbiCoder.encode(encTypes, encValues);
return Buffer.from(hexStr.slice(2, hexStr.length), 'hex');
}
function keccak256(arg) {
@ajb413
ajb413 / Get_COMP_APY.md
Last active August 8, 2023 11:03
Finding the COMP APY

From Blockchain With JSON RPC and JavaScript

const Compound = require('@compound-finance/compound-js');

const provider = 'https://mainnet.infura.io/v3/' + process.env.infuraApiKey;

const cTokenToGetCompApy = Compound.cUSDC; // Pick an asset

const underlying = cTokenToGetCompApy.slice(1, 10);
const underlyingDecimals = Compound.decimals[underlying];
@ajb413
ajb413 / comp_earned.md
Last active July 27, 2023 15:19
How do I retrieve the "COMP earned" value from the Compound protocol? Get the amount of accrued COMP token for an address using the Ethereum blockchain.

How do I retrieve the "COMP earned" value?

With a Smart Contract or JSON RPC

Get the value of COMP earned for an address that uses the Compound protocol. This can be done using the Lens contract with JSON RPC or another Smart Contract. If you do an eth_call with JSON RPC, it is free (no gas costs).

  1. Use the getCompBalanceMetadataExt method in the Lens contract https://etherscan.io/address/0xdCbDb7306c6Ff46f77B349188dC18cEd9DF30299#code
  2. Lens address is posted here https://github.com/compound-finance/compound-protocol/blob/master/networks/mainnet.json#L31
  3. Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L453
@erica
erica / pirate.txt
Last active November 29, 2020 20:39
********This Text Adventure is Copyright 1993, by Erica Sadun********
ALL RIGHTS RESERVED. Known bugs and differences from Infocom games? say ‘news’. Unfamiliar with certain words? say ‘jargon’
PIRATING
To hack and to slash with the best of the best
Means you must have a spirit which is steely and cold
You must fight without mercy, from earliest dawn
The heart of a pirate is ruthless and bold.
Richard T. Pettyheart, Scholar
Treatise on Pirates, 1638
@davidalger
davidalger / db-dump.sh
Last active September 29, 2020 03:10
Uses n98-magerun over SSH to dump a database and pull to local environment for import
#!/usr/bin/env bash
set -euo pipefail
trap 'error "$(printf "Command \`%s\` on line $LINENO failed with exit code $?" "$BASH_COMMAND")"' ERR
## setup functions for use throughout the script
function error {
>&2 printf "\033[31mERROR\033[0m: $@\n"
}
function :: {
@kwvg
kwvg / AMDAdobePatch.sh
Created June 14, 2020 09:29
Tested on Catalina 10.15.4
#!/usr/bin/env bash
cpuname=$(sysctl -n machdep.cpu.brand_string)
# Patch Lightroom Classic first
sudo perl -i -pe 's|\x90\x90\x90\x90\x56\xE8\x3A\x00|\x90\x90\x90\x90\x56\xE8\x1A\x00|sg' /Applications/Adobe\ Lightroom\ Classic/Adobe\ Lightroom\ Classic.app/Contents/Frameworks/CameraRaw.lrtoolkit/CameraRaw
sudo perl -i -pe 's|\x90\x90\x90\x90\x56\xE8\x5A\x00|\x90\x90\x90\x90\x56\xE8\x3A\x00|sg' /Applications/Adobe\ Lightroom\ Classic/Adobe\ Lightroom\ Classic.app/Contents/Frameworks/CameraRaw.lrtoolkit/CameraRaw
# Patch MMXCore and FastCore instances in all other applications
find /Applications/Adobe* -type f -name "MMXCore" -print0 | sudo xargs -0 -I "{}" perl -i -pe 's|\x90\x90\x90\x90\x56\xE8\x5A\x00|\x90\x90\x90\x90\x56\xE8\x3A\x00|sg' "{}"
####
# Retag
retag = "!f(){ name=`git tag`; git tag -d \"$name\"; echo "Retagged $name"; remote=`git remote -v`; \
if [ \"$remote\" != \"\" ]; then git push origin --delete \"$name\"; fi; \
git tag \"$name\"; \
if [ \"$remote\" != \"\" ]; then git push --tags; else echo "No remote"; fi; };f"
untag = "!f(){ name=`git tag`; git tag -d \"$name\"; remote=`git remote -v`; \
if [ \"$remote\" != \"\" ]; then git push origin --delete \"$name\"; \
else echo "No remote"; fi; };f"
tagit = "!f(){ git tag \"$@\"; echo "Tagged $name"; remote=`git remote -v`; \
@KingAlterIV
KingAlterIV / Prefix & Suffix Nametag.md
Last active February 9, 2024 17:17
The proper way of adding a prefix and suffix to nametags of a player using Scoreboard Teams made with packets and is possibly horribly made by me!

Feel free to update and expand upon this.

Requirements

  • ProtocolLib

Code

package your.package.here;