@ultrade/ultrade-js-sdk 2.0.31 → 2.0.32
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/dist/enum/market.enum.d.ts +0 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function te(){throw new Error("setTimeout has not been defined")}function re(){throw new Error("clearTimeout has not been defined")}var w=te,S=re;typeof globalThis.setTimeout=="function"&&(w=setTimeout);typeof globalThis.clearTimeout=="function"&&(S=clearTimeout);function ie(i){if(w===setTimeout)return setTimeout(i,0);if((w===te||!w)&&setTimeout)return w=setTimeout,setTimeout(i,0);try{return w(i,0)}catch{try{return w.call(null,i,0)}catch{return w.call(this,i,0)}}}function De(i){if(S===clearTimeout)return clearTimeout(i);if((S===re||!S)&&clearTimeout)return S=clearTimeout,clearTimeout(i);try{return S(i)}catch{try{return S.call(null,i)}catch{return S.call(this,i)}}}var _=[],N=!1,P,O=-1;function We(){!N||!P||(N=!1,P.length?_=P.concat(_):O=-1,_.length&&ne())}function ne(){if(!N){var i=ie(We);N=!0;for(var e=_.length;e;){for(P=_,_=[];++O<e;)P&&P[O].run();O=-1,e=_.length}P=null,N=!1,De(i)}}function Ne(i){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];_.push(new ae(i,e)),_.length===1&&!N&&ie(ne)}function ae(i,e){this.fun=i,this.array=e}ae.prototype.run=function(){this.fun.apply(null,this.array)};var Ue="browser",ve="browser",Fe=!0,Ge={},Oe=[],Ce="",Le={},Ve={},Ye={};function k(){}var $e=k,Be=k,Xe=k,qe=k,Ze=k,ze=k,Qe=k;function Je(i){throw new Error("process.binding is not supported")}function je(){return"/"}function Ke(i){throw new Error("process.chdir is not supported")}function He(){return 0}var W=globalThis.performance||{},et=W.now||W.mozNow||W.msNow||W.oNow||W.webkitNow||function(){return new Date().getTime()};function tt(i){var e=et.call(W)*.001,t=Math.floor(e),r=Math.floor(e%1*1e9);return i&&(t=t-i[0],r=r-i[1],r<0&&(t--,r+=1e9)),[t,r]}var rt=new Date;function it(){var i=new Date,e=i-rt;return e/1e3}var g={nextTick:Ne,title:Ue,browser:Fe,env:Ge,argv:Oe,version:Ce,versions:Le,on:$e,addListener:Be,once:Xe,off:qe,removeListener:Ze,removeAllListeners:ze,emit:Qe,binding:Je,cwd:je,chdir:Ke,umask:He,hrtime:tt,platform:ve,release:Ve,config:Ye,uptime:it},ee={};Object.keys(ee).forEach(i=>{let e=i.split("."),t=g;for(let r=0;r<e.length;r++){let n=e[r];r===e.length-1?t[n]=ee[i]:t=t[n]||(t[n]={})}});var A=[],b=[],nt=typeof Uint8Array<"u"?Uint8Array:Array,Z=!1;function ce(){Z=!0;for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=i.length;e<t;++e)A[e]=i[e],b[i.charCodeAt(e)]=e;b[45]=62,b[95]=63}function at(i){Z||ce();var e,t,r,n,a,o,c=i.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=i[c-2]==="="?2:i[c-1]==="="?1:0,o=new nt(c*3/4-a),r=a>0?c-4:c;var u=0;for(e=0,t=0;e<r;e+=4,t+=3)n=b[i.charCodeAt(e)]<<18|b[i.charCodeAt(e+1)]<<12|b[i.charCodeAt(e+2)]<<6|b[i.charCodeAt(e+3)],o[u++]=n>>16&255,o[u++]=n>>8&255,o[u++]=n&255;return a===2?(n=b[i.charCodeAt(e)]<<2|b[i.charCodeAt(e+1)]>>4,o[u++]=n&255):a===1&&(n=b[i.charCodeAt(e)]<<10|b[i.charCodeAt(e+1)]<<4|b[i.charCodeAt(e+2)]>>2,o[u++]=n>>8&255,o[u++]=n&255),o}function st(i){return A[i>>18&63]+A[i>>12&63]+A[i>>6&63]+A[i&63]}function ot(i,e,t){for(var r,n=[],a=e;a<t;a+=3)r=(i[a]<<16)+(i[a+1]<<8)+i[a+2],n.push(st(r));return n.join("")}function se(i){Z||ce();for(var e,t=i.length,r=t%3,n="",a=[],o=16383,c=0,u=t-r;c<u;c+=o)a.push(ot(i,c,c+o>u?u:c+o));return r===1?(e=i[t-1],n+=A[e>>2],n+=A[e<<4&63],n+="=="):r===2&&(e=(i[t-2]<<8)+i[t-1],n+=A[e>>10],n+=A[e>>4&63],n+=A[e<<2&63],n+="="),a.push(n),a.join("")}l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function C(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function y(i,e){if(C()<e)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(i=new Uint8Array(e),i.__proto__=l.prototype):(i===null&&(i=new l(e)),i.length=e),i}function l(i,e,t){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(i,e,t);if(typeof i=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return z(this,i)}return ue(this,i,e,t)}l.poolSize=8192;l._augment=function(i){return i.__proto__=l.prototype,i};function ue(i,e,t,r){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?ut(i,e,t,r):typeof e=="string"?ct(i,e,t):dt(i,e)}l.from=function(i,e,t){return ue(null,i,e,t)};l.kMaxLength=C();l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&l[Symbol.species]);function de(i){if(typeof i!="number")throw new TypeError('"size" argument must be a number');if(i<0)throw new RangeError('"size" argument must not be negative')}function lt(i,e,t,r){return de(e),e<=0?y(i,e):t!==void 0?typeof r=="string"?y(i,e).fill(t,r):y(i,e).fill(t):y(i,e)}l.alloc=function(i,e,t){return lt(null,i,e,t)};function z(i,e){if(de(e),i=y(i,e<0?0:Q(e)|0),!l.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)i[t]=0;return i}l.allocUnsafe=function(i){return z(null,i)};l.allocUnsafeSlow=function(i){return z(null,i)};function ct(i,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!l.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=me(e,t)|0;i=y(i,r);var n=i.write(e,t);return n!==r&&(i=i.slice(0,n)),i}function q(i,e){var t=e.length<0?0:Q(e.length)|0;i=y(i,t);for(var r=0;r<t;r+=1)i[r]=e[r]&255;return i}function ut(i,e,t,r){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(r||0))throw new RangeError("'length' is out of bounds");return t===void 0&&r===void 0?e=new Uint8Array(e):r===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,r),l.TYPED_ARRAY_SUPPORT?(i=e,i.__proto__=l.prototype):i=q(i,e),i}function dt(i,e){if(x(e)){var t=Q(e.length)|0;return i=y(i,t),i.length===0||e.copy(i,0,0,t),i}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||Mt(e.length)?y(i,0):q(i,e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(i,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Q(i){if(i>=C())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C().toString(16)+" bytes");return i|0}l.isBuffer=Dt;function x(i){return!!(i!=null&&i._isBuffer)}l.compare=function(e,t){if(!x(e)||!x(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,a=0,o=Math.min(r,n);a<o;++a)if(e[a]!==t[a]){r=e[a],n=t[a];break}return r<n?-1:n<r?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),a=0;for(r=0;r<e.length;++r){var o=e[r];if(!x(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,a),a+=o.length}return n};function me(i,e){if(x(i))return i.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(i)||i instanceof ArrayBuffer))return i.byteLength;typeof i!="string"&&(i=""+i);var t=i.length;if(t===0)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return L(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return be(i).length;default:if(r)return L(i).length;e=(""+e).toLowerCase(),r=!0}}l.byteLength=me;function mt(i,e,t){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return xt(this,e,t);case"utf8":case"utf-8":return fe(this,e,t);case"ascii":return It(this,e,t);case"latin1":case"binary":return At(this,e,t);case"base64":return Et(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _t(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),r=!0}}l.prototype._isBuffer=!0;function R(i,e,t){var r=i[e];i[e]=i[t],i[t]=r}l.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)R(this,t,t+1);return this};l.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)R(this,t,t+3),R(this,t+1,t+2);return this};l.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)R(this,t,t+7),R(this,t+1,t+6),R(this,t+2,t+5),R(this,t+3,t+4);return this};l.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?fe(this,0,e):mt.apply(this,arguments)};l.prototype.equals=function(e){if(!x(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.compare=function(e,t,r,n,a){if(!x(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),a===void 0&&(a=this.length),t<0||r>e.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&t>=r)return 0;if(n>=a)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,a>>>=0,this===e)return 0;for(var o=a-n,c=r-t,u=Math.min(o,c),d=this.slice(n,a),m=e.slice(t,r),p=0;p<u;++p)if(d[p]!==m[p]){o=d[p],c=m[p];break}return o<c?-1:c<o?1:0};function ge(i,e,t,r,n){if(i.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,r)),x(e))return e.length===0?-1:oe(i,e,t,r,n);if(typeof e=="number")return e=e&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):oe(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function oe(i,e,t,r,n){var a=1,o=i.length,c=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(i.length<2||e.length<2)return-1;a=2,o/=2,c/=2,t/=2}function u(E,D){return a===1?E[D]:E.readUInt16BE(D*a)}var d;if(n){var m=-1;for(d=t;d<o;d++)if(u(i,d)===u(e,m===-1?0:d-m)){if(m===-1&&(m=d),d-m+1===c)return m*a}else m!==-1&&(d-=d-m),m=-1}else for(t+c>o&&(t=o-c),d=t;d>=0;d--){for(var p=!0,I=0;I<c;I++)if(u(i,d+I)!==u(e,I)){p=!1;break}if(p)return d}return-1}l.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};l.prototype.indexOf=function(e,t,r){return ge(this,e,t,r,!0)};l.prototype.lastIndexOf=function(e,t,r){return ge(this,e,t,r,!1)};function gt(i,e,t,r){t=Number(t)||0;var n=i.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;var a=e.length;if(a%2!==0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o<r;++o){var c=parseInt(e.substr(o*2,2),16);if(isNaN(c))return o;i[t+o]=c}return o}function pt(i,e,t,r){return $(L(e,i.length-t),i,t,r)}function pe(i,e,t,r){return $(kt(e),i,t,r)}function ft(i,e,t,r){return pe(i,e,t,r)}function ht(i,e,t,r){return $(be(e),i,t,r)}function Tt(i,e,t,r){return $(Rt(e,i.length-t),i,t,r)}l.prototype.write=function(e,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(r)?(r=r|0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-t;if((r===void 0||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return gt(this,e,t,r);case"utf8":case"utf-8":return pt(this,e,t,r);case"ascii":return pe(this,e,t,r);case"latin1":case"binary":return ft(this,e,t,r);case"base64":return ht(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Et(i,e,t){return e===0&&t===i.length?se(i):se(i.slice(e,t))}function fe(i,e,t){t=Math.min(i.length,t);for(var r=[],n=e;n<t;){var a=i[n],o=null,c=a>239?4:a>223?3:a>191?2:1;if(n+c<=t){var u,d,m,p;switch(c){case 1:a<128&&(o=a);break;case 2:u=i[n+1],(u&192)===128&&(p=(a&31)<<6|u&63,p>127&&(o=p));break;case 3:u=i[n+1],d=i[n+2],(u&192)===128&&(d&192)===128&&(p=(a&15)<<12|(u&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:u=i[n+1],d=i[n+2],m=i[n+3],(u&192)===128&&(d&192)===128&&(m&192)===128&&(p=(a&15)<<18|(u&63)<<12|(d&63)<<6|m&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),n+=c}return bt(r)}var le=4096;function bt(i){var e=i.length;if(e<=le)return String.fromCharCode.apply(String,i);for(var t="",r=0;r<e;)t+=String.fromCharCode.apply(String,i.slice(r,r+=le));return t}function It(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]&127);return r}function At(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]);return r}function xt(i,e,t){var r=i.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);for(var n="",a=e;a<t;++a)n+=Pt(i[a]);return n}function _t(i,e,t){for(var r=i.slice(e,t),n="",a=0;a<r.length;a+=2)n+=String.fromCharCode(r[a]+r[a+1]*256);return n}l.prototype.slice=function(e,t){var r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);var n;if(l.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=l.prototype;else{var a=t-e;n=new l(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n};function h(i,e,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e],a=1,o=0;++o<t&&(a*=256);)n+=this[e+o]*a;return n};l.prototype.readUIntBE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e+--t],a=1;t>0&&(a*=256);)n+=this[e+--t]*a;return n};l.prototype.readUInt8=function(e,t){return t||h(e,1,this.length),this[e]};l.prototype.readUInt16LE=function(e,t){return t||h(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUInt16BE=function(e,t){return t||h(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUInt32LE=function(e,t){return t||h(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUInt32BE=function(e,t){return t||h(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readIntLE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e],a=1,o=0;++o<t&&(a*=256);)n+=this[e+o]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*t)),n};l.prototype.readIntBE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=t,a=1,o=this[e+--n];n>0&&(a*=256);)o+=this[e+--n]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*t)),o};l.prototype.readInt8=function(e,t){return t||h(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){t||h(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};l.prototype.readInt16BE=function(e,t){t||h(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};l.prototype.readInt32LE=function(e,t){return t||h(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return t||h(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readFloatLE=function(e,t){return t||h(e,4,this.length),B(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return t||h(e,4,this.length),B(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return t||h(e,8,this.length),B(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return t||h(e,8,this.length),B(this,e,!1,52,8)};function T(i,e,t,r,n,a){if(!x(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<a)throw new RangeError('"value" argument is out of bounds');if(t+r>i.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var a=Math.pow(2,8*r)-1;T(this,e,t,r,a,0)}var o=1,c=0;for(this[t]=e&255;++c<r&&(o*=256);)this[t+c]=e/o&255;return t+r};l.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var a=Math.pow(2,8*r)-1;T(this,e,t,r,a,0)}var o=r-1,c=1;for(this[t+o]=e&255;--o>=0&&(c*=256);)this[t+o]=e/c&255;return t+r};l.prototype.writeUInt8=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function V(i,e,t,r){e<0&&(e=65535+e+1);for(var n=0,a=Math.min(i.length-t,2);n<a;++n)i[t+n]=(e&255<<8*(r?n:1-n))>>>(r?n:1-n)*8}l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):V(this,e,t,!0),t+2};l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):V(this,e,t,!1),t+2};function Y(i,e,t,r){e<0&&(e=4294967295+e+1);for(var n=0,a=Math.min(i.length-t,4);n<a;++n)i[t+n]=e>>>(r?n:3-n)*8&255}l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Y(this,e,t,!0),t+4};l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Y(this,e,t,!1),t+4};l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t|0,!n){var a=Math.pow(2,8*r-1);T(this,e,t,r,a-1,-a)}var o=0,c=1,u=0;for(this[t]=e&255;++o<r&&(c*=256);)e<0&&u===0&&this[t+o-1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t|0,!n){var a=Math.pow(2,8*r-1);T(this,e,t,r,a-1,-a)}var o=r-1,c=1,u=0;for(this[t+o]=e&255;--o>=0&&(c*=256);)e<0&&u===0&&this[t+o+1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeInt8=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):V(this,e,t,!0),t+2};l.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):V(this,e,t,!1),t+2};l.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Y(this,e,t,!0),t+4};l.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Y(this,e,t,!1),t+4};function he(i,e,t,r,n,a){if(t+r>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Te(i,e,t,r,n){return n||he(i,e,t,4,34028234663852886e22,-34028234663852886e22),Ae(i,e,t,r,23,4),t+4}l.prototype.writeFloatLE=function(e,t,r){return Te(this,e,t,!0,r)};l.prototype.writeFloatBE=function(e,t,r){return Te(this,e,t,!1,r)};function Ee(i,e,t,r,n){return n||he(i,e,t,8,17976931348623157e292,-17976931348623157e292),Ae(i,e,t,r,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)};l.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)};l.prototype.copy=function(e,t,r,n){if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var a=n-r,o;if(this===e&&r<t&&t<n)for(o=a-1;o>=0;--o)e[o+t]=this[o+r];else if(a<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a};l.prototype.fill=function(e,t,r,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),e.length===1){var a=e.charCodeAt(0);a<256&&(e=a)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<r;++o)this[o]=e;else{var c=x(e)?e:L(new l(e,n).toString()),u=c.length;for(o=0;o<r-t;++o)this[o+t]=c[o%u]}return this};var yt=/[^+\/0-9A-Za-z-_]/g;function wt(i){if(i=St(i).replace(yt,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function St(i){return i.trim?i.trim():i.replace(/^\s+|\s+$/g,"")}function Pt(i){return i<16?"0"+i.toString(16):i.toString(16)}function L(i,e){e=e||1/0;for(var t,r=i.length,n=null,a=[],o=0;o<r;++o){if(t=i.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(e-=3)>-1&&a.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&a.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&a.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;a.push(t)}else if(t<2048){if((e-=2)<0)break;a.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;a.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;a.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return a}function kt(i){for(var e=[],t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function Rt(i,e){for(var t,r,n,a=[],o=0;o<i.length&&!((e-=2)<0);++o)t=i.charCodeAt(o),r=t>>8,n=t%256,a.push(n),a.push(r);return a}function be(i){return at(wt(i))}function $(i,e,t,r){for(var n=0;n<r&&!(n+t>=e.length||n>=i.length);++n)e[n+t]=i[n];return n}function Mt(i){return i!==i}function Dt(i){return i!=null&&(!!i._isBuffer||Ie(i)||Wt(i))}function Ie(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function Wt(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&Ie(i.slice(0,0))}function B(i,e,t,r,n){var a,o,c=n*8-r-1,u=(1<<c)-1,d=u>>1,m=-7,p=t?n-1:0,I=t?-1:1,E=i[e+p];for(p+=I,a=E&(1<<-m)-1,E>>=-m,m+=c;m>0;a=a*256+i[e+p],p+=I,m-=8);for(o=a&(1<<-m)-1,a>>=-m,m+=r;m>0;o=o*256+i[e+p],p+=I,m-=8);if(a===0)a=1-d;else{if(a===u)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,r),a=a-d}return(E?-1:1)*o*Math.pow(2,a-r)}function Ae(i,e,t,r,n,a){var o,c,u,d=a*8-n-1,m=(1<<d)-1,p=m>>1,I=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=r?0:a-1,D=r?1:-1,Me=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+p>=1?e+=I/u:e+=I*Math.pow(2,1-p),e*u>=2&&(o++,u/=2),o+p>=m?(c=0,o=m):o+p>=1?(c=(e*u-1)*Math.pow(2,n),o=o+p):(c=e*Math.pow(2,p-1)*Math.pow(2,n),o=0));n>=8;i[t+E]=c&255,E+=D,c/=256,n-=8);for(o=o<<n|c,d+=n;d>0;i[t+E]=o&255,E+=D,o/=256,d-=8);i[t+E-D]|=Me*128}import{io as nr}from"socket.io-client";import ar from"axios";import{DEFAULT_ORDER_EXPIRATION_DAYS as sr,ORDER_MSG_VERSION as or}from"@ultrade/shared/browser/constants";import{getRandomInt as H}from"@ultrade/shared/browser/common";import{getCancelOrderDataJsonBytes as lr,makeLoginMsg as cr,makeTradingKeyMsg as ke,makeCreateOrderMsg as ur}from"@ultrade/shared/browser/helpers/codex.helper";import{makeWithdrawMsg as dr}from"@ultrade/shared/browser/helpers/withdraw.helper";import{TradingKeyType as mr}from"@ultrade/shared/browser/interfaces";import{PROVIDERS as M}from"@ultrade/shared/browser/interfaces";import{OrderStatus as G}from"@ultrade/shared/browser/enums";import{makeDtwMsg as gr,makeTransferMsg as pr}from"@ultrade/shared/browser/helpers/codex";var U=class{constructor(e,t,r,n){this.onDisconnect=r;this.onConnectError=n;this.socket=null;this.socketPool={};this.streamCounters=new Map;this.callbacks=new Map;this.onAnyRegistered=!1;this.handlerIdCounter=0;this.websocketUrl=e,this.socketIOFactory=t,this.initializeSocket()}initializeSocket(){this.socket===null&&(this.socket=this.socketIOFactory(this.websocketUrl,{reconnection:!0,reconnectionDelay:1e3,reconnectionAttempts:9999,transports:["websocket"]}),this.onDisconnect&&this.socket.on("disconnect",()=>{this.onDisconnect(this.socket.id)}),this.onConnectError&&this.socket.on("connect_error",e=>{this.onConnectError(e)}),this.setupReconnectHandler())}getSocket(){return this.socket}subscribe(e,t){let r=Date.now()+ ++this.handlerIdCounter;this.socket===null&&this.initializeSocket(),this.callbacks.set(r,t),this.onAnyRegistered||(this.socket.onAny((a,...o)=>{this.callbacks.forEach(c=>{c(a,o)})}),this.onAnyRegistered=!0),e.streams.forEach(a=>{let o=String(a);if(!this.streamCounters.has(o)){this.streamCounters.set(o,1),console.log(`[SocketManager] Stream counter created: stream=${o}, count=1`);return}let c=this.streamCounters.get(o);this.streamCounters.set(o,c+1),console.log(`[SocketManager] Stream counter increased: stream=${o}, count=${c+1}`)});let n=()=>{this.socket&&(this.socket.emit("subscribe",e),console.log(`[SocketManager] SUBSCRIBE: handlerId=${r}, options=`,e,`connected=${this.socket.connected}, streamCounters=`,Object.fromEntries(this.streamCounters)))};return n(),this.socket.connected||(this.socket.once("connect",n),console.log(`[SocketManager] SUBSCRIBE (also waiting for connect): handlerId=${r}, options=`,e)),this.socketPool[r]=e,r}setupReconnectHandler(){this.socket&&(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",()=>{Object.entries(this.socketPool).forEach(([e,t])=>{this.socket?.emit("subscribe",t),console.log(`[SocketManager] RECONNECT re-subscribe: handlerId=${e}, options=`,t)})}))}unsubscribe(e){this.callbacks.delete(e);let t=this.socketPool[e];if(!t){console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e} not found in socketPool`);return}let r=[];if(t.streams.forEach(n=>{let a=String(n);if(!this.streamCounters.has(a)){console.log(`[SocketManager] Stream counter not found: stream=${a}, skipping unsubscribe (no subscription was made)`);return}let o=this.streamCounters.get(a);if(o===1)this.streamCounters.set(a,0),r.push(n),console.log(`[SocketManager] Stream counter <= 1, will unsubscribe: stream=${a}, count=${o}`);else if(o>1){let c=o-1;this.streamCounters.set(a,c),console.log(`[SocketManager] Stream counter decreased (no unsubscribe): stream=${a}, count=${c}`)}}),r.length>0&&this.socket){let n={...t,streams:r};this.socket.emit("unsubscribe",n),console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e}, unsubscribeSentForStreams=[${r.join(", ")}], streamCounters=`,Object.fromEntries(this.streamCounters),`remainingSubscriptions=${Object.keys(this.socketPool).length}`)}else console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e}, no streams to unsubscribe (all counters > 1), streamCounters=`,Object.fromEntries(this.streamCounters),`remainingSubscriptions=${Object.keys(this.socketPool).length}`);delete this.socketPool[e],Object.keys(this.socketPool).length===0&&this.socket&&(console.log("[SocketManager] UNSUBSCRIBE: No more subscriptions, disconnecting socket"),this.disconnect())}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.streamCounters.clear(),this.callbacks.clear(),this.onAnyRegistered=!1,console.log("[SocketManager] DISCONNECT: All stream counters and callbacks cleared")}isConnected(){return this.socket!==null&&this.socket.connected}on(e,t){this.socket&&this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.off(e))}emit(e,...t){this.socket&&this.socket.emit(e,...t)}emitCurrentPair(e){this.emit("currentPair",e)}emitOrderFilter(e){this.emit("orderFilter",e)}onReconnect(e){return this.socket?(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",e),()=>{this.socket&&this.socket.io.off("reconnect",e)}):()=>{}}offReconnect(e){this.socket&&(e?this.socket.io.off("reconnect",e):this.socket.io.off("reconnect"))}};import Nt from"react-secure-storage";var Ut=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host,xe=i=>`${i}_${Ut}`,vt=new Proxy(Nt,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem"].includes(e)&&(r[0]=xe(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),J=new Proxy(localStorage,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem","key"].includes(e)&&(r[0]=xe(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),X=class{constructor(){this.keys={mainWallet:"main-wallet",tradingKey:"trading-key"};this.isBrowser=typeof window<"u",this.isBrowser||(this.clearMainWallet=()=>{},this.getMainWallet=()=>null,this.setMainWallet=()=>{})}setMainWallet(e){J.setItem(this.keys.mainWallet,JSON.stringify(e))}getMainWallet(){let e=J.getItem(this.keys.mainWallet);if(!e)return null;let t=JSON.parse(e),r=vt.getItem(`${this.keys.tradingKey}-${t.address}`);return r&&(r.expiredAt===0||Number(new Date(r.expiredAt))-Date.now()>1)&&(t.tradingKey=r.address),t}clearMainWallet(){J.removeItem(this.keys.mainWallet)}};var Ft=(t=>(t.YES="Y",t.NO="N",t))(Ft||{}),Gt=(d=>(d.MFT_AUDIO_LINK="mft.audioLink",d.MFT_TITLE="mft.title",d.VIEW_BASE_COIN_ICON_LINK="view.baseCoinIconLink",d.VIEW_BASE_COIN_MARKET_LINK="view.baseCoinMarketLink",d.VIEW_PRICE_COIN_ICON_LINK="view.priceCoinIconLink",d.VIEW_PRICE_COIN_MARKET_LINK="view.priceCoinMarketLink",d.MAKER_FEE="makerFee",d.TAKER_FEE="takerFee",d.MODE_PRE_SALE="mode.preSale",d))(Gt||{});var Ot=(n=>(n[n.OPEN_ORDER=1]="OPEN_ORDER",n[n.CANCELLED=2]="CANCELLED",n[n.MATCHED=3]="MATCHED",n[n.SELF_MATCHED=4]="SELF_MATCHED",n))(Ot||{}),Ct=(t=>(t.open="open",t.close="close",t))(Ct||{}),Lt=(a=>(a[a.Open=1]="Open",a[a.Canceled=2]="Canceled",a[a.Completed=3]="Completed",a[a.SelfMatch=4]="SelfMatch",a[a.Expired=5]="Expired",a))(Lt||{}),Vt=(t=>(t[t.open=1]="open",t[t.close=2]="close",t))(Vt||{}),Yt=(n=>(n[n.Limit=0]="Limit",n[n.IOC=1]="IOC",n[n.POST=2]="POST",n[n.Market=3]="Market",n))(Yt||{}),$t=(r=>(r[r.created=1]="created",r[r.partially_filled=2]="partially_filled",r[r.removed=3]="removed",r))($t||{}),Bt=(s=>(s.ALGORAND="Algorand",s.SOLANA="Solana",s["5IRECHAIN_THUNDER_TESTNET"]="5ireChain Thunder Testnet",s.ACALA="Acala",s.ALFAJORES="Alfajores",s.APOTHEM_NETWORK="Apothem Network",s.ARBITRUM_GOERLI="Arbitrum Goerli",s.ARBITRUM_NOVA="Arbitrum Nova",s.ARBITRUM_ONE="Arbitrum",s.ARBITRUM_SEPOLIA="Arbitrum Sepolia",s.ASTAR="Astar",s.ASTAR_ZKEVM_TESTNET_ZKATANA="Astar zkEVM Testnet zKatana",s.AURORA="Aurora",s.AURORA_TESTNET="Aurora Testnet",s.AVALANCHE="Avalanche",s.AVALANCHE_FUJI="Avalanche Fuji",s.BAHAMUT="Bahamut",s.BASE="Base",s.BASE_GOERLI="Base Goerli",s.BASE_SEPOLIA="Base Sepolia",s.BEAR_NETWORK_CHAIN_MAINNET="Bear Network Chain Mainnet",s.BEAR_NETWORK_CHAIN_TESTNET="Bear Network Chain Testnet",s.BERACHAIN_ARTIO="Berachain Artio",s.BERESHEET_BEREEVM_TESTNET="Beresheet BereEVM Testnet",s.BINANCE_SMART_CHAIN_TESTNET="BNB Chain Testnet",s.BITTORRENT="BitTorrent",s.BITTORRENT_CHAIN_TESTNET="BitTorrent Chain Testnet",s.BLACKFORT_EXCHANGE_NETWORK="BlackFort Exchange Network",s.BLACKFORT_EXCHANGE_NETWORK_TESTNET="BlackFort Exchange Network Testnet",s.BLAST_SEPOLIA="Blast Sepolia",s.BNB_SMART_CHAIN="BNB Chain",s.BOBA_NETWORK="Boba Network",s.BRONOS="Bronos",s.BRONOS_TESTNET="Bronos Testnet",s.CANTO="Canto",s.CELO="Celo",s.CHILIZ_CHAIN="Chiliz Chain",s.CHILIZ_SPICY_TESTNET="Chiliz Spicy Testnet",s.CONFLUX_ESPACE="Conflux eSpace",s.CONFLUX_ESPACE_TESTNET="Conflux eSpace Testnet",s.CORE_DAO="Core Dao",s.COSTON="Coston",s.COSTON2="Coston2",s.CRONOS_MAINNET="Cronos Mainnet",s.CRONOS_TESTNET="Cronos Testnet",s.CROSSBELL="Crossbell",s.DEFICHAIN_EVM_MAINNET="DeFiChain EVM Mainnet",s.DEFICHAIN_EVM_TESTNET="DeFiChain EVM Testnet",s.DFK_CHAIN="DFK Chain",s.DOGECHAIN="Dogechain",s.EDGEWARE_EDGEEVM_MAINNET="Edgeware EdgeEVM Mainnet",s.EKTA="Ekta",s.EKTA_TESTNET="Ekta Testnet",s.EOS_EVM="EOS EVM",s.EOS_EVM_TESTNET="EOS EVM Testnet",s.ETHEREUM="Ethereum",s.ETHEREUM_CLASSIC="Ethereum Classic",s.EVMOS="Evmos",s.EVMOS_TESTNET="Evmos Testnet",s.FANTOM="Fantom",s.FANTOM_SONIC_OPEN_TESTNET="Fantom Sonic Open Testnet",s.FANTOM_TESTNET="Fantom Testnet",s.FIBO_CHAIN="Fibo Chain",s.FILECOIN_CALIBRATION="Filecoin Calibration",s.FILECOIN_HYPERSPACE="Filecoin Hyperspace",s.FILECOIN_MAINNET="Filecoin Mainnet",s.FLARE_MAINNET="Flare Mainnet",s.FOUNDRY="Foundry",s.FUSE="Fuse",s.FUSE_SPARKNET="Fuse Sparknet",s.GNOSIS="Gnosis",s.GNOSIS_CHIADO="Gnosis Chiado",s.GOERLI="Goerli",s.HAQQ_MAINNET="HAQQ Mainnet",s.HAQQ_TESTEDGE_2="HAQQ Testedge 2",s.HARDHAT="Hardhat",s.HARMONY_ONE="Harmony One",s.HEDERA_MAINNET="Hedera Mainnet",s.HEDERA_PREVIEWNET="Hedera Previewnet",s.HEDERA_TESTNET="Hedera Testnet",s.HOLESKY="Holesky",s.HORIZEN_GOBI_TESTNET="Horizen Gobi Testnet",s.IOTEX="IoTeX",s.IOTEX_TESTNET="IoTeX Testnet",s.JIBCHAIN_L1="JIBCHAIN L1",s.KARURA="Karura",s.KAVA_EVM="Kava EVM",s.KAVA_EVM_TESTNET="Kava EVM Testnet",s.KCC_MAINNET="KCC Mainnet",s.KLAYTN="Klaytn",s.KLAYTN_BAOBAB_TESTNET="Klaytn Baobab Testnet",s.KROMA="Kroma",s.KROMA_SEPOLIA="Kroma Sepolia",s.LIGHTLINK_PEGASUS_TESTNET="LightLink Pegasus Testnet",s.LIGHTLINK_PHOENIX="LightLink Phoenix",s.LINEA_GOERLI_TESTNET="Linea Goerli Testnet",s.LINEA_MAINNET="Linea Mainnet",s.LOCALHOST="Localhost",s.LUKSO="LUKSO",s.MANDALA_TC9="Mandala TC9",s.MANTA_PACIFIC_MAINNET="Manta Pacific Mainnet",s.MANTA_PACIFIC_TESTNET="Manta Pacific Testnet",s.MANTLE="Mantle",s.MANTLE_TESTNET="Mantle Testnet",s.METACHAIN_MAINNET="MetaChain Mainnet",s.METER="Meter",s.METER_TESTNET="Meter Testnet",s.METIS="Metis",s.METIS_GOERLI="Metis Goerli",s.MEVERSE_CHAIN_MAINNET="MEVerse Chain Mainnet",s.MEVERSE_CHAIN_TESTNET="MEVerse Chain Testnet",s.MODE_TESTNET="Mode Testnet",s.MOONBASE_ALPHA="Moonbase Alpha",s.MOONBEAM="Moonbeam",s.MOONBEAM_DEVELOPMENT_NODE="Moonbeam Development Node",s.MOONRIVER="Moonriver",s.NEON_EVM_DEVNET="Neon EVM DevNet",s.NEON_EVM_MAINNET="Neon EVM MainNet",s.NEXI="Nexi",s.NEXILIX_SMART_CHAIN="Nexilix Smart Chain",s.OASIS_SAPPHIRE="Oasis Sapphire",s.OASIS_SAPPHIRE_TESTNET="Oasis Sapphire Testnet",s.OASIS_TESTNET="Oasis Testnet",s.OASYS="Oasys",s.OKC="OKC",s.OORT_MAINNETDEV="OORT MainnetDev",s.OPBNB="opBNB",s.OPBNB_TESTNET="opBNB Testnet",s.OPTIMISM_GOERLI="Optimism Goerli",s.OP_MAINNET="Optimism",s.OP_SEPOLIA="Optimism Sepolia",s.PALM="Palm",s.PALM_TESTNET="Palm Testnet",s.PGN="PGN",s.PGN_="PGN ",s.PLINGA="Plinga",s.POLYGON="Polygon",s.POLYGON_AMOY="Polygon Amoy",s.POLYGON_MUMBAI="Polygon Mumbai",s.POLYGON_ZKEVM="Polygon zkEVM",s.POLYGON_ZKEVM_TESTNET="Polygon zkEVM Testnet",s.PULSECHAIN="PulseChain",s.PULSECHAIN_V4="PulseChain V4",s.Q_MAINNET="Q Mainnet",s.Q_TESTNET="Q Testnet",s.ROLLUX_MAINNET="Rollux Mainnet",s.ROLLUX_TESTNET="Rollux Testnet",s.RONIN="Ronin",s.ROOTSTOCK_MAINNET="Rootstock Mainnet",s.SAIGON_TESTNET="Saigon Testnet",s.SCROLL="Scroll",s.SCROLL_SEPOLIA="Scroll Sepolia",s.SCROLL_TESTNET="Scroll Testnet",s.SEPOLIA="Ethereum Sepolia",s.SHARDEUM_SPHINX="Shardeum Sphinx",s.SHIBARIUM="Shibarium",s.SHIMMER="Shimmer",s.SHIMMER_TESTNET="Shimmer Testnet",s["SKALE_|_BLOCK_BRAWLERS"]="SKALE | Block Brawlers",s["SKALE_|_CALYPSO_NFT_HUB"]="SKALE | Calypso NFT Hub",s["SKALE_|_CALYPSO_NFT_HUB_TESTNET"]="SKALE | Calypso NFT Hub Testnet",s["SKALE_|_CHAOS_TESTNET"]="SKALE | Chaos Testnet",s["SKALE_|_CRYPTOBLADES"]="SKALE | CryptoBlades",s["SKALE_|_CRYPTO_COLOSSEUM"]="SKALE | Crypto Colosseum",s["SKALE_|_EUROPA_LIQUIDITY_HUB"]="SKALE | Europa Liquidity Hub",s["SKALE_|_EUROPA_LIQUIDITY_HUB_TESTNET"]="SKALE | Europa Liquidity Hub Testnet",s["SKALE_|_EXORDE"]="SKALE | Exorde",s["SKALE_|_HUMAN_PROTOCOL"]="SKALE | Human Protocol",s["SKALE_|_NEBULA_GAMING_HUB"]="SKALE | Nebula Gaming Hub",s["SKALE_|_NEBULA_GAMING_HUB_TESTNET"]="SKALE | Nebula Gaming Hub Testnet",s["SKALE_|_RAZOR_NETWORK"]="SKALE | Razor Network",s["SKALE_|_TITAN_COMMUNITY_HUB"]="SKALE | Titan Community Hub",s["SKALE_|_TITAN_COMMUNITY_HUB_TESTNET"]="SKALE | Titan Community Hub Testnet",s.SONGBIRD_MAINNET="Songbird Mainnet",s.SYSCOIN_MAINNET="Syscoin Mainnet",s.SYSCOIN_TANENBAUM_TESTNET="Syscoin Tanenbaum Testnet",s["TAIKO_(ALPHA-3_TESTNET)"]="Taiko (Alpha-3 Testnet)",s["TAIKO_JOLNIR_(ALPHA-5_TESTNET)"]="Taiko Jolnir (Alpha-5 Testnet)",s["TAIKO_KATLA_(ALPHA-6_TESTNET)"]="Taiko Katla (Alpha-6 Testnet)",s.TARAXA_MAINNET="Taraxa Mainnet",s.TARAXA_TESTNET="Taraxa Testnet",s.TELOS="Telos",s.TENET="Tenet",s.VECHAIN="Vechain",s.WANCHAIN="Wanchain",s.WANCHAIN_TESTNET="Wanchain Testnet",s.WEMIX="WEMIX",s.WEMIX_TESTNET="WEMIX Testnet",s.X1_TESTNET="X1 Testnet",s.XINFIN_NETWORK="XinFin Network",s.ZETACHAIN_ATHENS_TESTNET="ZetaChain Athens Testnet",s.ZHEJIANG="Zhejiang",s.ZILLIQA="Zilliqa",s.ZILLIQA_TESTNET="Zilliqa Testnet",s.ZKFAIR_MAINNET="ZKFair Mainnet",s.ZKFAIR_TESTNET="ZKFair Testnet",s.ZKSYNC_ERA="zkSync Era",s.ZKSYNC_ERA_TESTNET="zkSync Era Testnet",s.ZKSYNC_SEPOLIA_TESTNET="zkSync Sepolia Testnet",s.ZORA="Zora",s.ZORA_GOERLI_TESTNET="Zora Goerli Testnet",s.ZORA_SEPOLIA="Zora Sepolia",s))(Bt||{}),Xt=(m=>(m.Pending="pending",m.Completed="completed",m.Failed="failed",m.Received="received",m.Success="success",m.Failure="failure",m.Dropped="dropped",m.Replaced="replaced",m.Stuck="stuck",m.Confirmed="confirmed",m))(Xt||{}),qt=(a=>(a.USER_TO_TMC="user_to_tmc",a.TMC_TO_USER="tmc_to_user",a.RELAYER_TO_TMC="relayer_to_tmc",a.RELAYER_TO_CODEX="relayer_to_codex",a.RELAYER_TO_CIRCLE="relayer_to_circle",a))(qt||{}),Zt=(n=>(n.D="deposit",n.W="withdraw",n.F="fast_deposit",n.T="transfer",n))(Zt||{});var zt=(n=>(n.COMPANY="COMPANY",n.TWITTER="TWITTER",n.DISCORD="DISCORD",n.TELEGRAM="TELEGRAM",n))(zt||{});import{STREAMS as _e,PRIVATE_STREAMS as j}from"@ultrade/shared/browser/enums";var Qt=(r=>(r.OFF="disable",r.ULTRADE="ultrade",r.ALL="all",r))(Qt||{}),Jt=(f=>(f.ENABLED="company.enabled",f.APP_TITLE="company.appTitle",f.DOMAIN="company.domain",f.DIRECT_SETTLE="company.directSettlement",f.KYC="markets.kycTradeRequirementEnabled",f.GEOBLOCK="company.geoblock",f.LOGO="appearance.logo",f.THEMES="appearance.themes",f.NEW_TAB="appearance.newTab",f.TARGET="appearance.target",f.REPORT_BUTTONS="appearance.reportButtons",f.CUSTOM_MENU_ITEMS="appearance.customMenuItems",f.APPEARANCE_CHART_TYPE="appearance.chartType",f.APPEARANCE_CHART_INT="appearance.chartInt",f.AMM="product.amm",f.OBDEX="product.obdex",f.POINTS="product.pointSystem",f.AFFILIATE_DASHBOARD_THRESHOLD="product.affiliateDashboardThreshold",f.AFFILIATE_DEFAULT_FEE_SHARE="product.affiliateDefaultFeeShare",f.AFFILIATE_DASHBOARD_VISIBILITY="product.affiliateDashboardVisibility",f.AMM_FEE="company.ammFee",f.FEE_SHARE="company.feeShare",f.MIN_FEE="company.minFee",f.MAKER_FEE="company.makerFee",f.TAKER_FEE="company.takerFee",f.PINNED_PAIRS="markets.pinnedPairs",f.TWITTER_ENABLED="point-system.twitterEnabled",f.TWITTER_JOB_ENABLED="point-system.twitterJobEnabled",f.TWITTER_HASHTAGS="point-system.twitterHashtags",f.TWITTER_ACCOUNT_NAME="point-system.twitterAccountName",f.DISCORD_ENABLED="point-system.discordEnabled",f.TELEGRAM_ENABLED="point-system.telegramEnabled",f.TELEGRAM_GROUP_NAME="point-system.telegramGroupName",f.TELEGRAM_BOT_NAME="point-system.telegramBotName",f.GUIDE_LINK="point-system.guideLink",f))(Jt||{});var jt=(r=>(r.DISABLED="disabled",r.ENABLED_FOR_ALL="enabled for all",r.ENABLED_FOR_AFFILIATES="enabled for affiliates",r))(jt||{});import{decodeStateArray as Kt,getTxnParams as Ht}from"@ultrade/shared/browser/helpers/algo.helper";import v from"algosdk";import er from"axios";var F=class{constructor(e,t,r){this.client=e,this.authCredentials=t,this.indexerDomain=r}isAppOptedIn(e,t){return!!e?.find(r=>r.id===t)}isAssetOptedIn(e,t){return Object.keys(e).includes(t.toString())}async optInAsset(e,t){let r=await this.getTxnParams();return v.makeAssetTransferTxnWithSuggestedParamsFromObject({suggestedParams:{...r},from:e,to:e,assetIndex:t,amount:0})}async makeAppCallTransaction(e,t,r,n,a){let o=[],c=[],u=[e];return v.makeApplicationNoOpTxn(t,a||await this.getTxnParams(),r,n,o,c,u)}makeTransferTransaction(e,t,r,n,a){if(r<=0)return null;let o={suggestedParams:{...e},from:n,to:a,amount:r};return t===0?v.makePaymentTxnWithSuggestedParamsFromObject(o):(o.assetIndex=t,v.makeAssetTransferTxnWithSuggestedParamsFromObject(o))}get signer(){return this.authCredentials.signer}set signer(e){this.authCredentials.signer=e}async signAndSend(e){Array.isArray(e)||(e=[e]);let t=this.getCurrentAccount();if(t){let r=e.map(n=>n.signTxn(t.sk));return this.client.sendRawTransaction(r).do()}return this.authCredentials.signer.signAndSend(e)}async signAndSendData(e,t,r,n){let a=typeof e=="string"?e:JSON.stringify(e),o=typeof e=="string"?{message:a}:{...e},c=await t(a,n);return r({...o,signature:c})}async getTxnParams(){return await Ht(this.client)}getCurrentAccount(){return this.authCredentials.mnemonic?v.mnemonicToSecretKey(this.authCredentials.mnemonic):null}async getAccountInfo(e){return this.client.accountInformation(e).do()}constructArgsForAppCall(...e){let t=[];return e.forEach(r=>{t.push(new Uint8Array(r.toBuffer?r.toBuffer():l.from(r.toString())))}),t}validateCredentials(){if(!this.authCredentials.mnemonic&&!this.authCredentials.signer)throw"You need specify mnemonic or signer to execute the method"}async getAppState(e){try{let t=await this.client.getApplicationByID(e).do();return Kt(t.params["global-state"])}catch(t){console.log(`Attempt to load app by id ${e}`),console.log(t.message)}}async getSuperAppId(e){return(await this.getAppState(e))?.UL_SUPERADMIN_APP||0}async getPairBalances(e,t){let{data:r}=await er.get(`${this.indexerDomain}/v2/accounts/${t}?include-all=true`);if(r.account.hasOwnProperty("apps-local-state")){let n=r.account["apps-local-state"].find(c=>c.id===e&&c.deleted===!1);if(!n)return null;let a=n["key-value"].find(c=>c.key==="YWNjb3VudEluZm8="),o=l.from(a.value.bytes,"base64");return ye(o)}}async calculateTransferAmount(e,t,r,n,a,o){let c=await this.getPairBalances(e,t),u=(r==="B"?c?.priceCoin_available:c?.baseCoin_available)??0;r==="B"&&(n=n/10**o*a);let d=Math.ceil(n-u);return d<0?0:d}};import we,{encodeAddress as tr}from"algosdk";var rr={priceCoin_locked:{type:"uint"},priceCoin_available:{type:"uint"},baseCoin_locked:{type:"uint"},baseCoin_available:{type:"uint"},companyId:{type:"uint"},WLFeeShare:{type:"uint"},WLCustomFee:{type:"uint"},slotMap:{type:"uint"}},ye=i=>{let e=new Map,t=0;for(let[r,n]of Object.entries(rr)){if(t>=i.length)throw new Error("Array index out of bounds");let a;switch(n.type){case"address":a=tr(i.slice(t,t+32)),t+=32;break;case"bytes":a=i.slice(t,t+n.size),a=we.decodeUint64(a,"mixed"),t+=n.size;break;case"uint":a=we.decodeUint64(i.slice(t,t+8),"mixed"),t+=8;break;case"string":a=ir(i.slice(t,t+n.size)),t+=n.size;break}e.set(r,a)}return Object.fromEntries(e)},ir=i=>l.from(i).toString("utf-8");var Se="By signing this message you are logging into your trading account and agreeing to all terms and conditions of the platform.";var Pe={mainnet:{algodNode:"https://mainnet-api.algonode.cloud",apiUrl:"https://mainnet-api.algonode.cloud",algodIndexer:"https://mainnet-idx.algonode.cloud"},testnet:{algodNode:"https://testnet-api.algonode.cloud",apiUrl:"https://testnet-apigw.ultradedev.net",algodIndexer:"https://testnet-idx.algonode.cloud"},local:{algodNode:"http://localhost:4001",apiUrl:"http://localhost:5001",algodIndexer:"http://localhost:8980"}},K=["/market/balances","/market/order","/market/orders","/market/account/kyc/status","/market/account/kyc/init","/market/withdrawal-fee","/market/operation-details","/wallet/key","/wallet/transactions","/wallet/transfer","/wallet/withdraw","/wallet/whitelist","/wallet/withdrawal-wallets"];var Re=class{constructor(e,t){this.axiosInterceptor=e=>{let t=c=>c.withWalletCredentials||(c.url?K.some(u=>c.url.includes(u)):!1),r=c=>{let u=["/market/order"];return c.withWalletCredentials||(c.url?u.some(d=>c.url.includes(d)):!1)},n=c=>{let u=["/wallet/signin","/market/account/kyc/init","/notifications"];return c.url?u.some(d=>c.url.includes(d)):!1},a=c=>{let u=["/social/"];return c.url?u.some(d=>c.url.includes(d)):!1},o=c=>c.url?K.some(u=>c.url.includes(u)):!1;return e.interceptors.request.use(c=>{if(this.wallet&&t(c)&&(c.headers["X-Wallet-Address"]=this.wallet.address,c.headers["X-Wallet-Token"]=this.wallet.token),this.wallet&&o(c)&&(c.headers.CompanyId=this.companyId),this.wallet&&r(c)){let u=this.localStorageService.getMainWallet()?.tradingKey;u&&(c.headers["X-Trading-Key"]=u)}return n(c)&&(c.headers.CompanyId=this.companyId),a(c)&&!c.headers.CompanyId&&(c.headers.CompanyId=this.isUltradeID?1:this.companyId),c},c=>Promise.reject(c)),e.interceptors.response.use(c=>c.data,async c=>(console.log("Request was failed",c),[401].includes(c?.response?.status)&&c.config&&t(c.config)&&(this.wallet=null,this.localStorageService.clearMainWallet()),Promise.reject(c))),e};let r=Pe[e.network];this.algodNode=r.algodNode,this.apiUrl=r.apiUrl,this.algodIndexer=r.algodIndexer,e.apiUrl!==void 0&&(this.apiUrl=e.apiUrl),e.companyId!==void 0&&(this.companyId=e.companyId),this.websocketUrl=e.websocketUrl,this.client=new F(e.algoSdkClient,t||{},this.algodIndexer),this._axios=this.axiosInterceptor(ar.create({baseURL:this.apiUrl})),this.localStorageService=new X,this.wallet=this.localStorageService.getMainWallet(),this.isUltradeID=!1,this.socketManager=new U(this.websocketUrl,nr,n=>{console.log(`Socket ${n} disconnected at`,new Date)},n=>{console.log(`Socket connect_error due to ${n}`)}),console.log("SDK Wallet",this.wallet)}get useUltradeID(){return this.isUltradeID}set useUltradeID(e){this.isUltradeID=e}get isLogged(){return!!this.wallet?.token}get mainWallet(){return this.wallet}set mainWallet(e){this.wallet=e,e?this.localStorageService.setMainWallet(e):this.localStorageService.clearMainWallet()}setSigner(e){this.client.signer=e}subscribe(e,t){let r=e.streams.some(n=>n===_e.TRADES&&e.options?.address?!0:j.includes(n));return r&&!this.mainWallet?.token&&!this.mainWallet?.tradingKey?(e.streams=e.streams.filter(n=>!j.includes(n)),this.socketManager.subscribe(e,t)):r?(e.options={...e.options,token:this.mainWallet?.token,tradingKey:this.mainWallet?.tradingKey},this.socketManager.subscribe(e,t)):this.socketManager.subscribe(e,t)}unsubscribe(e){this.socketManager.unsubscribe(e)}getPairList(e){let t=e?`&companyId=${e}`:"";return this._axios.get(`/market/markets?includeAllOrders=false${t}`)}getPair(e){return this._axios.get(`/market/market?symbol=${e}`)}getPrice(e){return this._axios.get(`/market/price?symbol=${e}`)}getDepth(e,t){return this._axios.get(`/market/depth?symbol=${e}&depth=${t}`)}getSymbols(e){return this._axios.get(`/market/symbols${e?"?mask="+e:""}`)}getLastTrades(e){return this._axios.get(`/market/last-trades?symbol=${e}`)}getHistory(e,t,r,n,a=500,o=1){return this._axios.get(`/market/history?symbol=${e}&interval=${t}&startTime=${r??""}&endTime=${n??""}&limit=${a}&page=${o}`)}getOrders(e,t,r=50,n,a){let o=t?t===1?G.Open:[G.Canceled,G.Matched,G.SelfMatched,G.Expired].join(","):"",c=e?`&symbol=${e}`:"",u=o?`&status=${o}`:"",d=a?`&startTime=${a}`:"",m=n?`&endTime=${n}`:"";return this._axios.get(`/market/orders?limit=${r}${c}${u}${d}${m}`)}getOrderById(e){return this._axios.get(`/market/order/${e}`)}getSettings(){let e=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host;return this._axios.get("/market/settings",{headers:{"wl-domain":e}})}getBalances(){return this._axios.get("/market/balances")}getChains(){return this._axios.get("/market/chains")}getCodexAssets(){return this._axios.get("/market/assets")}getCCTPAssets(){return this._axios.get("/market/cctp-assets")}getCCTPUnifiedAssets(){return this._axios.get("/market/cctp-unified-assets")}getWithdrawalFee(e,t){return this._axios.get(`/market/withdrawal-fee?assetAddress=${e}&chainId=${t}`)}getKycStatus(){return this._axios.get("/market/account/kyc/status")}getKycInitLink(e){return this._axios.post("/market/account/kyc/init",{embeddedAppUrl:e})}getDollarValues(e=[]){return this._axios.get(`/market/dollar-price?assetIds=${JSON.stringify(e)}`)}getTransactionDetalis(e){return this._axios.get(`/market/operation-details?operationId=${e}`)}getWalletTransactions(e,t,r=100){return this._axios.get(`/wallet/transactions?type=${e}&limit=${r}&page=${t}`,{withWalletCredentials:!0})}getTradingKeys(){return this._axios.get("/wallet/keys",{withWalletCredentials:!0})}getTransfers(e,t=100){return this._axios.get(`/wallet/transfers?limit=${t}&page=${e}`,{withWalletCredentials:!0})}getPendingTransactions(){return this._axios.get("/wallet/transactions/pending",{withWalletCredentials:!0})}getWhitelist(){return this._axios.get("/wallet/whitelist",{withWalletCredentials:!0})}async addWhitelist(e){e={...e,expiredDate:e.expiredDate&&Math.round(e.expiredDate/1e3)};let r=l.from(gr(e)).toString("hex");return await this.client.signAndSendData(r,this.client.signer.signMessage,({signature:n})=>this._axios.post("/wallet/whitelist",{message:r,signature:n}),"hex")}deleteWhitelist(e){let t={whitelistId:e};return this.client.signAndSendData(t,this.client.signer.signMessage,({signature:r})=>this._axios.delete("/wallet/whitelist",{data:{data:t,signature:r}}))}getAllWithdrawalWallets(){return this._axios.get("/wallet/withdrawal-wallets")}getWithdrawalWalletByAddress(e){return this._axios.get(`/wallet/withdrawal-wallets/${e}`)}createWithdrawalWallet(e){return this._axios.post("/wallet/withdrawal-wallets",e)}updateWithdrawalWallet(e){return this._axios.patch("/wallet/withdrawal-wallets",e)}deleteWithdrawalWallet(e){return this._axios.delete(`/wallet/withdrawal-wallets/${e}`)}getVersion(){return this._axios.get("/system/version")}getMaintenance(){return this._axios.get("/system/maintenance")}getNotifications(){return this._axios.get("/notifications",{withWalletCredentials:!0})}getNotificationsUnreadCount(){return this._axios.get("/notifications/count",{withWalletCredentials:!0})}readNotifications(e){return this._axios.put("/notifications",{notifications:e},{withWalletCredentials:!0})}getAffiliatesStatus(e){return this._axios.get(`/affiliates/${e}/dashboardStatus`,{withWalletCredentials:!0})}createAffiliate(e){return this._axios.post(`/affiliates/${e}`,{},{withWalletCredentials:!0})}getAffiliateProgress(e){return this._axios.get(`/affiliates/${e}/tradingVolumeProgress`,{withWalletCredentials:!0})}getAffiliateInfo(e,t){return this._axios.get(`/affiliates/${e}/dashboard?range=${t}`,{withWalletCredentials:!0})}async countAffiliateDepost(e){await this._axios.post(`/affiliates/${e}/deposit`,{},{withWalletCredentials:!0})}async countAffiliateClick(e){await this._axios.post("/affiliates/click",{referralToken:e},{withWalletCredentials:!0})}getSocialAccount(){return this._axios.get("/social/account",{withWalletCredentials:!0})}async addSocialEmail(e,t){await this._axios.put("/social/account/email",{email:e,embeddedAppUrl:t},{withWalletCredentials:!0})}async verifySocialEmail(e,t){await this._axios.put("/social/account/verifyEmail",{email:e,hash:t},{withWalletCredentials:!0})}getLeaderboards(){return this._axios.get("/social/leaderboard",{withWalletCredentials:!0})}getUnlocks(){return this._axios.get("/social/unlocks",{withWalletCredentials:!0})}getSocialSettings(){return this._axios.get("/social/settings",{withWalletCredentials:!0})}getSeason(e){return this._axios.get("/social/seasons/active",{withWalletCredentials:!0,headers:{CompanyId:e}})}getPastSeasons(){return this._axios.get("/social/seasons/history",{withWalletCredentials:!0})}addTelegram(e){return this._axios.post("/social/telegram/connect",e,{withWalletCredentials:!0})}async disconnectTelegram(e){await this._axios.put("/social/telegram/disconnect",e,{withWalletCredentials:!0})}async getDiscordConnectionUrl(e){let t=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"";return(await this._axios.get(`/social/discord/connect${t}`,{withWalletCredentials:!0})).url}async disconnectDiscord(){await this._axios.put("/social/discord/disconnect",{},{withWalletCredentials:!0})}async getTwitterConnectionUrl(e,t){let r=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"",n=t?`&scopes=${t}`:"";return(await this._axios.get(`/social/twitter/connect${r}${n}`,{withWalletCredentials:!0})).url}async disconnectTwitter(){await this._axios.put("/social/twitter/disconnect",{},{withWalletCredentials:!0})}getTweets(){return this._axios.get("/social/twitter/tweets",{withWalletCredentials:!0})}async actionWithTweet(e){await this._axios.post("/social/twitter/tweet/actions",e,{withWalletCredentials:!0})}getActions(){return this._axios.get("/social/actions",{withWalletCredentials:!0})}getActionHistory(){return this._axios.get("/social/actions/history",{withWalletCredentials:!0})}getAIStyles(){return this._axios.get("/social/twitter/tweets/styles",{withWalletCredentials:!0})}getAIComment(e,t){return this._axios.get(`/social/twitter/tweets/${t}/generateComment?styleId=${e}`,{withWalletCredentials:!0})}getTechnologyByProvider(e){switch(e){case M.PERA:return"ALGORAND";case M.METAMASK:return"EVM";case M.SOLFLARE:case M.COINBASE:case M.PHANTOM:case M.BACKPACK:case M.MOBILE:return"SOLANA";default:throw new Error("Not implemented")}}async login({address:e,provider:t,chain:r,referralToken:n,loginMessage:a}){let c=a||Se,u={address:e,technology:this.getTechnologyByProvider(t)},d=l.from(cr(u,c)).toString("hex");return await this.client.signAndSendData(d,this.client.signer.signMessage,async({signature:m})=>{let p=await this._axios.put("/wallet/signin",{data:u,message:d,encoding:"hex",signature:m,referralToken:n});return this.mainWallet={address:e,provider:t,token:p,chain:r},p},"hex")}async addTradingKey(e){let r=l.from(ke(e,!0)).toString("hex"),{device:n,type:a}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>{let c=await this._axios.post("/wallet/key",{data:{device:n,type:a},encoding:"hex",message:r,signature:o});return this.mainWallet&&c.type===mr.User&&(this.mainWallet.tradingKey=c.address),c},"hex")}async revokeTradingKey(e){let r=l.from(ke(e,!1)).toString("hex"),{device:n,type:a}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>(await this._axios.delete("/wallet/key",{data:{data:{device:n,type:a},encoding:"hex",message:r,signature:o}}),this.mainWallet&&e.tkAddress===this.mainWallet.tradingKey&&(this.mainWallet.tradingKey=void 0),{signature:o}),"hex")}async withdraw(e,t){let n={...e,random:H(1,Number.MAX_SAFE_INTEGER)},a=l.from(dr(n,t)).toString("hex");return await this.client.signAndSendData(a,this.client.signer.signMessage,({signature:o})=>this._axios.post("/wallet/withdraw",{encoding:"hex",message:a,signature:o,destinationAddress:n.recipient}),"hex")}async transfer(e){let r={...e,random:H(1,Number.MAX_SAFE_INTEGER)},n=l.from(pr(r)).toString("hex");return await this.client.signAndSendData(n,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/transfer",{message:n,signature:a}),"hex")}async createSpotOrder(e){let t=sr*24*60*60,r=Math.floor(Date.now()/1e3)+t,n={...e,version:or,expiredTime:r,random:H(1,Number.MAX_SAFE_INTEGER)},a="hex",o=l.from(ur(n)).toString(a);return await this.client.signAndSendData(o,this.client.signer.signMessageByToken,({signature:c})=>this._axios.post("/market/order",{encoding:a,message:o,signature:c}),a)}async cancelOrder(e){let t={orderId:e.orderId},r="hex",n=l.from(lr(e)).toString(r);return await this.client.signAndSendData(n,this.client.signer.signMessageByToken,({signature:a})=>this._axios.delete("/market/order",{data:{data:t,message:n,signature:a}}),r)}async cancelMultipleOrders({orderIds:e,pairId:t}){let r={orderIds:e,pairId:t};return await this.client.signAndSendData(r,this.client.signer.signMessageByToken,({signature:n})=>this._axios.delete("/market/orders",{data:{data:r,signature:n}}))}async ping(){let e=await this._axios.get("/system/time");return Math.round(Date.now()-e.currentTime)}getSocketSubscribeOptions(e,t){let r=this?.companyId,n=this?.wallet?.address;return{symbol:t,streams:e,options:{companyId:r,address:n}}}};export{Zt as ACTION_TYPE,jt as AffDashboardVisibilitySettingEnum,Bt as BLOCKCHAINS,Re as Client,Se as DEFAULT_LOGIN_MESSAGE,Ft as DIRECT_SETTLE,Pe as NETWORK_CONFIGS,Ot as ORDER_STATUS,Xt as OperationStatusEnum,Vt as OrderExecution,Ct as OrderExecutionType,Lt as OrderStatus,Yt as OrderTypeEnum,$t as OrderUpdateStaus,Qt as POINTS_SETTING,j as PRIVATE_STREAMS,Gt as PairSettingsIds,zt as SOCIAL_ACTION_SOURCE,_e as STREAMS,Jt as SettingIds,U as SocketManager,qt as TransactionType,K as tokenizedUrls};
|
|
1
|
+
function te(){throw new Error("setTimeout has not been defined")}function re(){throw new Error("clearTimeout has not been defined")}var w=te,S=re;typeof globalThis.setTimeout=="function"&&(w=setTimeout);typeof globalThis.clearTimeout=="function"&&(S=clearTimeout);function ie(i){if(w===setTimeout)return setTimeout(i,0);if((w===te||!w)&&setTimeout)return w=setTimeout,setTimeout(i,0);try{return w(i,0)}catch{try{return w.call(null,i,0)}catch{return w.call(this,i,0)}}}function De(i){if(S===clearTimeout)return clearTimeout(i);if((S===re||!S)&&clearTimeout)return S=clearTimeout,clearTimeout(i);try{return S(i)}catch{try{return S.call(null,i)}catch{return S.call(this,i)}}}var _=[],N=!1,P,O=-1;function We(){!N||!P||(N=!1,P.length?_=P.concat(_):O=-1,_.length&&ne())}function ne(){if(!N){var i=ie(We);N=!0;for(var e=_.length;e;){for(P=_,_=[];++O<e;)P&&P[O].run();O=-1,e=_.length}P=null,N=!1,De(i)}}function Ne(i){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];_.push(new ae(i,e)),_.length===1&&!N&&ie(ne)}function ae(i,e){this.fun=i,this.array=e}ae.prototype.run=function(){this.fun.apply(null,this.array)};var Ue="browser",ve="browser",Fe=!0,Ge={},Oe=[],Ce="",Le={},Ve={},Ye={};function k(){}var $e=k,Be=k,Xe=k,qe=k,Ze=k,ze=k,Qe=k;function Je(i){throw new Error("process.binding is not supported")}function je(){return"/"}function Ke(i){throw new Error("process.chdir is not supported")}function He(){return 0}var W=globalThis.performance||{},et=W.now||W.mozNow||W.msNow||W.oNow||W.webkitNow||function(){return new Date().getTime()};function tt(i){var e=et.call(W)*.001,t=Math.floor(e),r=Math.floor(e%1*1e9);return i&&(t=t-i[0],r=r-i[1],r<0&&(t--,r+=1e9)),[t,r]}var rt=new Date;function it(){var i=new Date,e=i-rt;return e/1e3}var g={nextTick:Ne,title:Ue,browser:Fe,env:Ge,argv:Oe,version:Ce,versions:Le,on:$e,addListener:Be,once:Xe,off:qe,removeListener:Ze,removeAllListeners:ze,emit:Qe,binding:Je,cwd:je,chdir:Ke,umask:He,hrtime:tt,platform:ve,release:Ve,config:Ye,uptime:it},ee={};Object.keys(ee).forEach(i=>{let e=i.split("."),t=g;for(let r=0;r<e.length;r++){let n=e[r];r===e.length-1?t[n]=ee[i]:t=t[n]||(t[n]={})}});var A=[],b=[],nt=typeof Uint8Array<"u"?Uint8Array:Array,Z=!1;function ce(){Z=!0;for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=i.length;e<t;++e)A[e]=i[e],b[i.charCodeAt(e)]=e;b[45]=62,b[95]=63}function at(i){Z||ce();var e,t,r,n,a,o,c=i.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=i[c-2]==="="?2:i[c-1]==="="?1:0,o=new nt(c*3/4-a),r=a>0?c-4:c;var u=0;for(e=0,t=0;e<r;e+=4,t+=3)n=b[i.charCodeAt(e)]<<18|b[i.charCodeAt(e+1)]<<12|b[i.charCodeAt(e+2)]<<6|b[i.charCodeAt(e+3)],o[u++]=n>>16&255,o[u++]=n>>8&255,o[u++]=n&255;return a===2?(n=b[i.charCodeAt(e)]<<2|b[i.charCodeAt(e+1)]>>4,o[u++]=n&255):a===1&&(n=b[i.charCodeAt(e)]<<10|b[i.charCodeAt(e+1)]<<4|b[i.charCodeAt(e+2)]>>2,o[u++]=n>>8&255,o[u++]=n&255),o}function st(i){return A[i>>18&63]+A[i>>12&63]+A[i>>6&63]+A[i&63]}function ot(i,e,t){for(var r,n=[],a=e;a<t;a+=3)r=(i[a]<<16)+(i[a+1]<<8)+i[a+2],n.push(st(r));return n.join("")}function se(i){Z||ce();for(var e,t=i.length,r=t%3,n="",a=[],o=16383,c=0,u=t-r;c<u;c+=o)a.push(ot(i,c,c+o>u?u:c+o));return r===1?(e=i[t-1],n+=A[e>>2],n+=A[e<<4&63],n+="=="):r===2&&(e=(i[t-2]<<8)+i[t-1],n+=A[e>>10],n+=A[e>>4&63],n+=A[e<<2&63],n+="="),a.push(n),a.join("")}l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function C(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function y(i,e){if(C()<e)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(i=new Uint8Array(e),i.__proto__=l.prototype):(i===null&&(i=new l(e)),i.length=e),i}function l(i,e,t){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(i,e,t);if(typeof i=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return z(this,i)}return ue(this,i,e,t)}l.poolSize=8192;l._augment=function(i){return i.__proto__=l.prototype,i};function ue(i,e,t,r){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?ut(i,e,t,r):typeof e=="string"?ct(i,e,t):dt(i,e)}l.from=function(i,e,t){return ue(null,i,e,t)};l.kMaxLength=C();l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&l[Symbol.species]);function de(i){if(typeof i!="number")throw new TypeError('"size" argument must be a number');if(i<0)throw new RangeError('"size" argument must not be negative')}function lt(i,e,t,r){return de(e),e<=0?y(i,e):t!==void 0?typeof r=="string"?y(i,e).fill(t,r):y(i,e).fill(t):y(i,e)}l.alloc=function(i,e,t){return lt(null,i,e,t)};function z(i,e){if(de(e),i=y(i,e<0?0:Q(e)|0),!l.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)i[t]=0;return i}l.allocUnsafe=function(i){return z(null,i)};l.allocUnsafeSlow=function(i){return z(null,i)};function ct(i,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!l.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=me(e,t)|0;i=y(i,r);var n=i.write(e,t);return n!==r&&(i=i.slice(0,n)),i}function q(i,e){var t=e.length<0?0:Q(e.length)|0;i=y(i,t);for(var r=0;r<t;r+=1)i[r]=e[r]&255;return i}function ut(i,e,t,r){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(r||0))throw new RangeError("'length' is out of bounds");return t===void 0&&r===void 0?e=new Uint8Array(e):r===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,r),l.TYPED_ARRAY_SUPPORT?(i=e,i.__proto__=l.prototype):i=q(i,e),i}function dt(i,e){if(x(e)){var t=Q(e.length)|0;return i=y(i,t),i.length===0||e.copy(i,0,0,t),i}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||Mt(e.length)?y(i,0):q(i,e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(i,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Q(i){if(i>=C())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C().toString(16)+" bytes");return i|0}l.isBuffer=Dt;function x(i){return!!(i!=null&&i._isBuffer)}l.compare=function(e,t){if(!x(e)||!x(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,a=0,o=Math.min(r,n);a<o;++a)if(e[a]!==t[a]){r=e[a],n=t[a];break}return r<n?-1:n<r?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),a=0;for(r=0;r<e.length;++r){var o=e[r];if(!x(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,a),a+=o.length}return n};function me(i,e){if(x(i))return i.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(i)||i instanceof ArrayBuffer))return i.byteLength;typeof i!="string"&&(i=""+i);var t=i.length;if(t===0)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return L(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return be(i).length;default:if(r)return L(i).length;e=(""+e).toLowerCase(),r=!0}}l.byteLength=me;function mt(i,e,t){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return xt(this,e,t);case"utf8":case"utf-8":return fe(this,e,t);case"ascii":return It(this,e,t);case"latin1":case"binary":return At(this,e,t);case"base64":return Et(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _t(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),r=!0}}l.prototype._isBuffer=!0;function R(i,e,t){var r=i[e];i[e]=i[t],i[t]=r}l.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)R(this,t,t+1);return this};l.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)R(this,t,t+3),R(this,t+1,t+2);return this};l.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)R(this,t,t+7),R(this,t+1,t+6),R(this,t+2,t+5),R(this,t+3,t+4);return this};l.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?fe(this,0,e):mt.apply(this,arguments)};l.prototype.equals=function(e){if(!x(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.compare=function(e,t,r,n,a){if(!x(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),a===void 0&&(a=this.length),t<0||r>e.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&t>=r)return 0;if(n>=a)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,a>>>=0,this===e)return 0;for(var o=a-n,c=r-t,u=Math.min(o,c),d=this.slice(n,a),m=e.slice(t,r),p=0;p<u;++p)if(d[p]!==m[p]){o=d[p],c=m[p];break}return o<c?-1:c<o?1:0};function ge(i,e,t,r,n){if(i.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,r)),x(e))return e.length===0?-1:oe(i,e,t,r,n);if(typeof e=="number")return e=e&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):oe(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function oe(i,e,t,r,n){var a=1,o=i.length,c=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(i.length<2||e.length<2)return-1;a=2,o/=2,c/=2,t/=2}function u(E,D){return a===1?E[D]:E.readUInt16BE(D*a)}var d;if(n){var m=-1;for(d=t;d<o;d++)if(u(i,d)===u(e,m===-1?0:d-m)){if(m===-1&&(m=d),d-m+1===c)return m*a}else m!==-1&&(d-=d-m),m=-1}else for(t+c>o&&(t=o-c),d=t;d>=0;d--){for(var p=!0,I=0;I<c;I++)if(u(i,d+I)!==u(e,I)){p=!1;break}if(p)return d}return-1}l.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};l.prototype.indexOf=function(e,t,r){return ge(this,e,t,r,!0)};l.prototype.lastIndexOf=function(e,t,r){return ge(this,e,t,r,!1)};function gt(i,e,t,r){t=Number(t)||0;var n=i.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;var a=e.length;if(a%2!==0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o<r;++o){var c=parseInt(e.substr(o*2,2),16);if(isNaN(c))return o;i[t+o]=c}return o}function pt(i,e,t,r){return $(L(e,i.length-t),i,t,r)}function pe(i,e,t,r){return $(kt(e),i,t,r)}function ft(i,e,t,r){return pe(i,e,t,r)}function ht(i,e,t,r){return $(be(e),i,t,r)}function Tt(i,e,t,r){return $(Rt(e,i.length-t),i,t,r)}l.prototype.write=function(e,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(r)?(r=r|0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-t;if((r===void 0||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return gt(this,e,t,r);case"utf8":case"utf-8":return pt(this,e,t,r);case"ascii":return pe(this,e,t,r);case"latin1":case"binary":return ft(this,e,t,r);case"base64":return ht(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tt(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Et(i,e,t){return e===0&&t===i.length?se(i):se(i.slice(e,t))}function fe(i,e,t){t=Math.min(i.length,t);for(var r=[],n=e;n<t;){var a=i[n],o=null,c=a>239?4:a>223?3:a>191?2:1;if(n+c<=t){var u,d,m,p;switch(c){case 1:a<128&&(o=a);break;case 2:u=i[n+1],(u&192)===128&&(p=(a&31)<<6|u&63,p>127&&(o=p));break;case 3:u=i[n+1],d=i[n+2],(u&192)===128&&(d&192)===128&&(p=(a&15)<<12|(u&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:u=i[n+1],d=i[n+2],m=i[n+3],(u&192)===128&&(d&192)===128&&(m&192)===128&&(p=(a&15)<<18|(u&63)<<12|(d&63)<<6|m&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),n+=c}return bt(r)}var le=4096;function bt(i){var e=i.length;if(e<=le)return String.fromCharCode.apply(String,i);for(var t="",r=0;r<e;)t+=String.fromCharCode.apply(String,i.slice(r,r+=le));return t}function It(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]&127);return r}function At(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]);return r}function xt(i,e,t){var r=i.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);for(var n="",a=e;a<t;++a)n+=Pt(i[a]);return n}function _t(i,e,t){for(var r=i.slice(e,t),n="",a=0;a<r.length;a+=2)n+=String.fromCharCode(r[a]+r[a+1]*256);return n}l.prototype.slice=function(e,t){var r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);var n;if(l.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=l.prototype;else{var a=t-e;n=new l(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n};function h(i,e,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e],a=1,o=0;++o<t&&(a*=256);)n+=this[e+o]*a;return n};l.prototype.readUIntBE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e+--t],a=1;t>0&&(a*=256);)n+=this[e+--t]*a;return n};l.prototype.readUInt8=function(e,t){return t||h(e,1,this.length),this[e]};l.prototype.readUInt16LE=function(e,t){return t||h(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUInt16BE=function(e,t){return t||h(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUInt32LE=function(e,t){return t||h(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUInt32BE=function(e,t){return t||h(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readIntLE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=this[e],a=1,o=0;++o<t&&(a*=256);)n+=this[e+o]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*t)),n};l.prototype.readIntBE=function(e,t,r){e=e|0,t=t|0,r||h(e,t,this.length);for(var n=t,a=1,o=this[e+--n];n>0&&(a*=256);)o+=this[e+--n]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*t)),o};l.prototype.readInt8=function(e,t){return t||h(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){t||h(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};l.prototype.readInt16BE=function(e,t){t||h(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};l.prototype.readInt32LE=function(e,t){return t||h(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return t||h(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readFloatLE=function(e,t){return t||h(e,4,this.length),B(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return t||h(e,4,this.length),B(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return t||h(e,8,this.length),B(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return t||h(e,8,this.length),B(this,e,!1,52,8)};function T(i,e,t,r,n,a){if(!x(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<a)throw new RangeError('"value" argument is out of bounds');if(t+r>i.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var a=Math.pow(2,8*r)-1;T(this,e,t,r,a,0)}var o=1,c=0;for(this[t]=e&255;++c<r&&(o*=256);)this[t+c]=e/o&255;return t+r};l.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var a=Math.pow(2,8*r)-1;T(this,e,t,r,a,0)}var o=r-1,c=1;for(this[t+o]=e&255;--o>=0&&(c*=256);)this[t+o]=e/c&255;return t+r};l.prototype.writeUInt8=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function V(i,e,t,r){e<0&&(e=65535+e+1);for(var n=0,a=Math.min(i.length-t,2);n<a;++n)i[t+n]=(e&255<<8*(r?n:1-n))>>>(r?n:1-n)*8}l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):V(this,e,t,!0),t+2};l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):V(this,e,t,!1),t+2};function Y(i,e,t,r){e<0&&(e=4294967295+e+1);for(var n=0,a=Math.min(i.length-t,4);n<a;++n)i[t+n]=e>>>(r?n:3-n)*8&255}l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Y(this,e,t,!0),t+4};l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Y(this,e,t,!1),t+4};l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t|0,!n){var a=Math.pow(2,8*r-1);T(this,e,t,r,a-1,-a)}var o=0,c=1,u=0;for(this[t]=e&255;++o<r&&(c*=256);)e<0&&u===0&&this[t+o-1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t|0,!n){var a=Math.pow(2,8*r-1);T(this,e,t,r,a-1,-a)}var o=r-1,c=1,u=0;for(this[t+o]=e&255;--o>=0&&(c*=256);)e<0&&u===0&&this[t+o+1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeInt8=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):V(this,e,t,!0),t+2};l.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):V(this,e,t,!1),t+2};l.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Y(this,e,t,!0),t+4};l.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t|0,r||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Y(this,e,t,!1),t+4};function he(i,e,t,r,n,a){if(t+r>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Te(i,e,t,r,n){return n||he(i,e,t,4,34028234663852886e22,-34028234663852886e22),Ae(i,e,t,r,23,4),t+4}l.prototype.writeFloatLE=function(e,t,r){return Te(this,e,t,!0,r)};l.prototype.writeFloatBE=function(e,t,r){return Te(this,e,t,!1,r)};function Ee(i,e,t,r,n){return n||he(i,e,t,8,17976931348623157e292,-17976931348623157e292),Ae(i,e,t,r,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,r){return Ee(this,e,t,!0,r)};l.prototype.writeDoubleBE=function(e,t,r){return Ee(this,e,t,!1,r)};l.prototype.copy=function(e,t,r,n){if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var a=n-r,o;if(this===e&&r<t&&t<n)for(o=a-1;o>=0;--o)e[o+t]=this[o+r];else if(a<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a};l.prototype.fill=function(e,t,r,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),e.length===1){var a=e.charCodeAt(0);a<256&&(e=a)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<r;++o)this[o]=e;else{var c=x(e)?e:L(new l(e,n).toString()),u=c.length;for(o=0;o<r-t;++o)this[o+t]=c[o%u]}return this};var yt=/[^+\/0-9A-Za-z-_]/g;function wt(i){if(i=St(i).replace(yt,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function St(i){return i.trim?i.trim():i.replace(/^\s+|\s+$/g,"")}function Pt(i){return i<16?"0"+i.toString(16):i.toString(16)}function L(i,e){e=e||1/0;for(var t,r=i.length,n=null,a=[],o=0;o<r;++o){if(t=i.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(e-=3)>-1&&a.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&a.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&a.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;a.push(t)}else if(t<2048){if((e-=2)<0)break;a.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;a.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;a.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return a}function kt(i){for(var e=[],t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function Rt(i,e){for(var t,r,n,a=[],o=0;o<i.length&&!((e-=2)<0);++o)t=i.charCodeAt(o),r=t>>8,n=t%256,a.push(n),a.push(r);return a}function be(i){return at(wt(i))}function $(i,e,t,r){for(var n=0;n<r&&!(n+t>=e.length||n>=i.length);++n)e[n+t]=i[n];return n}function Mt(i){return i!==i}function Dt(i){return i!=null&&(!!i._isBuffer||Ie(i)||Wt(i))}function Ie(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function Wt(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&Ie(i.slice(0,0))}function B(i,e,t,r,n){var a,o,c=n*8-r-1,u=(1<<c)-1,d=u>>1,m=-7,p=t?n-1:0,I=t?-1:1,E=i[e+p];for(p+=I,a=E&(1<<-m)-1,E>>=-m,m+=c;m>0;a=a*256+i[e+p],p+=I,m-=8);for(o=a&(1<<-m)-1,a>>=-m,m+=r;m>0;o=o*256+i[e+p],p+=I,m-=8);if(a===0)a=1-d;else{if(a===u)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,r),a=a-d}return(E?-1:1)*o*Math.pow(2,a-r)}function Ae(i,e,t,r,n,a){var o,c,u,d=a*8-n-1,m=(1<<d)-1,p=m>>1,I=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=r?0:a-1,D=r?1:-1,Me=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+p>=1?e+=I/u:e+=I*Math.pow(2,1-p),e*u>=2&&(o++,u/=2),o+p>=m?(c=0,o=m):o+p>=1?(c=(e*u-1)*Math.pow(2,n),o=o+p):(c=e*Math.pow(2,p-1)*Math.pow(2,n),o=0));n>=8;i[t+E]=c&255,E+=D,c/=256,n-=8);for(o=o<<n|c,d+=n;d>0;i[t+E]=o&255,E+=D,o/=256,d-=8);i[t+E-D]|=Me*128}import{io as nr}from"socket.io-client";import ar from"axios";import{DEFAULT_ORDER_EXPIRATION_DAYS as sr,ORDER_MSG_VERSION as or}from"@ultrade/shared/browser/constants";import{getRandomInt as H}from"@ultrade/shared/browser/common";import{getCancelOrderDataJsonBytes as lr,makeLoginMsg as cr,makeTradingKeyMsg as ke,makeCreateOrderMsg as ur}from"@ultrade/shared/browser/helpers/codex.helper";import{makeWithdrawMsg as dr}from"@ultrade/shared/browser/helpers/withdraw.helper";import{TradingKeyType as mr}from"@ultrade/shared/browser/interfaces";import{PROVIDERS as M}from"@ultrade/shared/browser/interfaces";import{OrderStatus as G}from"@ultrade/shared/browser/enums";import{makeDtwMsg as gr,makeTransferMsg as pr}from"@ultrade/shared/browser/helpers/codex";var U=class{constructor(e,t,r,n){this.onDisconnect=r;this.onConnectError=n;this.socket=null;this.socketPool={};this.streamCounters=new Map;this.callbacks=new Map;this.onAnyRegistered=!1;this.handlerIdCounter=0;this.websocketUrl=e,this.socketIOFactory=t,this.initializeSocket()}initializeSocket(){this.socket===null&&(this.socket=this.socketIOFactory(this.websocketUrl,{reconnection:!0,reconnectionDelay:1e3,reconnectionAttempts:9999,transports:["websocket"]}),this.onDisconnect&&this.socket.on("disconnect",()=>{this.onDisconnect(this.socket.id)}),this.onConnectError&&this.socket.on("connect_error",e=>{this.onConnectError(e)}),this.setupReconnectHandler())}getSocket(){return this.socket}subscribe(e,t){let r=Date.now()+ ++this.handlerIdCounter;this.socket===null&&this.initializeSocket(),this.callbacks.set(r,t),this.onAnyRegistered||(this.socket.onAny((a,...o)=>{this.callbacks.forEach(c=>{c(a,o)})}),this.onAnyRegistered=!0),e.streams.forEach(a=>{let o=String(a);if(!this.streamCounters.has(o)){this.streamCounters.set(o,1),console.log(`[SocketManager] Stream counter created: stream=${o}, count=1`);return}let c=this.streamCounters.get(o);this.streamCounters.set(o,c+1),console.log(`[SocketManager] Stream counter increased: stream=${o}, count=${c+1}`)});let n=()=>{this.socket&&(this.socket.emit("subscribe",e),console.log(`[SocketManager] SUBSCRIBE: handlerId=${r}, options=`,e,`connected=${this.socket.connected}, streamCounters=`,Object.fromEntries(this.streamCounters)))};return n(),this.socket.connected||(this.socket.once("connect",n),console.log(`[SocketManager] SUBSCRIBE (also waiting for connect): handlerId=${r}, options=`,e)),this.socketPool[r]=e,r}setupReconnectHandler(){this.socket&&(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",()=>{Object.entries(this.socketPool).forEach(([e,t])=>{this.socket?.emit("subscribe",t),console.log(`[SocketManager] RECONNECT re-subscribe: handlerId=${e}, options=`,t)})}))}unsubscribe(e){this.callbacks.delete(e);let t=this.socketPool[e];if(!t){console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e} not found in socketPool`);return}let r=[];if(t.streams.forEach(n=>{let a=String(n);if(!this.streamCounters.has(a)){console.log(`[SocketManager] Stream counter not found: stream=${a}, skipping unsubscribe (no subscription was made)`);return}let o=this.streamCounters.get(a);if(o===1)this.streamCounters.set(a,0),r.push(n),console.log(`[SocketManager] Stream counter <= 1, will unsubscribe: stream=${a}, count=${o}`);else if(o>1){let c=o-1;this.streamCounters.set(a,c),console.log(`[SocketManager] Stream counter decreased (no unsubscribe): stream=${a}, count=${c}`)}}),r.length>0&&this.socket){let n={...t,streams:r};this.socket.emit("unsubscribe",n),console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e}, unsubscribeSentForStreams=[${r.join(", ")}], streamCounters=`,Object.fromEntries(this.streamCounters),`remainingSubscriptions=${Object.keys(this.socketPool).length}`)}else console.log(`[SocketManager] UNSUBSCRIBE: handlerId=${e}, no streams to unsubscribe (all counters > 1), streamCounters=`,Object.fromEntries(this.streamCounters),`remainingSubscriptions=${Object.keys(this.socketPool).length}`);delete this.socketPool[e],Object.keys(this.socketPool).length===0&&this.socket&&(console.log("[SocketManager] UNSUBSCRIBE: No more subscriptions, disconnecting socket"),this.disconnect())}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.streamCounters.clear(),this.callbacks.clear(),this.onAnyRegistered=!1,console.log("[SocketManager] DISCONNECT: All stream counters and callbacks cleared")}isConnected(){return this.socket!==null&&this.socket.connected}on(e,t){this.socket&&this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.off(e))}emit(e,...t){this.socket&&this.socket.emit(e,...t)}emitCurrentPair(e){this.emit("currentPair",e)}emitOrderFilter(e){this.emit("orderFilter",e)}onReconnect(e){return this.socket?(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",e),()=>{this.socket&&this.socket.io.off("reconnect",e)}):()=>{}}offReconnect(e){this.socket&&(e?this.socket.io.off("reconnect",e):this.socket.io.off("reconnect"))}};import Nt from"react-secure-storage";var Ut=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host,xe=i=>`${i}_${Ut}`,vt=new Proxy(Nt,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem"].includes(e)&&(r[0]=xe(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),J=new Proxy(localStorage,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem","key"].includes(e)&&(r[0]=xe(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),X=class{constructor(){this.keys={mainWallet:"main-wallet",tradingKey:"trading-key"};this.isBrowser=typeof window<"u",this.isBrowser||(this.clearMainWallet=()=>{},this.getMainWallet=()=>null,this.setMainWallet=()=>{})}setMainWallet(e){J.setItem(this.keys.mainWallet,JSON.stringify(e))}getMainWallet(){let e=J.getItem(this.keys.mainWallet);if(!e)return null;let t=JSON.parse(e),r=vt.getItem(`${this.keys.tradingKey}-${t.address}`);return r&&(r.expiredAt===0||Number(new Date(r.expiredAt))-Date.now()>1)&&(t.tradingKey=r.address),t}clearMainWallet(){J.removeItem(this.keys.mainWallet)}};var Ft=(t=>(t.YES="Y",t.NO="N",t))(Ft||{}),Gt=(d=>(d.MFT_AUDIO_LINK="mft.audioLink",d.MFT_TITLE="mft.title",d.VIEW_BASE_COIN_ICON_LINK="view.baseCoinIconLink",d.VIEW_BASE_COIN_MARKET_LINK="view.baseCoinMarketLink",d.VIEW_PRICE_COIN_ICON_LINK="view.priceCoinIconLink",d.VIEW_PRICE_COIN_MARKET_LINK="view.priceCoinMarketLink",d.MAKER_FEE="makerFee",d.TAKER_FEE="takerFee",d.MODE_PRE_SALE="mode.preSale",d))(Gt||{});var Ot=(n=>(n[n.OPEN_ORDER=1]="OPEN_ORDER",n[n.CANCELLED=2]="CANCELLED",n[n.MATCHED=3]="MATCHED",n[n.SELF_MATCHED=4]="SELF_MATCHED",n))(Ot||{}),Ct=(t=>(t.open="open",t.close="close",t))(Ct||{}),Lt=(a=>(a[a.Open=1]="Open",a[a.Canceled=2]="Canceled",a[a.Completed=3]="Completed",a[a.SelfMatch=4]="SelfMatch",a[a.Expired=5]="Expired",a))(Lt||{}),Vt=(t=>(t[t.open=1]="open",t[t.close=2]="close",t))(Vt||{}),Yt=(n=>(n[n.Limit=0]="Limit",n[n.IOC=1]="IOC",n[n.POST=2]="POST",n[n.Market=3]="Market",n))(Yt||{}),$t=(r=>(r[r.created=1]="created",r[r.partially_filled=2]="partially_filled",r[r.removed=3]="removed",r))($t||{}),Bt=(s=>(s.ALGORAND="Algorand",s.SOLANA="Solana",s["5IRECHAIN_THUNDER_TESTNET"]="5ireChain Thunder Testnet",s.ACALA="Acala",s.ALFAJORES="Alfajores",s.APOTHEM_NETWORK="Apothem Network",s.ARBITRUM_GOERLI="Arbitrum Goerli",s.ARBITRUM_NOVA="Arbitrum Nova",s.ARBITRUM_ONE="Arbitrum",s.ARBITRUM_SEPOLIA="Arbitrum Sepolia",s.ASTAR="Astar",s.ASTAR_ZKEVM_TESTNET_ZKATANA="Astar zkEVM Testnet zKatana",s.AURORA="Aurora",s.AURORA_TESTNET="Aurora Testnet",s.AVALANCHE="Avalanche",s.AVALANCHE_FUJI="Avalanche Fuji",s.BAHAMUT="Bahamut",s.BASE="Base",s.BASE_GOERLI="Base Goerli",s.BASE_SEPOLIA="Base Sepolia",s.BEAR_NETWORK_CHAIN_MAINNET="Bear Network Chain Mainnet",s.BEAR_NETWORK_CHAIN_TESTNET="Bear Network Chain Testnet",s.BERACHAIN_ARTIO="Berachain Artio",s.BERESHEET_BEREEVM_TESTNET="Beresheet BereEVM Testnet",s.BINANCE_SMART_CHAIN_TESTNET="BNB Chain Testnet",s.BITTORRENT="BitTorrent",s.BITTORRENT_CHAIN_TESTNET="BitTorrent Chain Testnet",s.BLACKFORT_EXCHANGE_NETWORK="BlackFort Exchange Network",s.BLACKFORT_EXCHANGE_NETWORK_TESTNET="BlackFort Exchange Network Testnet",s.BLAST_SEPOLIA="Blast Sepolia",s.BNB_SMART_CHAIN="BNB Chain",s.BOBA_NETWORK="Boba Network",s.BRONOS="Bronos",s.BRONOS_TESTNET="Bronos Testnet",s.CANTO="Canto",s.CELO="Celo",s.CHILIZ_CHAIN="Chiliz Chain",s.CHILIZ_SPICY_TESTNET="Chiliz Spicy Testnet",s.CONFLUX_ESPACE="Conflux eSpace",s.CONFLUX_ESPACE_TESTNET="Conflux eSpace Testnet",s.CORE_DAO="Core Dao",s.COSTON="Coston",s.COSTON2="Coston2",s.CRONOS_MAINNET="Cronos Mainnet",s.CRONOS_TESTNET="Cronos Testnet",s.CROSSBELL="Crossbell",s.DEFICHAIN_EVM_MAINNET="DeFiChain EVM Mainnet",s.DEFICHAIN_EVM_TESTNET="DeFiChain EVM Testnet",s.DFK_CHAIN="DFK Chain",s.DOGECHAIN="Dogechain",s.EDGEWARE_EDGEEVM_MAINNET="Edgeware EdgeEVM Mainnet",s.EKTA="Ekta",s.EKTA_TESTNET="Ekta Testnet",s.EOS_EVM="EOS EVM",s.EOS_EVM_TESTNET="EOS EVM Testnet",s.ETHEREUM="Ethereum",s.ETHEREUM_CLASSIC="Ethereum Classic",s.EVMOS="Evmos",s.EVMOS_TESTNET="Evmos Testnet",s.FANTOM="Fantom",s.FANTOM_SONIC_OPEN_TESTNET="Fantom Sonic Open Testnet",s.FANTOM_TESTNET="Fantom Testnet",s.FIBO_CHAIN="Fibo Chain",s.FILECOIN_CALIBRATION="Filecoin Calibration",s.FILECOIN_HYPERSPACE="Filecoin Hyperspace",s.FILECOIN_MAINNET="Filecoin Mainnet",s.FLARE_MAINNET="Flare Mainnet",s.FOUNDRY="Foundry",s.FUSE="Fuse",s.FUSE_SPARKNET="Fuse Sparknet",s.GNOSIS="Gnosis",s.GNOSIS_CHIADO="Gnosis Chiado",s.GOERLI="Goerli",s.HAQQ_MAINNET="HAQQ Mainnet",s.HAQQ_TESTEDGE_2="HAQQ Testedge 2",s.HARDHAT="Hardhat",s.HARMONY_ONE="Harmony One",s.HEDERA_MAINNET="Hedera Mainnet",s.HEDERA_PREVIEWNET="Hedera Previewnet",s.HEDERA_TESTNET="Hedera Testnet",s.HOLESKY="Holesky",s.HORIZEN_GOBI_TESTNET="Horizen Gobi Testnet",s.IOTEX="IoTeX",s.IOTEX_TESTNET="IoTeX Testnet",s.JIBCHAIN_L1="JIBCHAIN L1",s.KARURA="Karura",s.KAVA_EVM="Kava EVM",s.KAVA_EVM_TESTNET="Kava EVM Testnet",s.KCC_MAINNET="KCC Mainnet",s.KLAYTN="Klaytn",s.KLAYTN_BAOBAB_TESTNET="Klaytn Baobab Testnet",s.KROMA="Kroma",s.KROMA_SEPOLIA="Kroma Sepolia",s.LIGHTLINK_PEGASUS_TESTNET="LightLink Pegasus Testnet",s.LIGHTLINK_PHOENIX="LightLink Phoenix",s.LINEA_GOERLI_TESTNET="Linea Goerli Testnet",s.LINEA_MAINNET="Linea Mainnet",s.LOCALHOST="Localhost",s.LUKSO="LUKSO",s.MANDALA_TC9="Mandala TC9",s.MANTA_PACIFIC_MAINNET="Manta Pacific Mainnet",s.MANTA_PACIFIC_TESTNET="Manta Pacific Testnet",s.MANTLE="Mantle",s.MANTLE_TESTNET="Mantle Testnet",s.METACHAIN_MAINNET="MetaChain Mainnet",s.METER="Meter",s.METER_TESTNET="Meter Testnet",s.METIS="Metis",s.METIS_GOERLI="Metis Goerli",s.MEVERSE_CHAIN_MAINNET="MEVerse Chain Mainnet",s.MEVERSE_CHAIN_TESTNET="MEVerse Chain Testnet",s.MODE_TESTNET="Mode Testnet",s.MOONBASE_ALPHA="Moonbase Alpha",s.MOONBEAM="Moonbeam",s.MOONBEAM_DEVELOPMENT_NODE="Moonbeam Development Node",s.MOONRIVER="Moonriver",s.NEON_EVM_DEVNET="Neon EVM DevNet",s.NEON_EVM_MAINNET="Neon EVM MainNet",s.NEXI="Nexi",s.NEXILIX_SMART_CHAIN="Nexilix Smart Chain",s.OASIS_SAPPHIRE="Oasis Sapphire",s.OASIS_SAPPHIRE_TESTNET="Oasis Sapphire Testnet",s.OASIS_TESTNET="Oasis Testnet",s.OASYS="Oasys",s.OKC="OKC",s.OORT_MAINNETDEV="OORT MainnetDev",s.OPBNB="opBNB",s.OPBNB_TESTNET="opBNB Testnet",s.OPTIMISM_GOERLI="Optimism Goerli",s.OP_MAINNET="Optimism",s.OP_SEPOLIA="Optimism Sepolia",s.PALM="Palm",s.PALM_TESTNET="Palm Testnet",s.PGN="PGN",s.PGN_="PGN ",s.PLINGA="Plinga",s.POLYGON="Polygon",s.POLYGON_AMOY="Polygon Amoy",s.POLYGON_MUMBAI="Polygon Mumbai",s.POLYGON_ZKEVM="Polygon zkEVM",s.POLYGON_ZKEVM_TESTNET="Polygon zkEVM Testnet",s.PULSECHAIN="PulseChain",s.PULSECHAIN_V4="PulseChain V4",s.Q_MAINNET="Q Mainnet",s.Q_TESTNET="Q Testnet",s.ROLLUX_MAINNET="Rollux Mainnet",s.ROLLUX_TESTNET="Rollux Testnet",s.RONIN="Ronin",s.ROOTSTOCK_MAINNET="Rootstock Mainnet",s.SAIGON_TESTNET="Saigon Testnet",s.SCROLL="Scroll",s.SCROLL_SEPOLIA="Scroll Sepolia",s.SCROLL_TESTNET="Scroll Testnet",s.SEPOLIA="Ethereum Sepolia",s.SHARDEUM_SPHINX="Shardeum Sphinx",s.SHIBARIUM="Shibarium",s.SHIMMER="Shimmer",s.SHIMMER_TESTNET="Shimmer Testnet",s["SKALE_|_BLOCK_BRAWLERS"]="SKALE | Block Brawlers",s["SKALE_|_CALYPSO_NFT_HUB"]="SKALE | Calypso NFT Hub",s["SKALE_|_CALYPSO_NFT_HUB_TESTNET"]="SKALE | Calypso NFT Hub Testnet",s["SKALE_|_CHAOS_TESTNET"]="SKALE | Chaos Testnet",s["SKALE_|_CRYPTOBLADES"]="SKALE | CryptoBlades",s["SKALE_|_CRYPTO_COLOSSEUM"]="SKALE | Crypto Colosseum",s["SKALE_|_EUROPA_LIQUIDITY_HUB"]="SKALE | Europa Liquidity Hub",s["SKALE_|_EUROPA_LIQUIDITY_HUB_TESTNET"]="SKALE | Europa Liquidity Hub Testnet",s["SKALE_|_EXORDE"]="SKALE | Exorde",s["SKALE_|_HUMAN_PROTOCOL"]="SKALE | Human Protocol",s["SKALE_|_NEBULA_GAMING_HUB"]="SKALE | Nebula Gaming Hub",s["SKALE_|_NEBULA_GAMING_HUB_TESTNET"]="SKALE | Nebula Gaming Hub Testnet",s["SKALE_|_RAZOR_NETWORK"]="SKALE | Razor Network",s["SKALE_|_TITAN_COMMUNITY_HUB"]="SKALE | Titan Community Hub",s["SKALE_|_TITAN_COMMUNITY_HUB_TESTNET"]="SKALE | Titan Community Hub Testnet",s.SONGBIRD_MAINNET="Songbird Mainnet",s.SYSCOIN_MAINNET="Syscoin Mainnet",s.SYSCOIN_TANENBAUM_TESTNET="Syscoin Tanenbaum Testnet",s["TAIKO_(ALPHA-3_TESTNET)"]="Taiko (Alpha-3 Testnet)",s["TAIKO_JOLNIR_(ALPHA-5_TESTNET)"]="Taiko Jolnir (Alpha-5 Testnet)",s["TAIKO_KATLA_(ALPHA-6_TESTNET)"]="Taiko Katla (Alpha-6 Testnet)",s.TARAXA_MAINNET="Taraxa Mainnet",s.TARAXA_TESTNET="Taraxa Testnet",s.TELOS="Telos",s.TENET="Tenet",s.VECHAIN="Vechain",s.WANCHAIN="Wanchain",s.WANCHAIN_TESTNET="Wanchain Testnet",s.WEMIX="WEMIX",s.WEMIX_TESTNET="WEMIX Testnet",s.X1_TESTNET="X1 Testnet",s.XINFIN_NETWORK="XinFin Network",s.ZETACHAIN_ATHENS_TESTNET="ZetaChain Athens Testnet",s.ZHEJIANG="Zhejiang",s.ZILLIQA="Zilliqa",s.ZILLIQA_TESTNET="Zilliqa Testnet",s.ZKFAIR_MAINNET="ZKFair Mainnet",s.ZKFAIR_TESTNET="ZKFair Testnet",s.ZKSYNC_ERA="zkSync Era",s.ZKSYNC_ERA_TESTNET="zkSync Era Testnet",s.ZKSYNC_SEPOLIA_TESTNET="zkSync Sepolia Testnet",s.ZORA="Zora",s.ZORA_GOERLI_TESTNET="Zora Goerli Testnet",s.ZORA_SEPOLIA="Zora Sepolia",s))(Bt||{}),Xt=(m=>(m.Pending="pending",m.Completed="completed",m.Failed="failed",m.Received="received",m.Success="success",m.Failure="failure",m.Dropped="dropped",m.Replaced="replaced",m.Stuck="stuck",m.Confirmed="confirmed",m))(Xt||{}),qt=(a=>(a.USER_TO_TMC="user_to_tmc",a.TMC_TO_USER="tmc_to_user",a.RELAYER_TO_TMC="relayer_to_tmc",a.RELAYER_TO_CODEX="relayer_to_codex",a.RELAYER_TO_CIRCLE="relayer_to_circle",a))(qt||{}),Zt=(r=>(r.D="deposit",r.W="withdraw",r.T="transfer",r))(Zt||{});var zt=(n=>(n.COMPANY="COMPANY",n.TWITTER="TWITTER",n.DISCORD="DISCORD",n.TELEGRAM="TELEGRAM",n))(zt||{});import{STREAMS as _e,PRIVATE_STREAMS as j}from"@ultrade/shared/browser/enums";var Qt=(r=>(r.OFF="disable",r.ULTRADE="ultrade",r.ALL="all",r))(Qt||{}),Jt=(f=>(f.ENABLED="company.enabled",f.APP_TITLE="company.appTitle",f.DOMAIN="company.domain",f.DIRECT_SETTLE="company.directSettlement",f.KYC="markets.kycTradeRequirementEnabled",f.GEOBLOCK="company.geoblock",f.LOGO="appearance.logo",f.THEMES="appearance.themes",f.NEW_TAB="appearance.newTab",f.TARGET="appearance.target",f.REPORT_BUTTONS="appearance.reportButtons",f.CUSTOM_MENU_ITEMS="appearance.customMenuItems",f.APPEARANCE_CHART_TYPE="appearance.chartType",f.APPEARANCE_CHART_INT="appearance.chartInt",f.AMM="product.amm",f.OBDEX="product.obdex",f.POINTS="product.pointSystem",f.AFFILIATE_DASHBOARD_THRESHOLD="product.affiliateDashboardThreshold",f.AFFILIATE_DEFAULT_FEE_SHARE="product.affiliateDefaultFeeShare",f.AFFILIATE_DASHBOARD_VISIBILITY="product.affiliateDashboardVisibility",f.AMM_FEE="company.ammFee",f.FEE_SHARE="company.feeShare",f.MIN_FEE="company.minFee",f.MAKER_FEE="company.makerFee",f.TAKER_FEE="company.takerFee",f.PINNED_PAIRS="markets.pinnedPairs",f.TWITTER_ENABLED="point-system.twitterEnabled",f.TWITTER_JOB_ENABLED="point-system.twitterJobEnabled",f.TWITTER_HASHTAGS="point-system.twitterHashtags",f.TWITTER_ACCOUNT_NAME="point-system.twitterAccountName",f.DISCORD_ENABLED="point-system.discordEnabled",f.TELEGRAM_ENABLED="point-system.telegramEnabled",f.TELEGRAM_GROUP_NAME="point-system.telegramGroupName",f.TELEGRAM_BOT_NAME="point-system.telegramBotName",f.GUIDE_LINK="point-system.guideLink",f))(Jt||{});var jt=(r=>(r.DISABLED="disabled",r.ENABLED_FOR_ALL="enabled for all",r.ENABLED_FOR_AFFILIATES="enabled for affiliates",r))(jt||{});import{decodeStateArray as Kt,getTxnParams as Ht}from"@ultrade/shared/browser/helpers/algo.helper";import v from"algosdk";import er from"axios";var F=class{constructor(e,t,r){this.client=e,this.authCredentials=t,this.indexerDomain=r}isAppOptedIn(e,t){return!!e?.find(r=>r.id===t)}isAssetOptedIn(e,t){return Object.keys(e).includes(t.toString())}async optInAsset(e,t){let r=await this.getTxnParams();return v.makeAssetTransferTxnWithSuggestedParamsFromObject({suggestedParams:{...r},from:e,to:e,assetIndex:t,amount:0})}async makeAppCallTransaction(e,t,r,n,a){let o=[],c=[],u=[e];return v.makeApplicationNoOpTxn(t,a||await this.getTxnParams(),r,n,o,c,u)}makeTransferTransaction(e,t,r,n,a){if(r<=0)return null;let o={suggestedParams:{...e},from:n,to:a,amount:r};return t===0?v.makePaymentTxnWithSuggestedParamsFromObject(o):(o.assetIndex=t,v.makeAssetTransferTxnWithSuggestedParamsFromObject(o))}get signer(){return this.authCredentials.signer}set signer(e){this.authCredentials.signer=e}async signAndSend(e){Array.isArray(e)||(e=[e]);let t=this.getCurrentAccount();if(t){let r=e.map(n=>n.signTxn(t.sk));return this.client.sendRawTransaction(r).do()}return this.authCredentials.signer.signAndSend(e)}async signAndSendData(e,t,r,n){let a=typeof e=="string"?e:JSON.stringify(e),o=typeof e=="string"?{message:a}:{...e},c=await t(a,n);return r({...o,signature:c})}async getTxnParams(){return await Ht(this.client)}getCurrentAccount(){return this.authCredentials.mnemonic?v.mnemonicToSecretKey(this.authCredentials.mnemonic):null}async getAccountInfo(e){return this.client.accountInformation(e).do()}constructArgsForAppCall(...e){let t=[];return e.forEach(r=>{t.push(new Uint8Array(r.toBuffer?r.toBuffer():l.from(r.toString())))}),t}validateCredentials(){if(!this.authCredentials.mnemonic&&!this.authCredentials.signer)throw"You need specify mnemonic or signer to execute the method"}async getAppState(e){try{let t=await this.client.getApplicationByID(e).do();return Kt(t.params["global-state"])}catch(t){console.log(`Attempt to load app by id ${e}`),console.log(t.message)}}async getSuperAppId(e){return(await this.getAppState(e))?.UL_SUPERADMIN_APP||0}async getPairBalances(e,t){let{data:r}=await er.get(`${this.indexerDomain}/v2/accounts/${t}?include-all=true`);if(r.account.hasOwnProperty("apps-local-state")){let n=r.account["apps-local-state"].find(c=>c.id===e&&c.deleted===!1);if(!n)return null;let a=n["key-value"].find(c=>c.key==="YWNjb3VudEluZm8="),o=l.from(a.value.bytes,"base64");return ye(o)}}async calculateTransferAmount(e,t,r,n,a,o){let c=await this.getPairBalances(e,t),u=(r==="B"?c?.priceCoin_available:c?.baseCoin_available)??0;r==="B"&&(n=n/10**o*a);let d=Math.ceil(n-u);return d<0?0:d}};import we,{encodeAddress as tr}from"algosdk";var rr={priceCoin_locked:{type:"uint"},priceCoin_available:{type:"uint"},baseCoin_locked:{type:"uint"},baseCoin_available:{type:"uint"},companyId:{type:"uint"},WLFeeShare:{type:"uint"},WLCustomFee:{type:"uint"},slotMap:{type:"uint"}},ye=i=>{let e=new Map,t=0;for(let[r,n]of Object.entries(rr)){if(t>=i.length)throw new Error("Array index out of bounds");let a;switch(n.type){case"address":a=tr(i.slice(t,t+32)),t+=32;break;case"bytes":a=i.slice(t,t+n.size),a=we.decodeUint64(a,"mixed"),t+=n.size;break;case"uint":a=we.decodeUint64(i.slice(t,t+8),"mixed"),t+=8;break;case"string":a=ir(i.slice(t,t+n.size)),t+=n.size;break}e.set(r,a)}return Object.fromEntries(e)},ir=i=>l.from(i).toString("utf-8");var Se="By signing this message you are logging into your trading account and agreeing to all terms and conditions of the platform.";var Pe={mainnet:{algodNode:"https://mainnet-api.algonode.cloud",apiUrl:"https://mainnet-api.algonode.cloud",algodIndexer:"https://mainnet-idx.algonode.cloud"},testnet:{algodNode:"https://testnet-api.algonode.cloud",apiUrl:"https://testnet-apigw.ultradedev.net",algodIndexer:"https://testnet-idx.algonode.cloud"},local:{algodNode:"http://localhost:4001",apiUrl:"http://localhost:5001",algodIndexer:"http://localhost:8980"}},K=["/market/balances","/market/order","/market/orders","/market/account/kyc/status","/market/account/kyc/init","/market/withdrawal-fee","/market/operation-details","/wallet/key","/wallet/transactions","/wallet/transfer","/wallet/withdraw","/wallet/whitelist","/wallet/withdrawal-wallets"];var Re=class{constructor(e,t){this.axiosInterceptor=e=>{let t=c=>c.withWalletCredentials||(c.url?K.some(u=>c.url.includes(u)):!1),r=c=>{let u=["/market/order"];return c.withWalletCredentials||(c.url?u.some(d=>c.url.includes(d)):!1)},n=c=>{let u=["/wallet/signin","/market/account/kyc/init","/notifications"];return c.url?u.some(d=>c.url.includes(d)):!1},a=c=>{let u=["/social/"];return c.url?u.some(d=>c.url.includes(d)):!1},o=c=>c.url?K.some(u=>c.url.includes(u)):!1;return e.interceptors.request.use(c=>{if(this.wallet&&t(c)&&(c.headers["X-Wallet-Address"]=this.wallet.address,c.headers["X-Wallet-Token"]=this.wallet.token),this.wallet&&o(c)&&(c.headers.CompanyId=this.companyId),this.wallet&&r(c)){let u=this.localStorageService.getMainWallet()?.tradingKey;u&&(c.headers["X-Trading-Key"]=u)}return n(c)&&(c.headers.CompanyId=this.companyId),a(c)&&!c.headers.CompanyId&&(c.headers.CompanyId=this.isUltradeID?1:this.companyId),c},c=>Promise.reject(c)),e.interceptors.response.use(c=>c.data,async c=>(console.log("Request was failed",c),[401].includes(c?.response?.status)&&c.config&&t(c.config)&&(this.wallet=null,this.localStorageService.clearMainWallet()),Promise.reject(c))),e};let r=Pe[e.network];this.algodNode=r.algodNode,this.apiUrl=r.apiUrl,this.algodIndexer=r.algodIndexer,e.apiUrl!==void 0&&(this.apiUrl=e.apiUrl),e.companyId!==void 0&&(this.companyId=e.companyId),this.websocketUrl=e.websocketUrl,this.client=new F(e.algoSdkClient,t||{},this.algodIndexer),this._axios=this.axiosInterceptor(ar.create({baseURL:this.apiUrl})),this.localStorageService=new X,this.wallet=this.localStorageService.getMainWallet(),this.isUltradeID=!1,this.socketManager=new U(this.websocketUrl,nr,n=>{console.log(`Socket ${n} disconnected at`,new Date)},n=>{console.log(`Socket connect_error due to ${n}`)}),console.log("SDK Wallet",this.wallet)}get useUltradeID(){return this.isUltradeID}set useUltradeID(e){this.isUltradeID=e}get isLogged(){return!!this.wallet?.token}get mainWallet(){return this.wallet}set mainWallet(e){this.wallet=e,e?this.localStorageService.setMainWallet(e):this.localStorageService.clearMainWallet()}setSigner(e){this.client.signer=e}subscribe(e,t){let r=e.streams.some(n=>n===_e.TRADES&&e.options?.address?!0:j.includes(n));return r&&!this.mainWallet?.token&&!this.mainWallet?.tradingKey?(e.streams=e.streams.filter(n=>!j.includes(n)),this.socketManager.subscribe(e,t)):r?(e.options={...e.options,token:this.mainWallet?.token,tradingKey:this.mainWallet?.tradingKey},this.socketManager.subscribe(e,t)):this.socketManager.subscribe(e,t)}unsubscribe(e){this.socketManager.unsubscribe(e)}getPairList(e){let t=e?`&companyId=${e}`:"";return this._axios.get(`/market/markets?includeAllOrders=false${t}`)}getPair(e){return this._axios.get(`/market/market?symbol=${e}`)}getPrice(e){return this._axios.get(`/market/price?symbol=${e}`)}getDepth(e,t){return this._axios.get(`/market/depth?symbol=${e}&depth=${t}`)}getSymbols(e){return this._axios.get(`/market/symbols${e?"?mask="+e:""}`)}getLastTrades(e){return this._axios.get(`/market/last-trades?symbol=${e}`)}getHistory(e,t,r,n,a=500,o=1){return this._axios.get(`/market/history?symbol=${e}&interval=${t}&startTime=${r??""}&endTime=${n??""}&limit=${a}&page=${o}`)}getOrders(e,t,r=50,n,a){let o=t?t===1?G.Open:[G.Canceled,G.Matched,G.SelfMatched,G.Expired].join(","):"",c=e?`&symbol=${e}`:"",u=o?`&status=${o}`:"",d=a?`&startTime=${a}`:"",m=n?`&endTime=${n}`:"";return this._axios.get(`/market/orders?limit=${r}${c}${u}${d}${m}`)}getOrderById(e){return this._axios.get(`/market/order/${e}`)}getSettings(){let e=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host;return this._axios.get("/market/settings",{headers:{"wl-domain":e}})}getBalances(){return this._axios.get("/market/balances")}getChains(){return this._axios.get("/market/chains")}getCodexAssets(){return this._axios.get("/market/assets")}getCCTPAssets(){return this._axios.get("/market/cctp-assets")}getCCTPUnifiedAssets(){return this._axios.get("/market/cctp-unified-assets")}getWithdrawalFee(e,t){return this._axios.get(`/market/withdrawal-fee?assetAddress=${e}&chainId=${t}`)}getKycStatus(){return this._axios.get("/market/account/kyc/status")}getKycInitLink(e){return this._axios.post("/market/account/kyc/init",{embeddedAppUrl:e})}getDollarValues(e=[]){return this._axios.get(`/market/dollar-price?assetIds=${JSON.stringify(e)}`)}getTransactionDetalis(e){return this._axios.get(`/market/operation-details?operationId=${e}`)}getWalletTransactions(e,t,r=100){return this._axios.get(`/wallet/transactions?type=${e}&limit=${r}&page=${t}`,{withWalletCredentials:!0})}getTradingKeys(){return this._axios.get("/wallet/keys",{withWalletCredentials:!0})}getTransfers(e,t=100){return this._axios.get(`/wallet/transfers?limit=${t}&page=${e}`,{withWalletCredentials:!0})}getPendingTransactions(){return this._axios.get("/wallet/transactions/pending",{withWalletCredentials:!0})}getWhitelist(){return this._axios.get("/wallet/whitelist",{withWalletCredentials:!0})}async addWhitelist(e){e={...e,expiredDate:e.expiredDate&&Math.round(e.expiredDate/1e3)};let r=l.from(gr(e)).toString("hex");return await this.client.signAndSendData(r,this.client.signer.signMessage,({signature:n})=>this._axios.post("/wallet/whitelist",{message:r,signature:n}),"hex")}deleteWhitelist(e){let t={whitelistId:e};return this.client.signAndSendData(t,this.client.signer.signMessage,({signature:r})=>this._axios.delete("/wallet/whitelist",{data:{data:t,signature:r}}))}getAllWithdrawalWallets(){return this._axios.get("/wallet/withdrawal-wallets")}getWithdrawalWalletByAddress(e){return this._axios.get(`/wallet/withdrawal-wallets/${e}`)}createWithdrawalWallet(e){return this._axios.post("/wallet/withdrawal-wallets",e)}updateWithdrawalWallet(e){return this._axios.patch("/wallet/withdrawal-wallets",e)}deleteWithdrawalWallet(e){return this._axios.delete(`/wallet/withdrawal-wallets/${e}`)}getVersion(){return this._axios.get("/system/version")}getMaintenance(){return this._axios.get("/system/maintenance")}getNotifications(){return this._axios.get("/notifications",{withWalletCredentials:!0})}getNotificationsUnreadCount(){return this._axios.get("/notifications/count",{withWalletCredentials:!0})}readNotifications(e){return this._axios.put("/notifications",{notifications:e},{withWalletCredentials:!0})}getAffiliatesStatus(e){return this._axios.get(`/affiliates/${e}/dashboardStatus`,{withWalletCredentials:!0})}createAffiliate(e){return this._axios.post(`/affiliates/${e}`,{},{withWalletCredentials:!0})}getAffiliateProgress(e){return this._axios.get(`/affiliates/${e}/tradingVolumeProgress`,{withWalletCredentials:!0})}getAffiliateInfo(e,t){return this._axios.get(`/affiliates/${e}/dashboard?range=${t}`,{withWalletCredentials:!0})}async countAffiliateDepost(e){await this._axios.post(`/affiliates/${e}/deposit`,{},{withWalletCredentials:!0})}async countAffiliateClick(e){await this._axios.post("/affiliates/click",{referralToken:e},{withWalletCredentials:!0})}getSocialAccount(){return this._axios.get("/social/account",{withWalletCredentials:!0})}async addSocialEmail(e,t){await this._axios.put("/social/account/email",{email:e,embeddedAppUrl:t},{withWalletCredentials:!0})}async verifySocialEmail(e,t){await this._axios.put("/social/account/verifyEmail",{email:e,hash:t},{withWalletCredentials:!0})}getLeaderboards(){return this._axios.get("/social/leaderboard",{withWalletCredentials:!0})}getUnlocks(){return this._axios.get("/social/unlocks",{withWalletCredentials:!0})}getSocialSettings(){return this._axios.get("/social/settings",{withWalletCredentials:!0})}getSeason(e){return this._axios.get("/social/seasons/active",{withWalletCredentials:!0,headers:{CompanyId:e}})}getPastSeasons(){return this._axios.get("/social/seasons/history",{withWalletCredentials:!0})}addTelegram(e){return this._axios.post("/social/telegram/connect",e,{withWalletCredentials:!0})}async disconnectTelegram(e){await this._axios.put("/social/telegram/disconnect",e,{withWalletCredentials:!0})}async getDiscordConnectionUrl(e){let t=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"";return(await this._axios.get(`/social/discord/connect${t}`,{withWalletCredentials:!0})).url}async disconnectDiscord(){await this._axios.put("/social/discord/disconnect",{},{withWalletCredentials:!0})}async getTwitterConnectionUrl(e,t){let r=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"",n=t?`&scopes=${t}`:"";return(await this._axios.get(`/social/twitter/connect${r}${n}`,{withWalletCredentials:!0})).url}async disconnectTwitter(){await this._axios.put("/social/twitter/disconnect",{},{withWalletCredentials:!0})}getTweets(){return this._axios.get("/social/twitter/tweets",{withWalletCredentials:!0})}async actionWithTweet(e){await this._axios.post("/social/twitter/tweet/actions",e,{withWalletCredentials:!0})}getActions(){return this._axios.get("/social/actions",{withWalletCredentials:!0})}getActionHistory(){return this._axios.get("/social/actions/history",{withWalletCredentials:!0})}getAIStyles(){return this._axios.get("/social/twitter/tweets/styles",{withWalletCredentials:!0})}getAIComment(e,t){return this._axios.get(`/social/twitter/tweets/${t}/generateComment?styleId=${e}`,{withWalletCredentials:!0})}getTechnologyByProvider(e){switch(e){case M.PERA:return"ALGORAND";case M.METAMASK:return"EVM";case M.SOLFLARE:case M.COINBASE:case M.PHANTOM:case M.BACKPACK:case M.MOBILE:return"SOLANA";default:throw new Error("Not implemented")}}async login({address:e,provider:t,chain:r,referralToken:n,loginMessage:a}){let c=a||Se,u={address:e,technology:this.getTechnologyByProvider(t)},d=l.from(cr(u,c)).toString("hex");return await this.client.signAndSendData(d,this.client.signer.signMessage,async({signature:m})=>{let p=await this._axios.put("/wallet/signin",{data:u,message:d,encoding:"hex",signature:m,referralToken:n});return this.mainWallet={address:e,provider:t,token:p,chain:r},p},"hex")}async addTradingKey(e){let r=l.from(ke(e,!0)).toString("hex"),{device:n,type:a}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>{let c=await this._axios.post("/wallet/key",{data:{device:n,type:a},encoding:"hex",message:r,signature:o});return this.mainWallet&&c.type===mr.User&&(this.mainWallet.tradingKey=c.address),c},"hex")}async revokeTradingKey(e){let r=l.from(ke(e,!1)).toString("hex"),{device:n,type:a}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>(await this._axios.delete("/wallet/key",{data:{data:{device:n,type:a},encoding:"hex",message:r,signature:o}}),this.mainWallet&&e.tkAddress===this.mainWallet.tradingKey&&(this.mainWallet.tradingKey=void 0),{signature:o}),"hex")}async withdraw(e,t){let n={...e,random:H(1,Number.MAX_SAFE_INTEGER)},a=l.from(dr(n,t)).toString("hex");return await this.client.signAndSendData(a,this.client.signer.signMessage,({signature:o})=>this._axios.post("/wallet/withdraw",{encoding:"hex",message:a,signature:o,destinationAddress:n.recipient}),"hex")}async transfer(e){let r={...e,random:H(1,Number.MAX_SAFE_INTEGER)},n=l.from(pr(r)).toString("hex");return await this.client.signAndSendData(n,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/transfer",{message:n,signature:a}),"hex")}async createSpotOrder(e){let t=sr*24*60*60,r=Math.floor(Date.now()/1e3)+t,n={...e,version:or,expiredTime:r,random:H(1,Number.MAX_SAFE_INTEGER)},a="hex",o=l.from(ur(n)).toString(a);return await this.client.signAndSendData(o,this.client.signer.signMessageByToken,({signature:c})=>this._axios.post("/market/order",{encoding:a,message:o,signature:c}),a)}async cancelOrder(e){let t={orderId:e.orderId},r="hex",n=l.from(lr(e)).toString(r);return await this.client.signAndSendData(n,this.client.signer.signMessageByToken,({signature:a})=>this._axios.delete("/market/order",{data:{data:t,message:n,signature:a}}),r)}async cancelMultipleOrders({orderIds:e,pairId:t}){let r={orderIds:e,pairId:t};return await this.client.signAndSendData(r,this.client.signer.signMessageByToken,({signature:n})=>this._axios.delete("/market/orders",{data:{data:r,signature:n}}))}async ping(){let e=await this._axios.get("/system/time");return Math.round(Date.now()-e.currentTime)}getSocketSubscribeOptions(e,t){let r=this?.companyId,n=this?.wallet?.address;return{symbol:t,streams:e,options:{companyId:r,address:n}}}};export{Zt as ACTION_TYPE,jt as AffDashboardVisibilitySettingEnum,Bt as BLOCKCHAINS,Re as Client,Se as DEFAULT_LOGIN_MESSAGE,Ft as DIRECT_SETTLE,Pe as NETWORK_CONFIGS,Ot as ORDER_STATUS,Xt as OperationStatusEnum,Vt as OrderExecution,Ct as OrderExecutionType,Lt as OrderStatus,Yt as OrderTypeEnum,$t as OrderUpdateStaus,Qt as POINTS_SETTING,j as PRIVATE_STREAMS,Gt as PairSettingsIds,zt as SOCIAL_ACTION_SOURCE,_e as STREAMS,Jt as SettingIds,U as SocketManager,qt as TransactionType,K as tokenizedUrls};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|