istox 0.1.119.pre.1 → 0.1.119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/istox/helpers/order_book_prorate.rb +9 -65
- data/lib/istox/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d369f69df949441ab14c3fac0c794b92d17d5fe3a6c5a54859fddecf530eb6c8
|
4
|
+
data.tar.gz: 0c588144bc9be77609880360723f28e7db90764d46eb12063ad57c0d8c497649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f152ebf349268814c9a1dcd73fd9a59475b22d2f55d014afd3e5917c99ac59eb5346129c205ed9d2aecc315cd7ae897caf58a1dd4fa7bf81fbb1e565effda6e4
|
7
|
+
data.tar.gz: 57d185c7104b0a6b7eebc2155c226e8ff3fcc786f19ce99c236b8417db76a9f77e8dd4b846a084b89676313f963661f30f560960c552d9efb75999b3e074c6a8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.1.
|
4
|
+
istox (0.1.115)
|
5
5
|
awesome_print
|
6
6
|
binding_of_caller
|
7
7
|
bunny (>= 2.12.0)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
ffi (1.11.3)
|
96
96
|
globalid (0.4.2)
|
97
97
|
activesupport (>= 4.2.0)
|
98
|
-
google-protobuf (3.11.2
|
98
|
+
google-protobuf (3.11.2)
|
99
99
|
googleapis-common-protos-types (1.0.4)
|
100
100
|
google-protobuf (~> 3.0)
|
101
101
|
graphlient (0.3.7)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
graphql-client (0.16.0)
|
107
107
|
activesupport (>= 3.0)
|
108
108
|
graphql (~> 1.8)
|
109
|
-
grpc (1.26.0
|
109
|
+
grpc (1.26.0)
|
110
110
|
google-protobuf (~> 3.8)
|
111
111
|
googleapis-common-protos-types (~> 1.0)
|
112
112
|
grpc-tools (1.26.0)
|
@@ -1,29 +1,8 @@
|
|
1
1
|
module Istox
|
2
2
|
class OrderBookProrate
|
3
3
|
class << self
|
4
|
-
def allocation(token_price:, min_investment:, bid_block:,
|
5
|
-
invest_step:, hard_cap:, investments
|
6
|
-
|
7
|
-
# make sure is hashes
|
8
|
-
original_investments = investments.as_json.map(&:symbolize_keys)
|
9
|
-
whitelists = whitelists.as_json.map(&:symbolize_keys)
|
10
|
-
investments = investments.as_json.map(&:symbolize_keys)
|
11
|
-
|
12
|
-
# process whitelist
|
13
|
-
whitelists.each do |whitelist|
|
14
|
-
investment = investments.find { |investment1| investment1[:account_id] == whitelist[:account_id] }
|
15
|
-
|
16
|
-
next unless investment.present?
|
17
|
-
|
18
|
-
granted_amount = [::BigDecimal.new(investment[:fiat_amount].to_s), ::BigDecimal.new(whitelist[:guaranteed_allocation].to_s)].min
|
19
|
-
|
20
|
-
next unless granted_amount.positive?
|
21
|
-
|
22
|
-
hard_cap = ::Istox::FMath.sub(hard_cap, granted_amount)
|
23
|
-
investment[:fiat_amount] = Istox::FMath.sub(investment[:fiat_amount], granted_amount)
|
24
|
-
investment[:is_vip] = true
|
25
|
-
investment[:granted_amount] = granted_amount.to_s
|
26
|
-
end
|
4
|
+
def allocation(token_price:, min_investment:, bid_block:,
|
5
|
+
invest_step:, hard_cap:, investments:)
|
27
6
|
|
28
7
|
# sort by id asc
|
29
8
|
interests = investments.sort do |a, b|
|
@@ -47,8 +26,7 @@ module Istox
|
|
47
26
|
hard_cap), 0)
|
48
27
|
result = result.to_d - result.to_d.modulo(invest_step.to_s.to_d)
|
49
28
|
|
50
|
-
|
51
|
-
result = min_investment.to_d if result < min_investment.to_d && interest[:is_vip].blank?
|
29
|
+
result = min_investment.to_d if result < min_investment.to_d
|
52
30
|
|
53
31
|
result
|
54
32
|
else
|
@@ -57,8 +35,6 @@ module Istox
|
|
57
35
|
|
58
36
|
{
|
59
37
|
id: interest[:id],
|
60
|
-
is_vip: interest[:is_vip],
|
61
|
-
granted_amount: interest[:granted_amount],
|
62
38
|
investment: investment.to_s
|
63
39
|
}
|
64
40
|
end
|
@@ -72,14 +48,9 @@ module Istox
|
|
72
48
|
if new_total_interests.to_d > hard_cap.to_s.to_d
|
73
49
|
total_deducting = ::Istox::FMath.sub(new_total_interests, hard_cap)
|
74
50
|
interests.reverse_each do |interest|
|
75
|
-
next unless interest[:investment].to_d > min_investment.to_d
|
51
|
+
next unless interest[:investment].to_d > min_investment.to_d
|
76
52
|
|
77
|
-
|
78
|
-
deductable = if interest[:is_vip]
|
79
|
-
interest[:investment]
|
80
|
-
else
|
81
|
-
::Istox::FMath.sub(interest[:investment], min_investment)
|
82
|
-
end
|
53
|
+
deductable = ::Istox::FMath.sub(interest[:investment], min_investment)
|
83
54
|
|
84
55
|
if deductable.to_d > total_deducting.to_d
|
85
56
|
interest[:investment] = ::Istox::FMath.sub(interest[:investment], total_deducting)
|
@@ -91,41 +62,14 @@ module Istox
|
|
91
62
|
end
|
92
63
|
end
|
93
64
|
|
94
|
-
final_interests = interests
|
95
|
-
interest[:investment] = ::Istox::FMath.add(interest[:investment], interest[:granted_amount]) if interest[:granted_amount].present? &&
|
96
|
-
interest[:granted_amount].to_d.positive?
|
97
|
-
interest.delete(:is_vip)
|
98
|
-
interest.delete(:granted_amount)
|
99
|
-
|
100
|
-
if include_refund_amount
|
101
|
-
original_investment = original_investments.find { |original_investment1| original_investment1[:id] == interest[:id] }
|
102
|
-
interest[:refund_amount] = ::Istox::FMath.sub(original_investment[:fiat_amount], interest[:investment])
|
103
|
-
end
|
104
|
-
interest
|
105
|
-
end
|
65
|
+
final_interests = interests
|
106
66
|
|
107
67
|
else
|
108
|
-
final_interests = interests.each_with_index.map do |interest|
|
109
|
-
|
110
|
-
::Istox::FMath.add(interest[:fiat_amount], interest[:granted_amount])
|
111
|
-
else
|
112
|
-
max_allowed_investor.positive? ? interest[:fiat_amount] : '0'
|
113
|
-
end
|
114
|
-
|
115
|
-
max_allowed_investor -= 1
|
116
|
-
result = {
|
68
|
+
final_interests = interests.each_with_index.map do |interest, i|
|
69
|
+
{
|
117
70
|
id: interest[:id],
|
118
|
-
investment: ::BigDecimal.new(
|
119
|
-
|
71
|
+
investment: i < max_allowed_investor ? ::BigDecimal.new(interest[:fiat_amount].to_s).to_s : ::BigDecimal.new('0').to_s
|
120
72
|
}
|
121
|
-
|
122
|
-
if include_refund_amount
|
123
|
-
original_investment = original_investments.find { |original_investment1| original_investment1[:id] == interest[:id] }
|
124
|
-
refund_amount = ::Istox::FMath.sub(original_investment[:fiat_amount], final_amount)
|
125
|
-
result[:refund_amount] = refund_amount
|
126
|
-
end
|
127
|
-
|
128
|
-
result
|
129
73
|
end
|
130
74
|
end
|
131
75
|
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.119
|
4
|
+
version: 0.1.119
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -411,9 +411,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
411
411
|
version: '0'
|
412
412
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
413
413
|
requirements:
|
414
|
-
- - "
|
414
|
+
- - ">="
|
415
415
|
- !ruby/object:Gem::Version
|
416
|
-
version:
|
416
|
+
version: '0'
|
417
417
|
requirements: []
|
418
418
|
rubygems_version: 3.0.6
|
419
419
|
signing_key:
|