istox 0.3.8 → 0.3.9

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: '08ae3c962e156368285e8e07ea655d428b93310ab4137a370dd6ab95f7ac00cc'
4
- data.tar.gz: 6f6c813fee420de9cd06e0175069e8f8f2e3b2d70eebe8e792962f3cac419190
3
+ metadata.gz: d6f34f20c9ecc7dc41e7e9ec9c979b82d1789be3ca9eeef71f7178cbe2294c7a
4
+ data.tar.gz: 9591b79548b047b03b7ab144f1fb01f42d963b03286d72ece0e017a1a8fd0bbd
5
5
  SHA512:
6
- metadata.gz: 534957ad873114132ca7fb35d79570f72c6020785d8bb7b71d7935fd98e6d2cb42d82166270dacdc6cf0f44dc8b649af80ec9724e2f022ce3646b0cbdf950a35
7
- data.tar.gz: 945b8a9e2bf22dfccd62c2a0c7a3d38cf0c682c095d8ef28ddcfa66f74388e7891e31389b986c0351537cf061cb4c54c8ae789957d3f1492a349b65170b1071f
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.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.19.0)
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.19.4-x86_64-darwin)
143
- googleapis-common-protos-types (1.3.0)
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.5.0)
145
+ graphlient (0.6.0)
146
146
  faraday (>= 1.0)
147
147
  faraday_middleware
148
148
  graphql-client
149
- graphql (1.13.6)
150
- graphql-client (0.17.0)
149
+ graphql (2.0.17)
150
+ graphql-client (0.18.0)
151
151
  activesupport (>= 3.0)
152
- graphql (~> 1.10)
153
- grpc (1.43.1-universal-darwin)
154
- google-protobuf (~> 3.18)
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.43.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.1.1)
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.13.11)
186
+ oj (3.14.2)
187
187
  ougai (2.0.0)
188
188
  oj (~> 3.10)
189
- paranoia (2.6.0)
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.1)
228
+ rb-fsevent (0.11.2)
229
229
  rb-inotify (0.10.1)
230
230
  ffi (~> 1.0)
231
- rbtree (0.4.5)
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.8.1)
241
- redis (>= 3.0.4)
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.1)
250
- redis (>= 4, < 5)
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.2)
274
- slop (4.9.1)
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)
@@ -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:, # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
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
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.3.8'.freeze
2
+ VERSION = '0.3.9'.freeze
3
3
  end
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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2024-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print