Skip to content

Instantly share code, notes, and snippets.

View riordant's full-sized avatar
💯

tadhg riordant

💯
View GitHub Profile
@riordant
riordant / btceur-arbitrage.py
Last active December 13, 2017 18:13
A small python script to detect bitcoin-euro arbitrage opportunities between a number of popular euro cryptocurrency exchanges.
import requests
import json
import pdb
import time
import sys
BUY = 0
SELL = 1
@riordant
riordant / bittrex_get_usdt_balance.py
Last active January 13, 2018 01:37
A script to get your total USDT balance on Bittrex via the API. Create API/secret combo on Bittrex and insert under 'key' and 'secret'
from time import time
import hashlib
import hmac
import requests
key = "API_KEY"
secret = "SECRET_KEY"
nonce = str(int(time() * 1000))
#sign and call the url.
//to accompany ethers_structs.js
pragma solidity 0.4.21;
pragma experimental ABIEncoderV2;
contract TestContract {
struct SubStruct {
uint256 id;
string description;
}
// setup ethers.js, sends an instance of a struct to an external function, and returns it the instance values.
//load in node: .load ~/path/to/file/ethers_setup.js
//first run testrpc locally.
var privkey = "0x{privkey}" //insert privkey from testrpc here
//dependancies
var solc = require('solc') //include solc application
var fs = require('fs') //include node file manipulation module
@riordant
riordant / ModExp.sol
Last active November 15, 2018 13:24 — forked from lionello/ModExp.sol
Solidity wrapper for Ethereum Byzantium's BigInt `modexp` built-in contract 0x5
// Wrapper for built-in BigNumber_modexp (contract 0x5) as described here. https://github.com/ethereum/EIPs/pull/198
function modexp(bytes memory _base, bytes memory _exp, bytes memory _mod) internal view returns(bytes memory ret) {
assembly {
let bl := mload(_base)
let el := mload(_exp)
let ml := mload(_mod)
@riordant
riordant / clean_zip_creation.cpp
Created December 21, 2018 16:00
Clean ZIP file creation using minizip in C++
/*
(Extension of the main answer for the question here - https://stackoverflow.com/questions/11370908/how-do-i-use-minizip-on-zlib)
* Creates a ZIP file -
after specifying an absolute path to a "root" directory, all filepaths derived from this path are stored in the ZIP file,
with only files and their paths from the root preserved.
eg. root path: /a/b/c/d/
filepaths(from root path): e/f.txt
g.dat
@riordant
riordant / account_liquidity_uniswap.js
Last active November 11, 2020 04:51
Get Liquidity (in USD) for all token pairings for an account from the UniSwap subgraph.
// npm install @apollo/client node-fetch apollo-link-http
// node account_liquidity_uniswap.js
apolloClient = require('@apollo/client')
fetch = require('node-fetch')
httpLink = require('apollo-link-http')
ApolloClient = apolloClient.ApolloClient
HttpLink = httpLink.HttpLink
InMemoryCache = apolloClient.InMemoryCache
@riordant
riordant / account_liquidity_balancer.js
Created November 27, 2020 07:26
Get info on provided address for provided Balancer pool.
// npm install axios
// node account_liquidity_balancer.js
axios = require('axios')
// variables
const poolId = "0xd3d14de568990854705c40221f75efbad8c0c981";
const userAddress = "0x64a63ef1b19519be8afb9080e5725bd608d6f389";
async function getPool(poolId, userAddress) {
const response = await axios({
@riordant
riordant / TokenWithNameSymbolChange.sol
Created January 6, 2021 06:51
OpenZeppelin ERC20 token with changeable name/symbol
pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC20/ERC20Detailed.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/ownership/Ownable.sol";
contract Token is ERC20, ERC20Detailed, Ownable {
string private _name = "DAOMaker Token";
string private _symbol = "DAO";
@riordant
riordant / miner.js
Created January 21, 2021 09:06
Miner for ganache-cli. run ganache-cli -d and this will mine blocks at an average of 5 seconds.
var ethers = require('ethers');
// ganache deterministic mnemonic
const mnemonic = 'myth like bonus scare over problem client lizard pioneer submit female collect';
// use last funded account
const account = "m/44'/60'/0'/0/9";
// default ganache provider
const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545");
function getRandomInt(min, max) {