Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let ether = 0;
  2. let token = 1;
  3. let rate = 500000;
  4.  
  5. function buy(amount) {
  6.     ether += amount;
  7.     let tokensToMint = calc(amount);
  8.     token += tokensToMint;
  9.     console.log(token);
  10. }
  11.  
  12. function calc(amount) {
  13.     // return token * (1 + amount) / ether ^ (rate - 1);
  14.     return token * ((1 + amount / ether) ** (rate / 1000000) - 1)
  15. }
  16.  
  17. for (let i = 0; i < 10; i++) {
  18.     buy(10);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement