@xoxno/sdk-js 1.0.202 → 1.0.204
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/sdk/stellar/lending-read-types.d.ts +63 -0
- package/dist/cjs/sdk/stellar/lending-read.d.ts +26 -1
- 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/sdk/stellar/lending-read-types.d.ts +63 -0
- package/dist/sdk/stellar/lending-read.d.ts +26 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,BASE_FEE as o,Contract as r,ScInt as n,TransactionBuilder as u,scValToNative as s,xdr as i}from"@stellar/stellar-sdk";var a={385(a,p,l){l.d(p,{ME:()=>d,nO:()=>y,G_:()=>xe,DU:()=>c,fA:()=>Go,A$:()=>m,J9:()=>f,hS:()=>g,gR:()=>Vo,Cg:()=>Wo,VZ:()=>lr,N0:()=>Jt,B_:()=>be,qL:()=>ne,eX:()=>se,z:()=>er,xD:()=>X,jR:()=>Z,P2:()=>dr,W6:()=>he,se:()=>fe,ZP:()=>ho,yr:()=>tr,sp:()=>et,Iu:()=>vo,yu:()=>xo,$9:()=>po,zw:()=>co,h_:()=>yo,e_:()=>go,Tk:()=>ao,BA:()=>lo,u9:()=>qo,bi:()=>wo,gc:()=>So,ay:()=>bo,SX:()=>Zt,UF:()=>jo,Y5:()=>tt,mE:()=>ot,xG:()=>Ft,s9:()=>rt,OL:()=>Ht,k6:()=>Ce,dj:()=>Ne,kD:()=>je,Yf:()=>We,AI:()=>mo,O2:()=>to,c5:()=>eo,N8:()=>Le,qU:()=>He,RZ:()=>Ze,ni:()=>$e,hF:()=>oo,Qk:()=>ro,Gw:()=>uo,$K:()=>Je,uj:()=>Be,Od:()=>Ue,X7:()=>Fe,Ub:()=>so,Dx:()=>Ve,OA:()=>Oe,$U:()=>Re,ob:()=>ze,$l:()=>Me,K:()=>Ge,Wb:()=>Ee,kw:()=>De,qA:()=>Ie,VS:()=>Ye,HP:()=>io,xQ:()=>To,YQ:()=>no,QY:()=>Qe,os:()=>Xe,Ko:()=>Ke,IJ:()=>ge,nw:()=>J,Pr:()=>st,ZE:()=>Y,X0:()=>ue,ev:()=>Kt,P8:()=>ie,aV:()=>oe,p2:()=>ee,sV:()=>pe,XD:()=>de,Js:()=>le,W5:()=>ae,Dy:()=>re,_i:()=>te,FZ:()=>ce,wG:()=>Yt,Ni:()=>F,v_:()=>H,qD:()=>ut,qR:()=>nt,QJ:()=>Qt,bm:()=>Xt,n_:()=>Se,v8:()=>ye,qM:()=>jt,gH:()=>me,O3:()=>K,Gz:()=>Q,pr:()=>j,Fm:()=>zo,Ft:()=>Wt,MB:()=>Ot,Dn:()=>Vt,pq:()=>Mt,Q3:()=>Lt,Jh:()=>Nt,wf:()=>Yo,Um:()=>Fo,xO:()=>_t,Lw:()=>Qo,KM:()=>b,mM:()=>bt,iE:()=>kt,zp:()=>xt,N3:()=>St,bN:()=>dt,QV:()=>S,T_:()=>At,XI:()=>vt,Lt:()=>Pt,KK:()=>yt,yl:()=>lt,vc:()=>h,kq:()=>ct,CH:()=>Jo,FI:()=>mt,KG:()=>Et,nW:()=>ht,jF:()=>ft,S2:()=>wt,uS:()=>It,u_:()=>gt,O5:()=>Tt,Av:()=>qt,LA:()=>nr,E6:()=>or,Ds:()=>rr,XV:()=>gr,CU:()=>Xo,Vx:()=>ar,DL:()=>ir,ON:()=>ko,Hh:()=>Rt,oV:()=>Ho,g5:()=>sr,L:()=>_o,Vu:()=>pr});const c={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},d={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},y={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},g={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},f={mainnet:process.env.STELLAR_QUOTE_URL_MAINNET??"https://stellar-swap.xoxno.com",testnet:process.env.STELLAR_QUOTE_URL_TESTNET??"https://testnet-stellar-swap.xoxno.com"},m={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function h(t){const e=c[t];if(!e)throw new Error(`Stellar lending controller address not configured for network "${t}". Set STELLAR_LENDING_CONTROLLER_${t.toUpperCase()} env var.`);return e}function b(t){const e=d[t];if(!e)throw new Error(`Stellar aggregator router address not configured for network "${t}". Set STELLAR_AGGREGATOR_ROUTER_${t.toUpperCase()} env var.`);return e}function S(t){const e=y[t];if(!e)throw new Error(`Stellar governance address not configured for network "${t}". Set STELLAR_GOVERNANCE_${t.toUpperCase()} env var.`);return e}const x=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],v={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},w=1e6,q=t=>new e(t).toScVal(),T=t=>new n(t).toI128(),_=t=>i.ScVal.scvU32(t),A=t=>new n("string"==typeof t?t:t.toString()).toU64(),k=t=>i.ScVal.scvBool(t),P=t=>i.ScVal.scvString(t),I=t=>i.ScVal.scvSymbol(t),E=()=>i.ScVal.scvVoid(),R=t=>i.ScVal.scvVec(t),O=(t,e=32)=>{const o=t.startsWith("0x")?t.slice(2):t,r=Buffer.from(o,"hex");if(r.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${r.length} bytes from "${t}")`);return i.ScVal.scvBytes(r)},M=(t,e)=>null==t?E():e(t),L=(t,e)=>C({asset:q(e),hub_id:_(t)}),N=(t,e,o)=>i.ScVal.scvVec([L(t,e),T(o)]),U=t=>i.ScVal.scvVec(t.map((t=>N(t.hubId,t.asset,t.amount)))),C=t=>{const e=Object.keys(t).sort().map((e=>new i.ScMapEntry({key:I(e),val:t[e]})));return i.ScVal.scvMap(e)};class ${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>w)throw new Error(`Stellar builder: split weight ${t} outside 1..=1000000`);return this.weights.push(t),this.weights.length-1}emit(t,e,o,r,n){this.ops.push([t,e,o,r,n])}emitPath(t,e){t.hops.forEach(((o,r)=>{if(o.tokenIn===o.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[r-1];if(n&&o.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(v[o.venue],0===r?e:1,this.asset(o.pool),this.asset(o.tokenIn),this.asset(o.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),o=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(o[t])continue;const r=e[t].hops[0]?.tokenIn,n=[];for(let o=t;o<e.length;o+=1)e[o].hops[0]?.tokenIn===r&&n.push(o);const u=n.reduce(((t,o)=>t+e[o].splitPpm),0);if(u>w)throw new Error(`Stellar builder: split weights for one token sum to ${u}, above 1000000`);const s=u===w;let i=w;n.forEach(((t,r)=>{o[t]=!0;const u=e[t];let a;if(r+1===n.length&&s)a=0;else{if(0===i)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(u.splitPpm*w/i);i-=Math.min(u.splitPpm,i),a=128+this.weight(t)}this.emitPath(u,a)}))}}toBytes(t,e,o){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const r=[1,t,e,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,this.ops.length,this.weights.length];for(const t of this.ops)r.push(...t);for(const t of this.weights)r.push(t>>>16&255,t>>>8&255,255&t);return Buffer.from(r)}get assetList(){return this.assets}get amountList(){return this.amounts}}const B=t=>{const e=new $(t.totalMinOut),o=e.asset(t.tokenIn),r=e.asset(t.tokenOut);if(o===r)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const r=e.asset(t.burnPool),n=e.amountList.length;for(const o of t.burnMinAmounts??[])e.amount(o);e.emit(5,0,r,o,n)}if(e.lowerPaths(t.paths),t.mintPool){const o=t.preSwapAmount;if(o&&BigInt(o)>0n){const r=t.mintPoolTokens;if(!r||2!==r.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,u]=r,[s,i]=t.preSwapFromA?[n,u]:[u,n];e.emit(v.Aquarius,2+e.amount(o),e.asset(t.mintPool),e.asset(s),e.asset(i))}e.emit(6,0,e.asset(t.mintPool),r,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return C({amounts:i.ScVal.scvVec(e.amountList.map((t=>T(t)))),assets:i.ScVal.scvVec(e.assetList.map((t=>q(t)))),ops:i.ScVal.scvBytes(e.toBytes(o,r,n))})},D=t=>{const e=Buffer.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 i.ScVal.scvBytes(e)},G=()=>i.ScVal.scvBytes(Buffer.alloc(0)),z=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((o=t).length>0&&o.length%2==0&&/^[0-9a-fA-F]+$/.test(o)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return Buffer.from(t,"hex")}var o;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(e))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const r=Buffer.from(e,"base64");if(0===r.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return r},W=t=>{if("string"==typeof t)return D(z(t));if(t instanceof Uint8Array)return 0===t.length?G():D(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?D(z(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?D(z(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?D(z(t.bytes)):0===t.bytes.length?G():D(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)throw new Error("Stellar builder: `steps.paths` must be a non-empty array of strategy paths");if("string"!=typeof e.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof e.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof e.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const o=new Map;for(const[t,r]of e.paths.entries()){if(!r||"number"!=typeof r.splitPpm||r.splitPpm<=0||!Array.isArray(r.hops)||0===r.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!x.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=r.hops[0];o.set(e.tokenIn,(o.get(e.tokenIn)??0)+r.splitPpm)}for(const[t,r]of o){if(r>w)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${r}, above 1000000`);if(!e.mintPool&&r!==w)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${r}`)}return e})(t),i.ScVal.scvBytes(Buffer.from(B(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},V=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=Buffer.from(e,"hex");return i.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return i.ScVal.scvBytes(Buffer.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function j(e,n,s){const i=e.controllerAddress??h(e.network),a=new r(i),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(a.call(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function F(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return j(t,"supply",[q(t.caller),A(o),_(r),U([...e.assets])])}function H(t,e){return F(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function X(t,e){return j(t,"borrow",[q(t.caller),A(e.accountNonce),U([...e.borrows]),M(e.to,q)])}function Z(t,e){return X(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function K(t,e){return j(t,"withdraw",[q(t.caller),A(e.accountNonce),U([...e.withdrawals]),M(e.to,q)])}function Q(t,e){return K(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function J(t,e){return j(t,"repay",[q(t.caller),A(e.accountNonce),U([...e.payments])])}function Y(t,e){return J(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function tt(t,e){return j(t,"liquidate",[q(t.caller),A(e.accountNonce),U([...e.debtPayments])])}function et(t,e){return j(t,"flash_loan",[q(t.caller),L(e.hubId,e.asset),T(e.amount),q(e.receiver),V(e.data)])}function ot(t,e){return j(t,"migrate_from_blend",[q(t.caller),A(e.accountId),_(e.spokeId),_(e.hubId),q(e.blendPool),R(e.collateralTokens.map(q)),R(e.supplyTokens.map(q)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),i.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,i.ScVal.scvVec([q(e),T(o)]);var e,o}))))]);var o}function rt(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return j(t,"multiply",[q(t.caller),A(o),_(r),L(e.collateral.hubId,e.collateral.asset),T(e.debtToFlashLoan),L(e.debt.hubId,e.debt.asset),_(e.mode),W(e.steps),M(e.initialPayment,(t=>N(t.hubId,t.asset,t.amount))),M(e.convertSwap,W)])}function nt(t,e){return j(t,"swap_debt",[q(t.caller),A(e.accountNonce),L(e.existingDebt.hubId,e.existingDebt.asset),T(e.newDebtAmount),L(e.newDebt.hubId,e.newDebt.asset),W(e.steps)])}function ut(t,e){return j(t,"swap_collateral",[q(t.caller),A(e.accountNonce),L(e.current.hubId,e.current.asset),T(e.fromAmount),L(e.newCollateral.hubId,e.newCollateral.asset),W(e.steps)])}function st(t,e){return j(t,"repay_debt_with_collateral",[q(t.caller),A(e.accountNonce),L(e.collateral.hubId,e.collateral.asset),T(e.collateralAmount),L(e.debt.hubId,e.debt.asset),W(e.steps),k(e.closePosition)])}const it="/stellar-lending",at=25,pt=encodeURIComponent,lt=(t,e)=>t.fetchWithTimeout(`${it}/context`,e),ct=(t,e)=>t.fetchWithTimeout(`${it}/live-state`,e),dt=(t,e)=>t.fetchWithTimeout(`${it}/assets`,e),yt=(t,e)=>t.fetchWithTimeout(`${it}/hubs`,e),gt=(t,e)=>t.fetchWithTimeout(`${it}/spokes`,e),ft=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${it}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},mt=(t,e,o,r,n)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}`,n),ht=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}/holders`,{...u,params:{side:n}}),bt=(t,e,o)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}`,o),St=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/page`,{...r,params:{...o}}),xt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/markets`,{...r,params:{side:o}}),vt=(t,e,o)=>t.fetchWithTimeout(`${it}/hubs/${e}`,o),wt=(t,e,o)=>t.fetchWithTimeout(`${it}/spokes/${e}`,o),qt=(t,e,o)=>t.fetchWithTimeout(`${it}/users/${pt(e)}/positions`,o),Tt=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${it}/users/${pt(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},_t=(t,e,o)=>t.fetchWithTimeout(`${it}/accounts/${pt(e)}/positions`,o),At=(t,e={},o)=>{const{top:r=at,continuationToken:n}=e;return t.fetchWithTimeout(`${it}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},kt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/graph`,{...r,params:{...o}}),Pt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/hubs/${e}/graph`,{...r,params:{...o}}),It=(t,e,o,r)=>t.fetchWithTimeout(`${it}/spokes/${e}/graph`,{...r,params:{...o}}),Et=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}/graph`,{...u,params:{...n}}),Rt=t=>({context:e=>lt(t,e),liveState:e=>ct(t,e),assets:e=>dt(t,e),hubs:e=>yt(t,e),spokes:e=>gt(t,e),reserves:(e,o)=>{return void 0===(r=e)||"hubId"in r||"spokeId"in r||"asset"in r?ft(t,e,o):ft(t,{},e);var r},reserve:(e,o,r,n)=>mt(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>ht(t,e,o,r,n,u),asset:(e,o)=>bt(t,e,o),assetMarkets:(e,o,r)=>xt(t,e,o,r),hub:(e,o)=>vt(t,e,o),spoke:(e,o)=>wt(t,e,o),userPositions:(e,o)=>qt(t,e,o),userActivity:(e,o,r)=>Tt(t,e,o,r),accountPositions:(e,o)=>_t(t,e,o),governanceProposals:(e,o)=>At(t,e,o),assetGraph:(e,o,r)=>kt(t,e,o,r),hubGraph:(e,o,r)=>Pt(t,e,o,r),spokeGraph:(e,o,r)=>It(t,e,o,r),reserveGraph:(e,o,r,n,u)=>Et(t,e,o,r,n,u)}),Ot=t=>C({base_borrow_rate:T(t.baseBorrowRateRay),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:_(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),Mt=t=>C({asset_decimals:_(t.assetDecimals),asset_id:q(t.assetId),base_borrow_rate:T(t.baseBorrowRateRay),flashloan_fee:_(t.flashloanFeeBps),is_flashloanable:k(t.isFlashloanable),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:_(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),Lt=t=>C({max_borrow_positions:_(t.maxBorrowPositions),max_supply_positions:_(t.maxSupplyPositions)}),Nt=t=>{if("Token"in t&&t.Token)return R([I("Token"),q(t.Token)]);if("Ref"in t&&t.Ref)return R([I("Ref"),I(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},Ut=t=>{if("Stellar"in t)return R([I("Stellar"),q(t.Stellar)]);if("Symbol"in t)return R([I("Symbol"),I(t.Symbol)]);if("String"in t)return R([I("String"),P(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},Ct=t=>{if("Spot"===t)return R([I("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return R([I("Twap"),_(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},$t=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return R([I(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},Bt=t=>{if("Market"===t||"Fundamental"===t)return R([I(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},Dt=t=>{if("Reflector"in t){const e=t.Reflector;return R([I("Reflector"),C({asset:Ut(e.asset),contract:q(e.contract),read_mode:Ct(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return R([I("MultiFeed"),C({contract:q(e.contract),feed_id:P(e.feedId),kind:$t(e.kind),nature:Bt(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},Gt=t=>{const e=t;return C({decimals:_(e.decimals),max_stale_seconds:A(e.maxStaleSeconds),provider:Dt(e.provider)})},zt=t=>{if("RequireDisjoint"===t)return R([I("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return R([I("AllowShared"),R(e.map((t=>C({contract:q(t.contract),kind:$t(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},Wt=t=>{const e=t,o=e.sources??[];let r,n;if("number"==typeof e.toleranceBps)r=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/r));else{const t=e.tolerance??{};r=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return C({asset_decimals:_(Number(e.assetDecimals)),independence:zt(e.independence),max_price_stale_seconds:A(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:T(String(e.maxSanityPriceWad)),min_sanity_price_wad:T(String(e.minSanityPriceWad)),sources:R(o.map((t=>(t=>{if("Feed"in t)return R([I("Feed"),Gt(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return R([I("Scaled"),C({factor:Gt(e.factor),max_factor_wad:T(e.maxFactorWad),min_factor_wad:T(e.minFactorWad),quote:Nt(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return R([I("LpShare"),C({key_a:Nt(e.keyA),key_b:Nt(e.keyB),kind:R([I(e.kind||"ConstantProduct")]),pool:q(e.pool),reserve_a_decimals:_(e.reserveADecimals),reserve_b_decimals:_(e.reserveBDecimals),share_decimals:_(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:C({lower_ratio_bps:_(n),upper_ratio_bps:_(r)})})},Vt=Wt;function jt(t,e){return j(t,"upgrade",[O(e.wasmHash)])}function Ft(t,e){return j(t,"migrate",[_(e.newVersion)])}function Ht(t){return j(t,"pause",[])}function Xt(t){return j(t,"unpause",[])}function Zt(t,e){return j(t,"grant_role",[q(e.account),I(e.role)])}function Kt(t,e){return j(t,"revoke_role",[q(e.account),I(e.role)])}function Qt(t,e){return j(t,"transfer_ownership",[q(e.newOwner),_(e.liveUntilLedger)])}function Jt(t){return j(t,"accept_ownership",[])}function Yt(t,e){return j(t,"set_swap_aggregator",[q(e.aggregator)])}function te(t,e){return j(t,"set_price_aggregator",[q(e.aggregator)])}const ee=Yt;function oe(t,e){return j(t,"set_accumulator",[q(e.accumulator)])}function re(t,e){return j(t,"set_position_limits",[Lt(e)])}function ne(t,e){return j(t,"approve_blend_pool",[q(e.pool)])}function ue(t,e){return j(t,"revoke_blend_pool",[q(e.pool)])}const se=ne,ie=ue;function ae(t,e){return j(t,"set_oracle",[Nt(e.key),Wt(e.oracle)])}const pe=ae;function le(t,e){const o=e.toleranceBps,r=e.upperRatioBps??1e4+o,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/r));return j(t,"set_tolerance",[Nt(e.key),C({lower_ratio_bps:_(n),upper_ratio_bps:_(r)})])}function ce(t,e){return j(t,"set_spoke_asset_flags",[_(e.spokeId),L(e.hubId,e.asset),k(e.paused),k(e.frozen)])}function de(t,e){return j(t,"set_oracle_sanity_bounds",[q(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function ye(t,e){return j(t,"update_indexes",[q(t.caller),R(e.assets.map((t=>L(t.hubId,t.asset))))])}function ge(t,e){return j(t,"renew_account",[q(t.caller),A(e.accountNonce)])}function fe(t,e){return j(t,"create_liquidity_pool",[_(e.hubId),q(e.asset),Mt(e.params)])}function me(t,e){return j(t,"upgrade_liquidity_pool_params",[L(e.hubId,e.asset),Ot(e.params)])}function he(t,e){return j(t,"claim_revenue",[q(t.caller),R(e.assets.map((t=>L(t.hubId,t.asset))))])}function be(t,e){return j(t,"add_rewards",[q(t.caller),U(e.rewards)])}function Se(t,e){return j(t,"update_account_threshold",[q(t.caller),k(e.hasRisks),R(e.accountNonces.map((t=>A(t))))])}const xe="00".repeat(32),ve=t=>{if("string"==typeof t)return O(t);const e=Buffer.from(t);if(32!==e.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${e.length} bytes)`);return i.ScVal.scvBytes(e)},we=(t,...e)=>R([I(t),...e]),qe=t=>C({new_owner:q(t.newOwner),live_until_ledger:_(t.liveUntilLedger)}),Te=t=>C({asset:q(t.asset),bonus:_(t.bonus),borrow_cap:T(t.borrowCap),can_borrow:k(t.canBorrow),can_collateral:k(t.canCollateral),frozen:k(t.frozen),hub_id:_(t.hubId),paused:k(t.paused),liquidation_fees:_(t.liquidationFees),ltv:_(t.ltv),oracle_override:R([I("None")]),spoke_id:_(t.spokeId),supply_cap:T(t.supplyCap),threshold:_(t.threshold)}),_e=t=>C({account:q(t.account),role:I(t.role)});function Ae(e,n,s){const i=e.governanceAddress??S(e.network),a=new r(i),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(a.call(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ke=(t,e,o)=>Ae(t,"propose",[q(t.caller),e,ve(o)]),Pe=(t,e,o)=>Ae(t,"execute_self",[E(),e,ve(o)]);function Ie(t,e,o){return ke(t,we("SetSwapAggregator",q(e.aggregator)),o)}function Ee(t,e,o){return ke(t,we("SetPriceAggregator",q(e.aggregator)),o)}const Re=Ie;function Oe(t,e,o){return ke(t,we("SetAccumulator",q(e.accumulator)),o)}function Me(t,e,o){return ke(t,we("SetPositionLimits",Lt(e)),o)}function Le(t,e){return ke(t,we("CreateHub"),e)}function Ne(t,e){return ke(t,we("AddSpoke"),e)}function Ue(t,e,o){return ke(t,we("RemoveSpoke",_(e.spokeId)),o)}function Ce(t,e,o){return ke(t,we("AddAssetToSpoke",Te(e)),o)}function $e(t,e,o){return ke(t,we("EditAssetInSpoke",Te(e)),o)}function Be(t,e,o){return ke(t,we("RemoveAssetFromSpoke",C({hub_asset:L((r=e).hubId,r.asset),spoke_id:_(r.spokeId)})),o);var r}function De(t,e,o){return ke(t,we("SetSpokeLiquidationCurve",C({hf_for_max_bonus_wad:T((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:_(r.liquidationBonusFactorBps),spoke_id:_(r.spokeId),target_hf_wad:T(r.targetHfWad)})),o);var r}function Ge(t,e,o){return ke(t,we("SetPositionManager",q(e.manager),k(e.isActive)),o)}function ze(t,e,o){return ke(t,we("SetMinBorrowCollateralUsd",T(e.floorWad)),o)}function We(t,e,o){return ke(t,we("ApproveToken",q(e.token)),o)}function Ve(t,e,o){return ke(t,we("RevokeToken",q(e.token)),o)}function je(t,e,o){return ke(t,we("ApproveBlendPool",q(e.pool)),o)}function Fe(t,e,o){return ke(t,we("RevokeBlendPool",q(e.pool)),o)}function He(t,e,o){return ke(t,we("CreateLiquidityPool",C({asset:q((r=e).asset),hub_id:_(r.hubId),params:Mt(r.params)})),o);var r}function Xe(t,e,o){return ke(t,we("UpgradeLiquidityPoolParams",C({hub_asset:L((r=e).hubId,r.asset),params:Ot(r.params)})),o);var r}function Ze(t,e,o){return ke(t,we("DeployPool",O(e.wasmHash)),o)}function Ke(t,e,o){return ke(t,we("UpgradePool",O(e.wasmHash)),o)}function Qe(t,e,o){return ke(t,we("UpgradeController",O(e.wasmHash)),o)}function Je(t,e,o){return ke(t,we("MigrateController",_(e.newVersion)),o)}function Ye(t,e,o){return ke(t,we("TransferCtrlOwnership",qe(e)),o)}function to(t,e,o){return ke(t,we("ConfigureAssetOracle",C({key:Nt((r=e).key),oracle:Wt(r.oracle)})),o);var r}const eo=to;function oo(t,e,o){return ke(t,we("EditOracleTolerance",C({key:Nt((r=e).key),tolerance:_(r.tolerance)})),o);var r}function ro(t,e,o){return ke(t,we("UpgradeGov",O(e.wasmHash)),o)}function no(t,e,o){return ke(t,we("UpdateGovDelay",_(e.newDelay)),o)}function uo(t,e,o){return ke(t,we("GrantGovRole",_e(e)),o)}function so(t,e,o){return ke(t,we("RevokeGovRole",_e(e)),o)}function io(t,e,o){return ke(t,we("TransferGovOwnership",qe(e)),o)}function ao(t,e){const o=R(e.argsXdr.map((t=>i.ScVal.fromXDR(t,"base64")))),r=ve(e.predecessor??xe);return Ae(t,"execute",[E(),q(e.target),I(e.functionName),o,r,ve(e.salt)])}function po(t,e,o){return Pe(t,we("UpgradeGov",O(e.wasmHash)),o)}function lo(t,e,o){return Pe(t,we("UpdateGovDelay",_(e.newDelay)),o)}function co(t,e,o){return Pe(t,we("GrantGovRole",_e(e)),o)}function yo(t,e,o){return Pe(t,we("RevokeGovRole",_e(e)),o)}function go(t,e,o){return Pe(t,we("TransferGovOwnership",qe(e)),o)}const fo=t=>R(t.map(q));function mo(t,e,o){return Ae(t,"propose_canceller_reset",[fo(e.newCancellers),ve(o)])}function ho(t,e,o){return Ae(t,"execute_canceller_reset",[M(e.executor,q),fo(e.newCancellers),ve(o)])}function bo(t,e){return Ae(t,"set_spoke_asset_flags",[q(t.caller),_(e.spokeId),L(e.hubId,e.asset),k(e.paused),k(e.frozen)])}function So(t,e){return Ae(t,"set_oracle_sanity_bounds",[q(t.caller),q(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function xo(t){return Ae(t,"create_hub",[q(t.caller)])}function vo(t){return Ae(t,"add_spoke",[q(t.caller)])}function wo(t,e){return Ae(t,"revoke_role_immediate",[q(e.account),I(e.role)])}function qo(t){return Ae(t,"pause",[q(t.caller)])}function To(t,e){return ke(t,we("Unpause"),e)}const _o=t=>t.toXDR("base64"),Ao=t=>i.ScVal.fromXDR(t,"base64"),ko=t=>t.map((t=>String(s(Ao(t))))).join(":"),Po=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),Io=t=>Number(t),Eo=t=>String(t),Ro=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),Oo=["None","Multiply","Long","Short"],Mo=["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"],Lo=t=>Array.isArray(t)?t:[],No=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],Mo[Io(r)]??Po(r)),positionType:e,hubId:Io(t[1]),asset:Eo(t[2]),scaledAmountRay:Po(t[3]),indexRay:Po(t[4]),amount:Po(t[5]),liquidationThresholdBps:o?void 0:Io(t[6]),liquidationBonusBps:o?void 0:Io(t[7]),loanToValueBps:o?void 0:Io(t[8]),liquidationFeesBps:o?void 0:Io(t[9])};var r},Uo=t=>{return{owner:Eo(t[0]),spokeId:Io(t[1]),mode:(e=t[2],Oo[Io(e)]??"None")};var e},Co=t=>Array.isArray(t)?t[1]:void 0,$o=t=>{const e=(o=t,Array.isArray(o)?Eo(o[0]):Eo(o));var o;if("Token"===e)return{Token:Eo(Co(t))};if("Ref"===e)return{Ref:Eo(Co(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:Eo(e.Token)};if(void 0!==e.Ref)return{Ref:Eo(e.Ref)}}return{Token:Eo(t)}},Bo=t=>{const e=t.tolerance??{};return{assetDecimals:Io(t.asset_decimals),maxPriceStaleSeconds:Io(t.max_price_stale_seconds),sources:Lo(t.sources).map((t=>t)),tolerance:{upperRatio:Io(e.upper_ratio_bps),lowerRatio:Io(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:Po(t.min_sanity_price_wad),maxSanityPriceWad:Po(t.max_sanity_price_wad)}},Do={"market:create":t=>({topic:"market:create",data:{hubId:Io(t.hub_id),baseAsset:Eo(t.base_asset),maxBorrowRate:Po(t.max_borrow_rate),baseBorrowRate:Po(t.base_borrow_rate),slope1:Po(t.slope1),slope2:Po(t.slope2),slope3:Po(t.slope3),midUtilization:Po(t.mid_utilization),optimalUtilization:Po(t.optimal_utilization),maxUtilization:Po(t.max_utilization),reserveFactor:Io(t.reserve_factor),marketAddress:Eo(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:Eo(t.asset),maxBorrowRateRay:Po(t.max_borrow_rate),baseBorrowRateRay:Po(t.base_borrow_rate),slope1Ray:Po(t.slope1),slope2Ray:Po(t.slope2),slope3Ray:Po(t.slope3),midUtilizationRay:Po(t.mid_utilization),optimalUtilizationRay:Po(t.optimal_utilization),maxUtilizationRay:Po(t.max_utilization),reserveFactorBps:Io(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:Lo(t).map((t=>{return e=Lo(t),{hubId:Io(e[0]),asset:Eo(e[1]),timestamp:Io(e[2]),supplyIndexRay:Po(e[3]),borrowIndexRay:Po(e[4]),cash:Po(e[5]),suppliedRay:Po(e[6]),borrowedRay:Po(e[7]),revenueRay:Po(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:Lo(t).map((t=>{const e=t;return{hubId:Io(e.hub_id),asset:Eo(e.asset),params:(o=e.params,{maxBorrowRateRay:Po(o.max_borrow_rate),baseBorrowRateRay:Po(o.base_borrow_rate),slope1Ray:Po(o.slope1),slope2Ray:Po(o.slope2),slope3Ray:Po(o.slope3),midUtilizationRay:Po(o.mid_utilization),optimalUtilizationRay:Po(o.optimal_utilization),maxUtilizationRay:Po(o.max_utilization),reserveFactorBps:Io(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:Io(o.flashloan_fee),assetId:Eo(o.asset_id),assetDecimals:Io(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=Lo(t);return{topic:"position:batch_update",data:{accountId:Po(e[0]),accountAttributes:Uo(Lo(e[1])),updates:[...Lo(e[2]).map((t=>No(Lo(t),"Deposit"))),...Lo(e[3]).map((t=>No(Lo(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:Io(t.hub_id),asset:Eo(t.asset),receiver:Eo(t.receiver),caller:Eo(t.caller),amount:Po(t.amount),fee:Po(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:$o(t.key),oracle:Bo(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:Eo(t.asset),oracle:Bo(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:Eo(t.liquidator),accountId:Po(t.account_id),repaidUsdWad:Po(t.repaid_usd_wad),bonusBps:Po(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:Po(t.account_id),totalBorrowUsdWad:Po(t.total_borrow_usd_wad),totalCollateralUsdWad:Po(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:Eo(t.token),amount:Po(t.amount),usdValueWad:Po(t.usd_value_wad),accountId:Po(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:Io(t.hub_id),asset:Eo(t.asset),amount:Po(t.amount),fee:Po(t.fee),amountSent:Po(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:Eo(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:Ro(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:Eo(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:Eo(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:Eo(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:Eo(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:Ro(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:Io(t.max_supply_positions),maxBorrowPositions:Io(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Po(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:Eo(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:Io(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:Po(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Po(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:Io(e.liquidation_bonus_factor_bps)}}}},Go=Object.freeze(Object.keys(Do));function zo(t,e){const o=ko(t),r=Do[o];return r?r(s(Ao(e))):null}const Wo="XLENDXLM-a7c9f3",Vo=1e4;function jo(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${Wo}-${o}`}function Fo(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function Ho(t,e=0){return t*Vo+e}function Xo(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Zo=(t,e,o)=>{const r=new URL(e,t.endsWith("/")?t:`${t}/`);if(o)for(const[t,e]of Object.entries(o))void 0!==e&&r.searchParams.set(t,String(e));return r.toString()},Ko=t=>t.baseUrl??f[t.network];async function Qo(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=Zo(Ko(e),"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,platform:t.platform,fresh:t.fresh}),r=await fetch(o,e.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${o} — ${t}`)}return await r.json()}async function Jo(t){const e=Zo(Ko(t),"api/v1/tokens"),o=await fetch(e,t.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${e} — ${t}`)}return await o.json()}const Yo=t=>B(t).toXDR("base64");function tr(e,n){const s=e.routerAddress??b(e.network),i=new r(s),a=new t(e.caller,e.sourceSequence),p=W(((t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t)(n,e.referralId));return{xdr:new u(a,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(i.call("execute_strategy",q(e.caller),T(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function er(t,e){return tr(t,e)}function or(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(ur),splitPpm:t.splitPpm}))):[{hops:t.hops.map(ur),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function rr(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:or(t,e)}const nr=or,ur=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function sr(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function ir(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw sr(o.invokedContractId,t);throw t}}async function ar(t,e,o){return ir(t,e.xdr,o)}function pr(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 lr(t,e){return new Uint8Array(0)}const cr=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 Buffer.from(e,"hex")};function dr(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",i.ScVal.scvBytes(cr(e.message)),i.ScVal.scvBytes(cr(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const yr={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."},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 gr(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=yr[o];return r?{code:o,...r}:null}}},p={};function l(t){var e=p[t];if(void 0!==e)return e.exports;var o=p[t]={exports:{}};return a[t](o,o.exports,l),o.exports}l.d=(t,e)=>{for(var o in e)l.o(e,o)&&!l.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const c="https://api.xoxno.com",d="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",g="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var f;!function(t){t.MAINNET="1",t.DEVNET="D"}(f||(f={}));class m{apiUrl;chain;init;config;constructor({chain:t=f.MAINNET,apiUrl:e=c,...o}={}){this.apiUrl=e??{[f.MAINNET]:c,[f.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==f.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:d,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:d,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:u,...s}=this.init,{next:i,cache:a,debug:p,headers:l,method:c="GET",...d}=o,y=l?.Authorization,g="Bearer undefined"===y?void 0:y,f={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===c?{}:{"Content-Type":"application/json"},...g?{Authorization:g}:{}},m=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),h=`${this.apiUrl}${t}${m.length?`?${m}`:""}`,{revalidate:b,...S}=r??{},{revalidate:x,...v}=i??{},w="GET"!==c||g?void 0:x??b,q="GET"!==c||g||w?void 0:a??n,T={...s,...d,method:c,...Object.keys(f).length?{headers:f}:{},cache:q,next:{...S,...v,revalidate:w}};(p??u)&&console.debug("SDK fetch: ",h,T);const _=await fetch(h,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${h}: ${t.message}`),{cause:t});throw t})),A=await _.text();if(!_.ok){let t;try{t=JSON.parse(A)}catch{t={message:A}}const e=[h,_.status,_.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const h=t=>{const e=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(t)),o=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t);return e||o},b=t=>{const e=/^0x[a-fA-F0-9]{1,64}$/.test(t),o=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(t);return e||o};class S extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class x extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const v=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^G[A-Z2-7]{55}$/.test(t)),w={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}}},q=["PATCH","POST","DELETE","PUT"];var T=l(385);const _=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function A(t,e,o,r){const{input:n,output:u,...s}=e,i=async(e={})=>{const n={...o,...e},u=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),s=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),i=Object.fromEntries(Object.entries(n).filter((([t])=>!s.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in i,p=/:collection[^A-Z]/.test(t)||"collection"in i;if(a){const t=n.address;if(!v(t))throw new x(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!h(t))):!h(t))throw new S(t)}const l=Object.fromEntries(Object.entries(i).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:c,auth:d,method:y,headers:g,cache:f,next:m,debug:b,continuationToken:w,...q}=l,T=d?`Bearer ${d}`:void 0,_={...g,...T?{Authorization:T}:{},...w?{"X-Continuation-Token":String(w)}:{}},A={...m,tags:[...m?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:q,body:c,headers:_,cache:f,debug:b,...A?{next:A}:{}})},a=(t={})=>i(t);for(const t of Object.keys(s))q.includes(t)&&(a[t]=e=>i({...e,method:e.method??t.toUpperCase()}));return a}function k(t){const e=function(){const t={static:{},params:{},leaves:[]};for(const[e,o]of Object.entries(w)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=_(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=_(t);n=n.static[e]||={static:{},params:{},leaves:[]}}n.leaves.push({rawPath:e,def:o})}return t}(),o=(e,r)=>{const n=e.leaves.length,u=Object.keys(e.static).length,s=Object.keys(e.params).length;let i;if(1===n&&u+s>0){const{rawPath:o,def:n}=e.leaves[0];i=A(o,n,r,t)}else{i={};for(const{rawPath:o,def:n}of e.leaves)i[_(o.split("/").pop().replace(/^:/,""))]=A(o,n,r,t)}for(const[t,n]of Object.entries(e.static)){const e=o(n,r);let u=e;if(e&&"object"==typeof e&&t in e&&"function"==typeof e[t]){const o=e[t],r=Object.fromEntries(Object.entries(e).filter((([e])=>e!==t)));1===o.length||(Object.assign(o,r),u=o)}void 0===i[t]?i[t]=u:"function"==typeof i[t]?Object.assign(i[t],u):"function"==typeof u?(Object.assign(u,i[t]),i[t]=u):Object.assign(i[t],u)}for(const[t,n]of Object.entries(e.params)){const e=e=>{const u=o(n,{...r,[t]:e});if(u&&"object"==typeof u&&1===Object.keys(u).length&&t in u&&"function"==typeof u[t]){const e=u[t],o=(...t)=>e(...t);return Object.assign(o,e)}return u};if(i[t]){const o=i[t];i[t]=t=>({...o(t),...e(t)})}else i[t]=e}return i};return o(e,{})}export{f as Chain,m as XOXNOClient,k as buildSdk,h as isValidCollectionTicker,b as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=T.ME;export const STELLAR_GOVERNANCE=T.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=T.G_;export const STELLAR_LENDING_CONTROLLER=T.DU;export const STELLAR_LENDING_TOPICS=T.fA;export const STELLAR_NETWORK_PASSPHRASE=T.A$;export const STELLAR_QUOTE_URL=T.J9;export const STELLAR_SOROBAN_RPC_URL=T.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=T.gR;export const XOXNO_LENDING_STELLAR_TICKER=T.Cg;export const buildSameTokenRepaySwapSteps=T.VZ;export const buildStellarAcceptOwnershipTx=T.N0;export const buildStellarAddRewardsTx=T.B_;export const buildStellarApproveBlendPoolTx=T.qL;export const buildStellarApproveTokenTx=T.eX;export const buildStellarBatchSwapTx=T.z;export const buildStellarBorrowBatchTx=T.xD;export const buildStellarBorrowTx=T.jR;export const buildStellarCctpForwardTx=T.P2;export const buildStellarClaimRevenueTx=T.W6;export const buildStellarCreateLiquidityPoolTx=T.se;export const buildStellarExecuteCancellerResetTx=T.ZP;export const buildStellarExecuteStrategyTx=T.yr;export const buildStellarFlashLoanTx=T.sp;export const buildStellarGovernanceAddSpokeImmediateTx=T.Iu;export const buildStellarGovernanceCreateHubImmediateTx=T.yu;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=T.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=T.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=T.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=T.e_;export const buildStellarGovernanceExecuteTx=T.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=T.BA;export const buildStellarGovernancePauseTx=T.u9;export const buildStellarGovernanceRevokeRoleImmediateTx=T.bi;export const buildStellarGovernanceSetOracleSanityBoundsImmediateTx=T.gc;export const buildStellarGovernanceSetSpokeAssetFlagsImmediateTx=T.ay;export const buildStellarGrantRoleTx=T.SX;export const buildStellarLendingIdentifier=T.UF;export const buildStellarLiquidateTx=T.Y5;export const buildStellarMigrateFromBlendTx=T.mE;export const buildStellarMigrateTx=T.xG;export const buildStellarMultiplyTx=T.s9;export const buildStellarPauseTx=T.OL;export const buildStellarProposeAddAssetToSpokeTx=T.k6;export const buildStellarProposeAddSpokeTx=T.dj;export const buildStellarProposeApproveBlendPoolTx=T.kD;export const buildStellarProposeApproveTokenTx=T.Yf;export const buildStellarProposeCancellerResetTx=T.AI;export const buildStellarProposeConfigureAssetOracleTx=T.O2;export const buildStellarProposeConfigureMarketOracleTx=T.c5;export const buildStellarProposeCreateHubTx=T.N8;export const buildStellarProposeCreateLiquidityPoolTx=T.qU;export const buildStellarProposeDeployPoolTx=T.RZ;export const buildStellarProposeEditAssetInSpokeTx=T.ni;export const buildStellarProposeEditOracleToleranceTx=T.hF;export const buildStellarProposeGovernanceUpgradeTx=T.Qk;export const buildStellarProposeGrantGovernanceRoleTx=T.Gw;export const buildStellarProposeMigrateControllerTx=T.$K;export const buildStellarProposeRemoveAssetFromSpokeTx=T.uj;export const buildStellarProposeRemoveSpokeTx=T.Od;export const buildStellarProposeRevokeBlendPoolTx=T.X7;export const buildStellarProposeRevokeGovernanceRoleTx=T.Ub;export const buildStellarProposeRevokeTokenTx=T.Dx;export const buildStellarProposeSetAccumulatorTx=T.OA;export const buildStellarProposeSetAggregatorTx=T.$U;export const buildStellarProposeSetMinBorrowCollatTx=T.ob;export const buildStellarProposeSetPositionLimitsTx=T.$l;export const buildStellarProposeSetPositionManagerTx=T.K;export const buildStellarProposeSetPriceAggregatorTx=T.Wb;export const buildStellarProposeSetSpokeLiquidationCurveTx=T.kw;export const buildStellarProposeSetSwapAggregatorTx=T.qA;export const buildStellarProposeTransferCtrlOwnershipTx=T.VS;export const buildStellarProposeTransferGovOwnTx=T.HP;export const buildStellarProposeUnpauseTx=T.xQ;export const buildStellarProposeUpdateDelayTx=T.YQ;export const buildStellarProposeUpgradeControllerTx=T.QY;export const buildStellarProposeUpgradePoolParamsTx=T.os;export const buildStellarProposeUpgradePoolTx=T.Ko;export const buildStellarRenewAccountTx=T.IJ;export const buildStellarRepayBatchTx=T.nw;export const buildStellarRepayDebtWithCollateralTx=T.Pr;export const buildStellarRepayTx=T.ZE;export const buildStellarRevokeBlendPoolTx=T.X0;export const buildStellarRevokeRoleTx=T.ev;export const buildStellarRevokeTokenTx=T.P8;export const buildStellarSetAccumulatorTx=T.aV;export const buildStellarSetAggregatorTx=T.p2;export const buildStellarSetMarketOracleConfigTx=T.sV;export const buildStellarSetOracleSanityBoundsTx=T.XD;export const buildStellarSetOracleToleranceTx=T.Js;export const buildStellarSetOracleTx=T.W5;export const buildStellarSetPositionLimitsTx=T.Dy;export const buildStellarSetPriceAggregatorTx=T._i;export const buildStellarSetSpokeAssetFlagsTx=T.FZ;export const buildStellarSetSwapAggregatorTx=T.wG;export const buildStellarSupplyBatchTx=T.Ni;export const buildStellarSupplyTx=T.v_;export const buildStellarSwapCollateralTx=T.qD;export const buildStellarSwapDebtTx=T.qR;export const buildStellarTransferOwnershipTx=T.QJ;export const buildStellarUnpauseTx=T.bm;export const buildStellarUpdateAccountThresholdTx=T.n_;export const buildStellarUpdateIndexesTx=T.v8;export const buildStellarUpgradeControllerTx=T.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=T.gH;export const buildStellarWithdrawBatchTx=T.O3;export const buildStellarWithdrawTx=T.Gz;export const buildTx=T.pr;export const decodeStellarLendingEvent=T.Fm;export const encodeAssetOracle=T.Ft;export const encodeInterestRateModel=T.MB;export const encodeMarketOracleConfigInput=T.Dn;export const encodeMarketParamsRaw=T.pq;export const encodePositionLimits=T.Q3;export const encodePriceKey=T.Jh;export const encodeStrategyPayloadToRouteXdr=T.wf;export const extractEventOrder=T.Um;export const getStellarAccountPositions=T.xO;export const getStellarAggregatorQuote=T.Lw;export const getStellarAggregatorRouter=T.KM;export const getStellarAsset=T.mM;export const getStellarAssetGraph=T.iE;export const getStellarAssetMarkets=T.zp;export const getStellarAssetPage=T.N3;export const getStellarAssets=T.bN;export const getStellarGovernance=T.QV;export const getStellarGovernanceProposals=T.T_;export const getStellarHub=T.XI;export const getStellarHubGraph=T.Lt;export const getStellarHubs=T.KK;export const getStellarLendingContext=T.yl;export const getStellarLendingController=T.vc;export const getStellarLendingLiveState=T.kq;export const getStellarQuoteTokens=T.CH;export const getStellarReserve=T.FI;export const getStellarReserveGraph=T.KG;export const getStellarReserveHolders=T.nW;export const getStellarReserves=T.jF;export const getStellarSpoke=T.S2;export const getStellarSpokeGraph=T.uS;export const getStellarSpokes=T.u_;export const getStellarUserActivity=T.O5;export const getStellarUserPositions=T.Av;export const mapQuoteResponseToAggregatorSwap=T.LA;export const mapQuoteResponseToStrategyPayload=T.E6;export const mapQuoteResponseToStrategySwap=T.Ds;export const mapSorobanError=T.XV;export const mapStellarPositionActivityType=T.CU;export const prepareStellarBuiltTx=T.Vx;export const prepareStellarTxXdr=T.DL;export const stellarLendingDispatchKey=T.ON;export const stellarLendingRead=T.Hh;export const syntheticEventOrder=T.oV;export const tagStellarInvokedContractError=T.g5;export const toBase64Xdr=T.L;export const toStellarPositionMode=T.Vu;
|
|
1
|
+
"undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,BASE_FEE as o,Contract as r,ScInt as n,TransactionBuilder as u,scValToNative as s,xdr as i}from"@stellar/stellar-sdk";var a={385(a,p,l){l.d(p,{ME:()=>d,nO:()=>y,G_:()=>_e,DU:()=>c,fA:()=>Fo,A$:()=>m,J9:()=>f,hS:()=>g,gR:()=>Ko,Cg:()=>Xo,VZ:()=>fr,N0:()=>re,B_:()=>qe,qL:()=>pe,eX:()=>ce,z:()=>sr,xD:()=>X,jR:()=>K,P2:()=>hr,W6:()=>we,se:()=>xe,ZP:()=>wo,yr:()=>ur,sp:()=>et,Iu:()=>Ao,yu:()=>_o,$9:()=>fo,zw:()=>ho,h_:()=>bo,e_:()=>So,Tk:()=>go,BA:()=>mo,u9:()=>Po,bi:()=>ko,gc:()=>To,ay:()=>qo,SX:()=>te,UF:()=>Zo,Y5:()=>tt,mE:()=>ot,xG:()=>Qt,s9:()=>rt,OL:()=>Jt,k6:()=>We,dj:()=>De,kD:()=>Ze,Yf:()=>Xe,AI:()=>vo,O2:()=>uo,c5:()=>so,N8:()=>Be,qU:()=>Je,RZ:()=>to,ni:()=>ze,hF:()=>io,Qk:()=>ao,Gw:()=>lo,$K:()=>ro,uj:()=>Ve,Od:()=>Ge,X7:()=>Qe,Ub:()=>co,Dx:()=>Ke,OA:()=>$e,$U:()=>Ue,ob:()=>He,$l:()=>Ce,K:()=>Fe,Wb:()=>Ne,kw:()=>je,qA:()=>Le,VS:()=>no,HP:()=>yo,xQ:()=>Io,YQ:()=>po,QY:()=>oo,os:()=>Ye,Ko:()=>eo,IJ:()=>Se,nw:()=>J,Pr:()=>st,ZE:()=>Y,X0:()=>le,ev:()=>ee,P8:()=>de,aV:()=>ie,p2:()=>se,sV:()=>ge,XD:()=>he,Js:()=>fe,W5:()=>ye,Dy:()=>ae,_i:()=>ue,FZ:()=>me,wG:()=>ne,Ni:()=>F,v_:()=>H,qD:()=>ut,qR:()=>nt,QJ:()=>oe,bm:()=>Yt,n_:()=>Te,v8:()=>be,qM:()=>Zt,gH:()=>ve,O3:()=>Z,Gz:()=>Q,pr:()=>j,Fm:()=>Ho,Ft:()=>Xt,MB:()=>$t,Dn:()=>Kt,pq:()=>Ct,Q3:()=>Bt,Jh:()=>Dt,wf:()=>nr,Um:()=>Qo,XR:()=>Lt,xO:()=>_t,Lw:()=>or,KM:()=>b,mM:()=>bt,iE:()=>kt,zp:()=>xt,N3:()=>St,bN:()=>dt,cK:()=>Nt,kV:()=>Ot,vo:()=>Mt,QV:()=>S,T_:()=>At,XI:()=>vt,Lt:()=>Pt,KK:()=>yt,yl:()=>lt,vc:()=>h,kq:()=>ct,Mi:()=>Rt,CH:()=>rr,FI:()=>mt,KG:()=>Et,nW:()=>ht,jF:()=>ft,S2:()=>wt,uS:()=>It,u_:()=>gt,O5:()=>Tt,Av:()=>qt,LA:()=>pr,E6:()=>ir,Ds:()=>ar,XV:()=>Sr,CU:()=>Yo,Vx:()=>yr,DL:()=>dr,ON:()=>Oo,Hh:()=>Ut,oV:()=>Jo,g5:()=>cr,L:()=>Eo,Vu:()=>gr});const c={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},d={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},y={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},g={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},f={mainnet:process.env.STELLAR_QUOTE_URL_MAINNET??"https://stellar-swap.xoxno.com",testnet:process.env.STELLAR_QUOTE_URL_TESTNET??"https://testnet-stellar-swap.xoxno.com"},m={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function h(t){const e=c[t];if(!e)throw new Error(`Stellar lending controller address not configured for network "${t}". Set STELLAR_LENDING_CONTROLLER_${t.toUpperCase()} env var.`);return e}function b(t){const e=d[t];if(!e)throw new Error(`Stellar aggregator router address not configured for network "${t}". Set STELLAR_AGGREGATOR_ROUTER_${t.toUpperCase()} env var.`);return e}function S(t){const e=y[t];if(!e)throw new Error(`Stellar governance address not configured for network "${t}". Set STELLAR_GOVERNANCE_${t.toUpperCase()} env var.`);return e}const x=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],v={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},w=1e6,q=t=>new e(t).toScVal(),T=t=>new n(t).toI128(),_=t=>i.ScVal.scvU32(t),A=t=>new n("string"==typeof t?t:t.toString()).toU64(),k=t=>i.ScVal.scvBool(t),P=t=>i.ScVal.scvString(t),I=t=>i.ScVal.scvSymbol(t),E=()=>i.ScVal.scvVoid(),R=t=>i.ScVal.scvVec(t),O=(t,e=32)=>{const o=t.startsWith("0x")?t.slice(2):t,r=Buffer.from(o,"hex");if(r.length!==e)throw new Error(`Stellar builder: expected a ${e}-byte BytesN (got ${r.length} bytes from "${t}")`);return i.ScVal.scvBytes(r)},M=(t,e)=>null==t?E():e(t),L=(t,e)=>$({asset:q(e),hub_id:_(t)}),N=(t,e,o)=>i.ScVal.scvVec([L(t,e),T(o)]),U=t=>i.ScVal.scvVec(t.map((t=>N(t.hubId,t.asset,t.amount)))),$=t=>{const e=Object.keys(t).sort().map((e=>new i.ScMapEntry({key:I(e),val:t[e]})));return i.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>w)throw new Error(`Stellar builder: split weight ${t} outside 1..=1000000`);return this.weights.push(t),this.weights.length-1}emit(t,e,o,r,n){this.ops.push([t,e,o,r,n])}emitPath(t,e){t.hops.forEach(((o,r)=>{if(o.tokenIn===o.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=t.hops[r-1];if(n&&o.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(v[o.venue],0===r?e:1,this.asset(o.pool),this.asset(o.tokenIn),this.asset(o.tokenOut))}))}lowerPaths(t){const e=t.filter((t=>t.hops.length>0)),o=Array.from({length:e.length},(()=>!1));for(let t=0;t<e.length;t+=1){if(o[t])continue;const r=e[t].hops[0]?.tokenIn,n=[];for(let o=t;o<e.length;o+=1)e[o].hops[0]?.tokenIn===r&&n.push(o);const u=n.reduce(((t,o)=>t+e[o].splitPpm),0);if(u>w)throw new Error(`Stellar builder: split weights for one token sum to ${u}, above 1000000`);const s=u===w;let i=w;n.forEach(((t,r)=>{o[t]=!0;const u=e[t];let a;if(r+1===n.length&&s)a=0;else{if(0===i)throw new Error("Stellar builder: split weights exhaust the group before its last path");const t=Math.floor(u.splitPpm*w/i);i-=Math.min(u.splitPpm,i),a=128+this.weight(t)}this.emitPath(u,a)}))}}toBytes(t,e,o){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const r=[1,t,e,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,this.ops.length,this.weights.length];for(const t of this.ops)r.push(...t);for(const t of this.weights)r.push(t>>>16&255,t>>>8&255,255&t);return Buffer.from(r)}get assetList(){return this.assets}get amountList(){return this.amounts}}const B=t=>{const e=new C(t.totalMinOut),o=e.asset(t.tokenIn),r=e.asset(t.tokenOut);if(o===r)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(t.burnPool){const r=e.asset(t.burnPool),n=e.amountList.length;for(const o of t.burnMinAmounts??[])e.amount(o);e.emit(5,0,r,o,n)}if(e.lowerPaths(t.paths),t.mintPool){const o=t.preSwapAmount;if(o&&BigInt(o)>0n){const r=t.mintPoolTokens;if(!r||2!==r.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,u]=r,[s,i]=t.preSwapFromA?[n,u]:[u,n];e.emit(v.Aquarius,2+e.amount(o),e.asset(t.mintPool),e.asset(s),e.asset(i))}e.emit(6,0,e.asset(t.mintPool),r,e.amount(t.mintMinShares??"1"))}const n=Number(t.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${t.referralId} does not fit the wire’s u32`);return $({amounts:i.ScVal.scvVec(e.amountList.map((t=>T(t)))),assets:i.ScVal.scvVec(e.assetList.map((t=>q(t)))),ops:i.ScVal.scvBytes(e.toBytes(o,r,n))})},D=t=>{const e=Buffer.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 i.ScVal.scvBytes(e)},G=()=>i.ScVal.scvBytes(Buffer.alloc(0)),W=t=>{const e=t.trim();if(e.startsWith("0x")){const t=e.slice(2);if(!((o=t).length>0&&o.length%2==0&&/^[0-9a-fA-F]+$/.test(o)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return Buffer.from(t,"hex")}var o;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(e))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const r=Buffer.from(e,"base64");if(0===r.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return r},z=t=>{if("string"==typeof t)return D(W(t));if(t instanceof Uint8Array)return 0===t.length?G():D(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?D(W(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?D(W(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?D(W(t.bytes)):0===t.bytes.length?G():D(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)throw new Error("Stellar builder: `steps.paths` must be a non-empty array of strategy paths");if("string"!=typeof e.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof e.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof e.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const o=new Map;for(const[t,r]of e.paths.entries()){if(!r||"number"!=typeof r.splitPpm||r.splitPpm<=0||!Array.isArray(r.hops)||0===r.hops.length)throw new Error(`Stellar builder: \`steps.paths[${t}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!x.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const e=r.hops[0];o.set(e.tokenIn,(o.get(e.tokenIn)??0)+r.splitPpm)}for(const[t,r]of o){if(r>w)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} sums to ${r}, above 1000000`);if(!e.mintPool&&r!==w)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${t} must sum to 1000000, got ${r}`)}return e})(t),i.ScVal.scvBytes(Buffer.from(B(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},V=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=Buffer.from(e,"hex");return i.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return i.ScVal.scvBytes(Buffer.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function j(e,n,s){const i=e.controllerAddress??h(e.network),a=new r(i),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(a.call(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function F(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return j(t,"supply",[q(t.caller),A(o),_(r),U([...e.assets])])}function H(t,e){return F(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function X(t,e){return j(t,"borrow",[q(t.caller),A(e.accountNonce),U([...e.borrows]),M(e.to,q)])}function K(t,e){return X(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Z(t,e){return j(t,"withdraw",[q(t.caller),A(e.accountNonce),U([...e.withdrawals]),M(e.to,q)])}function Q(t,e){return Z(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function J(t,e){return j(t,"repay",[q(t.caller),A(e.accountNonce),U([...e.payments])])}function Y(t,e){return J(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function tt(t,e){return j(t,"liquidate",[q(t.caller),A(e.accountNonce),U([...e.debtPayments])])}function et(t,e){return j(t,"flash_loan",[q(t.caller),L(e.hubId,e.asset),T(e.amount),q(e.receiver),V(e.data)])}function ot(t,e){return j(t,"migrate_from_blend",[q(t.caller),A(e.accountId),_(e.spokeId),_(e.hubId),q(e.blendPool),R(e.collateralTokens.map(q)),R(e.supplyTokens.map(q)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),i.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,i.ScVal.scvVec([q(e),T(o)]);var e,o}))))]);var o}function rt(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return j(t,"multiply",[q(t.caller),A(o),_(r),L(e.collateral.hubId,e.collateral.asset),T(e.debtToFlashLoan),L(e.debt.hubId,e.debt.asset),_(e.mode),z(e.steps),M(e.initialPayment,(t=>N(t.hubId,t.asset,t.amount))),M(e.convertSwap,z)])}function nt(t,e){return j(t,"swap_debt",[q(t.caller),A(e.accountNonce),L(e.existingDebt.hubId,e.existingDebt.asset),T(e.newDebtAmount),L(e.newDebt.hubId,e.newDebt.asset),z(e.steps)])}function ut(t,e){return j(t,"swap_collateral",[q(t.caller),A(e.accountNonce),L(e.current.hubId,e.current.asset),T(e.fromAmount),L(e.newCollateral.hubId,e.newCollateral.asset),z(e.steps)])}function st(t,e){return j(t,"repay_debt_with_collateral",[q(t.caller),A(e.accountNonce),L(e.collateral.hubId,e.collateral.asset),T(e.collateralAmount),L(e.debt.hubId,e.debt.asset),z(e.steps),k(e.closePosition)])}const it="/stellar-lending",at=25,pt=encodeURIComponent,lt=(t,e)=>t.fetchWithTimeout(`${it}/context`,e),ct=(t,e)=>t.fetchWithTimeout(`${it}/live-state`,e),dt=(t,e)=>t.fetchWithTimeout(`${it}/assets`,e),yt=(t,e)=>t.fetchWithTimeout(`${it}/hubs`,e),gt=(t,e)=>t.fetchWithTimeout(`${it}/spokes`,e),ft=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${it}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},mt=(t,e,o,r,n)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}`,n),ht=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}/holders`,{...u,params:{side:n}}),bt=(t,e,o)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}`,o),St=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/page`,{...r,params:{...o}}),xt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/markets`,{...r,params:{side:o}}),vt=(t,e,o)=>t.fetchWithTimeout(`${it}/hubs/${e}`,o),wt=(t,e,o)=>t.fetchWithTimeout(`${it}/spokes/${e}`,o),qt=(t,e,o)=>t.fetchWithTimeout(`${it}/users/${pt(e)}/positions`,o),Tt=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${it}/users/${pt(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},_t=(t,e,o)=>t.fetchWithTimeout(`${it}/accounts/${pt(e)}/positions`,o),At=(t,e={},o)=>{const{top:r=at,continuationToken:n}=e;return t.fetchWithTimeout(`${it}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},kt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/assets/${pt(e)}/graph`,{...r,params:{...o}}),Pt=(t,e,o,r)=>t.fetchWithTimeout(`${it}/hubs/${e}/graph`,{...r,params:{...o}}),It=(t,e,o,r)=>t.fetchWithTimeout(`${it}/spokes/${e}/graph`,{...r,params:{...o}}),Et=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${it}/reserves/${e}/${o}/${pt(r)}/graph`,{...u,params:{...n}}),Rt=(t,e)=>t.fetchWithTimeout(`${it}/protocol-config`,e),Ot=(t,e,o)=>t.fetchWithTimeout(`${it}/protocol-config/${pt(e)}`,o),Mt=(t,e,o)=>t.fetchWithTimeout(e?`${it}/roles?contractAddress=${pt(e)}`:`${it}/roles`,o),Lt=(t,e,o)=>t.fetchWithTimeout(`${it}/accounts/${pt(String(e))}/delegates`,o),Nt=(t,e)=>t.fetchWithTimeout(`${it}/blend-pools`,e),Ut=t=>({context:e=>lt(t,e),liveState:e=>ct(t,e),protocolConfig:e=>Rt(t,e),contractConfig:(e,o)=>Ot(t,e,o),contractRoles:(e,o)=>Mt(t,e,o),accountDelegates:(e,o)=>Lt(t,e,o),blendPools:e=>Nt(t,e),assets:e=>dt(t,e),hubs:e=>yt(t,e),spokes:e=>gt(t,e),reserves:(e,o)=>{return void 0===(r=e)||"hubId"in r||"spokeId"in r||"asset"in r?ft(t,e,o):ft(t,{},e);var r},reserve:(e,o,r,n)=>mt(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>ht(t,e,o,r,n,u),asset:(e,o)=>bt(t,e,o),assetMarkets:(e,o,r)=>xt(t,e,o,r),hub:(e,o)=>vt(t,e,o),spoke:(e,o)=>wt(t,e,o),userPositions:(e,o)=>qt(t,e,o),userActivity:(e,o,r)=>Tt(t,e,o,r),accountPositions:(e,o)=>_t(t,e,o),governanceProposals:(e,o)=>At(t,e,o),assetGraph:(e,o,r)=>kt(t,e,o,r),hubGraph:(e,o,r)=>Pt(t,e,o,r),spokeGraph:(e,o,r)=>It(t,e,o,r),reserveGraph:(e,o,r,n,u)=>Et(t,e,o,r,n,u)}),$t=t=>$({base_borrow_rate:T(t.baseBorrowRateRay),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:_(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),Ct=t=>$({asset_decimals:_(t.assetDecimals),asset_id:q(t.assetId),base_borrow_rate:T(t.baseBorrowRateRay),flashloan_fee:_(t.flashloanFeeBps),is_flashloanable:k(t.isFlashloanable),max_borrow_rate:T(t.maxBorrowRateRay),max_utilization:T(t.maxUtilizationRay),mid_utilization:T(t.midUtilizationRay),optimal_utilization:T(t.optimalUtilizationRay),reserve_factor:_(t.reserveFactorBps),slope1:T(t.slope1Ray),slope2:T(t.slope2Ray),slope3:T(t.slope3Ray)}),Bt=t=>$({max_borrow_positions:_(t.maxBorrowPositions),max_supply_positions:_(t.maxSupplyPositions)}),Dt=t=>{if("Token"in t&&t.Token)return R([I("Token"),q(t.Token)]);if("Ref"in t&&t.Ref)return R([I("Ref"),I(t.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(t)}`)},Gt=t=>{if("Stellar"in t)return R([I("Stellar"),q(t.Stellar)]);if("Symbol"in t)return R([I("Symbol"),I(t.Symbol)]);if("String"in t)return R([I("String"),P(t.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(t)}`)},Wt=t=>{if("Spot"===t)return R([I("Spot")]);if(t&&"object"==typeof t&&"Twap"in t)return R([I("Twap"),_(Number(t.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(t)}`)},zt=t=>{if("Reflector"===t||"RedStone"===t||"Xoxno"===t)return R([I(t)]);throw new Error(`Stellar builder: unknown ProviderKind "${t}"`)},Vt=t=>{if("Market"===t||"Fundamental"===t)return R([I(t)]);throw new Error(`Stellar builder: unknown FeedNature "${t}"`)},jt=t=>{if("Reflector"in t){const e=t.Reflector;return R([I("Reflector"),$({asset:Gt(e.asset),contract:q(e.contract),read_mode:Wt(e.readMode)})])}if("MultiFeed"in t){const e=t.MultiFeed;return R([I("MultiFeed"),$({contract:q(e.contract),feed_id:P(e.feedId),kind:zt(e.kind),nature:Vt(e.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(t)}`)},Ft=t=>{const e=t;return $({decimals:_(e.decimals),max_stale_seconds:A(e.maxStaleSeconds),provider:jt(e.provider)})},Ht=t=>{if("RequireDisjoint"===t)return R([I("RequireDisjoint")]);if(t&&"object"==typeof t&&"AllowShared"in t){const e=t.AllowShared;return R([I("AllowShared"),R(e.map((t=>$({contract:q(t.contract),kind:zt(t.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(t)}`)},Xt=t=>{const e=t,o=e.sources??[];let r,n;if("number"==typeof e.toleranceBps)r=1e4+e.toleranceBps,n=Math.max(1,Math.floor(1e8/r));else{const t=e.tolerance??{};r=Number(t.upperRatioBps),n=Number(t.lowerRatioBps)}return $({asset_decimals:_(Number(e.assetDecimals)),independence:Ht(e.independence),max_price_stale_seconds:A(Number(e.maxPriceStaleSeconds)),max_sanity_price_wad:T(String(e.maxSanityPriceWad)),min_sanity_price_wad:T(String(e.minSanityPriceWad)),sources:R(o.map((t=>(t=>{if("Feed"in t)return R([I("Feed"),Ft(t.Feed)]);if("Scaled"in t){const e=t.Scaled;return R([I("Scaled"),$({factor:Ft(e.factor),max_factor_wad:T(e.maxFactorWad),min_factor_wad:T(e.minFactorWad),quote:Dt(e.quote)})])}if("LpShare"in t){const e=t.LpShare;return R([I("LpShare"),$({key_a:Dt(e.keyA),key_b:Dt(e.keyB),kind:R([I(e.kind||"ConstantProduct")]),pool:q(e.pool),reserve_a_decimals:_(e.reserveADecimals),reserve_b_decimals:_(e.reserveBDecimals),share_decimals:_(e.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(t)}`)})(t)))),tolerance:$({lower_ratio_bps:_(n),upper_ratio_bps:_(r)})})},Kt=Xt;function Zt(t,e){return j(t,"upgrade",[O(e.wasmHash)])}function Qt(t,e){return j(t,"migrate",[_(e.newVersion)])}function Jt(t){return j(t,"pause",[])}function Yt(t){return j(t,"unpause",[])}function te(t,e){return j(t,"grant_role",[q(e.account),I(e.role)])}function ee(t,e){return j(t,"revoke_role",[q(e.account),I(e.role)])}function oe(t,e){return j(t,"transfer_ownership",[q(e.newOwner),_(e.liveUntilLedger)])}function re(t){return j(t,"accept_ownership",[])}function ne(t,e){return j(t,"set_swap_aggregator",[q(e.aggregator)])}function ue(t,e){return j(t,"set_price_aggregator",[q(e.aggregator)])}const se=ne;function ie(t,e){return j(t,"set_accumulator",[q(e.accumulator)])}function ae(t,e){return j(t,"set_position_limits",[Bt(e)])}function pe(t,e){return j(t,"approve_blend_pool",[q(e.pool)])}function le(t,e){return j(t,"revoke_blend_pool",[q(e.pool)])}const ce=pe,de=le;function ye(t,e){return j(t,"set_oracle",[Dt(e.key),Xt(e.oracle)])}const ge=ye;function fe(t,e){const o=e.toleranceBps,r=e.upperRatioBps??1e4+o,n=e.lowerRatioBps??Math.max(1,Math.floor(1e8/r));return j(t,"set_tolerance",[Dt(e.key),$({lower_ratio_bps:_(n),upper_ratio_bps:_(r)})])}function me(t,e){return j(t,"set_spoke_asset_flags",[_(e.spokeId),L(e.hubId,e.asset),k(e.paused),k(e.frozen)])}function he(t,e){return j(t,"set_oracle_sanity_bounds",[q(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function be(t,e){return j(t,"update_indexes",[q(t.caller),R(e.assets.map((t=>L(t.hubId,t.asset))))])}function Se(t,e){return j(t,"renew_account",[q(t.caller),A(e.accountNonce)])}function xe(t,e){return j(t,"create_liquidity_pool",[_(e.hubId),q(e.asset),Ct(e.params)])}function ve(t,e){return j(t,"upgrade_liquidity_pool_params",[L(e.hubId,e.asset),$t(e.params)])}function we(t,e){return j(t,"claim_revenue",[q(t.caller),R(e.assets.map((t=>L(t.hubId,t.asset))))])}function qe(t,e){return j(t,"add_rewards",[q(t.caller),U(e.rewards)])}function Te(t,e){return j(t,"update_account_threshold",[q(t.caller),k(e.hasRisks),R(e.accountNonces.map((t=>A(t))))])}const _e="00".repeat(32),Ae=t=>{if("string"==typeof t)return O(t);const e=Buffer.from(t);if(32!==e.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${e.length} bytes)`);return i.ScVal.scvBytes(e)},ke=(t,...e)=>R([I(t),...e]),Pe=t=>$({new_owner:q(t.newOwner),live_until_ledger:_(t.liveUntilLedger)}),Ie=t=>$({asset:q(t.asset),bonus:_(t.bonus),borrow_cap:T(t.borrowCap),can_borrow:k(t.canBorrow),can_collateral:k(t.canCollateral),frozen:k(t.frozen),hub_id:_(t.hubId),paused:k(t.paused),liquidation_fees:_(t.liquidationFees),ltv:_(t.ltv),oracle_override:R([I("None")]),spoke_id:_(t.spokeId),supply_cap:T(t.supplyCap),threshold:_(t.threshold)}),Ee=t=>$({account:q(t.account),role:I(t.role)});function Re(e,n,s){const i=e.governanceAddress??S(e.network),a=new r(i),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(a.call(n,...s)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Oe=(t,e,o)=>Re(t,"propose",[q(t.caller),e,Ae(o)]),Me=(t,e,o)=>Re(t,"execute_self",[E(),e,Ae(o)]);function Le(t,e,o){return Oe(t,ke("SetSwapAggregator",q(e.aggregator)),o)}function Ne(t,e,o){return Oe(t,ke("SetPriceAggregator",q(e.aggregator)),o)}const Ue=Le;function $e(t,e,o){return Oe(t,ke("SetAccumulator",q(e.accumulator)),o)}function Ce(t,e,o){return Oe(t,ke("SetPositionLimits",Bt(e)),o)}function Be(t,e){return Oe(t,ke("CreateHub"),e)}function De(t,e){return Oe(t,ke("AddSpoke"),e)}function Ge(t,e,o){return Oe(t,ke("RemoveSpoke",_(e.spokeId)),o)}function We(t,e,o){return Oe(t,ke("AddAssetToSpoke",Ie(e)),o)}function ze(t,e,o){return Oe(t,ke("EditAssetInSpoke",Ie(e)),o)}function Ve(t,e,o){return Oe(t,ke("RemoveAssetFromSpoke",$({hub_asset:L((r=e).hubId,r.asset),spoke_id:_(r.spokeId)})),o);var r}function je(t,e,o){return Oe(t,ke("SetSpokeLiquidationCurve",$({hf_for_max_bonus_wad:T((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:_(r.liquidationBonusFactorBps),spoke_id:_(r.spokeId),target_hf_wad:T(r.targetHfWad)})),o);var r}function Fe(t,e,o){return Oe(t,ke("SetPositionManager",q(e.manager),k(e.isActive)),o)}function He(t,e,o){return Oe(t,ke("SetMinBorrowCollateralUsd",T(e.floorWad)),o)}function Xe(t,e,o){return Oe(t,ke("ApproveToken",q(e.token)),o)}function Ke(t,e,o){return Oe(t,ke("RevokeToken",q(e.token)),o)}function Ze(t,e,o){return Oe(t,ke("ApproveBlendPool",q(e.pool)),o)}function Qe(t,e,o){return Oe(t,ke("RevokeBlendPool",q(e.pool)),o)}function Je(t,e,o){return Oe(t,ke("CreateLiquidityPool",$({asset:q((r=e).asset),hub_id:_(r.hubId),params:Ct(r.params)})),o);var r}function Ye(t,e,o){return Oe(t,ke("UpgradeLiquidityPoolParams",$({hub_asset:L((r=e).hubId,r.asset),params:$t(r.params)})),o);var r}function to(t,e,o){return Oe(t,ke("DeployPool",O(e.wasmHash)),o)}function eo(t,e,o){return Oe(t,ke("UpgradePool",O(e.wasmHash)),o)}function oo(t,e,o){return Oe(t,ke("UpgradeController",O(e.wasmHash)),o)}function ro(t,e,o){return Oe(t,ke("MigrateController",_(e.newVersion)),o)}function no(t,e,o){return Oe(t,ke("TransferCtrlOwnership",Pe(e)),o)}function uo(t,e,o){return Oe(t,ke("ConfigureAssetOracle",$({key:Dt((r=e).key),oracle:Xt(r.oracle)})),o);var r}const so=uo;function io(t,e,o){return Oe(t,ke("EditOracleTolerance",$({key:Dt((r=e).key),tolerance:_(r.tolerance)})),o);var r}function ao(t,e,o){return Oe(t,ke("UpgradeGov",O(e.wasmHash)),o)}function po(t,e,o){return Oe(t,ke("UpdateGovDelay",_(e.newDelay)),o)}function lo(t,e,o){return Oe(t,ke("GrantGovRole",Ee(e)),o)}function co(t,e,o){return Oe(t,ke("RevokeGovRole",Ee(e)),o)}function yo(t,e,o){return Oe(t,ke("TransferGovOwnership",Pe(e)),o)}function go(t,e){const o=R(e.argsXdr.map((t=>i.ScVal.fromXDR(t,"base64")))),r=Ae(e.predecessor??_e);return Re(t,"execute",[E(),q(e.target),I(e.functionName),o,r,Ae(e.salt)])}function fo(t,e,o){return Me(t,ke("UpgradeGov",O(e.wasmHash)),o)}function mo(t,e,o){return Me(t,ke("UpdateGovDelay",_(e.newDelay)),o)}function ho(t,e,o){return Me(t,ke("GrantGovRole",Ee(e)),o)}function bo(t,e,o){return Me(t,ke("RevokeGovRole",Ee(e)),o)}function So(t,e,o){return Me(t,ke("TransferGovOwnership",Pe(e)),o)}const xo=t=>R(t.map(q));function vo(t,e,o){return Re(t,"propose_canceller_reset",[xo(e.newCancellers),Ae(o)])}function wo(t,e,o){return Re(t,"execute_canceller_reset",[M(e.executor,q),xo(e.newCancellers),Ae(o)])}function qo(t,e){return Re(t,"set_spoke_asset_flags",[q(t.caller),_(e.spokeId),L(e.hubId,e.asset),k(e.paused),k(e.frozen)])}function To(t,e){return Re(t,"set_oracle_sanity_bounds",[q(t.caller),q(e.asset),T(e.minPriceWad),T(e.maxPriceWad)])}function _o(t){return Re(t,"create_hub",[q(t.caller)])}function Ao(t){return Re(t,"add_spoke",[q(t.caller)])}function ko(t,e){return Re(t,"revoke_role_immediate",[q(e.account),I(e.role)])}function Po(t){return Re(t,"pause",[q(t.caller)])}function Io(t,e){return Oe(t,ke("Unpause"),e)}const Eo=t=>t.toXDR("base64"),Ro=t=>i.ScVal.fromXDR(t,"base64"),Oo=t=>t.map((t=>String(s(Ro(t))))).join(":"),Mo=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),Lo=t=>Number(t),No=t=>String(t),Uo=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),$o=["None","Multiply","Long","Short"],Co=["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"],Bo=t=>Array.isArray(t)?t:[],Do=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],Co[Lo(r)]??Mo(r)),positionType:e,hubId:Lo(t[1]),asset:No(t[2]),scaledAmountRay:Mo(t[3]),indexRay:Mo(t[4]),amount:Mo(t[5]),liquidationThresholdBps:o?void 0:Lo(t[6]),liquidationBonusBps:o?void 0:Lo(t[7]),loanToValueBps:o?void 0:Lo(t[8]),liquidationFeesBps:o?void 0:Lo(t[9])};var r},Go=t=>{return{owner:No(t[0]),spokeId:Lo(t[1]),mode:(e=t[2],$o[Lo(e)]??"None")};var e},Wo=t=>Array.isArray(t)?t[1]:void 0,zo=t=>{const e=(o=t,Array.isArray(o)?No(o[0]):No(o));var o;if("Token"===e)return{Token:No(Wo(t))};if("Ref"===e)return{Ref:No(Wo(t))};if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;if(void 0!==e.Token)return{Token:No(e.Token)};if(void 0!==e.Ref)return{Ref:No(e.Ref)}}return{Token:No(t)}},Vo=t=>{const e=t.tolerance??{};return{assetDecimals:Lo(t.asset_decimals),maxPriceStaleSeconds:Lo(t.max_price_stale_seconds),sources:Bo(t.sources).map((t=>t)),tolerance:{upperRatio:Lo(e.upper_ratio_bps),lowerRatio:Lo(e.lower_ratio_bps)},independence:t.independence,minSanityPriceWad:Mo(t.min_sanity_price_wad),maxSanityPriceWad:Mo(t.max_sanity_price_wad)}},jo={"market:create":t=>({topic:"market:create",data:{hubId:Lo(t.hub_id),baseAsset:No(t.base_asset),maxBorrowRate:Mo(t.max_borrow_rate),baseBorrowRate:Mo(t.base_borrow_rate),slope1:Mo(t.slope1),slope2:Mo(t.slope2),slope3:Mo(t.slope3),midUtilization:Mo(t.mid_utilization),optimalUtilization:Mo(t.optimal_utilization),maxUtilization:Mo(t.max_utilization),reserveFactor:Lo(t.reserve_factor),marketAddress:No(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:No(t.asset),maxBorrowRateRay:Mo(t.max_borrow_rate),baseBorrowRateRay:Mo(t.base_borrow_rate),slope1Ray:Mo(t.slope1),slope2Ray:Mo(t.slope2),slope3Ray:Mo(t.slope3),midUtilizationRay:Mo(t.mid_utilization),optimalUtilizationRay:Mo(t.optimal_utilization),maxUtilizationRay:Mo(t.max_utilization),reserveFactorBps:Lo(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:Bo(t).map((t=>{return e=Bo(t),{hubId:Lo(e[0]),asset:No(e[1]),timestamp:Lo(e[2]),supplyIndexRay:Mo(e[3]),borrowIndexRay:Mo(e[4]),cash:Mo(e[5]),suppliedRay:Mo(e[6]),borrowedRay:Mo(e[7]),revenueRay:Mo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:Bo(t).map((t=>{const e=t;return{hubId:Lo(e.hub_id),asset:No(e.asset),params:(o=e.params,{maxBorrowRateRay:Mo(o.max_borrow_rate),baseBorrowRateRay:Mo(o.base_borrow_rate),slope1Ray:Mo(o.slope1),slope2Ray:Mo(o.slope2),slope3Ray:Mo(o.slope3),midUtilizationRay:Mo(o.mid_utilization),optimalUtilizationRay:Mo(o.optimal_utilization),maxUtilizationRay:Mo(o.max_utilization),reserveFactorBps:Lo(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:Lo(o.flashloan_fee),assetId:No(o.asset_id),assetDecimals:Lo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=Bo(t);return{topic:"position:batch_update",data:{accountId:Mo(e[0]),accountAttributes:Go(Bo(e[1])),updates:[...Bo(e[2]).map((t=>Do(Bo(t),"Deposit"))),...Bo(e[3]).map((t=>Do(Bo(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:Lo(t.hub_id),asset:No(t.asset),receiver:No(t.receiver),caller:No(t.caller),amount:Mo(t.amount),fee:Mo(t.fee)}}),"config:asset_oracle":t=>({topic:"config:asset_oracle",data:{key:zo(t.key),oracle:Vo(t.oracle)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:No(t.asset),oracle:Vo(t.config??t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:No(t.liquidator),accountId:Mo(t.account_id),repaidUsdWad:Mo(t.repaid_usd_wad),bonusBps:Mo(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:Mo(t.account_id),totalBorrowUsdWad:Mo(t.total_borrow_usd_wad),totalCollateralUsdWad:Mo(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:No(t.token),amount:Mo(t.amount),usdValueWad:Mo(t.usd_value_wad),accountId:Mo(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:Lo(t.hub_id),asset:No(t.asset),amount:Mo(t.amount),fee:Mo(t.fee),amountSent:Mo(t.amount_sent)}}),"config:approve_blend_pool":t=>({topic:"config:approve_blend_pool",data:{pool:No(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:Uo(t.wasm_hash??t.pool),approved:Boolean(t.approved)}}),"config:swap_aggregator":t=>({topic:"config:swap_aggregator",data:{aggregator:No(t.aggregator??t.swap_aggregator)}}),"config:price_aggregator":t=>({topic:"config:price_aggregator",data:{aggregator:No(t.aggregator??t.price_aggregator)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:No(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:No(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:Uo(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:Lo(t.max_supply_positions),maxBorrowPositions:Lo(t.max_borrow_positions)}}),"config:min_borrow_collateral":t=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Mo(t.min_borrow_collateral_usd_wad??t.floor_wad??t.value)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:No(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:Lo(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:Mo(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Mo(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:Lo(e.liquidation_bonus_factor_bps)}}}},Fo=Object.freeze(Object.keys(jo));function Ho(t,e){const o=Oo(t),r=jo[o];return r?r(s(Ro(e))):null}const Xo="XLENDXLM-a7c9f3",Ko=1e4;function Zo(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${Xo}-${o}`}function Qo(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function Jo(t,e=0){return t*Ko+e}function Yo(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const tr=(t,e,o)=>{const r=new URL(e,t.endsWith("/")?t:`${t}/`);if(o)for(const[t,e]of Object.entries(o))void 0!==e&&r.searchParams.set(t,String(e));return r.toString()},er=t=>t.baseUrl??f[t.network];async function or(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=tr(er(e),"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,platform:t.platform,fresh:t.fresh}),r=await fetch(o,e.fetchOptions);if(!r.ok){const t=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${o} — ${t}`)}return await r.json()}async function rr(t){const e=tr(er(t),"api/v1/tokens"),o=await fetch(e,t.fetchOptions);if(!o.ok){const t=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${e} — ${t}`)}return await o.json()}const nr=t=>B(t).toXDR("base64");function ur(e,n){const s=e.routerAddress??b(e.network),i=new r(s),a=new t(e.caller,e.sourceSequence),p=z(((t,e)=>(t=>Boolean(t&&"object"==typeof t&&!(t instanceof Uint8Array)&&"paths"in t))(t)&&void 0===t.referralId?{...t,referralId:e??0}:t)(n,e.referralId));return{xdr:new u(a,{fee:e.fee??o,networkPassphrase:m[e.network]}).addOperation(i.call("execute_strategy",q(e.caller),T(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function sr(t,e){return ur(t,e)}function ir(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(lr),splitPpm:t.splitPpm}))):[{hops:t.hops.map(lr),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function ar(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:ir(t,e)}const pr=ir,lr=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function cr(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function dr(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw cr(o.invokedContractId,t);throw t}}async function yr(t,e,o){return dr(t,e.xdr,o)}function gr(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 fr(t,e){return new Uint8Array(0)}const mr=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 Buffer.from(e,"hex")};function hr(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",i.ScVal.scvBytes(mr(e.message)),i.ScVal.scvBytes(mr(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:m[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const br={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."},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 Sr(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=br[o];return r?{code:o,...r}:null}}},p={};function l(t){var e=p[t];if(void 0!==e)return e.exports;var o=p[t]={exports:{}};return a[t](o,o.exports,l),o.exports}l.d=(t,e)=>{for(var o in e)l.o(e,o)&&!l.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const c="https://api.xoxno.com",d="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",g="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var f;!function(t){t.MAINNET="1",t.DEVNET="D"}(f||(f={}));class m{apiUrl;chain;init;config;constructor({chain:t=f.MAINNET,apiUrl:e=c,...o}={}){this.apiUrl=e??{[f.MAINNET]:c,[f.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==f.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:d,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:d,DR_SC:y,KG_SC:g,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:u,...s}=this.init,{next:i,cache:a,debug:p,headers:l,method:c="GET",...d}=o,y=l?.Authorization,g="Bearer undefined"===y?void 0:y,f={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===c?{}:{"Content-Type":"application/json"},...g?{Authorization:g}:{}},m=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),h=`${this.apiUrl}${t}${m.length?`?${m}`:""}`,{revalidate:b,...S}=r??{},{revalidate:x,...v}=i??{},w="GET"!==c||g?void 0:x??b,q="GET"!==c||g||w?void 0:a??n,T={...s,...d,method:c,...Object.keys(f).length?{headers:f}:{},cache:q,next:{...S,...v,revalidate:w}};(p??u)&&console.debug("SDK fetch: ",h,T);const _=await fetch(h,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${h}: ${t.message}`),{cause:t});throw t})),A=await _.text();if(!_.ok){let t;try{t=JSON.parse(A)}catch{t={message:A}}const e=[h,_.status,_.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const h=t=>{const e=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(t)),o=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t);return e||o},b=t=>{const e=/^0x[a-fA-F0-9]{1,64}$/.test(t),o=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(t);return e||o};class S extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class x extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const v=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^G[A-Z2-7]{55}$/.test(t)),w={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}}},q=["PATCH","POST","DELETE","PUT"];var T=l(385);const _=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function A(t,e,o,r){const{input:n,output:u,...s}=e,i=async(e={})=>{const n={...o,...e},u=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),s=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),i=Object.fromEntries(Object.entries(n).filter((([t])=>!s.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in i,p=/:collection[^A-Z]/.test(t)||"collection"in i;if(a){const t=n.address;if(!v(t))throw new x(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!h(t))):!h(t))throw new S(t)}const l=Object.fromEntries(Object.entries(i).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:c,auth:d,method:y,headers:g,cache:f,next:m,debug:b,continuationToken:w,...q}=l,T=d?`Bearer ${d}`:void 0,_={...g,...T?{Authorization:T}:{},...w?{"X-Continuation-Token":String(w)}:{}},A={...m,tags:[...m?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:q,body:c,headers:_,cache:f,debug:b,...A?{next:A}:{}})},a=(t={})=>i(t);for(const t of Object.keys(s))q.includes(t)&&(a[t]=e=>i({...e,method:e.method??t.toUpperCase()}));return a}function k(t){const e=function(){const t={static:{},params:{},leaves:[]};for(const[e,o]of Object.entries(w)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=_(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=_(t);n=n.static[e]||={static:{},params:{},leaves:[]}}n.leaves.push({rawPath:e,def:o})}return t}(),o=(e,r)=>{const n=e.leaves.length,u=Object.keys(e.static).length,s=Object.keys(e.params).length;let i;if(1===n&&u+s>0){const{rawPath:o,def:n}=e.leaves[0];i=A(o,n,r,t)}else{i={};for(const{rawPath:o,def:n}of e.leaves)i[_(o.split("/").pop().replace(/^:/,""))]=A(o,n,r,t)}for(const[t,n]of Object.entries(e.static)){const e=o(n,r);let u=e;if(e&&"object"==typeof e&&t in e&&"function"==typeof e[t]){const o=e[t],r=Object.fromEntries(Object.entries(e).filter((([e])=>e!==t)));1===o.length||(Object.assign(o,r),u=o)}void 0===i[t]?i[t]=u:"function"==typeof i[t]?Object.assign(i[t],u):"function"==typeof u?(Object.assign(u,i[t]),i[t]=u):Object.assign(i[t],u)}for(const[t,n]of Object.entries(e.params)){const e=e=>{const u=o(n,{...r,[t]:e});if(u&&"object"==typeof u&&1===Object.keys(u).length&&t in u&&"function"==typeof u[t]){const e=u[t],o=(...t)=>e(...t);return Object.assign(o,e)}return u};if(i[t]){const o=i[t];i[t]=t=>({...o(t),...e(t)})}else i[t]=e}return i};return o(e,{})}export{f as Chain,m as XOXNOClient,k as buildSdk,h as isValidCollectionTicker,b as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=T.ME;export const STELLAR_GOVERNANCE=T.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=T.G_;export const STELLAR_LENDING_CONTROLLER=T.DU;export const STELLAR_LENDING_TOPICS=T.fA;export const STELLAR_NETWORK_PASSPHRASE=T.A$;export const STELLAR_QUOTE_URL=T.J9;export const STELLAR_SOROBAN_RPC_URL=T.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=T.gR;export const XOXNO_LENDING_STELLAR_TICKER=T.Cg;export const buildSameTokenRepaySwapSteps=T.VZ;export const buildStellarAcceptOwnershipTx=T.N0;export const buildStellarAddRewardsTx=T.B_;export const buildStellarApproveBlendPoolTx=T.qL;export const buildStellarApproveTokenTx=T.eX;export const buildStellarBatchSwapTx=T.z;export const buildStellarBorrowBatchTx=T.xD;export const buildStellarBorrowTx=T.jR;export const buildStellarCctpForwardTx=T.P2;export const buildStellarClaimRevenueTx=T.W6;export const buildStellarCreateLiquidityPoolTx=T.se;export const buildStellarExecuteCancellerResetTx=T.ZP;export const buildStellarExecuteStrategyTx=T.yr;export const buildStellarFlashLoanTx=T.sp;export const buildStellarGovernanceAddSpokeImmediateTx=T.Iu;export const buildStellarGovernanceCreateHubImmediateTx=T.yu;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=T.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=T.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=T.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=T.e_;export const buildStellarGovernanceExecuteTx=T.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=T.BA;export const buildStellarGovernancePauseTx=T.u9;export const buildStellarGovernanceRevokeRoleImmediateTx=T.bi;export const buildStellarGovernanceSetOracleSanityBoundsImmediateTx=T.gc;export const buildStellarGovernanceSetSpokeAssetFlagsImmediateTx=T.ay;export const buildStellarGrantRoleTx=T.SX;export const buildStellarLendingIdentifier=T.UF;export const buildStellarLiquidateTx=T.Y5;export const buildStellarMigrateFromBlendTx=T.mE;export const buildStellarMigrateTx=T.xG;export const buildStellarMultiplyTx=T.s9;export const buildStellarPauseTx=T.OL;export const buildStellarProposeAddAssetToSpokeTx=T.k6;export const buildStellarProposeAddSpokeTx=T.dj;export const buildStellarProposeApproveBlendPoolTx=T.kD;export const buildStellarProposeApproveTokenTx=T.Yf;export const buildStellarProposeCancellerResetTx=T.AI;export const buildStellarProposeConfigureAssetOracleTx=T.O2;export const buildStellarProposeConfigureMarketOracleTx=T.c5;export const buildStellarProposeCreateHubTx=T.N8;export const buildStellarProposeCreateLiquidityPoolTx=T.qU;export const buildStellarProposeDeployPoolTx=T.RZ;export const buildStellarProposeEditAssetInSpokeTx=T.ni;export const buildStellarProposeEditOracleToleranceTx=T.hF;export const buildStellarProposeGovernanceUpgradeTx=T.Qk;export const buildStellarProposeGrantGovernanceRoleTx=T.Gw;export const buildStellarProposeMigrateControllerTx=T.$K;export const buildStellarProposeRemoveAssetFromSpokeTx=T.uj;export const buildStellarProposeRemoveSpokeTx=T.Od;export const buildStellarProposeRevokeBlendPoolTx=T.X7;export const buildStellarProposeRevokeGovernanceRoleTx=T.Ub;export const buildStellarProposeRevokeTokenTx=T.Dx;export const buildStellarProposeSetAccumulatorTx=T.OA;export const buildStellarProposeSetAggregatorTx=T.$U;export const buildStellarProposeSetMinBorrowCollatTx=T.ob;export const buildStellarProposeSetPositionLimitsTx=T.$l;export const buildStellarProposeSetPositionManagerTx=T.K;export const buildStellarProposeSetPriceAggregatorTx=T.Wb;export const buildStellarProposeSetSpokeLiquidationCurveTx=T.kw;export const buildStellarProposeSetSwapAggregatorTx=T.qA;export const buildStellarProposeTransferCtrlOwnershipTx=T.VS;export const buildStellarProposeTransferGovOwnTx=T.HP;export const buildStellarProposeUnpauseTx=T.xQ;export const buildStellarProposeUpdateDelayTx=T.YQ;export const buildStellarProposeUpgradeControllerTx=T.QY;export const buildStellarProposeUpgradePoolParamsTx=T.os;export const buildStellarProposeUpgradePoolTx=T.Ko;export const buildStellarRenewAccountTx=T.IJ;export const buildStellarRepayBatchTx=T.nw;export const buildStellarRepayDebtWithCollateralTx=T.Pr;export const buildStellarRepayTx=T.ZE;export const buildStellarRevokeBlendPoolTx=T.X0;export const buildStellarRevokeRoleTx=T.ev;export const buildStellarRevokeTokenTx=T.P8;export const buildStellarSetAccumulatorTx=T.aV;export const buildStellarSetAggregatorTx=T.p2;export const buildStellarSetMarketOracleConfigTx=T.sV;export const buildStellarSetOracleSanityBoundsTx=T.XD;export const buildStellarSetOracleToleranceTx=T.Js;export const buildStellarSetOracleTx=T.W5;export const buildStellarSetPositionLimitsTx=T.Dy;export const buildStellarSetPriceAggregatorTx=T._i;export const buildStellarSetSpokeAssetFlagsTx=T.FZ;export const buildStellarSetSwapAggregatorTx=T.wG;export const buildStellarSupplyBatchTx=T.Ni;export const buildStellarSupplyTx=T.v_;export const buildStellarSwapCollateralTx=T.qD;export const buildStellarSwapDebtTx=T.qR;export const buildStellarTransferOwnershipTx=T.QJ;export const buildStellarUnpauseTx=T.bm;export const buildStellarUpdateAccountThresholdTx=T.n_;export const buildStellarUpdateIndexesTx=T.v8;export const buildStellarUpgradeControllerTx=T.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=T.gH;export const buildStellarWithdrawBatchTx=T.O3;export const buildStellarWithdrawTx=T.Gz;export const buildTx=T.pr;export const decodeStellarLendingEvent=T.Fm;export const encodeAssetOracle=T.Ft;export const encodeInterestRateModel=T.MB;export const encodeMarketOracleConfigInput=T.Dn;export const encodeMarketParamsRaw=T.pq;export const encodePositionLimits=T.Q3;export const encodePriceKey=T.Jh;export const encodeStrategyPayloadToRouteXdr=T.wf;export const extractEventOrder=T.Um;export const getStellarAccountDelegates=T.XR;export const getStellarAccountPositions=T.xO;export const getStellarAggregatorQuote=T.Lw;export const getStellarAggregatorRouter=T.KM;export const getStellarAsset=T.mM;export const getStellarAssetGraph=T.iE;export const getStellarAssetMarkets=T.zp;export const getStellarAssetPage=T.N3;export const getStellarAssets=T.bN;export const getStellarBlendPools=T.cK;export const getStellarContractConfig=T.kV;export const getStellarContractRoles=T.vo;export const getStellarGovernance=T.QV;export const getStellarGovernanceProposals=T.T_;export const getStellarHub=T.XI;export const getStellarHubGraph=T.Lt;export const getStellarHubs=T.KK;export const getStellarLendingContext=T.yl;export const getStellarLendingController=T.vc;export const getStellarLendingLiveState=T.kq;export const getStellarProtocolConfig=T.Mi;export const getStellarQuoteTokens=T.CH;export const getStellarReserve=T.FI;export const getStellarReserveGraph=T.KG;export const getStellarReserveHolders=T.nW;export const getStellarReserves=T.jF;export const getStellarSpoke=T.S2;export const getStellarSpokeGraph=T.uS;export const getStellarSpokes=T.u_;export const getStellarUserActivity=T.O5;export const getStellarUserPositions=T.Av;export const mapQuoteResponseToAggregatorSwap=T.LA;export const mapQuoteResponseToStrategyPayload=T.E6;export const mapQuoteResponseToStrategySwap=T.Ds;export const mapSorobanError=T.XV;export const mapStellarPositionActivityType=T.CU;export const prepareStellarBuiltTx=T.Vx;export const prepareStellarTxXdr=T.DL;export const stellarLendingDispatchKey=T.ON;export const stellarLendingRead=T.Hh;export const syntheticEventOrder=T.oV;export const tagStellarInvokedContractError=T.g5;export const toBase64Xdr=T.L;export const toStellarPositionMode=T.Vu;
|