max_exchange_api 1.4.0 → 2.0.0
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/README.md +981 -372
- data/lib/max_exchange_api/helper.rb +7 -2
- data/lib/max_exchange_api/private_api.rb +3 -1
- data/lib/max_exchange_api/private_v2/account_api.rb +15 -0
- data/lib/max_exchange_api/private_v2/deposit_api.rb +75 -0
- data/lib/max_exchange_api/private_v2/internal_transfer_api.rb +26 -0
- data/lib/max_exchange_api/private_v2/order_api.rb +55 -0
- data/lib/max_exchange_api/private_v2/reward_api.rb +40 -0
- data/lib/max_exchange_api/private_v2/trade_api.rb +28 -0
- data/lib/max_exchange_api/private_v2/user_api.rb +19 -0
- data/lib/max_exchange_api/private_v2/withdraw_api.rb +42 -0
- data/lib/max_exchange_api/private_v2_api.rb +16 -214
- data/lib/max_exchange_api/private_v3/account_api.rb +15 -0
- data/lib/max_exchange_api/private_v3/convert_api.rb +29 -0
- data/lib/max_exchange_api/private_v3/deposit_api.rb +26 -0
- data/lib/max_exchange_api/private_v3/internal_transfer_api.rb +19 -0
- data/lib/max_exchange_api/private_v3/m_wallet_api.rb +76 -0
- data/lib/max_exchange_api/private_v3/order_api.rb +82 -0
- data/lib/max_exchange_api/private_v3/reward_api.rb +19 -0
- data/lib/max_exchange_api/private_v3/sub_account_api.rb +31 -0
- data/lib/max_exchange_api/private_v3/trade_api.rb +27 -0
- data/lib/max_exchange_api/private_v3/user_api.rb +11 -0
- data/lib/max_exchange_api/private_v3/withdraw_api.rb +35 -0
- data/lib/max_exchange_api/private_v3_api.rb +23 -0
- data/lib/max_exchange_api/public_api.rb +13 -14
- data/lib/max_exchange_api/public_v2_api.rb +65 -66
- data/lib/max_exchange_api/public_v3_api.rb +56 -0
- data/lib/max_exchange_api/version.rb +1 -1
- metadata +22 -3
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'base64'
|
|
4
|
+
require 'json'
|
|
4
5
|
|
|
5
6
|
module MaxExchangeApi
|
|
6
7
|
module Helper
|
|
7
8
|
class << self
|
|
8
|
-
def gen_headers(payload, access_key, secret_key)
|
|
9
|
+
def gen_headers(payload, access_key, secret_key, sub_account_sn: nil)
|
|
9
10
|
encoded_payload = encode(payload)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
headers = {
|
|
12
13
|
'X-MAX-ACCESSKEY' => access_key,
|
|
13
14
|
'X-MAX-PAYLOAD' => encoded_payload,
|
|
14
15
|
'X-MAX-SIGNATURE' => encrypt(encoded_payload, secret_key),
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
headers['X-Sub-Account'] = sub_account_sn if sub_account_sn
|
|
19
|
+
|
|
20
|
+
return headers
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
private
|
|
@@ -4,6 +4,8 @@ require 'max_exchange_api/base_api'
|
|
|
4
4
|
|
|
5
5
|
module MaxExchangeApi
|
|
6
6
|
class PrivateApi < BaseApi
|
|
7
|
+
attr_accessor :current_sub_account_sn
|
|
8
|
+
|
|
7
9
|
def initialize(access_key, secret_key, config: nil)
|
|
8
10
|
super(config: config)
|
|
9
11
|
|
|
@@ -17,7 +19,7 @@ module MaxExchangeApi
|
|
|
17
19
|
def send_request(method, path, query)
|
|
18
20
|
query = query.compact
|
|
19
21
|
query.merge!(path: "#{@base_path}#{path}", nonce: (Time.now.to_f * 1000).to_i)
|
|
20
|
-
return super(method, path, Helper.gen_headers(query, @access_key, @secret_key), query)
|
|
22
|
+
return super(method, path, Helper.gen_headers(query, @access_key, @secret_key, sub_account_sn: current_sub_account_sn), query)
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module AccountApi
|
|
6
|
+
def accounts
|
|
7
|
+
send_request(:get, '/members/accounts', {})
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def account(currency)
|
|
11
|
+
send_request(:get, "/members/accounts/#{currency}", {})
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module DepositApi
|
|
6
|
+
def deposits(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
7
|
+
send_request(
|
|
8
|
+
:get,
|
|
9
|
+
'/deposits',
|
|
10
|
+
currency: currency,
|
|
11
|
+
from: from,
|
|
12
|
+
to: to,
|
|
13
|
+
state: state,
|
|
14
|
+
pagination: pagination,
|
|
15
|
+
page: page,
|
|
16
|
+
limit: limit,
|
|
17
|
+
offset: offset,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def deposit(transaction_id)
|
|
22
|
+
send_request(:get, '/deposit', txid: transaction_id)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def deposit_addresses(currency: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
26
|
+
send_request(
|
|
27
|
+
:get,
|
|
28
|
+
'/deposit_addresses',
|
|
29
|
+
currency: currency,
|
|
30
|
+
pagination: pagination,
|
|
31
|
+
page: page,
|
|
32
|
+
limit: limit,
|
|
33
|
+
offset: offset,
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_deposit_addresses!(currency)
|
|
38
|
+
send_request(:post, '/deposit_addresses', currency: currency)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
42
|
+
path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
|
|
43
|
+
send_request(
|
|
44
|
+
:get,
|
|
45
|
+
path,
|
|
46
|
+
currency: currency,
|
|
47
|
+
from: from,
|
|
48
|
+
to: to,
|
|
49
|
+
pagination: pagination,
|
|
50
|
+
page: page,
|
|
51
|
+
limit: limit,
|
|
52
|
+
offset: offset,
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
57
|
+
send_request(
|
|
58
|
+
:get,
|
|
59
|
+
'/yields',
|
|
60
|
+
currency: currency,
|
|
61
|
+
from: from,
|
|
62
|
+
to: to,
|
|
63
|
+
pagination: pagination,
|
|
64
|
+
page: page,
|
|
65
|
+
limit: limit,
|
|
66
|
+
offset: offset,
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def max_rewards_yesterday
|
|
71
|
+
send_request(:get, '/max_rewards/yesterday', {})
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module InternalTransferApi
|
|
6
|
+
def internal_transfers(currency: nil, side: 'in', from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
7
|
+
send_request(
|
|
8
|
+
:get,
|
|
9
|
+
'/internal_transfers',
|
|
10
|
+
currency: currency,
|
|
11
|
+
side: side,
|
|
12
|
+
from: from,
|
|
13
|
+
to: to,
|
|
14
|
+
pagination: pagination,
|
|
15
|
+
page: page,
|
|
16
|
+
limit: limit,
|
|
17
|
+
offset: offset,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def internal_transfer(internal_transfer_id)
|
|
22
|
+
send_request(:get, '/internal_transfer', uuid: internal_transfer_id)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module OrderApi
|
|
6
|
+
def orders(market, state: nil, order_by: 'asc', group_id: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
7
|
+
send_request(
|
|
8
|
+
:get,
|
|
9
|
+
'/orders',
|
|
10
|
+
market: market,
|
|
11
|
+
state: state,
|
|
12
|
+
order_by: order_by,
|
|
13
|
+
group_id: group_id,
|
|
14
|
+
pagination: pagination,
|
|
15
|
+
page: page,
|
|
16
|
+
limit: limit,
|
|
17
|
+
offset: offset,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def order(order_id, use_client_id: false)
|
|
22
|
+
id_params_key = use_client_id ? :client_oid : :id
|
|
23
|
+
send_request(:get, '/order', id_params_key => order_id)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def cancel_orders!(market: nil, side: nil, group_id: nil)
|
|
27
|
+
send_request(:post, '/orders/clear', market: market, side: side, group_id: group_id)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def cancel_order!(order_id, use_client_id: false)
|
|
31
|
+
id_params_key = use_client_id ? :client_oid : :id
|
|
32
|
+
send_request(:post, '/order/delete', id_params_key => order_id)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def create_order!(market, side, volume, price: nil, client_oid: nil, stop_price: nil, ord_type: nil, group_id: nil)
|
|
36
|
+
send_request(
|
|
37
|
+
:post,
|
|
38
|
+
'/orders',
|
|
39
|
+
market: market,
|
|
40
|
+
side: side,
|
|
41
|
+
volume: volume,
|
|
42
|
+
price: price,
|
|
43
|
+
client_oid: client_oid,
|
|
44
|
+
stop_price: stop_price,
|
|
45
|
+
ord_type: ord_type,
|
|
46
|
+
group_id: group_id,
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def create_orders!(market, orders, group_id: nil)
|
|
51
|
+
send_request(:post, '/orders/multi/onebyone', market: market, orders: orders, group_id: group_id)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module RewardApi
|
|
6
|
+
def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
7
|
+
path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
|
|
8
|
+
send_request(
|
|
9
|
+
:get,
|
|
10
|
+
path,
|
|
11
|
+
currency: currency,
|
|
12
|
+
from: from,
|
|
13
|
+
to: to,
|
|
14
|
+
pagination: pagination,
|
|
15
|
+
page: page,
|
|
16
|
+
limit: limit,
|
|
17
|
+
offset: offset,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
22
|
+
send_request(
|
|
23
|
+
:get,
|
|
24
|
+
'/yields',
|
|
25
|
+
currency: currency,
|
|
26
|
+
from: from,
|
|
27
|
+
to: to,
|
|
28
|
+
pagination: pagination,
|
|
29
|
+
page: page,
|
|
30
|
+
limit: limit,
|
|
31
|
+
offset: offset,
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def max_rewards_yesterday
|
|
36
|
+
send_request(:get, '/max_rewards/yesterday', {})
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module TradeApi
|
|
6
|
+
def my_trades_of_order(order_id, use_client_id: false)
|
|
7
|
+
id_params_key = use_client_id ? :client_oid : :id
|
|
8
|
+
send_request(:get, '/trades/my/of_order', id_params_key => order_id)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def my_trades(market, timestamp: nil, from: nil, to: nil, order_by: 'desc', pagination: true, page: 1, limit: 50, offset: 0)
|
|
12
|
+
send_request(
|
|
13
|
+
:get,
|
|
14
|
+
'/trades/my',
|
|
15
|
+
market: market,
|
|
16
|
+
timestamp: timestamp,
|
|
17
|
+
from: from,
|
|
18
|
+
to: to,
|
|
19
|
+
order_by: order_by,
|
|
20
|
+
pagination: pagination,
|
|
21
|
+
page: page,
|
|
22
|
+
limit: limit,
|
|
23
|
+
offset: offset,
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module UserApi
|
|
6
|
+
def member_profile
|
|
7
|
+
send_request(:get, '/members/profile', {})
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def me
|
|
11
|
+
send_request(:get, '/members/me', {})
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def vip_level
|
|
15
|
+
send_request(:get, '/members/vip_level', {})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV2
|
|
5
|
+
module WithdrawApi
|
|
6
|
+
def withdrawal(withdraw_id)
|
|
7
|
+
send_request(:get, '/withdrawal', uuid: withdraw_id)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def withdrawals(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
11
|
+
send_request(
|
|
12
|
+
:get,
|
|
13
|
+
'/withdrawals',
|
|
14
|
+
currency: currency,
|
|
15
|
+
from: from,
|
|
16
|
+
to: to,
|
|
17
|
+
state: state,
|
|
18
|
+
pagination: pagination,
|
|
19
|
+
page: page,
|
|
20
|
+
limit: limit,
|
|
21
|
+
offset: offset,
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create_withdrawal!(currency, withdraw_address_id, amount)
|
|
26
|
+
send_request(:post, '/withdrawal', currency: currency, withdraw_address_uuid: withdraw_address_id, amount: amount)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def withdraw_addresses(currency, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
30
|
+
send_request(
|
|
31
|
+
:get,
|
|
32
|
+
'/withdraw_addresses',
|
|
33
|
+
currency: currency,
|
|
34
|
+
pagination: pagination,
|
|
35
|
+
page: page,
|
|
36
|
+
limit: limit,
|
|
37
|
+
offset: offset,
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -1,224 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'max_exchange_api/private_api'
|
|
4
|
+
require 'max_exchange_api/private_v2/user_api'
|
|
5
|
+
require 'max_exchange_api/private_v2/account_api'
|
|
6
|
+
require 'max_exchange_api/private_v2/order_api'
|
|
7
|
+
require 'max_exchange_api/private_v2/trade_api'
|
|
8
|
+
require 'max_exchange_api/private_v2/deposit_api'
|
|
9
|
+
require 'max_exchange_api/private_v2/withdraw_api'
|
|
10
|
+
require 'max_exchange_api/private_v2/internal_transfer_api'
|
|
11
|
+
require 'max_exchange_api/private_v2/reward_api'
|
|
4
12
|
|
|
5
13
|
module MaxExchangeApi
|
|
6
14
|
class PrivateV2Api < PrivateApi
|
|
7
15
|
base_uri 'https://max-api.maicoin.com/api/v2'
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
:get,
|
|
18
|
-
'/trades/my',
|
|
19
|
-
market: market,
|
|
20
|
-
timestamp: timestamp,
|
|
21
|
-
from: from,
|
|
22
|
-
to: to,
|
|
23
|
-
order_by: order_by,
|
|
24
|
-
pagination: pagination,
|
|
25
|
-
page: page,
|
|
26
|
-
limit: limit,
|
|
27
|
-
offset: offset,
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def member_profile
|
|
32
|
-
send_request(:get, '/members/profile', {})
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def me
|
|
36
|
-
send_request(:get, '/members/me', {})
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def vip_level
|
|
40
|
-
send_request(:get, '/members/vip_level', {})
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def accounts
|
|
44
|
-
send_request(:get, '/members/accounts', {})
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def account(currency)
|
|
48
|
-
send_request(:get, "/members/accounts/#{currency}", {})
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def deposits(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
|
|
52
|
-
offset: 0)
|
|
53
|
-
send_request(
|
|
54
|
-
:get,
|
|
55
|
-
'/deposits',
|
|
56
|
-
currency: currency,
|
|
57
|
-
from: from,
|
|
58
|
-
to: to,
|
|
59
|
-
state: state,
|
|
60
|
-
pagination: pagination,
|
|
61
|
-
page: page,
|
|
62
|
-
limit: limit,
|
|
63
|
-
offset: offset,
|
|
64
|
-
)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def deposit(transaction_id)
|
|
68
|
-
send_request(:get, '/deposit', txid: transaction_id)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def deposit_addresses(currency: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
72
|
-
send_request(
|
|
73
|
-
:get,
|
|
74
|
-
'/deposit_addresses',
|
|
75
|
-
currency: currency,
|
|
76
|
-
pagination: pagination,
|
|
77
|
-
page: page,
|
|
78
|
-
limit: limit,
|
|
79
|
-
offset: offset,
|
|
80
|
-
)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def create_deposit_addresses!(currency)
|
|
84
|
-
send_request(:post, '/deposit_addresses', currency: currency)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def withdraw_addresses(currency, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
88
|
-
send_request(
|
|
89
|
-
:get,
|
|
90
|
-
'/withdraw_addresses',
|
|
91
|
-
currency: currency,
|
|
92
|
-
pagination: pagination,
|
|
93
|
-
page: page,
|
|
94
|
-
limit: limit,
|
|
95
|
-
offset: offset,
|
|
96
|
-
)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def withdrawal(withdraw_id)
|
|
100
|
-
send_request(:get, '/withdrawal', uuid: withdraw_id)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def withdrawals(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
|
|
104
|
-
offset: 0)
|
|
105
|
-
send_request(
|
|
106
|
-
:get,
|
|
107
|
-
'/withdrawals',
|
|
108
|
-
currency: currency,
|
|
109
|
-
from: from,
|
|
110
|
-
to: to,
|
|
111
|
-
state: state,
|
|
112
|
-
pagination: pagination,
|
|
113
|
-
page: page,
|
|
114
|
-
limit: limit,
|
|
115
|
-
offset: offset,
|
|
116
|
-
)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def create_withdrawal!(currency, withdraw_address_id, amount)
|
|
120
|
-
send_request(:post, '/withdrawal', currency: currency, withdraw_address_uuid: withdraw_address_id, amount: amount)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def internal_transfers(currency: nil, side: 'in', from: nil, to: nil, pagination: nil, page: 1, limit: 50,
|
|
124
|
-
offset: 0)
|
|
125
|
-
send_request(
|
|
126
|
-
:get,
|
|
127
|
-
'/internal_transfers',
|
|
128
|
-
currency: currency,
|
|
129
|
-
side: side,
|
|
130
|
-
from: from,
|
|
131
|
-
to: to,
|
|
132
|
-
pagination: pagination,
|
|
133
|
-
page: page,
|
|
134
|
-
limit: limit,
|
|
135
|
-
offset: offset,
|
|
136
|
-
)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def internal_transfer(internal_transfer_id)
|
|
140
|
-
send_request(:get, '/internal_transfer', uuid: internal_transfer_id)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
144
|
-
path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
|
|
145
|
-
send_request(
|
|
146
|
-
:get,
|
|
147
|
-
path,
|
|
148
|
-
currency: currency,
|
|
149
|
-
from: from,
|
|
150
|
-
to: to,
|
|
151
|
-
pagination: pagination,
|
|
152
|
-
page: page,
|
|
153
|
-
limit: limit,
|
|
154
|
-
offset: offset,
|
|
155
|
-
)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
159
|
-
send_request(
|
|
160
|
-
:get,
|
|
161
|
-
'/yields',
|
|
162
|
-
currency: currency,
|
|
163
|
-
from: from,
|
|
164
|
-
to: to,
|
|
165
|
-
pagination: pagination,
|
|
166
|
-
page: page,
|
|
167
|
-
limit: limit,
|
|
168
|
-
offset: offset,
|
|
169
|
-
)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def max_rewards_yesterday
|
|
173
|
-
send_request(:get, '/max_rewards/yesterday', {})
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def orders(market, state: nil, order_by: 'asc', group_id: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
|
177
|
-
send_request(
|
|
178
|
-
:get,
|
|
179
|
-
'/orders',
|
|
180
|
-
market: market,
|
|
181
|
-
state: state,
|
|
182
|
-
order_by: order_by,
|
|
183
|
-
group_id: group_id,
|
|
184
|
-
pagination: pagination,
|
|
185
|
-
page: page,
|
|
186
|
-
limit: limit,
|
|
187
|
-
offset: offset,
|
|
188
|
-
)
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def order(order_id, use_client_id: false)
|
|
192
|
-
id_params_key = use_client_id ? :client_oid : :id
|
|
193
|
-
send_request(:get, '/order', id_params_key => order_id)
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def cancel_orders!(market: nil, side: nil, group_id: nil)
|
|
197
|
-
send_request(:post, '/orders/clear', market: market, side: side, group_id: group_id)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def cancel_order!(order_id, use_client_id: false)
|
|
201
|
-
id_params_key = use_client_id ? :client_oid : :id
|
|
202
|
-
send_request(:post, '/order/delete', id_params_key => order_id)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def create_order!(market, side, volume, price: nil, client_oid: nil, stop_price: nil, ord_type: nil, group_id: nil)
|
|
206
|
-
send_request(
|
|
207
|
-
:post,
|
|
208
|
-
'/orders',
|
|
209
|
-
market: market,
|
|
210
|
-
side: side,
|
|
211
|
-
volume: volume,
|
|
212
|
-
price: price,
|
|
213
|
-
client_oid: client_oid,
|
|
214
|
-
stop_price: stop_price,
|
|
215
|
-
ord_type: ord_type,
|
|
216
|
-
group_id: group_id,
|
|
217
|
-
)
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def create_orders!(market, orders, group_id: nil)
|
|
221
|
-
send_request(:post, '/orders/multi/onebyone', market: market, orders: orders, group_id: group_id)
|
|
222
|
-
end
|
|
17
|
+
include PrivateV2::UserApi
|
|
18
|
+
include PrivateV2::AccountApi
|
|
19
|
+
include PrivateV2::OrderApi
|
|
20
|
+
include PrivateV2::TradeApi
|
|
21
|
+
include PrivateV2::DepositApi
|
|
22
|
+
include PrivateV2::WithdrawApi
|
|
23
|
+
include PrivateV2::InternalTransferApi
|
|
24
|
+
include PrivateV2::RewardApi
|
|
223
25
|
end
|
|
224
26
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV3
|
|
5
|
+
module AccountApi
|
|
6
|
+
def accounts(wallet_type: 'spot', currency: nil)
|
|
7
|
+
send_request(
|
|
8
|
+
:get,
|
|
9
|
+
"/wallet/#{wallet_type}/accounts",
|
|
10
|
+
currency: currency,
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV3
|
|
5
|
+
module ConvertApi
|
|
6
|
+
def convert_orders(timestamp: nil, order_by: 'desc', limit: 50)
|
|
7
|
+
send_request(:get, '/converts', timestamp: timestamp, order: order_by, limit: limit)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def convert_order(sn)
|
|
11
|
+
send_request(:get, '/convert', sn: sn)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_convert_order(from: [], to: [])
|
|
15
|
+
from_amount, from_currency = from
|
|
16
|
+
to_amount, to_currency = to
|
|
17
|
+
|
|
18
|
+
send_request(
|
|
19
|
+
:post,
|
|
20
|
+
'/convert',
|
|
21
|
+
from_amount: from_amount,
|
|
22
|
+
from_currency: from_currency,
|
|
23
|
+
to_amount: to_amount,
|
|
24
|
+
to_currency: to_currency,
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV3
|
|
5
|
+
module DepositApi
|
|
6
|
+
def deposit_address(currency_version)
|
|
7
|
+
send_request(:get, '/deposit_address', currency_version: currency_version)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def deposits(currency: nil, timestamp: nil, order_by: 'desc', limit: 50)
|
|
11
|
+
send_request(
|
|
12
|
+
:get,
|
|
13
|
+
'/deposits',
|
|
14
|
+
currency: currency,
|
|
15
|
+
timestamp: timestamp,
|
|
16
|
+
order: order_by,
|
|
17
|
+
limit: limit,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def deposit(txid: nil, uuid: nil)
|
|
22
|
+
send_request(:get, '/deposit', txid: txid, uuid: uuid)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module MaxExchangeApi
|
|
4
|
+
module PrivateV3
|
|
5
|
+
module InternalTransferApi
|
|
6
|
+
def internal_transfers(currency: nil, side: 'in', timestamp: nil, order_by: 'desc', limit: 50)
|
|
7
|
+
send_request(
|
|
8
|
+
:get,
|
|
9
|
+
'/internal_transfers',
|
|
10
|
+
currency: currency,
|
|
11
|
+
side: side,
|
|
12
|
+
timestamp: timestamp,
|
|
13
|
+
order: order_by,
|
|
14
|
+
limit: limit,
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|