@multiversx/sdk-dapp-swap
Version:
A library to hold the main logic for swapping between tokens on the MultiversX blockchain
234 lines (228 loc) • 37.5 kB
JavaScript
"use strict";var nr=Object.create;var ne=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols,sr=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var et=(r,e,t)=>e in r?ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,G=(r,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&et(r,t,e[t]);if(me)for(var t of me(e))tt.call(e,t)&&et(r,t,e[t]);return r};var rt=(r,e)=>{var t={};for(var n in r)Ee.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&me)for(var n of me(r))e.indexOf(n)<0&&tt.call(r,n)&&(t[n]=r[n]);return t};var ar=(r,e)=>()=>(r&&(e=r(r=0)),e);var le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ur=(r,e)=>{for(var t in e)ne(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ir(e))!Ee.call(r,o)&&o!==t&&ne(r,o,{get:()=>e[o],enumerable:!(n=or(e,o))||n.enumerable});return r};var A=(r,e,t)=>(t=r!=null?nr(sr(r)):{},nt(e||!r||!r.__esModule?ne(t,"default",{value:r,enumerable:!0}):t,r)),cr=r=>nt(ne({},"__esModule",{value:!0}),r);var st=le(he=>{"use strict";i();he.byteLength=fr;he.toByteArray=lr;he.fromByteArray=yr;var v=[],b=[],pr=typeof Uint8Array!="undefined"?Uint8Array:Array,Ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(V=0,ot=Ae.length;V<ot;++V)v[V]=Ae[V],b[Ae.charCodeAt(V)]=V;var V,ot;b["-".charCodeAt(0)]=62;b["_".charCodeAt(0)]=63;function it(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function fr(r){var e=it(r),t=e[0],n=e[1];return(t+n)*3/4-n}function mr(r,e,t){return(e+t)*3/4-t}function lr(r){var e,t=it(r),n=t[0],o=t[1],s=new pr(mr(r,n,o)),a=0,l=o>0?n-4:n,m;for(m=0;m<l;m+=4)e=b[r.charCodeAt(m)]<<18|b[r.charCodeAt(m+1)]<<12|b[r.charCodeAt(m+2)]<<6|b[r.charCodeAt(m+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=e&255;return o===2&&(e=b[r.charCodeAt(m)]<<2|b[r.charCodeAt(m+1)]>>4,s[a++]=e&255),o===1&&(e=b[r.charCodeAt(m)]<<10|b[r.charCodeAt(m+1)]<<4|b[r.charCodeAt(m+2)]>>2,s[a++]=e>>8&255,s[a++]=e&255),s}function hr(r){return v[r>>18&63]+v[r>>12&63]+v[r>>6&63]+v[r&63]}function dr(r,e,t){for(var n,o=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),o.push(hr(n));return o.join("")}function yr(r){for(var e,t=r.length,n=t%3,o=[],s=16383,a=0,l=t-n;a<l;a+=s)o.push(dr(r,a,a+s>l?l:a+s));return n===1?(e=r[t-1],o.push(v[e>>2]+v[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],o.push(v[e>>10]+v[e>>4&63]+v[e<<2&63]+"=")),o.join("")}});var at=le(ke=>{i();ke.read=function(r,e,t,n,o){var s,a,l=o*8-n-1,m=(1<<l)-1,y=m>>1,d=-7,h=t?o-1:0,T=t?-1:1,x=r[e+h];for(h+=T,s=x&(1<<-d)-1,x>>=-d,d+=l;d>0;s=s*256+r[e+h],h+=T,d-=8);for(a=s&(1<<-d)-1,s>>=-d,d+=n;d>0;a=a*256+r[e+h],h+=T,d-=8);if(s===0)s=1-y;else{if(s===m)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),s=s-y}return(x?-1:1)*a*Math.pow(2,s-n)};ke.write=function(r,e,t,n,o,s){var a,l,m,y=s*8-o-1,d=(1<<y)-1,h=d>>1,T=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:s-1,U=n?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,a=d):(a=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-a))<1&&(a--,m*=2),a+h>=1?e+=T/m:e+=T*Math.pow(2,1-h),e*m>=2&&(a++,m/=2),a+h>=d?(l=0,a=d):a+h>=1?(l=(e*m-1)*Math.pow(2,o),a=a+h):(l=e*Math.pow(2,h-1)*Math.pow(2,o),a=0));o>=8;r[t+x]=l&255,x+=U,l/=256,o-=8);for(a=a<<o|l,y+=o;y>0;r[t+x]=a&255,x+=U,a/=256,y-=8);r[t+x-U]|=I*128}});var wt=le(j=>{"use strict";i();var Se=st(),H=at(),ut=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=u;j.SlowBuffer=Er;j.INSPECT_MAX_BYTES=50;var de=2147483647;j.kMaxLength=de;u.TYPED_ARRAY_SUPPORT=gr();!u.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function gr(){try{var r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch(t){return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(!!u.isBuffer(this))return this.buffer}});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(!!u.isBuffer(this))return this.byteOffset}});function N(r){if(r>de)throw new RangeError('The value "'+r+'" is invalid for option "size"');var e=new Uint8Array(r);return Object.setPrototypeOf(e,u.prototype),e}function u(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Pe(r)}return ft(r,e,t)}u.poolSize=8192;function ft(r,e,t){if(typeof r=="string")return xr(r,e);if(ArrayBuffer.isView(r))return wr(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(B(r,ArrayBuffer)||r&&B(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(B(r,SharedArrayBuffer)||r&&B(r.buffer,SharedArrayBuffer)))return be(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return u.from(n,e,t);var o=Ir(r);if(o)return o;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return u.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}u.from=function(r,e,t){return ft(r,e,t)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function mt(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Tr(r,e,t){return mt(r),r<=0?N(r):e!==void 0?typeof t=="string"?N(r).fill(e,t):N(r).fill(e):N(r)}u.alloc=function(r,e,t){return Tr(r,e,t)};function Pe(r){return mt(r),N(r<0?0:Ue(r)|0)}u.allocUnsafe=function(r){return Pe(r)};u.allocUnsafeSlow=function(r){return Pe(r)};function xr(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var t=lt(r,e)|0,n=N(t),o=n.write(r,e);return o!==t&&(n=n.slice(0,o)),n}function Fe(r){for(var e=r.length<0?0:Ue(r.length)|0,t=N(e),n=0;n<e;n+=1)t[n]=r[n]&255;return t}function wr(r){if(B(r,Uint8Array)){var e=new Uint8Array(r);return be(e.buffer,e.byteOffset,e.byteLength)}return Fe(r)}function be(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');var n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,u.prototype),n}function Ir(r){if(u.isBuffer(r)){var e=Ue(r.length)|0,t=N(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||ve(r.length)?N(0):Fe(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Fe(r.data)}function Ue(r){if(r>=de)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+de.toString(16)+" bytes");return r|0}function Er(r){return+r!=r&&(r=0),u.alloc(+r)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype};u.compare=function(e,t){if(B(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),B(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,o=t.length,s=0,a=Math.min(n,o);s<a;++s)if(e[s]!==t[s]){n=e[s],o=t[s];break}return n<o?-1:o<n?1:0};u.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}};u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var o=u.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){var a=e[n];if(B(a,Uint8Array))s+a.length>o.length?u.from(a).copy(o,s):Uint8Array.prototype.set.call(o,a,s);else if(u.isBuffer(a))a.copy(o,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return o};function lt(r,e){if(u.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||B(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return De(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return xt(r).length;default:if(o)return n?-1:De(r).length;e=(""+e).toLowerCase(),o=!0}}u.byteLength=lt;function Ar(r,e,t){var n=!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 Rr(this,e,t);case"utf8":case"utf-8":return dt(this,e,t);case"ascii":return vr(this,e,t);case"latin1":case"binary":return Br(this,e,t);case"base64":return Pr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Or(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function Q(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}u.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)Q(this,t,t+1);return this};u.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)Q(this,t,t+3),Q(this,t+1,t+2);return this};u.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)Q(this,t,t+7),Q(this,t+1,t+6),Q(this,t+2,t+5),Q(this,t+3,t+4);return this};u.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?dt(this,0,e):Ar.apply(this,arguments)};u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:u.compare(this,e)===0};u.prototype.inspect=function(){var e="",t=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};ut&&(u.prototype[ut]=u.prototype.inspect);u.prototype.compare=function(e,t,n,o,s){if(B(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),s===void 0&&(s=this.length),t<0||n>e.length||o<0||s>this.length)throw new RangeError("out of range index");if(o>=s&&t>=n)return 0;if(o>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,s>>>=0,this===e)return 0;for(var a=s-o,l=n-t,m=Math.min(a,l),y=this.slice(o,s),d=e.slice(t,n),h=0;h<m;++h)if(y[h]!==d[h]){a=y[h],l=d[h];break}return a<l?-1:l<a?1:0};function ht(r,e,t,n,o){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ve(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return-1;t=r.length-1}else if(t<0)if(o)t=0;else return-1;if(typeof e=="string"&&(e=u.from(e,n)),u.isBuffer(e))return e.length===0?-1:ct(r,e,t,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ct(r,[e],t,n,o);throw new TypeError("val must be string, number or Buffer")}function ct(r,e,t,n,o){var s=1,a=r.length,l=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,a/=2,l/=2,t/=2}function m(x,U){return s===1?x[U]:x.readUInt16BE(U*s)}var y;if(o){var d=-1;for(y=t;y<a;y++)if(m(r,y)===m(e,d===-1?0:y-d)){if(d===-1&&(d=y),y-d+1===l)return d*s}else d!==-1&&(y-=y-d),d=-1}else for(t+l>a&&(t=a-l),y=t;y>=0;y--){for(var h=!0,T=0;T<l;T++)if(m(r,y+T)!==m(e,T)){h=!1;break}if(h)return y}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};u.prototype.indexOf=function(e,t,n){return ht(this,e,t,n,!0)};u.prototype.lastIndexOf=function(e,t,n){return ht(this,e,t,n,!1)};function kr(r,e,t,n){t=Number(t)||0;var o=r.length-t;n?(n=Number(n),n>o&&(n=o)):n=o;var s=e.length;n>s/2&&(n=s/2);for(var a=0;a<n;++a){var l=parseInt(e.substr(a*2,2),16);if(ve(l))return a;r[t+a]=l}return a}function Sr(r,e,t,n){return ye(De(e,r.length-t),r,t,n)}function Fr(r,e,t,n){return ye(Nr(e),r,t,n)}function br(r,e,t,n){return ye(xt(e),r,t,n)}function Dr(r,e,t,n){return ye(_r(e,r.length-t),r,t,n)}u.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return kr(this,e,t,n);case"utf8":case"utf-8":return Sr(this,e,t,n);case"ascii":case"latin1":case"binary":return Fr(this,e,t,n);case"base64":return br(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dr(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Pr(r,e,t){return e===0&&t===r.length?Se.fromByteArray(r):Se.fromByteArray(r.slice(e,t))}function dt(r,e,t){t=Math.min(r.length,t);for(var n=[],o=e;o<t;){var s=r[o],a=null,l=s>239?4:s>223?3:s>191?2:1;if(o+l<=t){var m,y,d,h;switch(l){case 1:s<128&&(a=s);break;case 2:m=r[o+1],(m&192)===128&&(h=(s&31)<<6|m&63,h>127&&(a=h));break;case 3:m=r[o+1],y=r[o+2],(m&192)===128&&(y&192)===128&&(h=(s&15)<<12|(m&63)<<6|y&63,h>2047&&(h<55296||h>57343)&&(a=h));break;case 4:m=r[o+1],y=r[o+2],d=r[o+3],(m&192)===128&&(y&192)===128&&(d&192)===128&&(h=(s&15)<<18|(m&63)<<12|(y&63)<<6|d&63,h>65535&&h<1114112&&(a=h))}}a===null?(a=65533,l=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=l}return Ur(n)}var pt=4096;function Ur(r){var e=r.length;if(e<=pt)return String.fromCharCode.apply(String,r);for(var t="",n=0;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=pt));return t}function vr(r,e,t){var n="";t=Math.min(r.length,t);for(var o=e;o<t;++o)n+=String.fromCharCode(r[o]&127);return n}function Br(r,e,t){var n="";t=Math.min(r.length,t);for(var o=e;o<t;++o)n+=String.fromCharCode(r[o]);return n}function Rr(r,e,t){var n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);for(var o="",s=e;s<t;++s)o+=Mr[r[s]];return o}function Or(r,e,t){for(var n=r.slice(e,t),o="",s=0;s<n.length-1;s+=2)o+=String.fromCharCode(n[s]+n[s+1]*256);return o}u.prototype.slice=function(e,t){var n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);var o=this.subarray(e,t);return Object.setPrototypeOf(o,u.prototype),o};function w(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")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||w(e,t,this.length);for(var o=this[e],s=1,a=0;++a<t&&(s*=256);)o+=this[e+a]*s;return o};u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||w(e,t,this.length);for(var o=this[e+--t],s=1;t>0&&(s*=256);)o+=this[e+--t]*s;return o};u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e=e>>>0,t||w(e,1,this.length),this[e]};u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||w(e,2,this.length),this[e]|this[e+1]<<8};u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||w(e,2,this.length),this[e]<<8|this[e+1]};u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||w(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||w(e,t,this.length);for(var o=this[e],s=1,a=0;++a<t&&(s*=256);)o+=this[e+a]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};u.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||w(e,t,this.length);for(var o=t,s=1,a=this[e+--o];o>0&&(s*=256);)a+=this[e+--o]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*t)),a};u.prototype.readInt8=function(e,t){return e=e>>>0,t||w(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};u.prototype.readInt16LE=function(e,t){e=e>>>0,t||w(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(e,t){e=e>>>0,t||w(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(e,t){return e=e>>>0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function(e,t){return e=e>>>0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readFloatLE=function(e,t){return e=e>>>0,t||w(e,4,this.length),H.read(this,e,!0,23,4)};u.prototype.readFloatBE=function(e,t){return e=e>>>0,t||w(e,4,this.length),H.read(this,e,!1,23,4)};u.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||w(e,8,this.length),H.read(this,e,!0,52,8)};u.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||w(e,8,this.length),H.read(this,e,!1,52,8)};function E(r,e,t,n,o,s){if(!u.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){var s=Math.pow(2,8*n)-1;E(this,e,t,n,s,0)}var a=1,l=0;for(this[t]=e&255;++l<n&&(a*=256);)this[t+l]=e/a&255;return t+n};u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){var s=Math.pow(2,8*n)-1;E(this,e,t,n,s,0)}var a=n-1,l=1;for(this[t+a]=e&255;--a>=0&&(l*=256);)this[t+a]=e/l&255;return t+n};u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,1,255,0),this[t]=e&255,t+1};u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};u.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){var s=Math.pow(2,8*n-1);E(this,e,t,n,s-1,-s)}var a=0,l=1,m=0;for(this[t]=e&255;++a<n&&(l*=256);)e<0&&m===0&&this[t+a-1]!==0&&(m=1),this[t+a]=(e/l>>0)-m&255;return t+n};u.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){var s=Math.pow(2,8*n-1);E(this,e,t,n,s-1,-s)}var a=n-1,l=1,m=0;for(this[t+a]=e&255;--a>=0&&(l*=256);)e<0&&m===0&&this[t+a+1]!==0&&(m=1),this[t+a]=(e/l>>0)-m&255;return t+n};u.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};u.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};u.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};u.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};u.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||E(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function yt(r,e,t,n,o,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function gt(r,e,t,n,o){return e=+e,t=t>>>0,o||yt(r,e,t,4,34028234663852886e22,-34028234663852886e22),H.write(r,e,t,n,23,4),t+4}u.prototype.writeFloatLE=function(e,t,n){return gt(this,e,t,!0,n)};u.prototype.writeFloatBE=function(e,t,n){return gt(this,e,t,!1,n)};function Tt(r,e,t,n,o){return e=+e,t=t>>>0,o||yt(r,e,t,8,17976931348623157e292,-17976931348623157e292),H.write(r,e,t,n,52,8),t+8}u.prototype.writeDoubleLE=function(e,t,n){return Tt(this,e,t,!0,n)};u.prototype.writeDoubleBE=function(e,t,n){return Tt(this,e,t,!1,n)};u.prototype.copy=function(e,t,n,o){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);var s=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),s};u.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){var s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var a;if(typeof e=="number")for(a=t;a<n;++a)this[a]=e;else{var l=u.isBuffer(e)?e:u.from(e,o),m=l.length;if(m===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-t;++a)this[a+t]=l[a%m]}return this};var Lr=/[^+/0-9A-Za-z-_]/g;function Cr(r){if(r=r.split("=")[0],r=r.trim().replace(Lr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function De(r,e){e=e||1/0;for(var t,n=r.length,o=null,s=[],a=0;a<n;++a){if(t=r.charCodeAt(a),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=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 Nr(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function _r(r,e){for(var t,n,o,s=[],a=0;a<r.length&&!((e-=2)<0);++a)t=r.charCodeAt(a),n=t>>8,o=t%256,s.push(o),s.push(n);return s}function xt(r){return Se.toByteArray(Cr(r))}function ye(r,e,t,n){for(var o=0;o<n&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function B(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function ve(r){return r!==r}var Mr=function(){for(var r="0123456789abcdef",e=new Array(256),t=0;t<16;++t)for(var n=t*16,o=0;o<16;++o)e[n+o]=r[t]+r[o];return e}()});var St=le((Sn,kt)=>{i();var g=kt.exports={},R,O;function Be(){throw new Error("setTimeout has not been defined")}function Re(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?R=setTimeout:R=Be}catch(r){R=Be}try{typeof clearTimeout=="function"?O=clearTimeout:O=Re}catch(r){O=Re}})();function It(r){if(R===setTimeout)return setTimeout(r,0);if((R===Be||!R)&&setTimeout)return R=setTimeout,setTimeout(r,0);try{return R(r,0)}catch(e){try{return R.call(null,r,0)}catch(t){return R.call(this,r,0)}}}function $r(r){if(O===clearTimeout)return clearTimeout(r);if((O===Re||!O)&&clearTimeout)return O=clearTimeout,clearTimeout(r);try{return O(r)}catch(e){try{return O.call(null,r)}catch(t){return O.call(this,r)}}}var _=[],X=!1,W,ge=-1;function Gr(){!X||!W||(X=!1,W.length?_=W.concat(_):ge=-1,_.length&&Et())}function Et(){if(!X){var r=It(Gr);X=!0;for(var e=_.length;e;){for(W=_,_=[];++ge<e;)W&&W[ge].run();ge=-1,e=_.length}W=null,X=!1,$r(r)}}g.nextTick=function(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];_.push(new At(r,e)),_.length===1&&!X&&It(Et)};function At(r,e){this.fun=r,this.array=e}At.prototype.run=function(){this.fun.apply(null,this.array)};g.title="browser";g.browser=!0;g.env={};g.argv=[];g.version="";g.versions={};function M(){}g.on=M;g.addListener=M;g.once=M;g.off=M;g.removeListener=M;g.removeAllListeners=M;g.emit=M;g.prependListener=M;g.prependOnceListener=M;g.listeners=function(r){return[]};g.binding=function(r){throw new Error("process.binding is not supported")};g.cwd=function(){return"/"};g.chdir=function(r){throw new Error("process.chdir is not supported")};g.umask=function(){return 0}});var c,p,Fn,i=ar(()=>{c=A(wt()),p=A(St()),Fn=function(r){function e(){var n=this||self;return delete r.prototype.__magic__,n}if(typeof globalThis=="object")return globalThis;if(this)return e();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:e});var t=__magic__;return t}(Object)});var wn={};ur(wn,{useSwapRoute:()=>xn});module.exports=cr(wn);i();var D=require("react"),Jt=A(require("bignumber.js"));i();i();var bt=A(require("react")),oe=require("@apollo/client"),Qr=require("@apollo/client/link/context"),Wr=require("@apollo/client/link/error"),zr=require("@apollo/client/link/ws"),Hr=require("@apollo/client/utilities"),jr=require("graphql");i();i();var Te=require("react"),Ft=(0,Te.createContext)({accessToken:"",isAuthenticated:!1}),L=()=>{let r=(0,Te.useContext)(Ft);if(r==null)throw new Error("useAuthorizationContext must be used within a AuthorizationProvider");return r};i();var Z="EGLD";i();i();i();var C=`
balance
decimals
name
identifier
ticker
owner
assets {
website
description
status
pngUrl
svgUrl
}
price
type
previous24hPrice
previous7dPrice
`;i();i();i();var xe=`
assets {
website
description
status
pngUrl
svgUrl
}
decimals
name
collection
ticker
`;var Dt=`
address
lockedToken {
${xe}
}
lpProxyToken {
${xe}
}
farmProxyToken {
${xe}
}
intermediatedPairs
intermediatedFarms
`;var Oe=`
address
firstToken {
${C}
}
secondToken {
${C}
}
type
feesAPR
totalFeePercent
specialFeePercent
lockedTokensInfo {
lockingSC {
${Dt}
}
unlockEpoch
}
`;i();var K=`
value
receiver
gasPrice
gasLimit
data
chainID
version
`;i();var Le=`
defaultSlippage
slippageValues
minSlippage
maxSlippage
minSwapAmount
`;i();var Xr=`
__typename
valueUSD
`,Pt=`
${C}
${Xr}
`;i();i();var Ce=require("@apollo/client");var Ne="TRANSACTIONS_PLACEHOLDER",Zr=`
transactions {
${K}
}
`,Ut=`
query swapPackageSwapRoute (
$amountIn: String
$amountOut: String
$tokenInID: String!
$tokenOutID: String!
$tolerance: Float!
) {
swap(
amountIn: $amountIn
amountOut: $amountOut
tokenInID: $tokenInID
tokenOutID: $tokenOutID
tolerance: $tolerance
) {
amountIn
tokenInID
tokenInPriceUSD
tokenInExchangeRateDenom
amountOut
tokenOutID
tokenOutPriceUSD
tokenOutExchangeRateDenom
fees
swapType
tokenRoute
pricesImpact
maxPriceDeviationPercent
tokensPriceDeviationPercent
intermediaryAmounts
pairs {
${Oe}
}
smartSwap {
feeAmount
feePercentage
amountOut
tokenOutExchangeRateDenom
tokenInExchangeRateDenom
tokensPriceDeviationPercent
routes {
pairs {
${Oe}
}
tokenRoute
pricesImpact
intermediaryAmounts
fees
}
}
${Ne}
}
}
`,vt=Ce.gql`
${Ut.replace(Ne,Zr)}
`,Bt=Ce.gql`
${Ut.replace(Ne,"")}
`;i();i();var _e=require("@apollo/client");var Kr=_e.gql`
query swapPackageFilteredTokens ($enabledSwaps: Boolean, $pagination: ConnectionArgs, $searchInput: String, $identifiers: [String!]) {
filteredTokens (pagination: $pagination, filters: {searchToken: $searchInput, enabledSwaps: $enabledSwaps, identifiers: $identifiers}) {
edges {
node {
${C}
}
cursor
}
pageInfo {
hasNextPage
}
pageData {
count
}
}
wrappingInfo {
wrappedToken {
${C}
}
}
factory {
${Le}
}
}
`,Yr=_e.gql`
query swapPackageFilteredTokensWithBalance ($identifiers: [String!], $pagination: ConnectionArgs, $searchInput: String, $userTokensOffset: Int, $userTokensLimit: Int, $enabledSwaps: Boolean) {
filteredTokens (pagination: $pagination, filters: {searchToken: $searchInput, enabledSwaps: $enabledSwaps, identifiers: $identifiers}) {
edges {
node {
${C}
}
cursor
}
pageInfo {
hasNextPage
}
pageData {
count
}
}
userTokens (offset: $userTokensOffset, limit: $userTokensLimit) {
${Pt}
}
wrappingInfo {
wrappedToken {
${C}
}
}
factory {
${Le}
}
}
`;i();i();var Rt=require("@apollo/client");var Me=Rt.gql`
query swapPackageWrapEgld ($wrappingAmount: String!) {
wrapEgld(amount: $wrappingAmount) {
${K}
}
}
`;i();var Ot=require("@apollo/client");var $e=Ot.gql`
query swapPackageUnwrapEgld ($wrappingAmount: String!) {
unwrapEgld(amount: $wrappingAmount) {
${K}
}
}
`;i();i();var Lt=require("@apollo/client"),qr=Lt.gql`
query swapPackageMaintenance {
factory {
maintenance
}
}
`;i();i();i();i();i();i();i();i();i();i();i();i();var rn=A(require("bignumber.js"));i();i();i();var k=require("@multiversx/sdk-core");i();i();var P=require("@multiversx/sdk-dapp/out/constants/mvx.constants"),Jr=require("@multiversx/sdk-dapp/out/constants/network.constants");i();var en=require("@multiversx/sdk-dapp/out/types/enums.types");i();var Ct=require("@multiversx/sdk-dapp/out/utils/decoders/base64Utils");i();var Nt=require("@multiversx/sdk-dapp/out/store/store"),_t=require("@multiversx/sdk-dapp/out/store/selectors/accountSelectors");i();var we=require("@multiversx/sdk-dapp-utils/out/constants"),Y=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),Ge=require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount"),Ve=require("@multiversx/sdk-dapp-utils/out/helpers/stringIsFloat"),Mt=require("@multiversx/sdk-dapp-utils/out/helpers/stringIsInteger");i();i();var nn=A(require("bignumber.js"));i();i();i();i();i();i();i();var sn=A(require("bignumber.js"));i();i();i();var Vt=({firstTokenId:r,secondTokenId:e,wrappedEgld:t})=>{if(!r||!e||!t)return;let n=r===Z&&e===(t==null?void 0:t.identifier),o=r===(t==null?void 0:t.identifier)&&e===Z;return n?"wrap":o?"unwrap":"swap"};i();var Qt={"Multi swap disabled!":"Smart Swaps are temporarily disabled. We suggest using an alternative route to perform the token swap.","Spread too big!":"Smart Swap not possible because you would lose more than $placeholder_percentage%."},Qe=({serviceError:r,lossPercentage:e=""})=>{if(!r)return;let t="No trade route found.",n=Object.keys(Qt).find(o=>r.includes(o));return n?Qt[n].replace("$placeholder_percentage",e):t};i();var an=A(require("bignumber.js"));i();var un=require("bignumber.js");i();i();var cn=A(require("bignumber.js"));i();var pn=A(require("bignumber.js"));i();var fn=A(require("bignumber.js"));i();i();var ie=require("react"),qt=require("@apollo/client");i();i();i();var ln=require("react");i();var ze=require("react"),hn=A(require("bignumber.js"));i();var zt=require("react");i();var Ht=require("react");i();i();var q=require("react"),jt=()=>typeof document===void 0?!0:document.visibilityState==="visible",Xt=()=>{let[r,e]=(0,q.useState)(jt()),t=(0,q.useCallback)(()=>{e(jt())},[e]);return(0,q.useEffect)(()=>{if(typeof document!==void 0)return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[t]),r};i();var Ie=require("react");i();var dn=require("react");i();var Zt=require("react"),He=require("@apollo/client");var ea=He.gql`
subscription swapPackageTokensPriceUpdated {
tokensPriceUpdated {
updates
}
}
`;i();var Yt=require("react");i();var yn=require("react"),gn=A(require("bignumber.js"));i();var Tn=require("react");var je=({query:r,queryOptions:e,refetchTrigger:t,isPollingEnabled:n=!1,pollingIntervalMiliseconds:o=2e3,isRefetchEnabled:s=!1})=>{let a=Xt(),{client:l}=L(),ue=(0,qt.useQuery)(r,G({client:l,notifyOnNetworkStatusChange:!0,fetchPolicy:"no-cache",nextFetchPolicy:"no-cache"},e)),{error:m,loading:y,previousData:d,data:h=d,refetch:T,stopPolling:x,startPolling:U}=ue,I=rt(ue,["error","loading","previousData","data","refetch","stopPolling","startPolling"]),S=(0,ie.useCallback)(()=>{x(),a&&n&&!m&&!(e!=null&&e.skip)&&U(o)},[m,a,n,e==null?void 0:e.skip,e==null?void 0:e.variables]),se=()=>{T(),S()};(0,ie.useEffect)(()=>(S(),()=>{x()}),[S]),(0,ie.useEffect)(()=>{!s||t===0||(se(),S())},[t,s]);let ae=h==null&&y,J=Boolean(m);return G({data:h,error:m,isError:J,isLoading:ae,isRefetching:y,refetch:se},I)};var xn=({wrappedEgld:r,isPollingEnabled:e=!1,pollingIntervalMiliseconds:t=2e3})=>{var Ye,qe;let{client:n,isAuthenticated:o}=L();if(!n)throw new Error("Swap GraphQL client not initialized");let[s,a]=(0,D.useState)(),[l,m]=(0,D.useState)(),[y,d]=(0,D.useState)(),h=(0,D.useRef)(),T=(0,D.useMemo)(()=>Vt({firstTokenId:s==null?void 0:s.tokenInID,secondTokenId:s==null?void 0:s.tokenOutID,wrappedEgld:r}),[s,r]),x=(0,D.useMemo)(()=>T==="wrap"?Me:T==="unwrap"?$e:o?vt:Bt,[o,T]),U=(0,D.useMemo)(()=>{if(!s)return!0;let{amountIn:F,amountOut:$}=s;return!Boolean(F!=null?F:$)},[s]),{data:I,error:S,refetch:se,isRefetching:ae,isLoading:J,isError:Ze}=je({query:x,queryOptions:{skip:U,client:n,variables:s},isPollingEnabled:e,pollingIntervalMiliseconds:t}),ue=()=>{var F,$,ee;if(!s){m(void 0),d(Qe({serviceError:S==null?void 0:S.message}));return}switch(T){case"wrap":case"unwrap":let te=I==null?void 0:I.wrapEgld,re=I==null?void 0:I.unwrapEgld,ce=te!=null?te:re,pe=s.amountIn?0:1,z=(F=s.amountIn)!=null?F:s.amountOut,rr={amountIn:z!=null?z:"0",tokenInID:s.tokenInID,tokenInPriceUSD:($=r==null?void 0:r.price)!=null?$:"0",tokenInExchangeRateDenom:"1",maxPriceDeviationPercent:0,tokensPriceDeviationPercent:0,amountOut:z!=null?z:"0",tokenOutID:s.tokenOutID,tokenOutPriceUSD:(ee=r==null?void 0:r.price)!=null?ee:"0",tokenOutExchangeRateDenom:"1",fees:[],swapType:pe,tokenRoute:[],pricesImpact:[],intermediaryAmounts:[],pairs:[],transactions:ce?[ce]:[],smartSwap:null};d(void 0),m(rr);break;default:let fe=I==null?void 0:I.swap,Je=Qe({serviceError:S==null?void 0:S.message,lossPercentage:new Jt.default(fe==null?void 0:fe.maxPriceDeviationPercent).times(100).toString(10)});d(Je),m(Je?void 0:fe)}},Ke=({amountIn:F,amountOut:$,tokenInID:ee,tokenOutID:te,tolerancePercentage:re=1})=>{if(!F&&!$){a(void 0);return}let ce=re<0||re>100?1:re,pe={wrappingAmount:F!=null?F:$,amountIn:F,amountOut:$,tokenInID:ee,tokenOutID:te,tolerance:ce/100};a(pe),h.current=pe};(0,D.useEffect)(ue,[I,S,s]);let er=Boolean((J||ae)&&((Ye=h.current)==null?void 0:Ye.amountIn)),tr=Boolean((J||ae)&&((qe=h.current)==null?void 0:qe.amountOut));return{refetch:se,getSwapRoute:Ke,swapRoute:l,swapActionType:T,swapRouteError:y,isAmountInLoading:tr,isAmountOutLoading:er,isSwapRouteError:Ze,isSwapRouteLoading:J,transactions:l==null?void 0:l.transactions,previousFetchVariables:h}};0&&(module.exports={useSwapRoute});
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
//# sourceMappingURL=useSwapRoute.js.map