Skip to content

Instantly share code, notes, and snippets.

View dmihal's full-sized avatar

David Mihal dmihal

View GitHub Profile
@dmihal
dmihal / crypto_fees_2021.py
Created March 28, 2022 09:33
crypto_fees_2021.py
import requests
import pandas as pd
from datetime import date, timedelta
def cryptofees(_query_str):
fees_requests = requests.get("https://cryptofees.info/api/v1/feesByDay?" + _query_str)
json_data = fees_requests.json()
_df = pd.json_normalize(json_data['data'], record_path=['data'], meta=['id'], errors='ignore')
@dmihal
dmihal / getprice.ts
Created December 17, 2021 20:02
Subgraph getPrice
import { Address, BigInt, BigDecimal, dataSource } from "@graphprotocol/graph-ts"
import { UniswapV2Pair } from '../generated/Pool/UniswapV2Pair'
import { UniswapV2Factory } from '../generated/Pool/UniswapV2Factory'
let UNISWAP_FACTORY = Address.fromString('0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f')
let EIGHTEEN_DECIMALS = BigInt.fromI32(10).pow(18).toBigDecimal()
let wethAddress = new Map<string, Address>()
wethAddress.set('rinkeby', Address.fromString('0xc778417E063141139Fce010982780140Aa0cD5Ab'))
wethAddress.set('mainnet', Address.fromString('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'))
@dmihal
dmihal / L2TransferHelper.sol
Created December 1, 2021 19:14
Ticket payment scripts
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
interface IDai {
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
// function permit(address holder, address spender, uint256 nonce, uint256 expiry,
// bool allowed, uint8 v, bytes32 r, bytes32 s) external;
function transferFrom(address, address, uint256) external returns (bool);
function balanceOf(address) external view returns (uint256);
@dmihal
dmihal / uniswap.ts
Created June 4, 2021 09:39
Get Uniswap prices in a subgraph
import { Address, BigInt, BigDecimal, dataSource } from "@graphprotocol/graph-ts"
import { UniswapV2Pair } from '../generated/Pool/UniswapV2Pair'
import { UniswapV2Factory } from '../generated/Pool/UniswapV2Factory'
let UNISWAP_FACTORY = Address.fromString('0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f')
let EIGHTEEN_DECIMALS = BigInt.fromI32(10).pow(18).toBigDecimal()
let wethAddress = new Map<string, Address>()
wethAddress.set('rinkeby', Address.fromString('0xc778417E063141139Fce010982780140Aa0cD5Ab'))
wethAddress.set('mainnet', Address.fromString('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'))
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC777/IERC777.sol";
import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import "@openzeppelin/contracts/introspection/IERC1820Registry.sol";
abstract contract ERC777Receiver is IERC777Recipient {
IERC1820Registry constant internal ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
import CarbonPlugin from '@burner-wallet/carbon-plugin';
import LinkdropPlugin from '@linkdrop/burner-plugin';
//...
const BurnerWallet = () =>
<ModernUI
title="Basic Wallet"
core={core}
plugins={[
import { xdai, dai, eth, ERC20Asset } from '@burner-wallet/assets';
import Exchange, { Uniswap, XDaiBridge } from '@burner-wallet/exchange';
//...
const mkr = new ERC20Asset({
id: 'mkr',
name: 'Maker',
address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
network: '100',
priceSymbol: 'MKR',
import { xdai, dai, eth, ERC20Asset } from '@burner-wallet/assets';
import Exchange, { Uniswap, XDaiBridge } from '@burner-wallet/exchange';
//...
const mkr = new ERC20Asset({
id: 'mkr',
name: 'Maker',
address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
network: '100',
priceSymbol: 'MKR',
import ENSPlugin from '@burner-wallet/ens-plugin';
import ERC681Plugin from '@burner-wallet/erc681-plugin';
import RecentAccountsPlugin from '@burner-wallet/recent-accounts-plugin';
import MetamaskPlugin from '@burner-wallet/metamask-plugin';
//...
const BurnerWallet = () =>
<ModernUI
title="Basic Wallet"
import { xdai, dai, eth, ERC777Asset, ERC20Asset, NativeAsset } from '@burner-wallet/assets';
// ...
const goerlieth = new NativeAsset({
id: 'geth',
name: 'gETH',
network: '4',
});
const buffidai = new ERC777Asset({