Skip to content

Instantly share code, notes, and snippets.

@kolya-t
Created March 1, 2019 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolya-t/2c5d50761020464f7fb97ba66d886c7b to your computer and use it in GitHub Desktop.
Save kolya-t/2c5d50761020464f7fb97ba66d886c7b to your computer and use it in GitHub Desktop.
function getPrice(heirsCount, tokensCount, checkInterval, activeTo) {
const gasPrice = 40000000000;
const constructGas = 1660000;
const constructGasPerHeir = 40000;
const checkGas = 25000;
const triggerGas = 32000;
const triggerGasPerHeir = 42000;
const triggerGasPerToken = 18000;
const constructPrice = gasPrice * (constructGas + heirsCount * constructGasPerHeir);
const checkCount = Math.max(Math.abs((new Date().getTime() / 1000 - activeTo) / checkInterval), 1);
const checkPrice = checkGas * gasPrice * checkCount;
const triggerPrice = gasPrice * (triggerGas + triggerGasPerHeir * heirsCount + triggerGasPerToken * tokensCount * 2);
return constructPrice + checkPrice + triggerPrice;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment