2407 lines
115 KiB
Go
2407 lines
115 KiB
Go
package ccxt
|
|
|
|
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
|
|
type kuna struct {
|
|
Exchange
|
|
|
|
}
|
|
|
|
func NewKunaCore() kuna {
|
|
p := kuna{}
|
|
setDefaults(&p)
|
|
return p
|
|
}
|
|
|
|
func (this *kuna) Describe() interface{} {
|
|
return this.DeepExtend(this.Exchange.Describe(), map[string]interface{} {
|
|
"id": "kuna",
|
|
"name": "Kuna",
|
|
"countries": []interface{}{"UA"},
|
|
"rateLimit": 1000,
|
|
"version": "v4",
|
|
"has": map[string]interface{} {
|
|
"CORS": nil,
|
|
"spot": true,
|
|
"margin": false,
|
|
"swap": false,
|
|
"future": false,
|
|
"option": false,
|
|
"addMargin": false,
|
|
"cancelOrder": true,
|
|
"cancelOrders": true,
|
|
"closeAllPositions": false,
|
|
"closePosition": false,
|
|
"createDepositAddress": true,
|
|
"createOrder": true,
|
|
"createPostOnlyOrder": false,
|
|
"createReduceOnlyOrder": false,
|
|
"createStopLimitOrder": true,
|
|
"createStopMarketOrder": false,
|
|
"createStopOrder": true,
|
|
"fetchBalance": true,
|
|
"fetchBorrowInterest": false,
|
|
"fetchBorrowRateHistories": false,
|
|
"fetchBorrowRateHistory": false,
|
|
"fetchClosedOrders": true,
|
|
"fetchCrossBorrowRate": false,
|
|
"fetchCrossBorrowRates": false,
|
|
"fetchCurrencies": true,
|
|
"fetchDeposit": true,
|
|
"fetchDepositAddress": true,
|
|
"fetchDepositAddresses": false,
|
|
"fetchDepositAddressesByNetwork": false,
|
|
"fetchDeposits": true,
|
|
"fetchDepositsWithdrawals": false,
|
|
"fetchFundingHistory": false,
|
|
"fetchFundingRate": false,
|
|
"fetchFundingRateHistory": false,
|
|
"fetchFundingRates": false,
|
|
"fetchIndexOHLCV": false,
|
|
"fetchIsolatedBorrowRate": false,
|
|
"fetchIsolatedBorrowRates": false,
|
|
"fetchIsolatedPositions": false,
|
|
"fetchL3OrderBook": true,
|
|
"fetchLeverage": false,
|
|
"fetchLeverageTiers": false,
|
|
"fetchMarginMode": false,
|
|
"fetchMarketLeverageTiers": false,
|
|
"fetchMarkets": true,
|
|
"fetchMarkOHLCV": false,
|
|
"fetchMyTrades": true,
|
|
"fetchOHLCV": false,
|
|
"fetchOpenInterest": false,
|
|
"fetchOpenInterestHistory": false,
|
|
"fetchOpenOrders": true,
|
|
"fetchOrder": true,
|
|
"fetchOrderBook": true,
|
|
"fetchOrdersByStatus": true,
|
|
"fetchPosition": false,
|
|
"fetchPositionMode": false,
|
|
"fetchPositions": false,
|
|
"fetchPositionsForSymbol": false,
|
|
"fetchPositionsRisk": false,
|
|
"fetchPremiumIndexOHLCV": false,
|
|
"fetchTicker": true,
|
|
"fetchTickers": true,
|
|
"fetchTime": true,
|
|
"fetchTrades": true,
|
|
"fetchTradingFee": false,
|
|
"fetchTradingFees": false,
|
|
"fetchTransactions": false,
|
|
"fetchTransfers": false,
|
|
"fetchWithdrawAddresses": false,
|
|
"fetchWithdrawal": true,
|
|
"fetchWithdrawals": true,
|
|
"reduceMargin": false,
|
|
"repayCrossMargin": false,
|
|
"repayIsolatedMargin": false,
|
|
"setLeverage": false,
|
|
"setMargin": false,
|
|
"setMarginMode": false,
|
|
"setPositionMode": false,
|
|
"signIn": false,
|
|
"transfer": false,
|
|
"withdraw": true,
|
|
},
|
|
"timeframes": nil,
|
|
"urls": map[string]interface{} {
|
|
"extension": ".json",
|
|
"referral": "https://kuna.io?r=kunaid-gvfihe8az7o4",
|
|
"logo": "https://user-images.githubusercontent.com/51840849/87153927-f0578b80-c2c0-11ea-84b6-74612568e9e1.jpg",
|
|
"api": map[string]interface{} {
|
|
"xreserve": "https://api.xreserve.fund",
|
|
"v3": "https://api.kuna.io",
|
|
"v4": "https://api.kuna.io",
|
|
"public": "https://kuna.io",
|
|
"private": "https://kuna.io",
|
|
},
|
|
"www": "https://kuna.io",
|
|
"doc": "https://kuna.io/documents/api",
|
|
"fees": "https://kuna.io/documents/api",
|
|
},
|
|
"api": map[string]interface{} {
|
|
"xreserve": map[string]interface{} {
|
|
"get": map[string]interface{} {
|
|
"nonce": 1,
|
|
"fee": 1,
|
|
"delegated-transactions": 1,
|
|
},
|
|
"post": map[string]interface{} {
|
|
"delegate-transfer": 1,
|
|
},
|
|
},
|
|
"v4": map[string]interface{} {
|
|
"private": map[string]interface{} {
|
|
"get": map[string]interface{} {
|
|
"private/me": 1,
|
|
"private/getBalance": 1,
|
|
"order/private/active": 1,
|
|
"order/private/history": 1,
|
|
"order/private/{id}/trades": 1,
|
|
"order/private/details/{id}": 1,
|
|
"trade/private/history": 1,
|
|
"transaction/private/{hash}": 1,
|
|
"deposit/private/preRequest": 1,
|
|
"deposit/private/crypto/address": 1,
|
|
"deposit/private/crypto/getMerchantAddress": 1,
|
|
"deposit/private/history": 1,
|
|
"deposit/private/details/{depositId}": 1,
|
|
"withdraw/private/preRequest": 1,
|
|
"withdraw/private/history": 1,
|
|
"withdraw/private/details/{withdrawId}": 1,
|
|
"kuna-code/{id}": 1,
|
|
"kuna-code/{code}/check": 1,
|
|
"kuna-code/issued-by-me": 1,
|
|
"kuna-code/redeemed-by-me": 1,
|
|
},
|
|
"post": map[string]interface{} {
|
|
"order/private/create": 1,
|
|
"order/private/cancel": 1,
|
|
"order/private/cancel/multi": 1,
|
|
"deposit/private/crypto/generateAddress": 1,
|
|
"deposit/private/crypto/generateMerchantAddress": 1,
|
|
"withdraw/private/create": 1,
|
|
"kuna-code": 1,
|
|
},
|
|
"put": map[string]interface{} {
|
|
"kuna-code/redeem": 1,
|
|
},
|
|
},
|
|
"public": map[string]interface{} {
|
|
"get": map[string]interface{} {
|
|
"public/timestamp": 1,
|
|
"public/fees": 1,
|
|
"public/currencies?type={type}": 1,
|
|
"public/currencies": 1,
|
|
"markets/public/getAll": 1,
|
|
"markets/public/tickers?pairs={pairs}": 1,
|
|
"order/public/book/{pairs}": 1,
|
|
"trade/public/book/{pairs}": 1,
|
|
},
|
|
},
|
|
},
|
|
"v3": map[string]interface{} {
|
|
"public": map[string]interface{} {
|
|
"get": map[string]interface{} {
|
|
"timestamp": 1,
|
|
"currencies": 1,
|
|
"markets": 1,
|
|
"tickers": 1,
|
|
"k": 1,
|
|
"trades_history": 1,
|
|
"fees": 1,
|
|
"exchange-rates": 1,
|
|
"exchange-rates/currency": 1,
|
|
"book/market": 1,
|
|
"kuna_codes/code/check": 1,
|
|
"landing_page_statistic": 1,
|
|
"translations/locale": 1,
|
|
"trades/market/hist": 1,
|
|
},
|
|
"post": map[string]interface{} {
|
|
"http_test": 1,
|
|
"deposit_channels": 1,
|
|
"withdraw_channels": 1,
|
|
"subscription_plans": 1,
|
|
"send_to": 1,
|
|
"confirm_token": 1,
|
|
"kunaid": 1,
|
|
"withdraw/prerequest": 1,
|
|
"deposit/prerequest": 1,
|
|
"deposit/exchange-rates": 1,
|
|
},
|
|
},
|
|
"sign": map[string]interface{} {
|
|
"get": map[string]interface{} {
|
|
"reset_password/token": 1,
|
|
},
|
|
"post": map[string]interface{} {
|
|
"signup/google": 1,
|
|
"signup/resend_confirmation": 1,
|
|
"signup": 1,
|
|
"signin": 1,
|
|
"signin/two_factor": 1,
|
|
"signin/resend_confirm_device": 1,
|
|
"signin/confirm_device": 1,
|
|
"reset_password": 1,
|
|
"cool-signin": 1,
|
|
},
|
|
"put": map[string]interface{} {
|
|
"reset_password/token": 1,
|
|
"signup/code/confirm": 1,
|
|
},
|
|
},
|
|
"private": map[string]interface{} {
|
|
"post": map[string]interface{} {
|
|
"auth/w/order/submit": 1,
|
|
"auth/r/orders": 1,
|
|
"auth/r/orders/market": 1,
|
|
"auth/r/orders/markets": 1,
|
|
"auth/api_tokens/delete": 1,
|
|
"auth/api_tokens/create": 1,
|
|
"auth/api_tokens": 1,
|
|
"auth/signin_history/uniq": 1,
|
|
"auth/signin_history": 1,
|
|
"auth/disable_withdraw_confirmation": 1,
|
|
"auth/change_password": 1,
|
|
"auth/deposit_address": 1,
|
|
"auth/announcements/accept": 1,
|
|
"auth/announcements/unaccepted": 1,
|
|
"auth/otp/deactivate": 1,
|
|
"auth/otp/activate": 1,
|
|
"auth/otp/secret": 1,
|
|
"auth/r/order/market/:order_id/trades": 1,
|
|
"auth/r/orders/market/hist": 1,
|
|
"auth/r/orders/hist": 1,
|
|
"auth/r/orders/hist/markets": 1,
|
|
"auth/r/orders/details": 1,
|
|
"auth/assets-history": 1,
|
|
"auth/assets-history/withdraws": 1,
|
|
"auth/assets-history/deposits": 1,
|
|
"auth/r/wallets": 1,
|
|
"auth/markets/favorites": 1,
|
|
"auth/markets/favorites/list": 1,
|
|
"auth/me/update": 1,
|
|
"auth/me": 1,
|
|
"auth/fund_sources": 1,
|
|
"auth/fund_sources/list": 1,
|
|
"auth/withdraw/resend_confirmation": 1,
|
|
"auth/withdraw": 1,
|
|
"auth/withdraw/details": 1,
|
|
"auth/withdraw/info": 1,
|
|
"auth/payment_addresses": 1,
|
|
"auth/deposit/prerequest": 1,
|
|
"auth/deposit/exchange-rates": 1,
|
|
"auth/deposit": 1,
|
|
"auth/deposit/details": 1,
|
|
"auth/deposit/info": 1,
|
|
"auth/kuna_codes/count": 1,
|
|
"auth/kuna_codes/details": 1,
|
|
"auth/kuna_codes/edit": 1,
|
|
"auth/kuna_codes/send-pdf": 1,
|
|
"auth/kuna_codes": 1,
|
|
"auth/kuna_codes/redeemed-by-me": 1,
|
|
"auth/kuna_codes/issued-by-me": 1,
|
|
"auth/payment_requests/invoice": 1,
|
|
"auth/payment_requests/type": 1,
|
|
"auth/referral_program/weekly_earnings": 1,
|
|
"auth/referral_program/stats": 1,
|
|
"auth/merchant/payout_services": 1,
|
|
"auth/merchant/withdraw": 1,
|
|
"auth/merchant/payment_services": 1,
|
|
"auth/merchant/deposit": 1,
|
|
"auth/verification/auth_token": 1,
|
|
"auth/kunaid_purchase/create": 1,
|
|
"auth/devices/list": 1,
|
|
"auth/sessions/list": 1,
|
|
"auth/subscriptions/reactivate": 1,
|
|
"auth/subscriptions/cancel": 1,
|
|
"auth/subscriptions/prolong": 1,
|
|
"auth/subscriptions/create": 1,
|
|
"auth/subscriptions/list": 1,
|
|
"auth/kuna_ids/list": 1,
|
|
"order/cancel/multi": 1,
|
|
"order/cancel": 1,
|
|
},
|
|
"put": map[string]interface{} {
|
|
"auth/fund_sources/id": 1,
|
|
"auth/kuna_codes/redeem": 1,
|
|
},
|
|
"delete": map[string]interface{} {
|
|
"auth/markets/favorites": 1,
|
|
"auth/fund_sources": 1,
|
|
"auth/devices": 1,
|
|
"auth/devices/list": 1,
|
|
"auth/sessions/list": 1,
|
|
"auth/sessions": 1,
|
|
},
|
|
},
|
|
},
|
|
"public": map[string]interface{} {
|
|
"get": []interface{}{"depth", "k_with_pending_trades", "k", "markets", "order_book", "order_book/{market}", "tickers", "tickers/{market}", "timestamp", "trades", "trades/{market}"},
|
|
},
|
|
"private": map[string]interface{} {
|
|
"get": []interface{}{"members/me", "deposits", "deposit", "deposit_address", "orders", "order", "trades/my", "withdraws", "withdraw"},
|
|
"post": []interface{}{"orders", "orders/multi", "orders/clear", "order/delete", "withdraw"},
|
|
},
|
|
},
|
|
"features": map[string]interface{} {
|
|
"spot": map[string]interface{} {
|
|
"sandbox": false,
|
|
"createOrder": map[string]interface{} {
|
|
"marginMode": false,
|
|
"triggerPrice": true,
|
|
"triggerPriceType": nil,
|
|
"triggerDirection": false,
|
|
"stopLossPrice": false,
|
|
"takeProfitPrice": false,
|
|
"attachedStopLossTakeProfit": nil,
|
|
"timeInForce": map[string]interface{} {
|
|
"IOC": false,
|
|
"FOK": false,
|
|
"PO": false,
|
|
"GTD": false,
|
|
},
|
|
"hedged": false,
|
|
"selfTradePrevention": false,
|
|
"trailing": false,
|
|
"leverage": false,
|
|
"marketBuyByCost": true,
|
|
"marketBuyRequiresPrice": false,
|
|
"iceberg": false,
|
|
},
|
|
"createOrders": nil,
|
|
"fetchMyTrades": nil,
|
|
"fetchOrder": map[string]interface{} {
|
|
"marginMode": false,
|
|
"trigger": false,
|
|
"trailing": false,
|
|
"symbolRequired": false,
|
|
},
|
|
"fetchOpenOrders": map[string]interface{} {
|
|
"marginMode": false,
|
|
"limit": 100,
|
|
"trigger": false,
|
|
"trailing": false,
|
|
"symbolRequired": false,
|
|
},
|
|
"fetchOrders": nil,
|
|
"fetchClosedOrders": map[string]interface{} {
|
|
"marginMode": false,
|
|
"limit": 100,
|
|
"daysBack": 100000,
|
|
"daysBackCanceled": 1,
|
|
"untilDays": 14,
|
|
"trigger": false,
|
|
"trailing": false,
|
|
"symbolRequired": false,
|
|
},
|
|
"fetchOHLCV": nil,
|
|
},
|
|
"swap": map[string]interface{} {
|
|
"linear": nil,
|
|
"inverse": nil,
|
|
},
|
|
"future": map[string]interface{} {
|
|
"linear": nil,
|
|
"inverse": nil,
|
|
},
|
|
},
|
|
"fees": map[string]interface{} {
|
|
"trading": map[string]interface{} {
|
|
"tierBased": false,
|
|
"percentage": true,
|
|
"taker": this.ParseNumber("0.0025"),
|
|
"maker": this.ParseNumber("0.0025"),
|
|
},
|
|
"funding": map[string]interface{} {
|
|
"withdraw": map[string]interface{} {
|
|
"UAH": "1%",
|
|
"BTC": 0.001,
|
|
"BCH": 0.001,
|
|
"ETH": 0.01,
|
|
"WAVES": 0.01,
|
|
"GOL": 0,
|
|
"GBG": 0,
|
|
},
|
|
"deposit": map[string]interface{} {},
|
|
},
|
|
},
|
|
"commonCurrencies": map[string]interface{} {
|
|
"PLA": "Plair",
|
|
},
|
|
"precisionMode": TICK_SIZE,
|
|
"exceptions": map[string]interface{} {
|
|
"ARGUMENT_VALIDATION_ERROR": BadRequest,
|
|
"PAYMENT_METHOD_NOT_SUPPORTED": BadRequest,
|
|
"NOT_FOUND": OrderNotFound,
|
|
"INVALID:ORDER_SIZE": InvalidOrder,
|
|
"WrongRequestException": BadRequest,
|
|
"INSUFFICIENT_FUNDS": InsufficientFunds,
|
|
"2002": InsufficientFunds,
|
|
"2003": OrderNotFound,
|
|
},
|
|
"options": map[string]interface{} {},
|
|
})
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchTime
|
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
* @see https://docs.kuna.io/docs/get-time-on-the-server
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
*/
|
|
func (this *kuna) FetchTime(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
response:= (<-this.V4PublicGetPublicTimestamp(params))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "timestamp": 1686740531,
|
|
// "timestamp_miliseconds": 1686740531725,
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.SafeInteger(data, "timestamp_miliseconds")
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchCurrencies
|
|
* @description fetches all available currencies on an exchange
|
|
* @see https://docs.kuna.io/docs/get-information-about-available-currencies
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an associative dictionary of currencies
|
|
*/
|
|
func (this *kuna) FetchCurrencies(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
response:= (<-this.V4PublicGetPublicCurrencies(params))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "code": "BTC",
|
|
// "name": "Bitcoin",
|
|
// "payload": {
|
|
// "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
|
|
// "icons": {
|
|
// "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
|
|
// "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
|
|
// "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
|
|
// "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
|
|
// },
|
|
// "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
|
|
// },
|
|
// "position": 1,
|
|
// "precision": 8,
|
|
// "tradePrecision": 6,
|
|
// "type": "Crypto"
|
|
// }
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseCurrencies(data)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseCurrency(currency interface{}) interface{} {
|
|
//
|
|
// {
|
|
// "code": "BTC",
|
|
// "name": "Bitcoin",
|
|
// "payload": {
|
|
// "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
|
|
// "icons": {
|
|
// "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
|
|
// "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
|
|
// "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
|
|
// "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
|
|
// },
|
|
// "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
|
|
// },
|
|
// "position": 1,
|
|
// "precision": 8,
|
|
// "tradePrecision": 6,
|
|
// "type": "Crypto"
|
|
// }
|
|
//
|
|
var currencyId interface{} = this.SafeString(currency, "code")
|
|
var precision interface{} = this.SafeString(currency, "precision")
|
|
var tradePrecision interface{} = this.SafeString(currency, "tradePrecision")
|
|
return this.SafeCurrencyStructure(map[string]interface{} {
|
|
"info": currency,
|
|
"id": currencyId,
|
|
"code": this.SafeCurrencyCode(currencyId),
|
|
"type": nil,
|
|
"margin": nil,
|
|
"name": this.SafeString(currency, "name"),
|
|
"active": nil,
|
|
"deposit": nil,
|
|
"withdraw": nil,
|
|
"fee": nil,
|
|
"precision": this.ParseNumber(Precise.StringMin(precision, tradePrecision)),
|
|
"limits": map[string]interface{} {
|
|
"amount": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
"withdraw": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
},
|
|
"networks": map[string]interface{} {},
|
|
})
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchMarkets
|
|
* @description retrieves data on all markets for kuna
|
|
* @see https://docs.kuna.io/docs/get-all-traded-markets
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object[]} an array of objects representing market data
|
|
*/
|
|
func (this *kuna) FetchMarkets(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
response:= (<-this.V4PublicGetMarketsPublicGetAll(params))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "pair": "BTC_USDT", // Traded pair of assets
|
|
// "baseAsset": { // The base asset of the traded pair, the one to sell or buy as a result of the trade
|
|
// "code": "BTC",
|
|
// "precision": 6 // Maximum amount of digits for the decimal part of a number
|
|
// },
|
|
// "quoteAsset": { // The quoted asset of the traded pair, the one to use to sell or buy the base asset
|
|
// "code": "USDT",
|
|
// "precision": 2 // Maximum amount of digits for the decimal part of a number
|
|
// },
|
|
// "tickerPriceChange": "-0.07" // Relative change compared with the last tick
|
|
// }
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", []interface{}{})
|
|
var markets interface{} = []interface{}{}
|
|
for i := 0; IsLessThan(i, GetArrayLength(data)); i++ {
|
|
var item interface{} = GetValue(data, i)
|
|
var marketId interface{} = this.SafeString(item, "pair")
|
|
var baseAsset interface{} = this.SafeValue(item, "baseAsset")
|
|
var quoteAsset interface{} = this.SafeValue(item, "quoteAsset")
|
|
var baseId interface{} = this.SafeString(baseAsset, "code")
|
|
var quoteId interface{} = this.SafeString(quoteAsset, "code")
|
|
var base interface{} = this.SafeCurrencyCode(baseId)
|
|
var quote interface{} = this.SafeCurrencyCode(quoteId)
|
|
var basePrecision interface{} = this.SafeString(baseAsset, "precision")
|
|
var quotePrecision interface{} = this.SafeString(quoteAsset, "precision")
|
|
AppendToArray(&markets,map[string]interface{} {
|
|
"id": marketId,
|
|
"symbol": Add(Add(base, "/"), quote),
|
|
"base": base,
|
|
"quote": quote,
|
|
"settle": nil,
|
|
"baseId": baseId,
|
|
"quoteId": quoteId,
|
|
"settleId": nil,
|
|
"type": "spot",
|
|
"spot": true,
|
|
"margin": false,
|
|
"swap": false,
|
|
"future": false,
|
|
"option": false,
|
|
"active": nil,
|
|
"contract": false,
|
|
"linear": nil,
|
|
"inverse": nil,
|
|
"contractSize": nil,
|
|
"expiry": nil,
|
|
"expiryDatetime": nil,
|
|
"strike": nil,
|
|
"optionType": nil,
|
|
"precision": map[string]interface{} {
|
|
"amount": this.ParseNumber(this.ParsePrecision(basePrecision)),
|
|
"price": this.ParseNumber(this.ParsePrecision(quotePrecision)),
|
|
},
|
|
"limits": map[string]interface{} {
|
|
"leverage": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
"amount": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
"price": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
"cost": map[string]interface{} {
|
|
"min": nil,
|
|
"max": nil,
|
|
},
|
|
},
|
|
"created": nil,
|
|
"info": item,
|
|
})
|
|
}
|
|
|
|
ch <- markets
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchOrderBook
|
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
* @see https://docs.kuna.io/docs/get-public-orders-book
|
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
* @param {int} [limit] 5, 10, 20, 50, 100, 500, or 1000 (default)
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
*/
|
|
func (this *kuna) FetchOrderBook(symbol interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
limit := GetArg(optionalArgs, 0, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes6838 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes6838)
|
|
var market interface{} = this.Market(symbol)
|
|
var request interface{} = map[string]interface{} {
|
|
"pairs": GetValue(market, "id"),
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "level", limit)
|
|
}
|
|
|
|
response:= (<-this.V4PublicGetOrderPublicBookPairs(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "asks": [ // An array of sell orders
|
|
// [
|
|
// "16950", // Sell price, level 1
|
|
// "0.001" // Sell quantity, level 1
|
|
// ],
|
|
// [
|
|
// "17000", // Sell price, level 2
|
|
// "0.01" // Sell quantity, level 2
|
|
// ]
|
|
// ],
|
|
// "bids": [ // An array of buy orders
|
|
// [
|
|
// "16700", // Sell price, level 1
|
|
// "0.01" // Sell quantity, level 1
|
|
// ],
|
|
// [
|
|
// "16000", // Sell price, level 2
|
|
// "0.001" // Sell quantity, level 2
|
|
// ]
|
|
// ]
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseOrderBook(data, GetValue(market, "symbol"), nil, "bids", "asks", 0, 1)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseTicker(ticker interface{}, optionalArgs ...interface{}) interface{} {
|
|
//
|
|
// {
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
|
|
// "price": "27900", // Current median price
|
|
// "equivalentPrice": "", // TBD
|
|
// "high": "29059.69", // Highest price
|
|
// "low": "27900", // Lowest price
|
|
// "baseVolume": "2.9008499999999993", // Traded volume as base
|
|
// "quoteVolume": "82251.41477976", // Traded volume as quote
|
|
// "bestBidPrice": "27926.91", // The best bid price now
|
|
// "bestAskPrice": "27970.02", // The best ask price now
|
|
// "priceChange": "-973.9700000000012" // Absolute price change
|
|
// }
|
|
//
|
|
market := GetArg(optionalArgs, 0, nil)
|
|
_ = market
|
|
var marketId interface{} = this.SafeString(ticker, "pair")
|
|
return this.SafeTicker(map[string]interface{} {
|
|
"info": ticker,
|
|
"symbol": this.SafeSymbol(marketId, market),
|
|
"timestamp": nil,
|
|
"datetime": nil,
|
|
"high": this.SafeString(ticker, "high"),
|
|
"low": this.SafeString(ticker, "low"),
|
|
"bid": this.SafeString(ticker, "bestBidPrice"),
|
|
"ask": this.SafeString(ticker, "bestAskPrice"),
|
|
"vwap": nil,
|
|
"open": this.SafeString(ticker, "open"),
|
|
"close": nil,
|
|
"last": nil,
|
|
"previousClose": nil,
|
|
"change": this.SafeString(ticker, "priceChange"),
|
|
"percentage": this.SafeString(ticker, "percentagePriceChange"),
|
|
"average": nil,
|
|
"baseVolume": this.SafeString(ticker, "baseVolume"),
|
|
"quoteVolume": this.SafeString(ticker, "quoteVolume"),
|
|
}, market)
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchTickers
|
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market. The average is not returned in the response, but the median can be accessed via response['info']['price']
|
|
* @see https://docs.kuna.io/docs/get-market-info-by-tickers
|
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *kuna) FetchTickers(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbols := GetArg(optionalArgs, 0, nil)
|
|
_ = symbols
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes7718 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes7718)
|
|
if IsTrue(IsEqual(symbols, nil)) {
|
|
panic(ArgumentsRequired(Add(this.Id, " fetchTickers () requires a symbols argument")))
|
|
}
|
|
symbols = this.MarketSymbols(symbols)
|
|
var marketIds interface{} = this.MarketIds(symbols)
|
|
var request interface{} = map[string]interface{} {
|
|
"pairs": Join(marketIds, ","),
|
|
}
|
|
|
|
response:= (<-this.V4PublicGetMarketsPublicTickersPairsPairs(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
|
|
// "price": "27900", // Current median price
|
|
// "equivalentPrice": "", // TBD
|
|
// "high": "29059.69", // Highest price
|
|
// "low": "27900", // Lowest price
|
|
// "baseVolume": "2.9008499999999993", // Traded volume as base
|
|
// "quoteVolume": "82251.41477976", // Traded volume as quote
|
|
// "bestBidPrice": "27926.91", // The best bid price now
|
|
// "bestAskPrice": "27970.02", // The best ask price now
|
|
// "priceChange": "-973.9700000000012" // Absolute price change
|
|
// }
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseTickers(data, symbols, params)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchTicker
|
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
* @see https://docs.kuna.io/docs/get-market-info-by-tickers
|
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *kuna) FetchTicker(symbol interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes8158 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes8158)
|
|
var market interface{} = this.Market(symbol)
|
|
var request interface{} = map[string]interface{} {
|
|
"pairs": GetValue(market, "id"),
|
|
}
|
|
|
|
response:= (<-this.V4PublicGetMarketsPublicTickersPairsPairs(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
|
|
// "price": "27900", // Current median price
|
|
// "equivalentPrice": "", // TBD
|
|
// "high": "29059.69", // Highest price
|
|
// "low": "27900", // Lowest price
|
|
// "baseVolume": "2.9008499999999993", // Traded volume as base
|
|
// "quoteVolume": "82251.41477976", // Traded volume as quote
|
|
// "bestBidPrice": "27926.91", // The best bid price now
|
|
// "bestAskPrice": "27970.02", // The best ask price now
|
|
// "priceChange": "-973.9700000000012" // Absolute price change
|
|
// }
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", []interface{}{})
|
|
var ticker interface{} = this.SafeDict(data, 0)
|
|
|
|
ch <- this.ParseTicker(ticker, market)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* TODO: double check
|
|
* @method
|
|
* @name kuna#fetchL3OrderBook
|
|
* @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [limit] max number of orders to return, default is undefined
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}
|
|
*/
|
|
func (this *kuna) FetchL3OrderBook(symbol interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
limit := GetArg(optionalArgs, 0, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes85715 := (<-this.FetchOrderBook(symbol, limit, params))
|
|
PanicOnError(retRes85715)
|
|
ch <- retRes85715
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchTrades
|
|
* @description get the list of most recent trades for a particular symbol
|
|
* @see https://docs.kuna.io/docs/get-public-trades-book
|
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
* @param {int} [limit] between 1 and 100, 25 by default
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
*/
|
|
func (this *kuna) FetchTrades(symbol interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
since := GetArg(optionalArgs, 0, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 1, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 2, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes8728 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes8728)
|
|
var market interface{} = this.Market(symbol)
|
|
var request interface{} = map[string]interface{} {
|
|
"pairs": GetValue(market, "id"),
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "limit", limit)
|
|
}
|
|
|
|
response:= (<-this.V4PublicGetTradePublicBookPairs(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// 'data': [
|
|
// {
|
|
// 'createdAt': '2024-03-02T00:10:49.385Z',
|
|
// 'id': '3b42878a-3688-4bc1-891e-5cc2fc902142',
|
|
// 'matchPrice': '62181.31',
|
|
// 'matchQuantity': '0.00568',
|
|
// 'pair': 'BTC_USDT',
|
|
// 'quoteQuantity': '353.1898408',
|
|
// 'side': 'Bid'
|
|
// },
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseTrades(data, market, since, limit)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseTrade(trade interface{}, optionalArgs ...interface{}) interface{} {
|
|
//
|
|
// fetchTrades (public)
|
|
//
|
|
// {
|
|
// "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
|
|
// "pair": "BTC_USDT", // Market pair that is being traded
|
|
// "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
|
|
// "matchPrice": "18649", // Exchange price at the moment of execution
|
|
// "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
|
|
// "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
|
|
// "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
|
|
// }
|
|
//
|
|
// fetchMyTrades, fetchOrder (private)
|
|
//
|
|
// {
|
|
// "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
|
|
// "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
|
|
// "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
|
|
// "quantity": "1.5862", // Traded quantity of base asset
|
|
// "price": "19087", // Price of the trade
|
|
// "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
|
|
// "fee": "0.0039655", // Exchange commission fee
|
|
// "feeCurrency": "BTC", // Currency of the commission
|
|
// "isBuyer": true, // Buy or sell the base asset
|
|
// "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
|
|
// "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
|
|
// }
|
|
//
|
|
market := GetArg(optionalArgs, 0, nil)
|
|
_ = market
|
|
var datetime interface{} = this.SafeString(trade, "createdAt")
|
|
var marketId interface{} = this.SafeString(trade, "pair")
|
|
var isTaker interface{} = this.SafeValue(trade, "isMaker")
|
|
var side interface{} = this.SafeStringLower(trade, "side")
|
|
if IsTrue(IsEqual(side, nil)) {
|
|
var isBuyer interface{} = this.SafeValue(trade, "isBuyer")
|
|
side = Ternary(IsTrue(isBuyer), "buy", "sell")
|
|
}
|
|
return this.SafeTrade(map[string]interface{} {
|
|
"info": trade,
|
|
"id": this.SafeString(trade, "id"),
|
|
"symbol": this.SafeSymbol(marketId, market),
|
|
"timestamp": this.Parse8601(datetime),
|
|
"datetime": datetime,
|
|
"type": nil,
|
|
"side": side,
|
|
"order": this.SafeString(trade, "orderId"),
|
|
"takerOrMaker": Ternary(IsTrue(isTaker), "taker", "maker"),
|
|
"price": this.SafeString2(trade, "matchPrice", "price"),
|
|
"amount": this.SafeString2(trade, "matchQuantity", "quantity"),
|
|
"cost": this.SafeString(trade, "quoteQuantity"),
|
|
"fee": map[string]interface{} {
|
|
"cost": this.SafeString(trade, "fee"),
|
|
"currency": this.SafeCurrencyCode(this.SafeString(trade, "feeCurrency")),
|
|
},
|
|
}, market)
|
|
}
|
|
func (this *kuna) ParseBalance(response interface{}) interface{} {
|
|
//
|
|
// [
|
|
// {
|
|
// "currency": "UAH",
|
|
// "balance": "7134.6",
|
|
// "lockBalance": "100"
|
|
// }
|
|
// ...
|
|
// ]
|
|
//
|
|
var result interface{} = map[string]interface{} {
|
|
"info": response,
|
|
}
|
|
for i := 0; IsLessThan(i, GetArrayLength(response)); i++ {
|
|
var balance interface{} = GetValue(response, i)
|
|
var currencyId interface{} = this.SafeString(balance, "currency")
|
|
var code interface{} = this.SafeCurrencyCode(currencyId)
|
|
var account interface{} = this.Account()
|
|
AddElementToObject(account, "free", this.SafeString(balance, "balance"))
|
|
AddElementToObject(account, "used", this.SafeString(balance, "lockBalance"))
|
|
AddElementToObject(result, code, account)
|
|
}
|
|
return this.SafeBalance(result)
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchBalance
|
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
*/
|
|
func (this *kuna) FetchBalance(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes9918 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes9918)
|
|
|
|
response:= (<-this.V4PrivateGetPrivateGetBalance(params))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [{
|
|
// "currency": "UAH", // Wallet currency
|
|
// "balance": "7134.6", // Available balance, precision depends on the currency
|
|
// "lockBalance": "100" // Minimum amount locked on the balance
|
|
// }]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseBalance(data)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#createOrder
|
|
* @description create a trade order
|
|
* @see https://docs.kuna.io/docs/create-a-new-order-private
|
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
* @param {string} type 'market' or 'limit'
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.id] id must be a UUID format, if you do not specify id, it will be generated automatically.
|
|
* @param {float} [params.quoteQuantity] the max quantity of the quote asset to use for selling/buying
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) CreateOrder(symbol interface{}, typeVar interface{}, side interface{}, amount interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
price := GetArg(optionalArgs, 0, nil)
|
|
_ = price
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes10258 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes10258)
|
|
var market interface{} = this.Market(symbol)
|
|
var triggerPrice interface{} = this.SafeString2(params, "triggerPrice", "stopPrice")
|
|
params = this.Omit(params, []interface{}{"triggerPrice", "stopPrice"})
|
|
var capitalizedType interface{} = this.Capitalize(typeVar)
|
|
var request interface{} = map[string]interface{} {
|
|
"pair": GetValue(market, "id"),
|
|
"orderSide": Ternary(IsTrue((IsEqual(side, "buy"))), "Bid", "Ask"),
|
|
"quantity": this.NumberToString(amount),
|
|
"type": capitalizedType,
|
|
}
|
|
if IsTrue(IsEqual(capitalizedType, "Limit")) {
|
|
AddElementToObject(request, "price", this.PriceToPrecision(GetValue(market, "symbol"), price))
|
|
}
|
|
if IsTrue(!IsEqual(triggerPrice, nil)) {
|
|
if IsTrue(IsEqual(capitalizedType, "Market")) {
|
|
panic(BadRequest(Add(this.Id, " createOrder () cannot place trigger market orders, or trigger limit")))
|
|
}
|
|
AddElementToObject(request, "stopPrice", this.PriceToPrecision(GetValue(market, "symbol"), triggerPrice))
|
|
if IsTrue(!IsEqual(capitalizedType, "TakeProfitLimit")) {
|
|
AddElementToObject(request, "type", "StopLossLimit")
|
|
}
|
|
}
|
|
|
|
response:= (<-this.V4PrivatePostOrderPrivateCreate(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "b0fcb54c-2278-4f16-a300-02765faad8b0", // ID of your newly created order
|
|
// "type": "Limit", // Type of an order
|
|
// "quantity": "0.06", // Original order quantity
|
|
// "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "price": "26440.46", // Price of the trade
|
|
// "status": "Open", // The status of the order
|
|
// "createdAt": "2023-07-11T08:01:30.550Z", // Date-time of order creation, UTC
|
|
// "updatedAt": "2023-07-11T08:01:30.550Z" // Date-time of the last update of the order, UTC
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseOrder(data, market)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#cancelOrder
|
|
* @description cancels an open order
|
|
* @param {string} id order id
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) CancelOrder(id interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes10788 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes10788)
|
|
var request interface{} = map[string]interface{} {
|
|
"orderId": id,
|
|
}
|
|
|
|
response:= (<-this.V4PrivatePostOrderPrivateCancel(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "success": true
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeValue(response, "data", map[string]interface{} {})
|
|
var market interface{} = nil
|
|
if IsTrue(!IsEqual(symbol, nil)) {
|
|
market = this.Market(symbol)
|
|
}
|
|
var order interface{} = this.ParseOrder(data, market)
|
|
AddElementToObject(order, "id", id)
|
|
|
|
ch <- order
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#cancelOrders
|
|
* @description cancels an open order
|
|
* @param {string} ids order ids
|
|
* @param {string} symbol not used by kuna cancelOrder
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) CancelOrders(ids interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes11108 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes11108)
|
|
var request interface{} = map[string]interface{} {
|
|
"orderIds": ids,
|
|
}
|
|
|
|
response:= (<-this.V4PrivatePostOrderPrivateCancelMulti(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order
|
|
// "success": true // Status for this order
|
|
// },
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseOrders(data)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseOrderStatus(status interface{}) interface{} {
|
|
var statuses interface{} = map[string]interface{} {
|
|
"Canceled": "canceled",
|
|
"Closed": "filled",
|
|
"Pending": "open",
|
|
"Open": "open",
|
|
"done": "closed",
|
|
"wait": "open",
|
|
"cancel": "canceled",
|
|
}
|
|
return this.SafeString(statuses, status, status)
|
|
}
|
|
func (this *kuna) ParseOrder(order interface{}, optionalArgs ...interface{}) interface{} {
|
|
//
|
|
// createOrder, fetchOrder, fetchOpenOrders, fetchOrdersByStatus
|
|
//
|
|
// {
|
|
// "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
|
|
// "type": "Limit", // Type of an order
|
|
// "quantity": "5", // Original order quantity
|
|
// "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
|
|
// "cumulativeQuoteQty": "0", // *absent on createOrder* Traded quantity in money (>0 if traded)
|
|
// "cost": "0.05", // Total amount
|
|
// "side": "Bid", // *absent on createOrder* Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
|
|
// "pair": "TRX_USDT", // Traded pair
|
|
// "price": "0.01", // Price of the trade
|
|
// "status": "Open", // The status of the order
|
|
// "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
|
|
// "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
|
|
// "closedAt": "2023-05-08T08:53:58.333Z" // *absent on fetchOpenOrders/createOrder* Date-time of order finish time, UTC
|
|
// "trades": [ // * fetchOrder only *
|
|
// {
|
|
// "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
|
|
// "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "quantity": "0.00054", // Traded quantity
|
|
// "price": "27770", // Traded price
|
|
// "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
|
|
// "fee": "0.000001350", // Exchange commission fee
|
|
// "feeCurrency": "BTC", // Currency of the commission
|
|
// "isBuyer": true, // Buy or sell the base asset
|
|
// "quoteQuantity": "14.9958", // Quote asset quantity
|
|
// "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
|
|
// }
|
|
// ]
|
|
// }
|
|
//
|
|
// cancelOrder, cancelOrders
|
|
//
|
|
// {
|
|
// "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order *absent on cancelOrder*
|
|
// "success": true // Status for this order
|
|
// }
|
|
//
|
|
market := GetArg(optionalArgs, 0, nil)
|
|
_ = market
|
|
var marketId interface{} = this.SafeString(order, "pair")
|
|
var datetime interface{} = this.SafeString(order, "createdAt")
|
|
var side interface{} = this.SafeString(order, "side")
|
|
if IsTrue(IsEqual(side, "Bid")) {
|
|
side = "buy"
|
|
} else if IsTrue(IsEqual(side, "Ask")) {
|
|
side = "sell"
|
|
}
|
|
var trades interface{} = this.SafeValue(order, "trades", []interface{}{})
|
|
return this.SafeOrder(map[string]interface{} {
|
|
"info": order,
|
|
"id": this.SafeString2(order, "id", "orderId"),
|
|
"clientOrderId": nil,
|
|
"symbol": this.SafeSymbol(marketId, market),
|
|
"timestamp": this.Parse8601(datetime),
|
|
"datetime": datetime,
|
|
"lastTradeTimestamp": this.Parse8601(this.SafeString(order, "updatedAt")),
|
|
"status": this.ParseOrderStatus(this.SafeString(order, "status")),
|
|
"type": this.SafeStringLower(order, "type"),
|
|
"timeInForce": nil,
|
|
"postOnly": nil,
|
|
"side": side,
|
|
"price": this.SafeString(order, "price"),
|
|
"triggerPrice": this.SafeString(order, "stopPrice"),
|
|
"amount": this.SafeString(order, "quantity"),
|
|
"filled": this.SafeString(order, "executedQuantity"),
|
|
"remaining": nil,
|
|
"trades": this.ParseTrades(trades),
|
|
"cost": this.SafeString(order, "cost"),
|
|
"average": nil,
|
|
"fee": nil,
|
|
}, market)
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchOrder
|
|
* @description fetches information on an order made by the user
|
|
* @see https://docs.kuna.io/docs/get-order-details-by-id
|
|
* @param {string} id order id
|
|
* @param {string} symbol not used by kuna fetchOrder
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {boolean} [params.withTrades] default == true, specify if the response should include trades associated with the order
|
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) FetchOrder(id interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes12338 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes12338)
|
|
var request interface{} = map[string]interface{} {
|
|
"id": id,
|
|
"withTrades": true,
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetOrderPrivateDetailsId(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3",
|
|
// "type": "Limit",
|
|
// "quantity": "0.00054",
|
|
// "executedQuantity": "0.00054",
|
|
// "cumulativeQuoteQty": "14.99580",
|
|
// "cost": "14.9958",
|
|
// "side": "Bid",
|
|
// "pair": "BTC_USDT",
|
|
// "price": "27770",
|
|
// "status": "Closed",
|
|
// "createdAt": "2023-05-08T08:39:46.708Z",
|
|
// "updatedAt": "2023-05-08T08:53:58.332Z",
|
|
// "closedAt": "2023-05-08T08:53:58.333Z",
|
|
// "trades": [
|
|
// {
|
|
// "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
|
|
// "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "quantity": "0.00054", // Traded quantity
|
|
// "price": "27770", // Traded price
|
|
// "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
|
|
// "fee": "0.000001350", // Exchange commission fee
|
|
// "feeCurrency": "BTC", // Currency of the commission
|
|
// "isBuyer": true, // Buy or sell the base asset
|
|
// "quoteQuantity": "14.9958", // Quote asset quantity
|
|
// "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
|
|
// }
|
|
// ]
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseOrder(data)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchOpenOrders
|
|
* @description fetch all unfilled currently open orders
|
|
* @see https://docs.kuna.io/docs/get-active-client-orders-private
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
* @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest timestamp (ms) to fetch orders for
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) FetchOpenOrders(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes12938 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes12938)
|
|
var until interface{} = this.SafeInteger(params, "until")
|
|
params = this.Omit(params, []interface{}{"until"})
|
|
var market interface{} = nil
|
|
var request interface{} = map[string]interface{} {}
|
|
if IsTrue(!IsEqual(symbol, nil)) {
|
|
market = this.Market(symbol)
|
|
AddElementToObject(request, "pairs", GetValue(market, "id"))
|
|
}
|
|
if IsTrue(!IsEqual(since, nil)) {
|
|
AddElementToObject(request, "start", this.Iso8601(since))
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "limit", limit)
|
|
}
|
|
if IsTrue(!IsEqual(until, nil)) {
|
|
AddElementToObject(request, "end", this.Iso8601(until))
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetOrderPrivateActive(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
|
|
// "type": "Limit", // Type of an order
|
|
// "quantity": "5", // Original order quantity
|
|
// "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
|
|
// "cumulativeQuoteQty": "0", // Traded quantity in money (>0 if traded)
|
|
// "cost": "0.05", // Total amount
|
|
// "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
|
|
// "pair": "TRX_USDT", // Traded pair
|
|
// "price": "0.01", // Price of the trade
|
|
// "status": "Open", // The status of the order
|
|
// "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
|
|
// "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
|
|
// }
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseOrders(data, market, since, limit)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchClosedOrders
|
|
* @description fetches information on multiple closed orders made by the user
|
|
* @see https://docs.kuna.io/docs/get-private-orders-history
|
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) FetchClosedOrders(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes135415 := (<-this.FetchOrdersByStatus("closed", symbol, since, limit, params))
|
|
PanicOnError(retRes135415)
|
|
ch <- retRes135415
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchOrdersByStatus
|
|
* @description fetch a list of orders
|
|
* @see https://docs.kuna.io/docs/get-private-orders-history
|
|
* @param {string} status canceled, closed, expired, open, pending, rejected, or waitStop
|
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
* @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest timestamp (ms) to fetch orders for
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
|
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *kuna) FetchOrdersByStatus(status interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes13748 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes13748)
|
|
if IsTrue(IsEqual(status, "open")) {
|
|
|
|
ch <- this.FetchOpenOrders(symbol, since, limit, params)
|
|
return nil
|
|
}
|
|
var until interface{} = this.SafeInteger(params, "until")
|
|
params = this.Omit(params, []interface{}{"until"})
|
|
var market interface{} = nil
|
|
var request interface{} = map[string]interface{} {
|
|
"status": this.Capitalize(status),
|
|
}
|
|
if IsTrue(!IsEqual(symbol, nil)) {
|
|
market = this.Market(symbol)
|
|
AddElementToObject(request, "pairs", GetValue(market, "id"))
|
|
}
|
|
if IsTrue(!IsEqual(since, nil)) {
|
|
AddElementToObject(request, "start", this.Iso8601(since))
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "limit", limit)
|
|
}
|
|
if IsTrue(!IsEqual(until, nil)) {
|
|
AddElementToObject(request, "end", this.Iso8601(until))
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetOrderPrivateHistory(request))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an order
|
|
// "type": "Limit", // Type of an order
|
|
// "quantity": "0.00054", // Original order quantity
|
|
// "executedQuantity": "0.00054", // Traded quantity in stock (>0 if traded)
|
|
// "cumulativeQuoteQty": "14.99580", // Traded quantity in money (>0 if traded)
|
|
// "cost": "14.9958", // Total amount
|
|
// "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
|
|
// "pair": "BTC_USDT", // Traded pair
|
|
// "price": "27770", // Price of the trade
|
|
// "status": "Closed", // The status of the order
|
|
// "createdAt": "2023-05-08T08:39:46.708Z", // Date-time of order creation, UTC
|
|
// "updatedAt": "2023-05-08T08:53:58.332Z", // Date-time of the last update of the order, UTC
|
|
// "closedAt": "2023-05-08T08:53:58.333Z" // Date-time of order finish time, UTC
|
|
// },
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseOrders(data, market, since, limit)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchMyTrades
|
|
* @description fetch all trades made by the user
|
|
* @see https://docs.kuna.io/docs/get-private-trades-history
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] not used by kuna fetchMyTrades
|
|
* @param {int} [limit] not used by kuna fetchMyTrades
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.orderId] UUID of an order, to receive trades for this order only
|
|
* @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
|
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
*/
|
|
func (this *kuna) FetchMyTrades(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
symbol := GetArg(optionalArgs, 0, nil)
|
|
_ = symbol
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes14408 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes14408)
|
|
var market interface{} = nil
|
|
var request interface{} = map[string]interface{} {}
|
|
if IsTrue(!IsEqual(symbol, nil)) {
|
|
market = this.Market(symbol)
|
|
AddElementToObject(request, "pair", GetValue(market, "id"))
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetTradePrivateHistory(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
|
|
// "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
|
|
// "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
|
|
// "quantity": "1.5862", // Traded quantity of base asset
|
|
// "price": "19087", // Price of the trade
|
|
// "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
|
|
// "fee": "0.0039655", // Exchange commission fee
|
|
// "feeCurrency": "BTC", // Currency of the commission
|
|
// "isBuyer": true, // Buy or sell the base asset
|
|
// "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
|
|
// "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
|
|
// },
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data")
|
|
|
|
ch <- this.ParseTrades(data, market, since, limit)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#withdraw
|
|
* @description make a withdrawal
|
|
* @see https://docs.kuna.io/docs/create-a-withdraw
|
|
* @param {string} code unified currency code
|
|
* @param {float} amount the amount to withdraw
|
|
* @param {string} address the address to withdraw to
|
|
* @param {string} tag
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {string} [params.chain] the chain to withdraw to
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.id] id must be a uuid format, if you do not specify id, it will be generated automatically
|
|
* @param {boolean} [params.withdrawAll] this field says that the amount should also include a fee
|
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *kuna) Withdraw(code interface{}, amount interface{}, address interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
tag := GetArg(optionalArgs, 0, nil)
|
|
_ = tag
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
this.CheckAddress(address)
|
|
var chain interface{} = this.SafeString2(params, "chain", "network")
|
|
params = this.Omit(params, []interface{}{"chain", "network"})
|
|
|
|
retRes14928 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes14928)
|
|
var currency interface{} = this.Currency(code)
|
|
if IsTrue(IsEqual(chain, nil)) {
|
|
if IsTrue(IsGreaterThan(GetIndexOf(GetValue(currency, "code"), "USD"), 0)) {
|
|
panic(ArgumentsRequired(Add(Add(this.Id, " withdraw () requires an extra parameter params[\"network\"] to withdraw "), GetValue(currency, "code"))))
|
|
} else {
|
|
chain = ToUpper(GetValue(currency, "id"))
|
|
}
|
|
}
|
|
var networkId interface{} = this.NetworkCodeToId(chain)
|
|
var request interface{} = map[string]interface{} {
|
|
"currency": networkId,
|
|
"amount": amount,
|
|
"address": address,
|
|
"paymentMethod": chain,
|
|
}
|
|
if IsTrue(!IsEqual(tag, nil)) {
|
|
AddElementToObject(request, "paymentId", tag)
|
|
}
|
|
|
|
response:= (<-this.V4PrivatePostWithdrawPrivateCreate(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // unique identifier of a withdraw
|
|
// "status": "waitingForConfirmation" // status of a withdraw, if you turn off withdrawal confirmation by email, it will return "processing" status, which means that the transaction is already being processed on our side
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseTransaction(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchWithdrawals
|
|
* @description fetch all withdrawals made to an account
|
|
* @see https://docs.kuna.io/docs/get-withdraw-history
|
|
* @param {string} code unified currency code
|
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch deposits for
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
|
|
* @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
|
|
* @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
|
|
* @param {int} [params.skip] 0 - ... Select the number of transactions to skip
|
|
* @param {string} [params.address]
|
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *kuna) FetchWithdrawals(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
code := GetArg(optionalArgs, 0, nil)
|
|
_ = code
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes15448 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes15448)
|
|
var until interface{} = this.SafeInteger(params, "until")
|
|
params = this.Omit(params, "until")
|
|
var currency interface{} = nil
|
|
if IsTrue(!IsEqual(code, nil)) {
|
|
currency = this.Currency(code)
|
|
}
|
|
var request interface{} = map[string]interface{} {}
|
|
if IsTrue(!IsEqual(code, nil)) {
|
|
AddElementToObject(request, "currency", code)
|
|
}
|
|
if IsTrue(!IsEqual(since, nil)) {
|
|
AddElementToObject(request, "dateFrom", this.Iso8601(since))
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "take", limit)
|
|
}
|
|
if IsTrue(!IsEqual(until, nil)) {
|
|
AddElementToObject(request, "dateTo", this.Iso8601(until))
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetWithdrawPrivateHistory(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
|
|
// "amount": "10.75", // Amount deducted from your account
|
|
// "asset": "USDT", // Withdrawal currency
|
|
// "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
|
|
// "paymentCode": "TRX", // Blockchain name
|
|
// "status": "Processed", // Withdrawal status
|
|
// "type": "Withdraw", // Transaction type
|
|
// "reason": [], // Reason for manual transaction processing
|
|
// "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
|
|
// "memo": "", // Withdrawal memo
|
|
// "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
|
|
// "fee": "0.75", // Withdrawal fee
|
|
// "processedAmount": "10", // Withdrawal amount
|
|
// "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
|
|
// "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
|
|
// },
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseTransactions(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchWithdrawal
|
|
* @description fetch data on a currency withdrawal via the withdrawal id
|
|
* @see https://docs.kuna.io/docs/get-withdraw-details-by-id
|
|
* @param {string} id withdrawal id
|
|
* @param {string} code not used by kuna.fetchWithdrawal
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *kuna) FetchWithdrawal(id interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
code := GetArg(optionalArgs, 0, nil)
|
|
_ = code
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes16048 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes16048)
|
|
var request interface{} = map[string]interface{} {
|
|
"withdrawId": id,
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetWithdrawPrivateDetailsWithdrawId(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
|
|
// "amount": "10.75", // Amount deducted from your account
|
|
// "asset": "USDT", // Withdrawal currency
|
|
// "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
|
|
// "paymentCode": "TRX", // Blockchain name
|
|
// "status": "Processed", // Withdrawal status
|
|
// "type": "Withdraw", // Transaction type
|
|
// "reason": [], // Reason for manual transaction processing
|
|
// "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
|
|
// "memo": "", // Withdrawal memo
|
|
// "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
|
|
// "fee": "0.75", // Withdrawal fee
|
|
// "processedAmount": "10", // Withdrawal amount
|
|
// "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
|
|
// "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseTransaction(data)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#createDepositAddress
|
|
* @description create a currency deposit address
|
|
* @see https://docs.kuna.io/docs/generate-a-constant-crypto-address-for-deposit
|
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
*/
|
|
func (this *kuna) CreateDepositAddress(code interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes16448 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes16448)
|
|
var currency interface{} = this.Currency(code)
|
|
var request interface{} = map[string]interface{} {
|
|
"source": GetValue(currency, "id"),
|
|
}
|
|
|
|
response:= (<-this.V4PrivatePostDepositPrivateCryptoGenerateAddress(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "1300c2b6-ree4-4f1e-2a9d-e0f7ed0991a7", // ID of your address
|
|
// "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account
|
|
// "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseDepositAddress(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchDepositAddress
|
|
* @description fetch the deposit address for a currency associated with this account
|
|
* @see https://docs.kuna.io/docs/find-crypto-address-for-deposit
|
|
* @param {string} code unified currency code
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
*/
|
|
func (this *kuna) FetchDepositAddress(code interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
params := GetArg(optionalArgs, 0, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes16738 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes16738)
|
|
var currency interface{} = this.Currency(code)
|
|
var request interface{} = map[string]interface{} {
|
|
"source": ToUpper(GetValue(currency, "id")),
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetDepositPrivateCryptoAddress(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
|
|
// "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
|
|
// "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseDepositAddress(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseDepositAddress(depositAddress interface{}, optionalArgs ...interface{}) interface{} {
|
|
//
|
|
// {
|
|
// "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
|
|
// "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
|
|
// "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
|
|
// }
|
|
//
|
|
currency := GetArg(optionalArgs, 0, nil)
|
|
_ = currency
|
|
var currencyId interface{} = this.SafeString(depositAddress, "source")
|
|
return map[string]interface{} {
|
|
"info": this.SafeString(depositAddress, ""),
|
|
"currency": this.SafeCurrencyCode(currencyId, currency),
|
|
"network": nil,
|
|
"address": this.SafeString(depositAddress, "address"),
|
|
"tag": nil,
|
|
}
|
|
}
|
|
func (this *kuna) ParseTransactionStatus(status interface{}) interface{} {
|
|
var statuses interface{} = map[string]interface{} {
|
|
"Created": "pending",
|
|
"Canceled": "canceled",
|
|
"PartiallyProcessed": "pending",
|
|
"Processing": "pending",
|
|
"Processed": "ok",
|
|
"WaitForConfirmation": "pending",
|
|
"Pending": "pending",
|
|
"AmlChecking": "pending",
|
|
}
|
|
return this.SafeString(statuses, status, status)
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchDeposits
|
|
* @description fetch all deposits made to an account
|
|
* @see https://docs.kuna.io/docs/get-deposit-history
|
|
* @param {string} code unified currency code
|
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch deposits for
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
|
|
* @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
|
|
* @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
|
|
* @param {int} [params.skip] 0 - ... Select the number of transactions to skip
|
|
* @param {string} [params.address]
|
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *kuna) FetchDeposits(optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
code := GetArg(optionalArgs, 0, nil)
|
|
_ = code
|
|
since := GetArg(optionalArgs, 1, nil)
|
|
_ = since
|
|
limit := GetArg(optionalArgs, 2, nil)
|
|
_ = limit
|
|
params := GetArg(optionalArgs, 3, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes17448 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes17448)
|
|
var until interface{} = this.SafeInteger(params, "until")
|
|
params = this.Omit(params, "until")
|
|
var currency interface{} = nil
|
|
if IsTrue(!IsEqual(code, nil)) {
|
|
currency = this.Currency(code)
|
|
}
|
|
var request interface{} = map[string]interface{} {}
|
|
if IsTrue(!IsEqual(code, nil)) {
|
|
AddElementToObject(request, "currency", code)
|
|
}
|
|
if IsTrue(!IsEqual(since, nil)) {
|
|
AddElementToObject(request, "dateFrom", this.Iso8601(since))
|
|
}
|
|
if IsTrue(!IsEqual(limit, nil)) {
|
|
AddElementToObject(request, "take", limit)
|
|
}
|
|
if IsTrue(!IsEqual(until, nil)) {
|
|
AddElementToObject(request, "dateTo", this.Iso8601(until))
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetDepositPrivateHistory(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": [
|
|
// {
|
|
// "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
|
|
// "amount": "9.9", // Amount credited to your account
|
|
// "asset": "USDT", // Deposit currency
|
|
// "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
|
|
// "paymentCode": "TRX", // Blockchain name
|
|
// "status": "Processed", // Transactions status
|
|
// "type": "Deposit", // Transaction type
|
|
// "reason": [], // Reason for manual transaction processing
|
|
// "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
|
|
// "memo": "", // Deposit memo
|
|
// "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
|
|
// "fee": "0.1", // Deposit fee
|
|
// "processedAmount": "10", // Amount of deposit
|
|
// "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
|
|
// "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
|
|
// },
|
|
// ...
|
|
// ]
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeList(response, "data", []interface{}{})
|
|
|
|
ch <- this.ParseTransactions(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
/**
|
|
* @method
|
|
* @name kuna#fetchDeposit
|
|
* @description fetch data on a currency deposit via the deposit id
|
|
* @see https://docs.kuna.io/docs/get-deposit-details-by-id
|
|
* @param {string} id deposit id
|
|
* @param {string} code filter by currency code
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
*/
|
|
func (this *kuna) FetchDeposit(id interface{}, optionalArgs ...interface{}) <- chan interface{} {
|
|
ch := make(chan interface{})
|
|
go func() interface{} {
|
|
defer close(ch)
|
|
defer ReturnPanicError(ch)
|
|
code := GetArg(optionalArgs, 0, nil)
|
|
_ = code
|
|
params := GetArg(optionalArgs, 1, map[string]interface{} {})
|
|
_ = params
|
|
|
|
retRes18048 := (<-this.LoadMarkets())
|
|
PanicOnError(retRes18048)
|
|
var currency interface{} = nil
|
|
if IsTrue(!IsEqual(code, nil)) {
|
|
currency = this.Currency(code)
|
|
}
|
|
var request interface{} = map[string]interface{} {
|
|
"depositId": id,
|
|
}
|
|
|
|
response:= (<-this.V4PrivateGetDepositPrivateDetailsDepositId(this.Extend(request, params)))
|
|
PanicOnError(response)
|
|
//
|
|
// {
|
|
// "data": {
|
|
// "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
|
|
// "amount": "9.9", // Amount credited to your account
|
|
// "asset": "USDT", // Deposit currency
|
|
// "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
|
|
// "paymentCode": "TRX", // Blockchain name
|
|
// "status": "Processed", // Transactions status
|
|
// "type": "Deposit", // Transaction type
|
|
// "reason": [], // Reason for manual transaction processing
|
|
// "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
|
|
// "memo": "", // Deposit memo
|
|
// "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
|
|
// "fee": "0.1", // Deposit fee
|
|
// "processedAmount": "10", // Amount of deposit
|
|
// "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
|
|
// "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
|
|
// }
|
|
// }
|
|
//
|
|
var data interface{} = this.SafeDict(response, "data", map[string]interface{} {})
|
|
|
|
ch <- this.ParseTransaction(data, currency)
|
|
return nil
|
|
|
|
}()
|
|
return ch
|
|
}
|
|
func (this *kuna) ParseTransaction(transaction interface{}, optionalArgs ...interface{}) interface{} {
|
|
//
|
|
// {
|
|
// "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
|
|
// "amount": "9.9", // Amount credited to your account
|
|
// "asset": "USDT", // Deposit currency
|
|
// "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
|
|
// "paymentCode": "TRX", // Blockchain name
|
|
// "status": "Processed", // Transactions status
|
|
// "type": "Deposit", // Transaction type
|
|
// "reason": [], // Reason for manual transaction processing
|
|
// "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
|
|
// "memo": "", // Deposit memo
|
|
// "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
|
|
// "fee": "0.1", // Deposit fee
|
|
// "processedAmount": "10", // Amount of deposit
|
|
// "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
|
|
// "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
|
|
// }
|
|
//
|
|
currency := GetArg(optionalArgs, 0, nil)
|
|
_ = currency
|
|
var datetime interface{} = this.SafeString(transaction, "createdAt")
|
|
var currencyId interface{} = this.SafeString(transaction, "asset")
|
|
var code interface{} = this.SafeCurrencyCode(currencyId, currency)
|
|
var networkId interface{} = this.SafeString(transaction, "paymentCode")
|
|
var typeVar interface{} = this.SafeStringLower(transaction, "type")
|
|
var address interface{} = this.SafeString(transaction, "address")
|
|
var isDeposit interface{} = (IsEqual(typeVar, "deposit"))
|
|
var parsedType interface{} = Ternary(IsTrue(isDeposit), typeVar, "withdrawal")
|
|
return map[string]interface{} {
|
|
"info": transaction,
|
|
"id": this.SafeString(transaction, "id"),
|
|
"txid": this.SafeString(transaction, "txId"),
|
|
"currency": code,
|
|
"timestamp": this.Parse8601(datetime),
|
|
"datetime": datetime,
|
|
"network": this.NetworkIdToCode(networkId),
|
|
"addressFrom": nil,
|
|
"address": address,
|
|
"addressTo": address,
|
|
"amount": this.SafeNumber(transaction, "amount"),
|
|
"type": parsedType,
|
|
"status": this.ParseTransactionStatus(this.SafeString(transaction, "status")),
|
|
"updated": this.Parse8601(this.SafeString(transaction, "updatedAt")),
|
|
"tagFrom": nil,
|
|
"tag": nil,
|
|
"tagTo": nil,
|
|
"comment": this.SafeString(transaction, "memo"),
|
|
"internal": nil,
|
|
"fee": map[string]interface{} {
|
|
"cost": this.SafeNumber(transaction, "fee"),
|
|
"currency": code,
|
|
},
|
|
}
|
|
}
|
|
func (this *kuna) Nonce() interface{} {
|
|
return this.Milliseconds()
|
|
}
|
|
func (this *kuna) EncodeParams(params interface{}) interface{} {
|
|
if IsTrue(InOp(params, "orders")) {
|
|
var orders interface{} = GetValue(params, "orders")
|
|
var query interface{} = this.Urlencode(this.Keysort(this.Omit(params, "orders")))
|
|
for i := 0; IsLessThan(i, GetArrayLength(orders)); i++ {
|
|
var order interface{} = GetValue(orders, i)
|
|
var keys interface{} = ObjectKeys(order)
|
|
for k := 0; IsLessThan(k, GetArrayLength(keys)); k++ {
|
|
var key interface{} = GetValue(keys, k)
|
|
var value interface{} = GetValue(order, key)
|
|
query = Add(query, Add(Add(Add("&orders%5B%5D%5B", key), "%5D="), ToString(value)))
|
|
}
|
|
}
|
|
return query
|
|
}
|
|
return this.Urlencode(this.Keysort(params))
|
|
}
|
|
func (this *kuna) Sign(path interface{}, optionalArgs ...interface{}) interface{} {
|
|
api := GetArg(optionalArgs, 0, "public")
|
|
_ = api
|
|
method := GetArg(optionalArgs, 1, "GET")
|
|
_ = method
|
|
params := GetArg(optionalArgs, 2, map[string]interface{} {})
|
|
_ = params
|
|
headers := GetArg(optionalArgs, 3, nil)
|
|
_ = headers
|
|
body := GetArg(optionalArgs, 4, nil)
|
|
_ = body
|
|
var url interface{} = nil
|
|
if IsTrue(IsArray(api)) {
|
|
var isGet interface{} = IsEqual(method, "GET")
|
|
var version interface{} = this.SafeString(api, 0)
|
|
var access interface{} = this.SafeString(api, 1)
|
|
if IsTrue(IsEqual(version, "v3")) {
|
|
url = Add(Add(Add(Add(GetValue(GetValue(this.Urls, "api"), version), "/"), version), "/"), this.ImplodeParams(path, params))
|
|
if IsTrue(IsEqual(access, "public")) {
|
|
if IsTrue(isGet) {
|
|
if IsTrue(GetArrayLength(ObjectKeys(params))) {
|
|
url = Add(url, Add("?", this.Urlencode(params)))
|
|
}
|
|
} else if IsTrue(IsTrue((IsEqual(method, "POST"))) || IsTrue((IsEqual(method, "PUT")))) {
|
|
headers = map[string]interface{} {
|
|
"Content-Type": "application/json",
|
|
}
|
|
body = this.Json(params)
|
|
}
|
|
} else if IsTrue(IsEqual(access, "private")) {
|
|
panic(NotSupported(Add(this.Id, " private v3 API is not supported yet")))
|
|
}
|
|
} else if IsTrue(IsEqual(version, "v4")) {
|
|
var extractedParams interface{} = this.ExtractParams(path)
|
|
var urlPath interface{} = Add(Add(Add("/", version), "/"), this.ImplodeParams(path, params))
|
|
params = this.Omit(params, extractedParams)
|
|
if IsTrue(isGet) {
|
|
var paramsList interface{} = ObjectKeys(params)
|
|
var numParams interface{} = GetArrayLength(paramsList)
|
|
if IsTrue(IsGreaterThan(numParams, 0)) {
|
|
urlPath = Add(urlPath, Add("?", this.Urlencode(params)))
|
|
}
|
|
}
|
|
if IsTrue(IsEqual(access, "private")) {
|
|
var nonce interface{} = ToString(this.Nonce())
|
|
var auth interface{} = Add(urlPath, nonce)
|
|
if IsTrue(isGet) {
|
|
auth = Add(auth, this.Json(map[string]interface{} {}))
|
|
} else {
|
|
auth = Add(auth, this.Json(params))
|
|
body = params
|
|
}
|
|
headers = map[string]interface{} {
|
|
"Content-Type": "application/json",
|
|
"accept": "application/json",
|
|
"nonce": nonce,
|
|
"public-key": this.ApiKey,
|
|
"signature": this.Hmac(this.Encode(auth), this.Encode(this.Secret), sha384, "hex"),
|
|
}
|
|
var account interface{} = this.SafeString(this.Options, "account")
|
|
if IsTrue(IsEqual(account, "pro")) {
|
|
AddElementToObject(headers, "account", "pro")
|
|
}
|
|
}
|
|
url = Add(GetValue(GetValue(this.Urls, "api"), version), urlPath)
|
|
}
|
|
} else {
|
|
var request interface{} = Add(Add(Add("/api/", this.Version), "/"), this.ImplodeParams(path, params))
|
|
if IsTrue(InOp(this.Urls, "extension")) {
|
|
request = Add(request, GetValue(this.Urls, "extension"))
|
|
}
|
|
var query interface{} = this.Omit(params, this.ExtractParams(path))
|
|
url = Add(GetValue(GetValue(this.Urls, "api"), api), request)
|
|
if IsTrue(IsEqual(api, "public")) {
|
|
if IsTrue(GetArrayLength(ObjectKeys(query))) {
|
|
url = Add(url, Add("?", this.Urlencode(query)))
|
|
}
|
|
} else {
|
|
this.CheckRequiredCredentials()
|
|
var nonce interface{} = ToString(this.Nonce())
|
|
var queryInner interface{} = this.EncodeParams(this.Extend(map[string]interface{} {
|
|
"access_key": this.ApiKey,
|
|
"tonce": nonce,
|
|
}, params))
|
|
var auth interface{} = Add(Add(Add(Add(method, "|"), request), "|"), queryInner)
|
|
var signed interface{} = this.Hmac(this.Encode(auth), this.Encode(this.Secret), sha256)
|
|
var suffix interface{} = Add(Add(query, "&signature="), signed)
|
|
if IsTrue(IsEqual(method, "GET")) {
|
|
url = Add(url, Add("?", suffix))
|
|
} else {
|
|
body = suffix
|
|
headers = map[string]interface{} {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if IsTrue(!IsEqual(body, nil)) {
|
|
body = JsonStringify(body)
|
|
}
|
|
return map[string]interface{} {
|
|
"url": url,
|
|
"method": method,
|
|
"body": body,
|
|
"headers": headers,
|
|
}
|
|
}
|
|
func (this *kuna) HandleErrors(code interface{}, reason interface{}, url interface{}, method interface{}, headers interface{}, body interface{}, response interface{}, requestHeaders interface{}, requestBody interface{}) interface{} {
|
|
//
|
|
// {
|
|
// "errors": [
|
|
// {
|
|
// "extensions": {
|
|
// "code": "IP_NOT_IN_WHITE_LIST"
|
|
// },
|
|
// "code": "IP_NOT_IN_WHITE_LIST"
|
|
// }
|
|
// ]
|
|
// }
|
|
//
|
|
var errors interface{} = this.SafeValue(response, "errors")
|
|
if IsTrue(IsTrue((IsEqual(response, nil))) && IsTrue((IsEqual(errors, nil)))) {
|
|
return nil
|
|
}
|
|
if IsTrue(IsTrue((!IsEqual(errors, nil))) || IsTrue((IsEqual(code, 400)))) {
|
|
var error interface{} = this.SafeValue(errors, 0)
|
|
if IsTrue(IsEqual(error, nil)) {
|
|
error = this.SafeValue(response, "error")
|
|
}
|
|
var errorCode interface{} = this.SafeString(error, "code")
|
|
var feedback interface{} = Add(Add(this.Id, " "), this.Json(response))
|
|
this.ThrowExactlyMatchedException(this.Exceptions, errorCode, feedback)
|
|
panic(ExchangeError(feedback))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
|
|
func (this *kuna) Init(userConfig map[string]interface{}) {
|
|
this.Exchange = Exchange{}
|
|
this.Exchange.InitParent(userConfig, this.Describe().(map[string]interface{}), this)
|
|
this.Exchange.DerivedExchange = this
|
|
}
|