@xoxno/sdk-js 1.0.219 → 1.0.221

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.esm.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.esm.js.LICENSE.txt */
2
- "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,Asset as o,BASE_FEE as r,Contract as n,ScInt as i,StrKey as s,TransactionBuilder as u,scValToBigInt as a,scValToNative as l,xdr as p}from"@stellar/stellar-sdk";var c={526(t,e){e.byteLength=function(t){var e=u(t),o=e[0],r=e[1];return 3*(o+r)/4-r},e.toByteArray=function(t){var e,o,i=u(t),s=i[0],a=i[1],l=new n(function(t,e,o){return 3*(e+o)/4-o}(0,s,a)),p=0,c=a>0?s-4:s;for(o=0;o<c;o+=4)e=r[t.charCodeAt(o)]<<18|r[t.charCodeAt(o+1)]<<12|r[t.charCodeAt(o+2)]<<6|r[t.charCodeAt(o+3)],l[p++]=e>>16&255,l[p++]=e>>8&255,l[p++]=255&e;return 2===a&&(e=r[t.charCodeAt(o)]<<2|r[t.charCodeAt(o+1)]>>4,l[p++]=255&e),1===a&&(e=r[t.charCodeAt(o)]<<10|r[t.charCodeAt(o+1)]<<4|r[t.charCodeAt(o+2)]>>2,l[p++]=e>>8&255,l[p++]=255&e),l},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],s=16383,u=0,l=r-n;u<l;u+=s)i.push(a(t,u,u+s>l?l:u+s));return 1===n?(e=t[r-1],i.push(o[e>>2]+o[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(o[e>>10]+o[e>>4&63]+o[e<<2&63]+"=")),i.join("")};for(var o=[],r=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)o[s]=i[s],r[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=t.indexOf("=");return-1===o&&(o=e),[o,o===e?0:4-o%4]}function a(t,e,r){for(var n,i,s=[],u=e;u<r;u+=3)n=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(o[(i=n)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},287(t,e,o){const r=o(526),n=o(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=a,e.IS=50;const s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,o){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,o)}function l(t,e,o){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const o=0|y(t,e);let r=u(o);const n=r.write(t,e);return n!==o&&(r=r.slice(0,n)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(K(t,ArrayBuffer)||t&&K(t.buffer,ArrayBuffer))return f(t,e,o);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return f(t,e,o);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return a.from(r,e,o);const n=function(t){if(a.isBuffer(t)){const e=0|h(t.length),o=u(e);return 0===o.length||t.copy(o,0,0,e),o}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?u(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function p(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return p(t),u(t<0?0:0|h(t))}function d(t){const e=t.length<0?0:0|h(t.length),o=u(e);for(let r=0;r<e;r+=1)o[r]=255&t[r];return o}function f(t,e,o){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(o||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===o?new Uint8Array(t):void 0===o?new Uint8Array(t,e):new Uint8Array(t,e,o),Object.setPrototypeOf(r,a.prototype),r}function h(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||K(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const o=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===o)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*o;case"hex":return o>>>1;case"base64":return G(t).length;default:if(n)return r?-1:H(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,o){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===o||o>this.length)&&(o=this.length),o<=0)return"";if((o>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,o);case"utf8":case"utf-8":return q(this,e,o);case"ascii":return k(this,e,o);case"latin1":case"binary":return _(this,e,o);case"base64":return I(this,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,o);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,o){const r=t[e];t[e]=t[o],t[o]=r}function b(t,e,o,r,n){if(0===t.length)return-1;if("string"==typeof o?(r=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),Y(o=+o)&&(o=n?0:t.length-1),o<0&&(o=t.length+o),o>=t.length){if(n)return-1;o=t.length-1}else if(o<0){if(!n)return-1;o=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:w(t,e,o,r,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,o):Uint8Array.prototype.lastIndexOf.call(t,e,o):w(t,[e],o,r,n);throw new TypeError("val must be string, number or Buffer")}function w(t,e,o,r,n){let i,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,o/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){let r=-1;for(i=o;i<u;i++)if(l(t,i)===l(e,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===a)return r*s}else-1!==r&&(i-=i-r),r=-1}else for(o+a>u&&(o=u-a),i=o;i>=0;i--){let o=!0;for(let r=0;r<a;r++)if(l(t,i+r)!==l(e,r)){o=!1;break}if(o)return i}return-1}function S(t,e,o,r){o=Number(o)||0;const n=t.length-o;r?(r=Number(r))>n&&(r=n):r=n;const i=e.length;let s;for(r>i/2&&(r=i/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Y(r))return s;t[o+s]=r}return s}function v(t,e,o,r){return j(H(e,t.length-o),t,o,r)}function x(t,e,o,r){return j(function(t){const e=[];for(let o=0;o<t.length;++o)e.push(255&t.charCodeAt(o));return e}(e),t,o,r)}function A(t,e,o,r){return j(G(e),t,o,r)}function T(t,e,o,r){return j(function(t,e){let o,r,n;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)o=t.charCodeAt(s),r=o>>8,n=o%256,i.push(n),i.push(r);return i}(e,t.length-o),t,o,r)}function I(t,e,o){return 0===e&&o===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,o))}function q(t,e,o){o=Math.min(t.length,o);const r=[];let n=e;for(;n<o;){const e=t[n];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(n+s<=o){let o,r,u,a;switch(s){case 1:e<128&&(i=e);break;case 2:o=t[n+1],128==(192&o)&&(a=(31&e)<<6|63&o,a>127&&(i=a));break;case 3:o=t[n+1],r=t[n+2],128==(192&o)&&128==(192&r)&&(a=(15&e)<<12|(63&o)<<6|63&r,a>2047&&(a<55296||a>57343)&&(i=a));break;case 4:o=t[n+1],r=t[n+2],u=t[n+3],128==(192&o)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&o)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(i=a))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),n+=s}return function(t){const e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);let o="",r=0;for(;r<e;)o+=String.fromCharCode.apply(String,t.slice(r,r+=E));return o}(r)}a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,o){return l(t,e,o)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,o){return function(t,e,o){return p(t),t<=0?u(t):void 0!==e?"string"==typeof o?u(t).fill(e,o):u(t).fill(e):u(t)}(t,e,o)},a.allocUnsafe=function(t){return c(t)},a.allocUnsafeSlow=function(t){return c(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let o=t.length,r=e.length;for(let n=0,i=Math.min(o,r);n<i;++n)if(t[n]!==e[n]){o=t[n],r=e[n];break}return o<r?-1:r<o?1:0},a.isEncoding=function(t){switch(String(t).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}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let o;if(void 0===e)for(e=0,o=0;o<t.length;++o)e+=t[o].length;const r=a.allocUnsafe(e);let n=0;for(o=0;o<t.length;++o){let e=t[o];if(K(e,Uint8Array))n+e.length>r.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(r,n)):Uint8Array.prototype.set.call(r,e,n);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,n)}n+=e.length}return r},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?q(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let t="";const o=e.IS;return t=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(t+=" ... "),"<Buffer "+t+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,o,r,n){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===o&&(o=t?t.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),e<0||o>t.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&e>=o)return 0;if(r>=n)return-1;if(e>=o)return 1;if(this===t)return 0;let i=(n>>>=0)-(r>>>=0),s=(o>>>=0)-(e>>>=0);const u=Math.min(i,s),l=this.slice(r,n),p=t.slice(e,o);for(let t=0;t<u;++t)if(l[t]!==p[t]){i=l[t],s=p[t];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(t,e,o){return-1!==this.indexOf(t,e,o)},a.prototype.indexOf=function(t,e,o){return b(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return b(this,t,e,o,!1)},a.prototype.write=function(t,e,o,r){if(void 0===e)r="utf8",o=this.length,e=0;else if(void 0===o&&"string"==typeof e)r=e,o=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(o)?(o>>>=0,void 0===r&&(r="utf8")):(r=o,o=void 0)}const n=this.length-e;if((void 0===o||o>n)&&(o=n),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return S(this,t,e,o);case"utf8":case"utf-8":return v(this,t,e,o);case"ascii":case"latin1":case"binary":return x(this,t,e,o);case"base64":return A(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,o);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function k(t,e,o){let r="";o=Math.min(t.length,o);for(let n=e;n<o;++n)r+=String.fromCharCode(127&t[n]);return r}function _(t,e,o){let r="";o=Math.min(t.length,o);for(let n=e;n<o;++n)r+=String.fromCharCode(t[n]);return r}function R(t,e,o){const r=t.length;(!e||e<0)&&(e=0),(!o||o<0||o>r)&&(o=r);let n="";for(let r=e;r<o;++r)n+=J[t[r]];return n}function B(t,e,o){const r=t.slice(e,o);let n="";for(let t=0;t<r.length-1;t+=2)n+=String.fromCharCode(r[t]+256*r[t+1]);return n}function P(t,e,o){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>o)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,o,r,n,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<i)throw new RangeError('"value" argument is out of bounds');if(o+r>t.length)throw new RangeError("Index out of range")}function M(t,e,o,r,n){F(e,r,n,t,o,7);let i=Number(e&BigInt(4294967295));t[o++]=i,i>>=8,t[o++]=i,i>>=8,t[o++]=i,i>>=8,t[o++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[o++]=s,s>>=8,t[o++]=s,s>>=8,t[o++]=s,s>>=8,t[o++]=s,o}function U(t,e,o,r,n){F(e,r,n,t,o,7);let i=Number(e&BigInt(4294967295));t[o+7]=i,i>>=8,t[o+6]=i,i>>=8,t[o+5]=i,i>>=8,t[o+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[o+3]=s,s>>=8,t[o+2]=s,s>>=8,t[o+1]=s,s>>=8,t[o]=s,o+8}function C(t,e,o,r,n,i){if(o+r>t.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function $(t,e,o,r,i){return e=+e,o>>>=0,i||C(t,0,o,4),n.write(t,e,o,r,23,4),o+4}function L(t,e,o,r,i){return e=+e,o>>>=0,i||C(t,0,o,8),n.write(t,e,o,r,52,8),o+8}a.prototype.slice=function(t,e){const o=this.length;(t=~~t)<0?(t+=o)<0&&(t=0):t>o&&(t=o),(e=void 0===e?o:~~e)<0?(e+=o)<0&&(e=0):e>o&&(e=o),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,a.prototype),r},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t],n=1,i=0;for(;++i<e&&(n*=256);)r+=this[t+i]*n;return r},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t+--e],n=1;for(;e>0&&(n*=256);)r+=this[t+--e]*n;return r},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+o*2**24;return BigInt(r)+(BigInt(n)<<BigInt(32))})),a.prototype.readBigUInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+o;return(BigInt(r)<<BigInt(32))+BigInt(n)})),a.prototype.readIntLE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t],n=1,i=0;for(;++i<e&&(n*=256);)r+=this[t+i]*n;return n*=128,r>=n&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=e,n=1,i=this[t+--r];for(;r>0&&(n*=256);)i+=this[t+--r]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);const o=this[t]|this[t+1]<<8;return 32768&o?4294901760|o:o},a.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);const o=this[t+1]|this[t]<<8;return 32768&o?4294901760|o:o},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(o<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+o)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,r){t=+t,e>>>=0,o>>>=0,r||O(this,t,e,o,Math.pow(2,8*o)-1,0);let n=1,i=0;for(this[e]=255&t;++i<o&&(n*=256);)this[e+i]=t/n&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,r){t=+t,e>>>=0,o>>>=0,r||O(this,t,e,o,Math.pow(2,8*o)-1,0);let n=o-1,i=1;for(this[e+n]=255&t;--n>=0&&(i*=256);)this[e+n]=t/i&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=Z((function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,o,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*o-1);O(this,t,e,o,r-1,-r)}let n=0,i=1,s=0;for(this[e]=255&t;++n<o&&(i*=256);)t<0&&0===s&&0!==this[e+n-1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+o},a.prototype.writeIntBE=function(t,e,o,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*o-1);O(this,t,e,o,r-1,-r)}let n=o-1,i=1,s=0;for(this[e+n]=255&t;--n>=0&&(i*=256);)t<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=Z((function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,o){return $(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return $(this,t,e,!1,o)},a.prototype.writeDoubleLE=function(t,e,o){return L(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return L(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,r){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<o&&(r=o),r===o)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-o&&(r=t.length-e+o);const n=r-o;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,o,r):Uint8Array.prototype.set.call(t,this.subarray(o,r),e),n},a.prototype.fill=function(t,e,o,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,o=this.length):"string"==typeof o&&(r=o,o=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;let n;if(e>>>=0,o=void 0===o?this.length:o>>>0,t||(t=0),"number"==typeof t)for(n=e;n<o;++n)this[n]=t;else{const i=a.isBuffer(t)?t:a.from(t,r),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<o-e;++n)this[n+e]=i[n%s]}return this};const D={};function N(t,e,o){D[t]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",o=t.length;const r="-"===t[0]?1:0;for(;o>=r+4;o-=3)e=`_${t.slice(o-3,o)}${e}`;return`${t.slice(0,o)}${e}`}function F(t,e,o,r,n,i){if(t>o||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=i>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${e}${r} and <= ${o}${r}`,new D.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,o){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+o]||V(e,t.length-(o+1))}(r,n,i)}function z(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,o){if(Math.floor(t)!==t)throw z(t,o),new D.ERR_OUT_OF_RANGE(o||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),N("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),N("ERR_OUT_OF_RANGE",(function(t,e,o){let r=`The value of "${t}" is out of range.`,n=o;return Number.isInteger(o)&&Math.abs(o)>2**32?n=W(String(o)):"bigint"==typeof o&&(n=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(n=W(n)),n+="n"),r+=` It must be ${e}. Received ${n}`,r}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function H(t,e){let o;e=e||1/0;const r=t.length;let n=null;const i=[];for(let s=0;s<r;++s){if(o=t.charCodeAt(s),o>55295&&o<57344){if(!n){if(o>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}n=o;continue}if(o<56320){(e-=3)>-1&&i.push(239,191,189),n=o;continue}o=65536+(n-55296<<10|o-56320)}else n&&(e-=3)>-1&&i.push(239,191,189);if(n=null,o<128){if((e-=1)<0)break;i.push(o)}else if(o<2048){if((e-=2)<0)break;i.push(o>>6|192,63&o|128)}else if(o<65536){if((e-=3)<0)break;i.push(o>>12|224,o>>6&63|128,63&o|128)}else{if(!(o<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(o>>18|240,o>>12&63|128,o>>6&63|128,63&o|128)}}return i}function G(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,o,r){let n;for(n=0;n<r&&!(n+o>=e.length||n>=t.length);++n)e[n+o]=t[n];return n}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let o=0;o<16;++o){const r=16*o;for(let n=0;n<16;++n)e[r+n]=t[o]+t[n]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251(t,e){e.read=function(t,e,o,r,n){var i,s,u=8*n-r-1,a=(1<<u)-1,l=a>>1,p=-7,c=o?n-1:0,d=o?-1:1,f=t[e+c];for(c+=d,i=f&(1<<-p)-1,f>>=-p,p+=u;p>0;i=256*i+t[e+c],c+=d,p-=8);for(s=i&(1<<-p)-1,i>>=-p,p+=r;p>0;s=256*s+t[e+c],c+=d,p-=8);if(0===i)i=1-l;else{if(i===a)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},e.write=function(t,e,o,r,n,i){var s,u,a,l=8*i-n-1,p=(1<<l)-1,c=p>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,h=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?d/a:d*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=p?(u=0,s=p):s+c>=1?(u=(e*a-1)*Math.pow(2,n),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[o+f]=255&u,f+=h,u/=256,n-=8);for(s=s<<n|u,l+=n;l>0;t[o+f]=255&s,f+=h,s/=256,l-=8);t[o+f-h]|=128*y}},626(c,d,f){f.d(d,{UTY:()=>sn,fFH:()=>Dn,RCv:()=>ri,Z$K:()=>rn,OAi:()=>un,G_M:()=>ze,fAY:()=>pr,a_O:()=>h,A$9:()=>m,XvM:()=>Sr,gRW:()=>dr,cJU:()=>Mr,SVM:()=>vr,DYS:()=>nn,wFd:()=>an,wJe:()=>ei,$wP:()=>Un,eBc:()=>Fr,JtG:()=>Kr,Vhx:()=>Tn,xEs:()=>_n,t$R:()=>qn,pU3:()=>Xn,VZJ:()=>tn,N0v:()=>ve,B_D:()=>We,qLM:()=>Ee,eX8:()=>_e,zaA:()=>_r,xDR:()=>K,jR0:()=>Y,P2l:()=>on,W68:()=>Ne,sec:()=>Le,ZPB:()=>No,yrp:()=>kr,spi:()=>rt,Iu1:()=>Vo,yuB:()=>zo,$96:()=>Oo,zwJ:()=>Uo,h_A:()=>Co,e_X:()=>$o,TkG:()=>Po,BAg:()=>Mo,u9S:()=>Ho,biU:()=>Xo,gc5:()=>Fo,ayx:()=>Wo,SXg:()=>be,UFY:()=>fr,Y5o:()=>et,mEH:()=>nt,xGW:()=>ye,s9Q:()=>it,OL0:()=>ge,k6p:()=>so,djE:()=>no,kDJ:()=>yo,Yfw:()=>fo,AI1:()=>Do,O2U:()=>To,c5J:()=>Io,N8y:()=>ro,qUh:()=>mo,RZj:()=>wo,nio:()=>uo,hFg:()=>qo,Qkp:()=>Eo,GwL:()=>_o,$Kr:()=>xo,ujH:()=>ao,Odj:()=>io,X7c:()=>go,Ubz:()=>Ro,Dx4:()=>ho,OAr:()=>eo,$Uh:()=>to,obN:()=>co,$lZ:()=>oo,Kaw:()=>po,Wbk:()=>Qe,kwV:()=>lo,qAI:()=>Ze,VSx:()=>Ao,HPG:()=>Bo,xQk:()=>Go,YQw:()=>ko,QY:()=>vo,osR:()=>bo,Kob:()=>So,IJt:()=>$e,nw5:()=>Q,PrA:()=>at,ZEf:()=>tt,X0W:()=>ke,evz:()=>we,P8C:()=>Re,aVn:()=>Ie,p2b:()=>Te,sVY:()=>Pe,XDq:()=>Ue,Jsu:()=>Oe,W5:()=>Be,Dyw:()=>qe,_i2:()=>Ae,FZg:()=>Me,wGh:()=>xe,Nix:()=>G,v_o:()=>j,qDU:()=>ut,qRb:()=>st,QJY:()=>Se,bmW:()=>me,n_N:()=>Fe,v87:()=>Ce,qMI:()=>he,gHX:()=>De,O3p:()=>J,Gzh:()=>Z,prJ:()=>X,moD:()=>Yn,y5S:()=>oi,Fmy:()=>cr,OBV:()=>ot,aku:()=>Ar,HFl:()=>Cn,cCk:()=>fn,Ft:()=>de,MB4:()=>ee,Dnk:()=>fe,pqp:()=>oe,Q3w:()=>re,Jh3:()=>ne,wfs:()=>Er,UmN:()=>hr,xO7:()=>At,R11:()=>Gt,LwT:()=>br,mMz:()=>wt,iES:()=>Rt,zpK:()=>qt,N3x:()=>It,bNp:()=>ht,T3v:()=>Wt,KQV:()=>Qt,S9l:()=>Kt,rER:()=>g,XNg:()=>ft,VeU:()=>Vt,T_r:()=>Ct,m4Y:()=>Nt,XIn:()=>St,Lt0:()=>Bt,wsx:()=>kt,KKL:()=>yt,yl$:()=>ct,kqD:()=>dt,dEm:()=>Dt,bu4:()=>Xt,ftY:()=>Lt,Ht0:()=>Zt,$uf:()=>$t,wqt:()=>Jt,CHU:()=>wr,Wc$:()=>jt,Y5D:()=>bt,KGs:()=>Ot,nWw:()=>Et,jFb:()=>mt,Pvd:()=>zt,S2b:()=>vt,uSb:()=>Pt,N9t:()=>_t,bNM:()=>gt,PvK:()=>Ft,O5u:()=>Mt,NYX:()=>Ut,FCB:()=>Yt,h_O:()=>xt,zu2:()=>Ht,Xix:()=>Tt,C88:()=>Vn,LAw:()=>Pr,E6J:()=>Rr,Dsj:()=>Br,XVZ:()=>xi,CUR:()=>gr,Kye:()=>di,Q6F:()=>yi,SFb:()=>hi,tT6:()=>fi,fBQ:()=>Kn,LRi:()=>cn,M0l:()=>pn,sfH:()=>dn,NFG:()=>Rn,DGs:()=>Bn,BqG:()=>In,VxL:()=>Zr,DLQ:()=>Jr,mbb:()=>bi,AuU:()=>Si,vCP:()=>Ln,w74:()=>$n,JRY:()=>kn,BV_:()=>gn,ApP:()=>yn,Ei0:()=>mn,kQ9:()=>Nn,vp8:()=>Wn,$y9:()=>Gr,ONb:()=>Yo,HhT:()=>te,PF2:()=>y,oze:()=>Tr,oVm:()=>yr,g57:()=>Yr,LaM:()=>jo,DgJ:()=>ln,Vuj:()=>Qr,Ou3:()=>Sn,kRY:()=>xn,W_e:()=>An,Let:()=>vn,TXb:()=>Mn,shl:()=>Jn,TqQ:()=>jn,BKn:()=>qr,rWM:()=>En});const h={stellarMainnet:{name:"mainnet",passphrase:"Public Global Stellar Network ; September 2015",horizonUrl:"https://horizon.stellar.org",sorobanRpcUrl:"https://stellar-gateway.xoxno.com",quoteUrl:"https://stellar-swap.xoxno.com",explorerNetwork:"public",aquariusApiUrl:"https://amm-api.aqua.network",aquariusRouter:"CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",lendingController:"CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX",lendingPool:"CBXRNDQMAJFG4VUKMKFEMFS75UUXE2SPSNV4LEEFCSNBCN66PYRWBKXO",aggregatorRouter:"CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR",governance:"CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD",priceAggregator:"CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV",positionNftContract:"CAWCSG77AY2W24QZ6ZXLHZU4UXEFHZBM6EI4A4IF7JB5CTY4XND3TI6C"},stellarTestnet:{name:"testnet",passphrase:"Test SDF Network ; September 2015",horizonUrl:"https://horizon-testnet.stellar.org",sorobanRpcUrl:"https://stellar-testnet-gateway.xoxno.com",quoteUrl:"https://testnet-stellar-swap.xoxno.com",explorerNetwork:"testnet",aquariusApiUrl:"https://amm-api-testnet.aqua.network",aquariusRouter:"CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD",lendingController:"CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3",lendingPool:"CBSGF6QOQAMPFBEVSYPEQHSZRIHJ6RCGUPCRDMUX36DEKRWFAO2PZB5A",aggregatorRouter:"CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5",governance:"CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ",priceAggregator:"CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP",positionNftContract:"CDVN5JU675MEDPVRPCYC45AHFC275UH57WEU5OTFE4WFGZBNN7HTLPSY"}},y=h;function g(t){return h["testnet"===t?"stellarTestnet":"stellarMainnet"]}const m={mainnet:h.stellarMainnet.passphrase,testnet:h.stellarTestnet.passphrase};var b=f(287);const w=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],S={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},v=1e6,x=t=>new e(t).toScVal(),A=t=>new i(t).toI128(),T=t=>p.ScVal.scvU32(t),I=t=>{if("number"==typeof t&&!Number.isSafeInteger(t))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new i("string"==typeof t?t:t.toString()).toU64()},q=t=>p.ScVal.scvBool(t),E=t=>p.ScVal.scvString(t),k=t=>p.ScVal.scvSymbol(t),_=()=>p.ScVal.scvVoid(),R=t=>p.ScVal.scvVec(t),B=(t,e=32)=>{const o=t.startsWith("0x")?t.slice(2):t,r=b.hp.from(o,"hex");if(r.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${r.length} bytes from "${t}")`);return p.ScVal.scvBytes(r)},P=(t,e)=>null==t?_():e(t),O=(t,e)=>$({asset:x(e),hub_id:T(t)}),M=(t,e,o)=>p.ScVal.scvVec([O(t,e),A(o)]),U=t=>p.ScVal.scvVec(t.map((t=>M(t.hubId,t.asset,t.amount)))),C=t=>{if("Transfer"===t)return R([k("Transfer")]);if(t&&"object"==typeof t&&"Credit"in t){const e=t.Credit;if("number"==typeof e&&!Number.isInteger(e))throw new Error(`Stellar builder: SeizeMode Credit account id must be an integer u64, got ${e}`);return R([k("Credit"),I(e)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(t)}`)},$=t=>{const e=Object.keys(t).sort().map((e=>new p.ScMapEntry({key:k(e),val:t[e]})));return p.ScVal.scvMap(e)};class L{assets=[];amounts=[];ops=[];weights=[];constructor(t){this.amounts.push(t)}asset(t){const e=this.assets.indexOf(t);if(-1!==e)return e;if(this.assets.length>=256)throw new Error("Stellar builder: strategy references more than 256 distinct addresses");return this.assets.push(t),this.assets.length-1}amount(t){if(this.amounts.length>=126)throw new Error("Stellar builder: strategy references too many distinct amounts");return this.amounts.push(t),this.amounts.length-1}weight(t){if(this.weights.length>=32)throw new Error("Stellar builder: strategy uses more than 32 split weights");if(!Number.isInteger(t)||t<=0||t>v)throw new Error(`Stellar builder: split weight ${t} outside 1..=1000000`);return this.weights.push(t),this.weights.length-1}emit(t,e,o,r,n){this.ops.push([t,e,o,r,n])}emitPath(t,e){t.hops.forEach(((o,r)=>{if(o.tokenIn===o.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[r-1];if(n&&o.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(S[o.venue],0===r?e:1,this.asset(o.pool),this.asset(o.tokenIn),this.asset(o.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),o=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(o[t])continue;const r=e[t].hops[0]?.tokenIn,n=[];for(let o=t;o<e.length;o+=1)e[o].hops[0]?.tokenIn===r&&n.push(o);const i=n.reduce(((t,o)=>t+e[o].splitPpm),0);if(i>v)throw new Error(`Stellar builder: split weights for one token sum to ${i}, above 1000000`);const s=i===v;let u=v;n.forEach(((t,r)=>{o[t]=!0;const i=e[t];let a;if(r+1===n.length&&s)a=0;else{if(0===u)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(i.splitPpm*v/u);u-=Math.min(i.splitPpm,u),a=128+this.weight(t)}this.emitPath(i,a)}))}}toBytes(t,e,o){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const r=[1,t,e,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,this.ops.length,this.weights.length];for(const t of this.ops)r.push(...t);for(const t of this.weights)r.push(t>>>16&255,t>>>8&255,255&t);return b.hp.from(r)}get assetList(){return this.assets}get amountList(){return this.amounts}}const D=t=>{const e=new L(t.totalMinOut),o=e.asset(t.tokenIn),r=e.asset(t.tokenOut);if(o===r)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const r=e.asset(t.burnPool),n=e.amountList.length;for(const o of t.burnMinAmounts??[])e.amount(o);e.emit(5,0,r,o,n)}if(e.lowerPaths(t.paths),t.mintPool){const o=t.preSwapAmount;if(o&&BigInt(o)>0n){const r=t.mintPoolTokens;if(!r||2!==r.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=r,[s,u]=t.preSwapFromA?[n,i]:[i,n];e.emit(S.Aquarius,2+e.amount(o),e.asset(t.mintPool),e.asset(s),e.asset(u))}e.emit(6,0,e.asset(t.mintPool),r,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return $({amounts:p.ScVal.scvVec(e.amountList.map((t=>A(t)))),assets:p.ScVal.scvVec(e.assetList.map((t=>x(t)))),ops:p.ScVal.scvBytes(e.toBytes(o,r,n))})},N=t=>{const e=b.hp.from(t);if(0===e.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return p.ScVal.scvBytes(e)},W=()=>p.ScVal.scvBytes(b.hp.alloc(0)),F=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((o=t).length>0&&o.length%2==0&&/^[0-9a-fA-F]+$/.test(o)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return b.hp.from(t,"hex")}var o;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(e))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const r=b.hp.from(e,"base64");if(0===r.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return r},z=t=>{if("string"==typeof t)return N(F(t));if(t instanceof Uint8Array)return 0===t.length?W():N(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?N(F(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?N(F(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?N(F(t.bytes)):0===t.bytes.length?W():N(t.bytes):(e=(t=>{if(!t||"object"!=typeof t)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const e=t;if(!Array.isArray(e.paths)||0===e.paths.length&&!e.burnPool&&!e.mintPool)throw new Error("Stellar builder: `steps.paths` needs a strategy path or a liquidity burn/mint operation");if("string"!=typeof e.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof e.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof e.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const o=new Map;for(const[t,r]of e.paths.entries()){if(!r||"number"!=typeof r.splitPpm||r.splitPpm<=0||!Array.isArray(r.hops)||0===r.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!w.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=r.hops[0];o.set(e.tokenIn,(o.get(e.tokenIn)??0)+r.splitPpm)}for(const[t,r]of o){if(r>v)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${r}, above 1000000`);if(!e.mintPool&&r!==v)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${r}`)}return e})(t),p.ScVal.scvBytes(b.hp.from(D(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},V=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=b.hp.from(e,"hex");return p.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return p.ScVal.scvBytes(b.hp.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function X(e,o,i){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const s=new n(e.controllerAddress),a=new t(e.caller,e.sourceSequence);return{xdr:new u(a,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(s.call(o,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function H(t){if(!Number.isInteger(t)||t<1||t>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return T(t)}function G(t,e){const o=e.accountNonce??0;return X(t,"supply",[x(t.caller),I(o),H(e.spokeId),U([...e.assets])])}function j(t,e){return G(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function K(t,e){return X(t,"borrow",[x(t.caller),I(e.accountNonce),U([...e.borrows]),P(e.to,x)])}function Y(t,e){return K(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function J(t,e){return X(t,"withdraw",[x(t.caller),I(e.accountNonce),U([...e.withdrawals]),P(e.to,x)])}function Z(t,e){return J(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Q(t,e){return X(t,"repay",[x(t.caller),I(e.accountNonce),U([...e.payments])])}function tt(t,e){return Q(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function et(t,e){return X(t,"liquidate",[x(t.caller),I(e.accountNonce),U([...e.debtPayments]),C(e.seizeMode??"Transfer")])}function ot(t){const e=l(p.ScVal.fromXDR(t,"base64"));if("bigint"==typeof e||"number"==typeof e)return e.toString();throw new Error("Stellar builder: liquidate return value must be a u64, got "+typeof e)}function rt(t,e){return X(t,"flash_loan",[x(t.caller),O(e.hubId,e.asset),A(e.amount),x(e.receiver),V(e.data)])}function nt(t,e){return X(t,"migrate_from_blend",[x(t.caller),I(e.accountId),H(e.spokeId),T(e.hubId),x(e.blendPool),R(e.collateralTokens.map(x)),R(e.supplyTokens.map(x)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),p.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,p.ScVal.scvVec([x(e),A(o)]);var e,o}))))]);var o}function it(t,e){const o=e.accountNonce??0;return X(t,"multiply",[x(t.caller),I(o),H(e.spokeId),O(e.collateral.hubId,e.collateral.asset),A(e.debtToFlashLoan),O(e.debt.hubId,e.debt.asset),T(e.mode),z(e.steps),P(e.initialPayment,(t=>M(t.hubId,t.asset,t.amount))),P(e.convertSwap,z)])}function st(t,e){return X(t,"swap_debt",[x(t.caller),I(e.accountNonce),O(e.existingDebt.hubId,e.existingDebt.asset),A(e.newDebtAmount),O(e.newDebt.hubId,e.newDebt.asset),z(e.steps)])}function ut(t,e){return X(t,"swap_collateral",[x(t.caller),I(e.accountNonce),O(e.current.hubId,e.current.asset),A(e.fromAmount),O(e.newCollateral.hubId,e.newCollateral.asset),z(e.steps)])}function at(t,e){return X(t,"repay_debt_with_collateral",[x(t.caller),I(e.accountNonce),O(e.collateral.hubId,e.collateral.asset),A(e.collateralAmount),O(e.debt.hubId,e.debt.asset),z(e.steps),q(e.closePosition)])}const lt="/stellar-lending",pt=encodeURIComponent,ct=(t,e)=>t.fetchWithTimeout(`${lt}/context`,e),dt=(t,e)=>t.fetchWithTimeout(`${lt}/live-state`,e),ft=(t,e)=>t.fetchWithTimeout(`${lt}/markets/detailed`,e),ht=(t,e)=>t.fetchWithTimeout(`${lt}/assets`,e),yt=(t,e)=>t.fetchWithTimeout(`${lt}/hubs`,e),gt=(t,e)=>t.fetchWithTimeout(`${lt}/spokes`,e),mt=(t,e={},o)=>t.fetchWithTimeout(`${lt}/reserves`,{...o,params:{...e}}),bt=(t,e,o,r,n)=>t.fetchWithTimeout(`${lt}/reserves/${e}/${o}/${pt(r)}`,n),wt=(t,e,o)=>t.fetchWithTimeout(`${lt}/assets/${pt(e)}`,o),St=(t,e,o)=>t.fetchWithTimeout(`${lt}/hubs/${e}`,o),vt=(t,e,o)=>t.fetchWithTimeout(`${lt}/spokes/${e}`,o),xt=(t,e,o)=>t.fetchWithTimeout(`${lt}/users/${pt(e)}/positions`,o),At=(t,e,o)=>t.fetchWithTimeout(`${lt}/accounts/${pt(e)}/positions`,o),Tt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/users/${pt(e)}/assets/${pt(o)}/balance`,r),It=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/assets/${pt(e)}/page`,{...r,params:{...o}}),qt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/assets/${pt(e)}/markets`,{...r,params:{side:o}}),Et=(t,e,o,r,n,i)=>t.fetchWithTimeout(`${lt}/reserves/${e}/${o}/${pt(r)}/holders`,{...i,params:{side:n}}),kt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/hubs/${e}/holders`,{...r,params:{side:o}}),_t=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/spokes/${e}/holders`,{...r,params:{side:o}}),Rt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/assets/${pt(e)}/graph`,{...r,params:{...o}}),Bt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/hubs/${e}/graph`,{...r,params:{...o}}),Pt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/spokes/${e}/graph`,{...r,params:{...o}}),Ot=(t,e,o,r,n,i)=>t.fetchWithTimeout(`${lt}/reserves/${e}/${o}/${pt(r)}/graph`,{...i,params:{...n}}),Mt=(t,e,o={},r)=>t.fetchWithTimeout(`${lt}/users/${pt(e)}/activity`,{...r,params:{...o}}),Ut=(t,e,o={},r)=>t.fetchWithTimeout(`${lt}/users/${pt(e)}/activity/page`,{...r,params:{...o}}),Ct=(t,e={},o)=>t.fetchWithTimeout(`${lt}/governance/proposals`,{...o,params:{...e}}),$t=(t,e={},o)=>t.fetchWithTimeout(`${lt}/positions`,{...o,params:{...e}}),Lt=(t,e={},o)=>t.fetchWithTimeout(`${lt}/participants`,{...o,params:{...e}}),Dt=(t,e={},o)=>t.fetchWithTimeout(`${lt}/liquidations/leaderboard`,{...o,params:{...e}}),Nt=(t,e={},o)=>t.fetchWithTimeout(`${lt}/distribution`,{...o,params:{...e}}),Wt=(t,e={},o)=>t.fetchWithTimeout(`${lt}/campaign/leaderboard`,{...o,params:{...e}}),Ft=(t,e,o)=>t.fetchWithTimeout(`${lt}/stats/history`,{...o,params:{...e}}),zt=(t,e,o)=>t.fetchWithTimeout(`${lt}/revenue`,{...o,params:{...e}}),Vt=(t,e,o)=>t.fetchWithTimeout(`${lt}/revenue/fees`,{...o,params:{...e}}),Xt=(t,e,o)=>t.fetchWithTimeout(`${lt}/liquidations`,{...o,params:{...e}}),Ht=(t,e,o)=>t.fetchWithTimeout(`${lt}/volume`,{...o,params:{...e}}),Gt=(t,e,o)=>t.fetchWithTimeout(`${lt}/active-users`,{...o,params:{...e}}),jt=(t,e,o)=>t.fetchWithTimeout(`${lt}/rate-spread`,{...o,params:{...e}}),Kt=(t,e,o)=>t.fetchWithTimeout(`${lt}/defillama`,{...o,params:{...e}}),Yt=(t,e,o,r)=>t.fetchWithTimeout(`${lt}/users/${pt(e)}/history`,{...r,params:{...o}}),Jt=(t,e,o)=>t.fetchWithTimeout(`${lt}/pnl`,{...o,params:{accountId:e}}),Zt=(t,e,o)=>t.fetchWithTimeout(`${lt}/pnl/scope`,{...o,params:{scope:e}}),Qt=(t,e,o)=>t.fetchWithTimeout(`${lt}/campaign/me`,{...o,params:{owner:e}}),te=t=>({context:e=>ct(t,e),liveState:e=>dt(t,e),marketsDetailed:e=>ft(t,e),assets:e=>ht(t,e),hubs:e=>yt(t,e),spokes:e=>gt(t,e),reserves:(e={},o)=>void 0!==o||"hubId"in e||"spokeId"in e||"asset"in e?mt(t,e,o):mt(t,{},e),reserve:(e,o,r,n)=>bt(t,e,o,r,n),asset:(e,o)=>wt(t,e,o),hub:(e,o)=>St(t,e,o),spoke:(e,o)=>vt(t,e,o),userPositions:(e,o)=>xt(t,e,o),accountPositions:(e,o)=>At(t,e,o),walletBalance:(e,o,r)=>Tt(t,e,o,r),assetPage:(e,o,r)=>It(t,e,o,r),assetMarkets:(e,o,r)=>qt(t,e,o,r),reserveHolders:(e,o,r,n,i)=>Et(t,e,o,r,n,i),hubHolders:(e,o,r)=>kt(t,e,o,r),spokeHolders:(e,o,r)=>_t(t,e,o,r),assetGraph:(e,o,r)=>Rt(t,e,o,r),hubGraph:(e,o,r)=>Bt(t,e,o,r),spokeGraph:(e,o,r)=>Pt(t,e,o,r),reserveGraph:(e,o,r,n,i)=>Ot(t,e,o,r,n,i),userActivity:(e,o={},r)=>Mt(t,e,o,r),userActivityPage:(e,o={},r)=>Ut(t,e,o,r),governanceProposals:(e={},o)=>Ct(t,e,o),positionsLeaderboard:(e={},o)=>$t(t,e,o),participants:(e={},o)=>Lt(t,e,o),liquidationsLeaderboard:(e={},o)=>Dt(t,e,o),distribution:(e={},o)=>Nt(t,e,o),campaignLeaderboard:(e={},o)=>Wt(t,e,o),statsHistory:(e,o)=>Ft(t,e,o),revenue:(e,o)=>zt(t,e,o),feeRevenue:(e,o)=>Vt(t,e,o),liquidations:(e,o)=>Xt(t,e,o),volume:(e,o)=>Ht(t,e,o),activeUsers:(e,o)=>Gt(t,e,o),rateSpread:(e,o)=>jt(t,e,o),defillama:(e,o)=>Kt(t,e,o),userHistory:(e,o,r)=>Yt(t,e,o,r),positionsPnl:(e,o)=>Jt(t,e,o),pnlByScope:(e,o)=>Zt(t,e,o),campaignMe:(e,o)=>Qt(t,e,o)}),ee=t=>$({base_borrow_rate:A(t.baseBorrowRateRay),max_borrow_rate:A(t.maxBorrowRateRay),max_utilization:A(t.maxUtilizationRay),mid_utilization:A(t.midUtilizationRay),optimal_utilization:A(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:A(t.slope1Ray),slope2:A(t.slope2Ray),slope3:A(t.slope3Ray)}),oe=t=>$({asset_decimals:T(t.assetDecimals),asset_id:x(t.assetId),base_borrow_rate:A(t.baseBorrowRateRay),flashloan_fee:T(t.flashloanFeeBps),is_flashloanable:q(t.isFlashloanable),max_borrow_rate:A(t.maxBorrowRateRay),max_utilization:A(t.maxUtilizationRay),mid_utilization:A(t.midUtilizationRay),optimal_utilization:A(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:A(t.slope1Ray),slope2:A(t.slope2Ray),slope3:A(t.slope3Ray)}),re=t=>$({max_borrow_positions:T(t.maxBorrowPositions),max_supply_positions:T(t.maxSupplyPositions)}),ne=t=>{if("Token"in t&&t.Token)return R([k("Token"),x(t.Token)]);if("Ref"in t&&t.Ref)return R([k("Ref"),k(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},ie=t=>{if("Stellar"in t)return R([k("Stellar"),x(t.Stellar)]);if("Symbol"in t)return R([k("Symbol"),k(t.Symbol)]);if("String"in t)return R([k("String"),E(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},se=t=>{if("Spot"===t)return R([k("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return R([k("Twap"),T(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},ue=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return R([k(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},ae=t=>{if("Market"===t||"Fundamental"===t)return R([k(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},le=t=>{if("Reflector"in t){const e=t.Reflector;return R([k("Reflector"),$({asset:ie(e.asset),contract:x(e.contract),read_mode:se(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return R([k("MultiFeed"),$({contract:x(e.contract),feed_id:E(e.feedId),kind:ue(e.kind),nature:ae(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},pe=t=>{const e=t;return $({decimals:T(e.decimals),max_stale_seconds:I(e.maxStaleSeconds),provider:le(e.provider)})},ce=t=>{if("RequireDisjoint"===t)return R([k("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return R([k("AllowShared"),R(e.map((t=>$({contract:x(t.contract),kind:ue(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},de=t=>{const e=t,o=e.sources??[];let r,n;if("number"==typeof e.toleranceBps)r=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/r));else{const t=e.tolerance??{};r=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return $({asset_decimals:T(Number(e.assetDecimals)),independence:ce(e.independence),max_price_stale_seconds:I(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:A(String(e.maxSanityPriceWad)),min_sanity_price_wad:A(String(e.minSanityPriceWad)),sources:R(o.map((t=>(t=>{if("Feed"in t)return R([k("Feed"),pe(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return R([k("Scaled"),$({factor:pe(e.factor),max_factor_wad:A(e.maxFactorWad),min_factor_wad:A(e.minFactorWad),quote:ne(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return R([k("LpShare"),$({key_a:ne(e.keyA),key_b:ne(e.keyB),kind:R([k(e.kind||"ConstantProduct")]),pool:x(e.pool),reserve_a_decimals:T(e.reserveADecimals),reserve_b_decimals:T(e.reserveBDecimals),share_decimals:T(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:$({lower_ratio_bps:T(n),upper_ratio_bps:T(r)})})},fe=de;function he(t,e){return X(t,"upgrade",[B(e.wasmHash)])}function ye(t,e){return X(t,"migrate",[T(e.newVersion)])}function ge(t){return X(t,"pause",[])}function me(t){return X(t,"unpause",[])}function be(t,e){return X(t,"grant_role",[x(e.account),k(e.role)])}function we(t,e){return X(t,"revoke_role",[x(e.account),k(e.role)])}function Se(t,e){return X(t,"transfer_ownership",[x(e.newOwner),T(e.liveUntilLedger)])}function ve(t){return X(t,"accept_ownership",[])}function xe(t,e){return X(t,"set_swap_aggregator",[x(e.aggregator)])}function Ae(t,e){return X(t,"set_price_aggregator",[x(e.aggregator)])}const Te=xe;function Ie(t,e){return X(t,"set_accumulator",[x(e.accumulator)])}function qe(t,e){return X(t,"set_position_limits",[re(e)])}function Ee(t,e){return X(t,"approve_blend_pool",[x(e.pool)])}function ke(t,e){return X(t,"revoke_blend_pool",[x(e.pool)])}const _e=Ee,Re=ke;function Be(t,e){return X(t,"set_oracle",[ne(e.key),de(e.oracle)])}const Pe=Be;function Oe(t,e){const o=e.toleranceBps,r=e.upperRatioBps??1e4+o,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/r));return X(t,"set_tolerance",[ne(e.key),$({lower_ratio_bps:T(n),upper_ratio_bps:T(r)})])}function Me(t,e){return X(t,"set_spoke_asset_flags",[T(e.spokeId),O(e.hubId,e.asset),q(e.paused),q(e.frozen),q(e.noSeize)])}function Ue(t,e){return X(t,"set_oracle_sanity_bounds",[x(e.asset),A(e.minPriceWad),A(e.maxPriceWad)])}function Ce(t,e){return X(t,"update_indexes",[x(t.caller),R(e.assets.map((t=>O(t.hubId,t.asset))))])}function $e(t,e){return X(t,"renew_account",[x(t.caller),I(e.accountNonce)])}function Le(t,e){return X(t,"create_liquidity_pool",[T(e.hubId),x(e.asset),oe(e.params)])}function De(t,e){return X(t,"upgrade_liquidity_pool_params",[O(e.hubId,e.asset),ee(e.params)])}function Ne(t,e){return X(t,"claim_revenue",[x(t.caller),R(e.assets.map((t=>O(t.hubId,t.asset))))])}function We(t,e){return X(t,"add_rewards",[x(t.caller),U(e.rewards)])}function Fe(t,e){return X(t,"update_account_threshold",[x(t.caller),q(e.hasRisks),R(e.accountNonces.map((t=>I(t))))])}const ze="00".repeat(32),Ve=t=>{if("string"==typeof t)return B(t);const e=b.hp.from(t);if(32!==e.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${e.length} bytes)`);return p.ScVal.scvBytes(e)},Xe=(t,...e)=>R([k(t),...e]),He=t=>$({new_owner:x(t.newOwner),live_until_ledger:T(t.liveUntilLedger)}),Ge=t=>$({asset:x(t.asset),bonus:T(t.bonus),borrow_cap:A(t.borrowCap),can_borrow:q(t.canBorrow),can_collateral:q(t.canCollateral),frozen:q(t.frozen),hub_id:T(t.hubId),paused:q(t.paused),liquidation_fees:T(t.liquidationFees),ltv:T(t.ltv),no_seize:q(t.noSeize),spoke_id:T(t.spokeId),supply_cap:A(t.supplyCap),threshold:T(t.threshold)}),je=t=>$({account:x(t.account),role:k(t.role)});function Ke(e,o,i){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const s=new n(e.governanceAddress),a=new t(e.caller,e.sourceSequence);return{xdr:new u(a,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(s.call(o,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Ye=(t,e,o)=>Ke(t,"propose",[x(t.caller),e,Ve(o)]),Je=(t,e,o)=>Ke(t,"execute_self",[_(),e,Ve(o)]);function Ze(t,e,o){return Ye(t,Xe("SetSwapAggregator",x(e.aggregator)),o)}function Qe(t,e,o){return Ye(t,Xe("SetPriceAggregator",x(e.aggregator)),o)}const to=Ze;function eo(t,e,o){return Ye(t,Xe("SetAccumulator",x(e.accumulator)),o)}function oo(t,e,o){return Ye(t,Xe("SetPositionLimits",re(e)),o)}function ro(t,e){return Ye(t,Xe("CreateHub"),e)}function no(t,e){return Ye(t,Xe("AddSpoke"),e)}function io(t,e,o){return Ye(t,Xe("RemoveSpoke",T(e.spokeId)),o)}function so(t,e,o){return Ye(t,Xe("AddAssetToSpoke",Ge(e)),o)}function uo(t,e,o){return Ye(t,Xe("EditAssetInSpoke",Ge(e)),o)}function ao(t,e,o){return Ye(t,Xe("RemoveAssetFromSpoke",$({hub_asset:O((r=e).hubId,r.asset),spoke_id:T(r.spokeId)})),o);var r}function lo(t,e,o){return Ye(t,Xe("SetSpokeLiquidationCurve",$({hf_for_max_bonus_wad:A((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:T(r.liquidationBonusFactorBps),spoke_id:T(r.spokeId),target_hf_wad:A(r.targetHfWad)})),o);var r}function po(t,e,o){return Ye(t,Xe("SetPositionManager",x(e.manager),q(e.isActive)),o)}function co(t,e,o){return Ye(t,Xe("SetMinBorrowCollateralUsd",A(e.floorWad)),o)}function fo(t,e,o){return Ye(t,Xe("ApproveToken",x(e.token)),o)}function ho(t,e,o){return Ye(t,Xe("RevokeToken",x(e.token)),o)}function yo(t,e,o){return Ye(t,Xe("ApproveBlendPool",x(e.pool)),o)}function go(t,e,o){return Ye(t,Xe("RevokeBlendPool",x(e.pool)),o)}function mo(t,e,o){return Ye(t,Xe("CreateLiquidityPool",$({asset:x((r=e).asset),hub_id:T(r.hubId),params:oe(r.params)})),o);var r}function bo(t,e,o){return Ye(t,Xe("UpgradeLiquidityPoolParams",$({hub_asset:O((r=e).hubId,r.asset),params:ee(r.params)})),o);var r}function wo(t,e,o){return Ye(t,Xe("DeployPool",B(e.wasmHash)),o)}function So(t,e,o){return Ye(t,Xe("UpgradePool",B(e.wasmHash)),o)}function vo(t,e,o){return Ye(t,Xe("UpgradeController",B(e.wasmHash)),o)}function xo(t,e,o){return Ye(t,Xe("MigrateController",T(e.newVersion)),o)}function Ao(t,e,o){return Ye(t,Xe("TransferCtrlOwnership",He(e)),o)}function To(t,e,o){return Ye(t,Xe("ConfigureAssetOracle",$({key:ne((r=e).key),oracle:de(r.oracle)})),o);var r}const Io=To;function qo(t,e,o){return Ye(t,Xe("EditOracleTolerance",$({key:ne((r=e).key),tolerance:T(r.tolerance)})),o);var r}function Eo(t,e,o){return Ye(t,Xe("UpgradeGov",B(e.wasmHash)),o)}function ko(t,e,o){return Ye(t,Xe("UpdateGovDelay",T(e.newDelay)),o)}function _o(t,e,o){return Ye(t,Xe("GrantGovRole",je(e)),o)}function Ro(t,e,o){return Ye(t,Xe("RevokeGovRole",je(e)),o)}function Bo(t,e,o){return Ye(t,Xe("TransferGovOwnership",He(e)),o)}function Po(t,e){const o=R(e.argsXdr.map((t=>p.ScVal.fromXDR(t,"base64")))),r=Ve(e.predecessor??ze);return Ke(t,"execute",[_(),x(e.target),k(e.functionName),o,r,Ve(e.salt)])}function Oo(t,e,o){return Je(t,Xe("UpgradeGov",B(e.wasmHash)),o)}function Mo(t,e,o){return Je(t,Xe("UpdateGovDelay",T(e.newDelay)),o)}function Uo(t,e,o){return Je(t,Xe("GrantGovRole",je(e)),o)}function Co(t,e,o){return Je(t,Xe("RevokeGovRole",je(e)),o)}function $o(t,e,o){return Je(t,Xe("TransferGovOwnership",He(e)),o)}const Lo=t=>R(t.map(x));function Do(t,e,o){return Ke(t,"propose_canceller_reset",[Lo(e.newCancellers),Ve(o)])}function No(t,e,o){return Ke(t,"execute_canceller_reset",[P(e.executor,x),Lo(e.newCancellers),Ve(o)])}function Wo(t,e){return Ke(t,"set_spoke_asset_flags",[x(t.caller),T(e.spokeId),O(e.hubId,e.asset),q(e.paused),q(e.frozen),q(e.noSeize)])}function Fo(t,e){return Ke(t,"set_oracle_sanity_bounds",[x(t.caller),x(e.asset),A(e.minPriceWad),A(e.maxPriceWad)])}function zo(t){return Ke(t,"create_hub",[x(t.caller)])}function Vo(t){return Ke(t,"add_spoke",[x(t.caller)])}function Xo(t,e){return Ke(t,"revoke_role_immediate",[x(e.account),k(e.role)])}function Ho(t){return Ke(t,"pause",[x(t.caller)])}function Go(t,e){return Ye(t,Xe("Unpause"),e)}const jo=t=>t.toXDR("base64"),Ko=t=>p.ScVal.fromXDR(t,"base64"),Yo=t=>t.map((t=>String(l(Ko(t))))).join(":"),Jo=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),Zo=t=>Number(t),Qo=t=>String(t),tr=t=>t instanceof Uint8Array?b.hp.from(t).toString("hex"):b.hp.isBuffer(t)?t.toString("hex"):String(t),er=["None","Multiply","Long","Short"],or=["supply","borrow","withdraw","repay","liq_repay","liq_seize","multiply","param_upd","sw_debt_r","sw_col_wd","rp_col_wd","rp_col_r","close_wd","migrate","rp_col_net","liq_credit"],rr=t=>Array.isArray(t)?t:[],nr=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],or[Zo(r)]??Jo(r)),positionType:e,hubId:Zo(t[1]),asset:Qo(t[2]),scaledAmountRay:Jo(t[3]),indexRay:Jo(t[4]),amount:Jo(t[5]),liquidationThresholdBps:o?void 0:Zo(t[6]),liquidationBonusBps:o?void 0:Zo(t[7]),loanToValueBps:o?void 0:Zo(t[8]),liquidationFeesBps:o?void 0:Zo(t[9])};var r},ir=t=>{return{owner:Qo(t[0]),spokeId:Zo(t[1]),mode:(e=t[2],er[Zo(e)]??"None")};var e},sr=t=>Array.isArray(t)?t[1]:void 0,ur=t=>{const e=(o=t,Array.isArray(o)?Qo(o[0]):Qo(o));var o;if("Token"===e)return{Token:Qo(sr(t))};if("Ref"===e)return{Ref:Qo(sr(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:Qo(e.Token)};if(void 0!==e.Ref)return{Ref:Qo(e.Ref)}}return{Token:Qo(t)}},ar=t=>{const e=t.tolerance??{};return{assetDecimals:Zo(t.asset_decimals),maxPriceStaleSeconds:Zo(t.max_price_stale_seconds),sources:rr(t.sources).map((t=>t)),tolerance:{upperRatio:Zo(e.upper_ratio_bps),lowerRatio:Zo(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:Jo(t.min_sanity_price_wad),maxSanityPriceWad:Jo(t.max_sanity_price_wad)}},lr={"market:create":t=>({topic:"market:create",data:{hubId:Zo(t.hub_id),baseAsset:Qo(t.base_asset),maxBorrowRate:Jo(t.max_borrow_rate),baseBorrowRate:Jo(t.base_borrow_rate),slope1:Jo(t.slope1),slope2:Jo(t.slope2),slope3:Jo(t.slope3),midUtilization:Jo(t.mid_utilization),optimalUtilization:Jo(t.optimal_utilization),maxUtilization:Jo(t.max_utilization),reserveFactor:Zo(t.reserve_factor),marketAddress:Qo(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:Qo(t.asset),maxBorrowRateRay:Jo(t.max_borrow_rate),baseBorrowRateRay:Jo(t.base_borrow_rate),slope1Ray:Jo(t.slope1),slope2Ray:Jo(t.slope2),slope3Ray:Jo(t.slope3),midUtilizationRay:Jo(t.mid_utilization),optimalUtilizationRay:Jo(t.optimal_utilization),maxUtilizationRay:Jo(t.max_utilization),reserveFactorBps:Zo(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:rr(t).map((t=>{return e=rr(t),{hubId:Zo(e[0]),asset:Qo(e[1]),timestamp:Zo(e[2]),supplyIndexRay:Jo(e[3]),borrowIndexRay:Jo(e[4]),cash:Jo(e[5]),suppliedRay:Jo(e[6]),borrowedRay:Jo(e[7]),revenueRay:Jo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:rr(t).map((t=>{const e=t;return{hubId:Zo(e.hub_id),asset:Qo(e.asset),params:(o=e.params,{maxBorrowRateRay:Jo(o.max_borrow_rate),baseBorrowRateRay:Jo(o.base_borrow_rate),slope1Ray:Jo(o.slope1),slope2Ray:Jo(o.slope2),slope3Ray:Jo(o.slope3),midUtilizationRay:Jo(o.mid_utilization),optimalUtilizationRay:Jo(o.optimal_utilization),maxUtilizationRay:Jo(o.max_utilization),reserveFactorBps:Zo(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:Zo(o.flashloan_fee),assetId:Qo(o.asset_id),assetDecimals:Zo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=rr(t);return{topic:"position:batch_update",data:{accountId:Jo(e[0]),accountAttributes:ir(rr(e[1])),updates:[...rr(e[2]).map((t=>nr(rr(t),"Deposit"))),...rr(e[3]).map((t=>nr(rr(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:Zo(t.hub_id),asset:Qo(t.asset),receiver:Qo(t.receiver),caller:Qo(t.caller),amount:Jo(t.amount),fee:Jo(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:ur(t.key),oracle:ar(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:Qo(t.asset),oracle:ar(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:Qo(t.liquidator),accountId:Jo(t.account_id),repaidUsdWad:Jo(t.repaid_usd_wad),bonusBps:Jo(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:Jo(t.account_id),totalBorrowUsdWad:Jo(t.total_borrow_usd_wad),totalCollateralUsdWad:Jo(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:Qo(t.token),amount:Jo(t.amount),usdValueWad:Jo(t.usd_value_wad),accountId:Jo(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:Zo(t.hub_id),asset:Qo(t.asset),amount:Jo(t.amount),fee:Jo(t.fee),amountSent:Jo(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:Qo(t.pool??t.blend_pool??t.token),approved:Boolean(t.approved??t.is_approved??!0)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:tr(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:Qo(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:Qo(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:Qo(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:Qo(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:tr(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:Zo(t.max_supply_positions),maxBorrowPositions:Zo(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Jo(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:Qo(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:Zo(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:Jo(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Jo(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:Zo(e.liquidation_bonus_factor_bps)}}}},pr=Object.freeze(Object.keys(lr));function cr(t,e){const o=Yo(t),r=lr[o];return r?r(l(Ko(e))):null}const dr=1e4;function fr(t,e){return`${t}-${BigInt(e).toString(10)}`}function hr(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function yr(t,e=0){return t*dr+e}function gr(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"liq_credit":default:return"lendingUpdateAccountPosition";case"param_upd":return"lendingUpdateAccountParameters"}}const mr=(t,e,o)=>{const r=new URL(e,t.endsWith("/")?t:`${t}/`);if(o)for(const[t,e]of Object.entries(o))void 0!==e&&r.searchParams.set(t,String(e));return r.toString()};async function br(t,e){if(!e.baseUrl)throw new Error("Stellar quote baseUrl is required");if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=mr(e.baseUrl,"api/v1/quote",{from:t.from,to:t.to,amountIn:t.amountIn,amountOut:t.amountOut,maxHops:t.maxHops,maxSplits:t.maxSplits,slippage:t.slippage,includePaths:t.includePaths,sender:t.sender,router:t.router,referralId:t.referralId,platform:t.platform,fresh:t.fresh}),r=await fetch(o,e.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${o} — ${t}`)}return await r.json()}async function wr(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=mr(t.baseUrl,"api/v1/tokens"),o=await fetch(e,t.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${e} — ${t}`)}return await o.json()}const Sr=16384;class vr extends Error{code;constructor(t,e){super(`Stellar route verification failed [${t}]: ${e}`),this.name="StellarRouteVerificationError",this.code=t}}const xr=(t,e)=>{throw new vr(t,e)};function Ar(t){const o=(t=>{const e="string"==typeof t?t:t&&"object"==typeof t&&"routeXdr"in t?t.routeXdr:void 0;if("string"==typeof e&&e.length>2*Sr)return xr("OVERSIZED",`encoded route has ${e.length} characters`);try{return b.hp.from(z(t).bytes())}catch(t){return xr("MALFORMED",t instanceof Error?t.message:String(t))}})(t);0===o.length&&xr("MALFORMED","route is empty"),o.length>Sr&&xr("OVERSIZED",`route has ${o.length} bytes, above ${Sr}`);const r=(t=>{let e;try{e=p.ScVal.fromXDR(t)}catch(t){return xr("MALFORMED",`payload is not one XDR ScVal: ${t instanceof Error?t.message:String(t)}`)}if("scvMap"!==e.switch().name)return xr("MALFORMED","payload must be a StrategyPayload map");const o=e.map()??[];if("amounts,assets,ops"!==o.map((t=>"scvSymbol"===t.key().switch().name?t.key().sym().toString():"")).join(","))return xr("MALFORMED","payload fields must be exactly amounts, assets, ops");const[r,n,i]=o.map((t=>t.val()));return"scvVec"!==r.switch().name||"scvVec"!==n.switch().name||"scvBytes"!==i.switch().name?xr("MALFORMED","payload field has the wrong type"):{amounts:r.vec()??[],assets:n.vec()??[],ops:b.hp.from(i.bytes())}})(o),n=r.assets.length,i=r.amounts.length;0===n&&xr("MALFORMED","asset registry is empty"),(n>256||i>126)&&xr("OVERSIZED",`registries hold ${n} assets and ${i} amounts`);const s=r.assets.map(((t,o)=>"scvAddress"!==t.switch().name?xr("MALFORMED",`assets[${o}] is not an address`):e.fromScAddress(t.address()).toString())),u=r.amounts.map(((t,e)=>"scvI128"!==t.switch().name?xr("MALFORMED",`amounts[${e}] is not an i128`):a(t))),l=r.ops;l.length<10&&xr("MALFORMED","program header is truncated"),l.length>346&&xr("OVERSIZED",`program has ${l.length} bytes, above 346`);const c=t=>{const e=l[t];return void 0===e?xr("MALFORMED",`program byte ${t} is missing`):e},d=c(0);1!==d&&xr("UNSUPPORTED_VERSION",`program version ${d}, expected 1`);const f=c(8),h=c(9);0===f&&xr("INVALID_STRUCTURE","program has no instructions"),(f>48||h>32)&&xr("OVERSIZED",`program declares ${f} instructions and ${h} weights`);const y=10+5*f;l.length!==y+3*h&&xr("MALFORMED","program length does not match its instruction and weight counts");const g=c(1),m=c(2),S=c(3);(g>=n||m>=n||S>=i)&&xr("MALFORMED","header index is outside its registry"),g===m&&xr("INVALID_STRUCTURE","token_in equals token_out");const x=l.readUInt32BE(4),A=[];for(let t=0;t<h;t+=1){const e=l.readUIntBE(y+3*t,3);(0===e||e>v)&&xr("INVALID_STRUCTURE",`split weight ${e} outside 1..=1000000`),A.push(e)}const T=t=>s[t]??xr("MALFORMED",`asset index ${t} is outside the registry`),I=t=>u[t]??xr("MALFORMED",`amount index ${t} is outside the registry`),q=[];let E;for(let t=0;t<f;t+=1){const e=10+5*t,o=c(e),r=c(e+1),n=c(e+2),s=c(e+3),u=c(e+4);let a;if(o>6&&xr("UNKNOWN_OPCODE",`instruction ${t} has opcode ${o}`),0===r)a={kind:"all"};else if(1===r)void 0!==E&&E===s||xr("INVALID_STRUCTURE",`instruction ${t} does not chain onto its predecessor`),a={kind:"prev"};else if(r>=128){const e=A[r-128];void 0===e&&xr("MALFORMED",`instruction ${t} weight index is out of range`),a={kind:"ppm",ppm:e}}else a={kind:"fixed",amount:I(r-2)};const l=T(n);5!==o&&6!==o?(s===u&&xr("INVALID_STRUCTURE",`instruction ${t} swaps a token for itself`),q.push({kind:"swap",venue:w[o],mode:a,pool:l,tokenIn:T(s),tokenOut:T(u)}),E=u):("all"!==a.kind&&xr("MALFORMED",`liquidity instruction ${t} must use mode All`),u>=i&&xr("MALFORMED",`instruction ${t} amount index is out of range`),q.push({kind:5===o?"burn":"mint",pool:l,shareToken:T(s),amountIndex:u}),E=6===o?s:void 0)}const k=I(S);return k<=0n&&xr("MIN_OUT_TOO_LOW",`encoded total_min_out is ${k}`),{version:d,tokenIn:T(g),tokenOut:T(m),totalMinOut:k,referralId:x,assets:s,amounts:u,ops:q,weights:A}}function Tr(t,e){if(s.isValidContract(t))return t;if(!e)return xr("EXPECTATION_MISSING",`token ${t} is not a contract id; pass \`network\` to derive its asset contract`);try{const r=t.indexOf(":");return("XLM"===t||"native"===t?o.native():new o(t.slice(0,r),t.slice(r+1))).contractId(m[e])}catch{return xr("MALFORMED",`token id ${t} is not a contract id or a classic asset`)}}const Ir=(t,e)=>"bigint"==typeof t?t:/^\d+$/.test(t)?BigInt(t):xr("EXPECTATION_MISSING",`${e} must be a base-unit integer string`);function qr(t,e){const o=Ir(e.minOut,"expected.minOut");o<=0n&&xr("EXPECTATION_MISSING","expected.minOut must be positive");const r=Ar(t);if(r.tokenIn!==e.tokenIn&&xr("TOKEN_IN_MISMATCH",`route spends ${r.tokenIn}, expected ${e.tokenIn}`),r.tokenOut!==e.tokenOut&&xr("TOKEN_OUT_MISMATCH",`route delivers ${r.tokenOut}, expected ${e.tokenOut}`),r.totalMinOut<o&&xr("MIN_OUT_TOO_LOW",`route enforces a minimum of ${r.totalMinOut}, below the expected ${o}`),void 0!==e.amountIn){const t=Ir(e.amountIn,"expected.amountIn");for(const e of r.ops)"swap"===e.kind&&"fixed"===e.mode.kind&&e.tokenIn===r.tokenIn&&e.mode.amount>t&&xr("AMOUNT_IN_EXCEEDED",`a leg spends ${e.mode.amount}, above the input ${t}`)}return r}const Er=t=>D(t).toXDR("base64");function kr(e,o){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const i=new n(e.routerAddress),s=new t(e.caller,e.sourceSequence),a=z(((t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t)(o,e.referralId));return{xdr:new u(s,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(i.call("execute_strategy",x(e.caller),A(e.totalIn),a)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function _r(t,e){return kr(t,e)}function Rr(t,e={}){if("string"!=typeof t.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:t.paths?t.paths.map((t=>({hops:t.swaps.map(Or),splitPpm:t.splitPpm}))):[{hops:t.hops.map(Or),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Br(t,e={}){const o=e.expected??{},r="string"==typeof t.routeXdr&&t.routeXdr.length>0?{routeXdr:t.routeXdr}:Rr(t,e),n=[t.amountOutMin,o.minOut].filter((t=>void 0!==t)).map((t=>{if("bigint"==typeof t)return t;if("string"!=typeof t||!/^\d+$/.test(t))throw new vr("MALFORMED","minimum output must be a base-unit integer string");return BigInt(t)})).reduce(((t,e)=>void 0===t||e>t?e:t),void 0);if(void 0===n)throw new vr("EXPECTATION_MISSING","quote has no `amountOutMin`; pass `slippage` when fetching it or `expected.minOut`");return qr(r,{tokenIn:Tr(o.tokenIn??t.from,e.network),tokenOut:Tr(o.tokenOut??t.to,e.network),minOut:n,amountIn:o.amountIn??t.amountIn}),r}const Pr=Rr,Or=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});class Mr extends Error{code;offender;constructor(t,e,o){super(`Stellar authorization check failed [${t}]: ${e}${o?` — ${o.contract}.${o.fn}(${o.args.join(", ")})`:""}`),this.name="StellarAuthPolicyError",this.code=t,this.offender=o}}const Ur=t=>"scvAddress"===t?.switch().name?e.fromScAddress(t.address()).toString():void 0,Cr=t=>"scvI128"===t?.switch().name?a(t):void 0,$r=t=>"scvVec"===t?.switch().name?t.vec()??[]:void 0,Lr=(t,e)=>"scvMap"===t?.switch().name?(t.map()??[]).find((t=>"scvSymbol"===t.key().switch().name&&t.key().sym().toString()===e))?.val():void 0,Dr=t=>Ur(t)??Cr(t)?.toString()??t.toXDR("base64"),Nr=t=>({contract:e.fromScAddress(t.contractAddress()).toString(),fn:t.functionName().toString(),args:t.args().map(Dr)}),Wr=t=>{const e=t.function();return"sorobanAuthorizedFunctionTypeContractFn"===e.switch().name?e.contractFn():void 0};function Fr(t,o,r){const n=t.filter((t=>{const n=t.credentials();return("sorobanCredentialsAddress"===n.switch().name?e.fromScAddress(n.address().address()).toString():r??o.caller)===o.caller}));if(n.length>1)throw new Mr("DUPLICATE_ENTRY",`${n.length} authorization entries for ${o.caller}, expected one`);const i=n[0];if(!i)return;const s=Wr(i.rootInvocation());if(!s)throw new Mr("UNEXPECTED_ROOT","root is not a contract call");const u=Nr(s);if(u.contract!==o.root.contract||u.fn!==o.root.fn)throw new Mr("UNEXPECTED_ROOT",`expected ${o.root.contract}.${o.root.fn}`,u);const a=o.transfers.map((()=>0n)),l=(o.calls??[]).map((()=>0));for(const t of i.rootInvocation().subInvocations()){const e=Wr(t);if(!e)throw new Mr("UNEXPECTED_CALL","sub-invocation is not a contract call");const r=Nr(e);if(t.subInvocations().length>0)throw new Mr("NESTED_INVOCATION","sub-invocation carries its own sub-invocations",r);const n=(o.calls??[]).findIndex((t=>t.contract===r.contract&&t.fn===r.fn));if(-1!==n){const t=(o.calls??[])[n],i=t.reject(e.args());if(i)throw new Mr("UNEXPECTED_CALL",i,r);if(l[n]=(l[n]??0)+1,(l[n]??0)>t.maxCount)throw new Mr("UNEXPECTED_CALL",`more than ${t.maxCount} calls`,r);continue}if("transfer"!==r.fn||3!==e.args().length)throw new Mr("UNEXPECTED_CALL","only `transfer` is allowed",r);if(!o.transfers.some((t=>t.token===r.contract)))throw new Mr("UNEXPECTED_TOKEN","transfer on an unexpected token",r);const[i,s,u]=e.args();if(Ur(i)!==o.caller)throw new Mr("UNEXPECTED_SENDER","transfer is not from the caller",r);const p=Ur(s),c=o.transfers.findIndex((t=>t.token===r.contract&&t.to===p));if(-1===c)throw new Mr("UNEXPECTED_RECIPIENT","transfer to an unexpected recipient",r);const d=Cr(u),f=o.transfers[c],h=(a[c]??0n)+(d??0n);if(void 0===d||d<=0n||h>f.maxAmount)throw new Mr("AMOUNT_EXCEEDED",`transfers total ${h}, above the expected ${f.maxAmount}`,r);a[c]=h}}const zr=t=>{throw new Mr("MALFORMED_TRANSACTION",t)},Vr=(t,e)=>{const o=new Map;for(const e of $r(t)??zr("payments argument is not a vector")){const[t,r]=$r(e)??[],n=Ur(Lr(t,"asset")),i=Cr(r);if(void 0===n||void 0===i||i<0n)return zr("payment is not a (HubAssetKey, i128) tuple");o.set(n,(o.get(n)??0n)+i)}return[...o].map((([t,o])=>({token:t,to:e,maxAmount:o})))},Xr=new Set([1,3,5]),Hr=(t,e,o)=>({contract:t,fn:"submit",maxCount:2,reject:t=>{if(4!==t.length)return"submit must have four arguments";if(Ur(t[0])!==e)return"`from` is not the caller";if(Ur(t[1])!==o||Ur(t[2])!==o)return"`spender` and `to` must be the lending controller";const r=$r(t[3]);if(!r)return"requests is not a vector";for(const t of r){const e=Lr(t,"request_type");if("scvU32"!==e?.switch().name||!Xr.has(e.u32()))return"request is not a withdraw, withdraw-collateral, or repay"}}});function Gr(t,e,o){const{contract:r,fn:n}=Nr(e),i=e.args(),s={caller:t,root:{contract:r,fn:n},transfers:[]};if(r===o.governance)return s;if(r===o.aggregatorRouter){if("execute_strategy"!==n)return s;const e=Cr(i[1]);if(Ur(i[0])!==t||void 0===e||"scvBytes"!==i[2]?.switch().name)return zr("execute_strategy arguments must be (caller, total_in, swap_xdr)");const o=Ar(i[2].bytes());return s.transfers=[{token:o.tokenIn,to:r,maxAmount:e}],s}if(r!==o.lendingController)throw new Mr("UNSUPPORTED_CONTRACT",`no authorization policy for contract ${r}; pass an explicit policy`);if(Ur(i[0])!==t)throw new Mr("CALLER_MISMATCH",`${n} is not invoked for ${t}`);switch(n){case"supply":s.transfers=Vr(i[3],o.lendingPool);break;case"repay":case"liquidate":s.transfers=Vr(i[2],o.lendingPool);break;case"multiply":{const t=i[8];t&&"scvVoid"!==t.switch().name&&(s.transfers=Vr(p.ScVal.scvVec([t]),r));break}case"migrate_from_blend":{const e=Ur(i[4])??zr("blend_pool is not an address");s.calls=[Hr(e,t,r)];break}}return s}const jr=t=>{let e;try{e=p.TransactionEnvelope.fromXDR(t,"base64")}catch{return zr("not a transaction envelope")}if("envelopeTypeTx"!==e.switch().name)return zr("expected a regular (v1) transaction");const o=e.v1().tx(),r=o.operations()[0];if(!r||1!==o.operations().length)return zr("expected exactly one operation");const n=r.body();if("invokeHostFunction"!==n.switch().name)return zr("operation is not a contract invocation");const i=n.invokeHostFunctionOp();return"hostFunctionTypeInvokeContract"!==i.hostFunction().switch().name?zr("host function is not a contract call"):{source:(u=r.sourceAccount()??o.sourceAccount(),s.encodeEd25519PublicKey("keyTypeMuxedEd25519"===u.switch().name?u.med25519().ed25519():u.ed25519())),op:i,call:i.hostFunction().invokeContract()};var u};function Kr(t,e){const o=jr(t);if(void 0!==e.builtXdr&&jr(e.builtXdr).op.hostFunction().toXDR("base64")!==o.op.hostFunction().toXDR("base64"))throw new Mr("INVOCATION_CHANGED","the prepared transaction does not invoke what was built",Nr(o.call));const r=e.policy??Gr(e.caller,o.call,{...g(e.network),...e.deployment});Fr(o.op.auth(),r,o.source)}function Yr(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Jr(t,e,o){const r=u.fromXDR(e,o?.network?m[o.network]:"");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw Yr(o.invokedContractId,t);throw t}}async function Zr(t,e,o){return Jr(t,e.xdr,o)}function Qr(t){if(t<=0||t>4)throw new Error(`Invalid PositionMode ${t} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return t-1}function tn(t,e){return new Uint8Array(0)}const en=t=>{const e=t.startsWith("0x")?t.slice(2):t;if(e.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return b.hp.from(e,"hex")};function on(e){const o=new t(e.caller,e.sourceSequence),r=new n(e.forwarderAddress).call("mint_and_forward",p.ScVal.scvBytes(en(e.message)),p.ScVal.scvBytes(en(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const rn=10n**27n,nn=10n**18n,sn=10000n,un=27,an=18;function ln(t,e="value"){let o;if("bigint"==typeof t)o=t;else if("number"==typeof t){if(!Number.isSafeInteger(t))throw new Error(`Stellar math: ${e} must be a safe integer, got ${t}`);o=BigInt(t)}else{const r=t.trim();if(!/^-?\d+$/.test(r))throw new Error(`Stellar math: ${e} must be a decimal integer string, got "${t}"`);o=BigInt(r)}if(o<0n)throw new Error(`Stellar math: ${e} must be non-negative, got ${o}`);return o}function pn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");return t*e/o}function cn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");const r=t*e,n=r/o;return r%o===0n?n:n+1n}function dn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");return(t*e+o/2n)/o}function fn(t,e){if(0n===e)throw new Error("Stellar math: division by zero");const o=t/e;return t%e>=e/2n+e%2n?o+1n:o}const hn=t=>10n**BigInt(t);function yn(t,e,o){return e===o?t:o>e?t*hn(o-e):t/hn(e-o)}function gn(t,e,o){if(e===o)return t;if(o>e)return t*hn(o-e);const r=hn(e-o),n=t/r;return t%r===0n?n:n+1n}function mn(t,e,o){return e===o?t:o>e?t*hn(o-e):fn(t,hn(e-o))}const bn={floor:pn,ceil:cn,halfUp:dn},wn={floor:yn,ceil:gn,halfUp:mn};function Sn(t,e,o,r){return wn[r](bn[r](t,e,rn),un,o)}function vn(t,e,o){return Sn(ln(t,"scaledRay"),ln(e,"indexRay"),o,"floor")}function xn(t,e,o){return Sn(ln(t,"scaledRay"),ln(e,"indexRay"),o,"ceil")}function An(t,e,o){return Sn(ln(t,"scaledRay"),ln(e,"indexRay"),o,"halfUp")}function Tn(t,e){if(e>un)throw new Error(`Stellar math: decimals ${e} exceed RAY scale`);return yn(t,e,un)}function In(t,e,o,r){const n=bn[r](t,e,rn),i=wn[r](n,un,an);return bn[r](i,o,nn)}function qn(t,e,o,r){const n=wn[r](Tn(t,e),un,an);return bn[r](n,o,nn)}const En=t=>Number(t)/1e18,kn=t=>Number(t)/1e27,_n=(t,e)=>Number(t)/10**e;function Rn(t,e){if(!Number.isFinite(t)||t<=0||t>=1e21)return 0n;const o=t.toFixed(e),[r="0",n=""]=o.split(".");return BigInt(r+n.padEnd(e,"0"))}const Bn=t=>Rn(t,an),Pn=(t,e)=>dn(t,e,rn),On=(t,e)=>dn(t,rn,e);function Mn(t,e){return 0n===e?0n:On(t,e)}function Un(t,e){const o=t>rn?rn:t,r=ln(e.baseRateRay,"irm.baseRateRay"),n=ln(e.slope1Ray,"irm.slope1Ray"),i=ln(e.slope2Ray,"irm.slope2Ray"),s=ln(e.slope3Ray,"irm.slope3Ray"),u=ln(e.midUtilizationRay,"irm.midUtilizationRay"),a=ln(e.optimalUtilizationRay,"irm.optimalUtilizationRay"),l=ln(e.maxBorrowRateRay,"irm.maxBorrowRateRay");let p;if(o<u)p=r+On(Pn(o,n),u);else if(o<a){const t=a-u;p=r+n+On(Pn(o-u,i),t)}else{const t=rn-a;p=r+n+i+(0n===t?0n:On(Pn(o-a,s),t))}return p>l?l:p}function Cn(t,e,o){return 0n===t||!Number.isInteger(o)||o<0||o>=1e4?0n:dn(Pn(t,e),sn-BigInt(o),sn)}const $n=t=>kn(t),Ln=t=>Math.expm1(kn(t)),Dn=5n*nn,Nn=(t,e,o)=>`${t}:${e}:${o}`;function Wn(t,e,o,r){const n=Array.isArray(t)?t:void 0,i=n?n.find((t=>t.spokeId===e&&t.hubId===o&&t.asset===r)):t[Nn(e,o,r)]??Object.values(t).find((t=>t.spokeId===e&&t.hubId===o&&t.asset===r));if(!i)throw new Error(`Stellar math: no reserve for ${Nn(e,o,r)}`);return i}const Fn=/^0*[1-9]\d*$/,zn=t=>"string"==typeof t&&Fn.test(t)?BigInt(t).toString():null,Vn=(t,e)=>`${t}:${e}`;function Xn(t){const e=new Map,o=new Map,r=new Set,n=new Set;for(const i of t?.indexes??[]){const t=Vn(i.hubId,i.asset),s=zn(i.supplyIndex),u=zn(i.borrowIndex),a=zn(i.usdPrice),l=e.get(t),p=l&&zn(l.supplyIndex)===s&&zn(l.borrowIndex)===u&&zn(l.usdPrice)===a;null==s||null==u||null==a||l&&!p?r.add(t):l||e.set(t,i);const c=!1===i.valid||!0===i.stale||!0===i.deviation,d=o.get(i.asset);null==a||c||void 0!==d&&d.toString()!==a?n.add(i.asset):void 0===d&&o.set(i.asset,BigInt(a))}for(const t of r)e.delete(t);for(const t of n)o.delete(t);return{indexes:e,prices:o,rejectedIndexKeys:r,rejectedAssets:n}}const Hn=(t,e)=>pn(t,BigInt(e),sn);function Gn(t,e,o,r){const n="supply"===t.side,i=Math.min(t.entryLtvBps,t.entryLiquidationThresholdBps);return{side:t.side,hubId:t.hubId,asset:t.asset,decimals:t.decimals,scaledRay:t.scaledRay.toString(),indexRay:t.indexRay.toString(),usdPriceWad:t.priceWad.toString(),usdPrice:En(t.priceWad),amountBase:e.toString(),amountShort:_n(e,t.decimals),usdWad:o.toString(),usd:En(o),gateUsdWad:r.toString(),entryLtvBps:t.entryLtvBps,entryLiquidationThresholdBps:t.entryLiquidationThresholdBps,entryLiquidationBonusBps:t.entryLiquidationBonusBps,entryLiquidationFeesBps:t.entryLiquidationFeesBps,ltvWeightedUsdWad:n?Hn(r,i).toString():"0",liquidationWeightedUsdWad:n?Hn(r,t.entryLiquidationThresholdBps).toString():"0",liveDataUsed:t.liveDataUsed}}function jn(t){if("supply"===t.side)return Gn(t,Sn(t.scaledRay,t.indexRay,t.decimals,"floor"),In(t.scaledRay,t.indexRay,t.priceWad,"halfUp"),In(t.scaledRay,t.indexRay,t.priceWad,"floor"));const e=Sn(t.scaledRay,t.indexRay,t.decimals,"ceil"),o=In(t.scaledRay,t.indexRay,t.priceWad,"ceil");return Gn(t,e,o,o)}function Kn(t,e,o,r){const n=Tn(e,o);return"supply"===t?pn(n,rn,r):cn(n,rn,r)}function Yn(t,e,o,r){const n=Tn(e,o);return"supply"===t?cn(n,rn,r):pn(n,rn,r)}function Jn(t,e){return jn({...t,scaledRay:Kn(t.side,e,t.decimals,t.indexRay)})}const Zn=(...t)=>{for(const e of t){const t=zn(e);if(null!=t)return BigInt(t)}return rn};function Qn(t,e,o,r){const n=ln("supply"===t?e.supplyScaledRay:e.borrowScaledRay,`${t}ScaledRay`);if(0n===n)return null;const i=r.indexes.get(Vn(e.hubId,e.asset)),s=r.prices.get(e.asset),u="supply"===t?Zn(i?.supplyIndex,e.liveSupplyIndexRay,o.liveSupplyIndexRay,e.supplyIndexRay):Zn(i?.borrowIndex,e.liveBorrowIndexRay,o.liveBorrowIndexRay,e.borrowIndexRay),a=s??Bn(o.usdPrice);return jn({side:t,hubId:e.hubId,asset:e.asset,decimals:o.assetDecimals,scaledRay:n,indexRay:u,priceWad:a,entryLtvBps:e.entryLtvBps,entryLiquidationThresholdBps:e.entryLiquidationThresholdBps,entryLiquidationBonusBps:e.entryLiquidationBonusBps,entryLiquidationFeesBps:e.entryLiquidationFeesBps,liveDataUsed:void 0!==i&&void 0!==s})}const ti=(t,e)=>t.reduce(((t,o)=>t+BigInt(e(o))),0n);function ei(t,e,o,r,n){const i=ti(e,(t=>t.usdWad)),s=ti(e,(t=>t.ltvWeightedUsdWad)),u=ti(e,(t=>t.liquidationWeightedUsdWad)),a=ti(o,(t=>t.usdWad)),l=0n===a?null:pn(u,nn,a),p=0n===u?0:Number(a)/Number(u)*100,c=s<r||s<=a?0n:s-a;return{...t,supplies:e,borrows:o,totalCollateralUsdWad:i.toString(),totalCollateralUsd:En(i),ltvWeightedCollateralUsdWad:s.toString(),ltvWeightedCollateralUsd:En(s),liquidationWeightedCollateralUsdWad:u.toString(),liquidationWeightedCollateralUsd:En(u),totalDebtUsdWad:a.toString(),totalDebtUsd:En(a),healthFactorWad:null===l?null:l.toString(),healthFactor:null===l?null:En(l),healthPercent:p,borrowLimitUsdWad:s.toString(),borrowLimitUsd:En(s),availableBorrowUsdWad:c.toString(),availableBorrowUsd:En(c),minBorrowCollateralUsdWad:r.toString(),minBorrowCollateralUsd:En(r),isLiquidatable:null!==l&&l<nn,liveDataValid:n}}function oi(t){const{positions:e,reserves:o,liveState:r}=t,n=e[0];if(!n)throw new Error("Stellar math: computeAccountRisk needs at least one position row");for(const t of e)if(t.accountId!==n.accountId)throw new Error(`Stellar math: computeAccountRisk received mixed account ids (${n.accountId}, ${t.accountId})`);const i=Xn(r),s=[],u=[];for(const t of e){const e=Wn(o,t.spokeId,t.hubId,t.asset),r=Qn("supply",t,e,i);r&&s.push(r);const n=Qn("borrow",t,e,i);n&&u.push(n)}const a=null!=r?.minBorrowCollateralUsdWad?ln(r.minBorrowCollateralUsdWad,"minBorrowCollateralUsdWad"):Dn,l=void 0!==r&&[...s,...u].every((t=>t.liveDataUsed));return ei({accountId:n.accountId,owner:n.owner,spokeId:n.spokeId,mode:n.positionMode},s,u,a,l)}const ri=200n,ni=t=>t.reduce(((t,e)=>e.amount<t.amount?e:t)),ii=t=>t<0n?0n:t,si=(t,e,o,r)=>({amountBase:t.amount,amountShort:_n(t.amount,e),isFullClose:o,reason:t.reason,projectedUtilization:r}),ui=t=>({amountBase:0n,amountShort:0,isFullClose:!1,reason:t,projectedUtilization:null});function ai(t){const e=t.assetDecimals,o=ln(t.irm.maxUtilizationRay,"irm.maxUtilizationRay");return{suppliedBase:Rn(t.hubPool.suppliedShort,e),borrowedBase:Rn(t.hubPool.borrowedShort,e),cashBase:Rn(t.availableLiquidityShort,e),spokeSuppliedBase:Rn(t.suppliedShort,e),spokeBorrowedBase:Rn(t.borrowedShort,e),maxUtilizationRay:o>=rn?null:o}}const li=(t,e)=>t<=0n?null:Number(e)/Number(t);function pi(t,e){if(t<=0n||!e(0n))return 0n;let o=0n,r=t+1n;for(;r-o>1n;){const t=(o+r)/2n;e(t)?o=t:r=t}return o}const ci=(t,e)=>t.find((t=>t.hubId===e.hubId&&t.asset===e.asset));function di(t,e,o){if(e.paused)return ui("paused");if(e.frozen)return ui("frozen");if(!e.isBorrowable)return ui("cap");const r=e.assetDecimals,n=ai(e),i=ci(t.borrows,e),s=Xn(o).indexes.get(Vn(e.hubId,e.asset)),u=i?BigInt(i.indexRay):ln(s?.borrowIndex??e.liveBorrowIndexRay,"borrowIndex"),a=i?BigInt(i.usdPriceWad):function(t,e){return Xn(e).prices.get(t.asset)??Bn(t.usdPrice)}(e,o),l=i?BigInt(i.scaledRay):0n,p=BigInt(t.totalDebtUsdWad)-(i?BigInt(i.usdWad):0n),c=BigInt(t.ltvWeightedCollateralUsdWad),d=BigInt(t.minBorrowCollateralUsdWad),f=[];if(c<d)f.push({amount:0n,reason:"minCollateral"});else{const e=c-BigInt(t.totalDebtUsdWad),o=e<=0n||a<=0n?0n:pn(e,10n**BigInt(r),a),n=t=>p+In(l+Kn("borrow",t,r,u),u,a,"ceil");f.push({amount:0n===o?0n:pi(o+16n,(t=>n(t)<=c)),reason:"ltv"})}f.push({amount:ii(ln(e.borrowCap,"borrowCap")-n.spokeBorrowedBase),reason:"cap"});const h=dn(n.suppliedBase,ri,sn);f.push({amount:ii(n.cashBase-h),reason:"liquidity"});const y=function(t,e){const o=t.maxUtilizationRay;if(null===o)return null;const r=Tn(t.suppliedBase,e);return 0n===r?null:pi(ii(pn(t.suppliedBase,o,rn)-t.borrowedBase)+16n,(n=>Mn(Tn(t.borrowedBase+n,e),r)<=o))}(n,r);null!==y&&f.push({amount:y,reason:"utilizationCap"});const g=ni(f);return si(g,r,!1,li(n.suppliedBase,n.borrowedBase+g.amount))}function fi(t,e,o){if(e.paused)return ui("paused");const r=ci(t.supplies,e);if(!r)return ui(null);const n=r.decimals,i=ai(e),s=BigInt(r.scaledRay),u=BigInt(r.indexRay),a=BigInt(r.usdPriceWad),l=BigInt(r.amountBase),p=Sn(s,u,n,"halfUp"),c=BigInt(t.totalDebtUsdWad),d=BigInt(t.minBorrowCollateralUsdWad),f=BigInt(Math.min(r.entryLtvBps,r.entryLiquidationThresholdBps)),h=[];let y=!0;if(c>0n&&f>0n){const e=c>d?c:d,o=d>c?"minCollateral":"healthFactor",i=BigInt(t.ltvWeightedCollateralUsdWad)-BigInt(r.ltvWeightedUsdWad);if(i<e){y=!1;const t=e-i,l=cn(t,sn,f),c=BigInt(r.gateUsdWad)-l,d=c<=0n?0n:pn(c,10n**BigInt(n),a),g=p>0n?p-1n:0n,m=d+16n>g?g:d+16n,b=t=>{const e=Yn("supply",t,n,u);return pn(In(e>=s?0n:s-e,u,a,"floor"),f,sn)};h.push({amount:pi(m,(e=>b(e)>=t)),reason:o})}}h.push({amount:l,reason:null}),h.push({amount:i.cashBase,reason:"liquidity"});const g=function(t,e){const o=t.maxUtilizationRay;if(null===o||0n===t.borrowedBase)return null;if(0n===o)return 0n;const r=cn(t.borrowedBase,rn,o),n=t.suppliedBase<r?0n:t.suppliedBase-r+16n,i=Tn(t.borrowedBase,e);return pi(n>t.suppliedBase?t.suppliedBase:n,(r=>{const n=Tn(t.suppliedBase-r,e);return n>0n&&Mn(i,n)<=o}))}(i,n);null!==g&&h.push({amount:g,reason:"utilizationCap"});const m=ni(h),b=y&&m.amount>=l;return si(m,n,b,li(i.suppliedBase-m.amount,i.borrowedBase))}function hi(t){if(t.paused)return ui("paused");if(t.frozen)return ui("frozen");const e=t.assetDecimals,o=ai(t),r={amount:ii(ln(t.supplyCap,"supplyCap")-o.spokeSuppliedBase),reason:"cap"};return si(r,e,!1,li(o.suppliedBase+r.amount,o.borrowedBase))}function yi(t,e,o){if(e.paused)return ui("paused");const r=ci(t.borrows,e);if(!r)return ui(null);const n=r.decimals,i=ai(e),s=BigInt(r.amountBase),u=void 0===o?null:ln(o,"walletBalance"),a=null!==u&&u<s?{amount:u,reason:"liquidity"}:{amount:s,reason:null};return si(a,n,a.amount>=s,li(i.suppliedBase,ii(i.borrowedBase-a.amount)))}const gi=(t,e)=>t.hubId===e.hubId&&t.asset===e.asset,mi=t=>{if("bigint"==typeof t)return t;const e=t.trim();if(!/^-?\d+$/.test(e))throw new Error(`Stellar math: delta amountBase must be an integer string, got "${t}"`);return BigInt(e)};function bi(t,e){const o=[...t.supplies],r=[...t.borrows];for(const t of e){const e="supply"===t.side?o:r,n=e.findIndex((e=>gi(e,t))),i=-1===n?void 0:e[n],s=mi(t.amountBase);let u;if(i){const t={side:i.side,hubId:i.hubId,asset:i.asset,decimals:i.decimals,indexRay:BigInt(i.indexRay),priceWad:BigInt(i.usdPriceWad),entryLtvBps:i.entryLtvBps,entryLiquidationThresholdBps:i.entryLiquidationThresholdBps,entryLiquidationBonusBps:i.entryLiquidationBonusBps,entryLiquidationFeesBps:i.entryLiquidationFeesBps,liveDataUsed:i.liveDataUsed},e=BigInt(i.scaledRay);let o;if(s>=0n)o=e+Kn(t.side,s,t.decimals,t.indexRay);else{const r=-s,n=r>=("supply"===t.side?Sn(e,t.indexRay,t.decimals,"halfUp"):BigInt(i.amountBase))?e:Yn(t.side,r,t.decimals,t.indexRay);o=n>=e?0n:e-n}u=0n===o?null:jn({...t,scaledRay:o})}else u=s<=0n?null:Jn(wi(t),s);-1===n?u&&e.push(u):u?e[n]=u:e.splice(n,1)}return ei({accountId:t.accountId,owner:t.owner,spokeId:t.spokeId,mode:t.mode},o,r,BigInt(t.minBorrowCollateralUsdWad),t.liveDataValid)}function wi(t){const e=t.reserve;if(!e)throw new Error(`Stellar math: projectAccountRisk needs \`reserve\` for a new ${t.side} position on ${t.hubId}:${t.asset}`);return{side:t.side,hubId:t.hubId,asset:t.asset,decimals:e.assetDecimals,indexRay:ln("supply"===t.side?e.liveSupplyIndexRay:e.liveBorrowIndexRay,"reserve live index"),priceWad:Bn(e.usdPrice),entryLtvBps:e.collateralFactorBps,entryLiquidationThresholdBps:e.liquidationThresholdBps,entryLiquidationBonusBps:e.liquidationPenaltyBps,entryLiquidationFeesBps:e.liquidationFeesBps,liveDataUsed:!1}}function Si(t,e=0n,o=0n){const r=t.assetDecimals,n=t=>t<0n?0n:t,i=n(Rn(t.hubPool.suppliedShort,r)+mi(e)),s=Mn(Tn(n(Rn(t.hubPool.borrowedShort,r)+mi(o)),r),Tn(i,r)),u=Un(s,t.irm),a=Cn(s,u,t.irm.reserveFactorBps);return{utilization:kn(s),utilizationRay:s.toString(),borrowAprRay:u.toString(),supplyAprRay:a.toString(),borrowApr:$n(u),supplyApr:$n(a),borrowApy:Ln(u),supplyApy:Ln(a)}}const vi={1:{name:"AssetNotSupported",message:"This asset is not supported by the protocol."},2:{name:"AssetAlreadySupported",message:"This asset is already supported."},3:{name:"InvalidTicker",message:"Invalid asset ticker."},6:{name:"InvalidAsset",message:"Invalid asset address."},10:{name:"InvalidWasmHash",message:"The WASM hash is empty or invalid."},11:{name:"InvalidExchangeSrc",message:"The oracle configuration is invalid."},12:{name:"PairNotActive",message:"No oracle is configured for this asset."},32:{name:"OwnerNotSet",message:"The contract owner has not been set."},39:{name:"InvalidTimelockDelay",message:"The timelock delay is out of the allowed range."},41:{name:"InvalidRole",message:"The caller does not hold the required role."},43:{name:"HubNotActive",message:"This hub is not active."},44:{name:"NotAuthorized",message:"The caller is not authorized to perform this action."},46:{name:"OperationNotCancellable",message:"This governance operation cannot be cancelled."},113:{name:"InvalidLiqThreshold",message:"LTV, liquidation threshold, or bonus is out of bounds."},116:{name:"InvalidBorrowParams",message:"Supply or borrow cap configuration is invalid."},117:{name:"InvalidUtilRange",message:"Interest-rate utilization breakpoints are invalid."},132:{name:"AssetDecimalsTooHigh",message:"Asset decimals exceed the protocol maximum (27)."},300:{name:"SpokeNotFound",message:"This spoke does not exist."},301:{name:"SpokeDeprecated",message:"This spoke has been deprecated."},307:{name:"AssetNotInSpoke",message:"This asset is not listed on the spoke."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetInUse",message:"This spoke asset still has live positions; drain usage before removal."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},317:{name:"SpokeAssetFlagRelaxation",message:"Guardian flag updates may only tighten; clearing a flag requires the timelocked edit."},318:{name:"SpokeAssetSeizureHalted",message:"Liquidation seizure is halted for this spoke asset."},220:{name:"InvalidOracleBase",message:"The oracle quote asset/market is missing or invalid."},221:{name:"InvalidOracleDecimals",message:"The oracle decimals value is invalid."},224:{name:"InvalidSanityBounds",message:"Oracle sanity bounds are invalid (require 0 < min < max)."},225:{name:"OracleCycleDetected",message:"A cycle was detected in the oracle quote chain."}};function xi(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=vi[o];return r?{code:o,...r}:null}}},d={};function f(t){var e=d[t];if(void 0!==e)return e.exports;var o=d[t]={exports:{}};return c[t](o,o.exports,f),o.exports}f.d=(t,e)=>{for(var o in e)f.o(e,o)&&!f.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},f.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const h="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",g="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",m=3e4;var b;!function(t){t.MAINNET="1",t.DEVNET="D"}(b||(b={}));class w{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=b.MAINNET,apiUrl:o,...r}=t;this.apiUrl=o.trim().replace(/\/$/,""),this.chain=e,this.init=r,this.config=e==b.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:h,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:h,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:i,timeout:s,...u}=this.init,{next:a,cache:l,debug:p,timeout:c,headers:d,method:f="GET",...h}=o,y=d?.Authorization,g="Bearer undefined"===y?void 0:y,m="GET"!==f&&"HEAD"!==f&&"PUT"!==f,b={...d,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...m?{"Content-Type":"application/json"}:{},...g?{Authorization:g}:{}},w=Object.entries(e??{}).filter((([,t])=>void 0!==t)).flatMap((([t,e])=>Array.isArray(e)?e.filter((t=>void 0!==t)).map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),S=`${this.apiUrl}${t}${w.length?`?${w}`:""}`,{revalidate:v,...x}=r??{},{revalidate:A,...T}=a??{},I="GET"!==f||g?void 0:A??v,q="GET"!==f||g||I?void 0:l??n,E=h.body,k=c??s??(null==E?3e4:0),_=k>0?AbortSignal.timeout(k):void 0,R=h.signal??u.signal,B=_&&R?AbortSignal.any([R,_]):_??R,P={...u,...h,method:f,...Object.keys(b).length?{headers:b}:{},...B?{signal:B}:{},cache:q,next:{...x,...T,revalidate:I}};(p??i)&&console.debug("SDK fetch: ",S,P);const O=await fetch(S,P).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${S}: ${t.message}`),{cause:t});throw t})),M=await O.text();if(!O.ok){let t;try{t=JSON.parse(M)}catch{t={message:M}}const e=[S,O.status,O.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(M)}catch{return M}}}const S=t=>{const e=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(t)),o=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t),r=/^C[A-Z2-7]{55}$/.test(t);return e||o||r},v=t=>{const e=/^0x[a-fA-F0-9]{1,64}$/.test(t),o=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(t),r=/^C[A-Z2-7]{55}-\d+$/.test(t);return e||o||r};class x extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class A extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const T=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^[GC][A-Z2-7]{55}$/.test(t)),I={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/integrations/liquid-staking/multiversx/revenue":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/multiversx":{input:{},output:{}},"/integrations/lending/multiversx/revenue":{input:{},output:{}},"/integrations/lending/multiversx/liquidations":{input:{},output:{}},"/integrations/lending/multiversx/active-users":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/campaign/leaderboard":{input:{},output:{}},"/stellar-lending/campaign/me":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/stellar-lending/users/:owner/assets/:asset/balance":{input:{},output:{}},"/stellar-lending/users/:owner/activity/page":{input:{},output:{}}},q=["PATCH","POST","DELETE","PUT"];var E=f(626);const k=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function _(t,e,o,r){const{input:n,output:i,...s}=e,u=async(e={})=>{const n={...o,...e},i=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),s=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),u=Object.fromEntries(Object.entries(n).filter((([t])=>!s.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in u,l=/:collection[^A-Z]/.test(t)||"collection"in u;if(a){const t=n.address;if(!T(t))throw new A(t)}if(l){const t=n.collection;if(Array.isArray(t)?t.some((t=>!S(t))):!S(t))throw new x(t)}const p=Object.fromEntries(Object.entries(u).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:c,auth:d,method:f,headers:h,cache:y,next:g,debug:m,signal:b,credentials:w,mode:v,redirect:I,referrer:q,referrerPolicy:E,integrity:k,keepalive:_,priority:R,window:B,continuationToken:P,...O}=p,M=d?`Bearer ${d}`:void 0;t.startsWith("/stellar-lending/")&&void 0!==P&&(O.continuationToken=P);const U={...h,...M?{Authorization:M}:{},...P&&!t.startsWith("/stellar-lending/")?{"X-Continuation-Token":String(P)}:{}},C={...g,tags:[...g?.tags??[],i]};return r.fetchWithTimeout(i,{method:f,params:O,body:c,headers:U,cache:y,debug:m,...Object.fromEntries(Object.entries({signal:b,credentials:w,mode:v,redirect:I,referrer:q,referrerPolicy:E,integrity:k,keepalive:_,priority:R,window:B}).filter((([,t])=>void 0!==t))),...C?{next:C}:{}})},a=(t={})=>u(t);for(const t of Object.keys(s))q.includes(t)&&(a[t]=e=>u({...e,method:e.method??t.toUpperCase()}));return a}function R(t){const e=function(){const t={static:{},params:{},leaves:[]};for(const[e,o]of Object.entries(I)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=k(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=k(t);n=n.static[e]||={static:{},params:{},leaves:[]}}n.leaves.push({rawPath:e,def:o})}return t}(),o=(e,r)=>{const n=e.leaves.length,i=Object.keys(e.static).length,s=Object.keys(e.params).length;let u;if(1===n&&i+s>0){const{rawPath:o,def:n}=e.leaves[0];u=_(o,n,r,t)}else{u={};for(const{rawPath:o,def:n}of e.leaves)u[k(o.split("/").pop().replace(/^:/,""))]=_(o,n,r,t)}for(const[t,n]of Object.entries(e.static)){const e=o(n,r);let i=e;if(e&&"object"==typeof e&&t in e&&"function"==typeof e[t]){const o=e[t],r=Object.fromEntries(Object.entries(e).filter((([e])=>e!==t)));1===o.length||(Object.assign(o,r),i=o)}void 0===u[t]?u[t]=i:"function"==typeof u[t]?Object.assign(u[t],i):"function"==typeof i?(Object.assign(i,u[t]),u[t]=i):Object.assign(u[t],i)}for(const[t,n]of Object.entries(e.params)){const e=e=>{const i=o(n,{...r,[t]:e});if(i&&"object"==typeof i&&1===Object.keys(i).length&&t in i&&"function"==typeof i[t]){const e=i[t],o=(...t)=>e(...t);return Object.assign(o,e)}return i};if(u[t]){const o=u[t];u[t]=t=>({...o(t),...e(t)})}else u[t]=e}return u};return o(e,{})}export{b as Chain,m as DEFAULT_REQUEST_TIMEOUT_MS,w as XOXNOClient,R as buildSdk,S as isValidCollectionTicker,v as isValidNftIdentifier};export const BPS=E.UTY;export const DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD=E.fFH;export const LIQUIDATION_BUFFER_BPS=E.RCv;export const RAY=E.Z$K;export const RAY_DECIMALS=E.OAi;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=E.G_M;export const STELLAR_LENDING_TOPICS=E.fAY;export const STELLAR_NETWORKS=E.a_O;export const STELLAR_NETWORK_PASSPHRASE=E.A$9;export const STELLAR_ROUTE_MAX_BYTES=E.XvM;export const SYNTHETIC_EVENT_ORDER_STRIDE=E.gRW;export const StellarAuthPolicyError=E.cJU;export const StellarRouteVerificationError=E.SVM;export const WAD=E.DYS;export const WAD_DECIMALS=E.wFd;export const aggregateAccountRisk=E.wJe;export const annualBorrowRateRay=E.$wP;export const assertStellarAuthEntries=E.eBc;export const assertStellarPreparedTxAuth=E.JtG;export const baseToRay=E.Vhx;export const baseToShort=E.xEs;export const baseValueWad=E.t$R;export const buildLiveSnapshot=E.pU3;export const buildSameTokenRepaySwapSteps=E.VZJ;export const buildStellarAcceptOwnershipTx=E.N0v;export const buildStellarAddRewardsTx=E.B_D;export const buildStellarApproveBlendPoolTx=E.qLM;export const buildStellarApproveTokenTx=E.eX8;export const buildStellarBatchSwapTx=E.zaA;export const buildStellarBorrowBatchTx=E.xDR;export const buildStellarBorrowTx=E.jR0;export const buildStellarCctpForwardTx=E.P2l;export const buildStellarClaimRevenueTx=E.W68;export const buildStellarCreateLiquidityPoolTx=E.sec;export const buildStellarExecuteCancellerResetTx=E.ZPB;export const buildStellarExecuteStrategyTx=E.yrp;export const buildStellarFlashLoanTx=E.spi;export const buildStellarGovernanceAddSpokeImmediateTx=E.Iu1;export const buildStellarGovernanceCreateHubImmediateTx=E.yuB;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=E.$96;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=E.zwJ;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=E.h_A;export const buildStellarGovernanceExecuteTransferGovOwnTx=E.e_X;export const buildStellarGovernanceExecuteTx=E.TkG;export const buildStellarGovernanceExecuteUpdateDelayTx=E.BAg;export const buildStellarGovernancePauseTx=E.u9S;export const buildStellarGovernanceRevokeRoleImmediateTx=E.biU;export const buildStellarGovernanceSetOracleSanityBoundsImmediateTx=E.gc5;export const buildStellarGovernanceSetSpokeAssetFlagsImmediateTx=E.ayx;export const buildStellarGrantRoleTx=E.SXg;export const buildStellarLendingIdentifier=E.UFY;export const buildStellarLiquidateTx=E.Y5o;export const buildStellarMigrateFromBlendTx=E.mEH;export const buildStellarMigrateTx=E.xGW;export const buildStellarMultiplyTx=E.s9Q;export const buildStellarPauseTx=E.OL0;export const buildStellarProposeAddAssetToSpokeTx=E.k6p;export const buildStellarProposeAddSpokeTx=E.djE;export const buildStellarProposeApproveBlendPoolTx=E.kDJ;export const buildStellarProposeApproveTokenTx=E.Yfw;export const buildStellarProposeCancellerResetTx=E.AI1;export const buildStellarProposeConfigureAssetOracleTx=E.O2U;export const buildStellarProposeConfigureMarketOracleTx=E.c5J;export const buildStellarProposeCreateHubTx=E.N8y;export const buildStellarProposeCreateLiquidityPoolTx=E.qUh;export const buildStellarProposeDeployPoolTx=E.RZj;export const buildStellarProposeEditAssetInSpokeTx=E.nio;export const buildStellarProposeEditOracleToleranceTx=E.hFg;export const buildStellarProposeGovernanceUpgradeTx=E.Qkp;export const buildStellarProposeGrantGovernanceRoleTx=E.GwL;export const buildStellarProposeMigrateControllerTx=E.$Kr;export const buildStellarProposeRemoveAssetFromSpokeTx=E.ujH;export const buildStellarProposeRemoveSpokeTx=E.Odj;export const buildStellarProposeRevokeBlendPoolTx=E.X7c;export const buildStellarProposeRevokeGovernanceRoleTx=E.Ubz;export const buildStellarProposeRevokeTokenTx=E.Dx4;export const buildStellarProposeSetAccumulatorTx=E.OAr;export const buildStellarProposeSetAggregatorTx=E.$Uh;export const buildStellarProposeSetMinBorrowCollatTx=E.obN;export const buildStellarProposeSetPositionLimitsTx=E.$lZ;export const buildStellarProposeSetPositionManagerTx=E.Kaw;export const buildStellarProposeSetPriceAggregatorTx=E.Wbk;export const buildStellarProposeSetSpokeLiquidationCurveTx=E.kwV;export const buildStellarProposeSetSwapAggregatorTx=E.qAI;export const buildStellarProposeTransferCtrlOwnershipTx=E.VSx;export const buildStellarProposeTransferGovOwnTx=E.HPG;export const buildStellarProposeUnpauseTx=E.xQk;export const buildStellarProposeUpdateDelayTx=E.YQw;export const buildStellarProposeUpgradeControllerTx=E.QY;export const buildStellarProposeUpgradePoolParamsTx=E.osR;export const buildStellarProposeUpgradePoolTx=E.Kob;export const buildStellarRenewAccountTx=E.IJt;export const buildStellarRepayBatchTx=E.nw5;export const buildStellarRepayDebtWithCollateralTx=E.PrA;export const buildStellarRepayTx=E.ZEf;export const buildStellarRevokeBlendPoolTx=E.X0W;export const buildStellarRevokeRoleTx=E.evz;export const buildStellarRevokeTokenTx=E.P8C;export const buildStellarSetAccumulatorTx=E.aVn;export const buildStellarSetAggregatorTx=E.p2b;export const buildStellarSetMarketOracleConfigTx=E.sVY;export const buildStellarSetOracleSanityBoundsTx=E.XDq;export const buildStellarSetOracleToleranceTx=E.Jsu;export const buildStellarSetOracleTx=E.W5;export const buildStellarSetPositionLimitsTx=E.Dyw;export const buildStellarSetPriceAggregatorTx=E._i2;export const buildStellarSetSpokeAssetFlagsTx=E.FZg;export const buildStellarSetSwapAggregatorTx=E.wGh;export const buildStellarSupplyBatchTx=E.Nix;export const buildStellarSupplyTx=E.v_o;export const buildStellarSwapCollateralTx=E.qDU;export const buildStellarSwapDebtTx=E.qRb;export const buildStellarTransferOwnershipTx=E.QJY;export const buildStellarUnpauseTx=E.bmW;export const buildStellarUpdateAccountThresholdTx=E.n_N;export const buildStellarUpdateIndexesTx=E.v87;export const buildStellarUpgradeControllerTx=E.qMI;export const buildStellarUpgradeLiquidityPoolParamsTx=E.gHX;export const buildStellarWithdrawBatchTx=E.O3p;export const buildStellarWithdrawTx=E.Gzh;export const buildTx=E.prJ;export const burnShares=E.moD;export const computeAccountRisk=E.y5S;export const decodeStellarLendingEvent=E.Fmy;export const decodeStellarLiquidateReturn=E.OBV;export const decodeStellarRouteBytes=E.aku;export const depositRateRay=E.HFl;export const divByIntHalfUp=E.cCk;export const encodeAssetOracle=E.Ft;export const encodeInterestRateModel=E.MB4;export const encodeMarketOracleConfigInput=E.Dnk;export const encodeMarketParamsRaw=E.pqp;export const encodePositionLimits=E.Q3w;export const encodePriceKey=E.Jh3;export const encodeStrategyPayloadToRouteXdr=E.wfs;export const extractEventOrder=E.UmN;export const getStellarAccountPositions=E.xO7;export const getStellarActiveUsersSeries=E.R11;export const getStellarAggregatorQuote=E.LwT;export const getStellarAsset=E.mMz;export const getStellarAssetGraph=E.iES;export const getStellarAssetMarkets=E.zpK;export const getStellarAssetPage=E.N3x;export const getStellarAssets=E.bNp;export const getStellarCampaignLeaderboard=E.T3v;export const getStellarCampaignMe=E.KQV;export const getStellarDefiLlamaDimensions=E.S9l;export const getStellarDeployment=E.rER;export const getStellarDetailedMarkets=E.XNg;export const getStellarFeeRevenueSeries=E.VeU;export const getStellarGovernanceProposals=E.T_r;export const getStellarHolderDistribution=E.m4Y;export const getStellarHub=E.XIn;export const getStellarHubGraph=E.Lt0;export const getStellarHubHolders=E.wsx;export const getStellarHubs=E.KKL;export const getStellarLendingContext=E.yl$;export const getStellarLendingLiveState=E.kqD;export const getStellarLiquidationsLeaderboard=E.dEm;export const getStellarLiquidationsSeries=E.bu4;export const getStellarParticipantCounts=E.ftY;export const getStellarPnlByScope=E.Ht0;export const getStellarPositionsLeaderboard=E.$uf;export const getStellarPositionsPnl=E.wqt;export const getStellarQuoteTokens=E.CHU;export const getStellarRateSpreadSeries=E.Wc$;export const getStellarReserve=E.Y5D;export const getStellarReserveGraph=E.KGs;export const getStellarReserveHolders=E.nWw;export const getStellarReserves=E.jFb;export const getStellarRevenueSeries=E.Pvd;export const getStellarSpoke=E.S2b;export const getStellarSpokeGraph=E.uSb;export const getStellarSpokeHolders=E.N9t;export const getStellarSpokes=E.bNM;export const getStellarStatsHistory=E.PvK;export const getStellarUserActivity=E.O5u;export const getStellarUserActivityPage=E.NYX;export const getStellarUserHistory=E.FCB;export const getStellarUserPositions=E.h_O;export const getStellarVolumeSeries=E.zu2;export const getStellarWalletBalance=E.Xix;export const liveIndexKey=E.C88;export const mapQuoteResponseToAggregatorSwap=E.LAw;export const mapQuoteResponseToStrategyPayload=E.E6J;export const mapQuoteResponseToStrategySwap=E.Dsj;export const mapSorobanError=E.XVZ;export const mapStellarPositionActivityType=E.CUR;export const maxBorrow=E.Kye;export const maxRepay=E.Q6F;export const maxSupply=E.SFb;export const maxWithdraw=E.tT6;export const mintShares=E.fBQ;export const mulDivCeil=E.LRi;export const mulDivFloor=E.M0l;export const mulDivHalfUp=E.sfH;export const numberToScaled=E.NFG;export const numberToWad=E.DGs;export const positionValueWad=E.BqG;export const prepareStellarBuiltTx=E.VxL;export const prepareStellarTxXdr=E.DLQ;export const projectAccountRisk=E.mbb;export const projectReserveApy=E.AuU;export const rayAprToApy=E.vCP;export const rayAprToNumber=E.w74;export const rayToNumber=E.JRY;export const rescaleCeil=E.BV_;export const rescaleFloor=E.ApP;export const rescaleHalfUp=E.Ei0;export const reserveKey=E.kQ9;export const resolveReserve=E.vp8;export const stellarAuthPolicyForInvocation=E.$y9;export const stellarLendingDispatchKey=E.ONb;export const stellarLendingRead=E.HhT;export const stellarNetworks=E.PF2;export const stellarTokenContractId=E.oze;export const syntheticEventOrder=E.oVm;export const tagStellarInvokedContractError=E.g57;export const toBase64Xdr=E.LaM;export const toBigInt=E.DgJ;export const toStellarPositionMode=E.Vuj;export const unscale=E.Ou3;export const unscaleBorrowCeil=E.kRY;export const unscaleHalfUp=E.W_e;export const unscaleSupplyFloor=E.Let;export const utilizationRay=E.TXb;export const valueBasePosition=E.shl;export const valueScaledPosition=E.TqQ;export const verifyStellarRouteBytes=E.BKn;export const wadToNumber=E.rWM;
2
+ "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,Asset as o,BASE_FEE as r,Contract as n,ScInt as i,StrKey as s,TransactionBuilder as u,rpc as a,scValToBigInt as l,scValToNative as p,xdr as c}from"@stellar/stellar-sdk";var d={526(t,e){e.byteLength=function(t){var e=u(t),o=e[0],r=e[1];return 3*(o+r)/4-r},e.toByteArray=function(t){var e,o,i=u(t),s=i[0],a=i[1],l=new n(function(t,e,o){return 3*(e+o)/4-o}(0,s,a)),p=0,c=a>0?s-4:s;for(o=0;o<c;o+=4)e=r[t.charCodeAt(o)]<<18|r[t.charCodeAt(o+1)]<<12|r[t.charCodeAt(o+2)]<<6|r[t.charCodeAt(o+3)],l[p++]=e>>16&255,l[p++]=e>>8&255,l[p++]=255&e;return 2===a&&(e=r[t.charCodeAt(o)]<<2|r[t.charCodeAt(o+1)]>>4,l[p++]=255&e),1===a&&(e=r[t.charCodeAt(o)]<<10|r[t.charCodeAt(o+1)]<<4|r[t.charCodeAt(o+2)]>>2,l[p++]=e>>8&255,l[p++]=255&e),l},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],s=16383,u=0,l=r-n;u<l;u+=s)i.push(a(t,u,u+s>l?l:u+s));return 1===n?(e=t[r-1],i.push(o[e>>2]+o[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(o[e>>10]+o[e>>4&63]+o[e<<2&63]+"=")),i.join("")};for(var o=[],r=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)o[s]=i[s],r[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=t.indexOf("=");return-1===o&&(o=e),[o,o===e?0:4-o%4]}function a(t,e,r){for(var n,i,s=[],u=e;u<r;u+=3)n=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(o[(i=n)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},287(t,e,o){const r=o(526),n=o(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=a,e.IS=50;const s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,o){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,o)}function l(t,e,o){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const o=0|y(t,e);let r=u(o);const n=r.write(t,e);return n!==o&&(r=r.slice(0,n)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(K(t,ArrayBuffer)||t&&K(t.buffer,ArrayBuffer))return f(t,e,o);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return f(t,e,o);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return a.from(r,e,o);const n=function(t){if(a.isBuffer(t)){const e=0|h(t.length),o=u(e);return 0===o.length||t.copy(o,0,0,e),o}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?u(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function p(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return p(t),u(t<0?0:0|h(t))}function d(t){const e=t.length<0?0:0|h(t.length),o=u(e);for(let r=0;r<e;r+=1)o[r]=255&t[r];return o}function f(t,e,o){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(o||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===o?new Uint8Array(t):void 0===o?new Uint8Array(t,e):new Uint8Array(t,e,o),Object.setPrototypeOf(r,a.prototype),r}function h(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||K(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const o=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===o)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*o;case"hex":return o>>>1;case"base64":return G(t).length;default:if(n)return r?-1:H(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,o){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===o||o>this.length)&&(o=this.length),o<=0)return"";if((o>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,o);case"utf8":case"utf-8":return q(this,e,o);case"ascii":return k(this,e,o);case"latin1":case"binary":return _(this,e,o);case"base64":return I(this,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,o);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,o){const r=t[e];t[e]=t[o],t[o]=r}function b(t,e,o,r,n){if(0===t.length)return-1;if("string"==typeof o?(r=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),Y(o=+o)&&(o=n?0:t.length-1),o<0&&(o=t.length+o),o>=t.length){if(n)return-1;o=t.length-1}else if(o<0){if(!n)return-1;o=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:w(t,e,o,r,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,o):Uint8Array.prototype.lastIndexOf.call(t,e,o):w(t,[e],o,r,n);throw new TypeError("val must be string, number or Buffer")}function w(t,e,o,r,n){let i,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,o/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){let r=-1;for(i=o;i<u;i++)if(l(t,i)===l(e,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===a)return r*s}else-1!==r&&(i-=i-r),r=-1}else for(o+a>u&&(o=u-a),i=o;i>=0;i--){let o=!0;for(let r=0;r<a;r++)if(l(t,i+r)!==l(e,r)){o=!1;break}if(o)return i}return-1}function S(t,e,o,r){o=Number(o)||0;const n=t.length-o;r?(r=Number(r))>n&&(r=n):r=n;const i=e.length;let s;for(r>i/2&&(r=i/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Y(r))return s;t[o+s]=r}return s}function v(t,e,o,r){return j(H(e,t.length-o),t,o,r)}function x(t,e,o,r){return j(function(t){const e=[];for(let o=0;o<t.length;++o)e.push(255&t.charCodeAt(o));return e}(e),t,o,r)}function A(t,e,o,r){return j(G(e),t,o,r)}function T(t,e,o,r){return j(function(t,e){let o,r,n;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)o=t.charCodeAt(s),r=o>>8,n=o%256,i.push(n),i.push(r);return i}(e,t.length-o),t,o,r)}function I(t,e,o){return 0===e&&o===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,o))}function q(t,e,o){o=Math.min(t.length,o);const r=[];let n=e;for(;n<o;){const e=t[n];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(n+s<=o){let o,r,u,a;switch(s){case 1:e<128&&(i=e);break;case 2:o=t[n+1],128==(192&o)&&(a=(31&e)<<6|63&o,a>127&&(i=a));break;case 3:o=t[n+1],r=t[n+2],128==(192&o)&&128==(192&r)&&(a=(15&e)<<12|(63&o)<<6|63&r,a>2047&&(a<55296||a>57343)&&(i=a));break;case 4:o=t[n+1],r=t[n+2],u=t[n+3],128==(192&o)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&o)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(i=a))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),n+=s}return function(t){const e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);let o="",r=0;for(;r<e;)o+=String.fromCharCode.apply(String,t.slice(r,r+=E));return o}(r)}a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,o){return l(t,e,o)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,o){return function(t,e,o){return p(t),t<=0?u(t):void 0!==e?"string"==typeof o?u(t).fill(e,o):u(t).fill(e):u(t)}(t,e,o)},a.allocUnsafe=function(t){return c(t)},a.allocUnsafeSlow=function(t){return c(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let o=t.length,r=e.length;for(let n=0,i=Math.min(o,r);n<i;++n)if(t[n]!==e[n]){o=t[n],r=e[n];break}return o<r?-1:r<o?1:0},a.isEncoding=function(t){switch(String(t).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}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let o;if(void 0===e)for(e=0,o=0;o<t.length;++o)e+=t[o].length;const r=a.allocUnsafe(e);let n=0;for(o=0;o<t.length;++o){let e=t[o];if(K(e,Uint8Array))n+e.length>r.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(r,n)):Uint8Array.prototype.set.call(r,e,n);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,n)}n+=e.length}return r},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?q(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let t="";const o=e.IS;return t=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(t+=" ... "),"<Buffer "+t+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,o,r,n){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===o&&(o=t?t.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),e<0||o>t.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&e>=o)return 0;if(r>=n)return-1;if(e>=o)return 1;if(this===t)return 0;let i=(n>>>=0)-(r>>>=0),s=(o>>>=0)-(e>>>=0);const u=Math.min(i,s),l=this.slice(r,n),p=t.slice(e,o);for(let t=0;t<u;++t)if(l[t]!==p[t]){i=l[t],s=p[t];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(t,e,o){return-1!==this.indexOf(t,e,o)},a.prototype.indexOf=function(t,e,o){return b(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return b(this,t,e,o,!1)},a.prototype.write=function(t,e,o,r){if(void 0===e)r="utf8",o=this.length,e=0;else if(void 0===o&&"string"==typeof e)r=e,o=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(o)?(o>>>=0,void 0===r&&(r="utf8")):(r=o,o=void 0)}const n=this.length-e;if((void 0===o||o>n)&&(o=n),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return S(this,t,e,o);case"utf8":case"utf-8":return v(this,t,e,o);case"ascii":case"latin1":case"binary":return x(this,t,e,o);case"base64":return A(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,o);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function k(t,e,o){let r="";o=Math.min(t.length,o);for(let n=e;n<o;++n)r+=String.fromCharCode(127&t[n]);return r}function _(t,e,o){let r="";o=Math.min(t.length,o);for(let n=e;n<o;++n)r+=String.fromCharCode(t[n]);return r}function R(t,e,o){const r=t.length;(!e||e<0)&&(e=0),(!o||o<0||o>r)&&(o=r);let n="";for(let r=e;r<o;++r)n+=J[t[r]];return n}function B(t,e,o){const r=t.slice(e,o);let n="";for(let t=0;t<r.length-1;t+=2)n+=String.fromCharCode(r[t]+256*r[t+1]);return n}function P(t,e,o){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>o)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,o,r,n,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<i)throw new RangeError('"value" argument is out of bounds');if(o+r>t.length)throw new RangeError("Index out of range")}function M(t,e,o,r,n){F(e,r,n,t,o,7);let i=Number(e&BigInt(4294967295));t[o++]=i,i>>=8,t[o++]=i,i>>=8,t[o++]=i,i>>=8,t[o++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[o++]=s,s>>=8,t[o++]=s,s>>=8,t[o++]=s,s>>=8,t[o++]=s,o}function U(t,e,o,r,n){F(e,r,n,t,o,7);let i=Number(e&BigInt(4294967295));t[o+7]=i,i>>=8,t[o+6]=i,i>>=8,t[o+5]=i,i>>=8,t[o+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[o+3]=s,s>>=8,t[o+2]=s,s>>=8,t[o+1]=s,s>>=8,t[o]=s,o+8}function C(t,e,o,r,n,i){if(o+r>t.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function $(t,e,o,r,i){return e=+e,o>>>=0,i||C(t,0,o,4),n.write(t,e,o,r,23,4),o+4}function L(t,e,o,r,i){return e=+e,o>>>=0,i||C(t,0,o,8),n.write(t,e,o,r,52,8),o+8}a.prototype.slice=function(t,e){const o=this.length;(t=~~t)<0?(t+=o)<0&&(t=0):t>o&&(t=o),(e=void 0===e?o:~~e)<0?(e+=o)<0&&(e=0):e>o&&(e=o),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,a.prototype),r},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t],n=1,i=0;for(;++i<e&&(n*=256);)r+=this[t+i]*n;return r},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t+--e],n=1;for(;e>0&&(n*=256);)r+=this[t+--e]*n;return r},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+o*2**24;return BigInt(r)+(BigInt(n)<<BigInt(32))})),a.prototype.readBigUInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+o;return(BigInt(r)<<BigInt(32))+BigInt(n)})),a.prototype.readIntLE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=this[t],n=1,i=0;for(;++i<e&&(n*=256);)r+=this[t+i]*n;return n*=128,r>=n&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,o){t>>>=0,e>>>=0,o||P(t,e,this.length);let r=e,n=1,i=this[t+--r];for(;r>0&&(n*=256);)i+=this[t+--r]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);const o=this[t]|this[t+1]<<8;return 32768&o?4294901760|o:o},a.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);const o=this[t+1]|this[t]<<8;return 32768&o?4294901760|o:o},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(o<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=Z((function(t){z(t>>>=0,"offset");const e=this[t],o=this[t+7];void 0!==e&&void 0!==o||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+o)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,r){t=+t,e>>>=0,o>>>=0,r||O(this,t,e,o,Math.pow(2,8*o)-1,0);let n=1,i=0;for(this[e]=255&t;++i<o&&(n*=256);)this[e+i]=t/n&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,r){t=+t,e>>>=0,o>>>=0,r||O(this,t,e,o,Math.pow(2,8*o)-1,0);let n=o-1,i=1;for(this[e+n]=255&t;--n>=0&&(i*=256);)this[e+n]=t/i&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=Z((function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,o,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*o-1);O(this,t,e,o,r-1,-r)}let n=0,i=1,s=0;for(this[e]=255&t;++n<o&&(i*=256);)t<0&&0===s&&0!==this[e+n-1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+o},a.prototype.writeIntBE=function(t,e,o,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*o-1);O(this,t,e,o,r-1,-r)}let n=o-1,i=1,s=0;for(this[e+n]=255&t;--n>=0&&(i*=256);)t<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e>>>=0,o||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=Z((function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,o){return $(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return $(this,t,e,!1,o)},a.prototype.writeDoubleLE=function(t,e,o){return L(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return L(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,r){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<o&&(r=o),r===o)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-o&&(r=t.length-e+o);const n=r-o;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,o,r):Uint8Array.prototype.set.call(t,this.subarray(o,r),e),n},a.prototype.fill=function(t,e,o,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,o=this.length):"string"==typeof o&&(r=o,o=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;let n;if(e>>>=0,o=void 0===o?this.length:o>>>0,t||(t=0),"number"==typeof t)for(n=e;n<o;++n)this[n]=t;else{const i=a.isBuffer(t)?t:a.from(t,r),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<o-e;++n)this[n+e]=i[n%s]}return this};const D={};function N(t,e,o){D[t]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",o=t.length;const r="-"===t[0]?1:0;for(;o>=r+4;o-=3)e=`_${t.slice(o-3,o)}${e}`;return`${t.slice(0,o)}${e}`}function F(t,e,o,r,n,i){if(t>o||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=i>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${e}${r} and <= ${o}${r}`,new D.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,o){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+o]||V(e,t.length-(o+1))}(r,n,i)}function z(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,o){if(Math.floor(t)!==t)throw z(t,o),new D.ERR_OUT_OF_RANGE(o||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),N("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),N("ERR_OUT_OF_RANGE",(function(t,e,o){let r=`The value of "${t}" is out of range.`,n=o;return Number.isInteger(o)&&Math.abs(o)>2**32?n=W(String(o)):"bigint"==typeof o&&(n=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(n=W(n)),n+="n"),r+=` It must be ${e}. Received ${n}`,r}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function H(t,e){let o;e=e||1/0;const r=t.length;let n=null;const i=[];for(let s=0;s<r;++s){if(o=t.charCodeAt(s),o>55295&&o<57344){if(!n){if(o>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}n=o;continue}if(o<56320){(e-=3)>-1&&i.push(239,191,189),n=o;continue}o=65536+(n-55296<<10|o-56320)}else n&&(e-=3)>-1&&i.push(239,191,189);if(n=null,o<128){if((e-=1)<0)break;i.push(o)}else if(o<2048){if((e-=2)<0)break;i.push(o>>6|192,63&o|128)}else if(o<65536){if((e-=3)<0)break;i.push(o>>12|224,o>>6&63|128,63&o|128)}else{if(!(o<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(o>>18|240,o>>12&63|128,o>>6&63|128,63&o|128)}}return i}function G(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,o,r){let n;for(n=0;n<r&&!(n+o>=e.length||n>=t.length);++n)e[n+o]=t[n];return n}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let o=0;o<16;++o){const r=16*o;for(let n=0;n<16;++n)e[r+n]=t[o]+t[n]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251(t,e){e.read=function(t,e,o,r,n){var i,s,u=8*n-r-1,a=(1<<u)-1,l=a>>1,p=-7,c=o?n-1:0,d=o?-1:1,f=t[e+c];for(c+=d,i=f&(1<<-p)-1,f>>=-p,p+=u;p>0;i=256*i+t[e+c],c+=d,p-=8);for(s=i&(1<<-p)-1,i>>=-p,p+=r;p>0;s=256*s+t[e+c],c+=d,p-=8);if(0===i)i=1-l;else{if(i===a)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},e.write=function(t,e,o,r,n,i){var s,u,a,l=8*i-n-1,p=(1<<l)-1,c=p>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,h=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?d/a:d*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=p?(u=0,s=p):s+c>=1?(u=(e*a-1)*Math.pow(2,n),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[o+f]=255&u,f+=h,u/=256,n-=8);for(s=s<<n|u,l+=n;l>0;t[o+f]=255&s,f+=h,s/=256,l-=8);t[o+f-h]|=128*y}},626(d,f,h){h.d(f,{UTY:()=>un,fFH:()=>Nn,RCv:()=>ni,Z$K:()=>nn,OAi:()=>an,G_M:()=>Ve,fAY:()=>cr,a_O:()=>y,A$9:()=>b,XvM:()=>vr,gRW:()=>fr,cJU:()=>Ur,SVM:()=>xr,DYS:()=>sn,wFd:()=>ln,wJe:()=>oi,$wP:()=>Cn,eBc:()=>zr,JtG:()=>Yr,Vhx:()=>In,xEs:()=>Rn,t$R:()=>En,pU3:()=>Hn,VZJ:()=>en,N0v:()=>xe,B_D:()=>Fe,qLM:()=>ke,eX8:()=>Re,zaA:()=>Rr,xDR:()=>Y,jR0:()=>J,P2l:()=>rn,W68:()=>We,sec:()=>De,ZPB:()=>Wo,yrp:()=>_r,spi:()=>nt,Iu1:()=>Xo,yuB:()=>Vo,$96:()=>Mo,zwJ:()=>Co,h_A:()=>$o,e_X:()=>Lo,TkG:()=>Oo,BAg:()=>Uo,u9S:()=>Go,biU:()=>Ho,gc5:()=>zo,ayx:()=>Fo,SXg:()=>we,UFY:()=>hr,Y5o:()=>ot,mEH:()=>it,xGW:()=>ge,s9Q:()=>st,OL0:()=>me,k6p:()=>uo,djE:()=>io,kDJ:()=>go,Yfw:()=>ho,AI1:()=>No,O2U:()=>Io,c5J:()=>qo,N8y:()=>no,qUh:()=>bo,RZj:()=>So,nio:()=>ao,hFg:()=>Eo,Qkp:()=>ko,GwL:()=>Ro,$Kr:()=>Ao,ujH:()=>lo,Odj:()=>so,X7c:()=>mo,Ubz:()=>Bo,Dx4:()=>yo,OAr:()=>oo,$Uh:()=>eo,obN:()=>fo,$lZ:()=>ro,Kaw:()=>co,Wbk:()=>to,kwV:()=>po,qAI:()=>Qe,VSx:()=>To,HPG:()=>Po,xQk:()=>jo,YQw:()=>_o,QY:()=>xo,osR:()=>wo,Kob:()=>vo,IJt:()=>Le,nw5:()=>tt,PrA:()=>lt,ZEf:()=>et,X0W:()=>_e,evz:()=>Se,P8C:()=>Be,aVn:()=>qe,p2b:()=>Ie,sVY:()=>Oe,XDq:()=>Ce,Jsu:()=>Me,W5:()=>Pe,Dyw:()=>Ee,_i2:()=>Te,FZg:()=>Ue,wGh:()=>Ae,Nix:()=>j,v_o:()=>K,qDU:()=>at,qRb:()=>ut,QJY:()=>ve,bmW:()=>be,n_N:()=>ze,v87:()=>$e,qMI:()=>ye,gHX:()=>Ne,O3p:()=>Z,Gzh:()=>Q,prJ:()=>H,moD:()=>Jn,y5S:()=>ri,Fmy:()=>dr,OBV:()=>rt,aku:()=>Tr,HFl:()=>$n,cCk:()=>hn,Ft:()=>fe,MB4:()=>oe,Dnk:()=>he,pqp:()=>re,Q3w:()=>ne,Jh3:()=>ie,wfs:()=>kr,UmN:()=>yr,xO7:()=>Tt,R11:()=>jt,LwT:()=>wr,mMz:()=>St,iES:()=>Bt,zpK:()=>Et,N3x:()=>qt,bNp:()=>yt,T3v:()=>Ft,KQV:()=>te,S9l:()=>Yt,rER:()=>m,XNg:()=>ht,VeU:()=>Xt,T_r:()=>$t,m4Y:()=>Wt,XIn:()=>vt,Lt0:()=>Pt,wsx:()=>_t,KKL:()=>gt,yl$:()=>dt,kqD:()=>ft,dEm:()=>Nt,bu4:()=>Ht,ftY:()=>Dt,Ht0:()=>Qt,$uf:()=>Lt,wqt:()=>Zt,CHU:()=>Sr,Wc$:()=>Kt,Y5D:()=>wt,KGs:()=>Mt,nWw:()=>kt,jFb:()=>bt,Pvd:()=>Vt,S2b:()=>xt,uSb:()=>Ot,N9t:()=>Rt,bNM:()=>mt,PvK:()=>zt,O5u:()=>Ut,NYX:()=>Ct,FCB:()=>Jt,h_O:()=>At,zu2:()=>Gt,Xix:()=>It,C88:()=>Xn,LAw:()=>Or,E6J:()=>Br,Dsj:()=>Pr,XVZ:()=>Ai,CUR:()=>mr,Kye:()=>fi,Q6F:()=>gi,SFb:()=>yi,tT6:()=>hi,fBQ:()=>Yn,LRi:()=>dn,M0l:()=>cn,sfH:()=>fn,NFG:()=>Bn,DGs:()=>Pn,BqG:()=>qn,VxL:()=>Qr,DLQ:()=>Zr,mbb:()=>wi,AuU:()=>vi,vCP:()=>Dn,w74:()=>Ln,JRY:()=>_n,BV_:()=>mn,ApP:()=>gn,Ei0:()=>bn,kQ9:()=>Wn,vp8:()=>Fn,$y9:()=>jr,ONb:()=>Jo,HhT:()=>ee,PF2:()=>g,oze:()=>Ir,oVm:()=>gr,g57:()=>Jr,LaM:()=>Ko,DgJ:()=>pn,Vuj:()=>tn,Ou3:()=>vn,kRY:()=>An,W_e:()=>Tn,Let:()=>xn,TXb:()=>Un,shl:()=>Zn,TqQ:()=>Kn,BKn:()=>Er,rWM:()=>kn});const y={stellarMainnet:{name:"mainnet",passphrase:"Public Global Stellar Network ; September 2015",horizonUrl:"https://horizon.stellar.org",sorobanRpcUrl:"https://stellar-gateway.xoxno.com",quoteUrl:"https://stellar-swap.xoxno.com",explorerNetwork:"public",aquariusApiUrl:"https://amm-api.aqua.network",aquariusRouter:"CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",lendingController:"CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX",lendingPool:"CBXRNDQMAJFG4VUKMKFEMFS75UUXE2SPSNV4LEEFCSNBCN66PYRWBKXO",aggregatorRouter:"CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR",governance:"CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD",priceAggregator:"CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV",positionNftContract:"CAWCSG77AY2W24QZ6ZXLHZU4UXEFHZBM6EI4A4IF7JB5CTY4XND3TI6C"},stellarTestnet:{name:"testnet",passphrase:"Test SDF Network ; September 2015",horizonUrl:"https://horizon-testnet.stellar.org",sorobanRpcUrl:"https://stellar-testnet-gateway.xoxno.com",quoteUrl:"https://testnet-stellar-swap.xoxno.com",explorerNetwork:"testnet",aquariusApiUrl:"https://amm-api-testnet.aqua.network",aquariusRouter:"CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD",lendingController:"CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3",lendingPool:"CBSGF6QOQAMPFBEVSYPEQHSZRIHJ6RCGUPCRDMUX36DEKRWFAO2PZB5A",aggregatorRouter:"CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5",governance:"CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ",priceAggregator:"CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP",positionNftContract:"CDVN5JU675MEDPVRPCYC45AHFC275UH57WEU5OTFE4WFGZBNN7HTLPSY"}},g=y;function m(t){return y["testnet"===t?"stellarTestnet":"stellarMainnet"]}const b={mainnet:y.stellarMainnet.passphrase,testnet:y.stellarTestnet.passphrase};var w=h(287);const S=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],v={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},x=1e6,A=t=>new e(t).toScVal(),T=t=>new i(t).toI128(),I=t=>c.ScVal.scvU32(t),q=t=>{if("number"==typeof t&&!Number.isSafeInteger(t))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new i("string"==typeof t?t:t.toString()).toU64()},E=t=>c.ScVal.scvBool(t),k=t=>c.ScVal.scvString(t),_=t=>c.ScVal.scvSymbol(t),R=()=>c.ScVal.scvVoid(),B=t=>c.ScVal.scvVec(t),P=(t,e=32)=>{const o=t.startsWith("0x")?t.slice(2):t,r=w.hp.from(o,"hex");if(r.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${r.length} bytes from "${t}")`);return c.ScVal.scvBytes(r)},O=(t,e)=>null==t?R():e(t),M=(t,e)=>L({asset:A(e),hub_id:I(t)}),U=(t,e,o)=>c.ScVal.scvVec([M(t,e),T(o)]),C=t=>c.ScVal.scvVec(t.map((t=>U(t.hubId,t.asset,t.amount)))),$=t=>{if("Transfer"===t)return B([_("Transfer")]);if(t&&"object"==typeof t&&"Credit"in t){const e=t.Credit;if("number"==typeof e&&!Number.isInteger(e))throw new Error(`Stellar builder: SeizeMode Credit account id must be an integer u64, got ${e}`);return B([_("Credit"),q(e)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(t)}`)},L=t=>{const e=Object.keys(t).sort().map((e=>new c.ScMapEntry({key:_(e),val:t[e]})));return c.ScVal.scvMap(e)};class D{assets=[];amounts=[];ops=[];weights=[];constructor(t){this.amounts.push(t)}asset(t){const e=this.assets.indexOf(t);if(-1!==e)return e;if(this.assets.length>=256)throw new Error("Stellar builder: strategy references more than 256 distinct addresses");return this.assets.push(t),this.assets.length-1}amount(t){if(this.amounts.length>=126)throw new Error("Stellar builder: strategy references too many distinct amounts");return this.amounts.push(t),this.amounts.length-1}weight(t){if(this.weights.length>=32)throw new Error("Stellar builder: strategy uses more than 32 split weights");if(!Number.isInteger(t)||t<=0||t>x)throw new Error(`Stellar builder: split weight ${t} outside 1..=1000000`);return this.weights.push(t),this.weights.length-1}emit(t,e,o,r,n){this.ops.push([t,e,o,r,n])}emitPath(t,e){t.hops.forEach(((o,r)=>{if(o.tokenIn===o.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[r-1];if(n&&o.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(v[o.venue],0===r?e:1,this.asset(o.pool),this.asset(o.tokenIn),this.asset(o.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),o=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(o[t])continue;const r=e[t].hops[0]?.tokenIn,n=[];for(let o=t;o<e.length;o+=1)e[o].hops[0]?.tokenIn===r&&n.push(o);const i=n.reduce(((t,o)=>t+e[o].splitPpm),0);if(i>x)throw new Error(`Stellar builder: split weights for one token sum to ${i}, above 1000000`);const s=i===x;let u=x;n.forEach(((t,r)=>{o[t]=!0;const i=e[t];let a;if(r+1===n.length&&s)a=0;else{if(0===u)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(i.splitPpm*x/u);u-=Math.min(i.splitPpm,u),a=128+this.weight(t)}this.emitPath(i,a)}))}}toBytes(t,e,o){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const r=[1,t,e,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,this.ops.length,this.weights.length];for(const t of this.ops)r.push(...t);for(const t of this.weights)r.push(t>>>16&255,t>>>8&255,255&t);return w.hp.from(r)}get assetList(){return this.assets}get amountList(){return this.amounts}}const N=t=>{const e=new D(t.totalMinOut),o=e.asset(t.tokenIn),r=e.asset(t.tokenOut);if(o===r)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const r=e.asset(t.burnPool),n=e.amountList.length;for(const o of t.burnMinAmounts??[])e.amount(o);e.emit(5,0,r,o,n)}if(e.lowerPaths(t.paths),t.mintPool){const o=t.preSwapAmount;if(o&&BigInt(o)>0n){const r=t.mintPoolTokens;if(!r||2!==r.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=r,[s,u]=t.preSwapFromA?[n,i]:[i,n];e.emit(v.Aquarius,2+e.amount(o),e.asset(t.mintPool),e.asset(s),e.asset(u))}e.emit(6,0,e.asset(t.mintPool),r,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return L({amounts:c.ScVal.scvVec(e.amountList.map((t=>T(t)))),assets:c.ScVal.scvVec(e.assetList.map((t=>A(t)))),ops:c.ScVal.scvBytes(e.toBytes(o,r,n))})},W=t=>{const e=w.hp.from(t);if(0===e.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return c.ScVal.scvBytes(e)},F=()=>c.ScVal.scvBytes(w.hp.alloc(0)),z=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((o=t).length>0&&o.length%2==0&&/^[0-9a-fA-F]+$/.test(o)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return w.hp.from(t,"hex")}var o;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(e))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const r=w.hp.from(e,"base64");if(0===r.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return r},V=t=>{if("string"==typeof t)return W(z(t));if(t instanceof Uint8Array)return 0===t.length?F():W(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?W(z(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?W(z(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?W(z(t.bytes)):0===t.bytes.length?F():W(t.bytes):(e=(t=>{if(!t||"object"!=typeof t)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const e=t;if(!Array.isArray(e.paths)||0===e.paths.length&&!e.burnPool&&!e.mintPool)throw new Error("Stellar builder: `steps.paths` needs a strategy path or a liquidity burn/mint operation");if("string"!=typeof e.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof e.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof e.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const o=new Map;for(const[t,r]of e.paths.entries()){if(!r||"number"!=typeof r.splitPpm||r.splitPpm<=0||!Array.isArray(r.hops)||0===r.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!S.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=r.hops[0];o.set(e.tokenIn,(o.get(e.tokenIn)??0)+r.splitPpm)}for(const[t,r]of o){if(r>x)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${r}, above 1000000`);if(!e.mintPool&&r!==x)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${r}`)}return e})(t),c.ScVal.scvBytes(w.hp.from(N(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},X=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=w.hp.from(e,"hex");return c.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return c.ScVal.scvBytes(w.hp.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function H(e,o,i){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const s=new n(e.controllerAddress),a=new t(e.caller,e.sourceSequence);return{xdr:new u(a,{fee:e.fee??r,networkPassphrase:b[e.network]}).addOperation(s.call(o,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function G(t){if(!Number.isInteger(t)||t<1||t>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return I(t)}function j(t,e){const o=e.accountNonce??0;return H(t,"supply",[A(t.caller),q(o),G(e.spokeId),C([...e.assets])])}function K(t,e){return j(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function Y(t,e){return H(t,"borrow",[A(t.caller),q(e.accountNonce),C([...e.borrows]),O(e.to,A)])}function J(t,e){return Y(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Z(t,e){return H(t,"withdraw",[A(t.caller),q(e.accountNonce),C([...e.withdrawals]),O(e.to,A)])}function Q(t,e){return Z(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function tt(t,e){return H(t,"repay",[A(t.caller),q(e.accountNonce),C([...e.payments])])}function et(t,e){return tt(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function ot(t,e){return H(t,"liquidate",[A(t.caller),q(e.accountNonce),C([...e.debtPayments]),$(e.seizeMode??"Transfer")])}function rt(t){const e=p(c.ScVal.fromXDR(t,"base64"));if("bigint"==typeof e||"number"==typeof e)return e.toString();throw new Error("Stellar builder: liquidate return value must be a u64, got "+typeof e)}function nt(t,e){return H(t,"flash_loan",[A(t.caller),M(e.hubId,e.asset),T(e.amount),A(e.receiver),X(e.data)])}function it(t,e){return H(t,"migrate_from_blend",[A(t.caller),q(e.accountId),G(e.spokeId),I(e.hubId),A(e.blendPool),B(e.collateralTokens.map(A)),B(e.supplyTokens.map(A)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),c.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,c.ScVal.scvVec([A(e),T(o)]);var e,o}))))]);var o}function st(t,e){const o=e.accountNonce??0;return H(t,"multiply",[A(t.caller),q(o),G(e.spokeId),M(e.collateral.hubId,e.collateral.asset),T(e.debtToFlashLoan),M(e.debt.hubId,e.debt.asset),I(e.mode),V(e.steps),O(e.initialPayment,(t=>U(t.hubId,t.asset,t.amount))),O(e.convertSwap,V)])}function ut(t,e){return H(t,"swap_debt",[A(t.caller),q(e.accountNonce),M(e.existingDebt.hubId,e.existingDebt.asset),T(e.newDebtAmount),M(e.newDebt.hubId,e.newDebt.asset),V(e.steps)])}function at(t,e){return H(t,"swap_collateral",[A(t.caller),q(e.accountNonce),M(e.current.hubId,e.current.asset),T(e.fromAmount),M(e.newCollateral.hubId,e.newCollateral.asset),V(e.steps)])}function lt(t,e){return H(t,"repay_debt_with_collateral",[A(t.caller),q(e.accountNonce),M(e.collateral.hubId,e.collateral.asset),T(e.collateralAmount),M(e.debt.hubId,e.debt.asset),V(e.steps),E(e.closePosition)])}const pt="/stellar-lending",ct=encodeURIComponent,dt=(t,e)=>t.fetchWithTimeout(`${pt}/context`,e),ft=(t,e)=>t.fetchWithTimeout(`${pt}/live-state`,e),ht=(t,e)=>t.fetchWithTimeout(`${pt}/markets/detailed`,e),yt=(t,e)=>t.fetchWithTimeout(`${pt}/assets`,e),gt=(t,e)=>t.fetchWithTimeout(`${pt}/hubs`,e),mt=(t,e)=>t.fetchWithTimeout(`${pt}/spokes`,e),bt=(t,e={},o)=>t.fetchWithTimeout(`${pt}/reserves`,{...o,params:{...e}}),wt=(t,e,o,r,n)=>t.fetchWithTimeout(`${pt}/reserves/${e}/${o}/${ct(r)}`,n),St=(t,e,o)=>t.fetchWithTimeout(`${pt}/assets/${ct(e)}`,o),vt=(t,e,o)=>t.fetchWithTimeout(`${pt}/hubs/${e}`,o),xt=(t,e,o)=>t.fetchWithTimeout(`${pt}/spokes/${e}`,o),At=(t,e,o)=>t.fetchWithTimeout(`${pt}/users/${ct(e)}/positions`,o),Tt=(t,e,o)=>t.fetchWithTimeout(`${pt}/accounts/${ct(e)}/positions`,o),It=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/users/${ct(e)}/assets/${ct(o)}/balance`,r),qt=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/assets/${ct(e)}/page`,{...r,params:{...o}}),Et=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/assets/${ct(e)}/markets`,{...r,params:{side:o}}),kt=(t,e,o,r,n,i)=>t.fetchWithTimeout(`${pt}/reserves/${e}/${o}/${ct(r)}/holders`,{...i,params:{side:n}}),_t=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/hubs/${e}/holders`,{...r,params:{side:o}}),Rt=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/spokes/${e}/holders`,{...r,params:{side:o}}),Bt=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/assets/${ct(e)}/graph`,{...r,params:{...o}}),Pt=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/hubs/${e}/graph`,{...r,params:{...o}}),Ot=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/spokes/${e}/graph`,{...r,params:{...o}}),Mt=(t,e,o,r,n,i)=>t.fetchWithTimeout(`${pt}/reserves/${e}/${o}/${ct(r)}/graph`,{...i,params:{...n}}),Ut=(t,e,o={},r)=>t.fetchWithTimeout(`${pt}/users/${ct(e)}/activity`,{...r,params:{...o}}),Ct=(t,e,o={},r)=>t.fetchWithTimeout(`${pt}/users/${ct(e)}/activity/page`,{...r,params:{...o}}),$t=(t,e={},o)=>t.fetchWithTimeout(`${pt}/governance/proposals`,{...o,params:{...e}}),Lt=(t,e={},o)=>t.fetchWithTimeout(`${pt}/positions`,{...o,params:{...e}}),Dt=(t,e={},o)=>t.fetchWithTimeout(`${pt}/participants`,{...o,params:{...e}}),Nt=(t,e={},o)=>t.fetchWithTimeout(`${pt}/liquidations/leaderboard`,{...o,params:{...e}}),Wt=(t,e={},o)=>t.fetchWithTimeout(`${pt}/distribution`,{...o,params:{...e}}),Ft=(t,e={},o)=>t.fetchWithTimeout(`${pt}/campaign/leaderboard`,{...o,params:{...e}}),zt=(t,e,o)=>t.fetchWithTimeout(`${pt}/stats/history`,{...o,params:{...e}}),Vt=(t,e,o)=>t.fetchWithTimeout(`${pt}/revenue`,{...o,params:{...e}}),Xt=(t,e,o)=>t.fetchWithTimeout(`${pt}/revenue/fees`,{...o,params:{...e}}),Ht=(t,e,o)=>t.fetchWithTimeout(`${pt}/liquidations`,{...o,params:{...e}}),Gt=(t,e,o)=>t.fetchWithTimeout(`${pt}/volume`,{...o,params:{...e}}),jt=(t,e,o)=>t.fetchWithTimeout(`${pt}/active-users`,{...o,params:{...e}}),Kt=(t,e,o)=>t.fetchWithTimeout(`${pt}/rate-spread`,{...o,params:{...e}}),Yt=(t,e,o)=>t.fetchWithTimeout(`${pt}/defillama`,{...o,params:{...e}}),Jt=(t,e,o,r)=>t.fetchWithTimeout(`${pt}/users/${ct(e)}/history`,{...r,params:{...o}}),Zt=(t,e,o)=>t.fetchWithTimeout(`${pt}/pnl`,{...o,params:{accountId:e}}),Qt=(t,e,o)=>t.fetchWithTimeout(`${pt}/pnl/scope`,{...o,params:{scope:e}}),te=(t,e,o)=>t.fetchWithTimeout(`${pt}/campaign/me`,{...o,params:{owner:e}}),ee=t=>({context:e=>dt(t,e),liveState:e=>ft(t,e),marketsDetailed:e=>ht(t,e),assets:e=>yt(t,e),hubs:e=>gt(t,e),spokes:e=>mt(t,e),reserves:(e={},o)=>void 0!==o||"hubId"in e||"spokeId"in e||"asset"in e?bt(t,e,o):bt(t,{},e),reserve:(e,o,r,n)=>wt(t,e,o,r,n),asset:(e,o)=>St(t,e,o),hub:(e,o)=>vt(t,e,o),spoke:(e,o)=>xt(t,e,o),userPositions:(e,o)=>At(t,e,o),accountPositions:(e,o)=>Tt(t,e,o),walletBalance:(e,o,r)=>It(t,e,o,r),assetPage:(e,o,r)=>qt(t,e,o,r),assetMarkets:(e,o,r)=>Et(t,e,o,r),reserveHolders:(e,o,r,n,i)=>kt(t,e,o,r,n,i),hubHolders:(e,o,r)=>_t(t,e,o,r),spokeHolders:(e,o,r)=>Rt(t,e,o,r),assetGraph:(e,o,r)=>Bt(t,e,o,r),hubGraph:(e,o,r)=>Pt(t,e,o,r),spokeGraph:(e,o,r)=>Ot(t,e,o,r),reserveGraph:(e,o,r,n,i)=>Mt(t,e,o,r,n,i),userActivity:(e,o={},r)=>Ut(t,e,o,r),userActivityPage:(e,o={},r)=>Ct(t,e,o,r),governanceProposals:(e={},o)=>$t(t,e,o),positionsLeaderboard:(e={},o)=>Lt(t,e,o),participants:(e={},o)=>Dt(t,e,o),liquidationsLeaderboard:(e={},o)=>Nt(t,e,o),distribution:(e={},o)=>Wt(t,e,o),campaignLeaderboard:(e={},o)=>Ft(t,e,o),statsHistory:(e,o)=>zt(t,e,o),revenue:(e,o)=>Vt(t,e,o),feeRevenue:(e,o)=>Xt(t,e,o),liquidations:(e,o)=>Ht(t,e,o),volume:(e,o)=>Gt(t,e,o),activeUsers:(e,o)=>jt(t,e,o),rateSpread:(e,o)=>Kt(t,e,o),defillama:(e,o)=>Yt(t,e,o),userHistory:(e,o,r)=>Jt(t,e,o,r),positionsPnl:(e,o)=>Zt(t,e,o),pnlByScope:(e,o)=>Qt(t,e,o),campaignMe:(e,o)=>te(t,e,o)}),oe=t=>L({base_borrow_rate:T(t.baseBorrowRateRay),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:I(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),re=t=>L({asset_decimals:I(t.assetDecimals),asset_id:A(t.assetId),base_borrow_rate:T(t.baseBorrowRateRay),flashloan_fee:I(t.flashloanFeeBps),is_flashloanable:E(t.isFlashloanable),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:I(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),ne=t=>L({max_borrow_positions:I(t.maxBorrowPositions),max_supply_positions:I(t.maxSupplyPositions)}),ie=t=>{if("Token"in t&&t.Token)return B([_("Token"),A(t.Token)]);if("Ref"in t&&t.Ref)return B([_("Ref"),_(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},se=t=>{if("Stellar"in t)return B([_("Stellar"),A(t.Stellar)]);if("Symbol"in t)return B([_("Symbol"),_(t.Symbol)]);if("String"in t)return B([_("String"),k(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},ue=t=>{if("Spot"===t)return B([_("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return B([_("Twap"),I(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},ae=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return B([_(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},le=t=>{if("Market"===t||"Fundamental"===t)return B([_(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},pe=t=>{if("Reflector"in t){const e=t.Reflector;return B([_("Reflector"),L({asset:se(e.asset),contract:A(e.contract),read_mode:ue(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return B([_("MultiFeed"),L({contract:A(e.contract),feed_id:k(e.feedId),kind:ae(e.kind),nature:le(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},ce=t=>{const e=t;return L({decimals:I(e.decimals),max_stale_seconds:q(e.maxStaleSeconds),provider:pe(e.provider)})},de=t=>{if("RequireDisjoint"===t)return B([_("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return B([_("AllowShared"),B(e.map((t=>L({contract:A(t.contract),kind:ae(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},fe=t=>{const e=t,o=e.sources??[];let r,n;if("number"==typeof e.toleranceBps)r=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/r));else{const t=e.tolerance??{};r=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return L({asset_decimals:I(Number(e.assetDecimals)),independence:de(e.independence),max_price_stale_seconds:q(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:T(String(e.maxSanityPriceWad)),min_sanity_price_wad:T(String(e.minSanityPriceWad)),sources:B(o.map((t=>(t=>{if("Feed"in t)return B([_("Feed"),ce(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return B([_("Scaled"),L({factor:ce(e.factor),max_factor_wad:T(e.maxFactorWad),min_factor_wad:T(e.minFactorWad),quote:ie(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return B([_("LpShare"),L({key_a:ie(e.keyA),key_b:ie(e.keyB),kind:B([_(e.kind||"ConstantProduct")]),pool:A(e.pool),reserve_a_decimals:I(e.reserveADecimals),reserve_b_decimals:I(e.reserveBDecimals),share_decimals:I(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:L({lower_ratio_bps:I(n),upper_ratio_bps:I(r)})})},he=fe;function ye(t,e){return H(t,"upgrade",[P(e.wasmHash)])}function ge(t,e){return H(t,"migrate",[I(e.newVersion)])}function me(t){return H(t,"pause",[])}function be(t){return H(t,"unpause",[])}function we(t,e){return H(t,"grant_role",[A(e.account),_(e.role)])}function Se(t,e){return H(t,"revoke_role",[A(e.account),_(e.role)])}function ve(t,e){return H(t,"transfer_ownership",[A(e.newOwner),I(e.liveUntilLedger)])}function xe(t){return H(t,"accept_ownership",[])}function Ae(t,e){return H(t,"set_swap_aggregator",[A(e.aggregator)])}function Te(t,e){return H(t,"set_price_aggregator",[A(e.aggregator)])}const Ie=Ae;function qe(t,e){return H(t,"set_accumulator",[A(e.accumulator)])}function Ee(t,e){return H(t,"set_position_limits",[ne(e)])}function ke(t,e){return H(t,"approve_blend_pool",[A(e.pool)])}function _e(t,e){return H(t,"revoke_blend_pool",[A(e.pool)])}const Re=ke,Be=_e;function Pe(t,e){return H(t,"set_oracle",[ie(e.key),fe(e.oracle)])}const Oe=Pe;function Me(t,e){const o=e.toleranceBps,r=e.upperRatioBps??1e4+o,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/r));return H(t,"set_tolerance",[ie(e.key),L({lower_ratio_bps:I(n),upper_ratio_bps:I(r)})])}function Ue(t,e){return H(t,"set_spoke_asset_flags",[I(e.spokeId),M(e.hubId,e.asset),E(e.paused),E(e.frozen),E(e.noSeize)])}function Ce(t,e){return H(t,"set_oracle_sanity_bounds",[A(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function $e(t,e){return H(t,"update_indexes",[A(t.caller),B(e.assets.map((t=>M(t.hubId,t.asset))))])}function Le(t,e){return H(t,"renew_account",[A(t.caller),q(e.accountNonce)])}function De(t,e){return H(t,"create_liquidity_pool",[I(e.hubId),A(e.asset),re(e.params)])}function Ne(t,e){return H(t,"upgrade_liquidity_pool_params",[M(e.hubId,e.asset),oe(e.params)])}function We(t,e){return H(t,"claim_revenue",[A(t.caller),B(e.assets.map((t=>M(t.hubId,t.asset))))])}function Fe(t,e){return H(t,"add_rewards",[A(t.caller),C(e.rewards)])}function ze(t,e){return H(t,"update_account_threshold",[A(t.caller),E(e.hasRisks),B(e.accountNonces.map((t=>q(t))))])}const Ve="00".repeat(32),Xe=t=>{if("string"==typeof t)return P(t);const e=w.hp.from(t);if(32!==e.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${e.length} bytes)`);return c.ScVal.scvBytes(e)},He=(t,...e)=>B([_(t),...e]),Ge=t=>L({new_owner:A(t.newOwner),live_until_ledger:I(t.liveUntilLedger)}),je=t=>L({asset:A(t.asset),bonus:I(t.bonus),borrow_cap:T(t.borrowCap),can_borrow:E(t.canBorrow),can_collateral:E(t.canCollateral),frozen:E(t.frozen),hub_id:I(t.hubId),paused:E(t.paused),liquidation_fees:I(t.liquidationFees),ltv:I(t.ltv),no_seize:E(t.noSeize),spoke_id:I(t.spokeId),supply_cap:T(t.supplyCap),threshold:I(t.threshold)}),Ke=t=>L({account:A(t.account),role:_(t.role)});function Ye(e,o,i){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const s=new n(e.governanceAddress),a=new t(e.caller,e.sourceSequence);return{xdr:new u(a,{fee:e.fee??r,networkPassphrase:b[e.network]}).addOperation(s.call(o,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Je=(t,e,o)=>Ye(t,"propose",[A(t.caller),e,Xe(o)]),Ze=(t,e,o)=>Ye(t,"execute_self",[R(),e,Xe(o)]);function Qe(t,e,o){return Je(t,He("SetSwapAggregator",A(e.aggregator)),o)}function to(t,e,o){return Je(t,He("SetPriceAggregator",A(e.aggregator)),o)}const eo=Qe;function oo(t,e,o){return Je(t,He("SetAccumulator",A(e.accumulator)),o)}function ro(t,e,o){return Je(t,He("SetPositionLimits",ne(e)),o)}function no(t,e){return Je(t,He("CreateHub"),e)}function io(t,e){return Je(t,He("AddSpoke"),e)}function so(t,e,o){return Je(t,He("RemoveSpoke",I(e.spokeId)),o)}function uo(t,e,o){return Je(t,He("AddAssetToSpoke",je(e)),o)}function ao(t,e,o){return Je(t,He("EditAssetInSpoke",je(e)),o)}function lo(t,e,o){return Je(t,He("RemoveAssetFromSpoke",L({hub_asset:M((r=e).hubId,r.asset),spoke_id:I(r.spokeId)})),o);var r}function po(t,e,o){return Je(t,He("SetSpokeLiquidationCurve",L({hf_for_max_bonus_wad:T((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:I(r.liquidationBonusFactorBps),spoke_id:I(r.spokeId),target_hf_wad:T(r.targetHfWad)})),o);var r}function co(t,e,o){return Je(t,He("SetPositionManager",A(e.manager),E(e.isActive)),o)}function fo(t,e,o){return Je(t,He("SetMinBorrowCollateralUsd",T(e.floorWad)),o)}function ho(t,e,o){return Je(t,He("ApproveToken",A(e.token)),o)}function yo(t,e,o){return Je(t,He("RevokeToken",A(e.token)),o)}function go(t,e,o){return Je(t,He("ApproveBlendPool",A(e.pool)),o)}function mo(t,e,o){return Je(t,He("RevokeBlendPool",A(e.pool)),o)}function bo(t,e,o){return Je(t,He("CreateLiquidityPool",L({asset:A((r=e).asset),hub_id:I(r.hubId),params:re(r.params)})),o);var r}function wo(t,e,o){return Je(t,He("UpgradeLiquidityPoolParams",L({hub_asset:M((r=e).hubId,r.asset),params:oe(r.params)})),o);var r}function So(t,e,o){return Je(t,He("DeployPool",P(e.wasmHash)),o)}function vo(t,e,o){return Je(t,He("UpgradePool",P(e.wasmHash)),o)}function xo(t,e,o){return Je(t,He("UpgradeController",P(e.wasmHash)),o)}function Ao(t,e,o){return Je(t,He("MigrateController",I(e.newVersion)),o)}function To(t,e,o){return Je(t,He("TransferCtrlOwnership",Ge(e)),o)}function Io(t,e,o){return Je(t,He("ConfigureAssetOracle",L({key:ie((r=e).key),oracle:fe(r.oracle)})),o);var r}const qo=Io;function Eo(t,e,o){return Je(t,He("EditOracleTolerance",L({key:ie((r=e).key),tolerance:I(r.tolerance)})),o);var r}function ko(t,e,o){return Je(t,He("UpgradeGov",P(e.wasmHash)),o)}function _o(t,e,o){return Je(t,He("UpdateGovDelay",I(e.newDelay)),o)}function Ro(t,e,o){return Je(t,He("GrantGovRole",Ke(e)),o)}function Bo(t,e,o){return Je(t,He("RevokeGovRole",Ke(e)),o)}function Po(t,e,o){return Je(t,He("TransferGovOwnership",Ge(e)),o)}function Oo(t,e){const o=B(e.argsXdr.map((t=>c.ScVal.fromXDR(t,"base64")))),r=Xe(e.predecessor??Ve);return Ye(t,"execute",[R(),A(e.target),_(e.functionName),o,r,Xe(e.salt)])}function Mo(t,e,o){return Ze(t,He("UpgradeGov",P(e.wasmHash)),o)}function Uo(t,e,o){return Ze(t,He("UpdateGovDelay",I(e.newDelay)),o)}function Co(t,e,o){return Ze(t,He("GrantGovRole",Ke(e)),o)}function $o(t,e,o){return Ze(t,He("RevokeGovRole",Ke(e)),o)}function Lo(t,e,o){return Ze(t,He("TransferGovOwnership",Ge(e)),o)}const Do=t=>B(t.map(A));function No(t,e,o){return Ye(t,"propose_canceller_reset",[Do(e.newCancellers),Xe(o)])}function Wo(t,e,o){return Ye(t,"execute_canceller_reset",[O(e.executor,A),Do(e.newCancellers),Xe(o)])}function Fo(t,e){return Ye(t,"set_spoke_asset_flags",[A(t.caller),I(e.spokeId),M(e.hubId,e.asset),E(e.paused),E(e.frozen),E(e.noSeize)])}function zo(t,e){return Ye(t,"set_oracle_sanity_bounds",[A(t.caller),A(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function Vo(t){return Ye(t,"create_hub",[A(t.caller)])}function Xo(t){return Ye(t,"add_spoke",[A(t.caller)])}function Ho(t,e){return Ye(t,"revoke_role_immediate",[A(e.account),_(e.role)])}function Go(t){return Ye(t,"pause",[A(t.caller)])}function jo(t,e){return Je(t,He("Unpause"),e)}const Ko=t=>t.toXDR("base64"),Yo=t=>c.ScVal.fromXDR(t,"base64"),Jo=t=>t.map((t=>String(p(Yo(t))))).join(":"),Zo=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),Qo=t=>Number(t),tr=t=>String(t),er=t=>t instanceof Uint8Array?w.hp.from(t).toString("hex"):w.hp.isBuffer(t)?t.toString("hex"):String(t),or=["None","Multiply","Long","Short"],rr=["supply","borrow","withdraw","repay","liq_repay","liq_seize","multiply","param_upd","sw_debt_r","sw_col_wd","rp_col_wd","rp_col_r","close_wd","migrate","rp_col_net","liq_credit"],nr=t=>Array.isArray(t)?t:[],ir=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],rr[Qo(r)]??Zo(r)),positionType:e,hubId:Qo(t[1]),asset:tr(t[2]),scaledAmountRay:Zo(t[3]),indexRay:Zo(t[4]),amount:Zo(t[5]),liquidationThresholdBps:o?void 0:Qo(t[6]),liquidationBonusBps:o?void 0:Qo(t[7]),loanToValueBps:o?void 0:Qo(t[8]),liquidationFeesBps:o?void 0:Qo(t[9])};var r},sr=t=>{return{owner:tr(t[0]),spokeId:Qo(t[1]),mode:(e=t[2],or[Qo(e)]??"None")};var e},ur=t=>Array.isArray(t)?t[1]:void 0,ar=t=>{const e=(o=t,Array.isArray(o)?tr(o[0]):tr(o));var o;if("Token"===e)return{Token:tr(ur(t))};if("Ref"===e)return{Ref:tr(ur(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:tr(e.Token)};if(void 0!==e.Ref)return{Ref:tr(e.Ref)}}return{Token:tr(t)}},lr=t=>{const e=t.tolerance??{};return{assetDecimals:Qo(t.asset_decimals),maxPriceStaleSeconds:Qo(t.max_price_stale_seconds),sources:nr(t.sources).map((t=>t)),tolerance:{upperRatio:Qo(e.upper_ratio_bps),lowerRatio:Qo(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:Zo(t.min_sanity_price_wad),maxSanityPriceWad:Zo(t.max_sanity_price_wad)}},pr={"market:create":t=>({topic:"market:create",data:{hubId:Qo(t.hub_id),baseAsset:tr(t.base_asset),maxBorrowRate:Zo(t.max_borrow_rate),baseBorrowRate:Zo(t.base_borrow_rate),slope1:Zo(t.slope1),slope2:Zo(t.slope2),slope3:Zo(t.slope3),midUtilization:Zo(t.mid_utilization),optimalUtilization:Zo(t.optimal_utilization),maxUtilization:Zo(t.max_utilization),reserveFactor:Qo(t.reserve_factor),marketAddress:tr(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:tr(t.asset),maxBorrowRateRay:Zo(t.max_borrow_rate),baseBorrowRateRay:Zo(t.base_borrow_rate),slope1Ray:Zo(t.slope1),slope2Ray:Zo(t.slope2),slope3Ray:Zo(t.slope3),midUtilizationRay:Zo(t.mid_utilization),optimalUtilizationRay:Zo(t.optimal_utilization),maxUtilizationRay:Zo(t.max_utilization),reserveFactorBps:Qo(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:nr(t).map((t=>{return e=nr(t),{hubId:Qo(e[0]),asset:tr(e[1]),timestamp:Qo(e[2]),supplyIndexRay:Zo(e[3]),borrowIndexRay:Zo(e[4]),cash:Zo(e[5]),suppliedRay:Zo(e[6]),borrowedRay:Zo(e[7]),revenueRay:Zo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:nr(t).map((t=>{const e=t;return{hubId:Qo(e.hub_id),asset:tr(e.asset),params:(o=e.params,{maxBorrowRateRay:Zo(o.max_borrow_rate),baseBorrowRateRay:Zo(o.base_borrow_rate),slope1Ray:Zo(o.slope1),slope2Ray:Zo(o.slope2),slope3Ray:Zo(o.slope3),midUtilizationRay:Zo(o.mid_utilization),optimalUtilizationRay:Zo(o.optimal_utilization),maxUtilizationRay:Zo(o.max_utilization),reserveFactorBps:Qo(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:Qo(o.flashloan_fee),assetId:tr(o.asset_id),assetDecimals:Qo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=nr(t);return{topic:"position:batch_update",data:{accountId:Zo(e[0]),accountAttributes:sr(nr(e[1])),updates:[...nr(e[2]).map((t=>ir(nr(t),"Deposit"))),...nr(e[3]).map((t=>ir(nr(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:Qo(t.hub_id),asset:tr(t.asset),receiver:tr(t.receiver),caller:tr(t.caller),amount:Zo(t.amount),fee:Zo(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:ar(t.key),oracle:lr(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:tr(t.asset),oracle:lr(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:tr(t.liquidator),accountId:Zo(t.account_id),repaidUsdWad:Zo(t.repaid_usd_wad),bonusBps:Zo(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:Zo(t.account_id),totalBorrowUsdWad:Zo(t.total_borrow_usd_wad),totalCollateralUsdWad:Zo(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:tr(t.token),amount:Zo(t.amount),usdValueWad:Zo(t.usd_value_wad),accountId:Zo(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:Qo(t.hub_id),asset:tr(t.asset),amount:Zo(t.amount),fee:Zo(t.fee),amountSent:Zo(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:tr(t.pool??t.blend_pool??t.token),approved:Boolean(t.approved??t.is_approved??!0)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:er(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:tr(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:tr(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:tr(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:tr(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:er(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:Qo(t.max_supply_positions),maxBorrowPositions:Qo(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Zo(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:tr(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:Qo(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:Zo(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Zo(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:Qo(e.liquidation_bonus_factor_bps)}}}},cr=Object.freeze(Object.keys(pr));function dr(t,e){const o=Jo(t),r=pr[o];return r?r(p(Yo(e))):null}const fr=1e4;function hr(t,e){return`${t}-${BigInt(e).toString(10)}`}function yr(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function gr(t,e=0){return t*fr+e}function mr(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"liq_credit":default:return"lendingUpdateAccountPosition";case"param_upd":return"lendingUpdateAccountParameters"}}const br=(t,e,o)=>{const r=new URL(e,t.endsWith("/")?t:`${t}/`);if(o)for(const[t,e]of Object.entries(o))void 0!==e&&r.searchParams.set(t,String(e));return r.toString()};async function wr(t,e){if(!e.baseUrl)throw new Error("Stellar quote baseUrl is required");if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=br(e.baseUrl,"api/v1/quote",{from:t.from,to:t.to,amountIn:t.amountIn,amountOut:t.amountOut,maxHops:t.maxHops,maxSplits:t.maxSplits,slippage:t.slippage,includePaths:t.includePaths,sender:t.sender,router:t.router,referralId:t.referralId,platform:t.platform,fresh:t.fresh}),r=await fetch(o,e.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${o} — ${t}`)}return await r.json()}async function Sr(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=br(t.baseUrl,"api/v1/tokens"),o=await fetch(e,t.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${e} — ${t}`)}return await o.json()}const vr=16384;class xr extends Error{code;constructor(t,e){super(`Stellar route verification failed [${t}]: ${e}`),this.name="StellarRouteVerificationError",this.code=t}}const Ar=(t,e)=>{throw new xr(t,e)};function Tr(t){const o=(t=>{const e="string"==typeof t?t:t&&"object"==typeof t&&"routeXdr"in t?t.routeXdr:void 0;if("string"==typeof e&&e.length>2*vr)return Ar("OVERSIZED",`encoded route has ${e.length} characters`);try{return w.hp.from(V(t).bytes())}catch(t){return Ar("MALFORMED",t instanceof Error?t.message:String(t))}})(t);0===o.length&&Ar("MALFORMED","route is empty"),o.length>vr&&Ar("OVERSIZED",`route has ${o.length} bytes, above ${vr}`);const r=(t=>{let e;try{e=c.ScVal.fromXDR(t)}catch(t){return Ar("MALFORMED",`payload is not one XDR ScVal: ${t instanceof Error?t.message:String(t)}`)}if("scvMap"!==e.switch().name)return Ar("MALFORMED","payload must be a StrategyPayload map");const o=e.map()??[];if("amounts,assets,ops"!==o.map((t=>"scvSymbol"===t.key().switch().name?t.key().sym().toString():"")).join(","))return Ar("MALFORMED","payload fields must be exactly amounts, assets, ops");const[r,n,i]=o.map((t=>t.val()));return"scvVec"!==r.switch().name||"scvVec"!==n.switch().name||"scvBytes"!==i.switch().name?Ar("MALFORMED","payload field has the wrong type"):{amounts:r.vec()??[],assets:n.vec()??[],ops:w.hp.from(i.bytes())}})(o),n=r.assets.length,i=r.amounts.length;0===n&&Ar("MALFORMED","asset registry is empty"),(n>256||i>126)&&Ar("OVERSIZED",`registries hold ${n} assets and ${i} amounts`);const s=r.assets.map(((t,o)=>"scvAddress"!==t.switch().name?Ar("MALFORMED",`assets[${o}] is not an address`):e.fromScAddress(t.address()).toString())),u=r.amounts.map(((t,e)=>"scvI128"!==t.switch().name?Ar("MALFORMED",`amounts[${e}] is not an i128`):l(t))),a=r.ops;a.length<10&&Ar("MALFORMED","program header is truncated"),a.length>346&&Ar("OVERSIZED",`program has ${a.length} bytes, above 346`);const p=t=>{const e=a[t];return void 0===e?Ar("MALFORMED",`program byte ${t} is missing`):e},d=p(0);1!==d&&Ar("UNSUPPORTED_VERSION",`program version ${d}, expected 1`);const f=p(8),h=p(9);0===f&&Ar("INVALID_STRUCTURE","program has no instructions"),(f>48||h>32)&&Ar("OVERSIZED",`program declares ${f} instructions and ${h} weights`);const y=10+5*f;a.length!==y+3*h&&Ar("MALFORMED","program length does not match its instruction and weight counts");const g=p(1),m=p(2),b=p(3);(g>=n||m>=n||b>=i)&&Ar("MALFORMED","header index is outside its registry"),g===m&&Ar("INVALID_STRUCTURE","token_in equals token_out");const v=a.readUInt32BE(4),A=[];for(let t=0;t<h;t+=1){const e=a.readUIntBE(y+3*t,3);(0===e||e>x)&&Ar("INVALID_STRUCTURE",`split weight ${e} outside 1..=1000000`),A.push(e)}const T=t=>s[t]??Ar("MALFORMED",`asset index ${t} is outside the registry`),I=t=>u[t]??Ar("MALFORMED",`amount index ${t} is outside the registry`),q=[];let E;for(let t=0;t<f;t+=1){const e=10+5*t,o=p(e),r=p(e+1),n=p(e+2),s=p(e+3),u=p(e+4);let a;if(o>6&&Ar("UNKNOWN_OPCODE",`instruction ${t} has opcode ${o}`),0===r)a={kind:"all"};else if(1===r)void 0!==E&&E===s||Ar("INVALID_STRUCTURE",`instruction ${t} does not chain onto its predecessor`),a={kind:"prev"};else if(r>=128){const e=A[r-128];void 0===e&&Ar("MALFORMED",`instruction ${t} weight index is out of range`),a={kind:"ppm",ppm:e}}else a={kind:"fixed",amount:I(r-2)};const l=T(n);5!==o&&6!==o?(s===u&&Ar("INVALID_STRUCTURE",`instruction ${t} swaps a token for itself`),q.push({kind:"swap",venue:S[o],mode:a,pool:l,tokenIn:T(s),tokenOut:T(u)}),E=u):("all"!==a.kind&&Ar("MALFORMED",`liquidity instruction ${t} must use mode All`),u>=i&&Ar("MALFORMED",`instruction ${t} amount index is out of range`),q.push({kind:5===o?"burn":"mint",pool:l,shareToken:T(s),amountIndex:u}),E=6===o?s:void 0)}const k=I(b);return k<=0n&&Ar("MIN_OUT_TOO_LOW",`encoded total_min_out is ${k}`),{version:d,tokenIn:T(g),tokenOut:T(m),totalMinOut:k,referralId:v,assets:s,amounts:u,ops:q,weights:A}}function Ir(t,e){if(s.isValidContract(t))return t;if(!e)return Ar("EXPECTATION_MISSING",`token ${t} is not a contract id; pass \`network\` to derive its asset contract`);try{const r=t.indexOf(":");return("XLM"===t||"native"===t?o.native():new o(t.slice(0,r),t.slice(r+1))).contractId(b[e])}catch{return Ar("MALFORMED",`token id ${t} is not a contract id or a classic asset`)}}const qr=(t,e)=>"bigint"==typeof t?t:/^\d+$/.test(t)?BigInt(t):Ar("EXPECTATION_MISSING",`${e} must be a base-unit integer string`);function Er(t,e){const o=qr(e.minOut,"expected.minOut");o<=0n&&Ar("EXPECTATION_MISSING","expected.minOut must be positive");const r=Tr(t);if(r.tokenIn!==e.tokenIn&&Ar("TOKEN_IN_MISMATCH",`route spends ${r.tokenIn}, expected ${e.tokenIn}`),r.tokenOut!==e.tokenOut&&Ar("TOKEN_OUT_MISMATCH",`route delivers ${r.tokenOut}, expected ${e.tokenOut}`),r.totalMinOut<o&&Ar("MIN_OUT_TOO_LOW",`route enforces a minimum of ${r.totalMinOut}, below the expected ${o}`),void 0!==e.amountIn){const t=qr(e.amountIn,"expected.amountIn");for(const e of r.ops)"swap"===e.kind&&"fixed"===e.mode.kind&&e.tokenIn===r.tokenIn&&e.mode.amount>t&&Ar("AMOUNT_IN_EXCEEDED",`a leg spends ${e.mode.amount}, above the input ${t}`)}return r}const kr=t=>N(t).toXDR("base64");function _r(e,o){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const i=new n(e.routerAddress),s=new t(e.caller,e.sourceSequence),a=V(((t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t)(o,e.referralId));return{xdr:new u(s,{fee:e.fee??r,networkPassphrase:b[e.network]}).addOperation(i.call("execute_strategy",A(e.caller),T(e.totalIn),a)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Rr(t,e){return _r(t,e)}function Br(t,e={}){if("string"!=typeof t.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:t.paths?t.paths.map((t=>({hops:t.swaps.map(Mr),splitPpm:t.splitPpm}))):[{hops:t.hops.map(Mr),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Pr(t,e={}){const o=e.expected??{},r="string"==typeof t.routeXdr&&t.routeXdr.length>0?{routeXdr:t.routeXdr}:Br(t,e),n=[t.amountOutMin,o.minOut].filter((t=>void 0!==t)).map((t=>{if("bigint"==typeof t)return t;if("string"!=typeof t||!/^\d+$/.test(t))throw new xr("MALFORMED","minimum output must be a base-unit integer string");return BigInt(t)})).reduce(((t,e)=>void 0===t||e>t?e:t),void 0);if(void 0===n)throw new xr("EXPECTATION_MISSING","quote has no `amountOutMin`; pass `slippage` when fetching it or `expected.minOut`");return Er(r,{tokenIn:Ir(o.tokenIn??t.from,e.network),tokenOut:Ir(o.tokenOut??t.to,e.network),minOut:n,amountIn:o.amountIn??t.amountIn}),r}const Or=Br,Mr=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});class Ur extends Error{code;offender;constructor(t,e,o){super(`Stellar authorization check failed [${t}]: ${e}${o?` — ${o.contract}.${o.fn}(${o.args.join(", ")})`:""}`),this.name="StellarAuthPolicyError",this.code=t,this.offender=o}}const Cr=t=>"scvAddress"===t?.switch().name?e.fromScAddress(t.address()).toString():void 0,$r=t=>"scvI128"===t?.switch().name?l(t):void 0,Lr=t=>"scvVec"===t?.switch().name?t.vec()??[]:void 0,Dr=(t,e)=>"scvMap"===t?.switch().name?(t.map()??[]).find((t=>"scvSymbol"===t.key().switch().name&&t.key().sym().toString()===e))?.val():void 0,Nr=t=>Cr(t)??$r(t)?.toString()??t.toXDR("base64"),Wr=t=>({contract:e.fromScAddress(t.contractAddress()).toString(),fn:t.functionName().toString(),args:t.args().map(Nr)}),Fr=t=>{const e=t.function();return"sorobanAuthorizedFunctionTypeContractFn"===e.switch().name?e.contractFn():void 0};function zr(t,o,r){const n=t.filter((t=>{const n=t.credentials();return("sorobanCredentialsAddress"===n.switch().name?e.fromScAddress(n.address().address()).toString():r??o.caller)===o.caller}));if(n.length>1)throw new Ur("DUPLICATE_ENTRY",`${n.length} authorization entries for ${o.caller}, expected one`);const i=n[0];if(!i)return;const s=Fr(i.rootInvocation());if(!s)throw new Ur("UNEXPECTED_ROOT","root is not a contract call");const u=Wr(s);if(u.contract!==o.root.contract||u.fn!==o.root.fn)throw new Ur("UNEXPECTED_ROOT",`expected ${o.root.contract}.${o.root.fn}`,u);const a=o.transfers.map((()=>0n)),l=(o.calls??[]).map((()=>0));for(const t of i.rootInvocation().subInvocations()){const e=Fr(t);if(!e)throw new Ur("UNEXPECTED_CALL","sub-invocation is not a contract call");const r=Wr(e);if(t.subInvocations().length>0)throw new Ur("NESTED_INVOCATION","sub-invocation carries its own sub-invocations",r);const n=(o.calls??[]).findIndex((t=>t.contract===r.contract&&t.fn===r.fn));if(-1!==n){const t=(o.calls??[])[n],i=t.reject(e.args());if(i)throw new Ur("UNEXPECTED_CALL",i,r);if(l[n]=(l[n]??0)+1,(l[n]??0)>t.maxCount)throw new Ur("UNEXPECTED_CALL",`more than ${t.maxCount} calls`,r);continue}if("transfer"!==r.fn||3!==e.args().length)throw new Ur("UNEXPECTED_CALL","only `transfer` is allowed",r);if(!o.transfers.some((t=>t.token===r.contract)))throw new Ur("UNEXPECTED_TOKEN","transfer on an unexpected token",r);const[i,s,u]=e.args();if(Cr(i)!==o.caller)throw new Ur("UNEXPECTED_SENDER","transfer is not from the caller",r);const p=Cr(s),c=o.transfers.findIndex((t=>t.token===r.contract&&t.to===p));if(-1===c)throw new Ur("UNEXPECTED_RECIPIENT","transfer to an unexpected recipient",r);const d=$r(u),f=o.transfers[c],h=(a[c]??0n)+(d??0n);if(void 0===d||d<=0n||h>f.maxAmount)throw new Ur("AMOUNT_EXCEEDED",`transfers total ${h}, above the expected ${f.maxAmount}`,r);a[c]=h}}const Vr=t=>{throw new Ur("MALFORMED_TRANSACTION",t)},Xr=(t,e)=>{const o=new Map;for(const e of Lr(t)??Vr("payments argument is not a vector")){const[t,r]=Lr(e)??[],n=Cr(Dr(t,"asset")),i=$r(r);if(void 0===n||void 0===i||i<0n)return Vr("payment is not a (HubAssetKey, i128) tuple");o.set(n,(o.get(n)??0n)+i)}return[...o].map((([t,o])=>({token:t,to:e,maxAmount:o})))},Hr=new Set([1,3,5]),Gr=(t,e,o)=>({contract:t,fn:"submit",maxCount:2,reject:t=>{if(4!==t.length)return"submit must have four arguments";if(Cr(t[0])!==e)return"`from` is not the caller";if(Cr(t[1])!==o||Cr(t[2])!==o)return"`spender` and `to` must be the lending controller";const r=Lr(t[3]);if(!r)return"requests is not a vector";for(const t of r){const e=Dr(t,"request_type");if("scvU32"!==e?.switch().name||!Hr.has(e.u32()))return"request is not a withdraw, withdraw-collateral, or repay"}}});function jr(t,e,o){const{contract:r,fn:n}=Wr(e),i=e.args(),s={caller:t,root:{contract:r,fn:n},transfers:[]};if(r===o.governance)return s;if(r===o.aggregatorRouter){if("execute_strategy"!==n)return s;const e=$r(i[1]);if(Cr(i[0])!==t||void 0===e||"scvBytes"!==i[2]?.switch().name)return Vr("execute_strategy arguments must be (caller, total_in, swap_xdr)");const o=Tr(i[2].bytes());return s.transfers=[{token:o.tokenIn,to:r,maxAmount:e}],s}if(r!==o.lendingController)throw new Ur("UNSUPPORTED_CONTRACT",`no authorization policy for contract ${r}; pass an explicit policy`);if(Cr(i[0])!==t)throw new Ur("CALLER_MISMATCH",`${n} is not invoked for ${t}`);switch(n){case"supply":s.transfers=Xr(i[3],o.lendingPool);break;case"repay":case"liquidate":s.transfers=Xr(i[2],o.lendingPool);break;case"multiply":{const t=i[8];t&&"scvVoid"!==t.switch().name&&(s.transfers=Xr(c.ScVal.scvVec([t]),r));break}case"migrate_from_blend":{const e=Cr(i[4])??Vr("blend_pool is not an address");s.calls=[Gr(e,t,r)];break}}return s}const Kr=t=>{let e;try{e=c.TransactionEnvelope.fromXDR(t,"base64")}catch{return Vr("not a transaction envelope")}if("envelopeTypeTx"!==e.switch().name)return Vr("expected a regular (v1) transaction");const o=e.v1().tx(),r=o.operations()[0];if(!r||1!==o.operations().length)return Vr("expected exactly one operation");const n=r.body();if("invokeHostFunction"!==n.switch().name)return Vr("operation is not a contract invocation");const i=n.invokeHostFunctionOp();return"hostFunctionTypeInvokeContract"!==i.hostFunction().switch().name?Vr("host function is not a contract call"):{source:(u=r.sourceAccount()??o.sourceAccount(),s.encodeEd25519PublicKey("keyTypeMuxedEd25519"===u.switch().name?u.med25519().ed25519():u.ed25519())),op:i,call:i.hostFunction().invokeContract()};var u};function Yr(t,e){const o=Kr(t);if(void 0!==e.builtXdr&&Kr(e.builtXdr).op.hostFunction().toXDR("base64")!==o.op.hostFunction().toXDR("base64"))throw new Ur("INVOCATION_CHANGED","the prepared transaction does not invoke what was built",Wr(o.call));const r=e.policy??jr(e.caller,o.call,{...m(e.network),...e.deployment});zr(o.op.auth(),r,o.source)}function Jr(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Zr(t,e,o){const r=o?.instructionLeeway??2e7;if(!Number.isInteger(r)||r<0||r>4294967295)throw new Error("instructionLeeway must be an integer from 0 to 4294967295");const n=u.fromXDR(e,o?.network?b[o.network]:"");try{const e=await t.simulateTransaction(n,{cpuInstructions:r});if(a.Api.isSimulationError(e))throw new Error(e.error);return a.assembleTransaction(n,e).build().toXDR()}catch(t){if(o?.invokedContractId)throw Jr(o.invokedContractId,t);throw t}}async function Qr(t,e,o){return Zr(t,e.xdr,o)}function tn(t){if(t<=0||t>4)throw new Error(`Invalid PositionMode ${t} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return t-1}function en(t,e){return new Uint8Array(0)}const on=t=>{const e=t.startsWith("0x")?t.slice(2):t;if(e.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return w.hp.from(e,"hex")};function rn(e){const o=new t(e.caller,e.sourceSequence),r=new n(e.forwarderAddress).call("mint_and_forward",c.ScVal.scvBytes(on(e.message)),c.ScVal.scvBytes(on(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:b[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const nn=10n**27n,sn=10n**18n,un=10000n,an=27,ln=18;function pn(t,e="value"){let o;if("bigint"==typeof t)o=t;else if("number"==typeof t){if(!Number.isSafeInteger(t))throw new Error(`Stellar math: ${e} must be a safe integer, got ${t}`);o=BigInt(t)}else{const r=t.trim();if(!/^-?\d+$/.test(r))throw new Error(`Stellar math: ${e} must be a decimal integer string, got "${t}"`);o=BigInt(r)}if(o<0n)throw new Error(`Stellar math: ${e} must be non-negative, got ${o}`);return o}function cn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");return t*e/o}function dn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");const r=t*e,n=r/o;return r%o===0n?n:n+1n}function fn(t,e,o){if(0n===o)throw new Error("Stellar math: division by zero");return(t*e+o/2n)/o}function hn(t,e){if(0n===e)throw new Error("Stellar math: division by zero");const o=t/e;return t%e>=e/2n+e%2n?o+1n:o}const yn=t=>10n**BigInt(t);function gn(t,e,o){return e===o?t:o>e?t*yn(o-e):t/yn(e-o)}function mn(t,e,o){if(e===o)return t;if(o>e)return t*yn(o-e);const r=yn(e-o),n=t/r;return t%r===0n?n:n+1n}function bn(t,e,o){return e===o?t:o>e?t*yn(o-e):hn(t,yn(e-o))}const wn={floor:cn,ceil:dn,halfUp:fn},Sn={floor:gn,ceil:mn,halfUp:bn};function vn(t,e,o,r){return Sn[r](wn[r](t,e,nn),an,o)}function xn(t,e,o){return vn(pn(t,"scaledRay"),pn(e,"indexRay"),o,"floor")}function An(t,e,o){return vn(pn(t,"scaledRay"),pn(e,"indexRay"),o,"ceil")}function Tn(t,e,o){return vn(pn(t,"scaledRay"),pn(e,"indexRay"),o,"halfUp")}function In(t,e){if(e>an)throw new Error(`Stellar math: decimals ${e} exceed RAY scale`);return gn(t,e,an)}function qn(t,e,o,r){const n=wn[r](t,e,nn),i=Sn[r](n,an,ln);return wn[r](i,o,sn)}function En(t,e,o,r){const n=Sn[r](In(t,e),an,ln);return wn[r](n,o,sn)}const kn=t=>Number(t)/1e18,_n=t=>Number(t)/1e27,Rn=(t,e)=>Number(t)/10**e;function Bn(t,e){if(!Number.isFinite(t)||t<=0||t>=1e21)return 0n;const o=t.toFixed(e),[r="0",n=""]=o.split(".");return BigInt(r+n.padEnd(e,"0"))}const Pn=t=>Bn(t,ln),On=(t,e)=>fn(t,e,nn),Mn=(t,e)=>fn(t,nn,e);function Un(t,e){return 0n===e?0n:Mn(t,e)}function Cn(t,e){const o=t>nn?nn:t,r=pn(e.baseRateRay,"irm.baseRateRay"),n=pn(e.slope1Ray,"irm.slope1Ray"),i=pn(e.slope2Ray,"irm.slope2Ray"),s=pn(e.slope3Ray,"irm.slope3Ray"),u=pn(e.midUtilizationRay,"irm.midUtilizationRay"),a=pn(e.optimalUtilizationRay,"irm.optimalUtilizationRay"),l=pn(e.maxBorrowRateRay,"irm.maxBorrowRateRay");let p;if(o<u)p=r+Mn(On(o,n),u);else if(o<a){const t=a-u;p=r+n+Mn(On(o-u,i),t)}else{const t=nn-a;p=r+n+i+(0n===t?0n:Mn(On(o-a,s),t))}return p>l?l:p}function $n(t,e,o){return 0n===t||!Number.isInteger(o)||o<0||o>=1e4?0n:fn(On(t,e),un-BigInt(o),un)}const Ln=t=>_n(t),Dn=t=>Math.expm1(_n(t)),Nn=5n*sn,Wn=(t,e,o)=>`${t}:${e}:${o}`;function Fn(t,e,o,r){const n=Array.isArray(t)?t:void 0,i=n?n.find((t=>t.spokeId===e&&t.hubId===o&&t.asset===r)):t[Wn(e,o,r)]??Object.values(t).find((t=>t.spokeId===e&&t.hubId===o&&t.asset===r));if(!i)throw new Error(`Stellar math: no reserve for ${Wn(e,o,r)}`);return i}const zn=/^0*[1-9]\d*$/,Vn=t=>"string"==typeof t&&zn.test(t)?BigInt(t).toString():null,Xn=(t,e)=>`${t}:${e}`;function Hn(t){const e=new Map,o=new Map,r=new Set,n=new Set;for(const i of t?.indexes??[]){const t=Xn(i.hubId,i.asset),s=Vn(i.supplyIndex),u=Vn(i.borrowIndex),a=Vn(i.usdPrice),l=e.get(t),p=l&&Vn(l.supplyIndex)===s&&Vn(l.borrowIndex)===u&&Vn(l.usdPrice)===a;null==s||null==u||null==a||l&&!p?r.add(t):l||e.set(t,i);const c=!1===i.valid||!0===i.stale||!0===i.deviation,d=o.get(i.asset);null==a||c||void 0!==d&&d.toString()!==a?n.add(i.asset):void 0===d&&o.set(i.asset,BigInt(a))}for(const t of r)e.delete(t);for(const t of n)o.delete(t);return{indexes:e,prices:o,rejectedIndexKeys:r,rejectedAssets:n}}const Gn=(t,e)=>cn(t,BigInt(e),un);function jn(t,e,o,r){const n="supply"===t.side,i=Math.min(t.entryLtvBps,t.entryLiquidationThresholdBps);return{side:t.side,hubId:t.hubId,asset:t.asset,decimals:t.decimals,scaledRay:t.scaledRay.toString(),indexRay:t.indexRay.toString(),usdPriceWad:t.priceWad.toString(),usdPrice:kn(t.priceWad),amountBase:e.toString(),amountShort:Rn(e,t.decimals),usdWad:o.toString(),usd:kn(o),gateUsdWad:r.toString(),entryLtvBps:t.entryLtvBps,entryLiquidationThresholdBps:t.entryLiquidationThresholdBps,entryLiquidationBonusBps:t.entryLiquidationBonusBps,entryLiquidationFeesBps:t.entryLiquidationFeesBps,ltvWeightedUsdWad:n?Gn(r,i).toString():"0",liquidationWeightedUsdWad:n?Gn(r,t.entryLiquidationThresholdBps).toString():"0",liveDataUsed:t.liveDataUsed}}function Kn(t){if("supply"===t.side)return jn(t,vn(t.scaledRay,t.indexRay,t.decimals,"floor"),qn(t.scaledRay,t.indexRay,t.priceWad,"halfUp"),qn(t.scaledRay,t.indexRay,t.priceWad,"floor"));const e=vn(t.scaledRay,t.indexRay,t.decimals,"ceil"),o=qn(t.scaledRay,t.indexRay,t.priceWad,"ceil");return jn(t,e,o,o)}function Yn(t,e,o,r){const n=In(e,o);return"supply"===t?cn(n,nn,r):dn(n,nn,r)}function Jn(t,e,o,r){const n=In(e,o);return"supply"===t?dn(n,nn,r):cn(n,nn,r)}function Zn(t,e){return Kn({...t,scaledRay:Yn(t.side,e,t.decimals,t.indexRay)})}const Qn=(...t)=>{for(const e of t){const t=Vn(e);if(null!=t)return BigInt(t)}return nn};function ti(t,e,o,r){const n=pn("supply"===t?e.supplyScaledRay:e.borrowScaledRay,`${t}ScaledRay`);if(0n===n)return null;const i=r.indexes.get(Xn(e.hubId,e.asset)),s=r.prices.get(e.asset),u="supply"===t?Qn(i?.supplyIndex,e.liveSupplyIndexRay,o.liveSupplyIndexRay,e.supplyIndexRay):Qn(i?.borrowIndex,e.liveBorrowIndexRay,o.liveBorrowIndexRay,e.borrowIndexRay),a=s??Pn(o.usdPrice);return Kn({side:t,hubId:e.hubId,asset:e.asset,decimals:o.assetDecimals,scaledRay:n,indexRay:u,priceWad:a,entryLtvBps:e.entryLtvBps,entryLiquidationThresholdBps:e.entryLiquidationThresholdBps,entryLiquidationBonusBps:e.entryLiquidationBonusBps,entryLiquidationFeesBps:e.entryLiquidationFeesBps,liveDataUsed:void 0!==i&&void 0!==s})}const ei=(t,e)=>t.reduce(((t,o)=>t+BigInt(e(o))),0n);function oi(t,e,o,r,n){const i=ei(e,(t=>t.usdWad)),s=ei(e,(t=>t.ltvWeightedUsdWad)),u=ei(e,(t=>t.liquidationWeightedUsdWad)),a=ei(o,(t=>t.usdWad)),l=0n===a?null:cn(u,sn,a),p=0n===u?0:Number(a)/Number(u)*100,c=s<r||s<=a?0n:s-a;return{...t,supplies:e,borrows:o,totalCollateralUsdWad:i.toString(),totalCollateralUsd:kn(i),ltvWeightedCollateralUsdWad:s.toString(),ltvWeightedCollateralUsd:kn(s),liquidationWeightedCollateralUsdWad:u.toString(),liquidationWeightedCollateralUsd:kn(u),totalDebtUsdWad:a.toString(),totalDebtUsd:kn(a),healthFactorWad:null===l?null:l.toString(),healthFactor:null===l?null:kn(l),healthPercent:p,borrowLimitUsdWad:s.toString(),borrowLimitUsd:kn(s),availableBorrowUsdWad:c.toString(),availableBorrowUsd:kn(c),minBorrowCollateralUsdWad:r.toString(),minBorrowCollateralUsd:kn(r),isLiquidatable:null!==l&&l<sn,liveDataValid:n}}function ri(t){const{positions:e,reserves:o,liveState:r}=t,n=e[0];if(!n)throw new Error("Stellar math: computeAccountRisk needs at least one position row");for(const t of e)if(t.accountId!==n.accountId)throw new Error(`Stellar math: computeAccountRisk received mixed account ids (${n.accountId}, ${t.accountId})`);const i=Hn(r),s=[],u=[];for(const t of e){const e=Fn(o,t.spokeId,t.hubId,t.asset),r=ti("supply",t,e,i);r&&s.push(r);const n=ti("borrow",t,e,i);n&&u.push(n)}const a=null!=r?.minBorrowCollateralUsdWad?pn(r.minBorrowCollateralUsdWad,"minBorrowCollateralUsdWad"):Nn,l=void 0!==r&&[...s,...u].every((t=>t.liveDataUsed));return oi({accountId:n.accountId,owner:n.owner,spokeId:n.spokeId,mode:n.positionMode},s,u,a,l)}const ni=200n,ii=t=>t.reduce(((t,e)=>e.amount<t.amount?e:t)),si=t=>t<0n?0n:t,ui=(t,e,o,r)=>({amountBase:t.amount,amountShort:Rn(t.amount,e),isFullClose:o,reason:t.reason,projectedUtilization:r}),ai=t=>({amountBase:0n,amountShort:0,isFullClose:!1,reason:t,projectedUtilization:null});function li(t){const e=t.assetDecimals,o=pn(t.irm.maxUtilizationRay,"irm.maxUtilizationRay");return{suppliedBase:Bn(t.hubPool.suppliedShort,e),borrowedBase:Bn(t.hubPool.borrowedShort,e),cashBase:Bn(t.availableLiquidityShort,e),spokeSuppliedBase:Bn(t.suppliedShort,e),spokeBorrowedBase:Bn(t.borrowedShort,e),maxUtilizationRay:o>=nn?null:o}}const pi=(t,e)=>t<=0n?null:Number(e)/Number(t);function ci(t,e){if(t<=0n||!e(0n))return 0n;let o=0n,r=t+1n;for(;r-o>1n;){const t=(o+r)/2n;e(t)?o=t:r=t}return o}const di=(t,e)=>t.find((t=>t.hubId===e.hubId&&t.asset===e.asset));function fi(t,e,o){if(e.paused)return ai("paused");if(e.frozen)return ai("frozen");if(!e.isBorrowable)return ai("cap");const r=e.assetDecimals,n=li(e),i=di(t.borrows,e),s=Hn(o).indexes.get(Xn(e.hubId,e.asset)),u=i?BigInt(i.indexRay):pn(s?.borrowIndex??e.liveBorrowIndexRay,"borrowIndex"),a=i?BigInt(i.usdPriceWad):function(t,e){return Hn(e).prices.get(t.asset)??Pn(t.usdPrice)}(e,o),l=i?BigInt(i.scaledRay):0n,p=BigInt(t.totalDebtUsdWad)-(i?BigInt(i.usdWad):0n),c=BigInt(t.ltvWeightedCollateralUsdWad),d=BigInt(t.minBorrowCollateralUsdWad),f=[];if(c<d)f.push({amount:0n,reason:"minCollateral"});else{const e=c-BigInt(t.totalDebtUsdWad),o=e<=0n||a<=0n?0n:cn(e,10n**BigInt(r),a),n=t=>p+qn(l+Yn("borrow",t,r,u),u,a,"ceil");f.push({amount:0n===o?0n:ci(o+16n,(t=>n(t)<=c)),reason:"ltv"})}f.push({amount:si(pn(e.borrowCap,"borrowCap")-n.spokeBorrowedBase),reason:"cap"});const h=fn(n.suppliedBase,ni,un);f.push({amount:si(n.cashBase-h),reason:"liquidity"});const y=function(t,e){const o=t.maxUtilizationRay;if(null===o)return null;const r=In(t.suppliedBase,e);return 0n===r?null:ci(si(cn(t.suppliedBase,o,nn)-t.borrowedBase)+16n,(n=>Un(In(t.borrowedBase+n,e),r)<=o))}(n,r);null!==y&&f.push({amount:y,reason:"utilizationCap"});const g=ii(f);return ui(g,r,!1,pi(n.suppliedBase,n.borrowedBase+g.amount))}function hi(t,e,o){if(e.paused)return ai("paused");const r=di(t.supplies,e);if(!r)return ai(null);const n=r.decimals,i=li(e),s=BigInt(r.scaledRay),u=BigInt(r.indexRay),a=BigInt(r.usdPriceWad),l=BigInt(r.amountBase),p=vn(s,u,n,"halfUp"),c=BigInt(t.totalDebtUsdWad),d=BigInt(t.minBorrowCollateralUsdWad),f=BigInt(Math.min(r.entryLtvBps,r.entryLiquidationThresholdBps)),h=[];let y=!0;if(c>0n&&f>0n){const e=c>d?c:d,o=d>c?"minCollateral":"healthFactor",i=BigInt(t.ltvWeightedCollateralUsdWad)-BigInt(r.ltvWeightedUsdWad);if(i<e){y=!1;const t=e-i,l=dn(t,un,f),c=BigInt(r.gateUsdWad)-l,d=c<=0n?0n:cn(c,10n**BigInt(n),a),g=p>0n?p-1n:0n,m=d+16n>g?g:d+16n,b=t=>{const e=Jn("supply",t,n,u);return cn(qn(e>=s?0n:s-e,u,a,"floor"),f,un)};h.push({amount:ci(m,(e=>b(e)>=t)),reason:o})}}h.push({amount:l,reason:null}),h.push({amount:i.cashBase,reason:"liquidity"});const g=function(t,e){const o=t.maxUtilizationRay;if(null===o||0n===t.borrowedBase)return null;if(0n===o)return 0n;const r=dn(t.borrowedBase,nn,o),n=t.suppliedBase<r?0n:t.suppliedBase-r+16n,i=In(t.borrowedBase,e);return ci(n>t.suppliedBase?t.suppliedBase:n,(r=>{const n=In(t.suppliedBase-r,e);return n>0n&&Un(i,n)<=o}))}(i,n);null!==g&&h.push({amount:g,reason:"utilizationCap"});const m=ii(h),b=y&&m.amount>=l;return ui(m,n,b,pi(i.suppliedBase-m.amount,i.borrowedBase))}function yi(t){if(t.paused)return ai("paused");if(t.frozen)return ai("frozen");const e=t.assetDecimals,o=li(t),r={amount:si(pn(t.supplyCap,"supplyCap")-o.spokeSuppliedBase),reason:"cap"};return ui(r,e,!1,pi(o.suppliedBase+r.amount,o.borrowedBase))}function gi(t,e,o){if(e.paused)return ai("paused");const r=di(t.borrows,e);if(!r)return ai(null);const n=r.decimals,i=li(e),s=BigInt(r.amountBase),u=void 0===o?null:pn(o,"walletBalance"),a=null!==u&&u<s?{amount:u,reason:"liquidity"}:{amount:s,reason:null};return ui(a,n,a.amount>=s,pi(i.suppliedBase,si(i.borrowedBase-a.amount)))}const mi=(t,e)=>t.hubId===e.hubId&&t.asset===e.asset,bi=t=>{if("bigint"==typeof t)return t;const e=t.trim();if(!/^-?\d+$/.test(e))throw new Error(`Stellar math: delta amountBase must be an integer string, got "${t}"`);return BigInt(e)};function wi(t,e){const o=[...t.supplies],r=[...t.borrows];for(const t of e){const e="supply"===t.side?o:r,n=e.findIndex((e=>mi(e,t))),i=-1===n?void 0:e[n],s=bi(t.amountBase);let u;if(i){const t={side:i.side,hubId:i.hubId,asset:i.asset,decimals:i.decimals,indexRay:BigInt(i.indexRay),priceWad:BigInt(i.usdPriceWad),entryLtvBps:i.entryLtvBps,entryLiquidationThresholdBps:i.entryLiquidationThresholdBps,entryLiquidationBonusBps:i.entryLiquidationBonusBps,entryLiquidationFeesBps:i.entryLiquidationFeesBps,liveDataUsed:i.liveDataUsed},e=BigInt(i.scaledRay);let o;if(s>=0n)o=e+Yn(t.side,s,t.decimals,t.indexRay);else{const r=-s,n=r>=("supply"===t.side?vn(e,t.indexRay,t.decimals,"halfUp"):BigInt(i.amountBase))?e:Jn(t.side,r,t.decimals,t.indexRay);o=n>=e?0n:e-n}u=0n===o?null:Kn({...t,scaledRay:o})}else u=s<=0n?null:Zn(Si(t),s);-1===n?u&&e.push(u):u?e[n]=u:e.splice(n,1)}return oi({accountId:t.accountId,owner:t.owner,spokeId:t.spokeId,mode:t.mode},o,r,BigInt(t.minBorrowCollateralUsdWad),t.liveDataValid)}function Si(t){const e=t.reserve;if(!e)throw new Error(`Stellar math: projectAccountRisk needs \`reserve\` for a new ${t.side} position on ${t.hubId}:${t.asset}`);return{side:t.side,hubId:t.hubId,asset:t.asset,decimals:e.assetDecimals,indexRay:pn("supply"===t.side?e.liveSupplyIndexRay:e.liveBorrowIndexRay,"reserve live index"),priceWad:Pn(e.usdPrice),entryLtvBps:e.collateralFactorBps,entryLiquidationThresholdBps:e.liquidationThresholdBps,entryLiquidationBonusBps:e.liquidationPenaltyBps,entryLiquidationFeesBps:e.liquidationFeesBps,liveDataUsed:!1}}function vi(t,e=0n,o=0n){const r=t.assetDecimals,n=t=>t<0n?0n:t,i=n(Bn(t.hubPool.suppliedShort,r)+bi(e)),s=Un(In(n(Bn(t.hubPool.borrowedShort,r)+bi(o)),r),In(i,r)),u=Cn(s,t.irm),a=$n(s,u,t.irm.reserveFactorBps);return{utilization:_n(s),utilizationRay:s.toString(),borrowAprRay:u.toString(),supplyAprRay:a.toString(),borrowApr:Ln(u),supplyApr:Ln(a),borrowApy:Dn(u),supplyApy:Dn(a)}}const xi={1:{name:"AssetNotSupported",message:"This asset is not supported by the protocol."},2:{name:"AssetAlreadySupported",message:"This asset is already supported."},3:{name:"InvalidTicker",message:"Invalid asset ticker."},6:{name:"InvalidAsset",message:"Invalid asset address."},10:{name:"InvalidWasmHash",message:"The WASM hash is empty or invalid."},11:{name:"InvalidExchangeSrc",message:"The oracle configuration is invalid."},12:{name:"PairNotActive",message:"No oracle is configured for this asset."},14:{name:"AmountMustBePositive",message:"The amount must be greater than zero."},32:{name:"OwnerNotSet",message:"The contract owner has not been set."},39:{name:"InvalidTimelockDelay",message:"The timelock delay is out of the allowed range."},41:{name:"InvalidRole",message:"The caller does not hold the required role."},43:{name:"HubNotActive",message:"This hub is not active."},44:{name:"NotAuthorized",message:"The caller is not authorized to perform this action."},46:{name:"OperationNotCancellable",message:"This governance operation cannot be cancelled."},113:{name:"InvalidLiqThreshold",message:"LTV, liquidation threshold, or bonus is out of bounds."},116:{name:"InvalidBorrowParams",message:"Supply or borrow cap configuration is invalid."},117:{name:"InvalidUtilRange",message:"Interest-rate utilization breakpoints are invalid."},132:{name:"AssetDecimalsTooHigh",message:"Asset decimals exceed the protocol maximum (27)."},300:{name:"SpokeNotFound",message:"This spoke does not exist."},301:{name:"SpokeDeprecated",message:"This spoke has been deprecated."},307:{name:"AssetNotInSpoke",message:"This asset is not listed on the spoke."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetInUse",message:"This spoke asset still has live positions; drain usage before removal."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},317:{name:"SpokeAssetFlagRelaxation",message:"Guardian flag updates may only tighten; clearing a flag requires the timelocked edit."},318:{name:"SpokeAssetSeizureHalted",message:"Liquidation seizure is halted for this spoke asset."},220:{name:"InvalidOracleBase",message:"The oracle quote asset/market is missing or invalid."},221:{name:"InvalidOracleDecimals",message:"The oracle decimals value is invalid."},224:{name:"InvalidSanityBounds",message:"Oracle sanity bounds are invalid (require 0 < min < max)."},225:{name:"OracleCycleDetected",message:"A cycle was detected in the oracle quote chain."}};function Ai(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=xi[o];return r?{code:o,...r}:null}}},f={};function h(t){var e=f[t];if(void 0!==e)return e.exports;var o=f[t]={exports:{}};return d[t](o,o.exports,h),o.exports}h.d=(t,e)=>{for(var o in e)h.o(e,o)&&!h.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const y="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",g="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",m="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",b=3e4;var w;!function(t){t.MAINNET="1",t.DEVNET="D"}(w||(w={}));class S{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=w.MAINNET,apiUrl:o,...r}=t;this.apiUrl=o.trim().replace(/\/$/,""),this.chain=e,this.init=r,this.config=e==w.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:y,DR_SC:g,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:y,DR_SC:g,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:i,timeout:s,...u}=this.init,{next:a,cache:l,debug:p,timeout:c,headers:d,method:f="GET",...h}=o,y=d?.Authorization,g="Bearer undefined"===y?void 0:y,m="GET"!==f&&"HEAD"!==f&&"PUT"!==f,b={...d,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...m?{"Content-Type":"application/json"}:{},...g?{Authorization:g}:{}},w=Object.entries(e??{}).filter((([,t])=>void 0!==t)).flatMap((([t,e])=>Array.isArray(e)?e.filter((t=>void 0!==t)).map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),S=`${this.apiUrl}${t}${w.length?`?${w}`:""}`,{revalidate:v,...x}=r??{},{revalidate:A,...T}=a??{},I="GET"!==f||g?void 0:A??v,q="GET"!==f||g||I?void 0:l??n,E=h.body,k=c??s??(null==E?3e4:0),_=k>0?AbortSignal.timeout(k):void 0,R=h.signal??u.signal,B=_&&R?AbortSignal.any([R,_]):_??R,P={...u,...h,method:f,...Object.keys(b).length?{headers:b}:{},...B?{signal:B}:{},cache:q,next:{...x,...T,revalidate:I}};(p??i)&&console.debug("SDK fetch: ",S,P);const O=await fetch(S,P).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${S}: ${t.message}`),{cause:t});throw t})),M=await O.text();if(!O.ok){let t;try{t=JSON.parse(M)}catch{t={message:M}}const e=[S,O.status,O.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(M)}catch{return M}}}const v=t=>{const e=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(t)),o=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t),r=/^C[A-Z2-7]{55}$/.test(t);return e||o||r},x=t=>{const e=/^0x[a-fA-F0-9]{1,64}$/.test(t),o=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(t),r=/^C[A-Z2-7]{55}-\d+$/.test(t);return e||o||r};class A extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class T extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const I=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^[GC][A-Z2-7]{55}$/.test(t)),q={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/integrations/liquid-staking/multiversx/revenue":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/multiversx":{input:{},output:{}},"/integrations/lending/multiversx/revenue":{input:{},output:{}},"/integrations/lending/multiversx/liquidations":{input:{},output:{}},"/integrations/lending/multiversx/active-users":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/campaign/leaderboard":{input:{},output:{}},"/stellar-lending/campaign/me":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/stellar-lending/users/:owner/assets/:asset/balance":{input:{},output:{}},"/stellar-lending/users/:owner/activity/page":{input:{},output:{}}},E=["PATCH","POST","DELETE","PUT"];var k=h(626);const _=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function R(t,e,o,r){const{input:n,output:i,...s}=e,u=async(e={})=>{const n={...o,...e},i=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),s=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),u=Object.fromEntries(Object.entries(n).filter((([t])=>!s.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in u,l=/:collection[^A-Z]/.test(t)||"collection"in u;if(a){const t=n.address;if(!I(t))throw new T(t)}if(l){const t=n.collection;if(Array.isArray(t)?t.some((t=>!v(t))):!v(t))throw new A(t)}const p=Object.fromEntries(Object.entries(u).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:c,auth:d,method:f,headers:h,cache:y,next:g,debug:m,signal:b,credentials:w,mode:S,redirect:x,referrer:q,referrerPolicy:E,integrity:k,keepalive:_,priority:R,window:B,continuationToken:P,...O}=p,M=d?`Bearer ${d}`:void 0;t.startsWith("/stellar-lending/")&&void 0!==P&&(O.continuationToken=P);const U={...h,...M?{Authorization:M}:{},...P&&!t.startsWith("/stellar-lending/")?{"X-Continuation-Token":String(P)}:{}},C={...g,tags:[...g?.tags??[],i]};return r.fetchWithTimeout(i,{method:f,params:O,body:c,headers:U,cache:y,debug:m,...Object.fromEntries(Object.entries({signal:b,credentials:w,mode:S,redirect:x,referrer:q,referrerPolicy:E,integrity:k,keepalive:_,priority:R,window:B}).filter((([,t])=>void 0!==t))),...C?{next:C}:{}})},a=(t={})=>u(t);for(const t of Object.keys(s))E.includes(t)&&(a[t]=e=>u({...e,method:e.method??t.toUpperCase()}));return a}function B(t){const e=function(){const t={static:{},params:{},leaves:[]};for(const[e,o]of Object.entries(q)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=_(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=_(t);n=n.static[e]||={static:{},params:{},leaves:[]}}n.leaves.push({rawPath:e,def:o})}return t}(),o=(e,r)=>{const n=e.leaves.length,i=Object.keys(e.static).length,s=Object.keys(e.params).length;let u;if(1===n&&i+s>0){const{rawPath:o,def:n}=e.leaves[0];u=R(o,n,r,t)}else{u={};for(const{rawPath:o,def:n}of e.leaves)u[_(o.split("/").pop().replace(/^:/,""))]=R(o,n,r,t)}for(const[t,n]of Object.entries(e.static)){const e=o(n,r);let i=e;if(e&&"object"==typeof e&&t in e&&"function"==typeof e[t]){const o=e[t],r=Object.fromEntries(Object.entries(e).filter((([e])=>e!==t)));1===o.length||(Object.assign(o,r),i=o)}void 0===u[t]?u[t]=i:"function"==typeof u[t]?Object.assign(u[t],i):"function"==typeof i?(Object.assign(i,u[t]),u[t]=i):Object.assign(u[t],i)}for(const[t,n]of Object.entries(e.params)){const e=e=>{const i=o(n,{...r,[t]:e});if(i&&"object"==typeof i&&1===Object.keys(i).length&&t in i&&"function"==typeof i[t]){const e=i[t],o=(...t)=>e(...t);return Object.assign(o,e)}return i};if(u[t]){const o=u[t];u[t]=t=>({...o(t),...e(t)})}else u[t]=e}return u};return o(e,{})}export{w as Chain,b as DEFAULT_REQUEST_TIMEOUT_MS,S as XOXNOClient,B as buildSdk,v as isValidCollectionTicker,x as isValidNftIdentifier};export const BPS=k.UTY;export const DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD=k.fFH;export const LIQUIDATION_BUFFER_BPS=k.RCv;export const RAY=k.Z$K;export const RAY_DECIMALS=k.OAi;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=k.G_M;export const STELLAR_LENDING_TOPICS=k.fAY;export const STELLAR_NETWORKS=k.a_O;export const STELLAR_NETWORK_PASSPHRASE=k.A$9;export const STELLAR_ROUTE_MAX_BYTES=k.XvM;export const SYNTHETIC_EVENT_ORDER_STRIDE=k.gRW;export const StellarAuthPolicyError=k.cJU;export const StellarRouteVerificationError=k.SVM;export const WAD=k.DYS;export const WAD_DECIMALS=k.wFd;export const aggregateAccountRisk=k.wJe;export const annualBorrowRateRay=k.$wP;export const assertStellarAuthEntries=k.eBc;export const assertStellarPreparedTxAuth=k.JtG;export const baseToRay=k.Vhx;export const baseToShort=k.xEs;export const baseValueWad=k.t$R;export const buildLiveSnapshot=k.pU3;export const buildSameTokenRepaySwapSteps=k.VZJ;export const buildStellarAcceptOwnershipTx=k.N0v;export const buildStellarAddRewardsTx=k.B_D;export const buildStellarApproveBlendPoolTx=k.qLM;export const buildStellarApproveTokenTx=k.eX8;export const buildStellarBatchSwapTx=k.zaA;export const buildStellarBorrowBatchTx=k.xDR;export const buildStellarBorrowTx=k.jR0;export const buildStellarCctpForwardTx=k.P2l;export const buildStellarClaimRevenueTx=k.W68;export const buildStellarCreateLiquidityPoolTx=k.sec;export const buildStellarExecuteCancellerResetTx=k.ZPB;export const buildStellarExecuteStrategyTx=k.yrp;export const buildStellarFlashLoanTx=k.spi;export const buildStellarGovernanceAddSpokeImmediateTx=k.Iu1;export const buildStellarGovernanceCreateHubImmediateTx=k.yuB;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=k.$96;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=k.zwJ;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=k.h_A;export const buildStellarGovernanceExecuteTransferGovOwnTx=k.e_X;export const buildStellarGovernanceExecuteTx=k.TkG;export const buildStellarGovernanceExecuteUpdateDelayTx=k.BAg;export const buildStellarGovernancePauseTx=k.u9S;export const buildStellarGovernanceRevokeRoleImmediateTx=k.biU;export const buildStellarGovernanceSetOracleSanityBoundsImmediateTx=k.gc5;export const buildStellarGovernanceSetSpokeAssetFlagsImmediateTx=k.ayx;export const buildStellarGrantRoleTx=k.SXg;export const buildStellarLendingIdentifier=k.UFY;export const buildStellarLiquidateTx=k.Y5o;export const buildStellarMigrateFromBlendTx=k.mEH;export const buildStellarMigrateTx=k.xGW;export const buildStellarMultiplyTx=k.s9Q;export const buildStellarPauseTx=k.OL0;export const buildStellarProposeAddAssetToSpokeTx=k.k6p;export const buildStellarProposeAddSpokeTx=k.djE;export const buildStellarProposeApproveBlendPoolTx=k.kDJ;export const buildStellarProposeApproveTokenTx=k.Yfw;export const buildStellarProposeCancellerResetTx=k.AI1;export const buildStellarProposeConfigureAssetOracleTx=k.O2U;export const buildStellarProposeConfigureMarketOracleTx=k.c5J;export const buildStellarProposeCreateHubTx=k.N8y;export const buildStellarProposeCreateLiquidityPoolTx=k.qUh;export const buildStellarProposeDeployPoolTx=k.RZj;export const buildStellarProposeEditAssetInSpokeTx=k.nio;export const buildStellarProposeEditOracleToleranceTx=k.hFg;export const buildStellarProposeGovernanceUpgradeTx=k.Qkp;export const buildStellarProposeGrantGovernanceRoleTx=k.GwL;export const buildStellarProposeMigrateControllerTx=k.$Kr;export const buildStellarProposeRemoveAssetFromSpokeTx=k.ujH;export const buildStellarProposeRemoveSpokeTx=k.Odj;export const buildStellarProposeRevokeBlendPoolTx=k.X7c;export const buildStellarProposeRevokeGovernanceRoleTx=k.Ubz;export const buildStellarProposeRevokeTokenTx=k.Dx4;export const buildStellarProposeSetAccumulatorTx=k.OAr;export const buildStellarProposeSetAggregatorTx=k.$Uh;export const buildStellarProposeSetMinBorrowCollatTx=k.obN;export const buildStellarProposeSetPositionLimitsTx=k.$lZ;export const buildStellarProposeSetPositionManagerTx=k.Kaw;export const buildStellarProposeSetPriceAggregatorTx=k.Wbk;export const buildStellarProposeSetSpokeLiquidationCurveTx=k.kwV;export const buildStellarProposeSetSwapAggregatorTx=k.qAI;export const buildStellarProposeTransferCtrlOwnershipTx=k.VSx;export const buildStellarProposeTransferGovOwnTx=k.HPG;export const buildStellarProposeUnpauseTx=k.xQk;export const buildStellarProposeUpdateDelayTx=k.YQw;export const buildStellarProposeUpgradeControllerTx=k.QY;export const buildStellarProposeUpgradePoolParamsTx=k.osR;export const buildStellarProposeUpgradePoolTx=k.Kob;export const buildStellarRenewAccountTx=k.IJt;export const buildStellarRepayBatchTx=k.nw5;export const buildStellarRepayDebtWithCollateralTx=k.PrA;export const buildStellarRepayTx=k.ZEf;export const buildStellarRevokeBlendPoolTx=k.X0W;export const buildStellarRevokeRoleTx=k.evz;export const buildStellarRevokeTokenTx=k.P8C;export const buildStellarSetAccumulatorTx=k.aVn;export const buildStellarSetAggregatorTx=k.p2b;export const buildStellarSetMarketOracleConfigTx=k.sVY;export const buildStellarSetOracleSanityBoundsTx=k.XDq;export const buildStellarSetOracleToleranceTx=k.Jsu;export const buildStellarSetOracleTx=k.W5;export const buildStellarSetPositionLimitsTx=k.Dyw;export const buildStellarSetPriceAggregatorTx=k._i2;export const buildStellarSetSpokeAssetFlagsTx=k.FZg;export const buildStellarSetSwapAggregatorTx=k.wGh;export const buildStellarSupplyBatchTx=k.Nix;export const buildStellarSupplyTx=k.v_o;export const buildStellarSwapCollateralTx=k.qDU;export const buildStellarSwapDebtTx=k.qRb;export const buildStellarTransferOwnershipTx=k.QJY;export const buildStellarUnpauseTx=k.bmW;export const buildStellarUpdateAccountThresholdTx=k.n_N;export const buildStellarUpdateIndexesTx=k.v87;export const buildStellarUpgradeControllerTx=k.qMI;export const buildStellarUpgradeLiquidityPoolParamsTx=k.gHX;export const buildStellarWithdrawBatchTx=k.O3p;export const buildStellarWithdrawTx=k.Gzh;export const buildTx=k.prJ;export const burnShares=k.moD;export const computeAccountRisk=k.y5S;export const decodeStellarLendingEvent=k.Fmy;export const decodeStellarLiquidateReturn=k.OBV;export const decodeStellarRouteBytes=k.aku;export const depositRateRay=k.HFl;export const divByIntHalfUp=k.cCk;export const encodeAssetOracle=k.Ft;export const encodeInterestRateModel=k.MB4;export const encodeMarketOracleConfigInput=k.Dnk;export const encodeMarketParamsRaw=k.pqp;export const encodePositionLimits=k.Q3w;export const encodePriceKey=k.Jh3;export const encodeStrategyPayloadToRouteXdr=k.wfs;export const extractEventOrder=k.UmN;export const getStellarAccountPositions=k.xO7;export const getStellarActiveUsersSeries=k.R11;export const getStellarAggregatorQuote=k.LwT;export const getStellarAsset=k.mMz;export const getStellarAssetGraph=k.iES;export const getStellarAssetMarkets=k.zpK;export const getStellarAssetPage=k.N3x;export const getStellarAssets=k.bNp;export const getStellarCampaignLeaderboard=k.T3v;export const getStellarCampaignMe=k.KQV;export const getStellarDefiLlamaDimensions=k.S9l;export const getStellarDeployment=k.rER;export const getStellarDetailedMarkets=k.XNg;export const getStellarFeeRevenueSeries=k.VeU;export const getStellarGovernanceProposals=k.T_r;export const getStellarHolderDistribution=k.m4Y;export const getStellarHub=k.XIn;export const getStellarHubGraph=k.Lt0;export const getStellarHubHolders=k.wsx;export const getStellarHubs=k.KKL;export const getStellarLendingContext=k.yl$;export const getStellarLendingLiveState=k.kqD;export const getStellarLiquidationsLeaderboard=k.dEm;export const getStellarLiquidationsSeries=k.bu4;export const getStellarParticipantCounts=k.ftY;export const getStellarPnlByScope=k.Ht0;export const getStellarPositionsLeaderboard=k.$uf;export const getStellarPositionsPnl=k.wqt;export const getStellarQuoteTokens=k.CHU;export const getStellarRateSpreadSeries=k.Wc$;export const getStellarReserve=k.Y5D;export const getStellarReserveGraph=k.KGs;export const getStellarReserveHolders=k.nWw;export const getStellarReserves=k.jFb;export const getStellarRevenueSeries=k.Pvd;export const getStellarSpoke=k.S2b;export const getStellarSpokeGraph=k.uSb;export const getStellarSpokeHolders=k.N9t;export const getStellarSpokes=k.bNM;export const getStellarStatsHistory=k.PvK;export const getStellarUserActivity=k.O5u;export const getStellarUserActivityPage=k.NYX;export const getStellarUserHistory=k.FCB;export const getStellarUserPositions=k.h_O;export const getStellarVolumeSeries=k.zu2;export const getStellarWalletBalance=k.Xix;export const liveIndexKey=k.C88;export const mapQuoteResponseToAggregatorSwap=k.LAw;export const mapQuoteResponseToStrategyPayload=k.E6J;export const mapQuoteResponseToStrategySwap=k.Dsj;export const mapSorobanError=k.XVZ;export const mapStellarPositionActivityType=k.CUR;export const maxBorrow=k.Kye;export const maxRepay=k.Q6F;export const maxSupply=k.SFb;export const maxWithdraw=k.tT6;export const mintShares=k.fBQ;export const mulDivCeil=k.LRi;export const mulDivFloor=k.M0l;export const mulDivHalfUp=k.sfH;export const numberToScaled=k.NFG;export const numberToWad=k.DGs;export const positionValueWad=k.BqG;export const prepareStellarBuiltTx=k.VxL;export const prepareStellarTxXdr=k.DLQ;export const projectAccountRisk=k.mbb;export const projectReserveApy=k.AuU;export const rayAprToApy=k.vCP;export const rayAprToNumber=k.w74;export const rayToNumber=k.JRY;export const rescaleCeil=k.BV_;export const rescaleFloor=k.ApP;export const rescaleHalfUp=k.Ei0;export const reserveKey=k.kQ9;export const resolveReserve=k.vp8;export const stellarAuthPolicyForInvocation=k.$y9;export const stellarLendingDispatchKey=k.ONb;export const stellarLendingRead=k.HhT;export const stellarNetworks=k.PF2;export const stellarTokenContractId=k.oze;export const syntheticEventOrder=k.oVm;export const tagStellarInvokedContractError=k.g57;export const toBase64Xdr=k.LaM;export const toBigInt=k.DgJ;export const toStellarPositionMode=k.Vuj;export const unscale=k.Ou3;export const unscaleBorrowCeil=k.kRY;export const unscaleHalfUp=k.W_e;export const unscaleSupplyFloor=k.Let;export const utilizationRay=k.TXb;export const valueBasePosition=k.shl;export const valueScaledPosition=k.TqQ;export const verifyStellarRouteBytes=k.BKn;export const wadToNumber=k.rWM;