Skip to content

Instantly share code, notes, and snippets.

View sc0Vu's full-sized avatar
🎯
Focusing

Peter Lai sc0Vu

🎯
Focusing
View GitHub Profile
@sc0Vu
sc0Vu / testRegex.js
Created August 16, 2024 15:38 — forked from hanxiao/testRegex.js
Regex for chunking by using all semantic cues
// Updated: Aug. 15, 2024
// Run: node testRegex.js testText.txt
// Used in https://jina.ai/tokenizer
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
// NOTE: it's experimental.
// https://gist.github.com/sc0Vu/09e7f1838785825de800cd3422e4511a
// https://github.com/paulmillr/scure-starknet/blob/main/index.ts
const PEDERSEN_POINTS = [
new ProjectivePoint(2089986280348253421170679821480865132823066470938446095505822317253594081284n, 1713931329540660377023406109199410414810705867260802078187082345529207694986n, 1n),
new ProjectivePoint(996781205833008774514500082376783249102396023663454813447423147977397232763n, 1668503676786377725805489344771023921079126552019160156920634619255970485781n, 1n),
new ProjectivePoint(2251563274489750535117886426533222435294046428347329203627021249169616184184n, 1798716007562728905295480679789526322175868328062420237419143593021674992973n, 1n),
new ProjectivePoint(2138414695194151160943305727036575959195309218611738193261179310511854807447n, 113410276730064486255102093846540133784865286929052426931474106396135072156n, 1n),
new ProjectivePoint(2379962749567351885752724891227938183011949129833673362440656643086
from ecdsa.curves import Curve
from ecdsa.ellipticcurve import CurveFp, Point
from .signature import (
ALPHA,
BETA,
CONSTANT_POINTS,
EC_ORDER,
FIELD_PRIME,
N_ELEMENT_BITS_HASH,
@sc0Vu
sc0Vu / .env
Created April 23, 2022 15:39
raydium_apr
RPC_HOST="https://solana-api.projectserum.com"
API_HOST="https://api.raydium.io"
FARM_POOL_JSON="https://api.raydium.io/v2/sdk/farm/mainnet.json"
@sc0Vu
sc0Vu / calculate_address.ts
Created October 25, 2021 06:49
calculate_address
import { ethers } from "hardhat"
async function main() {
const factoryAddress = '6b6960949B595b22548F4FBf3561Be459cA4F964'
const bytecode = '60806040527312c85994c04520f5216ce788414fdde2b591e1a06000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561006457600080fd5b5061018e806100746000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610051578063380c7a6714610084575b600080fd5b34801561005d57600080fd5b5061006661009b565b60405180826000191660001916815260200191505060405180910390f35b34801561009057600080fd5b506100996100c3565b005b60007f736d617278000000000000000000000000000000000000000000000000000000905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663380c7a676040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b158015610148
@sc0Vu
sc0Vu / aave.ts
Created October 19, 2021 08:36
AAVE APR
import { fetchMultiReserveInfo, DECIMAL, RAY, YEAR_TO_SECONDS, toBN } from "./subgraph"
const main = async () => {
const ids = [
"0x6b175474e89094c44da98b954eedeac495271d0f0xb53c1a33016b2dc2ff3653530bff1848a515c8c5",
"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae90xb53c1a33016b2dc2ff3653530bff1848a515c8c5"
]
const rewardToken = "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9"
const { reserves } = (await fetchMultiReserveInfo(ids))
const reward = reserves.filter((r: Record<string, any>) => r.underlyingAsset === rewardToken)[0]
@sc0Vu
sc0Vu / abi.json
Last active July 23, 2021 02:08
Add abi.json
[{"inputs":[{"internalType":"contract IAuthorizer","name":"authorizer","type":"address"},{"internalType":"contract IWETH","name":"weth","type":"address"},{"internalType":"uint256","name":"pauseWindowDuration","type":"uint256"},{"internalType":"uint256","name":"bufferPeriodDuration","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAuthorizer","name":"newAuthorizer","type":"address"}],"name":"AuthorizerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ExternalBalanceTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IFlashLoanRecipient","name":"recipient",
const BigNumber = require('bignumber.js');
import { JsonRpcProvider } from '@ethersproject/providers';
import {
SOR as SOR2,
SwapTypes,
DisabledOptions,
SwapOptions,
PoolFilter,
fetchSubgraphPools
} from '@balancer-labs/sor2';
@sc0Vu
sc0Vu / Fetch feetokens
Last active April 29, 2021 08:40
Thegraph queries
interface url:
https://thegraph.com/explorer/subgraph/consenlabs/tokenlon-v5-staking
api url:
https://api.thegraph.com/subgraphs/name/consenlabs/tokenlon-v5-staking
feeTokens(where: { enabled: true }) {
id
}
@sc0Vu
sc0Vu / tokens
Last active April 29, 2021 03:53
Update to array
[
"TUSD",
"LON",
"BOND",
"RAI",
"UMA",
"YFI",
"BAT",
"MANA",
"1INCH",