Skip to content

Instantly share code, notes, and snippets.

View raypulver's full-sized avatar

Raymond Pulver IV raypulver

  • North Stonington, CT
View GitHub Profile
@raypulver
raypulver / get-balance-sheet.js
Last active February 6, 2018 20:43
script to get a JSON snapshot of the balances for a particular token
'use strict';
const db = require('../lib/db');
const { argv } = require('yargs');
const {
method,
bindKey,
partialRight,
property
} = require('lodash');
@raypulver
raypulver / idex-test-suite.js
Created January 31, 2018 19:08
test suite for new idex contract
'use strict';
const expect = require('chai').expect;
const eth = require('./eth');
const { join } = require('path');
const util = require('./util');
const { generate } = require('ethereumjs-wallet');
const {
unitMap,
soliditySha3
const BN = require('bignumber.js');
const buyAmount = new BN('1000').mul(new BN(10).pow(8)).toPrecision();
function generateSignature(...signingData) {
const raw = web3Util.soliditySha3(...signingData);
const salted = ethUtil.hashPersonalMessage(ethUtil.toBuffer(raw));
const {
v,
r,
s
} = lodash.mapValues(ethUtil.ecsign(salted, ethUtil.toBuffer('0x'+user.pk.trim())), (value, key) => key === 'v' ? value : ethUtil.bufferToHex(value));
//console.log("Signature complete! ", v, r, s);
return {v: v, r: r, s: s};
@raypulver
raypulver / ticker.js
Created January 4, 2018 21:50
transform in promise with no anonymous functions
const mapToMarkets = map(property('market'));
const fetchTickers = () => {
const markets = mapToMarkets(store.getState().targetedMarkets);
return mapSeries(markets, bindKey(liqui, 'getTicker')).then(zipObject(markets));
};
@raypulver
raypulver / client-modals.txt
Created January 3, 2018 19:16
IDEX client side modals
Client Modals:
client/eth.js —
1. Transaction is already pending from this address
happens when the client tries to send a new tx while one is pending
2. Error: User denied transaction signature.
happens when metamask rejects signing a message
@raypulver
raypulver / errors.txt
Created January 3, 2018 18:17
IDEX error codes and descriptions
TradeError --
'1': 'Order not found',
This happens when the client tries to fill an order that has been sniped during his attempt to match and sign and dispatch
'2': 'Trade signature invalid. Please try again.',
Self explanatory, invalid signature from the client (probably due to ledger issues)
'3': 'You have insufficient funds to place this order.',
Taker has insufficient funds to execute trade
@raypulver
raypulver / bot-parameters.txt
Created January 1, 2018 20:51
parameters for market making bot
- Selectable markets
- For each market
-- percentage of total ETH appropriated for market
-- percentage of total coin balance appropriated for market making with
-- For both buy and sell side
--- Amount of orders
--- Curve to use for setting prices
--- Curve to use for setting amount of total supply (spread out across orders)
- Curves
- For each curve
@raypulver
raypulver / dvip-remaining.js
Created December 20, 2017 19:53
Simple script to get the DVIP balance in the sale contract
// using web3@1.0.0-beta.26, bluebird, bignumber.js, and lodash
'use strict';
const BN = require('bignumber.js');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/aR7WPNCrZhhnYRnn8yRT'));
const { bindKey } = require('lodash');
const { promisify } = require('bluebird');
const encodeFunctionCall = bindKey(web3.eth.abi, 'encodeFunctionCall');
const payload = encodeFunctionCall({
@raypulver
raypulver / fetch-stats.js
Created December 10, 2017 04:43
token sale ES5 UI scripting serverless loading data from infura or backup
(function () {
'use strict';
var RPC = 'https://mainnet.infura.io/aR7WPNCrZhhnYRnn8yRT';
RPC = 'http://159.203.127.98:9176';
var saleAddress = '0x0d845706DdC11f181303a80828219c714ceb3687';
var dvipAddress = '0xadc46ff5434910bd17b24ffb429e585223287d7f';
var beneficiaryAddress = '0x532cc8b8AA6d61Da69c17E7C6197B0e43862a468';
var auraPerDvip = '50000';
var totalSaleDvip = '1600';
var pollInterval = 10000;