cns 0.9.1 → 0.9.2
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 +4 -4
- data/.rubocop.yml +2 -2
- data/Gemfile.lock +2 -2
- data/lib/cns/apibc.rb +4 -4
- data/lib/cns/apice.rb +9 -9
- data/lib/cns/bigquery.rb +106 -226
- data/lib/cns/bitcoinde.rb +11 -9
- data/lib/cns/etherscan.rb +12 -37
- data/lib/cns/greymass.rb +5 -10
- data/lib/cns/kraken.rb +15 -12
- data/lib/cns/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54f4e0bf0d8e859722edf7c9a4430d625b3789ac50761b03061db0050956062
|
4
|
+
data.tar.gz: 7e2fbaa074c7cb51157849b8db9798271cf54f4b7b6404869278dd48ceedd55c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917f7140253dbaa7e0619792c3912fb78533618640de779c473f86a1665e68ec5688d2f0d6624c0ed33678e698d19a5cadc47b5c20ce833d5273a8cbf7f87ff7
|
7
|
+
data.tar.gz: e56c3b51a6e0d539569b9deace1d491da55a63afaf44e3aaa08abb25807272c33164b55626f9de526b0660d27823514a6524c074b5449995c6d6161f0154a74f
|
data/.rubocop.yml
CHANGED
@@ -18,7 +18,7 @@ Metrics/AbcSize:
|
|
18
18
|
|
19
19
|
# Formatting Rules
|
20
20
|
Layout/LineLength:
|
21
|
-
Max:
|
21
|
+
Max: 185
|
22
22
|
AllowHeredoc: true
|
23
23
|
AllowURI: true
|
24
24
|
|
@@ -26,7 +26,7 @@ Layout/IndentationWidth:
|
|
26
26
|
Width: 2
|
27
27
|
|
28
28
|
Layout/SpaceInsideHashLiteralBraces:
|
29
|
-
EnforcedStyle:
|
29
|
+
EnforcedStyle: no_space
|
30
30
|
|
31
31
|
Layout/SingleLineBlockChain:
|
32
32
|
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cns (0.9.
|
4
|
+
cns (0.9.2)
|
5
5
|
curb
|
6
6
|
faraday
|
7
7
|
google-cloud-bigquery
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
logger
|
57
57
|
faraday-net_http (3.4.0)
|
58
58
|
net-http (>= 0.5.0)
|
59
|
-
google-apis-bigquery_v2 (0.
|
59
|
+
google-apis-bigquery_v2 (0.84.0)
|
60
60
|
google-apis-core (>= 0.15.0, < 2.a)
|
61
61
|
google-apis-core (0.16.0)
|
62
62
|
addressable (~> 2.5, >= 2.5.1)
|
data/lib/cns/apibc.rb
CHANGED
@@ -89,7 +89,7 @@ module Cns
|
|
89
89
|
def connection(base_url)
|
90
90
|
Faraday.new(base_url) do |conn|
|
91
91
|
conn.request(:json) # Automatically encodes body as JSON
|
92
|
-
conn.headers = {
|
92
|
+
conn.headers = {content_type: 'application/json', accept: 'application/json', user_agent: 'blockchain-api-client'}
|
93
93
|
conn.options.timeout = 30
|
94
94
|
conn.options.open_timeout = 10
|
95
95
|
conn.adapter(Faraday.default_adapter)
|
@@ -98,10 +98,10 @@ module Cns
|
|
98
98
|
|
99
99
|
# Generic Etherscan API request handler
|
100
100
|
def etherscan_req(action, address, page = 1, params = {})
|
101
|
-
params = {
|
101
|
+
params = {module: 'account', action: action, address: address, page: page, apikey: ENV.fetch('ETHERSCAN_API_KEY')}.merge(params)
|
102
102
|
parse_json(@etherscan_conn.get('/api', params))
|
103
103
|
rescue Faraday::Error
|
104
|
-
{
|
104
|
+
{status: '0'}
|
105
105
|
end
|
106
106
|
|
107
107
|
# Generic method for paginated Etherscan requests
|
@@ -127,7 +127,7 @@ module Cns
|
|
127
127
|
|
128
128
|
# Generic Greymass API error
|
129
129
|
def gm_erro
|
130
|
-
{
|
130
|
+
{core_liquid_balance: 0, total_resources: {net_weight: 0, cpu_weight: 0}}
|
131
131
|
end
|
132
132
|
|
133
133
|
# Generic Greymass API request handler
|
data/lib/cns/apice.rb
CHANGED
@@ -7,7 +7,7 @@ require('json')
|
|
7
7
|
|
8
8
|
# @author Hernani Rodrigues Vaz
|
9
9
|
module Cns
|
10
|
-
API = {
|
10
|
+
API = {de: 'https://api.bitcoin.de/v4', us: 'https://api.kraken.com/0/private'}.freeze
|
11
11
|
|
12
12
|
# classe para acesso dados centralized exchanges
|
13
13
|
class Apice
|
@@ -30,21 +30,21 @@ module Cns
|
|
30
30
|
|
31
31
|
# @return [Array<Hash>] trades bitcoinde
|
32
32
|
def trades_de
|
33
|
-
pag_de_req("#{API[:de]}/trades", {
|
33
|
+
pag_de_req("#{API[:de]}/trades", {state: 1}, :trades)
|
34
34
|
rescue Curl::Err::CurlError
|
35
35
|
[]
|
36
36
|
end
|
37
37
|
|
38
38
|
# @return [Array<Hash>] depositos uniformizados bitcoinde
|
39
39
|
def deposits_de
|
40
|
-
pag_de_req("#{API[:de]}/btc/deposits", {
|
40
|
+
pag_de_req("#{API[:de]}/btc/deposits", {state: 2}, :deposits) { |i| i.map { |h| deposit_unif(h) } }
|
41
41
|
rescue Curl::Err::CurlError
|
42
42
|
[]
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [Array<Hash>] withdrawals uniformizadas bitcoinde
|
46
46
|
def withdrawals_de
|
47
|
-
pag_de_req("#{API[:de]}/btc/withdrawals", {
|
47
|
+
pag_de_req("#{API[:de]}/btc/withdrawals", {state: 1}, :withdrawals) { |i| i.map { |h| withdrawal_unif(h) } }
|
48
48
|
rescue Curl::Err::CurlError
|
49
49
|
[]
|
50
50
|
end
|
@@ -52,7 +52,7 @@ module Cns
|
|
52
52
|
# @return [Hash] saldos kraken
|
53
53
|
def account_us
|
54
54
|
uri = 'Balance'
|
55
|
-
ops = {
|
55
|
+
ops = {nonce: nnc}
|
56
56
|
run_curl(@curl, "#{API[:us]}/#{uri}", method: :post, post_data: ops, headers: hus(uri, ops))
|
57
57
|
parse_json(@curl).fetch(:result, {})
|
58
58
|
rescue Curl::Err::CurlError
|
@@ -81,7 +81,7 @@ module Cns
|
|
81
81
|
ofs = 0
|
82
82
|
loop do
|
83
83
|
sleep(ofs.zero? ? 0 : 2)
|
84
|
-
ops = {
|
84
|
+
ops = {nonce: nnc, ofs: ofs}
|
85
85
|
run_curl(@curl, "#{API[:us]}/#{uri}", method: :post, post_data: ops, headers: hus(uri, ops))
|
86
86
|
batch = parse_json(@curl).fetch(:result, {}).fetch(key, [])
|
87
87
|
break if batch.empty?
|
@@ -133,7 +133,7 @@ module Cns
|
|
133
133
|
|
134
134
|
# @return [Hash] deposito uniformizado bitcoinde
|
135
135
|
def deposit_unif(has)
|
136
|
-
{
|
136
|
+
{add: has[:address], time: Time.parse(has[:created_at]), qt: has[:amount], txid: Integer(has[:deposit_id])}.merge(tp: 'deposit', moe: 'btc', fee: '0')
|
137
137
|
end
|
138
138
|
|
139
139
|
# @return [Hash] withdrawal uniformizada bitcoinde
|
@@ -156,7 +156,7 @@ module Cns
|
|
156
156
|
key = ENV.fetch('BITCOINDE_API_KEY', nil)
|
157
157
|
md5 = ['GET', qde, key, non, Digest::MD5.hexdigest('')].join('#')
|
158
158
|
mac = OpenSSL::HMAC.hexdigest('sha256', ENV.fetch('BITCOINDE_API_SECRET', nil), md5)
|
159
|
-
{
|
159
|
+
{'X-API-KEY': key, 'X-API-NONCE': non, 'X-API-SIGNATURE': mac}
|
160
160
|
end
|
161
161
|
|
162
162
|
# @param [String] qus query a incluir no pedido HTTP
|
@@ -167,7 +167,7 @@ module Cns
|
|
167
167
|
key = ENV.fetch('KRAKEN_API_KEY', nil)
|
168
168
|
sha = ['/0/private/', qus, Digest::SHA256.digest("#{ops[:nonce]}#{URI.encode_www_form(ops)}")].join
|
169
169
|
mac = OpenSSL::HMAC.digest('sha512', Base64.decode64(ENV.fetch('KRAKEN_API_SECRET', nil)), sha)
|
170
|
-
{
|
170
|
+
{'api-key': key, 'api-sign': Base64.strict_encode64(mac)}
|
171
171
|
end
|
172
172
|
end
|
173
173
|
end
|
data/lib/cns/bigquery.rb
CHANGED
@@ -9,16 +9,26 @@ module Cns
|
|
9
9
|
FO = File.expand_path("~/#{File.basename($PROGRAM_NAME)}.log")
|
10
10
|
EM = %i[EOS XETH ZEUR btc eth]
|
11
11
|
TB = {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
netht: %w[blocknumber timestamp txhash nonce blockhash transactionindex axfrom axto iax value gas gasprice gasused iserror txreceipt_status input contractaddress dias],
|
13
|
+
hetht: %i[blockNumber timeStamp hash nonce blockHash transactionIndex from to iax value gas gasPrice gasUsed isError txreceipt_status input contractAddress],
|
14
|
+
nethi: %w[blocknumber timestamp txhash axfrom axto iax value contractaddress input type gas gasused traceid iserror errcode dias],
|
15
|
+
hethi: %i[blockNumber timeStamp hash from to iax value contractAddress input type gas gasUsed traceId isError errCode],
|
16
|
+
nethp: %w[blocknumber timestamp blockreward iax dias],
|
17
|
+
hethp: %i[blockNumber timeStamp blockReward iax],
|
18
|
+
nethw: %w[withdrawalindex validatorindex address amount blocknumber timestamp dias],
|
19
|
+
hethw: %i[withdrawalIndex validatorIndex address amount blockNumber timeStamp],
|
20
|
+
nethk: %w[blocknumber timestamp txhash nonce blockhash transactionindex axfrom axto iax value tokenname tokensymbol tokendecimal gas gasprice gasused input contractaddress dias],
|
21
|
+
hethk: %i[blockNumber timeStamp hash nonce blockHash transactionIndex from to iax value tokenName tokenSymbol tokenDecimal gas gasPrice gasUsed input contractAddress],
|
17
22
|
neost: %w[gseq aseq bnum time contract action acfrom acto iax amount moeda memo dias],
|
23
|
+
heost: %i[global_action_seq account_action_seq block_num block_time account name from to iax quantity moe memo],
|
18
24
|
cdet: %w[txid time tp user btc eur dtc dias],
|
25
|
+
hdet: %i[trade_id successfully_finished_at type username btc eur trade_marked_as_paid_at],
|
19
26
|
cdel: %w[txid time tp add moe qt fee],
|
27
|
+
hdel: %i[nxid time tp add moe qtd fee],
|
20
28
|
cust: %w[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers dias],
|
21
|
-
|
29
|
+
hust: %i[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers],
|
30
|
+
cusl: %w[txid refid time type aclass asset amount fee],
|
31
|
+
husl: %i[txid refid time type aclass asset amount fee]
|
22
32
|
}
|
23
33
|
|
24
34
|
# classe para processar bigquery
|
@@ -65,93 +75,81 @@ module Cns
|
|
65
75
|
Time.now.strftime('TRANSACOES %Y-%m-%d %H:%M:%S')
|
66
76
|
end
|
67
77
|
|
68
|
-
# insere
|
78
|
+
# insere dados novos kraken/bitcoinde/etherscan/greymass no bigquery
|
69
79
|
def ptudo
|
70
80
|
puts("#{tct} #{pus}, #{pde}, #{peth}, #{peos}")
|
71
81
|
end
|
72
82
|
|
73
|
-
# insere
|
83
|
+
# insere dados novos kraken/etherscan no bigquery
|
74
84
|
def pwkrk
|
75
85
|
puts("#{tct} #{pus}, #{peth}")
|
76
86
|
end
|
77
87
|
|
78
|
-
# insere
|
88
|
+
# insere dados novos etherscan no bigquery
|
79
89
|
def pweth
|
80
90
|
puts("#{tct} #{peth}")
|
81
91
|
end
|
82
92
|
|
83
|
-
# insere
|
93
|
+
# insere dados novos etherscan no bigquery (output to file)
|
84
94
|
def pceth
|
85
|
-
File.open(FO, mode: 'a') { |
|
95
|
+
File.open(FO, mode: 'a') { |o| o.puts("#{tct} #{pethc}") }
|
86
96
|
end
|
87
97
|
|
88
98
|
private
|
89
99
|
|
90
|
-
# insere transacoes blockchain novas nas tabelas netht (norml), nethi (internas), nethp (block), nethw (withdrawals), nethk (token)
|
91
|
-
#
|
92
100
|
# @return [String] linhas & tabelas afetadas
|
93
101
|
def peth
|
94
|
-
|
102
|
+
dml_out(apies, %w[ETH], %i[netht nethi nethp nethw nethk])
|
95
103
|
end
|
96
104
|
|
97
|
-
# insere transacoes blockchain novas nas tabelas netht (norml), nethi (internas), nethp (block), nethw (withdrawals), nethk (token)
|
98
|
-
#
|
99
105
|
# @return [String] linhas & tabelas afetadas
|
100
106
|
def pethc
|
101
|
-
|
107
|
+
dml_out(apiesc, %w[ETH], %i[netht nethi nethp nethw nethk])
|
102
108
|
end
|
103
109
|
|
104
|
-
# insere transacoes exchange kraken novas nas tabelas ust (trades), usl (ledger)
|
105
|
-
#
|
106
110
|
# @return [String] linhas & tabelas afetadas
|
107
111
|
def pus
|
108
|
-
|
112
|
+
dml_out(apius, %w[KRAKEN], %i[cust cusl])
|
109
113
|
end
|
110
114
|
|
111
|
-
# insere transacoes exchange bitcoinde novas nas tabelas det (trades), del (ledger)
|
112
|
-
#
|
113
115
|
# @return [String] linhas & tabelas afetadas
|
114
116
|
def pde
|
115
|
-
|
117
|
+
dml_out(apide, %w[BITCOINDE], %i[cdet cdel])
|
116
118
|
end
|
117
119
|
|
118
|
-
# insere transacoes blockchain novas na tabela eos
|
119
|
-
#
|
120
120
|
# @return [String] linhas & tabelas afetadas
|
121
121
|
def peos
|
122
|
-
|
122
|
+
dml_out(apigm, %w[EOS], %i[neost])
|
123
123
|
end
|
124
124
|
|
125
125
|
# cria job bigquery & verifica execucao
|
126
|
-
#
|
127
126
|
# @param cmd (see sql)
|
128
127
|
# @return [Boolean] job ok?
|
129
128
|
def job?(cmd)
|
130
|
-
@job = api.query_job(cmd)
|
129
|
+
@job = api.query_job(cmd, priority: 'BATCH')
|
131
130
|
job.wait_until_done!
|
132
|
-
return
|
131
|
+
return true unless job.failed?
|
133
132
|
|
134
133
|
puts("BigQuery Error: #{job.error['message']}")
|
135
|
-
|
134
|
+
false
|
136
135
|
end
|
137
136
|
|
138
137
|
# cria Structured Query Language (SQL) job bigquery
|
139
|
-
#
|
140
138
|
# @param [String] cmd comando SQL a executar
|
141
139
|
# @param [String] res resultado quando SQL tem erro
|
142
140
|
# @return [Google::Cloud::Bigquery::Data] resultado do SQL
|
143
141
|
def sql(cmd, res = [])
|
144
|
-
@sqr = job?(cmd) ?
|
142
|
+
@sqr = job?(cmd) ? job.data : res
|
145
143
|
end
|
146
144
|
|
147
145
|
# cria Data Manipulation Language (DML) job bigquery
|
148
|
-
#
|
149
146
|
# @param cmd (see sql)
|
150
147
|
# @return [Integer] numero linhas afetadas
|
151
148
|
def dml(cmd)
|
152
|
-
job?(cmd) ?
|
149
|
+
job?(cmd) ? job.num_dml_affected_rows : 0
|
153
150
|
end
|
154
151
|
|
152
|
+
# @return [Etherscan] API blockchain ETH
|
155
153
|
def apiesg(prx)
|
156
154
|
Etherscan.new(
|
157
155
|
{
|
@@ -171,270 +169,152 @@ module Cns
|
|
171
169
|
@apies ||= apiesg('netb')
|
172
170
|
end
|
173
171
|
|
174
|
-
# @return [Etherscan] API blockchain ETH
|
172
|
+
# @return [Etherscan] API blockchain ETH (cron)
|
175
173
|
def apiesc
|
176
174
|
@apiesc ||= apiesg('netc')
|
177
175
|
end
|
178
176
|
|
179
177
|
# @return [Greymass] API blockchain EOS
|
180
178
|
def apigm
|
181
|
-
@apigm ||= Greymass.new({
|
179
|
+
@apigm ||= Greymass.new({wb: sql("select * from #{BD}.weos ORDER BY ax"), nt: sql("select * from #{BD}.neosx")}, ops)
|
182
180
|
end
|
183
181
|
|
184
182
|
# @return [Kraken] API exchange kraken
|
185
183
|
def apius
|
186
|
-
@apius ||= Kraken.new({
|
184
|
+
@apius ||= Kraken.new({sl: sql("select * from #{BD}.cuss").first, nt: sql("select * from #{BD}.cust"), nl: sql("select * from #{BD}.cusl")}, ops)
|
187
185
|
end
|
188
186
|
|
189
187
|
# @return [Bitcoinde] API exchange bitcoinde
|
190
188
|
def apide
|
191
|
-
@apide ||= Bitcoinde.new({
|
189
|
+
@apide ||= Bitcoinde.new({sl: sql("select * from #{BD}.cdes").first, nt: sql("select * from #{BD}.cdet"), nl: sql("select * from #{BD}.cdel")}, ops)
|
192
190
|
end
|
193
191
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
next if novx.empty?
|
198
|
-
|
199
|
-
# puts(insert_cus(prx, itm, novx))
|
200
|
-
str << format(' %<n>i %<t>s', n: dml(insert_cus(prx, itm, novx)), t: "#{prx}#{itm}")
|
201
|
-
end
|
202
|
-
str.join
|
192
|
+
# @return [String] comando insert SQL formatado
|
193
|
+
def ins_sql(tbl, lin)
|
194
|
+
"INSERT #{BD}.#{tbl} (#{TB[tbl].join(',')}) VALUES #{lin.map { |i| send("#{tbl}_val", i) }.join(',')}"
|
203
195
|
end
|
204
196
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
197
|
+
# @return [String] relatorio execucao dml
|
198
|
+
def dml_out(src, str, ltb)
|
199
|
+
str.concat(
|
200
|
+
ltb.filter_map do |itm|
|
201
|
+
novx = src.send("nov#{itm}")
|
202
|
+
next if novx.empty?
|
209
203
|
|
210
|
-
|
211
|
-
|
212
|
-
|
204
|
+
format(' %<n>i %<t>s', n: dml(ins_sql(itm, %i[cust cusl].include?(itm) ? novx.values : novx)), t: "#{itm}")
|
205
|
+
end
|
206
|
+
)
|
213
207
|
str.join
|
214
208
|
end
|
215
209
|
|
216
|
-
# @return [String]
|
217
|
-
def
|
218
|
-
|
210
|
+
# @return [String] escapes SQL user input strings
|
211
|
+
def escape_sql(value)
|
212
|
+
value.gsub("'", "''").gsub('\\', '\\\\')
|
219
213
|
end
|
220
214
|
|
221
|
-
# @return [String]
|
222
|
-
def insert_out(prx, tbl, lin)
|
223
|
-
"INSERT #{BD}.#{prx}#{tbl} (#{TB[tbl].join(',')}) VALUES #{lin.map { |itm| send("#{prx}#{tbl}_val", itm) }.join(',')}"
|
224
|
-
end
|
225
|
-
|
226
|
-
# SQL value formatting methods with improved safety
|
215
|
+
# @return [String] SQL string formatting
|
227
216
|
def fqt(value)
|
228
217
|
value.nil? || value.empty? ? 'null' : "'#{value}'"
|
229
218
|
end
|
230
219
|
|
220
|
+
# @return [String] SQL string formatting with improved safety
|
221
|
+
def fqe(value)
|
222
|
+
value.to_s.empty? ? 'null' : "'#{escape_sql(value.to_s)}'"
|
223
|
+
end
|
224
|
+
|
225
|
+
# @return [String] SQL numeric formatting
|
231
226
|
def fnm(value)
|
232
227
|
"CAST(#{value.to_d} AS NUMERIC)"
|
233
228
|
rescue StandardError
|
234
229
|
'CAST(0 AS NUMERIC)'
|
235
230
|
end
|
236
231
|
|
232
|
+
# @return [String] SQL integer formatting
|
237
233
|
def fin(value)
|
238
|
-
Integer(value).to_s
|
234
|
+
Integer(value || 0).to_s
|
239
235
|
rescue StandardError
|
240
236
|
'0'
|
241
237
|
end
|
242
238
|
|
243
|
-
|
244
|
-
"PARSE_DATETIME('%s', '#{sec.round}')"
|
245
|
-
end
|
246
|
-
|
239
|
+
# @return [String] SQL timestamp formatting
|
247
240
|
def fts(value)
|
248
|
-
"DATETIME(TIMESTAMP('#{value.iso8601}'))"
|
241
|
+
value.nil? ? 'null' : "DATETIME(TIMESTAMP('#{value.iso8601}'))"
|
242
|
+
end
|
243
|
+
|
244
|
+
# @return [String] formated SQL values for tables
|
245
|
+
def fvals(hsh, kys, idx = nil)
|
246
|
+
vls =
|
247
|
+
kys.map do |k|
|
248
|
+
case k
|
249
|
+
when :account_action_seq, :block_num, :blockNumber, :global_action_seq, :isError, :nonce, :timeStamp, :tokenDecimal, :transactionIndex, :nxid, :txreceipt_status, :validatorIndex, :withdrawalIndex then fin(hsh[k])
|
250
|
+
when :amount, :btc, :cost, :fee, :gas, :gasPrice, :gasUsed, :margin, :price, :quantity, :value, :vol, :eur, :blockReward, :qtd then fnm(hsh[k])
|
251
|
+
when :block_time, :successfully_finished_at, :time, :trade_marked_as_paid_at then fts(hsh[k])
|
252
|
+
when :memo, :input, :misc then fqe(hsh[k])
|
253
|
+
else fqt(hsh[k])
|
254
|
+
end
|
255
|
+
end
|
256
|
+
vls << fin(ops.dig(:h, hsh[idx].to_s)) if idx
|
257
|
+
"(#{vls.join(',')})"
|
249
258
|
end
|
250
259
|
|
251
260
|
# @param [Hash] htx transacao norml etherscan
|
252
|
-
# @return [String] valores formatados netht
|
261
|
+
# @return [String] valores formatados netht
|
253
262
|
def netht_val(htx)
|
254
|
-
|
255
|
-
fin(htx[:blockNumber]),
|
256
|
-
fin(htx[:timeStamp]),
|
257
|
-
fqt(htx[:hash]),
|
258
|
-
fin(htx[:nonce]),
|
259
|
-
fqt(htx[:blockHash]),
|
260
|
-
fin(htx[:transactionIndex]),
|
261
|
-
fqt(htx[:from]),
|
262
|
-
fqt(htx[:to]),
|
263
|
-
fqt(htx[:iax]),
|
264
|
-
fnm(htx[:value]),
|
265
|
-
fnm(htx[:gas]),
|
266
|
-
fnm(htx[:gasPrice]),
|
267
|
-
fnm(htx[:gasUsed]),
|
268
|
-
fin(htx[:isError]),
|
269
|
-
fin(htx[:txreceipt_status]),
|
270
|
-
fqt(htx[:input]),
|
271
|
-
fqt(htx[:contractAddress]),
|
272
|
-
fin(ops.dig(:h, htx[:hash]))
|
273
|
-
]
|
274
|
-
"(#{vls.join(',')})"
|
263
|
+
fvals(htx, TB[:hetht], :hash)
|
275
264
|
end
|
276
265
|
|
277
266
|
# @param [Hash] htx transacao internas etherscan
|
278
|
-
# @return [String] valores formatados nethi
|
267
|
+
# @return [String] valores formatados nethi
|
279
268
|
def nethi_val(htx)
|
280
|
-
|
281
|
-
fin(htx[:blockNumber]),
|
282
|
-
fin(htx[:timeStamp]),
|
283
|
-
fqt(htx[:hash]),
|
284
|
-
fqt(htx[:from]),
|
285
|
-
fqt(htx[:to]),
|
286
|
-
fqt(htx[:iax]),
|
287
|
-
fnm(htx[:value]),
|
288
|
-
fqt(htx[:contractAddress]),
|
289
|
-
fqt(htx[:input]),
|
290
|
-
fqt(htx[:type]),
|
291
|
-
fnm(htx[:gas]),
|
292
|
-
fnm(htx[:gasUsed]),
|
293
|
-
fqt(htx[:traceId]),
|
294
|
-
fin(htx[:isError]),
|
295
|
-
fqt(htx[:errCode]),
|
296
|
-
fin(ops.dig(:h, htx[:hash]))
|
297
|
-
]
|
298
|
-
"(#{vls.join(',')})"
|
269
|
+
fvals(htx, TB[:hethi], :hash)
|
299
270
|
end
|
300
271
|
|
301
272
|
# @param [Hash] htx transacao block etherscan
|
302
|
-
# @return [String] valores formatados
|
273
|
+
# @return [String] valores formatados nethp
|
303
274
|
def nethp_val(htx)
|
304
|
-
|
305
|
-
"(#{vls.join(',')})"
|
275
|
+
fvals(htx, TB[:hethp], :blockNumber)
|
306
276
|
end
|
307
277
|
|
308
278
|
# @param [Hash] htx transacao withdrawals etherscan
|
309
|
-
# @return [String] valores formatados
|
279
|
+
# @return [String] valores formatados nethw
|
310
280
|
def nethw_val(htx)
|
311
|
-
|
312
|
-
fin(htx[:withdrawalIndex]),
|
313
|
-
fin(htx[:validatorIndex]),
|
314
|
-
fqt(htx[:address]),
|
315
|
-
fnm(htx[:amount]),
|
316
|
-
fin(htx[:blockNumber]),
|
317
|
-
fin(htx[:timeStamp]),
|
318
|
-
fin(ops.dig(:h, htx[:withdrawalIndex]))
|
319
|
-
]
|
320
|
-
"(#{vls.join(',')})"
|
281
|
+
fvals(htx, TB[:hethw], :withdrawalIndex)
|
321
282
|
end
|
322
283
|
|
323
|
-
# @param [Hash]
|
324
|
-
# @return [String] valores formatados nethk
|
284
|
+
# @param [Hash] htx token etherscan
|
285
|
+
# @return [String] valores formatados nethk
|
325
286
|
def nethk_val(htx)
|
326
|
-
|
327
|
-
fin(htx[:blockNumber]),
|
328
|
-
fin(htx[:timeStamp]),
|
329
|
-
fqt(htx[:hash]),
|
330
|
-
fin(htx[:nonce]),
|
331
|
-
fqt(htx[:blockHash]),
|
332
|
-
fin(htx[:transactionIndex]),
|
333
|
-
fqt(htx[:from]),
|
334
|
-
fqt(htx[:to]),
|
335
|
-
fqt(htx[:iax]),
|
336
|
-
fnm(htx[:value]),
|
337
|
-
fqt(htx[:tokenName]),
|
338
|
-
fqt(htx[:tokenSymbol]),
|
339
|
-
fin(htx[:tokenDecimal]),
|
340
|
-
fnm(htx[:gas]),
|
341
|
-
fnm(htx[:gasPrice]),
|
342
|
-
fnm(htx[:gasUsed]),
|
343
|
-
fqt(htx[:input]),
|
344
|
-
fqt(htx[:contractAddress]),
|
345
|
-
fin(ops.dig(:h, htx[:hash]))
|
346
|
-
]
|
347
|
-
"(#{vls.join(',')})"
|
287
|
+
fvals(htx, TB[:hethk], :hash)
|
348
288
|
end
|
349
289
|
|
350
|
-
# @
|
351
|
-
# @
|
352
|
-
# @return [String] valores formatados para insert eos (parte1)
|
290
|
+
# @param [Hash] htx ledger greymass
|
291
|
+
# @return [String] valores formatados neost
|
353
292
|
def neost_val(htx)
|
354
|
-
|
355
|
-
# dat = act[:data]
|
356
|
-
# qtd = dat[:quantity].to_s
|
357
|
-
# str = dat[:memo].inspect
|
358
|
-
vls = [
|
359
|
-
fin(htx[:global_action_seq]),
|
360
|
-
fin(htx[:account_action_seq]),
|
361
|
-
fin(htx[:block_num]),
|
362
|
-
fts(htx[:block_time]),
|
363
|
-
fqt(htx[:account]),
|
364
|
-
fqt(htx[:name]),
|
365
|
-
fqt(htx[:from]),
|
366
|
-
fqt(htx[:to]),
|
367
|
-
fqt(htx[:iax]),
|
368
|
-
fnm(htx[:quantity]),
|
369
|
-
fqt(htx[:moe]),
|
370
|
-
fqt(htx[:memo]),
|
371
|
-
fin(ops.dig(:h, htx[:itx]))
|
372
|
-
]
|
373
|
-
"(#{vls.join(',')})"
|
293
|
+
fvals(htx, TB[:heost], :itx)
|
374
294
|
end
|
375
295
|
|
376
|
-
# @param [Hash] htx
|
377
|
-
# @return [String] valores formatados
|
296
|
+
# @param [Hash] htx trades bitcoinde
|
297
|
+
# @return [String] valores formatados cdet
|
378
298
|
def cdet_val(htx)
|
379
|
-
|
380
|
-
fqt(htx[:trade_id]),
|
381
|
-
fts(htx[:successfully_finished_at]),
|
382
|
-
fqt(htx[:type]),
|
383
|
-
fqt(htx[:trading_partner_information][:username]),
|
384
|
-
fnm(htx[:type] == 'buy' ? htx[:amount_currency_to_trade_after_fee] : "-#{htx[:amount_currency_to_trade]}"),
|
385
|
-
fnm(htx[:volume_currency_to_pay_after_fee]),
|
386
|
-
fts(htx[:trade_marked_as_paid_at]),
|
387
|
-
fin(ops.dig(:h, htx[:trade_id]))
|
388
|
-
]
|
389
|
-
"(#{vls.join(',')})"
|
299
|
+
fvals(htx, TB[:hdet], :trade_id)
|
390
300
|
end
|
391
301
|
|
392
|
-
# @param [Hash]
|
393
|
-
# @return [String] valores formatados
|
302
|
+
# @param [Hash] htx ledger (deposits + withdrawals) bitcoinde
|
303
|
+
# @return [String] valores formatados cdel
|
394
304
|
def cdel_val(htx)
|
395
|
-
|
396
|
-
fin(htx[:txid]),
|
397
|
-
fts(htx[:time]),
|
398
|
-
fqt(htx[:tp]),
|
399
|
-
fqt(htx[:add]),
|
400
|
-
fqt(htx[:moe]),
|
401
|
-
fnm(htx[:tp] == 'withdrawal' ? "-#{htx[:qt]}" : "#{htx[:qt]}"),
|
402
|
-
fnm(htx[:fee])
|
403
|
-
]
|
404
|
-
"(#{vls.join(',')})"
|
305
|
+
fvals(htx, TB[:hdel])
|
405
306
|
end
|
406
307
|
|
407
|
-
# @param [
|
408
|
-
# @
|
409
|
-
|
410
|
-
|
411
|
-
# gets ledgers related to this trade
|
412
|
-
ldg = apius.exd[:kl].select { |_, obj| obj[:refid] == idx.to_s }.keys.join(',')
|
413
|
-
vls = [
|
414
|
-
fqt(idx),
|
415
|
-
fqt(htx[:ordertxid]),
|
416
|
-
fqt(htx[:pair]),
|
417
|
-
fts(htx[:time]),
|
418
|
-
fqt(htx[:type]),
|
419
|
-
fqt(htx[:ordertype]),
|
420
|
-
fnm(htx[:price]),
|
421
|
-
fnm(htx[:cost]),
|
422
|
-
fnm(htx[:fee]),
|
423
|
-
fnm(htx[:vol]),
|
424
|
-
fnm(htx[:margin]),
|
425
|
-
fqt(htx[:misc]),
|
426
|
-
fqt(ldg),
|
427
|
-
fin(ops.dig(:h, idx))
|
428
|
-
]
|
429
|
-
"(#{vls.join(',')})"
|
308
|
+
# @param [Hash] htx trades kraken
|
309
|
+
# @return [String] valores formatados cust
|
310
|
+
def cust_val(htx)
|
311
|
+
fvals(htx.merge(ledgers: apius.exd[:kl].select { |_, o| o[:refid] == htx[:txid] }.keys.join(',')), TB[:hust], :txid)
|
430
312
|
end
|
431
313
|
|
432
|
-
# @param
|
433
|
-
# @
|
434
|
-
|
435
|
-
|
436
|
-
vls = [fqt(idx), fqt(hlx[:refid]), fts(hlx[:time]), fqt(hlx[:type]), fqt(hlx[:aclass]), fqt(hlx[:asset]), fnm(hlx[:amount]), fnm(hlx[:fee])]
|
437
|
-
"(#{vls.join(',')})"
|
314
|
+
# @param [Hash] htx ledger kraken
|
315
|
+
# @return [String] valores formatados cusl
|
316
|
+
def cusl_val(htx)
|
317
|
+
fvals(htx, TB[:husl])
|
438
318
|
end
|
439
319
|
end
|
440
320
|
end
|
data/lib/cns/bitcoinde.rb
CHANGED
@@ -27,7 +27,7 @@ module Cns
|
|
27
27
|
|
28
28
|
# @return [Hash] dados exchange bitcoinde - saldos & trades & deposits & withdrawals
|
29
29
|
def exd
|
30
|
-
@exd ||= {
|
30
|
+
@exd ||= {sl: pdea(api.account_de), tt: pdet(api.trades_de), tl: pdel(api.deposits_de + api.withdrawals_de)}
|
31
31
|
end
|
32
32
|
|
33
33
|
# @return [String] texto saldos & transacoes & ajuste dias
|
@@ -40,7 +40,7 @@ module Cns
|
|
40
40
|
mledger
|
41
41
|
return if novcdet.empty?
|
42
42
|
|
43
|
-
puts("\nstring ajuste dias dos trades\n-h=#{
|
43
|
+
puts("\nstring ajuste dias dos trades\n-h=#{novcdet.sort_by { |i| -i[:srx] }.map { |o| "#{o[:trade_id]}:0" }.join(' ')}")
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -102,8 +102,8 @@ module Cns
|
|
102
102
|
dp: htx[:trade_marked_as_paid_at].strftime('%F'),
|
103
103
|
ty: htx[:type],
|
104
104
|
mo: htx[:trading_pair],
|
105
|
-
vl: htx[:
|
106
|
-
co: htx[:
|
105
|
+
vl: htx[:btc],
|
106
|
+
co: htx[:eur]
|
107
107
|
)
|
108
108
|
end
|
109
109
|
|
@@ -116,7 +116,7 @@ module Cns
|
|
116
116
|
dt: hlx[:time].strftime('%F %T'),
|
117
117
|
ty: hlx[:tp],
|
118
118
|
mo: hlx[:moe],
|
119
|
-
pr: hlx[:
|
119
|
+
pr: hlx[:qtd],
|
120
120
|
vl: hlx[:fee]
|
121
121
|
)
|
122
122
|
end
|
@@ -136,7 +136,7 @@ module Cns
|
|
136
136
|
def mtrades
|
137
137
|
return unless ops[:v] && novcdet.any?
|
138
138
|
|
139
|
-
puts("\ntrades data hora dt criacao tipo par
|
139
|
+
puts("\ntrades data hora dt criacao tipo par btc eur")
|
140
140
|
novcdet.sort_by { |i| -i[:srx] }.each { |o| puts(formata_trades(o)) }
|
141
141
|
end
|
142
142
|
|
@@ -168,16 +168,18 @@ module Cns
|
|
168
168
|
itm.map do |t|
|
169
169
|
pdes(:successfully_finished_at, t).merge(
|
170
170
|
trade_marked_as_paid_at: ptm(t[:trade_marked_as_paid_at]),
|
171
|
-
|
172
|
-
|
171
|
+
username: t[:trading_partner_information][:username],
|
172
|
+
btc: t[:type] == 'buy' ? t[:amount_currency_to_trade_after_fee].to_d : -1 * t[:amount_currency_to_trade].to_d,
|
173
|
+
eur: t[:volume_currency_to_pay_after_fee].to_d,
|
173
174
|
trading_pair: t[:trading_pair].upcase
|
174
175
|
)
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
178
179
|
# Processa os ledger entries para garantir que as datas estejam no formato correto
|
180
|
+
|
179
181
|
def pdel(itm)
|
180
|
-
itm.map { |t| pdes(:time, t).merge(
|
182
|
+
itm.map { |t| pdes(:time, t).merge(qtd: (t[:tp] == 'withdrawal' ? -1 : 1) * t[:qt].to_d, nxid: t[:txid], fee: t[:fee].to_d, moe: t[:moe].upcase) }
|
181
183
|
end
|
182
184
|
end
|
183
185
|
end
|
data/lib/cns/etherscan.rb
CHANGED
@@ -19,38 +19,38 @@ module Cns
|
|
19
19
|
TT = {
|
20
20
|
normal: {
|
21
21
|
new: :novnetht,
|
22
|
-
sort_key: :srx,
|
23
22
|
format: :formata_tx_ti,
|
24
23
|
header: "\ntx normal from to data valor",
|
25
|
-
|
24
|
+
sork: :srx,
|
25
|
+
adjk: :hash
|
26
26
|
},
|
27
27
|
internal: {
|
28
28
|
new: :novnethi,
|
29
|
-
sort_key: :srx,
|
30
29
|
format: :formata_tx_ti,
|
31
30
|
header: "\ntx intern from to data valor",
|
32
|
-
|
31
|
+
sork: :srx,
|
32
|
+
adjk: :hash
|
33
33
|
},
|
34
34
|
block: {
|
35
35
|
new: :novnethp,
|
36
|
-
sort_key: :itx,
|
37
36
|
format: :formata_tx_block,
|
38
37
|
header: "\ntx block address data valor",
|
39
|
-
|
38
|
+
sork: :itx,
|
39
|
+
adjk: :blockNumber
|
40
40
|
},
|
41
41
|
token: {
|
42
42
|
new: :novnethk,
|
43
|
-
sort_key: :srx,
|
44
43
|
format: :formata_tx_token,
|
45
44
|
header: "\ntx token from to data valor moeda",
|
46
|
-
|
45
|
+
sork: :srx,
|
46
|
+
adjk: :hash
|
47
47
|
},
|
48
48
|
withdrawal: {
|
49
49
|
new: :novnethw,
|
50
|
-
sort_key: :itx,
|
51
50
|
format: :formata_tx_withw,
|
52
51
|
header: "\nwithdrawal validator data valor",
|
53
|
-
|
52
|
+
sork: :itx,
|
53
|
+
adjk: :withdrawalIndex
|
54
54
|
}
|
55
55
|
}
|
56
56
|
|
@@ -224,7 +224,7 @@ module Cns
|
|
224
224
|
next unless ops[:v] && ntx.any?
|
225
225
|
|
226
226
|
puts(cfg[:header])
|
227
|
-
ntx.sort_by { |s| -s[cfg[:
|
227
|
+
ntx.sort_by { |s| -s[cfg[:sork]] }.each { |t| puts(send(cfg[:format], t)) }
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -234,7 +234,7 @@ module Cns
|
|
234
234
|
ntx = send(cfg[:new])
|
235
235
|
next unless ntx.any?
|
236
236
|
|
237
|
-
puts("\najuste dias transacoes #{typ}\n-h=#{ntx.map { |t| "#{t[cfg[:
|
237
|
+
puts("\najuste dias transacoes #{typ}\n-h=#{ntx.sort_by { |s| -s[cfg[:sork]] }.map { |t| "#{t[cfg[:adjk]]}:0" }.join(' ')}")
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
@@ -366,31 +366,6 @@ module Cns
|
|
366
366
|
@novnethk ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
367
367
|
end
|
368
368
|
|
369
|
-
# @return [Array<Hash>] lista ordenada transacoes normais novas
|
370
|
-
def sortx
|
371
|
-
novnetht.sort_by { |i| -i[:srx] }
|
372
|
-
end
|
373
|
-
|
374
|
-
# @return [Array<Hash>] lista ordenada transacoes internas novas
|
375
|
-
def sorix
|
376
|
-
novnethi.sort_by { |i| -i[:srx] }
|
377
|
-
end
|
378
|
-
|
379
|
-
# @return [Array<Hash>] lista ordenada transacoes block novas
|
380
|
-
def sorpx
|
381
|
-
novnethp.sort_by { |i| -i[:itx] }
|
382
|
-
end
|
383
|
-
|
384
|
-
# @return [Array<Hash>] lista ordenada transacoes withdrawals novas
|
385
|
-
def sorwx
|
386
|
-
novnethw.sort_by { |i| -i[:itx] }
|
387
|
-
end
|
388
|
-
|
389
|
-
# @return [Array<Hash>] lista ordenada transacoes token novas
|
390
|
-
def sorkx
|
391
|
-
novnethk.sort_by { |i| -i[:srx] }
|
392
|
-
end
|
393
|
-
|
394
369
|
def pess(itm)
|
395
370
|
tym = Integer(itm[:timeStamp])
|
396
371
|
itm.merge(srx: tym, timeStamp: Time.at(tym))
|
data/lib/cns/greymass.rb
CHANGED
@@ -27,10 +27,10 @@ module Cns
|
|
27
27
|
|
28
28
|
TT = {
|
29
29
|
new: :novneost,
|
30
|
-
sort_key: :itx,
|
31
30
|
format: :formata_ledger,
|
32
31
|
header: "\nsequence num from to accao data valor moeda",
|
33
|
-
|
32
|
+
sork: :itx,
|
33
|
+
adjk: :itx
|
34
34
|
}
|
35
35
|
|
36
36
|
# @return [String] texto carteiras & transacoes & ajuste dias
|
@@ -87,7 +87,7 @@ module Cns
|
|
87
87
|
return unless ops[:v] && ntx.any?
|
88
88
|
|
89
89
|
puts(TT[:header])
|
90
|
-
ntx.sort_by { |s| -s[TT[:
|
90
|
+
ntx.sort_by { |s| -s[TT[:sork]] }.each { |t| puts(send(TT[:format], t)) }
|
91
91
|
end
|
92
92
|
|
93
93
|
# @return [String] texto configuracao ajuste dias das transacoes
|
@@ -95,7 +95,7 @@ module Cns
|
|
95
95
|
ntx = send(TT[:new])
|
96
96
|
return unless ntx.any?
|
97
97
|
|
98
|
-
puts("\nstring ajuste dias\n-h=#{ntx.map { |t| "#{t[TT[:
|
98
|
+
puts("\nstring ajuste dias\n-h=#{ntx.sort_by { |s| -s[TT[:sork]] }.map { |t| "#{t[TT[:adjk]]}:0" }.join(' ')}")
|
99
99
|
end
|
100
100
|
|
101
101
|
# @return [Array<Hash>] todos os dados greymass - saldos & transacoes
|
@@ -126,7 +126,7 @@ module Cns
|
|
126
126
|
# @return [Hash] dados greymass - address, saldo & transacoes
|
127
127
|
def base_bc(wbq)
|
128
128
|
xbq = wbq[:ax]
|
129
|
-
{
|
129
|
+
{ax: xbq, sl: peosa(xbq).reduce(:+), tx: peost(xbq, api.ledger_gm(xbq))}
|
130
130
|
end
|
131
131
|
|
132
132
|
# @param wbq (see base_bc)
|
@@ -149,11 +149,6 @@ module Cns
|
|
149
149
|
@novneost ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
|
150
150
|
end
|
151
151
|
|
152
|
-
# @return [Array<Hash>] lista ordenada transacoes
|
153
|
-
def soreost
|
154
|
-
novneost.sort_by { |i| -i[:itx] }
|
155
|
-
end
|
156
|
-
|
157
152
|
# @return [Array<BigDecimal>] lista recursos - liquido, net, spu
|
158
153
|
def peosa(add)
|
159
154
|
hac = api.account_gm(add)
|
data/lib/cns/kraken.rb
CHANGED
@@ -27,7 +27,7 @@ module Cns
|
|
27
27
|
|
28
28
|
# @return [Hash] dados exchange kraken - saldos & transacoes trades e ledger
|
29
29
|
def exd
|
30
|
-
@exd ||= {
|
30
|
+
@exd ||= {sl: pusa(api.account_us), kt: pust(api.trades_us), kl: pusl(api.ledger_us)}
|
31
31
|
end
|
32
32
|
|
33
33
|
# @return [String] texto saldos & transacoes & ajuste dias
|
@@ -40,7 +40,7 @@ module Cns
|
|
40
40
|
mledger
|
41
41
|
return if novcust.empty?
|
42
42
|
|
43
|
-
puts("\nstring ajuste dias dos trades\n-h=#{
|
43
|
+
puts("\nstring ajuste dias dos trades\n-h=#{novcust.sort_by { |_, v| -v[:srx] }.map { |k, _v| "#{k}:0" }.join(' ')}")
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -139,7 +139,7 @@ module Cns
|
|
139
139
|
return unless ops[:v] && novcust.any?
|
140
140
|
|
141
141
|
puts("\ntrade data hora tipo par preco volume custo")
|
142
|
-
novcust.sort_by { |_, v| -v[:srx] }.each { |
|
142
|
+
novcust.sort_by { |_, v| -v[:srx] }.each { |k, t| puts(formata_trades(k, t)) }
|
143
143
|
end
|
144
144
|
|
145
145
|
# @return [String] texto transacoes ledger
|
@@ -147,27 +147,30 @@ module Cns
|
|
147
147
|
return unless ops[:v] && novcusl.any?
|
148
148
|
|
149
149
|
puts("\nledger data hora tipo moeda quantidade custo")
|
150
|
-
novcusl.sort_by { |_, v| -v[:srx] }.each { |
|
150
|
+
novcusl.sort_by { |_, v| -v[:srx] }.each { |k, t| puts(formata_ledger(k, t)) }
|
151
151
|
end
|
152
152
|
|
153
|
-
# Processa
|
153
|
+
# Processa accounts para garantir formato correto
|
154
154
|
def pusa(itm)
|
155
155
|
itm.select { |k, _| EM.include?(k) }.transform_values { |v| v.to_d }
|
156
156
|
end
|
157
157
|
|
158
|
-
|
159
|
-
|
160
|
-
itm.
|
158
|
+
# Processa campos comuns para garantir formato correto
|
159
|
+
def pusk(itm)
|
160
|
+
itm.map do |k, v|
|
161
|
+
t = Integer(v[:time])
|
162
|
+
[k, v.merge(txid: k.to_s, srx: t, time: Time.at(t))]
|
163
|
+
end.to_h
|
161
164
|
end
|
162
165
|
|
163
|
-
# Processa
|
166
|
+
# Processa trades para garantir formato correto
|
164
167
|
def pust(itm)
|
165
|
-
itm.transform_values { |t|
|
168
|
+
pusk(itm).transform_values { |t| t.merge(pair: t[:pair].upcase, price: t[:price].to_d, vol: t[:vol].to_d, cost: t[:cost].to_d) }
|
166
169
|
end
|
167
170
|
|
168
|
-
# Processa
|
171
|
+
# Processa ledgers para garantir formato correto
|
169
172
|
def pusl(itm)
|
170
|
-
itm.transform_values { |t|
|
173
|
+
pusk(itm).transform_values { |t| t.merge(asset: t[:asset].upcase, amount: t[:amount].to_d, fee: t[:fee].to_d) }
|
171
174
|
end
|
172
175
|
end
|
173
176
|
end
|
data/lib/cns/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hernâni Rodrigues Vaz
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|