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 / .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",
import { Wallet, Contract, providers, BigNumber, utils } from 'ethers'
import { readFileSync } from 'fs'
import { _TypedDataEncoder } from "@ethersproject/hash"
async function permitSign(
wallet: Wallet,
token: any,
approve: {
spender: string
value: BigNumber
@sc0Vu
sc0Vu / permitabi.json
Last active March 25, 2021 05:53
Add EIP712Domain
[
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
package main
import (
"math/rand"
"runtime"
"github.com/pkg/profile"
)
const count = 100000