@xoxno/sdk-js 1.0.214 → 1.0.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/utils/__tests__/request-timeout.test.d.ts +1 -0
- package/dist/cjs/utils/api.d.ts +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/index.cjs +1 -1
- package/dist/sdk/stellar/index.esm.js +1 -1
- package/dist/utils/__tests__/request-timeout.test.d.ts +1 -0
- package/dist/utils/api.d.ts +21 -0
- package/package.json +1 -1
|
@@ -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 o,ScInt as n,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],o=e[1];return 3*(r+o)/4-o},e.toByteArray=function(t){var e,r,i=a(t),s=i[0],u=i[1],l=new n(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),c=0,f=u>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===u&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,o=t.length,n=o%3,i=[],s=16383,a=0,u=o-n;a<u;a+=s)i.push(l(t,a,a+s>u?u:a+s));return 1===n?(e=t[o-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[o-2]<<8)+t[o-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],o=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],o[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 o,n=[],i=e;i<r;i+=3)o=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),n.push(u(o));return n.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},287(t,e,r){const o=r(526),n=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 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 o=a(r);const n=o.write(t,e);return n!==r&&(o=o.slice(0,n)),o}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return h(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 h(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const o=t.valueOf&&t.valueOf();if(null!=o&&o!==t)return u.from(o,e,r);const n=function(t){if(u.isBuffer(t)){const e=0|d(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):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(n)return n;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|d(t))}function p(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let o=0;o<e;o+=1)r[o]=255&t[o];return r}function h(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 o;return o=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(o,u.prototype),o}function d(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,o=arguments.length>2&&!0===arguments[2];if(!o&&0===r)return 0;let n=!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(n)return o?-1:j(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){let o=!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 R(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(o)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}function y(t,e,r){const o=t[e];t[e]=t[r],t[r]=o}function w(t,e,r,o,n){if(0===t.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,o)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,o,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,o,n);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,o,n){let i,s=1,a=t.length,u=e.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){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(n){let o=-1;for(i=r;i<a;i++)if(l(t,i)===l(e,-1===o?0:i-o)){if(-1===o&&(o=i),i-o+1===u)return o*s}else-1!==o&&(i-=i-o),o=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){let r=!0;for(let o=0;o<u;o++)if(l(t,i+o)!==l(e,o)){r=!1;break}if(r)return i}return-1}function _(t,e,r,o){r=Number(r)||0;const n=t.length-r;o?(o=Number(o))>n&&(o=n):o=n;const i=e.length;let s;for(o>i/2&&(o=i/2),s=0;s<o;++s){const o=parseInt(e.substr(2*s,2),16);if(J(o))return s;t[r+s]=o}return s}function v(t,e,r,o){return H(j(e,t.length-r),t,r,o)}function S(t,e,r,o){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,o)}function q(t,e,r,o){return H(G(e),t,r,o)}function I(t,e,r,o){return H(function(t,e){let r,o,n;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),o=r>>8,n=r%256,i.push(n),i.push(o);return i}(e,t.length-r),t,r,o)}function k(t,e,r){return 0===e&&r===t.length?o.fromByteArray(t):o.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);const o=[];let n=e;for(;n<r;){const e=t[n];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(n+s<=r){let r,o,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[n+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[n+1],o=t[n+2],128==(192&r)&&128==(192&o)&&(u=(15&e)<<12|(63&r)<<6|63&o,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[n+1],o=t[n+2],a=t[n+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&o)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,o.push(i>>>10&1023|55296),i=56320|1023&i),o.push(i),n+=s}return function(t){const e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);let r="",o=0;for(;o<e;)r+=String.fromCharCode.apply(String,t.slice(o,o+=B));return r}(o)}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,o=e.length;for(let n=0,i=Math.min(r,o);n<i;++n)if(t[n]!==e[n]){r=t[n],o=e[n];break}return r<o?-1:o<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 o=u.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))n+e.length>o.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(o,n)):Uint8Array.prototype.set.call(o,e,n);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(o,n)}n+=e.length}return o},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?E(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,o,n){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===o&&(o=0),void 0===n&&(n=this.length),e<0||r>t.length||o<0||n>this.length)throw new RangeError("out of range index");if(o>=n&&e>=r)return 0;if(o>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(n>>>=0)-(o>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(i,s),l=this.slice(o,n),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,o){if(void 0===e)o="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)o=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===o&&(o="utf8")):(o=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return v(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return q(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: "+o);o=(""+o).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const B=4096;function A(t,e,r){let o="";r=Math.min(t.length,r);for(let n=e;n<r;++n)o+=String.fromCharCode(127&t[n]);return o}function T(t,e,r){let o="";r=Math.min(t.length,r);for(let n=e;n<r;++n)o+=String.fromCharCode(t[n]);return o}function R(t,e,r){const o=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>o)&&(r=o);let n="";for(let o=e;o<r;++o)n+=Y[t[o]];return n}function x(t,e,r){const o=t.slice(e,r);let n="";for(let t=0;t<o.length-1;t+=2)n+=String.fromCharCode(o[t]+256*o[t+1]);return n}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,o,n,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<i)throw new RangeError('"value" argument is out of bounds');if(r+o>t.length)throw new RangeError("Index out of range")}function O(t,e,r,o,n){F(e,o,n,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,o,n){F(e,o,n,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 C(t,e,r,o,n,i){if(r+o>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,o,i){return e=+e,r>>>=0,i||C(t,0,r,4),n.write(t,e,r,o,23,4),r+4}function M(t,e,r,o,i){return e=+e,r>>>=0,i||C(t,0,r,8),n.write(t,e,r,o,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 o=this.subarray(t,e);return Object.setPrototypeOf(o,u.prototype),o},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t],n=1,i=0;for(;++i<e&&(n*=256);)o+=this[t+i]*n;return o},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t+--e],n=1;for(;e>0&&(n*=256);)o+=this[t+--e]*n;return o},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=Z((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 o=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(o)+(BigInt(n)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((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 o=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(o)<<BigInt(32))+BigInt(n)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t],n=1,i=0;for(;++i<e&&(n*=256);)o+=this[t+i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*e)),o},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=e,n=1,i=this[t+--o];for(;o>0&&(n*=256);)i+=this[t+--o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},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=Z((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 o=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((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 o=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(o)<<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),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,o){t=+t,e>>>=0,r>>>=0,o||$(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,i=0;for(this[e]=255&t;++i<r&&(n*=256);)this[e+i]=t/n&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,o){t=+t,e>>>=0,r>>>=0,o||$(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,i=1;for(this[e+n]=255&t;--n>=0&&(i*=256);)this[e+n]=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 O(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,o){if(t=+t,e>>>=0,!o){const o=Math.pow(2,8*r-1);$(this,t,e,r,o-1,-o)}let n=0,i=1,s=0;for(this[e]=255&t;++n<r&&(i*=256);)t<0&&0===s&&0!==this[e+n-1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,o){if(t=+t,e>>>=0,!o){const o=Math.pow(2,8*r-1);$(this,t,e,r,o-1,-o)}let n=r-1,i=1,s=0;for(this[e+n]=255&t;--n>=0&&(i*=256);)t<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+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 O(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 N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(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,o){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<r&&(o=r),o===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(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-r&&(o=t.length-e+r);const n=o-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,o):Uint8Array.prototype.set.call(t,this.subarray(r,o),e),n},u.prototype.fill=function(t,e,r,o){if("string"==typeof t){if("string"==typeof e?(o=e,e=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){const e=t.charCodeAt(0);("utf8"===o&&e<128||"latin1"===o)&&(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 n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const i=u.isBuffer(t)?t:u.from(t,o),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<r-e;++n)this[n+e]=i[n%s]}return this};const W={};function L(t,e,r){W[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 o="-"===t[0]?1:0;for(;r>=o+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,o,n,i){if(t>r||t<e){const o="bigint"==typeof e?"n":"";let n;throw n=i>3?0===e||e===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${e}${o} and <= ${r}${o}`,new W.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(o,n,i)}function z(t,e){if("number"!=typeof t)throw new W.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw z(t,r),new W.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new W.ERR_BUFFER_OUT_OF_BOUNDS;throw new W.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}L("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),L("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),L("ERR_OUT_OF_RANGE",(function(t,e,r){let o=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=D(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=D(n)),n+="n"),o+=` It must be ${e}. Received ${n}`,o}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function j(t,e){let r;e=e||1/0;const o=t.length;let n=null;const i=[];for(let s=0;s<o;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(e-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&i.push(239,191,189);if(n=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 o.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,o){let n;for(n=0;n<o&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const o=16*r;for(let n=0;n<16;++n)e[o+n]=t[r]+t[n]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251(t,e){e.read=function(t,e,r,o,n){var i,s,a=8*n-o-1,u=(1<<a)-1,l=u>>1,c=-7,f=r?n-1:0,p=r?-1:1,h=t[e+f];for(f+=p,i=h&(1<<-c)-1,h>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=o;c>0;s=256*s+t[e+f],f+=p,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,o),i-=l}return(h?-1:1)*s*Math.pow(2,i-o)},e.write=function(t,e,r,o,n,i){var s,a,u,l=8*i-n-1,c=(1<<l)-1,f=c>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?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+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,n),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=255&a,h+=d,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;t[r+h]=255&s,h+=d,s/=256,l-=8);t[r+h-d]|=128*m}},387(t,e,r){r.d(e,{G:()=>i});var o,n=r(564);!function(t){t.MAINNET="1",t.DEVNET="D"}(o||(o={}));class i{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=o.MAINNET,apiUrl:r,...i}=t;this.apiUrl=r.trim().replace(/\/$/,""),this.chain=e,this.init=i,this.config=e==o.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:n.s0,FM_SC:n.ZZ,DR_SC:n.sM,KG_SC:n.KL,Staking_SC:n.V,Manager_SC:n.Rh,P2P_SC:n.EP}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:n.cM,FM_SC:n.ZZ,DR_SC:n.sM,KG_SC:n.KL,Staking_SC:n.J6,Manager_SC:n.Ff,P2P_SC:n.gx}}fetchWithTimeout=async(t,{params:e,...r}={})=>{const{next:o,cache:n,debug:i,...s}=this.init,{next:a,cache:u,debug:l,headers:c,method:f="GET",...p}=r,h=c?.Authorization,d="Bearer undefined"===h?void 0:h,m="GET"!==f&&"HEAD"!==f&&"PUT"!==f,g={...c,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...m?{"Content-Type":"application/json"}:{},...d?{Authorization:d}:{}},y=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("&"),w=`${this.apiUrl}${t}${y.length?`?${y}`:""}`,{revalidate:b,..._}=o??{},{revalidate:v,...S}=a??{},q="GET"!==f||d?void 0:v??b,I="GET"!==f||d||q?void 0:u??n,k={...s,...p,method:f,...Object.keys(g).length?{headers:g}:{},cache:I,next:{..._,...S,revalidate:q}};(l??i)&&console.debug("SDK fetch: ",w,k);const E=await fetch(w,k).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${w}: ${t.message}`),{cause:t});throw t})),B=await E.text();if(!E.ok){let t;try{t=JSON.parse(B)}catch{t={message:B}}const e=[w,E.status,E.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(B)}catch{return B}}}},564(t,e,r){r.d(e,{EP:()=>l,Ff:()=>p,J6:()=>f,KL:()=>s,Rh:()=>u,V:()=>a,ZZ:()=>n,cM:()=>c,gx:()=>h,s0:()=>o,sM:()=>i});const o="erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",n="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",i="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",s="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",a="erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",u="erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",l="erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6",c="erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",f="erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",p="erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",h="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 f=c(387);const p={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"}},h=p;function d(t){return p["testnet"===t?"stellarTestnet":"stellarMainnet"]}const m={mainnet:p.stellarMainnet.passphrase,testnet:p.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,_=t=>new e(t).toScVal(),v=t=>new n(t).toI128(),S=t=>a.ScVal.scvU32(t),q=t=>{if("number"==typeof t&&!Number.isSafeInteger(t))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new n("string"==typeof t?t:t.toString()).toU64()},I=t=>a.ScVal.scvBool(t),k=t=>a.ScVal.scvString(t),E=t=>a.ScVal.scvSymbol(t),B=()=>a.ScVal.scvVoid(),A=t=>a.ScVal.scvVec(t),T=(t,e=32)=>{const r=t.startsWith("0x")?t.slice(2):t,o=g.hp.from(r,"hex");if(o.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${o.length} bytes from "${t}")`);return a.ScVal.scvBytes(o)},R=(t,e)=>null==t?B():e(t),x=(t,e)=>P({asset:_(e),hub_id:S(t)}),U=(t,e,r)=>a.ScVal.scvVec([x(t,e),v(r)]),$=t=>a.ScVal.scvVec(t.map((t=>U(t.hubId,t.asset,t.amount)))),O=t=>{if("Transfer"===t)return A([E("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 A([E("Credit"),q(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:E(e),val:t[e]})));return a.ScVal.scvMap(e)};class C{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,o,n){this.ops.push([t,e,r,o,n])}emitPath(t,e){t.hops.forEach(((r,o)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[o-1];if(n&&r.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(w[r.venue],0===o?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 o=e[t].hops[0]?.tokenIn,n=[];for(let r=t;r<e.length;r+=1)e[r].hops[0]?.tokenIn===o&&n.push(r);const i=n.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;n.forEach(((t,o)=>{r[t]=!0;const i=e[t];let u;if(o+1===n.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 o=[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)o.push(...t);for(const t of this.weights)o.push(t>>>16&255,t>>>8&255,255&t);return g.hp.from(o)}get assetList(){return this.assets}get amountList(){return this.amounts}}const N=t=>{const e=new C(t.totalMinOut),r=e.asset(t.tokenIn),o=e.asset(t.tokenOut);if(r===o)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const o=e.asset(t.burnPool),n=e.amountList.length;for(const r of t.burnMinAmounts??[])e.amount(r);e.emit(5,0,o,r,n)}if(e.lowerPaths(t.paths),t.mintPool){const r=t.preSwapAmount;if(r&&BigInt(r)>0n){const o=t.mintPoolTokens;if(!o||2!==o.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=o,[s,a]=t.preSwapFromA?[n,i]:[i,n];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),o,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return P({amounts:a.ScVal.scvVec(e.amountList.map((t=>v(t)))),assets:a.ScVal.scvVec(e.assetList.map((t=>_(t)))),ops:a.ScVal.scvBytes(e.toBytes(r,o,n))})},M=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)},W=()=>a.ScVal.scvBytes(g.hp.alloc(0)),L=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 o=g.hp.from(e,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},D=t=>{if("string"==typeof t)return M(L(t));if(t instanceof Uint8Array)return 0===t.length?W():M(t);if(t&&"object"==typeof t)return"routeXdr"in(r=t)&&"string"==typeof r.routeXdr?M(L(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?M(L(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?M(L(t.bytes)):0===t.bytes.length?W():M(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,o]of e.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.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 o.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=o.hops[0];r.set(e.tokenIn,(r.get(e.tokenIn)??0)+o.splitPpm)}for(const[t,o]of r){if(o>b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${o}, above 1000000`);if(!e.mintPool&&o!==b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${o}`)}return e})(t),a.ScVal.scvBytes(g.hp.from(N(e).toXDR("base64"),"base64")));var e,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},F=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 z(e,n,s){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const a=new o(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(n,...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 z(t,"supply",[_(t.caller),q(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 z(t,"borrow",[_(t.caller),q(e.accountNonce),$([...e.borrows]),R(e.to,_)])}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 z(t,"withdraw",[_(t.caller),q(e.accountNonce),$([...e.withdrawals]),R(e.to,_)])}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 z(t,"repay",[_(t.caller),q(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 z(t,"liquidate",[_(t.caller),q(e.accountNonce),$([...e.debtPayments]),O(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 z(t,"flash_loan",[_(t.caller),x(e.hubId,e.asset),v(e.amount),_(e.receiver),F(e.data)])}function rt(t,e){return z(t,"migrate_from_blend",[_(t.caller),q(e.accountId),V(e.spokeId),S(e.hubId),_(e.blendPool),A(e.collateralTokens.map(_)),A(e.supplyTokens.map(_)),(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([_(e),v(r)]);var e,r}))))]);var r}function ot(t,e){const r=e.accountNonce??0;return z(t,"multiply",[_(t.caller),q(r),V(e.spokeId),x(e.collateral.hubId,e.collateral.asset),v(e.debtToFlashLoan),x(e.debt.hubId,e.debt.asset),S(e.mode),D(e.steps),R(e.initialPayment,(t=>U(t.hubId,t.asset,t.amount))),R(e.convertSwap,D)])}function nt(t,e){return z(t,"swap_debt",[_(t.caller),q(e.accountNonce),x(e.existingDebt.hubId,e.existingDebt.asset),v(e.newDebtAmount),x(e.newDebt.hubId,e.newDebt.asset),D(e.steps)])}function it(t,e){return z(t,"swap_collateral",[_(t.caller),q(e.accountNonce),x(e.current.hubId,e.current.asset),v(e.fromAmount),x(e.newCollateral.hubId,e.newCollateral.asset),D(e.steps)])}function st(t,e){return z(t,"repay_debt_with_collateral",[_(t.caller),q(e.accountNonce),x(e.collateral.hubId,e.collateral.asset),v(e.collateralAmount),x(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),ft=(t,e)=>t.fetchWithTimeout(`${at}/markets/detailed`,e),pt=(t,e)=>t.fetchWithTimeout(`${at}/assets`,e),ht=(t,e)=>t.fetchWithTimeout(`${at}/hubs`,e),dt=(t,e)=>t.fetchWithTimeout(`${at}/spokes`,e),mt=(t,e={},r)=>t.fetchWithTimeout(`${at}/reserves`,{...r,params:{...e}}),gt=(t,e,r,o,n)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}`,n),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),_t=(t,e,r)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/positions`,r),vt=(t,e,r)=>t.fetchWithTimeout(`${at}/accounts/${ut(e)}/positions`,r),St=(t,e,r,o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/assets/${ut(r)}/balance`,o),qt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/page`,{...o,params:{...r}}),It=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/markets`,{...o,params:{side:r}}),kt=(t,e,r,o,n,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}/holders`,{...i,params:{side:n}}),Et=(t,e,r,o)=>t.fetchWithTimeout(`${at}/hubs/${e}/holders`,{...o,params:{side:r}}),Bt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/spokes/${e}/holders`,{...o,params:{side:r}}),At=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/graph`,{...o,params:{...r}}),Tt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/hubs/${e}/graph`,{...o,params:{...r}}),Rt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/spokes/${e}/graph`,{...o,params:{...r}}),xt=(t,e,r,o,n,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}/graph`,{...i,params:{...n}}),Ut=(t,e,r={},o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity`,{...o,params:{...r}}),$t=(t,e,r={},o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity/page`,{...o,params:{...r}}),Ot=(t,e={},r)=>t.fetchWithTimeout(`${at}/governance/proposals`,{...r,params:{...e}}),Pt=(t,e={},r)=>t.fetchWithTimeout(`${at}/positions`,{...r,params:{...e}}),Ct=(t,e={},r)=>t.fetchWithTimeout(`${at}/participants`,{...r,params:{...e}}),Nt=(t,e={},r)=>t.fetchWithTimeout(`${at}/liquidations/leaderboard`,{...r,params:{...e}}),Mt=(t,e={},r)=>t.fetchWithTimeout(`${at}/distribution`,{...r,params:{...e}}),Wt=(t,e={},r)=>t.fetchWithTimeout(`${at}/campaign/leaderboard`,{...r,params:{...e}}),Lt=(t,e,r)=>t.fetchWithTimeout(`${at}/stats/history`,{...r,params:{...e}}),Dt=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue`,{...r,params:{...e}}),Ft=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue/fees`,{...r,params:{...e}}),zt=(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,o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/history`,{...o,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=>ft(t,e),assets:e=>pt(t,e),hubs:e=>ht(t,e),spokes:e=>dt(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,o,n)=>gt(t,e,r,o,n),asset:(e,r)=>yt(t,e,r),hub:(e,r)=>wt(t,e,r),spoke:(e,r)=>bt(t,e,r),userPositions:(e,r)=>_t(t,e,r),accountPositions:(e,r)=>vt(t,e,r),walletBalance:(e,r,o)=>St(t,e,r,o),assetPage:(e,r,o)=>qt(t,e,r,o),assetMarkets:(e,r,o)=>It(t,e,r,o),reserveHolders:(e,r,o,n,i)=>kt(t,e,r,o,n,i),hubHolders:(e,r,o)=>Et(t,e,r,o),spokeHolders:(e,r,o)=>Bt(t,e,r,o),assetGraph:(e,r,o)=>At(t,e,r,o),hubGraph:(e,r,o)=>Tt(t,e,r,o),spokeGraph:(e,r,o)=>Rt(t,e,r,o),reserveGraph:(e,r,o,n,i)=>xt(t,e,r,o,n,i),userActivity:(e,r={},o)=>Ut(t,e,r,o),userActivityPage:(e,r={},o)=>$t(t,e,r,o),governanceProposals:(e={},r)=>Ot(t,e,r),positionsLeaderboard:(e={},r)=>Pt(t,e,r),participants:(e={},r)=>Ct(t,e,r),liquidationsLeaderboard:(e={},r)=>Nt(t,e,r),distribution:(e={},r)=>Mt(t,e,r),campaignLeaderboard:(e={},r)=>Wt(t,e,r),statsHistory:(e,r)=>Lt(t,e,r),revenue:(e,r)=>Dt(t,e,r),feeRevenue:(e,r)=>Ft(t,e,r),liquidations:(e,r)=>zt(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,o)=>Ht(t,e,r,o),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:v(t.baseBorrowRateRay),max_borrow_rate:v(t.maxBorrowRateRay),max_utilization:v(t.maxUtilizationRay),mid_utilization:v(t.midUtilizationRay),optimal_utilization:v(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:v(t.slope1Ray),slope2:v(t.slope2Ray),slope3:v(t.slope3Ray)}),te=t=>P({asset_decimals:S(t.assetDecimals),asset_id:_(t.assetId),base_borrow_rate:v(t.baseBorrowRateRay),flashloan_fee:S(t.flashloanFeeBps),is_flashloanable:I(t.isFlashloanable),max_borrow_rate:v(t.maxBorrowRateRay),max_utilization:v(t.maxUtilizationRay),mid_utilization:v(t.midUtilizationRay),optimal_utilization:v(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:v(t.slope1Ray),slope2:v(t.slope2Ray),slope3:v(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 A([E("Token"),_(t.Token)]);if("Ref"in t&&t.Ref)return A([E("Ref"),E(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},oe=t=>{if("Stellar"in t)return A([E("Stellar"),_(t.Stellar)]);if("Symbol"in t)return A([E("Symbol"),E(t.Symbol)]);if("String"in t)return A([E("String"),k(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},ne=t=>{if("Spot"===t)return A([E("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return A([E("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 A([E(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},se=t=>{if("Market"===t||"Fundamental"===t)return A([E(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},ae=t=>{if("Reflector"in t){const e=t.Reflector;return A([E("Reflector"),P({asset:oe(e.asset),contract:_(e.contract),read_mode:ne(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return A([E("MultiFeed"),P({contract:_(e.contract),feed_id:k(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:q(e.maxStaleSeconds),provider:ae(e.provider)})},le=t=>{if("RequireDisjoint"===t)return A([E("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return A([E("AllowShared"),A(e.map((t=>P({contract:_(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 o,n;if("number"==typeof e.toleranceBps)o=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/o));else{const t=e.tolerance??{};o=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return P({asset_decimals:S(Number(e.assetDecimals)),independence:le(e.independence),max_price_stale_seconds:q(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:v(String(e.maxSanityPriceWad)),min_sanity_price_wad:v(String(e.minSanityPriceWad)),sources:A(r.map((t=>(t=>{if("Feed"in t)return A([E("Feed"),ue(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return A([E("Scaled"),P({factor:ue(e.factor),max_factor_wad:v(e.maxFactorWad),min_factor_wad:v(e.minFactorWad),quote:re(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return A([E("LpShare"),P({key_a:re(e.keyA),key_b:re(e.keyB),kind:A([E(e.kind||"ConstantProduct")]),pool:_(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(n),upper_ratio_bps:S(o)})})},fe=ce;function pe(t,e){return z(t,"upgrade",[T(e.wasmHash)])}function he(t,e){return z(t,"migrate",[S(e.newVersion)])}function de(t){return z(t,"pause",[])}function me(t){return z(t,"unpause",[])}function ge(t,e){return z(t,"grant_role",[_(e.account),E(e.role)])}function ye(t,e){return z(t,"revoke_role",[_(e.account),E(e.role)])}function we(t,e){return z(t,"transfer_ownership",[_(e.newOwner),S(e.liveUntilLedger)])}function be(t){return z(t,"accept_ownership",[])}function _e(t,e){return z(t,"set_swap_aggregator",[_(e.aggregator)])}function ve(t,e){return z(t,"set_price_aggregator",[_(e.aggregator)])}const Se=_e;function qe(t,e){return z(t,"set_accumulator",[_(e.accumulator)])}function Ie(t,e){return z(t,"set_position_limits",[ee(e)])}function ke(t,e){return z(t,"approve_blend_pool",[_(e.pool)])}function Ee(t,e){return z(t,"revoke_blend_pool",[_(e.pool)])}const Be=ke,Ae=Ee;function Te(t,e){return z(t,"set_oracle",[re(e.key),ce(e.oracle)])}const Re=Te;function xe(t,e){const r=e.toleranceBps,o=e.upperRatioBps??1e4+r,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/o));return z(t,"set_tolerance",[re(e.key),P({lower_ratio_bps:S(n),upper_ratio_bps:S(o)})])}function Ue(t,e){return z(t,"set_spoke_asset_flags",[S(e.spokeId),x(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function $e(t,e){return z(t,"set_oracle_sanity_bounds",[_(e.asset),v(e.minPriceWad),v(e.maxPriceWad)])}function Oe(t,e){return z(t,"update_indexes",[_(t.caller),A(e.assets.map((t=>x(t.hubId,t.asset))))])}function Pe(t,e){return z(t,"renew_account",[_(t.caller),q(e.accountNonce)])}function Ce(t,e){return z(t,"create_liquidity_pool",[S(e.hubId),_(e.asset),te(e.params)])}function Ne(t,e){return z(t,"upgrade_liquidity_pool_params",[x(e.hubId,e.asset),Qt(e.params)])}function Me(t,e){return z(t,"claim_revenue",[_(t.caller),A(e.assets.map((t=>x(t.hubId,t.asset))))])}function We(t,e){return z(t,"add_rewards",[_(t.caller),$(e.rewards)])}function Le(t,e){return z(t,"update_account_threshold",[_(t.caller),I(e.hasRisks),A(e.accountNonces.map((t=>q(t))))])}const De="00".repeat(32),Fe=t=>{if("string"==typeof t)return T(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)},ze=(t,...e)=>A([E(t),...e]),Ve=t=>P({new_owner:_(t.newOwner),live_until_ledger:S(t.liveUntilLedger)}),Xe=t=>P({asset:_(t.asset),bonus:S(t.bonus),borrow_cap:v(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:v(t.supplyCap),threshold:S(t.threshold)}),je=t=>P({account:_(t.account),role:E(t.role)});function Ge(e,n,s){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const a=new o(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(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const He=(t,e,r)=>Ge(t,"propose",[_(t.caller),e,Fe(r)]),Ke=(t,e,r)=>Ge(t,"execute_self",[B(),e,Fe(r)]);function Je(t,e,r){return He(t,ze("SetSwapAggregator",_(e.aggregator)),r)}function Ye(t,e,r){return He(t,ze("SetPriceAggregator",_(e.aggregator)),r)}const Ze=Je;function Qe(t,e,r){return He(t,ze("SetAccumulator",_(e.accumulator)),r)}function tr(t,e,r){return He(t,ze("SetPositionLimits",ee(e)),r)}function er(t,e){return He(t,ze("CreateHub"),e)}function rr(t,e){return He(t,ze("AddSpoke"),e)}function or(t,e,r){return He(t,ze("RemoveSpoke",S(e.spokeId)),r)}function nr(t,e,r){return He(t,ze("AddAssetToSpoke",Xe(e)),r)}function ir(t,e,r){return He(t,ze("EditAssetInSpoke",Xe(e)),r)}function sr(t,e,r){return He(t,ze("RemoveAssetFromSpoke",P({hub_asset:x((o=e).hubId,o.asset),spoke_id:S(o.spokeId)})),r);var o}function ar(t,e,r){return He(t,ze("SetSpokeLiquidationCurve",P({hf_for_max_bonus_wad:v((o=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:S(o.liquidationBonusFactorBps),spoke_id:S(o.spokeId),target_hf_wad:v(o.targetHfWad)})),r);var o}function ur(t,e,r){return He(t,ze("SetPositionManager",_(e.manager),I(e.isActive)),r)}function lr(t,e,r){return He(t,ze("SetMinBorrowCollateralUsd",v(e.floorWad)),r)}function cr(t,e,r){return He(t,ze("ApproveToken",_(e.token)),r)}function fr(t,e,r){return He(t,ze("RevokeToken",_(e.token)),r)}function pr(t,e,r){return He(t,ze("ApproveBlendPool",_(e.pool)),r)}function hr(t,e,r){return He(t,ze("RevokeBlendPool",_(e.pool)),r)}function dr(t,e,r){return He(t,ze("CreateLiquidityPool",P({asset:_((o=e).asset),hub_id:S(o.hubId),params:te(o.params)})),r);var o}function mr(t,e,r){return He(t,ze("UpgradeLiquidityPoolParams",P({hub_asset:x((o=e).hubId,o.asset),params:Qt(o.params)})),r);var o}function gr(t,e,r){return He(t,ze("DeployPool",T(e.wasmHash)),r)}function yr(t,e,r){return He(t,ze("UpgradePool",T(e.wasmHash)),r)}function wr(t,e,r){return He(t,ze("UpgradeController",T(e.wasmHash)),r)}function br(t,e,r){return He(t,ze("MigrateController",S(e.newVersion)),r)}function _r(t,e,r){return He(t,ze("TransferCtrlOwnership",Ve(e)),r)}function vr(t,e,r){return He(t,ze("ConfigureAssetOracle",P({key:re((o=e).key),oracle:ce(o.oracle)})),r);var o}const Sr=vr;function qr(t,e,r){return He(t,ze("EditOracleTolerance",P({key:re((o=e).key),tolerance:S(o.tolerance)})),r);var o}function Ir(t,e,r){return He(t,ze("UpgradeGov",T(e.wasmHash)),r)}function kr(t,e,r){return He(t,ze("UpdateGovDelay",S(e.newDelay)),r)}function Er(t,e,r){return He(t,ze("GrantGovRole",je(e)),r)}function Br(t,e,r){return He(t,ze("RevokeGovRole",je(e)),r)}function Ar(t,e,r){return He(t,ze("TransferGovOwnership",Ve(e)),r)}function Tr(t,e){const r=A(e.argsXdr.map((t=>a.ScVal.fromXDR(t,"base64")))),o=Fe(e.predecessor??De);return Ge(t,"execute",[B(),_(e.target),E(e.functionName),r,o,Fe(e.salt)])}function Rr(t,e,r){return Ke(t,ze("UpgradeGov",T(e.wasmHash)),r)}function xr(t,e,r){return Ke(t,ze("UpdateGovDelay",S(e.newDelay)),r)}function Ur(t,e,r){return Ke(t,ze("GrantGovRole",je(e)),r)}function $r(t,e,r){return Ke(t,ze("RevokeGovRole",je(e)),r)}function Or(t,e,r){return Ke(t,ze("TransferGovOwnership",Ve(e)),r)}const Pr=t=>A(t.map(_));function Cr(t,e,r){return Ge(t,"propose_canceller_reset",[Pr(e.newCancellers),Fe(r)])}function Nr(t,e,r){return Ge(t,"execute_canceller_reset",[R(e.executor,_),Pr(e.newCancellers),Fe(r)])}function Mr(t,e){return Ge(t,"set_spoke_asset_flags",[_(t.caller),S(e.spokeId),x(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function Wr(t,e){return Ge(t,"set_oracle_sanity_bounds",[_(t.caller),_(e.asset),v(e.minPriceWad),v(e.maxPriceWad)])}function Lr(t){return Ge(t,"create_hub",[_(t.caller)])}function Dr(t){return Ge(t,"add_spoke",[_(t.caller)])}function Fr(t,e){return Ge(t,"revoke_role_immediate",[_(e.account),E(e.role)])}function zr(t){return Ge(t,"pause",[_(t.caller)])}function Vr(t,e){return He(t,ze("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"],to=t=>Array.isArray(t)?t:[],eo=(t,e)=>{const r="Borrow"===e;return{action:(o=t[0],Qr[Kr(o)]??Hr(o)),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 o},ro=t=>{return{owner:Jr(t[0]),spokeId:Kr(t[1]),mode:(e=t[2],Zr[Kr(e)]??"None")};var e},oo=t=>Array.isArray(t)?t[1]:void 0,no=t=>{const e=(r=t,Array.isArray(r)?Jr(r[0]):Jr(r));var r;if("Token"===e)return{Token:Jr(oo(t))};if("Ref"===e)return{Ref:Jr(oo(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)}},io=t=>{const e=t.tolerance??{};return{assetDecimals:Kr(t.asset_decimals),maxPriceStaleSeconds:Kr(t.max_price_stale_seconds),sources:to(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)}},so={"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:to(t).map((t=>{return e=to(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:to(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=to(t);return{topic:"position:batch_update",data:{accountId:Hr(e[0]),accountAttributes:ro(to(e[1])),updates:[...to(e[2]).map((t=>eo(to(t),"Deposit"))),...to(e[3]).map((t=>eo(to(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:no(t.key),oracle:io(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:Jr(t.asset),oracle:io(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)}}}},ao=Object.freeze(Object.keys(so));function uo(t,e){const r=Gr(t),o=so[r];return o?o(s(jr(e))):null}const lo=1e4;function co(t,e){return`${t}-${BigInt(e).toString(10)}`}function fo(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function po(t,e=0){return 1e4*t+e}function ho(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 mo=(t,e,r)=>{const o=new URL(e,t.endsWith("/")?t:`${t}/`);if(r)for(const[t,e]of Object.entries(r))void 0!==e&&o.searchParams.set(t,String(e));return o.toString()};async function go(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=mo(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}),o=await fetch(r,e.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${t}`)}return await o.json()}async function yo(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=mo(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 wo=(t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t,bo=t=>N(t).toXDR("base64");function _o(e,n){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const s=new o(e.routerAddress),a=new t(e.caller,e.sourceSequence),u=D(wo(n,e.referralId));return{xdr:new i(a,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(s.call("execute_strategy",_(e.caller),v(e.totalIn),u)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function vo(t,e){return _o(t,e)}function So(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(ko),splitPpm:t.splitPpm}))):[{hops:t.hops.map(ko),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function qo(t,e={}){const r=t;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:So(t,e)}const Io=So,ko=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Eo(t,e){const r=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${r}`)}async function Bo(t,e,r){const o=i.fromXDR(e,r?.network?m[r.network]:"");try{return(await t.prepareTransaction(o)).toXDR()}catch(t){if(r?.invokedContractId)throw Eo(r.invokedContractId,t);throw t}}async function Ao(t,e,r){return Bo(t,e.xdr,r)}function To(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 Ro(t,e){return new Uint8Array(0)}const xo=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 Uo(e){const r=new t(e.caller,e.sourceSequence),n=new o(e.forwarderAddress).call("mint_and_forward",a.ScVal.scvBytes(xo(e.message)),a.ScVal.scvBytes(xo(e.attestation)));return{xdr:new i(r,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const $o={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 Oo(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const r=Number(e[1]),o=$o[r];return o?{code:r,...o}:null}export{De as STELLAR_GOVERNANCE_ZERO_PREDECESSOR,ao as STELLAR_LENDING_TOPICS,p as STELLAR_NETWORKS,m as STELLAR_NETWORK_PASSPHRASE,lo as SYNTHETIC_EVENT_ORDER_STRIDE,Ro as buildSameTokenRepaySwapSteps,be as buildStellarAcceptOwnershipTx,We as buildStellarAddRewardsTx,ke as buildStellarApproveBlendPoolTx,Be as buildStellarApproveTokenTx,vo as buildStellarBatchSwapTx,G as buildStellarBorrowBatchTx,H as buildStellarBorrowTx,Uo as buildStellarCctpForwardTx,Me as buildStellarClaimRevenueTx,Ce as buildStellarCreateLiquidityPoolTx,Nr as buildStellarExecuteCancellerResetTx,_o as buildStellarExecuteStrategyTx,et as buildStellarFlashLoanTx,Dr as buildStellarGovernanceAddSpokeImmediateTx,Lr as buildStellarGovernanceCreateHubImmediateTx,Rr as buildStellarGovernanceExecuteGovernanceUpgradeTx,Ur as buildStellarGovernanceExecuteGrantGovernanceRoleTx,$r as buildStellarGovernanceExecuteRevokeGovernanceRoleTx,Or as buildStellarGovernanceExecuteTransferGovOwnTx,Tr as buildStellarGovernanceExecuteTx,xr as buildStellarGovernanceExecuteUpdateDelayTx,zr as buildStellarGovernancePauseTx,Fr as buildStellarGovernanceRevokeRoleImmediateTx,Wr as buildStellarGovernanceSetOracleSanityBoundsImmediateTx,Mr as buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,ge as buildStellarGrantRoleTx,co as buildStellarLendingIdentifier,Q as buildStellarLiquidateTx,rt as buildStellarMigrateFromBlendTx,he as buildStellarMigrateTx,ot as buildStellarMultiplyTx,de as buildStellarPauseTx,nr as buildStellarProposeAddAssetToSpokeTx,rr as buildStellarProposeAddSpokeTx,pr as buildStellarProposeApproveBlendPoolTx,cr as buildStellarProposeApproveTokenTx,Cr as buildStellarProposeCancellerResetTx,vr as buildStellarProposeConfigureAssetOracleTx,Sr as buildStellarProposeConfigureMarketOracleTx,er as buildStellarProposeCreateHubTx,dr as buildStellarProposeCreateLiquidityPoolTx,gr as buildStellarProposeDeployPoolTx,ir as buildStellarProposeEditAssetInSpokeTx,qr as buildStellarProposeEditOracleToleranceTx,Ir as buildStellarProposeGovernanceUpgradeTx,Er as buildStellarProposeGrantGovernanceRoleTx,br as buildStellarProposeMigrateControllerTx,sr as buildStellarProposeRemoveAssetFromSpokeTx,or as buildStellarProposeRemoveSpokeTx,hr as buildStellarProposeRevokeBlendPoolTx,Br as buildStellarProposeRevokeGovernanceRoleTx,fr 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,_r as buildStellarProposeTransferCtrlOwnershipTx,Ar as buildStellarProposeTransferGovOwnTx,Vr as buildStellarProposeUnpauseTx,kr as buildStellarProposeUpdateDelayTx,wr as buildStellarProposeUpgradeControllerTx,mr as buildStellarProposeUpgradePoolParamsTx,yr as buildStellarProposeUpgradePoolTx,Pe as buildStellarRenewAccountTx,Y as buildStellarRepayBatchTx,st as buildStellarRepayDebtWithCollateralTx,Z as buildStellarRepayTx,Ee as buildStellarRevokeBlendPoolTx,ye as buildStellarRevokeRoleTx,Ae as buildStellarRevokeTokenTx,qe as buildStellarSetAccumulatorTx,Se as buildStellarSetAggregatorTx,Re as buildStellarSetMarketOracleConfigTx,$e as buildStellarSetOracleSanityBoundsTx,xe as buildStellarSetOracleToleranceTx,Te as buildStellarSetOracleTx,Ie as buildStellarSetPositionLimitsTx,ve as buildStellarSetPriceAggregatorTx,Ue as buildStellarSetSpokeAssetFlagsTx,_e as buildStellarSetSwapAggregatorTx,X as buildStellarSupplyBatchTx,j as buildStellarSupplyTx,it as buildStellarSwapCollateralTx,nt as buildStellarSwapDebtTx,we as buildStellarTransferOwnershipTx,me as buildStellarUnpauseTx,Le as buildStellarUpdateAccountThresholdTx,Oe as buildStellarUpdateIndexesTx,pe as buildStellarUpgradeControllerTx,Ne as buildStellarUpgradeLiquidityPoolParamsTx,K as buildStellarWithdrawBatchTx,J as buildStellarWithdrawTx,z as buildTx,uo as decodeStellarLendingEvent,tt as decodeStellarLiquidateReturn,ce as encodeAssetOracle,Qt as encodeInterestRateModel,fe as encodeMarketOracleConfigInput,te as encodeMarketParamsRaw,ee as encodePositionLimits,re as encodePriceKey,bo as encodeStrategyPayloadToRouteXdr,fo as extractEventOrder,vt as getStellarAccountPositions,Xt as getStellarActiveUsersSeries,go as getStellarAggregatorQuote,yt as getStellarAsset,At as getStellarAssetGraph,It as getStellarAssetMarkets,qt as getStellarAssetPage,pt as getStellarAssets,Wt as getStellarCampaignLeaderboard,Yt as getStellarCampaignMe,Gt as getStellarDefiLlamaDimensions,d as getStellarDeployment,ft as getStellarDetailedMarkets,Ft as getStellarFeeRevenueSeries,Ot as getStellarGovernanceProposals,Mt as getStellarHolderDistribution,wt as getStellarHub,Tt as getStellarHubGraph,Et as getStellarHubHolders,ht as getStellarHubs,lt as getStellarLendingContext,ct as getStellarLendingLiveState,Nt as getStellarLiquidationsLeaderboard,zt as getStellarLiquidationsSeries,Ct as getStellarParticipantCounts,Jt as getStellarPnlByScope,Pt as getStellarPositionsLeaderboard,Kt as getStellarPositionsPnl,yo as getStellarQuoteTokens,jt as getStellarRateSpreadSeries,gt as getStellarReserve,xt as getStellarReserveGraph,kt as getStellarReserveHolders,mt as getStellarReserves,Dt as getStellarRevenueSeries,bt as getStellarSpoke,Rt as getStellarSpokeGraph,Bt as getStellarSpokeHolders,dt as getStellarSpokes,Lt as getStellarStatsHistory,Ut as getStellarUserActivity,$t as getStellarUserActivityPage,Ht as getStellarUserHistory,_t as getStellarUserPositions,Vt as getStellarVolumeSeries,St as getStellarWalletBalance,Io as mapQuoteResponseToAggregatorSwap,So as mapQuoteResponseToStrategyPayload,qo as mapQuoteResponseToStrategySwap,Oo as mapSorobanError,ho as mapStellarPositionActivityType,Ao as prepareStellarBuiltTx,Bo as prepareStellarTxXdr,Gr as stellarLendingDispatchKey,Zt as stellarLendingRead,h as stellarNetworks,po as syntheticEventOrder,Eo as tagStellarInvokedContractError,Xr as toBase64Xdr,To as toStellarPositionMode};export const XOXNOClient=f.G;
|
|
2
|
+
"undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,BASE_FEE as r,Contract as o,ScInt as n,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],o=e[1];return 3*(r+o)/4-o},e.toByteArray=function(t){var e,r,i=a(t),s=i[0],u=i[1],l=new n(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),c=0,f=u>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===u&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,o=t.length,n=o%3,i=[],s=16383,a=0,u=o-n;a<u;a+=s)i.push(l(t,a,a+s>u?u:a+s));return 1===n?(e=t[o-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[o-2]<<8)+t[o-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],o=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],o[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 o,n=[],i=e;i<r;i+=3)o=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),n.push(u(o));return n.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},287(t,e,r){const o=r(526),n=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 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 o=a(r);const n=o.write(t,e);return n!==r&&(o=o.slice(0,n)),o}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return h(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 h(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const o=t.valueOf&&t.valueOf();if(null!=o&&o!==t)return u.from(o,e,r);const n=function(t){if(u.isBuffer(t)){const e=0|d(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):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(n)return n;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|d(t))}function p(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let o=0;o<e;o+=1)r[o]=255&t[o];return r}function h(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 o;return o=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(o,u.prototype),o}function d(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,o=arguments.length>2&&!0===arguments[2];if(!o&&0===r)return 0;let n=!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(n)return o?-1:j(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){let o=!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 R(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(o)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}function y(t,e,r){const o=t[e];t[e]=t[r],t[r]=o}function w(t,e,r,o,n){if(0===t.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,o)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,o,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,o,n);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,o,n){let i,s=1,a=t.length,u=e.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){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(n){let o=-1;for(i=r;i<a;i++)if(l(t,i)===l(e,-1===o?0:i-o)){if(-1===o&&(o=i),i-o+1===u)return o*s}else-1!==o&&(i-=i-o),o=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){let r=!0;for(let o=0;o<u;o++)if(l(t,i+o)!==l(e,o)){r=!1;break}if(r)return i}return-1}function _(t,e,r,o){r=Number(r)||0;const n=t.length-r;o?(o=Number(o))>n&&(o=n):o=n;const i=e.length;let s;for(o>i/2&&(o=i/2),s=0;s<o;++s){const o=parseInt(e.substr(2*s,2),16);if(J(o))return s;t[r+s]=o}return s}function v(t,e,r,o){return H(j(e,t.length-r),t,r,o)}function S(t,e,r,o){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,o)}function q(t,e,r,o){return H(G(e),t,r,o)}function I(t,e,r,o){return H(function(t,e){let r,o,n;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),o=r>>8,n=r%256,i.push(n),i.push(o);return i}(e,t.length-r),t,r,o)}function k(t,e,r){return 0===e&&r===t.length?o.fromByteArray(t):o.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);const o=[];let n=e;for(;n<r;){const e=t[n];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(n+s<=r){let r,o,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[n+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[n+1],o=t[n+2],128==(192&r)&&128==(192&o)&&(u=(15&e)<<12|(63&r)<<6|63&o,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[n+1],o=t[n+2],a=t[n+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&o)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,o.push(i>>>10&1023|55296),i=56320|1023&i),o.push(i),n+=s}return function(t){const e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);let r="",o=0;for(;o<e;)r+=String.fromCharCode.apply(String,t.slice(o,o+=B));return r}(o)}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,o=e.length;for(let n=0,i=Math.min(r,o);n<i;++n)if(t[n]!==e[n]){r=t[n],o=e[n];break}return r<o?-1:o<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 o=u.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))n+e.length>o.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(o,n)):Uint8Array.prototype.set.call(o,e,n);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(o,n)}n+=e.length}return o},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?E(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,o,n){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===o&&(o=0),void 0===n&&(n=this.length),e<0||r>t.length||o<0||n>this.length)throw new RangeError("out of range index");if(o>=n&&e>=r)return 0;if(o>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(n>>>=0)-(o>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(i,s),l=this.slice(o,n),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,o){if(void 0===e)o="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)o=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===o&&(o="utf8")):(o=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return v(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return q(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: "+o);o=(""+o).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const B=4096;function A(t,e,r){let o="";r=Math.min(t.length,r);for(let n=e;n<r;++n)o+=String.fromCharCode(127&t[n]);return o}function T(t,e,r){let o="";r=Math.min(t.length,r);for(let n=e;n<r;++n)o+=String.fromCharCode(t[n]);return o}function R(t,e,r){const o=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>o)&&(r=o);let n="";for(let o=e;o<r;++o)n+=Y[t[o]];return n}function x(t,e,r){const o=t.slice(e,r);let n="";for(let t=0;t<o.length-1;t+=2)n+=String.fromCharCode(o[t]+256*o[t+1]);return n}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,o,n,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<i)throw new RangeError('"value" argument is out of bounds');if(r+o>t.length)throw new RangeError("Index out of range")}function O(t,e,r,o,n){F(e,o,n,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,o,n){F(e,o,n,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 C(t,e,r,o,n,i){if(r+o>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,o,i){return e=+e,r>>>=0,i||C(t,0,r,4),n.write(t,e,r,o,23,4),r+4}function M(t,e,r,o,i){return e=+e,r>>>=0,i||C(t,0,r,8),n.write(t,e,r,o,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 o=this.subarray(t,e);return Object.setPrototypeOf(o,u.prototype),o},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t],n=1,i=0;for(;++i<e&&(n*=256);)o+=this[t+i]*n;return o},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t+--e],n=1;for(;e>0&&(n*=256);)o+=this[t+--e]*n;return o},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=Z((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 o=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(o)+(BigInt(n)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((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 o=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(o)<<BigInt(32))+BigInt(n)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=this[t],n=1,i=0;for(;++i<e&&(n*=256);)o+=this[t+i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*e)),o},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let o=e,n=1,i=this[t+--o];for(;o>0&&(n*=256);)i+=this[t+--o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},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=Z((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 o=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((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 o=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(o)<<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),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,o){t=+t,e>>>=0,r>>>=0,o||$(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,i=0;for(this[e]=255&t;++i<r&&(n*=256);)this[e+i]=t/n&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,o){t=+t,e>>>=0,r>>>=0,o||$(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,i=1;for(this[e+n]=255&t;--n>=0&&(i*=256);)this[e+n]=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 O(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,o){if(t=+t,e>>>=0,!o){const o=Math.pow(2,8*r-1);$(this,t,e,r,o-1,-o)}let n=0,i=1,s=0;for(this[e]=255&t;++n<r&&(i*=256);)t<0&&0===s&&0!==this[e+n-1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,o){if(t=+t,e>>>=0,!o){const o=Math.pow(2,8*r-1);$(this,t,e,r,o-1,-o)}let n=r-1,i=1,s=0;for(this[e+n]=255&t;--n>=0&&(i*=256);)t<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(t/i|0)-s&255;return e+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 O(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 N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(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,o){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<r&&(o=r),o===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(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-r&&(o=t.length-e+r);const n=o-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,o):Uint8Array.prototype.set.call(t,this.subarray(r,o),e),n},u.prototype.fill=function(t,e,r,o){if("string"==typeof t){if("string"==typeof e?(o=e,e=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){const e=t.charCodeAt(0);("utf8"===o&&e<128||"latin1"===o)&&(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 n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const i=u.isBuffer(t)?t:u.from(t,o),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<r-e;++n)this[n+e]=i[n%s]}return this};const W={};function L(t,e,r){W[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 o="-"===t[0]?1:0;for(;r>=o+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,o,n,i){if(t>r||t<e){const o="bigint"==typeof e?"n":"";let n;throw n=i>3?0===e||e===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${e}${o} and <= ${r}${o}`,new W.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(o,n,i)}function z(t,e){if("number"!=typeof t)throw new W.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw z(t,r),new W.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new W.ERR_BUFFER_OUT_OF_BOUNDS;throw new W.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}L("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),L("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),L("ERR_OUT_OF_RANGE",(function(t,e,r){let o=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=D(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=D(n)),n+="n"),o+=` It must be ${e}. Received ${n}`,o}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function j(t,e){let r;e=e||1/0;const o=t.length;let n=null;const i=[];for(let s=0;s<o;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(e-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&i.push(239,191,189);if(n=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 o.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,o){let n;for(n=0;n<o&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const o=16*r;for(let n=0;n<16;++n)e[o+n]=t[r]+t[n]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251(t,e){e.read=function(t,e,r,o,n){var i,s,a=8*n-o-1,u=(1<<a)-1,l=u>>1,c=-7,f=r?n-1:0,p=r?-1:1,h=t[e+f];for(f+=p,i=h&(1<<-c)-1,h>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=o;c>0;s=256*s+t[e+f],f+=p,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,o),i-=l}return(h?-1:1)*s*Math.pow(2,i-o)},e.write=function(t,e,r,o,n,i){var s,a,u,l=8*i-n-1,c=(1<<l)-1,f=c>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?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+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,n),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=255&a,h+=d,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;t[r+h]=255&s,h+=d,s/=256,l-=8);t[r+h-d]|=128*m}},387(t,e,r){r.d(e,{GW:()=>i});var o,n=r(564);!function(t){t.MAINNET="1",t.DEVNET="D"}(o||(o={}));class i{apiUrl;chain;init;config;constructor(t){if(!t?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:e=o.MAINNET,apiUrl:r,...i}=t;this.apiUrl=r.trim().replace(/\/$/,""),this.chain=e,this.init=i,this.config=e==o.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:n.s0,FM_SC:n.ZZ,DR_SC:n.sM,KG_SC:n.KL,Staking_SC:n.V,Manager_SC:n.Rh,P2P_SC:n.EP}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:n.cM,FM_SC:n.ZZ,DR_SC:n.sM,KG_SC:n.KL,Staking_SC:n.J6,Manager_SC:n.Ff,P2P_SC:n.gx}}fetchWithTimeout=async(t,{params:e,...r}={})=>{const{next:o,cache:n,debug:i,timeout:s,...a}=this.init,{next:u,cache:l,debug:c,timeout:f,headers:p,method:h="GET",...d}=r,m=p?.Authorization,g="Bearer undefined"===m?void 0:m,y="GET"!==h&&"HEAD"!==h&&"PUT"!==h,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("&"),_=`${this.apiUrl}${t}${b.length?`?${b}`:""}`,{revalidate:v,...S}=o??{},{revalidate:q,...I}=u??{},k="GET"!==h||g?void 0:q??v,E="GET"!==h||g||k?void 0:l??n,B=d.body,A=f??s??(null==B?3e4:0),T=A>0?AbortSignal.timeout(A):void 0,R=d.signal??a.signal,x=T&&R?AbortSignal.any([R,T]):T??R,U={...a,...d,method:h,...Object.keys(w).length?{headers:w}:{},...x?{signal:x}:{},cache:E,next:{...S,...I,revalidate:k}};(c??i)&&console.debug("SDK fetch: ",_,U);const $=await fetch(_,U).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${_}: ${t.message}`),{cause:t});throw t})),O=await $.text();if(!$.ok){let t;try{t=JSON.parse(O)}catch{t={message:O}}const e=[_,$.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:()=>s,Rh:()=>u,V:()=>a,ZZ:()=>n,cM:()=>c,gx:()=>h,s0:()=>o,sM:()=>i});const o="erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",n="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",i="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",s="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",a="erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",u="erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",l="erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6",c="erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",f="erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",p="erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",h="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 f=c(387);const p={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"}},h=p;function d(t){return p["testnet"===t?"stellarTestnet":"stellarMainnet"]}const m={mainnet:p.stellarMainnet.passphrase,testnet:p.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,_=t=>new e(t).toScVal(),v=t=>new n(t).toI128(),S=t=>a.ScVal.scvU32(t),q=t=>{if("number"==typeof t&&!Number.isSafeInteger(t))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new n("string"==typeof t?t:t.toString()).toU64()},I=t=>a.ScVal.scvBool(t),k=t=>a.ScVal.scvString(t),E=t=>a.ScVal.scvSymbol(t),B=()=>a.ScVal.scvVoid(),A=t=>a.ScVal.scvVec(t),T=(t,e=32)=>{const r=t.startsWith("0x")?t.slice(2):t,o=g.hp.from(r,"hex");if(o.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${o.length} bytes from "${t}")`);return a.ScVal.scvBytes(o)},R=(t,e)=>null==t?B():e(t),x=(t,e)=>P({asset:_(e),hub_id:S(t)}),U=(t,e,r)=>a.ScVal.scvVec([x(t,e),v(r)]),$=t=>a.ScVal.scvVec(t.map((t=>U(t.hubId,t.asset,t.amount)))),O=t=>{if("Transfer"===t)return A([E("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 A([E("Credit"),q(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:E(e),val:t[e]})));return a.ScVal.scvMap(e)};class C{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,o,n){this.ops.push([t,e,r,o,n])}emitPath(t,e){t.hops.forEach(((r,o)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[o-1];if(n&&r.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(w[r.venue],0===o?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 o=e[t].hops[0]?.tokenIn,n=[];for(let r=t;r<e.length;r+=1)e[r].hops[0]?.tokenIn===o&&n.push(r);const i=n.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;n.forEach(((t,o)=>{r[t]=!0;const i=e[t];let u;if(o+1===n.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 o=[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)o.push(...t);for(const t of this.weights)o.push(t>>>16&255,t>>>8&255,255&t);return g.hp.from(o)}get assetList(){return this.assets}get amountList(){return this.amounts}}const N=t=>{const e=new C(t.totalMinOut),r=e.asset(t.tokenIn),o=e.asset(t.tokenOut);if(r===o)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const o=e.asset(t.burnPool),n=e.amountList.length;for(const r of t.burnMinAmounts??[])e.amount(r);e.emit(5,0,o,r,n)}if(e.lowerPaths(t.paths),t.mintPool){const r=t.preSwapAmount;if(r&&BigInt(r)>0n){const o=t.mintPoolTokens;if(!o||2!==o.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=o,[s,a]=t.preSwapFromA?[n,i]:[i,n];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),o,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return P({amounts:a.ScVal.scvVec(e.amountList.map((t=>v(t)))),assets:a.ScVal.scvVec(e.assetList.map((t=>_(t)))),ops:a.ScVal.scvBytes(e.toBytes(r,o,n))})},M=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)},W=()=>a.ScVal.scvBytes(g.hp.alloc(0)),L=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 o=g.hp.from(e,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},D=t=>{if("string"==typeof t)return M(L(t));if(t instanceof Uint8Array)return 0===t.length?W():M(t);if(t&&"object"==typeof t)return"routeXdr"in(r=t)&&"string"==typeof r.routeXdr?M(L(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?M(L(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?M(L(t.bytes)):0===t.bytes.length?W():M(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,o]of e.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.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 o.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=o.hops[0];r.set(e.tokenIn,(r.get(e.tokenIn)??0)+o.splitPpm)}for(const[t,o]of r){if(o>b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${o}, above 1000000`);if(!e.mintPool&&o!==b)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${o}`)}return e})(t),a.ScVal.scvBytes(g.hp.from(N(e).toXDR("base64"),"base64")));var e,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},F=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 z(e,n,s){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const a=new o(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(n,...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 z(t,"supply",[_(t.caller),q(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 z(t,"borrow",[_(t.caller),q(e.accountNonce),$([...e.borrows]),R(e.to,_)])}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 z(t,"withdraw",[_(t.caller),q(e.accountNonce),$([...e.withdrawals]),R(e.to,_)])}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 z(t,"repay",[_(t.caller),q(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 z(t,"liquidate",[_(t.caller),q(e.accountNonce),$([...e.debtPayments]),O(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 z(t,"flash_loan",[_(t.caller),x(e.hubId,e.asset),v(e.amount),_(e.receiver),F(e.data)])}function rt(t,e){return z(t,"migrate_from_blend",[_(t.caller),q(e.accountId),V(e.spokeId),S(e.hubId),_(e.blendPool),A(e.collateralTokens.map(_)),A(e.supplyTokens.map(_)),(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([_(e),v(r)]);var e,r}))))]);var r}function ot(t,e){const r=e.accountNonce??0;return z(t,"multiply",[_(t.caller),q(r),V(e.spokeId),x(e.collateral.hubId,e.collateral.asset),v(e.debtToFlashLoan),x(e.debt.hubId,e.debt.asset),S(e.mode),D(e.steps),R(e.initialPayment,(t=>U(t.hubId,t.asset,t.amount))),R(e.convertSwap,D)])}function nt(t,e){return z(t,"swap_debt",[_(t.caller),q(e.accountNonce),x(e.existingDebt.hubId,e.existingDebt.asset),v(e.newDebtAmount),x(e.newDebt.hubId,e.newDebt.asset),D(e.steps)])}function it(t,e){return z(t,"swap_collateral",[_(t.caller),q(e.accountNonce),x(e.current.hubId,e.current.asset),v(e.fromAmount),x(e.newCollateral.hubId,e.newCollateral.asset),D(e.steps)])}function st(t,e){return z(t,"repay_debt_with_collateral",[_(t.caller),q(e.accountNonce),x(e.collateral.hubId,e.collateral.asset),v(e.collateralAmount),x(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),ft=(t,e)=>t.fetchWithTimeout(`${at}/markets/detailed`,e),pt=(t,e)=>t.fetchWithTimeout(`${at}/assets`,e),ht=(t,e)=>t.fetchWithTimeout(`${at}/hubs`,e),dt=(t,e)=>t.fetchWithTimeout(`${at}/spokes`,e),mt=(t,e={},r)=>t.fetchWithTimeout(`${at}/reserves`,{...r,params:{...e}}),gt=(t,e,r,o,n)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}`,n),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),_t=(t,e,r)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/positions`,r),vt=(t,e,r)=>t.fetchWithTimeout(`${at}/accounts/${ut(e)}/positions`,r),St=(t,e,r,o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/assets/${ut(r)}/balance`,o),qt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/page`,{...o,params:{...r}}),It=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/markets`,{...o,params:{side:r}}),kt=(t,e,r,o,n,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}/holders`,{...i,params:{side:n}}),Et=(t,e,r,o)=>t.fetchWithTimeout(`${at}/hubs/${e}/holders`,{...o,params:{side:r}}),Bt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/spokes/${e}/holders`,{...o,params:{side:r}}),At=(t,e,r,o)=>t.fetchWithTimeout(`${at}/assets/${ut(e)}/graph`,{...o,params:{...r}}),Tt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/hubs/${e}/graph`,{...o,params:{...r}}),Rt=(t,e,r,o)=>t.fetchWithTimeout(`${at}/spokes/${e}/graph`,{...o,params:{...r}}),xt=(t,e,r,o,n,i)=>t.fetchWithTimeout(`${at}/reserves/${e}/${r}/${ut(o)}/graph`,{...i,params:{...n}}),Ut=(t,e,r={},o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity`,{...o,params:{...r}}),$t=(t,e,r={},o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/activity/page`,{...o,params:{...r}}),Ot=(t,e={},r)=>t.fetchWithTimeout(`${at}/governance/proposals`,{...r,params:{...e}}),Pt=(t,e={},r)=>t.fetchWithTimeout(`${at}/positions`,{...r,params:{...e}}),Ct=(t,e={},r)=>t.fetchWithTimeout(`${at}/participants`,{...r,params:{...e}}),Nt=(t,e={},r)=>t.fetchWithTimeout(`${at}/liquidations/leaderboard`,{...r,params:{...e}}),Mt=(t,e={},r)=>t.fetchWithTimeout(`${at}/distribution`,{...r,params:{...e}}),Wt=(t,e={},r)=>t.fetchWithTimeout(`${at}/campaign/leaderboard`,{...r,params:{...e}}),Lt=(t,e,r)=>t.fetchWithTimeout(`${at}/stats/history`,{...r,params:{...e}}),Dt=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue`,{...r,params:{...e}}),Ft=(t,e,r)=>t.fetchWithTimeout(`${at}/revenue/fees`,{...r,params:{...e}}),zt=(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,o)=>t.fetchWithTimeout(`${at}/users/${ut(e)}/history`,{...o,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=>ft(t,e),assets:e=>pt(t,e),hubs:e=>ht(t,e),spokes:e=>dt(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,o,n)=>gt(t,e,r,o,n),asset:(e,r)=>yt(t,e,r),hub:(e,r)=>wt(t,e,r),spoke:(e,r)=>bt(t,e,r),userPositions:(e,r)=>_t(t,e,r),accountPositions:(e,r)=>vt(t,e,r),walletBalance:(e,r,o)=>St(t,e,r,o),assetPage:(e,r,o)=>qt(t,e,r,o),assetMarkets:(e,r,o)=>It(t,e,r,o),reserveHolders:(e,r,o,n,i)=>kt(t,e,r,o,n,i),hubHolders:(e,r,o)=>Et(t,e,r,o),spokeHolders:(e,r,o)=>Bt(t,e,r,o),assetGraph:(e,r,o)=>At(t,e,r,o),hubGraph:(e,r,o)=>Tt(t,e,r,o),spokeGraph:(e,r,o)=>Rt(t,e,r,o),reserveGraph:(e,r,o,n,i)=>xt(t,e,r,o,n,i),userActivity:(e,r={},o)=>Ut(t,e,r,o),userActivityPage:(e,r={},o)=>$t(t,e,r,o),governanceProposals:(e={},r)=>Ot(t,e,r),positionsLeaderboard:(e={},r)=>Pt(t,e,r),participants:(e={},r)=>Ct(t,e,r),liquidationsLeaderboard:(e={},r)=>Nt(t,e,r),distribution:(e={},r)=>Mt(t,e,r),campaignLeaderboard:(e={},r)=>Wt(t,e,r),statsHistory:(e,r)=>Lt(t,e,r),revenue:(e,r)=>Dt(t,e,r),feeRevenue:(e,r)=>Ft(t,e,r),liquidations:(e,r)=>zt(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,o)=>Ht(t,e,r,o),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:v(t.baseBorrowRateRay),max_borrow_rate:v(t.maxBorrowRateRay),max_utilization:v(t.maxUtilizationRay),mid_utilization:v(t.midUtilizationRay),optimal_utilization:v(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:v(t.slope1Ray),slope2:v(t.slope2Ray),slope3:v(t.slope3Ray)}),te=t=>P({asset_decimals:S(t.assetDecimals),asset_id:_(t.assetId),base_borrow_rate:v(t.baseBorrowRateRay),flashloan_fee:S(t.flashloanFeeBps),is_flashloanable:I(t.isFlashloanable),max_borrow_rate:v(t.maxBorrowRateRay),max_utilization:v(t.maxUtilizationRay),mid_utilization:v(t.midUtilizationRay),optimal_utilization:v(t.optimalUtilizationRay),reserve_factor:S(t.reserveFactorBps),slope1:v(t.slope1Ray),slope2:v(t.slope2Ray),slope3:v(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 A([E("Token"),_(t.Token)]);if("Ref"in t&&t.Ref)return A([E("Ref"),E(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},oe=t=>{if("Stellar"in t)return A([E("Stellar"),_(t.Stellar)]);if("Symbol"in t)return A([E("Symbol"),E(t.Symbol)]);if("String"in t)return A([E("String"),k(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},ne=t=>{if("Spot"===t)return A([E("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return A([E("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 A([E(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},se=t=>{if("Market"===t||"Fundamental"===t)return A([E(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},ae=t=>{if("Reflector"in t){const e=t.Reflector;return A([E("Reflector"),P({asset:oe(e.asset),contract:_(e.contract),read_mode:ne(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return A([E("MultiFeed"),P({contract:_(e.contract),feed_id:k(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:q(e.maxStaleSeconds),provider:ae(e.provider)})},le=t=>{if("RequireDisjoint"===t)return A([E("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return A([E("AllowShared"),A(e.map((t=>P({contract:_(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 o,n;if("number"==typeof e.toleranceBps)o=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/o));else{const t=e.tolerance??{};o=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return P({asset_decimals:S(Number(e.assetDecimals)),independence:le(e.independence),max_price_stale_seconds:q(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:v(String(e.maxSanityPriceWad)),min_sanity_price_wad:v(String(e.minSanityPriceWad)),sources:A(r.map((t=>(t=>{if("Feed"in t)return A([E("Feed"),ue(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return A([E("Scaled"),P({factor:ue(e.factor),max_factor_wad:v(e.maxFactorWad),min_factor_wad:v(e.minFactorWad),quote:re(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return A([E("LpShare"),P({key_a:re(e.keyA),key_b:re(e.keyB),kind:A([E(e.kind||"ConstantProduct")]),pool:_(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(n),upper_ratio_bps:S(o)})})},fe=ce;function pe(t,e){return z(t,"upgrade",[T(e.wasmHash)])}function he(t,e){return z(t,"migrate",[S(e.newVersion)])}function de(t){return z(t,"pause",[])}function me(t){return z(t,"unpause",[])}function ge(t,e){return z(t,"grant_role",[_(e.account),E(e.role)])}function ye(t,e){return z(t,"revoke_role",[_(e.account),E(e.role)])}function we(t,e){return z(t,"transfer_ownership",[_(e.newOwner),S(e.liveUntilLedger)])}function be(t){return z(t,"accept_ownership",[])}function _e(t,e){return z(t,"set_swap_aggregator",[_(e.aggregator)])}function ve(t,e){return z(t,"set_price_aggregator",[_(e.aggregator)])}const Se=_e;function qe(t,e){return z(t,"set_accumulator",[_(e.accumulator)])}function Ie(t,e){return z(t,"set_position_limits",[ee(e)])}function ke(t,e){return z(t,"approve_blend_pool",[_(e.pool)])}function Ee(t,e){return z(t,"revoke_blend_pool",[_(e.pool)])}const Be=ke,Ae=Ee;function Te(t,e){return z(t,"set_oracle",[re(e.key),ce(e.oracle)])}const Re=Te;function xe(t,e){const r=e.toleranceBps,o=e.upperRatioBps??1e4+r,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/o));return z(t,"set_tolerance",[re(e.key),P({lower_ratio_bps:S(n),upper_ratio_bps:S(o)})])}function Ue(t,e){return z(t,"set_spoke_asset_flags",[S(e.spokeId),x(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function $e(t,e){return z(t,"set_oracle_sanity_bounds",[_(e.asset),v(e.minPriceWad),v(e.maxPriceWad)])}function Oe(t,e){return z(t,"update_indexes",[_(t.caller),A(e.assets.map((t=>x(t.hubId,t.asset))))])}function Pe(t,e){return z(t,"renew_account",[_(t.caller),q(e.accountNonce)])}function Ce(t,e){return z(t,"create_liquidity_pool",[S(e.hubId),_(e.asset),te(e.params)])}function Ne(t,e){return z(t,"upgrade_liquidity_pool_params",[x(e.hubId,e.asset),Qt(e.params)])}function Me(t,e){return z(t,"claim_revenue",[_(t.caller),A(e.assets.map((t=>x(t.hubId,t.asset))))])}function We(t,e){return z(t,"add_rewards",[_(t.caller),$(e.rewards)])}function Le(t,e){return z(t,"update_account_threshold",[_(t.caller),I(e.hasRisks),A(e.accountNonces.map((t=>q(t))))])}const De="00".repeat(32),Fe=t=>{if("string"==typeof t)return T(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)},ze=(t,...e)=>A([E(t),...e]),Ve=t=>P({new_owner:_(t.newOwner),live_until_ledger:S(t.liveUntilLedger)}),Xe=t=>P({asset:_(t.asset),bonus:S(t.bonus),borrow_cap:v(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:v(t.supplyCap),threshold:S(t.threshold)}),je=t=>P({account:_(t.account),role:E(t.role)});function Ge(e,n,s){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const a=new o(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(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const He=(t,e,r)=>Ge(t,"propose",[_(t.caller),e,Fe(r)]),Ke=(t,e,r)=>Ge(t,"execute_self",[B(),e,Fe(r)]);function Je(t,e,r){return He(t,ze("SetSwapAggregator",_(e.aggregator)),r)}function Ye(t,e,r){return He(t,ze("SetPriceAggregator",_(e.aggregator)),r)}const Ze=Je;function Qe(t,e,r){return He(t,ze("SetAccumulator",_(e.accumulator)),r)}function tr(t,e,r){return He(t,ze("SetPositionLimits",ee(e)),r)}function er(t,e){return He(t,ze("CreateHub"),e)}function rr(t,e){return He(t,ze("AddSpoke"),e)}function or(t,e,r){return He(t,ze("RemoveSpoke",S(e.spokeId)),r)}function nr(t,e,r){return He(t,ze("AddAssetToSpoke",Xe(e)),r)}function ir(t,e,r){return He(t,ze("EditAssetInSpoke",Xe(e)),r)}function sr(t,e,r){return He(t,ze("RemoveAssetFromSpoke",P({hub_asset:x((o=e).hubId,o.asset),spoke_id:S(o.spokeId)})),r);var o}function ar(t,e,r){return He(t,ze("SetSpokeLiquidationCurve",P({hf_for_max_bonus_wad:v((o=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:S(o.liquidationBonusFactorBps),spoke_id:S(o.spokeId),target_hf_wad:v(o.targetHfWad)})),r);var o}function ur(t,e,r){return He(t,ze("SetPositionManager",_(e.manager),I(e.isActive)),r)}function lr(t,e,r){return He(t,ze("SetMinBorrowCollateralUsd",v(e.floorWad)),r)}function cr(t,e,r){return He(t,ze("ApproveToken",_(e.token)),r)}function fr(t,e,r){return He(t,ze("RevokeToken",_(e.token)),r)}function pr(t,e,r){return He(t,ze("ApproveBlendPool",_(e.pool)),r)}function hr(t,e,r){return He(t,ze("RevokeBlendPool",_(e.pool)),r)}function dr(t,e,r){return He(t,ze("CreateLiquidityPool",P({asset:_((o=e).asset),hub_id:S(o.hubId),params:te(o.params)})),r);var o}function mr(t,e,r){return He(t,ze("UpgradeLiquidityPoolParams",P({hub_asset:x((o=e).hubId,o.asset),params:Qt(o.params)})),r);var o}function gr(t,e,r){return He(t,ze("DeployPool",T(e.wasmHash)),r)}function yr(t,e,r){return He(t,ze("UpgradePool",T(e.wasmHash)),r)}function wr(t,e,r){return He(t,ze("UpgradeController",T(e.wasmHash)),r)}function br(t,e,r){return He(t,ze("MigrateController",S(e.newVersion)),r)}function _r(t,e,r){return He(t,ze("TransferCtrlOwnership",Ve(e)),r)}function vr(t,e,r){return He(t,ze("ConfigureAssetOracle",P({key:re((o=e).key),oracle:ce(o.oracle)})),r);var o}const Sr=vr;function qr(t,e,r){return He(t,ze("EditOracleTolerance",P({key:re((o=e).key),tolerance:S(o.tolerance)})),r);var o}function Ir(t,e,r){return He(t,ze("UpgradeGov",T(e.wasmHash)),r)}function kr(t,e,r){return He(t,ze("UpdateGovDelay",S(e.newDelay)),r)}function Er(t,e,r){return He(t,ze("GrantGovRole",je(e)),r)}function Br(t,e,r){return He(t,ze("RevokeGovRole",je(e)),r)}function Ar(t,e,r){return He(t,ze("TransferGovOwnership",Ve(e)),r)}function Tr(t,e){const r=A(e.argsXdr.map((t=>a.ScVal.fromXDR(t,"base64")))),o=Fe(e.predecessor??De);return Ge(t,"execute",[B(),_(e.target),E(e.functionName),r,o,Fe(e.salt)])}function Rr(t,e,r){return Ke(t,ze("UpgradeGov",T(e.wasmHash)),r)}function xr(t,e,r){return Ke(t,ze("UpdateGovDelay",S(e.newDelay)),r)}function Ur(t,e,r){return Ke(t,ze("GrantGovRole",je(e)),r)}function $r(t,e,r){return Ke(t,ze("RevokeGovRole",je(e)),r)}function Or(t,e,r){return Ke(t,ze("TransferGovOwnership",Ve(e)),r)}const Pr=t=>A(t.map(_));function Cr(t,e,r){return Ge(t,"propose_canceller_reset",[Pr(e.newCancellers),Fe(r)])}function Nr(t,e,r){return Ge(t,"execute_canceller_reset",[R(e.executor,_),Pr(e.newCancellers),Fe(r)])}function Mr(t,e){return Ge(t,"set_spoke_asset_flags",[_(t.caller),S(e.spokeId),x(e.hubId,e.asset),I(e.paused),I(e.frozen),I(e.noSeize)])}function Wr(t,e){return Ge(t,"set_oracle_sanity_bounds",[_(t.caller),_(e.asset),v(e.minPriceWad),v(e.maxPriceWad)])}function Lr(t){return Ge(t,"create_hub",[_(t.caller)])}function Dr(t){return Ge(t,"add_spoke",[_(t.caller)])}function Fr(t,e){return Ge(t,"revoke_role_immediate",[_(e.account),E(e.role)])}function zr(t){return Ge(t,"pause",[_(t.caller)])}function Vr(t,e){return He(t,ze("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"],to=t=>Array.isArray(t)?t:[],eo=(t,e)=>{const r="Borrow"===e;return{action:(o=t[0],Qr[Kr(o)]??Hr(o)),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 o},ro=t=>{return{owner:Jr(t[0]),spokeId:Kr(t[1]),mode:(e=t[2],Zr[Kr(e)]??"None")};var e},oo=t=>Array.isArray(t)?t[1]:void 0,no=t=>{const e=(r=t,Array.isArray(r)?Jr(r[0]):Jr(r));var r;if("Token"===e)return{Token:Jr(oo(t))};if("Ref"===e)return{Ref:Jr(oo(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)}},io=t=>{const e=t.tolerance??{};return{assetDecimals:Kr(t.asset_decimals),maxPriceStaleSeconds:Kr(t.max_price_stale_seconds),sources:to(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)}},so={"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:to(t).map((t=>{return e=to(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:to(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=to(t);return{topic:"position:batch_update",data:{accountId:Hr(e[0]),accountAttributes:ro(to(e[1])),updates:[...to(e[2]).map((t=>eo(to(t),"Deposit"))),...to(e[3]).map((t=>eo(to(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:no(t.key),oracle:io(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:Jr(t.asset),oracle:io(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)}}}},ao=Object.freeze(Object.keys(so));function uo(t,e){const r=Gr(t),o=so[r];return o?o(s(jr(e))):null}const lo=1e4;function co(t,e){return`${t}-${BigInt(e).toString(10)}`}function fo(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function po(t,e=0){return 1e4*t+e}function ho(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 mo=(t,e,r)=>{const o=new URL(e,t.endsWith("/")?t:`${t}/`);if(r)for(const[t,e]of Object.entries(r))void 0!==e&&o.searchParams.set(t,String(e));return o.toString()};async function go(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=mo(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}),o=await fetch(r,e.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${t}`)}return await o.json()}async function yo(t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");const e=mo(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 wo=(t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t,bo=t=>N(t).toXDR("base64");function _o(e,n){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const s=new o(e.routerAddress),a=new t(e.caller,e.sourceSequence),u=D(wo(n,e.referralId));return{xdr:new i(a,{fee:e.fee??r,networkPassphrase:m[e.network]}).addOperation(s.call("execute_strategy",_(e.caller),v(e.totalIn),u)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function vo(t,e){return _o(t,e)}function So(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(ko),splitPpm:t.splitPpm}))):[{hops:t.hops.map(ko),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function qo(t,e={}){const r=t;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:So(t,e)}const Io=So,ko=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Eo(t,e){const r=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${r}`)}async function Bo(t,e,r){const o=i.fromXDR(e,r?.network?m[r.network]:"");try{return(await t.prepareTransaction(o)).toXDR()}catch(t){if(r?.invokedContractId)throw Eo(r.invokedContractId,t);throw t}}async function Ao(t,e,r){return Bo(t,e.xdr,r)}function To(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 Ro(t,e){return new Uint8Array(0)}const xo=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 Uo(e){const r=new t(e.caller,e.sourceSequence),n=new o(e.forwarderAddress).call("mint_and_forward",a.ScVal.scvBytes(xo(e.message)),a.ScVal.scvBytes(xo(e.attestation)));return{xdr:new i(r,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const $o={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 Oo(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const r=Number(e[1]),o=$o[r];return o?{code:r,...o}:null}export{De as STELLAR_GOVERNANCE_ZERO_PREDECESSOR,ao as STELLAR_LENDING_TOPICS,p as STELLAR_NETWORKS,m as STELLAR_NETWORK_PASSPHRASE,lo as SYNTHETIC_EVENT_ORDER_STRIDE,Ro as buildSameTokenRepaySwapSteps,be as buildStellarAcceptOwnershipTx,We as buildStellarAddRewardsTx,ke as buildStellarApproveBlendPoolTx,Be as buildStellarApproveTokenTx,vo as buildStellarBatchSwapTx,G as buildStellarBorrowBatchTx,H as buildStellarBorrowTx,Uo as buildStellarCctpForwardTx,Me as buildStellarClaimRevenueTx,Ce as buildStellarCreateLiquidityPoolTx,Nr as buildStellarExecuteCancellerResetTx,_o as buildStellarExecuteStrategyTx,et as buildStellarFlashLoanTx,Dr as buildStellarGovernanceAddSpokeImmediateTx,Lr as buildStellarGovernanceCreateHubImmediateTx,Rr as buildStellarGovernanceExecuteGovernanceUpgradeTx,Ur as buildStellarGovernanceExecuteGrantGovernanceRoleTx,$r as buildStellarGovernanceExecuteRevokeGovernanceRoleTx,Or as buildStellarGovernanceExecuteTransferGovOwnTx,Tr as buildStellarGovernanceExecuteTx,xr as buildStellarGovernanceExecuteUpdateDelayTx,zr as buildStellarGovernancePauseTx,Fr as buildStellarGovernanceRevokeRoleImmediateTx,Wr as buildStellarGovernanceSetOracleSanityBoundsImmediateTx,Mr as buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,ge as buildStellarGrantRoleTx,co as buildStellarLendingIdentifier,Q as buildStellarLiquidateTx,rt as buildStellarMigrateFromBlendTx,he as buildStellarMigrateTx,ot as buildStellarMultiplyTx,de as buildStellarPauseTx,nr as buildStellarProposeAddAssetToSpokeTx,rr as buildStellarProposeAddSpokeTx,pr as buildStellarProposeApproveBlendPoolTx,cr as buildStellarProposeApproveTokenTx,Cr as buildStellarProposeCancellerResetTx,vr as buildStellarProposeConfigureAssetOracleTx,Sr as buildStellarProposeConfigureMarketOracleTx,er as buildStellarProposeCreateHubTx,dr as buildStellarProposeCreateLiquidityPoolTx,gr as buildStellarProposeDeployPoolTx,ir as buildStellarProposeEditAssetInSpokeTx,qr as buildStellarProposeEditOracleToleranceTx,Ir as buildStellarProposeGovernanceUpgradeTx,Er as buildStellarProposeGrantGovernanceRoleTx,br as buildStellarProposeMigrateControllerTx,sr as buildStellarProposeRemoveAssetFromSpokeTx,or as buildStellarProposeRemoveSpokeTx,hr as buildStellarProposeRevokeBlendPoolTx,Br as buildStellarProposeRevokeGovernanceRoleTx,fr 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,_r as buildStellarProposeTransferCtrlOwnershipTx,Ar as buildStellarProposeTransferGovOwnTx,Vr as buildStellarProposeUnpauseTx,kr as buildStellarProposeUpdateDelayTx,wr as buildStellarProposeUpgradeControllerTx,mr as buildStellarProposeUpgradePoolParamsTx,yr as buildStellarProposeUpgradePoolTx,Pe as buildStellarRenewAccountTx,Y as buildStellarRepayBatchTx,st as buildStellarRepayDebtWithCollateralTx,Z as buildStellarRepayTx,Ee as buildStellarRevokeBlendPoolTx,ye as buildStellarRevokeRoleTx,Ae as buildStellarRevokeTokenTx,qe as buildStellarSetAccumulatorTx,Se as buildStellarSetAggregatorTx,Re as buildStellarSetMarketOracleConfigTx,$e as buildStellarSetOracleSanityBoundsTx,xe as buildStellarSetOracleToleranceTx,Te as buildStellarSetOracleTx,Ie as buildStellarSetPositionLimitsTx,ve as buildStellarSetPriceAggregatorTx,Ue as buildStellarSetSpokeAssetFlagsTx,_e as buildStellarSetSwapAggregatorTx,X as buildStellarSupplyBatchTx,j as buildStellarSupplyTx,it as buildStellarSwapCollateralTx,nt as buildStellarSwapDebtTx,we as buildStellarTransferOwnershipTx,me as buildStellarUnpauseTx,Le as buildStellarUpdateAccountThresholdTx,Oe as buildStellarUpdateIndexesTx,pe as buildStellarUpgradeControllerTx,Ne as buildStellarUpgradeLiquidityPoolParamsTx,K as buildStellarWithdrawBatchTx,J as buildStellarWithdrawTx,z as buildTx,uo as decodeStellarLendingEvent,tt as decodeStellarLiquidateReturn,ce as encodeAssetOracle,Qt as encodeInterestRateModel,fe as encodeMarketOracleConfigInput,te as encodeMarketParamsRaw,ee as encodePositionLimits,re as encodePriceKey,bo as encodeStrategyPayloadToRouteXdr,fo as extractEventOrder,vt as getStellarAccountPositions,Xt as getStellarActiveUsersSeries,go as getStellarAggregatorQuote,yt as getStellarAsset,At as getStellarAssetGraph,It as getStellarAssetMarkets,qt as getStellarAssetPage,pt as getStellarAssets,Wt as getStellarCampaignLeaderboard,Yt as getStellarCampaignMe,Gt as getStellarDefiLlamaDimensions,d as getStellarDeployment,ft as getStellarDetailedMarkets,Ft as getStellarFeeRevenueSeries,Ot as getStellarGovernanceProposals,Mt as getStellarHolderDistribution,wt as getStellarHub,Tt as getStellarHubGraph,Et as getStellarHubHolders,ht as getStellarHubs,lt as getStellarLendingContext,ct as getStellarLendingLiveState,Nt as getStellarLiquidationsLeaderboard,zt as getStellarLiquidationsSeries,Ct as getStellarParticipantCounts,Jt as getStellarPnlByScope,Pt as getStellarPositionsLeaderboard,Kt as getStellarPositionsPnl,yo as getStellarQuoteTokens,jt as getStellarRateSpreadSeries,gt as getStellarReserve,xt as getStellarReserveGraph,kt as getStellarReserveHolders,mt as getStellarReserves,Dt as getStellarRevenueSeries,bt as getStellarSpoke,Rt as getStellarSpokeGraph,Bt as getStellarSpokeHolders,dt as getStellarSpokes,Lt as getStellarStatsHistory,Ut as getStellarUserActivity,$t as getStellarUserActivityPage,Ht as getStellarUserHistory,_t as getStellarUserPositions,Vt as getStellarVolumeSeries,St as getStellarWalletBalance,Io as mapQuoteResponseToAggregatorSwap,So as mapQuoteResponseToStrategyPayload,qo as mapQuoteResponseToStrategySwap,Oo as mapSorobanError,ho as mapStellarPositionActivityType,Ao as prepareStellarBuiltTx,Bo as prepareStellarTxXdr,Gr as stellarLendingDispatchKey,Zt as stellarLendingRead,h as stellarNetworks,po as syntheticEventOrder,Eo as tagStellarInvokedContractError,Xr as toBase64Xdr,To as toStellarPositionMode};export const XOXNOClient=f.GW;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -5,7 +5,27 @@ export type SafeHeaders = Record<string, string> & {
|
|
|
5
5
|
export type OurRequestInit = Omit<RequestInit, 'body' | 'headers'> & {
|
|
6
6
|
headers?: SafeHeaders;
|
|
7
7
|
debug?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Milliseconds before the request is aborted, as a client-wide default or a
|
|
10
|
+
* per-call override. `0` disables the deadline for that call.
|
|
11
|
+
*
|
|
12
|
+
* Defaults to {@link DEFAULT_REQUEST_TIMEOUT_MS} for requests with no body.
|
|
13
|
+
* Requests that send a body are left unbounded by default because their
|
|
14
|
+
* duration depends on the caller's uplink — a multipart upload on a slow
|
|
15
|
+
* mobile connection is not a stalled request. Pass `timeout` explicitly to
|
|
16
|
+
* bound those.
|
|
17
|
+
*/
|
|
18
|
+
timeout?: number;
|
|
8
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Default read deadline. Without one, a stalled response is bounded only by
|
|
22
|
+
* whatever the host runtime imposes (in Node, undici's Agent), which is
|
|
23
|
+
* typically longer than the caller's own budget — a Next.js `'use cache'` fill,
|
|
24
|
+
* for instance, gives up at `staticPageGenerationTimeout * 0.9` and turns the
|
|
25
|
+
* stall into a hard error instead of a fetch rejection the caller can degrade
|
|
26
|
+
* on. Generous enough that only a genuinely stuck read hits it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
9
29
|
/**
|
|
10
30
|
* Host-supplied configuration for {@link XOXNOClient}.
|
|
11
31
|
*
|
|
@@ -42,5 +62,6 @@ export declare class XOXNOClient {
|
|
|
42
62
|
fetchWithTimeout: <T>(path: string, { params, ...options }?: RequestInit & {
|
|
43
63
|
debug?: boolean;
|
|
44
64
|
params?: Record<string, any>;
|
|
65
|
+
timeout?: number;
|
|
45
66
|
}) => Promise<T>;
|
|
46
67
|
}
|