Skip to content

Instantly share code, notes, and snippets.

View snowkidind's full-sized avatar
💭
Was informed that there is a special place in hell for pureJS maximalists....

Keny Ruyter snowkidind

💭
Was informed that there is a special place in hell for pureJS maximalists....
View GitHub Profile
module.exports = {
// given an array of timestamps only, returns a set of relevant timestamps
// to previous hours, only allowing one timestamp per hour
hourlyTimestamps: function (array){
const now = new Date().getTime();
let msh = 3.6e+6; // milliseconds per hour
let hoursGone = 0;
let theseHours = []; // array of representative data on an hourly basis, 0 if no data
let analysisDuration = 168; // hours in a given week.
@snowkidind
snowkidind / caveman.js
Last active May 29, 2020 14:41
Caveman example using SnowSignals model output for simplified forecasting.
// Note: internal implementation. This does not use the snowsignals-api npm package, examples coming soon
// see also http://snowsignals.com:3333/apiDocs
const signalsApi = require('../api.js');
module.exports = {
whatThink: function(job){
return new Promise(async (resolve, reject) => {
job.emaslowemaw = 40;
const chalk = require('chalk');
const player = require('play-sound')();
const eventManager = require('../operations/eventManager');
const diagnostics = require('../utilities/diagnostics.js');
const request = require('request');
let executeTrades = true;
let lastBalanceTime = 0;
let lastBalance;
/*
* initDeliverable.js
*
* Storefront example application where user purchases ERC20, 721 and
* pays fees in the network's native fee curency.
* This is not a complete application, hence a gist.
* Modified version of community-points::transaction.js
* See also
* keny@eastcoastbands.com
*/
@snowkidind
snowkidind / deliverableWithFee.js
Last active September 24, 2020 02:37
OMG Network custom transaction example part 2
/*
* deliverableWithFee.js
*
* Storefront application where user purchases ERC20, 721 and
* pays fees in the network's native fee curency.
* Modified version of community-points::transaction.js
* See also
* keny@eastcoastbands.com
*/
@snowkidind
snowkidind / curveBrownie
Created December 21, 2020 07:38
Notes about getting a mainnet-fork version of curve working for non brownie-centrics
Working with Curve Source Repo, Including running from Brownie.
For starters, there is a pdf manual for brownie that should be found and utilized.
The way to configure the infura or whatever provider is via the command line,
in there you will want to set your mnemonic as well as your infura key or private RPC
$ brownie networks list true
$ brownie networks modify mainnet-fork mnemonic="\"your twelve word mnemonic\""
$ brownie networks modify mainnet host=https://rinkeby.infura.io/v3/dklfjh0g8og8ohg845jhsgr98
@snowkidind
snowkidind / README.md
Last active November 11, 2021 16:53
TDAmeritrade API Notes for Node.js

Access to Ameritrade API

notes that may be helpful for node.js devs

What I've gathered is authorization tokens must be earned first. Authorization tokens are good for three months, once you are setup, you will get two tokens which come as long strings, An access_token and a refresh_token. Access tokens are only valid for 30 minutes so you will need to code to refresh the session using the refresh token frequently. When you refresh, you are given a new access token and that is what you use to "login" or pull from the api for the next period. But in order to get the tokens, you will be required to go through some processes to get a valid token that applies to your app. The following text kind of steers you in that direction...

Making an app

On the api site you will need to make an app, where you pick some random name by using some random numbers. It should be automatically generated but it isnt. For this field item, I simply went to https://www.uuidgenerator.net/ and just grabbed the firs

// load solana transactions into the database
const env = require('node-env-file')
env(__dirname + '/../.env')
const solscan = require('../external/solscan.js')
const { dbLocation, dbChainTx, dbChainTxSync, dbSplAccount, dbKnownWallets } = require('../db')
const { dateutils, decimals, signal, utils } = require('../utils')
const { timeFmtDb, dateNowUTC } = dateutils
const { weiToDisplay, bigD } = decimals
Using const { AlphaRouter } = require('@uniswap/smart-order-router')
when calling
const wei = ethers.utils.parseUnits('100', 6)
const inputAmount = CurrencyAmount.fromRawAmount(USDC, jsbi.BigInt(wei)) // Note inputAmount contains its own JSBI's created by uniswap code which appear to be the source of the error
const route = await router.route(
inputAmount,
UNI,
TradeType.EXACT_INPUT,
{
const env = require('node-env-file')
env(__dirname + '/../.env')
const { ethers, BigNumber } = require('ethers')
const { dbCurrency } = require('../db')
const { multiEth, dateutils, decimals } = require('../utils')
const { round, weiToDisplay, displayToWei, bigD, d } = decimals
const { getProvider, newSigner } = multiEth
const provider = getProvider('mainnet')
const quoterAbi = require('../utils/lib/uniswapQuoter.json')