istox 0.1.74 → 0.1.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/istox/helpers/order_book.rb +17 -15
- data/lib/istox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9753f2f41469c34295741fbb9583c55be00aa683da8b37cf527f3a69ebb4129
|
4
|
+
data.tar.gz: 0c720e7acf4dd1b39f715c645cbdd739052136e367604177069bf1a777545b55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c25907b11f9110a5d9f86f205d256cefd410fd461a4ddbe7e6e72d9411dd99ae10d1e162f3e342a6cda07b6a57beab6b46fce4590e3fbb7ff59072bd558da6fb
|
7
|
+
data.tar.gz: 2d622f312e65b98d5c98e9e7506d16e9dcf7e79f7aa3eb8f6df9759b860924b0987af3393ffe7f2b2d27e9b7845316127720555516396c185354c5e600ed1846
|
data/Gemfile.lock
CHANGED
@@ -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
|
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]
|
23
|
-
total_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
|
30
|
-
unallocated = total_allocated
|
31
|
-
allocated = bid_token
|
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
|
36
|
-
total_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
|
39
|
-
allocated: allocated
|
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]
|
44
|
-
total_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
|
49
|
-
cutoff_price: cutoff_price
|
50
|
-
total_allocated: total_allocated
|
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