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
@snowkidind
snowkidind / dydx integration
Last active February 26, 2023 23:51
dydx nodejs typescript wrapper WIP
const { DydxClient } = require('@dydxprotocol/v3-client')
const Web3 = require('web3')
const web31 = new Web3(process.env.RPC_NODE)
const web32 = new Web3(process.env.RPC_NODE)
const signer1 = web31.eth.accounts.wallet.add(process.env.TRADING_ZERO_PVT_KEY)
const signer2 = web32.eth.accounts.wallet.add(process.env.TRADING_ONE_PVT_KEY)
const { dateutils } = require('../utils')
const { iso8601, dateNowUTC, timeFmtDb } = dateutils
@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
/*
* 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
*/
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;
@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;
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 / js is bad at numbers...
Created May 25, 2019 14:15
Why on earth does JS do the things it does....
function digits(n) {
return Math.floor(Math.log(n) / Math.log(10));
}
function round10(value, exp) {
return decimalAdjust('round', value, exp);
}
function decimalAdjust(type, value, exp) {
@snowkidind
snowkidind / median.js
Last active May 23, 2019 01:13
median
median: function (high_array, low_array) {
let error = false;
const highs = trimArrayTailToSize(high_array, 100);
const lowArr = trimArrayTailToSize(low_array, 100);
const lows = detectBadLowData(lowArr);
const precision = findPrecision(highs);
Group A: tokens with 3 or greater buy indicators
11:BCHABCBTC Rank: 3 Last Price: 0.04130400 triggerPrice: 0.04151000 difference: -0.00020600 duration: 5 gain: -0.50 prevStatus: 2 prevDuration: 1
42:ZRXBTC Rank: 43 Last Price: 0.00007254 triggerPrice: 0.00007254 difference: 0.00000000 duration: 1 gain: 0.00 prevStatus: 1 prevDuration: 1
111:POEBTC Rank: 58 Last Price: 0.00000137 triggerPrice: 0.00000137 difference: 0.00000000 duration: 1 gain: 0.00 prevStatus: 0 prevDuration: 58
141:DGDBTC Rank: 68 Last Price: 0.00459100 triggerPrice: 0.00453400 difference: 0.00005700 duration: 3 gain: 1.26 prevStatus: 1 prevDuration: 1
Group B tokens with 2 buy indicators
7:TNTBTC Rank: 4 Thresh B: Last Price: 0.00000530 triggerPrice: 0.00000466 difference: 0.00000064 duration: 3 gain: 13.73 prevStatus: 0 prevDuration: 5
16:ELFBTC Rank: 38 Thresh B: Last Price: 0.00004409 triggerPrice: 0.00004505 difference: -0.00000096 duration: 4 gain: -2.13 prevStatus: 0 prevDuration: 1
17:BNBBTC Rank: 1 Thresh B: Last Price: 0.004141