@xoxno/sdk-js 1.0.218 → 1.0.219

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.
@@ -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,BASE_FEE as r,Contract as n,ScInt as o,TransactionBuilder as i,scValToNative as s,xdr as a}from"@stellar/stellar-sdk";var u={526(t,e){e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=a(t),s=i[0],u=i[1],l=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),c=0,p=u>0?s-4:s;for(r=0;r<p;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,a=0,u=n-o;a<u;a+=s)i.push(l(t,a,a+s>u?u:a+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function l(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),o.push(u(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},287(t,e,r){const n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=u,e.IS=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return p(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|m(t,e);let n=a(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(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 d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|h(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||J(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(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 p(t){return c(t),a(t<0?0:0|h(t))}function f(t){const e=t.length<0?0:0|h(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}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 m(t,e){if(u.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 r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(t).length;default:if(o)return n?-1:j(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return q(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let n=-1;for(i=r;i<a;i++)if(l(t,i)===l(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===u)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){let r=!0;for(let n=0;n<u;n++)if(l(t,i+n)!==l(e,n)){r=!1;break}if(r)return i}return-1}function v(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let s;for(n>i/2&&(n=i/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(J(n))return s;t[r+s]=n}return s}function B(t,e,r,n){return H(j(e,t.length-r),t,r,n)}function S(t,e,r,n){return H(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return H(G(e),t,r,n)}function I(t,e,r,n){return H(function(t,e){let r,n,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function q(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],a=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}u.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}}(),u.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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return l(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},u.allocUnsafe=function(t){return p(t)},u.allocUnsafeSlow=function(t){return p(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))o+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=m,u.prototype._isBuffer=!0,u.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)y(this,e,e+1);return this},u.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)y(this,e,e+3),y(this,e+1,e+2);return this},u.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)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?R(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.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===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(i,s),l=this.slice(n,o),c=t.slice(e,r);for(let t=0;t<a;++t)if(l[t]!==c[t]){i=l[t],s=c[t];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return B(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function k(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function E(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function A(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=Y[t[n]];return o}function U(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function T(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function $(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,o){z(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function P(t,e,r,n,o){z(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function W(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,i){return e=+e,r>>>=0,i||W(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||W(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||$(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||$(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);$(this,t,e,r,n-1,-n)}let o=0,i=1,s=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);$(this,t,e,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i|0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeBigInt64LE=Z((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=u.isBuffer(t)?t:u.from(t,n),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%s]}return this};const L={};function M(t,e,r){L[t]=class extends r{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 D(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function z(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new L.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){F(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,o,i)}function F(t,e){if("number"!=typeof t)throw new L.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw F(t,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),M("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),M("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function j(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function G(t){return n.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 H(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}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,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,l=u>>1,c=-7,p=r?o-1:0,f=r?-1:1,d=t[e+p];for(p+=f,i=d&(1<<-c)-1,d>>=-c,c+=a;c>0;i=256*i+t[e+p],p+=f,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+p],p+=f,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=l}return(d?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,l=8*i-o-1,c=(1<<l)-1,p=c>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,h=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+p>=1?f/u:f*Math.pow(2,1-p))*u>=2&&(s++,u/=2),s+p>=c?(a=0,s=c):s+p>=1?(a=(e*u-1)*Math.pow(2,o),s+=p):(a=e*Math.pow(2,p-1)*Math.pow(2,o),s=0));o>=8;t[r+d]=255&a,d+=h,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;t[r+d]=255&s,d+=h,s/=256,l-=8);t[r+d-h]|=128*m}},387(t,e,r){r.d(e,{GW:()=>i});var n,o=r(564);!function(t){t.MAINNET="1",t.DEVNET="D"}(n||(n={}));class i{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=n.MAINNET,apiUrl:r,...i}=t;this.apiUrl=r.trim().replace(/\/$/,""),this.chain=e,this.init=i,this.config=e==n.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:o.s0,FM_SC:o.ZZ,DR_SC:o.sM,KG_SC:o.KL,Staking_SC:o.V,Manager_SC:o.Rh,P2P_SC:o.EP}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:o.cM,FM_SC:o.ZZ,DR_SC:o.sM,KG_SC:o.KL,Staking_SC:o.J6,Manager_SC:o.Ff,P2P_SC:o.gx}}fetchWithTimeout=async(t,{params:e,...r}={})=>{const{next:n,cache:o,debug:i,timeout:s,...a}=this.init,{next:u,cache:l,debug:c,timeout:p,headers:f,method:d="GET",...h}=r,m=f?.Authorization,g="Bearer undefined"===m?void 0:m,y="GET"!==d&&"HEAD"!==d&&"PUT"!==d,w={...f,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...y?{"Content-Type":"application/json"}:{},...g?{Authorization:g}:{}},b=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("&"),v=`${this.apiUrl}${t}${b.length?`?${b}`:""}`,{revalidate:B,...S}=n??{},{revalidate:_,...I}=u??{},q="GET"!==d||g?void 0:_??B,R="GET"!==d||g||q?void 0:l??o,x=h.body,k=p??s??(null==x?3e4:0),E=k>0?AbortSignal.timeout(k):void 0,A=h.signal??a.signal,U=E&&A?AbortSignal.any([A,E]):E??A,T={...a,...h,method:d,...Object.keys(w).length?{headers:w}:{},...U?{signal:U}:{},cache:R,next:{...S,...I,revalidate:q}};(c??i)&&console.debug("SDK fetch: ",v,T);const $=await fetch(v,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${v}: ${t.message}`),{cause:t});throw t})),C=await $.text();if(!$.ok){let t;try{t=JSON.parse(C)}catch{t={message:C}}const e=[v,$.status,$.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(C)}catch{return C}}}},564(t,e,r){r.d(e,{EP:()=>l,Ff:()=>f,J6:()=>p,KL:()=>s,Rh:()=>u,V:()=>a,ZZ:()=>o,cM:()=>c,gx:()=>d,s0:()=>n,sM:()=>i});const n="erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",o="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",i="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",s="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",a="erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",u="erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",l="erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6",c="erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",p="erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",f="erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",d="erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}},l={};function c(t){var e=l[t];if(void 0!==e)return e.exports;var r=l[t]={exports:{}};return u[t](r,r.exports,c),r.exports}c.d=(t,e)=>{for(var r in e)c.o(e,r)&&!c.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},c.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var p=c(387);const f={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",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",aggregatorRouter:"CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5",governance:"CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ",priceAggregator:"CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP",positionNftContract:"CDVN5JU675MEDPVRPCYC45AHFC275UH57WEU5OTFE4WFGZBNN7HTLPSY"}},d=f;function h(t){return f["testnet"===t?"stellarTestnet":"stellarMainnet"]}const m={mainnet:f.stellarMainnet.passphrase,testnet:f.stellarTestnet.passphrase};var g=c(287);const y=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],w={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},b=1e6,v=t=>new e(t).toScVal(),B=t=>new o(t).toI128(),S=t=>a.ScVal.scvU32(t),_=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 o("string"==typeof t?t:t.toString()).toU64()},I=t=>a.ScVal.scvBool(t),q=t=>a.ScVal.scvString(t),R=t=>a.ScVal.scvSymbol(t),x=()=>a.ScVal.scvVoid(),k=t=>a.ScVal.scvVec(t),E=(t,e=32)=>{const r=t.startsWith("0x")?t.slice(2):t,n=g.hp.from(r,"hex");if(n.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${n.length} bytes from "${t}")`);return a.ScVal.scvBytes(n)},A=(t,e)=>null==t?x():e(t),U=(t,e)=>P({asset:v(e),hub_id:S(t)}),T=(t,e,r)=>a.ScVal.scvVec([U(t,e),B(r)]),$=t=>a.ScVal.scvVec(t.map((t=>T(t.hubId,t.asset,t.amount)))),C=t=>{if("Transfer"===t)return k([R("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 k([R("Credit"),_(e)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(t)}`)},P=t=>{const e=Object.keys(t).sort().map((e=>new a.ScMapEntry({key:R(e),val:t[e]})));return a.ScVal.scvMap(e)};class W{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>b)throw new Error(`Stellar builder: split weight ${t} outside 1..=1000000`);return this.weights.push(t),this.weights.length-1}emit(t,e,r,n,o){this.ops.push([t,e,r,n,o])}emitPath(t,e){t.hops.forEach(((r,n)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const o=t.hops[n-1];if(o&&r.tokenIn!==o.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(w[r.venue],0===n?e:1,this.asset(r.pool),this.asset(r.tokenIn),this.asset(r.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),r=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(r[t])continue;const n=e[t].hops[0]?.tokenIn,o=[];for(let r=t;r<e.length;r+=1)e[r].hops[0]?.tokenIn===n&&o.push(r);const i=o.reduce(((t,r)=>t+e[r].splitPpm),0);if(i>b)throw new Error(`Stellar builder: split weights for one token sum to ${i}, above 1000000`);const s=i===b;let a=b;o.forEach(((t,n)=>{r[t]=!0;const i=e[t];let u;if(n+1===o.length&&s)u=0;else{if(0===a)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(i.splitPpm*b/a);a-=Math.min(i.splitPpm,a),u=128+this.weight(t)}this.emitPath(i,u)}))}}toBytes(t,e,r){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 n=[1,t,e,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,this.ops.length,this.weights.length];for(const t of this.ops)n.push(...t);for(const t of this.weights)n.push(t>>>16&255,t>>>8&255,255&t);return g.hp.from(n)}get assetList(){return this.assets}get amountList(){return this.amounts}}const O=t=>{const e=new W(t.totalMinOut),r=e.asset(t.tokenIn),n=e.asset(t.tokenOut);if(r===n)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const n=e.asset(t.burnPool),o=e.amountList.length;for(const r of t.burnMinAmounts??[])e.amount(r);e.emit(5,0,n,r,o)}if(e.lowerPaths(t.paths),t.mintPool){const r=t.preSwapAmount;if(r&&BigInt(r)>0n){const n=t.mintPoolTokens;if(!n||2!==n.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[o,i]=n,[s,a]=t.preSwapFromA?[o,i]:[i,o];e.emit(w.Aquarius,2+e.amount(r),e.asset(t.mintPool),e.asset(s),e.asset(a))}e.emit(6,0,e.asset(t.mintPool),n,e.amount(t.mintMinShares??"1"))}const o=Number(t.referralId??0);if(!Number.isInteger(o)||o<0||o>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return P({amounts:a.ScVal.scvVec(e.amountList.map((t=>B(t)))),assets:a.ScVal.scvVec(e.assetList.map((t=>v(t)))),ops:a.ScVal.scvBytes(e.toBytes(r,n,o))})},N=t=>{const e=g.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 a.ScVal.scvBytes(e)},L=()=>a.ScVal.scvBytes(g.hp.alloc(0)),M=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((r=t).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return g.hp.from(t,"hex")}var r;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 n=g.hp.from(e,"base64");if(0===n.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return n},D=t=>{if("string"==typeof t)return N(M(t));if(t instanceof Uint8Array)return 0===t.length?L():N(t);if(t&&"object"==typeof t)return"routeXdr"in(r=t)&&"string"==typeof r.routeXdr?N(M(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?N(M(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?N(M(t.bytes)):0===t.bytes.length?L():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 r=new Map;for(const[t,n]of e.paths.entries()){if(!n||"number"!=typeof n.splitPpm||n.splitPpm<=0||!Array.isArray(n.hops)||0===n.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,r]of n.hops.entries())if(!r||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!y.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=n.hops[0];r.set(e.tokenIn,(r.get(e.tokenIn)??0)+n.splitPpm)}for(const[t,n]of r){if(n>b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${n}, above 1000000`);if(!e.mintPool&&n!==b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${n}`)}return e})(t),a.ScVal.scvBytes(g.hp.from(O(e).toXDR("base64"),"base64")));var e,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},z=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,r=g.hp.from(e,"hex");return a.ScVal.scvBytes(r)})(t);if(t instanceof Uint8Array)return a.ScVal.scvBytes(g.hp.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function F(e,o,s){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const a=new n(e.controllerAddress),u=new t(e.caller,e.sourceSequence);return{xdr:new i(u,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(a.call(o,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function V(t){if(!Number.isInteger(t)||t<1||t>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return S(t)}function X(t,e){const r=e.accountNonce??0;return F(t,"supply",[v(t.caller),_(r),V(e.spokeId),$([...e.assets])])}function j(t,e){return X(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function G(t,e){return F(t,"borrow",[v(t.caller),_(e.accountNonce),$([...e.borrows]),A(e.to,v)])}function H(t,e){return G(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function K(t,e){return F(t,"withdraw",[v(t.caller),_(e.accountNonce),$([...e.withdrawals]),A(e.to,v)])}function J(t,e){return K(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Y(t,e){return F(t,"repay",[v(t.caller),_(e.accountNonce),$([...e.payments])])}function Z(t,e){return Y(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function Q(t,e){return F(t,"liquidate",[v(t.caller),_(e.accountNonce),$([...e.debtPayments]),C(e.seizeMode??"Transfer")])}function tt(t){const e=s(a.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 et(t,e){return F(t,"flash_loan",[v(t.caller),U(e.hubId,e.asset),B(e.amount),v(e.receiver),z(e.data)])}function rt(t,e){return F(t,"migrate_from_blend",[v(t.caller),_(e.accountId),V(e.spokeId),S(e.hubId),v(e.blendPool),k(e.collateralTokens.map(v)),k(e.supplyTokens.map(v)),(r=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),a.ScVal.scvVec(r.map((t=>{return e=t.token,r=t.amount,a.ScVal.scvVec([v(e),B(r)]);var e,r}))))]);var r}function nt(t,e){const r=e.accountNonce??0;return F(t,"multiply",[v(t.caller),_(r),V(e.spokeId),U(e.collateral.hubId,e.collateral.asset),B(e.debtToFlashLoan),U(e.debt.hubId,e.debt.asset),S(e.mode),D(e.steps),A(e.initialPayment,(t=>T(t.hubId,t.asset,t.amount))),A(e.convertSwap,D)])}function ot(t,e){return F(t,"swap_debt",[v(t.caller),_(e.accountNonce),U(e.existingDebt.hubId,e.existingDebt.asset),B(e.newDebtAmount),U(e.newDebt.hubId,e.newDebt.asset),D(e.steps)])}function it(t,e){return F(t,"swap_collateral",[v(t.caller),_(e.accountNonce),U(e.current.hubId,e.current.asset),B(e.fromAmount),U(e.newCollateral.hubId,e.newCollateral.asset),D(e.steps)])}function st(t,e){return F(t,"repay_debt_with_collateral",[v(t.caller),_(e.accountNonce),U(e.collateral.hubId,e.collateral.asset),B(e.collateralAmount),U(e.debt.hubId,e.debt.asset),D(e.steps),I(e.closePosition)])}const at="/stellar-lending",ut=encodeURIComponent,lt=(t,e)=>t.fetchWithTimeout(`${at}/context`,e),ct=(t,e)=>t.fetchWithTimeout(`${at}/live-state`,e),pt=(t,e)=>t.fetchWithTimeout(`${at}/markets/detailed`,e),ft=(t,e)=>t.fetchWithTimeout(`${at}/assets`,e),dt=(t,e)=>t.fetchWithTimeout(`${at}/hubs`,e),ht=(t,e)=>t.fetchWithTimeout(`${at}/spokes`,e),mt=(t,e={},r)=>t.fetchWithTimeout(`${at}/reserves`,{...r,params:{...e}}),gt=(t,e,r,n,o)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(n)}`,o),yt=(t,e,r)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}`,r),wt=(t,e,r)=>t.fetchWithTimeout(`${at}/hubs/${e}`,r),bt=(t,e,r)=>t.fetchWithTimeout(`${at}/spokes/${e}`,r),vt=(t,e,r)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/positions`,r),Bt=(t,e,r)=>t.fetchWithTimeout(`${at}/accounts/${ut(e)}/positions`,r),St=(t,e,r,n)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/assets/${ut(r)}/balance`,n),_t=(t,e,r,n)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/page`,{...n,params:{...r}}),It=(t,e,r,n)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/markets`,{...n,params:{side:r}}),qt=(t,e,r,n,o,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(n)}/holders`,{...i,params:{side:o}}),Rt=(t,e,r,n)=>t.fetchWithTimeout(`${at}/hubs/${e}/holders`,{...n,params:{side:r}}),xt=(t,e,r,n)=>t.fetchWithTimeout(`${at}/spokes/${e}/holders`,{...n,params:{side:r}}),kt=(t,e,r,n)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/graph`,{...n,params:{...r}}),Et=(t,e,r,n)=>t.fetchWithTimeout(`${at}/hubs/${e}/graph`,{...n,params:{...r}}),At=(t,e,r,n)=>t.fetchWithTimeout(`${at}/spokes/${e}/graph`,{...n,params:{...r}}),Ut=(t,e,r,n,o,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(n)}/graph`,{...i,params:{...o}}),Tt=(t,e,r={},n)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity`,{...n,params:{...r}}),$t=(t,e,r={},n)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity/page`,{...n,params:{...r}}),Ct=(t,e={},r)=>t.fetchWithTimeout(`${at}/governance/proposals`,{...r,params:{...e}}),Pt=(t,e={},r)=>t.fetchWithTimeout(`${at}/positions`,{...r,params:{...e}}),Wt=(t,e={},r)=>t.fetchWithTimeout(`${at}/participants`,{...r,params:{...e}}),Ot=(t,e={},r)=>t.fetchWithTimeout(`${at}/liquidations/leaderboard`,{...r,params:{...e}}),Nt=(t,e={},r)=>t.fetchWithTimeout(`${at}/distribution`,{...r,params:{...e}}),Lt=(t,e={},r)=>t.fetchWithTimeout(`${at}/campaign/leaderboard`,{...r,params:{...e}}),Mt=(t,e,r)=>t.fetchWithTimeout(`${at}/stats/history`,{...r,params:{...e}}),Dt=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue`,{...r,params:{...e}}),zt=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue/fees`,{...r,params:{...e}}),Ft=(t,e,r)=>t.fetchWithTimeout(`${at}/liquidations`,{...r,params:{...e}}),Vt=(t,e,r)=>t.fetchWithTimeout(`${at}/volume`,{...r,params:{...e}}),Xt=(t,e,r)=>t.fetchWithTimeout(`${at}/active-users`,{...r,params:{...e}}),jt=(t,e,r)=>t.fetchWithTimeout(`${at}/rate-spread`,{...r,params:{...e}}),Gt=(t,e,r)=>t.fetchWithTimeout(`${at}/defillama`,{...r,params:{...e}}),Ht=(t,e,r,n)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/history`,{...n,params:{...r}}),Kt=(t,e,r)=>t.fetchWithTimeout(`${at}/pnl`,{...r,params:{accountId:e}}),Jt=(t,e,r)=>t.fetchWithTimeout(`${at}/pnl/scope`,{...r,params:{scope:e}}),Yt=(t,e,r)=>t.fetchWithTimeout(`${at}/campaign/me`,{...r,params:{owner:e}}),Zt=t=>({context:e=>lt(t,e),liveState:e=>ct(t,e),marketsDetailed:e=>pt(t,e),assets:e=>ft(t,e),hubs:e=>dt(t,e),spokes:e=>ht(t,e),reserves:(e={},r)=>void 0!==r||"hubId"in e||"spokeId"in e||"asset"in e?mt(t,e,r):mt(t,{},e),reserve:(e,r,n,o)=>gt(t,e,r,n,o),asset:(e,r)=>yt(t,e,r),hub:(e,r)=>wt(t,e,r),spoke:(e,r)=>bt(t,e,r),userPositions:(e,r)=>vt(t,e,r),accountPositions:(e,r)=>Bt(t,e,r),walletBalance:(e,r,n)=>St(t,e,r,n),assetPage:(e,r,n)=>_t(t,e,r,n),assetMarkets:(e,r,n)=>It(t,e,r,n),reserveHolders:(e,r,n,o,i)=>qt(t,e,r,n,o,i),hubHolders:(e,r,n)=>Rt(t,e,r,n),spokeHolders:(e,r,n)=>xt(t,e,r,n),assetGraph:(e,r,n)=>kt(t,e,r,n),hubGraph:(e,r,n)=>Et(t,e,r,n),spokeGraph:(e,r,n)=>At(t,e,r,n),reserveGraph:(e,r,n,o,i)=>Ut(t,e,r,n,o,i),userActivity:(e,r={},n)=>Tt(t,e,r,n),userActivityPage:(e,r={},n)=>$t(t,e,r,n),governanceProposals:(e={},r)=>Ct(t,e,r),positionsLeaderboard:(e={},r)=>Pt(t,e,r),participants:(e={},r)=>Wt(t,e,r),liquidationsLeaderboard:(e={},r)=>Ot(t,e,r),distribution:(e={},r)=>Nt(t,e,r),campaignLeaderboard:(e={},r)=>Lt(t,e,r),statsHistory:(e,r)=>Mt(t,e,r),revenue:(e,r)=>Dt(t,e,r),feeRevenue:(e,r)=>zt(t,e,r),liquidations:(e,r)=>Ft(t,e,r),volume:(e,r)=>Vt(t,e,r),activeUsers:(e,r)=>Xt(t,e,r),rateSpread:(e,r)=>jt(t,e,r),defillama:(e,r)=>Gt(t,e,r),userHistory:(e,r,n)=>Ht(t,e,r,n),positionsPnl:(e,r)=>Kt(t,e,r),pnlByScope:(e,r)=>Jt(t,e,r),campaignMe:(e,r)=>Yt(t,e,r)}),Qt=t=>P({base_borrow_rate:B(t.baseBorrowRateRay),max_borrow_rate:B(t.maxBorrowRateRay),max_utilization:B(t.maxUtilizationRay),mid_utilization:B(t.midUtilizationRay),optimal_utilization:B(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:B(t.slope1Ray),slope2:B(t.slope2Ray),slope3:B(t.slope3Ray)}),te=t=>P({asset_decimals:S(t.assetDecimals),asset_id:v(t.assetId),base_borrow_rate:B(t.baseBorrowRateRay),flashloan_fee:S(t.flashloanFeeBps),is_flashloanable:I(t.isFlashloanable),max_borrow_rate:B(t.maxBorrowRateRay),max_utilization:B(t.maxUtilizationRay),mid_utilization:B(t.midUtilizationRay),optimal_utilization:B(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:B(t.slope1Ray),slope2:B(t.slope2Ray),slope3:B(t.slope3Ray)}),ee=t=>P({max_borrow_positions:S(t.maxBorrowPositions),max_supply_positions:S(t.maxSupplyPositions)}),re=t=>{if("Token"in t&&t.Token)return k([R("Token"),v(t.Token)]);if("Ref"in t&&t.Ref)return k([R("Ref"),R(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},ne=t=>{if("Stellar"in t)return k([R("Stellar"),v(t.Stellar)]);if("Symbol"in t)return k([R("Symbol"),R(t.Symbol)]);if("String"in t)return k([R("String"),q(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},oe=t=>{if("Spot"===t)return k([R("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return k([R("Twap"),S(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},ie=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return k([R(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},se=t=>{if("Market"===t||"Fundamental"===t)return k([R(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},ae=t=>{if("Reflector"in t){const e=t.Reflector;return k([R("Reflector"),P({asset:ne(e.asset),contract:v(e.contract),read_mode:oe(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return k([R("MultiFeed"),P({contract:v(e.contract),feed_id:q(e.feedId),kind:ie(e.kind),nature:se(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},ue=t=>{const e=t;return P({decimals:S(e.decimals),max_stale_seconds:_(e.maxStaleSeconds),provider:ae(e.provider)})},le=t=>{if("RequireDisjoint"===t)return k([R("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return k([R("AllowShared"),k(e.map((t=>P({contract:v(t.contract),kind:ie(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},ce=t=>{const e=t,r=e.sources??[];let n,o;if("number"==typeof e.toleranceBps)n=1e4+e.toleranceBps,o=Math.max(1,Math.floor(1e8/n));else{const t=e.tolerance??{};n=Number(t.upperRatioBps),o=Number(t.lowerRatioBps)}return P({asset_decimals:S(Number(e.assetDecimals)),independence:le(e.independence),max_price_stale_seconds:_(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:B(String(e.maxSanityPriceWad)),min_sanity_price_wad:B(String(e.minSanityPriceWad)),sources:k(r.map((t=>(t=>{if("Feed"in t)return k([R("Feed"),ue(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return k([R("Scaled"),P({factor:ue(e.factor),max_factor_wad:B(e.maxFactorWad),min_factor_wad:B(e.minFactorWad),quote:re(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return k([R("LpShare"),P({key_a:re(e.keyA),key_b:re(e.keyB),kind:k([R(e.kind||"ConstantProduct")]),pool:v(e.pool),reserve_a_decimals:S(e.reserveADecimals),reserve_b_decimals:S(e.reserveBDecimals),share_decimals:S(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:P({lower_ratio_bps:S(o),upper_ratio_bps:S(n)})})},pe=ce;function fe(t,e){return F(t,"upgrade",[E(e.wasmHash)])}function de(t,e){return F(t,"migrate",[S(e.newVersion)])}function he(t){return F(t,"pause",[])}function me(t){return F(t,"unpause",[])}function ge(t,e){return F(t,"grant_role",[v(e.account),R(e.role)])}function ye(t,e){return F(t,"revoke_role",[v(e.account),R(e.role)])}function we(t,e){return F(t,"transfer_ownership",[v(e.newOwner),S(e.liveUntilLedger)])}function be(t){return F(t,"accept_ownership",[])}function ve(t,e){return F(t,"set_swap_aggregator",[v(e.aggregator)])}function Be(t,e){return F(t,"set_price_aggregator",[v(e.aggregator)])}const Se=ve;function _e(t,e){return F(t,"set_accumulator",[v(e.accumulator)])}function Ie(t,e){return F(t,"set_position_limits",[ee(e)])}function qe(t,e){return F(t,"approve_blend_pool",[v(e.pool)])}function Re(t,e){return F(t,"revoke_blend_pool",[v(e.pool)])}const xe=qe,ke=Re;function Ee(t,e){return F(t,"set_oracle",[re(e.key),ce(e.oracle)])}const Ae=Ee;function Ue(t,e){const r=e.toleranceBps,n=e.upperRatioBps??1e4+r,o=e.lowerRatioBps??Math.max(1,Math.floor(1e8/n));return F(t,"set_tolerance",[re(e.key),P({lower_ratio_bps:S(o),upper_ratio_bps:S(n)})])}function Te(t,e){return F(t,"set_spoke_asset_flags",[S(e.spokeId),U(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function $e(t,e){return F(t,"set_oracle_sanity_bounds",[v(e.asset),B(e.minPriceWad),B(e.maxPriceWad)])}function Ce(t,e){return F(t,"update_indexes",[v(t.caller),k(e.assets.map((t=>U(t.hubId,t.asset))))])}function Pe(t,e){return F(t,"renew_account",[v(t.caller),_(e.accountNonce)])}function We(t,e){return F(t,"create_liquidity_pool",[S(e.hubId),v(e.asset),te(e.params)])}function Oe(t,e){return F(t,"upgrade_liquidity_pool_params",[U(e.hubId,e.asset),Qt(e.params)])}function Ne(t,e){return F(t,"claim_revenue",[v(t.caller),k(e.assets.map((t=>U(t.hubId,t.asset))))])}function Le(t,e){return F(t,"add_rewards",[v(t.caller),$(e.rewards)])}function Me(t,e){return F(t,"update_account_threshold",[v(t.caller),I(e.hasRisks),k(e.accountNonces.map((t=>_(t))))])}const De="00".repeat(32),ze=t=>{if("string"==typeof t)return E(t);const e=g.hp.from(t);if(32!==e.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${e.length} bytes)`);return a.ScVal.scvBytes(e)},Fe=(t,...e)=>k([R(t),...e]),Ve=t=>P({new_owner:v(t.newOwner),live_until_ledger:S(t.liveUntilLedger)}),Xe=t=>P({asset:v(t.asset),bonus:S(t.bonus),borrow_cap:B(t.borrowCap),can_borrow:I(t.canBorrow),can_collateral:I(t.canCollateral),frozen:I(t.frozen),hub_id:S(t.hubId),paused:I(t.paused),liquidation_fees:S(t.liquidationFees),ltv:S(t.ltv),no_seize:I(t.noSeize),spoke_id:S(t.spokeId),supply_cap:B(t.supplyCap),threshold:S(t.threshold)}),je=t=>P({account:v(t.account),role:R(t.role)});function Ge(e,o,s){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const a=new n(e.governanceAddress),u=new t(e.caller,e.sourceSequence);return{xdr:new i(u,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(a.call(o,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const He=(t,e,r)=>Ge(t,"propose",[v(t.caller),e,ze(r)]),Ke=(t,e,r)=>Ge(t,"execute_self",[x(),e,ze(r)]);function Je(t,e,r){return He(t,Fe("SetSwapAggregator",v(e.aggregator)),r)}function Ye(t,e,r){return He(t,Fe("SetPriceAggregator",v(e.aggregator)),r)}const Ze=Je;function Qe(t,e,r){return He(t,Fe("SetAccumulator",v(e.accumulator)),r)}function tr(t,e,r){return He(t,Fe("SetPositionLimits",ee(e)),r)}function er(t,e){return He(t,Fe("CreateHub"),e)}function rr(t,e){return He(t,Fe("AddSpoke"),e)}function nr(t,e,r){return He(t,Fe("RemoveSpoke",S(e.spokeId)),r)}function or(t,e,r){return He(t,Fe("AddAssetToSpoke",Xe(e)),r)}function ir(t,e,r){return He(t,Fe("EditAssetInSpoke",Xe(e)),r)}function sr(t,e,r){return He(t,Fe("RemoveAssetFromSpoke",P({hub_asset:U((n=e).hubId,n.asset),spoke_id:S(n.spokeId)})),r);var n}function ar(t,e,r){return He(t,Fe("SetSpokeLiquidationCurve",P({hf_for_max_bonus_wad:B((n=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:S(n.liquidationBonusFactorBps),spoke_id:S(n.spokeId),target_hf_wad:B(n.targetHfWad)})),r);var n}function ur(t,e,r){return He(t,Fe("SetPositionManager",v(e.manager),I(e.isActive)),r)}function lr(t,e,r){return He(t,Fe("SetMinBorrowCollateralUsd",B(e.floorWad)),r)}function cr(t,e,r){return He(t,Fe("ApproveToken",v(e.token)),r)}function pr(t,e,r){return He(t,Fe("RevokeToken",v(e.token)),r)}function fr(t,e,r){return He(t,Fe("ApproveBlendPool",v(e.pool)),r)}function dr(t,e,r){return He(t,Fe("RevokeBlendPool",v(e.pool)),r)}function hr(t,e,r){return He(t,Fe("CreateLiquidityPool",P({asset:v((n=e).asset),hub_id:S(n.hubId),params:te(n.params)})),r);var n}function mr(t,e,r){return He(t,Fe("UpgradeLiquidityPoolParams",P({hub_asset:U((n=e).hubId,n.asset),params:Qt(n.params)})),r);var n}function gr(t,e,r){return He(t,Fe("DeployPool",E(e.wasmHash)),r)}function yr(t,e,r){return He(t,Fe("UpgradePool",E(e.wasmHash)),r)}function wr(t,e,r){return He(t,Fe("UpgradeController",E(e.wasmHash)),r)}function br(t,e,r){return He(t,Fe("MigrateController",S(e.newVersion)),r)}function vr(t,e,r){return He(t,Fe("TransferCtrlOwnership",Ve(e)),r)}function Br(t,e,r){return He(t,Fe("ConfigureAssetOracle",P({key:re((n=e).key),oracle:ce(n.oracle)})),r);var n}const Sr=Br;function _r(t,e,r){return He(t,Fe("EditOracleTolerance",P({key:re((n=e).key),tolerance:S(n.tolerance)})),r);var n}function Ir(t,e,r){return He(t,Fe("UpgradeGov",E(e.wasmHash)),r)}function qr(t,e,r){return He(t,Fe("UpdateGovDelay",S(e.newDelay)),r)}function Rr(t,e,r){return He(t,Fe("GrantGovRole",je(e)),r)}function xr(t,e,r){return He(t,Fe("RevokeGovRole",je(e)),r)}function kr(t,e,r){return He(t,Fe("TransferGovOwnership",Ve(e)),r)}function Er(t,e){const r=k(e.argsXdr.map((t=>a.ScVal.fromXDR(t,"base64")))),n=ze(e.predecessor??De);return Ge(t,"execute",[x(),v(e.target),R(e.functionName),r,n,ze(e.salt)])}function Ar(t,e,r){return Ke(t,Fe("UpgradeGov",E(e.wasmHash)),r)}function Ur(t,e,r){return Ke(t,Fe("UpdateGovDelay",S(e.newDelay)),r)}function Tr(t,e,r){return Ke(t,Fe("GrantGovRole",je(e)),r)}function $r(t,e,r){return Ke(t,Fe("RevokeGovRole",je(e)),r)}function Cr(t,e,r){return Ke(t,Fe("TransferGovOwnership",Ve(e)),r)}const Pr=t=>k(t.map(v));function Wr(t,e,r){return Ge(t,"propose_canceller_reset",[Pr(e.newCancellers),ze(r)])}function Or(t,e,r){return Ge(t,"execute_canceller_reset",[A(e.executor,v),Pr(e.newCancellers),ze(r)])}function Nr(t,e){return Ge(t,"set_spoke_asset_flags",[v(t.caller),S(e.spokeId),U(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function Lr(t,e){return Ge(t,"set_oracle_sanity_bounds",[v(t.caller),v(e.asset),B(e.minPriceWad),B(e.maxPriceWad)])}function Mr(t){return Ge(t,"create_hub",[v(t.caller)])}function Dr(t){return Ge(t,"add_spoke",[v(t.caller)])}function zr(t,e){return Ge(t,"revoke_role_immediate",[v(e.account),R(e.role)])}function Fr(t){return Ge(t,"pause",[v(t.caller)])}function Vr(t,e){return He(t,Fe("Unpause"),e)}const Xr=t=>t.toXDR("base64"),jr=t=>a.ScVal.fromXDR(t,"base64"),Gr=t=>t.map((t=>String(s(jr(t))))).join(":"),Hr=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),Kr=t=>Number(t),Jr=t=>String(t),Yr=t=>t instanceof Uint8Array?g.hp.from(t).toString("hex"):g.hp.isBuffer(t)?t.toString("hex"):String(t),Zr=["None","Multiply","Long","Short"],Qr=["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"],tn=t=>Array.isArray(t)?t:[],en=(t,e)=>{const r="Borrow"===e;return{action:(n=t[0],Qr[Kr(n)]??Hr(n)),positionType:e,hubId:Kr(t[1]),asset:Jr(t[2]),scaledAmountRay:Hr(t[3]),indexRay:Hr(t[4]),amount:Hr(t[5]),liquidationThresholdBps:r?void 0:Kr(t[6]),liquidationBonusBps:r?void 0:Kr(t[7]),loanToValueBps:r?void 0:Kr(t[8]),liquidationFeesBps:r?void 0:Kr(t[9])};var n},rn=t=>{return{owner:Jr(t[0]),spokeId:Kr(t[1]),mode:(e=t[2],Zr[Kr(e)]??"None")};var e},nn=t=>Array.isArray(t)?t[1]:void 0,on=t=>{const e=(r=t,Array.isArray(r)?Jr(r[0]):Jr(r));var r;if("Token"===e)return{Token:Jr(nn(t))};if("Ref"===e)return{Ref:Jr(nn(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:Jr(e.Token)};if(void 0!==e.Ref)return{Ref:Jr(e.Ref)}}return{Token:Jr(t)}},sn=t=>{const e=t.tolerance??{};return{assetDecimals:Kr(t.asset_decimals),maxPriceStaleSeconds:Kr(t.max_price_stale_seconds),sources:tn(t.sources).map((t=>t)),tolerance:{upperRatio:Kr(e.upper_ratio_bps),lowerRatio:Kr(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:Hr(t.min_sanity_price_wad),maxSanityPriceWad:Hr(t.max_sanity_price_wad)}},an={"market:create":t=>({topic:"market:create",data:{hubId:Kr(t.hub_id),baseAsset:Jr(t.base_asset),maxBorrowRate:Hr(t.max_borrow_rate),baseBorrowRate:Hr(t.base_borrow_rate),slope1:Hr(t.slope1),slope2:Hr(t.slope2),slope3:Hr(t.slope3),midUtilization:Hr(t.mid_utilization),optimalUtilization:Hr(t.optimal_utilization),maxUtilization:Hr(t.max_utilization),reserveFactor:Kr(t.reserve_factor),marketAddress:Jr(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:Jr(t.asset),maxBorrowRateRay:Hr(t.max_borrow_rate),baseBorrowRateRay:Hr(t.base_borrow_rate),slope1Ray:Hr(t.slope1),slope2Ray:Hr(t.slope2),slope3Ray:Hr(t.slope3),midUtilizationRay:Hr(t.mid_utilization),optimalUtilizationRay:Hr(t.optimal_utilization),maxUtilizationRay:Hr(t.max_utilization),reserveFactorBps:Kr(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:tn(t).map((t=>{return e=tn(t),{hubId:Kr(e[0]),asset:Jr(e[1]),timestamp:Kr(e[2]),supplyIndexRay:Hr(e[3]),borrowIndexRay:Hr(e[4]),cash:Hr(e[5]),suppliedRay:Hr(e[6]),borrowedRay:Hr(e[7]),revenueRay:Hr(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:tn(t).map((t=>{const e=t;return{hubId:Kr(e.hub_id),asset:Jr(e.asset),params:(r=e.params,{maxBorrowRateRay:Hr(r.max_borrow_rate),baseBorrowRateRay:Hr(r.base_borrow_rate),slope1Ray:Hr(r.slope1),slope2Ray:Hr(r.slope2),slope3Ray:Hr(r.slope3),midUtilizationRay:Hr(r.mid_utilization),optimalUtilizationRay:Hr(r.optimal_utilization),maxUtilizationRay:Hr(r.max_utilization),reserveFactorBps:Kr(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:Kr(r.flashloan_fee),assetId:Jr(r.asset_id),assetDecimals:Kr(r.asset_decimals)})};var r}))}}),"position:batch_update":t=>{const e=tn(t);return{topic:"position:batch_update",data:{accountId:Hr(e[0]),accountAttributes:rn(tn(e[1])),updates:[...tn(e[2]).map((t=>en(tn(t),"Deposit"))),...tn(e[3]).map((t=>en(tn(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:Kr(t.hub_id),asset:Jr(t.asset),receiver:Jr(t.receiver),caller:Jr(t.caller),amount:Hr(t.amount),fee:Hr(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:on(t.key),oracle:sn(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:Jr(t.asset),oracle:sn(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:Jr(t.liquidator),accountId:Hr(t.account_id),repaidUsdWad:Hr(t.repaid_usd_wad),bonusBps:Hr(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:Hr(t.account_id),totalBorrowUsdWad:Hr(t.total_borrow_usd_wad),totalCollateralUsdWad:Hr(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:Jr(t.token),amount:Hr(t.amount),usdValueWad:Hr(t.usd_value_wad),accountId:Hr(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:Kr(t.hub_id),asset:Jr(t.asset),amount:Hr(t.amount),fee:Hr(t.fee),amountSent:Hr(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:Jr(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:Yr(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:Jr(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:Jr(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:Jr(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:Jr(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:Yr(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:Kr(t.max_supply_positions),maxBorrowPositions:Kr(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Hr(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:Jr(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:Kr(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:Hr(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Hr(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:Kr(e.liquidation_bonus_factor_bps)}}}},un=Object.freeze(Object.keys(an));function ln(t,e){const r=Gr(t),n=an[r];return n?n(s(jr(e))):null}const cn=1e4;function pn(t,e){return`${t}-${BigInt(e).toString(10)}`}function fn(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function dn(t,e=0){return 1e4*t+e}function hn(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 mn=(t,e,r)=>{const n=new URL(e,t.endsWith("/")?t:`${t}/`);if(r)for(const[t,e]of Object.entries(r))void 0!==e&&n.searchParams.set(t,String(e));return n.toString()};async function gn(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 r=mn(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}),n=await fetch(r,e.fetchOptions);if(!n.ok){const t=await n.text().catch((()=>""));throw new Error(`Stellar quote server responded ${n.status} ${n.statusText} for ${r} — ${t}`)}return await n.json()}async function yn(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=mn(t.baseUrl,"api/v1/tokens"),r=await fetch(e,t.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${e} — ${t}`)}return await r.json()}const wn=(t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t,bn=t=>O(t).toXDR("base64");function vn(e,o){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const s=new n(e.routerAddress),a=new t(e.caller,e.sourceSequence),u=D(wn(o,e.referralId));return{xdr:new i(a,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(s.call("execute_strategy",v(e.caller),B(e.totalIn),u)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Bn(t,e){return vn(t,e)}function Sn(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(qn),splitPpm:t.splitPpm}))):[{hops:t.hops.map(qn),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function _n(t,e={}){const r=t;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:Sn(t,e)}const In=Sn,qn=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Rn(t,e){const r=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${r}`)}async function xn(t,e,r){const n=i.fromXDR(e,r?.network?m[r.network]:"");try{return(await t.prepareTransaction(n)).toXDR()}catch(t){if(r?.invokedContractId)throw Rn(r.invokedContractId,t);throw t}}async function kn(t,e,r){return xn(t,e.xdr,r)}function En(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 An(t,e){return new Uint8Array(0)}const Un=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 g.hp.from(e,"hex")};function Tn(e){const r=new t(e.caller,e.sourceSequence),o=new n(e.forwarderAddress).call("mint_and_forward",a.ScVal.scvBytes(Un(e.message)),a.ScVal.scvBytes(Un(e.attestation)));return{xdr:new i(r,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(o).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const $n=10n**27n,Cn=10n**18n,Pn=10000n,Wn=27,On=18;function Nn(t,e="value"){let r;if("bigint"==typeof t)r=t;else if("number"==typeof t){if(!Number.isSafeInteger(t))throw new Error(`Stellar math: ${e} must be a safe integer, got ${t}`);r=BigInt(t)}else{const n=t.trim();if(!/^-?\d+$/.test(n))throw new Error(`Stellar math: ${e} must be a decimal integer string, got "${t}"`);r=BigInt(n)}if(r<0n)throw new Error(`Stellar math: ${e} must be non-negative, got ${r}`);return r}function Ln(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");return t*e/r}function Mn(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");const n=t*e,o=n/r;return n%r===0n?o:o+1n}function Dn(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");return(t*e+r/2n)/r}function zn(t,e){if(0n===e)throw new Error("Stellar math: division by zero");const r=t/e;return t%e>=e/2n+e%2n?r+1n:r}const Fn=t=>10n**BigInt(t);function Vn(t,e,r){return e===r?t:r>e?t*Fn(r-e):t/Fn(e-r)}function Xn(t,e,r){if(e===r)return t;if(r>e)return t*Fn(r-e);const n=Fn(e-r),o=t/n;return t%n===0n?o:o+1n}function jn(t,e,r){return e===r?t:r>e?t*Fn(r-e):zn(t,Fn(e-r))}const Gn={floor:Ln,ceil:Mn,halfUp:Dn},Hn={floor:Vn,ceil:Xn,halfUp:jn};function Kn(t,e,r,n){return Hn[n](Gn[n](t,e,$n),Wn,r)}function Jn(t,e,r){return Kn(Nn(t,"scaledRay"),Nn(e,"indexRay"),r,"floor")}function Yn(t,e,r){return Kn(Nn(t,"scaledRay"),Nn(e,"indexRay"),r,"ceil")}function Zn(t,e,r){return Kn(Nn(t,"scaledRay"),Nn(e,"indexRay"),r,"halfUp")}function Qn(t,e){if(e>Wn)throw new Error(`Stellar math: decimals ${e} exceed RAY scale`);return Vn(t,e,Wn)}function to(t,e,r,n){const o=Gn[n](t,e,$n),i=Hn[n](o,Wn,On);return Gn[n](i,r,Cn)}function eo(t,e,r,n){const o=Hn[n](Qn(t,e),Wn,On);return Gn[n](o,r,Cn)}const ro=t=>Number(t)/1e18,no=t=>Number(t)/1e27,oo=(t,e)=>Number(t)/10**e;function io(t,e){if(!Number.isFinite(t)||t<=0||t>=1e21)return 0n;const r=t.toFixed(e),[n="0",o=""]=r.split(".");return BigInt(n+o.padEnd(e,"0"))}const so=t=>io(t,On),ao=(t,e)=>Dn(t,e,$n),uo=(t,e)=>Dn(t,$n,e);function lo(t,e){return 0n===e?0n:uo(t,e)}function co(t,e){const r=t>$n?$n:t,n=Nn(e.baseRateRay,"irm.baseRateRay"),o=Nn(e.slope1Ray,"irm.slope1Ray"),i=Nn(e.slope2Ray,"irm.slope2Ray"),s=Nn(e.slope3Ray,"irm.slope3Ray"),a=Nn(e.midUtilizationRay,"irm.midUtilizationRay"),u=Nn(e.optimalUtilizationRay,"irm.optimalUtilizationRay"),l=Nn(e.maxBorrowRateRay,"irm.maxBorrowRateRay");let c;if(r<a)c=n+uo(ao(r,o),a);else if(r<u){const t=u-a;c=n+o+uo(ao(r-a,i),t)}else{const t=$n-u;c=n+o+i+(0n===t?0n:uo(ao(r-u,s),t))}return c>l?l:c}function po(t,e,r){return 0n===t||!Number.isInteger(r)||r<0||r>=1e4?0n:Dn(ao(t,e),Pn-BigInt(r),Pn)}const fo=t=>no(t),ho=t=>Math.expm1(no(t)),mo=5n*Cn,go=(t,e,r)=>`${t}:${e}:${r}`;function yo(t,e,r,n){const o=Array.isArray(t)?t:void 0,i=o?o.find((t=>t.spokeId===e&&t.hubId===r&&t.asset===n)):t[go(e,r,n)]??Object.values(t).find((t=>t.spokeId===e&&t.hubId===r&&t.asset===n));if(!i)throw new Error(`Stellar math: no reserve for ${go(e,r,n)}`);return i}const wo=/^0*[1-9]\d*$/,bo=t=>"string"==typeof t&&wo.test(t)?BigInt(t).toString():null,vo=(t,e)=>`${t}:${e}`;function Bo(t){const e=new Map,r=new Map,n=new Set,o=new Set;for(const i of t?.indexes??[]){const t=vo(i.hubId,i.asset),s=bo(i.supplyIndex),a=bo(i.borrowIndex),u=bo(i.usdPrice),l=e.get(t),c=l&&bo(l.supplyIndex)===s&&bo(l.borrowIndex)===a&&bo(l.usdPrice)===u;null==s||null==a||null==u||l&&!c?n.add(t):l||e.set(t,i);const p=!1===i.valid||!0===i.stale||!0===i.deviation,f=r.get(i.asset);null==u||p||void 0!==f&&f.toString()!==u?o.add(i.asset):void 0===f&&r.set(i.asset,BigInt(u))}for(const t of n)e.delete(t);for(const t of o)r.delete(t);return{indexes:e,prices:r,rejectedIndexKeys:n,rejectedAssets:o}}const So=(t,e)=>Ln(t,BigInt(e),Pn);function _o(t,e,r,n){const o="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:ro(t.priceWad),amountBase:e.toString(),amountShort:oo(e,t.decimals),usdWad:r.toString(),usd:ro(r),gateUsdWad:n.toString(),entryLtvBps:t.entryLtvBps,entryLiquidationThresholdBps:t.entryLiquidationThresholdBps,entryLiquidationBonusBps:t.entryLiquidationBonusBps,entryLiquidationFeesBps:t.entryLiquidationFeesBps,ltvWeightedUsdWad:o?So(n,i).toString():"0",liquidationWeightedUsdWad:o?So(n,t.entryLiquidationThresholdBps).toString():"0",liveDataUsed:t.liveDataUsed}}function Io(t){if("supply"===t.side)return _o(t,Kn(t.scaledRay,t.indexRay,t.decimals,"floor"),to(t.scaledRay,t.indexRay,t.priceWad,"halfUp"),to(t.scaledRay,t.indexRay,t.priceWad,"floor"));const e=Kn(t.scaledRay,t.indexRay,t.decimals,"ceil"),r=to(t.scaledRay,t.indexRay,t.priceWad,"ceil");return _o(t,e,r,r)}function qo(t,e,r,n){const o=Qn(e,r);return"supply"===t?Ln(o,$n,n):Mn(o,$n,n)}function Ro(t,e,r,n){const o=Qn(e,r);return"supply"===t?Mn(o,$n,n):Ln(o,$n,n)}function xo(t,e){return Io({...t,scaledRay:qo(t.side,e,t.decimals,t.indexRay)})}const ko=(...t)=>{for(const e of t){const t=bo(e);if(null!=t)return BigInt(t)}return $n};function Eo(t,e,r,n){const o=Nn("supply"===t?e.supplyScaledRay:e.borrowScaledRay,`${t}ScaledRay`);if(0n===o)return null;const i=n.indexes.get(vo(e.hubId,e.asset)),s=n.prices.get(e.asset),a="supply"===t?ko(i?.supplyIndex,e.liveSupplyIndexRay,r.liveSupplyIndexRay,e.supplyIndexRay):ko(i?.borrowIndex,e.liveBorrowIndexRay,r.liveBorrowIndexRay,e.borrowIndexRay),u=s??so(r.usdPrice);return Io({side:t,hubId:e.hubId,asset:e.asset,decimals:r.assetDecimals,scaledRay:o,indexRay:a,priceWad:u,entryLtvBps:e.entryLtvBps,entryLiquidationThresholdBps:e.entryLiquidationThresholdBps,entryLiquidationBonusBps:e.entryLiquidationBonusBps,entryLiquidationFeesBps:e.entryLiquidationFeesBps,liveDataUsed:void 0!==i&&void 0!==s})}const Ao=(t,e)=>t.reduce(((t,r)=>t+BigInt(e(r))),0n);function Uo(t,e,r,n,o){const i=Ao(e,(t=>t.usdWad)),s=Ao(e,(t=>t.ltvWeightedUsdWad)),a=Ao(e,(t=>t.liquidationWeightedUsdWad)),u=Ao(r,(t=>t.usdWad)),l=0n===u?null:Ln(a,Cn,u),c=0n===a?0:Number(u)/Number(a)*100,p=s<n||s<=u?0n:s-u;return{...t,supplies:e,borrows:r,totalCollateralUsdWad:i.toString(),totalCollateralUsd:ro(i),ltvWeightedCollateralUsdWad:s.toString(),ltvWeightedCollateralUsd:ro(s),liquidationWeightedCollateralUsdWad:a.toString(),liquidationWeightedCollateralUsd:ro(a),totalDebtUsdWad:u.toString(),totalDebtUsd:ro(u),healthFactorWad:null===l?null:l.toString(),healthFactor:null===l?null:ro(l),healthPercent:c,borrowLimitUsdWad:s.toString(),borrowLimitUsd:ro(s),availableBorrowUsdWad:p.toString(),availableBorrowUsd:ro(p),minBorrowCollateralUsdWad:n.toString(),minBorrowCollateralUsd:ro(n),isLiquidatable:null!==l&&l<Cn,liveDataValid:o}}function To(t){const{positions:e,reserves:r,liveState:n}=t,o=e[0];if(!o)throw new Error("Stellar math: computeAccountRisk needs at least one position row");for(const t of e)if(t.accountId!==o.accountId)throw new Error(`Stellar math: computeAccountRisk received mixed account ids (${o.accountId}, ${t.accountId})`);const i=Bo(n),s=[],a=[];for(const t of e){const e=yo(r,t.spokeId,t.hubId,t.asset),n=Eo("supply",t,e,i);n&&s.push(n);const o=Eo("borrow",t,e,i);o&&a.push(o)}const u=null!=n?.minBorrowCollateralUsdWad?Nn(n.minBorrowCollateralUsdWad,"minBorrowCollateralUsdWad"):mo,l=void 0!==n&&[...s,...a].every((t=>t.liveDataUsed));return Uo({accountId:o.accountId,owner:o.owner,spokeId:o.spokeId,mode:o.positionMode},s,a,u,l)}const $o=200n,Co=t=>t.reduce(((t,e)=>e.amount<t.amount?e:t)),Po=t=>t<0n?0n:t,Wo=(t,e,r,n)=>({amountBase:t.amount,amountShort:oo(t.amount,e),isFullClose:r,reason:t.reason,projectedUtilization:n}),Oo=t=>({amountBase:0n,amountShort:0,isFullClose:!1,reason:t,projectedUtilization:null});function No(t){const e=t.assetDecimals,r=Nn(t.irm.maxUtilizationRay,"irm.maxUtilizationRay");return{suppliedBase:io(t.hubPool.suppliedShort,e),borrowedBase:io(t.hubPool.borrowedShort,e),cashBase:io(t.availableLiquidityShort,e),spokeSuppliedBase:io(t.suppliedShort,e),spokeBorrowedBase:io(t.borrowedShort,e),maxUtilizationRay:r>=$n?null:r}}const Lo=(t,e)=>t<=0n?null:Number(e)/Number(t);function Mo(t,e){if(t<=0n||!e(0n))return 0n;let r=0n,n=t+1n;for(;n-r>1n;){const t=(r+n)/2n;e(t)?r=t:n=t}return r}const Do=(t,e)=>t.find((t=>t.hubId===e.hubId&&t.asset===e.asset));function zo(t,e,r){if(e.paused)return Oo("paused");if(e.frozen)return Oo("frozen");if(!e.isBorrowable)return Oo("cap");const n=e.assetDecimals,o=No(e),i=Do(t.borrows,e),s=Bo(r).indexes.get(vo(e.hubId,e.asset)),a=i?BigInt(i.indexRay):Nn(s?.borrowIndex??e.liveBorrowIndexRay,"borrowIndex"),u=i?BigInt(i.usdPriceWad):function(t,e){return Bo(e).prices.get(t.asset)??so(t.usdPrice)}(e,r),l=i?BigInt(i.scaledRay):0n,c=BigInt(t.totalDebtUsdWad)-(i?BigInt(i.usdWad):0n),p=BigInt(t.ltvWeightedCollateralUsdWad),f=BigInt(t.minBorrowCollateralUsdWad),d=[];if(p<f)d.push({amount:0n,reason:"minCollateral"});else{const e=p-BigInt(t.totalDebtUsdWad),r=e<=0n||u<=0n?0n:Ln(e,10n**BigInt(n),u),o=t=>c+to(l+qo("borrow",t,n,a),a,u,"ceil");d.push({amount:0n===r?0n:Mo(r+16n,(t=>o(t)<=p)),reason:"ltv"})}d.push({amount:Po(Nn(e.borrowCap,"borrowCap")-o.spokeBorrowedBase),reason:"cap"});const h=Dn(o.suppliedBase,200n,Pn);d.push({amount:Po(o.cashBase-h),reason:"liquidity"});const m=function(t,e){const r=t.maxUtilizationRay;if(null===r)return null;const n=Qn(t.suppliedBase,e);return 0n===n?null:Mo(Po(Ln(t.suppliedBase,r,$n)-t.borrowedBase)+16n,(o=>lo(Qn(t.borrowedBase+o,e),n)<=r))}(o,n);null!==m&&d.push({amount:m,reason:"utilizationCap"});const g=Co(d);return Wo(g,n,!1,Lo(o.suppliedBase,o.borrowedBase+g.amount))}function Fo(t,e,r){if(e.paused)return Oo("paused");const n=Do(t.supplies,e);if(!n)return Oo(null);const o=n.decimals,i=No(e),s=BigInt(n.scaledRay),a=BigInt(n.indexRay),u=BigInt(n.usdPriceWad),l=BigInt(n.amountBase),c=Kn(s,a,o,"halfUp"),p=BigInt(t.totalDebtUsdWad),f=BigInt(t.minBorrowCollateralUsdWad),d=BigInt(Math.min(n.entryLtvBps,n.entryLiquidationThresholdBps)),h=[];let m=!0;if(p>0n&&d>0n){const e=p>f?p:f,r=f>p?"minCollateral":"healthFactor",i=BigInt(t.ltvWeightedCollateralUsdWad)-BigInt(n.ltvWeightedUsdWad);if(i<e){m=!1;const t=e-i,l=Mn(t,Pn,d),p=BigInt(n.gateUsdWad)-l,f=p<=0n?0n:Ln(p,10n**BigInt(o),u),g=c>0n?c-1n:0n,y=f+16n>g?g:f+16n,w=t=>{const e=Ro("supply",t,o,a);return Ln(to(e>=s?0n:s-e,a,u,"floor"),d,Pn)};h.push({amount:Mo(y,(e=>w(e)>=t)),reason:r})}}h.push({amount:l,reason:null}),h.push({amount:i.cashBase,reason:"liquidity"});const g=function(t,e){const r=t.maxUtilizationRay;if(null===r||0n===t.borrowedBase)return null;if(0n===r)return 0n;const n=Mn(t.borrowedBase,$n,r),o=t.suppliedBase<n?0n:t.suppliedBase-n+16n,i=Qn(t.borrowedBase,e);return Mo(o>t.suppliedBase?t.suppliedBase:o,(n=>{const o=Qn(t.suppliedBase-n,e);return o>0n&&lo(i,o)<=r}))}(i,o);null!==g&&h.push({amount:g,reason:"utilizationCap"});const y=Co(h),w=m&&y.amount>=l;return Wo(y,o,w,Lo(i.suppliedBase-y.amount,i.borrowedBase))}function Vo(t){if(t.paused)return Oo("paused");if(t.frozen)return Oo("frozen");const e=t.assetDecimals,r=No(t),n={amount:Po(Nn(t.supplyCap,"supplyCap")-r.spokeSuppliedBase),reason:"cap"};return Wo(n,e,!1,Lo(r.suppliedBase+n.amount,r.borrowedBase))}function Xo(t,e,r){if(e.paused)return Oo("paused");const n=Do(t.borrows,e);if(!n)return Oo(null);const o=n.decimals,i=No(e),s=BigInt(n.amountBase),a=void 0===r?null:Nn(r,"walletBalance"),u=null!==a&&a<s?{amount:a,reason:"liquidity"}:{amount:s,reason:null};return Wo(u,o,u.amount>=s,Lo(i.suppliedBase,Po(i.borrowedBase-u.amount)))}const jo=(t,e)=>t.hubId===e.hubId&&t.asset===e.asset,Go=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 Ho(t,e){const r=[...t.supplies],n=[...t.borrows];for(const t of e){const e="supply"===t.side?r:n,o=e.findIndex((e=>jo(e,t))),i=-1===o?void 0:e[o],s=Go(t.amountBase);let a;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 r;if(s>=0n)r=e+qo(t.side,s,t.decimals,t.indexRay);else{const n=-s,o=n>=("supply"===t.side?Kn(e,t.indexRay,t.decimals,"halfUp"):BigInt(i.amountBase))?e:Ro(t.side,n,t.decimals,t.indexRay);r=o>=e?0n:e-o}a=0n===r?null:Io({...t,scaledRay:r})}else a=s<=0n?null:xo(Ko(t),s);-1===o?a&&e.push(a):a?e[o]=a:e.splice(o,1)}return Uo({accountId:t.accountId,owner:t.owner,spokeId:t.spokeId,mode:t.mode},r,n,BigInt(t.minBorrowCollateralUsdWad),t.liveDataValid)}function Ko(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:Nn("supply"===t.side?e.liveSupplyIndexRay:e.liveBorrowIndexRay,"reserve live index"),priceWad:so(e.usdPrice),entryLtvBps:e.collateralFactorBps,entryLiquidationThresholdBps:e.liquidationThresholdBps,entryLiquidationBonusBps:e.liquidationPenaltyBps,entryLiquidationFeesBps:e.liquidationFeesBps,liveDataUsed:!1}}function Jo(t,e=0n,r=0n){const n=t.assetDecimals,o=t=>t<0n?0n:t,i=o(io(t.hubPool.suppliedShort,n)+Go(e)),s=lo(Qn(o(io(t.hubPool.borrowedShort,n)+Go(r)),n),Qn(i,n)),a=co(s,t.irm),u=po(s,a,t.irm.reserveFactorBps);return{utilization:no(s),utilizationRay:s.toString(),borrowAprRay:a.toString(),supplyAprRay:u.toString(),borrowApr:fo(a),supplyApr:fo(u),borrowApy:ho(a),supplyApy:ho(u)}}const Yo={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 Zo(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const r=Number(e[1]),n=Yo[r];return n?{code:r,...n}:null}export{Pn as BPS,mo as DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD,$o as LIQUIDATION_BUFFER_BPS,$n as RAY,Wn as RAY_DECIMALS,De as STELLAR_GOVERNANCE_ZERO_PREDECESSOR,un as STELLAR_LENDING_TOPICS,f as STELLAR_NETWORKS,m as STELLAR_NETWORK_PASSPHRASE,cn as SYNTHETIC_EVENT_ORDER_STRIDE,Cn as WAD,On as WAD_DECIMALS,Uo as aggregateAccountRisk,co as annualBorrowRateRay,Qn as baseToRay,oo as baseToShort,eo as baseValueWad,Bo as buildLiveSnapshot,An as buildSameTokenRepaySwapSteps,be as buildStellarAcceptOwnershipTx,Le as buildStellarAddRewardsTx,qe as buildStellarApproveBlendPoolTx,xe as buildStellarApproveTokenTx,Bn as buildStellarBatchSwapTx,G as buildStellarBorrowBatchTx,H as buildStellarBorrowTx,Tn as buildStellarCctpForwardTx,Ne as buildStellarClaimRevenueTx,We as buildStellarCreateLiquidityPoolTx,Or as buildStellarExecuteCancellerResetTx,vn as buildStellarExecuteStrategyTx,et as buildStellarFlashLoanTx,Dr as buildStellarGovernanceAddSpokeImmediateTx,Mr as buildStellarGovernanceCreateHubImmediateTx,Ar as buildStellarGovernanceExecuteGovernanceUpgradeTx,Tr as buildStellarGovernanceExecuteGrantGovernanceRoleTx,$r as buildStellarGovernanceExecuteRevokeGovernanceRoleTx,Cr as buildStellarGovernanceExecuteTransferGovOwnTx,Er as buildStellarGovernanceExecuteTx,Ur as buildStellarGovernanceExecuteUpdateDelayTx,Fr as buildStellarGovernancePauseTx,zr as buildStellarGovernanceRevokeRoleImmediateTx,Lr as buildStellarGovernanceSetOracleSanityBoundsImmediateTx,Nr as buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,ge as buildStellarGrantRoleTx,pn as buildStellarLendingIdentifier,Q as buildStellarLiquidateTx,rt as buildStellarMigrateFromBlendTx,de as buildStellarMigrateTx,nt as buildStellarMultiplyTx,he as buildStellarPauseTx,or as buildStellarProposeAddAssetToSpokeTx,rr as buildStellarProposeAddSpokeTx,fr as buildStellarProposeApproveBlendPoolTx,cr as buildStellarProposeApproveTokenTx,Wr as buildStellarProposeCancellerResetTx,Br as buildStellarProposeConfigureAssetOracleTx,Sr as buildStellarProposeConfigureMarketOracleTx,er as buildStellarProposeCreateHubTx,hr as buildStellarProposeCreateLiquidityPoolTx,gr as buildStellarProposeDeployPoolTx,ir as buildStellarProposeEditAssetInSpokeTx,_r as buildStellarProposeEditOracleToleranceTx,Ir as buildStellarProposeGovernanceUpgradeTx,Rr as buildStellarProposeGrantGovernanceRoleTx,br as buildStellarProposeMigrateControllerTx,sr as buildStellarProposeRemoveAssetFromSpokeTx,nr as buildStellarProposeRemoveSpokeTx,dr as buildStellarProposeRevokeBlendPoolTx,xr as buildStellarProposeRevokeGovernanceRoleTx,pr as buildStellarProposeRevokeTokenTx,Qe as buildStellarProposeSetAccumulatorTx,Ze as buildStellarProposeSetAggregatorTx,lr as buildStellarProposeSetMinBorrowCollatTx,tr as buildStellarProposeSetPositionLimitsTx,ur as buildStellarProposeSetPositionManagerTx,Ye as buildStellarProposeSetPriceAggregatorTx,ar as buildStellarProposeSetSpokeLiquidationCurveTx,Je as buildStellarProposeSetSwapAggregatorTx,vr as buildStellarProposeTransferCtrlOwnershipTx,kr as buildStellarProposeTransferGovOwnTx,Vr as buildStellarProposeUnpauseTx,qr as buildStellarProposeUpdateDelayTx,wr as buildStellarProposeUpgradeControllerTx,mr as buildStellarProposeUpgradePoolParamsTx,yr as buildStellarProposeUpgradePoolTx,Pe as buildStellarRenewAccountTx,Y as buildStellarRepayBatchTx,st as buildStellarRepayDebtWithCollateralTx,Z as buildStellarRepayTx,Re as buildStellarRevokeBlendPoolTx,ye as buildStellarRevokeRoleTx,ke as buildStellarRevokeTokenTx,_e as buildStellarSetAccumulatorTx,Se as buildStellarSetAggregatorTx,Ae as buildStellarSetMarketOracleConfigTx,$e as buildStellarSetOracleSanityBoundsTx,Ue as buildStellarSetOracleToleranceTx,Ee as buildStellarSetOracleTx,Ie as buildStellarSetPositionLimitsTx,Be as buildStellarSetPriceAggregatorTx,Te as buildStellarSetSpokeAssetFlagsTx,ve as buildStellarSetSwapAggregatorTx,X as buildStellarSupplyBatchTx,j as buildStellarSupplyTx,it as buildStellarSwapCollateralTx,ot as buildStellarSwapDebtTx,we as buildStellarTransferOwnershipTx,me as buildStellarUnpauseTx,Me as buildStellarUpdateAccountThresholdTx,Ce as buildStellarUpdateIndexesTx,fe as buildStellarUpgradeControllerTx,Oe as buildStellarUpgradeLiquidityPoolParamsTx,K as buildStellarWithdrawBatchTx,J as buildStellarWithdrawTx,F as buildTx,Ro as burnShares,To as computeAccountRisk,ln as decodeStellarLendingEvent,tt as decodeStellarLiquidateReturn,po as depositRateRay,zn as divByIntHalfUp,ce as encodeAssetOracle,Qt as encodeInterestRateModel,pe as encodeMarketOracleConfigInput,te as encodeMarketParamsRaw,ee as encodePositionLimits,re as encodePriceKey,bn as encodeStrategyPayloadToRouteXdr,fn as extractEventOrder,Bt as getStellarAccountPositions,Xt as getStellarActiveUsersSeries,gn as getStellarAggregatorQuote,yt as getStellarAsset,kt as getStellarAssetGraph,It as getStellarAssetMarkets,_t as getStellarAssetPage,ft as getStellarAssets,Lt as getStellarCampaignLeaderboard,Yt as getStellarCampaignMe,Gt as getStellarDefiLlamaDimensions,h as getStellarDeployment,pt as getStellarDetailedMarkets,zt as getStellarFeeRevenueSeries,Ct as getStellarGovernanceProposals,Nt as getStellarHolderDistribution,wt as getStellarHub,Et as getStellarHubGraph,Rt as getStellarHubHolders,dt as getStellarHubs,lt as getStellarLendingContext,ct as getStellarLendingLiveState,Ot as getStellarLiquidationsLeaderboard,Ft as getStellarLiquidationsSeries,Wt as getStellarParticipantCounts,Jt as getStellarPnlByScope,Pt as getStellarPositionsLeaderboard,Kt as getStellarPositionsPnl,yn as getStellarQuoteTokens,jt as getStellarRateSpreadSeries,gt as getStellarReserve,Ut as getStellarReserveGraph,qt as getStellarReserveHolders,mt as getStellarReserves,Dt as getStellarRevenueSeries,bt as getStellarSpoke,At as getStellarSpokeGraph,xt as getStellarSpokeHolders,ht as getStellarSpokes,Mt as getStellarStatsHistory,Tt as getStellarUserActivity,$t as getStellarUserActivityPage,Ht as getStellarUserHistory,vt as getStellarUserPositions,Vt as getStellarVolumeSeries,St as getStellarWalletBalance,vo as liveIndexKey,In as mapQuoteResponseToAggregatorSwap,Sn as mapQuoteResponseToStrategyPayload,_n as mapQuoteResponseToStrategySwap,Zo as mapSorobanError,hn as mapStellarPositionActivityType,zo as maxBorrow,Xo as maxRepay,Vo as maxSupply,Fo as maxWithdraw,qo as mintShares,Mn as mulDivCeil,Ln as mulDivFloor,Dn as mulDivHalfUp,io as numberToScaled,so as numberToWad,to as positionValueWad,kn as prepareStellarBuiltTx,xn as prepareStellarTxXdr,Ho as projectAccountRisk,Jo as projectReserveApy,ho as rayAprToApy,fo as rayAprToNumber,no as rayToNumber,Xn as rescaleCeil,Vn as rescaleFloor,jn as rescaleHalfUp,go as reserveKey,yo as resolveReserve,Gr as stellarLendingDispatchKey,Zt as stellarLendingRead,d as stellarNetworks,dn as syntheticEventOrder,Rn as tagStellarInvokedContractError,Xr as toBase64Xdr,Nn as toBigInt,En as toStellarPositionMode,Kn as unscale,Yn as unscaleBorrowCeil,Zn as unscaleHalfUp,Jn as unscaleSupplyFloor,lo as utilizationRay,xo as valueBasePosition,Io as valueScaledPosition,ro as wadToNumber};export const XOXNOClient=p.GW;
2
+ "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,Asset as r,BASE_FEE as n,Contract as o,ScInt as s,StrKey as i,TransactionBuilder as a,scValToBigInt as u,scValToNative as l,xdr as c}from"@stellar/stellar-sdk";var f={526(t,e){e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,s=a(t),i=s[0],u=s[1],l=new o(function(t,e,r){return 3*(e+r)/4-r}(0,i,u)),c=0,f=u>0?i-4:i;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,s=[],i=16383,a=0,u=n-o;a<u;a+=i)s.push(l(t,a,a+i>u?u:a+i));return 1===o?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),s.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)r[i]=s[i],n[s.charCodeAt(i)]=i;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function l(t,e,r){for(var n,o=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(u(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},287(t,e,r){const n=r(526),o=r(251),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=u,e.IS=50;const i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|m(t,e);let n=a(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return p(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 d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|h(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?a(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(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 f(t){return c(t),a(t<0?0:0|h(t))}function p(t){const e=t.length<0?0:0|h(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function h(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function m(t,e){if(u.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 r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(t).length;default:if(o)return n?-1:j(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return q(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let s,i=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,a/=2,u/=2,r/=2}function l(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){let n=-1;for(s=r;s<a;s++)if(l(t,s)===l(e,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===u)return n*i}else-1!==n&&(s-=s-n),n=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){let r=!0;for(let n=0;n<u;n++)if(l(t,s+n)!==l(e,n)){r=!1;break}if(r)return s}return-1}function v(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const s=e.length;let i;for(n>s/2&&(n=s/2),i=0;i<n;++i){const n=parseInt(e.substr(2*i,2),16);if(Z(n))return i;t[r+i]=n}return i}function I(t,e,r,n){return H(j(e,t.length-r),t,r,n)}function S(t,e,r,n){return H(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return H(G(e),t,r,n)}function B(t,e,r,n){return H(function(t,e){let r,n,o;const s=[];for(let i=0;i<t.length&&!((e-=2)<0);++i)r=t.charCodeAt(i),n=r>>8,o=r%256,s.push(o),s.push(n);return s}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let s=null,i=e>239?4:e>223?3:e>191?2:1;if(o+i<=r){let r,n,a,u;switch(i){case 1:e<128&&(s=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(s=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(s=u));break;case 4:r=t[o+1],n=t[o+2],a=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(s=u))}}null===s?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=i}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}u.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}}(),u.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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return l(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},u.allocUnsafe=function(t){return f(t)},u.allocUnsafeSlow=function(t){return f(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,s=Math.min(r,n);o<s;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))o+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=m,u.prototype._isBuffer=!0,u.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)y(this,e,e+1);return this},u.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)y(this,e,e+3),y(this,e+1,e+2);return this},u.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)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?R(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},s&&(u.prototype[s]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.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===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(o>>>=0)-(n>>>=0),i=(r>>>=0)-(e>>>=0);const a=Math.min(s,i),l=this.slice(n,o),c=t.slice(e,r);for(let t=0;t<a;++t)if(l[t]!==c[t]){s=l[t],i=c[t];break}return s<i?-1:i<s?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return I(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function q(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=Y[t[n]];return o}function T(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function U(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function $(t,e,r,n,o,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function O(t,e,r,n,o){F(e,n,o,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let i=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,r}function C(t,e,r,n,o){F(e,n,o,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let i=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=i,i>>=8,t[r+2]=i,i>>=8,t[r+1]=i,i>>=8,t[r]=i,r+8}function N(t,e,r,n,o,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,n,s){return e=+e,r>>>=0,s||N(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,s){return e=+e,r>>>=0,s||N(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],o=1,s=0;for(;++s<e&&(o*=256);)n+=this[t+s]*o;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),u.prototype.readBigUInt64BE=J((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],o=1,s=0;for(;++s<e&&(o*=256);)n+=this[t+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=e,o=1,s=this[t+--n];for(;n>0&&(o*=256);)s+=this[t+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=J((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||$(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,s=0;for(this[e]=255&t;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||$(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,s=1;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeBigUInt64LE=J((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);$(this,t,e,r,n-1,-n)}let o=0,s=1,i=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===i&&0!==this[e+o-1]&&(i=1),this[e+o]=(t/s|0)-i&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);$(this,t,e,r,n-1,-n)}let o=r-1,s=1,i=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===i&&0!==this[e+o+1]&&(i=1),this[e+o]=(t/s|0)-i&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||$(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||$(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},u.prototype.writeBigInt64LE=J((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const s=u.isBuffer(t)?t:u.from(t,n),i=s.length;if(0===i)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%i]}return this};const L={};function D(t,e,r){L[t]=class extends r{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="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,n,o,s){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=s>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new L.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,o,s)}function z(t,e){if("number"!=typeof t)throw new L.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw z(t,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=W(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=W(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function j(t,e){let r;e=e||1/0;const n=t.length;let o=null;const s=[];for(let i=0;i<n;++i){if(r=t.charCodeAt(i),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(i+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function G(t){return n.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 H(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251(t,e){e.read=function(t,e,r,n,o){var s,i,a=8*o-n-1,u=(1<<a)-1,l=u>>1,c=-7,f=r?o-1:0,p=r?-1:1,d=t[e+f];for(f+=p,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+f],f+=p,c-=8);for(i=s&(1<<-c)-1,s>>=-c,c+=n;c>0;i=256*i+t[e+f],f+=p,c-=8);if(0===s)s=1-l;else{if(s===u)return i?NaN:1/0*(d?-1:1);i+=Math.pow(2,n),s-=l}return(d?-1:1)*i*Math.pow(2,s-n)},e.write=function(t,e,r,n,o,s){var i,a,u,l=8*s-o-1,c=(1<<l)-1,f=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,h=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=c):(i=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-i))<1&&(i--,u*=2),(e+=i+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(i++,u/=2),i+f>=c?(a=0,i=c):i+f>=1?(a=(e*u-1)*Math.pow(2,o),i+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),i=0));o>=8;t[r+d]=255&a,d+=h,a/=256,o-=8);for(i=i<<o|a,l+=o;l>0;t[r+d]=255&i,d+=h,i/=256,l-=8);t[r+d-h]|=128*m}},387(t,e,r){r.d(e,{GW:()=>s});var n,o=r(564);!function(t){t.MAINNET="1",t.DEVNET="D"}(n||(n={}));class s{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=n.MAINNET,apiUrl:r,...s}=t;this.apiUrl=r.trim().replace(/\/$/,""),this.chain=e,this.init=s,this.config=e==n.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:o.s0,FM_SC:o.ZZ,DR_SC:o.sM,KG_SC:o.KL,Staking_SC:o.V,Manager_SC:o.Rh,P2P_SC:o.EP}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:o.cM,FM_SC:o.ZZ,DR_SC:o.sM,KG_SC:o.KL,Staking_SC:o.J6,Manager_SC:o.Ff,P2P_SC:o.gx}}fetchWithTimeout=async(t,{params:e,...r}={})=>{const{next:n,cache:o,debug:s,timeout:i,...a}=this.init,{next:u,cache:l,debug:c,timeout:f,headers:p,method:d="GET",...h}=r,m=p?.Authorization,g="Bearer undefined"===m?void 0:m,y="GET"!==d&&"HEAD"!==d&&"PUT"!==d,w={...p,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...y?{"Content-Type":"application/json"}:{},...g?{Authorization:g}:{}},b=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("&"),v=`${this.apiUrl}${t}${b.length?`?${b}`:""}`,{revalidate:I,...S}=n??{},{revalidate:_,...B}=u??{},E="GET"!==d||g?void 0:_??I,R="GET"!==d||g||E?void 0:l??o,A=h.body,k=f??i??(null==A?3e4:0),q=k>0?AbortSignal.timeout(k):void 0,x=h.signal??a.signal,T=q&&x?AbortSignal.any([x,q]):q??x,U={...a,...h,method:d,...Object.keys(w).length?{headers:w}:{},...T?{signal:T}:{},cache:R,next:{...S,...B,revalidate:E}};(c??s)&&console.debug("SDK fetch: ",v,U);const $=await fetch(v,U).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${v}: ${t.message}`),{cause:t});throw t})),O=await $.text();if(!$.ok){let t;try{t=JSON.parse(O)}catch{t={message:O}}const e=[v,$.status,$.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(O)}catch{return O}}}},564(t,e,r){r.d(e,{EP:()=>l,Ff:()=>p,J6:()=>f,KL:()=>i,Rh:()=>u,V:()=>a,ZZ:()=>o,cM:()=>c,gx:()=>d,s0:()=>n,sM:()=>s});const n="erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",o="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",s="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",i="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",a="erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",u="erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",l="erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6",c="erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",f="erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",p="erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",d="erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}},p={};function d(t){var e=p[t];if(void 0!==e)return e.exports;var r=p[t]={exports:{}};return f[t](r,r.exports,d),r.exports}d.d=(t,e)=>{for(var r in e)d.o(e,r)&&!d.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},d.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var h=d(387);const m={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=m;function y(t){return m["testnet"===t?"stellarTestnet":"stellarMainnet"]}const w={mainnet:m.stellarMainnet.passphrase,testnet:m.stellarTestnet.passphrase};var b=d(287);const v=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],I={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},S=1,_=1e6,B=5,E=6,R=0,A=1,k=2,q=128,x=48,T=32,U=256,$=q-k,O=t=>new e(t).toScVal(),C=t=>new s(t).toI128(),N=t=>c.ScVal.scvU32(t),P=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 s("string"==typeof t?t:t.toString()).toU64()},M=t=>c.ScVal.scvBool(t),L=t=>c.ScVal.scvString(t),D=t=>c.ScVal.scvSymbol(t),W=()=>c.ScVal.scvVoid(),F=t=>c.ScVal.scvVec(t),z=(t,e=32)=>{const r=t.startsWith("0x")?t.slice(2):t,n=b.hp.from(r,"hex");if(n.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${n.length} bytes from "${t}")`);return c.ScVal.scvBytes(n)},V=(t,e)=>null==t?W():e(t),X=(t,e)=>K({asset:O(e),hub_id:N(t)}),j=(t,e,r)=>c.ScVal.scvVec([X(t,e),C(r)]),G=t=>c.ScVal.scvVec(t.map((t=>j(t.hubId,t.asset,t.amount)))),H=t=>{if("Transfer"===t)return F([D("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 F([D("Credit"),P(e)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(t)}`)},K=t=>{const e=Object.keys(t).sort().map((e=>new c.ScMapEntry({key:D(e),val:t[e]})));return c.ScVal.scvMap(e)};class Z{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>=U)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>=$)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>=T)throw new Error("Stellar builder: strategy uses more than 32 split weights");if(!Number.isInteger(t)||t<=0||t>_)throw new Error(`Stellar builder: split weight ${t} outside 1..=${_}`);return this.weights.push(t),this.weights.length-1}emit(t,e,r,n,o){this.ops.push([t,e,r,n,o])}emitPath(t,e){t.hops.forEach(((r,n)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const o=t.hops[n-1];if(o&&r.tokenIn!==o.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(I[r.venue],0===n?e:A,this.asset(r.pool),this.asset(r.tokenIn),this.asset(r.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),r=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(r[t])continue;const n=e[t].hops[0]?.tokenIn,o=[];for(let r=t;r<e.length;r+=1)e[r].hops[0]?.tokenIn===n&&o.push(r);const s=o.reduce(((t,r)=>t+e[r].splitPpm),0);if(s>_)throw new Error(`Stellar builder: split weights for one token sum to ${s}, above ${_}`);const i=s===_;let a=_;o.forEach(((t,n)=>{r[t]=!0;const s=e[t];let u;if(n+1===o.length&&i)u=R;else{if(0===a)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(s.splitPpm*_/a);a-=Math.min(s.splitPpm,a),u=q+this.weight(t)}this.emitPath(s,u)}))}}toBytes(t,e,r){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>x)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts ${x}`);const n=[S,t,e,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,this.ops.length,this.weights.length];for(const t of this.ops)n.push(...t);for(const t of this.weights)n.push(t>>>16&255,t>>>8&255,255&t);return b.hp.from(n)}get assetList(){return this.assets}get amountList(){return this.amounts}}const Y=t=>{const e=new Z(t.totalMinOut),r=e.asset(t.tokenIn),n=e.asset(t.tokenOut);if(r===n)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const n=e.asset(t.burnPool),o=e.amountList.length;for(const r of t.burnMinAmounts??[])e.amount(r);e.emit(B,R,n,r,o)}if(e.lowerPaths(t.paths),t.mintPool){const r=t.preSwapAmount;if(r&&BigInt(r)>0n){const n=t.mintPoolTokens;if(!n||2!==n.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[o,s]=n,[i,a]=t.preSwapFromA?[o,s]:[s,o];e.emit(I.Aquarius,k+e.amount(r),e.asset(t.mintPool),e.asset(i),e.asset(a))}e.emit(E,R,e.asset(t.mintPool),n,e.amount(t.mintMinShares??"1"))}const o=Number(t.referralId??0);if(!Number.isInteger(o)||o<0||o>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return K({amounts:c.ScVal.scvVec(e.amountList.map((t=>C(t)))),assets:c.ScVal.scvVec(e.assetList.map((t=>O(t)))),ops:c.ScVal.scvBytes(e.toBytes(r,n,o))})},J=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 c.ScVal.scvBytes(e)},Q=()=>c.ScVal.scvBytes(b.hp.alloc(0)),tt=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((r=t).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return b.hp.from(t,"hex")}var r;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 n=b.hp.from(e,"base64");if(0===n.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return n},et=t=>{if("string"==typeof t)return J(tt(t));if(t instanceof Uint8Array)return 0===t.length?Q():J(t);if(t&&"object"==typeof t)return"routeXdr"in(r=t)&&"string"==typeof r.routeXdr?J(tt(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?J(tt(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?J(tt(t.bytes)):0===t.bytes.length?Q():J(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 r=new Map;for(const[t,n]of e.paths.entries()){if(!n||"number"!=typeof n.splitPpm||n.splitPpm<=0||!Array.isArray(n.hops)||0===n.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,r]of n.hops.entries())if(!r||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!v.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=n.hops[0];r.set(e.tokenIn,(r.get(e.tokenIn)??0)+n.splitPpm)}for(const[t,n]of r){if(n>_)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${n}, above ${_}`);if(!e.mintPool&&n!==_)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to ${_}, got ${n}`)}return e})(t),c.ScVal.scvBytes(b.hp.from(Y(e).toXDR("base64"),"base64")));var e,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},rt=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,r=b.hp.from(e,"hex");return c.ScVal.scvBytes(r)})(t);if(t instanceof Uint8Array)return c.ScVal.scvBytes(b.hp.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function nt(e,r,s){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const i=new o(e.controllerAddress),u=new t(e.caller,e.sourceSequence);return{xdr:new a(u,{fee:e.fee??n,networkPassphrase:w[e.network]}).addOperation(i.call(r,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function ot(t){if(!Number.isInteger(t)||t<1||t>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return N(t)}function st(t,e){const r=e.accountNonce??0;return nt(t,"supply",[O(t.caller),P(r),ot(e.spokeId),G([...e.assets])])}function it(t,e){return st(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function at(t,e){return nt(t,"borrow",[O(t.caller),P(e.accountNonce),G([...e.borrows]),V(e.to,O)])}function ut(t,e){return at(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function lt(t,e){return nt(t,"withdraw",[O(t.caller),P(e.accountNonce),G([...e.withdrawals]),V(e.to,O)])}function ct(t,e){return lt(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function ft(t,e){return nt(t,"repay",[O(t.caller),P(e.accountNonce),G([...e.payments])])}function pt(t,e){return ft(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function dt(t,e){return nt(t,"liquidate",[O(t.caller),P(e.accountNonce),G([...e.debtPayments]),H(e.seizeMode??"Transfer")])}function ht(t){const e=l(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 mt(t,e){return nt(t,"flash_loan",[O(t.caller),X(e.hubId,e.asset),C(e.amount),O(e.receiver),rt(e.data)])}function gt(t,e){return nt(t,"migrate_from_blend",[O(t.caller),P(e.accountId),ot(e.spokeId),N(e.hubId),O(e.blendPool),F(e.collateralTokens.map(O)),F(e.supplyTokens.map(O)),(r=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),c.ScVal.scvVec(r.map((t=>{return e=t.token,r=t.amount,c.ScVal.scvVec([O(e),C(r)]);var e,r}))))]);var r}function yt(t,e){const r=e.accountNonce??0;return nt(t,"multiply",[O(t.caller),P(r),ot(e.spokeId),X(e.collateral.hubId,e.collateral.asset),C(e.debtToFlashLoan),X(e.debt.hubId,e.debt.asset),N(e.mode),et(e.steps),V(e.initialPayment,(t=>j(t.hubId,t.asset,t.amount))),V(e.convertSwap,et)])}function wt(t,e){return nt(t,"swap_debt",[O(t.caller),P(e.accountNonce),X(e.existingDebt.hubId,e.existingDebt.asset),C(e.newDebtAmount),X(e.newDebt.hubId,e.newDebt.asset),et(e.steps)])}function bt(t,e){return nt(t,"swap_collateral",[O(t.caller),P(e.accountNonce),X(e.current.hubId,e.current.asset),C(e.fromAmount),X(e.newCollateral.hubId,e.newCollateral.asset),et(e.steps)])}function vt(t,e){return nt(t,"repay_debt_with_collateral",[O(t.caller),P(e.accountNonce),X(e.collateral.hubId,e.collateral.asset),C(e.collateralAmount),X(e.debt.hubId,e.debt.asset),et(e.steps),M(e.closePosition)])}const It="/stellar-lending",St=encodeURIComponent,_t=(t,e)=>t.fetchWithTimeout(`${It}/context`,e),Bt=(t,e)=>t.fetchWithTimeout(`${It}/live-state`,e),Et=(t,e)=>t.fetchWithTimeout(`${It}/markets/detailed`,e),Rt=(t,e)=>t.fetchWithTimeout(`${It}/assets`,e),At=(t,e)=>t.fetchWithTimeout(`${It}/hubs`,e),kt=(t,e)=>t.fetchWithTimeout(`${It}/spokes`,e),qt=(t,e={},r)=>t.fetchWithTimeout(`${It}/reserves`,{...r,params:{...e}}),xt=(t,e,r,n,o)=>t.fetchWithTimeout(`${It}/reserves/${e}/${r}/${St(n)}`,o),Tt=(t,e,r)=>t.fetchWithTimeout(`${It}/assets/${St(e)}`,r),Ut=(t,e,r)=>t.fetchWithTimeout(`${It}/hubs/${e}`,r),$t=(t,e,r)=>t.fetchWithTimeout(`${It}/spokes/${e}`,r),Ot=(t,e,r)=>t.fetchWithTimeout(`${It}/users/${St(e)}/positions`,r),Ct=(t,e,r)=>t.fetchWithTimeout(`${It}/accounts/${St(e)}/positions`,r),Nt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/users/${St(e)}/assets/${St(r)}/balance`,n),Pt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/assets/${St(e)}/page`,{...n,params:{...r}}),Mt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/assets/${St(e)}/markets`,{...n,params:{side:r}}),Lt=(t,e,r,n,o,s)=>t.fetchWithTimeout(`${It}/reserves/${e}/${r}/${St(n)}/holders`,{...s,params:{side:o}}),Dt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/hubs/${e}/holders`,{...n,params:{side:r}}),Wt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/spokes/${e}/holders`,{...n,params:{side:r}}),Ft=(t,e,r,n)=>t.fetchWithTimeout(`${It}/assets/${St(e)}/graph`,{...n,params:{...r}}),zt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/hubs/${e}/graph`,{...n,params:{...r}}),Vt=(t,e,r,n)=>t.fetchWithTimeout(`${It}/spokes/${e}/graph`,{...n,params:{...r}}),Xt=(t,e,r,n,o,s)=>t.fetchWithTimeout(`${It}/reserves/${e}/${r}/${St(n)}/graph`,{...s,params:{...o}}),jt=(t,e,r={},n)=>t.fetchWithTimeout(`${It}/users/${St(e)}/activity`,{...n,params:{...r}}),Gt=(t,e,r={},n)=>t.fetchWithTimeout(`${It}/users/${St(e)}/activity/page`,{...n,params:{...r}}),Ht=(t,e={},r)=>t.fetchWithTimeout(`${It}/governance/proposals`,{...r,params:{...e}}),Kt=(t,e={},r)=>t.fetchWithTimeout(`${It}/positions`,{...r,params:{...e}}),Zt=(t,e={},r)=>t.fetchWithTimeout(`${It}/participants`,{...r,params:{...e}}),Yt=(t,e={},r)=>t.fetchWithTimeout(`${It}/liquidations/leaderboard`,{...r,params:{...e}}),Jt=(t,e={},r)=>t.fetchWithTimeout(`${It}/distribution`,{...r,params:{...e}}),Qt=(t,e={},r)=>t.fetchWithTimeout(`${It}/campaign/leaderboard`,{...r,params:{...e}}),te=(t,e,r)=>t.fetchWithTimeout(`${It}/stats/history`,{...r,params:{...e}}),ee=(t,e,r)=>t.fetchWithTimeout(`${It}/revenue`,{...r,params:{...e}}),re=(t,e,r)=>t.fetchWithTimeout(`${It}/revenue/fees`,{...r,params:{...e}}),ne=(t,e,r)=>t.fetchWithTimeout(`${It}/liquidations`,{...r,params:{...e}}),oe=(t,e,r)=>t.fetchWithTimeout(`${It}/volume`,{...r,params:{...e}}),se=(t,e,r)=>t.fetchWithTimeout(`${It}/active-users`,{...r,params:{...e}}),ie=(t,e,r)=>t.fetchWithTimeout(`${It}/rate-spread`,{...r,params:{...e}}),ae=(t,e,r)=>t.fetchWithTimeout(`${It}/defillama`,{...r,params:{...e}}),ue=(t,e,r,n)=>t.fetchWithTimeout(`${It}/users/${St(e)}/history`,{...n,params:{...r}}),le=(t,e,r)=>t.fetchWithTimeout(`${It}/pnl`,{...r,params:{accountId:e}}),ce=(t,e,r)=>t.fetchWithTimeout(`${It}/pnl/scope`,{...r,params:{scope:e}}),fe=(t,e,r)=>t.fetchWithTimeout(`${It}/campaign/me`,{...r,params:{owner:e}}),pe=t=>({context:e=>_t(t,e),liveState:e=>Bt(t,e),marketsDetailed:e=>Et(t,e),assets:e=>Rt(t,e),hubs:e=>At(t,e),spokes:e=>kt(t,e),reserves:(e={},r)=>void 0!==r||"hubId"in e||"spokeId"in e||"asset"in e?qt(t,e,r):qt(t,{},e),reserve:(e,r,n,o)=>xt(t,e,r,n,o),asset:(e,r)=>Tt(t,e,r),hub:(e,r)=>Ut(t,e,r),spoke:(e,r)=>$t(t,e,r),userPositions:(e,r)=>Ot(t,e,r),accountPositions:(e,r)=>Ct(t,e,r),walletBalance:(e,r,n)=>Nt(t,e,r,n),assetPage:(e,r,n)=>Pt(t,e,r,n),assetMarkets:(e,r,n)=>Mt(t,e,r,n),reserveHolders:(e,r,n,o,s)=>Lt(t,e,r,n,o,s),hubHolders:(e,r,n)=>Dt(t,e,r,n),spokeHolders:(e,r,n)=>Wt(t,e,r,n),assetGraph:(e,r,n)=>Ft(t,e,r,n),hubGraph:(e,r,n)=>zt(t,e,r,n),spokeGraph:(e,r,n)=>Vt(t,e,r,n),reserveGraph:(e,r,n,o,s)=>Xt(t,e,r,n,o,s),userActivity:(e,r={},n)=>jt(t,e,r,n),userActivityPage:(e,r={},n)=>Gt(t,e,r,n),governanceProposals:(e={},r)=>Ht(t,e,r),positionsLeaderboard:(e={},r)=>Kt(t,e,r),participants:(e={},r)=>Zt(t,e,r),liquidationsLeaderboard:(e={},r)=>Yt(t,e,r),distribution:(e={},r)=>Jt(t,e,r),campaignLeaderboard:(e={},r)=>Qt(t,e,r),statsHistory:(e,r)=>te(t,e,r),revenue:(e,r)=>ee(t,e,r),feeRevenue:(e,r)=>re(t,e,r),liquidations:(e,r)=>ne(t,e,r),volume:(e,r)=>oe(t,e,r),activeUsers:(e,r)=>se(t,e,r),rateSpread:(e,r)=>ie(t,e,r),defillama:(e,r)=>ae(t,e,r),userHistory:(e,r,n)=>ue(t,e,r,n),positionsPnl:(e,r)=>le(t,e,r),pnlByScope:(e,r)=>ce(t,e,r),campaignMe:(e,r)=>fe(t,e,r)}),de=t=>K({base_borrow_rate:C(t.baseBorrowRateRay),max_borrow_rate:C(t.maxBorrowRateRay),max_utilization:C(t.maxUtilizationRay),mid_utilization:C(t.midUtilizationRay),optimal_utilization:C(t.optimalUtilizationRay),reserve_factor:N(t.reserveFactorBps),slope1:C(t.slope1Ray),slope2:C(t.slope2Ray),slope3:C(t.slope3Ray)}),he=t=>K({asset_decimals:N(t.assetDecimals),asset_id:O(t.assetId),base_borrow_rate:C(t.baseBorrowRateRay),flashloan_fee:N(t.flashloanFeeBps),is_flashloanable:M(t.isFlashloanable),max_borrow_rate:C(t.maxBorrowRateRay),max_utilization:C(t.maxUtilizationRay),mid_utilization:C(t.midUtilizationRay),optimal_utilization:C(t.optimalUtilizationRay),reserve_factor:N(t.reserveFactorBps),slope1:C(t.slope1Ray),slope2:C(t.slope2Ray),slope3:C(t.slope3Ray)}),me=t=>K({max_borrow_positions:N(t.maxBorrowPositions),max_supply_positions:N(t.maxSupplyPositions)}),ge=t=>{if("Token"in t&&t.Token)return F([D("Token"),O(t.Token)]);if("Ref"in t&&t.Ref)return F([D("Ref"),D(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},ye=t=>{if("Stellar"in t)return F([D("Stellar"),O(t.Stellar)]);if("Symbol"in t)return F([D("Symbol"),D(t.Symbol)]);if("String"in t)return F([D("String"),L(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},we=t=>{if("Spot"===t)return F([D("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return F([D("Twap"),N(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},be=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return F([D(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},ve=t=>{if("Market"===t||"Fundamental"===t)return F([D(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},Ie=t=>{if("Reflector"in t){const e=t.Reflector;return F([D("Reflector"),K({asset:ye(e.asset),contract:O(e.contract),read_mode:we(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return F([D("MultiFeed"),K({contract:O(e.contract),feed_id:L(e.feedId),kind:be(e.kind),nature:ve(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},Se=t=>{const e=t;return K({decimals:N(e.decimals),max_stale_seconds:P(e.maxStaleSeconds),provider:Ie(e.provider)})},_e=t=>{if("RequireDisjoint"===t)return F([D("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return F([D("AllowShared"),F(e.map((t=>K({contract:O(t.contract),kind:be(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},Be=t=>{const e=t,r=e.sources??[];let n,o;if("number"==typeof e.toleranceBps)n=1e4+e.toleranceBps,o=Math.max(1,Math.floor(1e8/n));else{const t=e.tolerance??{};n=Number(t.upperRatioBps),o=Number(t.lowerRatioBps)}return K({asset_decimals:N(Number(e.assetDecimals)),independence:_e(e.independence),max_price_stale_seconds:P(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:C(String(e.maxSanityPriceWad)),min_sanity_price_wad:C(String(e.minSanityPriceWad)),sources:F(r.map((t=>(t=>{if("Feed"in t)return F([D("Feed"),Se(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return F([D("Scaled"),K({factor:Se(e.factor),max_factor_wad:C(e.maxFactorWad),min_factor_wad:C(e.minFactorWad),quote:ge(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return F([D("LpShare"),K({key_a:ge(e.keyA),key_b:ge(e.keyB),kind:F([D(e.kind||"ConstantProduct")]),pool:O(e.pool),reserve_a_decimals:N(e.reserveADecimals),reserve_b_decimals:N(e.reserveBDecimals),share_decimals:N(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:K({lower_ratio_bps:N(o),upper_ratio_bps:N(n)})})},Ee=Be;function Re(t,e){return nt(t,"upgrade",[z(e.wasmHash)])}function Ae(t,e){return nt(t,"migrate",[N(e.newVersion)])}function ke(t){return nt(t,"pause",[])}function qe(t){return nt(t,"unpause",[])}function xe(t,e){return nt(t,"grant_role",[O(e.account),D(e.role)])}function Te(t,e){return nt(t,"revoke_role",[O(e.account),D(e.role)])}function Ue(t,e){return nt(t,"transfer_ownership",[O(e.newOwner),N(e.liveUntilLedger)])}function $e(t){return nt(t,"accept_ownership",[])}function Oe(t,e){return nt(t,"set_swap_aggregator",[O(e.aggregator)])}function Ce(t,e){return nt(t,"set_price_aggregator",[O(e.aggregator)])}const Ne=Oe;function Pe(t,e){return nt(t,"set_accumulator",[O(e.accumulator)])}function Me(t,e){return nt(t,"set_position_limits",[me(e)])}function Le(t,e){return nt(t,"approve_blend_pool",[O(e.pool)])}function De(t,e){return nt(t,"revoke_blend_pool",[O(e.pool)])}const We=Le,Fe=De;function ze(t,e){return nt(t,"set_oracle",[ge(e.key),Be(e.oracle)])}const Ve=ze;function Xe(t,e){const r=e.toleranceBps,n=e.upperRatioBps??1e4+r,o=e.lowerRatioBps??Math.max(1,Math.floor(1e8/n));return nt(t,"set_tolerance",[ge(e.key),K({lower_ratio_bps:N(o),upper_ratio_bps:N(n)})])}function je(t,e){return nt(t,"set_spoke_asset_flags",[N(e.spokeId),X(e.hubId,e.asset),M(e.paused),M(e.frozen),M(e.noSeize)])}function Ge(t,e){return nt(t,"set_oracle_sanity_bounds",[O(e.asset),C(e.minPriceWad),C(e.maxPriceWad)])}function He(t,e){return nt(t,"update_indexes",[O(t.caller),F(e.assets.map((t=>X(t.hubId,t.asset))))])}function Ke(t,e){return nt(t,"renew_account",[O(t.caller),P(e.accountNonce)])}function Ze(t,e){return nt(t,"create_liquidity_pool",[N(e.hubId),O(e.asset),he(e.params)])}function Ye(t,e){return nt(t,"upgrade_liquidity_pool_params",[X(e.hubId,e.asset),de(e.params)])}function Je(t,e){return nt(t,"claim_revenue",[O(t.caller),F(e.assets.map((t=>X(t.hubId,t.asset))))])}function Qe(t,e){return nt(t,"add_rewards",[O(t.caller),G(e.rewards)])}function tr(t,e){return nt(t,"update_account_threshold",[O(t.caller),M(e.hasRisks),F(e.accountNonces.map((t=>P(t))))])}const er="00".repeat(32),rr=t=>{if("string"==typeof t)return z(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 c.ScVal.scvBytes(e)},nr=(t,...e)=>F([D(t),...e]),or=t=>K({new_owner:O(t.newOwner),live_until_ledger:N(t.liveUntilLedger)}),sr=t=>K({asset:O(t.asset),bonus:N(t.bonus),borrow_cap:C(t.borrowCap),can_borrow:M(t.canBorrow),can_collateral:M(t.canCollateral),frozen:M(t.frozen),hub_id:N(t.hubId),paused:M(t.paused),liquidation_fees:N(t.liquidationFees),ltv:N(t.ltv),no_seize:M(t.noSeize),spoke_id:N(t.spokeId),supply_cap:C(t.supplyCap),threshold:N(t.threshold)}),ir=t=>K({account:O(t.account),role:D(t.role)});function ar(e,r,s){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const i=new o(e.governanceAddress),u=new t(e.caller,e.sourceSequence);return{xdr:new a(u,{fee:e.fee??n,networkPassphrase:w[e.network]}).addOperation(i.call(r,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ur=(t,e,r)=>ar(t,"propose",[O(t.caller),e,rr(r)]),lr=(t,e,r)=>ar(t,"execute_self",[W(),e,rr(r)]);function cr(t,e,r){return ur(t,nr("SetSwapAggregator",O(e.aggregator)),r)}function fr(t,e,r){return ur(t,nr("SetPriceAggregator",O(e.aggregator)),r)}const pr=cr;function dr(t,e,r){return ur(t,nr("SetAccumulator",O(e.accumulator)),r)}function hr(t,e,r){return ur(t,nr("SetPositionLimits",me(e)),r)}function mr(t,e){return ur(t,nr("CreateHub"),e)}function gr(t,e){return ur(t,nr("AddSpoke"),e)}function yr(t,e,r){return ur(t,nr("RemoveSpoke",N(e.spokeId)),r)}function wr(t,e,r){return ur(t,nr("AddAssetToSpoke",sr(e)),r)}function br(t,e,r){return ur(t,nr("EditAssetInSpoke",sr(e)),r)}function vr(t,e,r){return ur(t,nr("RemoveAssetFromSpoke",K({hub_asset:X((n=e).hubId,n.asset),spoke_id:N(n.spokeId)})),r);var n}function Ir(t,e,r){return ur(t,nr("SetSpokeLiquidationCurve",K({hf_for_max_bonus_wad:C((n=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:N(n.liquidationBonusFactorBps),spoke_id:N(n.spokeId),target_hf_wad:C(n.targetHfWad)})),r);var n}function Sr(t,e,r){return ur(t,nr("SetPositionManager",O(e.manager),M(e.isActive)),r)}function _r(t,e,r){return ur(t,nr("SetMinBorrowCollateralUsd",C(e.floorWad)),r)}function Br(t,e,r){return ur(t,nr("ApproveToken",O(e.token)),r)}function Er(t,e,r){return ur(t,nr("RevokeToken",O(e.token)),r)}function Rr(t,e,r){return ur(t,nr("ApproveBlendPool",O(e.pool)),r)}function Ar(t,e,r){return ur(t,nr("RevokeBlendPool",O(e.pool)),r)}function kr(t,e,r){return ur(t,nr("CreateLiquidityPool",K({asset:O((n=e).asset),hub_id:N(n.hubId),params:he(n.params)})),r);var n}function qr(t,e,r){return ur(t,nr("UpgradeLiquidityPoolParams",K({hub_asset:X((n=e).hubId,n.asset),params:de(n.params)})),r);var n}function xr(t,e,r){return ur(t,nr("DeployPool",z(e.wasmHash)),r)}function Tr(t,e,r){return ur(t,nr("UpgradePool",z(e.wasmHash)),r)}function Ur(t,e,r){return ur(t,nr("UpgradeController",z(e.wasmHash)),r)}function $r(t,e,r){return ur(t,nr("MigrateController",N(e.newVersion)),r)}function Or(t,e,r){return ur(t,nr("TransferCtrlOwnership",or(e)),r)}function Cr(t,e,r){return ur(t,nr("ConfigureAssetOracle",K({key:ge((n=e).key),oracle:Be(n.oracle)})),r);var n}const Nr=Cr;function Pr(t,e,r){return ur(t,nr("EditOracleTolerance",K({key:ge((n=e).key),tolerance:N(n.tolerance)})),r);var n}function Mr(t,e,r){return ur(t,nr("UpgradeGov",z(e.wasmHash)),r)}function Lr(t,e,r){return ur(t,nr("UpdateGovDelay",N(e.newDelay)),r)}function Dr(t,e,r){return ur(t,nr("GrantGovRole",ir(e)),r)}function Wr(t,e,r){return ur(t,nr("RevokeGovRole",ir(e)),r)}function Fr(t,e,r){return ur(t,nr("TransferGovOwnership",or(e)),r)}function zr(t,e){const r=F(e.argsXdr.map((t=>c.ScVal.fromXDR(t,"base64")))),n=rr(e.predecessor??er);return ar(t,"execute",[W(),O(e.target),D(e.functionName),r,n,rr(e.salt)])}function Vr(t,e,r){return lr(t,nr("UpgradeGov",z(e.wasmHash)),r)}function Xr(t,e,r){return lr(t,nr("UpdateGovDelay",N(e.newDelay)),r)}function jr(t,e,r){return lr(t,nr("GrantGovRole",ir(e)),r)}function Gr(t,e,r){return lr(t,nr("RevokeGovRole",ir(e)),r)}function Hr(t,e,r){return lr(t,nr("TransferGovOwnership",or(e)),r)}const Kr=t=>F(t.map(O));function Zr(t,e,r){return ar(t,"propose_canceller_reset",[Kr(e.newCancellers),rr(r)])}function Yr(t,e,r){return ar(t,"execute_canceller_reset",[V(e.executor,O),Kr(e.newCancellers),rr(r)])}function Jr(t,e){return ar(t,"set_spoke_asset_flags",[O(t.caller),N(e.spokeId),X(e.hubId,e.asset),M(e.paused),M(e.frozen),M(e.noSeize)])}function Qr(t,e){return ar(t,"set_oracle_sanity_bounds",[O(t.caller),O(e.asset),C(e.minPriceWad),C(e.maxPriceWad)])}function tn(t){return ar(t,"create_hub",[O(t.caller)])}function en(t){return ar(t,"add_spoke",[O(t.caller)])}function rn(t,e){return ar(t,"revoke_role_immediate",[O(e.account),D(e.role)])}function nn(t){return ar(t,"pause",[O(t.caller)])}function on(t,e){return ur(t,nr("Unpause"),e)}const sn=t=>t.toXDR("base64"),an=t=>c.ScVal.fromXDR(t,"base64"),un=t=>t.map((t=>String(l(an(t))))).join(":"),ln=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),cn=t=>Number(t),fn=t=>String(t),pn=t=>t instanceof Uint8Array?b.hp.from(t).toString("hex"):b.hp.isBuffer(t)?t.toString("hex"):String(t),dn=["None","Multiply","Long","Short"],hn=["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"],mn=t=>Array.isArray(t)?t:[],gn=(t,e)=>{const r="Borrow"===e;return{action:(n=t[0],hn[cn(n)]??ln(n)),positionType:e,hubId:cn(t[1]),asset:fn(t[2]),scaledAmountRay:ln(t[3]),indexRay:ln(t[4]),amount:ln(t[5]),liquidationThresholdBps:r?void 0:cn(t[6]),liquidationBonusBps:r?void 0:cn(t[7]),loanToValueBps:r?void 0:cn(t[8]),liquidationFeesBps:r?void 0:cn(t[9])};var n},yn=t=>{return{owner:fn(t[0]),spokeId:cn(t[1]),mode:(e=t[2],dn[cn(e)]??"None")};var e},wn=t=>Array.isArray(t)?t[1]:void 0,bn=t=>{const e=(r=t,Array.isArray(r)?fn(r[0]):fn(r));var r;if("Token"===e)return{Token:fn(wn(t))};if("Ref"===e)return{Ref:fn(wn(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:fn(e.Token)};if(void 0!==e.Ref)return{Ref:fn(e.Ref)}}return{Token:fn(t)}},vn=t=>{const e=t.tolerance??{};return{assetDecimals:cn(t.asset_decimals),maxPriceStaleSeconds:cn(t.max_price_stale_seconds),sources:mn(t.sources).map((t=>t)),tolerance:{upperRatio:cn(e.upper_ratio_bps),lowerRatio:cn(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:ln(t.min_sanity_price_wad),maxSanityPriceWad:ln(t.max_sanity_price_wad)}},In={"market:create":t=>({topic:"market:create",data:{hubId:cn(t.hub_id),baseAsset:fn(t.base_asset),maxBorrowRate:ln(t.max_borrow_rate),baseBorrowRate:ln(t.base_borrow_rate),slope1:ln(t.slope1),slope2:ln(t.slope2),slope3:ln(t.slope3),midUtilization:ln(t.mid_utilization),optimalUtilization:ln(t.optimal_utilization),maxUtilization:ln(t.max_utilization),reserveFactor:cn(t.reserve_factor),marketAddress:fn(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:fn(t.asset),maxBorrowRateRay:ln(t.max_borrow_rate),baseBorrowRateRay:ln(t.base_borrow_rate),slope1Ray:ln(t.slope1),slope2Ray:ln(t.slope2),slope3Ray:ln(t.slope3),midUtilizationRay:ln(t.mid_utilization),optimalUtilizationRay:ln(t.optimal_utilization),maxUtilizationRay:ln(t.max_utilization),reserveFactorBps:cn(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:mn(t).map((t=>{return e=mn(t),{hubId:cn(e[0]),asset:fn(e[1]),timestamp:cn(e[2]),supplyIndexRay:ln(e[3]),borrowIndexRay:ln(e[4]),cash:ln(e[5]),suppliedRay:ln(e[6]),borrowedRay:ln(e[7]),revenueRay:ln(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:mn(t).map((t=>{const e=t;return{hubId:cn(e.hub_id),asset:fn(e.asset),params:(r=e.params,{maxBorrowRateRay:ln(r.max_borrow_rate),baseBorrowRateRay:ln(r.base_borrow_rate),slope1Ray:ln(r.slope1),slope2Ray:ln(r.slope2),slope3Ray:ln(r.slope3),midUtilizationRay:ln(r.mid_utilization),optimalUtilizationRay:ln(r.optimal_utilization),maxUtilizationRay:ln(r.max_utilization),reserveFactorBps:cn(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:cn(r.flashloan_fee),assetId:fn(r.asset_id),assetDecimals:cn(r.asset_decimals)})};var r}))}}),"position:batch_update":t=>{const e=mn(t);return{topic:"position:batch_update",data:{accountId:ln(e[0]),accountAttributes:yn(mn(e[1])),updates:[...mn(e[2]).map((t=>gn(mn(t),"Deposit"))),...mn(e[3]).map((t=>gn(mn(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:cn(t.hub_id),asset:fn(t.asset),receiver:fn(t.receiver),caller:fn(t.caller),amount:ln(t.amount),fee:ln(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:bn(t.key),oracle:vn(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:fn(t.asset),oracle:vn(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:fn(t.liquidator),accountId:ln(t.account_id),repaidUsdWad:ln(t.repaid_usd_wad),bonusBps:ln(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:ln(t.account_id),totalBorrowUsdWad:ln(t.total_borrow_usd_wad),totalCollateralUsdWad:ln(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:fn(t.token),amount:ln(t.amount),usdValueWad:ln(t.usd_value_wad),accountId:ln(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:cn(t.hub_id),asset:fn(t.asset),amount:ln(t.amount),fee:ln(t.fee),amountSent:ln(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:fn(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:pn(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:fn(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:fn(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:fn(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:fn(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:pn(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:cn(t.max_supply_positions),maxBorrowPositions:cn(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:ln(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:fn(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:cn(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:ln(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:ln(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:cn(e.liquidation_bonus_factor_bps)}}}},Sn=Object.freeze(Object.keys(In));function _n(t,e){const r=un(t),n=In[r];return n?n(l(an(e))):null}const Bn=1e4;function En(t,e){return`${t}-${BigInt(e).toString(10)}`}function Rn(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function An(t,e=0){return 1e4*t+e}function kn(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 qn=(t,e,r)=>{const n=new URL(e,t.endsWith("/")?t:`${t}/`);if(r)for(const[t,e]of Object.entries(r))void 0!==e&&n.searchParams.set(t,String(e));return n.toString()};async function xn(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 r=qn(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}),n=await fetch(r,e.fetchOptions);if(!n.ok){const t=await n.text().catch((()=>""));throw new Error(`Stellar quote server responded ${n.status} ${n.statusText} for ${r} — ${t}`)}return await n.json()}async function Tn(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=qn(t.baseUrl,"api/v1/tokens"),r=await fetch(e,t.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${e} — ${t}`)}return await r.json()}const Un=10,$n=5,On=3,Cn=Un+$n*x+On*T,Nn=16384;class Pn extends Error{code;constructor(t,e){super(`Stellar route verification failed [${t}]: ${e}`),this.name="StellarRouteVerificationError",this.code=t}}const Mn=(t,e)=>{throw new Pn(t,e)},Ln=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*Nn)return Mn("OVERSIZED",`encoded route has ${e.length} characters`);try{return b.hp.from(et(t).bytes())}catch(t){return Mn("MALFORMED",t instanceof Error?t.message:String(t))}},Dn=t=>{let e;try{e=c.ScVal.fromXDR(t)}catch(t){return Mn("MALFORMED",`payload is not one XDR ScVal: ${t instanceof Error?t.message:String(t)}`)}if("scvMap"!==e.switch().name)return Mn("MALFORMED","payload must be a StrategyPayload map");const r=e.map()??[];if("amounts,assets,ops"!==r.map((t=>"scvSymbol"===t.key().switch().name?t.key().sym().toString():"")).join(","))return Mn("MALFORMED","payload fields must be exactly amounts, assets, ops");const[n,o,s]=r.map((t=>t.val()));return"scvVec"!==n.switch().name||"scvVec"!==o.switch().name||"scvBytes"!==s.switch().name?Mn("MALFORMED","payload field has the wrong type"):{amounts:n.vec()??[],assets:o.vec()??[],ops:b.hp.from(s.bytes())}};function Wn(t){const r=Ln(t);0===r.length&&Mn("MALFORMED","route is empty"),r.length>Nn&&Mn("OVERSIZED",`route has ${r.length} bytes, above ${Nn}`);const n=Dn(r),o=n.assets.length,s=n.amounts.length;0===o&&Mn("MALFORMED","asset registry is empty"),(o>U||s>$)&&Mn("OVERSIZED",`registries hold ${o} assets and ${s} amounts`);const i=n.assets.map(((t,r)=>"scvAddress"!==t.switch().name?Mn("MALFORMED",`assets[${r}] is not an address`):e.fromScAddress(t.address()).toString())),a=n.amounts.map(((t,e)=>"scvI128"!==t.switch().name?Mn("MALFORMED",`amounts[${e}] is not an i128`):u(t))),l=n.ops;l.length<Un&&Mn("MALFORMED","program header is truncated"),l.length>Cn&&Mn("OVERSIZED",`program has ${l.length} bytes, above ${Cn}`);const c=t=>{const e=l[t];return void 0===e?Mn("MALFORMED",`program byte ${t} is missing`):e},f=c(0);f!==S&&Mn("UNSUPPORTED_VERSION",`program version ${f}, expected ${S}`);const p=c(8),d=c(9);0===p&&Mn("INVALID_STRUCTURE","program has no instructions"),(p>x||d>T)&&Mn("OVERSIZED",`program declares ${p} instructions and ${d} weights`);const h=Un+$n*p;l.length!==h+On*d&&Mn("MALFORMED","program length does not match its instruction and weight counts");const m=c(1),g=c(2),y=c(3);(m>=o||g>=o||y>=s)&&Mn("MALFORMED","header index is outside its registry"),m===g&&Mn("INVALID_STRUCTURE","token_in equals token_out");const w=l.readUInt32BE(4),b=[];for(let t=0;t<d;t+=1){const e=l.readUIntBE(h+On*t,On);(0===e||e>_)&&Mn("INVALID_STRUCTURE",`split weight ${e} outside 1..=${_}`),b.push(e)}const I=t=>i[t]??Mn("MALFORMED",`asset index ${t} is outside the registry`),O=t=>a[t]??Mn("MALFORMED",`amount index ${t} is outside the registry`),C=[];let N;for(let t=0;t<p;t+=1){const e=Un+$n*t,r=c(e),n=c(e+1),o=c(e+2),i=c(e+3),a=c(e+4);let u;if(r>E&&Mn("UNKNOWN_OPCODE",`instruction ${t} has opcode ${r}`),n===R)u={kind:"all"};else if(n===A)void 0!==N&&N===i||Mn("INVALID_STRUCTURE",`instruction ${t} does not chain onto its predecessor`),u={kind:"prev"};else if(n>=q){const e=b[n-q];void 0===e&&Mn("MALFORMED",`instruction ${t} weight index is out of range`),u={kind:"ppm",ppm:e}}else u={kind:"fixed",amount:O(n-k)};const l=I(o);r!==B&&r!==E?(i===a&&Mn("INVALID_STRUCTURE",`instruction ${t} swaps a token for itself`),C.push({kind:"swap",venue:v[r],mode:u,pool:l,tokenIn:I(i),tokenOut:I(a)}),N=a):("all"!==u.kind&&Mn("MALFORMED",`liquidity instruction ${t} must use mode All`),a>=s&&Mn("MALFORMED",`instruction ${t} amount index is out of range`),C.push({kind:r===B?"burn":"mint",pool:l,shareToken:I(i),amountIndex:a}),N=r===E?i:void 0)}const P=O(y);return P<=0n&&Mn("MIN_OUT_TOO_LOW",`encoded total_min_out is ${P}`),{version:f,tokenIn:I(m),tokenOut:I(g),totalMinOut:P,referralId:w,assets:i,amounts:a,ops:C,weights:b}}function Fn(t,e){if(i.isValidContract(t))return t;if(!e)return Mn("EXPECTATION_MISSING",`token ${t} is not a contract id; pass \`network\` to derive its asset contract`);try{const n=t.indexOf(":");return("XLM"===t||"native"===t?r.native():new r(t.slice(0,n),t.slice(n+1))).contractId(w[e])}catch{return Mn("MALFORMED",`token id ${t} is not a contract id or a classic asset`)}}const zn=(t,e)=>"bigint"==typeof t?t:/^\d+$/.test(t)?BigInt(t):Mn("EXPECTATION_MISSING",`${e} must be a base-unit integer string`);function Vn(t,e){const r=zn(e.minOut,"expected.minOut");r<=0n&&Mn("EXPECTATION_MISSING","expected.minOut must be positive");const n=Wn(t);if(n.tokenIn!==e.tokenIn&&Mn("TOKEN_IN_MISMATCH",`route spends ${n.tokenIn}, expected ${e.tokenIn}`),n.tokenOut!==e.tokenOut&&Mn("TOKEN_OUT_MISMATCH",`route delivers ${n.tokenOut}, expected ${e.tokenOut}`),n.totalMinOut<r&&Mn("MIN_OUT_TOO_LOW",`route enforces a minimum of ${n.totalMinOut}, below the expected ${r}`),void 0!==e.amountIn){const t=zn(e.amountIn,"expected.amountIn");for(const e of n.ops)"swap"===e.kind&&"fixed"===e.mode.kind&&e.tokenIn===n.tokenIn&&e.mode.amount>t&&Mn("AMOUNT_IN_EXCEEDED",`a leg spends ${e.mode.amount}, above the input ${t}`)}return n}const Xn=(t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t,jn=t=>Y(t).toXDR("base64");function Gn(e,r){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const s=new o(e.routerAddress),i=new t(e.caller,e.sourceSequence),u=et(Xn(r,e.referralId));return{xdr:new a(i,{fee:e.fee??n,networkPassphrase:w[e.network]}).addOperation(s.call("execute_strategy",O(e.caller),C(e.totalIn),u)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Hn(t,e){return Gn(t,e)}function Kn(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(Jn),splitPpm:t.splitPpm}))):[{hops:t.hops.map(Jn),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Zn(t,e={}){const r=e.expected??{},n="string"==typeof t.routeXdr&&t.routeXdr.length>0?{routeXdr:t.routeXdr}:Kn(t,e),o=[t.amountOutMin,r.minOut].filter((t=>void 0!==t)).map((t=>{if("bigint"==typeof t)return t;if("string"!=typeof t||!/^\d+$/.test(t))throw new Pn("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===o)throw new Pn("EXPECTATION_MISSING","quote has no `amountOutMin`; pass `slippage` when fetching it or `expected.minOut`");return Vn(n,{tokenIn:Fn(r.tokenIn??t.from,e.network),tokenOut:Fn(r.tokenOut??t.to,e.network),minOut:o,amountIn:r.amountIn??t.amountIn}),n}const Yn=Kn,Jn=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});class Qn extends Error{code;offender;constructor(t,e,r){super(`Stellar authorization check failed [${t}]: ${e}${r?` — ${r.contract}.${r.fn}(${r.args.join(", ")})`:""}`),this.name="StellarAuthPolicyError",this.code=t,this.offender=r}}const to=t=>"scvAddress"===t?.switch().name?e.fromScAddress(t.address()).toString():void 0,eo=t=>"scvI128"===t?.switch().name?u(t):void 0,ro=t=>"scvVec"===t?.switch().name?t.vec()??[]:void 0,no=(t,e)=>"scvMap"===t?.switch().name?(t.map()??[]).find((t=>"scvSymbol"===t.key().switch().name&&t.key().sym().toString()===e))?.val():void 0,oo=t=>to(t)??eo(t)?.toString()??t.toXDR("base64"),so=t=>({contract:e.fromScAddress(t.contractAddress()).toString(),fn:t.functionName().toString(),args:t.args().map(oo)}),io=t=>{const e=t.function();return"sorobanAuthorizedFunctionTypeContractFn"===e.switch().name?e.contractFn():void 0};function ao(t,r,n){const o=t.filter((t=>{const o=t.credentials();return("sorobanCredentialsAddress"===o.switch().name?e.fromScAddress(o.address().address()).toString():n??r.caller)===r.caller}));if(o.length>1)throw new Qn("DUPLICATE_ENTRY",`${o.length} authorization entries for ${r.caller}, expected one`);const s=o[0];if(!s)return;const i=io(s.rootInvocation());if(!i)throw new Qn("UNEXPECTED_ROOT","root is not a contract call");const a=so(i);if(a.contract!==r.root.contract||a.fn!==r.root.fn)throw new Qn("UNEXPECTED_ROOT",`expected ${r.root.contract}.${r.root.fn}`,a);const u=r.transfers.map((()=>0n)),l=(r.calls??[]).map((()=>0));for(const t of s.rootInvocation().subInvocations()){const e=io(t);if(!e)throw new Qn("UNEXPECTED_CALL","sub-invocation is not a contract call");const n=so(e);if(t.subInvocations().length>0)throw new Qn("NESTED_INVOCATION","sub-invocation carries its own sub-invocations",n);const o=(r.calls??[]).findIndex((t=>t.contract===n.contract&&t.fn===n.fn));if(-1!==o){const t=(r.calls??[])[o],s=t.reject(e.args());if(s)throw new Qn("UNEXPECTED_CALL",s,n);if(l[o]=(l[o]??0)+1,(l[o]??0)>t.maxCount)throw new Qn("UNEXPECTED_CALL",`more than ${t.maxCount} calls`,n);continue}if("transfer"!==n.fn||3!==e.args().length)throw new Qn("UNEXPECTED_CALL","only `transfer` is allowed",n);if(!r.transfers.some((t=>t.token===n.contract)))throw new Qn("UNEXPECTED_TOKEN","transfer on an unexpected token",n);const[s,i,a]=e.args();if(to(s)!==r.caller)throw new Qn("UNEXPECTED_SENDER","transfer is not from the caller",n);const c=to(i),f=r.transfers.findIndex((t=>t.token===n.contract&&t.to===c));if(-1===f)throw new Qn("UNEXPECTED_RECIPIENT","transfer to an unexpected recipient",n);const p=eo(a),d=r.transfers[f],h=(u[f]??0n)+(p??0n);if(void 0===p||p<=0n||h>d.maxAmount)throw new Qn("AMOUNT_EXCEEDED",`transfers total ${h}, above the expected ${d.maxAmount}`,n);u[f]=h}}const uo=t=>{throw new Qn("MALFORMED_TRANSACTION",t)},lo=(t,e)=>{const r=new Map;for(const e of ro(t)??uo("payments argument is not a vector")){const[t,n]=ro(e)??[],o=to(no(t,"asset")),s=eo(n);if(void 0===o||void 0===s||s<0n)return uo("payment is not a (HubAssetKey, i128) tuple");r.set(o,(r.get(o)??0n)+s)}return[...r].map((([t,r])=>({token:t,to:e,maxAmount:r})))},co=new Set([1,3,5]),fo=(t,e,r)=>({contract:t,fn:"submit",maxCount:2,reject:t=>{if(4!==t.length)return"submit must have four arguments";if(to(t[0])!==e)return"`from` is not the caller";if(to(t[1])!==r||to(t[2])!==r)return"`spender` and `to` must be the lending controller";const n=ro(t[3]);if(!n)return"requests is not a vector";for(const t of n){const e=no(t,"request_type");if("scvU32"!==e?.switch().name||!co.has(e.u32()))return"request is not a withdraw, withdraw-collateral, or repay"}}});function po(t,e,r){const{contract:n,fn:o}=so(e),s=e.args(),i={caller:t,root:{contract:n,fn:o},transfers:[]};if(n===r.governance)return i;if(n===r.aggregatorRouter){if("execute_strategy"!==o)return i;const e=eo(s[1]);if(to(s[0])!==t||void 0===e||"scvBytes"!==s[2]?.switch().name)return uo("execute_strategy arguments must be (caller, total_in, swap_xdr)");const r=Wn(s[2].bytes());return i.transfers=[{token:r.tokenIn,to:n,maxAmount:e}],i}if(n!==r.lendingController)throw new Qn("UNSUPPORTED_CONTRACT",`no authorization policy for contract ${n}; pass an explicit policy`);if(to(s[0])!==t)throw new Qn("CALLER_MISMATCH",`${o} is not invoked for ${t}`);switch(o){case"supply":i.transfers=lo(s[3],r.lendingPool);break;case"repay":case"liquidate":i.transfers=lo(s[2],r.lendingPool);break;case"multiply":{const t=s[8];t&&"scvVoid"!==t.switch().name&&(i.transfers=lo(c.ScVal.scvVec([t]),n));break}case"migrate_from_blend":{const e=to(s[4])??uo("blend_pool is not an address");i.calls=[fo(e,t,n)];break}}return i}const ho=t=>{let e;try{e=c.TransactionEnvelope.fromXDR(t,"base64")}catch{return uo("not a transaction envelope")}if("envelopeTypeTx"!==e.switch().name)return uo("expected a regular (v1) transaction");const r=e.v1().tx(),n=r.operations()[0];if(!n||1!==r.operations().length)return uo("expected exactly one operation");const o=n.body();if("invokeHostFunction"!==o.switch().name)return uo("operation is not a contract invocation");const s=o.invokeHostFunctionOp();return"hostFunctionTypeInvokeContract"!==s.hostFunction().switch().name?uo("host function is not a contract call"):{source:(a=n.sourceAccount()??r.sourceAccount(),i.encodeEd25519PublicKey("keyTypeMuxedEd25519"===a.switch().name?a.med25519().ed25519():a.ed25519())),op:s,call:s.hostFunction().invokeContract()};var a};function mo(t,e){const r=ho(t);if(void 0!==e.builtXdr&&ho(e.builtXdr).op.hostFunction().toXDR("base64")!==r.op.hostFunction().toXDR("base64"))throw new Qn("INVOCATION_CHANGED","the prepared transaction does not invoke what was built",so(r.call));const n=e.policy??po(e.caller,r.call,{...y(e.network),...e.deployment});ao(r.op.auth(),n,r.source)}function go(t,e){const r=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${r}`)}async function yo(t,e,r){const n=a.fromXDR(e,r?.network?w[r.network]:"");try{return(await t.prepareTransaction(n)).toXDR()}catch(t){if(r?.invokedContractId)throw go(r.invokedContractId,t);throw t}}async function wo(t,e,r){return yo(t,e.xdr,r)}function bo(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 vo(t,e){return new Uint8Array(0)}const Io=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 So(e){const r=new t(e.caller,e.sourceSequence),n=new o(e.forwarderAddress).call("mint_and_forward",c.ScVal.scvBytes(Io(e.message)),c.ScVal.scvBytes(Io(e.attestation)));return{xdr:new a(r,{fee:e.fee??"10000000",networkPassphrase:w[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const _o=10n**27n,Bo=10n**18n,Eo=10000n,Ro=27,Ao=18;function ko(t,e="value"){let r;if("bigint"==typeof t)r=t;else if("number"==typeof t){if(!Number.isSafeInteger(t))throw new Error(`Stellar math: ${e} must be a safe integer, got ${t}`);r=BigInt(t)}else{const n=t.trim();if(!/^-?\d+$/.test(n))throw new Error(`Stellar math: ${e} must be a decimal integer string, got "${t}"`);r=BigInt(n)}if(r<0n)throw new Error(`Stellar math: ${e} must be non-negative, got ${r}`);return r}function qo(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");return t*e/r}function xo(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");const n=t*e,o=n/r;return n%r===0n?o:o+1n}function To(t,e,r){if(0n===r)throw new Error("Stellar math: division by zero");return(t*e+r/2n)/r}function Uo(t,e){if(0n===e)throw new Error("Stellar math: division by zero");const r=t/e;return t%e>=e/2n+e%2n?r+1n:r}const $o=t=>10n**BigInt(t);function Oo(t,e,r){return e===r?t:r>e?t*$o(r-e):t/$o(e-r)}function Co(t,e,r){if(e===r)return t;if(r>e)return t*$o(r-e);const n=$o(e-r),o=t/n;return t%n===0n?o:o+1n}function No(t,e,r){return e===r?t:r>e?t*$o(r-e):Uo(t,$o(e-r))}const Po={floor:qo,ceil:xo,halfUp:To},Mo={floor:Oo,ceil:Co,halfUp:No};function Lo(t,e,r,n){return Mo[n](Po[n](t,e,_o),Ro,r)}function Do(t,e,r){return Lo(ko(t,"scaledRay"),ko(e,"indexRay"),r,"floor")}function Wo(t,e,r){return Lo(ko(t,"scaledRay"),ko(e,"indexRay"),r,"ceil")}function Fo(t,e,r){return Lo(ko(t,"scaledRay"),ko(e,"indexRay"),r,"halfUp")}function zo(t,e){if(e>Ro)throw new Error(`Stellar math: decimals ${e} exceed RAY scale`);return Oo(t,e,Ro)}function Vo(t,e,r,n){const o=Po[n](t,e,_o),s=Mo[n](o,Ro,Ao);return Po[n](s,r,Bo)}function Xo(t,e,r,n){const o=Mo[n](zo(t,e),Ro,Ao);return Po[n](o,r,Bo)}const jo=t=>Number(t)/1e18,Go=t=>Number(t)/1e27,Ho=(t,e)=>Number(t)/10**e;function Ko(t,e){if(!Number.isFinite(t)||t<=0||t>=1e21)return 0n;const r=t.toFixed(e),[n="0",o=""]=r.split(".");return BigInt(n+o.padEnd(e,"0"))}const Zo=t=>Ko(t,Ao),Yo=(t,e)=>To(t,e,_o),Jo=(t,e)=>To(t,_o,e);function Qo(t,e){return 0n===e?0n:Jo(t,e)}function ts(t,e){const r=t>_o?_o:t,n=ko(e.baseRateRay,"irm.baseRateRay"),o=ko(e.slope1Ray,"irm.slope1Ray"),s=ko(e.slope2Ray,"irm.slope2Ray"),i=ko(e.slope3Ray,"irm.slope3Ray"),a=ko(e.midUtilizationRay,"irm.midUtilizationRay"),u=ko(e.optimalUtilizationRay,"irm.optimalUtilizationRay"),l=ko(e.maxBorrowRateRay,"irm.maxBorrowRateRay");let c;if(r<a)c=n+Jo(Yo(r,o),a);else if(r<u){const t=u-a;c=n+o+Jo(Yo(r-a,s),t)}else{const t=_o-u;c=n+o+s+(0n===t?0n:Jo(Yo(r-u,i),t))}return c>l?l:c}function es(t,e,r){return 0n===t||!Number.isInteger(r)||r<0||r>=1e4?0n:To(Yo(t,e),Eo-BigInt(r),Eo)}const rs=t=>Go(t),ns=t=>Math.expm1(Go(t)),os=5n*Bo,ss=(t,e,r)=>`${t}:${e}:${r}`;function is(t,e,r,n){const o=Array.isArray(t)?t:void 0,s=o?o.find((t=>t.spokeId===e&&t.hubId===r&&t.asset===n)):t[ss(e,r,n)]??Object.values(t).find((t=>t.spokeId===e&&t.hubId===r&&t.asset===n));if(!s)throw new Error(`Stellar math: no reserve for ${ss(e,r,n)}`);return s}const as=/^0*[1-9]\d*$/,us=t=>"string"==typeof t&&as.test(t)?BigInt(t).toString():null,ls=(t,e)=>`${t}:${e}`;function cs(t){const e=new Map,r=new Map,n=new Set,o=new Set;for(const s of t?.indexes??[]){const t=ls(s.hubId,s.asset),i=us(s.supplyIndex),a=us(s.borrowIndex),u=us(s.usdPrice),l=e.get(t),c=l&&us(l.supplyIndex)===i&&us(l.borrowIndex)===a&&us(l.usdPrice)===u;null==i||null==a||null==u||l&&!c?n.add(t):l||e.set(t,s);const f=!1===s.valid||!0===s.stale||!0===s.deviation,p=r.get(s.asset);null==u||f||void 0!==p&&p.toString()!==u?o.add(s.asset):void 0===p&&r.set(s.asset,BigInt(u))}for(const t of n)e.delete(t);for(const t of o)r.delete(t);return{indexes:e,prices:r,rejectedIndexKeys:n,rejectedAssets:o}}const fs=(t,e)=>qo(t,BigInt(e),Eo);function ps(t,e,r,n){const o="supply"===t.side,s=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:jo(t.priceWad),amountBase:e.toString(),amountShort:Ho(e,t.decimals),usdWad:r.toString(),usd:jo(r),gateUsdWad:n.toString(),entryLtvBps:t.entryLtvBps,entryLiquidationThresholdBps:t.entryLiquidationThresholdBps,entryLiquidationBonusBps:t.entryLiquidationBonusBps,entryLiquidationFeesBps:t.entryLiquidationFeesBps,ltvWeightedUsdWad:o?fs(n,s).toString():"0",liquidationWeightedUsdWad:o?fs(n,t.entryLiquidationThresholdBps).toString():"0",liveDataUsed:t.liveDataUsed}}function ds(t){if("supply"===t.side)return ps(t,Lo(t.scaledRay,t.indexRay,t.decimals,"floor"),Vo(t.scaledRay,t.indexRay,t.priceWad,"halfUp"),Vo(t.scaledRay,t.indexRay,t.priceWad,"floor"));const e=Lo(t.scaledRay,t.indexRay,t.decimals,"ceil"),r=Vo(t.scaledRay,t.indexRay,t.priceWad,"ceil");return ps(t,e,r,r)}function hs(t,e,r,n){const o=zo(e,r);return"supply"===t?qo(o,_o,n):xo(o,_o,n)}function ms(t,e,r,n){const o=zo(e,r);return"supply"===t?xo(o,_o,n):qo(o,_o,n)}function gs(t,e){return ds({...t,scaledRay:hs(t.side,e,t.decimals,t.indexRay)})}const ys=(...t)=>{for(const e of t){const t=us(e);if(null!=t)return BigInt(t)}return _o};function ws(t,e,r,n){const o=ko("supply"===t?e.supplyScaledRay:e.borrowScaledRay,`${t}ScaledRay`);if(0n===o)return null;const s=n.indexes.get(ls(e.hubId,e.asset)),i=n.prices.get(e.asset),a="supply"===t?ys(s?.supplyIndex,e.liveSupplyIndexRay,r.liveSupplyIndexRay,e.supplyIndexRay):ys(s?.borrowIndex,e.liveBorrowIndexRay,r.liveBorrowIndexRay,e.borrowIndexRay),u=i??Zo(r.usdPrice);return ds({side:t,hubId:e.hubId,asset:e.asset,decimals:r.assetDecimals,scaledRay:o,indexRay:a,priceWad:u,entryLtvBps:e.entryLtvBps,entryLiquidationThresholdBps:e.entryLiquidationThresholdBps,entryLiquidationBonusBps:e.entryLiquidationBonusBps,entryLiquidationFeesBps:e.entryLiquidationFeesBps,liveDataUsed:void 0!==s&&void 0!==i})}const bs=(t,e)=>t.reduce(((t,r)=>t+BigInt(e(r))),0n);function vs(t,e,r,n,o){const s=bs(e,(t=>t.usdWad)),i=bs(e,(t=>t.ltvWeightedUsdWad)),a=bs(e,(t=>t.liquidationWeightedUsdWad)),u=bs(r,(t=>t.usdWad)),l=0n===u?null:qo(a,Bo,u),c=0n===a?0:Number(u)/Number(a)*100,f=i<n||i<=u?0n:i-u;return{...t,supplies:e,borrows:r,totalCollateralUsdWad:s.toString(),totalCollateralUsd:jo(s),ltvWeightedCollateralUsdWad:i.toString(),ltvWeightedCollateralUsd:jo(i),liquidationWeightedCollateralUsdWad:a.toString(),liquidationWeightedCollateralUsd:jo(a),totalDebtUsdWad:u.toString(),totalDebtUsd:jo(u),healthFactorWad:null===l?null:l.toString(),healthFactor:null===l?null:jo(l),healthPercent:c,borrowLimitUsdWad:i.toString(),borrowLimitUsd:jo(i),availableBorrowUsdWad:f.toString(),availableBorrowUsd:jo(f),minBorrowCollateralUsdWad:n.toString(),minBorrowCollateralUsd:jo(n),isLiquidatable:null!==l&&l<Bo,liveDataValid:o}}function Is(t){const{positions:e,reserves:r,liveState:n}=t,o=e[0];if(!o)throw new Error("Stellar math: computeAccountRisk needs at least one position row");for(const t of e)if(t.accountId!==o.accountId)throw new Error(`Stellar math: computeAccountRisk received mixed account ids (${o.accountId}, ${t.accountId})`);const s=cs(n),i=[],a=[];for(const t of e){const e=is(r,t.spokeId,t.hubId,t.asset),n=ws("supply",t,e,s);n&&i.push(n);const o=ws("borrow",t,e,s);o&&a.push(o)}const u=null!=n?.minBorrowCollateralUsdWad?ko(n.minBorrowCollateralUsdWad,"minBorrowCollateralUsdWad"):os,l=void 0!==n&&[...i,...a].every((t=>t.liveDataUsed));return vs({accountId:o.accountId,owner:o.owner,spokeId:o.spokeId,mode:o.positionMode},i,a,u,l)}const Ss=200n,_s=t=>t.reduce(((t,e)=>e.amount<t.amount?e:t)),Bs=t=>t<0n?0n:t,Es=(t,e,r,n)=>({amountBase:t.amount,amountShort:Ho(t.amount,e),isFullClose:r,reason:t.reason,projectedUtilization:n}),Rs=t=>({amountBase:0n,amountShort:0,isFullClose:!1,reason:t,projectedUtilization:null});function As(t){const e=t.assetDecimals,r=ko(t.irm.maxUtilizationRay,"irm.maxUtilizationRay");return{suppliedBase:Ko(t.hubPool.suppliedShort,e),borrowedBase:Ko(t.hubPool.borrowedShort,e),cashBase:Ko(t.availableLiquidityShort,e),spokeSuppliedBase:Ko(t.suppliedShort,e),spokeBorrowedBase:Ko(t.borrowedShort,e),maxUtilizationRay:r>=_o?null:r}}const ks=(t,e)=>t<=0n?null:Number(e)/Number(t);function qs(t,e){if(t<=0n||!e(0n))return 0n;let r=0n,n=t+1n;for(;n-r>1n;){const t=(r+n)/2n;e(t)?r=t:n=t}return r}const xs=(t,e)=>t.find((t=>t.hubId===e.hubId&&t.asset===e.asset));function Ts(t,e,r){if(e.paused)return Rs("paused");if(e.frozen)return Rs("frozen");if(!e.isBorrowable)return Rs("cap");const n=e.assetDecimals,o=As(e),s=xs(t.borrows,e),i=cs(r).indexes.get(ls(e.hubId,e.asset)),a=s?BigInt(s.indexRay):ko(i?.borrowIndex??e.liveBorrowIndexRay,"borrowIndex"),u=s?BigInt(s.usdPriceWad):function(t,e){return cs(e).prices.get(t.asset)??Zo(t.usdPrice)}(e,r),l=s?BigInt(s.scaledRay):0n,c=BigInt(t.totalDebtUsdWad)-(s?BigInt(s.usdWad):0n),f=BigInt(t.ltvWeightedCollateralUsdWad),p=BigInt(t.minBorrowCollateralUsdWad),d=[];if(f<p)d.push({amount:0n,reason:"minCollateral"});else{const e=f-BigInt(t.totalDebtUsdWad),r=e<=0n||u<=0n?0n:qo(e,10n**BigInt(n),u),o=t=>c+Vo(l+hs("borrow",t,n,a),a,u,"ceil");d.push({amount:0n===r?0n:qs(r+16n,(t=>o(t)<=f)),reason:"ltv"})}d.push({amount:Bs(ko(e.borrowCap,"borrowCap")-o.spokeBorrowedBase),reason:"cap"});const h=To(o.suppliedBase,200n,Eo);d.push({amount:Bs(o.cashBase-h),reason:"liquidity"});const m=function(t,e){const r=t.maxUtilizationRay;if(null===r)return null;const n=zo(t.suppliedBase,e);return 0n===n?null:qs(Bs(qo(t.suppliedBase,r,_o)-t.borrowedBase)+16n,(o=>Qo(zo(t.borrowedBase+o,e),n)<=r))}(o,n);null!==m&&d.push({amount:m,reason:"utilizationCap"});const g=_s(d);return Es(g,n,!1,ks(o.suppliedBase,o.borrowedBase+g.amount))}function Us(t,e,r){if(e.paused)return Rs("paused");const n=xs(t.supplies,e);if(!n)return Rs(null);const o=n.decimals,s=As(e),i=BigInt(n.scaledRay),a=BigInt(n.indexRay),u=BigInt(n.usdPriceWad),l=BigInt(n.amountBase),c=Lo(i,a,o,"halfUp"),f=BigInt(t.totalDebtUsdWad),p=BigInt(t.minBorrowCollateralUsdWad),d=BigInt(Math.min(n.entryLtvBps,n.entryLiquidationThresholdBps)),h=[];let m=!0;if(f>0n&&d>0n){const e=f>p?f:p,r=p>f?"minCollateral":"healthFactor",s=BigInt(t.ltvWeightedCollateralUsdWad)-BigInt(n.ltvWeightedUsdWad);if(s<e){m=!1;const t=e-s,l=xo(t,Eo,d),f=BigInt(n.gateUsdWad)-l,p=f<=0n?0n:qo(f,10n**BigInt(o),u),g=c>0n?c-1n:0n,y=p+16n>g?g:p+16n,w=t=>{const e=ms("supply",t,o,a);return qo(Vo(e>=i?0n:i-e,a,u,"floor"),d,Eo)};h.push({amount:qs(y,(e=>w(e)>=t)),reason:r})}}h.push({amount:l,reason:null}),h.push({amount:s.cashBase,reason:"liquidity"});const g=function(t,e){const r=t.maxUtilizationRay;if(null===r||0n===t.borrowedBase)return null;if(0n===r)return 0n;const n=xo(t.borrowedBase,_o,r),o=t.suppliedBase<n?0n:t.suppliedBase-n+16n,s=zo(t.borrowedBase,e);return qs(o>t.suppliedBase?t.suppliedBase:o,(n=>{const o=zo(t.suppliedBase-n,e);return o>0n&&Qo(s,o)<=r}))}(s,o);null!==g&&h.push({amount:g,reason:"utilizationCap"});const y=_s(h),w=m&&y.amount>=l;return Es(y,o,w,ks(s.suppliedBase-y.amount,s.borrowedBase))}function $s(t){if(t.paused)return Rs("paused");if(t.frozen)return Rs("frozen");const e=t.assetDecimals,r=As(t),n={amount:Bs(ko(t.supplyCap,"supplyCap")-r.spokeSuppliedBase),reason:"cap"};return Es(n,e,!1,ks(r.suppliedBase+n.amount,r.borrowedBase))}function Os(t,e,r){if(e.paused)return Rs("paused");const n=xs(t.borrows,e);if(!n)return Rs(null);const o=n.decimals,s=As(e),i=BigInt(n.amountBase),a=void 0===r?null:ko(r,"walletBalance"),u=null!==a&&a<i?{amount:a,reason:"liquidity"}:{amount:i,reason:null};return Es(u,o,u.amount>=i,ks(s.suppliedBase,Bs(s.borrowedBase-u.amount)))}const Cs=(t,e)=>t.hubId===e.hubId&&t.asset===e.asset,Ns=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 Ps(t,e){const r=[...t.supplies],n=[...t.borrows];for(const t of e){const e="supply"===t.side?r:n,o=e.findIndex((e=>Cs(e,t))),s=-1===o?void 0:e[o],i=Ns(t.amountBase);let a;if(s){const t={side:s.side,hubId:s.hubId,asset:s.asset,decimals:s.decimals,indexRay:BigInt(s.indexRay),priceWad:BigInt(s.usdPriceWad),entryLtvBps:s.entryLtvBps,entryLiquidationThresholdBps:s.entryLiquidationThresholdBps,entryLiquidationBonusBps:s.entryLiquidationBonusBps,entryLiquidationFeesBps:s.entryLiquidationFeesBps,liveDataUsed:s.liveDataUsed},e=BigInt(s.scaledRay);let r;if(i>=0n)r=e+hs(t.side,i,t.decimals,t.indexRay);else{const n=-i,o=n>=("supply"===t.side?Lo(e,t.indexRay,t.decimals,"halfUp"):BigInt(s.amountBase))?e:ms(t.side,n,t.decimals,t.indexRay);r=o>=e?0n:e-o}a=0n===r?null:ds({...t,scaledRay:r})}else a=i<=0n?null:gs(Ms(t),i);-1===o?a&&e.push(a):a?e[o]=a:e.splice(o,1)}return vs({accountId:t.accountId,owner:t.owner,spokeId:t.spokeId,mode:t.mode},r,n,BigInt(t.minBorrowCollateralUsdWad),t.liveDataValid)}function Ms(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:ko("supply"===t.side?e.liveSupplyIndexRay:e.liveBorrowIndexRay,"reserve live index"),priceWad:Zo(e.usdPrice),entryLtvBps:e.collateralFactorBps,entryLiquidationThresholdBps:e.liquidationThresholdBps,entryLiquidationBonusBps:e.liquidationPenaltyBps,entryLiquidationFeesBps:e.liquidationFeesBps,liveDataUsed:!1}}function Ls(t,e=0n,r=0n){const n=t.assetDecimals,o=t=>t<0n?0n:t,s=o(Ko(t.hubPool.suppliedShort,n)+Ns(e)),i=Qo(zo(o(Ko(t.hubPool.borrowedShort,n)+Ns(r)),n),zo(s,n)),a=ts(i,t.irm),u=es(i,a,t.irm.reserveFactorBps);return{utilization:Go(i),utilizationRay:i.toString(),borrowAprRay:a.toString(),supplyAprRay:u.toString(),borrowApr:rs(a),supplyApr:rs(u),borrowApy:ns(a),supplyApy:ns(u)}}const Ds={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 Ws(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const r=Number(e[1]),n=Ds[r];return n?{code:r,...n}:null}export{Eo as BPS,os as DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD,Ss as LIQUIDATION_BUFFER_BPS,_o as RAY,Ro as RAY_DECIMALS,er as STELLAR_GOVERNANCE_ZERO_PREDECESSOR,Sn as STELLAR_LENDING_TOPICS,m as STELLAR_NETWORKS,w as STELLAR_NETWORK_PASSPHRASE,Nn as STELLAR_ROUTE_MAX_BYTES,Bn as SYNTHETIC_EVENT_ORDER_STRIDE,Qn as StellarAuthPolicyError,Pn as StellarRouteVerificationError,Bo as WAD,Ao as WAD_DECIMALS,vs as aggregateAccountRisk,ts as annualBorrowRateRay,ao as assertStellarAuthEntries,mo as assertStellarPreparedTxAuth,zo as baseToRay,Ho as baseToShort,Xo as baseValueWad,cs as buildLiveSnapshot,vo as buildSameTokenRepaySwapSteps,$e as buildStellarAcceptOwnershipTx,Qe as buildStellarAddRewardsTx,Le as buildStellarApproveBlendPoolTx,We as buildStellarApproveTokenTx,Hn as buildStellarBatchSwapTx,at as buildStellarBorrowBatchTx,ut as buildStellarBorrowTx,So as buildStellarCctpForwardTx,Je as buildStellarClaimRevenueTx,Ze as buildStellarCreateLiquidityPoolTx,Yr as buildStellarExecuteCancellerResetTx,Gn as buildStellarExecuteStrategyTx,mt as buildStellarFlashLoanTx,en as buildStellarGovernanceAddSpokeImmediateTx,tn as buildStellarGovernanceCreateHubImmediateTx,Vr as buildStellarGovernanceExecuteGovernanceUpgradeTx,jr as buildStellarGovernanceExecuteGrantGovernanceRoleTx,Gr as buildStellarGovernanceExecuteRevokeGovernanceRoleTx,Hr as buildStellarGovernanceExecuteTransferGovOwnTx,zr as buildStellarGovernanceExecuteTx,Xr as buildStellarGovernanceExecuteUpdateDelayTx,nn as buildStellarGovernancePauseTx,rn as buildStellarGovernanceRevokeRoleImmediateTx,Qr as buildStellarGovernanceSetOracleSanityBoundsImmediateTx,Jr as buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,xe as buildStellarGrantRoleTx,En as buildStellarLendingIdentifier,dt as buildStellarLiquidateTx,gt as buildStellarMigrateFromBlendTx,Ae as buildStellarMigrateTx,yt as buildStellarMultiplyTx,ke as buildStellarPauseTx,wr as buildStellarProposeAddAssetToSpokeTx,gr as buildStellarProposeAddSpokeTx,Rr as buildStellarProposeApproveBlendPoolTx,Br as buildStellarProposeApproveTokenTx,Zr as buildStellarProposeCancellerResetTx,Cr as buildStellarProposeConfigureAssetOracleTx,Nr as buildStellarProposeConfigureMarketOracleTx,mr as buildStellarProposeCreateHubTx,kr as buildStellarProposeCreateLiquidityPoolTx,xr as buildStellarProposeDeployPoolTx,br as buildStellarProposeEditAssetInSpokeTx,Pr as buildStellarProposeEditOracleToleranceTx,Mr as buildStellarProposeGovernanceUpgradeTx,Dr as buildStellarProposeGrantGovernanceRoleTx,$r as buildStellarProposeMigrateControllerTx,vr as buildStellarProposeRemoveAssetFromSpokeTx,yr as buildStellarProposeRemoveSpokeTx,Ar as buildStellarProposeRevokeBlendPoolTx,Wr as buildStellarProposeRevokeGovernanceRoleTx,Er as buildStellarProposeRevokeTokenTx,dr as buildStellarProposeSetAccumulatorTx,pr as buildStellarProposeSetAggregatorTx,_r as buildStellarProposeSetMinBorrowCollatTx,hr as buildStellarProposeSetPositionLimitsTx,Sr as buildStellarProposeSetPositionManagerTx,fr as buildStellarProposeSetPriceAggregatorTx,Ir as buildStellarProposeSetSpokeLiquidationCurveTx,cr as buildStellarProposeSetSwapAggregatorTx,Or as buildStellarProposeTransferCtrlOwnershipTx,Fr as buildStellarProposeTransferGovOwnTx,on as buildStellarProposeUnpauseTx,Lr as buildStellarProposeUpdateDelayTx,Ur as buildStellarProposeUpgradeControllerTx,qr as buildStellarProposeUpgradePoolParamsTx,Tr as buildStellarProposeUpgradePoolTx,Ke as buildStellarRenewAccountTx,ft as buildStellarRepayBatchTx,vt as buildStellarRepayDebtWithCollateralTx,pt as buildStellarRepayTx,De as buildStellarRevokeBlendPoolTx,Te as buildStellarRevokeRoleTx,Fe as buildStellarRevokeTokenTx,Pe as buildStellarSetAccumulatorTx,Ne as buildStellarSetAggregatorTx,Ve as buildStellarSetMarketOracleConfigTx,Ge as buildStellarSetOracleSanityBoundsTx,Xe as buildStellarSetOracleToleranceTx,ze as buildStellarSetOracleTx,Me as buildStellarSetPositionLimitsTx,Ce as buildStellarSetPriceAggregatorTx,je as buildStellarSetSpokeAssetFlagsTx,Oe as buildStellarSetSwapAggregatorTx,st as buildStellarSupplyBatchTx,it as buildStellarSupplyTx,bt as buildStellarSwapCollateralTx,wt as buildStellarSwapDebtTx,Ue as buildStellarTransferOwnershipTx,qe as buildStellarUnpauseTx,tr as buildStellarUpdateAccountThresholdTx,He as buildStellarUpdateIndexesTx,Re as buildStellarUpgradeControllerTx,Ye as buildStellarUpgradeLiquidityPoolParamsTx,lt as buildStellarWithdrawBatchTx,ct as buildStellarWithdrawTx,nt as buildTx,ms as burnShares,Is as computeAccountRisk,_n as decodeStellarLendingEvent,ht as decodeStellarLiquidateReturn,Wn as decodeStellarRouteBytes,es as depositRateRay,Uo as divByIntHalfUp,Be as encodeAssetOracle,de as encodeInterestRateModel,Ee as encodeMarketOracleConfigInput,he as encodeMarketParamsRaw,me as encodePositionLimits,ge as encodePriceKey,jn as encodeStrategyPayloadToRouteXdr,Rn as extractEventOrder,Ct as getStellarAccountPositions,se as getStellarActiveUsersSeries,xn as getStellarAggregatorQuote,Tt as getStellarAsset,Ft as getStellarAssetGraph,Mt as getStellarAssetMarkets,Pt as getStellarAssetPage,Rt as getStellarAssets,Qt as getStellarCampaignLeaderboard,fe as getStellarCampaignMe,ae as getStellarDefiLlamaDimensions,y as getStellarDeployment,Et as getStellarDetailedMarkets,re as getStellarFeeRevenueSeries,Ht as getStellarGovernanceProposals,Jt as getStellarHolderDistribution,Ut as getStellarHub,zt as getStellarHubGraph,Dt as getStellarHubHolders,At as getStellarHubs,_t as getStellarLendingContext,Bt as getStellarLendingLiveState,Yt as getStellarLiquidationsLeaderboard,ne as getStellarLiquidationsSeries,Zt as getStellarParticipantCounts,ce as getStellarPnlByScope,Kt as getStellarPositionsLeaderboard,le as getStellarPositionsPnl,Tn as getStellarQuoteTokens,ie as getStellarRateSpreadSeries,xt as getStellarReserve,Xt as getStellarReserveGraph,Lt as getStellarReserveHolders,qt as getStellarReserves,ee as getStellarRevenueSeries,$t as getStellarSpoke,Vt as getStellarSpokeGraph,Wt as getStellarSpokeHolders,kt as getStellarSpokes,te as getStellarStatsHistory,jt as getStellarUserActivity,Gt as getStellarUserActivityPage,ue as getStellarUserHistory,Ot as getStellarUserPositions,oe as getStellarVolumeSeries,Nt as getStellarWalletBalance,ls as liveIndexKey,Yn as mapQuoteResponseToAggregatorSwap,Kn as mapQuoteResponseToStrategyPayload,Zn as mapQuoteResponseToStrategySwap,Ws as mapSorobanError,kn as mapStellarPositionActivityType,Ts as maxBorrow,Os as maxRepay,$s as maxSupply,Us as maxWithdraw,hs as mintShares,xo as mulDivCeil,qo as mulDivFloor,To as mulDivHalfUp,Ko as numberToScaled,Zo as numberToWad,Vo as positionValueWad,wo as prepareStellarBuiltTx,yo as prepareStellarTxXdr,Ps as projectAccountRisk,Ls as projectReserveApy,ns as rayAprToApy,rs as rayAprToNumber,Go as rayToNumber,Co as rescaleCeil,Oo as rescaleFloor,No as rescaleHalfUp,ss as reserveKey,is as resolveReserve,po as stellarAuthPolicyForInvocation,un as stellarLendingDispatchKey,pe as stellarLendingRead,g as stellarNetworks,Fn as stellarTokenContractId,An as syntheticEventOrder,go as tagStellarInvokedContractError,sn as toBase64Xdr,ko as toBigInt,bo as toStellarPositionMode,Lo as unscale,Wo as unscaleBorrowCeil,Fo as unscaleHalfUp,Do as unscaleSupplyFloor,Qo as utilizationRay,gs as valueBasePosition,ds as valueScaledPosition,Vn as verifyStellarRouteBytes,jo as wadToNumber};export const XOXNOClient=h.GW;