@ultrade/ultrade-js-sdk 0.2.7 → 2.0.1

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/index.js CHANGED
@@ -1,19 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./amm"), exports);
18
- __exportStar(require("./constants"), exports);
19
- __exportStar(require("./types"), exports);
1
+ function Z(){throw new Error("setTimeout has not been defined")}function j(){throw new Error("clearTimeout has not been defined")}var I=Z,_=j;typeof globalThis.setTimeout=="function"&&(I=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);function ee(r){if(I===setTimeout)return setTimeout(r,0);if((I===Z||!I)&&setTimeout)return I=setTimeout,setTimeout(r,0);try{return I(r,0)}catch{try{return I.call(null,r,0)}catch{return I.call(this,r,0)}}}function Ee(r){if(_===clearTimeout)return clearTimeout(r);if((_===j||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(r);try{return _(r)}catch{try{return _.call(null,r)}catch{return _.call(this,r)}}}var A=[],W=!1,E,B=-1;function Te(){!W||!E||(W=!1,E.length?A=E.concat(A):B=-1,A.length&&te())}function te(){if(!W){var r=ee(Te);W=!0;for(var e=A.length;e;){for(E=A,A=[];++B<e;)E&&E[B].run();B=-1,e=A.length}E=null,W=!1,Ee(r)}}function Ce(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];A.push(new re(r,e)),A.length===1&&!W&&ee(te)}function re(r,e){this.fun=r,this.array=e}re.prototype.run=function(){this.fun.apply(null,this.array)};var ve="browser",Pe="browser",Se=!0,We={},Ue=[],De="",Re={},Be={},Me={};function T(){}var Ne=T,Le=T,Oe=T,$e=T,Ye=T,Fe=T,Ke=T;function qe(r){throw new Error("process.binding is not supported")}function Ve(){return"/"}function Xe(r){throw new Error("process.chdir is not supported")}function Ge(){return 0}var S=globalThis.performance||{},ze=S.now||S.mozNow||S.msNow||S.oNow||S.webkitNow||function(){return new Date().getTime()};function He(r){var e=ze.call(S)*.001,t=Math.floor(e),i=Math.floor(e%1*1e9);return r&&(t=t-r[0],i=i-r[1],i<0&&(t--,i+=1e9)),[t,i]}var Je=new Date;function Qe(){var r=new Date,e=r-Je;return e/1e3}var b={nextTick:Ce,title:ve,browser:Se,env:We,argv:Ue,version:De,versions:Re,on:Ne,addListener:Le,once:Oe,off:$e,removeListener:Ye,removeAllListeners:Fe,emit:Ke,binding:qe,cwd:Ve,chdir:Xe,umask:Ge,hrtime:He,platform:Pe,release:Be,config:Me,uptime:Qe},Q={};Object.keys(Q).forEach(r=>{let e=r.split("."),t=b;for(let i=0;i<e.length;i++){let n=e[i];i===e.length-1?t[n]=Q[r]:t=t[n]||(t[n]={})}});var x=[],m=[],Ze=typeof Uint8Array<"u"?Uint8Array:Array,V=!1;function ae(){V=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)x[e]=r[e],m[r.charCodeAt(e)]=e;m[45]=62,m[95]=63}function je(r){V||ae();var e,t,i,n,s,a,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[c-2]==="="?2:r[c-1]==="="?1:0,a=new Ze(c*3/4-s),i=s>0?c-4:c;var l=0;for(e=0,t=0;e<i;e+=4,t+=3)n=m[r.charCodeAt(e)]<<18|m[r.charCodeAt(e+1)]<<12|m[r.charCodeAt(e+2)]<<6|m[r.charCodeAt(e+3)],a[l++]=n>>16&255,a[l++]=n>>8&255,a[l++]=n&255;return s===2?(n=m[r.charCodeAt(e)]<<2|m[r.charCodeAt(e+1)]>>4,a[l++]=n&255):s===1&&(n=m[r.charCodeAt(e)]<<10|m[r.charCodeAt(e+1)]<<4|m[r.charCodeAt(e+2)]>>2,a[l++]=n>>8&255,a[l++]=n&255),a}function et(r){return x[r>>18&63]+x[r>>12&63]+x[r>>6&63]+x[r&63]}function tt(r,e,t){for(var i,n=[],s=e;s<t;s+=3)i=(r[s]<<16)+(r[s+1]<<8)+r[s+2],n.push(et(i));return n.join("")}function ie(r){V||ae();for(var e,t=r.length,i=t%3,n="",s=[],a=16383,c=0,l=t-i;c<l;c+=a)s.push(tt(r,c,c+a>l?l:c+a));return i===1?(e=r[t-1],n+=x[e>>2],n+=x[e<<4&63],n+="=="):i===2&&(e=(r[t-2]<<8)+r[t-1],n+=x[e>>10],n+=x[e>>4&63],n+=x[e<<2&63],n+="="),s.push(n),s.join("")}o.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function M(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(r,e){if(M()<e)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=o.prototype):(r===null&&(r=new o(e)),r.length=e),r}function o(r,e,t){if(!o.TYPED_ARRAY_SUPPORT&&!(this instanceof o))return new o(r,e,t);if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return X(this,r)}return oe(this,r,e,t)}o.poolSize=8192;o._augment=function(r){return r.__proto__=o.prototype,r};function oe(r,e,t,i){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?nt(r,e,t,i):typeof e=="string"?it(r,e,t):st(r,e)}o.from=function(r,e,t){return oe(null,r,e,t)};o.kMaxLength=M();o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&o[Symbol.species]);function le(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function rt(r,e,t,i){return le(e),e<=0?k(r,e):t!==void 0?typeof i=="string"?k(r,e).fill(t,i):k(r,e).fill(t):k(r,e)}o.alloc=function(r,e,t){return rt(null,r,e,t)};function X(r,e){if(le(e),r=k(r,e<0?0:G(e)|0),!o.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}o.allocUnsafe=function(r){return X(null,r)};o.allocUnsafeSlow=function(r){return X(null,r)};function it(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var i=ce(e,t)|0;r=k(r,i);var n=r.write(e,t);return n!==i&&(r=r.slice(0,n)),r}function q(r,e){var t=e.length<0?0:G(e.length)|0;r=k(r,t);for(var i=0;i<t;i+=1)r[i]=e[i]&255;return r}function nt(r,e,t,i){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(i||0))throw new RangeError("'length' is out of bounds");return t===void 0&&i===void 0?e=new Uint8Array(e):i===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,i),o.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=o.prototype):r=q(r,e),r}function st(r,e){if(y(e)){var t=G(e.length)|0;return r=k(r,t),r.length===0||e.copy(r,0,0,t),r}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||_t(e.length)?k(r,0):q(r,e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function G(r){if(r>=M())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M().toString(16)+" bytes");return r|0}o.isBuffer=Et;function y(r){return!!(r!=null&&r._isBuffer)}o.compare=function(e,t){if(!y(e)||!y(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,s=0,a=Math.min(i,n);s<a;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?1:0};o.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}};o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=o.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var a=e[i];if(!y(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,s),s+=a.length}return n};function ce(r,e){if(y(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return N(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return me(r).length;default:if(i)return N(r).length;e=(""+e).toLowerCase(),i=!0}}o.byteLength=ce;function at(r,e,t){var i=!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(r||(r="utf8");;)switch(r){case"hex":return mt(this,e,t);case"utf8":case"utf-8":return fe(this,e,t);case"ascii":return dt(this,e,t);case"latin1":case"binary":return gt(this,e,t);case"base64":return ft(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wt(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}o.prototype._isBuffer=!0;function C(r,e,t){var i=r[e];r[e]=r[t],r[t]=i}o.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)C(this,t,t+1);return this};o.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)C(this,t,t+3),C(this,t+1,t+2);return this};o.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)C(this,t,t+7),C(this,t+1,t+6),C(this,t+2,t+5),C(this,t+3,t+4);return this};o.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?fe(this,0,e):at.apply(this,arguments)};o.prototype.equals=function(e){if(!y(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0};o.prototype.compare=function(e,t,i,n,s){if(!y(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var a=s-n,c=i-t,l=Math.min(a,c),u=this.slice(n,s),h=e.slice(t,i),f=0;f<l;++f)if(u[f]!==h[f]){a=u[f],c=h[f];break}return a<c?-1:c<a?1:0};function ue(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=o.from(e,i)),y(e))return e.length===0?-1:ne(r,e,t,i,n);if(typeof e=="number")return e=e&255,o.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ne(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function ne(r,e,t,i,n){var s=1,a=r.length,c=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,a/=2,c/=2,t/=2}function l(g,P){return s===1?g[P]:g.readUInt16BE(P*s)}var u;if(n){var h=-1;for(u=t;u<a;u++)if(l(r,u)===l(e,h===-1?0:u-h)){if(h===-1&&(h=u),u-h+1===c)return h*s}else h!==-1&&(u-=u-h),h=-1}else for(t+c>a&&(t=a-c),u=t;u>=0;u--){for(var f=!0,w=0;w<c;w++)if(l(r,u+w)!==l(e,w)){f=!1;break}if(f)return u}return-1}o.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};o.prototype.indexOf=function(e,t,i){return ue(this,e,t,i,!0)};o.prototype.lastIndexOf=function(e,t,i){return ue(this,e,t,i,!1)};function ot(r,e,t,i){t=Number(t)||0;var n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var a=0;a<i;++a){var c=parseInt(e.substr(a*2,2),16);if(isNaN(c))return a;r[t+a]=c}return a}function lt(r,e,t,i){return $(N(e,r.length-t),r,t,i)}function he(r,e,t,i){return $(kt(e),r,t,i)}function ct(r,e,t,i){return he(r,e,t,i)}function ut(r,e,t,i){return $(me(e),r,t,i)}function ht(r,e,t,i){return $(It(e,r.length-t),r,t,i)}o.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((i===void 0||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return ot(this,e,t,i);case"utf8":case"utf-8":return lt(this,e,t,i);case"ascii":return he(this,e,t,i);case"latin1":case"binary":return ct(this,e,t,i);case"base64":return ut(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ht(this,e,t,i);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}};o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ft(r,e,t){return e===0&&t===r.length?ie(r):ie(r.slice(e,t))}function fe(r,e,t){t=Math.min(r.length,t);for(var i=[],n=e;n<t;){var s=r[n],a=null,c=s>239?4:s>223?3:s>191?2:1;if(n+c<=t){var l,u,h,f;switch(c){case 1:s<128&&(a=s);break;case 2:l=r[n+1],(l&192)===128&&(f=(s&31)<<6|l&63,f>127&&(a=f));break;case 3:l=r[n+1],u=r[n+2],(l&192)===128&&(u&192)===128&&(f=(s&15)<<12|(l&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(a=f));break;case 4:l=r[n+1],u=r[n+2],h=r[n+3],(l&192)===128&&(u&192)===128&&(h&192)===128&&(f=(s&15)<<18|(l&63)<<12|(u&63)<<6|h&63,f>65535&&f<1114112&&(a=f))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|a&1023),i.push(a),n+=c}return pt(i)}var se=4096;function pt(r){var e=r.length;if(e<=se)return String.fromCharCode.apply(String,r);for(var t="",i=0;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=se));return t}function dt(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function gt(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function mt(r,e,t){var i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);for(var n="",s=e;s<t;++s)n+=bt(r[s]);return n}function wt(r,e,t){for(var i=r.slice(e,t),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+i[s+1]*256);return n}o.prototype.slice=function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=o.prototype;else{var s=t-e;n=new o(s,void 0);for(var a=0;a<s;++a)n[a]=this[a+e]}return n};function p(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUIntLE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e],s=1,a=0;++a<t&&(s*=256);)n+=this[e+a]*s;return n};o.prototype.readUIntBE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n};o.prototype.readUInt8=function(e,t){return t||p(e,1,this.length),this[e]};o.prototype.readUInt16LE=function(e,t){return t||p(e,2,this.length),this[e]|this[e+1]<<8};o.prototype.readUInt16BE=function(e,t){return t||p(e,2,this.length),this[e]<<8|this[e+1]};o.prototype.readUInt32LE=function(e,t){return t||p(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};o.prototype.readUInt32BE=function(e,t){return t||p(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};o.prototype.readIntLE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e],s=1,a=0;++a<t&&(s*=256);)n+=this[e+a]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n};o.prototype.readIntBE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=t,s=1,a=this[e+--n];n>0&&(s*=256);)a+=this[e+--n]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*t)),a};o.prototype.readInt8=function(e,t){return t||p(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};o.prototype.readInt16LE=function(e,t){t||p(e,2,this.length);var i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};o.prototype.readInt16BE=function(e,t){t||p(e,2,this.length);var i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};o.prototype.readInt32LE=function(e,t){return t||p(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};o.prototype.readInt32BE=function(e,t){return t||p(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};o.prototype.readFloatLE=function(e,t){return t||p(e,4,this.length),Y(this,e,!0,23,4)};o.prototype.readFloatBE=function(e,t){return t||p(e,4,this.length),Y(this,e,!1,23,4)};o.prototype.readDoubleLE=function(e,t){return t||p(e,8,this.length),Y(this,e,!0,52,8)};o.prototype.readDoubleBE=function(e,t){return t||p(e,8,this.length),Y(this,e,!1,52,8)};function d(r,e,t,i,n,s){if(!y(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}o.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;d(this,e,t,i,s,0)}var a=1,c=0;for(this[t]=e&255;++c<i&&(a*=256);)this[t+c]=e/a&255;return t+i};o.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;d(this,e,t,i,s,0)}var a=i-1,c=1;for(this[t+a]=e&255;--a>=0&&(c*=256);)this[t+a]=e/c&255;return t+i};o.prototype.writeUInt8=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function L(r,e,t,i){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(r.length-t,2);n<s;++n)r[t+n]=(e&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}o.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):L(this,e,t,!0),t+2};o.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):L(this,e,t,!1),t+2};function O(r,e,t,i){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(r.length-t,4);n<s;++n)r[t+n]=e>>>(i?n:3-n)*8&255}o.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):O(this,e,t,!0),t+4};o.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):O(this,e,t,!1),t+4};o.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);d(this,e,t,i,s-1,-s)}var a=0,c=1,l=0;for(this[t]=e&255;++a<i&&(c*=256);)e<0&&l===0&&this[t+a-1]!==0&&(l=1),this[t+a]=(e/c>>0)-l&255;return t+i};o.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);d(this,e,t,i,s-1,-s)}var a=i-1,c=1,l=0;for(this[t+a]=e&255;--a>=0&&(c*=256);)e<0&&l===0&&this[t+a+1]!==0&&(l=1),this[t+a]=(e/c>>0)-l&255;return t+i};o.prototype.writeInt8=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};o.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):L(this,e,t,!0),t+2};o.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):L(this,e,t,!1),t+2};o.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4};o.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):O(this,e,t,!1),t+4};function pe(r,e,t,i,n,s){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function de(r,e,t,i,n){return n||pe(r,e,t,4,34028234663852886e22,-34028234663852886e22),xe(r,e,t,i,23,4),t+4}o.prototype.writeFloatLE=function(e,t,i){return de(this,e,t,!0,i)};o.prototype.writeFloatBE=function(e,t,i){return de(this,e,t,!1,i)};function ge(r,e,t,i,n){return n||pe(r,e,t,8,17976931348623157e292,-17976931348623157e292),xe(r,e,t,i,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,i){return ge(this,e,t,!0,i)};o.prototype.writeDoubleBE=function(e,t,i){return ge(this,e,t,!1,i)};o.prototype.copy=function(e,t,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=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-i&&(n=e.length-t+i);var s=n-i,a;if(this===e&&i<t&&t<n)for(a=s-1;a>=0;--a)e[a+t]=this[a+i];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(a=0;a<s;++a)e[a+t]=this[a+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s};o.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var a;if(typeof e=="number")for(a=t;a<i;++a)this[a]=e;else{var c=y(e)?e:N(new o(e,n).toString()),l=c.length;for(a=0;a<i-t;++a)this[a+t]=c[a%l]}return this};var xt=/[^+\/0-9A-Za-z-_]/g;function yt(r){if(r=At(r).replace(xt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function At(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function bt(r){return r<16?"0"+r.toString(16):r.toString(16)}function N(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],a=0;a<i;++a){if(t=r.charCodeAt(a),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function kt(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function It(r,e){for(var t,i,n,s=[],a=0;a<r.length&&!((e-=2)<0);++a)t=r.charCodeAt(a),i=t>>8,n=t%256,s.push(n),s.push(i);return s}function me(r){return je(yt(r))}function $(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function _t(r){return r!==r}function Et(r){return r!=null&&(!!r._isBuffer||we(r)||Tt(r))}function we(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Tt(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&we(r.slice(0,0))}function Y(r,e,t,i,n){var s,a,c=n*8-i-1,l=(1<<c)-1,u=l>>1,h=-7,f=t?n-1:0,w=t?-1:1,g=r[e+f];for(f+=w,s=g&(1<<-h)-1,g>>=-h,h+=c;h>0;s=s*256+r[e+f],f+=w,h-=8);for(a=s&(1<<-h)-1,s>>=-h,h+=i;h>0;a=a*256+r[e+f],f+=w,h-=8);if(s===0)s=1-u;else{if(s===l)return a?NaN:(g?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-u}return(g?-1:1)*a*Math.pow(2,s-i)}function xe(r,e,t,i,n,s){var a,c,l,u=s*8-n-1,h=(1<<u)-1,f=h>>1,w=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=i?0:s-1,P=i?1:-1,_e=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+f>=1?e+=w/l:e+=w*Math.pow(2,1-f),e*l>=2&&(a++,l/=2),a+f>=h?(c=0,a=h):a+f>=1?(c=(e*l-1)*Math.pow(2,n),a=a+f):(c=e*Math.pow(2,f-1)*Math.pow(2,n),a=0));n>=8;r[t+g]=c&255,g+=P,c/=256,n-=8);for(a=a<<n|c,u+=n;u>0;r[t+g]=a&255,g+=P,a/=256,u-=8);r[t+g-P]|=_e*128}import Mt from"axios";import{DEFAULT_ORDER_EXPIRATION_DAYS as Nt,ORDER_MSG_VERSION as Lt}from"@ultrade/shared/constants";import{getRandomInt as J}from"@ultrade/shared/common/index";import{getCancelOrderDataJsonBytes as Ot,makeLoginMsg as $t,makeTradingKeyMsg as ke,makeCreateOrderMsg as Yt}from"@ultrade/shared/helpers/codex.helper";import{makeWithdrawMsg as Ft}from"@ultrade/shared/helpers/withdraw.helper";var U=class{constructor(e,t,i,n){this.onDisconnect=i;this.onConnectError=n;this.websocketUrl=e,this.socketIOFactory=t,this.initializeSocket()}socket=null;socketPool={};websocketUrl;socketIOFactory;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)}))}getSocket(){return this.socket}subscribe(e,t){let i=Date.now();return this.socket===null&&this.initializeSocket(),this.socket.onAny((n,...s)=>{t(n,s)}),this.socket.io.on("reconnect",()=>{this.socket.emit("subscribe",e)}),this.socket.emit("subscribe",e),this.socketPool[i]=e,i}unsubscribe(e){let t=this.socketPool[e];t&&this.socket&&(this.socket.emit("unsubscribe",t),delete this.socketPool[e]),Object.keys(this.socketPool).length===0&&this.socket&&this.disconnect()}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}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{decodeStateArray as St,getTxnParams as Wt}from"@ultrade/shared/helpers/algo.helper";import D from"algosdk";import Ut from"axios";import ye,{encodeAddress as Ct}from"algosdk";var vt={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"}},Ae=r=>{let e=new Map,t=0;for(let[i,n]of Object.entries(vt)){if(t>=r.length)throw new Error("Array index out of bounds");let s;switch(n.type){case"address":s=Ct(r.slice(t,t+32)),t+=32;break;case"bytes":s=r.slice(t,t+n.size),s=ye.decodeUint64(s,"mixed"),t+=n.size;break;case"uint":s=ye.decodeUint64(r.slice(t,t+8),"mixed"),t+=8;break;case"string":s=Pt(r.slice(t,t+n.size)),t+=n.size;break}e.set(i,s)}return Object.fromEntries(e)},Pt=r=>o.from(r).toString("utf-8");var F=class{client;authCredentials;indexerDomain;constructor(e,t,i){this.client=e,this.authCredentials=t,this.indexerDomain=i}isAppOptedIn(e,t){return!!e?.find(i=>i.id===t)}isAssetOptedIn(e,t){return Object.keys(e).includes(t.toString())}async optInAsset(e,t){let i=await this.getTxnParams();return D.makeAssetTransferTxnWithSuggestedParamsFromObject({suggestedParams:{...i},from:e,to:e,assetIndex:t,amount:0})}async makeAppCallTransaction(e,t,i,n,s){let a=[],c=[],l=[e];return D.makeApplicationNoOpTxn(t,s||await this.getTxnParams(),i,n,a,c,l)}makeTransferTransaction(e,t,i,n,s){if(i<=0)return null;let a={suggestedParams:{...e},from:n,to:s,amount:i};return t===0?D.makePaymentTxnWithSuggestedParamsFromObject(a):(a.assetIndex=t,D.makeAssetTransferTxnWithSuggestedParamsFromObject(a))}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 i=e.map(n=>n.signTxn(t.sk));return this.client.sendRawTransaction(i).do()}return this.authCredentials.signer.signAndSend(e)}async signAndSendData(e,t,i,n){let s=typeof e=="string"?e:JSON.stringify(e),a=typeof e=="string"?{message:s}:{...e},c=await t(s,n);return i({...a,signature:c})}async getTxnParams(){return await Wt(this.client)}getCurrentAccount(){return this.authCredentials.mnemonic?D.mnemonicToSecretKey(this.authCredentials.mnemonic):null}async getAccountInfo(e){return this.client.accountInformation(e).do()}constructArgsForAppCall(...e){let t=[];return e.forEach(i=>{t.push(new Uint8Array(i.toBuffer?i.toBuffer():o.from(i.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 St(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:i}=await Ut.get(`${this.indexerDomain}/v2/accounts/${t}?include-all=true`);if(i.account.hasOwnProperty("apps-local-state")){let n=i.account["apps-local-state"].find(c=>c.id===e&&c.deleted===!1);if(!n)return null;let s=n["key-value"].find(c=>c.key==="YWNjb3VudEluZm8="),a=o.from(s.value.bytes,"base64");return Ae(a)}}async calculateTransferAmount(e,t,i,n,s,a){let c=await this.getPairBalances(e,t),l=(i==="B"?c?.priceCoin_available:c?.baseCoin_available)??0;i==="B"&&(n=n/10**a*s);let u=Math.ceil(n-l);return u<0?0:u}};var z=[5,8,10,11];import Dt from"react-secure-storage";var Rt=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host,be=r=>`${r}_${Rt}`,Bt=new Proxy(Dt,{get(r,e,t){return typeof e=="string"&&typeof r[e]=="function"?function(...i){return typeof e=="string"&&["setItem","getItem","removeItem"].includes(e)&&(i[0]=be(i[0])),r[e].apply(r,i)}:Reflect.get(r,e,t)}}),H=new Proxy(localStorage,{get(r,e,t){return typeof e=="string"&&typeof r[e]=="function"?function(...i){return typeof e=="string"&&["setItem","getItem","removeItem","key"].includes(e)&&(i[0]=be(i[0])),r[e].apply(r,i)}:Reflect.get(r,e,t)}}),K=class{isBrowser;keys={mainWallet:"main-wallet",tradingKey:"trading-key"};constructor(){this.isBrowser=typeof window<"u",this.isBrowser||(this.clearMainWallet=()=>{},this.getMainWallet=()=>null,this.setMainWallet=()=>{})}setMainWallet(e){H.setItem(this.keys.mainWallet,JSON.stringify(e))}getMainWallet(){let e=H.getItem(this.keys.mainWallet);if(!e)return null;let t=JSON.parse(e),i=Bt.getItem(`${this.keys.tradingKey}-${t.address}`);return i&&(i.expiredAt===0||Number(new Date(i.expiredAt))-Date.now()>1)&&(t.tradingKey=i.address),t}clearMainWallet(){H.removeItem(this.keys.mainWallet)}};import{TradingKeyType as Kt}from"@ultrade/shared/interfaces";import{PROVIDERS as v}from"@ultrade/shared/interfaces";import{OrderStatus as R}from"@ultrade/shared/enums";import{makeDtwMsg as qt,makeTransferMsg as Vt}from"@ultrade/shared/helpers/codex/index";var Xt="By signing this message you are logging into your trading account and agreeing to all terms and conditions of the platform.",Ie=class{client;algodNode;algodIndexer;apiUrl;companyId;websocketUrl;wallet;_axios;localStorageService;isUltradeID;socketManager;constructor(e,t){e.network==="mainnet"?(this.algodNode="https://mainnet-api.algonode.cloud",this.apiUrl="https://mainnet-api.algonode.cloud",this.algodIndexer="https://mainnet-idx.algonode.cloud"):e.network==="testnet"?(this.apiUrl="https://testnet-apigw.ultradedev.net",this.algodNode="https://testnet-api.algonode.cloud",this.algodIndexer="https://testnet-idx.algonode.cloud"):(this.apiUrl="http://localhost:5001",this.algodNode="http://localhost:4001",this.algodIndexer="http://localhost:8980"),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(Mt.create({baseURL:this.apiUrl})),this.localStorageService=new K,this.wallet=this.localStorageService.getMainWallet(),this.isUltradeID=!1,this.socketManager=new U(this.websocketUrl,e.socketIO,i=>{console.log(`Socket ${i} disconnected at`,new Date)},i=>{console.log(`Socket connect_error due to ${i}`)}),console.log("SDK Wallet",this.wallet)}axiosInterceptor=e=>{let t=["/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"],i=l=>l.withWalletCredentials||t.some(u=>l.url.includes(u)),n=l=>{let u=["/market/order"];return l.withWalletCredentials||u.some(h=>l.url.includes(h))},s=l=>["/wallet/signin","/market/account/kyc/init","/notifications"].some(h=>l.url.includes(h)),a=l=>["/social/"].some(h=>l.url.includes(h)),c=l=>t.some(u=>l.url.includes(u));return e.interceptors.request.use(l=>{if(this.wallet&&i(l)&&(l.headers["X-Wallet-Address"]=this.wallet.address,l.headers["X-Wallet-Token"]=this.wallet.token),this.wallet&&c(l)&&(l.headers.CompanyId=this.companyId),this.wallet&&n(l)){let u=this.wallet?.tradingKey;u&&(l.headers["X-Trading-Key"]=u)}return s(l)&&(l.headers.CompanyId=this.companyId),a(l)&&!l.headers.CompanyId&&(l.headers.CompanyId=this.isUltradeID?1:this.companyId),l},l=>Promise.reject(l)),e.interceptors.response.use(l=>l.data,async l=>(console.log("Request was failed",l),[401].includes(l?.response?.status)&&i(l.config)&&(this.wallet=null,this.localStorageService.clearMainWallet()),Promise.reject(l))),e};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 i=e.streams.some(n=>z.includes(n));return i&&!this.mainWallet?.token&&!this.mainWallet?.tradingKey?(e.streams=e.streams.filter(n=>!z.includes(n)),this.socketManager.subscribe(e,t)):i?(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}`)}getExchangeInfo(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,i,n,s=500,a=1){return this._axios.get(`/market/history?symbol=${e}&interval=${t}&startTime=${i??""}&endTime=${n??""}&limit=${s}&page=${a}`)}getOrders(e,t,i=50,n,s){let a=t?t===1?R.Open:[R.Canceled,R.Matched,R.SelfMatched,R.Expired].join(","):"",c=e?`&symbol=${e}`:"",l=a?`&status=${a}`:"",u=s?`&startTime=${s}`:"",h=n?`&endTime=${n}`:"";return this._axios.get(`/market/orders?limit=${i}${c}${l}${u}${h}`)}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,i=100){return this._axios.get(`/wallet/transactions?type=${e}&limit=${i}&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})}addWhitelist(e){e={...e,expiredDate:e.expiredDate&&Math.round(e.expiredDate/1e3)};let i=o.from(qt(e)).toString("hex");return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:n})=>this._axios.post("/wallet/whitelist",{message:i,signature:n}),"hex")}deleteWhitelist(e){let t={whitelistId:e};return this.client.signAndSendData(t,this.client.signer.signMessage,({signature:i})=>this._axios.delete("/wallet/whitelist",{data:{data:t,signature:i}}))}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})}countAffiliateDepost(e){return this._axios.post(`/affiliates/${e}/deposit `,{},{withWalletCredentials:!0})}countAffiliateClick(e){return this._axios.post("/affiliates/click",{referralToken:e},{withWalletCredentials:!0})}getSocialAccount(){return this._axios.get("/social/account",{withWalletCredentials:!0})}addSocialEmail(e,t){return this._axios.put("/social/account/email",{email:e,embeddedAppUrl:t},{withWalletCredentials:!0})}verifySocialEmail(e,t){return 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})}disconnectTelegram(e){return this._axios.put("/social/telegram/disconnect",e,{withWalletCredentials:!0})}getDiscordConnectionUrl(e){let t=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"";return this._axios.get(`/social/discord/connect${t}`,{withWalletCredentials:!0}).then(({url:i})=>i)}disconnectDiscord(){return this._axios.put("/social/discord/disconnect",{},{withWalletCredentials:!0})}getTwitterConnectionUrl(e,t){let i=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"",n=t?`&scopes=${t}`:"";return this._axios.get(`/social/twitter/connect${i}${n}`,{withWalletCredentials:!0}).then(({url:s})=>s)}disconnectTwitter(){return this._axios.put("/social/twitter/disconnect",{},{withWalletCredentials:!0})}getTweets(){return this._axios.get("/social/twitter/tweets",{withWalletCredentials:!0})}actionWithTweet(e){return this._axios.post("/social/twitter/tweet/actions",e,{withWalletCredentials:!0})}async getActions(){return this._axios.get("/social/actions",{withWalletCredentials:!0})}async 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 v.PERA:return"ALGORAND";case v.METAMASK:return"EVM";case v.SOLFLARE:case v.COINBASE:case v.PHANTOM:case v.BACKPACK:case v.MOBILE:return"SOLANA";default:throw new Error("Not implemented")}}login({address:e,provider:t,chain:i,referralToken:n,loginMessage:s}){let c=s||Xt,l={address:e,technology:this.getTechnologyByProvider(t)},u=o.from($t(l,c)).toString("hex");return this.client.signAndSendData(u,this.client.signer.signMessage,({signature:h})=>this._axios.put("/wallet/signin",{data:l,message:u,encoding:"hex",signature:h,referralToken:n}).then(f=>(this.mainWallet={address:e,provider:t,token:f,chain:i},f)),"hex")}addTradingKey(e){let i=o.from(ke(e,!0)).toString("hex"),{device:n,type:s}=e;return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/key",{data:{device:n,type:s},encoding:"hex",message:i,signature:a}).then(c=>(this.mainWallet&&c.type===Kt.User&&(this.mainWallet.tradingKey=c.address),c)),"hex")}revokeTradingKey(e){let i=o.from(ke(e,!1)).toString("hex"),{device:n,type:s}=e;return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:a})=>this._axios.delete("/wallet/key",{data:{data:{device:n,type:s},encoding:"hex",message:i,signature:a}}).then(()=>{this.mainWallet&&e.tkAddress===this.mainWallet.tradingKey&&(this.mainWallet.tradingKey=void 0)}),"hex")}withdraw(e,t){let n={...e,random:J(1,Number.MAX_SAFE_INTEGER)},s=o.from(Ft(n,t)).toString("hex");return this.client.signAndSendData(s,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/withdraw",{encoding:"hex",message:s,signature:a,destinationAddress:n.recipient}),"hex")}transfer(e){let i={...e,random:J(1,Number.MAX_SAFE_INTEGER)},n=o.from(Vt(i)).toString("hex");return this.client.signAndSendData(n,this.client.signer.signMessage,({signature:s})=>this._axios.post("/wallet/transfer",{message:n,signature:s}),"hex")}async createOrder(e){let t=Nt*24*60*60,i=Math.floor(Date.now()/1e3)+t,n={...e,version:Lt,expiredTime:i,random:J(1,Number.MAX_SAFE_INTEGER)};console.log("CreateOrderData",n);let s="hex",a=o.from(Yt(n)).toString(s);return await this.client.signAndSendData(a,this.client.signer.signMessageByToken,({signature:c})=>this._axios.post("/market/order",{encoding:s,message:a,signature:c}),s)}async cancelOrder(e){let t={orderId:e.orderId},i="hex",n=o.from(Ot(e)).toString(i);return this.client.signAndSendData(n,this.client.signer.signMessageByToken,({signature:s})=>this._axios.delete("/market/order",{data:{data:t,message:n,signature:s}}),i)}async cancelMultipleOrders({orderIds:e,pairId:t}){let i={orderIds:e,pairId:t};return this.client.signAndSendData(i,this.client.signer.signMessageByToken,({signature:n})=>this._axios.delete("/market/orders",{data:{data:i,signature:n}}))}async ping(){let e=this._axios.get("/system/time");return Math.round(Date.now()-e.currentTime)}};export{Ie as Client,U as SocketManager};
2
+ /*! Bundled license information:
3
+
4
+ @esbuild-plugins/node-globals-polyfill/Buffer.js:
5
+ (*!
6
+ * The buffer module from node.js, for the browser.
7
+ *
8
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
9
+ * @license MIT
10
+ *)
11
+ */
@@ -0,0 +1,35 @@
1
+ import algosdk, { Transaction, SuggestedParams } from 'algosdk';
2
+ import { AuthCredentials, OrderSide, Signer } from './interfaces';
3
+ export declare class AlgodService {
4
+ private client;
5
+ private authCredentials;
6
+ private indexerDomain;
7
+ constructor(algodClient: algosdk.Algodv2, credentials: AuthCredentials, indexerDomain: string);
8
+ isAppOptedIn(appLocalState: any, appId: number): boolean;
9
+ isAssetOptedIn(balances: any, assetId: number): boolean;
10
+ optInAsset(userAddress: string, assetIndex: number): Promise<Transaction>;
11
+ makeAppCallTransaction(assetIndex: number, senderAddress: string, appId: number, args: any[], params?: any): Promise<algosdk.Transaction>;
12
+ makeTransferTransaction(params: SuggestedParams, assetIndex: number, transferAmount: number, senderAddress: string, appAddress: string): Transaction | null;
13
+ get signer(): Signer;
14
+ set signer(value: Signer);
15
+ signAndSend(txnGroup: Transaction[] | Transaction): Promise<any>;
16
+ signAndSendData(data: object | string, signMessage: (msg: string, encoding?: BufferEncoding) => Promise<string>, sendAction: (signedData: {
17
+ signature: string;
18
+ }) => Promise<{
19
+ signature: string;
20
+ }>, encoding?: BufferEncoding): Promise<{
21
+ signature: string;
22
+ }>;
23
+ getTxnParams(): Promise<SuggestedParams>;
24
+ getCurrentAccount(): {
25
+ addr: string;
26
+ sk: Uint8Array;
27
+ } | null;
28
+ getAccountInfo(address: string): Promise<Record<string, any>>;
29
+ constructArgsForAppCall(...args: any[]): Uint8Array<ArrayBufferLike>[];
30
+ validateCredentials(): void;
31
+ getAppState(appId: number): Promise<{}>;
32
+ getSuperAppId(appId: number): Promise<any>;
33
+ getPairBalances(appId: number, address: string): Promise<any>;
34
+ calculateTransferAmount(appId: number, address: string, side: OrderSide, quantity: number, price: number, decimal: number): Promise<number>;
35
+ }
@@ -0,0 +1,143 @@
1
+ import { AxiosResponse } from "axios";
2
+ import { SocketManager } from "./sockets";
3
+ import { AuthCredentials, ClientOptions, CancelOrderArgs, CreateOrderArgs, Signer, SubscribeOptions, TelegramData, WalletCredentials, UserNotification } from "./interfaces";
4
+ import { ITradingKeyData } from '@ultrade/shared/interfaces';
5
+ import { ILoginData, ITransferData, IWithdrawData } from "@ultrade/shared/interfaces";
6
+ import { KYCAuthenticationStatus } from "@ultrade/shared/enums";
7
+ import { CreateWithdrawalWallet, UpdateWithdrawalWallet } from "@ultrade/shared/interfaces";
8
+ import { ISafeWithdrawalWallets } from "@ultrade/shared/interfaces";
9
+ export declare class Client {
10
+ private client;
11
+ private algodNode;
12
+ private algodIndexer;
13
+ private apiUrl;
14
+ private companyId;
15
+ private websocketUrl;
16
+ private wallet;
17
+ private _axios;
18
+ private localStorageService;
19
+ private isUltradeID;
20
+ socketManager: SocketManager;
21
+ constructor(options: ClientOptions, authCredentials?: AuthCredentials);
22
+ private axiosInterceptor;
23
+ get useUltradeID(): boolean;
24
+ set useUltradeID(isUltrade: boolean);
25
+ get isLogged(): boolean;
26
+ get mainWallet(): WalletCredentials | null;
27
+ set mainWallet(wallet: WalletCredentials);
28
+ setSigner(signer: Signer): void;
29
+ subscribe(subscribeOptions: SubscribeOptions, callback: Function): number;
30
+ unsubscribe(handlerId: number): void;
31
+ getPairList(companyId?: number): Promise<AxiosResponse<any, any>>;
32
+ getExchangeInfo(symbol: string | number): Promise<AxiosResponse<any, any>>;
33
+ getPrice(symbol: string): Promise<{
34
+ ask: number;
35
+ bid: number;
36
+ last: number;
37
+ }>;
38
+ getDepth(symbol: string, depth: number): Promise<any>;
39
+ getSymbols(mask?: string): Promise<Array<{
40
+ pairKey: string;
41
+ }>>;
42
+ getLastTrades(symbol: string): Promise<any>;
43
+ getHistory(symbol: string, interval: string, startTime?: number, endTime?: number, limit?: number, page?: number): Promise<any>;
44
+ getOrders(symbol?: string, status?: number, limit?: number, endTime?: number, startTime?: number): Promise<AxiosResponse<any, any>>;
45
+ getOrderById(orderId: number): Promise<any>;
46
+ getSettings(): Promise<any>;
47
+ getBalances(): Promise<any>;
48
+ getChains(): Promise<any>;
49
+ getCodexAssets(): Promise<any>;
50
+ getCCTPAssets(): Promise<any>;
51
+ getCCTPUnifiedAssets(): Promise<any>;
52
+ getWithdrawalFee(assetAddress: string, chainId: number): Promise<any>;
53
+ getKycStatus(): Promise<{
54
+ kycStatus?: KYCAuthenticationStatus;
55
+ }>;
56
+ getKycInitLink(embeddedAppUrl: string | null): Promise<{
57
+ url: string;
58
+ }>;
59
+ getDollarValues(assetIds?: number[]): Promise<{
60
+ [key: string]: number;
61
+ }>;
62
+ getTransactionDetalis(transactionId: number): Promise<any>;
63
+ getWalletTransactions(type: string, page: number, limit?: number): Promise<AxiosResponse<any, any>>;
64
+ getTradingKeys(): Promise<AxiosResponse<any, any>>;
65
+ getTransfers(page: number, limit?: number): Promise<AxiosResponse<any, any>>;
66
+ getPendingTransactions(): Promise<AxiosResponse<any, any>>;
67
+ getWhitelist(): Promise<AxiosResponse<any, any>>;
68
+ addWhitelist(data: any): Promise<{
69
+ signature: string;
70
+ }>;
71
+ deleteWhitelist(whitelistId: number): Promise<{
72
+ signature: string;
73
+ }>;
74
+ getAllWithdrawalWallets(): Promise<ISafeWithdrawalWallets[]>;
75
+ getWithdrawalWalletByAddress(address: string): Promise<ISafeWithdrawalWallets>;
76
+ createWithdrawalWallet(body: CreateWithdrawalWallet): Promise<ISafeWithdrawalWallets>;
77
+ updateWithdrawalWallet(params: UpdateWithdrawalWallet): Promise<boolean>;
78
+ deleteWithdrawalWallet(address: string): Promise<boolean>;
79
+ getVersion(): Promise<any>;
80
+ getMaintenance(): Promise<any>;
81
+ getNotifications(): Promise<UserNotification[]>;
82
+ getNotificationsUnreadCount(): Promise<{
83
+ count: number;
84
+ }>;
85
+ readNotifications(notifications: any[]): Promise<any>;
86
+ getAffiliatesStatus(companyId: number): Promise<AxiosResponse<any, any>>;
87
+ createAffiliate(companyId: number): Promise<AxiosResponse<any, any>>;
88
+ getAffiliateProgress(companyId: number): Promise<AxiosResponse<any, any>>;
89
+ getAffiliateInfo(companyId: number, range: string): Promise<AxiosResponse<any, any>>;
90
+ countAffiliateDepost(companyId: number): Promise<AxiosResponse<any, any>>;
91
+ countAffiliateClick(referralToken: string): Promise<AxiosResponse<any, any>>;
92
+ getSocialAccount(): Promise<AxiosResponse<any, any>>;
93
+ addSocialEmail(email: string, embeddedAppUrl: string): Promise<AxiosResponse<any, any>>;
94
+ verifySocialEmail(email: string, hash: string): Promise<AxiosResponse<any, any>>;
95
+ getLeaderboards(): Promise<AxiosResponse<any, any>>;
96
+ getUnlocks(): Promise<AxiosResponse<any, any>>;
97
+ getSocialSettings(): Promise<AxiosResponse<any, any>>;
98
+ getSeason(ultradeId?: number): Promise<AxiosResponse<any, any>>;
99
+ getPastSeasons(): Promise<AxiosResponse<any, any>>;
100
+ addTelegram(data: TelegramData): Promise<AxiosResponse<any, any>>;
101
+ disconnectTelegram(data: TelegramData): Promise<AxiosResponse<any, any>>;
102
+ getDiscordConnectionUrl(url: any): Promise<any>;
103
+ disconnectDiscord(): Promise<AxiosResponse<any, any>>;
104
+ getTwitterConnectionUrl(appUrl: string, permissions?: string): Promise<any>;
105
+ disconnectTwitter(): Promise<AxiosResponse<any, any>>;
106
+ getTweets(): Promise<AxiosResponse<any, any>>;
107
+ actionWithTweet(data: {
108
+ actions: [{
109
+ id: number;
110
+ text?: string;
111
+ }];
112
+ tweetId?: string;
113
+ }): Promise<AxiosResponse<any, any>>;
114
+ getActions(): Promise<AxiosResponse<any, any>>;
115
+ getActionHistory(): Promise<AxiosResponse<any, any>>;
116
+ getAIStyles(): Promise<AxiosResponse<any, any>>;
117
+ getAIComment(styleId: number, tweetId: string): Promise<AxiosResponse<any, any>>;
118
+ private getTechnologyByProvider;
119
+ login({ address, provider, chain, referralToken, loginMessage }: ILoginData): Promise<{
120
+ signature: string;
121
+ }>;
122
+ addTradingKey(data: ITradingKeyData): Promise<{
123
+ signature: string;
124
+ }>;
125
+ revokeTradingKey(data: ITradingKeyData): Promise<{
126
+ signature: string;
127
+ }>;
128
+ withdraw(withdrawData: IWithdrawData, prettyMsg?: string): Promise<{
129
+ signature: string;
130
+ }>;
131
+ transfer(transferData: ITransferData): Promise<{
132
+ signature: string;
133
+ }>;
134
+ createOrder(order: CreateOrderArgs): Promise<{
135
+ signature: string;
136
+ }>;
137
+ cancelOrder(order: CancelOrderArgs): Promise<any>;
138
+ cancelMultipleOrders({ orderIds, pairId }: {
139
+ orderIds?: number[];
140
+ pairId?: number;
141
+ }): Promise<any>;
142
+ ping(): Promise<number>;
143
+ }
@@ -0,0 +1,34 @@
1
+ export declare enum DIRECT_SETTLE {
2
+ YES = "Y",
3
+ NO = "N"
4
+ }
5
+ export declare enum ORDER_STATUS {
6
+ OPEN_ORDER = 1,
7
+ CANCELLED = 2,
8
+ MATCHED = 3,
9
+ SELF_MATCHED = 4
10
+ }
11
+ export declare enum STREAMS {
12
+ QUOTE = 1,
13
+ LAST_PRICE = 2,
14
+ DEPTH = 3,
15
+ LAST_CANDLESTICK = 4,
16
+ ORDERS = 5,
17
+ TRADES = 6,
18
+ SYSTEM = 7,
19
+ WALLET_TRANSACTIONS = 8,
20
+ ALL_STAT = 9,
21
+ CODEX_ASSETS = 12,
22
+ CODEX_BALANCES = 10,
23
+ LAST_LOOK = 11,
24
+ SETTINGS_UPDATE = 13,
25
+ NEW_NOTIFICATION = 14,
26
+ POINT_SYSTEM_SETTINGS_UPDATE = 15
27
+ }
28
+ export declare const PRIVATE_STREAMS: STREAMS[];
29
+ export declare enum SOCIAL_ACTION_SOURCE {
30
+ COMPANY = "COMPANY",
31
+ TWITTER = "TWITTER",
32
+ DISCORD = "DISCORD",
33
+ TELEGRAM = "TELEGRAM"
34
+ }
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export { SocketManager } from './sockets';
@@ -0,0 +1,136 @@
1
+ import { STREAMS } from "./enums";
2
+ export interface Signer {
3
+ signAndSend: ([]: any[]) => any;
4
+ signMessage: (msg: string, encoding?: BufferEncoding) => Promise<string>;
5
+ signMessageByToken: (msg: string, encoding?: BufferEncoding) => Promise<string>;
6
+ }
7
+ export interface TelegramData {
8
+ auth_date: number;
9
+ id: number;
10
+ first_name: string;
11
+ hash: string;
12
+ photo_url: string;
13
+ username: string;
14
+ }
15
+ export interface AppSocketState {
16
+ address: string;
17
+ appId: number;
18
+ orderFilter: string;
19
+ pairKey: string;
20
+ pairId: number;
21
+ }
22
+ export interface AuthCredentials {
23
+ company: string;
24
+ clientId?: string;
25
+ clientSecret?: string;
26
+ mnemonic?: string;
27
+ signer: Signer;
28
+ }
29
+ export interface WalletCredentials {
30
+ address: string;
31
+ chain: string;
32
+ provider: string;
33
+ token: string;
34
+ tradingKey?: string;
35
+ }
36
+ export interface SocketIOClient {
37
+ connected: boolean;
38
+ id: string;
39
+ on: (event: string, handler: (...args: unknown[]) => void) => void;
40
+ off: (event: string, handler?: (...args: unknown[]) => void) => void;
41
+ emit: (event: string, ...args: unknown[]) => void;
42
+ onAny: (handler: (event: string, ...args: unknown[]) => void) => void;
43
+ disconnect: () => void;
44
+ io: {
45
+ on: (event: string, handler: (...args: unknown[]) => void) => void;
46
+ off: (event: string, handler?: (...args: unknown[]) => void) => void;
47
+ };
48
+ }
49
+ export interface SocketIOFactory {
50
+ (url: string, options?: unknown): SocketIOClient;
51
+ }
52
+ export interface ClientOptions {
53
+ network: 'mainnet' | 'testnet' | 'local';
54
+ apiUrl?: string;
55
+ algoSdkClient: any;
56
+ websocketUrl: string;
57
+ companyId?: number;
58
+ socketIO: SocketIOFactory;
59
+ }
60
+ export interface CancelOrderArgs {
61
+ orderId: number;
62
+ orderSide: OrderSide;
63
+ orderType: OrderType;
64
+ amount: string;
65
+ price: string;
66
+ baseTokenAddress: string;
67
+ baseChain: string;
68
+ baseCurrency: string;
69
+ baseDecimal: number;
70
+ priceTokenAddress: string;
71
+ priceChain: string;
72
+ priceCurrency: string;
73
+ priceDecimal: number;
74
+ }
75
+ export interface CreateOrderArgs {
76
+ pairId: number;
77
+ companyId: number;
78
+ orderSide: OrderSide;
79
+ orderType: OrderType;
80
+ amount: string;
81
+ price: string;
82
+ decimalPrice: number;
83
+ address: string;
84
+ chainId: number;
85
+ baseTokenAddress: string;
86
+ baseTokenChainId: number;
87
+ baseChain: string;
88
+ baseCurrency: string;
89
+ baseDecimal: number;
90
+ priceTokenAddress: string;
91
+ priceTokenChainId: number;
92
+ priceChain: string;
93
+ priceCurrency: string;
94
+ priceDecimal: number;
95
+ }
96
+ export interface SubscribeOptions {
97
+ symbol: string;
98
+ streams: STREAMS[];
99
+ options: WSOptions;
100
+ }
101
+ interface WSOptions {
102
+ address: string;
103
+ token?: string;
104
+ tradingKey?: string;
105
+ message?: string;
106
+ signature?: string;
107
+ depth?: number;
108
+ companyId?: number;
109
+ interval?: string;
110
+ }
111
+ export interface ServerToClientEvents {
112
+ reconnect: () => void;
113
+ }
114
+ export interface ClientToServerEvents {
115
+ subscribe: (options: SubscribeOptions) => void;
116
+ unsubscribe: (options: SubscribeOptions) => void;
117
+ }
118
+ export interface TxnParams {
119
+ suggestedParams: any;
120
+ from: string;
121
+ to: string;
122
+ amount: number;
123
+ assetIndex?: number;
124
+ }
125
+ export type OrderSide = 'S' | 'B';
126
+ export type OrderType = 'L' | 'I' | 'P' | 'M';
127
+ export interface UserNotification {
128
+ id: number;
129
+ globalNotificationId: number;
130
+ priority: any;
131
+ status: any;
132
+ type: any;
133
+ message: string;
134
+ createdAt: Date;
135
+ }
136
+ export {};
@@ -0,0 +1,9 @@
1
+ import { WalletCredentials } from './interfaces';
2
+ export declare class LocalStorageService {
3
+ private isBrowser;
4
+ private keys;
5
+ constructor();
6
+ setMainWallet(mainWallet: WalletCredentials): void;
7
+ getMainWallet(): WalletCredentials | null;
8
+ clearMainWallet(): void;
9
+ }
@@ -0,0 +1,30 @@
1
+ import { SubscribeOptions, SocketIOFactory, SocketIOClient } from './interfaces';
2
+ export declare class SocketManager {
3
+ private onDisconnect?;
4
+ private onConnectError?;
5
+ private socket;
6
+ private socketPool;
7
+ private websocketUrl;
8
+ private socketIOFactory;
9
+ constructor(url: string, socketIOFactory: SocketIOFactory, onDisconnect?: (socketId: string) => void, onConnectError?: (error: Error) => void);
10
+ private initializeSocket;
11
+ getSocket(): SocketIOClient | null;
12
+ subscribe(subscribeOptions: SubscribeOptions, callback: Function): number;
13
+ unsubscribe(handlerId: number): void;
14
+ disconnect(): void;
15
+ isConnected(): boolean;
16
+ on(event: string, handler: (...args: unknown[]) => void): void;
17
+ off(event: string, handler?: (...args: unknown[]) => void): void;
18
+ emit(event: string, ...args: unknown[]): void;
19
+ emitCurrentPair(data: {
20
+ address: string;
21
+ pair: string;
22
+ pair_id: number;
23
+ order_filter: string;
24
+ }): void;
25
+ emitOrderFilter(data: {
26
+ order_filter: string;
27
+ }): void;
28
+ onReconnect(handler: () => void): () => void;
29
+ offReconnect(handler?: () => void): void;
30
+ }
@@ -0,0 +1,2 @@
1
+ export declare const unpackData: (data: any) => any;
2
+ export declare const decodeString: (value: Uint8Array) => string;
package/package.json CHANGED
@@ -1,47 +1,36 @@
1
1
  {
2
2
  "name": "@ultrade/ultrade-js-sdk",
3
- "version": "0.2.7",
4
- "description": "Javascript SDK for interaction with the Ultrade AMM system",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "/dist"
9
- ],
10
- "directories": {
11
- "test": "tests"
12
- },
3
+ "version": "2.0.1",
4
+ "description": "This package contains the original js/ts SDK.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "type": "module",
13
9
  "scripts": {
14
- "build": "npm run clean && tsc",
15
- "test": "ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.spec.ts",
16
- "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
17
- "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
18
- "prepack": "npm run build",
19
- "clean": "rm -rf ./dist"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/ultrade-org/JS-SDK.git"
24
- },
25
- "author": "",
26
- "license": "ISC",
27
- "bugs": {
28
- "url": "https://github.com/ultrade-org/JS-SDK/issues"
10
+ "build": "cross-env MODE=production ts-node --esm esbuild.config.ts",
11
+ "dev": "ts-node --esm esbuild.config.ts",
12
+ "version:update": "npm version patch"
29
13
  },
30
- "homepage": "https://github.com/ultrade-org/JS-SDK#readme",
14
+ "files": [
15
+ "dist"
16
+ ],
31
17
  "devDependencies": {
32
- "@types/chai": "^4.3.1",
33
- "@types/mocha": "^9.1.1",
34
- "@types/node": "^18.0.6",
35
- "chai": "^4.3.6",
36
- "dotenv": "^16.0.1",
37
- "mocha": "^10.0.0",
38
- "prettier": "^2.7.1",
39
- "ts-mocha": "^10.0.0",
40
- "ts-node": "^10.9.1",
41
- "typescript": "^4.7.4"
18
+ "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
19
+ "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
20
+ "@types/node": "^18.19.130",
21
+ "cross-env": "^10.1.0",
22
+ "esbuild": "^0.27.0",
23
+ "esbuild-plugin-d.ts": "^1.3.1",
24
+ "ts-loader": "^9.2.3",
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5.6.3"
42
27
  },
43
- "dependencies": {
44
- "algosdk": "^2.1.0"
28
+ "peerDependencies": {
29
+ "algosdk": "^2.0.0",
30
+ "axios": "^0.27.2",
31
+ "react-secure-storage": "^1.3.2"
45
32
  },
46
- "keywords": ["Ultrade", "DEX", "AMM", "SDK"]
33
+ "dependencies": {
34
+ "@ultrade/shared": "^1.0.8"
35
+ }
47
36
  }