UNPKG

astro-perp-ccxt-dev

Version:

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges

1 lines 5.71 MB
(()=>{"use strict";var e={9223:()=>{var e,t=(e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),i=function(e,t,i,r){return new(i||(i=Promise))((function(s,a){function o(e){try{d(r.next(e))}catch(e){a(e)}}function n(e){try{d(r.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,n)}d((r=r.apply(e,t||[])).next())}))},r=function(e,t){var i,r,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=n(0),o.throw=n(1),o.return=n(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function n(n){return function(d){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,n[0]&&(a=0)),a;)try{if(i=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){a.label=n[1];break}if(6===n[0]&&a.label<s[1]){a.label=s[1],s=n;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(n);break}s[2]&&a.ops.pop(),a.trys.pop();continue}n=t.call(e,a)}catch(e){n=[6,e],r=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,d])}}};Object.defineProperty(exports,"__esModule",{value:!0});var s=require("./abstract/alpaca.js"),a=require("./base/Precise.js"),o=require("./base/errors.js"),n=require("./base/functions/number.js"),d=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t(s,e),s.prototype.describe=function(){return this.deepExtend(e.prototype.describe.call(this),{id:"alpaca",name:"Alpaca",countries:["US"],rateLimit:333,hostname:"alpaca.markets",pro:!0,urls:{logo:"https://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1b",www:"https://alpaca.markets",api:{broker:"https://broker-api.{hostname}",trader:"https://api.{hostname}",market:"https://data.{hostname}"},test:{broker:"https://broker-api.sandbox.{hostname}",trader:"https://paper-api.{hostname}",market:"https://data.{hostname}"},doc:"https://alpaca.markets/docs/",fees:"https://docs.alpaca.markets/docs/crypto-fees"},has:{CORS:!1,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL1OrderBook:!0,fetchL2OrderBook:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},api:{broker:{},trader:{private:{get:["v2/account","v2/orders","v2/orders/{order_id}","v2/positions","v2/positions/{symbol_or_asset_id}","v2/account/portfolio/history","v2/watchlists","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/account/configurations","v2/account/activities","v2/account/activities/{activity_type}","v2/calendar","v2/clock","v2/assets","v2/assets/{symbol_or_asset_id}","v2/corporate_actions/announcements/{id}","v2/corporate_actions/announcements","v2/wallets","v2/wallets/transfers"],post:["v2/orders","v2/watchlists","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/wallets/transfers"],put:["v2/orders/{order_id}","v2/watchlists/{watchlist_id}","v2/watchlists:by_name"],patch:["v2/orders/{order_id}","v2/account/configurations"],delete:["v2/orders","v2/orders/{order_id}","v2/positions","v2/positions/{symbol_or_asset_id}","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/watchlists/{watchlist_id}/{symbol}"]}},market:{public:{get:["v1beta3/crypto/{loc}/bars","v1beta3/crypto/{loc}/latest/bars","v1beta3/crypto/{loc}/latest/orderbooks","v1beta3/crypto/{loc}/latest/quotes","v1beta3/crypto/{loc}/latest/trades","v1beta3/crypto/{loc}/quotes","v1beta3/crypto/{loc}/snapshots","v1beta3/crypto/{loc}/trades"]},private:{get:["v1beta1/corporate-actions","v1beta1/forex/latest/rates","v1beta1/forex/rates","v1beta1/logos/{symbol}","v1beta1/news","v1beta1/screener/stocks/most-actives","v1beta1/screener/{market_type}/movers","v2/stocks/auctions","v2/stocks/bars","v2/stocks/bars/latest","v2/stocks/meta/conditions/{ticktype}","v2/stocks/meta/exchanges","v2/stocks/quotes","v2/stocks/quotes/latest","v2/stocks/snapshots","v2/stocks/trades","v2/stocks/trades/latest","v2/stocks/{symbol}/auctions","v2/stocks/{symbol}/bars","v2/stocks/{symbol}/bars/latest","v2/stocks/{symbol}/quotes","v2/stocks/{symbol}/quotes/latest","v2/stocks/{symbol}/snapshot","v2/stocks/{symbol}/trades","v2/stocks/{symbol}/trades/latest"]}}},timeframes:{"1m":"1min","3m":"3min","5m":"5min","15m":"15min","30m":"30min","1h":"1H","2h":"2H","4h":"4H","6h":"6H","8h":"8H","12h":"12H","1d":"1D","3d":"3D","1w":"1W","1M":"1M"},precisionMode:n.TICK_SIZE,requiredCredentials:{apiKey:!0,secret:!0},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0015"),taker:this.parseNumber("0.0025"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("100000"),this.parseNumber("0.0022")],[this.parseNumber("500000"),this.parseNumber("0.0020")],[this.parseNumber("1000000"),this.parseNumber("0.0018")],[this.parseNumber("10000000"),this.parseNumber("0.0015")],[this.parseNumber("25000000"),this.parseNumber("0.0013")],[this.parseNumber("50000000"),this.parseNumber("0.0012")],[this.parseNumber("100000000"),this.parseNumber("0.001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.0012")],[this.parseNumber("500000"),this.parseNumber("0.001")],[this.parseNumber("1000000"),this.parseNumber("0.0008")],[this.parseNumber("10000000"),this.parseNumber("0.0005")],[this.parseNumber("25000000"),this.parseNumber("0.0002")],[this.parseNumber("50000000"),this.parseNumber("0.0002")],[this.parseNumber("100000000"),this.parseNumber("0.00")]]}}},headers:{"APCA-PARTNER-ID":"ccxt"},options:{defaultExchange:"CBSE",exchanges:["CBSE","FTX","GNSS","ERSX"],defaultTimeInForce:"gtc",clientOrderId:"ccxt_{id}"},features:{spot:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!0},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:1e5,daysBackCanceled:void 0,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"forbidden.":o.PermissionDenied,4041e4:o.InvalidOrder,40010001:o.BadRequest,4011e4:o.PermissionDenied,4031e4:o.InsufficientFunds,4291e4:o.RateLimitExceeded},broad:{"Invalid format for parameter":o.BadRequest,"Invalid symbol":o.BadSymbol}}})},s.prototype.fetchTime=function(){return i(this,arguments,void 0,(function(e){var t,i,s,a,o,n;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.traderPrivateGetV2Clock(e)];case 1:return t=r.sent(),i=this.safeString(t,"timestamp"),s=i.slice(0,23),a=i.length-6,o=i.length-3,n=i.slice(a,o),[2,this.parse8601(s)-3600*this.parseToNumeric(n)*1e3]}}))}))},s.prototype.fetchMarkets=function(){return i(this,arguments,void 0,(function(e){var t,i;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return t={asset_class:"crypto",status:"active"},[4,this.traderPrivateGetV2Assets(this.extend(t,e))];case 1:return i=r.sent(),[2,this.parseMarkets(i)]}}))}))},s.prototype.parseMarket=function(e){var t=this.safeString(e,"symbol"),i=t.split("/"),r=this.safeString(e,"class"),s=this.safeString(i,0),a=this.safeString(i,1),o=this.safeCurrencyCode(s),n=this.safeCurrencyCode(a);void 0===n&&"us_equity"===r&&(n="USD");var d=o+"/"+n,c="active"===this.safeString(e,"status"),h=this.safeNumber(e,"min_order_size");return{id:t,symbol:d,base:o,quote:n,settle:void 0,baseId:s,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:c,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"min_trade_increment"),price:this.safeNumber(e,"price_increment")},limits:{leverage:{min:void 0,max:void 0},amount:{min:h,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}},s.prototype.fetchTrades=function(e){return i(this,arguments,void 0,(function(e,t,i,s){var a,n,d,c,h,u,l,p;return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),a=this.market(e),n=a.id,d=this.safeString(s,"loc","us"),c=this.safeString(s,"method","marketPublicGetV1beta3CryptoLocTrades"),h={symbols:n,loc:d},s=this.omit(s,["loc","method"]),u=void 0,"marketPublicGetV1beta3CryptoLocTrades"!==c?[3,3]:(void 0!==t&&(h.start=this.iso8601(t)),void 0!==i&&(h.limit=i),[4,this.marketPublicGetV1beta3CryptoLocTrades(this.extend(h,s))]);case 2:return l=r.sent(),p=this.safeDict(l,"trades",{}),u=this.safeList(p,n,[]),[3,6];case 3:return"marketPublicGetV1beta3CryptoLocLatestTrades"!==c?[3,5]:[4,this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(h,s))];case 4:return l=r.sent(),p=this.safeDict(l,"trades",{}),u=[u=this.safeDict(p,n,{})],[3,6];case 5:throw new o.NotSupported(this.id+" fetchTrades() does not support "+c+", marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported");case 6:return[2,this.parseTrades(u,a,t,i)]}}))}))},s.prototype.fetchOrderBook=function(e){return i(this,arguments,void 0,(function(e,t,i){var s,a,o,n,d,c,h,u;return void 0===t&&(t=void 0),void 0===i&&(i={}),r(this,(function(t){switch(t.label){case 0:return[4,this.loadMarkets()];case 1:return t.sent(),s=this.market(e),a=s.id,o=this.safeString(i,"loc","us"),n={symbols:a,loc:o},[4,this.marketPublicGetV1beta3CryptoLocLatestOrderbooks(this.extend(n,i))];case 2:return d=t.sent(),c=this.safeDict(d,"orderbooks",{}),h=this.safeDict(c,a,{}),u=this.parse8601(this.safeString(h,"t")),[2,this.parseOrderBook(h,s.symbol,u,"b","a","p","s")]}}))}))},s.prototype.fetchOHLCV=function(e){return i(this,arguments,void 0,(function(e,t,i,s,a){var n,d,c,h,u,l,p,f;return void 0===t&&(t="1m"),void 0===i&&(i=void 0),void 0===s&&(s=void 0),void 0===a&&(a={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),n=this.market(e),d=n.id,c=this.safeString(a,"loc","us"),h=this.safeString(a,"method","marketPublicGetV1beta3CryptoLocBars"),u={symbols:d,loc:c},a=this.omit(a,["loc","method"]),l=void 0,"marketPublicGetV1beta3CryptoLocBars"!==h?[3,3]:(void 0!==s&&(u.limit=s),void 0!==i&&(u.start=this.yyyymmdd(i)),u.timeframe=this.safeString(this.timeframes,t,t),[4,this.marketPublicGetV1beta3CryptoLocBars(this.extend(u,a))]);case 2:return p=r.sent(),f=this.safeDict(p,"bars",{}),l=this.safeList(f,d,[]),[3,6];case 3:return"marketPublicGetV1beta3CryptoLocLatestBars"!==h?[3,5]:[4,this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(u,a))];case 4:return p=r.sent(),f=this.safeDict(p,"bars",{}),l=[l=this.safeDict(f,d,{})],[3,6];case 5:throw new o.NotSupported(this.id+" fetchOHLCV() does not support "+h+", marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported");case 6:return[2,this.parseOHLCVs(l,n,t,i,s)]}}))}))},s.prototype.parseOHLCV=function(e,t){void 0===t&&(t=void 0);var i=this.safeString(e,"t");return[this.parse8601(i),this.safeNumber(e,"o"),this.safeNumber(e,"h"),this.safeNumber(e,"l"),this.safeNumber(e,"c"),this.safeNumber(e,"v")]},s.prototype.fetchTicker=function(e){return i(this,arguments,void 0,(function(e,t){var i;return void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),e=this.symbol(e),[4,this.fetchTickers([e],t)];case 2:return i=r.sent(),[2,this.safeDict(i,e)]}}))}))},s.prototype.fetchTickers=function(){return i(this,arguments,void 0,(function(e,t){var i,s,a,n,d,c,h,u,l,p,f,v,m,g,y,b,w;return void 0===e&&(e=void 0),void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:if(void 0===e)throw new o.ArgumentsRequired(this.id+" fetchTickers() requires a symbols argument");return[4,this.loadMarkets()];case 1:return r.sent(),e=this.marketSymbols(e),i=this.safeString(t,"loc","us"),s=this.marketIds(e),a={symbols:s.join(","),loc:i},t=this.omit(t,"loc"),[4,this.marketPublicGetV1beta3CryptoLocSnapshots(this.extend(a,t))];case 2:for(n=r.sent(),d=[],c=this.safeDict(n,"snapshots",{}),h=Object.keys(c),u=0;u<h.length;u++)l=h[u],p=this.safeMarket(l),f=this.safeDict(c,l),v=this.safeDict(f,"dailyBar",{}),m=this.safeDict(f,"prevDailyBar",{}),g=this.safeDict(f,"latestQuote",{}),y=this.safeDict(f,"latestTrade",{}),b=this.safeString(g,"t"),w=this.safeTicker({info:f,symbol:p.symbol,timestamp:this.parse8601(b),datetime:b,high:this.safeString(v,"h"),low:this.safeString(v,"l"),bid:this.safeString(g,"bp"),bidVolume:this.safeString(g,"bs"),ask:this.safeString(g,"ap"),askVolume:this.safeString(g,"as"),vwap:this.safeString(v,"vw"),open:this.safeString(v,"o"),close:this.safeString(v,"c"),last:this.safeString(y,"p"),previousClose:this.safeString(m,"c"),change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(v,"v"),quoteVolume:this.safeString(v,"n")},p),d.push(w);return[2,this.filterByArray(d,"symbol",e)]}}))}))},s.prototype.generateClientOrderId=function(e){var t=this.safeString(this.options,"clientOrderId"),i=this.uuid().split("-").join(""),r=this.implodeParams(t,{id:i});return this.safeString(e,"clientOrderId",r)},s.prototype.createMarketOrderWithCost=function(e,t,s){return i(this,arguments,void 0,(function(e,t,i,s){var a;return void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),a={cost:i},[4,this.createOrder(e,"market",t,0,void 0,this.extend(a,s))];case 2:return[2,r.sent()]}}))}))},s.prototype.createMarketBuyOrderWithCost=function(e,t){return i(this,arguments,void 0,(function(e,t,i){var s;return void 0===i&&(i={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),s={cost:t},[4,this.createOrder(e,"market","buy",0,void 0,this.extend(s,i))];case 2:return[2,r.sent()]}}))}))},s.prototype.createMarketSellOrderWithCost=function(e,t){return i(this,arguments,void 0,(function(e,t,i){var s;return void 0===i&&(i={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),s={cost:t},[4,this.createOrder(e,"market","sell",t,void 0,this.extend(s,i))];case 2:return[2,r.sent()]}}))}))},s.prototype.createOrder=function(e,t,s,a){return i(this,arguments,void 0,(function(e,t,i,s,a,n){var d,c,h,u,l,p,f,v;return void 0===a&&(a=void 0),void 0===n&&(n={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:if(r.sent(),d=this.market(e),c=d.id,h={symbol:c,side:i,type:t},void 0!==(u=this.safeStringN(n,["triggerPrice","stop_price"]))){if(l=void 0,!(t.indexOf("limit")>=0))throw new o.NotSupported(this.id+" createOrder() does not support stop orders for "+t+" orders, only stop_limit orders are supported");l="stop_limit",h.stop_price=this.priceToPrecision(e,u),h.type=l}return t.indexOf("limit")>=0&&(h.limit_price=this.priceToPrecision(e,a)),void 0!==(p=this.safeString(n,"cost"))?(n=this.omit(n,"cost"),h.notional=this.costToPrecision(e,p)):h.qty=this.amountToPrecision(e,s),f=this.safeString(this.options,"defaultTimeInForce"),h.time_in_force=this.safeString(n,"timeInForce",f),n=this.omit(n,["timeInForce","triggerPrice"]),h.client_order_id=this.generateClientOrderId(n),n=this.omit(n,["clientOrderId"]),[4,this.traderPrivatePostV2Orders(this.extend(h,n))];case 2:return v=r.sent(),[2,this.parseOrder(v,d)]}}))}))},s.prototype.cancelOrder=function(e){return i(this,arguments,void 0,(function(e,t,i){var s,a;return void 0===t&&(t=void 0),void 0===i&&(i={}),r(this,(function(t){switch(t.label){case 0:return s={order_id:e},[4,this.traderPrivateDeleteV2OrdersOrderId(this.extend(s,i))];case 1:return a=t.sent(),[2,this.parseOrder(a)]}}))}))},s.prototype.cancelAllOrders=function(){return i(this,arguments,void 0,(function(e,t){var i;return void 0===e&&(e=void 0),void 0===t&&(t={}),r(this,(function(e){switch(e.label){case 0:return[4,this.loadMarkets()];case 1:return e.sent(),[4,this.traderPrivateDeleteV2Orders(t)];case 2:return i=e.sent(),Array.isArray(i)?[2,this.parseOrders(i,void 0)]:[2,[this.safeOrder({info:i})]]}}))}))},s.prototype.fetchOrder=function(e){return i(this,arguments,void 0,(function(e,t,i){var s,a,o,n;return void 0===t&&(t=void 0),void 0===i&&(i={}),r(this,(function(t){switch(t.label){case 0:return[4,this.loadMarkets()];case 1:return t.sent(),s={order_id:e},[4,this.traderPrivateGetV2OrdersOrderId(this.extend(s,i))];case 2:return a=t.sent(),o=this.safeString(a,"symbol"),n=this.safeMarket(o),[2,this.parseOrder(a,n)]}}))}))},s.prototype.fetchOrders=function(){return i(this,arguments,void 0,(function(e,t,i,s){var a,o,n,d;return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),a={status:"all"},o=void 0,void 0!==e&&(o=this.market(e),a.symbols=o.id),void 0!==(n=this.safeInteger(s,"until"))&&(s=this.omit(s,"until"),a.endTime=this.iso8601(n)),void 0!==t&&(a.after=this.iso8601(t)),void 0!==i&&(a.limit=i),[4,this.traderPrivateGetV2Orders(this.extend(a,s))];case 2:return d=r.sent(),[2,this.parseOrders(d,o,t,i)]}}))}))},s.prototype.fetchOpenOrders=function(){return i(this,arguments,void 0,(function(e,t,i,s){var a;return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return a={status:"open"},[4,this.fetchOrders(e,t,i,this.extend(a,s))];case 1:return[2,r.sent()]}}))}))},s.prototype.fetchClosedOrders=function(){return i(this,arguments,void 0,(function(e,t,i,s){var a;return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return a={status:"closed"},[4,this.fetchOrders(e,t,i,this.extend(a,s))];case 1:return[2,r.sent()]}}))}))},s.prototype.editOrder=function(e,t,s,a){return i(this,arguments,void 0,(function(e,t,i,s,a,o,n){var d,c,h,u,l,p;return void 0===a&&(a=void 0),void 0===o&&(o=void 0),void 0===n&&(n={}),r(this,(function(i){switch(i.label){case 0:return[4,this.loadMarkets()];case 1:return i.sent(),d={order_id:e},c=void 0,void 0!==t&&(c=this.market(t)),void 0!==a&&(d.qty=this.amountToPrecision(t,a)),void 0!==(h=this.safeStringN(n,["triggerPrice","stop_price"]))&&(d.stop_price=this.priceToPrecision(t,h),n=this.omit(n,"triggerPrice")),void 0!==o&&(d.limit_price=this.priceToPrecision(t,o)),void 0,p=this.handleOptionAndParams2(n,"editOrder","timeInForce","defaultTimeInForce"),u=p[0],n=p[1],void 0!==u&&(d.time_in_force=u),d.client_order_id=this.generateClientOrderId(n),n=this.omit(n,["clientOrderId"]),[4,this.traderPrivatePatchV2OrdersOrderId(this.extend(d,n))];case 2:return l=i.sent(),[2,this.parseOrder(l,c)]}}))}))},s.prototype.parseOrder=function(e,t){void 0===t&&(t=void 0);var i=this.safeString(e,"symbol"),r=(t=this.safeMarket(i,t)).symbol,s=this.safeString(e,"status"),a=this.parseOrderStatus(s),o=this.safeString(e,"commission"),n=void 0;void 0!==o&&(n={cost:o,currency:"USD"});var d=this.safeString(e,"order_type");void 0!==d&&d.indexOf("limit")>=0&&(d="limit");var c=this.safeString(e,"submitted_at"),h=this.parse8601(c);return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:this.safeString(e,"client_order_id"),timestamp:h,datetime:c,lastTradeTimeStamp:void 0,status:a,symbol:r,type:d,timeInForce:this.parseTimeInForce(this.safeString(e,"time_in_force")),postOnly:void 0,side:this.safeString(e,"side"),price:this.safeNumber(e,"limit_price"),triggerPrice:this.safeNumber(e,"stop_price"),cost:void 0,average:this.safeNumber(e,"filled_avg_price"),amount:this.safeNumber(e,"qty"),filled:this.safeNumber(e,"filled_qty"),remaining:void 0,trades:void 0,fee:n,info:e},t)},s.prototype.parseOrderStatus=function(e){return this.safeString({pending_new:"open",accepted:"open",new:"open",partially_filled:"open",activated:"open",filled:"closed"},e,e)},s.prototype.parseTimeInForce=function(e){return this.safeString({day:"Day"},e,e)},s.prototype.fetchMyTrades=function(){return i(this,arguments,void 0,(function(e,t,i,s){var a,o,n,d,c;return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),a=void 0,o={activity_type:"FILL"},void 0!==e&&(a=this.market(e)),void 0!==(n=this.safeInteger(s,"until"))&&(s=this.omit(s,"until"),o.until=this.iso8601(n)),void 0!==t&&(o.after=this.iso8601(t)),void 0!==i&&(o.page_size=i),c=this.handleUntilOption("until",o,s),o=c[0],s=c[1],[4,this.traderPrivateGetV2AccountActivitiesActivityType(this.extend(o,s))];case 2:return d=r.sent(),[2,this.parseTrades(d,a,t,i)]}}))}))},s.prototype.parseTrade=function(e,t){void 0===t&&(t=void 0);var i=this.safeString2(e,"S","symbol"),r=this.safeSymbol(i,t),s=this.safeString2(e,"t","transaction_time"),a=this.parse8601(s),o=this.safeString(e,"tks"),n=this.safeString(e,"side");"B"===o?n="buy":"S"===o&&(n="sell");var d=this.safeString2(e,"p","price"),c=this.safeString2(e,"s","qty");return this.safeTrade({info:e,id:this.safeString2(e,"i","id"),timestamp:a,datetime:this.iso8601(a),symbol:r,order:this.safeString(e,"order_id"),type:void 0,side:n,takerOrMaker:"taker",price:d,amount:c,cost:void 0,fee:void 0},t)},s.prototype.fetchDepositAddress=function(e){return i(this,arguments,void 0,(function(e,t){var i,s,a;return void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),i=this.currency(e),s={asset:i.id},[4,this.traderPrivateGetV2Wallets(this.extend(s,t))];case 2:return a=r.sent(),[2,this.parseDepositAddress(a,i)]}}))}))},s.prototype.parseDepositAddress=function(e,t){void 0===t&&(t=void 0);var i=void 0;return void 0!==t&&(i=t.id),{info:e,currency:i,network:void 0,address:this.safeString(e,"address"),tag:void 0}},s.prototype.withdraw=function(e,t,s){return i(this,arguments,void 0,(function(e,t,i,s,a){var o,n,d,c;return void 0===s&&(s=void 0),void 0===a&&(a={}),r(this,(function(r){switch(r.label){case 0:return c=this.handleWithdrawTagAndParams(s,a),s=c[0],a=c[1],this.checkAddress(i),[4,this.loadMarkets()];case 1:return r.sent(),o=this.currency(e),s&&(i=i+":"+s),n={asset:o.id,address:i,amount:this.numberToString(t)},[4,this.traderPrivatePostV2WalletsTransfers(this.extend(n,a))];case 2:return d=r.sent(),[2,this.parseTransaction(d,o)]}}))}))},s.prototype.fetchTransactionsHelper=function(e,t,s,a,o){return i(this,void 0,void 0,(function(){var i,n,d,c,h;return r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),i=void 0,void 0!==t&&(i=this.currency(t)),[4,this.traderPrivateGetV2WalletsTransfers(o)];case 2:for(n=r.sent(),d=[],c=0;c<n.length;c++)h=n[c],(this.safeString(h,"direction")===e||"BOTH"===e)&&d.push(h);return[2,this.parseTransactions(d,i,s,a,o)]}}))}))},s.prototype.fetchDepositsWithdrawals=function(){return i(this,arguments,void 0,(function(e,t,i,s){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.fetchTransactionsHelper("BOTH",e,t,i,s)];case 1:return[2,r.sent()]}}))}))},s.prototype.fetchDeposits=function(){return i(this,arguments,void 0,(function(e,t,i,s){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.fetchTransactionsHelper("INCOMING",e,t,i,s)];case 1:return[2,r.sent()]}}))}))},s.prototype.fetchWithdrawals=function(){return i(this,arguments,void 0,(function(e,t,i,s){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.fetchTransactionsHelper("OUTGOING",e,t,i,s)];case 1:return[2,r.sent()]}}))}))},s.prototype.parseTransaction=function(e,t){void 0===t&&(t=void 0);var i=this.safeString(e,"created_at"),r=this.safeString(e,"asset"),s=this.safeCurrencyCode(r,t),o=this.safeString(e,"fees"),n=this.safeString(e,"network_fee"),d=a.Precise.stringAdd(o,n),c={cost:this.parseNumber(d),currency:s};return{info:e,id:this.safeString(e,"id"),txid:this.safeString(e,"tx_hash"),timestamp:this.parse8601(i),datetime:i,network:this.safeString(e,"chain"),address:this.safeString(e,"to_address"),addressTo:this.safeString(e,"to_address"),addressFrom:this.safeString(e,"from_address"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:this.parseTransactionType(this.safeString(e,"direction")),amount:this.safeNumber(e,"amount"),currency:s,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:void 0,fee:c,comment:void 0,internal:void 0}},s.prototype.parseTransactionStatus=function(e){return this.safeString({PROCESSING:"pending",FAILED:"failed",COMPLETE:"ok"},e,e)},s.prototype.parseTransactionType=function(e){return this.safeString({INCOMING:"deposit",OUTGOING:"withdrawal"},e,e)},s.prototype.fetchBalance=function(){return i(this,arguments,void 0,(function(e){var t;return void 0===e&&(e={}),r(this,(function(i){switch(i.label){case 0:return[4,this.loadMarkets()];case 1:return i.sent(),[4,this.traderPrivateGetV2Account(e)];case 2:return t=i.sent(),[2,this.parseBalance(t)]}}))}))},s.prototype.parseBalance=function(e){var t={info:e},i=this.account(),r=this.safeString(e,"currency"),s=this.safeCurrencyCode(r);return i.free=this.safeString(e,"cash"),i.total=this.safeString(e,"equity"),t[s]=i,this.safeBalance(t)},s.prototype.sign=function(e,t,i,r,s,a){void 0===t&&(t="public"),void 0===i&&(i="GET"),void 0===r&&(r={}),void 0===s&&(s=void 0),void 0===a&&(a=void 0);var o="/"+this.implodeParams(e,r),n=this.implodeHostname(this.urls.api[t[0]]);s=void 0!==s?s:{},"private"===t[1]&&(this.checkRequiredCredentials(),s["APCA-API-KEY-ID"]=this.apiKey,s["APCA-API-SECRET-KEY"]=this.secret);var d=this.omit(r,this.extractParams(e));return Object.keys(d).length&&("GET"===i||"DELETE"===i?o+="?"+this.urlencode(d):(a=this.json(d),s["Content-Type"]="application/json")),{url:n+=o,method:i,body:a,headers:s}},s.prototype.handleErrors=function(e,t,i,r,s,a,n,d,c){if(void 0!==n){var h=this.id+" "+a,u=this.safeString(n,"code");void 0!==e&&this.throwExactlyMatchedException(this.exceptions.exact,u,h);var l=this.safeValue(n,"message",void 0);if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,h),this.throwBroadlyMatchedException(this.exceptions.broad,l,h),new o.ExchangeError(h)}},s}(s.default);exports.default=d},3637:()=>{var e,t=(e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),i=function(e,t,i,r){return new(i||(i=Promise))((function(s,a){function o(e){try{d(r.next(e))}catch(e){a(e)}}function n(e){try{d(r.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,n)}d((r=r.apply(e,t||[])).next())}))},r=function(e,t){var i,r,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=n(0),o.throw=n(1),o.return=n(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function n(n){return function(d){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,n[0]&&(a=0)),a;)try{if(i=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){a.label=n[1];break}if(6===n[0]&&a.label<s[1]){a.label=s[1],s=n;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(n);break}s[2]&&a.ops.pop(),a.trys.pop();continue}n=t.call(e,a)}catch(e){n=[6,e],r=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,d])}}};Object.defineProperty(exports,"__esModule",{value:!0});var s=require("./base/Precise.js"),a=require("./abstract/apex.js"),o=require("./base/functions/number.js"),n=require("./static_dependencies/noble-hashes/sha256.js"),d=require("./base/errors.js"),c=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return t(a,e),a.prototype.describe=function(){return this.deepExtend(e.prototype.describe.call(this),{id:"apex",name:"Apex",countries:[],version:"v3",rateLimit:20,certified:!1,pro:!0,dex:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelOrdersForSymbols:!1,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!1,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchAccounts:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!1,fetchCanceledOrders:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfer:!0,fetchTransfers:!0,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","4h":"240","6h":"360","12h":"720","1d":"D","1w":"W","1M":"M"},hostname:"omni.apex.exchange",urls:{logo:"https://github.com/user-attachments/assets/fef8f2f7-4265-46aa-965e-33a91881cb00",api:{public:"https://{hostname}/api",private:"https://{hostname}/api"},test:{public:"https://testnet.omni.apex.exchange/api",private:"https://testnet.omni.apex.exchange/api"},www:"https://apex.exchange/",doc:"https://api-docs.pro.apex.exchange",fees:"https://apex-pro.gitbook.io/apex-pro/apex-omni-live-now/trading-perpetual-contracts/trading-fees",referral:"https://omni.apex.exchange/trade"},api:{public:{get:{"v3/symbols":1,"v3/history-funding":1,"v3/ticker":1,"v3/klines":1,"v3/trades":1,"v3/depth":1,"v3/time":1,"v3/data/all-ticker-info":1}},private:{get:{"v3/account":1,"v3/account-balance":1,"v3/fills":1,"v3/order-fills":1,"v3/order":1,"v3/history-orders":1,"v3/order-by-client-order-id":1,"v3/funding":1,"v3/historical-pnl":1,"v3/open-orders":1,"v3/transfers":1,"v3/transfer":1},post:{"v3/delete-open-orders":1,"v3/delete-client-order-id":1,"v3/delete-order":1,"v3/order":1,"v3/set-initial-margin-rate":1,"v3/transfer-out":1,"v3/contract-transfer-out":1}}},httpExceptions:{403:d.RateLimitExceeded},exceptions:{exact:{20006:"apikey sign error",20016:"request para error",10001:d.BadRequest},broad:{ORDER_PRICE_MUST_GREETER_ZERO:d.InvalidOrder,ORDER_POSSIBLE_LEAD_TO_ACCOUNT_LIQUIDATED:d.InvalidOrder,ORDER_WITH_THIS_PRICE_CANNOT_REDUCE_POSITION_ONLY:d.InvalidOrder}},fees:{swap:{taker:this.parseNumber("0.0005"),maker:this.parseNumber("0.0002")}},requiredCredentials:{apiKey:!0,secret:!0,walletAddress:!1,privateKey:!1,password:!0},precisionMode:o.TICK_SIZE,commonCurrencies:{},options:{defaultType:"swap",defaultSlippage:.05,brokerId:"6956"},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,selfTradePrevention:!1,trailing:!0,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:void 0,fetchOHLCV:{limit:200}},swap:{linear:{extends:"default"},inverse:void 0}}})},a.prototype.fetchTime=function(){return i(this,arguments,void 0,(function(e){var t,i;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.publicGetV3Time(e)];case 1:return t=r.sent(),i=this.safeDict(t,"data",{}),[2,this.safeInteger(i,"time")]}}))}))},a.prototype.parseBalance=function(e){var t=this.milliseconds(),i={info:e,timestamp:t,datetime:this.iso8601(t)},r=this.account();return r.free=this.safeString(e,"availableBalance"),r.total=this.safeString(e,"totalEquityValue"),i.USDT=r,this.safeBalance(i)},a.prototype.fetchBalance=function(){return i(this,arguments,void 0,(function(e){var t,i;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),[4,this.privateGetV3AccountBalance(e)];case 2:return t=r.sent(),i=this.safeDict(t,"data",{}),[2,this.parseBalance(i)]}}))}))},a.prototype.parseAccount=function(e){return{id:this.safeString(e,"id","0"),type:void 0,code:void 0,info:e}},a.prototype.fetchAccount=function(){return i(this,arguments,void 0,(function(e){var t,i;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),[4,this.privateGetV3Account(e)];case 2:return t=r.sent(),i=this.safeDict(t,"data",{}),[2,this.parseAccount(i)]}}))}))},a.prototype.fetchCurrencies=function(){return i(this,arguments,void 0,(function(e){var t,i,s,a,o,n,d,c,h,u,l,p,f,v,m,g,y,b,w,k,S,O,T;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.publicGetV3Symbols(e)];case 1:for(t=r.sent(),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"spotConfig",{}),a=this.safeDict(s,"multiChain",{}),o=this.safeList(s,"assets",[]),n=this.safeList(a,"chains",[]),d={},c=0;c<o.length;c++){for(h=o[c],u=this.safeString(h,"token"),l=this.safeCurrencyCode(u),p=this.safeString(h,"displayName"),f={},v=0;v<n.length;v++)for(m=n[v],g=this.safeList(m,"tokens",[]),y=0;y<g.length;y++)b=g[y],this.safeString(b,"token")===u&&(w=this.safeString(m,"chainId"),k=this.networkIdToCode(w),f[k]={info:m,id:w,network:k,active:void 0,deposit:!this.safeBool(m,"depositDisable"),withdraw:this.safeBool(b,"withdrawEnable"),fee:this.safeNumber(b,"minFee"),precision:this.parseNumber(this.parsePrecision(this.safeString(b,"decimals"))),limits:{withdraw:{min:this.safeNumber(b,"minWithdraw"),max:void 0},deposit:{min:this.safeNumber(m,"minDeposit"),max:void 0}}});S=Object.keys(f),O=S.length,T=!(0===O)&&void 0,d[l]=this.safeCurrencyStructure({info:h,code:l,id:u,type:"crypto",name:p,active:void 0,deposit:T,withdraw:T,fee:void 0,precision:void 0,limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},networks:f})}return[2,d]}}))}))},a.prototype.fetchMarkets=function(){return i(this,arguments,void 0,(function(e){var t,i,s,a;return void 0===e&&(e={}),r(this,(function(r){switch(r.label){case 0:return[4,this.publicGetV3Symbols(e)];case 1:return t=r.sent(),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"contractConfig",{}),a=this.safeList(s,"perpetualContract",[]),[2,this.parseMarkets(a)]}}))}))},a.prototype.parseMarket=function(e){var t=this.safeString(e,"symbol"),i=this.safeString(e,"crossSymbolName"),r=this.safeString(e,"l2PairId"),s=this.safeString(e,"baseTokenId"),a=this.safeString(e,"settleAssetId"),o=this.safeCurrencyCode(s),n=this.safeString(e,"settleAssetId"),d=this.safeCurrencyCode(n),c=s+"/"+a+":"+d,h=this.parseNumber("0.0002"),u=this.parseNumber("0.0005");return this.safeMarketStructure({id:t,id2:i,symbol:c,base:o,quote:a,settle:d,baseId:s,quoteId:r,settleId:n,type:"swap",spot:!1,margin:void 0,swap:!0,future:!1,option:!1,active:this.safeBool(e,"enableTrade"),contract:!0,linear:!0,inverse:!1,taker:h,maker:u,contractSize:this.safeNumber(e,"minOrderSize"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"stepSize"),price:this.safeNumber(e,"tickSize")},limits:{leverage:{min:this.safeNumber(e,"displayMinLeverage"),max:this.safeNumber(e,"displayMaxLeverage")},amount:{min:this.safeNumber(e,"minOrderSize"),max:this.safeNumber(e,"maxOrderSize")},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e})},a.prototype.parseTicker=function(e,t){void 0===t&&(t=void 0);var i=this.milliseconds(),r=this.safeString(e,"symbol");t=this.safeMarket(r,t);var s=this.safeSymbol(r,t),a=this.safeString(e,"lastPrice"),o=this.safeString(e,"price24hPcnt"),n=this.safeString(e,"turnover24h"),d=this.safeString(e,"volume24h"),c=this.safeString(e,"highPrice24h"),h=this.safeString(e,"lowPrice24h");return this.safeTicker({symbol:s,timestamp:i,datetime:this.iso8601(i),high:c,low:h,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:void 0,percentage:o,average:void 0,baseVolume:d,quoteVolume:n,markPrice:this.safeString(e,"markPrice"),indexPrice:this.safeString(e,"indexPrice"),info:e},t)},a.prototype.fetchTicker=function(e){return i(this,arguments,void 0,(function(e,t){var i,s,a,o,n;return void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),i=this.market(e),s={symbol:i.id2},[4,this.publicGetV3Ticker(this.extend(s,t))];case 2:return a=r.sent(),o=this.safeList(a,"data",[]),n=this.safeDict(o,0,{}),[2,this.parseTicker(n,i)]}}))}))},a.prototype.fetchTickers=function(){return i(this,arguments,void 0,(function(e,t){var i,s;return void 0===e&&(e=void 0),void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),[4,this.publicGetV3DataAllTickerInfo(t)];case 2:return i=r.sent(),s=this.safeList(i,"data",[]),[2,this.parseTickers(s,e)]}}))}))},a.prototype.fetchOHLCV=function(e){return i(this,arguments,void 0,(function(e,t,i,s,a){var o,n,d,c,h,u;return void 0===t&&(t="1m"),void 0===i&&(i=void 0),void 0===s&&(s=void 0),void 0===a&&(a={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),o=this.market(e),n={interval:this.safeString(this.timeframes,t,t),symbol:o.id2},void 0===s&&(s=200),n.limit=s,u=this.handleUntilOption("end",n,a),n=u[0],a=u[1],void 0!==i&&(n.start=i),[4,this.publicGetV3Klines(this.extend(n,a))];case 2:return d=r.sent(),c=this.safeDict(d,"data",{}),h=this.safeList(c,o.id2,[]),[2,this.parseOHLCVs(h,o,t,i,s)]}}))}))},a.prototype.parseOHLCV=function(e,t){return void 0===t&&(t=void 0),[this.safeIntegerN(e,["start","t"]),this.safeNumberN(e,["open","o"]),this.safeNumberN(e,["high","h"]),this.safeNumberN(e,["low","l"]),this.safeNumberN(e,["close","c"]),this.safeNumberN(e,["volume","v"])]},a.prototype.fetchOrderBook=function(e){return i(this,arguments,void 0,(function(e,t,i){var s,a,o,n,d,c;return void 0===t&&(t=void 0),void 0===i&&(i={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),s=this.market(e),a={symbol:s.id2},void 0===t&&(t=100),a.limit=t,[4,this.publicGetV3Depth(this.extend(a,i))];case 2:return o=r.sent(),n=this.safeDict(o,"data",{}),d=this.milliseconds(),(c=this.parseOrderBook(n,s.symbol,d,"b","a")).nonce=this.safeInteger(n,"u"),[2,c]}}))}))},a.prototype.fetchTrades=function(e){return i(this,arguments,void 0,(function(e,t,i,s){var a,o,n,d;return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),a=this.market(e),o={symbol:a.id2},void 0===i&&(i=500),o.limit=i,[4,this.publicGetV3Trades(this.extend(o,s))];case 2:return n=r.sent(),d=this.safeList(n,"data",[]),[2,this.parseTrades(d,a,t,i)]}}))}))},a.prototype.parseTrade=function(e,t){void 0===t&&(t=void 0);var i=this.safeStringN(e,["s","symbol"]);t=this.safeMarket(i,t);var r=this.safeStringN(e,["i","id"]),s=this.safeIntegerN(e,["t","T","createdAt"]),a=this.safeStringN(e,["p","price"]),o=this.safeStringN(e,["v","size"]),n=this.safeStringLowerN(e,["S","side"]),d=this.safeStringN(e,["type"]),c=this.safeStringN(e,["fee"]);return this.safeTrade({info:e,id:r,order:void 0,timestamp:s,datetime:this.iso8601(s),symbol:t.symbol,type:d,takerOrMaker:void 0,side:n,price:a,amount:o,cost:void 0,fee:c},t)},a.prototype.fetchOpenInterest=function(e){return i(this,arguments,void 0,(function(e,t){var i,s,a,o,n;return void 0===t&&(t={}),r(this,(function(r){switch(r.label){case 0:return[4,this.loadMarkets()];case 1:return r.sent(),i=this.market(e),s={symbol:i.id2},[4,this.publicGetV3Ticker(this.extend(s,t))];case 2:return a=r.sent(),o=this.safeList(a,"data",[]),n=this.safeDict(o,0,{}),[2,this.parseOpenInterest(n,i)]}}))}))},a.prototype.parseOpenInterest=function(e,t){void 0===t&&(t=void 0);var i=this.milliseconds(),r=this.safeString(e,"symbol");t=this.safeMarket(r,t);var s=this.safeSymbol(r,t);return this.safeOpenInterest({symbol:s,openInterestAmount:this.safeString(e,"openInterest"),openInterestValue:void 0,timestamp:i,datetime:this.iso8601(i),info:e},t)},a.prototype.fetchFundingRateHistory=function(){return i(this,arguments,void 0,(function(e,t,i,s){var a,o,n,c,h,u,l,p,f,v,m,g,y;return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===s&&(s={}),r(this,(function(r){switch(r.label){case 0:if(void 0===e)throw new d.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");return[4,this.loadMarkets()];case 1:return r.sent(),a={},o=this.market(e),a.symbol=o.id,void 0!==t&&(a.beginTimeInclusive=t),void 0!==i&&(a.limit=i),void 0!==(n=this.safeInteger(s,"page"))&&(a.page=n),void 0!==(c=this.safeIntegerN(s,["endTime","endTimeExclusive","until"]))&&(a.endTimeExclusive=c),[4,this.publicGetV3HistoryFunding(this.extend(a,s))];case 2:for(h=r.sent(),u=[],l=this.safeDict(h,"data",{}),p=this.safeList(l,"historyFunds",[]),f=0;f<p.length;f++)v=p[f],m=this.safeInteger(v,"fundingTimestamp"),g=this.safeString(v,"symbol"),u.push({info:v,symbol:this.safeSymbol(g,o),fundingRate:this.safeNumber(v,"rate"),timestamp:m,datetime:this.iso8601(m)});return y=this.sortBy(u,"timestamp"),[2,this.filterBySymbolSinceLimit(y,e,t,i)]}}))}))},a.prototype.parseOrder=function(e,t){void 0===t&&(t=void 0);var i=this.safeInteger(e,"createdAt"),r=this.safeString(e,"id"),s=this.safeString(e,"clientId"),a=this.safeString(e,"symbol"),o=(t=this.safeMarket(a,t)).symbol,n=this.safeString(e,"price"),d=this.safeString(e,"size"),c=this.safeString(e,"type"),h=this.safeString(e,"status"),u=this.safeStringLower(e,"side"),l=this.omitZero(this.safeString(e,"remainingSize")),p=this.safeInteger(e,"updatedTime");return this.safeOrder({id:r,clientOrderId:s,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,lastUpdateTimestamp:p,status:this.parseOrderStatus(h),symbol:o,type:this.parseOrderType(c),timeInForce:this.parseTimeInForce(this.safeString(e,"timeInForce")),postOnly:this.safeBool(e,"postOnly"),reduceOnly:this.safeBool(e,"reduceOnly"),side:u,price:n,triggerPrice:this.safeString(e,"triggerPrice"),takeProfitPrice:void 0,stopLossPrice:void 0,average:void 0,amount:d,filled:void 0,remaining:l,cost:void 0,trades:void 0,fee:{cost:this.safeString(e,"fee"),currency:t.settleId},info:e},t)},a.prototype.parseTimeInForce=function(e){return this.safeString({GOOD_TIL_CANCEL:"GOOD_TIL_CANCEL",FILL_OR_KILL:"FILL_OR_KILL",IMMEDIATE_OR_CANCEL:"IMMEDIATE_OR_CANCEL",POST_ONLY:"POST_ONLY"},e,void 0)},a.prototype.parseOrderStatus=function(e){if(void 0!==e){return this.safeString({PENDING:"open",OPEN:"open",FILLED:"filled",CANCELING:"canceled",CANCELED:"canceled",UNTRIGGERED:"open"},e,e)}return e},a.prototype.parseOrderType=function(e){return this.safeStringUpper({LIMIT:"LIMIT",MARKET:"MARKET",STOP_LIMIT:"STOP_LIMIT",STOP_MARKET:"STOP_MARKET",TAKE_PROFIT_LIMIT:"TAKE_PROFIT_LIMIT",TAKE_PROFIT_MARKET:"TAKE_PROFIT_MARKET"},e,e)},a.prototype.safeMarket=function(t,i,r,s){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===r&&(r=void 0),void 0===s&&(s=void 0),void 0===i&&void 0!==t)if(t in this.markets)i=this.markets[t];else if(t in this.markets_by_id)i=this.markets_by_id[t];else{var a=this.addHyphenBeforeUsdt(t);if(a in this.markets_by_id)this.markets_by_id[a].length>0&&this.markets_by_id[a][0].id2===t&&(i=this.markets_by_id[a][0])}return e.prototype.safeMarket.call(this,t,i,r,s)},a.prototype.generateRandomClientIdOmni=function(e){return"apexomni-"+(e||this.randNumber(12).toString())+"-"+this.milliseconds().toString()+"-"+this.randNumber(6).toString()},a.prototype.addHyphenBeforeUsdt=function(e){var t=e.toUpperCase().indexOf("USDT"),i=this.safeString(e,t-1);return t>0&&"-"!==i?e.slice(0,t)+"-"+e.slice(t):e},a.prototype.getSeeds=function(){var e=this.safeString(this.options,"seeds");if(void 0===e)throw new d.ArgumentsRequired(this.id+' the "seeds" key is required in the options to access private endpoints. You can find it in API Management > Omni Key, and then set it as exchange.options["seeds"] = XXXX');return e},a.prototype.getAccountId=function(){return i(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return"0"!==this.safeString(this.options,"accountId","0")?[3,2]:[4,this.fetchAccount()];case 1:e=t.sent(),this.options.accountId=this.safeString(e,"id","0"),t.label=2;case 2:return[2,this.options.accountId]}}))}))},a.prototype.createOrder=function(e,t,a,n){return i(this,arguments,void 0,(function(e,t,i,a,n,c){var h,u,l,p,f,v,m,g,y,b,w,k,S,O,T,P,I,M,x,_;return void 0===n&&(n=void 0),void 0