istox 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +22 -22
- data/lib/istox/helpers/formatter.rb +3 -3
- data/lib/istox/helpers/order_book_prorate.rb +21 -2
- 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: d6f34f20c9ecc7dc41e7e9ec9c979b82d1789be3ca9eeef71f7178cbe2294c7a
|
4
|
+
data.tar.gz: 9591b79548b047b03b7ab144f1fb01f42d963b03286d72ece0e017a1a8fd0bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df98c2b30e72736c4507f0175c9049815aa1ac3481f1b1a638d7f5a0332befcd04f109cb25d1341bfd5a6bd72b039356b90c8a31b32e404dfd6e0987ab924f81
|
7
|
+
data.tar.gz: 94d6069c5be4d86398cb97e7b47257f6de1585df342242a7d8bd84af807687b4bfb972cfe64a58f9888e94b41213508e363b8dc9b94044588dabc39a36d1d125
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.3.
|
4
|
+
istox (0.3.8)
|
5
5
|
amazing_print
|
6
6
|
awesome_print
|
7
7
|
aws-sdk-sns (~> 1)
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
bullet (5.7.6)
|
91
91
|
activesupport (>= 3.0.0)
|
92
92
|
uniform_notifier (~> 1.11.0)
|
93
|
-
bunny (2.
|
93
|
+
bunny (2.20.3)
|
94
94
|
amq-protocol (~> 2.3, >= 2.3.1)
|
95
95
|
sorted_set (~> 1, >= 1.0.2)
|
96
96
|
byebug (11.1.3)
|
@@ -139,21 +139,21 @@ GEM
|
|
139
139
|
ffi (1.15.5)
|
140
140
|
globalid (0.4.2)
|
141
141
|
activesupport (>= 4.2.0)
|
142
|
-
google-protobuf (3.
|
143
|
-
googleapis-common-protos-types (1.3.
|
142
|
+
google-protobuf (3.21.5-x86_64-darwin)
|
143
|
+
googleapis-common-protos-types (1.3.2)
|
144
144
|
google-protobuf (~> 3.14)
|
145
|
-
graphlient (0.
|
145
|
+
graphlient (0.6.0)
|
146
146
|
faraday (>= 1.0)
|
147
147
|
faraday_middleware
|
148
148
|
graphql-client
|
149
|
-
graphql (
|
150
|
-
graphql-client (0.
|
149
|
+
graphql (2.0.17)
|
150
|
+
graphql-client (0.18.0)
|
151
151
|
activesupport (>= 3.0)
|
152
|
-
graphql
|
153
|
-
grpc (1.
|
154
|
-
google-protobuf (~> 3.
|
152
|
+
graphql
|
153
|
+
grpc (1.48.0-x86_64-darwin)
|
154
|
+
google-protobuf (~> 3.19)
|
155
155
|
googleapis-common-protos-types (~> 1.0)
|
156
|
-
grpc-tools (1.
|
156
|
+
grpc-tools (1.48.0)
|
157
157
|
hashie (3.5.7)
|
158
158
|
i18n (0.9.5)
|
159
159
|
concurrent-ruby (~> 1.0)
|
@@ -178,15 +178,15 @@ GEM
|
|
178
178
|
mini_portile2 (2.5.3)
|
179
179
|
minitest (5.14.4)
|
180
180
|
multi_json (1.14.1)
|
181
|
-
multipart-post (2.
|
181
|
+
multipart-post (2.3.0)
|
182
182
|
nio4r (2.5.7)
|
183
183
|
nokogiri (1.11.7)
|
184
184
|
mini_portile2 (~> 2.5.0)
|
185
185
|
racc (~> 1.4)
|
186
|
-
oj (3.
|
186
|
+
oj (3.14.2)
|
187
187
|
ougai (2.0.0)
|
188
188
|
oj (~> 3.10)
|
189
|
-
paranoia (2.6.
|
189
|
+
paranoia (2.6.1)
|
190
190
|
activerecord (>= 5.1, < 7.1)
|
191
191
|
pry (0.12.2)
|
192
192
|
coderay (~> 1.1.0)
|
@@ -225,10 +225,10 @@ GEM
|
|
225
225
|
rake (>= 0.8.7)
|
226
226
|
thor (>= 0.19.0, < 2.0)
|
227
227
|
rake (10.5.0)
|
228
|
-
rb-fsevent (0.11.
|
228
|
+
rb-fsevent (0.11.2)
|
229
229
|
rb-inotify (0.10.1)
|
230
230
|
ffi (~> 1.0)
|
231
|
-
rbtree (0.4.
|
231
|
+
rbtree (0.4.6)
|
232
232
|
redis (4.3.1)
|
233
233
|
redis-actionpack (5.3.0)
|
234
234
|
actionpack (>= 5, < 8)
|
@@ -237,8 +237,8 @@ GEM
|
|
237
237
|
redis-activesupport (5.3.0)
|
238
238
|
activesupport (>= 3, < 8)
|
239
239
|
redis-store (>= 1.3, < 2)
|
240
|
-
redis-namespace (1.
|
241
|
-
redis (>=
|
240
|
+
redis-namespace (1.10.0)
|
241
|
+
redis (>= 4)
|
242
242
|
redis-rack (2.1.4)
|
243
243
|
rack (>= 2.0.8, < 3)
|
244
244
|
redis-store (>= 1.2, < 2)
|
@@ -246,8 +246,8 @@ GEM
|
|
246
246
|
redis-actionpack (>= 5.0, < 6)
|
247
247
|
redis-activesupport (>= 5.0, < 6)
|
248
248
|
redis-store (>= 1.2, < 2)
|
249
|
-
redis-store (1.9.
|
250
|
-
redis (>= 4, <
|
249
|
+
redis-store (1.9.2)
|
250
|
+
redis (>= 4, < 6)
|
251
251
|
rspec (3.8.0)
|
252
252
|
rspec-core (~> 3.8.0)
|
253
253
|
rspec-expectations (~> 3.8.0)
|
@@ -270,8 +270,8 @@ GEM
|
|
270
270
|
rspec-support (~> 3.8.0)
|
271
271
|
rspec-support (3.8.0)
|
272
272
|
ruby2_keywords (0.0.5)
|
273
|
-
set (1.0.
|
274
|
-
slop (4.
|
273
|
+
set (1.0.3)
|
274
|
+
slop (4.10.1)
|
275
275
|
sorted_set (1.0.3)
|
276
276
|
rbtree
|
277
277
|
set (~> 1.0)
|
@@ -10,8 +10,8 @@ module Istox
|
|
10
10
|
input = ::BigDecimal.new(input.to_s).round(precision, round_mode)
|
11
11
|
|
12
12
|
input = input.abs if abs_num
|
13
|
-
|
14
|
-
result =
|
13
|
+
# result = format("%.#{precision}f", input) # may produce floating point error
|
14
|
+
result = (input.truncate(precision).to_s('F') + '000000000000000000')[/.*\..{#{precision}}/]
|
15
15
|
|
16
16
|
parts = result.to_s.split('.')
|
17
17
|
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, '\\1,')
|
@@ -19,7 +19,7 @@ module Istox
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# format a money, eg. 20000.134 > SGD 20,000.14, position can be :front or :behind, abs_num: whether to absolute the number
|
22
|
-
def money(input, round_mode: :half_up, precision: nil,
|
22
|
+
def money(input, currency:, round_mode: :half_up, precision: nil, position: :front, abs_num: false, hide_currency: false)
|
23
23
|
# precision = ::Istox::CommonHelper.get_currency_decimal(currency, precision)
|
24
24
|
|
25
25
|
decimal_place = if precision.present?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Istox
|
2
2
|
class OrderBookProrate
|
3
3
|
class << self
|
4
|
-
def allocation(token_price:, min_investment:, bid_block:,
|
4
|
+
def allocation(token_price:, min_investment:, bid_block:,
|
5
5
|
invest_step:, hard_cap:, investments:, whitelists: [], include_refund_amount: false,
|
6
6
|
rollover_investments: [])
|
7
7
|
|
@@ -77,6 +77,8 @@ module Istox
|
|
77
77
|
# only need to handle when oversubscribe
|
78
78
|
if total_interests.to_d > hard_cap.to_s.to_d
|
79
79
|
|
80
|
+
puts total_interests.inspect
|
81
|
+
|
80
82
|
# prorate the interests
|
81
83
|
interests = interests.each_with_index.map do |interest|
|
82
84
|
investment = if interest[:fiat_amount].to_d.positive? && !interest[:to_be_set_zero]
|
@@ -100,7 +102,8 @@ module Istox
|
|
100
102
|
is_vip: interest[:is_vip],
|
101
103
|
granted_amount: interest[:granted_amount],
|
102
104
|
has_earlier_interest: interest[:has_earlier_interest],
|
103
|
-
investment: investment.to_s
|
105
|
+
investment: investment.to_s,
|
106
|
+
temp_refunded_amount: ::Istox::FMath.sub(interest[:fiat_amount], investment)
|
104
107
|
}
|
105
108
|
end
|
106
109
|
|
@@ -130,6 +133,21 @@ module Istox
|
|
130
133
|
total_deducting = ::Istox::FMath.sub(total_deducting, deductable)
|
131
134
|
end
|
132
135
|
end
|
136
|
+
elsif new_total_interests.to_d < hard_cap.to_s.to_d
|
137
|
+
remaining_amount = ::Istox::FMath.sub(hard_cap, new_total_interests)
|
138
|
+
|
139
|
+
interests.each do |interest|
|
140
|
+
next unless interest[:temp_refunded_amount].to_d > invest_step.to_s.to_d
|
141
|
+
|
142
|
+
can_be_add_amount = invest_step.to_s.to_d
|
143
|
+
|
144
|
+
interest[:investment] = ::Istox::FMath.add(interest[:investment], can_be_add_amount)
|
145
|
+
interest[:temp_refunded_amount] = ::Istox::FMath.sub(interest[:temp_refunded_amount], can_be_add_amount)
|
146
|
+
|
147
|
+
remaining_amount = ::Istox::FMath.sub(remaining_amount, can_be_add_amount)
|
148
|
+
|
149
|
+
break if remaining_amount.to_s.to_d < invest_step.to_s.to_d
|
150
|
+
end
|
133
151
|
end
|
134
152
|
|
135
153
|
final_interests = interests.map do |interest|
|
@@ -137,6 +155,7 @@ module Istox
|
|
137
155
|
interest[:granted_amount].to_d.positive?
|
138
156
|
interest.delete(:is_vip)
|
139
157
|
interest.delete(:granted_amount)
|
158
|
+
interest.delete(:temp_refunded_amount)
|
140
159
|
interest.delete(:has_earlier_interest)
|
141
160
|
|
142
161
|
if include_refund_amount
|
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.3.
|
4
|
+
version: 0.3.9
|
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:
|
11
|
+
date: 2024-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -505,7 +505,7 @@ files:
|
|
505
505
|
homepage: http://www.abc.com
|
506
506
|
licenses: []
|
507
507
|
metadata: {}
|
508
|
-
post_install_message:
|
508
|
+
post_install_message:
|
509
509
|
rdoc_options: []
|
510
510
|
require_paths:
|
511
511
|
- lib
|
@@ -520,8 +520,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
520
520
|
- !ruby/object:Gem::Version
|
521
521
|
version: '0'
|
522
522
|
requirements: []
|
523
|
-
rubygems_version: 3.
|
524
|
-
signing_key:
|
523
|
+
rubygems_version: 3.0.6
|
524
|
+
signing_key:
|
525
525
|
specification_version: 4
|
526
526
|
summary: istox backend shared gem
|
527
527
|
test_files: []
|