Skip to content

Instantly share code, notes, and snippets.

@normanlmfung
normanlmfung / gist:d1fedb7600698735d89d7cbf7253bd71
Created August 8, 2022 03:50
Fetch historical price of SINGLE/USDC from VVS/CRONOS
"""
This script gets the buy/sell prices from the vvs finance (https://vvs.finance/swap) smart contracts
for a given block number and path.
"""
from datetime import datetime
from dataclasses import dataclass
from typing import (
@normanlmfung
normanlmfung / gist:57d0d9d10e1d63cdbbd9aaf2a98a77bc
Created October 6, 2022 01:52
web3 test RPC node provider
import time
from datetime import datetime
from web3 import Web3
RATELIMIT_MESSAGES = [
"Too Many Requests"
]
# https://www.cronosresearch.com/resources/rpc-list
rpc_providers = [
from aptos_sdk.account import Account, AccountAddress
from aptos_sdk.client import RestClient, FaucetClient
from aptos_sdk.ed25519 import PrivateKey
NODE_URL = "https://fullnode.devnet.aptoslabs.com/v1"
FAUCET_URL = "https://tap.devnet.prod.gcp.aptosdev.com"
wallet_address = "xxx"
private_key = "xxx"
@normanlmfung
normanlmfung / gist:43d6a65bfa2fbb6888d540d8ceb1e131
Last active October 21, 2022 07:54
first contract interation with aptos
import time
from typing import Optional
from aptos_sdk.account import Account
from aptos_sdk.account_address import AccountAddress
from aptos_sdk.bcs import Serializer
from aptos_sdk.client import FaucetClient, RestClient
from aptos_sdk.transactions import (
EntryFunction,
TransactionArgument,
@normanlmfung
normanlmfung / gist:8a9fa41ff8f0bc219cc40aa0652d4df4
Last active November 4, 2022 04:29
aptos fetch coin balances
NODE_URL = "https://fullnode.mainnet.aptoslabs.com/v1"
FAUCET_URL = "https://tap.devnet.prod.gcp.aptosdev.com"
wallet_address = None
private_key = None
rest_client = HoustonClient(NODE_URL)
pk = PrivateKey.from_hex(private_key)
addr = AccountAddress.from_hex(wallet_address)
acc = Account(addr, pk)
D:\dev\samples\py>pypy -mpip install aptos_sdk
Defaulting to user installation because normal site-packages is not writeable
Collecting aptos_sdk
Using cached aptos_sdk-0.4.1-py3-none-any.whl (18 kB)
Collecting httpx
Using cached httpx-0.23.0-py3-none-any.whl (84 kB)
Collecting pynacl
Using cached PyNaCl-1.5.0.tar.gz (3.4 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
@normanlmfung
normanlmfung / gist:8a49197fdd26d4a5b145f409f116dcc4
Created November 16, 2022 05:11
aptos query transactions under given wallets
import time
import json
import requests
from datetime import datetime
# https://fullnode.mainnet.aptoslabs.com/v1/spec#/operations/get_account_transactions
all_transactions = []
for wallet in wallets:
try:
url = f"https://fullnode.mainnet.aptoslabs.com/v1/accounts/{wallet.address()}/transactions"
import time
from web3 import Web3
from dydx3 import Client
from dydx3.constants import API_HOST_MAINNET
from dydx3.constants import NETWORK_ID_MAINNET
from dydx3.constants import MARKET_BTC_USD
from dydx3.constants import ORDER_SIDE_BUY
from dydx3.constants import ORDER_TYPE_LIMIT
WEB_PROVIDER_URL = 'https://mainnet.infura.io/v3/????????????????????????????'
@normanlmfung
normanlmfung / gist:22e7c7a4bdfdc951f06b8441ef0acfb7
Last active September 26, 2023 20:32
Crypto Market Making scans for opportunities
from datetime import datetime
import time
from itertools import combinations
import pandas as pd
from ccxt import bybit
from ccxt import okx
from ccxt import gateio
CANDIDATE_FILE_NAME = "mm_candidates.csv"
using System;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main()
{
// Define a password, salt, and iteration count for key derivation
string password = "ThisIsAStrongPassword";