Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Created October 4, 2017 09:05
Show Gist options
  • Select an option

  • Save gkucmierz/36a12647af6c2535453053018e76ebbc to your computer and use it in GitHub Desktop.

Select an option

Save gkucmierz/36a12647af6c2535453053018e76ebbc to your computer and use it in GitHub Desktop.
const walletBalanceChanged = balance => {
const GAS_PRICE = 1e10;
const TX_GAS = 40e3;
const TX_PRICE = GAS_PRICE * TX_GAS;
let txsNum = balance / TX_PRICE;
const txsLvls = [2, 10, 20];
if (txsNum <= 2) {
return { action: 'contractWithdraw', amount: txsLvls[1] * TX_PRICE - balance };
}
if (20 < txsNum) {
return { action: 'contractDeposit', amount: balance - txsLvls[1] * TX_PRICE };
}
return { action: null };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment