istox 0.2.6.pre.4 → 0.2.10.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +91 -77
- data/lib/istox/helpers/blockchain_service.rb +7 -5
- data/lib/istox/helpers/messaging.rb +19 -0
- data/lib/istox/helpers/order_book_prorate.rb +64 -24
- data/lib/istox/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb9f52ae8d2903dd9945db8f4f9cc35bba65476b38fab52facd2ee7af1a9be3
|
4
|
+
data.tar.gz: 3ea4da15fce4939aa97e1449029ae023b2f6292f320c1ff00c8d86b060a17647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a8ec6ed983aff937d8a6732c451ac2f49e37ab5c325ecc2fe0ec0053ec3cc0de4f42e260d058117a5a16f583e5c708f49382a3065e956382ecb8bfcb15b0b7
|
7
|
+
data.tar.gz: dc287d41fea3dfbf61c1e6398c190bb67efefa45e879e8fa8271c7e50584c2e7ec91d6bfa95b897d0907a5e77a4c3356b524072ec56e85705ed1f9bb322ef32b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.2.
|
4
|
+
istox (0.2.10)
|
5
5
|
amazing_print
|
6
6
|
awesome_print
|
7
7
|
aws-sdk-sns (~> 1)
|
@@ -22,43 +22,43 @@ PATH
|
|
22
22
|
GEM
|
23
23
|
remote: https://rubygems.org/
|
24
24
|
specs:
|
25
|
-
actioncable (5.2.
|
26
|
-
actionpack (= 5.2.
|
25
|
+
actioncable (5.2.6)
|
26
|
+
actionpack (= 5.2.6)
|
27
27
|
nio4r (~> 2.0)
|
28
28
|
websocket-driver (>= 0.6.1)
|
29
|
-
actionmailer (5.2.
|
30
|
-
actionpack (= 5.2.
|
31
|
-
actionview (= 5.2.
|
32
|
-
activejob (= 5.2.
|
29
|
+
actionmailer (5.2.6)
|
30
|
+
actionpack (= 5.2.6)
|
31
|
+
actionview (= 5.2.6)
|
32
|
+
activejob (= 5.2.6)
|
33
33
|
mail (~> 2.5, >= 2.5.4)
|
34
34
|
rails-dom-testing (~> 2.0)
|
35
|
-
actionpack (5.2.
|
36
|
-
actionview (= 5.2.
|
37
|
-
activesupport (= 5.2.
|
38
|
-
rack (~> 2.0)
|
35
|
+
actionpack (5.2.6)
|
36
|
+
actionview (= 5.2.6)
|
37
|
+
activesupport (= 5.2.6)
|
38
|
+
rack (~> 2.0, >= 2.0.8)
|
39
39
|
rack-test (>= 0.6.3)
|
40
40
|
rails-dom-testing (~> 2.0)
|
41
41
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
42
|
-
actionview (5.2.
|
43
|
-
activesupport (= 5.2.
|
42
|
+
actionview (5.2.6)
|
43
|
+
activesupport (= 5.2.6)
|
44
44
|
builder (~> 3.1)
|
45
45
|
erubi (~> 1.4)
|
46
46
|
rails-dom-testing (~> 2.0)
|
47
47
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
48
|
-
activejob (5.2.
|
49
|
-
activesupport (= 5.2.
|
48
|
+
activejob (5.2.6)
|
49
|
+
activesupport (= 5.2.6)
|
50
50
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (5.2.
|
52
|
-
activesupport (= 5.2.
|
53
|
-
activerecord (5.2.
|
54
|
-
activemodel (= 5.2.
|
55
|
-
activesupport (= 5.2.
|
51
|
+
activemodel (5.2.6)
|
52
|
+
activesupport (= 5.2.6)
|
53
|
+
activerecord (5.2.6)
|
54
|
+
activemodel (= 5.2.6)
|
55
|
+
activesupport (= 5.2.6)
|
56
56
|
arel (>= 9.0)
|
57
|
-
activestorage (5.2.
|
58
|
-
actionpack (= 5.2.
|
59
|
-
activerecord (= 5.2.
|
60
|
-
marcel (~> 0.
|
61
|
-
activesupport (5.2.
|
57
|
+
activestorage (5.2.6)
|
58
|
+
actionpack (= 5.2.6)
|
59
|
+
activerecord (= 5.2.6)
|
60
|
+
marcel (~> 1.0.0)
|
61
|
+
activesupport (5.2.6)
|
62
62
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
63
63
|
i18n (>= 0.7, < 2)
|
64
64
|
minitest (~> 5.1)
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
amazing_print (1.3.0)
|
67
67
|
amq-protocol (2.3.2)
|
68
68
|
arel (9.0.0)
|
69
|
-
awesome_print (1.
|
69
|
+
awesome_print (1.9.2)
|
70
70
|
aws-eventstream (1.1.0)
|
71
71
|
aws-partitions (1.318.0)
|
72
72
|
aws-sdk-core (3.96.1)
|
@@ -91,16 +91,17 @@ GEM
|
|
91
91
|
bullet (5.7.6)
|
92
92
|
activesupport (>= 3.0.0)
|
93
93
|
uniform_notifier (~> 1.11.0)
|
94
|
-
bunny (2.
|
94
|
+
bunny (2.18.0)
|
95
95
|
amq-protocol (~> 2.3, >= 2.3.1)
|
96
|
+
sorted_set (~> 1, >= 1.0.2)
|
96
97
|
byebug (11.1.3)
|
97
98
|
coderay (1.1.2)
|
98
|
-
concurrent-ruby (1.1.
|
99
|
+
concurrent-ruby (1.1.9)
|
99
100
|
crass (1.0.6)
|
100
101
|
database_cleaner (1.6.2)
|
101
102
|
debug_inspector (1.1.0)
|
102
103
|
diff-lcs (1.3)
|
103
|
-
erubi (1.
|
104
|
+
erubi (1.10.0)
|
104
105
|
exponential-backoff (0.0.4)
|
105
106
|
factory_bot (4.8.2)
|
106
107
|
activesupport (>= 3.0.0)
|
@@ -111,31 +112,39 @@ GEM
|
|
111
112
|
i18n (~> 0.5)
|
112
113
|
fakeredis (0.7.0)
|
113
114
|
redis (>= 3.2, < 5.0)
|
114
|
-
faraday (1.
|
115
|
+
faraday (1.4.2)
|
116
|
+
faraday-em_http (~> 1.0)
|
117
|
+
faraday-em_synchrony (~> 1.0)
|
118
|
+
faraday-excon (~> 1.1)
|
115
119
|
faraday-net_http (~> 1.0)
|
120
|
+
faraday-net_http_persistent (~> 1.1)
|
116
121
|
multipart-post (>= 1.2, < 3)
|
117
|
-
ruby2_keywords
|
122
|
+
ruby2_keywords (>= 0.0.4)
|
123
|
+
faraday-em_http (1.0.0)
|
124
|
+
faraday-em_synchrony (1.0.0)
|
125
|
+
faraday-excon (1.1.0)
|
118
126
|
faraday-net_http (1.0.1)
|
127
|
+
faraday-net_http_persistent (1.1.0)
|
119
128
|
faraday_middleware (1.0.0)
|
120
129
|
faraday (~> 1.0)
|
121
|
-
ffi (1.15.
|
130
|
+
ffi (1.15.3)
|
122
131
|
globalid (0.4.2)
|
123
132
|
activesupport (>= 4.2.0)
|
124
|
-
google-protobuf (3.
|
125
|
-
googleapis-common-protos-types (1.0.
|
126
|
-
google-protobuf (~> 3.
|
133
|
+
google-protobuf (3.17.3)
|
134
|
+
googleapis-common-protos-types (1.0.6)
|
135
|
+
google-protobuf (~> 3.14)
|
127
136
|
graphlient (0.5.0)
|
128
137
|
faraday (>= 1.0)
|
129
138
|
faraday_middleware
|
130
139
|
graphql-client
|
131
|
-
graphql (1.
|
140
|
+
graphql (1.12.12)
|
132
141
|
graphql-client (0.16.0)
|
133
142
|
activesupport (>= 3.0)
|
134
143
|
graphql (~> 1.8)
|
135
|
-
grpc (1.
|
136
|
-
google-protobuf (~> 3.
|
144
|
+
grpc (1.38.0)
|
145
|
+
google-protobuf (~> 3.15)
|
137
146
|
googleapis-common-protos-types (~> 1.0)
|
138
|
-
grpc-tools (1.
|
147
|
+
grpc-tools (1.38.0)
|
139
148
|
hashie (3.5.7)
|
140
149
|
i18n (0.9.5)
|
141
150
|
concurrent-ruby (~> 1.0)
|
@@ -149,25 +158,24 @@ GEM
|
|
149
158
|
listen (3.0.8)
|
150
159
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
151
160
|
rb-inotify (~> 0.9, >= 0.9.7)
|
152
|
-
loofah (2.
|
161
|
+
loofah (2.10.0)
|
153
162
|
crass (~> 1.0.2)
|
154
163
|
nokogiri (>= 1.5.9)
|
155
164
|
mail (2.7.1)
|
156
165
|
mini_mime (>= 0.1.1)
|
157
|
-
marcel (0.
|
158
|
-
mimemagic (~> 0.3.2)
|
166
|
+
marcel (1.0.1)
|
159
167
|
method_source (0.9.2)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
minitest (5.14.0)
|
168
|
+
mini_mime (1.1.0)
|
169
|
+
mini_portile2 (2.5.3)
|
170
|
+
minitest (5.14.4)
|
164
171
|
multi_json (1.14.1)
|
165
172
|
multipart-post (2.1.1)
|
166
|
-
nio4r (2.
|
167
|
-
nokogiri (1.
|
168
|
-
mini_portile2 (~> 2.
|
169
|
-
|
170
|
-
|
173
|
+
nio4r (2.5.7)
|
174
|
+
nokogiri (1.11.7)
|
175
|
+
mini_portile2 (~> 2.5.0)
|
176
|
+
racc (~> 1.4)
|
177
|
+
oj (3.11.6)
|
178
|
+
ougai (2.0.0)
|
171
179
|
oj (~> 3.10)
|
172
180
|
paranoia (2.4.3)
|
173
181
|
activerecord (>= 4.0, < 6.2)
|
@@ -179,46 +187,48 @@ GEM
|
|
179
187
|
pry (~> 0.10)
|
180
188
|
pry-rails (0.3.9)
|
181
189
|
pry (>= 0.10.4)
|
182
|
-
|
190
|
+
racc (1.5.2)
|
191
|
+
rack (2.2.3)
|
183
192
|
rack-test (1.1.0)
|
184
193
|
rack (>= 1.0, < 3)
|
185
|
-
rails (5.2.
|
186
|
-
actioncable (= 5.2.
|
187
|
-
actionmailer (= 5.2.
|
188
|
-
actionpack (= 5.2.
|
189
|
-
actionview (= 5.2.
|
190
|
-
activejob (= 5.2.
|
191
|
-
activemodel (= 5.2.
|
192
|
-
activerecord (= 5.2.
|
193
|
-
activestorage (= 5.2.
|
194
|
-
activesupport (= 5.2.
|
194
|
+
rails (5.2.6)
|
195
|
+
actioncable (= 5.2.6)
|
196
|
+
actionmailer (= 5.2.6)
|
197
|
+
actionpack (= 5.2.6)
|
198
|
+
actionview (= 5.2.6)
|
199
|
+
activejob (= 5.2.6)
|
200
|
+
activemodel (= 5.2.6)
|
201
|
+
activerecord (= 5.2.6)
|
202
|
+
activestorage (= 5.2.6)
|
203
|
+
activesupport (= 5.2.6)
|
195
204
|
bundler (>= 1.3.0)
|
196
|
-
railties (= 5.2.
|
205
|
+
railties (= 5.2.6)
|
197
206
|
sprockets-rails (>= 2.0.0)
|
198
207
|
rails-dom-testing (2.0.3)
|
199
208
|
activesupport (>= 4.2.0)
|
200
209
|
nokogiri (>= 1.6)
|
201
210
|
rails-html-sanitizer (1.3.0)
|
202
211
|
loofah (~> 2.3)
|
203
|
-
railties (5.2.
|
204
|
-
actionpack (= 5.2.
|
205
|
-
activesupport (= 5.2.
|
212
|
+
railties (5.2.6)
|
213
|
+
actionpack (= 5.2.6)
|
214
|
+
activesupport (= 5.2.6)
|
206
215
|
method_source
|
207
216
|
rake (>= 0.8.7)
|
208
217
|
thor (>= 0.19.0, < 2.0)
|
209
218
|
rake (10.5.0)
|
210
|
-
rb-fsevent (0.
|
219
|
+
rb-fsevent (0.11.0)
|
211
220
|
rb-inotify (0.10.1)
|
212
221
|
ffi (~> 1.0)
|
222
|
+
rbtree (0.4.4)
|
213
223
|
redis (4.1.3)
|
214
224
|
redis-actionpack (5.2.0)
|
215
225
|
actionpack (>= 5, < 7)
|
216
226
|
redis-rack (>= 2.1.0, < 3)
|
217
227
|
redis-store (>= 1.1.0, < 2)
|
218
|
-
redis-activesupport (5.2.
|
228
|
+
redis-activesupport (5.2.1)
|
219
229
|
activesupport (>= 3, < 7)
|
220
230
|
redis-store (>= 1.3, < 2)
|
221
|
-
redis-namespace (1.8.
|
231
|
+
redis-namespace (1.8.1)
|
222
232
|
redis (>= 3.0.4)
|
223
233
|
redis-rack (2.1.3)
|
224
234
|
rack (>= 2.0.8, < 3)
|
@@ -250,27 +260,31 @@ GEM
|
|
250
260
|
rspec-mocks (~> 3.8.0)
|
251
261
|
rspec-support (~> 3.8.0)
|
252
262
|
rspec-support (3.8.0)
|
253
|
-
ruby2_keywords (0.0.
|
254
|
-
|
255
|
-
|
263
|
+
ruby2_keywords (0.0.4)
|
264
|
+
set (1.0.1)
|
265
|
+
slop (4.9.1)
|
266
|
+
sorted_set (1.0.3)
|
267
|
+
rbtree
|
268
|
+
set (~> 1.0)
|
269
|
+
sprockets (4.0.2)
|
256
270
|
concurrent-ruby (~> 1.0)
|
257
271
|
rack (> 1, < 3)
|
258
|
-
sprockets-rails (3.2.
|
272
|
+
sprockets-rails (3.2.2)
|
259
273
|
actionpack (>= 4.0)
|
260
274
|
activesupport (>= 4.0)
|
261
275
|
sprockets (>= 3.0.0)
|
262
276
|
sqlite3 (1.3.13)
|
263
|
-
thor (
|
277
|
+
thor (1.1.0)
|
264
278
|
thread_safe (0.3.6)
|
265
279
|
timecop (0.9.1)
|
266
|
-
tzinfo (1.2.
|
280
|
+
tzinfo (1.2.9)
|
267
281
|
thread_safe (~> 0.1)
|
268
282
|
uniform_notifier (1.11.0)
|
269
283
|
vault (0.16.0)
|
270
284
|
aws-sigv4
|
271
|
-
websocket-driver (0.7.
|
285
|
+
websocket-driver (0.7.5)
|
272
286
|
websocket-extensions (>= 0.1.0)
|
273
|
-
websocket-extensions (0.1.
|
287
|
+
websocket-extensions (0.1.5)
|
274
288
|
|
275
289
|
PLATFORMS
|
276
290
|
ruby
|
@@ -8,18 +8,18 @@ module Istox
|
|
8
8
|
@@blockchain_receipt_klass
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.request(sid:, action:, before:,
|
12
|
-
start(sid: sid, action: action, before: before, execute: execute, is_request: true, request_reason: request_reason)
|
11
|
+
def self.request(sid:, action:, before:, execute:, before_start: nil, request_reason: nil)
|
12
|
+
start(sid: sid, action: action, before: before, before_start: before_start, execute: execute, is_request: true, request_reason: request_reason)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.run(sid:, action:, before:, execute:)
|
16
|
-
start(sid: sid, action: action, before: before, execute: execute)
|
15
|
+
def self.run(sid:, action:, before:, execute:, before_start: nil)
|
16
|
+
start(sid: sid, action: action, before: before, before_start: before_start, execute: execute)
|
17
17
|
end
|
18
18
|
class << self
|
19
19
|
private
|
20
20
|
|
21
21
|
# before is the proc that will be executed before, must return the main model blockchain receipt will bind to
|
22
|
-
def start(sid:, action:, before:, execute:, is_request: false, request_reason: nil)
|
22
|
+
def start(sid:, action:, before:, execute:, before_start: nil, is_request: false, request_reason: nil)
|
23
23
|
# create blockchain receipt first
|
24
24
|
klass = blockchain_receipt_class
|
25
25
|
uuid = ::SecureRandom.uuid
|
@@ -33,6 +33,8 @@ module Istox
|
|
33
33
|
|
34
34
|
chainhub_processing = true
|
35
35
|
|
36
|
+
before_start.call(uuid) if before_start.present?
|
37
|
+
|
36
38
|
::ActiveRecord::Base.transaction do
|
37
39
|
# execute before proc, and get the model that blockchain receipt should bind to
|
38
40
|
model = before.call(uuid)
|
@@ -161,6 +161,25 @@ module Istox
|
|
161
161
|
end
|
162
162
|
template_data_arr.concat(copy_email_data_arr)
|
163
163
|
end
|
164
|
+
|
165
|
+
def push_notification(template_name, template_data_arr)
|
166
|
+
raise ArgumentError, 'Template name and template data arr cannot be empty' if template_name.blank? || template_data_arr.nil?
|
167
|
+
|
168
|
+
return log.info 'Template data is empty, skipping this request' if template_data_arr.empty?
|
169
|
+
|
170
|
+
::Istox::Publisher.manual_publish(
|
171
|
+
exchange: 'message',
|
172
|
+
exchange_type: 'direct',
|
173
|
+
routing_key: 'push_notification.message',
|
174
|
+
message: {
|
175
|
+
type: 'SEND_PUSH_NOTIFICATION',
|
176
|
+
data: {
|
177
|
+
template_name: template_name,
|
178
|
+
template_data_arr_json: template_data_arr.to_json
|
179
|
+
}
|
180
|
+
}
|
181
|
+
)
|
182
|
+
end
|
164
183
|
end
|
165
184
|
end
|
166
185
|
end
|
@@ -2,42 +2,75 @@ module Istox
|
|
2
2
|
class OrderBookProrate
|
3
3
|
class << self
|
4
4
|
def allocation(token_price:, min_investment:, bid_block:, # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
|
5
|
-
invest_step:, hard_cap:, investments:, whitelists: [], include_refund_amount: false
|
5
|
+
invest_step:, hard_cap:, investments:, whitelists: [], include_refund_amount: false,
|
6
|
+
rollover_investments: [])
|
6
7
|
|
7
8
|
# make sure is hashes
|
8
9
|
original_investments = investments.as_json.map(&:symbolize_keys)
|
9
10
|
whitelists = whitelists.as_json.map(&:symbolize_keys)
|
10
11
|
investments = investments.as_json.map(&:symbolize_keys)
|
12
|
+
rollover_investments = rollover_investments.as_json.map(&:symbolize_keys)
|
13
|
+
|
14
|
+
## rollover investment is guaranteed, so it should decrease the hard cap
|
15
|
+
rollover_investments.map do |rollover_investment|
|
16
|
+
hard_cap = ::Istox::FMath.sub(hard_cap, rollover_investment[:fiat_amount])
|
17
|
+
end
|
11
18
|
|
12
19
|
# process whitelist
|
13
20
|
whitelists.each do |whitelist|
|
14
|
-
|
21
|
+
whitelisted_investments = investments.select { |investment1| investment1[:account_id] == whitelist[:account_id] }
|
22
|
+
|
23
|
+
next unless whitelisted_investments.length.positive?
|
15
24
|
|
16
|
-
|
25
|
+
current_guarenteed_amount = ::BigDecimal.new(whitelist[:guaranteed_allocation].to_s)
|
17
26
|
|
18
|
-
|
27
|
+
whitelisted_investments.each do |whitelisted_investment|
|
28
|
+
granted_amount = [::BigDecimal.new(whitelisted_investment[:fiat_amount].to_s), current_guarenteed_amount].min
|
19
29
|
|
20
|
-
|
30
|
+
next unless granted_amount.positive?
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
current_guarenteed_amount = ::Istox::FMath.sub(current_guarenteed_amount, granted_amount).to_d
|
33
|
+
|
34
|
+
hard_cap = ::Istox::FMath.sub(hard_cap, granted_amount)
|
35
|
+
whitelisted_investment[:fiat_amount] = Istox::FMath.sub(whitelisted_investment[:fiat_amount], granted_amount)
|
36
|
+
whitelisted_investment[:is_vip] = true
|
37
|
+
whitelisted_investment[:granted_amount] = granted_amount.to_s
|
38
|
+
end
|
26
39
|
end
|
27
40
|
|
28
41
|
# sort by id asc
|
29
42
|
interests = investments.sort do |a, b|
|
30
43
|
a[:id] <=> b[:id]
|
31
44
|
end
|
45
|
+
|
46
|
+
## check whether each investment already had earlier investment from the same investor
|
47
|
+
interests = interests.map do |interest|
|
48
|
+
earlier_interest = interests.find do |i|
|
49
|
+
i[:account_id] == interest[:account_id] &&
|
50
|
+
i[:id] != interest[:id] && i[:id].to_i < interest[:id].to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
interest[:has_earlier_interest] = earlier_interest.present?
|
54
|
+
|
55
|
+
interest
|
56
|
+
end
|
57
|
+
|
32
58
|
total_interests = 0
|
33
59
|
|
34
60
|
max_allowed_investor = Istox::FMath.round_down(::Istox::FMath.div(hard_cap, min_investment), 0).to_i
|
35
61
|
|
36
|
-
|
62
|
+
allowed_investor_ids = []
|
37
63
|
interests.each_with_index.map do |interest|
|
38
|
-
if interest[:
|
64
|
+
if !allowed_investor_ids.include?(interest[:account_id]) &&
|
65
|
+
interest[:fiat_amount].to_d.positive? && allowed_investor_ids.length < max_allowed_investor
|
66
|
+
allowed_investor_ids.push(interest[:account_id])
|
67
|
+
interest[:to_be_set_zero] = false
|
39
68
|
total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount])
|
40
|
-
|
69
|
+
elsif allowed_investor_ids.include?(interest[:account_id]) && interest[:fiat_amount].to_d.positive?
|
70
|
+
interest[:to_be_set_zero] = false
|
71
|
+
total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount])
|
72
|
+
else
|
73
|
+
interest[:to_be_set_zero] = true
|
41
74
|
end
|
42
75
|
end
|
43
76
|
|
@@ -45,18 +78,18 @@ module Istox
|
|
45
78
|
if total_interests.to_d > hard_cap.to_s.to_d
|
46
79
|
|
47
80
|
# prorate the interests
|
48
|
-
i = 0
|
49
81
|
interests = interests.each_with_index.map do |interest|
|
50
|
-
investment = if
|
82
|
+
investment = if interest[:fiat_amount].to_d.positive? && !interest[:to_be_set_zero]
|
51
83
|
result = ::Istox::FMath.round_down(::Istox::FMath.mul(::Istox::FMath.div(interest[:fiat_amount], total_interests),
|
52
84
|
hard_cap), 0)
|
53
85
|
|
54
86
|
result = result.to_d - result.to_d.modulo(invest_step.to_s.to_d)
|
55
87
|
|
56
88
|
# only set to min investment if is not vip
|
57
|
-
|
89
|
+
if result < min_investment.to_d && interest[:is_vip].blank? && !interest[:has_earlier_interest]
|
90
|
+
result = min_investment.to_d
|
91
|
+
end
|
58
92
|
|
59
|
-
i += 1
|
60
93
|
result
|
61
94
|
else
|
62
95
|
::BigDecimal.new('0').to_s
|
@@ -66,6 +99,7 @@ module Istox
|
|
66
99
|
id: interest[:id],
|
67
100
|
is_vip: interest[:is_vip],
|
68
101
|
granted_amount: interest[:granted_amount],
|
102
|
+
has_earlier_interest: interest[:has_earlier_interest],
|
69
103
|
investment: investment.to_s
|
70
104
|
}
|
71
105
|
end
|
@@ -79,10 +113,10 @@ module Istox
|
|
79
113
|
if new_total_interests.to_d > hard_cap.to_s.to_d
|
80
114
|
total_deducting = ::Istox::FMath.sub(new_total_interests, hard_cap)
|
81
115
|
interests.reverse_each do |interest|
|
82
|
-
next unless interest[:investment].to_d > min_investment.to_d || interest[:is_vip]
|
116
|
+
next unless interest[:investment].to_d > min_investment.to_d || interest[:is_vip] || interest[:has_earlier_interest]
|
83
117
|
|
84
118
|
# allow to deduct to zero if is vip
|
85
|
-
deductable = if interest[:is_vip]
|
119
|
+
deductable = if interest[:is_vip] || interest[:has_earlier_interest]
|
86
120
|
interest[:investment]
|
87
121
|
else
|
88
122
|
::Istox::FMath.sub(interest[:investment], min_investment)
|
@@ -103,10 +137,11 @@ module Istox
|
|
103
137
|
interest[:granted_amount].to_d.positive?
|
104
138
|
interest.delete(:is_vip)
|
105
139
|
interest.delete(:granted_amount)
|
140
|
+
interest.delete(:has_earlier_interest)
|
106
141
|
|
107
142
|
if include_refund_amount
|
108
143
|
original_investment = original_investments.find { |original_investment1| original_investment1[:id] == interest[:id] }
|
109
|
-
interest[:refund_amount] = ::Istox::FMath.sub(original_investment[:fiat_amount], interest[:investment])
|
144
|
+
interest[:refund_amount] = original_investment.present? ? ::Istox::FMath.sub(original_investment[:fiat_amount], interest[:investment]) : '0'
|
110
145
|
end
|
111
146
|
interest
|
112
147
|
end
|
@@ -115,14 +150,12 @@ module Istox
|
|
115
150
|
|
116
151
|
final_interests = interests.each_with_index.map do |interest|
|
117
152
|
final_amount = if interest[:is_vip]
|
118
|
-
vip_fiat_amount =
|
153
|
+
vip_fiat_amount = !interest[:to_be_set_zero] ? interest[:fiat_amount] : '0'
|
119
154
|
::Istox::FMath.add(vip_fiat_amount, interest[:granted_amount])
|
120
155
|
else
|
121
|
-
|
156
|
+
!interest[:to_be_set_zero] ? interest[:fiat_amount] : '0'
|
122
157
|
end
|
123
158
|
|
124
|
-
max_allowed_investor -= 1 if interest[:fiat_amount].to_d.positive?
|
125
|
-
|
126
159
|
result = {
|
127
160
|
id: interest[:id],
|
128
161
|
investment: ::BigDecimal.new(final_amount.to_s).to_s
|
@@ -139,9 +172,16 @@ module Istox
|
|
139
172
|
end
|
140
173
|
end
|
141
174
|
|
175
|
+
transform_rollover_investments = rollover_investments.map do |rollover_investment|
|
176
|
+
rollover_investment[:investment] = ::BigDecimal.new(rollover_investment[:fiat_amount].to_s).to_s
|
177
|
+
rollover_investment[:refund_amount] = ::BigDecimal.new(0).to_s if include_refund_amount
|
178
|
+
|
179
|
+
rollover_investment.select { |k, _v| %i[id investment refund_amount].include?(k) }
|
180
|
+
end
|
181
|
+
|
142
182
|
{
|
143
183
|
cutoff_price: token_price.to_s,
|
144
|
-
interests: final_interests
|
184
|
+
interests: final_interests.concat(transform_rollover_investments)
|
145
185
|
}
|
146
186
|
end
|
147
187
|
end
|
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.2.
|
4
|
+
version: 0.2.10.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -517,7 +517,7 @@ files:
|
|
517
517
|
homepage: http://www.abc.com
|
518
518
|
licenses: []
|
519
519
|
metadata: {}
|
520
|
-
post_install_message:
|
520
|
+
post_install_message:
|
521
521
|
rdoc_options: []
|
522
522
|
require_paths:
|
523
523
|
- lib
|
@@ -532,8 +532,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
532
532
|
- !ruby/object:Gem::Version
|
533
533
|
version: 1.3.1
|
534
534
|
requirements: []
|
535
|
-
rubygems_version: 3.0.
|
536
|
-
signing_key:
|
535
|
+
rubygems_version: 3.0.6
|
536
|
+
signing_key:
|
537
537
|
specification_version: 4
|
538
538
|
summary: istox backend shared gem
|
539
539
|
test_files: []
|