Skip to content

Instantly share code, notes, and snippets.

@i001962
i001962 / cast.ts
Created February 21, 2024 04:29
cast example plus some
import { FarcasterNetwork, Message, makeCastAdd, NobleEd25519Signer } from "@farcaster/core";
import axios from "axios";
import sendBio from './bioUpdate';
import sendAi from './ai';
import { CastLengthLimit, NeynarAPI } from "../constants/constants";
const sendCast = async (
newPost: string,
setNewPost: React.Dispatch<React.SetStateAction<string>>,
setRemainingChars: React.Dispatch<React.SetStateAction<number>>,
@i001962
i001962 / FarcasterLogin.tsx
Created May 13, 2023 20:53
farcaster-react-login-warpcast
import styles from "./Farcaster.module.css";
import React, { useState, useEffect } from "react";
//import styles from "./DeployerInfo.module.css";
import * as ed from '@noble/ed25519';
import axios from "axios";
import QRCode from "react-qr-code";
import Button from "../../../UI/Button";
const generateKeyPair = async () => {
const privateKey = ed.utils.randomPrivateKey();

1 - Funding cycles with a target 2 - Overflow pool (runway) 3 - Revenue sources generated project tokens (mint and burn) these are a claim on the overflow pool redeemable for the project's overflow proportionally to the amount of tokens they hold 4 - Reserve rate is a % of the tokens that are minted and allocated to the list of people who have contributed to the project. These are accounts on the Reserve list. 5 - Discount rate is a % that decreases the amount of tokens that are minted when money comes into the project. This decreases each funding cycle and is allocated to the list of people who have contributed to the project on the reserve list.

V2 - Contractual outcomes when a project is funded

@i001962
i001962 / metalog.sol
Created September 23, 2022 20:20
metalog.sol - My first sol contract
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;
import "prb-math/contracts/PRBMathSD59x18.sol";
import "hardhat/console.sol";
// SAMPLE DATA
//0x06f05b59d3b20000 === 0.5 //0x0c59ea48da190000 === 0.89 for the probbility input
//["-0x062838e0865204ea","0x045c937afddaa9d2","-0x06632bf1c33f2d08","0x074b2caf2eb6469c","0x1d5c4ea2451ac020"] for the aCoeffs
// https://ethereum.stackexchange.com/questions/8086/logarithm-math-operation-in-solidity
//My advanced math library PRBMath offers log2 (binary logarithm), ln (natural logarithm) and log10 (common logarithm). I'm gonna paste my implementations here, for posterity, but check out the linked repo for the most up-to-date code.
//Log2
//Gas efficiency: min 377, max 7241, avg 4243. This seems to be faster than the solution posted by Mikhail Vladimirov.
/// @notice Finds the zero-based index of the first one 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.
check.hash = function(eve, msg, val, key, soul, at, no){
SEA.work(val, null, function(data){
console.log('kmac check stored hash', data);
function hexToBase64(hexStr) {
let base64 = "";
for(let i = 0; i < hexStr.length; i++) {
base64 += !(i - 1 & 1) ? String.fromCharCode(parseInt(hexStr.substring(i - 1, i + 1), 16)) : ""
}
return btoa(base64);
}
@i001962
i001962 / ImportSnapshot.js
Last active June 12, 2022 22:03
=ImportSnapShot(proposalID) into Google Sheets - First 1000 votes
// From a google sheet: Extensions -> App script, Paste this code and save. From sheet enter =ImportSnapshot("0x389d186c61410bd6f58ae48ed34237d8281693962337a333033df9e0ea427903")
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
@i001962
i001962 / gun_snippets.md
Last active June 19, 2022 19:42
Gun snippets

Array to gun object

// var gun1 = Gun('https://gun-manhattan.herokuapp.com/gun'); // KMM

var inputJsonWArray = {"name": null, "objectType": "sipModel", "libraryType": "SIPmath_3_0", "dateCreated": "11-07-2021", "provenance": "Uniswapsion", "U01": {"rng": [{"name": "hdr1", "function": "HDR_2_0", "arguments": {"counter": "PM_Index", "entity": 1, "varId": 6263189, "seed3": 0, "seed4": 0}}, {"name": "hdr2", "function": "HDR_2_0", "arguments": {"counter": "PM_Index", "entity": 1, "varId": 6263190, "seed3": 0, "seed4": 0}}, {"name": "hdr3", "function": "HDR_2_0", "arguments": {"counter": "PM_Index", "entity": 1, "varId": 6263191, "seed3": 0, "seed4": 0}}, {"name": "hdr4", "function": "HDR_2_0", "arguments": {"counter": "PM_Index", "entity": 1, "varId": 6263192, "seed3": 0, "seed4": 0}}]}, "sips": [{"name": "USD_ETH", "ref": {"source": "rng", "name": "hdr1"}, "function": "Metalog_1_0", "arguments": {"aCoefficients": [2381.561336996019, 118.75165039897796, -84.31315354434082, 2236.068488402199, 1837.339191913416]

@i001962
i001962 / protocol_images_scrapper.py
Last active May 17, 2022 23:08
protocol_images_scrapper.py
import pandas as pd
import json
import urllib.request, urllib.error
import shutil
#s3 = get_client('s3')
ACCESS_KEY = 'aaaaaa'
SECRET_KEY = 'aaaaaa'
# DATA_BUCKET = 'risk-data.solace.fi.data'
MY_BUCKET= 'assets.solace.fi'
@i001962
i001962 / getVolatility psudo code
Last active April 29, 2022 17:55
portfolioShaper.py
"""
Parameters
----------
SIPdata : df
Dataframe of SIPs without metadata
file_name : str
The name of the output file ending in .xlsx
author : str
The name of the author
SIPmetadata : df, optional