This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import time | |
| import timeit | |
| from typing import Type | |
| from sqlalchemy.orm import Session | |
| from sqlalchemy.sql import text | |
| from dex_ohlcv.db import get_real_database | |
| from dex_ohlcv.models.uniswap import Base, UniswapLikeCandle, Pair |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """A simple trade execution report database by using Python dataclass, Redis and JSON. | |
| - A very simple database for arbitrage trade execution reports. | |
| - Dataclasses are serialised and deserialised to JSON that is stored in the Redis. | |
| - There is type validation for members and class-types. | |
| - Class-types like Decimal are converted back to their original format upon deserialisation. | |
| - Optional members are supported and the member presence is validated. | |
| - Past trades can be iterated in either order by creation. | |
| - A simple CSV exported is provided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const HDWallet = require('ethereum-hdwallet') | |
| const mnemonic = 'your seed prhase goes here' | |
| const hdwallet = HDWallet.fromMnemonic(mnemonic) | |
| for(let i=0; i<1000; i++) { | |
| console.log(`0x${hdwallet.derive(`m/44'/60'/0'/0/${i}`).getAddress().toString('hex')}, 3.33`) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _console(context: ProcessContext): | |
| imported_objects = {} | |
| import datetime | |
| from IPython import embed | |
| from dex_ohlcv.models.base import Base | |
| imported_objects["db_session_scoper"] = context.create_db_session_scoper() | |
| imported_objects["web3"] = context.create_web3() | |
| imported_objects["datetime"] = datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import enum | |
| import datetime | |
| import sqlalchemy as sa | |
| from sqlalchemy import case, union_all | |
| from sqlalchemy.orm import Session, aliased | |
| from .utils import TimeStampedBaseModel | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Get all approve() transaction | |
| -- Web3.utils.keccak256("approve(address,uint256)").slice(0, 10); | |
| -- '0x095ea7b3' | |
| WITH txdata as ( | |
| SELECT tx.hash as txid, tx.block_timestamp as block_timestamp, cast(tx.receipt_gas_used as numeric) * cast(tx.gas_price as numeric) as cost FROM | |
| bigquery-public-data.crypto_ethereum.transactions as tx | |
| where | |
| tx.input | |
| LIKE "0x095ea7b3%") | |
| SELECT (SUM(cost) / POWER(10, 18)) as eth_cost from txdata; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LiquidityChanged(TransactionEvent): | |
| """A sampled liquidity at any moment.""" | |
| __tablename__ = "liquidity" | |
| delta0 = sa.Column(Int257, nullable=False, index=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """A stateful event scanner for Ethereum-based blockchains using web3.py. | |
| With the stateful mechanism, you can do one batch scan or incremental scans, | |
| where events are added where the scanner left last time. | |
| Copyright 2021 Mikko Ohtamaa, https://twitter.com/moo9000, licensed under MIT | |
| """ | |
| import datetime | |
| import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Web3.utils.keccak256("approve(address,uint256)").slice(0, 10); | |
| -- '0x095ea7b3' | |
| WITH txdata as ( | |
| SELECT tx.hash as txid, cast(tx.receipt_gas_used as numeric) * cast(tx.gas_price as numeric) as cost FROM | |
| bigquery-public-data.crypto_ethereum.transactions as tx | |
| where | |
| tx.input | |
| LIKE "0x095ea7b3%") | |
| SELECT (SUM(cost) / POWER(10, 18)) as eth_cost from txdata; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # This is a faux solc stub that runs a dockerized solc | |
| # | |
| VERSION=$SOLC_VERSION | |
| # Docker complains about abs paths | |
| ME=`dirname "$0"` | |
| ME=`realpath $ME` |