Skip to content

Instantly share code, notes, and snippets.

View danoctavian's full-sized avatar
🐻
⚔️ 🏹 🛡

Dan Half-Stack Octavian danoctavian

🐻
⚔️ 🏹 🛡
View GitHub Profile
q = C * MCReth ^ 3
adjustedTokens = - q / (3 * (V0+Vbuy) ^ 3)+ q /(3 * V0 ^ 3)
adjustedPrice = Vbuy / adjustedTokens
finalPrice = adjustedPrice + A
tokensOut = deltaETH / finalPrice
function calculateNxmForEth (Vt0, ethIn, mcrEth, stepSize) {
let previousV;
let currentV = Vt0;
let previousPrice;
let totalTokens = Decimal(0);
while (ethIn.gt('0')) {
const mcrPercentage = currentV.div(mcrEth);
const currentPrice = getSpotPrice(mcrPercentage, mcrEth);
@danoctavian
danoctavian / DoublyLinkedList.js
Created January 4, 2020 07:25
Javascript DoublyLinkedList for programming challenges + property based testing
const jsc = require('jsverify')
const lodash = require('lodash')
class DoublyLinkedList {
constructor(array) {
this.head = null
this.tail = null
this.length = 0
if (array) {
const axios = require('axios')
;(async () => {
const r = await axios.get('https://www.etherchain.org/api/gasPriceOracle')
console.log(`root coroutine Oracle answer: ${r.data.standard}`)
;(async () => {
try {
console.log('Running coroutine 0..')
const r = await axios.get('https://www.etherchain.org/api/gasPriceOracle')
console.log(`coroutine 0 Oracle answer: ${r.data.standard}`)
@danoctavian
danoctavian / gist:faf3668d4defd91483e9203cf204370c
Last active November 20, 2018 10:43
javascript function declaration VS function expression
function f(x) {
console.log(`x this ${this}`)
return y(x) + 1
}
// calling this here works, y is hoisted
console.log(f.bind(123)(3))
function y(y) {
console.log(`y args ${arguments[0]}`)
console.log(`y this ${this}`)
return y * 2

Keybase proof

I hereby claim:

  • I am danoctavian on github.
  • I am danoctavian (https://keybase.io/danoctavian) on keybase.
  • I have a public key ASBMjkwqB9ip6ceCIu1K494X_F1aoaNefQ44GKKqPdhsPAo

To claim this, I am signing this object: