ccxt 4.1.27 → 4.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/ccxt.browser.js +5 -2
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/woo.js +4 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/woo.js +4 -1
- package/package.json +1 -1
package/dist/ccxt.browser.min.js
CHANGED
|
@@ -18,11 +18,11 @@ const c=BigInt("5789604461865809771178549250434395392663499233282028201972879200
|
|
|
18
18
|
const h=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),l=BigInt(1),u=BigInt(2),f=(e,t)=>(e+t/u)/t;function p(e){const t=h,s=BigInt(3),i=BigInt(6),a=BigInt(11),n=BigInt(22),o=BigInt(23),d=BigInt(44),c=BigInt(88),l=e*e*e%t,f=l*l*e%t,p=(0,r.oA)(f,s,t)*f%t,g=(0,r.oA)(p,s,t)*f%t,y=(0,r.oA)(g,u,t)*l%t,v=(0,r.oA)(y,a,t)*y%t,b=(0,r.oA)(v,n,t)*v%t,w=(0,r.oA)(b,d,t)*b%t,S=(0,r.oA)(w,c,t)*w%t,k=(0,r.oA)(S,d,t)*b%t,O=(0,r.oA)(k,s,t)*f%t,T=(0,r.oA)(O,o,t)*v%t,I=(0,r.oA)(T,i,t)*l%t,x=(0,r.oA)(I,u,t);if(!m.eql(m.sqr(x),e))throw new Error("Cannot find square root");return x}const m=(0,r.Fp)(h,void 0,void 0,{sqrt:p}),g=(0,d._)({a:BigInt(0),b:BigInt(7),Fp:m,n:c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=c,s=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-l*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=s,o=BigInt("0x100000000000000000000000000000000"),d=f(n*e,t),h=f(-i*e,t);let u=(0,r.wQ)(e-d*s-h*a,t),p=(0,r.wQ)(-d*i-h*n,t);const m=u>o,g=p>o;if(m&&(u=t-u),g&&(p=t-p),u>o||p>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:m,k1:u,k2neg:g,k2:p}}}},i.J),y=BigInt(0),v=e=>"bigint"==typeof e&&y<e&&e<h,b={};function w(e,...t){let s=b[e];if(void 0===s){const t=(0,i.J)(Uint8Array.from(e,(e=>e.charCodeAt(0))));s=(0,n.concatBytes)(t,t),b[e]=s}return(0,i.J)((0,n.concatBytes)(s,...t))}const S=e=>e.toRawBytes(!0).slice(1),k=e=>(0,r.wQ)(e,h),O=g.ProjectivePoint;function T(e){if(!v(e))throw new Error("bad x: need 0 < x < p");const t=k(e*e);let s=p(k(t*e+BigInt(7)));s%2n!==0n&&(s=k(-s));const i=new O(e,s,l);return i.assertValidity(),i}g.utils.randomPrivateKey,n.numberToBytesBE,n.bytesToNumberBE,r.wQ;const I=o.i(m,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),x=(0,a.L4)(m,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:m.create(BigInt("-11"))}),{hashToCurve:P,encodeToCurve:M}=o.V1(g.ProjectivePoint,(e=>{const{x:t,y:s}=x(m.create(e[0]));return I(t,s)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:m.ORDER,m:1,k:128,expand:"xmd",hash:i.J})},3373:(e,t,s)=>{function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function r(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}s.d(t,{ZP:()=>n});const a={number:i,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:r,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");i(e.outputLen),i(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},output:function(e,t){r(e);const s=t.outputLen;if(e.length<s)throw new Error(`digestInto() expects output buffer of length at least ${s}`)}},n=a},3993:(e,t,s)=>{s.d(t,{N:()=>a});var i=s(3373),r=s(8006);class a extends r.kb{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,r.GL)(this.buffer)}update(e){i.ZP.exists(this);const{view:t,buffer:s,blockLen:a}=this,n=(e=(0,r.O0)(e)).length;for(let i=0;i<n;){const o=Math.min(a-this.pos,n-i);if(o!==a)s.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===a&&(this.process(t,0),this.pos=0);else{const t=(0,r.GL)(e);for(;a<=n-i;i+=a)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){i.ZP.exists(this),i.ZP.output(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:a,isLE:n}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>a-o&&(this.process(s,0),o=0);for(let e=o;e<a;e++)t[e]=0;!function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),a=BigInt(4294967295),n=Number(s>>r&a),o=Number(s&a),d=i?4:0,h=i?0:4;e.setUint32(t+d,n,i),e.setUint32(t+h,o,i)}(s,a-8,BigInt(8*this.length),n),this.process(s,0);const d=(0,r.GL)(e),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=h/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)d.setUint32(4*e,l[e],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:a,pos:n}=this;return e.length=i,e.pos=n,e.finished=r,e.destroyed=a,i%t&&e.buffer.set(s),e}}},1682:(e,t,s)=>{s.d(t,{ZP:()=>n});const i=BigInt(2**32-1),r=BigInt(32);function a(e,t=!1){return t?{h:Number(e&i),l:Number(e>>r&i)}:{h:0|Number(e>>r&i),l:0|Number(e&i)}}const n={fromBig:a,split:function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=a(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]},toBig:(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0),shrSH:(e,t,s)=>e>>>s,shrSL:(e,t,s)=>e<<32-s|t>>>s,rotrSH:(e,t,s)=>e>>>s|t<<32-s,rotrSL:(e,t,s)=>e<<32-s|t>>>s,rotrBH:(e,t,s)=>e<<64-s|t>>>s-32,rotrBL:(e,t,s)=>e>>>s-32|t<<64-s,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,s)=>e<<s|t>>>32-s,rotlSL:(e,t,s)=>t<<s|e>>>32-s,rotlBH:(e,t,s)=>t<<s-32|e>>>64-s,rotlBL:(e,t,s)=>e<<s-32|t>>>64-s,add:function(e,t,s,i){const r=(t>>>0)+(i>>>0);return{h:e+s+(r/2**32|0)|0,l:0|r}},add3L:(e,t,s)=>(e>>>0)+(t>>>0)+(s>>>0),add3H:(e,t,s,i)=>t+s+i+(e/2**32|0)|0,add4L:(e,t,s,i)=>(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0),add4H:(e,t,s,i,r)=>t+s+i+r+(e/2**32|0)|0,add5H:(e,t,s,i,r,a)=>t+s+i+r+a+(e/2**32|0)|0,add5L:(e,t,s,i,r)=>(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0)+(r>>>0)}},9362:(e,t,s)=>{s.d(t,{e:()=>i});const i="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},138:(e,t,s)=>{s.d(t,{b:()=>n});var i=s(3373),r=s(8006);class a extends r.kb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,i.ZP.hash(e);const s=(0,r.O0)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,n=new Uint8Array(a);n.set(s.length>a?e.create().update(s).digest():s);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),n.fill(0)}update(e){return i.ZP.exists(this),this.iHash.update(e),this}digestInto(e){i.ZP.exists(this),i.ZP.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:i,destroyed:r,blockLen:a,outputLen:n}=this;return e.finished=i,e.destroyed=r,e.blockLen=a,e.outputLen=n,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const n=(e,t,s)=>new a(e,t).update(s).digest();n.create=(e,t)=>new a(e,t)},7311:(e,t,s)=>{s.d(t,{F:()=>d});var i=s(8006);function r(e,t){var s=e[0],i=e[1],r=e[2],a=e[3];i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&r|~i&a)+t[0]-680876936|0)<<7|s>>>25)+i|0)&i|~s&r)+t[1]-389564586|0)<<12|a>>>20)+s|0)&s|~a&i)+t[2]+606105819|0)<<17|r>>>15)+a|0)&a|~r&s)+t[3]-1044525330|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&r|~i&a)+t[4]-176418897|0)<<7|s>>>25)+i|0)&i|~s&r)+t[5]+1200080426|0)<<12|a>>>20)+s|0)&s|~a&i)+t[6]-1473231341|0)<<17|r>>>15)+a|0)&a|~r&s)+t[7]-45705983|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&r|~i&a)+t[8]+1770035416|0)<<7|s>>>25)+i|0)&i|~s&r)+t[9]-1958414417|0)<<12|a>>>20)+s|0)&s|~a&i)+t[10]-42063|0)<<17|r>>>15)+a|0)&a|~r&s)+t[11]-1990404162|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&r|~i&a)+t[12]+1804603682|0)<<7|s>>>25)+i|0)&i|~s&r)+t[13]-40341101|0)<<12|a>>>20)+s|0)&s|~a&i)+t[14]-1502002290|0)<<17|r>>>15)+a|0)&a|~r&s)+t[15]+1236535329|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&a|r&~a)+t[1]-165796510|0)<<5|s>>>27)+i|0)&r|i&~r)+t[6]-1069501632|0)<<9|a>>>23)+s|0)&i|s&~i)+t[11]+643717713|0)<<14|r>>>18)+a|0)&s|a&~s)+t[0]-373897302|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&a|r&~a)+t[5]-701558691|0)<<5|s>>>27)+i|0)&r|i&~r)+t[10]+38016083|0)<<9|a>>>23)+s|0)&i|s&~i)+t[15]-660478335|0)<<14|r>>>18)+a|0)&s|a&~s)+t[4]-405537848|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&a|r&~a)+t[9]+568446438|0)<<5|s>>>27)+i|0)&r|i&~r)+t[14]-1019803690|0)<<9|a>>>23)+s|0)&i|s&~i)+t[3]-187363961|0)<<14|r>>>18)+a|0)&s|a&~s)+t[8]+1163531501|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i&a|r&~a)+t[13]-1444681467|0)<<5|s>>>27)+i|0)&r|i&~r)+t[2]-51403784|0)<<9|a>>>23)+s|0)&i|s&~i)+t[7]+1735328473|0)<<14|r>>>18)+a|0)&s|a&~s)+t[12]-1926607734|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i^r^a)+t[5]-378558|0)<<4|s>>>28)+i|0)^i^r)+t[8]-2022574463|0)<<11|a>>>21)+s|0)^s^i)+t[11]+1839030562|0)<<16|r>>>16)+a|0)^a^s)+t[14]-35309556|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i^r^a)+t[1]-1530992060|0)<<4|s>>>28)+i|0)^i^r)+t[4]+1272893353|0)<<11|a>>>21)+s|0)^s^i)+t[7]-155497632|0)<<16|r>>>16)+a|0)^a^s)+t[10]-1094730640|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i^r^a)+t[13]+681279174|0)<<4|s>>>28)+i|0)^i^r)+t[0]-358537222|0)<<11|a>>>21)+s|0)^s^i)+t[3]-722521979|0)<<16|r>>>16)+a|0)^a^s)+t[6]+76029189|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((a=((a+=((s=((s+=(i^r^a)+t[9]-640364487|0)<<4|s>>>28)+i|0)^i^r)+t[12]-421815835|0)<<11|a>>>21)+s|0)^s^i)+t[15]+530742520|0)<<16|r>>>16)+a|0)^a^s)+t[2]-995338651|0)<<23|i>>>9)+r|0,i=((i+=((a=((a+=(i^((s=((s+=(r^(i|~a))+t[0]-198630844|0)<<6|s>>>26)+i|0)|~r))+t[7]+1126891415|0)<<10|a>>>22)+s|0)^((r=((r+=(s^(a|~i))+t[14]-1416354905|0)<<15|r>>>17)+a|0)|~s))+t[5]-57434055|0)<<21|i>>>11)+r|0,i=((i+=((a=((a+=(i^((s=((s+=(r^(i|~a))+t[12]+1700485571|0)<<6|s>>>26)+i|0)|~r))+t[3]-1894986606|0)<<10|a>>>22)+s|0)^((r=((r+=(s^(a|~i))+t[10]-1051523|0)<<15|r>>>17)+a|0)|~s))+t[1]-2054922799|0)<<21|i>>>11)+r|0,i=((i+=((a=((a+=(i^((s=((s+=(r^(i|~a))+t[8]+1873313359|0)<<6|s>>>26)+i|0)|~r))+t[15]-30611744|0)<<10|a>>>22)+s|0)^((r=((r+=(s^(a|~i))+t[6]-1560198380|0)<<15|r>>>17)+a|0)|~s))+t[13]+1309151649|0)<<21|i>>>11)+r|0,i=((i+=((a=((a+=(i^((s=((s+=(r^(i|~a))+t[4]-145523070|0)<<6|s>>>26)+i|0)|~r))+t[11]-1120210379|0)<<10|a>>>22)+s|0)^((r=((r+=(s^(a|~i))+t[2]+718787259|0)<<15|r>>>17)+a|0)|~s))+t[9]-343485551|0)<<21|i>>>11)+r|0,e[0]=s+e[0]|0,e[1]=i+e[1]|0,e[2]=r+e[2]|0,e[3]=a+e[3]|0}function a(e){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return s}const n=new Uint32Array([1732584193,-271733879,-1732584194,271733878]);class o extends i.kb{constructor(){super(...arguments),this.blockLen=64,this.outputLen=16,this._buffer=new Uint8Array}digest(){const e=function(e){var t,s,i,o,d,h,c=e.length,l=new Uint32Array(n);for(t=64;t<=c;t+=64)r(l,a(e.subarray(t-64,t)));for(s=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<s;t+=1)i[t>>2]|=e[t]<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(r(l,i),t=0;t<16;t+=1)i[t]=0;o=(o=8*c).toString(16).match(/(.*?)(.{0,8})$/),d=parseInt(o[2],16),h=parseInt(o[1],16)||0,i[14]=d,i[15]=h,r(l,i);const u=new Uint8Array(4*l.length);for(let e=0;e<i.length;e++){const t=4*e;u[t]=255&l[e],u[t+1]=l[e]>>8&255,u[t+2]=l[e]>>16&255,u[t+3]=l[e]>>24}return u}(this._buffer);return this.destroy(),e}digestInto(e){const t=this.digest();for(let s=0;s<t.length;s++)e[s]=t[s]}_cloneInto(e){return this}destroy(){this._buffer=new Uint8Array}update(e){return this._buffer=(0,i.eV)(this._buffer,(0,i.O0)(e)),this}}let d;d=(0,i.hE)((()=>new o))},3307:(e,t,s)=>{s.d(t,{q:()=>c});var i=s(3993),r=s(8006);const a=(e,t)=>e<<t|e>>>32-t>>>0,n=(e,t,s)=>e&t^e&s^t&s,o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),d=new Uint32Array(80);class h extends i.N{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:e,B:t,C:s,D:i,E:r}=this;return[e,t,s,i,r]}set(e,t,s,i,r){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r}process(e,t){for(let s=0;s<16;s++,t+=4)d[s]=e.getUint32(t,!1);for(let e=16;e<80;e++)d[e]=a(d[e-3]^d[e-8]^d[e-14]^d[e-16],1);let{A:s,B:i,C:r,D:o,E:h}=this;for(let e=0;e<80;e++){let t,l;e<20?(t=(c=i)&r^~c&o,l=1518500249):e<40?(t=i^r^o,l=1859775393):e<60?(t=n(i,r,o),l=2400959708):(t=i^r^o,l=3395469782);const u=a(s,5)+t+h+l+d[e]|0;h=o,o=r,r=a(i,30),i=s,s=u}var c;s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,o=o+this.D|0,h=h+this.E|0,this.set(s,i,r,o,h)}roundClean(){d.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const c=(0,r.hE)((()=>new h))},1372:(e,t,s)=>{s.d(t,{J:()=>l});var i=s(3993),r=s(8006);const a=(e,t,s)=>e&t^e&s^t&s,n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint32Array(64);class h extends i.N{constructor(){super(64,32,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4],this.F=0|o[5],this.G=0|o[6],this.H=0|o[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:a,G:n,H:o}=this;return[e,t,s,i,r,a,n,o]}set(e,t,s,i,r,a,n,o){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|a,this.G=0|n,this.H=0|o}process(e,t){for(let s=0;s<16;s++,t+=4)d[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=d[e-15],s=d[e-2],i=(0,r.np)(t,7)^(0,r.np)(t,18)^t>>>3,a=(0,r.np)(s,17)^(0,r.np)(s,19)^s>>>10;d[e]=a+d[e-7]+i+d[e-16]|0}let{A:s,B:i,C:o,D:h,E:c,F:l,G:u,H:f}=this;for(let e=0;e<64;e++){const t=f+((0,r.np)(c,6)^(0,r.np)(c,11)^(0,r.np)(c,25))+((p=c)&l^~p&u)+n[e]+d[e]|0,m=((0,r.np)(s,2)^(0,r.np)(s,13)^(0,r.np)(s,22))+a(s,i,o)|0;f=u,u=l,l=c,c=h+t|0,h=o,o=i,i=s,s=t+m|0}var p;s=s+this.A|0,i=i+this.B|0,o=o+this.C|0,h=h+this.D|0,c=c+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(s,i,o,h,c,l,u,f)}roundClean(){d.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends h{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const l=(0,r.hE)((()=>new h));(0,r.hE)((()=>new c))},6739:(e,t,s)=>{s.d(t,{fr:()=>S});var i=s(3373),r=s(1682),a=s(8006);const[n,o,d]=[[],[],[]],h=BigInt(0),c=BigInt(1),l=BigInt(2),u=BigInt(7),f=BigInt(256),p=BigInt(113);for(let e=0,t=c,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],n.push(2*(5*i+s)),o.push((e+1)*(e+2)/2%64);let r=h;for(let e=0;e<7;e++)t=(t<<c^(t>>u)*p)%f,t&l&&(r^=c<<(c<<BigInt(e))-c);d.push(r)}const[m,g]=r.ZP.split(d,!0),y=(e,t,s)=>s>32?r.ZP.rotlBH(e,t,s):r.ZP.rotlSH(e,t,s),v=(e,t,s)=>s>32?r.ZP.rotlBL(e,t,s):r.ZP.rotlSL(e,t,s);class b extends a.kb{constructor(e,t,s,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,i.ZP.number(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,a.Jq)(this.state)}keccak(){!function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,a=s[r],n=s[r+1],o=y(a,n,1)^s[i],d=v(a,n,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=o,e[t+s+1]^=d}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=o[s],a=y(t,r,i),d=v(t,r,i),h=n[s];t=e[h],r=e[h+1],e[h]=a,e[h+1]=d}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=m[i],e[1]^=g[i]}s.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){i.ZP.exists(this);const{blockLen:t,state:s}=this,r=(e=(0,a.O0)(e)).length;for(let i=0;i<r;){const a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)s[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,0!=(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){i.ZP.exists(this,!1),i.ZP.bytes(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const a=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+a),i),this.posOut+=a,i+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return i.ZP.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(i.ZP.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:r,enableXOF:a}=this;return e||(e=new b(t,s,i,a,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=a,e.destroyed=this.destroyed,e}}const w=(e,t,s)=>(0,a.hE)((()=>new b(t,e,s))),S=(w(6,144,28),w(6,136,32),w(6,104,48),w(6,72,64),w(1,144,28),w(1,136,32)),k=(w(1,104,48),w(1,72,64),(e,t,s)=>(0,a.K$)(((i={})=>new b(t,e,void 0===i.dkLen?s:i.dkLen,!0))));k(31,168,16),k(31,136,32)},7110:(e,t,s)=>{s.d(t,{iC:()=>m,o:()=>p});var i=s(3993),r=s(1682),a=s(8006);const[n,o]=r.ZP.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))),d=new Uint32Array(80),h=new Uint32Array(80);class c extends i.N{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:s,Bl:i,Ch:r,Cl:a,Dh:n,Dl:o,Eh:d,El:h,Fh:c,Fl:l,Gh:u,Gl:f,Hh:p,Hl:m}=this;return[e,t,s,i,r,a,n,o,d,h,c,l,u,f,p,m]}set(e,t,s,i,r,a,n,o,d,h,c,l,u,f,p,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|s,this.Bl=0|i,this.Ch=0|r,this.Cl=0|a,this.Dh=0|n,this.Dl=0|o,this.Eh=0|d,this.El=0|h,this.Fh=0|c,this.Fl=0|l,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|m}process(e,t){for(let s=0;s<16;s++,t+=4)d[s]=e.getUint32(t),h[s]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|d[e-15],s=0|h[e-15],i=r.ZP.rotrSH(t,s,1)^r.ZP.rotrSH(t,s,8)^r.ZP.shrSH(t,s,7),a=r.ZP.rotrSL(t,s,1)^r.ZP.rotrSL(t,s,8)^r.ZP.shrSL(t,s,7),n=0|d[e-2],o=0|h[e-2],c=r.ZP.rotrSH(n,o,19)^r.ZP.rotrBH(n,o,61)^r.ZP.shrSH(n,o,6),l=r.ZP.rotrSL(n,o,19)^r.ZP.rotrBL(n,o,61)^r.ZP.shrSL(n,o,6),u=r.ZP.add4L(a,l,h[e-7],h[e-16]),f=r.ZP.add4H(u,i,c,d[e-7],d[e-16]);d[e]=0|f,h[e]=0|u}let{Ah:s,Al:i,Bh:a,Bl:c,Ch:l,Cl:u,Dh:f,Dl:p,Eh:m,El:g,Fh:y,Fl:v,Gh:b,Gl:w,Hh:S,Hl:k}=this;for(let e=0;e<80;e++){const t=r.ZP.rotrSH(m,g,14)^r.ZP.rotrSH(m,g,18)^r.ZP.rotrBH(m,g,41),O=r.ZP.rotrSL(m,g,14)^r.ZP.rotrSL(m,g,18)^r.ZP.rotrBL(m,g,41),T=m&y^~m&b,I=g&v^~g&w,x=r.ZP.add5L(k,O,I,o[e],h[e]),P=r.ZP.add5H(x,S,t,T,n[e],d[e]),M=0|x,A=r.ZP.rotrSH(s,i,28)^r.ZP.rotrBH(s,i,34)^r.ZP.rotrBH(s,i,39),C=r.ZP.rotrSL(s,i,28)^r.ZP.rotrBL(s,i,34)^r.ZP.rotrBL(s,i,39),E=s&a^s&l^a&l,_=i&c^i&u^c&u;S=0|b,k=0|w,b=0|y,w=0|v,y=0|m,v=0|g,({h:m,l:g}=r.ZP.add(0|f,0|p,0|P,0|M)),f=0|l,p=0|u,l=0|a,u=0|c,a=0|s,c=0|i;const B=r.ZP.add3L(M,C,_);s=r.ZP.add3H(B,P,A,E),i=0|B}({h:s,l:i}=r.ZP.add(0|this.Ah,0|this.Al,0|s,0|i)),({h:a,l:c}=r.ZP.add(0|this.Bh,0|this.Bl,0|a,0|c)),({h:l,l:u}=r.ZP.add(0|this.Ch,0|this.Cl,0|l,0|u)),({h:f,l:p}=r.ZP.add(0|this.Dh,0|this.Dl,0|f,0|p)),({h:m,l:g}=r.ZP.add(0|this.Eh,0|this.El,0|m,0|g)),({h:y,l:v}=r.ZP.add(0|this.Fh,0|this.Fl,0|y,0|v)),({h:b,l:w}=r.ZP.add(0|this.Gh,0|this.Gl,0|b,0|w)),({h:S,l:k}=r.ZP.add(0|this.Hh,0|this.Hl,0|S,0|k)),this.set(s,i,a,c,l,u,f,p,m,g,y,v,b,w,S,k)}roundClean(){d.fill(0),h.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class l extends c{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class u extends c{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class f extends c{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const p=(0,a.hE)((()=>new c)),m=((0,a.hE)((()=>new l)),(0,a.hE)((()=>new u)),(0,a.hE)((()=>new f)))},8006:(e,t,s)=>{s.d(t,{GL:()=>a,Jq:()=>r,K$:()=>u,O0:()=>d,O6:()=>f,eV:()=>h,hE:()=>l,iY:()=>o,kb:()=>c,np:()=>n});var i=s(9362);
|
|
19
19
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const r=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),a=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),n=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function o(e){if("string"!=typeof e)throw new TypeError("utf8ToBytes expected string, got "+typeof e);return(new TextEncoder).encode(e)}function d(e){if("string"==typeof e&&(e=o(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function h(...e){if(!e.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),s=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const r=e[t];s.set(r,i),i+=r.length}return s}class c{clone(){return this._cloneInto()}}function l(e){const t=t=>e().update(d(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}function u(e){const t=(t,s)=>e(s).update(d(t)).digest(),s=e({});return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}function f(e=32){if(i.e&&"function"==typeof i.e.getRandomValues)return i.e.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}},9651:(e,t,s)=>{
|
|
20
20
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
21
|
-
function i(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(...e){const t=(e,t)=>s=>e(t(s));return{encode:Array.from(e).reverse().reduce(((e,s)=>e?t(e,s.encode):s.encode),void 0),decode:e.reduce(((e,s)=>e?t(e,s.decode):s.decode),void 0)}}function a(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(i(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const s=e.indexOf(t);if(-1===s)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return s}))}}}function n(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function o(e,t="="){if(i(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(s){if(!Array.isArray(s)||s.length&&"string"!=typeof s[0])throw new Error("padding.encode input should be array of strings");for(let e of s)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;s.length*e%8;)s.push(t);return s},decode(s){if(!Array.isArray(s)||s.length&&"string"!=typeof s[0])throw new Error("padding.encode input should be array of strings");for(let e of s)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=s.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&s[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return s.slice(0,i)}}}function d(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function h(e,t,s){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(s<2)throw new Error(`convertRadix: wrong to=${s}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const a=[],n=Array.from(e);for(n.forEach((e=>{if(i(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,i=!0;for(let a=r;a<n.length;a++){const o=n[a],d=t*e+o;if(!Number.isSafeInteger(d)||t*e/t!==e||d-o!=t*e)throw new Error("convertRadix: carry overflow");if(e=d%s,n[a]=Math.floor(d/s),!Number.isSafeInteger(n[a])||n[a]*s+e!==d)throw new Error("convertRadix: carry overflow");i&&(n[a]?i=!1:r=a)}if(a.push(e),i)break}for(let t=0;t<e.length-1&&0===e[t];t++)a.push(0);return a.reverse()}s.d(t,{Jq:()=>S,KA:()=>A,US:()=>v,YU:()=>g,pJ:()=>y});const c=(e,t)=>t?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function u(e,t,s,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(s<=0||s>32)throw new Error(`convertRadix2: wrong to=${s}`);if(l(t,s)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${s} carryBits=${l(t,s)}`);let a=0,n=0;const o=2**s-1,d=[];for(const r of e){if(i(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(a=a<<t|r,n+t>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${t}`);for(n+=t;n>=s;n-=s)d.push((a>>n-s&o)>>>0);a&=2**n-1}if(a=a<<s-n&o,!r&&n>=t)throw new Error("Excess padding");if(!r&&a)throw new Error(`Non-zero padding: ${a}`);return r&&n>0&&d.push(a>>>0),d}function f(e){return i(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return h(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(h(t,e,256))}}}function p(e,t=!1){if(i(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:s=>{if(!(s instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(s),8,e,!t)},decode:s=>{if(!Array.isArray(s)||s.length&&"number"!=typeof s[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(s,e,8,t))}}}function m(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const g=r(p(4),a("0123456789abcdef"),n("")),y=r(p(5),a("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),o(5),n("")),v=(r(p(5),a("0123456789ABCDEFGHIJKLMNOPQRSTUV"),o(5),n("")),r(p(5),a("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),n(""),d((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o(6),n(""))),b=r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(6),n("")),w=e=>r(f(58),a(e),n("")),S=w("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),k=(w("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),w("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),O={encode(e){let t="";for(let s=0;s<e.length;s+=8){const i=e.subarray(s,s+8);t+=S.encode(i).padStart(k[i.length],"1")}return t},decode(e){let t=[];for(let s=0;s<e.length;s+=11){const i=e.slice(s,s+11),r=k.indexOf(i.length),a=S.decode(i);for(let e=0;e<a.length-r;e++)if(0!==a[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(a.slice(a.length-r)))}return Uint8Array.from(t)}},T=r(a("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),n("")),I=[996825010,642813549,513874426,1027748829,705979059];function x(e){const t=e>>25;let s=(33554431&e)<<5;for(let e=0;e<I.length;e++)1==(t>>e&1)&&(s^=I[e]);return s}function P(e,t,s=1){const i=e.length;let r=1;for(let t=0;t<i;t++){const s=e.charCodeAt(t);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);r=x(r)^s>>5}r=x(r);for(let t=0;t<i;t++)r=x(r)^31&e.charCodeAt(t);for(let e of t)r=x(r)^e;for(let e=0;e<6;e++)r=x(r);return r^=s,T.encode(u([r%2**30],30,5,!1))}function M(e){const t="bech32"===e?1:734539939,s=p(5),i=s.decode,r=s.encode,a=m(i);function n(e,s=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==s&&e.length>s)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${s})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const a=e.slice(0,r),n=e.slice(r+1);if(n.length<6)throw new Error("Data must be at least 6 characters long");const o=T.decode(n).slice(0,-6),d=P(a,o,t);if(!n.endsWith(d))throw new Error(`Invalid checksum in ${e}: expected "${d}"`);return{prefix:a,words:o}}return{encode:function(e,s,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(s)||s.length&&"number"!=typeof s[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof s);const r=e.length+7+s.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${T.encode(s)}${P(e,s,t)}`},decode:n,decodeToBytes:function(e){const{prefix:t,words:s}=n(e,!1);return{prefix:t,words:s,bytes:i(s)}},decodeUnsafe:m(n),fromWords:i,fromWordsUnsafe:a,toWords:r}}M("bech32"),M("bech32m");const A={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},C=r(p(4),a("0123456789abcdef"),n(""),d((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}))),E={utf8:A,hex:C,base16:g,base32:y,base64:v,base64url:b,base58:S,base58xmr:O};Object.keys(E).join(", ")},4224:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(6057),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"tidex",name:"Tidex",countries:["UK"],rateLimit:2e3,version:"3",userAgent:this.userAgents.chrome,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCurrencies:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/30781780-03149dc4-a12e-11e7-82bb-313b269d24d4.jpg",api:{web:"https://gate.tidex.com/api",public:"https://api.tidex.com/api/3",private:"https://api.tidex.com/tapi"},www:"https://tidex.com",doc:"https://tidex.com/exchange/public-api",referral:"https://tidex.com/exchange",fees:["https://tidex.com/exchange/assets-spec","https://tidex.com/exchange/pairs-spec"]},api:{web:{get:["currency","pairs","tickers","orders","ordershistory","trade-data","trade-data/{id}"]},public:{get:["info","ticker/{pair}","depth/{pair}","trades/{pair}"]},private:{post:["getInfoExt","getInfo","Trade","ActiveOrders","OrderInfo","CancelOrder","TradeHistory","getDepositAddress","createWithdraw","getWithdraw"]}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},commonCurrencies:{DSH:"DASH",EMGO:"MGO",MGO:"WMGO"},precisionMode:n.sh,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"IP restricted":r.PermissionDenied}},options:{fetchTickersMaxLength:2048},orders:{}})}async fetchCurrencies(e={}){const t=await this.webGetCurrency(e),s={};for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"symbol"),a=this.safeCurrencyCode(r);let n=!0===this.safeValue(i,"visible");const o=this.safeValue(i,"withdrawEnable",!0),d=this.safeValue(i,"depositEnable",!0);o&&d||(n=!1);const h=this.safeString(i,"name"),c=this.safeNumber(i,"withdrawFee");s[a]={id:r,code:a,name:h,active:n,deposit:d,withdraw:o,precision:this.parseNumber(this.parsePrecision(this.safeString(i,"amountPoint"))),funding:{withdraw:{active:o,fee:c},deposit:{active:d,fee:this.parseNumber("0")}},limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(i,"withdrawMinAmount"),max:void 0},deposit:{min:this.safeNumber(i,"depositMinAmount"),max:void 0}},info:i}}return s}async fetchMarkets(e={}){const t=(await this.publicGetInfo(e)).pairs,s=Object.keys(t),i=[];for(let e=0;e<s.length;e++){const r=s[e],n=t[r],[o,d]=r.split("_"),h=this.safeCurrencyCode(o),c=this.safeCurrencyCode(d),l=this.safeInteger(n,"hidden");let u=this.safeString(n,"fee");u=a.O.stringDiv(u,"100"),i.push({id:r,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:o,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_amount"),max:this.safeNumber(n,"max_amount")},price:{min:this.safeNumber(n,"min_price"),max:this.safeNumber(n,"max_price")},cost:{min:this.safeNumber(n,"min_total"),max:void 0}},created:void 0,info:n})}return i}parseBalance(e){const t=this.safeValue(e,"return"),s=this.safeTimestamp(t,"server_time"),i={info:e,timestamp:s,datetime:this.iso8601(s)},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],s=this.safeCurrencyCode(t),n=this.safeValue(r,t,{}),o=this.account();o.free=this.safeString(n,"value"),o.used=this.safeString(n,"inOrders"),i[s]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfoExt(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),a={pair:i.id};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s));if(!(i.id in n))throw new r.ExchangeError(this.id+" "+i.symbol+" order book is empty or not available");const o=n[i.id];return this.parseOrderBook(o,e)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join("-"),i.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join("-");const a={pair:i};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s)),o={};i=Object.keys(n);for(let e=0;e<i.length;e++){const t=i[e],s=this.safeSymbol(t);o[s]=this.parseOrderBook(n[t],s)}return o}parseTicker(e,t=undefined){const s=this.safeTimestamp(e,"updated");t=this.safeMarket(void 0,t);const i=this.safeString(e,"last");return this.safeTicker({symbol:t.symbol,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:i,last:i,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickers(e=undefined,t={}){let s;if(await this.loadMarkets(),void 0===(e=this.marketSymbols(e))){const e=this.ids.length;if(s=this.ids.join("-"),s.length>this.options.fetchTickersMaxLength){const t=this.safeInteger(this.options,"fetchTickersMaxLength",2048);throw new r.ArgumentsRequired(this.id+" fetchTickers() has "+e.toString()+" markets exceeding max URL length for this endpoint ("+t.toString()+" characters), please, specify a list of symbols of interest in the first argument to fetchTickers")}}else{s=this.marketIds(e).join("-")}const i={pair:s},a=await this.publicGetTickerPair(this.extend(i,t)),n={},o=Object.keys(a);for(let e=0;e<o.length;e++){const t=o[e],s=this.safeMarket(t);n[s.symbol]=this.parseTicker(a[t],s)}return this.filterByArrayTickers(n,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=undefined){const s=this.safeTimestamp(e,"timestamp");let i=this.safeString(e,"type");"ask"===i?i="sell":"bid"===i&&(i="buy");const r=this.safeString2(e,"rate","price"),n=this.safeString2(e,"trade_id","tid"),o=this.safeString(e,"order_id"),d=this.safeString(e,"pair"),h=this.safeSymbol(d,t),c=this.safeString(e,"amount"),l=this.parseNumber(r),u=this.parseNumber(c),f=this.parseNumber(a.O.stringMul(r,c)),p="limit";let m,g;const y=this.safeNumber(e,"commission");if(void 0!==y){const t=this.safeString(e,"commissionCurrency");g={cost:y,currency:this.safeCurrencyCode(t)}}const v=this.safeValue(e,"is_your_order");return void 0!==v&&(m="taker",v&&(m="maker"),void 0===g&&(g=this.calculateFee(h,p,i,u,l,m))),{id:n,order:o,timestamp:s,datetime:this.iso8601(s),symbol:h,type:p,side:i,takerOrMaker:m,price:l,amount:u,cost:f,fee:g,info:e}}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==s&&(a.limit=s);const n=await this.publicGetTradesPair(this.extend(a,i));if(Array.isArray(n)){if(0===n.length)return[]}return this.parseTrades(n[r.id],r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const o=i.toString(),d=a.toString();await this.loadMarkets();const h=this.market(e),c={pair:h.id,type:s,amount:this.amountToPrecision(e,i),rate:this.priceToPrecision(e,a)},l=await this.privatePostTrade(this.extend(c,n));let u,f="open",p="0.0",m=o;const g=this.safeValue(l,"return");void 0!==g&&(u=this.safeString(g,"order_id"),"0"===u&&(u=this.safeString(g,"init_order_id"),f="closed"),p=this.safeString(g,"received",p),m=this.safeString(g,"remains",o));const y=this.milliseconds();return this.safeOrder({id:u,timestamp:y,datetime:this.iso8601(y),lastTradeTimestamp:void 0,status:f,symbol:e,type:t,side:s,price:d,cost:void 0,amount:o,remaining:m,filled:p,fee:void 0,info:l,clientOrderId:void 0,average:void 0,trades:void 0},h)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)};return await this.privatePostCancelOrder(this.extend(i,s))}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"canceled"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"id"),i=this.parseOrderStatus(this.safeString(e,"status")),r=this.safeTimestamp(e,"timestamp_created"),a=this.safeString(e,"pair"),n=this.safeSymbol(a,t);let o,d;const h=this.safeString(e,"rate");"start_amount"in e?(d=this.safeString(e,"start_amount"),o=this.safeString(e,"amount")):o=this.safeString(e,"amount");return this.safeOrder({info:e,id:s,clientOrderId:void 0,symbol:n,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"type"),price:h,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:d,remaining:o,filled:void 0,status:i,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(i,s));e=e.toString();const a=this.safeValue(r,"return",{}),n=this.safeValue(a,e);return this.parseOrder(this.extend({id:e},n))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.pair=a.id);const n=await this.privatePostActiveOrders(this.extend(r,i)),o=this.safeValue(n,"return",[]);return this.parseOrders(o,a,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.pair=r.id),void 0!==s&&(a.count=s),void 0!==t&&(a.since=this.parseToInt(t/1e3));const n=await this.privatePostTradeHistory(this.extend(a,i)),o=this.safeValue(n,"return",[]);return this.parseTrades(o,r,t,s)}async withdraw(e,t,s,i=undefined,r={}){[i,r]=this.handleWithdrawTagAndParams(i,r),this.checkAddress(s),await this.loadMarkets();const a=this.currency(e),n={asset:a.id,amount:parseFloat(t),address:s};void 0!==i&&(n.memo=i);const o=await this.privatePostCreateWithdraw(this.extend(n,r)),d=this.safeValue(o,"return",{}),h=this.safeValue(d,"withdraw_info",{});return this.parseTransaction(h,a)}parseTransaction(e,t=undefined){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api[t];const d=this.omit(i,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const s=this.hmac(this.encode(a),this.encode(this.secret),o.o);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:s}}else"public"===t?(n+="/"+this.implodeParams(e,i),Object.keys(d).length&&(n+="?"+this.urlencode(d))):(n+="/"+this.implodeParams(e,i),"GET"===s?Object.keys(d).length&&(n+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&"success"in o){let e=this.safeValue(o,"success",!1);if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(o,"code"),t=this.safeString(o,"error"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}}},1067:(e,t,s)=>{s.d(t,{Z:()=>o});var i=s(1696),r=s(6689),a=s(2194),n=s(9292);class o extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"timex",name:"TimeX",countries:["AU"],version:"v1",rateLimit:1500,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,cancelOrders:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!0,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1},timeframes:{"1m":"I1","5m":"I5","15m":"I15","30m":"I30","1h":"H1","2h":"H2","4h":"H4","6h":"H6","12h":"H12","1d":"D1","1w":"W1"},urls:{logo:"https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg",api:{rest:"https://plasma-relay-backend.timex.io"},www:"https://timex.io",doc:"https://docs.timex.io",referral:"https://timex.io/?refcode=1x27vNkTbP1uwkCck"},api:{addressbook:{get:["me"],post:["","id/{id}","id/{id}/remove"]},custody:{get:["credentials","credentials/h/{hash}","credentials/k/{key}","credentials/me","credentials/me/address","deposit-addresses","deposit-addresses/h/{hash}"]},history:{get:["orders","orders/details","orders/export/csv","trades","trades/export/csv"]},currencies:{get:["a/{address}","i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},manager:{get:["deposits","transfers","withdrawals"]},markets:{get:["i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},public:{get:["candles","currencies","markets","orderbook","orderbook/raw","orderbook/v2","tickers","trades"]},statistics:{get:["address"]},trading:{get:["balances","fees","orders"],post:["orders","orders/json"],put:["orders","orders/json"],delete:["orders","orders/json"]},tradingview:{get:["config","history","symbol_info","time"]}},precisionMode:n.sh,exceptions:{exact:{0:r.ExchangeError,1:r.NotSupported,4e3:r.BadRequest,4001:r.BadRequest,4002:r.InsufficientFunds,4003:r.AuthenticationError,4004:r.AuthenticationError,4005:r.BadRequest,4006:r.BadRequest,4007:r.BadRequest,4300:r.PermissionDenied,4100:r.AuthenticationError,4400:r.OrderNotFound,5001:r.InvalidOrder,5002:r.ExchangeError,400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.OrderNotFound,429:r.RateLimitExceeded,500:r.ExchangeError,503:r.ExchangeNotAvailable},broad:{Insufficient:r.InsufficientFunds}},options:{expireIn:31536e3,fetchTickers:{period:"1d"},fetchTrades:{sort:"timestamp,asc"},fetchMyTrades:{sort:"timestamp,asc"},fetchOpenOrders:{sort:"createdAt,asc"},fetchClosedOrders:{sort:"createdAt,asc"},defaultSort:"timestamp,asc",defaultSortOrders:"createdAt,asc"}})}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e),s=[];for(let e=0;e<t.length;e++)s.push(this.parseMarket(t[e]));return s}async fetchCurrencies(e={}){const t=await this.publicGetCurrencies(e),s=[];for(let e=0;e<t.length;e++){const i=t[e];s.push(this.parseCurrency(i))}return this.indexBy(s,"code")}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){const a=this.safeString(i,"address");if(i=this.omit(i,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const n={address:a},o=await this.managerGetDeposits(this.extend(n,i)),d=this.safeCurrency(e);return this.parseTransactions(o,d,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){const a=this.safeString(i,"address");if(i=this.omit(i,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const n={address:a},o=await this.managerGetWithdrawals(this.extend(n,i)),d=this.safeCurrency(e);return this.parseTransactions(o,d,t,s)}getCurrencyByAddress(e){const t=this.currencies;for(let s=0;s<t.length;s++){const i=t[s],r=this.safeValue(i,"info",{});if(this.safeString(r,"address")===e)return i}}parseTransaction(e,t=undefined){const s=this.safeString(e,"timestamp"),i=this.safeString(e,"token","");return t=this.getCurrencyByAddress(i),{info:e,id:this.safeString(e,"transferHash"),txid:this.safeString(e,"txid"),timestamp:this.parse8601(s),datetime:s,network:void 0,address:void 0,addressTo:this.safeString(e,"to"),addressFrom:this.safeString(e,"from"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:this.safeNumber(e,"value"),currency:this.safeCurrencyCode(void 0,t),status:"ok",updated:void 0,fee:void 0}}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=this.safeString(this.options.fetchTickers,"period","1d"),i={period:this.timeframes[s]},r=await this.publicGetTickers(this.extend(i,t));return this.parseTickers(r,e)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i=this.safeString(this.options.fetchTickers,"period","1d"),r={market:s.id,period:this.timeframes[i]},a=await this.publicGetTickers(this.extend(r,t)),n=this.safeValue(a,0);return this.parseTicker(n,s)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={market:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.publicGetOrderbookV2(this.extend(i,s)),a=this.parse8601(this.safeString(r,"timestamp"));return this.parseOrderBook(r,e,a,"bid","ask","price","baseTokenAmount")}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a=this.safeValue(this.options,"fetchTrades",{}),n=this.safeValue(a,"sort","timestamp,asc"),o=this.safeString(i,"sort",n),d=this.omit(i,"sort"),h={market:r.id,sort:o};void 0!==t&&(h.from=this.iso8601(t)),void 0!==s&&(h.size=s);const c=await this.publicGetTrades(this.extend(h,d));return this.parseTrades(c,r,t,s)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={market:a.id,period:this.safeString(this.timeframes,t,t)},o=this.parseTimeframe(t);if(void 0===i&&(i=1e3),void 0!==s)n.from=this.iso8601(s),n.till=this.iso8601(this.sum(s,this.sum(i,1)*o*1e3));else{const e=this.milliseconds();n.till=this.iso8601(e),n.from=this.iso8601(e-i*o*1e3-1)}const d=await this.publicGetCandles(this.extend(n,r));return this.parseOHLCVs(d,a,t,s,i)}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.total=this.safeString(i,"totalBalance"),n.used=this.safeString(i,"lockedBalance"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.tradingGetBalances(e);return this.parseBalance(t)}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d=s.toUpperCase();let h=t.toUpperCase();this.safeValue(n,"postOnly",!1)&&(h="POST_ONLY",n=this.omit(n,["postOnly"]));const c={symbol:o.id,quantity:this.amountToPrecision(e,i),side:d,orderTypes:h};let l=n;if("LIMIT"===h||"POST_ONLY"===h){c.price=this.priceToPrecision(e,a);const s=this.safeInteger(this.options,"expireIn"),i=this.safeValue(n,"expireTime"),o=this.safeValue(n,"expireIn",s);if(void 0!==i)c.expireTime=i;else{if(void 0===o)throw new r.InvalidOrder(this.id+" createOrder() method requires a expireTime or expireIn param for a "+t+" order, you can also set the expireIn exchange-wide option");c.expireIn=o}l=this.omit(n,["expireTime","expireIn"])}else c.price=0;const u=await this.tradingPostOrders(this.extend(c,l)),f=this.safeValue(u,"orders",[]),p=this.safeValue(f,0,{});return this.parseOrder(p,o)}async editOrder(e,t,s,i,r=undefined,a=undefined,n={}){await this.loadMarkets();const o=this.market(t),d={id:e};void 0!==r&&(d.quantity=this.amountToPrecision(t,r)),void 0!==a&&(d.price=this.priceToPrecision(t,a));const h=await this.tradingPutOrders(this.extend(d,n));if("unchangedOrders"in h){const e=this.safeValue(h,"unchangedOrders",[]),t=this.safeString(e,0);return this.safeOrder({id:t,info:h})}const c=this.safeValue(h,"changedOrders",[]),l=this.safeValue(c,0,{}),u=this.safeValue(l,"newOrder",{});return this.parseOrder(u,o)}async cancelOrder(e,t=undefined,s={}){return await this.loadMarkets(),await this.cancelOrders([e],t,s)}async cancelOrders(e,t=undefined,s={}){await this.loadMarkets();const i={id:e};return await this.tradingDeleteOrders(this.extend(i,s))}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={orderHash:e},r=await this.historyGetOrdersDetails(i),a=this.safeValue(r,"order",{}),n=this.safeValue(r,"trades",[]);return this.parseOrder(this.extend(a,{trades:n}))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchOpenOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==s&&(d.size=s);const c=await this.tradingGetOrders(this.extend(d,o)),l=this.safeValue(c,"orders",[]);return this.parseOrders(l,h,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchClosedOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n,side:"BUY"};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==s&&(d.size=s);const c=await this.historyGetOrders(this.extend(d,o)),l=this.safeValue(c,"orders",[]);return this.parseOrders(l,h,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchMyTrades",{}),a=this.safeValue(r,"sort","timestamp,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==s&&(d.size=s);const c=await this.historyGetTrades(this.extend(d,o)),l=this.safeValue(c,"trades",[]);return this.parseTrades(l,h,t,s)}parseTradingFee(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeNumber(e,"fee");return{info:e,symbol:this.safeSymbol(s,t),maker:i,taker:i}}async fetchTradingFee(e,t={}){await this.loadMarkets();const s=this.market(e),i={markets:s.id},r=await this.tradingGetFees(this.extend(i,t)),a=this.safeValue(r,0,{});return this.parseTradingFee(a,s)}parseMarket(e){const t=this.safeValue(e,"locked"),s=this.safeString(e,"symbol"),i=this.safeString(e,"baseCurrency"),r=this.safeString(e,"quoteCurrency"),n=this.safeCurrencyCode(i),o=this.safeCurrencyCode(r),d=this.safeString(e,"quantityIncrement"),h=this.safeString(e,"baseMinSize"),c=a.O.stringMax(d,h),l=this.safeString(e,"tickSize"),u=this.safeString(e,"quoteMinSize");return{id:s,symbol:n+"/"+o,base:n,quote:o,settle:void 0,baseId:i,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!t,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"quantityIncrement"),price:this.safeNumber(e,"tickSize")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(c),max:void 0},price:{min:this.parseNumber(l),max:void 0},cost:{min:u,max:void 0}},created:void 0,info:e}}parseCurrency(e){const t=this.safeString(e,"symbol"),s=this.safeCurrencyCode(t),i=this.safeString(e,"name"),r=this.safeValue(e,"depositEnabled"),a=this.safeValue(e,"withdrawalEnabled"),n=this.safeValue(e,"active"),o=r&&a&&n,d=this.safeString(e,"withdrawalFee"),h=this.safeInteger(e,"tradeDecimals");let c;if(void 0!==d&&void 0!==h){const e=d.length-h;if(e>0){const t=d.slice(0,e),s=d.slice(-e);c=this.parseNumber(t+"."+s)}else{let t=".";for(let s=0;s<-e;s++)t+="0";c=this.parseNumber(t+d)}}return{id:s,code:s,info:e,type:void 0,name:i,active:o,deposit:r,withdraw:a,fee:c,precision:this.parseNumber(this.parsePrecision(this.safeString(e,"decimals"))),limits:{withdraw:{min:c,max:void 0},amount:{min:void 0,max:void 0}},networks:{}}}parseTicker(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"/"),r=this.parse8601(this.safeString(e,"timestamp")),a=this.safeString(e,"last"),n=this.safeString(e,"open");return this.safeTicker({symbol:i,info:e,timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:n,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:this.safeString(e,"volumeQuote")},t)}parseTrade(e,t=undefined){const s=this.safeString(e,"symbol"),i=this.safeSymbol(s,t),r=this.parse8601(this.safeString(e,"timestamp")),n=this.safeString(e,"price"),o=this.safeString(e,"quantity"),d=this.parseNumber(n),h=this.parseNumber(o),c=this.parseNumber(a.O.stringMul(n,o)),l=this.safeString(e,"id"),u=this.safeStringLower2(e,"direction","side"),f=this.safeStringLower(e,"makerOrTaker");let p,m;void 0!==f&&(p=this.safeString(e,f+"OrderId"));const g=this.safeNumber(e,"fee"),y=this.safeCurrencyCode(this.safeString(e,"feeToken"));return void 0!==g&&(m={cost:g,currency:y}),{info:e,id:l,timestamp:r,datetime:this.iso8601(r),symbol:i,order:p,type:void 0,side:u,price:d,amount:h,cost:c,takerOrMaker:f,fee:m}}parseOHLCV(e,t=undefined){return[this.parse8601(this.safeString(e,"timestamp")),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}parseOrder(e,t=undefined){const s=this.safeString(e,"id"),i=this.safeStringLower(e,"type"),r=this.safeStringLower(e,"side"),n=this.safeString(e,"symbol"),o=this.safeSymbol(n,t),d=this.parse8601(this.safeString(e,"createdAt")),h=this.safeString(e,"price"),c=this.safeString(e,"quantity"),l=this.safeString(e,"filledQuantity"),u=this.omitZero(this.safeString(e,"cancelledQuantity"));let f;f=a.O.stringEquals(l,c)?"closed":void 0!==u?"canceled":"open";const p=this.safeValue(e,"trades",[]),m=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,id:s,clientOrderId:m,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:o,type:i,timeInForce:void 0,postOnly:void 0,side:r,price:h,stopPrice:void 0,triggerPrice:void 0,amount:c,cost:void 0,average:void 0,filled:l,remaining:void 0,status:f,fee:void 0,trades:p},t)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/"+t+"/"+e;if(Object.keys(i).length&&(n+="?"+this.urlencodeWithArrayRepeat(i)),"public"!==t){this.checkRequiredCredentials();r={authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&e>=400){const e=this.id+" "+n;let t=this.safeValue(o,"error");void 0===t&&(t=o);const s=this.safeString2(t,"code","status"),i=this.safeString2(t,"message","debugMessage");throw this.throwBroadlyMatchedException(this.exceptions.broad,i,e),this.throwExactlyMatchedException(this.exceptions.exact,s,e),this.throwExactlyMatchedException(this.exceptions.exact,i,e),new r.ExchangeError(e)}}}},5261:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(58),r=s(9292),a=s(6689),n=s(2194),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"tokocrypto",name:"Tokocrypto",countries:["ID"],certified:!1,pro:!1,version:"v1",has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:void 0,borrowMargin:void 0,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:void 0,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:void 0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:void 0,fetchBorrowRate:void 0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchBorrowRates:void 0,fetchBorrowRatesPerSymbol:void 0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchL3OrderBook:!1,fetchLedger:void 0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpg",api:{rest:{public:"https://www.tokocrypto.com",binance:"https://api.binance.com/api/v3",private:"https://www.tokocrypto.com"}},www:"https://tokocrypto.com",doc:"https://www.tokocrypto.com/apidocs/",fees:"https://www.tokocrypto.com/fees/newschedule"},api:{binance:{get:{ping:1,time:1,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},trades:1,aggTrades:1,historicalTrades:5,klines:1,"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:1,noSymbol:2},exchangeInfo:10},put:{userDataStream:1},post:{userDataStream:1},delete:{userDataStream:1}},public:{get:{"open/v1/common/time":1,"open/v1/common/symbols":1,"open/v1/market/depth":1,"open/v1/market/trades":1,"open/v1/market/agg-trades":1,"open/v1/market/klines":1}},private:{get:{"open/v1/orders/detail":1,"open/v1/orders":1,"open/v1/account/spot":1,"open/v1/account/spot/asset":1,"open/v1/orders/trades":1,"open/v1/withdraws":1,"open/v1/deposits":1,"open/v1/deposits/address":1},post:{"open/v1/orders":1,"open/v1/orders/cancel":1,"open/v1/orders/oco":1,"open/v1/withdraws":1,"open/v1/user-data-stream":1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0075"),maker:this.parseNumber("0.0075")}},precisionMode:r.nr,options:{createMarketBuyOrderRequiresPrice:!0,defaultTimeInForce:"GTC",hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,newOrderRespType:{market:"FULL",limit:"FULL"},quoteOrderQty:!1,networks:{ERC20:"ETH",TRC20:"TRX",BEP2:"BNB",BEP20:"BSC",OMNI:"OMNI",EOS:"EOS",SPL:"SOL"},reverseNetworks:{"tronscan.org":"TRC20","etherscan.io":"ERC20","bscscan.com":"BSC","explorer.binance.org":"BEP2","bithomp.com":"XRP","bloks.io":"EOS","stellar.expert":"XLM","blockchair.com/bitcoin":"BTC","blockchair.com/bitcoin-cash":"BCH","blockchair.com/ecash":"XEC","explorer.litecoin.net":"LTC","explorer.avax.network":"AVAX","solscan.io":"SOL","polkadot.subscan.io":"DOT","dashboard.internetcomputer.org":"ICP","explorer.chiliz.com":"CHZ","cardanoscan.io":"ADA","mainnet.theoan.com":"AION","algoexplorer.io":"ALGO","explorer.ambrosus.com":"AMB","viewblock.io/zilliqa":"ZIL","viewblock.io/arweave":"AR","explorer.ark.io":"ARK","atomscan.com":"ATOM","www.mintscan.io":"CTK","explorer.bitcoindiamond.org":"BCD","btgexplorer.com":"BTG","bts.ai":"BTS","explorer.celo.org":"CELO","explorer.nervos.org":"CKB","cerebro.cortexlabs.ai":"CTXC","chainz.cryptoid.info":"VIA","explorer.dcrdata.org":"DCR","digiexplorer.info":"DGB","dock.subscan.io":"DOCK","dogechain.info":"DOGE","explorer.elrond.com":"EGLD","blockscout.com":"ETC","explore-fetchhub.fetch.ai":"FET","filfox.info":"FIL","fio.bloks.io":"FIO","explorer.firo.org":"FIRO","neoscan.io":"NEO","ftmscan.com":"FTM","explorer.gochain.io":"GO","block.gxb.io":"GXS","hash-hash.info":"HBAR","www.hiveblockexplorer.com":"HIVE","explorer.helium.com":"HNT","tracker.icon.foundation":"ICX","www.iostabc.com":"IOST","explorer.iota.org":"IOTA","iotexscan.io":"IOTX","irishub.iobscan.io":"IRIS","kava.mintscan.io":"KAVA","scope.klaytn.com":"KLAY","kmdexplorer.io":"KMD","kusama.subscan.io":"KSM","explorer.lto.network":"LTO","polygonscan.com":"POLYGON","explorer.ont.io":"ONT","minaexplorer.com":"MINA","nanolooker.com":"NANO","explorer.nebulas.io":"NAS","explorer.nbs.plus":"NBS","explorer.nebl.io":"NEBL","nulscan.io":"NULS","nxscan.com":"NXS","explorer.harmony.one":"ONE","explorer.poa.network":"POA","qtum.info":"QTUM","explorer.rsk.co":"RSK","www.oasisscan.com":"ROSE","ravencoin.network":"RVN","sc.tokenview.com":"SC","secretnodes.com":"SCRT","explorer.skycoin.com":"SKY","steemscan.com":"STEEM","explorer.stacks.co":"STX","www.thetascan.io":"THETA","scan.tomochain.com":"TOMO","explore.vechain.org":"VET","explorer.vite.net":"VITE","www.wanscan.org":"WAN","wavesexplorer.com":"WAVES","wax.eosx.io":"WAXP","waltonchain.pro":"WTC","chain.nem.ninja":"XEM","verge-blockchain.info":"XVG","explorer.yoyow.org":"YOYOW","explorer.zcha.in":"ZEC","explorer.zensystem.io":"ZEN"},impliedNetworks:{ETH:{ERC20:"ETH"},TRX:{TRC20:"TRX"}},legalMoney:{MXN:!0,UGX:!0,SEK:!0,CHF:!0,VND:!0,AED:!0,DKK:!0,KZT:!0,HUF:!0,PEN:!0,PHP:!0,USD:!0,TRY:!0,EUR:!0,NGN:!0,PLN:!0,BRL:!0,ZAR:!0,KES:!0,ARS:!0,RUB:!0,AUD:!0,NOK:!0,CZK:!0,GBP:!0,UAH:!0,GHS:!0,HKD:!0,CAD:!0,INR:!0,JPY:!0,NZD:!0}},exceptions:{exact:{"System is under maintenance.":a.OnMaintenance,"System abnormality":a.ExchangeError,"You are not authorized to execute this request.":a.PermissionDenied,"API key does not exist":a.AuthenticationError,"Order would trigger immediately.":a.OrderImmediatelyFillable,"Stop price would trigger immediately.":a.OrderImmediatelyFillable,"Order would immediately match and take.":a.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":a.InsufficientFunds,"Rest API trading is not enabled.":a.ExchangeNotAvailable,"You don't have permission.":a.PermissionDenied,"Market is closed.":a.ExchangeNotAvailable,"Too many requests. Please try again later.":a.DDoSProtection,"This action disabled is on this account.":a.AccountSuspended,"-1000":a.ExchangeNotAvailable,"-1001":a.ExchangeNotAvailable,"-1002":a.AuthenticationError,"-1003":a.RateLimitExceeded,"-1004":a.DDoSProtection,"-1005":a.PermissionDenied,"-1006":a.BadResponse,"-1007":a.RequestTimeout,"-1010":a.BadResponse,"-1011":a.PermissionDenied,"-1013":a.InvalidOrder,"-1014":a.InvalidOrder,"-1015":a.RateLimitExceeded,"-1016":a.ExchangeNotAvailable,"-1020":a.BadRequest,"-1021":a.InvalidNonce,"-1022":a.AuthenticationError,"-1023":a.BadRequest,"-1099":a.AuthenticationError,"-1100":a.BadRequest,"-1101":a.BadRequest,"-1102":a.BadRequest,"-1103":a.BadRequest,"-1104":a.BadRequest,"-1105":a.BadRequest,"-1106":a.BadRequest,"-1108":a.BadRequest,"-1109":a.AuthenticationError,"-1110":a.BadRequest,"-1111":a.BadRequest,"-1112":a.InvalidOrder,"-1113":a.BadRequest,"-1114":a.BadRequest,"-1115":a.BadRequest,"-1116":a.BadRequest,"-1117":a.BadRequest,"-1118":a.BadRequest,"-1119":a.BadRequest,"-1120":a.BadRequest,"-1121":a.BadSymbol,"-1125":a.AuthenticationError,"-1127":a.BadRequest,"-1128":a.BadRequest,"-1130":a.BadRequest,"-1131":a.BadRequest,"-1136":a.BadRequest,"-2008":a.AuthenticationError,"-2010":a.ExchangeError,"-2011":a.OrderNotFound,"-2013":a.OrderNotFound,"-2014":a.AuthenticationError,"-2015":a.AuthenticationError,"-2016":a.BadRequest,"-2018":a.InsufficientFunds,"-2019":a.InsufficientFunds,"-2020":a.OrderNotFillable,"-2021":a.OrderImmediatelyFillable,"-2022":a.InvalidOrder,"-2023":a.InsufficientFunds,"-2024":a.InsufficientFunds,"-2025":a.InvalidOrder,"-2026":a.InvalidOrder,"-2027":a.InvalidOrder,"-2028":a.InsufficientFunds,"-3000":a.ExchangeError,"-3001":a.AuthenticationError,"-3002":a.BadSymbol,"-3003":a.BadRequest,"-3004":a.ExchangeError,"-3005":a.InsufficientFunds,"-3006":a.InsufficientFunds,"-3007":a.ExchangeError,"-3008":a.InsufficientFunds,"-3009":a.BadRequest,"-3010":a.ExchangeError,"-3011":a.BadRequest,"-3012":a.ExchangeError,"-3013":a.BadRequest,"-3014":a.AccountSuspended,"-3015":a.ExchangeError,"-3016":a.BadRequest,"-3017":a.ExchangeError,"-3018":a.AccountSuspended,"-3019":a.AccountSuspended,"-3020":a.InsufficientFunds,"-3021":a.BadRequest,"-3022":a.AccountSuspended,"-3023":a.BadRequest,"-3024":a.ExchangeError,"-3025":a.BadRequest,"-3026":a.BadRequest,"-3027":a.BadSymbol,"-3028":a.BadSymbol,"-3029":a.ExchangeError,"-3036":a.AccountSuspended,"-3037":a.ExchangeError,"-3038":a.BadRequest,"-3041":a.InsufficientFunds,"-3042":a.BadRequest,"-3043":a.BadRequest,"-3044":a.DDoSProtection,"-3045":a.ExchangeError,"-3999":a.ExchangeError,"-4001":a.BadRequest,"-4002":a.BadRequest,"-4003":a.BadRequest,"-4004":a.AuthenticationError,"-4005":a.RateLimitExceeded,"-4006":a.BadRequest,"-4007":a.BadRequest,"-4008":a.BadRequest,"-4010":a.BadRequest,"-4011":a.BadRequest,"-4012":a.BadRequest,"-4013":a.AuthenticationError,"-4014":a.PermissionDenied,"-4015":a.ExchangeError,"-4016":a.PermissionDenied,"-4017":a.PermissionDenied,"-4018":a.BadSymbol,"-4019":a.BadSymbol,"-4021":a.BadRequest,"-4022":a.BadRequest,"-4023":a.ExchangeError,"-4024":a.InsufficientFunds,"-4025":a.InsufficientFunds,"-4026":a.InsufficientFunds,"-4027":a.ExchangeError,"-4028":a.BadRequest,"-4029":a.BadRequest,"-4030":a.ExchangeError,"-4031":a.ExchangeError,"-4032":a.ExchangeError,"-4033":a.BadRequest,"-4034":a.ExchangeError,"-4035":a.PermissionDenied,"-4036":a.BadRequest,"-4037":a.ExchangeError,"-4038":a.ExchangeError,"-4039":a.BadRequest,"-4040":a.BadRequest,"-4041":a.ExchangeError,"-4042":a.ExchangeError,"-4043":a.BadRequest,"-4044":a.BadRequest,"-4045":a.ExchangeError,"-4046":a.AuthenticationError,"-4047":a.BadRequest,"-5001":a.BadRequest,"-5002":a.InsufficientFunds,"-5003":a.InsufficientFunds,"-5004":a.BadRequest,"-5005":a.InsufficientFunds,"-5006":a.BadRequest,"-5007":a.BadRequest,"-5008":a.InsufficientFunds,"-5009":a.BadRequest,"-5010":a.ExchangeError,"-5011":a.BadRequest,"-5012":a.ExchangeError,"-5013":a.InsufficientFunds,"-5021":a.BadRequest,"-6001":a.BadRequest,"-6003":a.BadRequest,"-6004":a.ExchangeError,"-6005":a.InvalidOrder,"-6006":a.BadRequest,"-6007":a.BadRequest,"-6008":a.BadRequest,"-6009":a.RateLimitExceeded,"-6011":a.BadRequest,"-6012":a.InsufficientFunds,"-6013":a.ExchangeError,"-6014":a.BadRequest,"-6015":a.BadRequest,"-6016":a.BadRequest,"-6017":a.BadRequest,"-6018":a.BadRequest,"-6019":a.AuthenticationError,"-6020":a.BadRequest,"-7001":a.BadRequest,"-7002":a.BadRequest,"-9000":a.InsufficientFunds,"-10017":a.BadRequest,"-11008":a.InsufficientFunds,"-12014":a.RateLimitExceeded,"-13000":a.BadRequest,"-13001":a.BadRequest,"-13002":a.BadRequest,"-13003":a.BadRequest,"-13004":a.BadRequest,"-13005":a.BadRequest,"-13006":a.InvalidOrder,"-13007":a.AuthenticationError,"-21001":a.BadRequest,"-21002":a.BadRequest,"-21003":a.BadRequest,100001003:a.BadRequest,2202:a.InsufficientFunds,3210:a.InvalidOrder,3203:a.InvalidOrder,3211:a.InvalidOrder,3207:a.InvalidOrder,3218:a.OrderNotFound},broad:{"has no operation privilege":a.PermissionDenied,MAX_POSITION:a.InvalidOrder}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetOpenV1CommonTime(e);return this.safeInteger(t,"serverTime")}async fetchMarkets(e={}){const t=await this.publicGetOpenV1CommonSymbols(e);this.options.adjustForTimeDifference&&await this.loadTimeDifference();const s=this.safeValue(t,"data",{}),i=this.safeValue(s,"list",[]),r=[];for(let e=0;e<i.length;e++){const t=i[e],s=this.safeString(t,"baseAsset"),a=this.safeString(t,"quoteAsset"),n=this.safeString(t,"symbol"),o=this.safeStringLower(t,"symbol"),d=this.safeString(t,"marginAsset"),h=this.safeCurrencyCode(s),c=this.safeCurrencyCode(a),l=this.safeCurrencyCode(d),u=h+"/"+c,f=this.safeValue(t,"filters",[]),p=this.indexBy(f,"filterType");let m="1"===this.safeString(t,"spotTradingEnable");const g=this.safeValue(t,"permissions",[]);for(let e=0;e<g.length;e++)if("TRD_GRP_003"===g[e]){m=!1;break}const y={id:n,lowercaseId:o,symbol:u,base:h,quote:c,settle:l,baseId:s,quoteId:a,settleId:d,type:"spot",spot:!0,margin:this.safeValue(t,"isMarginTradingAllowed",!1),swap:!1,future:!1,delivery:!1,option:!1,active:m,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.safeInteger(t,"quantityPrecision"),price:this.safeInteger(t,"pricePrecision"),base:this.safeInteger(t,"baseAssetPrecision"),quote:this.safeInteger(t,"quotePrecision")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t};if("PRICE_FILTER"in p){const e=this.safeValue(p,"PRICE_FILTER",{}),t=this.safeString(e,"tickSize");y.precision.price=this.precisionFromString(t),y.limits.price={min:this.safeNumber(e,"minPrice"),max:this.safeNumber(e,"maxPrice")},y.precision.price=this.precisionFromString(e.tickSize)}if("LOT_SIZE"in p){const e=this.safeValue(p,"LOT_SIZE",{}),t=this.safeString(e,"stepSize");y.precision.amount=this.precisionFromString(t),y.limits.amount={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MARKET_LOT_SIZE"in p){const e=this.safeValue(p,"MARKET_LOT_SIZE",{});y.limits.market={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MIN_NOTIONAL"in p){const e=this.safeValue(p,"MIN_NOTIONAL",{});y.limits.cost.min=this.safeNumber2(e,"minNotional","notional")}r.push(y)}return r}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={};let a;void 0!==t&&(r.limit=t),"USDT"===i.quote?(r.symbol=i.baseId+i.quoteId,a=await this.binanceGetDepth(this.extend(r,s))):(r.symbol=i.id,a=await this.publicGetOpenV1MarketDepth(this.extend(r,s)));const n=this.safeValue(a,"data",a),o=this.safeInteger2(a,"T","timestamp"),d=this.parseOrderBook(n,e,o);return d.nonce=this.safeInteger(n,"lastUpdateId"),d}parseTrade(e,t=undefined){const s=this.safeInteger2(e,"T","time"),i=this.safeString2(e,"p","price"),r=this.safeString2(e,"q","qty"),a=this.safeString2(e,"quoteQty","baseQty"),n=this.safeString(e,"symbol"),o=this.safeSymbol(n,t);let d,h=this.safeString2(e,"t","a");h=this.safeString2(e,"id","tradeId",h);const c=this.safeString(e,"orderId"),l=this.safeValue2(e,"m","isBuyerMaker");let u,f;return void 0!==l?(d=l?"sell":"buy",u="taker"):"side"in e?d=this.safeStringLower(e,"side"):"isBuyer"in e&&(d=e.isBuyer?"buy":"sell"),"commission"in e&&(f={cost:this.safeString(e,"commission"),currency:this.safeCurrencyCode(this.safeString(e,"commissionAsset"))}),"isMaker"in e&&(u=e.isMaker?"maker":"taker"),"maker"in e&&(u=e.maker?"maker":"taker"),this.safeTrade({info:e,timestamp:s,datetime:this.iso8601(s),symbol:o,id:h,order:c,type:void 0,side:d,takerOrMaker:u,price:i,amount:r,cost:a,fee:f},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:this.getMarketIdByType(r)};if("USDT"!==r.quote){void 0!==s&&(a.limit=s);const e=this.publicGetOpenV1MarketTrades(this.extend(a,i)),n=this.safeValue(e,"data",{});return this.parseTrades(n,r,t,s)}const n=this.safeString(this.options,"fetchTradesMethod","binanceGetTrades");"binanceGetAggTrades"===n&&void 0!==t&&(a.startTime=t,a.endTime=this.sum(t,36e5)),void 0!==s&&(a.limit=s);const o=await this[n](this.extend(a,i));return this.parseTrades(o,r,t,s)}parseTicker(e,t=undefined){const s=this.safeInteger(e,"closeTime"),i=this.safeString(e,"symbol"),r=this.safeSymbol(i,t),a=this.safeString(e,"lastPrice");let n,o;return"baseVolume"in e?(n=this.safeString(e,"baseVolume"),o=this.safeString(e,"volume")):(n=this.safeString(e,"volume"),o=this.safeString(e,"quoteVolume")),this.safeTicker({symbol:r,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"highPrice"),low:this.safeString(e,"lowPrice"),bid:this.safeString(e,"bidPrice"),bidVolume:this.safeString(e,"bidQty"),ask:this.safeString(e,"askPrice"),askVolume:this.safeString(e,"askQty"),vwap:this.safeString(e,"weightedAvgPrice"),open:this.safeString(e,"openPrice"),close:a,last:a,previousClose:this.safeString(e,"prevClosePrice"),change:this.safeString(e,"priceChange"),percentage:this.safeString(e,"priceChangePercent"),average:void 0,baseVolume:n,quoteVolume:o,info:e},t)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=this.safeString(this.options,"fetchTickersMethod","binanceGetTicker24hr"),i=await this[s](t);return this.parseTickers(i,e)}getMarketIdByType(e){return"USDT"===e.quote?e.baseId+e.quoteId:e.id}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.baseId+s.quoteId},r=await this.binanceGetTicker24hr(this.extend(i,t));if(Array.isArray(r)){const e=this.safeValue(r,0,{});return this.parseTicker(e,s)}return this.parseTicker(r,s)}async fetchBidsAsks(e=undefined,t={}){await this.loadMarkets();const s=await this.binanceGetTickerBookTicker(t);return this.parseTickers(s,e)}parseOHLCV(e,t=undefined){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n=this.safeString(r,"price"),o=this.safeInteger(r,"until");r=this.omit(r,["price","until"]),i=void 0===i?500:Math.min(i,1500);const d={interval:this.safeString(this.timeframes,t,t),limit:i};let h;"index"===n?d.pair=a.id:d.symbol=this.getMarketIdByType(a),void 0!==s&&(d.startTime=s),void 0!==o&&(d.endTime=o),h="USDT"===a.quote?await this.binanceGetKlines(this.extend(d,r)):await this.publicGetOpenV1MarketKlines(this.extend(d,r));const c=this.safeValue(h,"data",h);return this.parseOHLCVs(c,a,t,s,i)}async fetchBalance(e={}){await this.loadMarkets();const t=this.safeString2(this.options,"fetchBalance","defaultType","spot"),s=this.safeString(e,"type",t),i=this.safeString2(this.options,"marginMode","defaultMarginMode"),r=this.safeStringLower(e,"marginMode",i),a=await this.privateGetOpenV1AccountSpot(this.extend({},e));return this.parseBalance(a,s,r)}parseBalance(e,t=undefined,s=undefined){const i=this.safeInteger(e,"updateTime"),r={info:e,timestamp:i,datetime:this.iso8601(i)},a=this.safeValue(e,"data",{}),n=this.safeValue(a,"accountAssets",[]);for(let e=0;e<n.length;e++){const t=n[e],s=this.safeString(t,"asset"),i=this.safeCurrencyCode(s),a=this.account();a.free=this.safeString(t,"free"),a.used=this.safeString(t,"locked"),r[i]=a}return this.safeBalance(r)}parseOrderStatus(e){return this.safeString({"-2":"open",0:"open",1:"open",2:"closed",3:"canceled",4:"canceling",5:"rejected",6:"expired",NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",PENDING_CANCEL:"canceling",REJECTED:"rejected",EXPIRED:"expired"},e,e)}parseOrder(e,t=undefined){const s=this.parseOrderStatus(this.safeString(e,"status")),i=this.safeString(e,"symbol"),r=this.safeSymbol(i,t),a=this.safeString(e,"executedQty","0"),n=this.safeInteger(e,"createTime"),o=this.safeString(e,"avgPrice"),d=this.safeString2(e,"price","executedPrice"),h=this.safeString(e,"origQty"),c=this.safeStringN(e,["cummulativeQuoteQty","cumQuote","executedQuoteQty","cumBase"]),l=this.safeString(e,"orderId"),u=this.parseOrderType(this.safeStringLower(e,"type"));let f=this.safeStringLower(e,"side");"0"===f?f="buy":"1"===f&&(f="sell");const p=this.safeValue(e,"fills",[]),m=this.safeString2(e,"clientOrderId","clientId");let g=this.safeString(e,"timeInForce");"GTX"===g&&(g="PO");const y="limit_maker"===u||"PO"===g,v=this.safeString(e,"stopPrice"),b=this.parseNumber(this.omitZero(v));return this.safeOrder({info:e,id:l,clientOrderId:m,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:void 0,symbol:r,type:u,timeInForce:g,postOnly:y,reduceOnly:this.safeValue(e,"reduceOnly"),side:f,price:d,stopPrice:b,triggerPrice:b,amount:h,cost:c,average:o,filled:a,remaining:void 0,status:s,fee:void 0,trades:p},t)}parseOrderType(e){return this.safeString({2:"market",1:"limit",4:"limit",7:"limit"},e,e)}async createOrder(e,t,s,i,o=undefined,d={}){await this.loadMarkets();const h=this.market(e),c=this.safeString2(d,"clientOrderId","clientId");this.safeValue(d,"postOnly",!1)&&(t="LIMIT_MAKER"),d=this.omit(d,["clientId","clientOrderId"]);const l=t.toUpperCase();let u=l;const f=this.safeValue2(d,"triggerPrice","stopPrice");void 0!==f&&(d=this.omit(d,["triggerPrice","stopPrice"]),"MARKET"===u?u="STOP_LOSS":"LIMIT"===u&&(u="STOP_LOSS_LIMIT"));const p=this.safeValue(h.info,"orderTypes");if(!this.inArray(u,p))throw l!==u?new a.InvalidOrder(this.id+" stopPrice parameter is not allowed for "+e+" "+t+" orders"):new a.InvalidOrder(this.id+" "+t+" is not a valid order type for the "+e+" market");const m={symbol:h.baseId+"_"+h.quoteId,type:this.safeString({LIMIT:1,MARKET:2,STOP_LOSS:3,STOP_LOSS_LIMIT:4,TAKE_PROFIT:5,TAKE_PROFIT_LIMIT:6,LIMIT_MAKER:7},u)};if("buy"===s?m.side=0:"sell"===s&&(m.side=1),void 0===c){const e=this.safeValue(this.options,"broker");if(void 0!==e){const t=this.safeString(e,"marketType");void 0!==t&&(m.clientId=t+this.uuid22())}}else m.clientId=c;let g=!1,y=!1,v=!1;if("MARKET"===u){const e=this.safeValue2(d,"quoteOrderQty","cost");if(this.options.createMarketBuyOrderRequiresPrice&&"buy"===s&&void 0===o&&void 0===e)throw new a.InvalidOrder(this.id+" createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter");const t=h.precision.price;if(void 0!==e)m.quoteOrderQty=this.decimalToPrecision(e,r.tk,t,this.precisionMode),d=this.omit(d,["quoteOrderQty","cost"]);else if(void 0!==o){const e=this.numberToString(i),s=this.numberToString(o),a=n.O.stringMul(e,s);m.quoteOrderQty=this.decimalToPrecision(a,r.tk,t,this.precisionMode)}else v=!0}else"LIMIT"===u?(g=!0,v=!0):"STOP_LOSS"===u||"TAKE_PROFIT"===u?(y=!0,v=!0,(h.linear||h.inverse)&&(g=!0)):"STOP_LOSS_LIMIT"===u||"TAKE_PROFIT_LIMIT"===u?(v=!0,y=!0,g=!0):"LIMIT_MAKER"===u&&(g=!0,v=!0);if(v&&(m.quantity=this.amountToPrecision(e,i)),g){if(void 0===o)throw new a.InvalidOrder(this.id+" createOrder() requires a price argument for a "+t+" order");m.price=this.priceToPrecision(e,o)}if(y){if(void 0===f)throw new a.InvalidOrder(this.id+" createOrder() requires a stopPrice extra param for a "+t+" order");m.stopPrice=this.priceToPrecision(e,f)}const b=await this.privatePostOpenV1Orders(this.extend(m,d)),w=this.safeValue(b,"data",{});return this.parseOrder(w,h)}async fetchOrder(e,t=undefined,s={}){const i={orderId:e},r=await this.privateGetOpenV1Orders(this.extend(i,s)),a=this.safeValue(r,"data",{}),n=this.safeValue(a,"list",[]),o=this.safeValue(n,0,{});return this.parseOrder(o)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const r=this.market(e),n={symbol:r.id};void 0!==t&&(n.startTime=t),void 0!==s&&(n.limit=s);const o=await this.privateGetOpenV1Orders(this.extend(n,i)),d=this.safeValue(o,"data",{}),h=this.safeValue(d,"list",[]);return this.parseOrders(h,r,t,s)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrders(e,t,s,this.extend({type:1},i))}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrders(e,t,s,this.extend({type:2},i))}async cancelOrder(e,t=undefined,s={}){const i={orderId:e},r=await this.privatePostOpenV1OrdersCancel(this.extend(i,s)),a=this.safeValue(r,"data",{});return this.parseOrder(a)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const r=this.market(e),n={symbol:r.id},o=this.safeInteger2(i,"until","endTime");void 0!==t&&(n.startTime=t),void 0!==o&&(n.endTime=o,i=this.omit(i,["endTime","until"])),void 0!==s&&(n.limit=s);const d=await this.privateGetOpenV1OrdersTrades(this.extend(n,i)),h=this.safeValue(d,"data",{}),c=this.safeValue(h,"list",[]);return this.parseTrades(c,r,t,s)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s={asset:this.currency(e).id},i=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(i,r,r),void 0!==r&&(s.network=r,t=this.omit(t,"network"));const a=await this.privateGetOpenV1DepositsAddress(this.extend(s,t)),n=this.safeValue(a,"data",{}),o=this.safeString(n,"address");let d=this.safeString(n,"addressTag","");return 0===d.length&&(d=void 0),this.checkAddress(o),{currency:e,address:o,tag:d,network:this.safeString(n,"network"),info:a}}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={},n=this.safeInteger(i,"until");if(void 0!==e&&(r=this.currency(e),a.coin=r.id),void 0!==t){a.startTime=t;let e=this.sum(t,7776e6);void 0!==n&&(e=Math.min(e,n)),a.endTime=e}void 0!==s&&(a.limit=s);const o=await this.privateGetOpenV1Deposits(this.extend(a,i)),d=this.safeValue(o,"data",{}),h=this.safeValue(d,"list",[]);return this.parseTransactions(h,r,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t,r.endTime=this.sum(t,7776e6)),void 0!==s&&(r.limit=s);const n=await this.privateGetOpenV1Withdraws(this.extend(r,i)),o=this.safeValue(n,"data",{}),d=this.safeValue(o,"list",[]);return this.parseTransactions(d,a,t,s)}parseTransactionStatusByType(e,t=undefined){const s=this.safeValue({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",1:"canceled",2:"pending",3:"failed",4:"pending",5:"failed",10:"ok"}},t,{});return this.safeString(s,e,e)}parseTransaction(e,t=undefined){const s=this.safeString(e,"address");let i=this.safeString(e,"addressTag");void 0!==i&&i.length<1&&(i=void 0);let r=this.safeString(e,"txId");void 0!==r&&r.indexOf("Internal transfer ")>=0&&(r=r.slice(18));const a=this.safeString2(e,"coin","fiatCurrency"),n=this.safeCurrencyCode(a,t);let o;const d=this.safeInteger(e,"insertTime"),h=this.safeInteger2(e,"createTime","timestamp");let c=this.safeString(e,"type");void 0===c&&(void 0!==d&&void 0===h?(c="deposit",o=d):void 0===d&&void 0!==h&&(c="withdrawal",o=h));const l=this.safeNumber2(e,"transactionFee","totalFee"),u={currency:void 0,cost:void 0,rate:void 0};void 0!==l&&(u.currency=n,u.cost=l);let f=!1;void 0!==this.safeInteger(e,"transferType")&&(f=!0);let p=this.safeString(e,"id");if(void 0===p){const t=this.safeValue(e,"data",{});p=this.safeString(t,"withdrawId"),c="withdrawal"}return{info:e,id:p,txid:r,type:c,currency:n,network:this.safeString(e,"network"),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatusByType(this.safeString(e,"status"),c),timestamp:o,datetime:this.iso8601(o),address:s,addressFrom:void 0,addressTo:s,tag:i,tagFrom:void 0,tagTo:i,updated:this.safeInteger2(e,"successTime","updateTime"),comment:void 0,internal:f,fee:u}}async withdraw(e,t,s,i=undefined,r={}){[i,r]=this.handleWithdrawTagAndParams(i,r),await this.loadMarkets(),this.checkAddress(s);const a=this.currency(e),n={asset:a.id,address:s,amount:this.numberToString(t)};void 0!==i&&(n.addressTag=i);const[o,d]=this.handleNetworkCodeAndParams(r),h=this.networkCodeToId(o);void 0!==h&&(n.network=h.toUpperCase());const c=await this.privatePostOpenV1Withdraws(this.extend(n,d));return this.parseTransaction(c,a)}sign(e,t="public",s="GET",i={},r=undefined,n=undefined){if(!(t in this.urls.api.rest))throw new a.NotSupported(this.id+" does not have a testnet/sandbox URL for "+t+" endpoints");let d=this.urls.api.rest[t];d+="/"+e,"wapi"===t&&(d+=".html");if("userDataStream"===e||"listenKey"===e){if(!this.apiKey)throw new a.AuthenticationError(this.id+" userDataStream endpoint requires `apiKey` credential");r={"X-MBX-APIKEY":this.apiKey,"Content-Type":"application/x-www-form-urlencoded"},"GET"!==s&&(n=this.urlencode(i))}else if("private"===t||"sapi"===t&&"system/status"!==e||"sapiV3"===t||"wapi"===t&&"systemStatus"!==e||"dapiPrivate"===t||"dapiPrivateV2"===t||"fapiPrivate"===t||"fapiPrivateV2"===t){let a;this.checkRequiredCredentials();const h=this.safeInteger(this.options,"recvWindow"),c=this.extend({timestamp:this.nonce()},i);void 0!==h&&(c.recvWindow=h);const l=this.safeInteger(i,"recvWindow");void 0!==l&&(c.recvWindow=l),a="sapi"===t&&"asset/dust"===e?this.urlencodeWithArrayRepeat(c):"batchOrders"===e||e.indexOf("sub-account")>=0||"capital/withdraw/apply"===e||e.indexOf("staking")>=0?this.rawencode(c):this.urlencode(c);a+="&signature="+this.hmac(this.encode(a),this.encode(this.secret),o.J),r={"X-MBX-APIKEY":this.apiKey},"GET"===s||"DELETE"===s||"wapi"===t?d+="?"+a:(n=a,r["Content-Type"]="application/x-www-form-urlencoded")}else Object.keys(i).length&&(d+="?"+this.urlencode(i));return{url:d,method:s,body:n,headers:r}}handleErrors(e,t,s,i,r,o,d,h,c){if(418===e||429===e)throw new a.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+o);if(e>=400){if(o.indexOf("Price * QTY is zero or less")>=0)throw new a.InvalidOrder(this.id+" order cost = amount * price is zero or less "+o);if(o.indexOf("LOT_SIZE")>=0)throw new a.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+o);if(o.indexOf("PRICE_FILTER")>=0)throw new a.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) "+o)}if(void 0===d)return;const l=this.safeValue(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const f=this.safeString(d,"code");if(void 0!==f){if("200"===f||n.O.stringEquals(f,"0"))return;if("-2015"===f&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new a.DDoSProtection(this.id+" "+o);const e=this.id+" "+o;if("No need to change margin type."===u)throw new a.MarginModeAlreadySet(e);throw this.throwExactlyMatchedException(this.exceptions.exact,f,e),new a.ExchangeError(e)}if(!l)throw new a.ExchangeError(this.id+" "+o)}calculateRateLimiterCost(e,t,s,i,r={}){if("noCoin"in r&&!("coin"in i))return r.noCoin;if("noSymbol"in r&&!("symbol"in i))return r.noSymbol;if("noPoolId"in r&&!("poolId"in i))return r.noPoolId;if("byLimit"in r&&"limit"in i){const e=i.limit,t=r.byLimit;for(let s=0;s<t.length;s++){const i=t[s];if(e<=i[0])return i[1]}}return this.safeInteger(r,"cost",1)}}},7584:(e,t,s)=>{s.d(t,{Z:()=>c});var i=s(2120),r=s(6689),a=s(2194),n=s(9292),o=s(7110),d=s(1372),h=s(5981);class c extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"upbit",name:"Upbit",countries:["KR"],version:"v1",rateLimit:1e3,pro:!0,has:{CORS:!0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createDepositAddress:!0,createMarketOrder:!0,createOrder:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!1,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactions:!1,fetchWithdrawals:!0,transfer:!1,withdraw:!0},timeframes:{"1m":"minutes","3m":"minutes","5m":"minutes","15m":"minutes","30m":"minutes","1h":"minutes","4h":"minutes","1d":"days","1w":"weeks","1M":"months"},hostname:"api.upbit.com",urls:{logo:"https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg",api:{public:"https://{hostname}",private:"https://{hostname}"},www:"https://upbit.com",doc:"https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C",fees:"https://upbit.com/service_center/guide"},api:{public:{get:["market/all","candles/{timeframe}","candles/{timeframe}/{unit}","candles/minutes/{unit}","candles/minutes/1","candles/minutes/3","candles/minutes/5","candles/minutes/15","candles/minutes/30","candles/minutes/60","candles/minutes/240","candles/days","candles/weeks","candles/months","trades/ticks","ticker","orderbook"]},private:{get:["accounts","orders/chance","order","orders","withdraws","withdraw","withdraws/chance","deposits","deposit","deposits/coin_addresses","deposits/coin_address"],post:["orders","withdraws/coin","withdraws/krw","deposits/generate_coin_address"],delete:["order"]}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},precisionMode:n.sh,exceptions:{exact:{"This key has expired.":r.AuthenticationError,"Missing request parameter error. Check the required parameters!":r.BadRequest,"side is missing, side does not have a valid value":r.InvalidOrder},broad:{thirdparty_agreement_required:r.PermissionDenied,out_of_scope:r.PermissionDenied,order_not_found:r.OrderNotFound,insufficient_funds:r.InsufficientFunds,invalid_access_key:r.AuthenticationError,jwt_verification:r.AuthenticationError,create_ask_error:r.ExchangeError,create_bid_error:r.ExchangeError,volume_too_large:r.InvalidOrder,invalid_funds:r.InvalidOrder}},options:{createMarketBuyOrderRequiresPrice:!0,fetchTickersMaxLength:4096,fetchOrderBooksMaxLength:4096,tradingFeesByQuoteCurrency:{KRW:5e-4}},commonCurrencies:{TON:"Tokamak Network"}})}async fetchCurrency(e,t={}){await this.loadMarkets();const s=this.currency(e);return await this.fetchCurrencyById(s.id,t)}async fetchCurrencyById(e,t={}){const s={currency:e},i=await this.privateGetWithdrawsChance(this.extend(s,t)),r=this.safeValue(i,"member_level",{}),a=this.safeValue(i,"currency",{}),n=this.safeValue(i,"withdraw_limit",{}),o=this.safeValue(n,"can_withdraw"),d=this.safeString(a,"wallet_state"),h=this.safeValue(r,"wallet_locked"),c=this.safeValue(r,"locked");let l=!0;void 0===o||o?("working"!==d||void 0!==h&&h||void 0!==c&&c)&&(l=!1):l=!1;const u=this.safeNumber(n,"onetime"),f=this.safeNumber(n,"daily",u),p=this.safeNumber(n,"remaining_daily",f);let m;m=p>0?p:f;const g=this.safeString(a,"code"),y=this.safeCurrencyCode(g);return{info:i,id:g,code:y,name:y,active:l,fee:this.safeNumber(a,"withdraw_fee"),precision:void 0,limits:{withdraw:{min:this.safeNumber(n,"minimum"),max:m}}}}async fetchMarket(e,t={}){await this.loadMarkets();const s=this.market(e);return await this.fetchMarketById(s.id,t)}async fetchMarketById(e,t={}){const s={market:e},i=await this.privateGetOrdersChance(this.extend(s,t)),r=this.safeValue(i,"market"),a=this.safeValue(r,"bid"),n=this.safeValue(r,"ask"),o=this.safeString(r,"id"),d=this.safeString(n,"currency"),h=this.safeString(a,"currency"),c=this.safeCurrencyCode(d),l=this.safeCurrencyCode(h),u=this.safeString(r,"state"),f=this.safeNumber(i,"bid_fee"),p=this.safeNumber(i,"ask_fee"),m=Math.max(f,p);return{id:o,symbol:c+"/"+l,base:c,quote:l,settle:void 0,baseId:d,quoteId:h,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:"active"===u,contract:!1,linear:void 0,inverse:void 0,taker:m,maker:m,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber("1e-8"),price:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_total"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(a,"min_total"),max:this.safeNumber(r,"max_total")},info:i}}}async fetchMarkets(e={}){const t=await this.publicGetMarketAll(e),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"market"),[a,n]=r.split("-"),o=this.safeCurrencyCode(n),d=this.safeCurrencyCode(a);s.push({id:r,symbol:o+"/"+d,base:o,quote:d,settle:void 0,baseId:n,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,d,this.fees.trading.taker),maker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,d,this.fees.trading.maker),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{price:this.parseNumber("1e-8"),amount:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.free=this.safeString(i,"balance"),n.used=this.safeString(i,"locked"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetAccounts(e);return this.parseBalance(t)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join(","),i.length>this.options.fetchOrderBooksMaxLength){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols ("+i.length.toString()+" characters) exceeding max URL length ("+this.options.fetchOrderBooksMaxLength.toString()+" characters), you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join(",");const a={markets:i},n=await this.publicGetOrderbook(this.extend(a,s)),o={};for(let e=0;e<n.length;e++){const t=n[e],s=this.safeString(t,"market"),i=this.safeSymbol(s,void 0,"-"),r=this.safeInteger(t,"timestamp");o[i]={symbol:i,bids:this.sortBy(this.parseBidsAsks(t.orderbook_units,"bid_price","bid_size"),0,!0),asks:this.sortBy(this.parseBidsAsks(t.orderbook_units,"ask_price","ask_size"),0),timestamp:r,datetime:this.iso8601(r),nonce:void 0}}return o}async fetchOrderBook(e,t=undefined,s={}){const i=await this.fetchOrderBooks([e],t,s);return this.safeValue(i,e)}parseTicker(e,t=undefined){const s=this.safeInteger(e,"trade_timestamp"),i=this.safeString2(e,"market","code");t=this.safeMarket(i,t,"-");const r=this.safeString(e,"trade_price");return this.safeTicker({symbol:t.symbol,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high_price"),low:this.safeString(e,"low_price"),bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:this.safeString(e,"opening_price"),close:r,last:r,previousClose:this.safeString(e,"prev_closing_price"),change:this.safeString(e,"signed_change_price"),percentage:this.safeString(e,"signed_change_rate"),average:void 0,baseVolume:this.safeString(e,"acc_trade_volume_24h"),quoteVolume:this.safeString(e,"acc_trade_price_24h"),info:e},t)}async fetchTickers(e=undefined,t={}){let s;if(await this.loadMarkets(),void 0===(e=this.marketSymbols(e))){if(s=this.ids.join(","),s.length>this.options.fetchTickersMaxLength){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchTickers() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchTickers")}}else s=this.marketIds(e),s=s.join(",");const i={markets:s},a=await this.publicGetTicker(this.extend(i,t)),n={};for(let e=0;e<a.length;e++){const t=this.parseTicker(a[e]);n[t.symbol]=t}return this.filterByArrayTickers(n,"symbol",e)}async fetchTicker(e,t={}){const s=await this.fetchTickers([e],t);return this.safeValue(s,e)}parseTrade(e,t=undefined){const s=this.safeString2(e,"sequential_id","uuid");let i,r=this.safeInteger(e,"timestamp");void 0===r&&(r=this.parse8601(this.safeString(e,"created_at")));const a=this.safeStringLower2(e,"ask_bid","side");"ask"===a?i="sell":"bid"===a&&(i="buy");const n=this.safeString(e,"funds"),o=this.safeString2(e,"trade_price","price"),d=this.safeString2(e,"trade_volume","volume"),h=this.safeString2(e,"market","code");let c;t=this.safeMarket(h,t,"-");const l=this.safeString(e,a+"_fee");return void 0!==l&&(c={currency:t.quote,cost:l}),this.safeTrade({id:s,info:e,order:undefined,timestamp:r,datetime:this.iso8601(r),symbol:t.symbol,type:void 0,side:i,takerOrMaker:void 0,price:o,amount:d,cost:n,fee:c},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e);void 0===s&&(s=200);const a={market:r.id,count:s},n=await this.publicGetTradesTicks(this.extend(a,i));return this.parseTrades(n,r,t,s)}async fetchTradingFee(e,t={}){await this.loadMarkets();const s={market:this.market(e).id},i=await this.privateGetOrdersChance(this.extend(s,t)),r=this.safeString(i,"ask_fee"),n=this.safeString(i,"bid_fee"),o=a.O.stringMax(r,n),d=this.safeString(i,"maker_ask_fee"),h=this.safeString(i,"maker_bid_fee"),c=a.O.stringMax(d,h);return{info:i,symbol:e,maker:this.parseNumber(c),taker:this.parseNumber(o),percentage:!0,tierBased:!1}}parseOHLCV(e,t=undefined){return[this.parse8601(this.safeString(e,"candle_date_time_utc")),this.safeNumber(e,"opening_price"),this.safeNumber(e,"high_price"),this.safeNumber(e,"low_price"),this.safeNumber(e,"trade_price"),this.safeNumber(e,"candle_acc_trade_volume")]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n=this.parseTimeframe(t),o=this.safeString(this.timeframes,t,t);void 0===i&&(i=200);const d={market:a.id,timeframe:o,count:i};let h="publicGetCandlesTimeframe";if("minutes"===o){const e=Math.round(n/60);d.unit=e,h+="Unit"}void 0!==s&&(d.to=this.iso8601(this.sum(s,n*i*1e3)));const c=await this[h](this.extend(d,r));return this.parseOHLCVs(c,a,t,s,i)}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t&&"buy"===s&&this.options.createMarketBuyOrderRequiresPrice){if(void 0===a)throw new r.InvalidOrder(this.id+' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');i*=a}let o;if("buy"===s)o="bid";else{if("sell"!==s)throw new r.InvalidOrder(this.id+" createOrder() allows buy or sell side only!");o="ask"}await this.loadMarkets();const d={market:this.market(e).id,side:o};"limit"===t?(d.volume=this.amountToPrecision(e,i),d.price=this.priceToPrecision(e,a),d.ord_type=t):"market"===t&&("buy"===s?(d.ord_type="price",d.price=this.priceToPrecision(e,i)):"sell"===s&&(d.ord_type=t,d.volume=this.amountToPrecision(e,i)));const h=this.safeString2(n,"clientOrderId","identifier");void 0!==h&&(d.identifier=h),n=this.omit(n,["clientOrderId","identifier"]);const c=await this.privatePostOrders(this.extend(d,n));return this.parseOrder(c)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={uuid:e},r=await this.privateDeleteOrder(this.extend(i,s));return this.parseOrder(r)}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==s&&(r.limit=s);const n=await this.privateGetDeposits(this.extend(r,i));return this.parseTransactions(n,a,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==s&&(r.limit=s);const n=await this.privateGetWithdraws(this.extend(r,i));return this.parseTransactions(n,a,t,s)}parseTransactionStatus(e){return this.safeString({submitting:"pending",submitted:"pending",almost_accepted:"pending",rejected:"failed",accepted:"pending",processing:"pending",done:"ok",canceled:"canceled"},e,e)}parseTransaction(e,t=undefined){const s=this.safeString(e,"uuid"),i=this.safeNumber(e,"amount"),r=this.safeString(e,"txid"),a=this.safeString(e,"done_at"),n=this.parse8601(a),o=this.parse8601(this.safeString(e,"created_at",a));let d=this.safeString(e,"type");"withdraw"===d&&(d="withdrawal");const h=this.safeString(e,"currency"),c=this.safeCurrencyCode(h),l=this.parseTransactionStatus(this.safeStringLower(e,"state")),u=this.safeNumber(e,"fee");return{info:e,id:s,currency:c,amount:i,network:void 0,address:undefined,addressTo:void 0,addressFrom:void 0,tag:undefined,tagTo:void 0,tagFrom:void 0,status:l,type:d,updated:n,txid:r,timestamp:o,datetime:this.iso8601(o),fee:{currency:c,cost:u}}}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"uuid");let i=this.safeString(e,"side");i="bid"===i?"buy":"sell";let r=this.safeString(e,"ord_type");const n=this.parse8601(this.safeString(e,"created_at")),o=this.parseOrderStatus(this.safeString(e,"state"));let d,h=this.safeString(e,"price");const c=this.safeString(e,"volume"),l=this.safeString(e,"remaining_volume"),u=this.safeString(e,"executed_volume");let f,p,m;"price"===r&&(r="market",f=h,h=void 0);let g=this.safeString(e,"paid_fee");const y=this.safeString(e,"market");t=this.safeMarket(y,t);let v=this.safeValue(e,"trades",[]);v=this.parseTrades(v,t,void 0,void 0,{order:s,type:r});const b=v.length;if(b>0){d=v[b-1].timestamp;let e=!1;void 0===g&&(e=!0,g="0"),f="0";for(let t=0;t<b;t++){const s=v[t];if(f=a.O.stringAdd(f,this.safeString(s,"cost")),e){const e=this.safeValue(v[t],"fee",{}),s=this.safeString(e,"cost");void 0!==s&&(g=a.O.stringAdd(g,s))}}p=a.O.stringDiv(f,u)}return void 0!==g&&(m={currency:t.quote,cost:g}),this.safeOrder({info:e,id:s,clientOrderId:void 0,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:d,symbol:t.symbol,type:r,timeInForce:void 0,postOnly:void 0,side:i,price:h,stopPrice:void 0,triggerPrice:void 0,cost:this.parseNumber(f),average:this.parseNumber(p),amount:c,filled:u,remaining:l,status:o,fee:m,trades:v})}async fetchOrdersByState(e,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={state:e};let n;void 0!==t&&(n=this.market(t),a.market=n.id);const o=await this.privateGetOrders(this.extend(a,r));return this.parseOrders(o,n,s,i)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("wait",e,t,s,i)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("done",e,t,s,i)}async fetchCanceledOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("cancel",e,t,s,i)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={uuid:e},r=await this.privateGetOrder(this.extend(i,s));return this.parseOrder(r)}async fetchDepositAddresses(e=undefined,t={}){await this.loadMarkets();const s=await this.privateGetDepositsCoinAddresses(t);return this.parseDepositAddresses(s,e)}parseDepositAddress(e,t=undefined){const s=this.safeString(e,"deposit_address"),i=this.safeString(e,"secondary_address"),r=this.safeString(e,"currency"),a=this.safeCurrencyCode(r);return this.checkAddress(s),{currency:a,address:s,tag:i,network:void 0,info:e}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i=await this.privateGetDepositsCoinAddress(this.extend({currency:s.id},t));return this.parseDepositAddress(i)}async createDepositAddress(e,t={}){await this.loadMarkets();const s={currency:this.currency(e).id},i=await this.privatePostDepositsGenerateCoinAddress(this.extend(s,t));if(void 0!==this.safeString(i,"message"))throw new r.AddressPending(this.id+" is generating "+e+" deposit address, call fetchDepositAddress or createDepositAddress one more time later to retrieve the generated address");return this.parseDepositAddress(i)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e),o={amount:t};let d="privatePostWithdraws";if("KRW"!==e){const e=this.safeStringUpper2(a,"network","net_type");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a network argument");a=this.omit(a,["network"]),o.net_type=e,d+="Coin",o.currency=n.id,o.address=s,void 0!==i&&(o.secondary_address=i),a=this.omit(a,"network")}else d+="Krw";const h=await this[d](this.extend(o,a));return this.parseTransaction(h)}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.implodeParams(this.urls.api[t],{hostname:this.hostname});n+="/"+this.version+"/"+this.implodeParams(e,i);const c=this.omit(i,this.extractParams(e));if("POST"!==s&&Object.keys(c).length&&(n+="?"+this.urlencode(c)),"private"===t){this.checkRequiredCredentials();const e=this.nonce(),t={access_key:this.apiKey,nonce:e};if(Object.keys(c).length){const e=this.urlencode(c),s=this.hash(this.encode(e),o.o);t.query_hash=s,t.query_hash_alg="SHA512"}r={Authorization:"Bearer "+(0,h.F)(t,this.encode(this.secret),d.J)},"GET"!==s&&"DELETE"!==s&&(a=this.json(i),r["Content-Type"]="application/json")}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.safeValue(o,"error");if(void 0!==c){const e=this.safeString(c,"message"),t=this.safeString(c,"name"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,e,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}},3853:(e,t,s)=>{s.d(t,{Z:()=>h});var i=s(8888),r=s(6689),a=s(2194),n=s(8817),o=s(6890),d=s(9292);class h extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"wavesexchange",name:"Waves.Exchange",countries:["CH"],certified:!0,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createMarketOrder:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchDepositAddress:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,signIn:!0,transfer:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","3h":"3h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg",test:{matcher:"https://matcher-testnet.wx.network",node:"https://nodes-testnet.wavesnodes.com",public:"https://api-testnet.wavesplatform.com/v0",private:"https://api-testnet.wx.network/v1",forward:"https://testnet.wx.network/api/v1/forward/matcher",market:"https://testnet.wx.network/api/v1/forward/marketdata/api/v1"},api:{matcher:"https://matcher.wx.network",node:"https://nodes.wx.network",public:"https://api.wavesplatform.com/v0",private:"https://api.wx.network/v1",forward:"https://wx.network/api/v1/forward/matcher",market:"https://wx.network/api/v1/forward/marketdata/api/v1"},doc:"https://docs.wx.network",www:"https://wx.network"},api:{matcher:{get:["matcher","matcher/settings","matcher/settings/rates","matcher/balance/reserved/{publicKey}","matcher/debug/allSnashotOffsets","matcher/debug/currentOffset","matcher/debug/lastOffset","matcher/debug/oldestSnapshotOffset","matcher/debug/config","matcher/debug/address/{address}","matcher/debug/status","matcher/debug/address/{address}/check","matcher/orderbook","matcher/orderbook/{baseId}/{quoteId}","matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}","matcher/orderbook/{baseId}/{quoteId}/{orderId}","matcher/orderbook/{baseId}/{quoteId}/info","matcher/orderbook/{baseId}/{quoteId}/status","matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}","matcher/orderbook/{publicKey}","matcher/orderbook/{publicKey}/{orderId}","matcher/orders/{address}","matcher/orders/{address}/{orderId}","matcher/transactions/{orderId}","api/v1/orderbook/{baseId}/{quoteId}"],post:["matcher/orderbook","matcher/orderbook/market","matcher/orderbook/cancel","matcher/orderbook/{baseId}/{quoteId}/cancel","matcher/orderbook/{baseId}/{quoteId}/calculateFee","matcher/orderbook/{baseId}/{quoteId}/delete","matcher/orderbook/{baseId}/{quoteId}/cancelAll","matcher/debug/saveSnapshots","matcher/orders/{address}/cancel","matcher/orders/cancel/{orderId}","matcher/orders/serialize"],delete:["matcher/orderbook/{baseId}/{quoteId}","matcher/settings/rates/{assetId}"],put:["matcher/settings/rates/{assetId}"]},node:{get:["addresses","addresses/balance/{address}","addresses/balance/{address}/{confirmations}","addresses/balance/details/{address}","addresses/data/{address}","addresses/data/{address}/{key}","addresses/effectiveBalance/{address}","addresses/effectiveBalance/{address}/{confirmations}","addresses/publicKey/{publicKey}","addresses/scriptInfo/{address}","addresses/scriptInfo/{address}/meta","addresses/seed/{address}","addresses/seq/{from}/{to}","addresses/validate/{address}","alias/by-address/{address}","alias/by-alias/{alias}","assets/{assetId}/distribution/{height}/{limit}","assets/balance/{address}","assets/balance/{address}/{assetId}","assets/details/{assetId}","assets/nft/{address}/limit/{limit}","blockchain/rewards","blockchain/rewards/height","blocks/address/{address}/{from}/{to}/","blocks/at/{height}","blocks/delay/{signature}/{blockNum}","blocks/first","blocks/headers/last","blocks/headers/seq/{from}/{to}","blocks/height","blocks/height/{signature}","blocks/last","blocks/seq/{from}/{to}","blocks/signature/{signature}","consensus/algo","consensus/basetarget","consensus/basetarget/{blockId}","consensus/{generatingbalance}/address","consensus/generationsignature","consensus/generationsignature/{blockId}","debug/balances/history/{address}","debug/blocks/{howMany}","debug/configInfo","debug/historyInfo","debug/info","debug/minerInfo","debug/portfolios/{address}","debug/state","debug/stateChanges/address/{address}","debug/stateChanges/info/{id}","debug/stateWaves/{height}","leasing/active/{address}","node/state","node/version","peers/all","peers/blacklisted","peers/connected","peers/suspended","transactions/address/{address}/limit/{limit}","transactions/info/{id}","transactions/status","transactions/unconfirmed","transactions/unconfirmed/info/{id}","transactions/unconfirmed/size","utils/seed","utils/seed/{length}","utils/time","wallet/seed"],post:["addresses","addresses/data/{address}","addresses/sign/{address}","addresses/signText/{address}","addresses/verify/{address}","addresses/verifyText/{address}","debug/blacklist","debug/print","debug/rollback","debug/validate","node/stop","peers/clearblacklist","peers/connect","transactions/broadcast","transactions/calculateFee","tranasctions/sign","transactions/sign/{signerAddress}","tranasctions/status","utils/hash/fast","utils/hash/secure","utils/script/compileCode","utils/script/compileWithImports","utils/script/decompile","utils/script/estimate","utils/sign/{privateKey}","utils/transactionsSerialize"],delete:["addresses/{address}","debug/rollback-to/{signature}"]},public:{get:["assets","pairs","candles/{baseId}/{quoteId}","transactions/exchange"]},private:{get:["deposit/addresses/{currency}","deposit/addresses/{currency}/{platform}","platforms","deposit/currencies","withdraw/currencies","withdraw/addresses/{currency}/{address}"],post:["oauth2/token"]},forward:{get:["matcher/orders/{address}","matcher/orders/{address}/{orderId}"],post:["matcher/orders/{wavesAddress}/cancel"]},market:{get:["tickers"]}},currencies:{WX:this.safeCurrencyStructure({id:"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",numericId:void 0,code:"WX",precision:this.parseNumber("8")})},precisionMode:d.nr,options:{allowedCandles:1440,accessToken:void 0,createMarketBuyOrderRequiresPrice:!0,matcherPublicKey:void 0,quotes:void 0,createOrderDefaultExpiry:24192e5,wavesAddress:void 0,withdrawFeeUSDN:7420,withdrawFeeWAVES:1e5,wavesPrecision:8,messagePrefix:"W",networks:{ERC20:"ETH",BEP20:"BSC"}},commonCurrencies:{EGG:"Waves Ducks"},requiresEddsa:!0,exceptions:{3147270:r.InsufficientFunds,112:r.InsufficientFunds,4:r.ExchangeError,13:r.ExchangeNotAvailable,14:r.ExchangeNotAvailable,3145733:r.AccountSuspended,3148040:r.DuplicateOrderId,3148801:r.AuthenticationError,9440512:r.AuthenticationError,9440771:r.BadSymbol,9441026:r.InvalidOrder,9441282:r.InvalidOrder,9441286:r.InvalidOrder,9441295:r.InvalidOrder,9441540:r.InvalidOrder,9441542:r.InvalidOrder,106954752:r.AuthenticationError,106954769:r.AuthenticationError,106957828:r.AuthenticationError,106960131:r.AuthenticationError,106981137:r.AuthenticationError,9437184:r.BadRequest,9437193:r.OrderNotFound,1048577:r.BadRequest,1051904:r.AuthenticationError}})}setSandboxMode(e){this.options.messagePrefix=e?"T":"W",this.options.sandboxMode=e,super.setSandboxMode(e)}async getFeesForAsset(e,t,s,i,r={}){await this.loadMarkets();const a=this.market(e);s=this.customAmountToPrecision(e,s),i=this.customPriceToPrecision(e,i);const n=this.extend({baseId:a.baseId,quoteId:a.quoteId,orderType:t,amount:s,price:i},r);return await this.matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee(n)}async customCalculateFee(e,t,s,i,r,n="taker",o={}){const d=await this.getFeesForAsset(e,s,i,r);let h;h=this.safeValue(o,"isDiscountFee",!1)?this.safeValue(d,"discount"):this.safeValue(d,"base");const c=this.safeString(h,"matcherFee"),l=this.safeString(h,"feeAssetId"),u=this.safeCurrencyCode(l),f=this.currencyFromPrecision(u,c),p=this.numberToString(i),m=this.numberToString(r),g=this.feeToPrecision(e,this.parseNumber(f)),y=a.O.stringDiv(f,a.O.stringMul(p,m));return{type:n,currency:u,rate:this.parseNumber(y),cost:this.parseNumber(g)}}async getQuotes(){let e=this.safeValue(this.options,"quotes");if(e)return e;{const t=await this.matcherGetMatcherSettings();e={};const s=this.safeValue(t,"priceAssets");for(let t=0;t<s.length;t++)e[s[t]]=!0;return this.options.quotes=e,e}}async fetchMarkets(e={}){const t=await this.marketGetTickers(),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"amountAssetID"),a=this.safeString(i,"priceAssetID"),n=r+"/"+a,o=this.safeString(i,"symbol");let[d,h]=o.split("/");d=this.safeCurrencyCode(d),h=this.safeCurrencyCode(h);const c=d+"/"+h;s.push({id:n,symbol:c,base:d,quote:h,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,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.safeInteger(i,"amountAssetDecimals"),price:this.safeInteger(i,"priceAssetDecimals")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r=this.extend({baseId:i.baseId,quoteId:i.quoteId},s),a=await this.matcherGetMatcherOrderbookBaseIdQuoteId(r),n=this.safeInteger(a,"timestamp");return{symbol:e,bids:this.parseOrderBookSide(this.safeValue(a,"bids"),i,t),asks:this.parseOrderBookSide(this.safeValue(a,"asks"),i,t),timestamp:n,datetime:this.iso8601(n),nonce:void 0}}parseOrderBookSide(e,t=undefined,s=undefined){const i=t.precision,r=this.safeString(this.options,"wavesPrecision","8"),n="1e"+this.numberToString(i.amount),o=this.numberToString(i.amount),d=this.numberToString(i.price),h=a.O.stringSub(o,d),c="1e"+a.O.stringSub(r,h),l=[];for(let t=0;t<e.length;t++){const i=e[t],r=this.safeString(i,"price","0"),o=this.safeString(i,"amount","0");let d,h;if(void 0!==c&&void 0!==r&&(d=a.O.stringDiv(r,c)),void 0!==n&&void 0!==o&&(h=a.O.stringDiv(o,n)),void 0!==s&&t>s)break;l.push([this.parseNumber(d),this.parseNumber(h)])}return l}checkRequiredKeys(){if(void 0===this.apiKey)throw new r.AuthenticationError(this.id+" requires apiKey credential");if(void 0===this.secret)throw new r.AuthenticationError(this.id+" requires secret credential");let e,t;try{e=this.base58ToBinary(this.apiKey)}catch(e){throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key")}try{t=this.base58ToBinary(this.secret)}catch(e){throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}const s=this.binaryToBase16(e),i=this.binaryToBase16(t);if(64!==s.length)throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key");if(64!==i.length)throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=this.omit(i,this.extractParams(e)),o="matcher/orders/{wavesAddress}/cancel"===e;e=this.implodeParams(e,i);let d=this.urls.api[t]+"/"+e,h=this.urlencodeWithArrayRepeat(n);if("private"===t||"forward"===t){r={Accept:"application/json"};const e=this.safeString(this.options,"accessToken");e&&(r.Authorization="Bearer "+e),r["content-type"]="POST"===s?"application/json":"application/x-www-form-urlencoded",o&&(a=this.json([n.orderId]),h=""),h.length>0&&(d+="?"+h)}else"matcher"===t?"POST"===s?(r={Accept:"application/json","Content-Type":"application/json"},a=this.json(n)):r=n:"POST"===s?(r={"content-type":"application/json"},a=this.json(n)):(r={"content-type":"application/x-www-form-urlencoded"},h.length>0&&(d+="?"+h));return{url:d,method:s,body:a,headers:r}}async signIn(e={}){if(!this.safeString(this.options,"accessToken")){const e="ffffff01",t=604800;let s=this.sum(this.seconds(),t);s=s.toString();const i="wx.network",r=this.safeString(this.options,"messagePrefix","W")+":"+i+":"+s,a=e+this.binaryToBase16(this.encode(r)),d=this.binaryToBase16(this.base58ToBinary(this.secret)),h=(0,o.gC)(a,d,n.UN),c={grant_type:"password",scope:"general",username:this.apiKey,password:s+":"+h,client_id:i},l=await this.privatePostOauth2Token(c);return this.options.accessToken=this.safeString(l,"access_token"),this.options.accessToken}}parseTicker(e,t=undefined){const s=this.safeInteger(e,"timestamp"),i=this.safeString(e,"symbol"),r=(t=this.safeMarket(i,t,"/")).symbol,a=this.safeString2(e,"24h_close","lastPrice"),n=this.safeString2(e,"24h_low","low"),o=this.safeString2(e,"24h_high","high"),d=this.safeString2(e,"24h_vwap","weightedAveragePrice"),h=this.safeString2(e,"24h_volume","volume"),c=this.safeString2(e,"24h_priceVolume","quoteVolume"),l=this.safeString2(e,"24h_open","firstPrice");return this.safeTicker({symbol:r,timestamp:s,datetime:this.iso8601(s),high:o,low:n,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:d,open:l,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:h,quoteVolume:c,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={pairs:s.id},r=await this.publicGetPairs(this.extend(i,t)),a=this.safeValue(r,"data",[]),n=this.safeValue(a,0,{}),o=this.safeValue(n,"data",{});return this.parseTicker(o,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=await this.marketGetTickers(t);return this.parseTickers(s,e)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={baseId:a.baseId,quoteId:a.quoteId,interval:this.safeString(this.timeframes,t,t)},o=this.safeInteger(this.options,"allowedCandles",1440);void 0===i&&(i=o),i=Math.min(o,i);const d=1e3*this.parseTimeframe(t);if(void 0===s){const e=this.parseToInt(this.milliseconds()/d)*d-(i-1)*d;n.timeStart=e.toString()}else{n.timeStart=s.toString();const e=this.sum(s,d*i);n.timeEnd=e.toString()}const h=await this.publicGetCandlesBaseIdQuoteId(this.extend(n,r)),c=this.safeValue(h,"data",[]);let l,u=this.parseOHLCVs(c,a,t,s,i);u=this.filterFutureCandles(u);const f=u.length;for(let e=0;e<u.length;e++){const t=f-e-1,s=u[t];void 0===s[1]&&(s[1]=l,s[2]=l,s[3]=l,s[4]=l,u[t]=s),l=s[4]}return u}filterFutureCandles(e){const t=[],s=this.milliseconds();for(let i=0;i<e.length&&!(e[i][0]>s);i++)t.push(e[i]);return t}parseOHLCV(e,t=undefined){const s=this.safeValue(e,"data",{});return[this.parse8601(this.safeString(s,"time")),this.safeNumber(s,"open"),this.safeNumber(s,"high"),this.safeNumber(s,"low"),this.safeNumber(s,"close"),this.safeNumber(s,"volume",0)]}async fetchDepositAddress(e,t={}){await this.signIn();const s=this.safeValue(this.options,"networks",{}),i=this.safeStringUpper(t,"network"),a=this.safeString(s,i,i);t=this.omit(t,["network"]);const n=await this.privateGetPlatforms(),o={},d={},h=this.safeValue(n,"items",[]);for(let e=0;e<h.length;e++){const t=h[e],s=this.safeString(t,"id"),i=this.safeValue(t,"currencies",[]);for(let e=0;e<i.length;e++){const t=this.safeString(i,e);o[t]=!0,t in d||(d[t]={}),d[t][s]=!0}}if(!(e in o)){const t=Object.keys(o);throw new r.ExchangeError(this.id+" fetchDepositAddress() "+e+" not supported. Currency code must be one of "+t.join(", "))}let c;if(void 0===a){const s={currency:e};c=await this.privateGetDepositAddressesCurrency(this.extend(s,t))}else{const s=d[e];if(!(a in s)){const t=Object.keys(s);throw new r.ExchangeError(this.id+" "+a+" network "+e+" deposit address not supported. Network must be one of "+t.join(", "))}if("WAVES"===a){const t={publicKey:this.apiKey},s=await this.nodeGetAddressesPublicKeyPublicKey(this.extend(t,t));return{address:this.safeString(c,"address"),code:e,currency:e,network:a,tag:void 0,info:s}}{const s={currency:e,platform:a};c=await this.privateGetDepositAddressesCurrencyPlatform(this.extend(s,t))}}const l=this.safeValue(c,"currency"),u=this.safeString(l,"platform_id"),f=this.safeValue(this.options,"networkByIds",{}),p=this.safeString(f,u,u),m=this.safeValue(c,"deposit_addresses");return{address:this.safeString(m,0),code:e,currency:e,tag:void 0,network:p,info:c}}async getMatcherPublicKey(){const e=this.safeString(this.options,"matcherPublicKey");if(e)return e;{const e=await this.matcherGetMatcher();return this.options.matcherPublicKey=e.slice(1,e.length-1),this.options.matcherPublicKey}}getAssetBytes(e){return"WAVES"===e?this.numberToBE(0,1):this.binaryConcat(this.numberToBE(1,1),this.base58ToBinary(e))}getAssetId(e){return"WAVES"===e?"":e}customPriceToPrecision(e,t){const s=this.markets[e],i=this.safeString(this.options,"wavesPrecision","8"),r=this.numberToString(s.precision.amount),n=this.numberToString(s.precision.price),o=a.O.stringSub(r,n),d=a.O.stringSub(i,o),h=this.toPrecision(t,d).toString();return this.parseToInt(parseFloat(h))}customAmountToPrecision(e,t){const s=this.numberToString(this.toPrecision(t,this.numberToString(this.markets[e].precision.amount)));return this.parseToInt(parseFloat(s))}currencyToPrecision(e,t,s=undefined){const i=this.numberToString(this.toPrecision(t,this.currencies[e].precision));return this.parseToInt(parseFloat(i))}fromPrecision(e,t){if(void 0===e)return;const s=new a.O(e);return s.decimals=this.sum(s.decimals,t),s.reduce(),s.toString()}toPrecision(e,t){const s=this.numberToString(e),i=new a.O(s);return i.decimals=this.parseToInt(a.O.stringSub(this.numberToString(i.decimals),this.numberToString(t))),i.reduce(),i}currencyFromPrecision(e,t){const s=this.currencies[e].precision;return this.fromPrecision(t,s)}priceFromPrecision(e,t){const s=this.markets[e],i=this.safeInteger(this.options,"wavesPrecision",8),r=this.sum(i,s.precision.price)-s.precision.amount;return this.fromPrecision(t,r)}safeGetDynamic(e){const t=this.safeValue(e,"orderFee");return"dynamic"in t?this.safeValue(t,"dynamic"):this.safeValue(t.composite.default,"dynamic")}safeGetRates(e){const t=this.safeValue(e,"rates");return void 0===t?{WAVES:1}:t}async createOrder(e,t,s,i,a=undefined,d={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const h=this.market(e),c=await this.getMatcherPublicKey(),l=this.getAssetId(h.baseId),u=this.getAssetId(h.quoteId),f="market"===t,p=this.safeFloat2(d,"triggerPrice","stopPrice"),m=void 0!==p;if(f&&void 0===a)throw new r.InvalidOrder(this.id+" createOrder() requires a price argument for "+t+" orders to determine the max price for buy and the min price for sell");const g=this.milliseconds(),y=this.safeInteger(this.options,"createOrderDefaultExpiry",24192e5),v=this.sum(g,y),b=await this.getFeesForAsset(e,s,i,a),w=this.safeValue2(b,"base","discount"),S=this.safeString(w,"feeAssetId"),k=this.safeCurrencyCode(S),O=this.safeString(w,"matcherFee"),T=this.safeValue(b,"discount"),I=this.safeString(T,"feeAssetId"),x=this.safeCurrencyCode(I),P=this.safeString(T,"matcherFee");let M,A;if("feeAsset"in d||"feeAsset"in this.options){const e=this.safeString(d,"feeAsset",this.safeString(this.options,"feeAsset")),t=this.currency(e);M=this.safeString(t,"id")}const C=await this.fetchBalance();if(void 0!==M){if(S!==M&&I!==M)throw new r.InvalidOrder(this.id+" asset fee must be "+k+" or "+x);const e=this.safeCurrencyCode(M),t=M===S?O:P,s=parseFloat(this.currencyFromPrecision(e,t));if(!(e in C&&C[e].free>=s))throw new r.InsufficientFunds(this.id+" not enough funds of the selected asset fee");A=parseInt(t)}if(void 0===M){const e=parseFloat(this.currencyFromPrecision(k,O));if(k in C&&C[k].free>=e)M=S,A=parseInt(O);else{const e=parseFloat(this.currencyFromPrecision(x,P));x in C&&C[x].free>=e&&(M=I,A=parseInt(P))}}if(void 0===M)throw new r.InsufficientFunds(this.id+" not enough funds on none of the eligible asset fees");i=this.customAmountToPrecision(e,i),a=this.customPriceToPrecision(e,a);const E={amountAsset:l,priceAsset:u},_=this.safeValue(this.options,"sandboxMode",!1)?84:87,B={senderPublicKey:this.apiKey,matcherPublicKey:c,assetPair:E,orderType:s,price:a,amount:i,timestamp:g,expiration:v,matcherFee:parseInt(A),priceMode:"assetDecimals",version:4,chainId:_};if(m){const t={v:1,c:{t:"sp",v:{p:this.customPriceToPrecision(e,p)}}};B.attachment=this.binaryToBase58(this.encode(JSON.stringify(t)))}"WAVES"!==M&&(B.matcherFeeAssetId=M);let N=await this.matcherPostMatcherOrdersSerialize(B);'"'===N[0]&&'"'===N[N.length-1]&&(N=N.slice(1,N.length-1));const V=(0,o.gC)(this.binaryToBase16(this.base58ToBinary(N)),this.binaryToBase16(this.base58ToBinary(this.secret)),n.UN);if(B.signature=V,f){const e=await this.matcherPostMatcherOrderbookMarket(B),t=this.safeValue(e,"message");return this.parseOrder(t,h)}{const e=await this.matcherPostMatcherOrderbook(B),t=this.safeValue(e,"message");return this.parseOrder(t,h)}}async cancelOrder(e,t=undefined,s={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.signIn();const i=await this.getWavesAddress(),r=await this.forwardPostMatcherOrdersWavesAddressCancel({wavesAddress:i,orderId:e}),a=this.safeValue(r,"message"),n=this.safeValue(a,0),o=this.safeValue(n,0);return{info:r,id:this.safeString(o,"orderId"),clientOrderId:void 0,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,symbol:t,type:void 0,side:void 0,price:void 0,amount:void 0,cost:void 0,average:void 0,filled:void 0,remaining:void 0,status:void 0,fee:void 0,trades:void 0}}async fetchOrder(e,t=undefined,s={}){let i;this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets(),void 0!==t&&(i=this.market(t));const r=this.milliseconds(),a=[this.base58ToBinary(this.apiKey),this.numberToBE(r,8)],d=this.binaryConcatArray(a),h=this.binaryToBase16(this.base58ToBinary(this.secret)),c=(0,o.gC)(this.binaryToBase16(d),h,n.UN),l={Timestamp:r.toString(),Signature:c,publicKey:this.apiKey,orderId:e},u=await this.matcherGetMatcherOrderbookPublicKeyOrderId(this.extend(l,s));return this.parseOrder(u,i)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(this.checkRequiredDependencies(),this.checkRequiredKeys(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires symbol argument");await this.loadMarkets();const a=this.market(e),d=this.milliseconds(),h=[this.base58ToBinary(this.apiKey),this.numberToBE(d,8)],c=this.binaryConcatArray(h),l=this.binaryToBase16(this.base58ToBinary(this.secret)),u=(0,o.gC)(this.binaryToBase16(c),l,n.UN),f={Accept:"application/json",Timestamp:d.toString(),Signature:u,publicKey:this.apiKey,baseId:a.baseId,quoteId:a.quoteId},p=await this.matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKey(this.extend(f,i));return this.parseOrders(p,a,t,s)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),activeOnly:!0},n=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(n,r,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),closedOnly:!0},n=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(n,r,t,s)}parseOrderStatus(e){return this.safeString({Cancelled:"canceled",Accepted:"open",Filled:"closed",PartiallyFilled:"open"},e,e)}getSymbolFromAssetPair(e){const t=this.safeString(e,"amountAsset","WAVES"),s=this.safeString(e,"priceAsset","WAVES");return this.safeCurrencyCode(t)+"/"+this.safeCurrencyCode(s)}parseOrder(e,t=undefined){const s=this.safeInteger(e,"timestamp"),i=this.safeString2(e,"type","orderType");let r="limit";"type"in e&&(r=this.safeString(e,"orderType",r));const a=this.safeString(e,"id"),n=this.safeString(e,"filled"),o=this.safeString(e,"price"),d=this.safeString(e,"amount"),h=this.safeValue(e,"assetPair");let c;void 0!==h?c=this.getSymbolFromAssetPair(h):void 0!==t&&(c=t.symbol);const l=this.safeCurrencyCode(this.safeString(h,"amountAsset","WAVES")),u=this.priceFromPrecision(c,o),f=this.currencyFromPrecision(l,d),p=this.currencyFromPrecision(l,n),m=this.priceFromPrecision(c,this.safeString(e,"avgWeighedPrice")),g=this.parseOrderStatus(this.safeString(e,"status"));let y,v;if("type"in e){const t=this.safeCurrencyCode(this.safeString(e,"feeAsset"));y={currency:t,fee:this.parseNumber(this.currencyFromPrecision(t,this.safeString(e,"filledFee")))}}else{const t=this.safeCurrencyCode(this.safeString(e,"matcherFeeAssetId","WAVES"));y={currency:t,fee:this.parseNumber(this.currencyFromPrecision(t,this.safeString(e,"matcherFee")))}}const b=this.safeString(e,"attachment");if(void 0!==b){const e=this.parseJson(this.decode(this.base58ToBinary(b)));if(void 0!==e){const t=this.safeValue(e,"c");if(void 0!==t){const e=this.safeValue(t,"v");void 0!==e&&(v=this.safeString(e,"p"))}}}return this.safeOrder({info:e,id:a,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,symbol:c,type:r,timeInForce:void 0,postOnly:void 0,side:i,price:u,stopPrice:v,triggerPrice:v,amount:f,cost:void 0,average:m,filled:p,remaining:void 0,status:g,fee:y,trades:void 0},t)}async getWavesAddress(){const e=this.safeString(this.options,"wavesAddress");if(void 0===e){const e={publicKey:this.apiKey},t=await this.nodeGetAddressesPublicKeyPublicKey(e);return this.options.wavesAddress=this.safeString(t,"address"),this.options.wavesAddress}return e}async fetchBalance(e={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const t=await this.getWavesAddress(),s={address:t},i=await this.nodeGetAssetsBalanceAddress(s),r=this.safeValue(i,"balances",[]),a={};let d;const h=[],c=[];for(let e=0;e<r.length;e++){const t=r[e],s=this.safeInteger(t,"timestamp");d=void 0===d?s:Math.max(d,s);const i=this.safeValue(t,"issueTransaction"),n=this.safeString(t,"assetId"),o=this.safeString(t,"balance");if(void 0===i){h.push(n),c.push(o);continue}const l=this.safeInteger(i,"decimals");let u;n in this.currencies_by_id&&(u=this.safeCurrencyCode(n),a[u]=this.account(),a[u].total=this.fromPrecision(o,l))}if(h.length){const e={ids:h},t=await this.publicGetAssets(e),s=this.safeValue(t,"data",[]);for(let e=0;e<s.length;e++){const t=s[e],i=c[e],r=this.safeValue(t,"data"),n=this.safeInteger(r,"precision"),o=this.safeString(r,"ticker"),d=this.safeCurrencyCode(o);a[d]=this.account(),a[d].total=this.fromPrecision(i,n)}}const l=this.milliseconds(),u=[this.base58ToBinary(this.apiKey),this.numberToBE(l,8)],f=this.binaryConcatArray(u),p=this.binaryToBase16(this.base58ToBinary(this.secret)),m=(0,o.gC)(this.binaryToBase16(f),p,n.UN),g={publicKey:this.apiKey,signature:m,timestamp:l.toString()},y=await this.matcherGetMatcherBalanceReservedPublicKey(g),v=Object.keys(y);for(let e=0;e<v.length;e++){const t=v[e],s=this.safeCurrencyCode(t);s in a||(a[s]=this.account());const i=this.safeString(y,t);s in this.currencies?a[s].used=this.currencyFromPrecision(s,i):a[s].used=i}const b={address:t},w=await this.nodeGetAddressesBalanceAddress(b);a.WAVES=this.safeValue(a,"WAVES",{}),a.WAVES.total=this.currencyFromPrecision("WAVES",this.safeString(w,"balance"));const S=Object.keys(a);for(let e=0;e<S.length;e++){const t=S[e];void 0===this.safeValue(a[t],"used")&&(a[t].used="0")}return a.timestamp=d,a.datetime=this.iso8601(d),this.safeBalance(a)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={sender:await this.getWavesAddress()};let a;void 0!==e&&(a=this.market(e),r.amountAsset=a.baseId,r.priceAsset=a.quoteId);const n=await this.publicGetTransactionsExchange(r),o=this.safeValue(n,"data");return this.parseTrades(o,a,t,s)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={amountAsset:r.baseId,priceAsset:r.quoteId};void 0!==s&&(a.limit=s),void 0!==t&&(a.timeStart=t);const n=await this.publicGetTransactionsExchange(a),o=this.safeValue(n,"data");return this.parseTrades(o,r,t,s)}parseTrade(e,t=undefined){const s=this.safeValue(e,"data"),i=this.safeString(s,"timestamp"),r=this.parse8601(i),a=this.safeString(s,"id"),n=this.safeString(s,"price"),o=this.safeString(s,"amount"),d=this.safeValue(s,"order1"),h=this.safeValue(s,"order2");let c,l;c=this.safeString(d,"senderPublicKey")===this.apiKey?d:h;const u=this.safeValue(c,"assetPair");void 0!==u?l=this.getSymbolFromAssetPair(u):void 0!==t&&(l=t.symbol);const f=this.safeString(c,"orderType"),p=this.safeString(c,"id"),m={cost:this.safeString(c,"matcherFee"),currency:this.safeCurrencyCode(this.safeString(c,"matcherFeeAssetId","WAVES"))};return this.safeTrade({info:e,timestamp:r,datetime:i,symbol:l,id:a,order:p,type:void 0,side:f,takerOrMaker:void 0,price:n,amount:o,cost:void 0,fee:m},t)}parseDepositWithdrawFees(e,t=undefined,s=undefined){const i={};t=this.marketCodes(t);for(let r=0;r<e.length;r++){const a=e[r],n=this.safeString(a,s),o=this.safeValue(this.currencies_by_id,n),d=this.safeString(o,"code",n);if(void 0===t||this.inArray(d,t)){let e=this.safeValue(i,d);void 0===e?e={info:[a],withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}}:(e=i[d],e.info=this.arrayConcat(e.info,[a]));const t=this.safeString(a,"platform_id"),s=this.safeString(o,"code"),r=this.networkIdToCode(t,s);let n=this.safeValue(e.networks,r);void 0===n&&(n={withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0}});const h=this.safeString(a,"type"),c=this.safeValue(a,"fees");let l="deposit";"withdrawal_currency"===h&&(l="withdraw"),n[l]={fee:this.safeNumber(c,"flat"),percentage:!1},e.networks[r]=n,i[d]=e}}const r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e],s=i[t],a=this.safeValue(s,"networks"),n=Object.keys(a);if(1===n.length){const e=this.safeValue(a,n[0]);i[t].withdraw=this.safeValue(e,"withdraw"),i[t].deposit=this.safeValue(e,"deposit")}}return i}async fetchDepositWithdrawFees(e=undefined,t={}){await this.loadMarkets();let s=[],i=[];i.push(this.privateGetDepositCurrencies(t)),i.push(this.privateGetWithdrawCurrencies(t)),i=await Promise.all(i);for(let e=0;e<i.length;e++){const t=this.safeValue(i[e],"items");s=this.arrayConcat(s,t)}return this.parseDepositWithdrawFees(s,e,"id")}handleErrors(e,t,s,i,a,n,o,d,h){const c=this.safeString(o,"error"),l=this.safeValue(o,"success",!0),u=this.safeValue(this.exceptions,c);if(void 0!==u){const e=this.safeString(o,"message");throw new u(this.id+" "+e)}if("Validation Error"===this.safeString(o,"message"))throw new r.BadRequest(this.id+" "+n);if(!l)throw new r.ExchangeError(this.id+" "+n)}async withdraw(e,t,s,i=undefined,a={}){if([i,a]=this.handleWithdrawTagAndParams(i,a),"WAVES"!==e){const t=await this.privateGetWithdrawCurrencies(),s={},i=this.safeValue(t,"items",[]);for(let e=0;e<i.length;e++){const t=i[e];s[this.safeString(t,"id")]=!0}if(!(e in s)){const t=Object.keys(s);throw new r.ExchangeError(this.id+" withdraw() "+e+" not supported. Currency code must be one of "+t.toString())}}await this.loadMarkets();const d=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],h={};for(let e=0;e<d.length;e++){h[d[e]]=!0}let c=!0;const l=this.remove0xPrefix(s).toLowerCase(),u=1*l.length;for(let e=0;e<u;e++){if(!(l[e]in h)){c=!1;break}}let f;if(await this.signIn(),"WAVES"!==e||c){const i={address:s,currency:e},a=await this.privateGetWithdrawAddressesCurrencyAddress(i),n=this.safeValue(a,"currency"),o=this.safeValue(n,"allowed_amount"),d=this.safeNumber(o,"min");if(t<=d)throw new r.BadRequest(this.id+" "+e+" withdraw failed, amount "+t.toString()+" must be greater than the minimum allowed amount of "+d.toString());const h=this.safeValue(a,"proxy_addresses",[]);f=this.safeString(h,0)}else f=s;const p=this.safeInteger(this.options,"withdrawFeeWAVES",1e5),m="WAVES",g=this.currencyToPrecision(e,t),y=this.currency(e),v=this.milliseconds(),b=[this.numberToBE(4,1),this.numberToBE(2,1),this.base58ToBinary(this.apiKey),this.getAssetBytes(y.id),this.getAssetBytes(m),this.numberToBE(v,8),this.numberToBE(g,8),this.numberToBE(p,8),this.base58ToBinary(f),this.numberToBE(0,2)],w=this.binaryConcatArray(b),S=this.binaryToBase16(this.base58ToBinary(this.secret)),k=(0,o.gC)(this.binaryToBase16(w),S,n.UN),O={senderPublicKey:this.apiKey,amount:g,fee:p,type:4,version:2,attachment:"",feeAssetId:this.getAssetId(m),proofs:[k],assetId:this.getAssetId(y.id),recipient:f,timestamp:v,signature:k},T=await this.nodePostTransactionsBroadcast(O);return this.parseTransaction(T,y)}parseTransaction(e,t=undefined){return{id:void 0,txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:(t=this.safeCurrency(void 0,t)).code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}}},6536:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(9564),r=s(6689),a=s(2194),n=s(9292),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"wazirx",name:"WazirX",countries:["IN"],version:"v2",rateLimit:1e3,pro:!0,has:{CORS:!1,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelAllOrders:!0,cancelOrder:!0,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchClosedOrders:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!1,transfer:!1,withdraw:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/148647666-c109c20b-f8ac-472f-91c3-5f658cb90f49.jpeg",api:{rest:"https://api.wazirx.com/sapi/v1"},www:"https://wazirx.com",doc:"https://docs.wazirx.com/#public-rest-api-for-wazirx",fees:"https://wazirx.com/fees",referral:"https://wazirx.com/invite/k7rrnks5"},api:{public:{get:{exchangeInfo:1,depth:1,ping:1,systemStatus:1,"tickers/24hr":1,"ticker/24hr":1,time:1,trades:1,klines:1}},private:{get:{account:1,allOrders:1,funds:1,historicalTrades:1,openOrders:1,order:.5,myTrades:.5},post:{order:.1,"order/test":.5},delete:{order:.1,openOrders:1}}},fees:{WRX:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.0")}},precisionMode:n.sh,exceptions:{exact:{"-1121":r.BadSymbol,1999:r.BadRequest,2002:r.InsufficientFunds,2005:r.BadRequest,2078:r.PermissionDenied,2098:r.BadRequest,2031:r.InvalidOrder,2113:r.BadRequest,2115:r.BadRequest,2136:r.RateLimitExceeded,94001:r.InvalidOrder}},timeframes:{"1m":"1m","5m":"5m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w"},options:{recvWindow:1e4}})}async fetchMarkets(e={}){const t=await this.publicGetExchangeInfo(e),s=this.safeValue(t,"symbols",[]),i=[];for(let e=0;e<s.length;e++){const t=s[e],r=this.safeString(t,"symbol"),n=this.safeString(t,"baseAsset"),o=this.safeString(t,"quoteAsset"),d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=this.safeValue(t,"isSpotTradingAllowed"),l=this.safeValue(t,"filters");let u;for(let e=0;e<l.length;e++){const t=l[e];"PRICE_FILTER"===this.safeString(t,"filterType")&&(u=this.safeNumber(t,"minPrice"))}const f=this.safeValue(this.fees,h,{});let p=this.safeString(f,"taker","0.2");p=a.O.stringDiv(p,"100");let m=this.safeString(f,"maker","0.2");m=a.O.stringDiv(m,"100");const g=this.safeString(t,"status");i.push({id:r,symbol:d+"/"+h,base:d,quote:h,settle:void 0,baseId:n,quoteId:o,settleId:void 0,type:"spot",spot:c,margin:!1,swap:!1,future:!1,option:!1,active:"trading"===g,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(p),maker:this.parseNumber(m),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(t,"baseAssetPrecision"))),price:this.parseNumber(this.parsePrecision(this.safeString(t,"quoteAssetPrecision")))},limits:{leverage:{min:void 0,max:void 0},price:{min:u,max:void 0},amount:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t})}return i}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.id,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.limit=i);const o=this.safeInteger(r,"until");r=this.omit(r,["until"]),void 0!==s&&(n.startTime=this.parseToInt(s/1e3)),void 0!==o&&(n.endTime=o);const d=await this.publicGetKlines(this.extend(n,r));return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={symbol:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.publicGetDepth(this.extend(i,s)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.publicGetTicker24hr(this.extend(i,t));return this.parseTicker(r,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=await this.publicGetTickers24hr(),i={};for(let e=0;e<s.length;e++){const t=s[e],r=this.parseTicker(t);i[r.symbol]=r}return this.filterByArrayTickers(i,"symbol",e)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==s&&(a.limit=Math.min(s,1e3));const n=this.safeString(this.options,"fetchTradesMethod","publicGetTrades"),o=await this[n](this.extend(a,i));return this.parseTrades(o,r,t,s)}parseTrade(e,t=undefined){const s=this.safeString(e,"id"),i=this.safeInteger(e,"time"),r=this.iso8601(i);t=this.safeMarket(void 0,t);const a=this.safeValue(e,"isBuyerMaker")?"sell":"buy",n=this.safeNumber(e,"price"),o=this.safeNumber(e,"qty"),d=this.safeNumber(e,"quoteQty");return this.safeTrade({info:e,id:s,timestamp:i,datetime:r,symbol:t.symbol,order:s,type:void 0,side:a,takerOrMaker:void 0,price:n,amount:o,cost:d,fee:void 0},t)}async fetchStatus(e={}){const t=await this.publicGetSystemStatus(e);return{status:"normal"===this.safeString(t,"status")?"ok":"maintenance",updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.publicGetTime(e);return this.safeInteger(t,"serverTime")}parseTicker(e,t=undefined){const s=this.safeString(e,"symbol"),i=(t=this.safeMarket(s,t)).symbol,r=this.safeString(e,"lastPrice"),a=this.safeString(e,"openPrice"),n=this.safeString(e,"highPrice"),o=this.safeString(e,"lowPrice"),d=this.safeString(e,"volume"),h=this.safeString(e,"bidPrice"),c=this.safeString(e,"askPrice"),l=this.safeInteger(e,"at");return this.safeTicker({symbol:i,timestamp:l,datetime:this.iso8601(l),high:n,low:o,bid:h,bidVolume:void 0,ask:c,askVolume:void 0,vwap:void 0,open:a,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:d,quoteVolume:void 0,info:e},t)}parseBalance(e){const t={info:e};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"asset"),a=this.safeCurrencyCode(r),n=this.account();n.free=this.safeString(i,"free"),n.used=this.safeString(i,"locked"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetFunds(e);return this.parseBalance(t)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires a `symbol` argument");await this.loadMarkets();const a=this.market(e),n={symbol:a.id};void 0!==t&&(n.startTime=t),void 0!==s&&(n.limit=s);const o=await this.privateGetAllOrders(this.extend(n,i));let d=this.parseOrders(o,a,t,s);return d=this.filterBy(d,"symbol",e),d}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id);const n=await this.privateGetOpenOrders(this.extend(r,i));return this.parseOrders(n,a,t,s)}async cancelAllOrders(e=undefined,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a `symbol` argument");await this.loadMarkets();const s={symbol:this.market(e).id};return await this.privateDeleteOpenOrders(this.extend(s,t))}async cancelOrder(e,t=undefined,s={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a `symbol` argument");await this.loadMarkets();const i={symbol:this.market(t).id,orderId:e},a=await this.privateDeleteOrder(this.extend(i,s));return this.parseOrder(a)}async createOrder(e,t,s,i,a=undefined,n={}){if("limit"!==(t=t.toLowerCase())&&"stop_limit"!==t)throw new r.ExchangeError(this.id+" createOrder() supports limit and stop_limit orders only");if(void 0===a)throw new r.ExchangeError(this.id+" createOrder() requires a price argument");await this.loadMarkets();const o=this.market(e),d={symbol:o.id,side:s,quantity:i,type:"limit"};d.price=this.priceToPrecision(e,a);const h=this.safeString(n,"stopPrice");void 0!==h&&(d.type="stop_limit",d.stopPrice=this.priceToPrecision(e,h));const c=await this.privatePostOrder(this.extend(d,n));return this.parseOrder(c,o)}parseOrder(e,t=undefined){const s=this.safeInteger(e,"createdTime"),i=this.safeInteger(e,"updatedTime"),r=this.safeString(e,"symbol"),a=this.safeSymbol(r,t),n=this.safeString(e,"quantity"),o=this.safeString(e,"executedQty"),d=this.parseOrderStatus(this.safeString(e,"status")),h=this.safeString(e,"id"),c=this.safeString(e,"price"),l=this.safeStringLower(e,"type"),u=this.safeStringLower(e,"side");return this.safeOrder({info:e,id:h,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:i,status:d,symbol:a,type:l,timeInForce:void 0,postOnly:void 0,side:u,price:c,amount:n,filled:o,remaining:void 0,cost:void 0,fee:void 0,average:void 0,trades:[]},t)}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/"+e;if("public"===t&&Object.keys(i).length&&(n+="?"+this.urlencode(i)),"private"===t){this.checkRequiredCredentials();const e=this.milliseconds();let t=this.extend({recvWindow:this.options.recvWindow,timestamp:e},i);t=this.keysort(t);const s=this.hmac(this.encode(this.urlencode(t)),this.encode(this.secret),o.J);n+="?"+this.urlencode(t),n+="&signature="+s,r={"Content-Type":"application/x-www-form-urlencoded","X-Api-Key":this.apiKey}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.safeString(o,"code");if(void 0!==c){const e=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,c,e),new r.ExchangeError(e)}}}},5467:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5307),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"whitebit",name:"WhiteBit",version:"v4",countries:["EE"],rateLimit:500,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderTrades:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!0,repayMargin:!1,setLeverage:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg",api:{v1:{public:"https://whitebit.com/api/v1/public",private:"https://whitebit.com/api/v1"},v2:{public:"https://whitebit.com/api/v2/public"},v4:{public:"https://whitebit.com/api/v4/public",private:"https://whitebit.com/api/v4"}},www:"https://www.whitebit.com",doc:"https://github.com/whitebit-exchange/api-docs",fees:"https://whitebit.com/fee-schedule",referral:"https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963"},api:{web:{get:["v1/healthcheck"]},v1:{public:{get:["markets","tickers","ticker","symbols","depth/result","history","kline"]},private:{post:["account/balance","order/new","order/cancel","orders","account/order_history","account/executed_history","account/executed_history/all","account/order"]}},v2:{public:{get:["markets","ticker","assets","fee","depth/{market}","trades/{market}"]}},v4:{public:{get:["assets","collateral/markets","fee","orderbook/{market}","ticker","trades/{market}","time","ping","markets","futures"]},private:{post:["collateral-account/balance","collateral-account/positions/history","collateral-account/leverage","collateral-account/positions/open","collateral-account/summary","main-account/address","main-account/balance","main-account/create-new-address","main-account/codes","main-account/codes/apply","main-account/codes/my","main-account/codes/history","main-account/fiat-deposit-url","main-account/history","main-account/withdraw","main-account/withdraw-pay","main-account/transfer","trade-account/balance","trade-account/executed-history","trade-account/order","trade-account/order/history","order/collateral/limit","order/collateral/market","order/collateral/trigger_market","order/new","order/market","order/stock_market","order/stop_limit","order/stop_market","order/cancel","orders","profile/websocket_token"]}}},fees:{trading:{tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},options:{fiatCurrencies:["EUR","USD","RUB","UAH"],fetchBalance:{account:"spot"},accountsByType:{main:"main",spot:"spot",margin:"collateral",trade:"spot"},networksById:{BEP20:"BSC"},defaultType:"spot",brokerId:"ccxt"},precisionMode:n.sh,exceptions:{exact:{"Unauthorized request.":r.AuthenticationError,"The market format is invalid.":r.BadSymbol,"Market is not available":r.BadSymbol,"Invalid payload.":r.BadRequest,"Amount must be greater than 0":r.InvalidOrder,"Not enough balance.":r.InsufficientFunds,"The order id field is required.":r.InvalidOrder,"Not enough balance":r.InsufficientFunds,"This action is unauthorized.":r.PermissionDenied,"This API Key is not authorized to perform this action.":r.PermissionDenied,"Unexecuted order was not found.":r.OrderNotFound,"The selected from is invalid.":r.BadRequest,503:r.ExchangeNotAvailable,422:r.OrderNotFound},broad:{"This action is unauthorized":r.PermissionDenied,"Given amount is less than min amount":r.InvalidOrder,"Total is less than":r.InvalidOrder,"fee must be no less than":r.InvalidOrder,"Enable your key in API settings":r.PermissionDenied,"You don't have such amount for transfer":r.InsufficientFunds}}})}async fetchMarkets(e={}){const t=await this.v4PublicGetMarkets(),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"name"),n=this.safeString(i,"stock");let o=this.safeString(i,"money");o="PERP"===o?"USDT":o;const d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=this.safeValue(i,"tradesEnabled"),l=this.safeValue(i,"isCollateral");let u,f,p,m=d+"/"+h;const g="futures"===this.safeString(i,"type"),y=l&&!g;let v=!1;const b=this.parseNumber(this.parsePrecision(this.safeString(i,"stockPrec"))),w=b;let S,k;g?(p=o,f=this.safeCurrencyCode(p),m=m+":"+f,u="swap",v=!0,S=!0,k=!1):u="spot";const O=this.safeString(i,"takerFee"),T=a.O.stringDiv(O,"100"),I=this.safeString(i,"makerFee"),x=a.O.stringDiv(I,"100"),P={id:r,symbol:m,base:d,quote:h,settle:f,baseId:n,quoteId:o,settleId:p,type:u,spot:!g,margin:y,swap:g,future:!1,option:!1,active:c,contract:v,linear:S,inverse:k,taker:this.parseNumber(T),maker:this.parseNumber(x),contractSize:w,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:b,price:this.parseNumber(this.parsePrecision(this.safeString(i,"moneyPrec")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(i,"minAmount"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(i,"minTotal"),max:this.safeNumber(i,"maxTotal")}},created:void 0,info:i};s.push(P)}return s}async fetchCurrencies(e={}){const t=await this.v4PublicGetAssets(e),s=Object.keys(t),i={};for(let e=0;e<s.length;e++){const r=s[e],a=t[r],n=this.safeValue(a,"can_deposit",!0),o=this.safeValue(a,"can_withdraw",!0),d=n&&o,h=this.safeCurrencyCode(r);i[h]={id:r,code:h,info:a,name:void 0,active:d,deposit:n,withdraw:o,fee:void 0,precision:void 0,limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(a,"min_withdraw"),max:this.safeNumber(a,"max_withdraw")}}}}return i}async fetchTransactionFees(e=undefined,t={}){await this.loadMarkets();const s=await this.v4PublicGetFee(t),i=Object.keys(s),r={},a={};for(let e=0;e<i.length;e++){const t=i[e],n=s[t],o=this.safeCurrencyCode(t),d=this.safeValue(n,"withdraw",{});r[o]=this.safeString(d,"fixed");const h=this.safeValue(n,"deposit",{});a[o]=this.safeString(h,"fixed")}return{withdraw:r,deposit:a,info:s}}async fetchDepositWithdrawFees(e=undefined,t={}){await this.loadMarkets();const s=await this.v4PublicGetFee(t);return this.parseDepositWithdrawFees(s,e)}parseDepositWithdrawFees(e,t=undefined,s=undefined){const i={};t=this.marketCodes(t);const r=Object.keys(e);for(let s=0;s<r.length;s++){const a=r[s],n=a.split(" "),o=n[0],d=e[a],h=this.safeCurrencyCode(o);if(void 0===t||this.inArray(h,t)){void 0===this.safeValue(i,h)&&(i[h]=this.depositWithdrawFee({})),i[h].info[a]=d;let e=this.safeString(n,1);const t=this.safeValue(d,"withdraw"),s=this.safeValue(d,"deposit"),r=this.safeNumber(t,"fixed"),o=this.safeNumber(s,"fixed"),c={fee:r,percentage:void 0===r&&void 0},l={fee:o,percentage:void 0===o&&void 0};if(void 0!==e){const t=e.length;e=e.slice(1,t-1);const s=this.networkIdToCode(e);i[h].networks[s]={withdraw:c,deposit:l}}else i[h].withdraw=c,i[h].deposit=l}}const a=Object.keys(i);for(let e=0;e<a.length;e++){const t=a[e],s=this.currency(t);i[t]=this.assignDefaultDepositWithdrawFees(i[t],s)}return i}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v4PublicGetAssets(e),s={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e],r=this.market(i),n=this.safeValue(t,r.baseId,{});let o=this.safeString(n,"maker_fee"),d=this.safeString(n,"taker_fee");o=a.O.stringDiv(o,"100"),d=a.O.stringDiv(d,"100"),s[i]={info:n,symbol:r.symbol,percentage:!0,tierBased:!1,maker:this.parseNumber(o),taker:this.parseNumber(d)}}return s}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={market:s.id},r=await this.v1PublicGetTicker(this.extend(i,t)),a=this.safeValue(r,"result",{});return this.parseTicker(a,s)}parseTicker(e,t=undefined){t=this.safeMarket(void 0,t);const s=this.safeString(e,"last_price");return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"open"),close:s,last:s,previousClose:void 0,change:void 0,percentage:this.safeString(e,"change"),average:void 0,baseVolume:this.safeString2(e,"base_volume","volume"),quoteVolume:this.safeString2(e,"quote_volume","deal"),info:e},t)}async fetchTickers(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v4PublicGetTicker(t),i=Object.keys(s),r={};for(let e=0;e<i.length;e++){const t=i[e],a=this.safeMarket(t),n=this.parseTicker(s[t],a);r[n.symbol]=n}return this.filterByArrayTickers(r,"symbol",e)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={market:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.v4PublicGetOrderbookMarket(this.extend(i,s)),a=this.safeTimestamp(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},n=await this.v4PublicGetTradesMarket(this.extend(a,i));return this.parseTrades(n,r,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id);const n=await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(a,i));if(Array.isArray(n))return this.parseTrades(n,r,t,s);{let e=[];const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],o=this.safeMarket(a,void 0,"_"),d=this.safeValue(n,a,[]),h=this.parseTrades(d,o,t,s);e=this.arrayConcat(e,h)}return e=this.sortBy2(e,"timestamp","id"),this.filterBySinceLimit(e,t,s,"timestamp")}}parseTrade(e,t=undefined){t=this.safeMarket(void 0,t);const s=this.safeTimestamp2(e,"time","trade_timestamp"),i=this.safeString2(e,"dealOrderId","orderId"),r=this.safeString(e,"deal"),a=this.safeString(e,"price"),n=this.safeString2(e,"amount","quote_volume"),o=this.safeString2(e,"id","tradeID"),d=this.safeString2(e,"type","side"),h=t.symbol,c=this.safeInteger(e,"role");let l,u;void 0!==c&&(l=1===c?"maker":"taker");const f=this.safeString(e,"fee");return void 0!==f&&(u={cost:f,currency:t.quote}),this.safeTrade({info:e,timestamp:s,datetime:this.iso8601(s),symbol:h,id:o,order:i,type:void 0,takerOrMaker:l,side:d,price:a,amount:n,cost:r,fee:u},t)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={market:a.id,interval:this.safeString(this.timeframes,t,t)};if(void 0!==s){const e=1440;void 0===i&&(i=e),i=Math.min(i,e);const t=this.parseToInt(s/1e3);n.start=t}void 0!==i&&(n.limit=Math.min(i,1440));const o=await this.v1PublicGetKline(this.extend(n,r)),d=this.safeValue(o,"result",[]);return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,2),this.safeNumber(e,5)]}async fetchStatus(e={}){const t=await this.v4PublicGetPing(e),s=this.safeString(t,0);return{status:"pong"===s?"ok":s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v4PublicGetTime(e);return this.safeInteger(t,"time")}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d={market:o.id,side:s,amount:this.amountToPrecision(e,i)},h=this.safeString2(n,"clOrdId","clientOrderId");if(void 0===h){const e=this.safeString(this.options,"brokerId");void 0!==e&&(d.clientOrderId=e+this.uuid16())}else d.clientOrderId=h,n=this.omit(n,["clientOrderId"]);const c=this.safeString(o,"type"),l="limit"===t,u="market"===t,f=this.safeNumberN(n,["triggerPrice","stopPrice","activation_price"]),p=void 0!==f,m=this.isPostOnly(u,!1,n),[g,y]=this.handleMarginModeAndParams("createOrder",n);let v;if(m&&(d.postOnly=!0),void 0!==g&&"cross"!==g)throw new r.NotSupported(this.id+" createOrder() is only available for cross margin");const b=void 0!==g||"swap"===c;p?(d.activation_price=this.priceToPrecision(e,f),l?(v="v4PrivatePostOrderStopLimit",d.price=this.priceToPrecision(e,a)):(v="v4PrivatePostOrderStopMarket",b&&(v="v4PrivatePostOrderCollateralTriggerMarket"))):l?(v="v4PrivatePostOrderNew",b&&(v="v4PrivatePostOrderCollateralLimit"),d.price=this.priceToPrecision(e,a)):(v="v4PrivatePostOrderStockMarket",b&&(v="v4PrivatePostOrderCollateralMarket")),n=this.omit(y,["postOnly","triggerPrice","stopPrice"]);const w=await this[v](this.extend(d,n));return this.parseOrder(w)}async cancelOrder(e,t=undefined,s={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const i={market:this.market(t).id,orderId:parseInt(e)};return await this.v4PrivatePostOrderCancel(this.extend(i,s))}parseBalance(e){const t=Object.keys(e),s={};for(let i=0;i<t.length;i++){const r=t[i],a=this.safeCurrencyCode(r),n=e[r];if("object"==typeof n&&void 0!==n){const e=this.account();e.free=this.safeString(n,"available"),e.used=this.safeString(n,"freeze"),e.total=this.safeString(n,"main_balance"),s[a]=e}else{const e=this.account();e.total=n,s[a]=e}}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const[t,s]=this.handleMarketTypeAndParams("fetchBalance",void 0,e);let i;if("swap"===t)i="v4PrivatePostCollateralAccountBalance";else{const t=this.safeValue(this.options,"fetchBalance",{}),s=this.safeString(t,"account"),r=this.safeString(e,"account",s);e=this.omit(e,"account"),i="main"===r?"v4PrivatePostMainAccountBalance":"v4PrivatePostTradeAccountBalance"}const r=await this[i](s);return this.parseBalance(r)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n={market:a.id};void 0!==s&&(n.limit=Math.min(s,100));const o=await this.v4PrivatePostOrders(this.extend(n,i));return this.parseOrders(o,a,t,s,{status:"open"})}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),e=a.symbol,r.market=a.id),void 0!==s&&(r.limit=Math.min(s,100));const n=await this.v4PrivatePostTradeAccountOrderHistory(this.extend(r,i)),o=Object.keys(n);let d=[];for(let e=0;e<o.length;e++){const t=o[e],s=this.safeMarket(t,void 0,"_"),i=n[t];for(let e=0;e<i.length;e++){const t=this.parseOrder(i[e],s);d.push(this.extend(t,{status:"closed"}))}}return d=this.sortBy(d,"timestamp"),d=this.filterBySymbolSinceLimit(d,e,t,s),d}parseOrderType(e){return this.safeString({limit:"limit",market:"market","stop market":"market","stop limit":"limit","stock market":"market","margin limit":"limit","margin market":"market"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"market"),i=(t=this.safeMarket(s,t,"_")).symbol,r=this.safeString(e,"side"),a=this.safeString(e,"dealStock"),n=this.safeString(e,"left");let o=this.safeString(e,"clientOrderId");""===o&&(o=void 0);const d=this.safeString(e,"price"),h=this.safeNumber(e,"activation_price"),c=this.safeString2(e,"orderId","id"),l=this.safeString(e,"type");let u=this.safeString(e,"amount");const f=this.safeString(e,"dealMoney");"buy"!==r||"market"!==l&&"stop market"!==l||(u=a);const p=this.safeString(e,"dealFee");let m;void 0!==p&&(m={cost:this.parseNumber(p),currency:t.quote});const g=this.safeTimestamp2(e,"ctime","timestamp"),y=this.safeTimestamp(e,"ftime");return this.safeOrder({info:e,id:c,symbol:i,clientOrderId:o,timestamp:g,datetime:this.iso8601(g),lastTradeTimestamp:y,timeInForce:void 0,postOnly:void 0,status:void 0,side:r,price:d,type:this.parseOrderType(l),stopPrice:h,triggerPrice:h,amount:u,filled:a,remaining:n,average:void 0,cost:f,fee:m,trades:void 0},t)}async fetchOrderTrades(e,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={orderId:parseInt(e)};let n;void 0!==t&&(n=this.market(t),a.market=n.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostTradeAccountOrder(this.extend(a,r)),d=this.safeValue(o,"records",[]);return this.parseTrades(d,n)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s={ticker:this.currency(e).id};let i="v4PrivatePostMainAccountAddress";if(this.isFiat(e)){i="v4PrivatePostMainAccountFiatDepositUrl";const e=this.safeNumber(t,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires a provider when the ticker is fiat");s.provider=e;const a=this.safeNumber(t,"amount");if(void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an amount when the ticker is fiat");s.amount=a;if(void 0===this.safeValue(t,"uniqueId"))throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an uniqueId when the ticker is fiat")}const a=await this[i](this.extend(s,t)),n=this.safeString(a,"url"),o=this.safeValue(a,"account",{}),d=this.safeString(o,"address",n),h=this.safeString(o,"memo");return this.checkAddress(d),{currency:e,address:d,tag:h,network:void 0,info:a}}async setLeverage(e,t=undefined,s={}){if(await this.loadMarkets(),void 0!==t)throw new r.NotSupported(this.id+" setLeverage() does not allow to set per symbol");if(e<1||e>20)throw new r.BadRequest(this.id+" setLeverage() leverage should be between 1 and 20");const i={leverage:e};return await this.v4PrivatePostCollateralAccountLeverage(this.extend(i,s))}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n=this.safeValue(this.options,"accountsByType"),o=this.safeString(n,s,s),d=this.safeString(n,i,i),h=this.currencyToPrecision(e,t),c={ticker:a.id,amount:h,from:o,to:d},l=await this.v4PrivatePostMainAccountTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=undefined){return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async withdraw(e,t,s,i=undefined,a={}){await this.loadMarkets();const n=this.currency(e),o={ticker:n.id,amount:this.currencyToPrecision(e,t),address:s};let d=this.safeValue(a,"uniqueId");if(void 0===d&&(d=this.uuid22()),o.uniqueId=d,void 0!==i&&(o.memo=i),this.isFiat(e)){const e=this.safeValue(a,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a provider when the ticker is fiat");o.provider=e}const h=await this.v4PrivatePostMainAccountWithdraw(this.extend(o,a));return this.extend({id:d},this.parseTransaction(h,n))}parseTransaction(e,t=undefined){t=this.safeCurrency(void 0,t);const s=this.safeString(e,"address"),i=this.safeTimestamp(e,"createdAt"),r=this.safeString(e,"ticker"),a=this.safeString(e,"status"),n=this.safeString(e,"method");return{id:this.safeString(e,"uniqueId"),txid:this.safeString(e,"transactionHash"),timestamp:i,datetime:this.iso8601(i),network:this.safeString(e,"network"),addressFrom:"1"===n?s:void 0,address:s,addressTo:"2"===n?s:void 0,amount:this.safeNumber(e,"amount"),type:"1"===n?"deposit":"withdrawal",currency:this.safeCurrencyCode(r,t),status:this.parseTransactionStatus(a),updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:this.safeString(e,"description"),fee:{cost:this.safeNumber(e,"fee"),currency:this.safeCurrencyCode(r,t)},info:e}}parseTransactionStatus(e){return this.safeString({1:"pending",2:"pending",3:"ok",4:"canceled",5:"pending",6:"pending",7:"ok",9:"canceled",10:"pending",11:"pending",12:"pending",13:"pending",14:"pending",15:"pending",16:"pending",17:"pending"},e,e)}async fetchDeposit(e,t=undefined,s={}){let i;await this.loadMarkets();const r={transactionMethod:1,uniqueId:e,limit:1,offset:0};void 0!==t&&(i=this.currency(t),r.ticker=i.id);const a=await this.v4PrivatePostMainAccountHistory(this.extend(r,s)),n=this.safeValue(a,"records",[]),o=this.safeValue(n,0,{});return this.parseTransaction(o,i)}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={transactionMethod:1,limit:100,offset:0};void 0!==e&&(r=this.currency(e),a.ticker=r.id),void 0!==s&&(a.limit=Math.min(s,100));const n=await this.v4PrivatePostMainAccountHistory(this.extend(a,i)),o=this.safeValue(n,"records",[]);return this.parseTransactions(o,r,t,s)}async fetchBorrowInterest(e=undefined,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={};let n;void 0!==t&&(n=this.market(t),a.market=n.id);const o=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(a,r)),d=this.parseBorrowInterests(o,n);return this.filterByCurrencySinceLimit(d,e,s,i)}parseBorrowInterest(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"_"),r=this.safeTimestamp(e,"modifyDate");return{symbol:i,marginMode:"cross",currency:"USDT",interest:this.safeNumber(e,"unrealizedFunding"),interestRate:98e-5,amountBorrowed:this.safeNumber(e,"amount"),timestamp:r,datetime:this.iso8601(r),info:e}}async fetchFundingRate(e,t={}){await this.loadMarkets(),e=this.symbol(e);const s=await this.fetchFundingRates([e],t);return this.safeValue(s,e)}async fetchFundingRates(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v4PublicGetFutures(t),i=this.safeValue(s,"result",[]),r=this.parseFundingRates(i);return this.filterByArray(r,"symbol",e)}parseFundingRate(e,t=undefined){const s=this.safeString(e,"ticker_id"),i=this.safeSymbol(s,t),r=this.safeNumber(e,"markPrice"),a=this.safeNumber(e,"indexPrice"),n=this.safeNumber(e,"interestRate"),o=this.safeNumber(e,"funding_rate"),d=this.safeInteger(e,"next_funding_rate_timestamp");return{info:e,symbol:i,markPrice:r,indexPrice:a,interestRate:n,timestamp:void 0,datetime:void 0,fundingRate:o,fundingTimestamp:void 0,fundingDatetime:this.iso8601(void 0),nextFundingRate:void 0,nextFundingTimestamp:d,nextFundingDatetime:this.iso8601(d),previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0}}isFiat(e){const t=this.safeValue(this.options,"fiatCurrencies",[]);return this.inArray(e,t)}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=this.omit(i,this.extractParams(e)),d=this.safeValue(t,0),h=this.safeValue(t,1),c="/"+this.implodeParams(e,i);let l=this.urls.api[d][h]+c;if("public"===h&&Object.keys(n).length&&(l+="?"+this.urlencode(n)),"private"===h){this.checkRequiredCredentials();const e=this.nonce().toString(),t=this.encode(this.secret),s="/api/"+d+c;a=this.json(this.extend({request:s,nonce:e},i));const n=this.stringToBase64(a),h=this.hmac(this.encode(n),t,o.o);r={"Content-Type":"application/json","X-TXC-APIKEY":this.apiKey,"X-TXC-PAYLOAD":n,"X-TXC-SIGNATURE":h}}return{url:l,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(404===e)throw new r.ExchangeError(this.id+" "+e.toString()+" endpoint not found");if(void 0!==o){const e=this.safeString(o,"status"),t=this.safeString(o,"message"),s=this.safeInteger(o,"code"),i=void 0!==e&&"200"!==e;if(i||void 0!==s){const s=this.id+" "+n;let a=t;if(i)a=e;else{const e=this.safeValue(o,"errors");if(void 0!==e){const t=Object.keys(e)[0],s=this.safeValue(e,t,[]);a=s.length>0?s[0]:n}}throw this.throwExactlyMatchedException(this.exceptions.exact,a,s),this.throwBroadlyMatchedException(this.exceptions.broad,n,s),new r.ExchangeError(s)}}}}},517:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(3771),r=s(6689),a=s(2194),n=s(9292),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"woo",name:"WOO X",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,hostname:"woo.org",has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelWithdraw:!1,createDepositAddress:!1,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAccounts:!0,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,repayMargin:!0,setLeverage:!0,setMargin:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg",api:{pub:"https://api-pub.woo.org",public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{pub:"https://api-pub.staging.woo.org",public:"https://api.staging.woo.org",private:"https://api.staging.woo.org"},www:"https://woo.org/",doc:["https://docs.woo.org/"],fees:["https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees"],referral:"https://referral.woo.org/BAJS6oNmZb3vi3RGA"},api:{v1:{pub:{get:{"hist/kline":10,"hist/trades":1}},public:{get:{info:1,"info/{symbol}":1,system_info:1,market_trades:1,token:1,token_network:1,funding_rates:1,"funding_rate/{symbol}":1,funding_rate_history:1,futures:1,"futures/{symbol}":1,"orderbook/{symbol}":1,kline:1}},private:{get:{"client/token":1,"order/{oid}":1,"client/order/{client_order_id}":1,orders:1,"client/trade/{tid}":1,"order/{oid}/trades":1,"client/trades":1,"asset/deposit":10,"asset/history":60,"sub_account/all":60,"sub_account/assets":60,token_interest:60,"token_interest/{token}":60,"interest/history":60,"interest/repay":60,"funding_fee/history":30,positions:3.33,"position/{symbol}":3.33,"client/transaction_history":60},post:{order:5,"asset/main_sub_transfer":30,"asset/withdraw":30,"interest/repay":60,"client/account_mode":120,"client/leverage":120},delete:{order:1,"client/order":1,orders:1,"asset/withdraw":120}}},v2:{private:{get:{"client/holding":1}}},v3:{private:{get:{"algo/order/{oid}":1,"algo/orders":1,balances:1,accountinfo:60,positions:3.33,buypower:1,referrals:60,referral_rewards:60,"convert/exchangeInfo":1,"convert/assetInfo":1,"convert/rfq":60,"convert/trade":1,"convert/trades":1},post:{"algo/order":5,"convert/rft":60},put:{"order/{oid}":2,"order/client/{client_order_id}":2,"algo/order/{oid}":2,"algo/order/client/{client_order_id}":2},delete:{"algo/order/{order_id}":1,"algo/orders/pending":1,"algo/orders/pending/{symbol}":1,"orders/pending":1}}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{createMarketBuyOrderRequiresPrice:!0,"network-aliases-for-tokens":{HT:"ERC20",OMG:"ERC20",UATOM:"ATOM",ZRX:"ZRX"},networks:{TRX:"TRON",TRC20:"TRON",ERC20:"ETH",BEP20:"BSC"},defaultNetworkCodeForCurrencies:{},transfer:{fillResponseFromRequest:!0},brokerId:"bc830de7-50f3-460b-9ee0-f430f83f9dad"},commonCurrencies:{},exceptions:{exact:{"-1000":r.ExchangeError,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.BadRequest,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.BadRequest,"-1011":r.ExchangeError,"-1012":r.BadRequest,"-1101":r.InvalidOrder,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder},broad:{"symbol must not be blank":r.BadRequest,"The token is not supported":r.BadRequest,"Your order and symbol are not valid or already canceled":r.BadRequest,"Insufficient WOO. Please enable margin trading for leverage trading":r.BadRequest}},precisionMode:n.sh})}async fetchMarkets(e={}){const t=await this.v1PublicGetInfo(e),s=[],i=this.safeValue(t,"rows",[]);for(let e=0;e<i.length;e++){const t=i[e],r=this.safeString(t,"symbol"),a=r.split("_");let n=this.safeStringLower(a,0);const o="spot"===n,d="perp"===n,h=this.safeString(a,1),c=this.safeString(a,2),l=this.safeCurrencyCode(h),u=this.safeCurrencyCode(c);let f,p,m,g,y=l+"/"+u,v=!0;const b=d;b&&(v=!1,f=this.safeString(a,2),p=this.safeCurrencyCode(f),y=l+"/"+u+":"+p,m=this.parseNumber("1"),n="swap",g=!0),s.push({id:r,symbol:y,base:l,quote:u,settle:p,baseId:h,quoteId:c,settleId:f,type:n,spot:o,margin:v,swap:d,future:!1,option:!1,active:void 0,contract:b,linear:g,inverse:void 0,contractSize:m,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(t,"base_tick"),price:this.safeNumber(t,"quote_tick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(t,"base_min"),max:this.safeNumber(t,"base_max")},price:{min:this.safeNumber(t,"quote_min"),max:this.safeNumber(t,"quote_max")},cost:{min:this.safeNumber(t,"min_notional"),max:void 0}},created:this.safeTimestamp(t,"created_time"),info:t})}return s}async fetchTrades(e,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n={symbol:a.id};void 0!==s&&(n.limit=s);const o=await this.v1PublicGetMarketTrades(this.extend(n,i)),d=this.safeValue(o,"rows",{});return this.parseTrades(d,a,t,s)}parseTrade(e,t=undefined){const s="id"in e,i=this.safeTimestamp(e,"executed_timestamp"),r=this.safeString(e,"symbol"),n=(t=this.safeMarket(r,t)).symbol,o=this.safeString(e,"executed_price"),d=this.safeString(e,"executed_quantity"),h=this.safeString(e,"order_id"),c=this.parseTokenAndFeeTemp(e,"fee_asset","fee"),l=a.O.stringMul(o,d),u=this.safeStringLower(e,"side"),f=this.safeString(e,"id");let p;if(s){p="1"===this.safeString(e,"is_maker")?"maker":"taker"}return this.safeTrade({id:f,timestamp:i,datetime:this.iso8601(i),symbol:n,side:u,price:o,amount:d,cost:l,order:h,takerOrMaker:p,type:void 0,fee:c,info:e},t)}parseTokenAndFeeTemp(e,t,s){const i=this.safeString(e,s);let r;if(void 0!==i){const s=this.safeString(e,t);r={cost:i,currency:this.safeCurrencyCode(s)}}return r}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v3PrivateGetAccountinfo(e),s=this.safeValue(t,"data",{}),i=this.safeString(s,"makerFeeRate"),r=this.safeString(s,"takerFeeRate"),n={};for(let e=0;e<this.symbols.length;e++){const s=this.symbols[e];n[s]={info:t,symbol:s,maker:this.parseNumber(a.O.stringDiv(i,"10000")),taker:this.parseNumber(a.O.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return n}async fetchCurrencies(e={}){const t={},s=await this.v1PublicGetToken(e),i=this.safeValue(s,"rows",[]),r=this.groupBy(i,"balance_token"),n=Object.keys(r);for(let e=0;e<n.length;e++){const s=n[e],i=r[s],o=this.safeCurrencyCode(s);let d,h;const c={};for(let e=0;e<i.length;e++){const t=i[e];d=this.safeString(t,"fullname");const s=this.safeString(t,"token"),r=s.split("_")[0],n=this.parsePrecision(this.safeString(t,"decimals"));void 0!==n&&(h=void 0===h?n:a.O.stringMin(n,h)),c[r]={id:s,network:r,limits:{withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},active:void 0,deposit:void 0,withdraw:void 0,fee:void 0,precision:this.parseNumber(n),info:t}}t[o]={id:s,name:d,code:o,precision:this.parseNumber(h),active:void 0,fee:void 0,networks:c,deposit:void 0,withdraw:void 0,limits:{deposit:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},info:i}}return t}async createOrder(e,t,s,i,n=undefined,o={}){const d=this.safeValue2(o,"reduceOnly","reduce_only"),h=t.toUpperCase();await this.loadMarkets();const c=this.market(e),l=s.toUpperCase(),u={symbol:c.id,side:l},f=this.safeNumber2(o,"triggerPrice","stopPrice"),p=this.safeValue(o,"stopLoss"),m=this.safeValue(o,"takeProfit"),g=this.safeString(o,"algoType"),y=void 0!==f||void 0!==p||void 0!==m||void 0!==this.safeValue(o,"childOrders"),v="MARKET"===h,b=this.safeStringLower(o,"timeInForce"),w=this.isPostOnly(v,void 0,o),S=y?"reduceOnly":"reduce_only",k=y?"clientOrderId":"client_order_id",O=y?"quantity":"order_quantity",T=y?"price":"order_price";if(u[y?"type":"order_type"]=h,y||(w?u.order_type="POST_ONLY":"fok"===b?u.order_type="FOK":"ioc"===b&&(u.order_type="IOC")),d&&(u[S]=d),void 0!==n&&(u[T]=this.priceToPrecision(e,n)),v&&!y)if(c.spot&&"BUY"===l){const t=this.safeNumber(o,"cost");if(this.safeValue(this.options,"createMarketBuyOrderRequiresPrice",!0))if(void 0===t){if(void 0===n)throw new r.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate total order cost. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or alternatively, supply the total cost value in the 'order_amount' in exchange-specific parameters");{const t=this.numberToString(i),s=this.numberToString(n),r=a.O.stringMul(t,s);u.order_amount=this.costToPrecision(e,r)}}else u.order_amount=this.costToPrecision(e,t);else u.order_amount=this.costToPrecision(e,i)}else u.order_quantity=this.amountToPrecision(e,i);else"POSITIONAL_TP_SL"!==g&&(u[O]=this.amountToPrecision(e,i));const I=this.safeStringN(o,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==I&&(u[k]=I),void 0!==f)"TRAILING_STOP"!==g&&(u.triggerPrice=this.priceToPrecision(e,f),u.algoType="STOP");else if(void 0!==p||void 0!==m){u.algoType="BRACKET";const t={symbol:c.id,reduceOnly:!1,algoType:"POSITIONAL_TP_SL",childOrders:[]},s="BUY"===l?"SELL":"BUY";if(void 0!==p){const i=this.safeNumber2(p,"triggerPrice","price",p),r={side:s,algoType:"STOP_LOSS",triggerPrice:this.priceToPrecision(e,i),type:"CLOSE_POSITION",reduceOnly:!0};t.childOrders.push(r)}if(void 0!==m){const i=this.safeNumber2(m,"triggerPrice","price",m),r={side:s,algoType:"TAKE_PROFIT",triggerPrice:this.priceToPrecision(e,i),type:"CLOSE_POSITION",reduceOnly:!0};t.childOrders.push(r)}u.childOrders=[t]}let x;o=this.omit(o,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit"]),x=y?await this.v3PrivatePostAlgoOrder(this.extend(u,o)):await this.v1PrivatePostOrder(this.extend(u,o));const P=this.safeValue(x,"data");if(void 0!==P){const e=this.safeValue(P,"rows",[]);return this.parseOrder(e[0],c)}const M=this.parseOrder(x,c);return M.type=t,M}async editOrder(e,t,s,i,r=undefined,a=undefined,n={}){await this.loadMarkets();const o=this.market(t),d={};void 0!==a&&(d.price=this.priceToPrecision(t,a)),void 0!==r&&(d.quantity=this.amountToPrecision(t,r));const h=this.safeString2(n,"clOrdID","clientOrderId"),c=this.safeString(n,"client_order_id",h),l=void 0!==c,u=this.safeNumberN(n,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==u&&(d.triggerPrice=this.priceToPrecision(t,u));const f=void 0!==u||void 0!==this.safeValue(n,"childOrders");let p;l?f?(p="v3PrivatePutAlgoOrderClientClientOrderId",d.oid=e):(p="v3PrivatePutOrderClientClientOrderId",d.client_order_id=c):(p=f?"v3PrivatePutAlgoOrderOid":"v3PrivatePutOrderOid",d.oid=e),n=this.omit(n,["clOrdID","clientOrderId","client_order_id","stopPrice","triggerPrice","takeProfitPrice","stopLossPrice"]);const m=await this[p](this.extend(d,n)),g=this.safeValue(m,"data",{});return this.parseOrder(g,o)}async cancelOrder(e,t=undefined,s={}){const i=this.safeValue(s,"stop",!1);s=this.omit(s,"stop"),i||this.checkRequiredSymbol("cancelOrder",t),await this.loadMarkets();const r={},a=this.safeString2(s,"clOrdID","clientOrderId"),n=this.safeString(s,"client_order_id",a),o=void 0!==n;let d,h;i?(d="v3PrivateDeleteAlgoOrderOrderId",r.order_id=e):o?(d="v1PrivateDeleteClientOrder",r.client_order_id=n,s=this.omit(s,["clOrdID","clientOrderId","client_order_id"])):(d="v1PrivateDeleteOrder",r.order_id=e),void 0!==t&&(h=this.market(t)),i||(r.symbol=h.id);const c=await this[d](this.extend(r,s)),l={symbol:t};return o?l.client_order_id=n:l.id=e,this.extend(this.parseOrder(c),l)}async cancelAllOrders(e=undefined,t={}){await this.loadMarkets();const s=this.safeValue(t,"stop");if(t=this.omit(t,"stop"),s)return await this.v3PrivateDeleteAlgoOrdersPending(t);this.checkRequiredSymbol("cancelOrders",e);const i={symbol:this.market(e).id};return await this.v1PrivateDeleteOrders(this.extend(i,t))}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i=void 0!==t?this.market(t):void 0,r=this.safeValue(s,"stop");s=this.omit(s,"stop");const a={},n=this.safeString2(s,"clOrdID","clientOrderId");let o;r?(o="v3PrivateGetAlgoOrderOid",a.oid=e):n?(o="v1PrivateGetClientOrderClientOrderId",a.client_order_id=n):(o="v1PrivateGetOrderOid",a.oid=e);const d=await this[o](this.extend(a,s)),h=this.safeValue(d,"data",d);return this.parseOrder(h,i)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;const n=this.safeValue(i,"stop");let o;i=this.omit(i,"stop"),void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(n?r.createdTimeStart=t:r.start_t=t),n&&(r.algoType="stop"),o=n?await this.v3PrivateGetAlgoOrders(this.extend(r,i)):await this.v1PrivateGetOrders(this.extend(r,i));const d=this.safeValue(o,"data",o),h=this.safeValue(d,"rows");return this.parseOrders(h,a,t,s,i)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrder(e,t=undefined){const s=this.safeTimestampN(e,["timestamp","created_time","createdTime"]),i=this.safeStringN(e,["order_id","orderId","algoOrderId"]),r=this.omitZero(this.safeString2(e,"client_order_id","clientOrderId")),n=this.safeString(e,"symbol"),o=(t=this.safeMarket(n,t)).symbol,d=this.safeString2(e,"order_price","price"),h=this.safeString2(e,"order_quantity","quantity"),c=this.safeString2(e,"order_amount","amount"),l=this.safeStringLower2(e,"order_type","type"),u=this.safeValue2(e,"status","algoStatus"),f=this.safeStringLower(e,"side"),p=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),m=this.omitZero(this.safeString2(e,"average_executed_price","averageExecutedPrice")),g=a.O.stringSub(c,p),y=this.safeValue2(e,"total_fee","totalFee"),v=this.safeString2(e,"fee_asset","feeAsset"),b=this.safeValue(e,"Transactions"),w=this.safeNumber(e,"triggerPrice");let S,k;const O=this.safeValue(e,"childOrders");if(void 0!==O){const e=this.safeValue(O,0),t=this.safeValue(e,"childOrders",[]);if(t.length>0){const e=this.safeValue(t,0),s=this.safeValue(t,1);S=this.safeNumber(e,"triggerPrice"),k=this.safeNumber(s,"triggerPrice")}}const T=this.safeTimestamp2(e,"updatedTime","updated_time");return this.safeOrder({id:i,clientOrderId:r,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:T,status:this.parseOrderStatus(u),symbol:o,type:l,timeInForce:this.parseTimeInForce(l),postOnly:void 0,reduceOnly:this.safeValue(e,"reduce_only"),side:f,price:d,stopPrice:w,triggerPrice:w,takeProfitPrice:S,stopLossPrice:k,average:m,amount:h,filled:p,remaining:g,cost:c,trades:b,fee:{cost:y,currency:v},info:e},t)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={symbol:this.market(e).id};void 0!==t&&(t=Math.min(t,1e3),i.max_level=t);const r=await this.v1PublicGetOrderbookSymbol(this.extend(i,s)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a,"bids","asks","price","quantity")}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.limit=Math.min(i,1e3));const o=await this.v1PublicGetKline(this.extend(n,r)),d=this.safeValue(o,"rows",[]);return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeInteger(e,"start_timestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOrderTrades(e,t=undefined,s=undefined,i=undefined,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const n={oid:e},o=await this.v1PrivateGetOrderOidTrades(this.extend(n,r)),d=this.safeValue(o,"rows",[]);return this.parseTrades(d,a,s,i,r)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.start_t=t);const n=await this.v1PrivateGetClientTrades(this.extend(r,i)),o=this.safeValue(n,"rows",[]);return this.parseTrades(o,a,t,s,i)}async fetchAccounts(e={}){const t=await this.v1PrivateGetSubAccountAssets(e),s=this.safeValue(t,"rows",[]);return this.parseAccounts(s,e)}parseAccount(e){const t=this.safeString(e,"account");return{info:e,id:this.safeString(e,"application_id"),name:t,code:void 0,type:"Main"===t?"main":"subaccount"}}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v3PrivateGetBalances(e),s=this.safeValue(t,"data");return this.parseBalance(s)}parseBalance(e){const t={info:e},s=this.safeValue(e,"holding",[]);for(let e=0;e<s.length;e++){const i=s[e],r=this.safeCurrencyCode(this.safeString(i,"token")),a=this.account();a.total=this.safeString(i,"holding"),a.free=this.safeString(i,"availableBalance"),t[r]=a}return this.safeBalance(t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i=this.defaultNetworkCodeForCurrency(e),r=this.safeString(t,"network",i);t=this.omit(t,"network");const a={token:r+"_"+s.code},n=await this.v1PrivateGetAssetDeposit(this.extend(a,t)),o=this.safeString(n,"extra"),d=this.safeString(n,"address");return this.checkAddress(d),{currency:e,address:d,tag:o,network:r,info:n}}async getAssetHistoryRows(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.balance_token=a.id),void 0!==t&&(r.start_t=t),void 0!==s&&(r.pageSize=s);const n=this.safeString(i,"type");i=this.omit(i,"type"),void 0!==n&&(r.type=n);const o=await this.v1PrivateGetAssetHistory(this.extend(r,i));return[a,this.safeValue(o,"rows",{})]}async fetchLedger(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,i);return this.parseLedger(a,r,t,s,i)}parseLedgerEntry(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code,r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"token_side")?"in":"out",n=this.safeTimestamp(e,"created_time"),o=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount");return{id:this.safeString(e,"id"),currency:i,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"tx_id"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,fee:o,direction:a,timestamp:n,datetime:this.iso8601(n),type:this.parseLedgerEntryType(this.safeString(e,"type")),info:e}}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}getCurrencyFromChaincode(e,t){if(void 0!==t)return t;{const s=e.split("_"),i=s.length,r=this.safeString(s,0);let a=this.safeString(s,1,r);i>2&&(a+="_"+this.safeString(s,2)),t=this.safeCurrency(a)}return t}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchDepositsWithdrawals(e,t,s,this.extend({token_side:"DEPOSIT"},i))}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchDepositsWithdrawals(e,t,s,this.extend({token_side:"WITHDRAW"},i))}async fetchDepositsWithdrawals(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,this.extend({type:"BALANCE"},i));return this.parseTransactions(a,r,t,s,i)}parseTransaction(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code;let r=this.safeStringLower(e,"token_side");"withdraw"===r&&(r="withdrawal");const a=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount"),n=this.safeString(e,"target_address"),o=this.safeString(e,"source_address"),d=this.safeTimestamp(e,"created_time");return{info:e,id:this.safeString2(e,"id","withdraw_id"),txid:this.safeString(e,"tx_id"),timestamp:d,datetime:this.iso8601(d),address:void 0,addressFrom:o,addressTo:n,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeTimestamp(e,"updated_time"),comment:void 0,fee:a}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n={token:a.id,amount:this.parseNumber(t),from_application_id:s,to_application_id:i},o=await this.v1PrivatePostAssetMainSubTransfer(this.extend(n,r)),d=this.parseTransfer(o,a),h=this.safeValue(this.options,"transfer",{});return this.safeValue(h,"fillResponseFromRequest",!0)&&(d.amount=t,d.fromAccount=s,d.toAccount=i),d}async fetchTransfers(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,this.extend({type:"COLLATERAL"},i));return this.parseTransfers(a,r,t,s,i)}parseTransfer(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code;let r,a,n=this.safeStringLower(e,"token_side");"withdraw"===n&&(n="withdrawal"),"withdraw"===n?(r=void 0,a="spot"):"deposit"===n&&(r="spot",a=void 0);const o=this.safeTimestamp(e,"created_time"),d=this.safeValue(e,"success");let h;return void 0!==d&&(h=d?"ok":"failed"),{id:this.safeString(e,"id"),timestamp:o,datetime:this.iso8601(o),currency:i,amount:this.safeNumber(e,"amount"),fromAccount:r,toAccount:a,status:this.parseTransferStatus(this.safeString(e,"status",h)),info:e}}parseTransferStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),await this.loadMarkets(),this.checkAddress(s);const n=this.currency(e),o={amount:t,address:s};void 0!==i&&(o.extra=i);const d=this.safeValue(this.options,"networks",{}),h=this.safeValue(n,"networks",{}),c=this.safeStringUpper(a,"network"),l=this.safeString(d,c,c),u=this.safeValue(h,l,{}),f=this.safeString(u,"id");if(void 0===f)throw new r.BadRequest(this.id+" withdraw() require network parameter");o.token=f;const p=await this.v1PrivatePostAssetWithdraw(this.extend(o,a));return this.parseTransaction(p,n)}async repayMargin(e,t,s=undefined,i={}){let r;await this.loadMarkets(),void 0!==s&&(r=this.market(s),s=r.symbol);const a=this.currency(e),n={token:a.id,amount:this.currencyToPrecision(e,t)},o=await this.v1PrivatePostInterestRepay(this.extend(n,i)),d=this.parseMarginLoan(o,a);return this.extend(d,{amount:t,symbol:s})}parseMarginLoan(e,t=undefined){return{id:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,symbol:void 0,timestamp:void 0,datetime:void 0,info:e}}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=t[0],d=t[1],h=this.implodeParams(e,i);let c=this.implodeHostname(this.urls.api[d]);if(c+="/"+n+"/",i=this.omit(i,this.extractParams(e)),i=this.keysort(i),"public"===d)c+=d+"/"+h,Object.keys(i).length&&(c+="?"+this.urlencode(i));else{if(this.checkRequiredCredentials(),"POST"===s&&("algo/order"===e||"order"===e)){const t="bc830de7-50f3-460b-9ee0-f430f83f9dad",s=this.safeString(this.options,"brokerId",t);e.indexOf("algo")>-1?i.brokerId=s:i.broker_id=s,i=this.keysort(i)}let t="";const d=this.nonce().toString();if(c+=h,r={"x-api-key":this.apiKey,"x-api-timestamp":d},"v3"===n){if(t=d+s+"/"+n+"/"+h,"POST"===s||"PUT"===s||"DELETE"===s)t+=a=this.json(i);else if(Object.keys(i).length){const e=this.urlencode(i);c+="?"+e,t+="?"+e}r["content-type"]="application/json"}else t=this.urlencode(i),"POST"===s||"PUT"===s||"DELETE"===s?a=t:c+="?"+t,t+="|"+d,r["content-type"]="application/x-www-form-urlencoded";r["x-api-signature"]=this.hmac(this.encode(t),this.encode(this.secret),o.J)}return{url:c,method:s,body:a,headers:r}}handleErrors(e,t,s,i,r,a,n,o,d){if(!n)return;const h=this.safeValue(n,"success"),c=this.safeString(n,"code");if(!h){const e=this.id+" "+this.json(n);this.throwBroadlyMatchedException(this.exceptions.broad,a,e),this.throwExactlyMatchedException(this.exceptions.exact,c,e)}}parseIncome(e,t=undefined){const s=this.safeString(e,"symbol"),i=this.safeSymbol(s,t),r=this.safeNumber(e,"funding_fee"),a=this.safeCurrencyCode("USD"),n=this.safeString(e,"id"),o=this.safeTimestamp(e,"updated_time"),d=this.safeNumber(e,"funding_rate");return{info:e,symbol:i,code:a,timestamp:o,datetime:this.iso8601(o),id:n,amount:r,rate:d}}async fetchFundingHistory(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.start_t=t);const n=await this.v1PrivateGetFundingFeeHistory(this.extend(r,i)),o=this.safeValue(n,"rows",[]);return this.parseIncomes(o,a,t,s)}parseFundingRate(e,t=undefined){const s=this.safeString(e,"symbol");t=this.market(s);const i=this.safeInteger(e,"next_funding_time"),r=this.safeInteger(e,"est_funding_rate_timestamp"),a=this.safeInteger(e,"last_funding_rate_timestamp");return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"est_funding_rate"),fundingTimestamp:i,fundingDatetime:this.iso8601(i),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"last_funding_rate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a)}}async fetchFundingRate(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.v1PublicGetFundingRateSymbol(this.extend(i,t));return this.parseFundingRate(r,s)}async fetchFundingRates(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v1PublicGetFundingRates(t),i=this.safeValue(s,"rows",{}),r=this.parseFundingRates(i);return this.filterByArray(r,"symbol",e)}async fetchFundingRateHistory(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();let r=!1;if([r,i]=this.handleOptionAndParams(i,"fetchFundingRateHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,s,i,"page",25);let a={};if(void 0!==e){const t=this.market(e);e=t.symbol,a.symbol=t.id}void 0!==t&&(a.start_t=this.parseToInt(t/1e3)),[a,i]=this.handleUntilOption("end_t",a,i,.001);const n=await this.v1PublicGetFundingRateHistory(this.extend(a,i)),o=this.safeValue(n,"rows"),d=[];for(let e=0;e<o.length;e++){const t=o[e],s=this.safeString(t,"symbol"),i=this.safeInteger(t,"funding_rate_timestamp");d.push({info:t,symbol:this.safeSymbol(s),fundingRate:this.safeNumber(t,"funding_rate"),timestamp:i,datetime:this.iso8601(i)})}const h=this.sortBy(d,"timestamp");return this.filterBySymbolSinceLimit(h,e,t,s)}async fetchLeverage(e,t={}){await this.loadMarkets();const s=await this.v3PrivateGetAccountinfo(t),i=this.safeValue(s,"data");return{info:s,leverage:this.safeNumber(i,"leverage")}}async setLeverage(e,t=undefined,s={}){if(await this.loadMarkets(),e<1||e>20)throw new r.BadRequest(this.id+" leverage should be between 1 and 20");const i={leverage:e};return await this.v1PrivatePostClientLeverage(this.extend(i,s))}async fetchPosition(e=undefined,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.v1PrivateGetPositionSymbol(this.extend(i,t));return this.parsePosition(r,s)}async fetchPositions(e=undefined,t={}){await this.loadMarkets();const s=await this.v3PrivateGetPositions(t),i=this.safeValue(s,"data",{}),r=this.safeValue(i,"positions",[]);return this.parsePositions(r,e)}parsePosition(e,t=undefined){const s=this.safeString(e,"symbol");t=this.safeMarket(s,t);let i,r=this.safeString(e,"holding");i=a.O.stringGt(r,"0")?"long":"short";const n=this.safeString(t,"contractSize"),o=this.safeString(e,"markPrice"),d=this.safeTimestamp(e,"timestamp"),h=this.safeString(e,"averageOpenPrice"),c=a.O.stringSub(o,h),l=a.O.stringMul(c,r);r=a.O.stringAbs(r);const u=a.O.stringMul(r,o);return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:d,datetime:this.iso8601(d),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(h),notional:this.parseNumber(u),leverage:void 0,unrealizedPnl:this.parseNumber(l),contracts:this.parseNumber(r),contractSize:this.parseNumber(n),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"estLiqPrice"),markPrice:this.parseNumber(o),lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:i,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}defaultNetworkCodeForCurrency(e){const t=this.currency(e).networks,s=Object.keys(t);for(let e=0;e<s.length;e++){const t=s[e];if("ETH"===t)return t}return this.safeValue(s,0)}}},3850:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5790),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"yobit",name:"YoBit",countries:["RU"],rateLimit:2e3,version:"3",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createDepositAddress:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchDepositAddress:!0,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawals:!1,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0,ws:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpg",api:{public:"https://yobit.net/api",private:"https://yobit.net/tapi"},www:"https://www.yobit.net",doc:"https://www.yobit.net/en/api/",fees:"https://www.yobit.net/en/fees/"},api:{public:{get:{"depth/{pair}":1,info:1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{ActiveOrders:1,CancelOrder:1,GetDepositAddress:1,getInfo:1,OrderInfo:1,Trade:1,TradeHistory:1,WithdrawCoinsToAddress:1}}},fees:{trading:{maker:.002,taker:.002},funding:{withdraw:{}}},commonCurrencies:{AIR:"AirCoin",ANI:"ANICoin",ANT:"AntsCoin",ATMCHA:"ATM",ASN:"Ascension",AST:"Astral",ATM:"Autumncoin",AUR:"AuroraCoin",BAB:"Babel",BAN:"BANcoin",BCC:"BCH",BCS:"BitcoinStake",BITS:"Bitstar",BLN:"Bulleon",BNS:"Benefit Bonus Coin",BOT:"BOTcoin",BON:"BONES",BPC:"BitcoinPremium",BST:"BitStone",BTS:"Bitshares2",CAT:"BitClave",CBC:"CryptoBossCoin",CMT:"CometCoin",COIN:"Coin.com",COV:"Coven Coin",COVX:"COV",CPC:"Capricoin",CREDIT:"Creditbit",CS:"CryptoSpots",DCT:"Discount",DFT:"DraftCoin",DGD:"DarkGoldCoin",DIRT:"DIRTY",DROP:"FaucetCoin",DSH:"DASH",EGC:"EverGreenCoin",EGG:"EggCoin",EKO:"EkoCoin",ENTER:"ENTRC",EPC:"ExperienceCoin",ESC:"EdwardSnowden",EUROPE:"EUROP",EXT:"LifeExtension",FUND:"FUNDChains",FUNK:"FUNKCoin",FX:"FCoin",GCC:"GlobalCryptocurrency",GEN:"Genstake",GENE:"Genesiscoin",GMR:"Gimmer",GOLD:"GoldMint",GOT:"Giotto Coin",GSX:"GlowShares",GT:"GTcoin",HTML5:"HTML",HYPERX:"HYPER",ICN:"iCoin",INSANE:"INSN",JNT:"JointCoin",JPC:"JupiterCoin",JWL:"Jewels",KNC:"KingN Coin",LBTCX:"LiteBitcoin",LIZI:"LiZi",LOC:"LocoCoin",LOCX:"LOC",LUNYR:"LUN",LUN:"LunarCoin",LUNA:"Luna Coin",MASK:"Yobit MASK",MDT:"Midnight",MEME:"Memez Token",MIS:"MIScoin",MM:"MasterMint",NAV:"NavajoCoin",NBT:"NiceBytes",OMG:"OMGame",ONX:"Onix",PAC:"$PAC",PLAY:"PlayCoin",PIVX:"Darknet",PURE:"PurePOS",PUTIN:"PutinCoin",SPACE:"Spacecoin",STK:"StakeCoin",SUB:"Subscriptio",PAY:"EPAY",PLC:"Platin Coin",RAI:"RaiderCoin",RCN:"RCoin",REP:"Republicoin",RUR:"RUB",SBTC:"Super Bitcoin",SMC:"SmartCoin",SOLO:"SoloCoin",SOUL:"SoulCoin",STAR:"StarCoin",SUPER:"SuperCoin",TNS:"Transcodium",TTC:"TittieCoin",UNI:"Universe",UST:"Uservice",VOL:"VolumeCoin",XIN:"XINCoin",XMT:"SummitCoin",XRA:"Ratecoin"},options:{maxUrlLength:2048,fetchOrdersRequiresSymbol:!0,networks:{ETH:"ERC20",TRX:"TRC20",BSC:"BEP20"}},precisionMode:n.sh,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"The given order has already been cancelled":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"Total transaction amount":r.InvalidOrder,"The given order has already been closed and cannot be cancelled":r.InvalidOrder,"Insufficient funds":r.InsufficientFunds,"invalid key":r.AuthenticationError,"invalid nonce":r.InvalidNonce,"Total order amount is less than minimal amount":r.InvalidOrder,"Rate Limited":r.RateLimitExceeded}},orders:{}})}parseBalance(e){const t=this.safeValue(e,"return",{}),s=this.safeInteger(t,"server_time"),i={info:e,timestamp:s,datetime:this.iso8601(s)},r=this.safeValue(t,"funds",{}),a=this.safeValue(t,"funds_incl_orders",{}),n=Object.keys(this.extend(r,a));for(let e=0;e<n.length;e++){const t=n[e],s=this.safeCurrencyCode(t),o=this.account();o.free=this.safeString(r,t),o.total=this.safeString(a,t),i[s]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchMarkets(e={}){const t=await this.publicGetInfo(e),s=this.safeValue(t,"pairs",{}),i=Object.keys(s),r=[];for(let e=0;e<i.length;e++){const t=i[e],n=s[t],[o,d]=t.split("_");let h=o.toUpperCase(),c=d.toUpperCase();h=this.safeCurrencyCode(h),c=this.safeCurrencyCode(c);const l=this.safeInteger(n,"hidden");let u=this.safeString(n,"fee");u=a.O.stringDiv(u,"100"),r.push({id:t,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:o,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),maker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_amount"),max:this.safeNumber(n,"max_amount")},price:{min:this.safeNumber(n,"min_price"),max:this.safeNumber(n,"max_price")},cost:{min:this.safeNumber(n,"min_total"),max:void 0}},created:void 0,info:n})}return r}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),a={pair:i.id};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s));if(!(i.id in n))throw new r.ExchangeError(this.id+" "+i.symbol+" order book is empty or not available");const o=n[i.id];return this.parseOrderBook(o,e)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join("-"),i.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join("-");const a={pair:i};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s)),o={};i=Object.keys(n);for(let e=0;e<i.length;e++){const t=i[e],s=this.safeSymbol(t);o[s]=this.parseOrderBook(n[t],s)}return o}parseTicker(e,t=undefined){const s=this.safeTimestamp(e,"updated"),i=this.safeString(e,"last");return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:i,last:i,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickers(e=undefined,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+' fetchTickers() requires "symbols" argument');let s;await this.loadMarkets(),s=void 0===(e=this.marketSymbols(e))?this.ids:this.marketIds(e);const i=s.length,a=s.join("-"),n=this.safeInteger(this.options,"maxUrlLength",2048),o=a.length+30;if(o>n)throw new r.ArgumentsRequired(this.id+" fetchTickers() is being requested for "+i.toString()+" markets (which has an URL length of "+o.toString()+" characters), but it exceedes max URL length ("+n.toString()+"), please pass limisted symbols array to fetchTickers to fit in one request");const d={pair:a},h=await this.publicGetTickerPair(this.extend(d,t)),c={},l=Object.keys(h);for(let e=0;e<l.length;e++){const t=l[e],s=h[t],i=this.safeMarket(t);c[i.symbol]=this.parseTicker(s,i)}return this.filterByArrayTickers(c,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=undefined){const s=this.safeTimestamp(e,"timestamp");let i=this.safeString(e,"type");"ask"===i?i="sell":"bid"===i&&(i="buy");const r=this.safeString2(e,"rate","price"),a=this.safeString2(e,"trade_id","tid"),n=this.safeString(e,"order_id"),o=this.safeString(e,"pair"),d=this.safeSymbol(o,t),h=this.safeString(e,"amount"),c=this.parseNumber(r),l=this.parseNumber(h),u="limit";let f;const p=this.safeNumber(e,"commission");if(void 0!==p){const t=this.safeString(e,"commissionCurrency");f={cost:p,currency:this.safeCurrencyCode(t)}}if(void 0!==this.safeValue(e,"is_your_order")&&void 0===f){const e=this.calculateFee(d,u,i,l,c,"taker");f={currency:this.safeString(e,"currency"),cost:this.safeString(e,"cost"),rate:this.safeString(e,"rate")}}return this.safeTrade({id:a,order:n,timestamp:s,datetime:this.iso8601(s),symbol:d,type:u,side:i,takerOrMaker:void 0,price:r,amount:h,cost:void 0,fee:f,info:e},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==s&&(a.limit=s);const n=await this.publicGetTradesPair(this.extend(a,i));if(Array.isArray(n)){if(0===n.length)return[]}const o=this.safeValue(n,r.id,[]);return this.parseTrades(o,r,t,s)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.publicGetInfo(e),s=this.safeValue(t,"pairs",{}),i=Object.keys(s),r={};for(let e=0;e<i.length;e++){const t=i[e],n=this.safeValue(s,t,{}),o=this.safeSymbol(t,void 0,"_"),d=this.safeString(n,"fee_buyer"),h=this.safeString(n,"fee_seller"),c=this.parseNumber(a.O.stringDiv(d,"100")),l=this.parseNumber(a.O.stringDiv(h,"100"));r[o]={info:n,symbol:o,taker:c,maker:l,percentage:!0,tierBased:!1}}return r}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");await this.loadMarkets();const o=this.market(e),d={pair:o.id,type:s,amount:this.amountToPrecision(e,i),rate:this.priceToPrecision(e,a)},h=await this.privatePostTrade(this.extend(d,n)),c=this.safeValue(h,"return");return this.parseOrder(c,o)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostCancelOrder(this.extend(i,s)),a=this.safeValue(r,"return",{});return this.parseOrder(a)}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"open"},e,e)}parseOrder(e,t=undefined){let s=this.safeString2(e,"id","order_id"),i=this.parseOrderStatus(this.safeString(e,"status","open"));"0"===s&&(s=this.safeString(e,"init_order_id"),i="closed");const r=this.safeTimestamp2(e,"timestamp_created","server_time"),a=this.safeString(e,"pair"),n=this.safeSymbol(a,t),o=this.safeString(e,"start_amount"),d=this.safeString2(e,"amount","remains"),h=this.safeString(e,"received","0.0"),c=this.safeString(e,"rate"),l=this.safeString(e,"type");return this.safeOrder({info:e,id:s,clientOrderId:void 0,symbol:n,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:o,remaining:d,filled:h,status:i,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(i,s));e=e.toString();const a=this.safeValue(r,"return",{});return this.parseOrder(this.extend({id:e},a[e]))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a={};if(void 0!==e){const t=this.market(e);a.pair=t.id}const n=await this.privatePostActiveOrders(this.extend(a,i)),o=this.safeValue(n,"return",{});return this.parseOrders(o,undefined,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a `symbol` argument");await this.loadMarkets();const a=this.market(e),n={pair:a.id};void 0!==s&&(n.count=s),void 0!==t&&(n.since=this.parseToInt(t/1e3));const o=await this.privatePostTradeHistory(this.extend(n,i)),d=this.safeValue(o,"return",{}),h=Object.keys(d),c=[];for(let e=0;e<h.length;e++){const t=h[e],s=this.parseTrade(this.extend(d[t],{trade_id:t}),a);c.push(s)}return this.filterBySymbolSinceLimit(c,a.symbol,t,s)}async createDepositAddress(e,t={}){const s=await this.fetchDepositAddress(e,this.extend({need_new:1},t)),i=this.safeString(s,"address");return this.checkAddress(i),{currency:e,address:i,tag:void 0,info:s.info}}async fetchDepositAddress(e,t={}){await this.loadMarkets();let s=this.currency(e).id;const i=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(i,r,r),void 0!==r&&("ERC20"!==r&&(s+=r.toLowerCase()),t=this.omit(t,"network"));const a={coinName:s,need_new:0},n=await this.privatePostGetDepositAddress(this.extend(a,t)),o=this.safeString(n.return,"address");return this.checkAddress(o),{currency:e,address:o,tag:void 0,network:void 0,info:n}}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n={coinName:this.currency(e).id,amount:t,address:s};if(void 0!==i)throw new r.ExchangeError(this.id+" withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.");return{info:await this.privatePostWithdrawCoinsToAddress(this.extend(n,a)),id:void 0}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api[t];const d=this.omit(i,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const s=this.hmac(this.encode(a),this.encode(this.secret),o.o);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:s}}else"public"===t?(n+="/"+this.version+"/"+this.implodeParams(e,i),Object.keys(d).length&&(n+="?"+this.urlencode(d))):(n+="/"+this.implodeParams(e,i),"GET"===s?Object.keys(d).length&&(n+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&"success"in o){let e=this.safeValue(o,"success",!1);if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(o,"code"),t=this.safeString(o,"error"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}}},5934:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5224),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"zaif",name:"Zaif",countries:["JP"],rateLimit:100,version:"1",has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766927-39ca2ada-5eeb-11e7-972f-1b4199518ca6.jpg",api:{rest:"https://api.zaif.jp"},www:"https://zaif.jp",doc:["https://techbureau-api-document.readthedocs.io/ja/latest/index.html","https://corp.zaif.jp/api-docs","https://corp.zaif.jp/api-docs/api_links","https://www.npmjs.com/package/zaif.jp","https://github.com/you21979/node-zaif"],fees:"https://zaif.jp/fee?lang=en"},fees:{trading:{percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0")}},api:{public:{get:{"depth/{pair}":1,"currencies/{pair}":1,"currencies/all":1,"currency_pairs/{pair}":1,"currency_pairs/all":1,"last_price/{pair}":1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{active_orders:5,cancel_order:5,deposit_history:5,get_id_info:5,get_info:10,get_info2:5,get_personal_info:5,trade:5,trade_history:50,withdraw:5,withdraw_history:5}},ecapi:{post:{createInvoice:1,getInvoice:1,getInvoiceIdsByOrderNumber:1,cancelInvoice:1}},tlapi:{post:{get_positions:66,position_history:66,active_positions:5,create_position:33,change_position:33,cancel_position:33}},fapi:{get:{"groups/{group_id}":1,"last_price/{group_id}/{pair}":1,"ticker/{group_id}/{pair}":1,"trades/{group_id}/{pair}":1,"depth/{group_id}/{pair}":1}}},options:{fees:{"BTC/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.001")},"BCH/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.003")},"BCH/BTC":{maker:this.parseNumber("0"),taker:this.parseNumber("0.003")},"PEPECASH/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.0001")},"PEPECASH/BT":{maker:this.parseNumber("0"),taker:this.parseNumber("0.0001")}}},precisionMode:n.sh,exceptions:{exact:{"unsupported currency_pair":r.BadRequest},broad:{}}})}async fetchMarkets(e={}){const t=await this.publicGetCurrencyPairsAll(e),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"currency_pair"),a=this.safeString(i,"name"),[n,o]=a.split("/"),d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=d+"/"+h,l=this.safeValue(this.options.fees,c,this.fees.trading);s.push({id:r,symbol:c,base:d,quote:h,settle:void 0,baseId:n,quoteId:o,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:l.taker,maker:l.maker,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(i,"item_unit_step"),price:this.parseNumber(this.parsePrecision(this.safeString(i,"aux_unit_point")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(i,"item_unit_min"),max:void 0},price:{min:this.safeNumber(i,"aux_unit_min"),max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}parseBalance(e){const t=this.safeValue(e,"return",{}),s=this.safeValue(t,"deposit"),i={info:e,timestamp:void 0,datetime:void 0},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],n=this.safeCurrencyCode(t),o=this.safeString(r,t),d=this.account();d.free=o,d.total=o,void 0!==s&&t in s&&(d.total=this.safeString(s,t)),i[n]=d}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={pair:i.id},a=await this.publicGetDepthPair(this.extend(r,s));return this.parseOrderBook(a,i.symbol)}parseTicker(e,t=undefined){const s=this.safeSymbol(void 0,t),i=this.milliseconds(),r=this.safeString(e,"vwap"),n=this.safeString(e,"volume"),o=a.O.stringMul(n,r),d=this.safeString(e,"last");return this.safeTicker({symbol:s,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:r,open:void 0,close:d,last:d,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:n,quoteVolume:o,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={pair:s.id},r=await this.publicGetTickerPair(this.extend(i,t));return this.parseTicker(r,s)}parseTrade(e,t=undefined){let s=this.safeString(e,"trade_type");s="bid"===s?"buy":"sell";const i=this.safeTimestamp(e,"date"),r=this.safeString2(e,"id","tid"),a=this.safeString(e,"price"),n=this.safeString(e,"amount"),o=this.safeString(e,"currency_pair"),d=this.safeSymbol(o,t,"_");return this.safeTrade({id:r,info:e,timestamp:i,datetime:this.iso8601(i),symbol:d,type:void 0,side:s,order:void 0,takerOrMaker:void 0,price:a,amount:n,cost:void 0,fee:void 0},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};let n=await this.publicGetTradesPair(this.extend(a,i));if(1===n.length){const e=n[0];Object.keys(e).length||(n=[])}return this.parseTrades(n,r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){if(await this.loadMarkets(),"limit"!==t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const o=this.market(e),d={currency_pair:o.id,action:"buy"===s?"bid":"ask",amount:i,price:a},h=await this.privatePostTrade(this.extend(d,n));return this.safeOrder({info:h,id:h.return.order_id.toString()},o)}async cancelOrder(e,t=undefined,s={}){const i={order_id:e};return await this.privatePostCancelOrder(this.extend(i,s))}parseOrder(e,t=undefined){let s=this.safeString(e,"action");s="bid"===s?"buy":"sell";const i=this.safeTimestamp(e,"timestamp"),r=this.safeString(e,"currency_pair"),a=this.safeSymbol(r,t,"_"),n=this.safeString(e,"price"),o=this.safeString(e,"amount"),d=this.safeString(e,"id");return this.safeOrder({id:d,clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,status:"open",symbol:a,type:"limit",timeInForce:void 0,postOnly:void 0,side:s,price:n,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:o,filled:void 0,remaining:void 0,trades:void 0,fee:void 0,info:e,average:void 0},t)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const n=await this.privatePostActiveOrders(this.extend(a,i));return this.parseOrders(n.return,r,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const n=await this.privatePostTradeHistory(this.extend(a,i));return this.parseOrders(n.return,r,t,s)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e);if("JPY"===e)throw new r.ExchangeError(this.id+" withdraw() does not allow "+e+" withdrawals");const o={currency:n.id,amount:t,address:s};void 0!==i&&(o.message=i);const d=await this.privatePostWithdraw(this.extend(o,a)),h=this.safeValue(d,"return");return this.parseTransaction(h,n)}parseTransaction(e,t=undefined){let s;t=this.safeCurrency(void 0,t);const i=this.safeValue(e,"fee");return void 0!==i&&(s={cost:i,currency:t.code}),{id:this.safeString(e,"id"),txid:this.safeString(e,"txid"),timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:s,info:e}}customNonce(){const e=(this.milliseconds()/1e3).toString();return parseFloat(e).toFixed(8)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/";if("public"===t)n+="api/"+this.version+"/"+this.implodeParams(e,i);else if("fapi"===t)n+="fapi/"+this.version+"/"+this.implodeParams(e,i);else{this.checkRequiredCredentials(),n+="ecapi"===t?"ecapi":"tlapi"===t?"tlapi":"tapi";const s=this.customNonce();a=this.urlencode(this.extend({method:e,nonce:s},i)),r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:this.hmac(this.encode(a),this.encode(this.secret),o.o)}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.id+" "+n,l=this.safeString(o,"error");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c);if(!this.safeValue(o,"success",!0))throw new r.ExchangeError(c)}}},5140:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(3565),r=s(6689),a=s(9292),n=s(2194),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"zonda",name:"Zonda",countries:["EE"],rateLimit:1e3,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDeposits:void 0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:void 0,fetchTransfer:!1,fetchWithdrawal:!1,fetchWithdrawals:void 0,reduceMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"60","3m":"180","5m":"300","15m":"900","30m":"1800","1h":"3600","2h":"7200","4h":"14400","6h":"21600","12h":"43200","1d":"86400","3d":"259200","1w":"604800"},hostname:"zonda.exchange",urls:{referral:"https://auth.zondaglobal.com/ref/jHlbB4mIkdS1",logo:"https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg",www:"https://zondaglobal.com",api:{public:"https://{hostname}/API/Public",private:"https://{hostname}/API/Trading/tradingApi.php",v1_01Public:"https://api.{hostname}/rest",v1_01Private:"https://api.{hostname}/rest"},doc:["https://docs.zonda.exchange/","https://github.com/BitBayNet/API"],support:"https://zondaglobal.com/en/helpdesk/zonda-exchange",fees:"https://zondaglobal.com/legal/zonda-exchange/fees"},api:{public:{get:["{id}/all","{id}/market","{id}/orderbook","{id}/ticker","{id}/trades"]},private:{post:["info","trade","cancel","orderbook","orders","transfer","withdraw","history","transactions"]},v1_01Public:{get:["trading/ticker","trading/ticker/{symbol}","trading/stats","trading/stats/{symbol}","trading/orderbook/{symbol}","trading/transactions/{symbol}","trading/candle/history/{symbol}/{resolution}"]},v1_01Private:{get:["api_payments/deposits/crypto/addresses","payments/withdrawal/{detailId}","payments/deposit/{detailId}","trading/offer","trading/stop/offer","trading/config/{symbol}","trading/history/transactions","balances/BITBAY/history","balances/BITBAY/balance","fiat_cantor/rate/{baseId}/{quoteId}","fiat_cantor/history"],post:["trading/offer/{symbol}","trading/stop/offer/{symbol}","trading/config/{symbol}","balances/BITBAY/balance","balances/BITBAY/balance/transfer/{source}/{destination}","fiat_cantor/exchange"],delete:["trading/offer/{symbol}/{id}/{side}/{price}","trading/stop/offer/{symbol}/{id}/{side}/{price}"],put:["balances/BITBAY/balance/{id}"]}},fees:{trading:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.001"),percentage:!0,tierBased:!1},fiat:{maker:this.parseNumber("0.0030"),taker:this.parseNumber("0.0043"),percentage:!0,tierBased:!0,tiers:{taker:[[this.parseNumber("0.0043"),this.parseNumber("0")],[this.parseNumber("0.0042"),this.parseNumber("1250")],[this.parseNumber("0.0041"),this.parseNumber("3750")],[this.parseNumber("0.0040"),this.parseNumber("7500")],[this.parseNumber("0.0039"),this.parseNumber("10000")],[this.parseNumber("0.0038"),this.parseNumber("15000")],[this.parseNumber("0.0037"),this.parseNumber("20000")],[this.parseNumber("0.0036"),this.parseNumber("25000")],[this.parseNumber("0.0035"),this.parseNumber("37500")],[this.parseNumber("0.0034"),this.parseNumber("50000")],[this.parseNumber("0.0033"),this.parseNumber("75000")],[this.parseNumber("0.0032"),this.parseNumber("100000")],[this.parseNumber("0.0031"),this.parseNumber("150000")],[this.parseNumber("0.0030"),this.parseNumber("200000")],[this.parseNumber("0.0029"),this.parseNumber("250000")],[this.parseNumber("0.0028"),this.parseNumber("375000")],[this.parseNumber("0.0027"),this.parseNumber("500000")],[this.parseNumber("0.0026"),this.parseNumber("625000")],[this.parseNumber("0.0025"),this.parseNumber("875000")]],maker:[[this.parseNumber("0.0030"),this.parseNumber("0")],[this.parseNumber("0.0029"),this.parseNumber("1250")],[this.parseNumber("0.0028"),this.parseNumber("3750")],[this.parseNumber("0.0028"),this.parseNumber("7500")],[this.parseNumber("0.0027"),this.parseNumber("10000")],[this.parseNumber("0.0026"),this.parseNumber("15000")],[this.parseNumber("0.0025"),this.parseNumber("20000")],[this.parseNumber("0.0025"),this.parseNumber("25000")],[this.parseNumber("0.0024"),this.parseNumber("37500")],[this.parseNumber("0.0023"),this.parseNumber("50000")],[this.parseNumber("0.0023"),this.parseNumber("75000")],[this.parseNumber("0.0022"),this.parseNumber("100000")],[this.parseNumber("0.0021"),this.parseNumber("150000")],[this.parseNumber("0.0021"),this.parseNumber("200000")],[this.parseNumber("0.0020"),this.parseNumber("250000")],[this.parseNumber("0.0019"),this.parseNumber("375000")],[this.parseNumber("0.0018"),this.parseNumber("500000")],[this.parseNumber("0.0018"),this.parseNumber("625000")],[this.parseNumber("0.0017"),this.parseNumber("875000")]]}},funding:{withdraw:{}}},options:{fetchTickerMethod:"v1_01PublicGetTradingTickerSymbol",fetchTickersMethod:"v1_01PublicGetTradingTicker",fiatCurrencies:["EUR","USD","GBP","PLN"],transfer:{fillResponseFromRequest:!0}},precisionMode:a.sh,exceptions:{400:r.ExchangeError,401:r.InvalidOrder,402:r.InvalidOrder,403:r.InvalidOrder,404:r.InvalidOrder,405:r.InvalidOrder,406:r.InsufficientFunds,408:r.InvalidOrder,501:r.AuthenticationError,502:r.AuthenticationError,503:r.InvalidNonce,504:r.ExchangeError,505:r.AuthenticationError,506:r.AccountSuspended,509:r.ExchangeError,510:r.BadSymbol,FUNDS_NOT_SUFFICIENT:r.InsufficientFunds,OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS:r.InvalidOrder,OFFER_NOT_FOUND:r.OrderNotFound,OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED:r.OrderImmediatelyFillable,ACTION_LIMIT_EXCEEDED:r.RateLimitExceeded,UNDER_MAINTENANCE:r.OnMaintenance,REQUEST_TIMESTAMP_TOO_OLD:r.InvalidNonce,PERMISSIONS_NOT_SUFFICIENT:r.PermissionDenied,INVALID_STOP_RATE:r.InvalidOrder},commonCurrencies:{GGC:"Global Game Coin"}})}async fetchMarkets(e={}){const t=await this.v1_01PublicGetTradingTicker(e),s=this.safeValue(this.options,"fiatCurrencies",[]),i=[],r=this.safeValue(t,"items",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],n=r[t],o=this.safeValue(n,"market",{}),d=this.safeValue(o,"first",{}),h=this.safeValue(o,"second",{}),c=this.safeString(d,"currency"),l=this.safeString(h,"currency"),u=this.safeCurrencyCode(c),f=this.safeCurrencyCode(l);let p=this.safeValue(this.fees,"trading",{});(this.inArray(u,s)||this.inArray(f,s))&&(p=this.safeValue(this.fees,"fiat",{})),i.push({id:t,symbol:u+"/"+f,base:u,quote:f,settle:void 0,baseId:c,quoteId:l,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(p,"taker"),maker:this.safeNumber(p,"maker"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,optionType:void 0,strike:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(d,"scale"))),price:this.parseNumber(this.parsePrecision(this.safeString(h,"scale")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(d,"minOffer"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(h,"minOffer"),max:void 0}},created:void 0,info:n})}return i}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=await this.v1_01PrivateGetTradingOffer(this.extend({},i)),a=this.safeValue(r,"items",[]);return this.parseOrders(a,void 0,t,s,{status:"open"})}parseOrder(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"-"),r=this.safeInteger(e,"time"),a=this.safeString(e,"startAmount"),n=this.safeString(e,"currentAmount"),o=this.safeValue(e,"postOnly");return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:void 0,info:e,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,status:void 0,symbol:i,type:this.safeString(e,"mode"),timeInForce:void 0,postOnly:o,side:this.safeStringLower(e,"offerType"),price:this.safeString(e,"rate"),stopPrice:void 0,triggerPrice:void 0,amount:a,cost:void 0,filled:void 0,remaining:n,average:void 0,fee:void 0,trades:void 0},t)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};if(e){const t=[this.marketId(e)];e=this.symbol(e),r.markets=t}const a={query:this.json(this.extend(r,i))},n=await this.v1_01PrivateGetTradingHistoryTransactions(a),o=this.safeValue(n,"items"),d=this.parseTrades(o,void 0,t,s);return void 0===e?d:this.filterBySymbol(d,e)}parseBalance(e){const t=this.safeValue(e,"balances");if(void 0===t)throw new r.ExchangeError(this.id+" empty balance response "+this.json(e));const s={info:e};for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.used=this.safeString(i,"lockedFunds"),n.free=this.safeString(i,"availableFunds"),s[a]=n}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1_01PrivateGetBalancesBITBAYBalance(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={symbol:i.id},a=await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(r,s)),n=this.safeValue(a,"buy",[]),o=this.safeValue(a,"sell",[]),d=this.safeInteger(a,"timestamp");return{symbol:i.symbol,bids:this.parseBidsAsks(n,"ra","ca"),asks:this.parseBidsAsks(o,"ra","ca"),timestamp:d,datetime:this.iso8601(d),nonce:this.safeInteger(a,"seqNo")}}parseTicker(e,t=undefined){const s=this.safeValue(e,"market"),i=this.safeString2(s,"code","m");t=this.safeMarket(i,t);const r=this.safeInteger(e,"time"),a=this.safeValue(e,"rate");return this.safeTicker({symbol:this.safeSymbol(i,t),timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"h"),low:this.safeString(e,"l"),bid:this.safeNumber(e,"highestBid"),bidVolume:void 0,ask:this.safeNumber(e,"lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"r24h"),close:a,last:a,previousClose:this.safeValue(e,"previousRate"),change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"v"),quoteVolume:void 0,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},a="v1_01PublicGetTradingTickerSymbol",n=this.safeString(this.options,"fetchTickerMethod",a),o=this.safeString2(t,"method","fetchTickerMethod",n);let d;if(o===a)d=await this.v1_01PublicGetTradingTickerSymbol(this.extend(i,t));else{if("v1_01PublicGetTradingStatsSymbol"!==o)throw new r.BadRequest(this.id+' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');d=await this.v1_01PublicGetTradingStatsSymbol(this.extend(i,t))}const h=this.safeValue2(d,"ticker","stats");return this.parseTicker(h,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s="v1_01PublicGetTradingTicker",i=this.safeString(this.options,"fetchTickersMethod",s),a=this.safeString2(t,"method","fetchTickersMethod",i);let n;if(a===s)n=await this.v1_01PublicGetTradingTicker(t);else{if("v1_01PublicGetTradingStats"!==a)throw new r.BadRequest(this.id+' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');n=await this.v1_01PublicGetTradingStats(t)}const o=this.safeValue(n,"items");return this.parseTickers(o,e)}async fetchLedger(e=undefined,t=undefined,s=undefined,i={}){const r=[];if(void 0!==e){const t=this.currency(e);r.push(t.id)}let a={balanceCurrencies:r};void 0!==t&&(a.fromTime=t),void 0!==s&&(a.limit=s),a=this.extend(a,i);const n=(await this.v1_01PrivateGetBalancesBITBAYHistory({query:this.json(a)})).items;return this.parseLedger(n,void 0,t,s)}parseLedgerEntry(e,t=undefined){const s=this.safeInteger(e,"time"),i=this.safeValue(e,"balance",{}),r=this.safeString(i,"currency"),a=this.safeValue(e,"change",{});let o=this.safeString(a,"total"),d="in";n.O.stringLt(o,"0")&&(d="out",o=n.O.stringNeg(o));const h=this.safeValue(e,"fundsBefore",{}),c=this.safeValue(e,"fundsAfter",{});return{info:e,id:this.safeString(e,"historyId"),direction:d,account:void 0,referenceId:this.safeString(e,"detailId"),referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(r),amount:this.parseNumber(o),before:this.safeNumber(h,"total"),after:this.safeNumber(c,"total"),status:"ok",timestamp:s,datetime:this.iso8601(s),fee:void 0}}parseLedgerEntryType(e){return this.safeString({ADD_FUNDS:"transaction",BITCOIN_GOLD_FORK:"transaction",CREATE_BALANCE:"transaction",FUNDS_MIGRATION:"transaction",WITHDRAWAL_LOCK_FUNDS:"transaction",WITHDRAWAL_SUBTRACT_FUNDS:"transaction",WITHDRAWAL_UNLOCK_FUNDS:"transaction",TRANSACTION_COMMISSION_OUTCOME:"fee",TRANSACTION_COMMISSION_RETURN:"fee",TRANSACTION_OFFER_ABORTED_RETURN:"trade",TRANSACTION_OFFER_COMPLETED_RETURN:"trade",TRANSACTION_POST_INCOME:"trade",TRANSACTION_POST_OUTCOME:"trade",TRANSACTION_PRE_LOCKING:"trade"},e,e)}parseOHLCV(e,t=undefined){const s=this.safeValue(e,1,{});return[this.safeInteger(e,0),this.safeNumber(s,"o"),this.safeNumber(s,"h"),this.safeNumber(s,"l"),this.safeNumber(s,"c"),this.safeNumber(s,"v")]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.baseId+"-"+a.quoteId,resolution:this.safeString(this.timeframes,t,t)};void 0===i&&(i=100);const o=i*this.parseTimeframe(t)*1e3;void 0===s?(n.to=this.milliseconds(),n.from=n.to-o):(n.from=s,n.to=this.sum(n.from,o));const d=await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(n,r)),h=this.safeValue(d,"items",[]);return this.parseOHLCVs(h,a,t,s,i)}parseTrade(e,t=undefined){const s=this.safeInteger2(e,"time","t"),i=this.safeStringLower2(e,"userAction","ty"),r=this.safeValue(e,"wasTaker");let a;void 0!==r&&(a=r?"taker":"maker");const n=this.safeString2(e,"rate","r"),o=this.safeString2(e,"amount","a"),d=this.safeString(e,"commissionValue"),h=this.safeString(e,"market"),c=(t=this.safeMarket(h,t,"-")).symbol;let l;if(void 0!==d){l={currency:"buy"===i?t.base:t.quote,cost:d}}const u=this.safeString(e,"offerId");let f;return void 0!==u&&(f=u?"limit":"market"),this.safeTrade({id:this.safeString(e,"id"),order:u,timestamp:s,datetime:this.iso8601(s),symbol:c,type:f,side:i,price:n,amount:o,cost:void 0,takerOrMaker:a,fee:l,info:e},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.baseId+"-"+r.quoteId};void 0!==t&&(a.fromTime=t-1),void 0!==s&&(a.limit=s);const n=await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(a,i)),o=this.safeValue(n,"items");return this.parseTrades(o,r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d=o.baseId+"-"+o.quoteId;i=parseFloat(this.amountToPrecision(e,i));const h={symbol:d,offerType:s.toUpperCase(),amount:i},c=this.safeValue2(n,"stopPrice","stopLossPrice"),l=void 0!==c,u="limit"===t,f="market"===t,p="stop-limit"===t||u&&l,m="stop-market"===t||f&&l,g=p||m,y=g?"v1_01PrivatePostTradingStopOfferSymbol":"v1_01PrivatePostTradingOfferSymbol";if(u||p)h.rate=this.priceToPrecision(e,a),h.mode=p?"stop-limit":"limit";else{if(!f&&!m)throw new r.ExchangeError(this.id+" createOrder() invalid type");h.mode=m?"stop-market":"market"}if(g){if(!l)throw new r.ExchangeError(this.id+" createOrder() zonda requires `triggerPrice` or `stopPrice` parameter for stop-limit or stop-market orders");h.stopRate=this.priceToPrecision(e,c)}n=this.omit(n,["stopPrice","stopLossPrice"]);const v=await this[y](this.extend(h,n)),b=this.safeString2(v,"offerId","stopOfferId"),w=this.safeValue(v,"completed",!1)?"closed":"open",S=this.safeValue(v,"transactions");return this.safeOrder({id:b,info:v,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,status:w,symbol:e,type:t,side:s,price:a,amount:i,cost:void 0,filled:void 0,remaining:void 0,average:void 0,fee:void 0,trades:S,clientOrderId:void 0})}async cancelOrder(e,t=undefined,s={}){const i=this.safeString(s,"side");if(void 0===i)throw new r.ExchangeError(this.id+' cancelOrder() requires a `side` parameter ("buy" or "sell")');const a=this.safeValue(s,"price");if(void 0===a)throw new r.ExchangeError(this.id+" cancelOrder() requires a `price` parameter (float or string)");await this.loadMarkets();const n=this.market(t),o={symbol:n.baseId+"-"+n.quoteId,id:e,side:i,price:a};return await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(o,s))}isFiat(e){return this.safeValue({USD:!0,EUR:!0,PLN:!0},e,!1)}parseDepositAddress(e,t=undefined){const s=this.safeString(e,"currency"),i=this.safeString(e,"address");return this.checkAddress(i),{currency:this.safeCurrencyCode(s,t),address:i,tag:this.safeString(e,"tag"),network:void 0,info:e}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i={currency:s.id},r=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(i,t)),a=this.safeValue(r,"data"),n=this.safeValue(a,0);return this.parseDepositAddress(n,s)}async fetchDepositAddresses(e=undefined,t={}){await this.loadMarkets();const s=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(t),i=this.safeValue(s,"data");return this.parseDepositAddresses(i,e)}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n={source:s,destination:i,currency:e,funds:this.currencyToPrecision(e,t)},o=await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(n,r)),d=this.parseTransfer(o,a),h=this.safeValue(this.options,"transfer",{});return this.safeValue(h,"fillResponseFromRequest",!0)&&(d.amount=t),d}parseTransfer(e,t=undefined){const s=this.safeString(e,"status"),i=this.safeValue(e,"from",{}),r=this.safeString(i,"id"),a=this.safeValue(e,"to",{}),n=this.safeString(a,"id"),o=this.safeString(i,"currency");return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(o,t),amount:void 0,fromAccount:r,toAccount:n,status:this.parseTransferStatus(s)}}parseTransferStatus(e){return this.safeString({Ok:"ok",Fail:"failed"},e,e)}async withdraw(e,t,s,i=undefined,r={}){let a;[i,r]=this.handleWithdrawTagAndParams(i,r),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e),o={currency:n.id,quantity:t};this.isFiat(e)?a="privatePostWithdraw":(a="privatePostTransfer",void 0!==i&&(s+="?dt="+i.toString()),o.address=s);const d=await this[a](this.extend(o,r)),h=this.safeValue(d,"data");return this.parseTransaction(h,n)}parseTransaction(e,t=undefined){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.implodeHostname(this.urls.api[t]);if("public"===t){const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i)+".json",Object.keys(t).length&&(n+="?"+this.urlencode(t))}else if("v1_01Public"===t){const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i),Object.keys(t).length&&(n+="?"+this.urlencode(t))}else if("v1_01Private"===t){this.checkRequiredCredentials();const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i);const d=this.milliseconds().toString();let h;"POST"!==s?(Object.keys(t).length&&(n+="?"+this.urlencode(t)),h=this.apiKey+d):void 0===a&&(a=this.json(t),h=this.apiKey+d+a),r={"Request-Timestamp":d,"Operation-Id":this.uuid(),"API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(h),this.encode(this.secret),o.o),"Content-Type":"application/json"}}else this.checkRequiredCredentials(),a=this.urlencode(this.extend({method:e,moment:this.nonce()},i)),r={"Content-Type":"application/x-www-form-urlencoded","API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(a),this.encode(this.secret),o.o)};return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o){if("code"in o){const e=this.safeString(o,"code"),t=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions,e,t),new r.ExchangeError(t)}if("status"in o){if("Fail"===this.safeString(o,"status")){const e=this.safeValue(o,"errors"),t=this.id+" "+n;for(let s=0;s<e.length;s++){const i=e[s];this.throwExactlyMatchedException(this.exceptions,i,t)}throw new r.ExchangeError(t)}}}}}},7026:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},3183:e=>{var t=String.prototype.replace,s=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return t.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},3165:(e,t,s)=>{var i=s(6463),r=s(163),a=s(3183);e.exports={formats:a,parse:r,stringify:i}},163:(e,t,s)=>{var i=s(8584),r=Object.prototype.hasOwnProperty,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},n=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},o=function(e,t,s){if(e){var i=s.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,n=/(\[[^[\]]*])/.exec(i),o=n?i.slice(0,n.index):i,d=[];if(o){if(!s.plainObjects&&r.call(Object.prototype,o)&&!s.allowPrototypes)return;d.push(o)}for(var h=0;null!==(n=a.exec(i))&&h<s.depth;){if(h+=1,!s.plainObjects&&r.call(Object.prototype,n[1].slice(1,-1))&&!s.allowPrototypes)return;d.push(n[1])}return n&&d.push("["+i.slice(n.index)+"]"),function(e,t,s){for(var i=t,r=e.length-1;r>=0;--r){var a,n=e[r];if("[]"===n&&s.parseArrays)a=[].concat(i);else{a=s.plainObjects?Object.create(null):{};var o="["===n.charAt(0)&&"]"===n.charAt(n.length-1)?n.slice(1,-1):n,d=parseInt(o,10);s.parseArrays||""!==o?!isNaN(d)&&n!==o&&String(d)===o&&d>=0&&s.parseArrays&&d<=s.arrayLimit?(a=[])[d]=i:a[o]=i:a={0:i}}i=a}return i}(d,t,s)}};e.exports=function(e,t){var s=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||i.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth?e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return s.plainObjects?Object.create(null):{};for(var d="string"==typeof e?function(e,t){var s,o={},d=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,h=t.parameterLimit===1/0?void 0:t.parameterLimit,c=d.split(t.delimiter,h),l=-1,u=t.charset;if(t.charsetSentinel)for(s=0;s<c.length;++s)0===c[s].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[s]?u="utf-8":"utf8=%26%2310003%3B"===c[s]&&(u="iso-8859-1"),l=s,s=c.length);for(s=0;s<c.length;++s)if(s!==l){var f,p,m=c[s],g=m.indexOf("]="),y=-1===g?m.indexOf("="):g+1;-1===y?(f=t.decoder(m,a.decoder,u),p=t.strictNullHandling?null:""):(f=t.decoder(m.slice(0,y),a.decoder,u),p=t.decoder(m.slice(y+1),a.decoder,u)),p&&t.interpretNumericEntities&&"iso-8859-1"===u&&(p=n(p)),p&&t.comma&&p.indexOf(",")>-1&&(p=p.split(",")),r.call(o,f)?o[f]=i.combine(o[f],p):o[f]=p}return o}(e,s):e,h=s.plainObjects?Object.create(null):{},c=Object.keys(d),l=0;l<c.length;++l){var u=c[l],f=o(u,d[u],s);h=i.merge(h,f,s)}return i.compact(h)}},6463:(e,t,s)=>{var i=s(8584),r=s(3183),a=Object.prototype.hasOwnProperty,n={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},o=Array.isArray,d=Array.prototype.push,h=function(e,t){d.apply(e,o(t)?t:[t])},c=Date.prototype.toISOString,l={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,formatter:r.formatters[r.default],indices:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},u=function e(t,s,r,a,n,d,c,u,f,p,m,g,y){var v=t;if("function"==typeof c?v=c(s,v):v instanceof Date?v=p(v):"comma"===r&&o(v)&&(v=v.join(",")),null===v){if(a)return d&&!g?d(s,l.encoder,y):s;v=""}if("string"==typeof v||"number"==typeof v||"boolean"==typeof v||i.isBuffer(v))return d?[m(g?s:d(s,l.encoder,y))+"="+m(d(v,l.encoder,y))]:[m(s)+"="+m(String(v))];var b,w=[];if(void 0===v)return w;if(o(c))b=c;else{var S=Object.keys(v);b=u?S.sort(u):S}for(var k=0;k<b.length;++k){var O=b[k];n&&null===v[O]||(o(v)?h(w,e(v[O],"function"==typeof r?r(s,O):s,r,a,n,d,c,u,f,p,m,g,y)):h(w,e(v[O],s+(f?"."+O:"["+O+"]"),r,a,n,d,c,u,f,p,m,g,y)))}return w};e.exports=function(e,t){var s,i=e,d=function(e){if(!e)return l;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||l.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var s=r.default;if(void 0!==e.format){if(!a.call(r.formatters,e.format))throw new TypeError("Unknown format option provided.");s=e.format}var i=r.formatters[s],n=l.filter;return("function"==typeof e.filter||o(e.filter))&&(n=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:l.addQueryPrefix,allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,delimiter:void 0===e.delimiter?l.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:l.encode,encoder:"function"==typeof e.encoder?e.encoder:l.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:l.encodeValuesOnly,filter:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:l.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:l.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling}}(t);"function"==typeof d.filter?i=(0,d.filter)("",i):o(d.filter)&&(s=d.filter);var c,f=[];if("object"!=typeof i||null===i)return"";c=t&&t.arrayFormat in n?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=n[c];s||(s=Object.keys(i)),d.sort&&s.sort(d.sort);for(var m=0;m<s.length;++m){var g=s[m];d.skipNulls&&null===i[g]||h(f,u(i[g],g,p,d.strictNullHandling,d.skipNulls,d.encode?d.encoder:null,d.filter,d.sort,d.allowDots,d.serializeDate,d.formatter,d.encodeValuesOnly,d.charset))}var y=f.join(d.delimiter),v=!0===d.addQueryPrefix?"?":"";return d.charsetSentinel&&("iso-8859-1"===d.charset?v+="utf8=%26%2310003%3B&":v+="utf8=%E2%9C%93&"),y.length>0?v+y:""}},8584:e=>{var t=Object.prototype.hasOwnProperty,s=Array.isArray,i=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),r=function(e,t){for(var s=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)void 0!==e[i]&&(s[i]=e[i]);return s};e.exports={arrayToObject:r,assign:function(e,t){return Object.keys(t).reduce((function(e,s){return e[s]=t[s],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],i=[],r=0;r<t.length;++r)for(var a=t[r],n=a.obj[a.prop],o=Object.keys(n),d=0;d<o.length;++d){var h=o[d],c=n[h];"object"==typeof c&&null!==c&&-1===i.indexOf(c)&&(t.push({obj:n,prop:h}),i.push(c))}return function(e){for(;e.length>1;){var t=e.pop(),i=t.obj[t.prop];if(s(i)){for(var r=[],a=0;a<i.length;++a)void 0!==i[a]&&r.push(i[a]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,s){var i=e.replace(/\+/g," ");if("iso-8859-1"===s)return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch(e){return i}},encode:function(e,t,s){if(0===e.length)return e;var r="string"==typeof e?e:String(e);if("iso-8859-1"===s)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var a="",n=0;n<r.length;++n){var o=r.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122?a+=r.charAt(n):o<128?a+=i[o]:o<2048?a+=i[192|o>>6]+i[128|63&o]:o<55296||o>=57344?a+=i[224|o>>12]+i[128|o>>6&63]+i[128|63&o]:(n+=1,o=65536+((1023&o)<<10|1023&r.charCodeAt(n)),a+=i[240|o>>18]+i[128|o>>12&63]+i[128|o>>6&63]+i[128|63&o])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(i,a,n){if(!a)return i;if("object"!=typeof a){if(s(i))i.push(a);else{if(!i||"object"!=typeof i)return[i,a];(n&&(n.plainObjects||n.allowPrototypes)||!t.call(Object.prototype,a))&&(i[a]=!0)}return i}if(!i||"object"!=typeof i)return[i].concat(a);var o=i;return s(i)&&!s(a)&&(o=r(i,n)),s(i)&&s(a)?(a.forEach((function(s,r){if(t.call(i,r)){var a=i[r];a&&"object"==typeof a&&s&&"object"==typeof s?i[r]=e(a,s,n):i.push(s)}else i[r]=s})),i):Object.keys(a).reduce((function(s,i){var r=a[i];return t.call(s,i)?s[i]=e(s[i],r,n):s[i]=r,s}),o)}}},7348:(e,t,s)=>{s.d(t,{_Z:()=>V,n:()=>N});var i=Uint8Array,r=Uint16Array,a=Uint32Array,n=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),d=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var s=new r(31),i=0;i<31;++i)s[i]=t+=1<<e[i-1];var n=new a(s[30]);for(i=1;i<30;++i)for(var o=s[i];o<s[i+1];++o)n[o]=o-s[i]<<5|i;return[s,n]},c=h(n,2),l=c[0],u=c[1];l[28]=258,u[258]=28;for(var f=h(o,0),p=f[0],m=(f[1],new r(32768)),g=0;g<32768;++g){var y=(43690&g)>>>1|(21845&g)<<1;y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4,m[g]=((65280&y)>>>8|(255&y)<<8)>>>1}var v=function(e,t,s){for(var i=e.length,a=0,n=new r(t);a<i;++a)e[a]&&++n[e[a]-1];var o,d=new r(t);for(a=0;a<t;++a)d[a]=d[a-1]+n[a-1]<<1;if(s){o=new r(1<<t);var h=15-t;for(a=0;a<i;++a)if(e[a])for(var c=a<<4|e[a],l=t-e[a],u=d[e[a]-1]++<<l,f=u|(1<<l)-1;u<=f;++u)o[m[u]>>>h]=c}else for(o=new r(i),a=0;a<i;++a)e[a]&&(o[a]=m[d[e[a]-1]++]>>>15-e[a]);return o},b=new i(288);for(g=0;g<144;++g)b[g]=8;for(g=144;g<256;++g)b[g]=9;for(g=256;g<280;++g)b[g]=7;for(g=280;g<288;++g)b[g]=8;var w=new i(32);for(g=0;g<32;++g)w[g]=5;var S=v(b,9,1),k=v(w,5,1),O=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},T=function(e,t,s){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&s},I=function(e,t){var s=t/8|0;return(e[s]|e[s+1]<<8|e[s+2]<<16)>>(7&t)},x=function(e){return(e+7)/8|0},P=function(e,t,s){(null==t||t<0)&&(t=0),(null==s||s>e.length)&&(s=e.length);var n=new(2==e.BYTES_PER_ELEMENT?r:4==e.BYTES_PER_ELEMENT?a:i)(s-t);return n.set(e.subarray(t,s)),n},M=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(e,t,s){var i=new Error(t||M[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,A),!s)throw i;return i},C=function(e,t,s){var r=e.length;if(!r||s&&s.f&&!s.l)return t||new i(0);var a=!t||s,h=!s||s.i;s||(s={}),t||(t=new i(3*r));var c=function(e){var s=t.length;if(e>s){var r=new i(Math.max(2*s,e));r.set(t),t=r}},u=s.f||0,f=s.p||0,m=s.b||0,g=s.l,y=s.d,b=s.m,w=s.n,M=8*r;do{if(!g){u=T(e,f,1);var C=T(e,f+1,3);if(f+=3,!C){var E=e[(H=x(f)+4)-4]|e[H-3]<<8,_=H+E;if(_>r){h&&A(0);break}a&&c(m+E),t.set(e.subarray(H,_),m),s.b=m+=E,s.p=f=8*_,s.f=u;continue}if(1==C)g=S,y=k,b=9,w=5;else if(2==C){var B=T(e,f,31)+257,N=T(e,f+10,15)+4,V=B+T(e,f+5,31)+1;f+=14;for(var R=new i(V),L=new i(19),D=0;D<N;++D)L[d[D]]=T(e,f+3*D,7);f+=3*N;var q=O(L),F=(1<<q)-1,G=v(L,q,1);for(D=0;D<V;){var H,U=G[T(e,f,F)];if(f+=15&U,(H=U>>>4)<16)R[D++]=H;else{var W=0,j=0;for(16==H?(j=3+T(e,f,3),f+=2,W=R[D-1]):17==H?(j=3+T(e,f,7),f+=3):18==H&&(j=11+T(e,f,127),f+=7);j--;)R[D++]=W}}var K=R.subarray(0,B),Z=R.subarray(B);b=O(K),w=O(Z),g=v(K,b,1),y=v(Z,w,1)}else A(1);if(f>M){h&&A(0);break}}a&&c(m+131072);for(var z=(1<<b)-1,X=(1<<w)-1,Q=f;;Q=f){var Y=(W=g[I(e,f)&z])>>>4;if((f+=15&W)>M){h&&A(0);break}if(W||A(2),Y<256)t[m++]=Y;else{if(256==Y){Q=f,g=null;break}var J=Y-254;if(Y>264){var $=n[D=Y-257];J=T(e,f,(1<<$)-1)+l[D],f+=$}var ee=y[I(e,f)&X],te=ee>>>4;ee||A(3),f+=15ⅇZ=p[te];if(te>3){$=o[te];Z+=I(e,f)&(1<<$)-1,f+=$}if(f>M){h&&A(0);break}a&&c(m+131072);for(var se=m+J;m<se;m+=4)t[m]=t[m-Z],t[m+1]=t[m+1-Z],t[m+2]=t[m+2-Z],t[m+3]=t[m+3-Z];m=se}}s.l=g,s.p=Q,s.b=m,s.f=u,g&&(u=1,s.m=b,s.d=y,s.n=w)}while(!u);return m==t.length?t:P(t,0,m)},E=new i(0),_=function(e){31==e[0]&&139==e[1]&&8==e[2]||A(6,"invalid gzip data");var t=e[3],s=10;4&t&&(s+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[s++]);return s+(2&t)},B=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0};function N(e,t=undefined){return C(e,t)}function V(e,t=undefined){return C(e.subarray(_(e),-8),t||new i(B(e)))}var R="undefined"!=typeof TextDecoder&&new TextDecoder;try{R.decode(E,{stream:!0}),1}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6294:(e,t,s)=>{s.d(t,{f:()=>a});var i=s(2833),r=s(1532),a={};void 0!==a.asn1&&a.asn1||(a.asn1={}),a.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var s=t.substr(1).length;s%2==1?s+=1:t.match(/^[0-7]/)||(s+=2);for(var r="",a=0;a<s;a++)r+="f";t=new i.Jh(r,16).xor(e).add(i.Jh.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return hextopem(e,t)},this.newObject=function(e){var t=a.asn1,s=t.DERBoolean,i=t.DERInteger,r=t.DERBitString,n=t.DEROctetString,o=t.DERNull,d=t.DERObjectIdentifier,h=t.DEREnumerated,c=t.DERUTF8String,l=t.DERNumericString,u=t.DERPrintableString,f=t.DERTeletexString,p=t.DERIA5String,m=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERSequence,v=t.DERSet,b=t.DERTaggedObject,w=t.ASN1Util.newObject,S=Object.keys(e);if(1!=S.length)throw"key of param shall be only one.";var k=S[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+k+":"))throw"undefined key: "+k;if("bool"==k)return new s(e[k]);if("int"==k)return new i(e[k]);if("bitstr"==k)return new r(e[k]);if("octstr"==k)return new n(e[k]);if("null"==k)return new o(e[k]);if("oid"==k)return new d(e[k]);if("enum"==k)return new h(e[k]);if("utf8str"==k)return new c(e[k]);if("numstr"==k)return new l(e[k]);if("prnstr"==k)return new u(e[k]);if("telstr"==k)return new f(e[k]);if("ia5str"==k)return new p(e[k]);if("utctime"==k)return new m(e[k]);if("gentime"==k)return new g(e[k]);if("seq"==k){for(var O=e[k],T=[],I=0;I<O.length;I++){var x=w(O[I]);T.push(x)}return new y({array:T})}if("set"==k){for(O=e[k],T=[],I=0;I<O.length;I++){x=w(O[I]);T.push(x)}return new v({array:T})}if("tag"==k){var P=e[k];if("[object Array]"===Object.prototype.toString.call(P)&&3==P.length){var M=w(P[2]);return new b({tag:P[0],explicit:P[1],obj:M})}var A={};if(void 0!==P.explicit&&(A.explicit=P.explicit),void 0!==P.tag&&(A.tag=P.tag),void 0===P.obj)throw"obj shall be specified for 'tag'.";return A.obj=w(P.obj),new b(A)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},a.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",s=parseInt(e.substr(0,2),16),r=(t=Math.floor(s/40)+"."+s%40,""),a=2;a<e.length;a+=2){var n=("00000000"+parseInt(e.substr(a,2),16).toString(2)).slice(-8);if(r+=n.substr(1,7),"0"==n.substr(0,1))t=t+"."+new i.Jh(r,2).toString(10),r=""}return t},a.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},s=function(e){var s="",r=new i.Jh(e,10).toString(2),a=7-r.length%7;7==a&&(a=0);for(var n="",o=0;o<a;o++)n+="0";r=n+r;for(o=0;o<r.length-1;o+=7){var d=r.substr(o,7);o!=r.length-7&&(d="1"+d),s+=t(parseInt(d,2))}return s};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",a=e.split("."),n=40*parseInt(a[0])+parseInt(a[1]);r+=t(n),a.splice(0,2);for(var o=0;o<a.length;o++)r+=s(a[o]);return r},a.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var s=t.length/2;if(s>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+s).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},a.asn1.DERAbstractString=function(e){a.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(this.s)},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},r.u.lang.extend(a.asn1.DERAbstractString,a.asn1.ASN1Object),a.asn1.DERAbstractTime=function(e){a.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(e){return utc=e.getTime()+6e4*e.getTimezoneOffset(),new Date(utc)},this.formatDate=function(e,t,s){var i=this.zeroPadding,r=this.localDateToUTC(e),a=String(r.getFullYear());"utc"==t&&(a=a.substr(2,2));var n=a+i(String(r.getMonth()+1),2)+i(String(r.getDate()),2)+i(String(r.getHours()),2)+i(String(r.getMinutes()),2)+i(String(r.getSeconds()),2);if(!0===s){var o=r.getMilliseconds();if(0!=o){var d=i(String(o),3);n=n+"."+(d=d.replace(/[0]+$/,""))}}return n+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(e)},this.setByDateValue=function(e,t,s,i,r,a){var n=new Date(Date.UTC(e,t-1,s,i,r,a,0));this.setByDate(n)},this.getFreshValueHex=function(){return this.hV}},r.u.lang.extend(a.asn1.DERAbstractTime,a.asn1.ASN1Object),a.asn1.DERAbstractStructured=function(e){a.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},r.u.lang.extend(a.asn1.DERAbstractStructured,a.asn1.ASN1Object),a.asn1.DERBoolean=function(){a.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.u.lang.extend(a.asn1.DERBoolean,a.asn1.ASN1Object),a.asn1.DERInteger=function(e){a.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=a.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new i.Jh(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},r.u.lang.extend(a.asn1.DERInteger,a.asn1.ASN1Object),a.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=a.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}a.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var s="0"+e;this.hTLV=null,this.isModified=!0,this.hV=s+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var s=0;s<=t;s++)e+="0";var i="";for(s=0;s<e.length-1;s+=8){var r=e.substr(s,8),a=parseInt(r,2).toString(16);1==a.length&&(a="0"+a),i+=a}this.hTLV=null,this.isModified=!0,this.hV="0"+t+i},this.setByBooleanArray=function(e){for(var t="",s=0;s<e.length;s++)1==e[s]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),s=0;s<e;s++)t[s]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},r.u.lang.extend(a.asn1.DERBitString,a.asn1.ASN1Object),a.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=a.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}a.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},r.u.lang.extend(a.asn1.DEROctetString,a.asn1.DERAbstractString),a.asn1.DERNull=function(){a.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},r.u.lang.extend(a.asn1.DERNull,a.asn1.ASN1Object),a.asn1.DERObjectIdentifier=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},s=function(e){var s="",r=new i.Jh(e,10).toString(2),a=7-r.length%7;7==a&&(a=0);for(var n="",o=0;o<a;o++)n+="0";r=n+r;for(o=0;o<r.length-1;o+=7){var d=r.substr(o,7);o!=r.length-7&&(d="1"+d),s+=t(parseInt(d,2))}return s};a.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var i="",r=e.split("."),a=40*parseInt(r[0])+parseInt(r[1]);i+=t(a),r.splice(0,2);for(var n=0;n<r.length;n++)i+=s(r[n]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(e){var t=a.asn1.x509.OID.name2oid(e);if(""===t)throw"DERObjectIdentifier oidName undefined: "+e;this.setValueOidString(t)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e):void 0!==e.oid?this.setValueOidString(e.oid):void 0!==e.hex?this.setValueHex(e.hex):void 0!==e.name&&this.setValueName(e.name))},r.u.lang.extend(a.asn1.DERObjectIdentifier,a.asn1.ASN1Object),a.asn1.DEREnumerated=function(e){a.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=a.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new i.Jh(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},r.u.lang.extend(a.asn1.DEREnumerated,a.asn1.ASN1Object),a.asn1.DERUTF8String=function(e){a.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},r.u.lang.extend(a.asn1.DERUTF8String,a.asn1.DERAbstractString),a.asn1.DERNumericString=function(e){a.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},r.u.lang.extend(a.asn1.DERNumericString,a.asn1.DERAbstractString),a.asn1.DERPrintableString=function(e){a.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},r.u.lang.extend(a.asn1.DERPrintableString,a.asn1.DERAbstractString),a.asn1.DERTeletexString=function(e){a.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},r.u.lang.extend(a.asn1.DERTeletexString,a.asn1.DERAbstractString),a.asn1.DERIA5String=function(e){a.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},r.u.lang.extend(a.asn1.DERIA5String,a.asn1.DERAbstractString),a.asn1.DERUTCTime=function(e){a.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},r.u.lang.extend(a.asn1.DERUTCTime,a.asn1.DERAbstractTime),a.asn1.DERGeneralizedTime=function(e){a.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},r.u.lang.extend(a.asn1.DERGeneralizedTime,a.asn1.DERAbstractTime),a.asn1.DERSequence=function(e){a.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},r.u.lang.extend(a.asn1.DERSequence,a.asn1.DERAbstractStructured),a.asn1.DERSet=function(e){a.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var s=this.asn1Array[t];e.push(s.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},r.u.lang.extend(a.asn1.DERSet,a.asn1.DERAbstractStructured),a.asn1.DERTaggedObject=function(e){a.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,s){this.hT=t,this.isExplicit=e,this.asn1Object=s,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=s.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.tag&&(this.hT=e.tag),void 0!==e.explicit&&(this.isExplicit=e.explicit),void 0!==e.obj&&(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},r.u.lang.extend(a.asn1.DERTaggedObject,a.asn1.ASN1Object)},1532:(e,t,s)=>{s.d(t,{u:()=>i});
|
|
21
|
+
function i(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(...e){const t=(e,t)=>s=>e(t(s));return{encode:Array.from(e).reverse().reduce(((e,s)=>e?t(e,s.encode):s.encode),void 0),decode:e.reduce(((e,s)=>e?t(e,s.decode):s.decode),void 0)}}function a(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(i(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const s=e.indexOf(t);if(-1===s)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return s}))}}}function n(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function o(e,t="="){if(i(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(s){if(!Array.isArray(s)||s.length&&"string"!=typeof s[0])throw new Error("padding.encode input should be array of strings");for(let e of s)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;s.length*e%8;)s.push(t);return s},decode(s){if(!Array.isArray(s)||s.length&&"string"!=typeof s[0])throw new Error("padding.encode input should be array of strings");for(let e of s)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=s.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&s[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return s.slice(0,i)}}}function d(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function h(e,t,s){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(s<2)throw new Error(`convertRadix: wrong to=${s}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const a=[],n=Array.from(e);for(n.forEach((e=>{if(i(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,i=!0;for(let a=r;a<n.length;a++){const o=n[a],d=t*e+o;if(!Number.isSafeInteger(d)||t*e/t!==e||d-o!=t*e)throw new Error("convertRadix: carry overflow");if(e=d%s,n[a]=Math.floor(d/s),!Number.isSafeInteger(n[a])||n[a]*s+e!==d)throw new Error("convertRadix: carry overflow");i&&(n[a]?i=!1:r=a)}if(a.push(e),i)break}for(let t=0;t<e.length-1&&0===e[t];t++)a.push(0);return a.reverse()}s.d(t,{Jq:()=>S,KA:()=>A,US:()=>v,YU:()=>g,pJ:()=>y});const c=(e,t)=>t?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function u(e,t,s,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(s<=0||s>32)throw new Error(`convertRadix2: wrong to=${s}`);if(l(t,s)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${s} carryBits=${l(t,s)}`);let a=0,n=0;const o=2**s-1,d=[];for(const r of e){if(i(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(a=a<<t|r,n+t>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${t}`);for(n+=t;n>=s;n-=s)d.push((a>>n-s&o)>>>0);a&=2**n-1}if(a=a<<s-n&o,!r&&n>=t)throw new Error("Excess padding");if(!r&&a)throw new Error(`Non-zero padding: ${a}`);return r&&n>0&&d.push(a>>>0),d}function f(e){return i(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return h(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(h(t,e,256))}}}function p(e,t=!1){if(i(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:s=>{if(!(s instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(s),8,e,!t)},decode:s=>{if(!Array.isArray(s)||s.length&&"number"!=typeof s[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(s,e,8,t))}}}function m(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const g=r(p(4),a("0123456789abcdef"),n("")),y=r(p(5),a("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),o(5),n("")),v=(r(p(5),a("0123456789ABCDEFGHIJKLMNOPQRSTUV"),o(5),n("")),r(p(5),a("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),n(""),d((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o(6),n(""))),b=r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(6),n("")),w=e=>r(f(58),a(e),n("")),S=w("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),k=(w("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),w("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),O={encode(e){let t="";for(let s=0;s<e.length;s+=8){const i=e.subarray(s,s+8);t+=S.encode(i).padStart(k[i.length],"1")}return t},decode(e){let t=[];for(let s=0;s<e.length;s+=11){const i=e.slice(s,s+11),r=k.indexOf(i.length),a=S.decode(i);for(let e=0;e<a.length-r;e++)if(0!==a[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(a.slice(a.length-r)))}return Uint8Array.from(t)}},T=r(a("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),n("")),I=[996825010,642813549,513874426,1027748829,705979059];function x(e){const t=e>>25;let s=(33554431&e)<<5;for(let e=0;e<I.length;e++)1==(t>>e&1)&&(s^=I[e]);return s}function P(e,t,s=1){const i=e.length;let r=1;for(let t=0;t<i;t++){const s=e.charCodeAt(t);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);r=x(r)^s>>5}r=x(r);for(let t=0;t<i;t++)r=x(r)^31&e.charCodeAt(t);for(let e of t)r=x(r)^e;for(let e=0;e<6;e++)r=x(r);return r^=s,T.encode(u([r%2**30],30,5,!1))}function M(e){const t="bech32"===e?1:734539939,s=p(5),i=s.decode,r=s.encode,a=m(i);function n(e,s=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==s&&e.length>s)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${s})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const a=e.slice(0,r),n=e.slice(r+1);if(n.length<6)throw new Error("Data must be at least 6 characters long");const o=T.decode(n).slice(0,-6),d=P(a,o,t);if(!n.endsWith(d))throw new Error(`Invalid checksum in ${e}: expected "${d}"`);return{prefix:a,words:o}}return{encode:function(e,s,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(s)||s.length&&"number"!=typeof s[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof s);const r=e.length+7+s.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${T.encode(s)}${P(e,s,t)}`},decode:n,decodeToBytes:function(e){const{prefix:t,words:s}=n(e,!1);return{prefix:t,words:s,bytes:i(s)}},decodeUnsafe:m(n),fromWords:i,fromWordsUnsafe:a,toWords:r}}M("bech32"),M("bech32m");const A={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},C=r(p(4),a("0123456789abcdef"),n(""),d((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}))),E={utf8:A,hex:C,base16:g,base32:y,base64:v,base64url:b,base58:S,base58xmr:O};Object.keys(E).join(", ")},4224:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(6057),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"tidex",name:"Tidex",countries:["UK"],rateLimit:2e3,version:"3",userAgent:this.userAgents.chrome,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCurrencies:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/30781780-03149dc4-a12e-11e7-82bb-313b269d24d4.jpg",api:{web:"https://gate.tidex.com/api",public:"https://api.tidex.com/api/3",private:"https://api.tidex.com/tapi"},www:"https://tidex.com",doc:"https://tidex.com/exchange/public-api",referral:"https://tidex.com/exchange",fees:["https://tidex.com/exchange/assets-spec","https://tidex.com/exchange/pairs-spec"]},api:{web:{get:["currency","pairs","tickers","orders","ordershistory","trade-data","trade-data/{id}"]},public:{get:["info","ticker/{pair}","depth/{pair}","trades/{pair}"]},private:{post:["getInfoExt","getInfo","Trade","ActiveOrders","OrderInfo","CancelOrder","TradeHistory","getDepositAddress","createWithdraw","getWithdraw"]}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},commonCurrencies:{DSH:"DASH",EMGO:"MGO",MGO:"WMGO"},precisionMode:n.sh,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"IP restricted":r.PermissionDenied}},options:{fetchTickersMaxLength:2048},orders:{}})}async fetchCurrencies(e={}){const t=await this.webGetCurrency(e),s={};for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"symbol"),a=this.safeCurrencyCode(r);let n=!0===this.safeValue(i,"visible");const o=this.safeValue(i,"withdrawEnable",!0),d=this.safeValue(i,"depositEnable",!0);o&&d||(n=!1);const h=this.safeString(i,"name"),c=this.safeNumber(i,"withdrawFee");s[a]={id:r,code:a,name:h,active:n,deposit:d,withdraw:o,precision:this.parseNumber(this.parsePrecision(this.safeString(i,"amountPoint"))),funding:{withdraw:{active:o,fee:c},deposit:{active:d,fee:this.parseNumber("0")}},limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(i,"withdrawMinAmount"),max:void 0},deposit:{min:this.safeNumber(i,"depositMinAmount"),max:void 0}},info:i}}return s}async fetchMarkets(e={}){const t=(await this.publicGetInfo(e)).pairs,s=Object.keys(t),i=[];for(let e=0;e<s.length;e++){const r=s[e],n=t[r],[o,d]=r.split("_"),h=this.safeCurrencyCode(o),c=this.safeCurrencyCode(d),l=this.safeInteger(n,"hidden");let u=this.safeString(n,"fee");u=a.O.stringDiv(u,"100"),i.push({id:r,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:o,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_amount"),max:this.safeNumber(n,"max_amount")},price:{min:this.safeNumber(n,"min_price"),max:this.safeNumber(n,"max_price")},cost:{min:this.safeNumber(n,"min_total"),max:void 0}},created:void 0,info:n})}return i}parseBalance(e){const t=this.safeValue(e,"return"),s=this.safeTimestamp(t,"server_time"),i={info:e,timestamp:s,datetime:this.iso8601(s)},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],s=this.safeCurrencyCode(t),n=this.safeValue(r,t,{}),o=this.account();o.free=this.safeString(n,"value"),o.used=this.safeString(n,"inOrders"),i[s]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfoExt(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),a={pair:i.id};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s));if(!(i.id in n))throw new r.ExchangeError(this.id+" "+i.symbol+" order book is empty or not available");const o=n[i.id];return this.parseOrderBook(o,e)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join("-"),i.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join("-");const a={pair:i};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s)),o={};i=Object.keys(n);for(let e=0;e<i.length;e++){const t=i[e],s=this.safeSymbol(t);o[s]=this.parseOrderBook(n[t],s)}return o}parseTicker(e,t=undefined){const s=this.safeTimestamp(e,"updated");t=this.safeMarket(void 0,t);const i=this.safeString(e,"last");return this.safeTicker({symbol:t.symbol,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:i,last:i,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickers(e=undefined,t={}){let s;if(await this.loadMarkets(),void 0===(e=this.marketSymbols(e))){const e=this.ids.length;if(s=this.ids.join("-"),s.length>this.options.fetchTickersMaxLength){const t=this.safeInteger(this.options,"fetchTickersMaxLength",2048);throw new r.ArgumentsRequired(this.id+" fetchTickers() has "+e.toString()+" markets exceeding max URL length for this endpoint ("+t.toString()+" characters), please, specify a list of symbols of interest in the first argument to fetchTickers")}}else{s=this.marketIds(e).join("-")}const i={pair:s},a=await this.publicGetTickerPair(this.extend(i,t)),n={},o=Object.keys(a);for(let e=0;e<o.length;e++){const t=o[e],s=this.safeMarket(t);n[s.symbol]=this.parseTicker(a[t],s)}return this.filterByArrayTickers(n,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=undefined){const s=this.safeTimestamp(e,"timestamp");let i=this.safeString(e,"type");"ask"===i?i="sell":"bid"===i&&(i="buy");const r=this.safeString2(e,"rate","price"),n=this.safeString2(e,"trade_id","tid"),o=this.safeString(e,"order_id"),d=this.safeString(e,"pair"),h=this.safeSymbol(d,t),c=this.safeString(e,"amount"),l=this.parseNumber(r),u=this.parseNumber(c),f=this.parseNumber(a.O.stringMul(r,c)),p="limit";let m,g;const y=this.safeNumber(e,"commission");if(void 0!==y){const t=this.safeString(e,"commissionCurrency");g={cost:y,currency:this.safeCurrencyCode(t)}}const v=this.safeValue(e,"is_your_order");return void 0!==v&&(m="taker",v&&(m="maker"),void 0===g&&(g=this.calculateFee(h,p,i,u,l,m))),{id:n,order:o,timestamp:s,datetime:this.iso8601(s),symbol:h,type:p,side:i,takerOrMaker:m,price:l,amount:u,cost:f,fee:g,info:e}}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==s&&(a.limit=s);const n=await this.publicGetTradesPair(this.extend(a,i));if(Array.isArray(n)){if(0===n.length)return[]}return this.parseTrades(n[r.id],r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const o=i.toString(),d=a.toString();await this.loadMarkets();const h=this.market(e),c={pair:h.id,type:s,amount:this.amountToPrecision(e,i),rate:this.priceToPrecision(e,a)},l=await this.privatePostTrade(this.extend(c,n));let u,f="open",p="0.0",m=o;const g=this.safeValue(l,"return");void 0!==g&&(u=this.safeString(g,"order_id"),"0"===u&&(u=this.safeString(g,"init_order_id"),f="closed"),p=this.safeString(g,"received",p),m=this.safeString(g,"remains",o));const y=this.milliseconds();return this.safeOrder({id:u,timestamp:y,datetime:this.iso8601(y),lastTradeTimestamp:void 0,status:f,symbol:e,type:t,side:s,price:d,cost:void 0,amount:o,remaining:m,filled:p,fee:void 0,info:l,clientOrderId:void 0,average:void 0,trades:void 0},h)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)};return await this.privatePostCancelOrder(this.extend(i,s))}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"canceled"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"id"),i=this.parseOrderStatus(this.safeString(e,"status")),r=this.safeTimestamp(e,"timestamp_created"),a=this.safeString(e,"pair"),n=this.safeSymbol(a,t);let o,d;const h=this.safeString(e,"rate");"start_amount"in e?(d=this.safeString(e,"start_amount"),o=this.safeString(e,"amount")):o=this.safeString(e,"amount");return this.safeOrder({info:e,id:s,clientOrderId:void 0,symbol:n,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"type"),price:h,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:d,remaining:o,filled:void 0,status:i,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(i,s));e=e.toString();const a=this.safeValue(r,"return",{}),n=this.safeValue(a,e);return this.parseOrder(this.extend({id:e},n))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.pair=a.id);const n=await this.privatePostActiveOrders(this.extend(r,i)),o=this.safeValue(n,"return",[]);return this.parseOrders(o,a,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.pair=r.id),void 0!==s&&(a.count=s),void 0!==t&&(a.since=this.parseToInt(t/1e3));const n=await this.privatePostTradeHistory(this.extend(a,i)),o=this.safeValue(n,"return",[]);return this.parseTrades(o,r,t,s)}async withdraw(e,t,s,i=undefined,r={}){[i,r]=this.handleWithdrawTagAndParams(i,r),this.checkAddress(s),await this.loadMarkets();const a=this.currency(e),n={asset:a.id,amount:parseFloat(t),address:s};void 0!==i&&(n.memo=i);const o=await this.privatePostCreateWithdraw(this.extend(n,r)),d=this.safeValue(o,"return",{}),h=this.safeValue(d,"withdraw_info",{});return this.parseTransaction(h,a)}parseTransaction(e,t=undefined){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api[t];const d=this.omit(i,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const s=this.hmac(this.encode(a),this.encode(this.secret),o.o);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:s}}else"public"===t?(n+="/"+this.implodeParams(e,i),Object.keys(d).length&&(n+="?"+this.urlencode(d))):(n+="/"+this.implodeParams(e,i),"GET"===s?Object.keys(d).length&&(n+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&"success"in o){let e=this.safeValue(o,"success",!1);if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(o,"code"),t=this.safeString(o,"error"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}}},1067:(e,t,s)=>{s.d(t,{Z:()=>o});var i=s(1696),r=s(6689),a=s(2194),n=s(9292);class o extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"timex",name:"TimeX",countries:["AU"],version:"v1",rateLimit:1500,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,cancelOrders:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!0,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1},timeframes:{"1m":"I1","5m":"I5","15m":"I15","30m":"I30","1h":"H1","2h":"H2","4h":"H4","6h":"H6","12h":"H12","1d":"D1","1w":"W1"},urls:{logo:"https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg",api:{rest:"https://plasma-relay-backend.timex.io"},www:"https://timex.io",doc:"https://docs.timex.io",referral:"https://timex.io/?refcode=1x27vNkTbP1uwkCck"},api:{addressbook:{get:["me"],post:["","id/{id}","id/{id}/remove"]},custody:{get:["credentials","credentials/h/{hash}","credentials/k/{key}","credentials/me","credentials/me/address","deposit-addresses","deposit-addresses/h/{hash}"]},history:{get:["orders","orders/details","orders/export/csv","trades","trades/export/csv"]},currencies:{get:["a/{address}","i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},manager:{get:["deposits","transfers","withdrawals"]},markets:{get:["i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},public:{get:["candles","currencies","markets","orderbook","orderbook/raw","orderbook/v2","tickers","trades"]},statistics:{get:["address"]},trading:{get:["balances","fees","orders"],post:["orders","orders/json"],put:["orders","orders/json"],delete:["orders","orders/json"]},tradingview:{get:["config","history","symbol_info","time"]}},precisionMode:n.sh,exceptions:{exact:{0:r.ExchangeError,1:r.NotSupported,4e3:r.BadRequest,4001:r.BadRequest,4002:r.InsufficientFunds,4003:r.AuthenticationError,4004:r.AuthenticationError,4005:r.BadRequest,4006:r.BadRequest,4007:r.BadRequest,4300:r.PermissionDenied,4100:r.AuthenticationError,4400:r.OrderNotFound,5001:r.InvalidOrder,5002:r.ExchangeError,400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.OrderNotFound,429:r.RateLimitExceeded,500:r.ExchangeError,503:r.ExchangeNotAvailable},broad:{Insufficient:r.InsufficientFunds}},options:{expireIn:31536e3,fetchTickers:{period:"1d"},fetchTrades:{sort:"timestamp,asc"},fetchMyTrades:{sort:"timestamp,asc"},fetchOpenOrders:{sort:"createdAt,asc"},fetchClosedOrders:{sort:"createdAt,asc"},defaultSort:"timestamp,asc",defaultSortOrders:"createdAt,asc"}})}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e),s=[];for(let e=0;e<t.length;e++)s.push(this.parseMarket(t[e]));return s}async fetchCurrencies(e={}){const t=await this.publicGetCurrencies(e),s=[];for(let e=0;e<t.length;e++){const i=t[e];s.push(this.parseCurrency(i))}return this.indexBy(s,"code")}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){const a=this.safeString(i,"address");if(i=this.omit(i,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const n={address:a},o=await this.managerGetDeposits(this.extend(n,i)),d=this.safeCurrency(e);return this.parseTransactions(o,d,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){const a=this.safeString(i,"address");if(i=this.omit(i,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const n={address:a},o=await this.managerGetWithdrawals(this.extend(n,i)),d=this.safeCurrency(e);return this.parseTransactions(o,d,t,s)}getCurrencyByAddress(e){const t=this.currencies;for(let s=0;s<t.length;s++){const i=t[s],r=this.safeValue(i,"info",{});if(this.safeString(r,"address")===e)return i}}parseTransaction(e,t=undefined){const s=this.safeString(e,"timestamp"),i=this.safeString(e,"token","");return t=this.getCurrencyByAddress(i),{info:e,id:this.safeString(e,"transferHash"),txid:this.safeString(e,"txid"),timestamp:this.parse8601(s),datetime:s,network:void 0,address:void 0,addressTo:this.safeString(e,"to"),addressFrom:this.safeString(e,"from"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:this.safeNumber(e,"value"),currency:this.safeCurrencyCode(void 0,t),status:"ok",updated:void 0,fee:void 0}}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=this.safeString(this.options.fetchTickers,"period","1d"),i={period:this.timeframes[s]},r=await this.publicGetTickers(this.extend(i,t));return this.parseTickers(r,e)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i=this.safeString(this.options.fetchTickers,"period","1d"),r={market:s.id,period:this.timeframes[i]},a=await this.publicGetTickers(this.extend(r,t)),n=this.safeValue(a,0);return this.parseTicker(n,s)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={market:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.publicGetOrderbookV2(this.extend(i,s)),a=this.parse8601(this.safeString(r,"timestamp"));return this.parseOrderBook(r,e,a,"bid","ask","price","baseTokenAmount")}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a=this.safeValue(this.options,"fetchTrades",{}),n=this.safeValue(a,"sort","timestamp,asc"),o=this.safeString(i,"sort",n),d=this.omit(i,"sort"),h={market:r.id,sort:o};void 0!==t&&(h.from=this.iso8601(t)),void 0!==s&&(h.size=s);const c=await this.publicGetTrades(this.extend(h,d));return this.parseTrades(c,r,t,s)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={market:a.id,period:this.safeString(this.timeframes,t,t)},o=this.parseTimeframe(t);if(void 0===i&&(i=1e3),void 0!==s)n.from=this.iso8601(s),n.till=this.iso8601(this.sum(s,this.sum(i,1)*o*1e3));else{const e=this.milliseconds();n.till=this.iso8601(e),n.from=this.iso8601(e-i*o*1e3-1)}const d=await this.publicGetCandles(this.extend(n,r));return this.parseOHLCVs(d,a,t,s,i)}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.total=this.safeString(i,"totalBalance"),n.used=this.safeString(i,"lockedBalance"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.tradingGetBalances(e);return this.parseBalance(t)}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d=s.toUpperCase();let h=t.toUpperCase();this.safeValue(n,"postOnly",!1)&&(h="POST_ONLY",n=this.omit(n,["postOnly"]));const c={symbol:o.id,quantity:this.amountToPrecision(e,i),side:d,orderTypes:h};let l=n;if("LIMIT"===h||"POST_ONLY"===h){c.price=this.priceToPrecision(e,a);const s=this.safeInteger(this.options,"expireIn"),i=this.safeValue(n,"expireTime"),o=this.safeValue(n,"expireIn",s);if(void 0!==i)c.expireTime=i;else{if(void 0===o)throw new r.InvalidOrder(this.id+" createOrder() method requires a expireTime or expireIn param for a "+t+" order, you can also set the expireIn exchange-wide option");c.expireIn=o}l=this.omit(n,["expireTime","expireIn"])}else c.price=0;const u=await this.tradingPostOrders(this.extend(c,l)),f=this.safeValue(u,"orders",[]),p=this.safeValue(f,0,{});return this.parseOrder(p,o)}async editOrder(e,t,s,i,r=undefined,a=undefined,n={}){await this.loadMarkets();const o=this.market(t),d={id:e};void 0!==r&&(d.quantity=this.amountToPrecision(t,r)),void 0!==a&&(d.price=this.priceToPrecision(t,a));const h=await this.tradingPutOrders(this.extend(d,n));if("unchangedOrders"in h){const e=this.safeValue(h,"unchangedOrders",[]),t=this.safeString(e,0);return this.safeOrder({id:t,info:h})}const c=this.safeValue(h,"changedOrders",[]),l=this.safeValue(c,0,{}),u=this.safeValue(l,"newOrder",{});return this.parseOrder(u,o)}async cancelOrder(e,t=undefined,s={}){return await this.loadMarkets(),await this.cancelOrders([e],t,s)}async cancelOrders(e,t=undefined,s={}){await this.loadMarkets();const i={id:e};return await this.tradingDeleteOrders(this.extend(i,s))}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={orderHash:e},r=await this.historyGetOrdersDetails(i),a=this.safeValue(r,"order",{}),n=this.safeValue(r,"trades",[]);return this.parseOrder(this.extend(a,{trades:n}))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchOpenOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==s&&(d.size=s);const c=await this.tradingGetOrders(this.extend(d,o)),l=this.safeValue(c,"orders",[]);return this.parseOrders(l,h,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchClosedOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n,side:"BUY"};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==s&&(d.size=s);const c=await this.historyGetOrders(this.extend(d,o)),l=this.safeValue(c,"orders",[]);return this.parseOrders(l,h,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchMyTrades",{}),a=this.safeValue(r,"sort","timestamp,asc"),n=this.safeString(i,"sort",a),o=this.omit(i,"sort"),d={sort:n};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==s&&(d.size=s);const c=await this.historyGetTrades(this.extend(d,o)),l=this.safeValue(c,"trades",[]);return this.parseTrades(l,h,t,s)}parseTradingFee(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeNumber(e,"fee");return{info:e,symbol:this.safeSymbol(s,t),maker:i,taker:i}}async fetchTradingFee(e,t={}){await this.loadMarkets();const s=this.market(e),i={markets:s.id},r=await this.tradingGetFees(this.extend(i,t)),a=this.safeValue(r,0,{});return this.parseTradingFee(a,s)}parseMarket(e){const t=this.safeValue(e,"locked"),s=this.safeString(e,"symbol"),i=this.safeString(e,"baseCurrency"),r=this.safeString(e,"quoteCurrency"),n=this.safeCurrencyCode(i),o=this.safeCurrencyCode(r),d=this.safeString(e,"quantityIncrement"),h=this.safeString(e,"baseMinSize"),c=a.O.stringMax(d,h),l=this.safeString(e,"tickSize"),u=this.safeString(e,"quoteMinSize");return{id:s,symbol:n+"/"+o,base:n,quote:o,settle:void 0,baseId:i,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!t,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"quantityIncrement"),price:this.safeNumber(e,"tickSize")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(c),max:void 0},price:{min:this.parseNumber(l),max:void 0},cost:{min:u,max:void 0}},created:void 0,info:e}}parseCurrency(e){const t=this.safeString(e,"symbol"),s=this.safeCurrencyCode(t),i=this.safeString(e,"name"),r=this.safeValue(e,"depositEnabled"),a=this.safeValue(e,"withdrawalEnabled"),n=this.safeValue(e,"active"),o=r&&a&&n,d=this.safeString(e,"withdrawalFee"),h=this.safeInteger(e,"tradeDecimals");let c;if(void 0!==d&&void 0!==h){const e=d.length-h;if(e>0){const t=d.slice(0,e),s=d.slice(-e);c=this.parseNumber(t+"."+s)}else{let t=".";for(let s=0;s<-e;s++)t+="0";c=this.parseNumber(t+d)}}return{id:s,code:s,info:e,type:void 0,name:i,active:o,deposit:r,withdraw:a,fee:c,precision:this.parseNumber(this.parsePrecision(this.safeString(e,"decimals"))),limits:{withdraw:{min:c,max:void 0},amount:{min:void 0,max:void 0}},networks:{}}}parseTicker(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"/"),r=this.parse8601(this.safeString(e,"timestamp")),a=this.safeString(e,"last"),n=this.safeString(e,"open");return this.safeTicker({symbol:i,info:e,timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:n,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:this.safeString(e,"volumeQuote")},t)}parseTrade(e,t=undefined){const s=this.safeString(e,"symbol"),i=this.safeSymbol(s,t),r=this.parse8601(this.safeString(e,"timestamp")),n=this.safeString(e,"price"),o=this.safeString(e,"quantity"),d=this.parseNumber(n),h=this.parseNumber(o),c=this.parseNumber(a.O.stringMul(n,o)),l=this.safeString(e,"id"),u=this.safeStringLower2(e,"direction","side"),f=this.safeStringLower(e,"makerOrTaker");let p,m;void 0!==f&&(p=this.safeString(e,f+"OrderId"));const g=this.safeNumber(e,"fee"),y=this.safeCurrencyCode(this.safeString(e,"feeToken"));return void 0!==g&&(m={cost:g,currency:y}),{info:e,id:l,timestamp:r,datetime:this.iso8601(r),symbol:i,order:p,type:void 0,side:u,price:d,amount:h,cost:c,takerOrMaker:f,fee:m}}parseOHLCV(e,t=undefined){return[this.parse8601(this.safeString(e,"timestamp")),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}parseOrder(e,t=undefined){const s=this.safeString(e,"id"),i=this.safeStringLower(e,"type"),r=this.safeStringLower(e,"side"),n=this.safeString(e,"symbol"),o=this.safeSymbol(n,t),d=this.parse8601(this.safeString(e,"createdAt")),h=this.safeString(e,"price"),c=this.safeString(e,"quantity"),l=this.safeString(e,"filledQuantity"),u=this.omitZero(this.safeString(e,"cancelledQuantity"));let f;f=a.O.stringEquals(l,c)?"closed":void 0!==u?"canceled":"open";const p=this.safeValue(e,"trades",[]),m=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,id:s,clientOrderId:m,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:o,type:i,timeInForce:void 0,postOnly:void 0,side:r,price:h,stopPrice:void 0,triggerPrice:void 0,amount:c,cost:void 0,average:void 0,filled:l,remaining:void 0,status:f,fee:void 0,trades:p},t)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/"+t+"/"+e;if(Object.keys(i).length&&(n+="?"+this.urlencodeWithArrayRepeat(i)),"public"!==t){this.checkRequiredCredentials();r={authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&e>=400){const e=this.id+" "+n;let t=this.safeValue(o,"error");void 0===t&&(t=o);const s=this.safeString2(t,"code","status"),i=this.safeString2(t,"message","debugMessage");throw this.throwBroadlyMatchedException(this.exceptions.broad,i,e),this.throwExactlyMatchedException(this.exceptions.exact,s,e),this.throwExactlyMatchedException(this.exceptions.exact,i,e),new r.ExchangeError(e)}}}},5261:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(58),r=s(9292),a=s(6689),n=s(2194),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"tokocrypto",name:"Tokocrypto",countries:["ID"],certified:!1,pro:!1,version:"v1",has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:void 0,borrowMargin:void 0,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:void 0,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:void 0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:void 0,fetchBorrowRate:void 0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchBorrowRates:void 0,fetchBorrowRatesPerSymbol:void 0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchL3OrderBook:!1,fetchLedger:void 0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpg",api:{rest:{public:"https://www.tokocrypto.com",binance:"https://api.binance.com/api/v3",private:"https://www.tokocrypto.com"}},www:"https://tokocrypto.com",doc:"https://www.tokocrypto.com/apidocs/",fees:"https://www.tokocrypto.com/fees/newschedule"},api:{binance:{get:{ping:1,time:1,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},trades:1,aggTrades:1,historicalTrades:5,klines:1,"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:1,noSymbol:2},exchangeInfo:10},put:{userDataStream:1},post:{userDataStream:1},delete:{userDataStream:1}},public:{get:{"open/v1/common/time":1,"open/v1/common/symbols":1,"open/v1/market/depth":1,"open/v1/market/trades":1,"open/v1/market/agg-trades":1,"open/v1/market/klines":1}},private:{get:{"open/v1/orders/detail":1,"open/v1/orders":1,"open/v1/account/spot":1,"open/v1/account/spot/asset":1,"open/v1/orders/trades":1,"open/v1/withdraws":1,"open/v1/deposits":1,"open/v1/deposits/address":1},post:{"open/v1/orders":1,"open/v1/orders/cancel":1,"open/v1/orders/oco":1,"open/v1/withdraws":1,"open/v1/user-data-stream":1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0075"),maker:this.parseNumber("0.0075")}},precisionMode:r.nr,options:{createMarketBuyOrderRequiresPrice:!0,defaultTimeInForce:"GTC",hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,newOrderRespType:{market:"FULL",limit:"FULL"},quoteOrderQty:!1,networks:{ERC20:"ETH",TRC20:"TRX",BEP2:"BNB",BEP20:"BSC",OMNI:"OMNI",EOS:"EOS",SPL:"SOL"},reverseNetworks:{"tronscan.org":"TRC20","etherscan.io":"ERC20","bscscan.com":"BSC","explorer.binance.org":"BEP2","bithomp.com":"XRP","bloks.io":"EOS","stellar.expert":"XLM","blockchair.com/bitcoin":"BTC","blockchair.com/bitcoin-cash":"BCH","blockchair.com/ecash":"XEC","explorer.litecoin.net":"LTC","explorer.avax.network":"AVAX","solscan.io":"SOL","polkadot.subscan.io":"DOT","dashboard.internetcomputer.org":"ICP","explorer.chiliz.com":"CHZ","cardanoscan.io":"ADA","mainnet.theoan.com":"AION","algoexplorer.io":"ALGO","explorer.ambrosus.com":"AMB","viewblock.io/zilliqa":"ZIL","viewblock.io/arweave":"AR","explorer.ark.io":"ARK","atomscan.com":"ATOM","www.mintscan.io":"CTK","explorer.bitcoindiamond.org":"BCD","btgexplorer.com":"BTG","bts.ai":"BTS","explorer.celo.org":"CELO","explorer.nervos.org":"CKB","cerebro.cortexlabs.ai":"CTXC","chainz.cryptoid.info":"VIA","explorer.dcrdata.org":"DCR","digiexplorer.info":"DGB","dock.subscan.io":"DOCK","dogechain.info":"DOGE","explorer.elrond.com":"EGLD","blockscout.com":"ETC","explore-fetchhub.fetch.ai":"FET","filfox.info":"FIL","fio.bloks.io":"FIO","explorer.firo.org":"FIRO","neoscan.io":"NEO","ftmscan.com":"FTM","explorer.gochain.io":"GO","block.gxb.io":"GXS","hash-hash.info":"HBAR","www.hiveblockexplorer.com":"HIVE","explorer.helium.com":"HNT","tracker.icon.foundation":"ICX","www.iostabc.com":"IOST","explorer.iota.org":"IOTA","iotexscan.io":"IOTX","irishub.iobscan.io":"IRIS","kava.mintscan.io":"KAVA","scope.klaytn.com":"KLAY","kmdexplorer.io":"KMD","kusama.subscan.io":"KSM","explorer.lto.network":"LTO","polygonscan.com":"POLYGON","explorer.ont.io":"ONT","minaexplorer.com":"MINA","nanolooker.com":"NANO","explorer.nebulas.io":"NAS","explorer.nbs.plus":"NBS","explorer.nebl.io":"NEBL","nulscan.io":"NULS","nxscan.com":"NXS","explorer.harmony.one":"ONE","explorer.poa.network":"POA","qtum.info":"QTUM","explorer.rsk.co":"RSK","www.oasisscan.com":"ROSE","ravencoin.network":"RVN","sc.tokenview.com":"SC","secretnodes.com":"SCRT","explorer.skycoin.com":"SKY","steemscan.com":"STEEM","explorer.stacks.co":"STX","www.thetascan.io":"THETA","scan.tomochain.com":"TOMO","explore.vechain.org":"VET","explorer.vite.net":"VITE","www.wanscan.org":"WAN","wavesexplorer.com":"WAVES","wax.eosx.io":"WAXP","waltonchain.pro":"WTC","chain.nem.ninja":"XEM","verge-blockchain.info":"XVG","explorer.yoyow.org":"YOYOW","explorer.zcha.in":"ZEC","explorer.zensystem.io":"ZEN"},impliedNetworks:{ETH:{ERC20:"ETH"},TRX:{TRC20:"TRX"}},legalMoney:{MXN:!0,UGX:!0,SEK:!0,CHF:!0,VND:!0,AED:!0,DKK:!0,KZT:!0,HUF:!0,PEN:!0,PHP:!0,USD:!0,TRY:!0,EUR:!0,NGN:!0,PLN:!0,BRL:!0,ZAR:!0,KES:!0,ARS:!0,RUB:!0,AUD:!0,NOK:!0,CZK:!0,GBP:!0,UAH:!0,GHS:!0,HKD:!0,CAD:!0,INR:!0,JPY:!0,NZD:!0}},exceptions:{exact:{"System is under maintenance.":a.OnMaintenance,"System abnormality":a.ExchangeError,"You are not authorized to execute this request.":a.PermissionDenied,"API key does not exist":a.AuthenticationError,"Order would trigger immediately.":a.OrderImmediatelyFillable,"Stop price would trigger immediately.":a.OrderImmediatelyFillable,"Order would immediately match and take.":a.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":a.InsufficientFunds,"Rest API trading is not enabled.":a.ExchangeNotAvailable,"You don't have permission.":a.PermissionDenied,"Market is closed.":a.ExchangeNotAvailable,"Too many requests. Please try again later.":a.DDoSProtection,"This action disabled is on this account.":a.AccountSuspended,"-1000":a.ExchangeNotAvailable,"-1001":a.ExchangeNotAvailable,"-1002":a.AuthenticationError,"-1003":a.RateLimitExceeded,"-1004":a.DDoSProtection,"-1005":a.PermissionDenied,"-1006":a.BadResponse,"-1007":a.RequestTimeout,"-1010":a.BadResponse,"-1011":a.PermissionDenied,"-1013":a.InvalidOrder,"-1014":a.InvalidOrder,"-1015":a.RateLimitExceeded,"-1016":a.ExchangeNotAvailable,"-1020":a.BadRequest,"-1021":a.InvalidNonce,"-1022":a.AuthenticationError,"-1023":a.BadRequest,"-1099":a.AuthenticationError,"-1100":a.BadRequest,"-1101":a.BadRequest,"-1102":a.BadRequest,"-1103":a.BadRequest,"-1104":a.BadRequest,"-1105":a.BadRequest,"-1106":a.BadRequest,"-1108":a.BadRequest,"-1109":a.AuthenticationError,"-1110":a.BadRequest,"-1111":a.BadRequest,"-1112":a.InvalidOrder,"-1113":a.BadRequest,"-1114":a.BadRequest,"-1115":a.BadRequest,"-1116":a.BadRequest,"-1117":a.BadRequest,"-1118":a.BadRequest,"-1119":a.BadRequest,"-1120":a.BadRequest,"-1121":a.BadSymbol,"-1125":a.AuthenticationError,"-1127":a.BadRequest,"-1128":a.BadRequest,"-1130":a.BadRequest,"-1131":a.BadRequest,"-1136":a.BadRequest,"-2008":a.AuthenticationError,"-2010":a.ExchangeError,"-2011":a.OrderNotFound,"-2013":a.OrderNotFound,"-2014":a.AuthenticationError,"-2015":a.AuthenticationError,"-2016":a.BadRequest,"-2018":a.InsufficientFunds,"-2019":a.InsufficientFunds,"-2020":a.OrderNotFillable,"-2021":a.OrderImmediatelyFillable,"-2022":a.InvalidOrder,"-2023":a.InsufficientFunds,"-2024":a.InsufficientFunds,"-2025":a.InvalidOrder,"-2026":a.InvalidOrder,"-2027":a.InvalidOrder,"-2028":a.InsufficientFunds,"-3000":a.ExchangeError,"-3001":a.AuthenticationError,"-3002":a.BadSymbol,"-3003":a.BadRequest,"-3004":a.ExchangeError,"-3005":a.InsufficientFunds,"-3006":a.InsufficientFunds,"-3007":a.ExchangeError,"-3008":a.InsufficientFunds,"-3009":a.BadRequest,"-3010":a.ExchangeError,"-3011":a.BadRequest,"-3012":a.ExchangeError,"-3013":a.BadRequest,"-3014":a.AccountSuspended,"-3015":a.ExchangeError,"-3016":a.BadRequest,"-3017":a.ExchangeError,"-3018":a.AccountSuspended,"-3019":a.AccountSuspended,"-3020":a.InsufficientFunds,"-3021":a.BadRequest,"-3022":a.AccountSuspended,"-3023":a.BadRequest,"-3024":a.ExchangeError,"-3025":a.BadRequest,"-3026":a.BadRequest,"-3027":a.BadSymbol,"-3028":a.BadSymbol,"-3029":a.ExchangeError,"-3036":a.AccountSuspended,"-3037":a.ExchangeError,"-3038":a.BadRequest,"-3041":a.InsufficientFunds,"-3042":a.BadRequest,"-3043":a.BadRequest,"-3044":a.DDoSProtection,"-3045":a.ExchangeError,"-3999":a.ExchangeError,"-4001":a.BadRequest,"-4002":a.BadRequest,"-4003":a.BadRequest,"-4004":a.AuthenticationError,"-4005":a.RateLimitExceeded,"-4006":a.BadRequest,"-4007":a.BadRequest,"-4008":a.BadRequest,"-4010":a.BadRequest,"-4011":a.BadRequest,"-4012":a.BadRequest,"-4013":a.AuthenticationError,"-4014":a.PermissionDenied,"-4015":a.ExchangeError,"-4016":a.PermissionDenied,"-4017":a.PermissionDenied,"-4018":a.BadSymbol,"-4019":a.BadSymbol,"-4021":a.BadRequest,"-4022":a.BadRequest,"-4023":a.ExchangeError,"-4024":a.InsufficientFunds,"-4025":a.InsufficientFunds,"-4026":a.InsufficientFunds,"-4027":a.ExchangeError,"-4028":a.BadRequest,"-4029":a.BadRequest,"-4030":a.ExchangeError,"-4031":a.ExchangeError,"-4032":a.ExchangeError,"-4033":a.BadRequest,"-4034":a.ExchangeError,"-4035":a.PermissionDenied,"-4036":a.BadRequest,"-4037":a.ExchangeError,"-4038":a.ExchangeError,"-4039":a.BadRequest,"-4040":a.BadRequest,"-4041":a.ExchangeError,"-4042":a.ExchangeError,"-4043":a.BadRequest,"-4044":a.BadRequest,"-4045":a.ExchangeError,"-4046":a.AuthenticationError,"-4047":a.BadRequest,"-5001":a.BadRequest,"-5002":a.InsufficientFunds,"-5003":a.InsufficientFunds,"-5004":a.BadRequest,"-5005":a.InsufficientFunds,"-5006":a.BadRequest,"-5007":a.BadRequest,"-5008":a.InsufficientFunds,"-5009":a.BadRequest,"-5010":a.ExchangeError,"-5011":a.BadRequest,"-5012":a.ExchangeError,"-5013":a.InsufficientFunds,"-5021":a.BadRequest,"-6001":a.BadRequest,"-6003":a.BadRequest,"-6004":a.ExchangeError,"-6005":a.InvalidOrder,"-6006":a.BadRequest,"-6007":a.BadRequest,"-6008":a.BadRequest,"-6009":a.RateLimitExceeded,"-6011":a.BadRequest,"-6012":a.InsufficientFunds,"-6013":a.ExchangeError,"-6014":a.BadRequest,"-6015":a.BadRequest,"-6016":a.BadRequest,"-6017":a.BadRequest,"-6018":a.BadRequest,"-6019":a.AuthenticationError,"-6020":a.BadRequest,"-7001":a.BadRequest,"-7002":a.BadRequest,"-9000":a.InsufficientFunds,"-10017":a.BadRequest,"-11008":a.InsufficientFunds,"-12014":a.RateLimitExceeded,"-13000":a.BadRequest,"-13001":a.BadRequest,"-13002":a.BadRequest,"-13003":a.BadRequest,"-13004":a.BadRequest,"-13005":a.BadRequest,"-13006":a.InvalidOrder,"-13007":a.AuthenticationError,"-21001":a.BadRequest,"-21002":a.BadRequest,"-21003":a.BadRequest,100001003:a.BadRequest,2202:a.InsufficientFunds,3210:a.InvalidOrder,3203:a.InvalidOrder,3211:a.InvalidOrder,3207:a.InvalidOrder,3218:a.OrderNotFound},broad:{"has no operation privilege":a.PermissionDenied,MAX_POSITION:a.InvalidOrder}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetOpenV1CommonTime(e);return this.safeInteger(t,"serverTime")}async fetchMarkets(e={}){const t=await this.publicGetOpenV1CommonSymbols(e);this.options.adjustForTimeDifference&&await this.loadTimeDifference();const s=this.safeValue(t,"data",{}),i=this.safeValue(s,"list",[]),r=[];for(let e=0;e<i.length;e++){const t=i[e],s=this.safeString(t,"baseAsset"),a=this.safeString(t,"quoteAsset"),n=this.safeString(t,"symbol"),o=this.safeStringLower(t,"symbol"),d=this.safeString(t,"marginAsset"),h=this.safeCurrencyCode(s),c=this.safeCurrencyCode(a),l=this.safeCurrencyCode(d),u=h+"/"+c,f=this.safeValue(t,"filters",[]),p=this.indexBy(f,"filterType");let m="1"===this.safeString(t,"spotTradingEnable");const g=this.safeValue(t,"permissions",[]);for(let e=0;e<g.length;e++)if("TRD_GRP_003"===g[e]){m=!1;break}const y={id:n,lowercaseId:o,symbol:u,base:h,quote:c,settle:l,baseId:s,quoteId:a,settleId:d,type:"spot",spot:!0,margin:this.safeValue(t,"isMarginTradingAllowed",!1),swap:!1,future:!1,delivery:!1,option:!1,active:m,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.safeInteger(t,"quantityPrecision"),price:this.safeInteger(t,"pricePrecision"),base:this.safeInteger(t,"baseAssetPrecision"),quote:this.safeInteger(t,"quotePrecision")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t};if("PRICE_FILTER"in p){const e=this.safeValue(p,"PRICE_FILTER",{}),t=this.safeString(e,"tickSize");y.precision.price=this.precisionFromString(t),y.limits.price={min:this.safeNumber(e,"minPrice"),max:this.safeNumber(e,"maxPrice")},y.precision.price=this.precisionFromString(e.tickSize)}if("LOT_SIZE"in p){const e=this.safeValue(p,"LOT_SIZE",{}),t=this.safeString(e,"stepSize");y.precision.amount=this.precisionFromString(t),y.limits.amount={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MARKET_LOT_SIZE"in p){const e=this.safeValue(p,"MARKET_LOT_SIZE",{});y.limits.market={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MIN_NOTIONAL"in p){const e=this.safeValue(p,"MIN_NOTIONAL",{});y.limits.cost.min=this.safeNumber2(e,"minNotional","notional")}r.push(y)}return r}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={};let a;void 0!==t&&(r.limit=t),"USDT"===i.quote?(r.symbol=i.baseId+i.quoteId,a=await this.binanceGetDepth(this.extend(r,s))):(r.symbol=i.id,a=await this.publicGetOpenV1MarketDepth(this.extend(r,s)));const n=this.safeValue(a,"data",a),o=this.safeInteger2(a,"T","timestamp"),d=this.parseOrderBook(n,e,o);return d.nonce=this.safeInteger(n,"lastUpdateId"),d}parseTrade(e,t=undefined){const s=this.safeInteger2(e,"T","time"),i=this.safeString2(e,"p","price"),r=this.safeString2(e,"q","qty"),a=this.safeString2(e,"quoteQty","baseQty"),n=this.safeString(e,"symbol"),o=this.safeSymbol(n,t);let d,h=this.safeString2(e,"t","a");h=this.safeString2(e,"id","tradeId",h);const c=this.safeString(e,"orderId"),l=this.safeValue2(e,"m","isBuyerMaker");let u,f;return void 0!==l?(d=l?"sell":"buy",u="taker"):"side"in e?d=this.safeStringLower(e,"side"):"isBuyer"in e&&(d=e.isBuyer?"buy":"sell"),"commission"in e&&(f={cost:this.safeString(e,"commission"),currency:this.safeCurrencyCode(this.safeString(e,"commissionAsset"))}),"isMaker"in e&&(u=e.isMaker?"maker":"taker"),"maker"in e&&(u=e.maker?"maker":"taker"),this.safeTrade({info:e,timestamp:s,datetime:this.iso8601(s),symbol:o,id:h,order:c,type:void 0,side:d,takerOrMaker:u,price:i,amount:r,cost:a,fee:f},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:this.getMarketIdByType(r)};if("USDT"!==r.quote){void 0!==s&&(a.limit=s);const e=this.publicGetOpenV1MarketTrades(this.extend(a,i)),n=this.safeValue(e,"data",{});return this.parseTrades(n,r,t,s)}const n=this.safeString(this.options,"fetchTradesMethod","binanceGetTrades");"binanceGetAggTrades"===n&&void 0!==t&&(a.startTime=t,a.endTime=this.sum(t,36e5)),void 0!==s&&(a.limit=s);const o=await this[n](this.extend(a,i));return this.parseTrades(o,r,t,s)}parseTicker(e,t=undefined){const s=this.safeInteger(e,"closeTime"),i=this.safeString(e,"symbol"),r=this.safeSymbol(i,t),a=this.safeString(e,"lastPrice");let n,o;return"baseVolume"in e?(n=this.safeString(e,"baseVolume"),o=this.safeString(e,"volume")):(n=this.safeString(e,"volume"),o=this.safeString(e,"quoteVolume")),this.safeTicker({symbol:r,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"highPrice"),low:this.safeString(e,"lowPrice"),bid:this.safeString(e,"bidPrice"),bidVolume:this.safeString(e,"bidQty"),ask:this.safeString(e,"askPrice"),askVolume:this.safeString(e,"askQty"),vwap:this.safeString(e,"weightedAvgPrice"),open:this.safeString(e,"openPrice"),close:a,last:a,previousClose:this.safeString(e,"prevClosePrice"),change:this.safeString(e,"priceChange"),percentage:this.safeString(e,"priceChangePercent"),average:void 0,baseVolume:n,quoteVolume:o,info:e},t)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=this.safeString(this.options,"fetchTickersMethod","binanceGetTicker24hr"),i=await this[s](t);return this.parseTickers(i,e)}getMarketIdByType(e){return"USDT"===e.quote?e.baseId+e.quoteId:e.id}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.baseId+s.quoteId},r=await this.binanceGetTicker24hr(this.extend(i,t));if(Array.isArray(r)){const e=this.safeValue(r,0,{});return this.parseTicker(e,s)}return this.parseTicker(r,s)}async fetchBidsAsks(e=undefined,t={}){await this.loadMarkets();const s=await this.binanceGetTickerBookTicker(t);return this.parseTickers(s,e)}parseOHLCV(e,t=undefined){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n=this.safeString(r,"price"),o=this.safeInteger(r,"until");r=this.omit(r,["price","until"]),i=void 0===i?500:Math.min(i,1500);const d={interval:this.safeString(this.timeframes,t,t),limit:i};let h;"index"===n?d.pair=a.id:d.symbol=this.getMarketIdByType(a),void 0!==s&&(d.startTime=s),void 0!==o&&(d.endTime=o),h="USDT"===a.quote?await this.binanceGetKlines(this.extend(d,r)):await this.publicGetOpenV1MarketKlines(this.extend(d,r));const c=this.safeValue(h,"data",h);return this.parseOHLCVs(c,a,t,s,i)}async fetchBalance(e={}){await this.loadMarkets();const t=this.safeString2(this.options,"fetchBalance","defaultType","spot"),s=this.safeString(e,"type",t),i=this.safeString2(this.options,"marginMode","defaultMarginMode"),r=this.safeStringLower(e,"marginMode",i),a=await this.privateGetOpenV1AccountSpot(this.extend({},e));return this.parseBalance(a,s,r)}parseBalance(e,t=undefined,s=undefined){const i=this.safeInteger(e,"updateTime"),r={info:e,timestamp:i,datetime:this.iso8601(i)},a=this.safeValue(e,"data",{}),n=this.safeValue(a,"accountAssets",[]);for(let e=0;e<n.length;e++){const t=n[e],s=this.safeString(t,"asset"),i=this.safeCurrencyCode(s),a=this.account();a.free=this.safeString(t,"free"),a.used=this.safeString(t,"locked"),r[i]=a}return this.safeBalance(r)}parseOrderStatus(e){return this.safeString({"-2":"open",0:"open",1:"open",2:"closed",3:"canceled",4:"canceling",5:"rejected",6:"expired",NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",PENDING_CANCEL:"canceling",REJECTED:"rejected",EXPIRED:"expired"},e,e)}parseOrder(e,t=undefined){const s=this.parseOrderStatus(this.safeString(e,"status")),i=this.safeString(e,"symbol"),r=this.safeSymbol(i,t),a=this.safeString(e,"executedQty","0"),n=this.safeInteger(e,"createTime"),o=this.safeString(e,"avgPrice"),d=this.safeString2(e,"price","executedPrice"),h=this.safeString(e,"origQty"),c=this.safeStringN(e,["cummulativeQuoteQty","cumQuote","executedQuoteQty","cumBase"]),l=this.safeString(e,"orderId"),u=this.parseOrderType(this.safeStringLower(e,"type"));let f=this.safeStringLower(e,"side");"0"===f?f="buy":"1"===f&&(f="sell");const p=this.safeValue(e,"fills",[]),m=this.safeString2(e,"clientOrderId","clientId");let g=this.safeString(e,"timeInForce");"GTX"===g&&(g="PO");const y="limit_maker"===u||"PO"===g,v=this.safeString(e,"stopPrice"),b=this.parseNumber(this.omitZero(v));return this.safeOrder({info:e,id:l,clientOrderId:m,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:void 0,symbol:r,type:u,timeInForce:g,postOnly:y,reduceOnly:this.safeValue(e,"reduceOnly"),side:f,price:d,stopPrice:b,triggerPrice:b,amount:h,cost:c,average:o,filled:a,remaining:void 0,status:s,fee:void 0,trades:p},t)}parseOrderType(e){return this.safeString({2:"market",1:"limit",4:"limit",7:"limit"},e,e)}async createOrder(e,t,s,i,o=undefined,d={}){await this.loadMarkets();const h=this.market(e),c=this.safeString2(d,"clientOrderId","clientId");this.safeValue(d,"postOnly",!1)&&(t="LIMIT_MAKER"),d=this.omit(d,["clientId","clientOrderId"]);const l=t.toUpperCase();let u=l;const f=this.safeValue2(d,"triggerPrice","stopPrice");void 0!==f&&(d=this.omit(d,["triggerPrice","stopPrice"]),"MARKET"===u?u="STOP_LOSS":"LIMIT"===u&&(u="STOP_LOSS_LIMIT"));const p=this.safeValue(h.info,"orderTypes");if(!this.inArray(u,p))throw l!==u?new a.InvalidOrder(this.id+" stopPrice parameter is not allowed for "+e+" "+t+" orders"):new a.InvalidOrder(this.id+" "+t+" is not a valid order type for the "+e+" market");const m={symbol:h.baseId+"_"+h.quoteId,type:this.safeString({LIMIT:1,MARKET:2,STOP_LOSS:3,STOP_LOSS_LIMIT:4,TAKE_PROFIT:5,TAKE_PROFIT_LIMIT:6,LIMIT_MAKER:7},u)};if("buy"===s?m.side=0:"sell"===s&&(m.side=1),void 0===c){const e=this.safeValue(this.options,"broker");if(void 0!==e){const t=this.safeString(e,"marketType");void 0!==t&&(m.clientId=t+this.uuid22())}}else m.clientId=c;let g=!1,y=!1,v=!1;if("MARKET"===u){const e=this.safeValue2(d,"quoteOrderQty","cost");if(this.options.createMarketBuyOrderRequiresPrice&&"buy"===s&&void 0===o&&void 0===e)throw new a.InvalidOrder(this.id+" createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter");const t=h.precision.price;if(void 0!==e)m.quoteOrderQty=this.decimalToPrecision(e,r.tk,t,this.precisionMode),d=this.omit(d,["quoteOrderQty","cost"]);else if(void 0!==o){const e=this.numberToString(i),s=this.numberToString(o),a=n.O.stringMul(e,s);m.quoteOrderQty=this.decimalToPrecision(a,r.tk,t,this.precisionMode)}else v=!0}else"LIMIT"===u?(g=!0,v=!0):"STOP_LOSS"===u||"TAKE_PROFIT"===u?(y=!0,v=!0,(h.linear||h.inverse)&&(g=!0)):"STOP_LOSS_LIMIT"===u||"TAKE_PROFIT_LIMIT"===u?(v=!0,y=!0,g=!0):"LIMIT_MAKER"===u&&(g=!0,v=!0);if(v&&(m.quantity=this.amountToPrecision(e,i)),g){if(void 0===o)throw new a.InvalidOrder(this.id+" createOrder() requires a price argument for a "+t+" order");m.price=this.priceToPrecision(e,o)}if(y){if(void 0===f)throw new a.InvalidOrder(this.id+" createOrder() requires a stopPrice extra param for a "+t+" order");m.stopPrice=this.priceToPrecision(e,f)}const b=await this.privatePostOpenV1Orders(this.extend(m,d)),w=this.safeValue(b,"data",{});return this.parseOrder(w,h)}async fetchOrder(e,t=undefined,s={}){const i={orderId:e},r=await this.privateGetOpenV1Orders(this.extend(i,s)),a=this.safeValue(r,"data",{}),n=this.safeValue(a,"list",[]),o=this.safeValue(n,0,{});return this.parseOrder(o)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const r=this.market(e),n={symbol:r.id};void 0!==t&&(n.startTime=t),void 0!==s&&(n.limit=s);const o=await this.privateGetOpenV1Orders(this.extend(n,i)),d=this.safeValue(o,"data",{}),h=this.safeValue(d,"list",[]);return this.parseOrders(h,r,t,s)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrders(e,t,s,this.extend({type:1},i))}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrders(e,t,s,this.extend({type:2},i))}async cancelOrder(e,t=undefined,s={}){const i={orderId:e},r=await this.privatePostOpenV1OrdersCancel(this.extend(i,s)),a=this.safeValue(r,"data",{});return this.parseOrder(a)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const r=this.market(e),n={symbol:r.id},o=this.safeInteger2(i,"until","endTime");void 0!==t&&(n.startTime=t),void 0!==o&&(n.endTime=o,i=this.omit(i,["endTime","until"])),void 0!==s&&(n.limit=s);const d=await this.privateGetOpenV1OrdersTrades(this.extend(n,i)),h=this.safeValue(d,"data",{}),c=this.safeValue(h,"list",[]);return this.parseTrades(c,r,t,s)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s={asset:this.currency(e).id},i=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(i,r,r),void 0!==r&&(s.network=r,t=this.omit(t,"network"));const a=await this.privateGetOpenV1DepositsAddress(this.extend(s,t)),n=this.safeValue(a,"data",{}),o=this.safeString(n,"address");let d=this.safeString(n,"addressTag","");return 0===d.length&&(d=void 0),this.checkAddress(o),{currency:e,address:o,tag:d,network:this.safeString(n,"network"),info:a}}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={},n=this.safeInteger(i,"until");if(void 0!==e&&(r=this.currency(e),a.coin=r.id),void 0!==t){a.startTime=t;let e=this.sum(t,7776e6);void 0!==n&&(e=Math.min(e,n)),a.endTime=e}void 0!==s&&(a.limit=s);const o=await this.privateGetOpenV1Deposits(this.extend(a,i)),d=this.safeValue(o,"data",{}),h=this.safeValue(d,"list",[]);return this.parseTransactions(h,r,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t,r.endTime=this.sum(t,7776e6)),void 0!==s&&(r.limit=s);const n=await this.privateGetOpenV1Withdraws(this.extend(r,i)),o=this.safeValue(n,"data",{}),d=this.safeValue(o,"list",[]);return this.parseTransactions(d,a,t,s)}parseTransactionStatusByType(e,t=undefined){const s=this.safeValue({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",1:"canceled",2:"pending",3:"failed",4:"pending",5:"failed",10:"ok"}},t,{});return this.safeString(s,e,e)}parseTransaction(e,t=undefined){const s=this.safeString(e,"address");let i=this.safeString(e,"addressTag");void 0!==i&&i.length<1&&(i=void 0);let r=this.safeString(e,"txId");void 0!==r&&r.indexOf("Internal transfer ")>=0&&(r=r.slice(18));const a=this.safeString2(e,"coin","fiatCurrency"),n=this.safeCurrencyCode(a,t);let o;const d=this.safeInteger(e,"insertTime"),h=this.safeInteger2(e,"createTime","timestamp");let c=this.safeString(e,"type");void 0===c&&(void 0!==d&&void 0===h?(c="deposit",o=d):void 0===d&&void 0!==h&&(c="withdrawal",o=h));const l=this.safeNumber2(e,"transactionFee","totalFee"),u={currency:void 0,cost:void 0,rate:void 0};void 0!==l&&(u.currency=n,u.cost=l);let f=!1;void 0!==this.safeInteger(e,"transferType")&&(f=!0);let p=this.safeString(e,"id");if(void 0===p){const t=this.safeValue(e,"data",{});p=this.safeString(t,"withdrawId"),c="withdrawal"}return{info:e,id:p,txid:r,type:c,currency:n,network:this.safeString(e,"network"),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatusByType(this.safeString(e,"status"),c),timestamp:o,datetime:this.iso8601(o),address:s,addressFrom:void 0,addressTo:s,tag:i,tagFrom:void 0,tagTo:i,updated:this.safeInteger2(e,"successTime","updateTime"),comment:void 0,internal:f,fee:u}}async withdraw(e,t,s,i=undefined,r={}){[i,r]=this.handleWithdrawTagAndParams(i,r),await this.loadMarkets(),this.checkAddress(s);const a=this.currency(e),n={asset:a.id,address:s,amount:this.numberToString(t)};void 0!==i&&(n.addressTag=i);const[o,d]=this.handleNetworkCodeAndParams(r),h=this.networkCodeToId(o);void 0!==h&&(n.network=h.toUpperCase());const c=await this.privatePostOpenV1Withdraws(this.extend(n,d));return this.parseTransaction(c,a)}sign(e,t="public",s="GET",i={},r=undefined,n=undefined){if(!(t in this.urls.api.rest))throw new a.NotSupported(this.id+" does not have a testnet/sandbox URL for "+t+" endpoints");let d=this.urls.api.rest[t];d+="/"+e,"wapi"===t&&(d+=".html");if("userDataStream"===e||"listenKey"===e){if(!this.apiKey)throw new a.AuthenticationError(this.id+" userDataStream endpoint requires `apiKey` credential");r={"X-MBX-APIKEY":this.apiKey,"Content-Type":"application/x-www-form-urlencoded"},"GET"!==s&&(n=this.urlencode(i))}else if("private"===t||"sapi"===t&&"system/status"!==e||"sapiV3"===t||"wapi"===t&&"systemStatus"!==e||"dapiPrivate"===t||"dapiPrivateV2"===t||"fapiPrivate"===t||"fapiPrivateV2"===t){let a;this.checkRequiredCredentials();const h=this.safeInteger(this.options,"recvWindow"),c=this.extend({timestamp:this.nonce()},i);void 0!==h&&(c.recvWindow=h);const l=this.safeInteger(i,"recvWindow");void 0!==l&&(c.recvWindow=l),a="sapi"===t&&"asset/dust"===e?this.urlencodeWithArrayRepeat(c):"batchOrders"===e||e.indexOf("sub-account")>=0||"capital/withdraw/apply"===e||e.indexOf("staking")>=0?this.rawencode(c):this.urlencode(c);a+="&signature="+this.hmac(this.encode(a),this.encode(this.secret),o.J),r={"X-MBX-APIKEY":this.apiKey},"GET"===s||"DELETE"===s||"wapi"===t?d+="?"+a:(n=a,r["Content-Type"]="application/x-www-form-urlencoded")}else Object.keys(i).length&&(d+="?"+this.urlencode(i));return{url:d,method:s,body:n,headers:r}}handleErrors(e,t,s,i,r,o,d,h,c){if(418===e||429===e)throw new a.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+o);if(e>=400){if(o.indexOf("Price * QTY is zero or less")>=0)throw new a.InvalidOrder(this.id+" order cost = amount * price is zero or less "+o);if(o.indexOf("LOT_SIZE")>=0)throw new a.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+o);if(o.indexOf("PRICE_FILTER")>=0)throw new a.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) "+o)}if(void 0===d)return;const l=this.safeValue(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const f=this.safeString(d,"code");if(void 0!==f){if("200"===f||n.O.stringEquals(f,"0"))return;if("-2015"===f&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new a.DDoSProtection(this.id+" "+o);const e=this.id+" "+o;if("No need to change margin type."===u)throw new a.MarginModeAlreadySet(e);throw this.throwExactlyMatchedException(this.exceptions.exact,f,e),new a.ExchangeError(e)}if(!l)throw new a.ExchangeError(this.id+" "+o)}calculateRateLimiterCost(e,t,s,i,r={}){if("noCoin"in r&&!("coin"in i))return r.noCoin;if("noSymbol"in r&&!("symbol"in i))return r.noSymbol;if("noPoolId"in r&&!("poolId"in i))return r.noPoolId;if("byLimit"in r&&"limit"in i){const e=i.limit,t=r.byLimit;for(let s=0;s<t.length;s++){const i=t[s];if(e<=i[0])return i[1]}}return this.safeInteger(r,"cost",1)}}},7584:(e,t,s)=>{s.d(t,{Z:()=>c});var i=s(2120),r=s(6689),a=s(2194),n=s(9292),o=s(7110),d=s(1372),h=s(5981);class c extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"upbit",name:"Upbit",countries:["KR"],version:"v1",rateLimit:1e3,pro:!0,has:{CORS:!0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createDepositAddress:!0,createMarketOrder:!0,createOrder:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!1,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactions:!1,fetchWithdrawals:!0,transfer:!1,withdraw:!0},timeframes:{"1m":"minutes","3m":"minutes","5m":"minutes","15m":"minutes","30m":"minutes","1h":"minutes","4h":"minutes","1d":"days","1w":"weeks","1M":"months"},hostname:"api.upbit.com",urls:{logo:"https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg",api:{public:"https://{hostname}",private:"https://{hostname}"},www:"https://upbit.com",doc:"https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C",fees:"https://upbit.com/service_center/guide"},api:{public:{get:["market/all","candles/{timeframe}","candles/{timeframe}/{unit}","candles/minutes/{unit}","candles/minutes/1","candles/minutes/3","candles/minutes/5","candles/minutes/15","candles/minutes/30","candles/minutes/60","candles/minutes/240","candles/days","candles/weeks","candles/months","trades/ticks","ticker","orderbook"]},private:{get:["accounts","orders/chance","order","orders","withdraws","withdraw","withdraws/chance","deposits","deposit","deposits/coin_addresses","deposits/coin_address"],post:["orders","withdraws/coin","withdraws/krw","deposits/generate_coin_address"],delete:["order"]}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},precisionMode:n.sh,exceptions:{exact:{"This key has expired.":r.AuthenticationError,"Missing request parameter error. Check the required parameters!":r.BadRequest,"side is missing, side does not have a valid value":r.InvalidOrder},broad:{thirdparty_agreement_required:r.PermissionDenied,out_of_scope:r.PermissionDenied,order_not_found:r.OrderNotFound,insufficient_funds:r.InsufficientFunds,invalid_access_key:r.AuthenticationError,jwt_verification:r.AuthenticationError,create_ask_error:r.ExchangeError,create_bid_error:r.ExchangeError,volume_too_large:r.InvalidOrder,invalid_funds:r.InvalidOrder}},options:{createMarketBuyOrderRequiresPrice:!0,fetchTickersMaxLength:4096,fetchOrderBooksMaxLength:4096,tradingFeesByQuoteCurrency:{KRW:5e-4}},commonCurrencies:{TON:"Tokamak Network"}})}async fetchCurrency(e,t={}){await this.loadMarkets();const s=this.currency(e);return await this.fetchCurrencyById(s.id,t)}async fetchCurrencyById(e,t={}){const s={currency:e},i=await this.privateGetWithdrawsChance(this.extend(s,t)),r=this.safeValue(i,"member_level",{}),a=this.safeValue(i,"currency",{}),n=this.safeValue(i,"withdraw_limit",{}),o=this.safeValue(n,"can_withdraw"),d=this.safeString(a,"wallet_state"),h=this.safeValue(r,"wallet_locked"),c=this.safeValue(r,"locked");let l=!0;void 0===o||o?("working"!==d||void 0!==h&&h||void 0!==c&&c)&&(l=!1):l=!1;const u=this.safeNumber(n,"onetime"),f=this.safeNumber(n,"daily",u),p=this.safeNumber(n,"remaining_daily",f);let m;m=p>0?p:f;const g=this.safeString(a,"code"),y=this.safeCurrencyCode(g);return{info:i,id:g,code:y,name:y,active:l,fee:this.safeNumber(a,"withdraw_fee"),precision:void 0,limits:{withdraw:{min:this.safeNumber(n,"minimum"),max:m}}}}async fetchMarket(e,t={}){await this.loadMarkets();const s=this.market(e);return await this.fetchMarketById(s.id,t)}async fetchMarketById(e,t={}){const s={market:e},i=await this.privateGetOrdersChance(this.extend(s,t)),r=this.safeValue(i,"market"),a=this.safeValue(r,"bid"),n=this.safeValue(r,"ask"),o=this.safeString(r,"id"),d=this.safeString(n,"currency"),h=this.safeString(a,"currency"),c=this.safeCurrencyCode(d),l=this.safeCurrencyCode(h),u=this.safeString(r,"state"),f=this.safeNumber(i,"bid_fee"),p=this.safeNumber(i,"ask_fee"),m=Math.max(f,p);return{id:o,symbol:c+"/"+l,base:c,quote:l,settle:void 0,baseId:d,quoteId:h,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:"active"===u,contract:!1,linear:void 0,inverse:void 0,taker:m,maker:m,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber("1e-8"),price:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_total"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(a,"min_total"),max:this.safeNumber(r,"max_total")},info:i}}}async fetchMarkets(e={}){const t=await this.publicGetMarketAll(e),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"market"),[a,n]=r.split("-"),o=this.safeCurrencyCode(n),d=this.safeCurrencyCode(a);s.push({id:r,symbol:o+"/"+d,base:o,quote:d,settle:void 0,baseId:n,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,d,this.fees.trading.taker),maker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,d,this.fees.trading.maker),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{price:this.parseNumber("1e-8"),amount:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.free=this.safeString(i,"balance"),n.used=this.safeString(i,"locked"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetAccounts(e);return this.parseBalance(t)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join(","),i.length>this.options.fetchOrderBooksMaxLength){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols ("+i.length.toString()+" characters) exceeding max URL length ("+this.options.fetchOrderBooksMaxLength.toString()+" characters), you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join(",");const a={markets:i},n=await this.publicGetOrderbook(this.extend(a,s)),o={};for(let e=0;e<n.length;e++){const t=n[e],s=this.safeString(t,"market"),i=this.safeSymbol(s,void 0,"-"),r=this.safeInteger(t,"timestamp");o[i]={symbol:i,bids:this.sortBy(this.parseBidsAsks(t.orderbook_units,"bid_price","bid_size"),0,!0),asks:this.sortBy(this.parseBidsAsks(t.orderbook_units,"ask_price","ask_size"),0),timestamp:r,datetime:this.iso8601(r),nonce:void 0}}return o}async fetchOrderBook(e,t=undefined,s={}){const i=await this.fetchOrderBooks([e],t,s);return this.safeValue(i,e)}parseTicker(e,t=undefined){const s=this.safeInteger(e,"trade_timestamp"),i=this.safeString2(e,"market","code");t=this.safeMarket(i,t,"-");const r=this.safeString(e,"trade_price");return this.safeTicker({symbol:t.symbol,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high_price"),low:this.safeString(e,"low_price"),bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:this.safeString(e,"opening_price"),close:r,last:r,previousClose:this.safeString(e,"prev_closing_price"),change:this.safeString(e,"signed_change_price"),percentage:this.safeString(e,"signed_change_rate"),average:void 0,baseVolume:this.safeString(e,"acc_trade_volume_24h"),quoteVolume:this.safeString(e,"acc_trade_price_24h"),info:e},t)}async fetchTickers(e=undefined,t={}){let s;if(await this.loadMarkets(),void 0===(e=this.marketSymbols(e))){if(s=this.ids.join(","),s.length>this.options.fetchTickersMaxLength){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchTickers() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchTickers")}}else s=this.marketIds(e),s=s.join(",");const i={markets:s},a=await this.publicGetTicker(this.extend(i,t)),n={};for(let e=0;e<a.length;e++){const t=this.parseTicker(a[e]);n[t.symbol]=t}return this.filterByArrayTickers(n,"symbol",e)}async fetchTicker(e,t={}){const s=await this.fetchTickers([e],t);return this.safeValue(s,e)}parseTrade(e,t=undefined){const s=this.safeString2(e,"sequential_id","uuid");let i,r=this.safeInteger(e,"timestamp");void 0===r&&(r=this.parse8601(this.safeString(e,"created_at")));const a=this.safeStringLower2(e,"ask_bid","side");"ask"===a?i="sell":"bid"===a&&(i="buy");const n=this.safeString(e,"funds"),o=this.safeString2(e,"trade_price","price"),d=this.safeString2(e,"trade_volume","volume"),h=this.safeString2(e,"market","code");let c;t=this.safeMarket(h,t,"-");const l=this.safeString(e,a+"_fee");return void 0!==l&&(c={currency:t.quote,cost:l}),this.safeTrade({id:s,info:e,order:undefined,timestamp:r,datetime:this.iso8601(r),symbol:t.symbol,type:void 0,side:i,takerOrMaker:void 0,price:o,amount:d,cost:n,fee:c},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e);void 0===s&&(s=200);const a={market:r.id,count:s},n=await this.publicGetTradesTicks(this.extend(a,i));return this.parseTrades(n,r,t,s)}async fetchTradingFee(e,t={}){await this.loadMarkets();const s={market:this.market(e).id},i=await this.privateGetOrdersChance(this.extend(s,t)),r=this.safeString(i,"ask_fee"),n=this.safeString(i,"bid_fee"),o=a.O.stringMax(r,n),d=this.safeString(i,"maker_ask_fee"),h=this.safeString(i,"maker_bid_fee"),c=a.O.stringMax(d,h);return{info:i,symbol:e,maker:this.parseNumber(c),taker:this.parseNumber(o),percentage:!0,tierBased:!1}}parseOHLCV(e,t=undefined){return[this.parse8601(this.safeString(e,"candle_date_time_utc")),this.safeNumber(e,"opening_price"),this.safeNumber(e,"high_price"),this.safeNumber(e,"low_price"),this.safeNumber(e,"trade_price"),this.safeNumber(e,"candle_acc_trade_volume")]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n=this.parseTimeframe(t),o=this.safeString(this.timeframes,t,t);void 0===i&&(i=200);const d={market:a.id,timeframe:o,count:i};let h="publicGetCandlesTimeframe";if("minutes"===o){const e=Math.round(n/60);d.unit=e,h+="Unit"}void 0!==s&&(d.to=this.iso8601(this.sum(s,n*i*1e3)));const c=await this[h](this.extend(d,r));return this.parseOHLCVs(c,a,t,s,i)}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t&&"buy"===s&&this.options.createMarketBuyOrderRequiresPrice){if(void 0===a)throw new r.InvalidOrder(this.id+' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');i*=a}let o;if("buy"===s)o="bid";else{if("sell"!==s)throw new r.InvalidOrder(this.id+" createOrder() allows buy or sell side only!");o="ask"}await this.loadMarkets();const d={market:this.market(e).id,side:o};"limit"===t?(d.volume=this.amountToPrecision(e,i),d.price=this.priceToPrecision(e,a),d.ord_type=t):"market"===t&&("buy"===s?(d.ord_type="price",d.price=this.priceToPrecision(e,i)):"sell"===s&&(d.ord_type=t,d.volume=this.amountToPrecision(e,i)));const h=this.safeString2(n,"clientOrderId","identifier");void 0!==h&&(d.identifier=h),n=this.omit(n,["clientOrderId","identifier"]);const c=await this.privatePostOrders(this.extend(d,n));return this.parseOrder(c)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={uuid:e},r=await this.privateDeleteOrder(this.extend(i,s));return this.parseOrder(r)}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==s&&(r.limit=s);const n=await this.privateGetDeposits(this.extend(r,i));return this.parseTransactions(n,a,t,s)}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==s&&(r.limit=s);const n=await this.privateGetWithdraws(this.extend(r,i));return this.parseTransactions(n,a,t,s)}parseTransactionStatus(e){return this.safeString({submitting:"pending",submitted:"pending",almost_accepted:"pending",rejected:"failed",accepted:"pending",processing:"pending",done:"ok",canceled:"canceled"},e,e)}parseTransaction(e,t=undefined){const s=this.safeString(e,"uuid"),i=this.safeNumber(e,"amount"),r=this.safeString(e,"txid"),a=this.safeString(e,"done_at"),n=this.parse8601(a),o=this.parse8601(this.safeString(e,"created_at",a));let d=this.safeString(e,"type");"withdraw"===d&&(d="withdrawal");const h=this.safeString(e,"currency"),c=this.safeCurrencyCode(h),l=this.parseTransactionStatus(this.safeStringLower(e,"state")),u=this.safeNumber(e,"fee");return{info:e,id:s,currency:c,amount:i,network:void 0,address:undefined,addressTo:void 0,addressFrom:void 0,tag:undefined,tagTo:void 0,tagFrom:void 0,status:l,type:d,updated:n,txid:r,timestamp:o,datetime:this.iso8601(o),fee:{currency:c,cost:u}}}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"uuid");let i=this.safeString(e,"side");i="bid"===i?"buy":"sell";let r=this.safeString(e,"ord_type");const n=this.parse8601(this.safeString(e,"created_at")),o=this.parseOrderStatus(this.safeString(e,"state"));let d,h=this.safeString(e,"price");const c=this.safeString(e,"volume"),l=this.safeString(e,"remaining_volume"),u=this.safeString(e,"executed_volume");let f,p,m;"price"===r&&(r="market",f=h,h=void 0);let g=this.safeString(e,"paid_fee");const y=this.safeString(e,"market");t=this.safeMarket(y,t);let v=this.safeValue(e,"trades",[]);v=this.parseTrades(v,t,void 0,void 0,{order:s,type:r});const b=v.length;if(b>0){d=v[b-1].timestamp;let e=!1;void 0===g&&(e=!0,g="0"),f="0";for(let t=0;t<b;t++){const s=v[t];if(f=a.O.stringAdd(f,this.safeString(s,"cost")),e){const e=this.safeValue(v[t],"fee",{}),s=this.safeString(e,"cost");void 0!==s&&(g=a.O.stringAdd(g,s))}}p=a.O.stringDiv(f,u)}return void 0!==g&&(m={currency:t.quote,cost:g}),this.safeOrder({info:e,id:s,clientOrderId:void 0,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:d,symbol:t.symbol,type:r,timeInForce:void 0,postOnly:void 0,side:i,price:h,stopPrice:void 0,triggerPrice:void 0,cost:this.parseNumber(f),average:this.parseNumber(p),amount:c,filled:u,remaining:l,status:o,fee:m,trades:v})}async fetchOrdersByState(e,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={state:e};let n;void 0!==t&&(n=this.market(t),a.market=n.id);const o=await this.privateGetOrders(this.extend(a,r));return this.parseOrders(o,n,s,i)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("wait",e,t,s,i)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("done",e,t,s,i)}async fetchCanceledOrders(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchOrdersByState("cancel",e,t,s,i)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={uuid:e},r=await this.privateGetOrder(this.extend(i,s));return this.parseOrder(r)}async fetchDepositAddresses(e=undefined,t={}){await this.loadMarkets();const s=await this.privateGetDepositsCoinAddresses(t);return this.parseDepositAddresses(s,e)}parseDepositAddress(e,t=undefined){const s=this.safeString(e,"deposit_address"),i=this.safeString(e,"secondary_address"),r=this.safeString(e,"currency"),a=this.safeCurrencyCode(r);return this.checkAddress(s),{currency:a,address:s,tag:i,network:void 0,info:e}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i=await this.privateGetDepositsCoinAddress(this.extend({currency:s.id},t));return this.parseDepositAddress(i)}async createDepositAddress(e,t={}){await this.loadMarkets();const s={currency:this.currency(e).id},i=await this.privatePostDepositsGenerateCoinAddress(this.extend(s,t));if(void 0!==this.safeString(i,"message"))throw new r.AddressPending(this.id+" is generating "+e+" deposit address, call fetchDepositAddress or createDepositAddress one more time later to retrieve the generated address");return this.parseDepositAddress(i)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e),o={amount:t};let d="privatePostWithdraws";if("KRW"!==e){const e=this.safeStringUpper2(a,"network","net_type");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a network argument");a=this.omit(a,["network"]),o.net_type=e,d+="Coin",o.currency=n.id,o.address=s,void 0!==i&&(o.secondary_address=i),a=this.omit(a,"network")}else d+="Krw";const h=await this[d](this.extend(o,a));return this.parseTransaction(h)}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.implodeParams(this.urls.api[t],{hostname:this.hostname});n+="/"+this.version+"/"+this.implodeParams(e,i);const c=this.omit(i,this.extractParams(e));if("POST"!==s&&Object.keys(c).length&&(n+="?"+this.urlencode(c)),"private"===t){this.checkRequiredCredentials();const e=this.nonce(),t={access_key:this.apiKey,nonce:e};if(Object.keys(c).length){const e=this.urlencode(c),s=this.hash(this.encode(e),o.o);t.query_hash=s,t.query_hash_alg="SHA512"}r={Authorization:"Bearer "+(0,h.F)(t,this.encode(this.secret),d.J)},"GET"!==s&&"DELETE"!==s&&(a=this.json(i),r["Content-Type"]="application/json")}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.safeValue(o,"error");if(void 0!==c){const e=this.safeString(c,"message"),t=this.safeString(c,"name"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,e,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}},3853:(e,t,s)=>{s.d(t,{Z:()=>h});var i=s(8888),r=s(6689),a=s(2194),n=s(8817),o=s(6890),d=s(9292);class h extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"wavesexchange",name:"Waves.Exchange",countries:["CH"],certified:!0,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createMarketOrder:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchDepositAddress:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,signIn:!0,transfer:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","3h":"3h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg",test:{matcher:"https://matcher-testnet.wx.network",node:"https://nodes-testnet.wavesnodes.com",public:"https://api-testnet.wavesplatform.com/v0",private:"https://api-testnet.wx.network/v1",forward:"https://testnet.wx.network/api/v1/forward/matcher",market:"https://testnet.wx.network/api/v1/forward/marketdata/api/v1"},api:{matcher:"https://matcher.wx.network",node:"https://nodes.wx.network",public:"https://api.wavesplatform.com/v0",private:"https://api.wx.network/v1",forward:"https://wx.network/api/v1/forward/matcher",market:"https://wx.network/api/v1/forward/marketdata/api/v1"},doc:"https://docs.wx.network",www:"https://wx.network"},api:{matcher:{get:["matcher","matcher/settings","matcher/settings/rates","matcher/balance/reserved/{publicKey}","matcher/debug/allSnashotOffsets","matcher/debug/currentOffset","matcher/debug/lastOffset","matcher/debug/oldestSnapshotOffset","matcher/debug/config","matcher/debug/address/{address}","matcher/debug/status","matcher/debug/address/{address}/check","matcher/orderbook","matcher/orderbook/{baseId}/{quoteId}","matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}","matcher/orderbook/{baseId}/{quoteId}/{orderId}","matcher/orderbook/{baseId}/{quoteId}/info","matcher/orderbook/{baseId}/{quoteId}/status","matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}","matcher/orderbook/{publicKey}","matcher/orderbook/{publicKey}/{orderId}","matcher/orders/{address}","matcher/orders/{address}/{orderId}","matcher/transactions/{orderId}","api/v1/orderbook/{baseId}/{quoteId}"],post:["matcher/orderbook","matcher/orderbook/market","matcher/orderbook/cancel","matcher/orderbook/{baseId}/{quoteId}/cancel","matcher/orderbook/{baseId}/{quoteId}/calculateFee","matcher/orderbook/{baseId}/{quoteId}/delete","matcher/orderbook/{baseId}/{quoteId}/cancelAll","matcher/debug/saveSnapshots","matcher/orders/{address}/cancel","matcher/orders/cancel/{orderId}","matcher/orders/serialize"],delete:["matcher/orderbook/{baseId}/{quoteId}","matcher/settings/rates/{assetId}"],put:["matcher/settings/rates/{assetId}"]},node:{get:["addresses","addresses/balance/{address}","addresses/balance/{address}/{confirmations}","addresses/balance/details/{address}","addresses/data/{address}","addresses/data/{address}/{key}","addresses/effectiveBalance/{address}","addresses/effectiveBalance/{address}/{confirmations}","addresses/publicKey/{publicKey}","addresses/scriptInfo/{address}","addresses/scriptInfo/{address}/meta","addresses/seed/{address}","addresses/seq/{from}/{to}","addresses/validate/{address}","alias/by-address/{address}","alias/by-alias/{alias}","assets/{assetId}/distribution/{height}/{limit}","assets/balance/{address}","assets/balance/{address}/{assetId}","assets/details/{assetId}","assets/nft/{address}/limit/{limit}","blockchain/rewards","blockchain/rewards/height","blocks/address/{address}/{from}/{to}/","blocks/at/{height}","blocks/delay/{signature}/{blockNum}","blocks/first","blocks/headers/last","blocks/headers/seq/{from}/{to}","blocks/height","blocks/height/{signature}","blocks/last","blocks/seq/{from}/{to}","blocks/signature/{signature}","consensus/algo","consensus/basetarget","consensus/basetarget/{blockId}","consensus/{generatingbalance}/address","consensus/generationsignature","consensus/generationsignature/{blockId}","debug/balances/history/{address}","debug/blocks/{howMany}","debug/configInfo","debug/historyInfo","debug/info","debug/minerInfo","debug/portfolios/{address}","debug/state","debug/stateChanges/address/{address}","debug/stateChanges/info/{id}","debug/stateWaves/{height}","leasing/active/{address}","node/state","node/version","peers/all","peers/blacklisted","peers/connected","peers/suspended","transactions/address/{address}/limit/{limit}","transactions/info/{id}","transactions/status","transactions/unconfirmed","transactions/unconfirmed/info/{id}","transactions/unconfirmed/size","utils/seed","utils/seed/{length}","utils/time","wallet/seed"],post:["addresses","addresses/data/{address}","addresses/sign/{address}","addresses/signText/{address}","addresses/verify/{address}","addresses/verifyText/{address}","debug/blacklist","debug/print","debug/rollback","debug/validate","node/stop","peers/clearblacklist","peers/connect","transactions/broadcast","transactions/calculateFee","tranasctions/sign","transactions/sign/{signerAddress}","tranasctions/status","utils/hash/fast","utils/hash/secure","utils/script/compileCode","utils/script/compileWithImports","utils/script/decompile","utils/script/estimate","utils/sign/{privateKey}","utils/transactionsSerialize"],delete:["addresses/{address}","debug/rollback-to/{signature}"]},public:{get:["assets","pairs","candles/{baseId}/{quoteId}","transactions/exchange"]},private:{get:["deposit/addresses/{currency}","deposit/addresses/{currency}/{platform}","platforms","deposit/currencies","withdraw/currencies","withdraw/addresses/{currency}/{address}"],post:["oauth2/token"]},forward:{get:["matcher/orders/{address}","matcher/orders/{address}/{orderId}"],post:["matcher/orders/{wavesAddress}/cancel"]},market:{get:["tickers"]}},currencies:{WX:this.safeCurrencyStructure({id:"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",numericId:void 0,code:"WX",precision:this.parseNumber("8")})},precisionMode:d.nr,options:{allowedCandles:1440,accessToken:void 0,createMarketBuyOrderRequiresPrice:!0,matcherPublicKey:void 0,quotes:void 0,createOrderDefaultExpiry:24192e5,wavesAddress:void 0,withdrawFeeUSDN:7420,withdrawFeeWAVES:1e5,wavesPrecision:8,messagePrefix:"W",networks:{ERC20:"ETH",BEP20:"BSC"}},commonCurrencies:{EGG:"Waves Ducks"},requiresEddsa:!0,exceptions:{3147270:r.InsufficientFunds,112:r.InsufficientFunds,4:r.ExchangeError,13:r.ExchangeNotAvailable,14:r.ExchangeNotAvailable,3145733:r.AccountSuspended,3148040:r.DuplicateOrderId,3148801:r.AuthenticationError,9440512:r.AuthenticationError,9440771:r.BadSymbol,9441026:r.InvalidOrder,9441282:r.InvalidOrder,9441286:r.InvalidOrder,9441295:r.InvalidOrder,9441540:r.InvalidOrder,9441542:r.InvalidOrder,106954752:r.AuthenticationError,106954769:r.AuthenticationError,106957828:r.AuthenticationError,106960131:r.AuthenticationError,106981137:r.AuthenticationError,9437184:r.BadRequest,9437193:r.OrderNotFound,1048577:r.BadRequest,1051904:r.AuthenticationError}})}setSandboxMode(e){this.options.messagePrefix=e?"T":"W",this.options.sandboxMode=e,super.setSandboxMode(e)}async getFeesForAsset(e,t,s,i,r={}){await this.loadMarkets();const a=this.market(e);s=this.customAmountToPrecision(e,s),i=this.customPriceToPrecision(e,i);const n=this.extend({baseId:a.baseId,quoteId:a.quoteId,orderType:t,amount:s,price:i},r);return await this.matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee(n)}async customCalculateFee(e,t,s,i,r,n="taker",o={}){const d=await this.getFeesForAsset(e,s,i,r);let h;h=this.safeValue(o,"isDiscountFee",!1)?this.safeValue(d,"discount"):this.safeValue(d,"base");const c=this.safeString(h,"matcherFee"),l=this.safeString(h,"feeAssetId"),u=this.safeCurrencyCode(l),f=this.currencyFromPrecision(u,c),p=this.numberToString(i),m=this.numberToString(r),g=this.feeToPrecision(e,this.parseNumber(f)),y=a.O.stringDiv(f,a.O.stringMul(p,m));return{type:n,currency:u,rate:this.parseNumber(y),cost:this.parseNumber(g)}}async getQuotes(){let e=this.safeValue(this.options,"quotes");if(e)return e;{const t=await this.matcherGetMatcherSettings();e={};const s=this.safeValue(t,"priceAssets");for(let t=0;t<s.length;t++)e[s[t]]=!0;return this.options.quotes=e,e}}async fetchMarkets(e={}){const t=await this.marketGetTickers(),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"amountAssetID"),a=this.safeString(i,"priceAssetID"),n=r+"/"+a,o=this.safeString(i,"symbol");let[d,h]=o.split("/");d=this.safeCurrencyCode(d),h=this.safeCurrencyCode(h);const c=d+"/"+h;s.push({id:n,symbol:c,base:d,quote:h,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,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.safeInteger(i,"amountAssetDecimals"),price:this.safeInteger(i,"priceAssetDecimals")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r=this.extend({baseId:i.baseId,quoteId:i.quoteId},s),a=await this.matcherGetMatcherOrderbookBaseIdQuoteId(r),n=this.safeInteger(a,"timestamp");return{symbol:e,bids:this.parseOrderBookSide(this.safeValue(a,"bids"),i,t),asks:this.parseOrderBookSide(this.safeValue(a,"asks"),i,t),timestamp:n,datetime:this.iso8601(n),nonce:void 0}}parseOrderBookSide(e,t=undefined,s=undefined){const i=t.precision,r=this.safeString(this.options,"wavesPrecision","8"),n="1e"+this.numberToString(i.amount),o=this.numberToString(i.amount),d=this.numberToString(i.price),h=a.O.stringSub(o,d),c="1e"+a.O.stringSub(r,h),l=[];for(let t=0;t<e.length;t++){const i=e[t],r=this.safeString(i,"price","0"),o=this.safeString(i,"amount","0");let d,h;if(void 0!==c&&void 0!==r&&(d=a.O.stringDiv(r,c)),void 0!==n&&void 0!==o&&(h=a.O.stringDiv(o,n)),void 0!==s&&t>s)break;l.push([this.parseNumber(d),this.parseNumber(h)])}return l}checkRequiredKeys(){if(void 0===this.apiKey)throw new r.AuthenticationError(this.id+" requires apiKey credential");if(void 0===this.secret)throw new r.AuthenticationError(this.id+" requires secret credential");let e,t;try{e=this.base58ToBinary(this.apiKey)}catch(e){throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key")}try{t=this.base58ToBinary(this.secret)}catch(e){throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}const s=this.binaryToBase16(e),i=this.binaryToBase16(t);if(64!==s.length)throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key");if(64!==i.length)throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=this.omit(i,this.extractParams(e)),o="matcher/orders/{wavesAddress}/cancel"===e;e=this.implodeParams(e,i);let d=this.urls.api[t]+"/"+e,h=this.urlencodeWithArrayRepeat(n);if("private"===t||"forward"===t){r={Accept:"application/json"};const e=this.safeString(this.options,"accessToken");e&&(r.Authorization="Bearer "+e),r["content-type"]="POST"===s?"application/json":"application/x-www-form-urlencoded",o&&(a=this.json([n.orderId]),h=""),h.length>0&&(d+="?"+h)}else"matcher"===t?"POST"===s?(r={Accept:"application/json","Content-Type":"application/json"},a=this.json(n)):r=n:"POST"===s?(r={"content-type":"application/json"},a=this.json(n)):(r={"content-type":"application/x-www-form-urlencoded"},h.length>0&&(d+="?"+h));return{url:d,method:s,body:a,headers:r}}async signIn(e={}){if(!this.safeString(this.options,"accessToken")){const e="ffffff01",t=604800;let s=this.sum(this.seconds(),t);s=s.toString();const i="wx.network",r=this.safeString(this.options,"messagePrefix","W")+":"+i+":"+s,a=e+this.binaryToBase16(this.encode(r)),d=this.binaryToBase16(this.base58ToBinary(this.secret)),h=(0,o.gC)(a,d,n.UN),c={grant_type:"password",scope:"general",username:this.apiKey,password:s+":"+h,client_id:i},l=await this.privatePostOauth2Token(c);return this.options.accessToken=this.safeString(l,"access_token"),this.options.accessToken}}parseTicker(e,t=undefined){const s=this.safeInteger(e,"timestamp"),i=this.safeString(e,"symbol"),r=(t=this.safeMarket(i,t,"/")).symbol,a=this.safeString2(e,"24h_close","lastPrice"),n=this.safeString2(e,"24h_low","low"),o=this.safeString2(e,"24h_high","high"),d=this.safeString2(e,"24h_vwap","weightedAveragePrice"),h=this.safeString2(e,"24h_volume","volume"),c=this.safeString2(e,"24h_priceVolume","quoteVolume"),l=this.safeString2(e,"24h_open","firstPrice");return this.safeTicker({symbol:r,timestamp:s,datetime:this.iso8601(s),high:o,low:n,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:d,open:l,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:h,quoteVolume:c,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={pairs:s.id},r=await this.publicGetPairs(this.extend(i,t)),a=this.safeValue(r,"data",[]),n=this.safeValue(a,0,{}),o=this.safeValue(n,"data",{});return this.parseTicker(o,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=await this.marketGetTickers(t);return this.parseTickers(s,e)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={baseId:a.baseId,quoteId:a.quoteId,interval:this.safeString(this.timeframes,t,t)},o=this.safeInteger(this.options,"allowedCandles",1440);void 0===i&&(i=o),i=Math.min(o,i);const d=1e3*this.parseTimeframe(t);if(void 0===s){const e=this.parseToInt(this.milliseconds()/d)*d-(i-1)*d;n.timeStart=e.toString()}else{n.timeStart=s.toString();const e=this.sum(s,d*i);n.timeEnd=e.toString()}const h=await this.publicGetCandlesBaseIdQuoteId(this.extend(n,r)),c=this.safeValue(h,"data",[]);let l,u=this.parseOHLCVs(c,a,t,s,i);u=this.filterFutureCandles(u);const f=u.length;for(let e=0;e<u.length;e++){const t=f-e-1,s=u[t];void 0===s[1]&&(s[1]=l,s[2]=l,s[3]=l,s[4]=l,u[t]=s),l=s[4]}return u}filterFutureCandles(e){const t=[],s=this.milliseconds();for(let i=0;i<e.length&&!(e[i][0]>s);i++)t.push(e[i]);return t}parseOHLCV(e,t=undefined){const s=this.safeValue(e,"data",{});return[this.parse8601(this.safeString(s,"time")),this.safeNumber(s,"open"),this.safeNumber(s,"high"),this.safeNumber(s,"low"),this.safeNumber(s,"close"),this.safeNumber(s,"volume",0)]}async fetchDepositAddress(e,t={}){await this.signIn();const s=this.safeValue(this.options,"networks",{}),i=this.safeStringUpper(t,"network"),a=this.safeString(s,i,i);t=this.omit(t,["network"]);const n=await this.privateGetPlatforms(),o={},d={},h=this.safeValue(n,"items",[]);for(let e=0;e<h.length;e++){const t=h[e],s=this.safeString(t,"id"),i=this.safeValue(t,"currencies",[]);for(let e=0;e<i.length;e++){const t=this.safeString(i,e);o[t]=!0,t in d||(d[t]={}),d[t][s]=!0}}if(!(e in o)){const t=Object.keys(o);throw new r.ExchangeError(this.id+" fetchDepositAddress() "+e+" not supported. Currency code must be one of "+t.join(", "))}let c;if(void 0===a){const s={currency:e};c=await this.privateGetDepositAddressesCurrency(this.extend(s,t))}else{const s=d[e];if(!(a in s)){const t=Object.keys(s);throw new r.ExchangeError(this.id+" "+a+" network "+e+" deposit address not supported. Network must be one of "+t.join(", "))}if("WAVES"===a){const t={publicKey:this.apiKey},s=await this.nodeGetAddressesPublicKeyPublicKey(this.extend(t,t));return{address:this.safeString(c,"address"),code:e,currency:e,network:a,tag:void 0,info:s}}{const s={currency:e,platform:a};c=await this.privateGetDepositAddressesCurrencyPlatform(this.extend(s,t))}}const l=this.safeValue(c,"currency"),u=this.safeString(l,"platform_id"),f=this.safeValue(this.options,"networkByIds",{}),p=this.safeString(f,u,u),m=this.safeValue(c,"deposit_addresses");return{address:this.safeString(m,0),code:e,currency:e,tag:void 0,network:p,info:c}}async getMatcherPublicKey(){const e=this.safeString(this.options,"matcherPublicKey");if(e)return e;{const e=await this.matcherGetMatcher();return this.options.matcherPublicKey=e.slice(1,e.length-1),this.options.matcherPublicKey}}getAssetBytes(e){return"WAVES"===e?this.numberToBE(0,1):this.binaryConcat(this.numberToBE(1,1),this.base58ToBinary(e))}getAssetId(e){return"WAVES"===e?"":e}customPriceToPrecision(e,t){const s=this.markets[e],i=this.safeString(this.options,"wavesPrecision","8"),r=this.numberToString(s.precision.amount),n=this.numberToString(s.precision.price),o=a.O.stringSub(r,n),d=a.O.stringSub(i,o),h=this.toPrecision(t,d).toString();return this.parseToInt(parseFloat(h))}customAmountToPrecision(e,t){const s=this.numberToString(this.toPrecision(t,this.numberToString(this.markets[e].precision.amount)));return this.parseToInt(parseFloat(s))}currencyToPrecision(e,t,s=undefined){const i=this.numberToString(this.toPrecision(t,this.currencies[e].precision));return this.parseToInt(parseFloat(i))}fromPrecision(e,t){if(void 0===e)return;const s=new a.O(e);return s.decimals=this.sum(s.decimals,t),s.reduce(),s.toString()}toPrecision(e,t){const s=this.numberToString(e),i=new a.O(s);return i.decimals=this.parseToInt(a.O.stringSub(this.numberToString(i.decimals),this.numberToString(t))),i.reduce(),i}currencyFromPrecision(e,t){const s=this.currencies[e].precision;return this.fromPrecision(t,s)}priceFromPrecision(e,t){const s=this.markets[e],i=this.safeInteger(this.options,"wavesPrecision",8),r=this.sum(i,s.precision.price)-s.precision.amount;return this.fromPrecision(t,r)}safeGetDynamic(e){const t=this.safeValue(e,"orderFee");return"dynamic"in t?this.safeValue(t,"dynamic"):this.safeValue(t.composite.default,"dynamic")}safeGetRates(e){const t=this.safeValue(e,"rates");return void 0===t?{WAVES:1}:t}async createOrder(e,t,s,i,a=undefined,d={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const h=this.market(e),c=await this.getMatcherPublicKey(),l=this.getAssetId(h.baseId),u=this.getAssetId(h.quoteId),f="market"===t,p=this.safeFloat2(d,"triggerPrice","stopPrice"),m=void 0!==p;if(f&&void 0===a)throw new r.InvalidOrder(this.id+" createOrder() requires a price argument for "+t+" orders to determine the max price for buy and the min price for sell");const g=this.milliseconds(),y=this.safeInteger(this.options,"createOrderDefaultExpiry",24192e5),v=this.sum(g,y),b=await this.getFeesForAsset(e,s,i,a),w=this.safeValue2(b,"base","discount"),S=this.safeString(w,"feeAssetId"),k=this.safeCurrencyCode(S),O=this.safeString(w,"matcherFee"),T=this.safeValue(b,"discount"),I=this.safeString(T,"feeAssetId"),x=this.safeCurrencyCode(I),P=this.safeString(T,"matcherFee");let M,A;if("feeAsset"in d||"feeAsset"in this.options){const e=this.safeString(d,"feeAsset",this.safeString(this.options,"feeAsset")),t=this.currency(e);M=this.safeString(t,"id")}const C=await this.fetchBalance();if(void 0!==M){if(S!==M&&I!==M)throw new r.InvalidOrder(this.id+" asset fee must be "+k+" or "+x);const e=this.safeCurrencyCode(M),t=M===S?O:P,s=parseFloat(this.currencyFromPrecision(e,t));if(!(e in C&&C[e].free>=s))throw new r.InsufficientFunds(this.id+" not enough funds of the selected asset fee");A=parseInt(t)}if(void 0===M){const e=parseFloat(this.currencyFromPrecision(k,O));if(k in C&&C[k].free>=e)M=S,A=parseInt(O);else{const e=parseFloat(this.currencyFromPrecision(x,P));x in C&&C[x].free>=e&&(M=I,A=parseInt(P))}}if(void 0===M)throw new r.InsufficientFunds(this.id+" not enough funds on none of the eligible asset fees");i=this.customAmountToPrecision(e,i),a=this.customPriceToPrecision(e,a);const E={amountAsset:l,priceAsset:u},_=this.safeValue(this.options,"sandboxMode",!1)?84:87,B={senderPublicKey:this.apiKey,matcherPublicKey:c,assetPair:E,orderType:s,price:a,amount:i,timestamp:g,expiration:v,matcherFee:parseInt(A),priceMode:"assetDecimals",version:4,chainId:_};if(m){const t={v:1,c:{t:"sp",v:{p:this.customPriceToPrecision(e,p)}}};B.attachment=this.binaryToBase58(this.encode(JSON.stringify(t)))}"WAVES"!==M&&(B.matcherFeeAssetId=M);let N=await this.matcherPostMatcherOrdersSerialize(B);'"'===N[0]&&'"'===N[N.length-1]&&(N=N.slice(1,N.length-1));const V=(0,o.gC)(this.binaryToBase16(this.base58ToBinary(N)),this.binaryToBase16(this.base58ToBinary(this.secret)),n.UN);if(B.signature=V,f){const e=await this.matcherPostMatcherOrderbookMarket(B),t=this.safeValue(e,"message");return this.parseOrder(t,h)}{const e=await this.matcherPostMatcherOrderbook(B),t=this.safeValue(e,"message");return this.parseOrder(t,h)}}async cancelOrder(e,t=undefined,s={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.signIn();const i=await this.getWavesAddress(),r=await this.forwardPostMatcherOrdersWavesAddressCancel({wavesAddress:i,orderId:e}),a=this.safeValue(r,"message"),n=this.safeValue(a,0),o=this.safeValue(n,0);return{info:r,id:this.safeString(o,"orderId"),clientOrderId:void 0,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,symbol:t,type:void 0,side:void 0,price:void 0,amount:void 0,cost:void 0,average:void 0,filled:void 0,remaining:void 0,status:void 0,fee:void 0,trades:void 0}}async fetchOrder(e,t=undefined,s={}){let i;this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets(),void 0!==t&&(i=this.market(t));const r=this.milliseconds(),a=[this.base58ToBinary(this.apiKey),this.numberToBE(r,8)],d=this.binaryConcatArray(a),h=this.binaryToBase16(this.base58ToBinary(this.secret)),c=(0,o.gC)(this.binaryToBase16(d),h,n.UN),l={Timestamp:r.toString(),Signature:c,publicKey:this.apiKey,orderId:e},u=await this.matcherGetMatcherOrderbookPublicKeyOrderId(this.extend(l,s));return this.parseOrder(u,i)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(this.checkRequiredDependencies(),this.checkRequiredKeys(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires symbol argument");await this.loadMarkets();const a=this.market(e),d=this.milliseconds(),h=[this.base58ToBinary(this.apiKey),this.numberToBE(d,8)],c=this.binaryConcatArray(h),l=this.binaryToBase16(this.base58ToBinary(this.secret)),u=(0,o.gC)(this.binaryToBase16(c),l,n.UN),f={Accept:"application/json",Timestamp:d.toString(),Signature:u,publicKey:this.apiKey,baseId:a.baseId,quoteId:a.quoteId},p=await this.matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKey(this.extend(f,i));return this.parseOrders(p,a,t,s)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),activeOnly:!0},n=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(n,r,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),closedOnly:!0},n=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(n,r,t,s)}parseOrderStatus(e){return this.safeString({Cancelled:"canceled",Accepted:"open",Filled:"closed",PartiallyFilled:"open"},e,e)}getSymbolFromAssetPair(e){const t=this.safeString(e,"amountAsset","WAVES"),s=this.safeString(e,"priceAsset","WAVES");return this.safeCurrencyCode(t)+"/"+this.safeCurrencyCode(s)}parseOrder(e,t=undefined){const s=this.safeInteger(e,"timestamp"),i=this.safeString2(e,"type","orderType");let r="limit";"type"in e&&(r=this.safeString(e,"orderType",r));const a=this.safeString(e,"id"),n=this.safeString(e,"filled"),o=this.safeString(e,"price"),d=this.safeString(e,"amount"),h=this.safeValue(e,"assetPair");let c;void 0!==h?c=this.getSymbolFromAssetPair(h):void 0!==t&&(c=t.symbol);const l=this.safeCurrencyCode(this.safeString(h,"amountAsset","WAVES")),u=this.priceFromPrecision(c,o),f=this.currencyFromPrecision(l,d),p=this.currencyFromPrecision(l,n),m=this.priceFromPrecision(c,this.safeString(e,"avgWeighedPrice")),g=this.parseOrderStatus(this.safeString(e,"status"));let y,v;if("type"in e){const t=this.safeCurrencyCode(this.safeString(e,"feeAsset"));y={currency:t,fee:this.parseNumber(this.currencyFromPrecision(t,this.safeString(e,"filledFee")))}}else{const t=this.safeCurrencyCode(this.safeString(e,"matcherFeeAssetId","WAVES"));y={currency:t,fee:this.parseNumber(this.currencyFromPrecision(t,this.safeString(e,"matcherFee")))}}const b=this.safeString(e,"attachment");if(void 0!==b){const e=this.parseJson(this.decode(this.base58ToBinary(b)));if(void 0!==e){const t=this.safeValue(e,"c");if(void 0!==t){const e=this.safeValue(t,"v");void 0!==e&&(v=this.safeString(e,"p"))}}}return this.safeOrder({info:e,id:a,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,symbol:c,type:r,timeInForce:void 0,postOnly:void 0,side:i,price:u,stopPrice:v,triggerPrice:v,amount:f,cost:void 0,average:m,filled:p,remaining:void 0,status:g,fee:y,trades:void 0},t)}async getWavesAddress(){const e=this.safeString(this.options,"wavesAddress");if(void 0===e){const e={publicKey:this.apiKey},t=await this.nodeGetAddressesPublicKeyPublicKey(e);return this.options.wavesAddress=this.safeString(t,"address"),this.options.wavesAddress}return e}async fetchBalance(e={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const t=await this.getWavesAddress(),s={address:t},i=await this.nodeGetAssetsBalanceAddress(s),r=this.safeValue(i,"balances",[]),a={};let d;const h=[],c=[];for(let e=0;e<r.length;e++){const t=r[e],s=this.safeInteger(t,"timestamp");d=void 0===d?s:Math.max(d,s);const i=this.safeValue(t,"issueTransaction"),n=this.safeString(t,"assetId"),o=this.safeString(t,"balance");if(void 0===i){h.push(n),c.push(o);continue}const l=this.safeInteger(i,"decimals");let u;n in this.currencies_by_id&&(u=this.safeCurrencyCode(n),a[u]=this.account(),a[u].total=this.fromPrecision(o,l))}if(h.length){const e={ids:h},t=await this.publicGetAssets(e),s=this.safeValue(t,"data",[]);for(let e=0;e<s.length;e++){const t=s[e],i=c[e],r=this.safeValue(t,"data"),n=this.safeInteger(r,"precision"),o=this.safeString(r,"ticker"),d=this.safeCurrencyCode(o);a[d]=this.account(),a[d].total=this.fromPrecision(i,n)}}const l=this.milliseconds(),u=[this.base58ToBinary(this.apiKey),this.numberToBE(l,8)],f=this.binaryConcatArray(u),p=this.binaryToBase16(this.base58ToBinary(this.secret)),m=(0,o.gC)(this.binaryToBase16(f),p,n.UN),g={publicKey:this.apiKey,signature:m,timestamp:l.toString()},y=await this.matcherGetMatcherBalanceReservedPublicKey(g),v=Object.keys(y);for(let e=0;e<v.length;e++){const t=v[e],s=this.safeCurrencyCode(t);s in a||(a[s]=this.account());const i=this.safeString(y,t);s in this.currencies?a[s].used=this.currencyFromPrecision(s,i):a[s].used=i}const b={address:t},w=await this.nodeGetAddressesBalanceAddress(b);a.WAVES=this.safeValue(a,"WAVES",{}),a.WAVES.total=this.currencyFromPrecision("WAVES",this.safeString(w,"balance"));const S=Object.keys(a);for(let e=0;e<S.length;e++){const t=S[e];void 0===this.safeValue(a[t],"used")&&(a[t].used="0")}return a.timestamp=d,a.datetime=this.iso8601(d),this.safeBalance(a)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={sender:await this.getWavesAddress()};let a;void 0!==e&&(a=this.market(e),r.amountAsset=a.baseId,r.priceAsset=a.quoteId);const n=await this.publicGetTransactionsExchange(r),o=this.safeValue(n,"data");return this.parseTrades(o,a,t,s)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={amountAsset:r.baseId,priceAsset:r.quoteId};void 0!==s&&(a.limit=s),void 0!==t&&(a.timeStart=t);const n=await this.publicGetTransactionsExchange(a),o=this.safeValue(n,"data");return this.parseTrades(o,r,t,s)}parseTrade(e,t=undefined){const s=this.safeValue(e,"data"),i=this.safeString(s,"timestamp"),r=this.parse8601(i),a=this.safeString(s,"id"),n=this.safeString(s,"price"),o=this.safeString(s,"amount"),d=this.safeValue(s,"order1"),h=this.safeValue(s,"order2");let c,l;c=this.safeString(d,"senderPublicKey")===this.apiKey?d:h;const u=this.safeValue(c,"assetPair");void 0!==u?l=this.getSymbolFromAssetPair(u):void 0!==t&&(l=t.symbol);const f=this.safeString(c,"orderType"),p=this.safeString(c,"id"),m={cost:this.safeString(c,"matcherFee"),currency:this.safeCurrencyCode(this.safeString(c,"matcherFeeAssetId","WAVES"))};return this.safeTrade({info:e,timestamp:r,datetime:i,symbol:l,id:a,order:p,type:void 0,side:f,takerOrMaker:void 0,price:n,amount:o,cost:void 0,fee:m},t)}parseDepositWithdrawFees(e,t=undefined,s=undefined){const i={};t=this.marketCodes(t);for(let r=0;r<e.length;r++){const a=e[r],n=this.safeString(a,s),o=this.safeValue(this.currencies_by_id,n),d=this.safeString(o,"code",n);if(void 0===t||this.inArray(d,t)){let e=this.safeValue(i,d);void 0===e?e={info:[a],withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}}:(e=i[d],e.info=this.arrayConcat(e.info,[a]));const t=this.safeString(a,"platform_id"),s=this.safeString(o,"code"),r=this.networkIdToCode(t,s);let n=this.safeValue(e.networks,r);void 0===n&&(n={withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0}});const h=this.safeString(a,"type"),c=this.safeValue(a,"fees");let l="deposit";"withdrawal_currency"===h&&(l="withdraw"),n[l]={fee:this.safeNumber(c,"flat"),percentage:!1},e.networks[r]=n,i[d]=e}}const r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e],s=i[t],a=this.safeValue(s,"networks"),n=Object.keys(a);if(1===n.length){const e=this.safeValue(a,n[0]);i[t].withdraw=this.safeValue(e,"withdraw"),i[t].deposit=this.safeValue(e,"deposit")}}return i}async fetchDepositWithdrawFees(e=undefined,t={}){await this.loadMarkets();let s=[],i=[];i.push(this.privateGetDepositCurrencies(t)),i.push(this.privateGetWithdrawCurrencies(t)),i=await Promise.all(i);for(let e=0;e<i.length;e++){const t=this.safeValue(i[e],"items");s=this.arrayConcat(s,t)}return this.parseDepositWithdrawFees(s,e,"id")}handleErrors(e,t,s,i,a,n,o,d,h){const c=this.safeString(o,"error"),l=this.safeValue(o,"success",!0),u=this.safeValue(this.exceptions,c);if(void 0!==u){const e=this.safeString(o,"message");throw new u(this.id+" "+e)}if("Validation Error"===this.safeString(o,"message"))throw new r.BadRequest(this.id+" "+n);if(!l)throw new r.ExchangeError(this.id+" "+n)}async withdraw(e,t,s,i=undefined,a={}){if([i,a]=this.handleWithdrawTagAndParams(i,a),"WAVES"!==e){const t=await this.privateGetWithdrawCurrencies(),s={},i=this.safeValue(t,"items",[]);for(let e=0;e<i.length;e++){const t=i[e];s[this.safeString(t,"id")]=!0}if(!(e in s)){const t=Object.keys(s);throw new r.ExchangeError(this.id+" withdraw() "+e+" not supported. Currency code must be one of "+t.toString())}}await this.loadMarkets();const d=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],h={};for(let e=0;e<d.length;e++){h[d[e]]=!0}let c=!0;const l=this.remove0xPrefix(s).toLowerCase(),u=1*l.length;for(let e=0;e<u;e++){if(!(l[e]in h)){c=!1;break}}let f;if(await this.signIn(),"WAVES"!==e||c){const i={address:s,currency:e},a=await this.privateGetWithdrawAddressesCurrencyAddress(i),n=this.safeValue(a,"currency"),o=this.safeValue(n,"allowed_amount"),d=this.safeNumber(o,"min");if(t<=d)throw new r.BadRequest(this.id+" "+e+" withdraw failed, amount "+t.toString()+" must be greater than the minimum allowed amount of "+d.toString());const h=this.safeValue(a,"proxy_addresses",[]);f=this.safeString(h,0)}else f=s;const p=this.safeInteger(this.options,"withdrawFeeWAVES",1e5),m="WAVES",g=this.currencyToPrecision(e,t),y=this.currency(e),v=this.milliseconds(),b=[this.numberToBE(4,1),this.numberToBE(2,1),this.base58ToBinary(this.apiKey),this.getAssetBytes(y.id),this.getAssetBytes(m),this.numberToBE(v,8),this.numberToBE(g,8),this.numberToBE(p,8),this.base58ToBinary(f),this.numberToBE(0,2)],w=this.binaryConcatArray(b),S=this.binaryToBase16(this.base58ToBinary(this.secret)),k=(0,o.gC)(this.binaryToBase16(w),S,n.UN),O={senderPublicKey:this.apiKey,amount:g,fee:p,type:4,version:2,attachment:"",feeAssetId:this.getAssetId(m),proofs:[k],assetId:this.getAssetId(y.id),recipient:f,timestamp:v,signature:k},T=await this.nodePostTransactionsBroadcast(O);return this.parseTransaction(T,y)}parseTransaction(e,t=undefined){return{id:void 0,txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:(t=this.safeCurrency(void 0,t)).code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}}},6536:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(9564),r=s(6689),a=s(2194),n=s(9292),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"wazirx",name:"WazirX",countries:["IN"],version:"v2",rateLimit:1e3,pro:!0,has:{CORS:!1,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelAllOrders:!0,cancelOrder:!0,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchClosedOrders:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!1,transfer:!1,withdraw:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/148647666-c109c20b-f8ac-472f-91c3-5f658cb90f49.jpeg",api:{rest:"https://api.wazirx.com/sapi/v1"},www:"https://wazirx.com",doc:"https://docs.wazirx.com/#public-rest-api-for-wazirx",fees:"https://wazirx.com/fees",referral:"https://wazirx.com/invite/k7rrnks5"},api:{public:{get:{exchangeInfo:1,depth:1,ping:1,systemStatus:1,"tickers/24hr":1,"ticker/24hr":1,time:1,trades:1,klines:1}},private:{get:{account:1,allOrders:1,funds:1,historicalTrades:1,openOrders:1,order:.5,myTrades:.5},post:{order:.1,"order/test":.5},delete:{order:.1,openOrders:1}}},fees:{WRX:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.0")}},precisionMode:n.sh,exceptions:{exact:{"-1121":r.BadSymbol,1999:r.BadRequest,2002:r.InsufficientFunds,2005:r.BadRequest,2078:r.PermissionDenied,2098:r.BadRequest,2031:r.InvalidOrder,2113:r.BadRequest,2115:r.BadRequest,2136:r.RateLimitExceeded,94001:r.InvalidOrder}},timeframes:{"1m":"1m","5m":"5m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w"},options:{recvWindow:1e4}})}async fetchMarkets(e={}){const t=await this.publicGetExchangeInfo(e),s=this.safeValue(t,"symbols",[]),i=[];for(let e=0;e<s.length;e++){const t=s[e],r=this.safeString(t,"symbol"),n=this.safeString(t,"baseAsset"),o=this.safeString(t,"quoteAsset"),d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=this.safeValue(t,"isSpotTradingAllowed"),l=this.safeValue(t,"filters");let u;for(let e=0;e<l.length;e++){const t=l[e];"PRICE_FILTER"===this.safeString(t,"filterType")&&(u=this.safeNumber(t,"minPrice"))}const f=this.safeValue(this.fees,h,{});let p=this.safeString(f,"taker","0.2");p=a.O.stringDiv(p,"100");let m=this.safeString(f,"maker","0.2");m=a.O.stringDiv(m,"100");const g=this.safeString(t,"status");i.push({id:r,symbol:d+"/"+h,base:d,quote:h,settle:void 0,baseId:n,quoteId:o,settleId:void 0,type:"spot",spot:c,margin:!1,swap:!1,future:!1,option:!1,active:"trading"===g,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(p),maker:this.parseNumber(m),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(t,"baseAssetPrecision"))),price:this.parseNumber(this.parsePrecision(this.safeString(t,"quoteAssetPrecision")))},limits:{leverage:{min:void 0,max:void 0},price:{min:u,max:void 0},amount:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t})}return i}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.id,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.limit=i);const o=this.safeInteger(r,"until");r=this.omit(r,["until"]),void 0!==s&&(n.startTime=this.parseToInt(s/1e3)),void 0!==o&&(n.endTime=o);const d=await this.publicGetKlines(this.extend(n,r));return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={symbol:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.publicGetDepth(this.extend(i,s)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.publicGetTicker24hr(this.extend(i,t));return this.parseTicker(r,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s=await this.publicGetTickers24hr(),i={};for(let e=0;e<s.length;e++){const t=s[e],r=this.parseTicker(t);i[r.symbol]=r}return this.filterByArrayTickers(i,"symbol",e)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==s&&(a.limit=Math.min(s,1e3));const n=this.safeString(this.options,"fetchTradesMethod","publicGetTrades"),o=await this[n](this.extend(a,i));return this.parseTrades(o,r,t,s)}parseTrade(e,t=undefined){const s=this.safeString(e,"id"),i=this.safeInteger(e,"time"),r=this.iso8601(i);t=this.safeMarket(void 0,t);const a=this.safeValue(e,"isBuyerMaker")?"sell":"buy",n=this.safeNumber(e,"price"),o=this.safeNumber(e,"qty"),d=this.safeNumber(e,"quoteQty");return this.safeTrade({info:e,id:s,timestamp:i,datetime:r,symbol:t.symbol,order:s,type:void 0,side:a,takerOrMaker:void 0,price:n,amount:o,cost:d,fee:void 0},t)}async fetchStatus(e={}){const t=await this.publicGetSystemStatus(e);return{status:"normal"===this.safeString(t,"status")?"ok":"maintenance",updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.publicGetTime(e);return this.safeInteger(t,"serverTime")}parseTicker(e,t=undefined){const s=this.safeString(e,"symbol"),i=(t=this.safeMarket(s,t)).symbol,r=this.safeString(e,"lastPrice"),a=this.safeString(e,"openPrice"),n=this.safeString(e,"highPrice"),o=this.safeString(e,"lowPrice"),d=this.safeString(e,"volume"),h=this.safeString(e,"bidPrice"),c=this.safeString(e,"askPrice"),l=this.safeInteger(e,"at");return this.safeTicker({symbol:i,timestamp:l,datetime:this.iso8601(l),high:n,low:o,bid:h,bidVolume:void 0,ask:c,askVolume:void 0,vwap:void 0,open:a,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:d,quoteVolume:void 0,info:e},t)}parseBalance(e){const t={info:e};for(let s=0;s<e.length;s++){const i=e[s],r=this.safeString(i,"asset"),a=this.safeCurrencyCode(r),n=this.account();n.free=this.safeString(i,"free"),n.used=this.safeString(i,"locked"),t[a]=n}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetFunds(e);return this.parseBalance(t)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires a `symbol` argument");await this.loadMarkets();const a=this.market(e),n={symbol:a.id};void 0!==t&&(n.startTime=t),void 0!==s&&(n.limit=s);const o=await this.privateGetAllOrders(this.extend(n,i));let d=this.parseOrders(o,a,t,s);return d=this.filterBy(d,"symbol",e),d}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id);const n=await this.privateGetOpenOrders(this.extend(r,i));return this.parseOrders(n,a,t,s)}async cancelAllOrders(e=undefined,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a `symbol` argument");await this.loadMarkets();const s={symbol:this.market(e).id};return await this.privateDeleteOpenOrders(this.extend(s,t))}async cancelOrder(e,t=undefined,s={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a `symbol` argument");await this.loadMarkets();const i={symbol:this.market(t).id,orderId:e},a=await this.privateDeleteOrder(this.extend(i,s));return this.parseOrder(a)}async createOrder(e,t,s,i,a=undefined,n={}){if("limit"!==(t=t.toLowerCase())&&"stop_limit"!==t)throw new r.ExchangeError(this.id+" createOrder() supports limit and stop_limit orders only");if(void 0===a)throw new r.ExchangeError(this.id+" createOrder() requires a price argument");await this.loadMarkets();const o=this.market(e),d={symbol:o.id,side:s,quantity:i,type:"limit"};d.price=this.priceToPrecision(e,a);const h=this.safeString(n,"stopPrice");void 0!==h&&(d.type="stop_limit",d.stopPrice=this.priceToPrecision(e,h));const c=await this.privatePostOrder(this.extend(d,n));return this.parseOrder(c,o)}parseOrder(e,t=undefined){const s=this.safeInteger(e,"createdTime"),i=this.safeInteger(e,"updatedTime"),r=this.safeString(e,"symbol"),a=this.safeSymbol(r,t),n=this.safeString(e,"quantity"),o=this.safeString(e,"executedQty"),d=this.parseOrderStatus(this.safeString(e,"status")),h=this.safeString(e,"id"),c=this.safeString(e,"price"),l=this.safeStringLower(e,"type"),u=this.safeStringLower(e,"side");return this.safeOrder({info:e,id:h,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:i,status:d,symbol:a,type:l,timeInForce:void 0,postOnly:void 0,side:u,price:c,amount:n,filled:o,remaining:void 0,cost:void 0,fee:void 0,average:void 0,trades:[]},t)}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/"+e;if("public"===t&&Object.keys(i).length&&(n+="?"+this.urlencode(i)),"private"===t){this.checkRequiredCredentials();const e=this.milliseconds();let t=this.extend({recvWindow:this.options.recvWindow,timestamp:e},i);t=this.keysort(t);const s=this.hmac(this.encode(this.urlencode(t)),this.encode(this.secret),o.J);n+="?"+this.urlencode(t),n+="&signature="+s,r={"Content-Type":"application/x-www-form-urlencoded","X-Api-Key":this.apiKey}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.safeString(o,"code");if(void 0!==c){const e=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,c,e),new r.ExchangeError(e)}}}},5467:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5307),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"whitebit",name:"WhiteBit",version:"v4",countries:["EE"],rateLimit:500,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderTrades:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!0,repayMargin:!1,setLeverage:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg",api:{v1:{public:"https://whitebit.com/api/v1/public",private:"https://whitebit.com/api/v1"},v2:{public:"https://whitebit.com/api/v2/public"},v4:{public:"https://whitebit.com/api/v4/public",private:"https://whitebit.com/api/v4"}},www:"https://www.whitebit.com",doc:"https://github.com/whitebit-exchange/api-docs",fees:"https://whitebit.com/fee-schedule",referral:"https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963"},api:{web:{get:["v1/healthcheck"]},v1:{public:{get:["markets","tickers","ticker","symbols","depth/result","history","kline"]},private:{post:["account/balance","order/new","order/cancel","orders","account/order_history","account/executed_history","account/executed_history/all","account/order"]}},v2:{public:{get:["markets","ticker","assets","fee","depth/{market}","trades/{market}"]}},v4:{public:{get:["assets","collateral/markets","fee","orderbook/{market}","ticker","trades/{market}","time","ping","markets","futures"]},private:{post:["collateral-account/balance","collateral-account/positions/history","collateral-account/leverage","collateral-account/positions/open","collateral-account/summary","main-account/address","main-account/balance","main-account/create-new-address","main-account/codes","main-account/codes/apply","main-account/codes/my","main-account/codes/history","main-account/fiat-deposit-url","main-account/history","main-account/withdraw","main-account/withdraw-pay","main-account/transfer","trade-account/balance","trade-account/executed-history","trade-account/order","trade-account/order/history","order/collateral/limit","order/collateral/market","order/collateral/trigger_market","order/new","order/market","order/stock_market","order/stop_limit","order/stop_market","order/cancel","orders","profile/websocket_token"]}}},fees:{trading:{tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},options:{fiatCurrencies:["EUR","USD","RUB","UAH"],fetchBalance:{account:"spot"},accountsByType:{main:"main",spot:"spot",margin:"collateral",trade:"spot"},networksById:{BEP20:"BSC"},defaultType:"spot",brokerId:"ccxt"},precisionMode:n.sh,exceptions:{exact:{"Unauthorized request.":r.AuthenticationError,"The market format is invalid.":r.BadSymbol,"Market is not available":r.BadSymbol,"Invalid payload.":r.BadRequest,"Amount must be greater than 0":r.InvalidOrder,"Not enough balance.":r.InsufficientFunds,"The order id field is required.":r.InvalidOrder,"Not enough balance":r.InsufficientFunds,"This action is unauthorized.":r.PermissionDenied,"This API Key is not authorized to perform this action.":r.PermissionDenied,"Unexecuted order was not found.":r.OrderNotFound,"The selected from is invalid.":r.BadRequest,503:r.ExchangeNotAvailable,422:r.OrderNotFound},broad:{"This action is unauthorized":r.PermissionDenied,"Given amount is less than min amount":r.InvalidOrder,"Total is less than":r.InvalidOrder,"fee must be no less than":r.InvalidOrder,"Enable your key in API settings":r.PermissionDenied,"You don't have such amount for transfer":r.InsufficientFunds}}})}async fetchMarkets(e={}){const t=await this.v4PublicGetMarkets(),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"name"),n=this.safeString(i,"stock");let o=this.safeString(i,"money");o="PERP"===o?"USDT":o;const d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=this.safeValue(i,"tradesEnabled"),l=this.safeValue(i,"isCollateral");let u,f,p,m=d+"/"+h;const g="futures"===this.safeString(i,"type"),y=l&&!g;let v=!1;const b=this.parseNumber(this.parsePrecision(this.safeString(i,"stockPrec"))),w=b;let S,k;g?(p=o,f=this.safeCurrencyCode(p),m=m+":"+f,u="swap",v=!0,S=!0,k=!1):u="spot";const O=this.safeString(i,"takerFee"),T=a.O.stringDiv(O,"100"),I=this.safeString(i,"makerFee"),x=a.O.stringDiv(I,"100"),P={id:r,symbol:m,base:d,quote:h,settle:f,baseId:n,quoteId:o,settleId:p,type:u,spot:!g,margin:y,swap:g,future:!1,option:!1,active:c,contract:v,linear:S,inverse:k,taker:this.parseNumber(T),maker:this.parseNumber(x),contractSize:w,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:b,price:this.parseNumber(this.parsePrecision(this.safeString(i,"moneyPrec")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(i,"minAmount"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(i,"minTotal"),max:this.safeNumber(i,"maxTotal")}},created:void 0,info:i};s.push(P)}return s}async fetchCurrencies(e={}){const t=await this.v4PublicGetAssets(e),s=Object.keys(t),i={};for(let e=0;e<s.length;e++){const r=s[e],a=t[r],n=this.safeValue(a,"can_deposit",!0),o=this.safeValue(a,"can_withdraw",!0),d=n&&o,h=this.safeCurrencyCode(r);i[h]={id:r,code:h,info:a,name:void 0,active:d,deposit:n,withdraw:o,fee:void 0,precision:void 0,limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(a,"min_withdraw"),max:this.safeNumber(a,"max_withdraw")}}}}return i}async fetchTransactionFees(e=undefined,t={}){await this.loadMarkets();const s=await this.v4PublicGetFee(t),i=Object.keys(s),r={},a={};for(let e=0;e<i.length;e++){const t=i[e],n=s[t],o=this.safeCurrencyCode(t),d=this.safeValue(n,"withdraw",{});r[o]=this.safeString(d,"fixed");const h=this.safeValue(n,"deposit",{});a[o]=this.safeString(h,"fixed")}return{withdraw:r,deposit:a,info:s}}async fetchDepositWithdrawFees(e=undefined,t={}){await this.loadMarkets();const s=await this.v4PublicGetFee(t);return this.parseDepositWithdrawFees(s,e)}parseDepositWithdrawFees(e,t=undefined,s=undefined){const i={};t=this.marketCodes(t);const r=Object.keys(e);for(let s=0;s<r.length;s++){const a=r[s],n=a.split(" "),o=n[0],d=e[a],h=this.safeCurrencyCode(o);if(void 0===t||this.inArray(h,t)){void 0===this.safeValue(i,h)&&(i[h]=this.depositWithdrawFee({})),i[h].info[a]=d;let e=this.safeString(n,1);const t=this.safeValue(d,"withdraw"),s=this.safeValue(d,"deposit"),r=this.safeNumber(t,"fixed"),o=this.safeNumber(s,"fixed"),c={fee:r,percentage:void 0===r&&void 0},l={fee:o,percentage:void 0===o&&void 0};if(void 0!==e){const t=e.length;e=e.slice(1,t-1);const s=this.networkIdToCode(e);i[h].networks[s]={withdraw:c,deposit:l}}else i[h].withdraw=c,i[h].deposit=l}}const a=Object.keys(i);for(let e=0;e<a.length;e++){const t=a[e],s=this.currency(t);i[t]=this.assignDefaultDepositWithdrawFees(i[t],s)}return i}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v4PublicGetAssets(e),s={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e],r=this.market(i),n=this.safeValue(t,r.baseId,{});let o=this.safeString(n,"maker_fee"),d=this.safeString(n,"taker_fee");o=a.O.stringDiv(o,"100"),d=a.O.stringDiv(d,"100"),s[i]={info:n,symbol:r.symbol,percentage:!0,tierBased:!1,maker:this.parseNumber(o),taker:this.parseNumber(d)}}return s}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={market:s.id},r=await this.v1PublicGetTicker(this.extend(i,t)),a=this.safeValue(r,"result",{});return this.parseTicker(a,s)}parseTicker(e,t=undefined){t=this.safeMarket(void 0,t);const s=this.safeString(e,"last_price");return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"open"),close:s,last:s,previousClose:void 0,change:void 0,percentage:this.safeString(e,"change"),average:void 0,baseVolume:this.safeString2(e,"base_volume","volume"),quoteVolume:this.safeString2(e,"quote_volume","deal"),info:e},t)}async fetchTickers(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v4PublicGetTicker(t),i=Object.keys(s),r={};for(let e=0;e<i.length;e++){const t=i[e],a=this.safeMarket(t),n=this.parseTicker(s[t],a);r[n.symbol]=n}return this.filterByArrayTickers(r,"symbol",e)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={market:this.market(e).id};void 0!==t&&(i.limit=t);const r=await this.v4PublicGetOrderbookMarket(this.extend(i,s)),a=this.safeTimestamp(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},n=await this.v4PublicGetTradesMarket(this.extend(a,i));return this.parseTrades(n,r,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id);const n=await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(a,i));if(Array.isArray(n))return this.parseTrades(n,r,t,s);{let e=[];const i=Object.keys(n);for(let r=0;r<i.length;r++){const a=i[r],o=this.safeMarket(a,void 0,"_"),d=this.safeValue(n,a,[]),h=this.parseTrades(d,o,t,s);e=this.arrayConcat(e,h)}return e=this.sortBy2(e,"timestamp","id"),this.filterBySinceLimit(e,t,s,"timestamp")}}parseTrade(e,t=undefined){t=this.safeMarket(void 0,t);const s=this.safeTimestamp2(e,"time","trade_timestamp"),i=this.safeString2(e,"dealOrderId","orderId"),r=this.safeString(e,"deal"),a=this.safeString(e,"price"),n=this.safeString2(e,"amount","quote_volume"),o=this.safeString2(e,"id","tradeID"),d=this.safeString2(e,"type","side"),h=t.symbol,c=this.safeInteger(e,"role");let l,u;void 0!==c&&(l=1===c?"maker":"taker");const f=this.safeString(e,"fee");return void 0!==f&&(u={cost:f,currency:t.quote}),this.safeTrade({info:e,timestamp:s,datetime:this.iso8601(s),symbol:h,id:o,order:i,type:void 0,takerOrMaker:l,side:d,price:a,amount:n,cost:r,fee:u},t)}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={market:a.id,interval:this.safeString(this.timeframes,t,t)};if(void 0!==s){const e=1440;void 0===i&&(i=e),i=Math.min(i,e);const t=this.parseToInt(s/1e3);n.start=t}void 0!==i&&(n.limit=Math.min(i,1440));const o=await this.v1PublicGetKline(this.extend(n,r)),d=this.safeValue(o,"result",[]);return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,2),this.safeNumber(e,5)]}async fetchStatus(e={}){const t=await this.v4PublicGetPing(e),s=this.safeString(t,0);return{status:"pong"===s?"ok":s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v4PublicGetTime(e);return this.safeInteger(t,"time")}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d={market:o.id,side:s,amount:this.amountToPrecision(e,i)},h=this.safeString2(n,"clOrdId","clientOrderId");if(void 0===h){const e=this.safeString(this.options,"brokerId");void 0!==e&&(d.clientOrderId=e+this.uuid16())}else d.clientOrderId=h,n=this.omit(n,["clientOrderId"]);const c=this.safeString(o,"type"),l="limit"===t,u="market"===t,f=this.safeNumberN(n,["triggerPrice","stopPrice","activation_price"]),p=void 0!==f,m=this.isPostOnly(u,!1,n),[g,y]=this.handleMarginModeAndParams("createOrder",n);let v;if(m&&(d.postOnly=!0),void 0!==g&&"cross"!==g)throw new r.NotSupported(this.id+" createOrder() is only available for cross margin");const b=void 0!==g||"swap"===c;p?(d.activation_price=this.priceToPrecision(e,f),l?(v="v4PrivatePostOrderStopLimit",d.price=this.priceToPrecision(e,a)):(v="v4PrivatePostOrderStopMarket",b&&(v="v4PrivatePostOrderCollateralTriggerMarket"))):l?(v="v4PrivatePostOrderNew",b&&(v="v4PrivatePostOrderCollateralLimit"),d.price=this.priceToPrecision(e,a)):(v="v4PrivatePostOrderStockMarket",b&&(v="v4PrivatePostOrderCollateralMarket")),n=this.omit(y,["postOnly","triggerPrice","stopPrice"]);const w=await this[v](this.extend(d,n));return this.parseOrder(w)}async cancelOrder(e,t=undefined,s={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const i={market:this.market(t).id,orderId:parseInt(e)};return await this.v4PrivatePostOrderCancel(this.extend(i,s))}parseBalance(e){const t=Object.keys(e),s={};for(let i=0;i<t.length;i++){const r=t[i],a=this.safeCurrencyCode(r),n=e[r];if("object"==typeof n&&void 0!==n){const e=this.account();e.free=this.safeString(n,"available"),e.used=this.safeString(n,"freeze"),e.total=this.safeString(n,"main_balance"),s[a]=e}else{const e=this.account();e.total=n,s[a]=e}}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const[t,s]=this.handleMarketTypeAndParams("fetchBalance",void 0,e);let i;if("swap"===t)i="v4PrivatePostCollateralAccountBalance";else{const t=this.safeValue(this.options,"fetchBalance",{}),s=this.safeString(t,"account"),r=this.safeString(e,"account",s);e=this.omit(e,"account"),i="main"===r?"v4PrivatePostMainAccountBalance":"v4PrivatePostTradeAccountBalance"}const r=await this[i](s);return this.parseBalance(r)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n={market:a.id};void 0!==s&&(n.limit=Math.min(s,100));const o=await this.v4PrivatePostOrders(this.extend(n,i));return this.parseOrders(o,a,t,s,{status:"open"})}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),e=a.symbol,r.market=a.id),void 0!==s&&(r.limit=Math.min(s,100));const n=await this.v4PrivatePostTradeAccountOrderHistory(this.extend(r,i)),o=Object.keys(n);let d=[];for(let e=0;e<o.length;e++){const t=o[e],s=this.safeMarket(t,void 0,"_"),i=n[t];for(let e=0;e<i.length;e++){const t=this.parseOrder(i[e],s);d.push(this.extend(t,{status:"closed"}))}}return d=this.sortBy(d,"timestamp"),d=this.filterBySymbolSinceLimit(d,e,t,s),d}parseOrderType(e){return this.safeString({limit:"limit",market:"market","stop market":"market","stop limit":"limit","stock market":"market","margin limit":"limit","margin market":"market"},e,e)}parseOrder(e,t=undefined){const s=this.safeString(e,"market"),i=(t=this.safeMarket(s,t,"_")).symbol,r=this.safeString(e,"side"),a=this.safeString(e,"dealStock"),n=this.safeString(e,"left");let o=this.safeString(e,"clientOrderId");""===o&&(o=void 0);const d=this.safeString(e,"price"),h=this.safeNumber(e,"activation_price"),c=this.safeString2(e,"orderId","id"),l=this.safeString(e,"type");let u=this.safeString(e,"amount");const f=this.safeString(e,"dealMoney");"buy"!==r||"market"!==l&&"stop market"!==l||(u=a);const p=this.safeString(e,"dealFee");let m;void 0!==p&&(m={cost:this.parseNumber(p),currency:t.quote});const g=this.safeTimestamp2(e,"ctime","timestamp"),y=this.safeTimestamp(e,"ftime");return this.safeOrder({info:e,id:c,symbol:i,clientOrderId:o,timestamp:g,datetime:this.iso8601(g),lastTradeTimestamp:y,timeInForce:void 0,postOnly:void 0,status:void 0,side:r,price:d,type:this.parseOrderType(l),stopPrice:h,triggerPrice:h,amount:u,filled:a,remaining:n,average:void 0,cost:f,fee:m,trades:void 0},t)}async fetchOrderTrades(e,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={orderId:parseInt(e)};let n;void 0!==t&&(n=this.market(t),a.market=n.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostTradeAccountOrder(this.extend(a,r)),d=this.safeValue(o,"records",[]);return this.parseTrades(d,n)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s={ticker:this.currency(e).id};let i="v4PrivatePostMainAccountAddress";if(this.isFiat(e)){i="v4PrivatePostMainAccountFiatDepositUrl";const e=this.safeNumber(t,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires a provider when the ticker is fiat");s.provider=e;const a=this.safeNumber(t,"amount");if(void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an amount when the ticker is fiat");s.amount=a;if(void 0===this.safeValue(t,"uniqueId"))throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an uniqueId when the ticker is fiat")}const a=await this[i](this.extend(s,t)),n=this.safeString(a,"url"),o=this.safeValue(a,"account",{}),d=this.safeString(o,"address",n),h=this.safeString(o,"memo");return this.checkAddress(d),{currency:e,address:d,tag:h,network:void 0,info:a}}async setLeverage(e,t=undefined,s={}){if(await this.loadMarkets(),void 0!==t)throw new r.NotSupported(this.id+" setLeverage() does not allow to set per symbol");if(e<1||e>20)throw new r.BadRequest(this.id+" setLeverage() leverage should be between 1 and 20");const i={leverage:e};return await this.v4PrivatePostCollateralAccountLeverage(this.extend(i,s))}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n=this.safeValue(this.options,"accountsByType"),o=this.safeString(n,s,s),d=this.safeString(n,i,i),h=this.currencyToPrecision(e,t),c={ticker:a.id,amount:h,from:o,to:d},l=await this.v4PrivatePostMainAccountTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=undefined){return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async withdraw(e,t,s,i=undefined,a={}){await this.loadMarkets();const n=this.currency(e),o={ticker:n.id,amount:this.currencyToPrecision(e,t),address:s};let d=this.safeValue(a,"uniqueId");if(void 0===d&&(d=this.uuid22()),o.uniqueId=d,void 0!==i&&(o.memo=i),this.isFiat(e)){const e=this.safeValue(a,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a provider when the ticker is fiat");o.provider=e}const h=await this.v4PrivatePostMainAccountWithdraw(this.extend(o,a));return this.extend({id:d},this.parseTransaction(h,n))}parseTransaction(e,t=undefined){t=this.safeCurrency(void 0,t);const s=this.safeString(e,"address"),i=this.safeTimestamp(e,"createdAt"),r=this.safeString(e,"ticker"),a=this.safeString(e,"status"),n=this.safeString(e,"method");return{id:this.safeString(e,"uniqueId"),txid:this.safeString(e,"transactionHash"),timestamp:i,datetime:this.iso8601(i),network:this.safeString(e,"network"),addressFrom:"1"===n?s:void 0,address:s,addressTo:"2"===n?s:void 0,amount:this.safeNumber(e,"amount"),type:"1"===n?"deposit":"withdrawal",currency:this.safeCurrencyCode(r,t),status:this.parseTransactionStatus(a),updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:this.safeString(e,"description"),fee:{cost:this.safeNumber(e,"fee"),currency:this.safeCurrencyCode(r,t)},info:e}}parseTransactionStatus(e){return this.safeString({1:"pending",2:"pending",3:"ok",4:"canceled",5:"pending",6:"pending",7:"ok",9:"canceled",10:"pending",11:"pending",12:"pending",13:"pending",14:"pending",15:"pending",16:"pending",17:"pending"},e,e)}async fetchDeposit(e,t=undefined,s={}){let i;await this.loadMarkets();const r={transactionMethod:1,uniqueId:e,limit:1,offset:0};void 0!==t&&(i=this.currency(t),r.ticker=i.id);const a=await this.v4PrivatePostMainAccountHistory(this.extend(r,s)),n=this.safeValue(a,"records",[]),o=this.safeValue(n,0,{});return this.parseTransaction(o,i)}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={transactionMethod:1,limit:100,offset:0};void 0!==e&&(r=this.currency(e),a.ticker=r.id),void 0!==s&&(a.limit=Math.min(s,100));const n=await this.v4PrivatePostMainAccountHistory(this.extend(a,i)),o=this.safeValue(n,"records",[]);return this.parseTransactions(o,r,t,s)}async fetchBorrowInterest(e=undefined,t=undefined,s=undefined,i=undefined,r={}){await this.loadMarkets();const a={};let n;void 0!==t&&(n=this.market(t),a.market=n.id);const o=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(a,r)),d=this.parseBorrowInterests(o,n);return this.filterByCurrencySinceLimit(d,e,s,i)}parseBorrowInterest(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"_"),r=this.safeTimestamp(e,"modifyDate");return{symbol:i,marginMode:"cross",currency:"USDT",interest:this.safeNumber(e,"unrealizedFunding"),interestRate:98e-5,amountBorrowed:this.safeNumber(e,"amount"),timestamp:r,datetime:this.iso8601(r),info:e}}async fetchFundingRate(e,t={}){await this.loadMarkets(),e=this.symbol(e);const s=await this.fetchFundingRates([e],t);return this.safeValue(s,e)}async fetchFundingRates(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v4PublicGetFutures(t),i=this.safeValue(s,"result",[]),r=this.parseFundingRates(i);return this.filterByArray(r,"symbol",e)}parseFundingRate(e,t=undefined){const s=this.safeString(e,"ticker_id"),i=this.safeSymbol(s,t),r=this.safeNumber(e,"markPrice"),a=this.safeNumber(e,"indexPrice"),n=this.safeNumber(e,"interestRate"),o=this.safeNumber(e,"funding_rate"),d=this.safeInteger(e,"next_funding_rate_timestamp");return{info:e,symbol:i,markPrice:r,indexPrice:a,interestRate:n,timestamp:void 0,datetime:void 0,fundingRate:o,fundingTimestamp:void 0,fundingDatetime:this.iso8601(void 0),nextFundingRate:void 0,nextFundingTimestamp:d,nextFundingDatetime:this.iso8601(d),previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0}}isFiat(e){const t=this.safeValue(this.options,"fiatCurrencies",[]);return this.inArray(e,t)}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=this.omit(i,this.extractParams(e)),d=this.safeValue(t,0),h=this.safeValue(t,1),c="/"+this.implodeParams(e,i);let l=this.urls.api[d][h]+c;if("public"===h&&Object.keys(n).length&&(l+="?"+this.urlencode(n)),"private"===h){this.checkRequiredCredentials();const e=this.nonce().toString(),t=this.encode(this.secret),s="/api/"+d+c;a=this.json(this.extend({request:s,nonce:e},i));const n=this.stringToBase64(a),h=this.hmac(this.encode(n),t,o.o);r={"Content-Type":"application/json","X-TXC-APIKEY":this.apiKey,"X-TXC-PAYLOAD":n,"X-TXC-SIGNATURE":h}}return{url:l,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(404===e)throw new r.ExchangeError(this.id+" "+e.toString()+" endpoint not found");if(void 0!==o){const e=this.safeString(o,"status"),t=this.safeString(o,"message"),s=this.safeInteger(o,"code"),i=void 0!==e&&"200"!==e;if(i||void 0!==s){const s=this.id+" "+n;let a=t;if(i)a=e;else{const e=this.safeValue(o,"errors");if(void 0!==e){const t=Object.keys(e)[0],s=this.safeValue(e,t,[]);a=s.length>0?s[0]:n}}throw this.throwExactlyMatchedException(this.exceptions.exact,a,s),this.throwBroadlyMatchedException(this.exceptions.broad,n,s),new r.ExchangeError(s)}}}}},517:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(3771),r=s(6689),a=s(2194),n=s(9292),o=s(1372);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"woo",name:"WOO X",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,hostname:"woo.org",has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelWithdraw:!1,createDepositAddress:!1,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAccounts:!0,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,repayMargin:!0,setLeverage:!0,setMargin:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg",api:{pub:"https://api-pub.woo.org",public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{pub:"https://api-pub.staging.woo.org",public:"https://api.staging.woo.org",private:"https://api.staging.woo.org"},www:"https://woo.org/",doc:["https://docs.woo.org/"],fees:["https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees"],referral:{url:"https://x.woo.org/register?ref=YWOWC96B",discount:.35}},api:{v1:{pub:{get:{"hist/kline":10,"hist/trades":1}},public:{get:{info:1,"info/{symbol}":1,system_info:1,market_trades:1,token:1,token_network:1,funding_rates:1,"funding_rate/{symbol}":1,funding_rate_history:1,futures:1,"futures/{symbol}":1,"orderbook/{symbol}":1,kline:1}},private:{get:{"client/token":1,"order/{oid}":1,"client/order/{client_order_id}":1,orders:1,"client/trade/{tid}":1,"order/{oid}/trades":1,"client/trades":1,"asset/deposit":10,"asset/history":60,"sub_account/all":60,"sub_account/assets":60,token_interest:60,"token_interest/{token}":60,"interest/history":60,"interest/repay":60,"funding_fee/history":30,positions:3.33,"position/{symbol}":3.33,"client/transaction_history":60},post:{order:5,"asset/main_sub_transfer":30,"asset/withdraw":30,"interest/repay":60,"client/account_mode":120,"client/leverage":120},delete:{order:1,"client/order":1,orders:1,"asset/withdraw":120}}},v2:{private:{get:{"client/holding":1}}},v3:{private:{get:{"algo/order/{oid}":1,"algo/orders":1,balances:1,accountinfo:60,positions:3.33,buypower:1,referrals:60,referral_rewards:60,"convert/exchangeInfo":1,"convert/assetInfo":1,"convert/rfq":60,"convert/trade":1,"convert/trades":1},post:{"algo/order":5,"convert/rft":60},put:{"order/{oid}":2,"order/client/{client_order_id}":2,"algo/order/{oid}":2,"algo/order/client/{client_order_id}":2},delete:{"algo/order/{order_id}":1,"algo/orders/pending":1,"algo/orders/pending/{symbol}":1,"orders/pending":1}}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{createMarketBuyOrderRequiresPrice:!0,"network-aliases-for-tokens":{HT:"ERC20",OMG:"ERC20",UATOM:"ATOM",ZRX:"ZRX"},networks:{TRX:"TRON",TRC20:"TRON",ERC20:"ETH",BEP20:"BSC"},defaultNetworkCodeForCurrencies:{},transfer:{fillResponseFromRequest:!0},brokerId:"bc830de7-50f3-460b-9ee0-f430f83f9dad"},commonCurrencies:{},exceptions:{exact:{"-1000":r.ExchangeError,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.BadRequest,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.BadRequest,"-1011":r.ExchangeError,"-1012":r.BadRequest,"-1101":r.InvalidOrder,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder},broad:{"symbol must not be blank":r.BadRequest,"The token is not supported":r.BadRequest,"Your order and symbol are not valid or already canceled":r.BadRequest,"Insufficient WOO. Please enable margin trading for leverage trading":r.BadRequest}},precisionMode:n.sh})}async fetchMarkets(e={}){const t=await this.v1PublicGetInfo(e),s=[],i=this.safeValue(t,"rows",[]);for(let e=0;e<i.length;e++){const t=i[e],r=this.safeString(t,"symbol"),a=r.split("_");let n=this.safeStringLower(a,0);const o="spot"===n,d="perp"===n,h=this.safeString(a,1),c=this.safeString(a,2),l=this.safeCurrencyCode(h),u=this.safeCurrencyCode(c);let f,p,m,g,y=l+"/"+u,v=!0;const b=d;b&&(v=!1,f=this.safeString(a,2),p=this.safeCurrencyCode(f),y=l+"/"+u+":"+p,m=this.parseNumber("1"),n="swap",g=!0),s.push({id:r,symbol:y,base:l,quote:u,settle:p,baseId:h,quoteId:c,settleId:f,type:n,spot:o,margin:v,swap:d,future:!1,option:!1,active:void 0,contract:b,linear:g,inverse:void 0,contractSize:m,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(t,"base_tick"),price:this.safeNumber(t,"quote_tick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(t,"base_min"),max:this.safeNumber(t,"base_max")},price:{min:this.safeNumber(t,"quote_min"),max:this.safeNumber(t,"quote_max")},cost:{min:this.safeNumber(t,"min_notional"),max:void 0}},created:this.safeTimestamp(t,"created_time"),info:t})}return s}async fetchTrades(e,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n={symbol:a.id};void 0!==s&&(n.limit=s);const o=await this.v1PublicGetMarketTrades(this.extend(n,i)),d=this.safeValue(o,"rows",{});return this.parseTrades(d,a,t,s)}parseTrade(e,t=undefined){const s="id"in e,i=this.safeTimestamp(e,"executed_timestamp"),r=this.safeString(e,"symbol"),n=(t=this.safeMarket(r,t)).symbol,o=this.safeString(e,"executed_price"),d=this.safeString(e,"executed_quantity"),h=this.safeString(e,"order_id"),c=this.parseTokenAndFeeTemp(e,"fee_asset","fee"),l=a.O.stringMul(o,d),u=this.safeStringLower(e,"side"),f=this.safeString(e,"id");let p;if(s){p="1"===this.safeString(e,"is_maker")?"maker":"taker"}return this.safeTrade({id:f,timestamp:i,datetime:this.iso8601(i),symbol:n,side:u,price:o,amount:d,cost:l,order:h,takerOrMaker:p,type:void 0,fee:c,info:e},t)}parseTokenAndFeeTemp(e,t,s){const i=this.safeString(e,s);let r;if(void 0!==i){const s=this.safeString(e,t);r={cost:i,currency:this.safeCurrencyCode(s)}}return r}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v3PrivateGetAccountinfo(e),s=this.safeValue(t,"data",{}),i=this.safeString(s,"makerFeeRate"),r=this.safeString(s,"takerFeeRate"),n={};for(let e=0;e<this.symbols.length;e++){const s=this.symbols[e];n[s]={info:t,symbol:s,maker:this.parseNumber(a.O.stringDiv(i,"10000")),taker:this.parseNumber(a.O.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return n}async fetchCurrencies(e={}){const t={},s=await this.v1PublicGetToken(e),i=this.safeValue(s,"rows",[]),r=this.groupBy(i,"balance_token"),n=Object.keys(r);for(let e=0;e<n.length;e++){const s=n[e],i=r[s],o=this.safeCurrencyCode(s);let d,h;const c={};for(let e=0;e<i.length;e++){const t=i[e];d=this.safeString(t,"fullname");const s=this.safeString(t,"token"),r=s.split("_")[0],n=this.parsePrecision(this.safeString(t,"decimals"));void 0!==n&&(h=void 0===h?n:a.O.stringMin(n,h)),c[r]={id:s,network:r,limits:{withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},active:void 0,deposit:void 0,withdraw:void 0,fee:void 0,precision:this.parseNumber(n),info:t}}t[o]={id:s,name:d,code:o,precision:this.parseNumber(h),active:void 0,fee:void 0,networks:c,deposit:void 0,withdraw:void 0,limits:{deposit:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},info:i}}return t}async createOrder(e,t,s,i,n=undefined,o={}){const d=this.safeValue2(o,"reduceOnly","reduce_only"),h=t.toUpperCase();await this.loadMarkets();const c=this.market(e),l=s.toUpperCase(),u={symbol:c.id,side:l},f=this.safeNumber2(o,"triggerPrice","stopPrice"),p=this.safeValue(o,"stopLoss"),m=this.safeValue(o,"takeProfit"),g=this.safeString(o,"algoType"),y=void 0!==f||void 0!==p||void 0!==m||void 0!==this.safeValue(o,"childOrders"),v="MARKET"===h,b=this.safeStringLower(o,"timeInForce"),w=this.isPostOnly(v,void 0,o),S=y?"reduceOnly":"reduce_only",k=y?"clientOrderId":"client_order_id",O=y?"quantity":"order_quantity",T=y?"price":"order_price";if(u[y?"type":"order_type"]=h,y||(w?u.order_type="POST_ONLY":"fok"===b?u.order_type="FOK":"ioc"===b&&(u.order_type="IOC")),d&&(u[S]=d),void 0!==n&&(u[T]=this.priceToPrecision(e,n)),v&&!y)if(c.spot&&"BUY"===l){const t=this.safeNumber(o,"cost");if(this.safeValue(this.options,"createMarketBuyOrderRequiresPrice",!0))if(void 0===t){if(void 0===n)throw new r.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate total order cost. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or alternatively, supply the total cost value in the 'order_amount' in exchange-specific parameters");{const t=this.numberToString(i),s=this.numberToString(n),r=a.O.stringMul(t,s);u.order_amount=this.costToPrecision(e,r)}}else u.order_amount=this.costToPrecision(e,t);else u.order_amount=this.costToPrecision(e,i)}else u.order_quantity=this.amountToPrecision(e,i);else"POSITIONAL_TP_SL"!==g&&(u[O]=this.amountToPrecision(e,i));const I=this.safeStringN(o,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==I&&(u[k]=I),void 0!==f)"TRAILING_STOP"!==g&&(u.triggerPrice=this.priceToPrecision(e,f),u.algoType="STOP");else if(void 0!==p||void 0!==m){u.algoType="BRACKET";const t={symbol:c.id,reduceOnly:!1,algoType:"POSITIONAL_TP_SL",childOrders:[]},s="BUY"===l?"SELL":"BUY";if(void 0!==p){const i=this.safeNumber2(p,"triggerPrice","price",p),r={side:s,algoType:"STOP_LOSS",triggerPrice:this.priceToPrecision(e,i),type:"CLOSE_POSITION",reduceOnly:!0};t.childOrders.push(r)}if(void 0!==m){const i=this.safeNumber2(m,"triggerPrice","price",m),r={side:s,algoType:"TAKE_PROFIT",triggerPrice:this.priceToPrecision(e,i),type:"CLOSE_POSITION",reduceOnly:!0};t.childOrders.push(r)}u.childOrders=[t]}let x;o=this.omit(o,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit"]),x=y?await this.v3PrivatePostAlgoOrder(this.extend(u,o)):await this.v1PrivatePostOrder(this.extend(u,o));const P=this.safeValue(x,"data");if(void 0!==P){const e=this.safeValue(P,"rows",[]);return this.parseOrder(e[0],c)}const M=this.parseOrder(x,c);return M.type=t,M}async editOrder(e,t,s,i,r=undefined,a=undefined,n={}){await this.loadMarkets();const o=this.market(t),d={};void 0!==a&&(d.price=this.priceToPrecision(t,a)),void 0!==r&&(d.quantity=this.amountToPrecision(t,r));const h=this.safeString2(n,"clOrdID","clientOrderId"),c=this.safeString(n,"client_order_id",h),l=void 0!==c,u=this.safeNumberN(n,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==u&&(d.triggerPrice=this.priceToPrecision(t,u));const f=void 0!==u||void 0!==this.safeValue(n,"childOrders");let p;l?f?(p="v3PrivatePutAlgoOrderClientClientOrderId",d.oid=e):(p="v3PrivatePutOrderClientClientOrderId",d.client_order_id=c):(p=f?"v3PrivatePutAlgoOrderOid":"v3PrivatePutOrderOid",d.oid=e),n=this.omit(n,["clOrdID","clientOrderId","client_order_id","stopPrice","triggerPrice","takeProfitPrice","stopLossPrice"]);const m=await this[p](this.extend(d,n)),g=this.safeValue(m,"data",{});return this.parseOrder(g,o)}async cancelOrder(e,t=undefined,s={}){const i=this.safeValue(s,"stop",!1);s=this.omit(s,"stop"),i||this.checkRequiredSymbol("cancelOrder",t),await this.loadMarkets();const r={},a=this.safeString2(s,"clOrdID","clientOrderId"),n=this.safeString(s,"client_order_id",a),o=void 0!==n;let d,h;i?(d="v3PrivateDeleteAlgoOrderOrderId",r.order_id=e):o?(d="v1PrivateDeleteClientOrder",r.client_order_id=n,s=this.omit(s,["clOrdID","clientOrderId","client_order_id"])):(d="v1PrivateDeleteOrder",r.order_id=e),void 0!==t&&(h=this.market(t)),i||(r.symbol=h.id);const c=await this[d](this.extend(r,s)),l={symbol:t};return o?l.client_order_id=n:l.id=e,this.extend(this.parseOrder(c),l)}async cancelAllOrders(e=undefined,t={}){await this.loadMarkets();const s=this.safeValue(t,"stop");if(t=this.omit(t,"stop"),s)return await this.v3PrivateDeleteAlgoOrdersPending(t);this.checkRequiredSymbol("cancelOrders",e);const i={symbol:this.market(e).id};return await this.v1PrivateDeleteOrders(this.extend(i,t))}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i=void 0!==t?this.market(t):void 0,r=this.safeValue(s,"stop");s=this.omit(s,"stop");const a={},n=this.safeString2(s,"clOrdID","clientOrderId");let o;r?(o="v3PrivateGetAlgoOrderOid",a.oid=e):n?(o="v1PrivateGetClientOrderClientOrderId",a.client_order_id=n):(o="v1PrivateGetOrderOid",a.oid=e);const d=await this[o](this.extend(a,s)),h=this.safeValue(d,"data",d);return this.parseOrder(h,i)}async fetchOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;const n=this.safeValue(i,"stop");let o;i=this.omit(i,"stop"),void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(n?r.createdTimeStart=t:r.start_t=t),n&&(r.algoType="stop"),o=n?await this.v3PrivateGetAlgoOrders(this.extend(r,i)):await this.v1PrivateGetOrders(this.extend(r,i));const d=this.safeValue(o,"data",o),h=this.safeValue(d,"rows");return this.parseOrders(h,a,t,s,i)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrder(e,t=undefined){const s=this.safeTimestampN(e,["timestamp","created_time","createdTime"]),i=this.safeStringN(e,["order_id","orderId","algoOrderId"]),r=this.omitZero(this.safeString2(e,"client_order_id","clientOrderId")),n=this.safeString(e,"symbol"),o=(t=this.safeMarket(n,t)).symbol,d=this.safeString2(e,"order_price","price"),h=this.safeString2(e,"order_quantity","quantity"),c=this.safeString2(e,"order_amount","amount"),l=this.safeStringLower2(e,"order_type","type"),u=this.safeValue2(e,"status","algoStatus"),f=this.safeStringLower(e,"side"),p=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),m=this.omitZero(this.safeString2(e,"average_executed_price","averageExecutedPrice")),g=a.O.stringSub(c,p),y=this.safeValue2(e,"total_fee","totalFee"),v=this.safeString2(e,"fee_asset","feeAsset"),b=this.safeValue(e,"Transactions"),w=this.safeNumber(e,"triggerPrice");let S,k;const O=this.safeValue(e,"childOrders");if(void 0!==O){const e=this.safeValue(O,0),t=this.safeValue(e,"childOrders",[]);if(t.length>0){const e=this.safeValue(t,0),s=this.safeValue(t,1);S=this.safeNumber(e,"triggerPrice"),k=this.safeNumber(s,"triggerPrice")}}const T=this.safeTimestamp2(e,"updatedTime","updated_time");return this.safeOrder({id:i,clientOrderId:r,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:T,status:this.parseOrderStatus(u),symbol:o,type:l,timeInForce:this.parseTimeInForce(l),postOnly:void 0,reduceOnly:this.safeValue(e,"reduce_only"),side:f,price:d,stopPrice:w,triggerPrice:w,takeProfitPrice:S,stopLossPrice:k,average:m,amount:h,filled:p,remaining:g,cost:c,trades:b,fee:{cost:y,currency:v},info:e},t)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i={symbol:this.market(e).id};void 0!==t&&(t=Math.min(t,1e3),i.max_level=t);const r=await this.v1PublicGetOrderbookSymbol(this.extend(i,s)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a,"bids","asks","price","quantity")}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.limit=Math.min(i,1e3));const o=await this.v1PublicGetKline(this.extend(n,r)),d=this.safeValue(o,"rows",[]);return this.parseOHLCVs(d,a,t,s,i)}parseOHLCV(e,t=undefined){return[this.safeInteger(e,"start_timestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOrderTrades(e,t=undefined,s=undefined,i=undefined,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const n={oid:e},o=await this.v1PrivateGetOrderOidTrades(this.extend(n,r)),d=this.safeValue(o,"rows",[]);return this.parseTrades(d,a,s,i,r)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.start_t=t);const n=await this.v1PrivateGetClientTrades(this.extend(r,i)),o=this.safeValue(n,"rows",[]);return this.parseTrades(o,a,t,s,i)}async fetchAccounts(e={}){const t=await this.v1PrivateGetSubAccountAssets(e),s=this.safeValue(t,"rows",[]);return this.parseAccounts(s,e)}parseAccount(e){const t=this.safeString(e,"account");return{info:e,id:this.safeString(e,"application_id"),name:t,code:void 0,type:"Main"===t?"main":"subaccount"}}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v3PrivateGetBalances(e),s=this.safeValue(t,"data");return this.parseBalance(s)}parseBalance(e){const t={info:e},s=this.safeValue(e,"holding",[]);for(let e=0;e<s.length;e++){const i=s[e],r=this.safeCurrencyCode(this.safeString(i,"token")),a=this.account();a.total=this.safeString(i,"holding"),a.free=this.safeString(i,"availableBalance"),t[r]=a}return this.safeBalance(t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i=this.defaultNetworkCodeForCurrency(e),r=this.safeString(t,"network",i);t=this.omit(t,"network");const a={token:r+"_"+s.code},n=await this.v1PrivateGetAssetDeposit(this.extend(a,t)),o=this.safeString(n,"extra"),d=this.safeString(n,"address");return this.checkAddress(d),{currency:e,address:d,tag:o,network:r,info:n}}async getAssetHistoryRows(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.balance_token=a.id),void 0!==t&&(r.start_t=t),void 0!==s&&(r.pageSize=s);const n=this.safeString(i,"type");i=this.omit(i,"type"),void 0!==n&&(r.type=n);const o=await this.v1PrivateGetAssetHistory(this.extend(r,i));return[a,this.safeValue(o,"rows",{})]}async fetchLedger(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,i);return this.parseLedger(a,r,t,s,i)}parseLedgerEntry(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code,r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"token_side")?"in":"out",n=this.safeTimestamp(e,"created_time"),o=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount");return{id:this.safeString(e,"id"),currency:i,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"tx_id"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,fee:o,direction:a,timestamp:n,datetime:this.iso8601(n),type:this.parseLedgerEntryType(this.safeString(e,"type")),info:e}}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}getCurrencyFromChaincode(e,t){if(void 0!==t)return t;{const s=e.split("_"),i=s.length,r=this.safeString(s,0);let a=this.safeString(s,1,r);i>2&&(a+="_"+this.safeString(s,2)),t=this.safeCurrency(a)}return t}async fetchDeposits(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchDepositsWithdrawals(e,t,s,this.extend({token_side:"DEPOSIT"},i))}async fetchWithdrawals(e=undefined,t=undefined,s=undefined,i={}){return await this.fetchDepositsWithdrawals(e,t,s,this.extend({token_side:"WITHDRAW"},i))}async fetchDepositsWithdrawals(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,this.extend({type:"BALANCE"},i));return this.parseTransactions(a,r,t,s,i)}parseTransaction(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code;let r=this.safeStringLower(e,"token_side");"withdraw"===r&&(r="withdrawal");const a=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount"),n=this.safeString(e,"target_address"),o=this.safeString(e,"source_address"),d=this.safeTimestamp(e,"created_time");return{info:e,id:this.safeString2(e,"id","withdraw_id"),txid:this.safeString(e,"tx_id"),timestamp:d,datetime:this.iso8601(d),address:void 0,addressFrom:o,addressTo:n,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeTimestamp(e,"updated_time"),comment:void 0,fee:a}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n={token:a.id,amount:this.parseNumber(t),from_application_id:s,to_application_id:i},o=await this.v1PrivatePostAssetMainSubTransfer(this.extend(n,r)),d=this.parseTransfer(o,a),h=this.safeValue(this.options,"transfer",{});return this.safeValue(h,"fillResponseFromRequest",!0)&&(d.amount=t,d.fromAccount=s,d.toAccount=i),d}async fetchTransfers(e=undefined,t=undefined,s=undefined,i={}){const[r,a]=await this.getAssetHistoryRows(e,t,s,this.extend({type:"COLLATERAL"},i));return this.parseTransfers(a,r,t,s,i)}parseTransfer(e,t=undefined){const s=this.safeString(e,"token"),i=this.getCurrencyFromChaincode(s,t).code;let r,a,n=this.safeStringLower(e,"token_side");"withdraw"===n&&(n="withdrawal"),"withdraw"===n?(r=void 0,a="spot"):"deposit"===n&&(r="spot",a=void 0);const o=this.safeTimestamp(e,"created_time"),d=this.safeValue(e,"success");let h;return void 0!==d&&(h=d?"ok":"failed"),{id:this.safeString(e,"id"),timestamp:o,datetime:this.iso8601(o),currency:i,amount:this.safeNumber(e,"amount"),fromAccount:r,toAccount:a,status:this.parseTransferStatus(this.safeString(e,"status",h)),info:e}}parseTransferStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),await this.loadMarkets(),this.checkAddress(s);const n=this.currency(e),o={amount:t,address:s};void 0!==i&&(o.extra=i);const d=this.safeValue(this.options,"networks",{}),h=this.safeValue(n,"networks",{}),c=this.safeStringUpper(a,"network"),l=this.safeString(d,c,c),u=this.safeValue(h,l,{}),f=this.safeString(u,"id");if(void 0===f)throw new r.BadRequest(this.id+" withdraw() require network parameter");o.token=f;const p=await this.v1PrivatePostAssetWithdraw(this.extend(o,a));return this.parseTransaction(p,n)}async repayMargin(e,t,s=undefined,i={}){let r;await this.loadMarkets(),void 0!==s&&(r=this.market(s),s=r.symbol);const a=this.currency(e),n={token:a.id,amount:this.currencyToPrecision(e,t)},o=await this.v1PrivatePostInterestRepay(this.extend(n,i)),d=this.parseMarginLoan(o,a);return this.extend(d,{amount:t,symbol:s})}parseMarginLoan(e,t=undefined){return{id:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,symbol:void 0,timestamp:void 0,datetime:void 0,info:e}}nonce(){return this.milliseconds()}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){const n=t[0],d=t[1],h=this.implodeParams(e,i);let c=this.implodeHostname(this.urls.api[d]);if(c+="/"+n+"/",i=this.omit(i,this.extractParams(e)),i=this.keysort(i),"public"===d)c+=d+"/"+h,Object.keys(i).length&&(c+="?"+this.urlencode(i));else{if(this.checkRequiredCredentials(),"POST"===s&&("algo/order"===e||"order"===e)){const t="bc830de7-50f3-460b-9ee0-f430f83f9dad",s=this.safeString(this.options,"brokerId",t);e.indexOf("algo")>-1?i.brokerId=s:i.broker_id=s,i=this.keysort(i)}let t="";const d=this.nonce().toString();if(c+=h,r={"x-api-key":this.apiKey,"x-api-timestamp":d},"v3"===n){if(t=d+s+"/"+n+"/"+h,"POST"===s||"PUT"===s||"DELETE"===s)t+=a=this.json(i);else if(Object.keys(i).length){const e=this.urlencode(i);c+="?"+e,t+="?"+e}r["content-type"]="application/json"}else t=this.urlencode(i),"POST"===s||"PUT"===s||"DELETE"===s?a=t:c+="?"+t,t+="|"+d,r["content-type"]="application/x-www-form-urlencoded";r["x-api-signature"]=this.hmac(this.encode(t),this.encode(this.secret),o.J)}return{url:c,method:s,body:a,headers:r}}handleErrors(e,t,s,i,r,a,n,o,d){if(!n)return;const h=this.safeValue(n,"success"),c=this.safeString(n,"code");if(!h){const e=this.id+" "+this.json(n);this.throwBroadlyMatchedException(this.exceptions.broad,a,e),this.throwExactlyMatchedException(this.exceptions.exact,c,e)}}parseIncome(e,t=undefined){const s=this.safeString(e,"symbol"),i=this.safeSymbol(s,t),r=this.safeNumber(e,"funding_fee"),a=this.safeCurrencyCode("USD"),n=this.safeString(e,"id"),o=this.safeTimestamp(e,"updated_time"),d=this.safeNumber(e,"funding_rate");return{info:e,symbol:i,code:a,timestamp:o,datetime:this.iso8601(o),id:n,amount:r,rate:d}}async fetchFundingHistory(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.start_t=t);const n=await this.v1PrivateGetFundingFeeHistory(this.extend(r,i)),o=this.safeValue(n,"rows",[]);return this.parseIncomes(o,a,t,s)}parseFundingRate(e,t=undefined){const s=this.safeString(e,"symbol");t=this.market(s);const i=this.safeInteger(e,"next_funding_time"),r=this.safeInteger(e,"est_funding_rate_timestamp"),a=this.safeInteger(e,"last_funding_rate_timestamp");return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"est_funding_rate"),fundingTimestamp:i,fundingDatetime:this.iso8601(i),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"last_funding_rate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a)}}async fetchFundingRate(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.v1PublicGetFundingRateSymbol(this.extend(i,t));return this.parseFundingRate(r,s)}async fetchFundingRates(e=undefined,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const s=await this.v1PublicGetFundingRates(t),i=this.safeValue(s,"rows",{}),r=this.parseFundingRates(i);return this.filterByArray(r,"symbol",e)}async fetchFundingRateHistory(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();let r=!1;if([r,i]=this.handleOptionAndParams(i,"fetchFundingRateHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,s,i,"page",25);let a={};if(void 0!==e){const t=this.market(e);e=t.symbol,a.symbol=t.id}void 0!==t&&(a.start_t=this.parseToInt(t/1e3)),[a,i]=this.handleUntilOption("end_t",a,i,.001);const n=await this.v1PublicGetFundingRateHistory(this.extend(a,i)),o=this.safeValue(n,"rows"),d=[];for(let e=0;e<o.length;e++){const t=o[e],s=this.safeString(t,"symbol"),i=this.safeInteger(t,"funding_rate_timestamp");d.push({info:t,symbol:this.safeSymbol(s),fundingRate:this.safeNumber(t,"funding_rate"),timestamp:i,datetime:this.iso8601(i)})}const h=this.sortBy(d,"timestamp");return this.filterBySymbolSinceLimit(h,e,t,s)}async fetchLeverage(e,t={}){await this.loadMarkets();const s=await this.v3PrivateGetAccountinfo(t),i=this.safeValue(s,"data");return{info:s,leverage:this.safeNumber(i,"leverage")}}async setLeverage(e,t=undefined,s={}){if(await this.loadMarkets(),e<1||e>20)throw new r.BadRequest(this.id+" leverage should be between 1 and 20");const i={leverage:e};return await this.v1PrivatePostClientLeverage(this.extend(i,s))}async fetchPosition(e=undefined,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},r=await this.v1PrivateGetPositionSymbol(this.extend(i,t));return this.parsePosition(r,s)}async fetchPositions(e=undefined,t={}){await this.loadMarkets();const s=await this.v3PrivateGetPositions(t),i=this.safeValue(s,"data",{}),r=this.safeValue(i,"positions",[]);return this.parsePositions(r,e)}parsePosition(e,t=undefined){const s=this.safeString(e,"symbol");t=this.safeMarket(s,t);let i,r=this.safeString(e,"holding");i=a.O.stringGt(r,"0")?"long":"short";const n=this.safeString(t,"contractSize"),o=this.safeString(e,"markPrice"),d=this.safeTimestamp(e,"timestamp"),h=this.safeString(e,"averageOpenPrice"),c=a.O.stringSub(o,h),l=a.O.stringMul(c,r);r=a.O.stringAbs(r);const u=a.O.stringMul(r,o);return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:d,datetime:this.iso8601(d),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(h),notional:this.parseNumber(u),leverage:void 0,unrealizedPnl:this.parseNumber(l),contracts:this.parseNumber(r),contractSize:this.parseNumber(n),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"estLiqPrice"),markPrice:this.parseNumber(o),lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:i,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}defaultNetworkCodeForCurrency(e){const t=this.currency(e).networks,s=Object.keys(t);for(let e=0;e<s.length;e++){const t=s[e];if("ETH"===t)return t}return this.safeValue(s,0)}}},3850:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5790),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"yobit",name:"YoBit",countries:["RU"],rateLimit:2e3,version:"3",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,createDepositAddress:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchDepositAddress:!0,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawals:!1,reduceMargin:!1,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0,ws:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpg",api:{public:"https://yobit.net/api",private:"https://yobit.net/tapi"},www:"https://www.yobit.net",doc:"https://www.yobit.net/en/api/",fees:"https://www.yobit.net/en/fees/"},api:{public:{get:{"depth/{pair}":1,info:1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{ActiveOrders:1,CancelOrder:1,GetDepositAddress:1,getInfo:1,OrderInfo:1,Trade:1,TradeHistory:1,WithdrawCoinsToAddress:1}}},fees:{trading:{maker:.002,taker:.002},funding:{withdraw:{}}},commonCurrencies:{AIR:"AirCoin",ANI:"ANICoin",ANT:"AntsCoin",ATMCHA:"ATM",ASN:"Ascension",AST:"Astral",ATM:"Autumncoin",AUR:"AuroraCoin",BAB:"Babel",BAN:"BANcoin",BCC:"BCH",BCS:"BitcoinStake",BITS:"Bitstar",BLN:"Bulleon",BNS:"Benefit Bonus Coin",BOT:"BOTcoin",BON:"BONES",BPC:"BitcoinPremium",BST:"BitStone",BTS:"Bitshares2",CAT:"BitClave",CBC:"CryptoBossCoin",CMT:"CometCoin",COIN:"Coin.com",COV:"Coven Coin",COVX:"COV",CPC:"Capricoin",CREDIT:"Creditbit",CS:"CryptoSpots",DCT:"Discount",DFT:"DraftCoin",DGD:"DarkGoldCoin",DIRT:"DIRTY",DROP:"FaucetCoin",DSH:"DASH",EGC:"EverGreenCoin",EGG:"EggCoin",EKO:"EkoCoin",ENTER:"ENTRC",EPC:"ExperienceCoin",ESC:"EdwardSnowden",EUROPE:"EUROP",EXT:"LifeExtension",FUND:"FUNDChains",FUNK:"FUNKCoin",FX:"FCoin",GCC:"GlobalCryptocurrency",GEN:"Genstake",GENE:"Genesiscoin",GMR:"Gimmer",GOLD:"GoldMint",GOT:"Giotto Coin",GSX:"GlowShares",GT:"GTcoin",HTML5:"HTML",HYPERX:"HYPER",ICN:"iCoin",INSANE:"INSN",JNT:"JointCoin",JPC:"JupiterCoin",JWL:"Jewels",KNC:"KingN Coin",LBTCX:"LiteBitcoin",LIZI:"LiZi",LOC:"LocoCoin",LOCX:"LOC",LUNYR:"LUN",LUN:"LunarCoin",LUNA:"Luna Coin",MASK:"Yobit MASK",MDT:"Midnight",MEME:"Memez Token",MIS:"MIScoin",MM:"MasterMint",NAV:"NavajoCoin",NBT:"NiceBytes",OMG:"OMGame",ONX:"Onix",PAC:"$PAC",PLAY:"PlayCoin",PIVX:"Darknet",PURE:"PurePOS",PUTIN:"PutinCoin",SPACE:"Spacecoin",STK:"StakeCoin",SUB:"Subscriptio",PAY:"EPAY",PLC:"Platin Coin",RAI:"RaiderCoin",RCN:"RCoin",REP:"Republicoin",RUR:"RUB",SBTC:"Super Bitcoin",SMC:"SmartCoin",SOLO:"SoloCoin",SOUL:"SoulCoin",STAR:"StarCoin",SUPER:"SuperCoin",TNS:"Transcodium",TTC:"TittieCoin",UNI:"Universe",UST:"Uservice",VOL:"VolumeCoin",XIN:"XINCoin",XMT:"SummitCoin",XRA:"Ratecoin"},options:{maxUrlLength:2048,fetchOrdersRequiresSymbol:!0,networks:{ETH:"ERC20",TRX:"TRC20",BSC:"BEP20"}},precisionMode:n.sh,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"The given order has already been cancelled":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"Total transaction amount":r.InvalidOrder,"The given order has already been closed and cannot be cancelled":r.InvalidOrder,"Insufficient funds":r.InsufficientFunds,"invalid key":r.AuthenticationError,"invalid nonce":r.InvalidNonce,"Total order amount is less than minimal amount":r.InvalidOrder,"Rate Limited":r.RateLimitExceeded}},orders:{}})}parseBalance(e){const t=this.safeValue(e,"return",{}),s=this.safeInteger(t,"server_time"),i={info:e,timestamp:s,datetime:this.iso8601(s)},r=this.safeValue(t,"funds",{}),a=this.safeValue(t,"funds_incl_orders",{}),n=Object.keys(this.extend(r,a));for(let e=0;e<n.length;e++){const t=n[e],s=this.safeCurrencyCode(t),o=this.account();o.free=this.safeString(r,t),o.total=this.safeString(a,t),i[s]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchMarkets(e={}){const t=await this.publicGetInfo(e),s=this.safeValue(t,"pairs",{}),i=Object.keys(s),r=[];for(let e=0;e<i.length;e++){const t=i[e],n=s[t],[o,d]=t.split("_");let h=o.toUpperCase(),c=d.toUpperCase();h=this.safeCurrencyCode(h),c=this.safeCurrencyCode(c);const l=this.safeInteger(n,"hidden");let u=this.safeString(n,"fee");u=a.O.stringDiv(u,"100"),r.push({id:t,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:o,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),maker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(n,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_amount"),max:this.safeNumber(n,"max_amount")},price:{min:this.safeNumber(n,"min_price"),max:this.safeNumber(n,"max_price")},cost:{min:this.safeNumber(n,"min_total"),max:void 0}},created:void 0,info:n})}return r}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),a={pair:i.id};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s));if(!(i.id in n))throw new r.ExchangeError(this.id+" "+i.symbol+" order book is empty or not available");const o=n[i.id];return this.parseOrderBook(o,e)}async fetchOrderBooks(e=undefined,t=undefined,s={}){let i;if(await this.loadMarkets(),void 0===e){if(i=this.ids.join("-"),i.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else i=this.marketIds(e),i=i.join("-");const a={pair:i};void 0!==t&&(a.limit=t);const n=await this.publicGetDepthPair(this.extend(a,s)),o={};i=Object.keys(n);for(let e=0;e<i.length;e++){const t=i[e],s=this.safeSymbol(t);o[s]=this.parseOrderBook(n[t],s)}return o}parseTicker(e,t=undefined){const s=this.safeTimestamp(e,"updated"),i=this.safeString(e,"last");return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:i,last:i,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickers(e=undefined,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+' fetchTickers() requires "symbols" argument');let s;await this.loadMarkets(),s=void 0===(e=this.marketSymbols(e))?this.ids:this.marketIds(e);const i=s.length,a=s.join("-"),n=this.safeInteger(this.options,"maxUrlLength",2048),o=a.length+30;if(o>n)throw new r.ArgumentsRequired(this.id+" fetchTickers() is being requested for "+i.toString()+" markets (which has an URL length of "+o.toString()+" characters), but it exceedes max URL length ("+n.toString()+"), please pass limisted symbols array to fetchTickers to fit in one request");const d={pair:a},h=await this.publicGetTickerPair(this.extend(d,t)),c={},l=Object.keys(h);for(let e=0;e<l.length;e++){const t=l[e],s=h[t],i=this.safeMarket(t);c[i.symbol]=this.parseTicker(s,i)}return this.filterByArrayTickers(c,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=undefined){const s=this.safeTimestamp(e,"timestamp");let i=this.safeString(e,"type");"ask"===i?i="sell":"bid"===i&&(i="buy");const r=this.safeString2(e,"rate","price"),a=this.safeString2(e,"trade_id","tid"),n=this.safeString(e,"order_id"),o=this.safeString(e,"pair"),d=this.safeSymbol(o,t),h=this.safeString(e,"amount"),c=this.parseNumber(r),l=this.parseNumber(h),u="limit";let f;const p=this.safeNumber(e,"commission");if(void 0!==p){const t=this.safeString(e,"commissionCurrency");f={cost:p,currency:this.safeCurrencyCode(t)}}if(void 0!==this.safeValue(e,"is_your_order")&&void 0===f){const e=this.calculateFee(d,u,i,l,c,"taker");f={currency:this.safeString(e,"currency"),cost:this.safeString(e,"cost"),rate:this.safeString(e,"rate")}}return this.safeTrade({id:a,order:n,timestamp:s,datetime:this.iso8601(s),symbol:d,type:u,side:i,takerOrMaker:void 0,price:r,amount:h,cost:void 0,fee:f,info:e},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==s&&(a.limit=s);const n=await this.publicGetTradesPair(this.extend(a,i));if(Array.isArray(n)){if(0===n.length)return[]}const o=this.safeValue(n,r.id,[]);return this.parseTrades(o,r,t,s)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.publicGetInfo(e),s=this.safeValue(t,"pairs",{}),i=Object.keys(s),r={};for(let e=0;e<i.length;e++){const t=i[e],n=this.safeValue(s,t,{}),o=this.safeSymbol(t,void 0,"_"),d=this.safeString(n,"fee_buyer"),h=this.safeString(n,"fee_seller"),c=this.parseNumber(a.O.stringDiv(d,"100")),l=this.parseNumber(a.O.stringDiv(h,"100"));r[o]={info:n,symbol:o,taker:c,maker:l,percentage:!0,tierBased:!1}}return r}async createOrder(e,t,s,i,a=undefined,n={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");await this.loadMarkets();const o=this.market(e),d={pair:o.id,type:s,amount:this.amountToPrecision(e,i),rate:this.priceToPrecision(e,a)},h=await this.privatePostTrade(this.extend(d,n)),c=this.safeValue(h,"return");return this.parseOrder(c,o)}async cancelOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostCancelOrder(this.extend(i,s)),a=this.safeValue(r,"return",{});return this.parseOrder(a)}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"open"},e,e)}parseOrder(e,t=undefined){let s=this.safeString2(e,"id","order_id"),i=this.parseOrderStatus(this.safeString(e,"status","open"));"0"===s&&(s=this.safeString(e,"init_order_id"),i="closed");const r=this.safeTimestamp2(e,"timestamp_created","server_time"),a=this.safeString(e,"pair"),n=this.safeSymbol(a,t),o=this.safeString(e,"start_amount"),d=this.safeString2(e,"amount","remains"),h=this.safeString(e,"received","0.0"),c=this.safeString(e,"rate"),l=this.safeString(e,"type");return this.safeOrder({info:e,id:s,clientOrderId:void 0,symbol:n,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:l,price:c,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:o,remaining:d,filled:h,status:i,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=undefined,s={}){await this.loadMarkets();const i={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(i,s));e=e.toString();const a=this.safeValue(r,"return",{});return this.parseOrder(this.extend({id:e},a[e]))}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a={};if(void 0!==e){const t=this.market(e);a.pair=t.id}const n=await this.privatePostActiveOrders(this.extend(a,i)),o=this.safeValue(n,"return",{});return this.parseOrders(o,undefined,t,s)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a `symbol` argument");await this.loadMarkets();const a=this.market(e),n={pair:a.id};void 0!==s&&(n.count=s),void 0!==t&&(n.since=this.parseToInt(t/1e3));const o=await this.privatePostTradeHistory(this.extend(n,i)),d=this.safeValue(o,"return",{}),h=Object.keys(d),c=[];for(let e=0;e<h.length;e++){const t=h[e],s=this.parseTrade(this.extend(d[t],{trade_id:t}),a);c.push(s)}return this.filterBySymbolSinceLimit(c,a.symbol,t,s)}async createDepositAddress(e,t={}){const s=await this.fetchDepositAddress(e,this.extend({need_new:1},t)),i=this.safeString(s,"address");return this.checkAddress(i),{currency:e,address:i,tag:void 0,info:s.info}}async fetchDepositAddress(e,t={}){await this.loadMarkets();let s=this.currency(e).id;const i=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(i,r,r),void 0!==r&&("ERC20"!==r&&(s+=r.toLowerCase()),t=this.omit(t,"network"));const a={coinName:s,need_new:0},n=await this.privatePostGetDepositAddress(this.extend(a,t)),o=this.safeString(n.return,"address");return this.checkAddress(o),{currency:e,address:o,tag:void 0,network:void 0,info:n}}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n={coinName:this.currency(e).id,amount:t,address:s};if(void 0!==i)throw new r.ExchangeError(this.id+" withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.");return{info:await this.privatePostWithdrawCoinsToAddress(this.extend(n,a)),id:void 0}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api[t];const d=this.omit(i,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const s=this.hmac(this.encode(a),this.encode(this.secret),o.o);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:s}}else"public"===t?(n+="/"+this.version+"/"+this.implodeParams(e,i),Object.keys(d).length&&(n+="?"+this.urlencode(d))):(n+="/"+this.implodeParams(e,i),"GET"===s?Object.keys(d).length&&(n+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o&&"success"in o){let e=this.safeValue(o,"success",!1);if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(o,"code"),t=this.safeString(o,"error"),s=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwExactlyMatchedException(this.exceptions.exact,t,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}}},5934:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(5224),r=s(6689),a=s(2194),n=s(9292),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"zaif",name:"Zaif",countries:["JP"],rateLimit:100,version:"1",has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766927-39ca2ada-5eeb-11e7-972f-1b4199518ca6.jpg",api:{rest:"https://api.zaif.jp"},www:"https://zaif.jp",doc:["https://techbureau-api-document.readthedocs.io/ja/latest/index.html","https://corp.zaif.jp/api-docs","https://corp.zaif.jp/api-docs/api_links","https://www.npmjs.com/package/zaif.jp","https://github.com/you21979/node-zaif"],fees:"https://zaif.jp/fee?lang=en"},fees:{trading:{percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0")}},api:{public:{get:{"depth/{pair}":1,"currencies/{pair}":1,"currencies/all":1,"currency_pairs/{pair}":1,"currency_pairs/all":1,"last_price/{pair}":1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{active_orders:5,cancel_order:5,deposit_history:5,get_id_info:5,get_info:10,get_info2:5,get_personal_info:5,trade:5,trade_history:50,withdraw:5,withdraw_history:5}},ecapi:{post:{createInvoice:1,getInvoice:1,getInvoiceIdsByOrderNumber:1,cancelInvoice:1}},tlapi:{post:{get_positions:66,position_history:66,active_positions:5,create_position:33,change_position:33,cancel_position:33}},fapi:{get:{"groups/{group_id}":1,"last_price/{group_id}/{pair}":1,"ticker/{group_id}/{pair}":1,"trades/{group_id}/{pair}":1,"depth/{group_id}/{pair}":1}}},options:{fees:{"BTC/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.001")},"BCH/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.003")},"BCH/BTC":{maker:this.parseNumber("0"),taker:this.parseNumber("0.003")},"PEPECASH/JPY":{maker:this.parseNumber("0"),taker:this.parseNumber("0.0001")},"PEPECASH/BT":{maker:this.parseNumber("0"),taker:this.parseNumber("0.0001")}}},precisionMode:n.sh,exceptions:{exact:{"unsupported currency_pair":r.BadRequest},broad:{}}})}async fetchMarkets(e={}){const t=await this.publicGetCurrencyPairsAll(e),s=[];for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"currency_pair"),a=this.safeString(i,"name"),[n,o]=a.split("/"),d=this.safeCurrencyCode(n),h=this.safeCurrencyCode(o),c=d+"/"+h,l=this.safeValue(this.options.fees,c,this.fees.trading);s.push({id:r,symbol:c,base:d,quote:h,settle:void 0,baseId:n,quoteId:o,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:l.taker,maker:l.maker,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(i,"item_unit_step"),price:this.parseNumber(this.parsePrecision(this.safeString(i,"aux_unit_point")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(i,"item_unit_min"),max:void 0},price:{min:this.safeNumber(i,"aux_unit_min"),max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i})}return s}parseBalance(e){const t=this.safeValue(e,"return",{}),s=this.safeValue(t,"deposit"),i={info:e,timestamp:void 0,datetime:void 0},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],n=this.safeCurrencyCode(t),o=this.safeString(r,t),d=this.account();d.free=o,d.total=o,void 0!==s&&t in s&&(d.total=this.safeString(s,t)),i[n]=d}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={pair:i.id},a=await this.publicGetDepthPair(this.extend(r,s));return this.parseOrderBook(a,i.symbol)}parseTicker(e,t=undefined){const s=this.safeSymbol(void 0,t),i=this.milliseconds(),r=this.safeString(e,"vwap"),n=this.safeString(e,"volume"),o=a.O.stringMul(n,r),d=this.safeString(e,"last");return this.safeTicker({symbol:s,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:r,open:void 0,close:d,last:d,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:n,quoteVolume:o,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={pair:s.id},r=await this.publicGetTickerPair(this.extend(i,t));return this.parseTicker(r,s)}parseTrade(e,t=undefined){let s=this.safeString(e,"trade_type");s="bid"===s?"buy":"sell";const i=this.safeTimestamp(e,"date"),r=this.safeString2(e,"id","tid"),a=this.safeString(e,"price"),n=this.safeString(e,"amount"),o=this.safeString(e,"currency_pair"),d=this.safeSymbol(o,t,"_");return this.safeTrade({id:r,info:e,timestamp:i,datetime:this.iso8601(i),symbol:d,type:void 0,side:s,order:void 0,takerOrMaker:void 0,price:a,amount:n,cost:void 0,fee:void 0},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};let n=await this.publicGetTradesPair(this.extend(a,i));if(1===n.length){const e=n[0];Object.keys(e).length||(n=[])}return this.parseTrades(n,r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){if(await this.loadMarkets(),"limit"!==t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const o=this.market(e),d={currency_pair:o.id,action:"buy"===s?"bid":"ask",amount:i,price:a},h=await this.privatePostTrade(this.extend(d,n));return this.safeOrder({info:h,id:h.return.order_id.toString()},o)}async cancelOrder(e,t=undefined,s={}){const i={order_id:e};return await this.privatePostCancelOrder(this.extend(i,s))}parseOrder(e,t=undefined){let s=this.safeString(e,"action");s="bid"===s?"buy":"sell";const i=this.safeTimestamp(e,"timestamp"),r=this.safeString(e,"currency_pair"),a=this.safeSymbol(r,t,"_"),n=this.safeString(e,"price"),o=this.safeString(e,"amount"),d=this.safeString(e,"id");return this.safeOrder({id:d,clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,status:"open",symbol:a,type:"limit",timeInForce:void 0,postOnly:void 0,side:s,price:n,stopPrice:void 0,triggerPrice:void 0,cost:void 0,amount:o,filled:void 0,remaining:void 0,trades:void 0,fee:void 0,info:e,average:void 0},t)}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const n=await this.privatePostActiveOrders(this.extend(a,i));return this.parseOrders(n.return,r,t,s)}async fetchClosedOrders(e=undefined,t=undefined,s=undefined,i={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const n=await this.privatePostTradeHistory(this.extend(a,i));return this.parseOrders(n.return,r,t,s)}async withdraw(e,t,s,i=undefined,a={}){[i,a]=this.handleWithdrawTagAndParams(i,a),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e);if("JPY"===e)throw new r.ExchangeError(this.id+" withdraw() does not allow "+e+" withdrawals");const o={currency:n.id,amount:t,address:s};void 0!==i&&(o.message=i);const d=await this.privatePostWithdraw(this.extend(o,a)),h=this.safeValue(d,"return");return this.parseTransaction(h,n)}parseTransaction(e,t=undefined){let s;t=this.safeCurrency(void 0,t);const i=this.safeValue(e,"fee");return void 0!==i&&(s={cost:i,currency:t.code}),{id:this.safeString(e,"id"),txid:this.safeString(e,"txid"),timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:s,info:e}}customNonce(){const e=(this.milliseconds()/1e3).toString();return parseFloat(e).toFixed(8)}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.urls.api.rest+"/";if("public"===t)n+="api/"+this.version+"/"+this.implodeParams(e,i);else if("fapi"===t)n+="fapi/"+this.version+"/"+this.implodeParams(e,i);else{this.checkRequiredCredentials(),n+="ecapi"===t?"ecapi":"tlapi"===t?"tlapi":"tapi";const s=this.customNonce();a=this.urlencode(this.extend({method:e,nonce:s},i)),r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:this.hmac(this.encode(a),this.encode(this.secret),o.o)}}return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0===o)return;const c=this.id+" "+n,l=this.safeString(o,"error");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c);if(!this.safeValue(o,"success",!0))throw new r.ExchangeError(c)}}},5140:(e,t,s)=>{s.d(t,{Z:()=>d});var i=s(3565),r=s(6689),a=s(9292),n=s(2194),o=s(7110);class d extends i.Z{describe(){return this.deepExtend(super.describe(),{id:"zonda",name:"Zonda",countries:["EE"],rateLimit:1e3,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDeposits:void 0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:void 0,fetchTransfer:!1,fetchWithdrawal:!1,fetchWithdrawals:void 0,reduceMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"60","3m":"180","5m":"300","15m":"900","30m":"1800","1h":"3600","2h":"7200","4h":"14400","6h":"21600","12h":"43200","1d":"86400","3d":"259200","1w":"604800"},hostname:"zonda.exchange",urls:{referral:"https://auth.zondaglobal.com/ref/jHlbB4mIkdS1",logo:"https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg",www:"https://zondaglobal.com",api:{public:"https://{hostname}/API/Public",private:"https://{hostname}/API/Trading/tradingApi.php",v1_01Public:"https://api.{hostname}/rest",v1_01Private:"https://api.{hostname}/rest"},doc:["https://docs.zonda.exchange/","https://github.com/BitBayNet/API"],support:"https://zondaglobal.com/en/helpdesk/zonda-exchange",fees:"https://zondaglobal.com/legal/zonda-exchange/fees"},api:{public:{get:["{id}/all","{id}/market","{id}/orderbook","{id}/ticker","{id}/trades"]},private:{post:["info","trade","cancel","orderbook","orders","transfer","withdraw","history","transactions"]},v1_01Public:{get:["trading/ticker","trading/ticker/{symbol}","trading/stats","trading/stats/{symbol}","trading/orderbook/{symbol}","trading/transactions/{symbol}","trading/candle/history/{symbol}/{resolution}"]},v1_01Private:{get:["api_payments/deposits/crypto/addresses","payments/withdrawal/{detailId}","payments/deposit/{detailId}","trading/offer","trading/stop/offer","trading/config/{symbol}","trading/history/transactions","balances/BITBAY/history","balances/BITBAY/balance","fiat_cantor/rate/{baseId}/{quoteId}","fiat_cantor/history"],post:["trading/offer/{symbol}","trading/stop/offer/{symbol}","trading/config/{symbol}","balances/BITBAY/balance","balances/BITBAY/balance/transfer/{source}/{destination}","fiat_cantor/exchange"],delete:["trading/offer/{symbol}/{id}/{side}/{price}","trading/stop/offer/{symbol}/{id}/{side}/{price}"],put:["balances/BITBAY/balance/{id}"]}},fees:{trading:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.001"),percentage:!0,tierBased:!1},fiat:{maker:this.parseNumber("0.0030"),taker:this.parseNumber("0.0043"),percentage:!0,tierBased:!0,tiers:{taker:[[this.parseNumber("0.0043"),this.parseNumber("0")],[this.parseNumber("0.0042"),this.parseNumber("1250")],[this.parseNumber("0.0041"),this.parseNumber("3750")],[this.parseNumber("0.0040"),this.parseNumber("7500")],[this.parseNumber("0.0039"),this.parseNumber("10000")],[this.parseNumber("0.0038"),this.parseNumber("15000")],[this.parseNumber("0.0037"),this.parseNumber("20000")],[this.parseNumber("0.0036"),this.parseNumber("25000")],[this.parseNumber("0.0035"),this.parseNumber("37500")],[this.parseNumber("0.0034"),this.parseNumber("50000")],[this.parseNumber("0.0033"),this.parseNumber("75000")],[this.parseNumber("0.0032"),this.parseNumber("100000")],[this.parseNumber("0.0031"),this.parseNumber("150000")],[this.parseNumber("0.0030"),this.parseNumber("200000")],[this.parseNumber("0.0029"),this.parseNumber("250000")],[this.parseNumber("0.0028"),this.parseNumber("375000")],[this.parseNumber("0.0027"),this.parseNumber("500000")],[this.parseNumber("0.0026"),this.parseNumber("625000")],[this.parseNumber("0.0025"),this.parseNumber("875000")]],maker:[[this.parseNumber("0.0030"),this.parseNumber("0")],[this.parseNumber("0.0029"),this.parseNumber("1250")],[this.parseNumber("0.0028"),this.parseNumber("3750")],[this.parseNumber("0.0028"),this.parseNumber("7500")],[this.parseNumber("0.0027"),this.parseNumber("10000")],[this.parseNumber("0.0026"),this.parseNumber("15000")],[this.parseNumber("0.0025"),this.parseNumber("20000")],[this.parseNumber("0.0025"),this.parseNumber("25000")],[this.parseNumber("0.0024"),this.parseNumber("37500")],[this.parseNumber("0.0023"),this.parseNumber("50000")],[this.parseNumber("0.0023"),this.parseNumber("75000")],[this.parseNumber("0.0022"),this.parseNumber("100000")],[this.parseNumber("0.0021"),this.parseNumber("150000")],[this.parseNumber("0.0021"),this.parseNumber("200000")],[this.parseNumber("0.0020"),this.parseNumber("250000")],[this.parseNumber("0.0019"),this.parseNumber("375000")],[this.parseNumber("0.0018"),this.parseNumber("500000")],[this.parseNumber("0.0018"),this.parseNumber("625000")],[this.parseNumber("0.0017"),this.parseNumber("875000")]]}},funding:{withdraw:{}}},options:{fetchTickerMethod:"v1_01PublicGetTradingTickerSymbol",fetchTickersMethod:"v1_01PublicGetTradingTicker",fiatCurrencies:["EUR","USD","GBP","PLN"],transfer:{fillResponseFromRequest:!0}},precisionMode:a.sh,exceptions:{400:r.ExchangeError,401:r.InvalidOrder,402:r.InvalidOrder,403:r.InvalidOrder,404:r.InvalidOrder,405:r.InvalidOrder,406:r.InsufficientFunds,408:r.InvalidOrder,501:r.AuthenticationError,502:r.AuthenticationError,503:r.InvalidNonce,504:r.ExchangeError,505:r.AuthenticationError,506:r.AccountSuspended,509:r.ExchangeError,510:r.BadSymbol,FUNDS_NOT_SUFFICIENT:r.InsufficientFunds,OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS:r.InvalidOrder,OFFER_NOT_FOUND:r.OrderNotFound,OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED:r.OrderImmediatelyFillable,ACTION_LIMIT_EXCEEDED:r.RateLimitExceeded,UNDER_MAINTENANCE:r.OnMaintenance,REQUEST_TIMESTAMP_TOO_OLD:r.InvalidNonce,PERMISSIONS_NOT_SUFFICIENT:r.PermissionDenied,INVALID_STOP_RATE:r.InvalidOrder},commonCurrencies:{GGC:"Global Game Coin"}})}async fetchMarkets(e={}){const t=await this.v1_01PublicGetTradingTicker(e),s=this.safeValue(this.options,"fiatCurrencies",[]),i=[],r=this.safeValue(t,"items",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],n=r[t],o=this.safeValue(n,"market",{}),d=this.safeValue(o,"first",{}),h=this.safeValue(o,"second",{}),c=this.safeString(d,"currency"),l=this.safeString(h,"currency"),u=this.safeCurrencyCode(c),f=this.safeCurrencyCode(l);let p=this.safeValue(this.fees,"trading",{});(this.inArray(u,s)||this.inArray(f,s))&&(p=this.safeValue(this.fees,"fiat",{})),i.push({id:t,symbol:u+"/"+f,base:u,quote:f,settle:void 0,baseId:c,quoteId:l,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(p,"taker"),maker:this.safeNumber(p,"maker"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,optionType:void 0,strike:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(d,"scale"))),price:this.parseNumber(this.parsePrecision(this.safeString(h,"scale")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(d,"minOffer"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(h,"minOffer"),max:void 0}},created:void 0,info:n})}return i}async fetchOpenOrders(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=await this.v1_01PrivateGetTradingOffer(this.extend({},i)),a=this.safeValue(r,"items",[]);return this.parseOrders(a,void 0,t,s,{status:"open"})}parseOrder(e,t=undefined){const s=this.safeString(e,"market"),i=this.safeSymbol(s,t,"-"),r=this.safeInteger(e,"time"),a=this.safeString(e,"startAmount"),n=this.safeString(e,"currentAmount"),o=this.safeValue(e,"postOnly");return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:void 0,info:e,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,status:void 0,symbol:i,type:this.safeString(e,"mode"),timeInForce:void 0,postOnly:o,side:this.safeStringLower(e,"offerType"),price:this.safeString(e,"rate"),stopPrice:void 0,triggerPrice:void 0,amount:a,cost:void 0,filled:void 0,remaining:n,average:void 0,fee:void 0,trades:void 0},t)}async fetchMyTrades(e=undefined,t=undefined,s=undefined,i={}){await this.loadMarkets();const r={};if(e){const t=[this.marketId(e)];e=this.symbol(e),r.markets=t}const a={query:this.json(this.extend(r,i))},n=await this.v1_01PrivateGetTradingHistoryTransactions(a),o=this.safeValue(n,"items"),d=this.parseTrades(o,void 0,t,s);return void 0===e?d:this.filterBySymbol(d,e)}parseBalance(e){const t=this.safeValue(e,"balances");if(void 0===t)throw new r.ExchangeError(this.id+" empty balance response "+this.json(e));const s={info:e};for(let e=0;e<t.length;e++){const i=t[e],r=this.safeString(i,"currency"),a=this.safeCurrencyCode(r),n=this.account();n.used=this.safeString(i,"lockedFunds"),n.free=this.safeString(i,"availableFunds"),s[a]=n}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1_01PrivateGetBalancesBITBAYBalance(e);return this.parseBalance(t)}async fetchOrderBook(e,t=undefined,s={}){await this.loadMarkets();const i=this.market(e),r={symbol:i.id},a=await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(r,s)),n=this.safeValue(a,"buy",[]),o=this.safeValue(a,"sell",[]),d=this.safeInteger(a,"timestamp");return{symbol:i.symbol,bids:this.parseBidsAsks(n,"ra","ca"),asks:this.parseBidsAsks(o,"ra","ca"),timestamp:d,datetime:this.iso8601(d),nonce:this.safeInteger(a,"seqNo")}}parseTicker(e,t=undefined){const s=this.safeValue(e,"market"),i=this.safeString2(s,"code","m");t=this.safeMarket(i,t);const r=this.safeInteger(e,"time"),a=this.safeValue(e,"rate");return this.safeTicker({symbol:this.safeSymbol(i,t),timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"h"),low:this.safeString(e,"l"),bid:this.safeNumber(e,"highestBid"),bidVolume:void 0,ask:this.safeNumber(e,"lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"r24h"),close:a,last:a,previousClose:this.safeValue(e,"previousRate"),change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"v"),quoteVolume:void 0,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const s=this.market(e),i={symbol:s.id},a="v1_01PublicGetTradingTickerSymbol",n=this.safeString(this.options,"fetchTickerMethod",a),o=this.safeString2(t,"method","fetchTickerMethod",n);let d;if(o===a)d=await this.v1_01PublicGetTradingTickerSymbol(this.extend(i,t));else{if("v1_01PublicGetTradingStatsSymbol"!==o)throw new r.BadRequest(this.id+' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');d=await this.v1_01PublicGetTradingStatsSymbol(this.extend(i,t))}const h=this.safeValue2(d,"ticker","stats");return this.parseTicker(h,s)}async fetchTickers(e=undefined,t={}){await this.loadMarkets();const s="v1_01PublicGetTradingTicker",i=this.safeString(this.options,"fetchTickersMethod",s),a=this.safeString2(t,"method","fetchTickersMethod",i);let n;if(a===s)n=await this.v1_01PublicGetTradingTicker(t);else{if("v1_01PublicGetTradingStats"!==a)throw new r.BadRequest(this.id+' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');n=await this.v1_01PublicGetTradingStats(t)}const o=this.safeValue(n,"items");return this.parseTickers(o,e)}async fetchLedger(e=undefined,t=undefined,s=undefined,i={}){const r=[];if(void 0!==e){const t=this.currency(e);r.push(t.id)}let a={balanceCurrencies:r};void 0!==t&&(a.fromTime=t),void 0!==s&&(a.limit=s),a=this.extend(a,i);const n=(await this.v1_01PrivateGetBalancesBITBAYHistory({query:this.json(a)})).items;return this.parseLedger(n,void 0,t,s)}parseLedgerEntry(e,t=undefined){const s=this.safeInteger(e,"time"),i=this.safeValue(e,"balance",{}),r=this.safeString(i,"currency"),a=this.safeValue(e,"change",{});let o=this.safeString(a,"total"),d="in";n.O.stringLt(o,"0")&&(d="out",o=n.O.stringNeg(o));const h=this.safeValue(e,"fundsBefore",{}),c=this.safeValue(e,"fundsAfter",{});return{info:e,id:this.safeString(e,"historyId"),direction:d,account:void 0,referenceId:this.safeString(e,"detailId"),referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(r),amount:this.parseNumber(o),before:this.safeNumber(h,"total"),after:this.safeNumber(c,"total"),status:"ok",timestamp:s,datetime:this.iso8601(s),fee:void 0}}parseLedgerEntryType(e){return this.safeString({ADD_FUNDS:"transaction",BITCOIN_GOLD_FORK:"transaction",CREATE_BALANCE:"transaction",FUNDS_MIGRATION:"transaction",WITHDRAWAL_LOCK_FUNDS:"transaction",WITHDRAWAL_SUBTRACT_FUNDS:"transaction",WITHDRAWAL_UNLOCK_FUNDS:"transaction",TRANSACTION_COMMISSION_OUTCOME:"fee",TRANSACTION_COMMISSION_RETURN:"fee",TRANSACTION_OFFER_ABORTED_RETURN:"trade",TRANSACTION_OFFER_COMPLETED_RETURN:"trade",TRANSACTION_POST_INCOME:"trade",TRANSACTION_POST_OUTCOME:"trade",TRANSACTION_PRE_LOCKING:"trade"},e,e)}parseOHLCV(e,t=undefined){const s=this.safeValue(e,1,{});return[this.safeInteger(e,0),this.safeNumber(s,"o"),this.safeNumber(s,"h"),this.safeNumber(s,"l"),this.safeNumber(s,"c"),this.safeNumber(s,"v")]}async fetchOHLCV(e,t="1m",s=undefined,i=undefined,r={}){await this.loadMarkets();const a=this.market(e),n={symbol:a.baseId+"-"+a.quoteId,resolution:this.safeString(this.timeframes,t,t)};void 0===i&&(i=100);const o=i*this.parseTimeframe(t)*1e3;void 0===s?(n.to=this.milliseconds(),n.from=n.to-o):(n.from=s,n.to=this.sum(n.from,o));const d=await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(n,r)),h=this.safeValue(d,"items",[]);return this.parseOHLCVs(h,a,t,s,i)}parseTrade(e,t=undefined){const s=this.safeInteger2(e,"time","t"),i=this.safeStringLower2(e,"userAction","ty"),r=this.safeValue(e,"wasTaker");let a;void 0!==r&&(a=r?"taker":"maker");const n=this.safeString2(e,"rate","r"),o=this.safeString2(e,"amount","a"),d=this.safeString(e,"commissionValue"),h=this.safeString(e,"market"),c=(t=this.safeMarket(h,t,"-")).symbol;let l;if(void 0!==d){l={currency:"buy"===i?t.base:t.quote,cost:d}}const u=this.safeString(e,"offerId");let f;return void 0!==u&&(f=u?"limit":"market"),this.safeTrade({id:this.safeString(e,"id"),order:u,timestamp:s,datetime:this.iso8601(s),symbol:c,type:f,side:i,price:n,amount:o,cost:void 0,takerOrMaker:a,fee:l,info:e},t)}async fetchTrades(e,t=undefined,s=undefined,i={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.baseId+"-"+r.quoteId};void 0!==t&&(a.fromTime=t-1),void 0!==s&&(a.limit=s);const n=await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(a,i)),o=this.safeValue(n,"items");return this.parseTrades(o,r,t,s)}async createOrder(e,t,s,i,a=undefined,n={}){await this.loadMarkets();const o=this.market(e),d=o.baseId+"-"+o.quoteId;i=parseFloat(this.amountToPrecision(e,i));const h={symbol:d,offerType:s.toUpperCase(),amount:i},c=this.safeValue2(n,"stopPrice","stopLossPrice"),l=void 0!==c,u="limit"===t,f="market"===t,p="stop-limit"===t||u&&l,m="stop-market"===t||f&&l,g=p||m,y=g?"v1_01PrivatePostTradingStopOfferSymbol":"v1_01PrivatePostTradingOfferSymbol";if(u||p)h.rate=this.priceToPrecision(e,a),h.mode=p?"stop-limit":"limit";else{if(!f&&!m)throw new r.ExchangeError(this.id+" createOrder() invalid type");h.mode=m?"stop-market":"market"}if(g){if(!l)throw new r.ExchangeError(this.id+" createOrder() zonda requires `triggerPrice` or `stopPrice` parameter for stop-limit or stop-market orders");h.stopRate=this.priceToPrecision(e,c)}n=this.omit(n,["stopPrice","stopLossPrice"]);const v=await this[y](this.extend(h,n)),b=this.safeString2(v,"offerId","stopOfferId"),w=this.safeValue(v,"completed",!1)?"closed":"open",S=this.safeValue(v,"transactions");return this.safeOrder({id:b,info:v,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,status:w,symbol:e,type:t,side:s,price:a,amount:i,cost:void 0,filled:void 0,remaining:void 0,average:void 0,fee:void 0,trades:S,clientOrderId:void 0})}async cancelOrder(e,t=undefined,s={}){const i=this.safeString(s,"side");if(void 0===i)throw new r.ExchangeError(this.id+' cancelOrder() requires a `side` parameter ("buy" or "sell")');const a=this.safeValue(s,"price");if(void 0===a)throw new r.ExchangeError(this.id+" cancelOrder() requires a `price` parameter (float or string)");await this.loadMarkets();const n=this.market(t),o={symbol:n.baseId+"-"+n.quoteId,id:e,side:i,price:a};return await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(o,s))}isFiat(e){return this.safeValue({USD:!0,EUR:!0,PLN:!0},e,!1)}parseDepositAddress(e,t=undefined){const s=this.safeString(e,"currency"),i=this.safeString(e,"address");return this.checkAddress(i),{currency:this.safeCurrencyCode(s,t),address:i,tag:this.safeString(e,"tag"),network:void 0,info:e}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const s=this.currency(e),i={currency:s.id},r=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(i,t)),a=this.safeValue(r,"data"),n=this.safeValue(a,0);return this.parseDepositAddress(n,s)}async fetchDepositAddresses(e=undefined,t={}){await this.loadMarkets();const s=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(t),i=this.safeValue(s,"data");return this.parseDepositAddresses(i,e)}async transfer(e,t,s,i,r={}){await this.loadMarkets();const a=this.currency(e),n={source:s,destination:i,currency:e,funds:this.currencyToPrecision(e,t)},o=await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(n,r)),d=this.parseTransfer(o,a),h=this.safeValue(this.options,"transfer",{});return this.safeValue(h,"fillResponseFromRequest",!0)&&(d.amount=t),d}parseTransfer(e,t=undefined){const s=this.safeString(e,"status"),i=this.safeValue(e,"from",{}),r=this.safeString(i,"id"),a=this.safeValue(e,"to",{}),n=this.safeString(a,"id"),o=this.safeString(i,"currency");return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(o,t),amount:void 0,fromAccount:r,toAccount:n,status:this.parseTransferStatus(s)}}parseTransferStatus(e){return this.safeString({Ok:"ok",Fail:"failed"},e,e)}async withdraw(e,t,s,i=undefined,r={}){let a;[i,r]=this.handleWithdrawTagAndParams(i,r),this.checkAddress(s),await this.loadMarkets();const n=this.currency(e),o={currency:n.id,quantity:t};this.isFiat(e)?a="privatePostWithdraw":(a="privatePostTransfer",void 0!==i&&(s+="?dt="+i.toString()),o.address=s);const d=await this[a](this.extend(o,r)),h=this.safeValue(d,"data");return this.parseTransaction(h,n)}parseTransaction(e,t=undefined){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,fee:void 0,info:e}}sign(e,t="public",s="GET",i={},r=undefined,a=undefined){let n=this.implodeHostname(this.urls.api[t]);if("public"===t){const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i)+".json",Object.keys(t).length&&(n+="?"+this.urlencode(t))}else if("v1_01Public"===t){const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i),Object.keys(t).length&&(n+="?"+this.urlencode(t))}else if("v1_01Private"===t){this.checkRequiredCredentials();const t=this.omit(i,this.extractParams(e));n+="/"+this.implodeParams(e,i);const d=this.milliseconds().toString();let h;"POST"!==s?(Object.keys(t).length&&(n+="?"+this.urlencode(t)),h=this.apiKey+d):void 0===a&&(a=this.json(t),h=this.apiKey+d+a),r={"Request-Timestamp":d,"Operation-Id":this.uuid(),"API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(h),this.encode(this.secret),o.o),"Content-Type":"application/json"}}else this.checkRequiredCredentials(),a=this.urlencode(this.extend({method:e,moment:this.nonce()},i)),r={"Content-Type":"application/x-www-form-urlencoded","API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(a),this.encode(this.secret),o.o)};return{url:n,method:s,body:a,headers:r}}handleErrors(e,t,s,i,a,n,o,d,h){if(void 0!==o){if("code"in o){const e=this.safeString(o,"code"),t=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions,e,t),new r.ExchangeError(t)}if("status"in o){if("Fail"===this.safeString(o,"status")){const e=this.safeValue(o,"errors"),t=this.id+" "+n;for(let s=0;s<e.length;s++){const i=e[s];this.throwExactlyMatchedException(this.exceptions,i,t)}throw new r.ExchangeError(t)}}}}}},7026:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},3183:e=>{var t=String.prototype.replace,s=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return t.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},3165:(e,t,s)=>{var i=s(6463),r=s(163),a=s(3183);e.exports={formats:a,parse:r,stringify:i}},163:(e,t,s)=>{var i=s(8584),r=Object.prototype.hasOwnProperty,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},n=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},o=function(e,t,s){if(e){var i=s.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,n=/(\[[^[\]]*])/.exec(i),o=n?i.slice(0,n.index):i,d=[];if(o){if(!s.plainObjects&&r.call(Object.prototype,o)&&!s.allowPrototypes)return;d.push(o)}for(var h=0;null!==(n=a.exec(i))&&h<s.depth;){if(h+=1,!s.plainObjects&&r.call(Object.prototype,n[1].slice(1,-1))&&!s.allowPrototypes)return;d.push(n[1])}return n&&d.push("["+i.slice(n.index)+"]"),function(e,t,s){for(var i=t,r=e.length-1;r>=0;--r){var a,n=e[r];if("[]"===n&&s.parseArrays)a=[].concat(i);else{a=s.plainObjects?Object.create(null):{};var o="["===n.charAt(0)&&"]"===n.charAt(n.length-1)?n.slice(1,-1):n,d=parseInt(o,10);s.parseArrays||""!==o?!isNaN(d)&&n!==o&&String(d)===o&&d>=0&&s.parseArrays&&d<=s.arrayLimit?(a=[])[d]=i:a[o]=i:a={0:i}}i=a}return i}(d,t,s)}};e.exports=function(e,t){var s=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||i.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth?e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return s.plainObjects?Object.create(null):{};for(var d="string"==typeof e?function(e,t){var s,o={},d=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,h=t.parameterLimit===1/0?void 0:t.parameterLimit,c=d.split(t.delimiter,h),l=-1,u=t.charset;if(t.charsetSentinel)for(s=0;s<c.length;++s)0===c[s].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[s]?u="utf-8":"utf8=%26%2310003%3B"===c[s]&&(u="iso-8859-1"),l=s,s=c.length);for(s=0;s<c.length;++s)if(s!==l){var f,p,m=c[s],g=m.indexOf("]="),y=-1===g?m.indexOf("="):g+1;-1===y?(f=t.decoder(m,a.decoder,u),p=t.strictNullHandling?null:""):(f=t.decoder(m.slice(0,y),a.decoder,u),p=t.decoder(m.slice(y+1),a.decoder,u)),p&&t.interpretNumericEntities&&"iso-8859-1"===u&&(p=n(p)),p&&t.comma&&p.indexOf(",")>-1&&(p=p.split(",")),r.call(o,f)?o[f]=i.combine(o[f],p):o[f]=p}return o}(e,s):e,h=s.plainObjects?Object.create(null):{},c=Object.keys(d),l=0;l<c.length;++l){var u=c[l],f=o(u,d[u],s);h=i.merge(h,f,s)}return i.compact(h)}},6463:(e,t,s)=>{var i=s(8584),r=s(3183),a=Object.prototype.hasOwnProperty,n={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},o=Array.isArray,d=Array.prototype.push,h=function(e,t){d.apply(e,o(t)?t:[t])},c=Date.prototype.toISOString,l={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,formatter:r.formatters[r.default],indices:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},u=function e(t,s,r,a,n,d,c,u,f,p,m,g,y){var v=t;if("function"==typeof c?v=c(s,v):v instanceof Date?v=p(v):"comma"===r&&o(v)&&(v=v.join(",")),null===v){if(a)return d&&!g?d(s,l.encoder,y):s;v=""}if("string"==typeof v||"number"==typeof v||"boolean"==typeof v||i.isBuffer(v))return d?[m(g?s:d(s,l.encoder,y))+"="+m(d(v,l.encoder,y))]:[m(s)+"="+m(String(v))];var b,w=[];if(void 0===v)return w;if(o(c))b=c;else{var S=Object.keys(v);b=u?S.sort(u):S}for(var k=0;k<b.length;++k){var O=b[k];n&&null===v[O]||(o(v)?h(w,e(v[O],"function"==typeof r?r(s,O):s,r,a,n,d,c,u,f,p,m,g,y)):h(w,e(v[O],s+(f?"."+O:"["+O+"]"),r,a,n,d,c,u,f,p,m,g,y)))}return w};e.exports=function(e,t){var s,i=e,d=function(e){if(!e)return l;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||l.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var s=r.default;if(void 0!==e.format){if(!a.call(r.formatters,e.format))throw new TypeError("Unknown format option provided.");s=e.format}var i=r.formatters[s],n=l.filter;return("function"==typeof e.filter||o(e.filter))&&(n=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:l.addQueryPrefix,allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,delimiter:void 0===e.delimiter?l.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:l.encode,encoder:"function"==typeof e.encoder?e.encoder:l.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:l.encodeValuesOnly,filter:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:l.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:l.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling}}(t);"function"==typeof d.filter?i=(0,d.filter)("",i):o(d.filter)&&(s=d.filter);var c,f=[];if("object"!=typeof i||null===i)return"";c=t&&t.arrayFormat in n?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=n[c];s||(s=Object.keys(i)),d.sort&&s.sort(d.sort);for(var m=0;m<s.length;++m){var g=s[m];d.skipNulls&&null===i[g]||h(f,u(i[g],g,p,d.strictNullHandling,d.skipNulls,d.encode?d.encoder:null,d.filter,d.sort,d.allowDots,d.serializeDate,d.formatter,d.encodeValuesOnly,d.charset))}var y=f.join(d.delimiter),v=!0===d.addQueryPrefix?"?":"";return d.charsetSentinel&&("iso-8859-1"===d.charset?v+="utf8=%26%2310003%3B&":v+="utf8=%E2%9C%93&"),y.length>0?v+y:""}},8584:e=>{var t=Object.prototype.hasOwnProperty,s=Array.isArray,i=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),r=function(e,t){for(var s=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)void 0!==e[i]&&(s[i]=e[i]);return s};e.exports={arrayToObject:r,assign:function(e,t){return Object.keys(t).reduce((function(e,s){return e[s]=t[s],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],i=[],r=0;r<t.length;++r)for(var a=t[r],n=a.obj[a.prop],o=Object.keys(n),d=0;d<o.length;++d){var h=o[d],c=n[h];"object"==typeof c&&null!==c&&-1===i.indexOf(c)&&(t.push({obj:n,prop:h}),i.push(c))}return function(e){for(;e.length>1;){var t=e.pop(),i=t.obj[t.prop];if(s(i)){for(var r=[],a=0;a<i.length;++a)void 0!==i[a]&&r.push(i[a]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,s){var i=e.replace(/\+/g," ");if("iso-8859-1"===s)return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch(e){return i}},encode:function(e,t,s){if(0===e.length)return e;var r="string"==typeof e?e:String(e);if("iso-8859-1"===s)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var a="",n=0;n<r.length;++n){var o=r.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122?a+=r.charAt(n):o<128?a+=i[o]:o<2048?a+=i[192|o>>6]+i[128|63&o]:o<55296||o>=57344?a+=i[224|o>>12]+i[128|o>>6&63]+i[128|63&o]:(n+=1,o=65536+((1023&o)<<10|1023&r.charCodeAt(n)),a+=i[240|o>>18]+i[128|o>>12&63]+i[128|o>>6&63]+i[128|63&o])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(i,a,n){if(!a)return i;if("object"!=typeof a){if(s(i))i.push(a);else{if(!i||"object"!=typeof i)return[i,a];(n&&(n.plainObjects||n.allowPrototypes)||!t.call(Object.prototype,a))&&(i[a]=!0)}return i}if(!i||"object"!=typeof i)return[i].concat(a);var o=i;return s(i)&&!s(a)&&(o=r(i,n)),s(i)&&s(a)?(a.forEach((function(s,r){if(t.call(i,r)){var a=i[r];a&&"object"==typeof a&&s&&"object"==typeof s?i[r]=e(a,s,n):i.push(s)}else i[r]=s})),i):Object.keys(a).reduce((function(s,i){var r=a[i];return t.call(s,i)?s[i]=e(s[i],r,n):s[i]=r,s}),o)}}},7348:(e,t,s)=>{s.d(t,{_Z:()=>V,n:()=>N});var i=Uint8Array,r=Uint16Array,a=Uint32Array,n=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),d=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var s=new r(31),i=0;i<31;++i)s[i]=t+=1<<e[i-1];var n=new a(s[30]);for(i=1;i<30;++i)for(var o=s[i];o<s[i+1];++o)n[o]=o-s[i]<<5|i;return[s,n]},c=h(n,2),l=c[0],u=c[1];l[28]=258,u[258]=28;for(var f=h(o,0),p=f[0],m=(f[1],new r(32768)),g=0;g<32768;++g){var y=(43690&g)>>>1|(21845&g)<<1;y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4,m[g]=((65280&y)>>>8|(255&y)<<8)>>>1}var v=function(e,t,s){for(var i=e.length,a=0,n=new r(t);a<i;++a)e[a]&&++n[e[a]-1];var o,d=new r(t);for(a=0;a<t;++a)d[a]=d[a-1]+n[a-1]<<1;if(s){o=new r(1<<t);var h=15-t;for(a=0;a<i;++a)if(e[a])for(var c=a<<4|e[a],l=t-e[a],u=d[e[a]-1]++<<l,f=u|(1<<l)-1;u<=f;++u)o[m[u]>>>h]=c}else for(o=new r(i),a=0;a<i;++a)e[a]&&(o[a]=m[d[e[a]-1]++]>>>15-e[a]);return o},b=new i(288);for(g=0;g<144;++g)b[g]=8;for(g=144;g<256;++g)b[g]=9;for(g=256;g<280;++g)b[g]=7;for(g=280;g<288;++g)b[g]=8;var w=new i(32);for(g=0;g<32;++g)w[g]=5;var S=v(b,9,1),k=v(w,5,1),O=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},T=function(e,t,s){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&s},I=function(e,t){var s=t/8|0;return(e[s]|e[s+1]<<8|e[s+2]<<16)>>(7&t)},x=function(e){return(e+7)/8|0},P=function(e,t,s){(null==t||t<0)&&(t=0),(null==s||s>e.length)&&(s=e.length);var n=new(2==e.BYTES_PER_ELEMENT?r:4==e.BYTES_PER_ELEMENT?a:i)(s-t);return n.set(e.subarray(t,s)),n},M=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(e,t,s){var i=new Error(t||M[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,A),!s)throw i;return i},C=function(e,t,s){var r=e.length;if(!r||s&&s.f&&!s.l)return t||new i(0);var a=!t||s,h=!s||s.i;s||(s={}),t||(t=new i(3*r));var c=function(e){var s=t.length;if(e>s){var r=new i(Math.max(2*s,e));r.set(t),t=r}},u=s.f||0,f=s.p||0,m=s.b||0,g=s.l,y=s.d,b=s.m,w=s.n,M=8*r;do{if(!g){u=T(e,f,1);var C=T(e,f+1,3);if(f+=3,!C){var E=e[(H=x(f)+4)-4]|e[H-3]<<8,_=H+E;if(_>r){h&&A(0);break}a&&c(m+E),t.set(e.subarray(H,_),m),s.b=m+=E,s.p=f=8*_,s.f=u;continue}if(1==C)g=S,y=k,b=9,w=5;else if(2==C){var B=T(e,f,31)+257,N=T(e,f+10,15)+4,V=B+T(e,f+5,31)+1;f+=14;for(var R=new i(V),L=new i(19),D=0;D<N;++D)L[d[D]]=T(e,f+3*D,7);f+=3*N;var q=O(L),F=(1<<q)-1,G=v(L,q,1);for(D=0;D<V;){var H,U=G[T(e,f,F)];if(f+=15&U,(H=U>>>4)<16)R[D++]=H;else{var W=0,j=0;for(16==H?(j=3+T(e,f,3),f+=2,W=R[D-1]):17==H?(j=3+T(e,f,7),f+=3):18==H&&(j=11+T(e,f,127),f+=7);j--;)R[D++]=W}}var K=R.subarray(0,B),Z=R.subarray(B);b=O(K),w=O(Z),g=v(K,b,1),y=v(Z,w,1)}else A(1);if(f>M){h&&A(0);break}}a&&c(m+131072);for(var z=(1<<b)-1,X=(1<<w)-1,Q=f;;Q=f){var Y=(W=g[I(e,f)&z])>>>4;if((f+=15&W)>M){h&&A(0);break}if(W||A(2),Y<256)t[m++]=Y;else{if(256==Y){Q=f,g=null;break}var J=Y-254;if(Y>264){var $=n[D=Y-257];J=T(e,f,(1<<$)-1)+l[D],f+=$}var ee=y[I(e,f)&X],te=ee>>>4;ee||A(3),f+=15ⅇZ=p[te];if(te>3){$=o[te];Z+=I(e,f)&(1<<$)-1,f+=$}if(f>M){h&&A(0);break}a&&c(m+131072);for(var se=m+J;m<se;m+=4)t[m]=t[m-Z],t[m+1]=t[m+1-Z],t[m+2]=t[m+2-Z],t[m+3]=t[m+3-Z];m=se}}s.l=g,s.p=Q,s.b=m,s.f=u,g&&(u=1,s.m=b,s.d=y,s.n=w)}while(!u);return m==t.length?t:P(t,0,m)},E=new i(0),_=function(e){31==e[0]&&139==e[1]&&8==e[2]||A(6,"invalid gzip data");var t=e[3],s=10;4&t&&(s+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[s++]);return s+(2&t)},B=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0};function N(e,t=undefined){return C(e,t)}function V(e,t=undefined){return C(e.subarray(_(e),-8),t||new i(B(e)))}var R="undefined"!=typeof TextDecoder&&new TextDecoder;try{R.decode(E,{stream:!0}),1}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6294:(e,t,s)=>{s.d(t,{f:()=>a});var i=s(2833),r=s(1532),a={};void 0!==a.asn1&&a.asn1||(a.asn1={}),a.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var s=t.substr(1).length;s%2==1?s+=1:t.match(/^[0-7]/)||(s+=2);for(var r="",a=0;a<s;a++)r+="f";t=new i.Jh(r,16).xor(e).add(i.Jh.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return hextopem(e,t)},this.newObject=function(e){var t=a.asn1,s=t.DERBoolean,i=t.DERInteger,r=t.DERBitString,n=t.DEROctetString,o=t.DERNull,d=t.DERObjectIdentifier,h=t.DEREnumerated,c=t.DERUTF8String,l=t.DERNumericString,u=t.DERPrintableString,f=t.DERTeletexString,p=t.DERIA5String,m=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERSequence,v=t.DERSet,b=t.DERTaggedObject,w=t.ASN1Util.newObject,S=Object.keys(e);if(1!=S.length)throw"key of param shall be only one.";var k=S[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+k+":"))throw"undefined key: "+k;if("bool"==k)return new s(e[k]);if("int"==k)return new i(e[k]);if("bitstr"==k)return new r(e[k]);if("octstr"==k)return new n(e[k]);if("null"==k)return new o(e[k]);if("oid"==k)return new d(e[k]);if("enum"==k)return new h(e[k]);if("utf8str"==k)return new c(e[k]);if("numstr"==k)return new l(e[k]);if("prnstr"==k)return new u(e[k]);if("telstr"==k)return new f(e[k]);if("ia5str"==k)return new p(e[k]);if("utctime"==k)return new m(e[k]);if("gentime"==k)return new g(e[k]);if("seq"==k){for(var O=e[k],T=[],I=0;I<O.length;I++){var x=w(O[I]);T.push(x)}return new y({array:T})}if("set"==k){for(O=e[k],T=[],I=0;I<O.length;I++){x=w(O[I]);T.push(x)}return new v({array:T})}if("tag"==k){var P=e[k];if("[object Array]"===Object.prototype.toString.call(P)&&3==P.length){var M=w(P[2]);return new b({tag:P[0],explicit:P[1],obj:M})}var A={};if(void 0!==P.explicit&&(A.explicit=P.explicit),void 0!==P.tag&&(A.tag=P.tag),void 0===P.obj)throw"obj shall be specified for 'tag'.";return A.obj=w(P.obj),new b(A)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},a.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",s=parseInt(e.substr(0,2),16),r=(t=Math.floor(s/40)+"."+s%40,""),a=2;a<e.length;a+=2){var n=("00000000"+parseInt(e.substr(a,2),16).toString(2)).slice(-8);if(r+=n.substr(1,7),"0"==n.substr(0,1))t=t+"."+new i.Jh(r,2).toString(10),r=""}return t},a.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},s=function(e){var s="",r=new i.Jh(e,10).toString(2),a=7-r.length%7;7==a&&(a=0);for(var n="",o=0;o<a;o++)n+="0";r=n+r;for(o=0;o<r.length-1;o+=7){var d=r.substr(o,7);o!=r.length-7&&(d="1"+d),s+=t(parseInt(d,2))}return s};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",a=e.split("."),n=40*parseInt(a[0])+parseInt(a[1]);r+=t(n),a.splice(0,2);for(var o=0;o<a.length;o++)r+=s(a[o]);return r},a.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var s=t.length/2;if(s>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+s).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},a.asn1.DERAbstractString=function(e){a.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(this.s)},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},r.u.lang.extend(a.asn1.DERAbstractString,a.asn1.ASN1Object),a.asn1.DERAbstractTime=function(e){a.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(e){return utc=e.getTime()+6e4*e.getTimezoneOffset(),new Date(utc)},this.formatDate=function(e,t,s){var i=this.zeroPadding,r=this.localDateToUTC(e),a=String(r.getFullYear());"utc"==t&&(a=a.substr(2,2));var n=a+i(String(r.getMonth()+1),2)+i(String(r.getDate()),2)+i(String(r.getHours()),2)+i(String(r.getMinutes()),2)+i(String(r.getSeconds()),2);if(!0===s){var o=r.getMilliseconds();if(0!=o){var d=i(String(o),3);n=n+"."+(d=d.replace(/[0]+$/,""))}}return n+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(e)},this.setByDateValue=function(e,t,s,i,r,a){var n=new Date(Date.UTC(e,t-1,s,i,r,a,0));this.setByDate(n)},this.getFreshValueHex=function(){return this.hV}},r.u.lang.extend(a.asn1.DERAbstractTime,a.asn1.ASN1Object),a.asn1.DERAbstractStructured=function(e){a.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},r.u.lang.extend(a.asn1.DERAbstractStructured,a.asn1.ASN1Object),a.asn1.DERBoolean=function(){a.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.u.lang.extend(a.asn1.DERBoolean,a.asn1.ASN1Object),a.asn1.DERInteger=function(e){a.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=a.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new i.Jh(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},r.u.lang.extend(a.asn1.DERInteger,a.asn1.ASN1Object),a.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=a.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}a.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var s="0"+e;this.hTLV=null,this.isModified=!0,this.hV=s+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var s=0;s<=t;s++)e+="0";var i="";for(s=0;s<e.length-1;s+=8){var r=e.substr(s,8),a=parseInt(r,2).toString(16);1==a.length&&(a="0"+a),i+=a}this.hTLV=null,this.isModified=!0,this.hV="0"+t+i},this.setByBooleanArray=function(e){for(var t="",s=0;s<e.length;s++)1==e[s]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),s=0;s<e;s++)t[s]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},r.u.lang.extend(a.asn1.DERBitString,a.asn1.ASN1Object),a.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=a.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}a.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},r.u.lang.extend(a.asn1.DEROctetString,a.asn1.DERAbstractString),a.asn1.DERNull=function(){a.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},r.u.lang.extend(a.asn1.DERNull,a.asn1.ASN1Object),a.asn1.DERObjectIdentifier=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},s=function(e){var s="",r=new i.Jh(e,10).toString(2),a=7-r.length%7;7==a&&(a=0);for(var n="",o=0;o<a;o++)n+="0";r=n+r;for(o=0;o<r.length-1;o+=7){var d=r.substr(o,7);o!=r.length-7&&(d="1"+d),s+=t(parseInt(d,2))}return s};a.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var i="",r=e.split("."),a=40*parseInt(r[0])+parseInt(r[1]);i+=t(a),r.splice(0,2);for(var n=0;n<r.length;n++)i+=s(r[n]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(e){var t=a.asn1.x509.OID.name2oid(e);if(""===t)throw"DERObjectIdentifier oidName undefined: "+e;this.setValueOidString(t)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e):void 0!==e.oid?this.setValueOidString(e.oid):void 0!==e.hex?this.setValueHex(e.hex):void 0!==e.name&&this.setValueName(e.name))},r.u.lang.extend(a.asn1.DERObjectIdentifier,a.asn1.ASN1Object),a.asn1.DEREnumerated=function(e){a.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=a.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new i.Jh(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},r.u.lang.extend(a.asn1.DEREnumerated,a.asn1.ASN1Object),a.asn1.DERUTF8String=function(e){a.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},r.u.lang.extend(a.asn1.DERUTF8String,a.asn1.DERAbstractString),a.asn1.DERNumericString=function(e){a.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},r.u.lang.extend(a.asn1.DERNumericString,a.asn1.DERAbstractString),a.asn1.DERPrintableString=function(e){a.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},r.u.lang.extend(a.asn1.DERPrintableString,a.asn1.DERAbstractString),a.asn1.DERTeletexString=function(e){a.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},r.u.lang.extend(a.asn1.DERTeletexString,a.asn1.DERAbstractString),a.asn1.DERIA5String=function(e){a.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},r.u.lang.extend(a.asn1.DERIA5String,a.asn1.DERAbstractString),a.asn1.DERUTCTime=function(e){a.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},r.u.lang.extend(a.asn1.DERUTCTime,a.asn1.DERAbstractTime),a.asn1.DERGeneralizedTime=function(e){a.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},r.u.lang.extend(a.asn1.DERGeneralizedTime,a.asn1.DERAbstractTime),a.asn1.DERSequence=function(e){a.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},r.u.lang.extend(a.asn1.DERSequence,a.asn1.DERAbstractStructured),a.asn1.DERSet=function(e){a.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var s=this.asn1Array[t];e.push(s.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},r.u.lang.extend(a.asn1.DERSet,a.asn1.DERAbstractStructured),a.asn1.DERTaggedObject=function(e){a.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,s){this.hT=t,this.isExplicit=e,this.asn1Object=s,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=s.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.tag&&(this.hT=e.tag),void 0!==e.explicit&&(this.isExplicit=e.explicit),void 0!==e.obj&&(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},r.u.lang.extend(a.asn1.DERTaggedObject,a.asn1.ASN1Object)},1532:(e,t,s)=>{s.d(t,{u:()=>i});
|
|
22
22
|
/*!
|
|
23
23
|
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
|
|
24
24
|
Code licensed under the BSD License:
|
|
25
25
|
http://developer.yahoo.com/yui/license.html
|
|
26
26
|
version: 2.9.0
|
|
27
27
|
*/
|
|
28
|
-
var i={};i.lang={extend:function(e,t,s){if(!t||!e)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var i=function(){};if(i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t),s){var r;for(r in s)e.prototype[r]=s[r];var a=function(){},n=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(a=function(e,t){for(r=0;r<n.length;r+=1){var s=n[r],i=t[s];"function"==typeof i&&i!=Object.prototype[s]&&(e[s]=i)}})}catch(e){}a(e.prototype,s)}}}}},t={};function s(i){var r=t[i];if(void 0!==r)return r.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{s.r(i),s.d(i,{AccountNotEnabled:()=>a.AccountNotEnabled,AccountSuspended:()=>a.AccountSuspended,AddressPending:()=>a.AddressPending,ArgumentsRequired:()=>a.ArgumentsRequired,AuthenticationError:()=>a.AuthenticationError,BadRequest:()=>a.BadRequest,BadResponse:()=>a.BadResponse,BadSymbol:()=>a.BadSymbol,BaseError:()=>a.BaseError,CancelPending:()=>a.CancelPending,DDoSProtection:()=>a.DDoSProtection,DuplicateOrderId:()=>a.DuplicateOrderId,Exchange:()=>e.e,ExchangeError:()=>a.ExchangeError,ExchangeNotAvailable:()=>a.ExchangeNotAvailable,InsufficientFunds:()=>a.InsufficientFunds,InvalidAddress:()=>a.InvalidAddress,InvalidNonce:()=>a.InvalidNonce,InvalidOrder:()=>a.InvalidOrder,MarginModeAlreadySet:()=>a.MarginModeAlreadySet,NetworkError:()=>a.NetworkError,NoChange:()=>a.NoChange,NotSupported:()=>a.NotSupported,NullResponse:()=>a.NullResponse,OnMaintenance:()=>a.OnMaintenance,OrderImmediatelyFillable:()=>a.OrderImmediatelyFillable,OrderNotCached:()=>a.OrderNotCached,OrderNotFillable:()=>a.OrderNotFillable,OrderNotFound:()=>a.OrderNotFound,PermissionDenied:()=>a.PermissionDenied,Precise:()=>t.O,RateLimitExceeded:()=>a.RateLimitExceeded,RequestTimeout:()=>a.RequestTimeout,ace:()=>n.Z,alpaca:()=>o.Z,ascendex:()=>d.Z,bequant:()=>h.Z,bigone:()=>c.Z,binance:()=>l.Z,binancecoinm:()=>u.Z,binanceus:()=>f.Z,binanceusdm:()=>p.Z,bingx:()=>m.Z,bit2c:()=>g.Z,bitbank:()=>y.Z,bitbay:()=>v.Z,bitbns:()=>b.Z,bitcoincom:()=>w.Z,bitfinex:()=>S.Z,bitfinex2:()=>k.Z,bitflyer:()=>O.Z,bitforex:()=>T.Z,bitget:()=>I.Z,bithumb:()=>x.Z,bitmart:()=>P.Z,bitmex:()=>M.Z,bitopro:()=>A.Z,bitpanda:()=>C.Z,bitrue:()=>E.Z,bitso:()=>_.Z,bitstamp:()=>B.Z,bitstamp1:()=>N.Z,bittrex:()=>V.Z,bitvavo:()=>R.Z,bl3p:()=>L.Z,blockchaincom:()=>D.Z,btcalpha:()=>q.Z,btcbox:()=>F.Z,btcmarkets:()=>G.Z,btctradeua:()=>H.Z,btcturk:()=>U.Z,bybit:()=>W.Z,cex:()=>j.Z,coinbase:()=>K.Z,coinbaseprime:()=>Z.Z,coinbasepro:()=>z.Z,coincheck:()=>X.Z,coinex:()=>Q.Z,coinfalcon:()=>Y.Z,coinmate:()=>J.Z,coinone:()=>$.Z,coinsph:()=>ee.Z,coinspot:()=>te.Z,cryptocom:()=>se.Z,currencycom:()=>ie.Z,default:()=>us,delta:()=>re.Z,deribit:()=>ae.Z,digifinex:()=>ne.Z,errors:()=>a,exchanges:()=>cs,exmo:()=>oe.Z,fmfwio:()=>de.Z,functions:()=>r,gate:()=>he.Z,gateio:()=>ce.Z,gemini:()=>le.Z,hitbtc:()=>ue.Z,hitbtc3:()=>fe.Z,hollaex:()=>pe.Z,huobi:()=>me.Z,huobijp:()=>ge.Z,huobipro:()=>ye.Z,idex:()=>ve.Z,independentreserve:()=>be.Z,indodax:()=>we.Z,kraken:()=>Se.Z,krakenfutures:()=>ke.Z,kucoin:()=>Oe.Z,kucoinfutures:()=>Te.Z,kuna:()=>Ie.Z,latoken:()=>xe.Z,lbank:()=>Pe.Z,lbank2:()=>Me.Z,luno:()=>Ae.Z,lykke:()=>Ce.Z,mercado:()=>Ee.Z,mexc:()=>_e.Z,mexc3:()=>Be.Z,ndax:()=>Ne.Z,novadax:()=>Ve.Z,oceanex:()=>Re.Z,okcoin:()=>Le.Z,okex:()=>De.Z,okex5:()=>qe.Z,okx:()=>Fe.Z,paymium:()=>Ge.Z,phemex:()=>He.Z,poloniex:()=>Ue.Z,poloniexfutures:()=>We.Z,pro:()=>ls,probit:()=>je.Z,tidex:()=>Ke.Z,timex:()=>Ze.Z,tokocrypto:()=>ze.Z,upbit:()=>Xe.Z,version:()=>hs,wavesexchange:()=>Qe.Z,wazirx:()=>Ye.Z,whitebit:()=>Je.Z,woo:()=>$e.Z,yobit:()=>et.Z,zaif:()=>tt.Z,zonda:()=>st.Z});var e=s(3043),t=s(2194),r=s(7100),a=s(6689),n=s(9869),o=s(5660),d=s(9612),h=s(2049),c=s(7679),l=s(9987),u=s(9212),f=s(2723),p=s(3254),m=s(7960),g=s(7691),y=s(7820),v=s(668),b=s(7790),w=s(1819),S=s(6537),k=s(730),O=s(8429),T=s(2035),I=s(9051),x=s(5305),P=s(3718),M=s(7077),A=s(172),C=s(2737),E=s(854),_=s(4388),B=s(4667),N=s(1242),V=s(8963),R=s(9943),L=s(9476),D=s(182),q=s(6246),F=s(7796),G=s(1776),H=s(8776),U=s(6304),W=s(3527),j=s(6445),K=s(437),Z=s(1741),z=s(8856),X=s(2117),Q=s(332),Y=s(5585),J=s(9816),$=s(7811),ee=s(5782),te=s(7794),se=s(9129),ie=s(3214),re=s(1753),ae=s(24),ne=s(8846),oe=s(1729),de=s(5788),he=s(7290),ce=s(7036),le=s(6743),ue=s(4714),fe=s(4815),pe=s(8422),me=s(8146),ge=s(7034),ye=s(5547),ve=s(8232),be=s(9570),we=s(1605),Se=s(9922),ke=s(4470),Oe=s(3583),Te=s(1924),Ie=s(7732),xe=s(2545),Pe=s(3944),Me=s(8601),Ae=s(1758),Ce=s(3803),Ee=s(9013),_e=s(6641),Be=s(2305),Ne=s(4531),Ve=s(2449),Re=s(6749),Le=s(3007),De=s(5322),qe=s(7826),Fe=s(4042),Ge=s(7082),He=s(79),Ue=s(8891),We=s(6877),je=s(3657),Ke=s(4224),Ze=s(1067),ze=s(5261),Xe=s(7584),Qe=s(3853),Ye=s(6536),Je=s(5467),$e=s(517),et=s(3850),tt=s(5934),st=s(5140),it=s(2467),rt=s(2383),at=s(8848),nt=s(8764),ot=s(5078),dt=s(1326),ht=s(1230),ct=s(6955),lt=s(453),ut=s(9772),ft=s(588),pt=s(1885),mt=s(7504),gt=s(2302),yt=s(2191),vt=s(1297),bt=s(3005),wt=s(3623),St=s(2883),kt=s(6977),Ot=s(2519),Tt=s(5030),It=s(5272),xt=s(3414),Pt=s(3848),Mt=s(8368),At=s(204),Ct=s(6820),Et=s(2952),_t=s(1788),Bt=s(9004),Nt=s(8335),Vt=s(1465),Rt=s(9488),Lt=s(5189),Dt=s(8559),qt=s(8384),Ft=s(9021),Gt=s(4625),Ht=s(3484),Ut=s(1311),Wt=s(736),jt=s(449),Kt=s(2387),Zt=s(7181),zt=s(627),Xt=s(6484),Qt=s(5351),Yt=s(8080),Jt=s(7105),$t=s(1530),es=s(2214),ts=s(4360),ss=s(7924),is=s(3541),rs=s(9782),as=s(7614),ns=s(4828),os=s(5630),ds=s(3910);const hs="4.1.
|
|
28
|
+
var i={};i.lang={extend:function(e,t,s){if(!t||!e)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var i=function(){};if(i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t),s){var r;for(r in s)e.prototype[r]=s[r];var a=function(){},n=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(a=function(e,t){for(r=0;r<n.length;r+=1){var s=n[r],i=t[s];"function"==typeof i&&i!=Object.prototype[s]&&(e[s]=i)}})}catch(e){}a(e.prototype,s)}}}}},t={};function s(i){var r=t[i];if(void 0!==r)return r.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{s.r(i),s.d(i,{AccountNotEnabled:()=>a.AccountNotEnabled,AccountSuspended:()=>a.AccountSuspended,AddressPending:()=>a.AddressPending,ArgumentsRequired:()=>a.ArgumentsRequired,AuthenticationError:()=>a.AuthenticationError,BadRequest:()=>a.BadRequest,BadResponse:()=>a.BadResponse,BadSymbol:()=>a.BadSymbol,BaseError:()=>a.BaseError,CancelPending:()=>a.CancelPending,DDoSProtection:()=>a.DDoSProtection,DuplicateOrderId:()=>a.DuplicateOrderId,Exchange:()=>e.e,ExchangeError:()=>a.ExchangeError,ExchangeNotAvailable:()=>a.ExchangeNotAvailable,InsufficientFunds:()=>a.InsufficientFunds,InvalidAddress:()=>a.InvalidAddress,InvalidNonce:()=>a.InvalidNonce,InvalidOrder:()=>a.InvalidOrder,MarginModeAlreadySet:()=>a.MarginModeAlreadySet,NetworkError:()=>a.NetworkError,NoChange:()=>a.NoChange,NotSupported:()=>a.NotSupported,NullResponse:()=>a.NullResponse,OnMaintenance:()=>a.OnMaintenance,OrderImmediatelyFillable:()=>a.OrderImmediatelyFillable,OrderNotCached:()=>a.OrderNotCached,OrderNotFillable:()=>a.OrderNotFillable,OrderNotFound:()=>a.OrderNotFound,PermissionDenied:()=>a.PermissionDenied,Precise:()=>t.O,RateLimitExceeded:()=>a.RateLimitExceeded,RequestTimeout:()=>a.RequestTimeout,ace:()=>n.Z,alpaca:()=>o.Z,ascendex:()=>d.Z,bequant:()=>h.Z,bigone:()=>c.Z,binance:()=>l.Z,binancecoinm:()=>u.Z,binanceus:()=>f.Z,binanceusdm:()=>p.Z,bingx:()=>m.Z,bit2c:()=>g.Z,bitbank:()=>y.Z,bitbay:()=>v.Z,bitbns:()=>b.Z,bitcoincom:()=>w.Z,bitfinex:()=>S.Z,bitfinex2:()=>k.Z,bitflyer:()=>O.Z,bitforex:()=>T.Z,bitget:()=>I.Z,bithumb:()=>x.Z,bitmart:()=>P.Z,bitmex:()=>M.Z,bitopro:()=>A.Z,bitpanda:()=>C.Z,bitrue:()=>E.Z,bitso:()=>_.Z,bitstamp:()=>B.Z,bitstamp1:()=>N.Z,bittrex:()=>V.Z,bitvavo:()=>R.Z,bl3p:()=>L.Z,blockchaincom:()=>D.Z,btcalpha:()=>q.Z,btcbox:()=>F.Z,btcmarkets:()=>G.Z,btctradeua:()=>H.Z,btcturk:()=>U.Z,bybit:()=>W.Z,cex:()=>j.Z,coinbase:()=>K.Z,coinbaseprime:()=>Z.Z,coinbasepro:()=>z.Z,coincheck:()=>X.Z,coinex:()=>Q.Z,coinfalcon:()=>Y.Z,coinmate:()=>J.Z,coinone:()=>$.Z,coinsph:()=>ee.Z,coinspot:()=>te.Z,cryptocom:()=>se.Z,currencycom:()=>ie.Z,default:()=>us,delta:()=>re.Z,deribit:()=>ae.Z,digifinex:()=>ne.Z,errors:()=>a,exchanges:()=>cs,exmo:()=>oe.Z,fmfwio:()=>de.Z,functions:()=>r,gate:()=>he.Z,gateio:()=>ce.Z,gemini:()=>le.Z,hitbtc:()=>ue.Z,hitbtc3:()=>fe.Z,hollaex:()=>pe.Z,huobi:()=>me.Z,huobijp:()=>ge.Z,huobipro:()=>ye.Z,idex:()=>ve.Z,independentreserve:()=>be.Z,indodax:()=>we.Z,kraken:()=>Se.Z,krakenfutures:()=>ke.Z,kucoin:()=>Oe.Z,kucoinfutures:()=>Te.Z,kuna:()=>Ie.Z,latoken:()=>xe.Z,lbank:()=>Pe.Z,lbank2:()=>Me.Z,luno:()=>Ae.Z,lykke:()=>Ce.Z,mercado:()=>Ee.Z,mexc:()=>_e.Z,mexc3:()=>Be.Z,ndax:()=>Ne.Z,novadax:()=>Ve.Z,oceanex:()=>Re.Z,okcoin:()=>Le.Z,okex:()=>De.Z,okex5:()=>qe.Z,okx:()=>Fe.Z,paymium:()=>Ge.Z,phemex:()=>He.Z,poloniex:()=>Ue.Z,poloniexfutures:()=>We.Z,pro:()=>ls,probit:()=>je.Z,tidex:()=>Ke.Z,timex:()=>Ze.Z,tokocrypto:()=>ze.Z,upbit:()=>Xe.Z,version:()=>hs,wavesexchange:()=>Qe.Z,wazirx:()=>Ye.Z,whitebit:()=>Je.Z,woo:()=>$e.Z,yobit:()=>et.Z,zaif:()=>tt.Z,zonda:()=>st.Z});var e=s(3043),t=s(2194),r=s(7100),a=s(6689),n=s(9869),o=s(5660),d=s(9612),h=s(2049),c=s(7679),l=s(9987),u=s(9212),f=s(2723),p=s(3254),m=s(7960),g=s(7691),y=s(7820),v=s(668),b=s(7790),w=s(1819),S=s(6537),k=s(730),O=s(8429),T=s(2035),I=s(9051),x=s(5305),P=s(3718),M=s(7077),A=s(172),C=s(2737),E=s(854),_=s(4388),B=s(4667),N=s(1242),V=s(8963),R=s(9943),L=s(9476),D=s(182),q=s(6246),F=s(7796),G=s(1776),H=s(8776),U=s(6304),W=s(3527),j=s(6445),K=s(437),Z=s(1741),z=s(8856),X=s(2117),Q=s(332),Y=s(5585),J=s(9816),$=s(7811),ee=s(5782),te=s(7794),se=s(9129),ie=s(3214),re=s(1753),ae=s(24),ne=s(8846),oe=s(1729),de=s(5788),he=s(7290),ce=s(7036),le=s(6743),ue=s(4714),fe=s(4815),pe=s(8422),me=s(8146),ge=s(7034),ye=s(5547),ve=s(8232),be=s(9570),we=s(1605),Se=s(9922),ke=s(4470),Oe=s(3583),Te=s(1924),Ie=s(7732),xe=s(2545),Pe=s(3944),Me=s(8601),Ae=s(1758),Ce=s(3803),Ee=s(9013),_e=s(6641),Be=s(2305),Ne=s(4531),Ve=s(2449),Re=s(6749),Le=s(3007),De=s(5322),qe=s(7826),Fe=s(4042),Ge=s(7082),He=s(79),Ue=s(8891),We=s(6877),je=s(3657),Ke=s(4224),Ze=s(1067),ze=s(5261),Xe=s(7584),Qe=s(3853),Ye=s(6536),Je=s(5467),$e=s(517),et=s(3850),tt=s(5934),st=s(5140),it=s(2467),rt=s(2383),at=s(8848),nt=s(8764),ot=s(5078),dt=s(1326),ht=s(1230),ct=s(6955),lt=s(453),ut=s(9772),ft=s(588),pt=s(1885),mt=s(7504),gt=s(2302),yt=s(2191),vt=s(1297),bt=s(3005),wt=s(3623),St=s(2883),kt=s(6977),Ot=s(2519),Tt=s(5030),It=s(5272),xt=s(3414),Pt=s(3848),Mt=s(8368),At=s(204),Ct=s(6820),Et=s(2952),_t=s(1788),Bt=s(9004),Nt=s(8335),Vt=s(1465),Rt=s(9488),Lt=s(5189),Dt=s(8559),qt=s(8384),Ft=s(9021),Gt=s(4625),Ht=s(3484),Ut=s(1311),Wt=s(736),jt=s(449),Kt=s(2387),Zt=s(7181),zt=s(627),Xt=s(6484),Qt=s(5351),Yt=s(8080),Jt=s(7105),$t=s(1530),es=s(2214),ts=s(4360),ss=s(7924),is=s(3541),rs=s(9782),as=s(7614),ns=s(4828),os=s(5630),ds=s(3910);const hs="4.1.27";e.e.ccxtVersion=hs;const cs={ace:n.Z,alpaca:o.Z,ascendex:d.Z,bequant:h.Z,bigone:c.Z,binance:l.Z,binancecoinm:u.Z,binanceus:f.Z,binanceusdm:p.Z,bingx:m.Z,bit2c:g.Z,bitbank:y.Z,bitbay:v.Z,bitbns:b.Z,bitcoincom:w.Z,bitfinex:S.Z,bitfinex2:k.Z,bitflyer:O.Z,bitforex:T.Z,bitget:I.Z,bithumb:x.Z,bitmart:P.Z,bitmex:M.Z,bitopro:A.Z,bitpanda:C.Z,bitrue:E.Z,bitso:_.Z,bitstamp:B.Z,bitstamp1:N.Z,bittrex:V.Z,bitvavo:R.Z,bl3p:L.Z,blockchaincom:D.Z,btcalpha:q.Z,btcbox:F.Z,btcmarkets:G.Z,btctradeua:H.Z,btcturk:U.Z,bybit:W.Z,cex:j.Z,coinbase:K.Z,coinbaseprime:Z.Z,coinbasepro:z.Z,coincheck:X.Z,coinex:Q.Z,coinfalcon:Y.Z,coinmate:J.Z,coinone:$.Z,coinsph:ee.Z,coinspot:te.Z,cryptocom:se.Z,currencycom:ie.Z,delta:re.Z,deribit:ae.Z,digifinex:ne.Z,exmo:oe.Z,fmfwio:de.Z,gate:he.Z,gateio:ce.Z,gemini:le.Z,hitbtc:ue.Z,hitbtc3:fe.Z,hollaex:pe.Z,huobi:me.Z,huobijp:ge.Z,huobipro:ye.Z,idex:ve.Z,independentreserve:be.Z,indodax:we.Z,kraken:Se.Z,krakenfutures:ke.Z,kucoin:Oe.Z,kucoinfutures:Te.Z,kuna:Ie.Z,latoken:xe.Z,lbank:Pe.Z,lbank2:Me.Z,luno:Ae.Z,lykke:Ce.Z,mercado:Ee.Z,mexc:_e.Z,mexc3:Be.Z,ndax:Ne.Z,novadax:Ve.Z,oceanex:Re.Z,okcoin:Le.Z,okex:De.Z,okex5:qe.Z,okx:Fe.Z,paymium:Ge.Z,phemex:He.Z,poloniex:Ue.Z,poloniexfutures:We.Z,probit:je.Z,tidex:Ke.Z,timex:Ze.Z,tokocrypto:ze.Z,upbit:Xe.Z,wavesexchange:Qe.Z,wazirx:Ye.Z,whitebit:Je.Z,woo:$e.Z,yobit:et.Z,zaif:tt.Z,zonda:st.Z},ls={alpaca:it.Z,ascendex:rt.Z,bequant:at.Z,binance:nt.Z,binancecoinm:ot.Z,binanceus:dt.Z,binanceusdm:ht.Z,bingx:ct.Z,bitcoincom:lt.Z,bitfinex:ut.Z,bitfinex2:ft.Z,bitget:pt.Z,bitmart:mt.Z,bitmex:gt.Z,bitopro:yt.Z,bitpanda:vt.Z,bitrue:bt.Z,bitstamp:wt.Z,bittrex:St.Z,bitvavo:kt.Z,blockchaincom:Ot.Z,bybit:Tt.Z,cex:It.Z,coinbase:xt.Z,coinbaseprime:Pt.Z,coinbasepro:Mt.Z,coinex:At.Z,cryptocom:Ct.Z,currencycom:Et.Z,deribit:_t.Z,exmo:Bt.Z,gate:Nt.Z,gateio:Vt.Z,gemini:Rt.Z,hitbtc:Lt.Z,hollaex:Dt.Z,huobi:qt.Z,huobijp:Ft.Z,huobipro:Gt.Z,idex:Ht.Z,independentreserve:Ut.Z,kraken:Wt.Z,krakenfutures:jt.Z,kucoin:Kt.Z,kucoinfutures:Zt.Z,luno:zt.Z,mexc:Xt.Z,mexc3:Qt.Z,ndax:Yt.Z,okcoin:Jt.Z,okex:$t.Z,okx:es.Z,phemex:ts.Z,poloniex:ss.Z,poloniexfutures:is.Z,probit:rs.Z,upbit:as.Z,wazirx:ns.Z,whitebit:os.Z,woo:ds.Z};for(const e in ls);ls.exchanges=Object.keys(ls),ls.Exchange=e.e;const us=Object.assign({version:hs,Exchange:e.e,Precise:t.O,exchanges:Object.keys(cs),pro:ls},cs,r,a)})(),self.ccxt=i})();
|