Skip to content

Instantly share code, notes, and snippets.

Nikola Vuković sterlu

Block or report user

Report or block sterlu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sterlu
sterlu / Savings APR-APY conversion.js
Created Feb 24, 2020
Convert between APR & APY yearly returns
View Savings APR-APY conversion.js
const SECONDS_PER_YEAR = 365.25 * 24 * 60 * 60;
const BLOCKS_IN_A_YEAR = SECONDS_PER_YEAR / 14;
/**
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
*
* @param interest {Number} APY as percentage (ie. 6)
* @param frequency {Number} Compounding frequency (times a year)
* @returns {Number} APR as percentage (ie. 5.82 for APY of 6%)
*/
@sterlu
sterlu / ens-reverse.js
Last active Apr 2, 2019
Registering an ENS domain and setting up reverse lookup
View ens-reverse.js
// Disclamer:
// We are assuming Web3@1.0 is instantiated with a MetaMask provider or similar
const yourAccount = (await web3.eth.getAccounts())[0].toLowerCase()
function namehash(name) {
var node = '0x0000000000000000000000000000000000000000000000000000000000000000';
if (name !== '') {
var labels = name.split(".");
for(var i = labels.length - 1; i >= 0; i--) {
You can’t perform that action at this time.