From 710df930a46da1de792624655f24b9ae21520d3e Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 9 Mar 2021 13:19:08 +0800 Subject: [PATCH 1/3] maxapi: add bash version withdrawal history command --- scripts/max.sh | 14 +++++++++++++- scripts/maxapi.sh | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/max.sh b/scripts/max.sh index 1dc1f1e90..127672b37 100644 --- a/scripts/max.sh +++ b/scripts/max.sh @@ -24,6 +24,18 @@ case "$command" in submitOrder order_params ;; + withdrawal-history) + declare -A params=() + currency=$1 + if [[ -n $currency ]] ; then + params[currency]=$currency + fi + + withdrawalHistory params \ + | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ + | column -ts $'\t' + ;; + limit) market=$1 side=$2 @@ -83,7 +95,7 @@ case "$command" in rewards rewards_params | jq -r '.[] | [ .uuid, .type, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ | column -ts $'\t' ;; - + trades) if [[ $# < 1 ]] ; then echo "$0 trades [market]" diff --git a/scripts/maxapi.sh b/scripts/maxapi.sh index 24367c761..ff13ea5ab 100755 --- a/scripts/maxapi.sh +++ b/scripts/maxapi.sh @@ -116,21 +116,27 @@ function cancelOrder() function myOrders() { - local -n params=$1 - send_auth_request "GET" "/api/v2/orders" params + local -n _params=$1 + send_auth_request "GET" "/api/v2/orders" _params } function myTrades() { - local -n params=$1 - send_auth_request "GET" "/api/v2/trades/my" params + local -n _params=$1 + send_auth_request "GET" "/api/v2/trades/my" _params } function rewards() { - local -n params=$1 - send_auth_request "GET" "/api/v2/rewards" params + local -n _params=$1 + send_auth_request "GET" "/api/v2/rewards" _params +} + +function withdrawalHistory() +{ + local -n _params=$1 + send_auth_request "GET" "/api/v2/withdrawals" _params } From a4a3f0fbd8df381fcb23a71d3a2bb85dba981bd6 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 13 Mar 2021 20:49:36 +0800 Subject: [PATCH 2/3] maxapi: add withdraw command --- scripts/max.sh | 26 +++++++++++++++++++++++++- scripts/maxapi.sh | 8 +++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/max.sh b/scripts/max.sh index 127672b37..651bd007d 100644 --- a/scripts/max.sh +++ b/scripts/max.sh @@ -24,7 +24,31 @@ case "$command" in submitOrder order_params ;; - withdrawal-history) + deposits) + declare -A params=() + currency=$1 + if [[ -n $currency ]] ; then + params[currency]=$currency + fi + + deposits params \ + | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ + | column -ts $'\t' + ;; + + withdrawals) + declare -A params=() + currency=$1 + if [[ -n $currency ]] ; then + params[currency]=$currency + fi + + withdrawals params \ + | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ + | column -ts $'\t' + ;; + + withdrawals) declare -A params=() currency=$1 if [[ -n $currency ]] ; then diff --git a/scripts/maxapi.sh b/scripts/maxapi.sh index ff13ea5ab..2bb68d6f3 100755 --- a/scripts/maxapi.sh +++ b/scripts/maxapi.sh @@ -133,7 +133,13 @@ function rewards() send_auth_request "GET" "/api/v2/rewards" _params } -function withdrawalHistory() +function deposits() +{ + local -n _params=$1 + send_auth_request "GET" "/api/v2/deposits" _params +} + +function withdrawals() { local -n _params=$1 send_auth_request "GET" "/api/v2/withdrawals" _params From d7278d07428548dcc3bd7c95c803aba798067c0e Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 14 Mar 2021 10:42:11 +0800 Subject: [PATCH 3/3] maxapi: add tx id to the columns --- scripts/max.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/scripts/max.sh b/scripts/max.sh index 651bd007d..3454ede7d 100644 --- a/scripts/max.sh +++ b/scripts/max.sh @@ -32,7 +32,7 @@ case "$command" in fi deposits params \ - | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ + | jq -r '.[] | [ .uuid, .txid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ | column -ts $'\t' ;; @@ -44,19 +44,7 @@ case "$command" in fi withdrawals params \ - | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ - | column -ts $'\t' - ;; - - withdrawals) - declare -A params=() - currency=$1 - if [[ -n $currency ]] ; then - params[currency]=$currency - fi - - withdrawalHistory params \ - | jq -r '.[] | [ .uuid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ + | jq -r '.[] | [ .uuid, .txid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \ | column -ts $'\t' ;;