@xoxno/sdk-js 1.0.186 → 1.0.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +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 i,xdr as s}from"@stellar/stellar-sdk";var a={385(a,p,l){l.d(p,{ME:()=>c,nO:()=>y,G_:()=>ue,DU:()=>d,fA:()=>ho,A$:()=>f,J9:()=>b,hS:()=>m,gR:()=>xo,Cg:()=>So,VZ:()=>Go,N0:()=>Vt,B_:()=>re,eX:()=>Ft,z:()=>Oo,xD:()=>j,jR:()=>H,P2:()=>Vo,W6:()=>oe,se:()=>te,yr:()=>Ro,sp:()=>J,$9:()=>He,zw:()=>Fe,h_:()=>Qe,e_:()=>Ke,Tk:()=>je,BA:()=>Xe,SX:()=>Dt,UF:()=>qo,Y5:()=>Z,mE:()=>Y,xG:()=>$t,s9:()=>tt,OL:()=>Ct,k6:()=>xe,dj:()=>ve,kD:()=>Ie,Yf:()=>ke,c5:()=>Ce,N8:()=>he,qU:()=>Re,RZ:()=>Me,ni:()=>qe,hF:()=>Be,Qk:()=>De,Gw:()=>ze,$K:()=>Ne,uj:()=>Te,Od:()=>Se,X7:()=>Ee,Ub:()=>Ve,Dx:()=>Pe,OA:()=>be,$U:()=>me,ob:()=>Ae,cY:()=>fe,$l:()=>ge,K:()=>we,kw:()=>_e,VS:()=>$e,HP:()=>We,YQ:()=>Ge,QY:()=>Le,os:()=>Oe,Ko:()=>Ue,IJ:()=>Yt,nw:()=>Q,Pr:()=>rt,ZE:()=>K,ev:()=>Gt,P8:()=>Qt,aV:()=>jt,p2:()=>Wt,Ww:()=>Ht,sV:()=>Kt,Js:()=>Zt,Dy:()=>Xt,Ni:()=>V,v_:()=>W,qD:()=>ot,qR:()=>et,QJ:()=>zt,bm:()=>Bt,n_:()=>ne,v8:()=>Jt,qM:()=>Nt,gH:()=>ee,O3:()=>X,Gz:()=>F,pr:()=>z,Fm:()=>vo,MB:()=>It,Dn:()=>Lt,pq:()=>Et,ml:()=>Ut,Q3:()=>Rt,wf:()=>Eo,Um:()=>To,xO:()=>xt,Lw:()=>Po,KM:()=>h,mM:()=>mt,iE:()=>Tt,zp:()=>ft,N3:()=>bt,bN:()=>at,QV:()=>v,T_:()=>qt,XI:()=>gt,Lt:()=>_t,KK:()=>pt,yl:()=>st,vc:()=>g,CH:()=>Io,FI:()=>ct,KG:()=>At,nW:()=>yt,jF:()=>dt,S2:()=>ht,uS:()=>wt,u_:()=>lt,O5:()=>St,Av:()=>vt,LA:()=>Lo,E6:()=>Mo,Ds:()=>Uo,XV:()=>jo,CU:()=>wo,Vx:()=>Bo,DL:()=>Co,ON:()=>Ye,Hh:()=>kt,oV:()=>_o,g5:()=>$o,L:()=>Ze,Vu:()=>Do});const d={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},c={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??""},m={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},b={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"},f={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function g(t){const e=d[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 h(t){const e=c[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 v(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 S=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],x=t=>new e(t).toScVal(),q=t=>new n(t).toI128(),T=t=>s.ScVal.scvU32(t),_=t=>new n("string"==typeof t?t:t.toString()).toU64(),w=t=>s.ScVal.scvBool(t),A=t=>s.ScVal.scvString(t),k=t=>s.ScVal.scvSymbol(t),P=()=>s.ScVal.scvVoid(),I=t=>s.ScVal.scvVec(t),E=(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 s.ScVal.scvBytes(r)},R=(t,e)=>null==t?P():e(t),O=(t,e)=>L({asset:x(e),hub_id:T(t)}),M=(t,e,o)=>s.ScVal.scvVec([O(t,e),q(o)]),U=t=>s.ScVal.scvVec(t.map((t=>M(t.hubId,t.asset,t.amount)))),L=t=>{const e=Object.keys(t).sort().map((e=>new s.ScMapEntry({key:k(e),val:t[e]})));return s.ScVal.scvMap(e)},N=t=>{const e=t.paths.map((t=>{const e=t.hops.map((t=>{return L({amount_out:q(t.amountOut),pool:x(t.pool),token_in:x(t.tokenIn),token_out:x(t.tokenOut),venue:(e=t.venue,s.ScVal.scvVec([k(e)]))});var e}));return L({hops:s.ScVal.scvVec(e),split_ppm:T(t.splitPpm)})}));return L({paths:s.ScVal.scvVec(e),referral_id:_(t.referralId??0),token_in:x(t.tokenIn),token_out:x(t.tokenOut),total_min_out:q(t.totalMinOut)})},$=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 s.ScVal.scvBytes(e)},C=()=>s.ScVal.scvBytes(Buffer.alloc(0)),B=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},D=t=>{if("string"==typeof t)return $(B(t));if(t instanceof Uint8Array)return 0===t.length?C():$(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?$(B(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?$(B(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?$(B(t.bytes)):0===t.bytes.length?C():$(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");let o=0;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`);o+=r.splitPpm;for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.amountOut||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!S.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have amountOut, pool, tokenIn, tokenOut, and a valid Soroban venue`)}if(1e6!==o)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` must sum to 1_000_000, got ${o}`);return e})(t),s.ScVal.scvBytes(Buffer.from(N(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},G=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=Buffer.from(e,"hex");return s.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return s.ScVal.scvBytes(Buffer.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function z(e,n,i){const s=e.controllerAddress??g(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:f[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function V(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return z(t,"supply",[x(t.caller),_(o),T(r),U([...e.assets])])}function W(t,e){return V(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function j(t,e){return z(t,"borrow",[x(t.caller),_(e.accountNonce),U([...e.borrows]),R(e.to,x)])}function H(t,e){return j(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function X(t,e){return z(t,"withdraw",[x(t.caller),_(e.accountNonce),U([...e.withdrawals]),R(e.to,x)])}function F(t,e){return X(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Q(t,e){return z(t,"repay",[x(t.caller),_(e.accountNonce),U([...e.payments])])}function K(t,e){return Q(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function Z(t,e){return z(t,"liquidate",[x(t.caller),_(e.accountNonce),U([...e.debtPayments])])}function J(t,e){return z(t,"flash_loan",[x(t.caller),O(e.hubId,e.asset),q(e.amount),x(e.receiver),G(e.data)])}function Y(t,e){return z(t,"migrate_from_blend",[x(t.caller),_(e.accountId),T(e.spokeId),T(e.hubId),x(e.blendPool),I(e.collateralTokens.map(x)),I(e.supplyTokens.map(x)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),s.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,s.ScVal.scvVec([x(e),q(o)]);var e,o}))))]);var o}function tt(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return z(t,"multiply",[x(t.caller),_(o),T(r),O(e.collateral.hubId,e.collateral.asset),q(e.debtToFlashLoan),O(e.debt.hubId,e.debt.asset),T(e.mode),D(e.steps),R(e.initialPayment,(t=>M(t.hubId,t.asset,t.amount))),R(e.convertSwap,D)])}function et(t,e){return z(t,"swap_debt",[x(t.caller),_(e.accountNonce),O(e.existingDebt.hubId,e.existingDebt.asset),q(e.newDebtAmount),O(e.newDebt.hubId,e.newDebt.asset),D(e.steps)])}function ot(t,e){return z(t,"swap_collateral",[x(t.caller),_(e.accountNonce),O(e.current.hubId,e.current.asset),q(e.fromAmount),O(e.newCollateral.hubId,e.newCollateral.asset),D(e.steps)])}function rt(t,e){return z(t,"repay_debt_with_collateral",[x(t.caller),_(e.accountNonce),O(e.collateral.hubId,e.collateral.asset),q(e.collateralAmount),O(e.debt.hubId,e.debt.asset),D(e.steps),w(e.closePosition)])}const nt="/stellar-lending",ut=25,it=encodeURIComponent,st=(t,e)=>t.fetchWithTimeout(`${nt}/context`,e),at=(t,e)=>t.fetchWithTimeout(`${nt}/assets`,e),pt=(t,e)=>t.fetchWithTimeout(`${nt}/hubs`,e),lt=(t,e)=>t.fetchWithTimeout(`${nt}/spokes`,e),dt=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${nt}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},ct=(t,e,o,r,n)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}`,n),yt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}/holders`,{...u,params:{side:n}}),mt=(t,e,o)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}`,o),bt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/page`,{...r,params:{...o}}),ft=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/markets`,{...r,params:{side:o}}),gt=(t,e,o)=>t.fetchWithTimeout(`${nt}/hubs/${e}`,o),ht=(t,e,o)=>t.fetchWithTimeout(`${nt}/spokes/${e}`,o),vt=(t,e,o)=>t.fetchWithTimeout(`${nt}/users/${it(e)}/positions`,o),St=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${nt}/users/${it(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},xt=(t,e,o)=>t.fetchWithTimeout(`${nt}/accounts/${it(e)}/positions`,o),qt=(t,e={},o)=>{const{top:r=ut,continuationToken:n}=e;return t.fetchWithTimeout(`${nt}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},Tt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/graph`,{...r,params:{...o}}),_t=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/hubs/${e}/graph`,{...r,params:{...o}}),wt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/spokes/${e}/graph`,{...r,params:{...o}}),At=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}/graph`,{...u,params:{...n}}),kt=t=>({context:e=>st(t,e),assets:e=>at(t,e),hubs:e=>pt(t,e),spokes:e=>lt(t,e),reserves:(e,o)=>{return void 0===(r=e)||"hubId"in r||"spokeId"in r||"asset"in r?dt(t,e,o):dt(t,{},e);var r},reserve:(e,o,r,n)=>ct(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>yt(t,e,o,r,n,u),asset:(e,o)=>mt(t,e,o),assetMarkets:(e,o,r)=>ft(t,e,o,r),hub:(e,o)=>gt(t,e,o),spoke:(e,o)=>ht(t,e,o),userPositions:(e,o)=>vt(t,e,o),userActivity:(e,o,r)=>St(t,e,o,r),accountPositions:(e,o)=>xt(t,e,o),governanceProposals:(e,o)=>qt(t,e,o),assetGraph:(e,o,r)=>Tt(t,e,o,r),hubGraph:(e,o,r)=>_t(t,e,o,r),spokeGraph:(e,o,r)=>wt(t,e,o,r),reserveGraph:(e,o,r,n,u)=>At(t,e,o,r,n,u)}),Pt={Single:0,PrimaryWithAnchor:1},It=t=>L({base_borrow_rate:q(t.baseBorrowRateRay),max_borrow_rate:q(t.maxBorrowRateRay),max_utilization:q(t.maxUtilizationRay),mid_utilization:q(t.midUtilizationRay),optimal_utilization:q(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:q(t.slope1Ray),slope2:q(t.slope2Ray),slope3:q(t.slope3Ray)}),Et=t=>L({asset_decimals:T(t.assetDecimals),asset_id:x(t.assetId),base_borrow_rate:q(t.baseBorrowRateRay),flashloan_fee:T(t.flashloanFeeBps),is_flashloanable:w(t.isFlashloanable),max_borrow_rate:q(t.maxBorrowRateRay),max_utilization:q(t.maxUtilizationRay),mid_utilization:q(t.midUtilizationRay),optimal_utilization:q(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:q(t.slope1Ray),slope2:q(t.slope2Ray),slope3:q(t.slope3Ray)}),Rt=t=>L({max_borrow_positions:T(t.maxBorrowPositions),max_supply_positions:T(t.maxSupplyPositions)}),Ot=t=>{const e=t.kind;switch(e){case"Stellar":return I([k("Stellar"),x(t.value)]);case"Symbol":return I([k("Symbol"),k(t.value)]);case"String":return I([k("String"),A(t.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${e}"`)}},Mt=(t,e)=>{if("Twap"===t){if("number"!=typeof e)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return I([k("Twap"),T(e)])}return I([k("Spot")])},Ut=t=>{const e=t.provider;if("ReflectorSep40"===e){if(!t.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return I([k("Reflector"),L({asset:Ot(t.asset),contract:x(t.contract),read_mode:Mt(t.readMode,t.twapRecords)})])}if("RedStonePriceFeed"===e){if("string"!=typeof t.feedId)throw new Error("Stellar builder: RedStone oracle source requires `feedId`");if("number"!=typeof t.maxStaleSeconds)throw new Error("Stellar builder: RedStone oracle source requires `maxStaleSeconds`");return I([k("RedStone"),L({contract:x(t.contract),feed_id:A(t.feedId),max_stale_seconds:_(t.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${e}"`)},Lt=t=>{const e=Pt[t.strategy];if(void 0===e)throw new Error(`Stellar builder: unknown oracle strategy "${t.strategy}"`);return L({anchor:(o=t.anchor,I(null==o?[k("None")]:[k("Some"),Ut(o)])),max_price_stale_seconds:_(t.maxPriceStaleSeconds),max_sanity_price_wad:q(t.maxSanityPriceWad),min_sanity_price_wad:q(t.minSanityPriceWad),primary:Ut(t.primary),strategy:T(e),tolerance_bps:T(t.toleranceBps)});var o};function Nt(t,e){return z(t,"upgrade",[E(e.wasmHash)])}function $t(t,e){return z(t,"migrate",[T(e.newVersion)])}function Ct(t){return z(t,"pause",[])}function Bt(t){return z(t,"unpause",[])}function Dt(t,e){return z(t,"grant_role",[x(e.account),k(e.role)])}function Gt(t,e){return z(t,"revoke_role",[x(e.account),k(e.role)])}function zt(t,e){return z(t,"transfer_ownership",[x(e.newOwner),T(e.liveUntilLedger)])}function Vt(t){return z(t,"accept_ownership",[])}function Wt(t,e){return z(t,"set_aggregator",[x(e.aggregator)])}function jt(t,e){return z(t,"set_accumulator",[x(e.accumulator)])}function Ht(t,e){return z(t,"set_liquidity_pool_template",[E(e.wasmHash)])}function Xt(t,e){return z(t,"set_position_limits",[Rt(e)])}function Ft(t,e){return z(t,"approve_token",[x(e.token)])}function Qt(t,e){return z(t,"revoke_token",[x(e.token)])}function Kt(t,e){return z(t,"set_market_oracle_config",[O(e.hubId,e.asset),Lt(e.config)])}function Zt(t,e){return z(t,"set_oracle_tolerance",[x(e.asset),L({lower_ratio_bps:T(e.lowerRatioBps),upper_ratio_bps:T(e.upperRatioBps)})])}function Jt(t,e){return z(t,"update_indexes",[x(t.caller),I(e.assets.map((t=>O(t.hubId,t.asset))))])}function Yt(t,e){return z(t,"renew_account",[x(t.caller),_(e.accountNonce)])}function te(t,e){return z(t,"create_liquidity_pool",[T(e.hubId),x(e.asset),Et(e.params)])}function ee(t,e){return z(t,"upgrade_liquidity_pool_params",[O(e.hubId,e.asset),It(e.params)])}function oe(t,e){return z(t,"claim_revenue",[x(t.caller),I(e.assets.map((t=>O(t.hubId,t.asset))))])}function re(t,e){return z(t,"add_rewards",[x(t.caller),U(e.rewards)])}function ne(t,e){return z(t,"update_account_threshold",[x(t.caller),w(e.hasRisks),I(e.accountNonces.map((t=>_(t))))])}const ue="00".repeat(32),ie=t=>{if("string"==typeof t)return E(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 s.ScVal.scvBytes(e)},se=(t,...e)=>I([k(t),...e]),ae=t=>L({new_owner:x(t.newOwner),live_until_ledger:T(t.liveUntilLedger)}),pe=t=>L({asset:x(t.asset),bonus:T(t.bonus),borrow_cap:q(t.borrowCap),can_borrow:w(t.canBorrow),can_collateral:w(t.canCollateral),frozen:w(t.frozen),hub_id:T(t.hubId),paused:w(t.paused),liquidation_fees:T(t.liquidationFees),ltv:T(t.ltv),oracle_override:I([k("None")]),spoke_id:T(t.spokeId),supply_cap:q(t.supplyCap),threshold:T(t.threshold)}),le=t=>L({account:x(t.account),role:k(t.role)});function de(e,n,i){const s=e.governanceAddress??v(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:f[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ce=(t,e,o)=>de(t,"propose",[x(t.caller),e,ie(o)]),ye=(t,e,o)=>de(t,"execute_self",[P(),e,ie(o)]);function me(t,e,o){return ce(t,se("SetAggregator",x(e.aggregator)),o)}function be(t,e,o){return ce(t,se("SetAccumulator",x(e.accumulator)),o)}function fe(t,e,o){return ce(t,se("SetLiquidityPoolTemplate",E(e.wasmHash)),o)}function ge(t,e,o){return ce(t,se("SetPositionLimits",Rt(e)),o)}function he(t,e){return ce(t,se("CreateHub"),e)}function ve(t,e){return ce(t,se("AddSpoke"),e)}function Se(t,e,o){return ce(t,se("RemoveSpoke",T(e.spokeId)),o)}function xe(t,e,o){return ce(t,se("AddAssetToSpoke",pe(e)),o)}function qe(t,e,o){return ce(t,se("EditAssetInSpoke",pe(e)),o)}function Te(t,e,o){return ce(t,se("RemoveAssetFromSpoke",L({hub_asset:O((r=e).hubId,r.asset),spoke_id:T(r.spokeId)})),o);var r}function _e(t,e,o){return ce(t,se("SetSpokeLiquidationCurve",L({hf_for_max_bonus_wad:q((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:T(r.liquidationBonusFactorBps),spoke_id:T(r.spokeId),target_hf_wad:q(r.targetHfWad)})),o);var r}function we(t,e,o){return ce(t,se("SetPositionManager",x(e.manager),w(e.isActive)),o)}function Ae(t,e,o){return ce(t,se("SetMinBorrowCollateralUsd",q(e.floorWad)),o)}function ke(t,e,o){return ce(t,se("ApproveToken",x(e.token)),o)}function Pe(t,e,o){return ce(t,se("RevokeToken",x(e.token)),o)}function Ie(t,e,o){return ce(t,se("ApproveBlendPool",x(e.pool)),o)}function Ee(t,e,o){return ce(t,se("RevokeBlendPool",x(e.pool)),o)}function Re(t,e,o){return ce(t,se("CreateLiquidityPool",L({asset:x((r=e).asset),hub_id:T(r.hubId),params:Et(r.params)})),o);var r}function Oe(t,e,o){return ce(t,se("UpgradeLiquidityPoolParams",L({hub_asset:O((r=e).hubId,r.asset),params:It(r.params)})),o);var r}function Me(t,e){return ce(t,se("DeployPool"),e)}function Ue(t,e,o){return ce(t,se("UpgradePool",E(e.wasmHash)),o)}function Le(t,e,o){return ce(t,se("UpgradeController",E(e.wasmHash)),o)}function Ne(t,e,o){return ce(t,se("MigrateController",T(e.newVersion)),o)}function $e(t,e,o){return ce(t,se("TransferCtrlOwnership",ae(e)),o)}function Ce(t,e,o){return ce(t,se("ConfigureMarketOracle",L({cfg:Lt((r=e).config),hub_asset:O(r.hubId,r.asset)})),o);var r}function Be(t,e,o){return ce(t,se("EditOracleTolerance",L({asset:x((r=e).asset),tolerance:T(r.tolerance)})),o);var r}function De(t,e,o){return ce(t,se("UpgradeGov",E(e.wasmHash)),o)}function Ge(t,e,o){return ce(t,se("UpdateGovDelay",T(e.newDelay)),o)}function ze(t,e,o){return ce(t,se("GrantGovRole",le(e)),o)}function Ve(t,e,o){return ce(t,se("RevokeGovRole",le(e)),o)}function We(t,e,o){return ce(t,se("TransferGovOwnership",ae(e)),o)}function je(t,e){const o=I(e.argsXdr.map((t=>s.ScVal.fromXDR(t,"base64")))),r=ie(e.predecessor??ue);return de(t,"execute",[P(),x(e.target),k(e.functionName),o,r,ie(e.salt)])}function He(t,e,o){return ye(t,se("UpgradeGov",E(e.wasmHash)),o)}function Xe(t,e,o){return ye(t,se("UpdateGovDelay",T(e.newDelay)),o)}function Fe(t,e,o){return ye(t,se("GrantGovRole",le(e)),o)}function Qe(t,e,o){return ye(t,se("RevokeGovRole",le(e)),o)}function Ke(t,e,o){return ye(t,se("TransferGovOwnership",ae(e)),o)}const Ze=t=>t.toXDR("base64"),Je=t=>s.ScVal.fromXDR(t,"base64"),Ye=t=>t.map((t=>String(i(Je(t))))).join(":"),to=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),eo=t=>Number(t),oo=t=>String(t),ro=t=>null==t?void 0:to(t),no=t=>null==t?void 0:oo(t),uo=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),io=["None","Multiply","Long","Short"],so=["Single","PrimaryWithAnchor"],ao=["ReflectorSep40","RedStonePriceFeed"],po=["Spot","Twap"],lo=["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"],co=t=>Array.isArray(t)?t:[],yo=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],lo[eo(r)]??to(r)),positionType:e,hubId:eo(t[1]),asset:oo(t[2]),scaledAmountRay:to(t[3]),indexRay:to(t[4]),amount:to(t[5]),liquidationThresholdBps:o?void 0:eo(t[6]),liquidationBonusBps:o?void 0:eo(t[7]),loanToValueBps:o?void 0:eo(t[8]),liquidationFeesBps:o?void 0:eo(t[9])};var r},mo=t=>{return{owner:oo(t[0]),spokeId:eo(t[1]),mode:(e=t[2],io[eo(e)]??"None")};var e},bo=(t,e)=>{const o=po[eo(t[`${e}_read_mode`])]??"Spot",r=t[`${e}_asset`],n=t[`${e}_symbol`],u=null!=r?{kind:"Stellar",value:oo(r)}:null!=n?{kind:"Symbol",value:oo(n)}:void 0;return{provider:ao[eo(t[`${e}_provider`])]??"ReflectorSep40",contractAddress:oo(t[`${e}_contract`]),asset:u,feedId:no(t[`${e}_feed_id`]),readMode:o,twapRecords:"Twap"===o?eo(t[`${e}_twap_records`]):void 0,decimals:eo(t[`${e}_decimals`]),resolutionSeconds:eo(t[`${e}_resolution_seconds`]),maxStaleSeconds:eo(t[`${e}_max_stale_seconds`])}},fo=t=>{const e=null!==t.anchor_provider&&void 0!==t.anchor_provider;return{baseTokenId:oo(t.base_token_id),quoteTokenId:oo(t.quote_token_id),tolerance:{upperRatio:eo(t.upper_ratio_bps??t.tolerance?.upper_ratio_bps),lowerRatio:eo(t.lower_ratio_bps??t.tolerance?.lower_ratio_bps)},assetDecimals:eo(t.asset_decimals),maxPriceStaleSeconds:eo(t.max_price_stale_seconds),strategy:so[eo(t.strategy)]??"Single",primary:bo(t,"primary"),anchor:e?bo(t,"anchor"):void 0,primaryQuoteToken:no(t.primary_quote_token),anchorQuoteToken:no(t.anchor_quote_token),minSanityPriceWad:ro(t.min_sanity_price_wad),maxSanityPriceWad:ro(t.max_sanity_price_wad)}},go={"market:create":t=>({topic:"market:create",data:{hubId:eo(t.hub_id),baseAsset:oo(t.base_asset),maxBorrowRate:to(t.max_borrow_rate),baseBorrowRate:to(t.base_borrow_rate),slope1:to(t.slope1),slope2:to(t.slope2),slope3:to(t.slope3),midUtilization:to(t.mid_utilization),optimalUtilization:to(t.optimal_utilization),maxUtilization:to(t.max_utilization),reserveFactor:eo(t.reserve_factor),marketAddress:oo(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:oo(t.asset),maxBorrowRateRay:to(t.max_borrow_rate),baseBorrowRateRay:to(t.base_borrow_rate),slope1Ray:to(t.slope1),slope2Ray:to(t.slope2),slope3Ray:to(t.slope3),midUtilizationRay:to(t.mid_utilization),optimalUtilizationRay:to(t.optimal_utilization),maxUtilizationRay:to(t.max_utilization),reserveFactorBps:eo(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:co(t).map((t=>{return e=co(t),{hubId:eo(e[0]),asset:oo(e[1]),timestamp:eo(e[2]),supplyIndexRay:to(e[3]),borrowIndexRay:to(e[4]),cash:to(e[5]),suppliedRay:to(e[6]),borrowedRay:to(e[7]),revenueRay:to(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:co(t).map((t=>{const e=t;return{hubId:eo(e.hub_id),asset:oo(e.asset),params:(o=e.params,{maxBorrowRateRay:to(o.max_borrow_rate),baseBorrowRateRay:to(o.base_borrow_rate),slope1Ray:to(o.slope1),slope2Ray:to(o.slope2),slope3Ray:to(o.slope3),midUtilizationRay:to(o.mid_utilization),optimalUtilizationRay:to(o.optimal_utilization),maxUtilizationRay:to(o.max_utilization),reserveFactorBps:eo(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:eo(o.flashloan_fee),assetId:oo(o.asset_id),assetDecimals:eo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=co(t);return{topic:"position:batch_update",data:{accountId:to(e[0]),accountAttributes:mo(co(e[1])),updates:[...co(e[2]).map((t=>yo(co(t),"Deposit"))),...co(e[3]).map((t=>yo(co(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:eo(t.hub_id),asset:oo(t.asset),receiver:oo(t.receiver),caller:oo(t.caller),amount:to(t.amount),fee:to(t.fee)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:oo(t.asset),oracle:fo(t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:oo(t.liquidator),accountId:to(t.account_id),repaidUsdWad:to(t.repaid_usd_wad),bonusBps:to(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:to(t.account_id),totalBorrowUsdWad:to(t.total_borrow_usd_wad),totalCollateralUsdWad:to(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:oo(t.token),amount:to(t.amount),usdValueWad:to(t.usd_value_wad),accountId:to(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:eo(t.hub_id),asset:oo(t.asset),amount:to(t.amount),fee:to(t.fee),amountSent:to(t.amount_sent)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:uo(t.wasm_hash),approved:Boolean(t.approved)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:oo(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:oo(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:eo(t.max_supply_positions),maxBorrowPositions:eo(t.max_borrow_positions)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:oo(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:eo(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:to(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:to(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:eo(e.liquidation_bonus_factor_bps)}}}},ho=Object.freeze(Object.keys(go));function vo(t,e){const o=Ye(t),r=go[o];return r?r(i(Je(e))):null}const So="XLENDXLM-a7c9f3",xo=1e4;function qo(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${So}-${o}`}function To(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function _o(t,e=0){return t*xo+e}function wo(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Ao=(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??b[t.network];async function Po(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=Ao(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 Io(t){const e=Ao(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 Eo=t=>N(t).toXDR("base64");function Ro(e,n){const i=e.routerAddress??h(e.network),s=new r(i),a=new t(e.caller,e.sourceSequence),p=D(((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:f[e.network]}).addOperation(s.call("execute_strategy",x(e.caller),q(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Oo(t,e){return Ro(t,e)}function Mo(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(No),splitPpm:t.splitPpm}))):[{hops:t.hops.map(No),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Uo(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:Mo(t,e)}const Lo=Mo,No=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function $o(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Co(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw $o(o.invokedContractId,t);throw t}}async function Bo(t,e,o){return Co(t,e.xdr,o)}function Do(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 Go(t,e){return new Uint8Array(0)}const zo=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 Vo(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",s.ScVal.scvBytes(zo(e.message)),s.ScVal.scvBytes(zo(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:f[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const Wo={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:"InvalidPoolTemplate",message:"The liquidity pool template hash is 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."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetsLimitReached",message:"This spoke has reached its asset limit."},314:{name:"SpokeCapBelowUsage",message:"The new cap is below current usage on this spoke asset."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},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 jo(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=Wo[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 d="https://api.xoxno.com",c="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",m="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var b;!function(t){t.MAINNET="1",t.DEVNET="D"}(b||(b={}));class f{apiUrl;chain;init;config;constructor({chain:t=b.MAINNET,apiUrl:e=d,...o}={}){this.apiUrl=e??{[b.MAINNET]:d,[b.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==b.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:c,DR_SC:y,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:c,DR_SC:y,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:u,...i}=this.init,{next:s,cache:a,debug:p,headers:l,method:d="GET",...c}=o,y=l?.Authorization,m="Bearer undefined"===y?void 0:y,b={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===d?{}:{"Content-Type":"application/json"},...m?{Authorization:m}:{}},f=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),g=`${this.apiUrl}${t}${f.length?`?${f}`:""}`,{revalidate:h,...v}=r??{},{revalidate:S,...x}=s??{},q="GET"!==d||m?void 0:S??h,T="GET"!==d||m||q?void 0:a??n,_={...i,...c,method:d,...Object.keys(b).length?{headers:b}:{},cache:T,next:{...v,...x,revalidate:q}};(p??u)&&console.debug("SDK fetch: ",g,_);const w=await fetch(g,_).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${g}: ${t.message}`),{cause:t});throw t})),A=await w.text();if(!w.ok){let t;try{t=JSON.parse(A)}catch{t={message:A}}const e=[g,w.status,w.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const g=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},h=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 v extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class S extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const x=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)),q={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/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:{}},"/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/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:{}}}},T=["PATCH","POST","DELETE","PUT"];var _=l(385);const w=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function A(t,e,o,r){const{input:n,output:u,...i}=e,s=async(e={})=>{const n={...o,...e},u=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),i=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),s=Object.fromEntries(Object.entries(n).filter((([t])=>!i.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in s,p=/:collection[^A-Z]/.test(t)||"collection"in s;if(a){const t=n.address;if(!x(t))throw new S(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!g(t))):!g(t))throw new v(t)}const l=Object.fromEntries(Object.entries(s).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:d,auth:c,method:y,headers:m,cache:b,next:f,debug:h,continuationToken:q,...T}=l,_=c?`Bearer ${c}`:void 0,w={...m,..._?{Authorization:_}:{},...q?{"X-Continuation-Token":String(q)}:{}},A={...f,tags:[...f?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:T,body:d,headers:w,cache:b,debug:h,...A?{next:A}:{}})},a=(t={})=>s(t);for(const t of Object.keys(i))T.includes(t)&&(a[t]=e=>s({...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(q)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=w(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=w(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,i=Object.keys(e.params).length;let s;if(1===n&&u+i>0){const{rawPath:o,def:n}=e.leaves[0];s=A(o,n,r,t)}else{s={};for(const{rawPath:o,def:n}of e.leaves)s[w(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===s[t]?s[t]=u:"function"==typeof s[t]?Object.assign(s[t],u):"function"==typeof u?(Object.assign(u,s[t]),s[t]=u):Object.assign(s[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(s[t]){const o=s[t];s[t]=t=>({...o(t),...e(t)})}else s[t]=e}return s};return o(e,{})}export{b as Chain,f as XOXNOClient,k as buildSdk,g as isValidCollectionTicker,h as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=_.ME;export const STELLAR_GOVERNANCE=_.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=_.G_;export const STELLAR_LENDING_CONTROLLER=_.DU;export const STELLAR_LENDING_TOPICS=_.fA;export const STELLAR_NETWORK_PASSPHRASE=_.A$;export const STELLAR_QUOTE_URL=_.J9;export const STELLAR_SOROBAN_RPC_URL=_.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=_.gR;export const XOXNO_LENDING_STELLAR_TICKER=_.Cg;export const buildSameTokenRepaySwapSteps=_.VZ;export const buildStellarAcceptOwnershipTx=_.N0;export const buildStellarAddRewardsTx=_.B_;export const buildStellarApproveTokenTx=_.eX;export const buildStellarBatchSwapTx=_.z;export const buildStellarBorrowBatchTx=_.xD;export const buildStellarBorrowTx=_.jR;export const buildStellarCctpForwardTx=_.P2;export const buildStellarClaimRevenueTx=_.W6;export const buildStellarCreateLiquidityPoolTx=_.se;export const buildStellarExecuteStrategyTx=_.yr;export const buildStellarFlashLoanTx=_.sp;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=_.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=_.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=_.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=_.e_;export const buildStellarGovernanceExecuteTx=_.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=_.BA;export const buildStellarGrantRoleTx=_.SX;export const buildStellarLendingIdentifier=_.UF;export const buildStellarLiquidateTx=_.Y5;export const buildStellarMigrateFromBlendTx=_.mE;export const buildStellarMigrateTx=_.xG;export const buildStellarMultiplyTx=_.s9;export const buildStellarPauseTx=_.OL;export const buildStellarProposeAddAssetToSpokeTx=_.k6;export const buildStellarProposeAddSpokeTx=_.dj;export const buildStellarProposeApproveBlendPoolTx=_.kD;export const buildStellarProposeApproveTokenTx=_.Yf;export const buildStellarProposeConfigureMarketOracleTx=_.c5;export const buildStellarProposeCreateHubTx=_.N8;export const buildStellarProposeCreateLiquidityPoolTx=_.qU;export const buildStellarProposeDeployPoolTx=_.RZ;export const buildStellarProposeEditAssetInSpokeTx=_.ni;export const buildStellarProposeEditOracleToleranceTx=_.hF;export const buildStellarProposeGovernanceUpgradeTx=_.Qk;export const buildStellarProposeGrantGovernanceRoleTx=_.Gw;export const buildStellarProposeMigrateControllerTx=_.$K;export const buildStellarProposeRemoveAssetFromSpokeTx=_.uj;export const buildStellarProposeRemoveSpokeTx=_.Od;export const buildStellarProposeRevokeBlendPoolTx=_.X7;export const buildStellarProposeRevokeGovernanceRoleTx=_.Ub;export const buildStellarProposeRevokeTokenTx=_.Dx;export const buildStellarProposeSetAccumulatorTx=_.OA;export const buildStellarProposeSetAggregatorTx=_.$U;export const buildStellarProposeSetMinBorrowCollatTx=_.ob;export const buildStellarProposeSetPoolTemplateTx=_.cY;export const buildStellarProposeSetPositionLimitsTx=_.$l;export const buildStellarProposeSetPositionManagerTx=_.K;export const buildStellarProposeSetSpokeLiquidationCurveTx=_.kw;export const buildStellarProposeTransferCtrlOwnershipTx=_.VS;export const buildStellarProposeTransferGovOwnTx=_.HP;export const buildStellarProposeUpdateDelayTx=_.YQ;export const buildStellarProposeUpgradeControllerTx=_.QY;export const buildStellarProposeUpgradePoolParamsTx=_.os;export const buildStellarProposeUpgradePoolTx=_.Ko;export const buildStellarRenewAccountTx=_.IJ;export const buildStellarRepayBatchTx=_.nw;export const buildStellarRepayDebtWithCollateralTx=_.Pr;export const buildStellarRepayTx=_.ZE;export const buildStellarRevokeRoleTx=_.ev;export const buildStellarRevokeTokenTx=_.P8;export const buildStellarSetAccumulatorTx=_.aV;export const buildStellarSetAggregatorTx=_.p2;export const buildStellarSetLiquidityPoolTemplateTx=_.Ww;export const buildStellarSetMarketOracleConfigTx=_.sV;export const buildStellarSetOracleToleranceTx=_.Js;export const buildStellarSetPositionLimitsTx=_.Dy;export const buildStellarSupplyBatchTx=_.Ni;export const buildStellarSupplyTx=_.v_;export const buildStellarSwapCollateralTx=_.qD;export const buildStellarSwapDebtTx=_.qR;export const buildStellarTransferOwnershipTx=_.QJ;export const buildStellarUnpauseTx=_.bm;export const buildStellarUpdateAccountThresholdTx=_.n_;export const buildStellarUpdateIndexesTx=_.v8;export const buildStellarUpgradeControllerTx=_.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=_.gH;export const buildStellarWithdrawBatchTx=_.O3;export const buildStellarWithdrawTx=_.Gz;export const buildTx=_.pr;export const decodeStellarLendingEvent=_.Fm;export const encodeInterestRateModel=_.MB;export const encodeMarketOracleConfigInput=_.Dn;export const encodeMarketParamsRaw=_.pq;export const encodeOracleSourceConfigInput=_.ml;export const encodePositionLimits=_.Q3;export const encodeStrategyPayloadToRouteXdr=_.wf;export const extractEventOrder=_.Um;export const getStellarAccountPositions=_.xO;export const getStellarAggregatorQuote=_.Lw;export const getStellarAggregatorRouter=_.KM;export const getStellarAsset=_.mM;export const getStellarAssetGraph=_.iE;export const getStellarAssetMarkets=_.zp;export const getStellarAssetPage=_.N3;export const getStellarAssets=_.bN;export const getStellarGovernance=_.QV;export const getStellarGovernanceProposals=_.T_;export const getStellarHub=_.XI;export const getStellarHubGraph=_.Lt;export const getStellarHubs=_.KK;export const getStellarLendingContext=_.yl;export const getStellarLendingController=_.vc;export const getStellarQuoteTokens=_.CH;export const getStellarReserve=_.FI;export const getStellarReserveGraph=_.KG;export const getStellarReserveHolders=_.nW;export const getStellarReserves=_.jF;export const getStellarSpoke=_.S2;export const getStellarSpokeGraph=_.uS;export const getStellarSpokes=_.u_;export const getStellarUserActivity=_.O5;export const getStellarUserPositions=_.Av;export const mapQuoteResponseToAggregatorSwap=_.LA;export const mapQuoteResponseToStrategyPayload=_.E6;export const mapQuoteResponseToStrategySwap=_.Ds;export const mapSorobanError=_.XV;export const mapStellarPositionActivityType=_.CU;export const prepareStellarBuiltTx=_.Vx;export const prepareStellarTxXdr=_.DL;export const stellarLendingDispatchKey=_.ON;export const stellarLendingRead=_.Hh;export const syntheticEventOrder=_.oV;export const tagStellarInvokedContractError=_.g5;export const toBase64Xdr=_.L;export const toStellarPositionMode=_.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 i,xdr as s}from"@stellar/stellar-sdk";var a={385(a,p,l){l.d(p,{ME:()=>c,nO:()=>y,G_:()=>ie,DU:()=>d,fA:()=>vo,A$:()=>f,J9:()=>b,hS:()=>m,gR:()=>qo,Cg:()=>xo,VZ:()=>zo,N0:()=>Wt,B_:()=>ne,eX:()=>Qt,z:()=>Mo,xD:()=>j,jR:()=>H,P2:()=>Wo,W6:()=>re,se:()=>ee,yr:()=>Oo,sp:()=>J,$9:()=>Xe,zw:()=>Qe,h_:()=>Ke,e_:()=>Ze,Tk:()=>He,BA:()=>Fe,SX:()=>Gt,UF:()=>To,Y5:()=>Z,mE:()=>Y,xG:()=>Ct,s9:()=>tt,OL:()=>Bt,k6:()=>qe,dj:()=>Se,kD:()=>Ee,Yf:()=>Pe,c5:()=>Be,N8:()=>ve,qU:()=>Oe,RZ:()=>Ue,ni:()=>Te,hF:()=>De,Qk:()=>Ge,Gw:()=>Ve,$K:()=>Ne,uj:()=>_e,Od:()=>xe,X7:()=>Re,Ub:()=>We,Dx:()=>Ie,OA:()=>fe,$U:()=>be,ob:()=>ke,cY:()=>ge,$l:()=>he,K:()=>Ae,kw:()=>we,VS:()=>Ce,HP:()=>je,YQ:()=>ze,QY:()=>$e,os:()=>Me,Ko:()=>Le,IJ:()=>te,nw:()=>Q,Pr:()=>rt,ZE:()=>K,ev:()=>zt,P8:()=>Kt,aV:()=>Ht,p2:()=>jt,Ww:()=>Xt,sV:()=>Zt,Js:()=>Jt,Dy:()=>Ft,Ni:()=>V,v_:()=>W,qD:()=>ot,qR:()=>et,QJ:()=>Vt,bm:()=>Dt,n_:()=>ue,v8:()=>Yt,qM:()=>Nt,gH:()=>oe,O3:()=>X,Gz:()=>F,pr:()=>z,Fm:()=>So,MB:()=>Et,Dn:()=>$t,pq:()=>Rt,ml:()=>Lt,Q3:()=>Ot,wf:()=>Ro,Um:()=>_o,xO:()=>xt,Lw:()=>Io,KM:()=>h,mM:()=>mt,iE:()=>Tt,zp:()=>ft,N3:()=>bt,bN:()=>at,QV:()=>v,T_:()=>qt,XI:()=>gt,Lt:()=>_t,KK:()=>pt,yl:()=>st,vc:()=>g,CH:()=>Eo,FI:()=>ct,KG:()=>At,nW:()=>yt,jF:()=>dt,S2:()=>ht,uS:()=>wt,u_:()=>lt,O5:()=>St,Av:()=>vt,LA:()=>$o,E6:()=>Uo,Ds:()=>Lo,XV:()=>Ho,CU:()=>Ao,Vx:()=>Do,DL:()=>Bo,ON:()=>to,Hh:()=>kt,oV:()=>wo,g5:()=>Co,L:()=>Je,Vu:()=>Go});const d={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},c={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??""},m={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},b={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"},f={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function g(t){const e=d[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 h(t){const e=c[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 v(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 S=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],x=t=>new e(t).toScVal(),q=t=>new n(t).toI128(),T=t=>s.ScVal.scvU32(t),_=t=>new n("string"==typeof t?t:t.toString()).toU64(),w=t=>s.ScVal.scvBool(t),A=t=>s.ScVal.scvString(t),k=t=>s.ScVal.scvSymbol(t),P=()=>s.ScVal.scvVoid(),I=t=>s.ScVal.scvVec(t),E=(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 s.ScVal.scvBytes(r)},R=(t,e)=>null==t?P():e(t),O=(t,e)=>L({asset:x(e),hub_id:T(t)}),M=(t,e,o)=>s.ScVal.scvVec([O(t,e),q(o)]),U=t=>s.ScVal.scvVec(t.map((t=>M(t.hubId,t.asset,t.amount)))),L=t=>{const e=Object.keys(t).sort().map((e=>new s.ScMapEntry({key:k(e),val:t[e]})));return s.ScVal.scvMap(e)},$=t=>{const e=t.paths.map((t=>{const e=t.hops.map((t=>{return L({amount_out:q(t.amountOut),pool:x(t.pool),token_in:x(t.tokenIn),token_out:x(t.tokenOut),venue:(e=t.venue,s.ScVal.scvVec([k(e)]))});var e}));return L({hops:s.ScVal.scvVec(e),split_ppm:T(t.splitPpm)})}));return L({paths:s.ScVal.scvVec(e),referral_id:_(t.referralId??0),token_in:x(t.tokenIn),token_out:x(t.tokenOut),total_min_out:q(t.totalMinOut)})},N=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 s.ScVal.scvBytes(e)},C=()=>s.ScVal.scvBytes(Buffer.alloc(0)),B=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},D=t=>{if("string"==typeof t)return N(B(t));if(t instanceof Uint8Array)return 0===t.length?C():N(t);if(t&&"object"==typeof t)return"routeXdr"in(o=t)&&"string"==typeof o.routeXdr?N(B(t.routeXdr)):(t=>"swapXdr"in t&&"string"==typeof t.swapXdr)(t)?N(B(t.swapXdr)):(t=>"bytes"in t&&("string"==typeof t.bytes||t.bytes instanceof Uint8Array))(t)?"string"==typeof t.bytes?N(B(t.bytes)):0===t.bytes.length?C():N(t.bytes):(e=(t=>{if(!t||"object"!=typeof t)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const e=t;if(!Array.isArray(e.paths)||0===e.paths.length)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");let o=0;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`);o+=r.splitPpm;for(const[e,o]of r.hops.entries())if(!o||"string"!=typeof o.amountOut||"string"!=typeof o.pool||"string"!=typeof o.tokenIn||"string"!=typeof o.tokenOut||!S.includes(o.venue))throw new Error(`Stellar builder: \`steps.paths[${t}].hops[${e}]\` must have amountOut, pool, tokenIn, tokenOut, and a valid Soroban venue`)}if(1e6!==o)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` must sum to 1_000_000, got ${o}`);return e})(t),s.ScVal.scvBytes(Buffer.from($(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},G=t=>{if("string"==typeof t)return(t=>{const e=t.startsWith("0x")?t.slice(2):t,o=Buffer.from(e,"hex");return s.ScVal.scvBytes(o)})(t);if(t instanceof Uint8Array)return s.ScVal.scvBytes(Buffer.from(t));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function z(e,n,i){const s=e.controllerAddress??g(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:f[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function V(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return z(t,"supply",[x(t.caller),_(o),T(r),U([...e.assets])])}function W(t,e){return V(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function j(t,e){return z(t,"borrow",[x(t.caller),_(e.accountNonce),U([...e.borrows]),R(e.to,x)])}function H(t,e){return j(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function X(t,e){return z(t,"withdraw",[x(t.caller),_(e.accountNonce),U([...e.withdrawals]),R(e.to,x)])}function F(t,e){return X(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function Q(t,e){return z(t,"repay",[x(t.caller),_(e.accountNonce),U([...e.payments])])}function K(t,e){return Q(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function Z(t,e){return z(t,"liquidate",[x(t.caller),_(e.accountNonce),U([...e.debtPayments])])}function J(t,e){return z(t,"flash_loan",[x(t.caller),O(e.hubId,e.asset),q(e.amount),x(e.receiver),G(e.data)])}function Y(t,e){return z(t,"migrate_from_blend",[x(t.caller),_(e.accountId),T(e.spokeId),T(e.hubId),x(e.blendPool),I(e.collateralTokens.map(x)),I(e.supplyTokens.map(x)),(o=e.debtCaps.map((t=>({token:t.token,amount:t.cap}))),s.ScVal.scvVec(o.map((t=>{return e=t.token,o=t.amount,s.ScVal.scvVec([x(e),q(o)]);var e,o}))))]);var o}function tt(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return z(t,"multiply",[x(t.caller),_(o),T(r),O(e.collateral.hubId,e.collateral.asset),q(e.debtToFlashLoan),O(e.debt.hubId,e.debt.asset),T(e.mode),D(e.steps),R(e.initialPayment,(t=>M(t.hubId,t.asset,t.amount))),R(e.convertSwap,D)])}function et(t,e){return z(t,"swap_debt",[x(t.caller),_(e.accountNonce),O(e.existingDebt.hubId,e.existingDebt.asset),q(e.newDebtAmount),O(e.newDebt.hubId,e.newDebt.asset),D(e.steps)])}function ot(t,e){return z(t,"swap_collateral",[x(t.caller),_(e.accountNonce),O(e.current.hubId,e.current.asset),q(e.fromAmount),O(e.newCollateral.hubId,e.newCollateral.asset),D(e.steps)])}function rt(t,e){return z(t,"repay_debt_with_collateral",[x(t.caller),_(e.accountNonce),O(e.collateral.hubId,e.collateral.asset),q(e.collateralAmount),O(e.debt.hubId,e.debt.asset),D(e.steps),w(e.closePosition)])}const nt="/stellar-lending",ut=25,it=encodeURIComponent,st=(t,e)=>t.fetchWithTimeout(`${nt}/context`,e),at=(t,e)=>t.fetchWithTimeout(`${nt}/assets`,e),pt=(t,e)=>t.fetchWithTimeout(`${nt}/hubs`,e),lt=(t,e)=>t.fetchWithTimeout(`${nt}/spokes`,e),dt=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${nt}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},ct=(t,e,o,r,n)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}`,n),yt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}/holders`,{...u,params:{side:n}}),mt=(t,e,o)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}`,o),bt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/page`,{...r,params:{...o}}),ft=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/markets`,{...r,params:{side:o}}),gt=(t,e,o)=>t.fetchWithTimeout(`${nt}/hubs/${e}`,o),ht=(t,e,o)=>t.fetchWithTimeout(`${nt}/spokes/${e}`,o),vt=(t,e,o)=>t.fetchWithTimeout(`${nt}/users/${it(e)}/positions`,o),St=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${nt}/users/${it(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},xt=(t,e,o)=>t.fetchWithTimeout(`${nt}/accounts/${it(e)}/positions`,o),qt=(t,e={},o)=>{const{top:r=ut,continuationToken:n}=e;return t.fetchWithTimeout(`${nt}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},Tt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/assets/${it(e)}/graph`,{...r,params:{...o}}),_t=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/hubs/${e}/graph`,{...r,params:{...o}}),wt=(t,e,o,r)=>t.fetchWithTimeout(`${nt}/spokes/${e}/graph`,{...r,params:{...o}}),At=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${nt}/reserves/${e}/${o}/${it(r)}/graph`,{...u,params:{...n}}),kt=t=>({context:e=>st(t,e),assets:e=>at(t,e),hubs:e=>pt(t,e),spokes:e=>lt(t,e),reserves:(e,o)=>{return void 0===(r=e)||"hubId"in r||"spokeId"in r||"asset"in r?dt(t,e,o):dt(t,{},e);var r},reserve:(e,o,r,n)=>ct(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>yt(t,e,o,r,n,u),asset:(e,o)=>mt(t,e,o),assetMarkets:(e,o,r)=>ft(t,e,o,r),hub:(e,o)=>gt(t,e,o),spoke:(e,o)=>ht(t,e,o),userPositions:(e,o)=>vt(t,e,o),userActivity:(e,o,r)=>St(t,e,o,r),accountPositions:(e,o)=>xt(t,e,o),governanceProposals:(e,o)=>qt(t,e,o),assetGraph:(e,o,r)=>Tt(t,e,o,r),hubGraph:(e,o,r)=>_t(t,e,o,r),spokeGraph:(e,o,r)=>wt(t,e,o,r),reserveGraph:(e,o,r,n,u)=>At(t,e,o,r,n,u)}),Pt={Single:0,PrimaryWithAnchor:1},It="RedStonePriceFeed",Et=t=>L({base_borrow_rate:q(t.baseBorrowRateRay),max_borrow_rate:q(t.maxBorrowRateRay),max_utilization:q(t.maxUtilizationRay),mid_utilization:q(t.midUtilizationRay),optimal_utilization:q(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:q(t.slope1Ray),slope2:q(t.slope2Ray),slope3:q(t.slope3Ray)}),Rt=t=>L({asset_decimals:T(t.assetDecimals),asset_id:x(t.assetId),base_borrow_rate:q(t.baseBorrowRateRay),flashloan_fee:T(t.flashloanFeeBps),is_flashloanable:w(t.isFlashloanable),max_borrow_rate:q(t.maxBorrowRateRay),max_utilization:q(t.maxUtilizationRay),mid_utilization:q(t.midUtilizationRay),optimal_utilization:q(t.optimalUtilizationRay),reserve_factor:T(t.reserveFactorBps),slope1:q(t.slope1Ray),slope2:q(t.slope2Ray),slope3:q(t.slope3Ray)}),Ot=t=>L({max_borrow_positions:T(t.maxBorrowPositions),max_supply_positions:T(t.maxSupplyPositions)}),Mt=t=>{const e=t.kind;switch(e){case"Stellar":return I([k("Stellar"),x(t.value)]);case"Symbol":return I([k("Symbol"),k(t.value)]);case"String":return I([k("String"),A(t.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${e}"`)}},Ut=(t,e)=>{if("Twap"===t){if("number"!=typeof e)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return I([k("Twap"),T(e)])}return I([k("Spot")])},Lt=t=>{const e=t.provider;if("ReflectorSep40"===e){if(!t.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return I([k("Reflector"),L({asset:Mt(t.asset),contract:x(t.contract),read_mode:Ut(t.readMode,t.twapRecords)})])}if(e===It||"XoxnoPriceFeed"===e){const o=e===It?"RedStone":"Xoxno";if("string"!=typeof t.feedId)throw new Error(`Stellar builder: ${o} oracle source requires \`feedId\``);if("number"!=typeof t.maxStaleSeconds)throw new Error(`Stellar builder: ${o} oracle source requires \`maxStaleSeconds\``);return I([k(o),L({contract:x(t.contract),feed_id:A(t.feedId),max_stale_seconds:_(t.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${e}"`)},$t=t=>{const e=Pt[t.strategy];if(void 0===e)throw new Error(`Stellar builder: unknown oracle strategy "${t.strategy}"`);return L({anchor:(o=t.anchor,I(null==o?[k("None")]:[k("Some"),Lt(o)])),max_price_stale_seconds:_(t.maxPriceStaleSeconds),max_sanity_price_wad:q(t.maxSanityPriceWad),min_sanity_price_wad:q(t.minSanityPriceWad),primary:Lt(t.primary),strategy:T(e),tolerance_bps:T(t.toleranceBps)});var o};function Nt(t,e){return z(t,"upgrade",[E(e.wasmHash)])}function Ct(t,e){return z(t,"migrate",[T(e.newVersion)])}function Bt(t){return z(t,"pause",[])}function Dt(t){return z(t,"unpause",[])}function Gt(t,e){return z(t,"grant_role",[x(e.account),k(e.role)])}function zt(t,e){return z(t,"revoke_role",[x(e.account),k(e.role)])}function Vt(t,e){return z(t,"transfer_ownership",[x(e.newOwner),T(e.liveUntilLedger)])}function Wt(t){return z(t,"accept_ownership",[])}function jt(t,e){return z(t,"set_aggregator",[x(e.aggregator)])}function Ht(t,e){return z(t,"set_accumulator",[x(e.accumulator)])}function Xt(t,e){return z(t,"set_liquidity_pool_template",[E(e.wasmHash)])}function Ft(t,e){return z(t,"set_position_limits",[Ot(e)])}function Qt(t,e){return z(t,"approve_token",[x(e.token)])}function Kt(t,e){return z(t,"revoke_token",[x(e.token)])}function Zt(t,e){return z(t,"set_market_oracle_config",[O(e.hubId,e.asset),$t(e.config)])}function Jt(t,e){return z(t,"set_oracle_tolerance",[x(e.asset),L({lower_ratio_bps:T(e.lowerRatioBps),upper_ratio_bps:T(e.upperRatioBps)})])}function Yt(t,e){return z(t,"update_indexes",[x(t.caller),I(e.assets.map((t=>O(t.hubId,t.asset))))])}function te(t,e){return z(t,"renew_account",[x(t.caller),_(e.accountNonce)])}function ee(t,e){return z(t,"create_liquidity_pool",[T(e.hubId),x(e.asset),Rt(e.params)])}function oe(t,e){return z(t,"upgrade_liquidity_pool_params",[O(e.hubId,e.asset),Et(e.params)])}function re(t,e){return z(t,"claim_revenue",[x(t.caller),I(e.assets.map((t=>O(t.hubId,t.asset))))])}function ne(t,e){return z(t,"add_rewards",[x(t.caller),U(e.rewards)])}function ue(t,e){return z(t,"update_account_threshold",[x(t.caller),w(e.hasRisks),I(e.accountNonces.map((t=>_(t))))])}const ie="00".repeat(32),se=t=>{if("string"==typeof t)return E(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 s.ScVal.scvBytes(e)},ae=(t,...e)=>I([k(t),...e]),pe=t=>L({new_owner:x(t.newOwner),live_until_ledger:T(t.liveUntilLedger)}),le=t=>L({asset:x(t.asset),bonus:T(t.bonus),borrow_cap:q(t.borrowCap),can_borrow:w(t.canBorrow),can_collateral:w(t.canCollateral),frozen:w(t.frozen),hub_id:T(t.hubId),paused:w(t.paused),liquidation_fees:T(t.liquidationFees),ltv:T(t.ltv),oracle_override:I([k("None")]),spoke_id:T(t.spokeId),supply_cap:q(t.supplyCap),threshold:T(t.threshold)}),de=t=>L({account:x(t.account),role:k(t.role)});function ce(e,n,i){const s=e.governanceAddress??v(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:f[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ye=(t,e,o)=>ce(t,"propose",[x(t.caller),e,se(o)]),me=(t,e,o)=>ce(t,"execute_self",[P(),e,se(o)]);function be(t,e,o){return ye(t,ae("SetAggregator",x(e.aggregator)),o)}function fe(t,e,o){return ye(t,ae("SetAccumulator",x(e.accumulator)),o)}function ge(t,e,o){return ye(t,ae("SetLiquidityPoolTemplate",E(e.wasmHash)),o)}function he(t,e,o){return ye(t,ae("SetPositionLimits",Ot(e)),o)}function ve(t,e){return ye(t,ae("CreateHub"),e)}function Se(t,e){return ye(t,ae("AddSpoke"),e)}function xe(t,e,o){return ye(t,ae("RemoveSpoke",T(e.spokeId)),o)}function qe(t,e,o){return ye(t,ae("AddAssetToSpoke",le(e)),o)}function Te(t,e,o){return ye(t,ae("EditAssetInSpoke",le(e)),o)}function _e(t,e,o){return ye(t,ae("RemoveAssetFromSpoke",L({hub_asset:O((r=e).hubId,r.asset),spoke_id:T(r.spokeId)})),o);var r}function we(t,e,o){return ye(t,ae("SetSpokeLiquidationCurve",L({hf_for_max_bonus_wad:q((r=e).hfForMaxBonusWad),liquidation_bonus_factor_bps:T(r.liquidationBonusFactorBps),spoke_id:T(r.spokeId),target_hf_wad:q(r.targetHfWad)})),o);var r}function Ae(t,e,o){return ye(t,ae("SetPositionManager",x(e.manager),w(e.isActive)),o)}function ke(t,e,o){return ye(t,ae("SetMinBorrowCollateralUsd",q(e.floorWad)),o)}function Pe(t,e,o){return ye(t,ae("ApproveToken",x(e.token)),o)}function Ie(t,e,o){return ye(t,ae("RevokeToken",x(e.token)),o)}function Ee(t,e,o){return ye(t,ae("ApproveBlendPool",x(e.pool)),o)}function Re(t,e,o){return ye(t,ae("RevokeBlendPool",x(e.pool)),o)}function Oe(t,e,o){return ye(t,ae("CreateLiquidityPool",L({asset:x((r=e).asset),hub_id:T(r.hubId),params:Rt(r.params)})),o);var r}function Me(t,e,o){return ye(t,ae("UpgradeLiquidityPoolParams",L({hub_asset:O((r=e).hubId,r.asset),params:Et(r.params)})),o);var r}function Ue(t,e){return ye(t,ae("DeployPool"),e)}function Le(t,e,o){return ye(t,ae("UpgradePool",E(e.wasmHash)),o)}function $e(t,e,o){return ye(t,ae("UpgradeController",E(e.wasmHash)),o)}function Ne(t,e,o){return ye(t,ae("MigrateController",T(e.newVersion)),o)}function Ce(t,e,o){return ye(t,ae("TransferCtrlOwnership",pe(e)),o)}function Be(t,e,o){return ye(t,ae("ConfigureMarketOracle",L({cfg:$t((r=e).config),hub_asset:O(r.hubId,r.asset)})),o);var r}function De(t,e,o){return ye(t,ae("EditOracleTolerance",L({asset:x((r=e).asset),tolerance:T(r.tolerance)})),o);var r}function Ge(t,e,o){return ye(t,ae("UpgradeGov",E(e.wasmHash)),o)}function ze(t,e,o){return ye(t,ae("UpdateGovDelay",T(e.newDelay)),o)}function Ve(t,e,o){return ye(t,ae("GrantGovRole",de(e)),o)}function We(t,e,o){return ye(t,ae("RevokeGovRole",de(e)),o)}function je(t,e,o){return ye(t,ae("TransferGovOwnership",pe(e)),o)}function He(t,e){const o=I(e.argsXdr.map((t=>s.ScVal.fromXDR(t,"base64")))),r=se(e.predecessor??ie);return ce(t,"execute",[P(),x(e.target),k(e.functionName),o,r,se(e.salt)])}function Xe(t,e,o){return me(t,ae("UpgradeGov",E(e.wasmHash)),o)}function Fe(t,e,o){return me(t,ae("UpdateGovDelay",T(e.newDelay)),o)}function Qe(t,e,o){return me(t,ae("GrantGovRole",de(e)),o)}function Ke(t,e,o){return me(t,ae("RevokeGovRole",de(e)),o)}function Ze(t,e,o){return me(t,ae("TransferGovOwnership",pe(e)),o)}const Je=t=>t.toXDR("base64"),Ye=t=>s.ScVal.fromXDR(t,"base64"),to=t=>t.map((t=>String(i(Ye(t))))).join(":"),eo=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),oo=t=>Number(t),ro=t=>String(t),no=t=>null==t?void 0:eo(t),uo=t=>null==t?void 0:ro(t),io=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),so=["None","Multiply","Long","Short"],ao=["Single","PrimaryWithAnchor"],po=["ReflectorSep40","RedStonePriceFeed"],lo=["Spot","Twap"],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"],yo=t=>Array.isArray(t)?t:[],mo=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],co[oo(r)]??eo(r)),positionType:e,hubId:oo(t[1]),asset:ro(t[2]),scaledAmountRay:eo(t[3]),indexRay:eo(t[4]),amount:eo(t[5]),liquidationThresholdBps:o?void 0:oo(t[6]),liquidationBonusBps:o?void 0:oo(t[7]),loanToValueBps:o?void 0:oo(t[8]),liquidationFeesBps:o?void 0:oo(t[9])};var r},bo=t=>{return{owner:ro(t[0]),spokeId:oo(t[1]),mode:(e=t[2],so[oo(e)]??"None")};var e},fo=(t,e)=>{const o=lo[oo(t[`${e}_read_mode`])]??"Spot",r=t[`${e}_asset`],n=t[`${e}_symbol`],u=null!=r?{kind:"Stellar",value:ro(r)}:null!=n?{kind:"Symbol",value:ro(n)}:void 0;return{provider:po[oo(t[`${e}_provider`])]??"ReflectorSep40",contractAddress:ro(t[`${e}_contract`]),asset:u,feedId:uo(t[`${e}_feed_id`]),readMode:o,twapRecords:"Twap"===o?oo(t[`${e}_twap_records`]):void 0,decimals:oo(t[`${e}_decimals`]),resolutionSeconds:oo(t[`${e}_resolution_seconds`]),maxStaleSeconds:oo(t[`${e}_max_stale_seconds`])}},go=t=>{const e=null!==t.anchor_provider&&void 0!==t.anchor_provider;return{baseTokenId:ro(t.base_token_id),quoteTokenId:ro(t.quote_token_id),tolerance:{upperRatio:oo(t.upper_ratio_bps??t.tolerance?.upper_ratio_bps),lowerRatio:oo(t.lower_ratio_bps??t.tolerance?.lower_ratio_bps)},assetDecimals:oo(t.asset_decimals),maxPriceStaleSeconds:oo(t.max_price_stale_seconds),strategy:ao[oo(t.strategy)]??"Single",primary:fo(t,"primary"),anchor:e?fo(t,"anchor"):void 0,primaryQuoteToken:uo(t.primary_quote_token),anchorQuoteToken:uo(t.anchor_quote_token),minSanityPriceWad:no(t.min_sanity_price_wad),maxSanityPriceWad:no(t.max_sanity_price_wad)}},ho={"market:create":t=>({topic:"market:create",data:{hubId:oo(t.hub_id),baseAsset:ro(t.base_asset),maxBorrowRate:eo(t.max_borrow_rate),baseBorrowRate:eo(t.base_borrow_rate),slope1:eo(t.slope1),slope2:eo(t.slope2),slope3:eo(t.slope3),midUtilization:eo(t.mid_utilization),optimalUtilization:eo(t.optimal_utilization),maxUtilization:eo(t.max_utilization),reserveFactor:oo(t.reserve_factor),marketAddress:ro(t.market_address)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:ro(t.asset),maxBorrowRateRay:eo(t.max_borrow_rate),baseBorrowRateRay:eo(t.base_borrow_rate),slope1Ray:eo(t.slope1),slope2Ray:eo(t.slope2),slope3Ray:eo(t.slope3),midUtilizationRay:eo(t.mid_utilization),optimalUtilizationRay:eo(t.optimal_utilization),maxUtilizationRay:eo(t.max_utilization),reserveFactorBps:oo(t.reserve_factor)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:yo(t).map((t=>{return e=yo(t),{hubId:oo(e[0]),asset:ro(e[1]),timestamp:oo(e[2]),supplyIndexRay:eo(e[3]),borrowIndexRay:eo(e[4]),cash:eo(e[5]),suppliedRay:eo(e[6]),borrowedRay:eo(e[7]),revenueRay:eo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:yo(t).map((t=>{const e=t;return{hubId:oo(e.hub_id),asset:ro(e.asset),params:(o=e.params,{maxBorrowRateRay:eo(o.max_borrow_rate),baseBorrowRateRay:eo(o.base_borrow_rate),slope1Ray:eo(o.slope1),slope2Ray:eo(o.slope2),slope3Ray:eo(o.slope3),midUtilizationRay:eo(o.mid_utilization),optimalUtilizationRay:eo(o.optimal_utilization),maxUtilizationRay:eo(o.max_utilization),reserveFactorBps:oo(o.reserve_factor),isFlashloanable:Boolean(o.is_flashloanable),flashloanFeeBps:oo(o.flashloan_fee),assetId:ro(o.asset_id),assetDecimals:oo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=yo(t);return{topic:"position:batch_update",data:{accountId:eo(e[0]),accountAttributes:bo(yo(e[1])),updates:[...yo(e[2]).map((t=>mo(yo(t),"Deposit"))),...yo(e[3]).map((t=>mo(yo(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{hubId:oo(t.hub_id),asset:ro(t.asset),receiver:ro(t.receiver),caller:ro(t.caller),amount:eo(t.amount),fee:eo(t.fee)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:ro(t.asset),oracle:go(t.oracle)}}),"position:liquidation":t=>({topic:"position:liquidation",data:{liquidator:ro(t.liquidator),accountId:eo(t.account_id),repaidUsdWad:eo(t.repaid_usd_wad),bonusBps:eo(t.bonus_bps)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:eo(t.account_id),totalBorrowUsdWad:eo(t.total_borrow_usd_wad),totalCollateralUsdWad:eo(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:ro(t.token),amount:eo(t.amount),usdValueWad:eo(t.usd_value_wad),accountId:eo(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{hubId:oo(t.hub_id),asset:ro(t.asset),amount:eo(t.amount),fee:eo(t.fee),amountSent:eo(t.amount_sent)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:io(t.wasm_hash),approved:Boolean(t.approved)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:ro(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:ro(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:io(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:oo(t.max_supply_positions),maxBorrowPositions:oo(t.max_borrow_positions)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:ro(t.asset)}}),"config:spoke":t=>{const e=t.spoke;return{topic:"config:spoke",data:{spokeId:oo(e.spoke_id),isDeprecated:Boolean(e.is_deprecated),liquidationTargetHfWad:eo(e.liquidation_target_hf_wad),healthFactorForMaxBonusWad:eo(e.hf_for_max_bonus_wad),liquidationBonusFactorBps:oo(e.liquidation_bonus_factor_bps)}}}},vo=Object.freeze(Object.keys(ho));function So(t,e){const o=to(t),r=ho[o];return r?r(i(Ye(e))):null}const xo="XLENDXLM-a7c9f3",qo=1e4;function To(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${xo}-${o}`}function _o(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function wo(t,e=0){return t*qo+e}function Ao(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const ko=(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()},Po=t=>t.baseUrl??b[t.network];async function Io(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=ko(Po(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 Eo(t){const e=ko(Po(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 Ro=t=>$(t).toXDR("base64");function Oo(e,n){const i=e.routerAddress??h(e.network),s=new r(i),a=new t(e.caller,e.sourceSequence),p=D(((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:f[e.network]}).addOperation(s.call("execute_strategy",x(e.caller),q(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Mo(t,e){return Oo(t,e)}function Uo(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(No),splitPpm:t.splitPpm}))):[{hops:t.hops.map(No),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Lo(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:Uo(t,e)}const $o=Uo,No=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Co(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Bo(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw Co(o.invokedContractId,t);throw t}}async function Do(t,e,o){return Bo(t,e.xdr,o)}function Go(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 zo(t,e){return new Uint8Array(0)}const Vo=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 Wo(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",s.ScVal.scvBytes(Vo(e.message)),s.ScVal.scvBytes(Vo(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:f[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const jo={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:"InvalidPoolTemplate",message:"The liquidity pool template hash is 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."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetsLimitReached",message:"This spoke has reached its asset limit."},314:{name:"SpokeCapBelowUsage",message:"The new cap is below current usage on this spoke asset."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},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 Ho(t){const e=t.match(/Error\(Contract,\s*#(\d+)\)/);if(!e)return null;const o=Number(e[1]),r=jo[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 d="https://api.xoxno.com",c="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",m="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var b;!function(t){t.MAINNET="1",t.DEVNET="D"}(b||(b={}));class f{apiUrl;chain;init;config;constructor({chain:t=b.MAINNET,apiUrl:e=d,...o}={}){this.apiUrl=e??{[b.MAINNET]:d,[b.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==b.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:c,DR_SC:y,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:c,DR_SC:y,KG_SC:m,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(t,{params:e,...o}={})=>{const{next:r,cache:n,debug:u,...i}=this.init,{next:s,cache:a,debug:p,headers:l,method:d="GET",...c}=o,y=l?.Authorization,m="Bearer undefined"===y?void 0:y,b={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===d?{}:{"Content-Type":"application/json"},...m?{Authorization:m}:{}},f=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),g=`${this.apiUrl}${t}${f.length?`?${f}`:""}`,{revalidate:h,...v}=r??{},{revalidate:S,...x}=s??{},q="GET"!==d||m?void 0:S??h,T="GET"!==d||m||q?void 0:a??n,_={...i,...c,method:d,...Object.keys(b).length?{headers:b}:{},cache:T,next:{...v,...x,revalidate:q}};(p??u)&&console.debug("SDK fetch: ",g,_);const w=await fetch(g,_).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${g}: ${t.message}`),{cause:t});throw t})),A=await w.text();if(!w.ok){let t;try{t=JSON.parse(A)}catch{t={message:A}}const e=[g,w.status,w.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const g=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},h=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 v extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class S extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const x=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)),q={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/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:{}},"/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/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:{}}}},T=["PATCH","POST","DELETE","PUT"];var _=l(385);const w=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));function A(t,e,o,r){const{input:n,output:u,...i}=e,s=async(e={})=>{const n={...o,...e},u=t.replace(/:([a-zA-Z_]+)/g,((t,e)=>`${n[e]}`)),i=[...t.matchAll(/:([a-zA-Z_]+)/g)].map((t=>t[1])),s=Object.fromEntries(Object.entries(n).filter((([t])=>!i.includes(t)))),a=/:address[^A-Z]/.test(t)||"address"in s,p=/:collection[^A-Z]/.test(t)||"collection"in s;if(a){const t=n.address;if(!x(t))throw new S(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!g(t))):!g(t))throw new v(t)}const l=Object.fromEntries(Object.entries(s).map((([t,e])=>[t,e instanceof FormData?e:"filter"===t||"body"===t?JSON.stringify(e):Array.isArray(e)?e.join(","):e]))),{body:d,auth:c,method:y,headers:m,cache:b,next:f,debug:h,continuationToken:q,...T}=l,_=c?`Bearer ${c}`:void 0,w={...m,..._?{Authorization:_}:{},...q?{"X-Continuation-Token":String(q)}:{}},A={...f,tags:[...f?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:T,body:d,headers:w,cache:b,debug:h,...A?{next:A}:{}})},a=(t={})=>s(t);for(const t of Object.keys(i))T.includes(t)&&(a[t]=e=>s({...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(q)){const r=e.split("/").filter(Boolean);let n=t;for(const t of r)if(t.startsWith(":")){const e=w(t.slice(1));n=n.params[e]||={static:{},params:{},leaves:[]}}else{const e=w(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,i=Object.keys(e.params).length;let s;if(1===n&&u+i>0){const{rawPath:o,def:n}=e.leaves[0];s=A(o,n,r,t)}else{s={};for(const{rawPath:o,def:n}of e.leaves)s[w(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===s[t]?s[t]=u:"function"==typeof s[t]?Object.assign(s[t],u):"function"==typeof u?(Object.assign(u,s[t]),s[t]=u):Object.assign(s[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(s[t]){const o=s[t];s[t]=t=>({...o(t),...e(t)})}else s[t]=e}return s};return o(e,{})}export{b as Chain,f as XOXNOClient,k as buildSdk,g as isValidCollectionTicker,h as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=_.ME;export const STELLAR_GOVERNANCE=_.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=_.G_;export const STELLAR_LENDING_CONTROLLER=_.DU;export const STELLAR_LENDING_TOPICS=_.fA;export const STELLAR_NETWORK_PASSPHRASE=_.A$;export const STELLAR_QUOTE_URL=_.J9;export const STELLAR_SOROBAN_RPC_URL=_.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=_.gR;export const XOXNO_LENDING_STELLAR_TICKER=_.Cg;export const buildSameTokenRepaySwapSteps=_.VZ;export const buildStellarAcceptOwnershipTx=_.N0;export const buildStellarAddRewardsTx=_.B_;export const buildStellarApproveTokenTx=_.eX;export const buildStellarBatchSwapTx=_.z;export const buildStellarBorrowBatchTx=_.xD;export const buildStellarBorrowTx=_.jR;export const buildStellarCctpForwardTx=_.P2;export const buildStellarClaimRevenueTx=_.W6;export const buildStellarCreateLiquidityPoolTx=_.se;export const buildStellarExecuteStrategyTx=_.yr;export const buildStellarFlashLoanTx=_.sp;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=_.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=_.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=_.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=_.e_;export const buildStellarGovernanceExecuteTx=_.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=_.BA;export const buildStellarGrantRoleTx=_.SX;export const buildStellarLendingIdentifier=_.UF;export const buildStellarLiquidateTx=_.Y5;export const buildStellarMigrateFromBlendTx=_.mE;export const buildStellarMigrateTx=_.xG;export const buildStellarMultiplyTx=_.s9;export const buildStellarPauseTx=_.OL;export const buildStellarProposeAddAssetToSpokeTx=_.k6;export const buildStellarProposeAddSpokeTx=_.dj;export const buildStellarProposeApproveBlendPoolTx=_.kD;export const buildStellarProposeApproveTokenTx=_.Yf;export const buildStellarProposeConfigureMarketOracleTx=_.c5;export const buildStellarProposeCreateHubTx=_.N8;export const buildStellarProposeCreateLiquidityPoolTx=_.qU;export const buildStellarProposeDeployPoolTx=_.RZ;export const buildStellarProposeEditAssetInSpokeTx=_.ni;export const buildStellarProposeEditOracleToleranceTx=_.hF;export const buildStellarProposeGovernanceUpgradeTx=_.Qk;export const buildStellarProposeGrantGovernanceRoleTx=_.Gw;export const buildStellarProposeMigrateControllerTx=_.$K;export const buildStellarProposeRemoveAssetFromSpokeTx=_.uj;export const buildStellarProposeRemoveSpokeTx=_.Od;export const buildStellarProposeRevokeBlendPoolTx=_.X7;export const buildStellarProposeRevokeGovernanceRoleTx=_.Ub;export const buildStellarProposeRevokeTokenTx=_.Dx;export const buildStellarProposeSetAccumulatorTx=_.OA;export const buildStellarProposeSetAggregatorTx=_.$U;export const buildStellarProposeSetMinBorrowCollatTx=_.ob;export const buildStellarProposeSetPoolTemplateTx=_.cY;export const buildStellarProposeSetPositionLimitsTx=_.$l;export const buildStellarProposeSetPositionManagerTx=_.K;export const buildStellarProposeSetSpokeLiquidationCurveTx=_.kw;export const buildStellarProposeTransferCtrlOwnershipTx=_.VS;export const buildStellarProposeTransferGovOwnTx=_.HP;export const buildStellarProposeUpdateDelayTx=_.YQ;export const buildStellarProposeUpgradeControllerTx=_.QY;export const buildStellarProposeUpgradePoolParamsTx=_.os;export const buildStellarProposeUpgradePoolTx=_.Ko;export const buildStellarRenewAccountTx=_.IJ;export const buildStellarRepayBatchTx=_.nw;export const buildStellarRepayDebtWithCollateralTx=_.Pr;export const buildStellarRepayTx=_.ZE;export const buildStellarRevokeRoleTx=_.ev;export const buildStellarRevokeTokenTx=_.P8;export const buildStellarSetAccumulatorTx=_.aV;export const buildStellarSetAggregatorTx=_.p2;export const buildStellarSetLiquidityPoolTemplateTx=_.Ww;export const buildStellarSetMarketOracleConfigTx=_.sV;export const buildStellarSetOracleToleranceTx=_.Js;export const buildStellarSetPositionLimitsTx=_.Dy;export const buildStellarSupplyBatchTx=_.Ni;export const buildStellarSupplyTx=_.v_;export const buildStellarSwapCollateralTx=_.qD;export const buildStellarSwapDebtTx=_.qR;export const buildStellarTransferOwnershipTx=_.QJ;export const buildStellarUnpauseTx=_.bm;export const buildStellarUpdateAccountThresholdTx=_.n_;export const buildStellarUpdateIndexesTx=_.v8;export const buildStellarUpgradeControllerTx=_.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=_.gH;export const buildStellarWithdrawBatchTx=_.O3;export const buildStellarWithdrawTx=_.Gz;export const buildTx=_.pr;export const decodeStellarLendingEvent=_.Fm;export const encodeInterestRateModel=_.MB;export const encodeMarketOracleConfigInput=_.Dn;export const encodeMarketParamsRaw=_.pq;export const encodeOracleSourceConfigInput=_.ml;export const encodePositionLimits=_.Q3;export const encodeStrategyPayloadToRouteXdr=_.wf;export const extractEventOrder=_.Um;export const getStellarAccountPositions=_.xO;export const getStellarAggregatorQuote=_.Lw;export const getStellarAggregatorRouter=_.KM;export const getStellarAsset=_.mM;export const getStellarAssetGraph=_.iE;export const getStellarAssetMarkets=_.zp;export const getStellarAssetPage=_.N3;export const getStellarAssets=_.bN;export const getStellarGovernance=_.QV;export const getStellarGovernanceProposals=_.T_;export const getStellarHub=_.XI;export const getStellarHubGraph=_.Lt;export const getStellarHubs=_.KK;export const getStellarLendingContext=_.yl;export const getStellarLendingController=_.vc;export const getStellarQuoteTokens=_.CH;export const getStellarReserve=_.FI;export const getStellarReserveGraph=_.KG;export const getStellarReserveHolders=_.nW;export const getStellarReserves=_.jF;export const getStellarSpoke=_.S2;export const getStellarSpokeGraph=_.uS;export const getStellarSpokes=_.u_;export const getStellarUserActivity=_.O5;export const getStellarUserPositions=_.Av;export const mapQuoteResponseToAggregatorSwap=_.LA;export const mapQuoteResponseToStrategyPayload=_.E6;export const mapQuoteResponseToStrategySwap=_.Ds;export const mapSorobanError=_.XV;export const mapStellarPositionActivityType=_.CU;export const prepareStellarBuiltTx=_.Vx;export const prepareStellarTxXdr=_.DL;export const stellarLendingDispatchKey=_.ON;export const stellarLendingRead=_.Hh;export const syntheticEventOrder=_.oV;export const tagStellarInvokedContractError=_.g5;export const toBase64Xdr=_.L;export const toStellarPositionMode=_.Vu;
@@ -18,7 +18,7 @@ export declare const encodeInterestRateModel: (m: InterestRateModelDto) => xdr.S
18
18
  export declare const encodeMarketParamsRaw: (p: MarketParamsRawDto) => xdr.ScVal;
19
19
  /** `PositionLimits` — per-account supply/borrow position caps. */
20
20
  export declare const encodePositionLimits: (l: PositionLimitsDto) => xdr.ScVal;
21
- /** `OracleSourceConfigInput` data-enum — `Reflector(...)` | `RedStone(...)`. */
21
+ /** `OracleSourceConfigInput` data-enum — `Reflector(...)` | `RedStone(...)` | `Xoxno(...)`. */
22
22
  export declare const encodeOracleSourceConfigInput: (src: OracleSourceConfigInputDto) => xdr.ScVal;
23
23
  /** `MarketOracleConfigInput` — strategy + primary/anchor sources + sanity bounds. */
24
24
  export declare const encodeMarketOracleConfigInput: (cfg: MarketOracleConfigInputDto) => xdr.ScVal;
@@ -1 +1 @@
1
- "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis),(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{STELLAR_AGGREGATOR_ROUTER:()=>o,STELLAR_GOVERNANCE:()=>a,STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>Ye,STELLAR_LENDING_CONTROLLER:()=>r,STELLAR_LENDING_TOPICS:()=>Sr,STELLAR_NETWORK_PASSPHRASE:()=>i,STELLAR_QUOTE_URL:()=>s,STELLAR_SOROBAN_RPC_URL:()=>n,SYNTHETIC_EVENT_ORDER_STRIDE:()=>gr,XOXNO_LENDING_STELLAR_TICKER:()=>_r,buildSameTokenRepaySwapSteps:()=>Dr,buildStellarAcceptOwnershipTx:()=>Ue,buildStellarAddRewardsTx:()=>Ke,buildStellarApproveTokenTx:()=>Ve,buildStellarBatchSwapTx:()=>Or,buildStellarBorrowBatchTx:()=>q,buildStellarBorrowTx:()=>G,buildStellarCctpForwardTx:()=>Wr,buildStellarClaimRevenueTx:()=>Qe,buildStellarCreateLiquidityPoolTx:()=>He,buildStellarExecuteStrategyTx:()=>Pr,buildStellarFlashLoanTx:()=>X,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>Xt,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>Ht,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>jt,buildStellarGovernanceExecuteTransferGovOwnTx:()=>Qt,buildStellarGovernanceExecuteTx:()=>Mt,buildStellarGovernanceExecuteUpdateDelayTx:()=>Ft,buildStellarGrantRoleTx:()=>Le,buildStellarLendingIdentifier:()=>wr,buildStellarLiquidateTx:()=>M,buildStellarMigrateFromBlendTx:()=>F,buildStellarMigrateTx:()=>Pe,buildStellarMultiplyTx:()=>H,buildStellarPauseTx:()=>Oe,buildStellarProposeAddAssetToSpokeTx:()=>wt,buildStellarProposeAddSpokeTx:()=>_t,buildStellarProposeApproveBlendPoolTx:()=>At,buildStellarProposeApproveTokenTx:()=>kt,buildStellarProposeConfigureMarketOracleTx:()=>Ct,buildStellarProposeCreateHubTx:()=>bt,buildStellarProposeCreateLiquidityPoolTx:()=>Pt,buildStellarProposeDeployPoolTx:()=>Bt,buildStellarProposeEditAssetInSpokeTx:()=>yt,buildStellarProposeEditOracleToleranceTx:()=>qt,buildStellarProposeGovernanceUpgradeTx:()=>Gt,buildStellarProposeGrantGovernanceRoleTx:()=>Vt,buildStellarProposeMigrateControllerTx:()=>$t,buildStellarProposeRemoveAssetFromSpokeTx:()=>Tt,buildStellarProposeRemoveSpokeTx:()=>gt,buildStellarProposeRevokeBlendPoolTx:()=>It,buildStellarProposeRevokeGovernanceRoleTx:()=>Wt,buildStellarProposeRevokeTokenTx:()=>Et,buildStellarProposeSetAccumulatorTx:()=>ft,buildStellarProposeSetAggregatorTx:()=>mt,buildStellarProposeSetMinBorrowCollatTx:()=>Rt,buildStellarProposeSetPoolTemplateTx:()=>ht,buildStellarProposeSetPositionLimitsTx:()=>St,buildStellarProposeSetPositionManagerTx:()=>xt,buildStellarProposeSetSpokeLiquidationCurveTx:()=>vt,buildStellarProposeTransferCtrlOwnershipTx:()=>Ut,buildStellarProposeTransferGovOwnTx:()=>zt,buildStellarProposeUpdateDelayTx:()=>Dt,buildStellarProposeUpgradeControllerTx:()=>Nt,buildStellarProposeUpgradePoolParamsTx:()=>Ot,buildStellarProposeUpgradePoolTx:()=>Lt,buildStellarRenewAccountTx:()=>Fe,buildStellarRepayBatchTx:()=>W,buildStellarRepayDebtWithCollateralTx:()=>K,buildStellarRepayTx:()=>z,buildStellarRevokeRoleTx:()=>Ne,buildStellarRevokeTokenTx:()=>We,buildStellarSetAccumulatorTx:()=>qe,buildStellarSetAggregatorTx:()=>Ce,buildStellarSetLiquidityPoolTemplateTx:()=>Ge,buildStellarSetMarketOracleConfigTx:()=>ze,buildStellarSetOracleToleranceTx:()=>Me,buildStellarSetPositionLimitsTx:()=>De,buildStellarSupplyBatchTx:()=>U,buildStellarSupplyTx:()=>C,buildStellarSwapCollateralTx:()=>Q,buildStellarSwapDebtTx:()=>j,buildStellarTransferOwnershipTx:()=>$e,buildStellarUnpauseTx:()=>Be,buildStellarUpdateAccountThresholdTx:()=>Ze,buildStellarUpdateIndexesTx:()=>Xe,buildStellarUpgradeControllerTx:()=>Ie,buildStellarUpgradeLiquidityPoolParamsTx:()=>je,buildStellarWithdrawBatchTx:()=>D,buildStellarWithdrawTx:()=>V,buildTx:()=>$,decodeStellarLendingEvent:()=>br,encodeInterestRateModel:()=>Te,encodeMarketOracleConfigInput:()=>Ae,encodeMarketParamsRaw:()=>ve,encodeOracleSourceConfigInput:()=>Ee,encodePositionLimits:()=>xe,encodeStrategyPayloadToRouteXdr:()=>Ir,extractEventOrder:()=>yr,getStellarAccountPositions:()=>fe,getStellarAggregatorQuote:()=>kr,getStellarAggregatorRouter:()=>u,getStellarAsset:()=>ie,getStellarAssetGraph:()=>Se,getStellarAssetMarkets:()=>ue,getStellarAssetPage:()=>le,getStellarAssets:()=>te,getStellarGovernance:()=>c,getStellarGovernanceProposals:()=>he,getStellarHub:()=>ce,getStellarHubGraph:()=>be,getStellarHubs:()=>re,getStellarLendingContext:()=>ee,getStellarLendingController:()=>l,getStellarQuoteTokens:()=>Er,getStellarReserve:()=>ne,getStellarReserveGraph:()=>ge,getStellarReserveHolders:()=>se,getStellarReserves:()=>ae,getStellarSpoke:()=>de,getStellarSpokeGraph:()=>_e,getStellarSpokes:()=>oe,getStellarUserActivity:()=>me,getStellarUserPositions:()=>pe,mapQuoteResponseToAggregatorSwap:()=>Nr,mapQuoteResponseToStrategyPayload:()=>Br,mapQuoteResponseToStrategySwap:()=>Lr,mapSorobanError:()=>Mr,mapStellarPositionActivityType:()=>vr,prepareStellarBuiltTx:()=>qr,prepareStellarTxXdr:()=>Cr,stellarLendingDispatchKey:()=>Yt,stellarLendingRead:()=>we,syntheticEventOrder:()=>Tr,tagStellarInvokedContractError:()=>Ur,toBase64Xdr:()=>Kt,toStellarPositionMode:()=>Gr});const r={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},o={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},a={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},n={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},s={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"},i={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function l(e){const t=r[e];if(!t)throw new Error(`Stellar lending controller address not configured for network "${e}". Set STELLAR_LENDING_CONTROLLER_${e.toUpperCase()} env var.`);return t}function u(e){const t=o[e];if(!t)throw new Error(`Stellar aggregator router address not configured for network "${e}". Set STELLAR_AGGREGATOR_ROUTER_${e.toUpperCase()} env var.`);return t}function c(e){const t=a[e];if(!t)throw new Error(`Stellar governance address not configured for network "${e}". Set STELLAR_GOVERNANCE_${e.toUpperCase()} env var.`);return t}const d=require("@stellar/stellar-sdk"),p=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],m=e=>new d.Address(e).toScVal(),f=e=>new d.ScInt(e).toI128(),h=e=>d.xdr.ScVal.scvU32(e),S=e=>new d.ScInt("string"==typeof e?e:e.toString()).toU64(),b=e=>d.xdr.ScVal.scvBool(e),_=e=>d.xdr.ScVal.scvString(e),g=e=>d.xdr.ScVal.scvSymbol(e),w=()=>d.xdr.ScVal.scvVoid(),y=e=>d.xdr.ScVal.scvVec(e),T=(e,t=32)=>{const r=e.startsWith("0x")?e.slice(2):e,o=Buffer.from(r,"hex");if(o.length!==t)throw new Error(`Stellar builder: expected a ${t}-byte BytesN (got ${o.length} bytes from "${e}")`);return d.xdr.ScVal.scvBytes(o)},v=(e,t)=>null==e?w():t(e),x=e=>d.xdr.ScVal.scvVec(e.map((e=>{return t=e.token,r=e.amount,d.xdr.ScVal.scvVec([m(t),f(r)]);var t,r}))),R=(e,t)=>A({asset:m(t),hub_id:h(e)}),k=(e,t,r)=>d.xdr.ScVal.scvVec([R(e,t),f(r)]),E=e=>d.xdr.ScVal.scvVec(e.map((e=>k(e.hubId,e.asset,e.amount)))),A=e=>{const t=Object.keys(e).sort().map((t=>new d.xdr.ScMapEntry({key:g(t),val:e[t]})));return d.xdr.ScVal.scvMap(t)},I=e=>{const t=e.paths.map((e=>{const t=e.hops.map((e=>{return A({amount_out:f(e.amountOut),pool:m(e.pool),token_in:m(e.tokenIn),token_out:m(e.tokenOut),venue:(t=e.venue,d.xdr.ScVal.scvVec([g(t)]))});var t}));return A({hops:d.xdr.ScVal.scvVec(t),split_ppm:h(e.splitPpm)})}));return A({paths:d.xdr.ScVal.scvVec(t),referral_id:S(e.referralId??0),token_in:m(e.tokenIn),token_out:m(e.tokenOut),total_min_out:f(e.totalMinOut)})},P=e=>{const t=Buffer.from(e);if(0===t.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return d.xdr.ScVal.scvBytes(t)},O=()=>d.xdr.ScVal.scvBytes(Buffer.alloc(0)),B=e=>{const t=e.trim();if(t.startsWith("0x")){const e=t.slice(2);if(!((r=e).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return Buffer.from(e,"hex")}var r;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const o=Buffer.from(t,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},L=e=>{if("string"==typeof e)return P(B(e));if(e instanceof Uint8Array)return 0===e.length?O():P(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?P(B(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?P(B(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?P(B(e.bytes)):0===e.bytes.length?O():P(e.bytes):(t=(e=>{if(!e||"object"!=typeof e)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const t=e;if(!Array.isArray(t.paths)||0===t.paths.length)throw new Error("Stellar builder: `steps.paths` must be a non-empty array of strategy paths");if("string"!=typeof t.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof t.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof t.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");let r=0;for(const[e,o]of t.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.hops.length)throw new Error(`Stellar builder: \`steps.paths[${e}]\` must have splitPpm > 0 and a non-empty hops array`);r+=o.splitPpm;for(const[t,r]of o.hops.entries())if(!r||"string"!=typeof r.amountOut||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!p.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${e}].hops[${t}]\` must have amountOut, pool, tokenIn, tokenOut, and a valid Soroban venue`)}if(1e6!==r)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` must sum to 1_000_000, got ${r}`);return t})(e),d.xdr.ScVal.scvBytes(Buffer.from(I(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},N=e=>{if("string"==typeof e)return(e=>{const t=e.startsWith("0x")?e.slice(2):e,r=Buffer.from(t,"hex");return d.xdr.ScVal.scvBytes(r)})(e);if(e instanceof Uint8Array)return d.xdr.ScVal.scvBytes(Buffer.from(e));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function $(e,t,r){const o=e.controllerAddress??l(e.network),a=new d.Contract(o),n=new d.Account(e.caller,e.sourceSequence);return{xdr:new d.TransactionBuilder(n,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function U(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return $(e,"supply",[m(e.caller),S(r),h(o),E([...t.assets])])}function C(e,t){return U(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function q(e,t){return $(e,"borrow",[m(e.caller),S(t.accountNonce),E([...t.borrows]),v(t.to,m)])}function G(e,t){return q(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function D(e,t){return $(e,"withdraw",[m(e.caller),S(t.accountNonce),E([...t.withdrawals]),v(t.to,m)])}function V(e,t){return D(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function W(e,t){return $(e,"repay",[m(e.caller),S(t.accountNonce),E([...t.payments])])}function z(e,t){return W(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function M(e,t){return $(e,"liquidate",[m(e.caller),S(t.accountNonce),E([...t.debtPayments])])}function X(e,t){return $(e,"flash_loan",[m(e.caller),R(t.hubId,t.asset),f(t.amount),m(t.receiver),N(t.data)])}function F(e,t){return $(e,"migrate_from_blend",[m(e.caller),S(t.accountId),h(t.spokeId),h(t.hubId),m(t.blendPool),y(t.collateralTokens.map(m)),y(t.supplyTokens.map(m)),x(t.debtCaps.map((e=>({token:e.token,amount:e.cap}))))])}function H(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return $(e,"multiply",[m(e.caller),S(r),h(o),R(t.collateral.hubId,t.collateral.asset),f(t.debtToFlashLoan),R(t.debt.hubId,t.debt.asset),h(t.mode),L(t.steps),v(t.initialPayment,(e=>k(e.hubId,e.asset,e.amount))),v(t.convertSwap,L)])}function j(e,t){return $(e,"swap_debt",[m(e.caller),S(t.accountNonce),R(t.existingDebt.hubId,t.existingDebt.asset),f(t.newDebtAmount),R(t.newDebt.hubId,t.newDebt.asset),L(t.steps)])}function Q(e,t){return $(e,"swap_collateral",[m(e.caller),S(t.accountNonce),R(t.current.hubId,t.current.asset),f(t.fromAmount),R(t.newCollateral.hubId,t.newCollateral.asset),L(t.steps)])}function K(e,t){return $(e,"repay_debt_with_collateral",[m(e.caller),S(t.accountNonce),R(t.collateral.hubId,t.collateral.asset),f(t.collateralAmount),R(t.debt.hubId,t.debt.asset),L(t.steps),b(t.closePosition)])}const Z="/stellar-lending",Y=25,J=encodeURIComponent,ee=(e,t)=>e.fetchWithTimeout(`${Z}/context`,t),te=(e,t)=>e.fetchWithTimeout(`${Z}/assets`,t),re=(e,t)=>e.fetchWithTimeout(`${Z}/hubs`,t),oe=(e,t)=>e.fetchWithTimeout(`${Z}/spokes`,t),ae=(e,t={},r)=>{const{hubId:o,spokeId:a,asset:n}=t;return e.fetchWithTimeout(`${Z}/reserves`,{...r,params:{...void 0!==o?{hubId:o}:{},...void 0!==a?{spokeId:a}:{},...n?{asset:n}:{}}})},ne=(e,t,r,o,a)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}`,a),se=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}/holders`,{...n,params:{side:a}}),ie=(e,t,r)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}`,r),le=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/page`,{...o,params:{...r}}),ue=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/markets`,{...o,params:{side:r}}),ce=(e,t,r)=>e.fetchWithTimeout(`${Z}/hubs/${t}`,r),de=(e,t,r)=>e.fetchWithTimeout(`${Z}/spokes/${t}`,r),pe=(e,t,r)=>e.fetchWithTimeout(`${Z}/users/${J(t)}/positions`,r),me=(e,t,r={},o)=>{const{skip:a,top:n}=r;return e.fetchWithTimeout(`${Z}/users/${J(t)}/activity`,{...o,params:{...void 0!==a?{skip:a}:{},...void 0!==n?{top:n}:{}}})},fe=(e,t,r)=>e.fetchWithTimeout(`${Z}/accounts/${J(t)}/positions`,r),he=(e,t={},r)=>{const{top:o=Y,continuationToken:a}=t;return e.fetchWithTimeout(`${Z}/governance/proposals`,{...r,params:{top:o,...a?{continuationToken:a}:{}}})},Se=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/graph`,{...o,params:{...r}}),be=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/hubs/${t}/graph`,{...o,params:{...r}}),_e=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/spokes/${t}/graph`,{...o,params:{...r}}),ge=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}/graph`,{...n,params:{...a}}),we=e=>({context:t=>ee(e,t),assets:t=>te(e,t),hubs:t=>re(e,t),spokes:t=>oe(e,t),reserves:(t,r)=>{return void 0===(o=t)||"hubId"in o||"spokeId"in o||"asset"in o?ae(e,t,r):ae(e,{},t);var o},reserve:(t,r,o,a)=>ne(e,t,r,o,a),reserveHolders:(t,r,o,a,n)=>se(e,t,r,o,a,n),asset:(t,r)=>ie(e,t,r),assetMarkets:(t,r,o)=>ue(e,t,r,o),hub:(t,r)=>ce(e,t,r),spoke:(t,r)=>de(e,t,r),userPositions:(t,r)=>pe(e,t,r),userActivity:(t,r,o)=>me(e,t,r,o),accountPositions:(t,r)=>fe(e,t,r),governanceProposals:(t,r)=>he(e,t,r),assetGraph:(t,r,o)=>Se(e,t,r,o),hubGraph:(t,r,o)=>be(e,t,r,o),spokeGraph:(t,r,o)=>_e(e,t,r,o),reserveGraph:(t,r,o,a,n)=>ge(e,t,r,o,a,n)}),ye={Single:0,PrimaryWithAnchor:1},Te=e=>A({base_borrow_rate:f(e.baseBorrowRateRay),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),ve=e=>A({asset_decimals:h(e.assetDecimals),asset_id:m(e.assetId),base_borrow_rate:f(e.baseBorrowRateRay),flashloan_fee:h(e.flashloanFeeBps),is_flashloanable:b(e.isFlashloanable),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),xe=e=>A({max_borrow_positions:h(e.maxBorrowPositions),max_supply_positions:h(e.maxSupplyPositions)}),Re=e=>{const t=e.kind;switch(t){case"Stellar":return y([g("Stellar"),m(e.value)]);case"Symbol":return y([g("Symbol"),g(e.value)]);case"String":return y([g("String"),_(e.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${t}"`)}},ke=(e,t)=>{if("Twap"===e){if("number"!=typeof t)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return y([g("Twap"),h(t)])}return y([g("Spot")])},Ee=e=>{const t=e.provider;if("ReflectorSep40"===t){if(!e.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return y([g("Reflector"),A({asset:Re(e.asset),contract:m(e.contract),read_mode:ke(e.readMode,e.twapRecords)})])}if("RedStonePriceFeed"===t){if("string"!=typeof e.feedId)throw new Error("Stellar builder: RedStone oracle source requires `feedId`");if("number"!=typeof e.maxStaleSeconds)throw new Error("Stellar builder: RedStone oracle source requires `maxStaleSeconds`");return y([g("RedStone"),A({contract:m(e.contract),feed_id:_(e.feedId),max_stale_seconds:S(e.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${t}"`)},Ae=e=>{const t=ye[e.strategy];if(void 0===t)throw new Error(`Stellar builder: unknown oracle strategy "${e.strategy}"`);return A({anchor:(r=e.anchor,y(null==r?[g("None")]:[g("Some"),Ee(r)])),max_price_stale_seconds:S(e.maxPriceStaleSeconds),max_sanity_price_wad:f(e.maxSanityPriceWad),min_sanity_price_wad:f(e.minSanityPriceWad),primary:Ee(e.primary),strategy:h(t),tolerance_bps:h(e.toleranceBps)});var r};function Ie(e,t){return $(e,"upgrade",[T(t.wasmHash)])}function Pe(e,t){return $(e,"migrate",[h(t.newVersion)])}function Oe(e){return $(e,"pause",[])}function Be(e){return $(e,"unpause",[])}function Le(e,t){return $(e,"grant_role",[m(t.account),g(t.role)])}function Ne(e,t){return $(e,"revoke_role",[m(t.account),g(t.role)])}function $e(e,t){return $(e,"transfer_ownership",[m(t.newOwner),h(t.liveUntilLedger)])}function Ue(e){return $(e,"accept_ownership",[])}function Ce(e,t){return $(e,"set_aggregator",[m(t.aggregator)])}function qe(e,t){return $(e,"set_accumulator",[m(t.accumulator)])}function Ge(e,t){return $(e,"set_liquidity_pool_template",[T(t.wasmHash)])}function De(e,t){return $(e,"set_position_limits",[xe(t)])}function Ve(e,t){return $(e,"approve_token",[m(t.token)])}function We(e,t){return $(e,"revoke_token",[m(t.token)])}function ze(e,t){return $(e,"set_market_oracle_config",[R(t.hubId,t.asset),Ae(t.config)])}function Me(e,t){return $(e,"set_oracle_tolerance",[m(t.asset),A({lower_ratio_bps:h(t.lowerRatioBps),upper_ratio_bps:h(t.upperRatioBps)})])}function Xe(e,t){return $(e,"update_indexes",[m(e.caller),y(t.assets.map((e=>R(e.hubId,e.asset))))])}function Fe(e,t){return $(e,"renew_account",[m(e.caller),S(t.accountNonce)])}function He(e,t){return $(e,"create_liquidity_pool",[h(t.hubId),m(t.asset),ve(t.params)])}function je(e,t){return $(e,"upgrade_liquidity_pool_params",[R(t.hubId,t.asset),Te(t.params)])}function Qe(e,t){return $(e,"claim_revenue",[m(e.caller),y(t.assets.map((e=>R(e.hubId,e.asset))))])}function Ke(e,t){return $(e,"add_rewards",[m(e.caller),E(t.rewards)])}function Ze(e,t){return $(e,"update_account_threshold",[m(e.caller),b(t.hasRisks),y(t.accountNonces.map((e=>S(e))))])}const Ye="00".repeat(32),Je=e=>{if("string"==typeof e)return T(e);const t=Buffer.from(e);if(32!==t.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${t.length} bytes)`);return d.xdr.ScVal.scvBytes(t)},et=(e,...t)=>y([g(e),...t]),tt=e=>A({asset:m(e.asset),hub_id:h(e.hubId),params:ve(e.params)}),rt=e=>A({hub_asset:R(e.hubId,e.asset),params:Te(e.params)}),ot=e=>A({new_owner:m(e.newOwner),live_until_ledger:h(e.liveUntilLedger)}),at=e=>A({cfg:Ae(e.config),hub_asset:R(e.hubId,e.asset)}),nt=e=>A({asset:m(e.asset),bonus:h(e.bonus),borrow_cap:f(e.borrowCap),can_borrow:b(e.canBorrow),can_collateral:b(e.canCollateral),frozen:b(e.frozen),hub_id:h(e.hubId),paused:b(e.paused),liquidation_fees:h(e.liquidationFees),ltv:h(e.ltv),oracle_override:y([g("None")]),spoke_id:h(e.spokeId),supply_cap:f(e.supplyCap),threshold:h(e.threshold)}),st=e=>A({hub_asset:R(e.hubId,e.asset),spoke_id:h(e.spokeId)}),it=e=>A({hf_for_max_bonus_wad:f(e.hfForMaxBonusWad),liquidation_bonus_factor_bps:h(e.liquidationBonusFactorBps),spoke_id:h(e.spokeId),target_hf_wad:f(e.targetHfWad)}),lt=e=>A({asset:m(e.asset),tolerance:h(e.tolerance)}),ut=e=>A({account:m(e.account),role:g(e.role)});function ct(e,t,r){const o=e.governanceAddress??c(e.network),a=new d.Contract(o),n=new d.Account(e.caller,e.sourceSequence);return{xdr:new d.TransactionBuilder(n,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const dt=(e,t,r)=>ct(e,"propose",[m(e.caller),t,Je(r)]),pt=(e,t,r)=>ct(e,"execute_self",[w(),t,Je(r)]);function mt(e,t,r){return dt(e,et("SetAggregator",m(t.aggregator)),r)}function ft(e,t,r){return dt(e,et("SetAccumulator",m(t.accumulator)),r)}function ht(e,t,r){return dt(e,et("SetLiquidityPoolTemplate",T(t.wasmHash)),r)}function St(e,t,r){return dt(e,et("SetPositionLimits",xe(t)),r)}function bt(e,t){return dt(e,et("CreateHub"),t)}function _t(e,t){return dt(e,et("AddSpoke"),t)}function gt(e,t,r){return dt(e,et("RemoveSpoke",h(t.spokeId)),r)}function wt(e,t,r){return dt(e,et("AddAssetToSpoke",nt(t)),r)}function yt(e,t,r){return dt(e,et("EditAssetInSpoke",nt(t)),r)}function Tt(e,t,r){return dt(e,et("RemoveAssetFromSpoke",st(t)),r)}function vt(e,t,r){return dt(e,et("SetSpokeLiquidationCurve",it(t)),r)}function xt(e,t,r){return dt(e,et("SetPositionManager",m(t.manager),b(t.isActive)),r)}function Rt(e,t,r){return dt(e,et("SetMinBorrowCollateralUsd",f(t.floorWad)),r)}function kt(e,t,r){return dt(e,et("ApproveToken",m(t.token)),r)}function Et(e,t,r){return dt(e,et("RevokeToken",m(t.token)),r)}function At(e,t,r){return dt(e,et("ApproveBlendPool",m(t.pool)),r)}function It(e,t,r){return dt(e,et("RevokeBlendPool",m(t.pool)),r)}function Pt(e,t,r){return dt(e,et("CreateLiquidityPool",tt(t)),r)}function Ot(e,t,r){return dt(e,et("UpgradeLiquidityPoolParams",rt(t)),r)}function Bt(e,t){return dt(e,et("DeployPool"),t)}function Lt(e,t,r){return dt(e,et("UpgradePool",T(t.wasmHash)),r)}function Nt(e,t,r){return dt(e,et("UpgradeController",T(t.wasmHash)),r)}function $t(e,t,r){return dt(e,et("MigrateController",h(t.newVersion)),r)}function Ut(e,t,r){return dt(e,et("TransferCtrlOwnership",ot(t)),r)}function Ct(e,t,r){return dt(e,et("ConfigureMarketOracle",at(t)),r)}function qt(e,t,r){return dt(e,et("EditOracleTolerance",lt(t)),r)}function Gt(e,t,r){return dt(e,et("UpgradeGov",T(t.wasmHash)),r)}function Dt(e,t,r){return dt(e,et("UpdateGovDelay",h(t.newDelay)),r)}function Vt(e,t,r){return dt(e,et("GrantGovRole",ut(t)),r)}function Wt(e,t,r){return dt(e,et("RevokeGovRole",ut(t)),r)}function zt(e,t,r){return dt(e,et("TransferGovOwnership",ot(t)),r)}function Mt(e,t){const r=y(t.argsXdr.map((e=>d.xdr.ScVal.fromXDR(e,"base64")))),o=Je(t.predecessor??Ye);return ct(e,"execute",[w(),m(t.target),g(t.functionName),r,o,Je(t.salt)])}function Xt(e,t,r){return pt(e,et("UpgradeGov",T(t.wasmHash)),r)}function Ft(e,t,r){return pt(e,et("UpdateGovDelay",h(t.newDelay)),r)}function Ht(e,t,r){return pt(e,et("GrantGovRole",ut(t)),r)}function jt(e,t,r){return pt(e,et("RevokeGovRole",ut(t)),r)}function Qt(e,t,r){return pt(e,et("TransferGovOwnership",ot(t)),r)}const Kt=e=>e.toXDR("base64"),Zt=e=>d.xdr.ScVal.fromXDR(e,"base64"),Yt=e=>e.map((e=>String((0,d.scValToNative)(Zt(e))))).join(":"),Jt=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),er=e=>Number(e),tr=e=>String(e),rr=e=>null==e?void 0:Jt(e),or=e=>null==e?void 0:tr(e),ar=e=>e instanceof Uint8Array?Buffer.from(e).toString("hex"):Buffer.isBuffer(e)?e.toString("hex"):String(e),nr=["None","Multiply","Long","Short"],sr=["Single","PrimaryWithAnchor"],ir=["ReflectorSep40","RedStonePriceFeed"],lr=["Spot","Twap"],ur=["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"],cr=e=>Array.isArray(e)?e:[],dr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],ur[er(o)]??Jt(o)),positionType:t,hubId:er(e[1]),asset:tr(e[2]),scaledAmountRay:Jt(e[3]),indexRay:Jt(e[4]),amount:Jt(e[5]),liquidationThresholdBps:r?void 0:er(e[6]),liquidationBonusBps:r?void 0:er(e[7]),loanToValueBps:r?void 0:er(e[8]),liquidationFeesBps:r?void 0:er(e[9])};var o},pr=e=>{return{owner:tr(e[0]),spokeId:er(e[1]),mode:(t=e[2],nr[er(t)]??"None")};var t},mr=(e,t)=>{const r=lr[er(e[`${t}_read_mode`])]??"Spot",o=e[`${t}_asset`],a=e[`${t}_symbol`],n=null!=o?{kind:"Stellar",value:tr(o)}:null!=a?{kind:"Symbol",value:tr(a)}:void 0;return{provider:ir[er(e[`${t}_provider`])]??"ReflectorSep40",contractAddress:tr(e[`${t}_contract`]),asset:n,feedId:or(e[`${t}_feed_id`]),readMode:r,twapRecords:"Twap"===r?er(e[`${t}_twap_records`]):void 0,decimals:er(e[`${t}_decimals`]),resolutionSeconds:er(e[`${t}_resolution_seconds`]),maxStaleSeconds:er(e[`${t}_max_stale_seconds`])}},fr=e=>{const t=null!==e.anchor_provider&&void 0!==e.anchor_provider;return{baseTokenId:tr(e.base_token_id),quoteTokenId:tr(e.quote_token_id),tolerance:{upperRatio:er(e.upper_ratio_bps??e.tolerance?.upper_ratio_bps),lowerRatio:er(e.lower_ratio_bps??e.tolerance?.lower_ratio_bps)},assetDecimals:er(e.asset_decimals),maxPriceStaleSeconds:er(e.max_price_stale_seconds),strategy:sr[er(e.strategy)]??"Single",primary:mr(e,"primary"),anchor:t?mr(e,"anchor"):void 0,primaryQuoteToken:or(e.primary_quote_token),anchorQuoteToken:or(e.anchor_quote_token),minSanityPriceWad:rr(e.min_sanity_price_wad),maxSanityPriceWad:rr(e.max_sanity_price_wad)}},hr={"market:create":e=>({topic:"market:create",data:{hubId:er(e.hub_id),baseAsset:tr(e.base_asset),maxBorrowRate:Jt(e.max_borrow_rate),baseBorrowRate:Jt(e.base_borrow_rate),slope1:Jt(e.slope1),slope2:Jt(e.slope2),slope3:Jt(e.slope3),midUtilization:Jt(e.mid_utilization),optimalUtilization:Jt(e.optimal_utilization),maxUtilization:Jt(e.max_utilization),reserveFactor:er(e.reserve_factor),marketAddress:tr(e.market_address)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:tr(e.asset),maxBorrowRateRay:Jt(e.max_borrow_rate),baseBorrowRateRay:Jt(e.base_borrow_rate),slope1Ray:Jt(e.slope1),slope2Ray:Jt(e.slope2),slope3Ray:Jt(e.slope3),midUtilizationRay:Jt(e.mid_utilization),optimalUtilizationRay:Jt(e.optimal_utilization),maxUtilizationRay:Jt(e.max_utilization),reserveFactorBps:er(e.reserve_factor)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:cr(e).map((e=>{return t=cr(e),{hubId:er(t[0]),asset:tr(t[1]),timestamp:er(t[2]),supplyIndexRay:Jt(t[3]),borrowIndexRay:Jt(t[4]),cash:Jt(t[5]),suppliedRay:Jt(t[6]),borrowedRay:Jt(t[7]),revenueRay:Jt(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:cr(e).map((e=>{const t=e;return{hubId:er(t.hub_id),asset:tr(t.asset),params:(r=t.params,{maxBorrowRateRay:Jt(r.max_borrow_rate),baseBorrowRateRay:Jt(r.base_borrow_rate),slope1Ray:Jt(r.slope1),slope2Ray:Jt(r.slope2),slope3Ray:Jt(r.slope3),midUtilizationRay:Jt(r.mid_utilization),optimalUtilizationRay:Jt(r.optimal_utilization),maxUtilizationRay:Jt(r.max_utilization),reserveFactorBps:er(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:er(r.flashloan_fee),assetId:tr(r.asset_id),assetDecimals:er(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=cr(e);return{topic:"position:batch_update",data:{accountId:Jt(t[0]),accountAttributes:pr(cr(t[1])),updates:[...cr(t[2]).map((e=>dr(cr(e),"Deposit"))),...cr(t[3]).map((e=>dr(cr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{hubId:er(e.hub_id),asset:tr(e.asset),receiver:tr(e.receiver),caller:tr(e.caller),amount:Jt(e.amount),fee:Jt(e.fee)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:tr(e.asset),oracle:fr(e.oracle)}}),"position:liquidation":e=>({topic:"position:liquidation",data:{liquidator:tr(e.liquidator),accountId:Jt(e.account_id),repaidUsdWad:Jt(e.repaid_usd_wad),bonusBps:Jt(e.bonus_bps)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:Jt(e.account_id),totalBorrowUsdWad:Jt(e.total_borrow_usd_wad),totalCollateralUsdWad:Jt(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:tr(e.token),amount:Jt(e.amount),usdValueWad:Jt(e.usd_value_wad),accountId:Jt(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{hubId:er(e.hub_id),asset:tr(e.asset),amount:Jt(e.amount),fee:Jt(e.fee),amountSent:Jt(e.amount_sent)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:ar(e.wasm_hash),approved:Boolean(e.approved)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:tr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:tr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:ar(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:er(e.max_supply_positions),maxBorrowPositions:er(e.max_borrow_positions)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:tr(e.asset)}}),"config:spoke":e=>{const t=e.spoke;return{topic:"config:spoke",data:{spokeId:er(t.spoke_id),isDeprecated:Boolean(t.is_deprecated),liquidationTargetHfWad:Jt(t.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Jt(t.hf_for_max_bonus_wad),liquidationBonusFactorBps:er(t.liquidation_bonus_factor_bps)}}}},Sr=Object.freeze(Object.keys(hr));function br(e,t){const r=Yt(e),o=hr[r];return o?o((0,d.scValToNative)(Zt(t))):null}const _r="XLENDXLM-a7c9f3",gr=1e4;function wr(e){const t=BigInt(e).toString(16),r=t.length%2==0?t:`0${t}`;return`${_r}-${r}`}function yr(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function Tr(e,t=0){return e*gr+t}function vr(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const xr=(e,t,r)=>{const o=new URL(t,e.endsWith("/")?e:`${e}/`);if(r)for(const[e,t]of Object.entries(r))void 0!==t&&o.searchParams.set(e,String(t));return o.toString()},Rr=e=>e.baseUrl??s[e.network];async function kr(e,t){if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=xr(Rr(t),"api/v1/quote",{from:e.from,to:e.to,amountIn:e.amountIn,amountOut:e.amountOut,maxHops:e.maxHops,maxSplits:e.maxSplits,slippage:e.slippage,includePaths:e.includePaths,sender:e.sender,router:e.router,platform:e.platform,fresh:e.fresh}),o=await fetch(r,t.fetchOptions);if(!o.ok){const e=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${e}`)}return await o.json()}async function Er(e){const t=xr(Rr(e),"api/v1/tokens"),r=await fetch(t,e.fetchOptions);if(!r.ok){const e=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${t} — ${e}`)}return await r.json()}const Ar=(e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e,Ir=e=>I(e).toXDR("base64");function Pr(e,t){const r=e.routerAddress??u(e.network),o=new d.Contract(r),a=new d.Account(e.caller,e.sourceSequence),n=L(Ar(t,e.referralId));return{xdr:new d.TransactionBuilder(a,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(o.call("execute_strategy",m(e.caller),f(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Or(e,t){return Pr(e,t)}function Br(e,t={}){if("string"!=typeof e.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:e.paths?e.paths.map((e=>({hops:e.swaps.map($r),splitPpm:e.splitPpm}))):[{hops:e.hops.map($r),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function Lr(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:Br(e,t)}const Nr=Br,$r=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function Ur(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function Cr(e,t,r){const o=d.TransactionBuilder.fromXDR(t,"base64");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw Ur(r.invokedContractId,e);throw e}}async function qr(e,t,r){return Cr(e,t.xdr,r)}function Gr(e){if(e<=0||e>4)throw new Error(`Invalid PositionMode ${e} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return e-1}function Dr(e,t){return new Uint8Array(0)}const Vr=e=>{const t=e.startsWith("0x")?e.slice(2):e;if(t.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return Buffer.from(t,"hex")};function Wr(e){const t=new d.Account(e.caller,e.sourceSequence),r=new d.Contract(e.forwarderAddress).call("mint_and_forward",d.xdr.ScVal.scvBytes(Vr(e.message)),d.xdr.ScVal.scvBytes(Vr(e.attestation)));return{xdr:new d.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:i[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const zr={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:"InvalidPoolTemplate",message:"The liquidity pool template hash is 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."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetsLimitReached",message:"This spoke has reached its asset limit."},314:{name:"SpokeCapBelowUsage",message:"The new cap is below current usage on this spoke asset."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},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 Mr(e){const t=e.match(/Error\(Contract,\s*#(\d+)\)/);if(!t)return null;const r=Number(t[1]),o=zr[r];return o?{code:r,...o}:null}module.exports=t})();
1
+ "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis),(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{STELLAR_AGGREGATOR_ROUTER:()=>o,STELLAR_GOVERNANCE:()=>a,STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>Je,STELLAR_LENDING_CONTROLLER:()=>r,STELLAR_LENDING_TOPICS:()=>br,STELLAR_NETWORK_PASSPHRASE:()=>i,STELLAR_QUOTE_URL:()=>s,STELLAR_SOROBAN_RPC_URL:()=>n,SYNTHETIC_EVENT_ORDER_STRIDE:()=>wr,XOXNO_LENDING_STELLAR_TICKER:()=>gr,buildSameTokenRepaySwapSteps:()=>Vr,buildStellarAcceptOwnershipTx:()=>Ce,buildStellarAddRewardsTx:()=>Ze,buildStellarApproveTokenTx:()=>We,buildStellarBatchSwapTx:()=>Br,buildStellarBorrowBatchTx:()=>q,buildStellarBorrowTx:()=>G,buildStellarCctpForwardTx:()=>zr,buildStellarClaimRevenueTx:()=>Ke,buildStellarCreateLiquidityPoolTx:()=>je,buildStellarExecuteStrategyTx:()=>Or,buildStellarFlashLoanTx:()=>X,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>Ft,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>jt,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>Qt,buildStellarGovernanceExecuteTransferGovOwnTx:()=>Kt,buildStellarGovernanceExecuteTx:()=>Xt,buildStellarGovernanceExecuteUpdateDelayTx:()=>Ht,buildStellarGrantRoleTx:()=>$e,buildStellarLendingIdentifier:()=>yr,buildStellarLiquidateTx:()=>M,buildStellarMigrateFromBlendTx:()=>F,buildStellarMigrateTx:()=>Oe,buildStellarMultiplyTx:()=>H,buildStellarPauseTx:()=>Be,buildStellarProposeAddAssetToSpokeTx:()=>yt,buildStellarProposeAddSpokeTx:()=>gt,buildStellarProposeApproveBlendPoolTx:()=>It,buildStellarProposeApproveTokenTx:()=>Et,buildStellarProposeConfigureMarketOracleTx:()=>qt,buildStellarProposeCreateHubTx:()=>_t,buildStellarProposeCreateLiquidityPoolTx:()=>Ot,buildStellarProposeDeployPoolTx:()=>Lt,buildStellarProposeEditAssetInSpokeTx:()=>Tt,buildStellarProposeEditOracleToleranceTx:()=>Gt,buildStellarProposeGovernanceUpgradeTx:()=>Dt,buildStellarProposeGrantGovernanceRoleTx:()=>Wt,buildStellarProposeMigrateControllerTx:()=>Ut,buildStellarProposeRemoveAssetFromSpokeTx:()=>vt,buildStellarProposeRemoveSpokeTx:()=>wt,buildStellarProposeRevokeBlendPoolTx:()=>Pt,buildStellarProposeRevokeGovernanceRoleTx:()=>zt,buildStellarProposeRevokeTokenTx:()=>At,buildStellarProposeSetAccumulatorTx:()=>ht,buildStellarProposeSetAggregatorTx:()=>ft,buildStellarProposeSetMinBorrowCollatTx:()=>kt,buildStellarProposeSetPoolTemplateTx:()=>St,buildStellarProposeSetPositionLimitsTx:()=>bt,buildStellarProposeSetPositionManagerTx:()=>Rt,buildStellarProposeSetSpokeLiquidationCurveTx:()=>xt,buildStellarProposeTransferCtrlOwnershipTx:()=>Ct,buildStellarProposeTransferGovOwnTx:()=>Mt,buildStellarProposeUpdateDelayTx:()=>Vt,buildStellarProposeUpgradeControllerTx:()=>Nt,buildStellarProposeUpgradePoolParamsTx:()=>Bt,buildStellarProposeUpgradePoolTx:()=>$t,buildStellarRenewAccountTx:()=>He,buildStellarRepayBatchTx:()=>W,buildStellarRepayDebtWithCollateralTx:()=>K,buildStellarRepayTx:()=>z,buildStellarRevokeRoleTx:()=>Ne,buildStellarRevokeTokenTx:()=>ze,buildStellarSetAccumulatorTx:()=>Ge,buildStellarSetAggregatorTx:()=>qe,buildStellarSetLiquidityPoolTemplateTx:()=>De,buildStellarSetMarketOracleConfigTx:()=>Me,buildStellarSetOracleToleranceTx:()=>Xe,buildStellarSetPositionLimitsTx:()=>Ve,buildStellarSupplyBatchTx:()=>U,buildStellarSupplyTx:()=>C,buildStellarSwapCollateralTx:()=>Q,buildStellarSwapDebtTx:()=>j,buildStellarTransferOwnershipTx:()=>Ue,buildStellarUnpauseTx:()=>Le,buildStellarUpdateAccountThresholdTx:()=>Ye,buildStellarUpdateIndexesTx:()=>Fe,buildStellarUpgradeControllerTx:()=>Pe,buildStellarUpgradeLiquidityPoolParamsTx:()=>Qe,buildStellarWithdrawBatchTx:()=>D,buildStellarWithdrawTx:()=>V,buildTx:()=>N,decodeStellarLendingEvent:()=>_r,encodeInterestRateModel:()=>ve,encodeMarketOracleConfigInput:()=>Ie,encodeMarketParamsRaw:()=>xe,encodeOracleSourceConfigInput:()=>Ae,encodePositionLimits:()=>Re,encodeStrategyPayloadToRouteXdr:()=>Pr,extractEventOrder:()=>Tr,getStellarAccountPositions:()=>fe,getStellarAggregatorQuote:()=>Er,getStellarAggregatorRouter:()=>u,getStellarAsset:()=>ie,getStellarAssetGraph:()=>Se,getStellarAssetMarkets:()=>ue,getStellarAssetPage:()=>le,getStellarAssets:()=>te,getStellarGovernance:()=>c,getStellarGovernanceProposals:()=>he,getStellarHub:()=>ce,getStellarHubGraph:()=>be,getStellarHubs:()=>re,getStellarLendingContext:()=>ee,getStellarLendingController:()=>l,getStellarQuoteTokens:()=>Ar,getStellarReserve:()=>ne,getStellarReserveGraph:()=>ge,getStellarReserveHolders:()=>se,getStellarReserves:()=>ae,getStellarSpoke:()=>de,getStellarSpokeGraph:()=>_e,getStellarSpokes:()=>oe,getStellarUserActivity:()=>me,getStellarUserPositions:()=>pe,mapQuoteResponseToAggregatorSwap:()=>Nr,mapQuoteResponseToStrategyPayload:()=>Lr,mapQuoteResponseToStrategySwap:()=>$r,mapSorobanError:()=>Xr,mapStellarPositionActivityType:()=>xr,prepareStellarBuiltTx:()=>Gr,prepareStellarTxXdr:()=>qr,stellarLendingDispatchKey:()=>Jt,stellarLendingRead:()=>we,syntheticEventOrder:()=>vr,tagStellarInvokedContractError:()=>Cr,toBase64Xdr:()=>Zt,toStellarPositionMode:()=>Dr});const r={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},o={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},a={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},n={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},s={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"},i={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function l(e){const t=r[e];if(!t)throw new Error(`Stellar lending controller address not configured for network "${e}". Set STELLAR_LENDING_CONTROLLER_${e.toUpperCase()} env var.`);return t}function u(e){const t=o[e];if(!t)throw new Error(`Stellar aggregator router address not configured for network "${e}". Set STELLAR_AGGREGATOR_ROUTER_${e.toUpperCase()} env var.`);return t}function c(e){const t=a[e];if(!t)throw new Error(`Stellar governance address not configured for network "${e}". Set STELLAR_GOVERNANCE_${e.toUpperCase()} env var.`);return t}const d=require("@stellar/stellar-sdk"),p=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],m=e=>new d.Address(e).toScVal(),f=e=>new d.ScInt(e).toI128(),h=e=>d.xdr.ScVal.scvU32(e),S=e=>new d.ScInt("string"==typeof e?e:e.toString()).toU64(),b=e=>d.xdr.ScVal.scvBool(e),_=e=>d.xdr.ScVal.scvString(e),g=e=>d.xdr.ScVal.scvSymbol(e),w=()=>d.xdr.ScVal.scvVoid(),y=e=>d.xdr.ScVal.scvVec(e),T=(e,t=32)=>{const r=e.startsWith("0x")?e.slice(2):e,o=Buffer.from(r,"hex");if(o.length!==t)throw new Error(`Stellar builder: expected a ${t}-byte BytesN (got ${o.length} bytes from "${e}")`);return d.xdr.ScVal.scvBytes(o)},v=(e,t)=>null==e?w():t(e),x=e=>d.xdr.ScVal.scvVec(e.map((e=>{return t=e.token,r=e.amount,d.xdr.ScVal.scvVec([m(t),f(r)]);var t,r}))),R=(e,t)=>A({asset:m(t),hub_id:h(e)}),k=(e,t,r)=>d.xdr.ScVal.scvVec([R(e,t),f(r)]),E=e=>d.xdr.ScVal.scvVec(e.map((e=>k(e.hubId,e.asset,e.amount)))),A=e=>{const t=Object.keys(e).sort().map((t=>new d.xdr.ScMapEntry({key:g(t),val:e[t]})));return d.xdr.ScVal.scvMap(t)},I=e=>{const t=e.paths.map((e=>{const t=e.hops.map((e=>{return A({amount_out:f(e.amountOut),pool:m(e.pool),token_in:m(e.tokenIn),token_out:m(e.tokenOut),venue:(t=e.venue,d.xdr.ScVal.scvVec([g(t)]))});var t}));return A({hops:d.xdr.ScVal.scvVec(t),split_ppm:h(e.splitPpm)})}));return A({paths:d.xdr.ScVal.scvVec(t),referral_id:S(e.referralId??0),token_in:m(e.tokenIn),token_out:m(e.tokenOut),total_min_out:f(e.totalMinOut)})},P=e=>{const t=Buffer.from(e);if(0===t.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return d.xdr.ScVal.scvBytes(t)},O=()=>d.xdr.ScVal.scvBytes(Buffer.alloc(0)),B=e=>{const t=e.trim();if(t.startsWith("0x")){const e=t.slice(2);if(!((r=e).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return Buffer.from(e,"hex")}var r;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const o=Buffer.from(t,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},L=e=>{if("string"==typeof e)return P(B(e));if(e instanceof Uint8Array)return 0===e.length?O():P(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?P(B(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?P(B(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?P(B(e.bytes)):0===e.bytes.length?O():P(e.bytes):(t=(e=>{if(!e||"object"!=typeof e)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const t=e;if(!Array.isArray(t.paths)||0===t.paths.length)throw new Error("Stellar builder: `steps.paths` must be a non-empty array of strategy paths");if("string"!=typeof t.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof t.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof t.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");let r=0;for(const[e,o]of t.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.hops.length)throw new Error(`Stellar builder: \`steps.paths[${e}]\` must have splitPpm > 0 and a non-empty hops array`);r+=o.splitPpm;for(const[t,r]of o.hops.entries())if(!r||"string"!=typeof r.amountOut||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!p.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${e}].hops[${t}]\` must have amountOut, pool, tokenIn, tokenOut, and a valid Soroban venue`)}if(1e6!==r)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` must sum to 1_000_000, got ${r}`);return t})(e),d.xdr.ScVal.scvBytes(Buffer.from(I(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},$=e=>{if("string"==typeof e)return(e=>{const t=e.startsWith("0x")?e.slice(2):e,r=Buffer.from(t,"hex");return d.xdr.ScVal.scvBytes(r)})(e);if(e instanceof Uint8Array)return d.xdr.ScVal.scvBytes(Buffer.from(e));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function N(e,t,r){const o=e.controllerAddress??l(e.network),a=new d.Contract(o),n=new d.Account(e.caller,e.sourceSequence);return{xdr:new d.TransactionBuilder(n,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function U(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return N(e,"supply",[m(e.caller),S(r),h(o),E([...t.assets])])}function C(e,t){return U(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function q(e,t){return N(e,"borrow",[m(e.caller),S(t.accountNonce),E([...t.borrows]),v(t.to,m)])}function G(e,t){return q(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function D(e,t){return N(e,"withdraw",[m(e.caller),S(t.accountNonce),E([...t.withdrawals]),v(t.to,m)])}function V(e,t){return D(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function W(e,t){return N(e,"repay",[m(e.caller),S(t.accountNonce),E([...t.payments])])}function z(e,t){return W(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function M(e,t){return N(e,"liquidate",[m(e.caller),S(t.accountNonce),E([...t.debtPayments])])}function X(e,t){return N(e,"flash_loan",[m(e.caller),R(t.hubId,t.asset),f(t.amount),m(t.receiver),$(t.data)])}function F(e,t){return N(e,"migrate_from_blend",[m(e.caller),S(t.accountId),h(t.spokeId),h(t.hubId),m(t.blendPool),y(t.collateralTokens.map(m)),y(t.supplyTokens.map(m)),x(t.debtCaps.map((e=>({token:e.token,amount:e.cap}))))])}function H(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return N(e,"multiply",[m(e.caller),S(r),h(o),R(t.collateral.hubId,t.collateral.asset),f(t.debtToFlashLoan),R(t.debt.hubId,t.debt.asset),h(t.mode),L(t.steps),v(t.initialPayment,(e=>k(e.hubId,e.asset,e.amount))),v(t.convertSwap,L)])}function j(e,t){return N(e,"swap_debt",[m(e.caller),S(t.accountNonce),R(t.existingDebt.hubId,t.existingDebt.asset),f(t.newDebtAmount),R(t.newDebt.hubId,t.newDebt.asset),L(t.steps)])}function Q(e,t){return N(e,"swap_collateral",[m(e.caller),S(t.accountNonce),R(t.current.hubId,t.current.asset),f(t.fromAmount),R(t.newCollateral.hubId,t.newCollateral.asset),L(t.steps)])}function K(e,t){return N(e,"repay_debt_with_collateral",[m(e.caller),S(t.accountNonce),R(t.collateral.hubId,t.collateral.asset),f(t.collateralAmount),R(t.debt.hubId,t.debt.asset),L(t.steps),b(t.closePosition)])}const Z="/stellar-lending",Y=25,J=encodeURIComponent,ee=(e,t)=>e.fetchWithTimeout(`${Z}/context`,t),te=(e,t)=>e.fetchWithTimeout(`${Z}/assets`,t),re=(e,t)=>e.fetchWithTimeout(`${Z}/hubs`,t),oe=(e,t)=>e.fetchWithTimeout(`${Z}/spokes`,t),ae=(e,t={},r)=>{const{hubId:o,spokeId:a,asset:n}=t;return e.fetchWithTimeout(`${Z}/reserves`,{...r,params:{...void 0!==o?{hubId:o}:{},...void 0!==a?{spokeId:a}:{},...n?{asset:n}:{}}})},ne=(e,t,r,o,a)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}`,a),se=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}/holders`,{...n,params:{side:a}}),ie=(e,t,r)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}`,r),le=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/page`,{...o,params:{...r}}),ue=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/markets`,{...o,params:{side:r}}),ce=(e,t,r)=>e.fetchWithTimeout(`${Z}/hubs/${t}`,r),de=(e,t,r)=>e.fetchWithTimeout(`${Z}/spokes/${t}`,r),pe=(e,t,r)=>e.fetchWithTimeout(`${Z}/users/${J(t)}/positions`,r),me=(e,t,r={},o)=>{const{skip:a,top:n}=r;return e.fetchWithTimeout(`${Z}/users/${J(t)}/activity`,{...o,params:{...void 0!==a?{skip:a}:{},...void 0!==n?{top:n}:{}}})},fe=(e,t,r)=>e.fetchWithTimeout(`${Z}/accounts/${J(t)}/positions`,r),he=(e,t={},r)=>{const{top:o=Y,continuationToken:a}=t;return e.fetchWithTimeout(`${Z}/governance/proposals`,{...r,params:{top:o,...a?{continuationToken:a}:{}}})},Se=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/assets/${J(t)}/graph`,{...o,params:{...r}}),be=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/hubs/${t}/graph`,{...o,params:{...r}}),_e=(e,t,r,o)=>e.fetchWithTimeout(`${Z}/spokes/${t}/graph`,{...o,params:{...r}}),ge=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${Z}/reserves/${t}/${r}/${J(o)}/graph`,{...n,params:{...a}}),we=e=>({context:t=>ee(e,t),assets:t=>te(e,t),hubs:t=>re(e,t),spokes:t=>oe(e,t),reserves:(t,r)=>{return void 0===(o=t)||"hubId"in o||"spokeId"in o||"asset"in o?ae(e,t,r):ae(e,{},t);var o},reserve:(t,r,o,a)=>ne(e,t,r,o,a),reserveHolders:(t,r,o,a,n)=>se(e,t,r,o,a,n),asset:(t,r)=>ie(e,t,r),assetMarkets:(t,r,o)=>ue(e,t,r,o),hub:(t,r)=>ce(e,t,r),spoke:(t,r)=>de(e,t,r),userPositions:(t,r)=>pe(e,t,r),userActivity:(t,r,o)=>me(e,t,r,o),accountPositions:(t,r)=>fe(e,t,r),governanceProposals:(t,r)=>he(e,t,r),assetGraph:(t,r,o)=>Se(e,t,r,o),hubGraph:(t,r,o)=>be(e,t,r,o),spokeGraph:(t,r,o)=>_e(e,t,r,o),reserveGraph:(t,r,o,a,n)=>ge(e,t,r,o,a,n)}),ye={Single:0,PrimaryWithAnchor:1},Te="RedStonePriceFeed",ve=e=>A({base_borrow_rate:f(e.baseBorrowRateRay),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),xe=e=>A({asset_decimals:h(e.assetDecimals),asset_id:m(e.assetId),base_borrow_rate:f(e.baseBorrowRateRay),flashloan_fee:h(e.flashloanFeeBps),is_flashloanable:b(e.isFlashloanable),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),Re=e=>A({max_borrow_positions:h(e.maxBorrowPositions),max_supply_positions:h(e.maxSupplyPositions)}),ke=e=>{const t=e.kind;switch(t){case"Stellar":return y([g("Stellar"),m(e.value)]);case"Symbol":return y([g("Symbol"),g(e.value)]);case"String":return y([g("String"),_(e.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${t}"`)}},Ee=(e,t)=>{if("Twap"===e){if("number"!=typeof t)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return y([g("Twap"),h(t)])}return y([g("Spot")])},Ae=e=>{const t=e.provider;if("ReflectorSep40"===t){if(!e.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return y([g("Reflector"),A({asset:ke(e.asset),contract:m(e.contract),read_mode:Ee(e.readMode,e.twapRecords)})])}if(t===Te||"XoxnoPriceFeed"===t){const r=t===Te?"RedStone":"Xoxno";if("string"!=typeof e.feedId)throw new Error(`Stellar builder: ${r} oracle source requires \`feedId\``);if("number"!=typeof e.maxStaleSeconds)throw new Error(`Stellar builder: ${r} oracle source requires \`maxStaleSeconds\``);return y([g(r),A({contract:m(e.contract),feed_id:_(e.feedId),max_stale_seconds:S(e.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${t}"`)},Ie=e=>{const t=ye[e.strategy];if(void 0===t)throw new Error(`Stellar builder: unknown oracle strategy "${e.strategy}"`);return A({anchor:(r=e.anchor,y(null==r?[g("None")]:[g("Some"),Ae(r)])),max_price_stale_seconds:S(e.maxPriceStaleSeconds),max_sanity_price_wad:f(e.maxSanityPriceWad),min_sanity_price_wad:f(e.minSanityPriceWad),primary:Ae(e.primary),strategy:h(t),tolerance_bps:h(e.toleranceBps)});var r};function Pe(e,t){return N(e,"upgrade",[T(t.wasmHash)])}function Oe(e,t){return N(e,"migrate",[h(t.newVersion)])}function Be(e){return N(e,"pause",[])}function Le(e){return N(e,"unpause",[])}function $e(e,t){return N(e,"grant_role",[m(t.account),g(t.role)])}function Ne(e,t){return N(e,"revoke_role",[m(t.account),g(t.role)])}function Ue(e,t){return N(e,"transfer_ownership",[m(t.newOwner),h(t.liveUntilLedger)])}function Ce(e){return N(e,"accept_ownership",[])}function qe(e,t){return N(e,"set_aggregator",[m(t.aggregator)])}function Ge(e,t){return N(e,"set_accumulator",[m(t.accumulator)])}function De(e,t){return N(e,"set_liquidity_pool_template",[T(t.wasmHash)])}function Ve(e,t){return N(e,"set_position_limits",[Re(t)])}function We(e,t){return N(e,"approve_token",[m(t.token)])}function ze(e,t){return N(e,"revoke_token",[m(t.token)])}function Me(e,t){return N(e,"set_market_oracle_config",[R(t.hubId,t.asset),Ie(t.config)])}function Xe(e,t){return N(e,"set_oracle_tolerance",[m(t.asset),A({lower_ratio_bps:h(t.lowerRatioBps),upper_ratio_bps:h(t.upperRatioBps)})])}function Fe(e,t){return N(e,"update_indexes",[m(e.caller),y(t.assets.map((e=>R(e.hubId,e.asset))))])}function He(e,t){return N(e,"renew_account",[m(e.caller),S(t.accountNonce)])}function je(e,t){return N(e,"create_liquidity_pool",[h(t.hubId),m(t.asset),xe(t.params)])}function Qe(e,t){return N(e,"upgrade_liquidity_pool_params",[R(t.hubId,t.asset),ve(t.params)])}function Ke(e,t){return N(e,"claim_revenue",[m(e.caller),y(t.assets.map((e=>R(e.hubId,e.asset))))])}function Ze(e,t){return N(e,"add_rewards",[m(e.caller),E(t.rewards)])}function Ye(e,t){return N(e,"update_account_threshold",[m(e.caller),b(t.hasRisks),y(t.accountNonces.map((e=>S(e))))])}const Je="00".repeat(32),et=e=>{if("string"==typeof e)return T(e);const t=Buffer.from(e);if(32!==t.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${t.length} bytes)`);return d.xdr.ScVal.scvBytes(t)},tt=(e,...t)=>y([g(e),...t]),rt=e=>A({asset:m(e.asset),hub_id:h(e.hubId),params:xe(e.params)}),ot=e=>A({hub_asset:R(e.hubId,e.asset),params:ve(e.params)}),at=e=>A({new_owner:m(e.newOwner),live_until_ledger:h(e.liveUntilLedger)}),nt=e=>A({cfg:Ie(e.config),hub_asset:R(e.hubId,e.asset)}),st=e=>A({asset:m(e.asset),bonus:h(e.bonus),borrow_cap:f(e.borrowCap),can_borrow:b(e.canBorrow),can_collateral:b(e.canCollateral),frozen:b(e.frozen),hub_id:h(e.hubId),paused:b(e.paused),liquidation_fees:h(e.liquidationFees),ltv:h(e.ltv),oracle_override:y([g("None")]),spoke_id:h(e.spokeId),supply_cap:f(e.supplyCap),threshold:h(e.threshold)}),it=e=>A({hub_asset:R(e.hubId,e.asset),spoke_id:h(e.spokeId)}),lt=e=>A({hf_for_max_bonus_wad:f(e.hfForMaxBonusWad),liquidation_bonus_factor_bps:h(e.liquidationBonusFactorBps),spoke_id:h(e.spokeId),target_hf_wad:f(e.targetHfWad)}),ut=e=>A({asset:m(e.asset),tolerance:h(e.tolerance)}),ct=e=>A({account:m(e.account),role:g(e.role)});function dt(e,t,r){const o=e.governanceAddress??c(e.network),a=new d.Contract(o),n=new d.Account(e.caller,e.sourceSequence);return{xdr:new d.TransactionBuilder(n,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const pt=(e,t,r)=>dt(e,"propose",[m(e.caller),t,et(r)]),mt=(e,t,r)=>dt(e,"execute_self",[w(),t,et(r)]);function ft(e,t,r){return pt(e,tt("SetAggregator",m(t.aggregator)),r)}function ht(e,t,r){return pt(e,tt("SetAccumulator",m(t.accumulator)),r)}function St(e,t,r){return pt(e,tt("SetLiquidityPoolTemplate",T(t.wasmHash)),r)}function bt(e,t,r){return pt(e,tt("SetPositionLimits",Re(t)),r)}function _t(e,t){return pt(e,tt("CreateHub"),t)}function gt(e,t){return pt(e,tt("AddSpoke"),t)}function wt(e,t,r){return pt(e,tt("RemoveSpoke",h(t.spokeId)),r)}function yt(e,t,r){return pt(e,tt("AddAssetToSpoke",st(t)),r)}function Tt(e,t,r){return pt(e,tt("EditAssetInSpoke",st(t)),r)}function vt(e,t,r){return pt(e,tt("RemoveAssetFromSpoke",it(t)),r)}function xt(e,t,r){return pt(e,tt("SetSpokeLiquidationCurve",lt(t)),r)}function Rt(e,t,r){return pt(e,tt("SetPositionManager",m(t.manager),b(t.isActive)),r)}function kt(e,t,r){return pt(e,tt("SetMinBorrowCollateralUsd",f(t.floorWad)),r)}function Et(e,t,r){return pt(e,tt("ApproveToken",m(t.token)),r)}function At(e,t,r){return pt(e,tt("RevokeToken",m(t.token)),r)}function It(e,t,r){return pt(e,tt("ApproveBlendPool",m(t.pool)),r)}function Pt(e,t,r){return pt(e,tt("RevokeBlendPool",m(t.pool)),r)}function Ot(e,t,r){return pt(e,tt("CreateLiquidityPool",rt(t)),r)}function Bt(e,t,r){return pt(e,tt("UpgradeLiquidityPoolParams",ot(t)),r)}function Lt(e,t){return pt(e,tt("DeployPool"),t)}function $t(e,t,r){return pt(e,tt("UpgradePool",T(t.wasmHash)),r)}function Nt(e,t,r){return pt(e,tt("UpgradeController",T(t.wasmHash)),r)}function Ut(e,t,r){return pt(e,tt("MigrateController",h(t.newVersion)),r)}function Ct(e,t,r){return pt(e,tt("TransferCtrlOwnership",at(t)),r)}function qt(e,t,r){return pt(e,tt("ConfigureMarketOracle",nt(t)),r)}function Gt(e,t,r){return pt(e,tt("EditOracleTolerance",ut(t)),r)}function Dt(e,t,r){return pt(e,tt("UpgradeGov",T(t.wasmHash)),r)}function Vt(e,t,r){return pt(e,tt("UpdateGovDelay",h(t.newDelay)),r)}function Wt(e,t,r){return pt(e,tt("GrantGovRole",ct(t)),r)}function zt(e,t,r){return pt(e,tt("RevokeGovRole",ct(t)),r)}function Mt(e,t,r){return pt(e,tt("TransferGovOwnership",at(t)),r)}function Xt(e,t){const r=y(t.argsXdr.map((e=>d.xdr.ScVal.fromXDR(e,"base64")))),o=et(t.predecessor??Je);return dt(e,"execute",[w(),m(t.target),g(t.functionName),r,o,et(t.salt)])}function Ft(e,t,r){return mt(e,tt("UpgradeGov",T(t.wasmHash)),r)}function Ht(e,t,r){return mt(e,tt("UpdateGovDelay",h(t.newDelay)),r)}function jt(e,t,r){return mt(e,tt("GrantGovRole",ct(t)),r)}function Qt(e,t,r){return mt(e,tt("RevokeGovRole",ct(t)),r)}function Kt(e,t,r){return mt(e,tt("TransferGovOwnership",at(t)),r)}const Zt=e=>e.toXDR("base64"),Yt=e=>d.xdr.ScVal.fromXDR(e,"base64"),Jt=e=>e.map((e=>String((0,d.scValToNative)(Yt(e))))).join(":"),er=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),tr=e=>Number(e),rr=e=>String(e),or=e=>null==e?void 0:er(e),ar=e=>null==e?void 0:rr(e),nr=e=>e instanceof Uint8Array?Buffer.from(e).toString("hex"):Buffer.isBuffer(e)?e.toString("hex"):String(e),sr=["None","Multiply","Long","Short"],ir=["Single","PrimaryWithAnchor"],lr=["ReflectorSep40","RedStonePriceFeed"],ur=["Spot","Twap"],cr=["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"],dr=e=>Array.isArray(e)?e:[],pr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],cr[tr(o)]??er(o)),positionType:t,hubId:tr(e[1]),asset:rr(e[2]),scaledAmountRay:er(e[3]),indexRay:er(e[4]),amount:er(e[5]),liquidationThresholdBps:r?void 0:tr(e[6]),liquidationBonusBps:r?void 0:tr(e[7]),loanToValueBps:r?void 0:tr(e[8]),liquidationFeesBps:r?void 0:tr(e[9])};var o},mr=e=>{return{owner:rr(e[0]),spokeId:tr(e[1]),mode:(t=e[2],sr[tr(t)]??"None")};var t},fr=(e,t)=>{const r=ur[tr(e[`${t}_read_mode`])]??"Spot",o=e[`${t}_asset`],a=e[`${t}_symbol`],n=null!=o?{kind:"Stellar",value:rr(o)}:null!=a?{kind:"Symbol",value:rr(a)}:void 0;return{provider:lr[tr(e[`${t}_provider`])]??"ReflectorSep40",contractAddress:rr(e[`${t}_contract`]),asset:n,feedId:ar(e[`${t}_feed_id`]),readMode:r,twapRecords:"Twap"===r?tr(e[`${t}_twap_records`]):void 0,decimals:tr(e[`${t}_decimals`]),resolutionSeconds:tr(e[`${t}_resolution_seconds`]),maxStaleSeconds:tr(e[`${t}_max_stale_seconds`])}},hr=e=>{const t=null!==e.anchor_provider&&void 0!==e.anchor_provider;return{baseTokenId:rr(e.base_token_id),quoteTokenId:rr(e.quote_token_id),tolerance:{upperRatio:tr(e.upper_ratio_bps??e.tolerance?.upper_ratio_bps),lowerRatio:tr(e.lower_ratio_bps??e.tolerance?.lower_ratio_bps)},assetDecimals:tr(e.asset_decimals),maxPriceStaleSeconds:tr(e.max_price_stale_seconds),strategy:ir[tr(e.strategy)]??"Single",primary:fr(e,"primary"),anchor:t?fr(e,"anchor"):void 0,primaryQuoteToken:ar(e.primary_quote_token),anchorQuoteToken:ar(e.anchor_quote_token),minSanityPriceWad:or(e.min_sanity_price_wad),maxSanityPriceWad:or(e.max_sanity_price_wad)}},Sr={"market:create":e=>({topic:"market:create",data:{hubId:tr(e.hub_id),baseAsset:rr(e.base_asset),maxBorrowRate:er(e.max_borrow_rate),baseBorrowRate:er(e.base_borrow_rate),slope1:er(e.slope1),slope2:er(e.slope2),slope3:er(e.slope3),midUtilization:er(e.mid_utilization),optimalUtilization:er(e.optimal_utilization),maxUtilization:er(e.max_utilization),reserveFactor:tr(e.reserve_factor),marketAddress:rr(e.market_address)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:rr(e.asset),maxBorrowRateRay:er(e.max_borrow_rate),baseBorrowRateRay:er(e.base_borrow_rate),slope1Ray:er(e.slope1),slope2Ray:er(e.slope2),slope3Ray:er(e.slope3),midUtilizationRay:er(e.mid_utilization),optimalUtilizationRay:er(e.optimal_utilization),maxUtilizationRay:er(e.max_utilization),reserveFactorBps:tr(e.reserve_factor)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:dr(e).map((e=>{return t=dr(e),{hubId:tr(t[0]),asset:rr(t[1]),timestamp:tr(t[2]),supplyIndexRay:er(t[3]),borrowIndexRay:er(t[4]),cash:er(t[5]),suppliedRay:er(t[6]),borrowedRay:er(t[7]),revenueRay:er(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:dr(e).map((e=>{const t=e;return{hubId:tr(t.hub_id),asset:rr(t.asset),params:(r=t.params,{maxBorrowRateRay:er(r.max_borrow_rate),baseBorrowRateRay:er(r.base_borrow_rate),slope1Ray:er(r.slope1),slope2Ray:er(r.slope2),slope3Ray:er(r.slope3),midUtilizationRay:er(r.mid_utilization),optimalUtilizationRay:er(r.optimal_utilization),maxUtilizationRay:er(r.max_utilization),reserveFactorBps:tr(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:tr(r.flashloan_fee),assetId:rr(r.asset_id),assetDecimals:tr(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=dr(e);return{topic:"position:batch_update",data:{accountId:er(t[0]),accountAttributes:mr(dr(t[1])),updates:[...dr(t[2]).map((e=>pr(dr(e),"Deposit"))),...dr(t[3]).map((e=>pr(dr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{hubId:tr(e.hub_id),asset:rr(e.asset),receiver:rr(e.receiver),caller:rr(e.caller),amount:er(e.amount),fee:er(e.fee)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:rr(e.asset),oracle:hr(e.oracle)}}),"position:liquidation":e=>({topic:"position:liquidation",data:{liquidator:rr(e.liquidator),accountId:er(e.account_id),repaidUsdWad:er(e.repaid_usd_wad),bonusBps:er(e.bonus_bps)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:er(e.account_id),totalBorrowUsdWad:er(e.total_borrow_usd_wad),totalCollateralUsdWad:er(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:rr(e.token),amount:er(e.amount),usdValueWad:er(e.usd_value_wad),accountId:er(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{hubId:tr(e.hub_id),asset:rr(e.asset),amount:er(e.amount),fee:er(e.fee),amountSent:er(e.amount_sent)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:nr(e.wasm_hash),approved:Boolean(e.approved)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:rr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:rr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:nr(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:tr(e.max_supply_positions),maxBorrowPositions:tr(e.max_borrow_positions)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:rr(e.asset)}}),"config:spoke":e=>{const t=e.spoke;return{topic:"config:spoke",data:{spokeId:tr(t.spoke_id),isDeprecated:Boolean(t.is_deprecated),liquidationTargetHfWad:er(t.liquidation_target_hf_wad),healthFactorForMaxBonusWad:er(t.hf_for_max_bonus_wad),liquidationBonusFactorBps:tr(t.liquidation_bonus_factor_bps)}}}},br=Object.freeze(Object.keys(Sr));function _r(e,t){const r=Jt(e),o=Sr[r];return o?o((0,d.scValToNative)(Yt(t))):null}const gr="XLENDXLM-a7c9f3",wr=1e4;function yr(e){const t=BigInt(e).toString(16),r=t.length%2==0?t:`0${t}`;return`${gr}-${r}`}function Tr(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function vr(e,t=0){return e*wr+t}function xr(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Rr=(e,t,r)=>{const o=new URL(t,e.endsWith("/")?e:`${e}/`);if(r)for(const[e,t]of Object.entries(r))void 0!==t&&o.searchParams.set(e,String(t));return o.toString()},kr=e=>e.baseUrl??s[e.network];async function Er(e,t){if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=Rr(kr(t),"api/v1/quote",{from:e.from,to:e.to,amountIn:e.amountIn,amountOut:e.amountOut,maxHops:e.maxHops,maxSplits:e.maxSplits,slippage:e.slippage,includePaths:e.includePaths,sender:e.sender,router:e.router,platform:e.platform,fresh:e.fresh}),o=await fetch(r,t.fetchOptions);if(!o.ok){const e=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${e}`)}return await o.json()}async function Ar(e){const t=Rr(kr(e),"api/v1/tokens"),r=await fetch(t,e.fetchOptions);if(!r.ok){const e=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${t} — ${e}`)}return await r.json()}const Ir=(e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e,Pr=e=>I(e).toXDR("base64");function Or(e,t){const r=e.routerAddress??u(e.network),o=new d.Contract(r),a=new d.Account(e.caller,e.sourceSequence),n=L(Ir(t,e.referralId));return{xdr:new d.TransactionBuilder(a,{fee:e.fee??d.BASE_FEE,networkPassphrase:i[e.network]}).addOperation(o.call("execute_strategy",m(e.caller),f(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Br(e,t){return Or(e,t)}function Lr(e,t={}){if("string"!=typeof e.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:e.paths?e.paths.map((e=>({hops:e.swaps.map(Ur),splitPpm:e.splitPpm}))):[{hops:e.hops.map(Ur),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function $r(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:Lr(e,t)}const Nr=Lr,Ur=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function Cr(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function qr(e,t,r){const o=d.TransactionBuilder.fromXDR(t,"base64");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw Cr(r.invokedContractId,e);throw e}}async function Gr(e,t,r){return qr(e,t.xdr,r)}function Dr(e){if(e<=0||e>4)throw new Error(`Invalid PositionMode ${e} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return e-1}function Vr(e,t){return new Uint8Array(0)}const Wr=e=>{const t=e.startsWith("0x")?e.slice(2):e;if(t.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return Buffer.from(t,"hex")};function zr(e){const t=new d.Account(e.caller,e.sourceSequence),r=new d.Contract(e.forwarderAddress).call("mint_and_forward",d.xdr.ScVal.scvBytes(Wr(e.message)),d.xdr.ScVal.scvBytes(Wr(e.attestation)));return{xdr:new d.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:i[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const Mr={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:"InvalidPoolTemplate",message:"The liquidity pool template hash is 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."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetsLimitReached",message:"This spoke has reached its asset limit."},314:{name:"SpokeCapBelowUsage",message:"The new cap is below current usage on this spoke asset."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},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 Xr(e){const t=e.match(/Error\(Contract,\s*#(\d+)\)/);if(!t)return null;const r=Number(t[1]),o=Mr[r];return o?{code:r,...o}:null}module.exports=t})();