istox 0.1.74 → 0.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddff3bd1460aa44f126c5d5ebb6710654cab919454ff0868e29d6d0b129050c7
4
- data.tar.gz: 7c34f6f2356bb4456123b0a045a036f662d26fe22b7cfbfdfa91b814b1bdf68a
3
+ metadata.gz: f9753f2f41469c34295741fbb9583c55be00aa683da8b37cf527f3a69ebb4129
4
+ data.tar.gz: 0c720e7acf4dd1b39f715c645cbdd739052136e367604177069bf1a777545b55
5
5
  SHA512:
6
- metadata.gz: f1006312fee26837a7727113d555c43f8e9bae7d4e7b2bb5a3a4605fb8dd0326f659eaf32f44cc2c79ba79fddd33726c01d1d2a8a501b574f6040071e8738fa9
7
- data.tar.gz: 9c7a1d084bda1c80294e5b29f0bc3b632059e2919e2ff7156a67c3e944282c4b9950f4b5c7f6c6bd0d40abb858e70dbac77e12f960d96d611cb3d17686c84599
6
+ metadata.gz: c25907b11f9110a5d9f86f205d256cefd410fd461a4ddbe7e6e72d9411dd99ae10d1e162f3e342a6cda07b6a57beab6b46fce4590e3fbb7ff59072bd558da6fb
7
+ data.tar.gz: 2d622f312e65b98d5c98e9e7506d16e9dcf7e79f7aa3eb8f6df9759b860924b0987af3393ffe7f2b2d27e9b7845316127720555516396c185354c5e600ed1846
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.73)
4
+ istox (0.1.74)
5
5
  binding_of_caller
6
6
  bunny (>= 2.12.0)
7
7
  graphlient
@@ -8,6 +8,8 @@ module Istox
8
8
  [b[:token_price], a[:id]] <=> [a[:token_price], b[:id]]
9
9
  end
10
10
 
11
+ total_supply = ::BigDecimal.new(total_supply.to_s)
12
+
11
13
  interests = investments
12
14
  if interests.count > 0
13
15
  cutoff_price = 0.0
@@ -15,39 +17,39 @@ module Istox
15
17
  total_allocated = 0.0
16
18
  total_unallocated = 0.0
17
19
  total_investment = 0.0
18
- cutoff_price = (soft_cap / total_supply).round(4)
20
+ cutoff_price = ::Istox::FMath.div(soft_cap, total_supply)
19
21
  is_cutoff = false
20
22
 
21
23
  interests = interests.map do |item|
22
- bid_token = (item[:fiat_amount] / item[:token_price]).round(4)
23
- total_bid_token += bid_token
24
+ bid_token = ::Istox::FMath.div(item[:fiat_amount], item[:token_price])
25
+ total_bid_token = ::Istox::FMath.add(total_bid_token, bid_token)
24
26
  allocated = 0.0
25
27
  unallocated = bid_token
26
28
  unless is_cutoff
27
29
  allocated = bid_token
28
30
  unallocated = 0.0
29
- if total_allocated + bid_token >= total_supply
30
- unallocated = total_allocated + bid_token - total_supply
31
- allocated = bid_token - unallocated
31
+ if ::BigDecimal.new(::Istox::FMath.add(total_allocated, bid_token)) >= total_supply
32
+ unallocated = ::Istox::FMath.sub(::Istox::FMath.add(total_allocated, bid_token), total_supply)
33
+ allocated = ::Istox::FMath.sub(bid_token, unallocated)
32
34
  cutoff_price = item[:token_price]
33
35
  is_cutoff = true
34
36
  end
35
- total_allocated += allocated
36
- total_unallocated += unallocated
37
+ total_allocated = ::Istox::FMath.add(total_allocated, allocated)
38
+ total_unallocated = ::Istox::FMath.add(total_unallocated, unallocated)
37
39
  end
38
- { id: item[:id], fiat_amount: item[:fiat_amount], bid_price: item[:token_price], bid_token: bid_token.round(4),
39
- allocated: allocated.round(4), unallocated: unallocated.round(4) }
40
+ { id: item[:id], fiat_amount: item[:fiat_amount], bid_price: item[:token_price], bid_token: bid_token,
41
+ allocated: allocated, unallocated: unallocated }
40
42
  end
41
43
 
42
44
  interests = interests.map do |item|
43
- investment = item[:allocated] * cutoff_price
44
- total_investment += investment
45
+ investment = ::Istox::FMath.mul(item[:allocated], cutoff_price)
46
+ total_investment = ::Istox::FMath.add(total_investment, investment)
45
47
  item.merge!(investment: investment)
46
48
  end
47
49
 
48
- return { total_supply: total_supply, total_investment: total_investment.round(4),
49
- cutoff_price: cutoff_price.round(4), total_bid_token: total_bid_token.round(4),
50
- total_allocated: total_allocated.round(4), total_unallocated: total_unallocated.round(4),
50
+ return { total_supply: total_supply, total_investment: total_investment,
51
+ cutoff_price: cutoff_price, total_bid_token: total_bid_token,
52
+ total_allocated: total_allocated, total_unallocated: total_unallocated,
51
53
  interests: interests }
52
54
  else
53
55
  raise 'Registration interest is empty'
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = "0.1.74"
2
+ VERSION = "0.1.75"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.74
4
+ version: 0.1.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng