@stefanobernardi/

filecoin-sale

Ruby

Calculating the potential total amount raised in the Filecoin token sale

fork
loading
Files
  • main.rb

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5902076450323088","path":"main.rb","file":{"path":"main.rb","content":{"asEncoding":{"base64":"Y29pbnMgPSAwLjAwICMganVzdCB0byBpbml0aWFsaXplLgpwcmljZSA9IDEuMDAgIyB0aGUgcHJpY2UgRmlsZWNvaW4gc3RhdGVzIGlzIHRoZSBtaW5pbXVtCmFtb3VudF9yYWlzZWQgPSA1MjAwMDAwMC4wMCAjIHRoZXkndmUgc2FpZCB0aGV5IGFscmVhZHkgc29sZCAkNTJNIGluIHRoZSBwcmVzYWxlCnRvdGFsX2ZpbGVjb2luX3NvbGQgPSA4NTAwMDAwMC4wMCAjIHRoZSBudW1iZXIgb2YgRmlsZWNvaW5zIGFscmVhZHkgc29sZCBpbiB0aGUgcHJlc2FsZS4gVGhpcyB3b3VsZCBiZSAkNTJNL3ByaWNlIChwcmljZSB3YXMgJDAuNzUgYW5kIGludmVzdG9ycyBjb3VsZCBjaG9vc2UgdXAgdG8gMzAlIGRpc2NvdW50LiBJJ20gdXNpbmcgODVNIGNvaW5zIGFzIGFuIGFzc3VtcHRpb24gKG1pbiA2OU0gbWF4IDk5TSkuCmF2ZXJhZ2VfaW52ZXN0bWVudCA9IDEwMDAwMC4wMCAjIEknbSBhbHJlYWR5IGJlaW5nIGdlbmVyb3VzIGhlcmUKd2hpbGUgdG90YWxfZmlsZWNvaW5fc29sZCA8ICgyMDAwMDAwMDAuMDAgLSBjb2lucykgZG8gIyAyMDBNIGlzIHRoZSBtYXggYW1vdW50IG9mIGNvaW5zCiAgcHJpY2UgPSBhbW91bnRfcmFpc2VkLzQwMDAwMDAwLjAwICMgdGhpcyBpcyB0aGVpciBmdW5jdGlvbiwgaXQncyBhbHdheXMgbW9yZSB0aGFuICQxCiAgcHJpY2UgPSBwcmljZSAqIDAuOSAjIGlmIHlvdSB3YW50IHRvIG1vZGVsIGFuIGF2ZXJhZ2UgZGlzY291bnQgcGVvcGxlIHdpbGwgY2hvb3NlCgljb2lucyA9IGF2ZXJhZ2VfaW52ZXN0bWVudCAvIHByaWNlICMgdGhlIGFtb3VudCBvZiBjb2lucyB5b3UgZ2V0IHdpdGggZXZlcnkgaW52ZXN0bWVudAoJYW1vdW50X3JhaXNlZCA9IGFtb3VudF9yYWlzZWQgKyBhdmVyYWdlX2ludmVzdG1lbnQgIyBsZXQncyBhZGQgdGhlIGludmVzdG1lbnQgdG8gdGhlIHRvdGFsIHJhaXNlZAoJdG90YWxfZmlsZWNvaW5fc29sZCA9IHRvdGFsX2ZpbGVjb2luX3NvbGQgKyBjb2lucyAjIGxldCdzIGFkZCB0aGUgbmV3IGNvaW5zIHRvIHRoZSB0b3RhbAogICMgcHV0cyAiQm91Z2h0ICIgKyBjb2lucy50b19zICsgIiBGaWxlY29pbnMgYXQgIiArIHByaWNlLnRvX3MgKyAiLiBUb3RhbCByYWlzZWQgPSAkICIgKyBhbW91bnRfcmFpc2VkLnRvX3MucmV2ZXJzZS5nc3ViKC8oXGR7M30pKD89XGQpLywgJ1xcMSwnKS5yZXZlcnNlICsgIiwgYW5kIHRvdGFsIGNvaW5zID0gIiArIHRvdGFsX2ZpbGVjb2luX3NvbGQudG9fcwplbmQKcHV0cyAiRmluYWwgcHJpY2UgaXMgJCIgKyBwcmljZS50b19zCnB1dHMgIlJhaXNlZCAkIiArICBhbW91bnRfcmFpc2VkLnRvX3MucmV2ZXJzZS5nc3ViKC8oXGR7M30pKD89XGQpLywgJ1xcMSwnKS5yZXZlcnNlCnB1dHMgIlRvdGFsIGZpbGVjb2lucyBzb2xkOiAiICsgdG90YWxfZmlsZWNvaW5fc29sZC50b19z"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
coins = 0.00 # just to initialize.
price = 1.00 # the price Filecoin states is the minimum
amount_raised = 52000000.00 # they've said they already sold $52M in the presale
total_filecoin_sold = 85000000.00 # the number of Filecoins already sold in the presale. This would be $52M/price (price was $0.75 and investors could choose up to 30% discount. I'm using 85M coins as an assumption (min 69M max 99M).
average_investment = 100000.00 # I'm already being generous here
while total_filecoin_sold < (200000000.00 - coins) do # 200M is the max amount of coins
  price = amount_raised/40000000.00 # this is their function, it's always more than $1
  price = price * 0.9 # if you want to model an average discount people will choose
	coins = average_investment / price # the amount of coins you get with every investment
	amount_raised = amount_raised + average_investment # let's add the investment to the total raised
	total_filecoin_sold = total_filecoin_sold + coins # let's add the new coins to the total
  # puts "Bought " + coins.to_s + " Filecoins at " + price.to_s + ". Total raised = $ " + amount_raised.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse + ", and total coins = " + total_filecoin_sold.to_s
end
puts "Final price is $" + price.to_s
puts "Raised $" +  amount_raised.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
puts "Total filecoins sold: " + total_filecoin_sold.to_s
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]