@xoxno/sdk-js 1.0.170 → 1.0.172

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={388(a,p,l){l.d(p,{ME:()=>d,nO:()=>y,G_:()=>be,DU:()=>c,fA:()=>Eo,A$:()=>g,J9:()=>f,hS:()=>b,gR:()=>Ro,Cg:()=>Mo,VZ:()=>Zo,N0:()=>zt,Wc:()=>Zt,hu:()=>Ft,B_:()=>de,eX:()=>ee,z:()=>zo,xD:()=>W,jR:()=>j,P2:()=>Yo,W6:()=>ce,KH:()=>re,se:()=>ae,ln:()=>ue,g:()=>Ht,jP:()=>Jt,FM:()=>ne,yr:()=>Go,sp:()=>Z,$9:()=>eo,zw:()=>ro,h_:()=>no,e_:()=>uo,Tk:()=>to,BA:()=>oo,SX:()=>Nt,UF:()=>Oo,Y5:()=>K,mE:()=>J,xG:()=>Lt,s9:()=>Y,OL:()=>$t,Mq:()=>Re,fc:()=>Pe,kD:()=>$e,Yf:()=>Ue,c5:()=>Xe,qU:()=>Ne,RZ:()=>Ge,PD:()=>Ve,cJ:()=>Ae,vM:()=>Oe,hF:()=>Fe,Qk:()=>Qe,Gw:()=>Ze,$K:()=>je,cO:()=>Ce,Qy:()=>Me,X7:()=>Be,Ub:()=>Je,Dx:()=>Le,OA:()=>Te,$U:()=>qe,ob:()=>Ee,cY:()=>we,$l:()=>ke,VS:()=>He,HP:()=>Ye,YQ:()=>Ke,mK:()=>Ie,QY:()=>We,os:()=>De,Ko:()=>ze,kz:()=>te,Oy:()=>Qt,IJ:()=>se,nw:()=>F,Pr:()=>ot,ZE:()=>Q,ev:()=>Dt,P8:()=>oe,aV:()=>Wt,p2:()=>Vt,Ww:()=>jt,Dy:()=>Xt,Ni:()=>z,v_:()=>V,qD:()=>et,qR:()=>tt,QJ:()=>Gt,bm:()=>Bt,n_:()=>ye,v8:()=>ie,Y_:()=>Yt,qM:()=>Ut,gH:()=>pe,un:()=>le,O3:()=>H,Gz:()=>X,pr:()=>G,Fm:()=>Po,ns:()=>Pt,MB:()=>kt,Dn:()=>Ct,pq:()=>Et,ml:()=>It,Q3:()=>Mt,wf:()=>Do,Um:()=>Io,xO:()=>_t,Lw:()=>Bo,KM:()=>h,mM:()=>dt,iE:()=>vt,zp:()=>bt,N3:()=>yt,bN:()=>it,QV:()=>_,T_:()=>xt,XI:()=>ft,Lt:()=>St,KK:()=>st,vc:()=>m,CH:()=>No,FI:()=>lt,KG:()=>Tt,nW:()=>ct,jF:()=>pt,S2:()=>gt,uS:()=>qt,u_:()=>at,O5:()=>ht,Av:()=>mt,LA:()=>jo,E6:()=>Vo,Ds:()=>Wo,CU:()=>Uo,Vx:()=>Qo,DL:()=>Fo,ON:()=>ao,Hh:()=>wt,oV:()=>Co,g5:()=>Xo,L:()=>io,Vu:()=>Ko});const c={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},d={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},y={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},b={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},f={mainnet:process.env.STELLAR_QUOTE_URL_MAINNET??"https://stellar-swap.xoxno.com",testnet:process.env.STELLAR_QUOTE_URL_TESTNET??"https://testnet-stellar-swap.xoxno.com"},g={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function m(t){const e=c[t];if(!e)throw new Error(`Stellar lending controller address not configured for network "${t}". Set STELLAR_LENDING_CONTROLLER_${t.toUpperCase()} env var.`);return e}function h(t){const e=d[t];if(!e)throw new Error(`Stellar aggregator router address not configured for network "${t}". Set STELLAR_AGGREGATOR_ROUTER_${t.toUpperCase()} env var.`);return e}function _(t){const e=y[t];if(!e)throw new Error(`Stellar governance address not configured for network "${t}". Set STELLAR_GOVERNANCE_${t.toUpperCase()} env var.`);return e}const x=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],v=t=>new e(t).toScVal(),S=t=>new n(t).toI128(),q=t=>s.ScVal.scvU32(t),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),E=()=>s.ScVal.scvVoid(),P=t=>s.ScVal.scvVec(t),M=(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?E():e(t),O=(t,e)=>U({asset:v(e),hub_id:q(t)}),I=(t,e,o)=>s.ScVal.scvVec([O(t,e),S(o)]),C=t=>s.ScVal.scvVec(t.map((t=>I(t.hubId,t.asset,t.amount)))),U=t=>{const e=Object.keys(t).sort().map((e=>new s.ScMapEntry({key:k(e),val:t[e]})));return s.ScVal.scvMap(e)},L=t=>{const e=t.paths.map((t=>{const e=t.hops.map((t=>{return U({amount_out:S(t.amountOut),pool:v(t.pool),token_in:v(t.tokenIn),token_out:v(t.tokenOut),venue:(e=t.venue,s.ScVal.scvVec([k(e)]))});var e}));return U({hops:s.ScVal.scvVec(e),split_ppm:q(t.splitPpm)})}));return U({paths:s.ScVal.scvVec(e),referral_id:T(t.referralId??0),token_in:v(t.tokenIn),token_out:v(t.tokenOut),total_min_out:S(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)},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},N=t=>{if("string"==typeof t)return $(B(t));if(t instanceof Uint8Array)return $(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)):$(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||!x.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(L(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},D=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 G(e,n,i){const s=e.controllerAddress??m(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:g[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function z(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return G(t,"supply",[v(t.caller),T(o),q(r),C([...e.assets])])}function V(t,e){return z(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function W(t,e){return G(t,"borrow",[v(t.caller),T(e.accountNonce),C([...e.borrows]),R(e.to,v)])}function j(t,e){return W(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function H(t,e){return G(t,"withdraw",[v(t.caller),T(e.accountNonce),C([...e.withdrawals]),R(e.to,v)])}function X(t,e){return H(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function F(t,e){return G(t,"repay",[v(t.caller),T(e.accountNonce),C([...e.payments])])}function Q(t,e){return F(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function K(t,e){return G(t,"liquidate",[v(t.caller),T(e.accountNonce),C([...e.debtPayments])])}function Z(t,e){return G(t,"flash_loan",[v(t.caller),O(e.hubId,e.asset),S(e.amount),v(e.receiver),D(e.data)])}function J(t,e){return G(t,"migrate_from_blend",[v(t.caller),T(e.accountId),q(e.spokeId),q(e.hubId),v(e.blendPool),P(e.collateralTokens.map(v)),P(e.supplyTokens.map(v)),(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([v(e),S(o)]);var e,o}))))]);var o}function Y(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return G(t,"multiply",[v(t.caller),T(o),q(r),O(e.collateral.hubId,e.collateral.asset),S(e.debtToFlashLoan),O(e.debt.hubId,e.debt.asset),q(e.mode),N(e.steps),R(e.initialPayment,(t=>I(t.hubId,t.asset,t.amount))),R(e.convertSwap,N)])}function tt(t,e){return G(t,"swap_debt",[v(t.caller),T(e.accountNonce),O(e.existingDebt.hubId,e.existingDebt.asset),S(e.newDebtAmount),O(e.newDebt.hubId,e.newDebt.asset),N(e.steps)])}function et(t,e){return G(t,"swap_collateral",[v(t.caller),T(e.accountNonce),O(e.current.hubId,e.current.asset),S(e.fromAmount),O(e.newCollateral.hubId,e.newCollateral.asset),N(e.steps)])}function ot(t,e){return G(t,"repay_debt_with_collateral",[v(t.caller),T(e.accountNonce),O(e.collateral.hubId,e.collateral.asset),S(e.collateralAmount),O(e.debt.hubId,e.debt.asset),N(e.steps),w(e.closePosition)])}const rt="/stellar-lending",nt=25,ut=encodeURIComponent,it=(t,e)=>t.fetchWithTimeout(`${rt}/assets`,e),st=(t,e)=>t.fetchWithTimeout(`${rt}/hubs`,e),at=(t,e)=>t.fetchWithTimeout(`${rt}/spokes`,e),pt=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${rt}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},lt=(t,e,o,r,n)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}`,n),ct=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}/holders`,{...u,params:{side:n}}),dt=(t,e,o)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}`,o),yt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/page`,{...r,params:{...o}}),bt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/markets`,{...r,params:{side:o}}),ft=(t,e,o)=>t.fetchWithTimeout(`${rt}/hubs/${e}`,o),gt=(t,e,o)=>t.fetchWithTimeout(`${rt}/spokes/${e}`,o),mt=(t,e,o)=>t.fetchWithTimeout(`${rt}/users/${ut(e)}/positions`,o),ht=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${rt}/users/${ut(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},_t=(t,e,o)=>t.fetchWithTimeout(`${rt}/accounts/${ut(e)}/positions`,o),xt=(t,e={},o)=>{const{top:r=nt,continuationToken:n}=e;return t.fetchWithTimeout(`${rt}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},vt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/graph`,{...r,params:{...o}}),St=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/hubs/${e}/graph`,{...r,params:{...o}}),qt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/spokes/${e}/graph`,{...r,params:{...o}}),Tt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}/graph`,{...u,params:{...n}}),wt=t=>({assets:e=>it(t,e),hubs:e=>st(t,e),spokes:e=>at(t,e),reserves:(e,o)=>pt(t,e,o),reserve:(e,o,r,n)=>lt(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>ct(t,e,o,r,n,u),asset:(e,o)=>dt(t,e,o),assetMarkets:(e,o,r)=>bt(t,e,o,r),hub:(e,o)=>ft(t,e,o),spoke:(e,o)=>gt(t,e,o),userPositions:(e,o)=>mt(t,e,o),userActivity:(e,o,r)=>ht(t,e,o,r),accountPositions:(e,o)=>_t(t,e,o),governanceProposals:(e,o)=>xt(t,e,o),assetGraph:(e,o,r)=>vt(t,e,o,r),hubGraph:(e,o,r)=>St(t,e,o,r),spokeGraph:(e,o,r)=>qt(t,e,o,r),reserveGraph:(e,o,r,n,u)=>Tt(t,e,o,r,n,u)}),At={Single:0,PrimaryWithAnchor:1},kt=t=>U({base_borrow_rate_ray:S(t.baseBorrowRateRay),max_borrow_rate_ray:S(t.maxBorrowRateRay),max_utilization_ray:S(t.maxUtilizationRay),mid_utilization_ray:S(t.midUtilizationRay),optimal_utilization_ray:S(t.optimalUtilizationRay),reserve_factor_bps:q(t.reserveFactorBps),slope1_ray:S(t.slope1Ray),slope2_ray:S(t.slope2Ray),slope3_ray:S(t.slope3Ray)}),Et=t=>U({asset_decimals:q(t.assetDecimals),asset_id:v(t.assetId),base_borrow_rate_ray:S(t.baseBorrowRateRay),borrow_cap:S(t.borrowCap),max_borrow_rate_ray:S(t.maxBorrowRateRay),max_utilization_ray:S(t.maxUtilizationRay),mid_utilization_ray:S(t.midUtilizationRay),optimal_utilization_ray:S(t.optimalUtilizationRay),reserve_factor_bps:q(t.reserveFactorBps),slope1_ray:S(t.slope1Ray),slope2_ray:S(t.slope2Ray),slope3_ray:S(t.slope3Ray),supply_cap:S(t.supplyCap)}),Pt=t=>U({asset_decimals:q(0),e_mode_categories:P(t.eModeCategories.map((t=>q(t)))),flashloan_fee_bps:q(t.flashloanFeeBps),is_borrowable:w(t.isBorrowable),is_collateralizable:w(t.isCollateralizable),is_flashloanable:w(t.isFlashloanable),liquidation_bonus_bps:q(t.liquidationBonusBps),liquidation_fees_bps:q(t.liquidationFeesBps),liquidation_threshold_bps:q(t.liquidationThresholdBps),loan_to_value_bps:q(t.loanToValueBps)}),Mt=t=>U({max_borrow_positions:q(t.maxBorrowPositions),max_supply_positions:q(t.maxSupplyPositions)}),Rt=t=>{const e=t.kind;switch(e){case"Stellar":return P([k("Stellar"),v(t.value)]);case"Symbol":return P([k("Symbol"),k(t.value)]);case"String":return P([k("String"),A(t.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${e}"`)}},Ot=(t,e)=>{if("Twap"===t){if("number"!=typeof e)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return P([k("Twap"),q(e)])}return P([k("Spot")])},It=t=>{const e=t.provider;if("ReflectorSep40"===e){if(!t.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return P([k("Reflector"),U({asset:Rt(t.asset),contract:v(t.contract),read_mode:Ot(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 P([k("RedStone"),U({contract:v(t.contract),feed_id:A(t.feedId),max_stale_seconds:T(t.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${e}"`)},Ct=t=>{const e=At[t.strategy];if(void 0===e)throw new Error(`Stellar builder: unknown oracle strategy "${t.strategy}"`);return U({anchor:(o=t.anchor,P(null==o?[k("None")]:[k("Some"),It(o)])),max_price_stale_seconds:T(t.maxPriceStaleSeconds),max_sanity_price_wad:S(t.maxSanityPriceWad),min_sanity_price_wad:S(t.minSanityPriceWad),primary:It(t.primary),strategy:q(e),tolerance_bps:q(t.toleranceBps)});var o};function Ut(t,e){return G(t,"upgrade",[M(e.wasmHash)])}function Lt(t,e){return G(t,"migrate",[q(e.newVersion)])}function $t(t){return G(t,"pause",[])}function Bt(t){return G(t,"unpause",[])}function Nt(t,e){return G(t,"grant_role",[v(e.account),k(e.role)])}function Dt(t,e){return G(t,"revoke_role",[v(e.account),k(e.role)])}function Gt(t,e){return G(t,"transfer_ownership",[v(e.newOwner),q(e.liveUntilLedger)])}function zt(t){return G(t,"accept_ownership",[])}function Vt(t,e){return G(t,"set_aggregator",[v(e.aggregator)])}function Wt(t,e){return G(t,"set_accumulator",[v(e.accumulator)])}function jt(t,e){return G(t,"set_liquidity_pool_template",[M(e.wasmHash)])}function Ht(t,e){return G(t,"edit_asset_config",[v(e.asset),Pt(e.config)])}function Xt(t,e){return G(t,"set_position_limits",[Mt(e)])}function Ft(t){return G(t,"add_e_mode_category",[])}function Qt(t,e){return G(t,"remove_e_mode_category",[q(e.id)])}const Kt=t=>U({asset:v(t.asset),category_id:q(t.categoryId),can_collateral:w(t.canCollateral),can_borrow:w(t.canBorrow),ltv:q(t.ltv),threshold:q(t.threshold),bonus:q(t.bonus),supply_cap:S(t.supplyCap),borrow_cap:S(t.borrowCap)});function Zt(t,e){return G(t,"add_asset_to_e_mode_category",[Kt(e)])}function Jt(t,e){return G(t,"edit_asset_in_e_mode_category",[Kt(e)])}function Yt(t,e){return G(t,"update_pool_caps",[v(e.asset),S(e.supplyCap),S(e.borrowCap)])}function te(t,e){return G(t,"remove_asset_from_e_mode",[v(e.asset),q(e.categoryId)])}function ee(t,e){return G(t,"approve_token",[v(e.token)])}function oe(t,e){return G(t,"revoke_token",[v(e.token)])}function re(t,e){return G(t,"configure_market_oracle",[v(t.caller),v(e.asset),Ct(e.config)])}function ne(t,e){return G(t,"edit_oracle_tolerance",[v(t.caller),v(e.asset),q(e.tolerance)])}function ue(t,e){return G(t,"disable_token_oracle",[v(t.caller),v(e.asset)])}function ie(t,e){return G(t,"update_indexes",[v(t.caller),P(e.assets.map((t=>v(t))))])}function se(t,e){return G(t,"renew_account",[v(t.caller),T(e.accountNonce)])}function ae(t,e){return G(t,"create_liquidity_pool",[v(e.asset),Et(e.params),Pt(e.config)])}function pe(t,e){return G(t,"upgrade_liquidity_pool_params",[v(e.asset),kt(e.params)])}function le(t,e){return G(t,"upgrade_liquidity_pool",[v(e.asset),M(e.wasmHash)])}function ce(t,e){return G(t,"claim_revenue",[v(t.caller),P(e.assets.map((t=>v(t))))])}function de(t,e){return G(t,"add_rewards",[v(t.caller),P(e.rewards.map((t=>P([v(t.token),S(t.amount)]))))])}function ye(t,e){return G(t,"update_account_threshold",[v(t.caller),v(e.asset),w(e.hasRisks),P(e.accountNonces.map((t=>T(t))))])}const be="00".repeat(32),fe=t=>{if("string"==typeof t)return M(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)},ge=(t,...e)=>P([k(t),...e]),me=t=>U({asset:v(t.asset),category_id:q(t.categoryId),can_collateral:w(t.canCollateral),can_borrow:w(t.canBorrow),ltv:q(t.ltv),threshold:q(t.threshold),bonus:q(t.bonus),supply_cap:S(t.supplyCap),borrow_cap:S(t.borrowCap)}),he=t=>U({new_owner:v(t.newOwner),live_until_ledger:q(t.liveUntilLedger)}),_e=t=>U({account:v(t.account),role:k(t.role)});function xe(e,n,i){const s=e.governanceAddress??_(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:g[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ve=(t,e,o)=>xe(t,"propose",[v(t.caller),e,fe(o)]),Se=(t,e,o)=>xe(t,"execute_self",[E(),e,fe(o)]);function qe(t,e,o){return ve(t,ge("SetAggregator",v(e.aggregator)),o)}function Te(t,e,o){return ve(t,ge("SetAccumulator",v(e.accumulator)),o)}function we(t,e,o){return ve(t,ge("SetLiquidityPoolTemplate",M(e.wasmHash)),o)}function Ae(t,e,o){return ve(t,ge("EditAssetConfig",v(e.asset),Pt(e.config)),o)}function ke(t,e,o){return ve(t,ge("SetPositionLimits",Mt(e)),o)}function Ee(t,e,o){return ve(t,ge("SetMinBorrowCollateralUsd",S(e.floorWad)),o)}function Pe(t,e){return ve(t,ge("AddEModeCategory"),e)}function Me(t,e,o){return ve(t,ge("RemoveEModeCategory",q(e.id)),o)}function Re(t,e,o){return ve(t,ge("AddAssetToEModeCategory",me(e)),o)}function Oe(t,e,o){return ve(t,ge("EditAssetInEModeCategory",me(e)),o)}function Ie(t,e,o){return ve(t,ge("UpdatePoolCaps",U({asset:v((r=e).asset),supply_cap:S(r.supplyCap),borrow_cap:S(r.borrowCap)})),o);var r}function Ce(t,e,o){return ve(t,ge("RemoveAssetFromEMode",U({asset:v((r=e).asset),category_id:q(r.categoryId)})),o);var r}function Ue(t,e,o){return ve(t,ge("ApproveToken",v(e.token)),o)}function Le(t,e,o){return ve(t,ge("RevokeToken",v(e.token)),o)}function $e(t,e,o){return ve(t,ge("ApproveBlendPool",v(e.pool)),o)}function Be(t,e,o){return ve(t,ge("RevokeBlendPool",v(e.pool)),o)}function Ne(t,e,o){return ve(t,ge("CreateLiquidityPool",U({asset:v((r=e).asset),params:Et(r.params),config:Pt(r.config)})),o);var r}function De(t,e,o){return ve(t,ge("UpgradeLiquidityPoolParams",U({asset:v((r=e).asset),params:kt(r.params)})),o);var r}function Ge(t,e){return ve(t,ge("DeployPool"),e)}function ze(t,e,o){return ve(t,ge("UpgradePool",M(e.wasmHash)),o)}function Ve(t,e,o){return ve(t,ge("DisableTokenOracle",v(e.asset)),o)}function We(t,e,o){return ve(t,ge("UpgradeController",M(e.wasmHash)),o)}function je(t,e,o){return ve(t,ge("MigrateController",q(e.newVersion)),o)}function He(t,e,o){return ve(t,ge("TransferCtrlOwnership",he(e)),o)}function Xe(t,e,o){return ve(t,ge("ConfigureMarketOracle",U({asset:v((r=e).asset),cfg:Ct(r.config)})),o);var r}function Fe(t,e,o){return ve(t,ge("EditOracleTolerance",U({asset:v((r=e).asset),tolerance:q(r.tolerance)})),o);var r}function Qe(t,e,o){return ve(t,ge("UpgradeGov",M(e.wasmHash)),o)}function Ke(t,e,o){return ve(t,ge("UpdateGovDelay",q(e.newDelay)),o)}function Ze(t,e,o){return ve(t,ge("GrantGovRole",_e(e)),o)}function Je(t,e,o){return ve(t,ge("RevokeGovRole",_e(e)),o)}function Ye(t,e,o){return ve(t,ge("TransferGovOwnership",he(e)),o)}function to(t,e){const o=P(e.argsXdr.map((t=>s.ScVal.fromXDR(t,"base64")))),r=fe(e.predecessor??be);return xe(t,"execute",[E(),v(e.target),k(e.functionName),o,r,fe(e.salt)])}function eo(t,e,o){return Se(t,ge("UpgradeGov",M(e.wasmHash)),o)}function oo(t,e,o){return Se(t,ge("UpdateGovDelay",q(e.newDelay)),o)}function ro(t,e,o){return Se(t,ge("GrantGovRole",_e(e)),o)}function no(t,e,o){return Se(t,ge("RevokeGovRole",_e(e)),o)}function uo(t,e,o){return Se(t,ge("TransferGovOwnership",he(e)),o)}const io=t=>t.toXDR("base64"),so=t=>s.ScVal.fromXDR(t,"base64"),ao=t=>t.map((t=>String(i(so(t))))).join(":"),po=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),lo=t=>Number(t),co=t=>String(t),yo=t=>null==t?void 0:po(t),bo=t=>null==t?void 0:co(t),fo=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),go=["None","Multiply","Long","Short"],mo=["Single","PrimaryWithAnchor"],ho=["ReflectorSep40","RedStonePriceFeed"],_o=["Spot","Twap"],xo=["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"],vo=t=>Array.isArray(t)?t:[],So=t=>({loanToValueBps:lo(t.loan_to_value_bps),liquidationThresholdBps:lo(t.liquidation_threshold_bps),liquidationBonusBps:lo(t.liquidation_bonus_bps),liquidationFeesBps:lo(t.liquidation_fees_bps),isCollateralizable:Boolean(t.is_collateralizable),isBorrowable:Boolean(t.is_borrowable),isFlashloanable:Boolean(t.is_flashloanable),flashloanFeeBps:lo(t.flashloan_fee_bps),eModeCategories:(t.e_mode_categories??[]).map(lo)}),qo=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],xo[lo(r)]??po(r)),positionType:e,asset:co(t[1]),scaledAmountRay:po(t[2]),indexRay:po(t[3]),amount:po(t[4]),liquidationThresholdBps:o?void 0:lo(t[5]),liquidationBonusBps:o?void 0:lo(t[6]),loanToValueBps:o?void 0:lo(t[7])};var r},To=t=>{return{owner:co(t[0]),eModeCategoryId:lo(t[1]),mode:(e=t[2],go[lo(e)]??"None")};var e},wo=(t,e)=>{const o=_o[lo(t[`${e}_read_mode`])]??"Spot",r=t[`${e}_asset`],n=t[`${e}_symbol`],u=null!=r?{kind:"Stellar",value:co(r)}:null!=n?{kind:"Symbol",value:co(n)}:void 0;return{provider:ho[lo(t[`${e}_provider`])]??"ReflectorSep40",contractAddress:co(t[`${e}_contract`]),asset:u,feedId:bo(t[`${e}_feed_id`]),readMode:o,twapRecords:"Twap"===o?lo(t[`${e}_twap_records`]):void 0,decimals:lo(t[`${e}_decimals`]),resolutionSeconds:lo(t[`${e}_resolution_seconds`]),maxStaleSeconds:lo(t[`${e}_max_stale_seconds`])}},Ao=t=>{const e=null!==t.anchor_provider&&void 0!==t.anchor_provider;return{baseTokenId:co(t.base_token_id),quoteTokenId:co(t.quote_token_id),tolerance:{upperRatio:lo(t.upper_ratio_bps??t.tolerance?.upper_ratio_bps),lowerRatio:lo(t.lower_ratio_bps??t.tolerance?.lower_ratio_bps)},assetDecimals:lo(t.asset_decimals),maxPriceStaleSeconds:lo(t.max_price_stale_seconds),strategy:mo[lo(t.strategy)]??"Single",primary:wo(t,"primary"),anchor:e?wo(t,"anchor"):void 0,primaryQuoteToken:bo(t.primary_quote_token),anchorQuoteToken:bo(t.anchor_quote_token),minSanityPriceWad:yo(t.min_sanity_price_wad),maxSanityPriceWad:yo(t.max_sanity_price_wad)}},ko={"market:create":t=>({topic:"market:create",data:{baseAsset:co(t.base_asset),maxBorrowRate:po(t.max_borrow_rate),baseBorrowRate:po(t.base_borrow_rate),slope1:po(t.slope1),slope2:po(t.slope2),slope3:po(t.slope3),midUtilization:po(t.mid_utilization),optimalUtilization:po(t.optimal_utilization),maxUtilization:yo(t.max_utilization),reserveFactor:lo(t.reserve_factor),marketAddress:co(t.market_address),config:So(t.config)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:co(t.asset),maxBorrowRateRay:po(t.max_borrow_rate_ray),baseBorrowRateRay:po(t.base_borrow_rate_ray),slope1Ray:po(t.slope1_ray),slope2Ray:po(t.slope2_ray),slope3Ray:po(t.slope3_ray),midUtilizationRay:po(t.mid_utilization_ray),optimalUtilizationRay:po(t.optimal_utilization_ray),maxUtilizationRay:yo(t.max_utilization_ray),reserveFactorBps:lo(t.reserve_factor_bps)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:vo(t).map((t=>{return e=vo(t),{asset:co(e[0]),timestamp:lo(e[1]),supplyIndexRay:po(e[2]),borrowIndexRay:po(e[3]),reservesRay:po(e[4]),suppliedRay:po(e[5]),borrowedRay:po(e[6]),revenueRay:po(e[7]),assetPriceWad:yo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:vo(t).map((t=>{const e=t;return{asset:co(e.asset),params:(o=e.params,{maxBorrowRateRay:po(o.max_borrow_rate_ray),baseBorrowRateRay:po(o.base_borrow_rate_ray),slope1Ray:po(o.slope1_ray),slope2Ray:po(o.slope2_ray),slope3Ray:po(o.slope3_ray),midUtilizationRay:po(o.mid_utilization_ray),optimalUtilizationRay:po(o.optimal_utilization_ray),maxUtilizationRay:yo(o.max_utilization_ray),reserveFactorBps:lo(o.reserve_factor_bps),supplyCap:po(o.supply_cap),borrowCap:po(o.borrow_cap),assetId:bo(o.asset_id),assetDecimals:void 0===o.asset_decimals?void 0:lo(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=vo(t);return{topic:"position:batch_update",data:{accountId:po(e[0]),accountAttributes:To(vo(e[1])),updates:[...vo(e[2]).map((t=>qo(vo(t),"Deposit"))),...vo(e[3]).map((t=>qo(vo(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{asset:co(t.asset),receiver:co(t.receiver),caller:co(t.caller),amount:po(t.amount),fee:po(t.fee)}}),"config:asset":t=>({topic:"config:asset",data:{asset:co(t.asset),config:So(t.config)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:co(t.asset),oracle:Ao(t.oracle)}}),"config:emode_category":t=>({topic:"config:emode_category",data:{category:{categoryId:lo(t.category.category_id),isDeprecated:Boolean(t.category.is_deprecated)}}}),"config:emode_asset":t=>({topic:"config:emode_asset",data:{asset:co(t.asset),config:{isCollateralizable:Boolean(t.config.is_collateralizable),isBorrowable:Boolean(t.config.is_borrowable),loanToValueBps:lo(t.config.loan_to_value_bps),liquidationThresholdBps:lo(t.config.liquidation_threshold_bps),liquidationBonusBps:lo(t.config.liquidation_bonus_bps),supplyCap:po(t.config.supply_cap),borrowCap:po(t.config.borrow_cap)},categoryId:lo(t.category_id)}}),"config:remove_emode_asset":t=>({topic:"config:remove_emode_asset",data:{asset:co(t.asset),categoryId:lo(t.category_id)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:po(t.account_id),totalBorrowUsdWad:po(t.total_borrow_usd_wad),totalCollateralUsdWad:po(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:co(t.token),amount:po(t.amount),usdValueWad:po(t.usd_value_wad),accountId:po(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{asset:co(t.asset),amount:po(t.amount),fee:po(t.fee),amountSent:po(t.amount_sent)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:fo(t.wasm_hash),approved:Boolean(t.approved)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:co(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:co(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:fo(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:lo(t.max_supply_positions),maxBorrowPositions:lo(t.max_borrow_positions)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:co(t.asset)}})},Eo=Object.freeze(Object.keys(ko));function Po(t,e){const o=ao(t),r=ko[o];return r?r(i(so(e))):null}const Mo="XLENDXLM-a7c9f3",Ro=1e4;function Oo(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${Mo}-${o}`}function Io(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function Co(t,e=0){return t*Ro+e}function Uo(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Lo=(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()},$o=t=>t.baseUrl??f[t.network];async function Bo(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=Lo($o(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 No(t){const e=Lo($o(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 Do=t=>L(t).toXDR("base64");function Go(e,n){const i=e.routerAddress??h(e.network),s=new r(i),a=new t(e.caller,e.sourceSequence),p=N(((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:g[e.network]}).addOperation(s.call("execute_strategy",v(e.caller),S(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function zo(t,e){return Go(t,e)}function Vo(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(Ho),splitPpm:t.splitPpm}))):[{hops:t.hops.map(Ho),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Wo(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:Vo(t,e)}const jo=Vo,Ho=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Xo(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Fo(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw Xo(o.invokedContractId,t);throw t}}async function Qo(t,e,o){return Fo(t,e.xdr,o)}function Ko(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{paths:[{hops:[{amountOut:"0",pool:t,tokenIn:t,tokenOut:t,venue:"Soroswap"}],splitPpm:1e6}],referralId:0,tokenIn:t,tokenOut:t,totalMinOut:e}}const Jo=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 Yo(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",s.ScVal.scvBytes(Jo(e.message)),s.ScVal.scvBytes(Jo(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:g[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}}},p={};function l(t){var e=p[t];if(void 0!==e)return e.exports;var o=p[t]={exports:{}};return a[t](o,o.exports,l),o.exports}l.d=(t,e)=>{for(var o in e)l.o(e,o)&&!l.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const c="https://api.xoxno.com",d="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",b="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var f;!function(t){t.MAINNET="1",t.DEVNET="D"}(f||(f={}));class g{apiUrl;chain;init;config;constructor({chain:t=f.MAINNET,apiUrl:e=c,...o}={}){this.apiUrl=e??{[f.MAINNET]:c,[f.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==f.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:d,DR_SC:y,KG_SC:b,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:d,DR_SC:y,KG_SC:b,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:c="GET",...d}=o,y=l?.Authorization,b="Bearer undefined"===y?void 0:y,f={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===c?{}:{"Content-Type":"application/json"},...b?{Authorization:b}:{}},g=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),m=`${this.apiUrl}${t}${g.length?`?${g}`:""}`,{revalidate:h,..._}=r??{},{revalidate:x,...v}=s??{},S="GET"!==c||b?void 0:x??h,q="GET"!==c||b||S?void 0:a??n,T={...i,...d,method:c,...Object.keys(f).length?{headers:f}:{},cache:q,next:{..._,...v,revalidate:S}};(p??u)&&console.debug("SDK fetch: ",m,T);const w=await fetch(m,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${m}: ${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=[m,w.status,w.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const m=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 _ extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class x extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const v=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^G[A-Z2-7]{55}$/.test(t)),S={"/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/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/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}}},q=["PATCH","POST","DELETE","PUT"];var T=l(388);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(!v(t))throw new x(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!m(t))):!m(t))throw new _(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:c,auth:d,method:y,headers:b,cache:f,next:g,debug:h,continuationToken:S,...q}=l,T=d?`Bearer ${d}`:void 0,w={...b,...T?{Authorization:T}:{},...S?{"X-Continuation-Token":String(S)}:{}},A={...g,tags:[...g?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:q,body:c,headers:w,cache:f,debug:h,...A?{next:A}:{}})},a=(t={})=>s(t);for(const t of Object.keys(i))q.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(S)){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{f as Chain,g as XOXNOClient,k as buildSdk,m as isValidCollectionTicker,h as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=T.ME;export const STELLAR_GOVERNANCE=T.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=T.G_;export const STELLAR_LENDING_CONTROLLER=T.DU;export const STELLAR_LENDING_TOPICS=T.fA;export const STELLAR_NETWORK_PASSPHRASE=T.A$;export const STELLAR_QUOTE_URL=T.J9;export const STELLAR_SOROBAN_RPC_URL=T.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=T.gR;export const XOXNO_LENDING_STELLAR_TICKER=T.Cg;export const buildSameTokenRepaySwapSteps=T.VZ;export const buildStellarAcceptOwnershipTx=T.N0;export const buildStellarAddAssetToEModeCategoryTx=T.Wc;export const buildStellarAddEModeCategoryTx=T.hu;export const buildStellarAddRewardsTx=T.B_;export const buildStellarApproveTokenTx=T.eX;export const buildStellarBatchSwapTx=T.z;export const buildStellarBorrowBatchTx=T.xD;export const buildStellarBorrowTx=T.jR;export const buildStellarCctpForwardTx=T.P2;export const buildStellarClaimRevenueTx=T.W6;export const buildStellarConfigureMarketOracleTx=T.KH;export const buildStellarCreateLiquidityPoolTx=T.se;export const buildStellarDisableTokenOracleTx=T.ln;export const buildStellarEditAssetConfigTx=T.g;export const buildStellarEditAssetInEModeCategoryTx=T.jP;export const buildStellarEditOracleToleranceTx=T.FM;export const buildStellarExecuteStrategyTx=T.yr;export const buildStellarFlashLoanTx=T.sp;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=T.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=T.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=T.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=T.e_;export const buildStellarGovernanceExecuteTx=T.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=T.BA;export const buildStellarGrantRoleTx=T.SX;export const buildStellarLendingIdentifier=T.UF;export const buildStellarLiquidateTx=T.Y5;export const buildStellarMigrateFromBlendTx=T.mE;export const buildStellarMigrateTx=T.xG;export const buildStellarMultiplyTx=T.s9;export const buildStellarPauseTx=T.OL;export const buildStellarProposeAddAssetToEModeTx=T.Mq;export const buildStellarProposeAddEModeCategoryTx=T.fc;export const buildStellarProposeApproveBlendPoolTx=T.kD;export const buildStellarProposeApproveTokenTx=T.Yf;export const buildStellarProposeConfigureMarketOracleTx=T.c5;export const buildStellarProposeCreateLiquidityPoolTx=T.qU;export const buildStellarProposeDeployPoolTx=T.RZ;export const buildStellarProposeDisableTokenOracleTx=T.PD;export const buildStellarProposeEditAssetConfigTx=T.cJ;export const buildStellarProposeEditAssetInEModeTx=T.vM;export const buildStellarProposeEditOracleToleranceTx=T.hF;export const buildStellarProposeGovernanceUpgradeTx=T.Qk;export const buildStellarProposeGrantGovernanceRoleTx=T.Gw;export const buildStellarProposeMigrateControllerTx=T.$K;export const buildStellarProposeRemoveAssetFromEModeTx=T.cO;export const buildStellarProposeRemoveEModeCategoryTx=T.Qy;export const buildStellarProposeRevokeBlendPoolTx=T.X7;export const buildStellarProposeRevokeGovernanceRoleTx=T.Ub;export const buildStellarProposeRevokeTokenTx=T.Dx;export const buildStellarProposeSetAccumulatorTx=T.OA;export const buildStellarProposeSetAggregatorTx=T.$U;export const buildStellarProposeSetMinBorrowCollatTx=T.ob;export const buildStellarProposeSetPoolTemplateTx=T.cY;export const buildStellarProposeSetPositionLimitsTx=T.$l;export const buildStellarProposeTransferCtrlOwnershipTx=T.VS;export const buildStellarProposeTransferGovOwnTx=T.HP;export const buildStellarProposeUpdateDelayTx=T.YQ;export const buildStellarProposeUpdatePoolCapsTx=T.mK;export const buildStellarProposeUpgradeControllerTx=T.QY;export const buildStellarProposeUpgradePoolParamsTx=T.os;export const buildStellarProposeUpgradePoolTx=T.Ko;export const buildStellarRemoveAssetFromEModeTx=T.kz;export const buildStellarRemoveEModeCategoryTx=T.Oy;export const buildStellarRenewAccountTx=T.IJ;export const buildStellarRepayBatchTx=T.nw;export const buildStellarRepayDebtWithCollateralTx=T.Pr;export const buildStellarRepayTx=T.ZE;export const buildStellarRevokeRoleTx=T.ev;export const buildStellarRevokeTokenTx=T.P8;export const buildStellarSetAccumulatorTx=T.aV;export const buildStellarSetAggregatorTx=T.p2;export const buildStellarSetLiquidityPoolTemplateTx=T.Ww;export const buildStellarSetPositionLimitsTx=T.Dy;export const buildStellarSupplyBatchTx=T.Ni;export const buildStellarSupplyTx=T.v_;export const buildStellarSwapCollateralTx=T.qD;export const buildStellarSwapDebtTx=T.qR;export const buildStellarTransferOwnershipTx=T.QJ;export const buildStellarUnpauseTx=T.bm;export const buildStellarUpdateAccountThresholdTx=T.n_;export const buildStellarUpdateIndexesTx=T.v8;export const buildStellarUpdatePoolCapsTx=T.Y_;export const buildStellarUpgradeControllerTx=T.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=T.gH;export const buildStellarUpgradeLiquidityPoolTx=T.un;export const buildStellarWithdrawBatchTx=T.O3;export const buildStellarWithdrawTx=T.Gz;export const buildTx=T.pr;export const decodeStellarLendingEvent=T.Fm;export const encodeAssetConfigRaw=T.ns;export const encodeInterestRateModel=T.MB;export const encodeMarketOracleConfigInput=T.Dn;export const encodeMarketParamsRaw=T.pq;export const encodeOracleSourceConfigInput=T.ml;export const encodePositionLimits=T.Q3;export const encodeStrategyPayloadToRouteXdr=T.wf;export const extractEventOrder=T.Um;export const getStellarAccountPositions=T.xO;export const getStellarAggregatorQuote=T.Lw;export const getStellarAggregatorRouter=T.KM;export const getStellarAsset=T.mM;export const getStellarAssetGraph=T.iE;export const getStellarAssetMarkets=T.zp;export const getStellarAssetPage=T.N3;export const getStellarAssets=T.bN;export const getStellarGovernance=T.QV;export const getStellarGovernanceProposals=T.T_;export const getStellarHub=T.XI;export const getStellarHubGraph=T.Lt;export const getStellarHubs=T.KK;export const getStellarLendingController=T.vc;export const getStellarQuoteTokens=T.CH;export const getStellarReserve=T.FI;export const getStellarReserveGraph=T.KG;export const getStellarReserveHolders=T.nW;export const getStellarReserves=T.jF;export const getStellarSpoke=T.S2;export const getStellarSpokeGraph=T.uS;export const getStellarSpokes=T.u_;export const getStellarUserActivity=T.O5;export const getStellarUserPositions=T.Av;export const mapQuoteResponseToAggregatorSwap=T.LA;export const mapQuoteResponseToStrategyPayload=T.E6;export const mapQuoteResponseToStrategySwap=T.Ds;export const mapStellarPositionActivityType=T.CU;export const prepareStellarBuiltTx=T.Vx;export const prepareStellarTxXdr=T.DL;export const stellarLendingDispatchKey=T.ON;export const stellarLendingRead=T.Hh;export const syntheticEventOrder=T.oV;export const tagStellarInvokedContractError=T.g5;export const toBase64Xdr=T.L;export const toStellarPositionMode=T.Vu;
1
+ "undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis);import{Account as t,Address as e,BASE_FEE as o,Contract as r,ScInt as n,TransactionBuilder as u,scValToNative as i,xdr as s}from"@stellar/stellar-sdk";var a={388(a,p,l){l.d(p,{ME:()=>d,nO:()=>y,G_:()=>fe,DU:()=>c,fA:()=>Po,A$:()=>g,J9:()=>f,hS:()=>b,gR:()=>Oo,Cg:()=>Ro,VZ:()=>Jo,N0:()=>Vt,Wc:()=>Jt,hu:()=>Qt,B_:()=>ye,eX:()=>oe,z:()=>Vo,xD:()=>W,jR:()=>j,P2:()=>tr,W6:()=>de,KH:()=>ne,se:()=>pe,ln:()=>ie,g:()=>Xt,jP:()=>Yt,FM:()=>ue,yr:()=>zo,sp:()=>Z,$9:()=>oo,zw:()=>no,h_:()=>uo,e_:()=>io,Tk:()=>eo,BA:()=>ro,SX:()=>Dt,UF:()=>Io,Y5:()=>K,mE:()=>J,xG:()=>$t,s9:()=>Y,OL:()=>Bt,Mq:()=>Oe,fc:()=>Me,kD:()=>Be,Yf:()=>Le,c5:()=>Fe,qU:()=>De,RZ:()=>ze,PD:()=>We,cJ:()=>ke,vM:()=>Ie,hF:()=>Qe,Qk:()=>Ke,Gw:()=>Je,$K:()=>He,cO:()=>Ue,Qy:()=>Re,X7:()=>Ne,Ub:()=>Ye,Dx:()=>$e,OA:()=>we,$U:()=>Te,ob:()=>Pe,cY:()=>Ae,$l:()=>Ee,VS:()=>Xe,HP:()=>to,YQ:()=>Ze,mK:()=>Ce,QY:()=>je,os:()=>Ge,Ko:()=>Ve,kz:()=>ee,Oy:()=>Kt,IJ:()=>ae,nw:()=>F,Pr:()=>ot,ZE:()=>Q,ev:()=>Gt,P8:()=>re,aV:()=>jt,p2:()=>Wt,Ww:()=>Ht,Dy:()=>Ft,Ni:()=>z,v_:()=>V,qD:()=>et,qR:()=>tt,QJ:()=>zt,bm:()=>Nt,n_:()=>be,v8:()=>se,Y_:()=>te,qM:()=>Lt,gH:()=>le,un:()=>ce,O3:()=>H,Gz:()=>X,pr:()=>G,Fm:()=>Mo,ns:()=>Mt,MB:()=>Et,Dn:()=>Ut,pq:()=>Pt,ml:()=>Ct,Q3:()=>Rt,wf:()=>Go,Um:()=>Co,xO:()=>xt,Lw:()=>No,KM:()=>h,mM:()=>yt,iE:()=>St,zp:()=>ft,N3:()=>bt,bN:()=>st,QV:()=>_,T_:()=>vt,XI:()=>gt,Lt:()=>qt,KK:()=>at,yl:()=>it,vc:()=>m,CH:()=>Do,FI:()=>ct,KG:()=>wt,nW:()=>dt,jF:()=>lt,S2:()=>mt,uS:()=>Tt,u_:()=>pt,O5:()=>_t,Av:()=>ht,LA:()=>Ho,E6:()=>Wo,Ds:()=>jo,CU:()=>Lo,Vx:()=>Ko,DL:()=>Qo,ON:()=>po,Hh:()=>At,oV:()=>Uo,g5:()=>Fo,L:()=>so,Vu:()=>Zo});const c={mainnet:process.env.STELLAR_LENDING_CONTROLLER_MAINNET??"",testnet:process.env.STELLAR_LENDING_CONTROLLER_TESTNET??""},d={mainnet:process.env.STELLAR_AGGREGATOR_ROUTER_MAINNET??"",testnet:process.env.STELLAR_AGGREGATOR_ROUTER_TESTNET??""},y={mainnet:process.env.STELLAR_GOVERNANCE_MAINNET??"",testnet:process.env.STELLAR_GOVERNANCE_TESTNET??""},b={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},f={mainnet:process.env.STELLAR_QUOTE_URL_MAINNET??"https://stellar-swap.xoxno.com",testnet:process.env.STELLAR_QUOTE_URL_TESTNET??"https://testnet-stellar-swap.xoxno.com"},g={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function m(t){const e=c[t];if(!e)throw new Error(`Stellar lending controller address not configured for network "${t}". Set STELLAR_LENDING_CONTROLLER_${t.toUpperCase()} env var.`);return e}function h(t){const e=d[t];if(!e)throw new Error(`Stellar aggregator router address not configured for network "${t}". Set STELLAR_AGGREGATOR_ROUTER_${t.toUpperCase()} env var.`);return e}function _(t){const e=y[t];if(!e)throw new Error(`Stellar governance address not configured for network "${t}". Set STELLAR_GOVERNANCE_${t.toUpperCase()} env var.`);return e}const x=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],v=t=>new e(t).toScVal(),S=t=>new n(t).toI128(),q=t=>s.ScVal.scvU32(t),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),E=()=>s.ScVal.scvVoid(),P=t=>s.ScVal.scvVec(t),M=(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?E():e(t),O=(t,e)=>U({asset:v(e),hub_id:q(t)}),I=(t,e,o)=>s.ScVal.scvVec([O(t,e),S(o)]),C=t=>s.ScVal.scvVec(t.map((t=>I(t.hubId,t.asset,t.amount)))),U=t=>{const e=Object.keys(t).sort().map((e=>new s.ScMapEntry({key:k(e),val:t[e]})));return s.ScVal.scvMap(e)},L=t=>{const e=t.paths.map((t=>{const e=t.hops.map((t=>{return U({amount_out:S(t.amountOut),pool:v(t.pool),token_in:v(t.tokenIn),token_out:v(t.tokenOut),venue:(e=t.venue,s.ScVal.scvVec([k(e)]))});var e}));return U({hops:s.ScVal.scvVec(e),split_ppm:q(t.splitPpm)})}));return U({paths:s.ScVal.scvVec(e),referral_id:T(t.referralId??0),token_in:v(t.tokenIn),token_out:v(t.tokenOut),total_min_out:S(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)},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},N=t=>{if("string"==typeof t)return $(B(t));if(t instanceof Uint8Array)return $(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)):$(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||!x.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(L(e).toXDR("base64"),"base64")));var e,o;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},D=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 G(e,n,i){const s=e.controllerAddress??m(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:g[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function z(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return G(t,"supply",[v(t.caller),T(o),q(r),C([...e.assets])])}function V(t,e){return z(t,{accountNonce:e.accountNonce,spokeId:e.spokeId,assets:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function W(t,e){return G(t,"borrow",[v(t.caller),T(e.accountNonce),C([...e.borrows]),R(e.to,v)])}function j(t,e){return W(t,{accountNonce:e.accountNonce,borrows:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function H(t,e){return G(t,"withdraw",[v(t.caller),T(e.accountNonce),C([...e.withdrawals]),R(e.to,v)])}function X(t,e){return H(t,{accountNonce:e.accountNonce,withdrawals:[{hubId:e.hubId,asset:e.asset,amount:e.amount}],to:e.to})}function F(t,e){return G(t,"repay",[v(t.caller),T(e.accountNonce),C([...e.payments])])}function Q(t,e){return F(t,{accountNonce:e.accountNonce,payments:[{hubId:e.hubId,asset:e.asset,amount:e.amount}]})}function K(t,e){return G(t,"liquidate",[v(t.caller),T(e.accountNonce),C([...e.debtPayments])])}function Z(t,e){return G(t,"flash_loan",[v(t.caller),O(e.hubId,e.asset),S(e.amount),v(e.receiver),D(e.data)])}function J(t,e){return G(t,"migrate_from_blend",[v(t.caller),T(e.accountId),q(e.spokeId),q(e.hubId),v(e.blendPool),P(e.collateralTokens.map(v)),P(e.supplyTokens.map(v)),(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([v(e),S(o)]);var e,o}))))]);var o}function Y(t,e){const o=e.accountNonce??0,r=e.spokeId??0;return G(t,"multiply",[v(t.caller),T(o),q(r),O(e.collateral.hubId,e.collateral.asset),S(e.debtToFlashLoan),O(e.debt.hubId,e.debt.asset),q(e.mode),N(e.steps),R(e.initialPayment,(t=>I(t.hubId,t.asset,t.amount))),R(e.convertSwap,N)])}function tt(t,e){return G(t,"swap_debt",[v(t.caller),T(e.accountNonce),O(e.existingDebt.hubId,e.existingDebt.asset),S(e.newDebtAmount),O(e.newDebt.hubId,e.newDebt.asset),N(e.steps)])}function et(t,e){return G(t,"swap_collateral",[v(t.caller),T(e.accountNonce),O(e.current.hubId,e.current.asset),S(e.fromAmount),O(e.newCollateral.hubId,e.newCollateral.asset),N(e.steps)])}function ot(t,e){return G(t,"repay_debt_with_collateral",[v(t.caller),T(e.accountNonce),O(e.collateral.hubId,e.collateral.asset),S(e.collateralAmount),O(e.debt.hubId,e.debt.asset),N(e.steps),w(e.closePosition)])}const rt="/stellar-lending",nt=25,ut=encodeURIComponent,it=(t,e)=>t.fetchWithTimeout(`${rt}/context`,e),st=(t,e)=>t.fetchWithTimeout(`${rt}/assets`,e),at=(t,e)=>t.fetchWithTimeout(`${rt}/hubs`,e),pt=(t,e)=>t.fetchWithTimeout(`${rt}/spokes`,e),lt=(t,e={},o)=>{const{hubId:r,spokeId:n,asset:u}=e;return t.fetchWithTimeout(`${rt}/reserves`,{...o,params:{...void 0!==r?{hubId:r}:{},...void 0!==n?{spokeId:n}:{},...u?{asset:u}:{}}})},ct=(t,e,o,r,n)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}`,n),dt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}/holders`,{...u,params:{side:n}}),yt=(t,e,o)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}`,o),bt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/page`,{...r,params:{...o}}),ft=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/markets`,{...r,params:{side:o}}),gt=(t,e,o)=>t.fetchWithTimeout(`${rt}/hubs/${e}`,o),mt=(t,e,o)=>t.fetchWithTimeout(`${rt}/spokes/${e}`,o),ht=(t,e,o)=>t.fetchWithTimeout(`${rt}/users/${ut(e)}/positions`,o),_t=(t,e,o={},r)=>{const{skip:n,top:u}=o;return t.fetchWithTimeout(`${rt}/users/${ut(e)}/activity`,{...r,params:{...void 0!==n?{skip:n}:{},...void 0!==u?{top:u}:{}}})},xt=(t,e,o)=>t.fetchWithTimeout(`${rt}/accounts/${ut(e)}/positions`,o),vt=(t,e={},o)=>{const{top:r=nt,continuationToken:n}=e;return t.fetchWithTimeout(`${rt}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},St=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/graph`,{...r,params:{...o}}),qt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/hubs/${e}/graph`,{...r,params:{...o}}),Tt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/spokes/${e}/graph`,{...r,params:{...o}}),wt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}/graph`,{...u,params:{...n}}),At=t=>({context:e=>it(t,e),assets:e=>st(t,e),hubs:e=>at(t,e),spokes:e=>pt(t,e),reserves:(e,o)=>{return void 0===(r=e)||"hubId"in r||"spokeId"in r||"asset"in r?lt(t,e,o):lt(t,{},e);var r},reserve:(e,o,r,n)=>ct(t,e,o,r,n),reserveHolders:(e,o,r,n,u)=>dt(t,e,o,r,n,u),asset:(e,o)=>yt(t,e,o),assetMarkets:(e,o,r)=>ft(t,e,o,r),hub:(e,o)=>gt(t,e,o),spoke:(e,o)=>mt(t,e,o),userPositions:(e,o)=>ht(t,e,o),userActivity:(e,o,r)=>_t(t,e,o,r),accountPositions:(e,o)=>xt(t,e,o),governanceProposals:(e,o)=>vt(t,e,o),assetGraph:(e,o,r)=>St(t,e,o,r),hubGraph:(e,o,r)=>qt(t,e,o,r),spokeGraph:(e,o,r)=>Tt(t,e,o,r),reserveGraph:(e,o,r,n,u)=>wt(t,e,o,r,n,u)}),kt={Single:0,PrimaryWithAnchor:1},Et=t=>U({base_borrow_rate_ray:S(t.baseBorrowRateRay),max_borrow_rate_ray:S(t.maxBorrowRateRay),max_utilization_ray:S(t.maxUtilizationRay),mid_utilization_ray:S(t.midUtilizationRay),optimal_utilization_ray:S(t.optimalUtilizationRay),reserve_factor_bps:q(t.reserveFactorBps),slope1_ray:S(t.slope1Ray),slope2_ray:S(t.slope2Ray),slope3_ray:S(t.slope3Ray)}),Pt=t=>U({asset_decimals:q(t.assetDecimals),asset_id:v(t.assetId),base_borrow_rate_ray:S(t.baseBorrowRateRay),borrow_cap:S(t.borrowCap),max_borrow_rate_ray:S(t.maxBorrowRateRay),max_utilization_ray:S(t.maxUtilizationRay),mid_utilization_ray:S(t.midUtilizationRay),optimal_utilization_ray:S(t.optimalUtilizationRay),reserve_factor_bps:q(t.reserveFactorBps),slope1_ray:S(t.slope1Ray),slope2_ray:S(t.slope2Ray),slope3_ray:S(t.slope3Ray),supply_cap:S(t.supplyCap)}),Mt=t=>U({asset_decimals:q(0),e_mode_categories:P(t.eModeCategories.map((t=>q(t)))),flashloan_fee_bps:q(t.flashloanFeeBps),is_borrowable:w(t.isBorrowable),is_collateralizable:w(t.isCollateralizable),is_flashloanable:w(t.isFlashloanable),liquidation_bonus_bps:q(t.liquidationBonusBps),liquidation_fees_bps:q(t.liquidationFeesBps),liquidation_threshold_bps:q(t.liquidationThresholdBps),loan_to_value_bps:q(t.loanToValueBps)}),Rt=t=>U({max_borrow_positions:q(t.maxBorrowPositions),max_supply_positions:q(t.maxSupplyPositions)}),Ot=t=>{const e=t.kind;switch(e){case"Stellar":return P([k("Stellar"),v(t.value)]);case"Symbol":return P([k("Symbol"),k(t.value)]);case"String":return P([k("String"),A(t.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${e}"`)}},It=(t,e)=>{if("Twap"===t){if("number"!=typeof e)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return P([k("Twap"),q(e)])}return P([k("Spot")])},Ct=t=>{const e=t.provider;if("ReflectorSep40"===e){if(!t.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return P([k("Reflector"),U({asset:Ot(t.asset),contract:v(t.contract),read_mode:It(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 P([k("RedStone"),U({contract:v(t.contract),feed_id:A(t.feedId),max_stale_seconds:T(t.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${e}"`)},Ut=t=>{const e=kt[t.strategy];if(void 0===e)throw new Error(`Stellar builder: unknown oracle strategy "${t.strategy}"`);return U({anchor:(o=t.anchor,P(null==o?[k("None")]:[k("Some"),Ct(o)])),max_price_stale_seconds:T(t.maxPriceStaleSeconds),max_sanity_price_wad:S(t.maxSanityPriceWad),min_sanity_price_wad:S(t.minSanityPriceWad),primary:Ct(t.primary),strategy:q(e),tolerance_bps:q(t.toleranceBps)});var o};function Lt(t,e){return G(t,"upgrade",[M(e.wasmHash)])}function $t(t,e){return G(t,"migrate",[q(e.newVersion)])}function Bt(t){return G(t,"pause",[])}function Nt(t){return G(t,"unpause",[])}function Dt(t,e){return G(t,"grant_role",[v(e.account),k(e.role)])}function Gt(t,e){return G(t,"revoke_role",[v(e.account),k(e.role)])}function zt(t,e){return G(t,"transfer_ownership",[v(e.newOwner),q(e.liveUntilLedger)])}function Vt(t){return G(t,"accept_ownership",[])}function Wt(t,e){return G(t,"set_aggregator",[v(e.aggregator)])}function jt(t,e){return G(t,"set_accumulator",[v(e.accumulator)])}function Ht(t,e){return G(t,"set_liquidity_pool_template",[M(e.wasmHash)])}function Xt(t,e){return G(t,"edit_asset_config",[v(e.asset),Mt(e.config)])}function Ft(t,e){return G(t,"set_position_limits",[Rt(e)])}function Qt(t){return G(t,"add_e_mode_category",[])}function Kt(t,e){return G(t,"remove_e_mode_category",[q(e.id)])}const Zt=t=>U({asset:v(t.asset),category_id:q(t.categoryId),can_collateral:w(t.canCollateral),can_borrow:w(t.canBorrow),ltv:q(t.ltv),threshold:q(t.threshold),bonus:q(t.bonus),supply_cap:S(t.supplyCap),borrow_cap:S(t.borrowCap)});function Jt(t,e){return G(t,"add_asset_to_e_mode_category",[Zt(e)])}function Yt(t,e){return G(t,"edit_asset_in_e_mode_category",[Zt(e)])}function te(t,e){return G(t,"update_pool_caps",[v(e.asset),S(e.supplyCap),S(e.borrowCap)])}function ee(t,e){return G(t,"remove_asset_from_e_mode",[v(e.asset),q(e.categoryId)])}function oe(t,e){return G(t,"approve_token",[v(e.token)])}function re(t,e){return G(t,"revoke_token",[v(e.token)])}function ne(t,e){return G(t,"configure_market_oracle",[v(t.caller),v(e.asset),Ut(e.config)])}function ue(t,e){return G(t,"edit_oracle_tolerance",[v(t.caller),v(e.asset),q(e.tolerance)])}function ie(t,e){return G(t,"disable_token_oracle",[v(t.caller),v(e.asset)])}function se(t,e){return G(t,"update_indexes",[v(t.caller),P(e.assets.map((t=>v(t))))])}function ae(t,e){return G(t,"renew_account",[v(t.caller),T(e.accountNonce)])}function pe(t,e){return G(t,"create_liquidity_pool",[v(e.asset),Pt(e.params),Mt(e.config)])}function le(t,e){return G(t,"upgrade_liquidity_pool_params",[v(e.asset),Et(e.params)])}function ce(t,e){return G(t,"upgrade_liquidity_pool",[v(e.asset),M(e.wasmHash)])}function de(t,e){return G(t,"claim_revenue",[v(t.caller),P(e.assets.map((t=>v(t))))])}function ye(t,e){return G(t,"add_rewards",[v(t.caller),P(e.rewards.map((t=>P([v(t.token),S(t.amount)]))))])}function be(t,e){return G(t,"update_account_threshold",[v(t.caller),v(e.asset),w(e.hasRisks),P(e.accountNonces.map((t=>T(t))))])}const fe="00".repeat(32),ge=t=>{if("string"==typeof t)return M(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)},me=(t,...e)=>P([k(t),...e]),he=t=>U({asset:v(t.asset),category_id:q(t.categoryId),can_collateral:w(t.canCollateral),can_borrow:w(t.canBorrow),ltv:q(t.ltv),threshold:q(t.threshold),bonus:q(t.bonus),supply_cap:S(t.supplyCap),borrow_cap:S(t.borrowCap)}),_e=t=>U({new_owner:v(t.newOwner),live_until_ledger:q(t.liveUntilLedger)}),xe=t=>U({account:v(t.account),role:k(t.role)});function ve(e,n,i){const s=e.governanceAddress??_(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:g[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Se=(t,e,o)=>ve(t,"propose",[v(t.caller),e,ge(o)]),qe=(t,e,o)=>ve(t,"execute_self",[E(),e,ge(o)]);function Te(t,e,o){return Se(t,me("SetAggregator",v(e.aggregator)),o)}function we(t,e,o){return Se(t,me("SetAccumulator",v(e.accumulator)),o)}function Ae(t,e,o){return Se(t,me("SetLiquidityPoolTemplate",M(e.wasmHash)),o)}function ke(t,e,o){return Se(t,me("EditAssetConfig",v(e.asset),Mt(e.config)),o)}function Ee(t,e,o){return Se(t,me("SetPositionLimits",Rt(e)),o)}function Pe(t,e,o){return Se(t,me("SetMinBorrowCollateralUsd",S(e.floorWad)),o)}function Me(t,e){return Se(t,me("AddEModeCategory"),e)}function Re(t,e,o){return Se(t,me("RemoveEModeCategory",q(e.id)),o)}function Oe(t,e,o){return Se(t,me("AddAssetToEModeCategory",he(e)),o)}function Ie(t,e,o){return Se(t,me("EditAssetInEModeCategory",he(e)),o)}function Ce(t,e,o){return Se(t,me("UpdatePoolCaps",U({asset:v((r=e).asset),supply_cap:S(r.supplyCap),borrow_cap:S(r.borrowCap)})),o);var r}function Ue(t,e,o){return Se(t,me("RemoveAssetFromEMode",U({asset:v((r=e).asset),category_id:q(r.categoryId)})),o);var r}function Le(t,e,o){return Se(t,me("ApproveToken",v(e.token)),o)}function $e(t,e,o){return Se(t,me("RevokeToken",v(e.token)),o)}function Be(t,e,o){return Se(t,me("ApproveBlendPool",v(e.pool)),o)}function Ne(t,e,o){return Se(t,me("RevokeBlendPool",v(e.pool)),o)}function De(t,e,o){return Se(t,me("CreateLiquidityPool",U({asset:v((r=e).asset),params:Pt(r.params),config:Mt(r.config)})),o);var r}function Ge(t,e,o){return Se(t,me("UpgradeLiquidityPoolParams",U({asset:v((r=e).asset),params:Et(r.params)})),o);var r}function ze(t,e){return Se(t,me("DeployPool"),e)}function Ve(t,e,o){return Se(t,me("UpgradePool",M(e.wasmHash)),o)}function We(t,e,o){return Se(t,me("DisableTokenOracle",v(e.asset)),o)}function je(t,e,o){return Se(t,me("UpgradeController",M(e.wasmHash)),o)}function He(t,e,o){return Se(t,me("MigrateController",q(e.newVersion)),o)}function Xe(t,e,o){return Se(t,me("TransferCtrlOwnership",_e(e)),o)}function Fe(t,e,o){return Se(t,me("ConfigureMarketOracle",U({asset:v((r=e).asset),cfg:Ut(r.config)})),o);var r}function Qe(t,e,o){return Se(t,me("EditOracleTolerance",U({asset:v((r=e).asset),tolerance:q(r.tolerance)})),o);var r}function Ke(t,e,o){return Se(t,me("UpgradeGov",M(e.wasmHash)),o)}function Ze(t,e,o){return Se(t,me("UpdateGovDelay",q(e.newDelay)),o)}function Je(t,e,o){return Se(t,me("GrantGovRole",xe(e)),o)}function Ye(t,e,o){return Se(t,me("RevokeGovRole",xe(e)),o)}function to(t,e,o){return Se(t,me("TransferGovOwnership",_e(e)),o)}function eo(t,e){const o=P(e.argsXdr.map((t=>s.ScVal.fromXDR(t,"base64")))),r=ge(e.predecessor??fe);return ve(t,"execute",[E(),v(e.target),k(e.functionName),o,r,ge(e.salt)])}function oo(t,e,o){return qe(t,me("UpgradeGov",M(e.wasmHash)),o)}function ro(t,e,o){return qe(t,me("UpdateGovDelay",q(e.newDelay)),o)}function no(t,e,o){return qe(t,me("GrantGovRole",xe(e)),o)}function uo(t,e,o){return qe(t,me("RevokeGovRole",xe(e)),o)}function io(t,e,o){return qe(t,me("TransferGovOwnership",_e(e)),o)}const so=t=>t.toXDR("base64"),ao=t=>s.ScVal.fromXDR(t,"base64"),po=t=>t.map((t=>String(i(ao(t))))).join(":"),lo=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),co=t=>Number(t),yo=t=>String(t),bo=t=>null==t?void 0:lo(t),fo=t=>null==t?void 0:yo(t),go=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),mo=["None","Multiply","Long","Short"],ho=["Single","PrimaryWithAnchor"],_o=["ReflectorSep40","RedStonePriceFeed"],xo=["Spot","Twap"],vo=["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"],So=t=>Array.isArray(t)?t:[],qo=t=>({loanToValueBps:co(t.loan_to_value_bps),liquidationThresholdBps:co(t.liquidation_threshold_bps),liquidationBonusBps:co(t.liquidation_bonus_bps),liquidationFeesBps:co(t.liquidation_fees_bps),isCollateralizable:Boolean(t.is_collateralizable),isBorrowable:Boolean(t.is_borrowable),isFlashloanable:Boolean(t.is_flashloanable),flashloanFeeBps:co(t.flashloan_fee_bps),eModeCategories:(t.e_mode_categories??[]).map(co)}),To=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],vo[co(r)]??lo(r)),positionType:e,asset:yo(t[1]),scaledAmountRay:lo(t[2]),indexRay:lo(t[3]),amount:lo(t[4]),liquidationThresholdBps:o?void 0:co(t[5]),liquidationBonusBps:o?void 0:co(t[6]),loanToValueBps:o?void 0:co(t[7])};var r},wo=t=>{return{owner:yo(t[0]),eModeCategoryId:co(t[1]),mode:(e=t[2],mo[co(e)]??"None")};var e},Ao=(t,e)=>{const o=xo[co(t[`${e}_read_mode`])]??"Spot",r=t[`${e}_asset`],n=t[`${e}_symbol`],u=null!=r?{kind:"Stellar",value:yo(r)}:null!=n?{kind:"Symbol",value:yo(n)}:void 0;return{provider:_o[co(t[`${e}_provider`])]??"ReflectorSep40",contractAddress:yo(t[`${e}_contract`]),asset:u,feedId:fo(t[`${e}_feed_id`]),readMode:o,twapRecords:"Twap"===o?co(t[`${e}_twap_records`]):void 0,decimals:co(t[`${e}_decimals`]),resolutionSeconds:co(t[`${e}_resolution_seconds`]),maxStaleSeconds:co(t[`${e}_max_stale_seconds`])}},ko=t=>{const e=null!==t.anchor_provider&&void 0!==t.anchor_provider;return{baseTokenId:yo(t.base_token_id),quoteTokenId:yo(t.quote_token_id),tolerance:{upperRatio:co(t.upper_ratio_bps??t.tolerance?.upper_ratio_bps),lowerRatio:co(t.lower_ratio_bps??t.tolerance?.lower_ratio_bps)},assetDecimals:co(t.asset_decimals),maxPriceStaleSeconds:co(t.max_price_stale_seconds),strategy:ho[co(t.strategy)]??"Single",primary:Ao(t,"primary"),anchor:e?Ao(t,"anchor"):void 0,primaryQuoteToken:fo(t.primary_quote_token),anchorQuoteToken:fo(t.anchor_quote_token),minSanityPriceWad:bo(t.min_sanity_price_wad),maxSanityPriceWad:bo(t.max_sanity_price_wad)}},Eo={"market:create":t=>({topic:"market:create",data:{baseAsset:yo(t.base_asset),maxBorrowRate:lo(t.max_borrow_rate),baseBorrowRate:lo(t.base_borrow_rate),slope1:lo(t.slope1),slope2:lo(t.slope2),slope3:lo(t.slope3),midUtilization:lo(t.mid_utilization),optimalUtilization:lo(t.optimal_utilization),maxUtilization:bo(t.max_utilization),reserveFactor:co(t.reserve_factor),marketAddress:yo(t.market_address),config:qo(t.config)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:yo(t.asset),maxBorrowRateRay:lo(t.max_borrow_rate_ray),baseBorrowRateRay:lo(t.base_borrow_rate_ray),slope1Ray:lo(t.slope1_ray),slope2Ray:lo(t.slope2_ray),slope3Ray:lo(t.slope3_ray),midUtilizationRay:lo(t.mid_utilization_ray),optimalUtilizationRay:lo(t.optimal_utilization_ray),maxUtilizationRay:bo(t.max_utilization_ray),reserveFactorBps:co(t.reserve_factor_bps)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:So(t).map((t=>{return e=So(t),{asset:yo(e[0]),timestamp:co(e[1]),supplyIndexRay:lo(e[2]),borrowIndexRay:lo(e[3]),reservesRay:lo(e[4]),suppliedRay:lo(e[5]),borrowedRay:lo(e[6]),revenueRay:lo(e[7]),assetPriceWad:bo(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:So(t).map((t=>{const e=t;return{asset:yo(e.asset),params:(o=e.params,{maxBorrowRateRay:lo(o.max_borrow_rate_ray),baseBorrowRateRay:lo(o.base_borrow_rate_ray),slope1Ray:lo(o.slope1_ray),slope2Ray:lo(o.slope2_ray),slope3Ray:lo(o.slope3_ray),midUtilizationRay:lo(o.mid_utilization_ray),optimalUtilizationRay:lo(o.optimal_utilization_ray),maxUtilizationRay:bo(o.max_utilization_ray),reserveFactorBps:co(o.reserve_factor_bps),supplyCap:lo(o.supply_cap),borrowCap:lo(o.borrow_cap),assetId:fo(o.asset_id),assetDecimals:void 0===o.asset_decimals?void 0:co(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=So(t);return{topic:"position:batch_update",data:{accountId:lo(e[0]),accountAttributes:wo(So(e[1])),updates:[...So(e[2]).map((t=>To(So(t),"Deposit"))),...So(e[3]).map((t=>To(So(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{asset:yo(t.asset),receiver:yo(t.receiver),caller:yo(t.caller),amount:lo(t.amount),fee:lo(t.fee)}}),"config:asset":t=>({topic:"config:asset",data:{asset:yo(t.asset),config:qo(t.config)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:yo(t.asset),oracle:ko(t.oracle)}}),"config:emode_category":t=>({topic:"config:emode_category",data:{category:{categoryId:co(t.category.category_id),isDeprecated:Boolean(t.category.is_deprecated)}}}),"config:emode_asset":t=>({topic:"config:emode_asset",data:{asset:yo(t.asset),config:{isCollateralizable:Boolean(t.config.is_collateralizable),isBorrowable:Boolean(t.config.is_borrowable),loanToValueBps:co(t.config.loan_to_value_bps),liquidationThresholdBps:co(t.config.liquidation_threshold_bps),liquidationBonusBps:co(t.config.liquidation_bonus_bps),supplyCap:lo(t.config.supply_cap),borrowCap:lo(t.config.borrow_cap)},categoryId:co(t.category_id)}}),"config:remove_emode_asset":t=>({topic:"config:remove_emode_asset",data:{asset:yo(t.asset),categoryId:co(t.category_id)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:lo(t.account_id),totalBorrowUsdWad:lo(t.total_borrow_usd_wad),totalCollateralUsdWad:lo(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:yo(t.token),amount:lo(t.amount),usdValueWad:lo(t.usd_value_wad),accountId:lo(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{asset:yo(t.asset),amount:lo(t.amount),fee:lo(t.fee),amountSent:lo(t.amount_sent)}}),"config:approve_token":t=>({topic:"config:approve_token",data:{wasmHash:go(t.wasm_hash),approved:Boolean(t.approved)}}),"config:aggregator":t=>({topic:"config:aggregator",data:{aggregator:yo(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:yo(t.accumulator)}}),"config:pool_template":t=>({topic:"config:pool_template",data:{wasmHash:go(t.wasm_hash)}}),"config:position_limits":t=>({topic:"config:position_limits",data:{maxSupplyPositions:co(t.max_supply_positions),maxBorrowPositions:co(t.max_borrow_positions)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:yo(t.asset)}})},Po=Object.freeze(Object.keys(Eo));function Mo(t,e){const o=po(t),r=Eo[o];return r?r(i(ao(e))):null}const Ro="XLENDXLM-a7c9f3",Oo=1e4;function Io(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${Ro}-${o}`}function Co(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function Uo(t,e=0){return t*Oo+e}function Lo(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const $o=(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()},Bo=t=>t.baseUrl??f[t.network];async function No(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=$o(Bo(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 Do(t){const e=$o(Bo(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 Go=t=>L(t).toXDR("base64");function zo(e,n){const i=e.routerAddress??h(e.network),s=new r(i),a=new t(e.caller,e.sourceSequence),p=N(((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:g[e.network]}).addOperation(s.call("execute_strategy",v(e.caller),S(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Vo(t,e){return zo(t,e)}function Wo(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(Xo),splitPpm:t.splitPpm}))):[{hops:t.hops.map(Xo),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function jo(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:Wo(t,e)}const Ho=Wo,Xo=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Fo(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Qo(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw Fo(o.invokedContractId,t);throw t}}async function Ko(t,e,o){return Qo(t,e.xdr,o)}function Zo(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 Jo(t,e){return{paths:[{hops:[{amountOut:"0",pool:t,tokenIn:t,tokenOut:t,venue:"Soroswap"}],splitPpm:1e6}],referralId:0,tokenIn:t,tokenOut:t,totalMinOut:e}}const Yo=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 tr(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",s.ScVal.scvBytes(Yo(e.message)),s.ScVal.scvBytes(Yo(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:g[e.network]}).addOperation(n).setTimeout(e.timeoutSeconds??120).build().toXDR()}}}},p={};function l(t){var e=p[t];if(void 0!==e)return e.exports;var o=p[t]={exports:{}};return a[t](o,o.exports,l),o.exports}l.d=(t,e)=>{for(var o in e)l.o(e,o)&&!l.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const c="https://api.xoxno.com",d="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",y="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",b="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var f;!function(t){t.MAINNET="1",t.DEVNET="D"}(f||(f={}));class g{apiUrl;chain;init;config;constructor({chain:t=f.MAINNET,apiUrl:e=c,...o}={}){this.apiUrl=e??{[f.MAINNET]:c,[f.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==f.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:d,DR_SC:y,KG_SC:b,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:d,DR_SC:y,KG_SC:b,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:c="GET",...d}=o,y=l?.Authorization,b="Bearer undefined"===y?void 0:y,f={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===c?{}:{"Content-Type":"application/json"},...b?{Authorization:b}:{}},g=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),m=`${this.apiUrl}${t}${g.length?`?${g}`:""}`,{revalidate:h,..._}=r??{},{revalidate:x,...v}=s??{},S="GET"!==c||b?void 0:x??h,q="GET"!==c||b||S?void 0:a??n,T={...i,...d,method:c,...Object.keys(f).length?{headers:f}:{},cache:q,next:{..._,...v,revalidate:S}};(p??u)&&console.debug("SDK fetch: ",m,T);const w=await fetch(m,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${m}: ${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=[m,w.status,w.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const m=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 _ extends Error{constructor(t){super(`Invalid collection ticker: ${t}`)}}class x extends Error{constructor(t){super(`Invalid address: ${t}`)}}Error,Error;const v=t=>!!t&&(t.startsWith("erd1")&&62===t.length||/^0x[a-fA-F0-9]{40,64}$/.test(t)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t)||/^G[A-Z2-7]{55}$/.test(t)),S={"/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/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}}},q=["PATCH","POST","DELETE","PUT"];var T=l(388);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(!v(t))throw new x(t)}if(p){const t=n.collection;if(Array.isArray(t)?t.some((t=>!m(t))):!m(t))throw new _(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:c,auth:d,method:y,headers:b,cache:f,next:g,debug:h,continuationToken:S,...q}=l,T=d?`Bearer ${d}`:void 0,w={...b,...T?{Authorization:T}:{},...S?{"X-Continuation-Token":String(S)}:{}},A={...g,tags:[...g?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:q,body:c,headers:w,cache:f,debug:h,...A?{next:A}:{}})},a=(t={})=>s(t);for(const t of Object.keys(i))q.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(S)){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{f as Chain,g as XOXNOClient,k as buildSdk,m as isValidCollectionTicker,h as isValidNftIdentifier};export const STELLAR_AGGREGATOR_ROUTER=T.ME;export const STELLAR_GOVERNANCE=T.nO;export const STELLAR_GOVERNANCE_ZERO_PREDECESSOR=T.G_;export const STELLAR_LENDING_CONTROLLER=T.DU;export const STELLAR_LENDING_TOPICS=T.fA;export const STELLAR_NETWORK_PASSPHRASE=T.A$;export const STELLAR_QUOTE_URL=T.J9;export const STELLAR_SOROBAN_RPC_URL=T.hS;export const SYNTHETIC_EVENT_ORDER_STRIDE=T.gR;export const XOXNO_LENDING_STELLAR_TICKER=T.Cg;export const buildSameTokenRepaySwapSteps=T.VZ;export const buildStellarAcceptOwnershipTx=T.N0;export const buildStellarAddAssetToEModeCategoryTx=T.Wc;export const buildStellarAddEModeCategoryTx=T.hu;export const buildStellarAddRewardsTx=T.B_;export const buildStellarApproveTokenTx=T.eX;export const buildStellarBatchSwapTx=T.z;export const buildStellarBorrowBatchTx=T.xD;export const buildStellarBorrowTx=T.jR;export const buildStellarCctpForwardTx=T.P2;export const buildStellarClaimRevenueTx=T.W6;export const buildStellarConfigureMarketOracleTx=T.KH;export const buildStellarCreateLiquidityPoolTx=T.se;export const buildStellarDisableTokenOracleTx=T.ln;export const buildStellarEditAssetConfigTx=T.g;export const buildStellarEditAssetInEModeCategoryTx=T.jP;export const buildStellarEditOracleToleranceTx=T.FM;export const buildStellarExecuteStrategyTx=T.yr;export const buildStellarFlashLoanTx=T.sp;export const buildStellarGovernanceExecuteGovernanceUpgradeTx=T.$9;export const buildStellarGovernanceExecuteGrantGovernanceRoleTx=T.zw;export const buildStellarGovernanceExecuteRevokeGovernanceRoleTx=T.h_;export const buildStellarGovernanceExecuteTransferGovOwnTx=T.e_;export const buildStellarGovernanceExecuteTx=T.Tk;export const buildStellarGovernanceExecuteUpdateDelayTx=T.BA;export const buildStellarGrantRoleTx=T.SX;export const buildStellarLendingIdentifier=T.UF;export const buildStellarLiquidateTx=T.Y5;export const buildStellarMigrateFromBlendTx=T.mE;export const buildStellarMigrateTx=T.xG;export const buildStellarMultiplyTx=T.s9;export const buildStellarPauseTx=T.OL;export const buildStellarProposeAddAssetToEModeTx=T.Mq;export const buildStellarProposeAddEModeCategoryTx=T.fc;export const buildStellarProposeApproveBlendPoolTx=T.kD;export const buildStellarProposeApproveTokenTx=T.Yf;export const buildStellarProposeConfigureMarketOracleTx=T.c5;export const buildStellarProposeCreateLiquidityPoolTx=T.qU;export const buildStellarProposeDeployPoolTx=T.RZ;export const buildStellarProposeDisableTokenOracleTx=T.PD;export const buildStellarProposeEditAssetConfigTx=T.cJ;export const buildStellarProposeEditAssetInEModeTx=T.vM;export const buildStellarProposeEditOracleToleranceTx=T.hF;export const buildStellarProposeGovernanceUpgradeTx=T.Qk;export const buildStellarProposeGrantGovernanceRoleTx=T.Gw;export const buildStellarProposeMigrateControllerTx=T.$K;export const buildStellarProposeRemoveAssetFromEModeTx=T.cO;export const buildStellarProposeRemoveEModeCategoryTx=T.Qy;export const buildStellarProposeRevokeBlendPoolTx=T.X7;export const buildStellarProposeRevokeGovernanceRoleTx=T.Ub;export const buildStellarProposeRevokeTokenTx=T.Dx;export const buildStellarProposeSetAccumulatorTx=T.OA;export const buildStellarProposeSetAggregatorTx=T.$U;export const buildStellarProposeSetMinBorrowCollatTx=T.ob;export const buildStellarProposeSetPoolTemplateTx=T.cY;export const buildStellarProposeSetPositionLimitsTx=T.$l;export const buildStellarProposeTransferCtrlOwnershipTx=T.VS;export const buildStellarProposeTransferGovOwnTx=T.HP;export const buildStellarProposeUpdateDelayTx=T.YQ;export const buildStellarProposeUpdatePoolCapsTx=T.mK;export const buildStellarProposeUpgradeControllerTx=T.QY;export const buildStellarProposeUpgradePoolParamsTx=T.os;export const buildStellarProposeUpgradePoolTx=T.Ko;export const buildStellarRemoveAssetFromEModeTx=T.kz;export const buildStellarRemoveEModeCategoryTx=T.Oy;export const buildStellarRenewAccountTx=T.IJ;export const buildStellarRepayBatchTx=T.nw;export const buildStellarRepayDebtWithCollateralTx=T.Pr;export const buildStellarRepayTx=T.ZE;export const buildStellarRevokeRoleTx=T.ev;export const buildStellarRevokeTokenTx=T.P8;export const buildStellarSetAccumulatorTx=T.aV;export const buildStellarSetAggregatorTx=T.p2;export const buildStellarSetLiquidityPoolTemplateTx=T.Ww;export const buildStellarSetPositionLimitsTx=T.Dy;export const buildStellarSupplyBatchTx=T.Ni;export const buildStellarSupplyTx=T.v_;export const buildStellarSwapCollateralTx=T.qD;export const buildStellarSwapDebtTx=T.qR;export const buildStellarTransferOwnershipTx=T.QJ;export const buildStellarUnpauseTx=T.bm;export const buildStellarUpdateAccountThresholdTx=T.n_;export const buildStellarUpdateIndexesTx=T.v8;export const buildStellarUpdatePoolCapsTx=T.Y_;export const buildStellarUpgradeControllerTx=T.qM;export const buildStellarUpgradeLiquidityPoolParamsTx=T.gH;export const buildStellarUpgradeLiquidityPoolTx=T.un;export const buildStellarWithdrawBatchTx=T.O3;export const buildStellarWithdrawTx=T.Gz;export const buildTx=T.pr;export const decodeStellarLendingEvent=T.Fm;export const encodeAssetConfigRaw=T.ns;export const encodeInterestRateModel=T.MB;export const encodeMarketOracleConfigInput=T.Dn;export const encodeMarketParamsRaw=T.pq;export const encodeOracleSourceConfigInput=T.ml;export const encodePositionLimits=T.Q3;export const encodeStrategyPayloadToRouteXdr=T.wf;export const extractEventOrder=T.Um;export const getStellarAccountPositions=T.xO;export const getStellarAggregatorQuote=T.Lw;export const getStellarAggregatorRouter=T.KM;export const getStellarAsset=T.mM;export const getStellarAssetGraph=T.iE;export const getStellarAssetMarkets=T.zp;export const getStellarAssetPage=T.N3;export const getStellarAssets=T.bN;export const getStellarGovernance=T.QV;export const getStellarGovernanceProposals=T.T_;export const getStellarHub=T.XI;export const getStellarHubGraph=T.Lt;export const getStellarHubs=T.KK;export const getStellarLendingContext=T.yl;export const getStellarLendingController=T.vc;export const getStellarQuoteTokens=T.CH;export const getStellarReserve=T.FI;export const getStellarReserveGraph=T.KG;export const getStellarReserveHolders=T.nW;export const getStellarReserves=T.jF;export const getStellarSpoke=T.S2;export const getStellarSpokeGraph=T.uS;export const getStellarSpokes=T.u_;export const getStellarUserActivity=T.O5;export const getStellarUserPositions=T.Av;export const mapQuoteResponseToAggregatorSwap=T.LA;export const mapQuoteResponseToStrategyPayload=T.E6;export const mapQuoteResponseToStrategySwap=T.Ds;export const mapStellarPositionActivityType=T.CU;export const prepareStellarBuiltTx=T.Vx;export const prepareStellarTxXdr=T.DL;export const stellarLendingDispatchKey=T.ON;export const stellarLendingRead=T.Hh;export const syntheticEventOrder=T.oV;export const tagStellarInvokedContractError=T.g5;export const toBase64Xdr=T.L;export const toStellarPositionMode=T.Vu;
@@ -1 +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:()=>lt,STELLAR_LENDING_CONTROLLER:()=>r,STELLAR_LENDING_TOPICS:()=>Er,STELLAR_NETWORK_PASSPHRASE:()=>l,STELLAR_QUOTE_URL:()=>s,STELLAR_SOROBAN_RPC_URL:()=>n,SYNTHETIC_EVENT_ORDER_STRIDE:()=>Pr,XOXNO_LENDING_STELLAR_TICKER:()=>Ar,buildSameTokenRepaySwapSteps:()=>Kr,buildStellarAcceptOwnershipTx:()=>$e,buildStellarAddAssetToEModeCategoryTx:()=>We,buildStellarAddEModeCategoryTx:()=>Ve,buildStellarAddRewardsTx:()=>nt,buildStellarApproveTokenTx:()=>je,buildStellarBatchSwapTx:()=>Vr,buildStellarBorrowBatchTx:()=>U,buildStellarBorrowTx:()=>G,buildStellarCctpForwardTx:()=>Yr,buildStellarClaimRevenueTx:()=>at,buildStellarConfigureMarketOracleTx:()=>Ke,buildStellarCreateLiquidityPoolTx:()=>tt,buildStellarDisableTokenOracleTx:()=>Ye,buildStellarEditAssetConfigTx:()=>qe,buildStellarEditAssetInEModeCategoryTx:()=>Xe,buildStellarEditOracleToleranceTx:()=>Ze,buildStellarExecuteStrategyTx:()=>Mr,buildStellarFlashLoanTx:()=>W,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>er,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>rr,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>or,buildStellarGovernanceExecuteTransferGovOwnTx:()=>ar,buildStellarGovernanceExecuteTx:()=>Jt,buildStellarGovernanceExecuteUpdateDelayTx:()=>tr,buildStellarGrantRoleTx:()=>Oe,buildStellarLendingIdentifier:()=>Ir,buildStellarLiquidateTx:()=>z,buildStellarMigrateFromBlendTx:()=>X,buildStellarMigrateTx:()=>Pe,buildStellarMultiplyTx:()=>F,buildStellarPauseTx:()=>Ie,buildStellarProposeAddAssetToEModeTx:()=>It,buildStellarProposeAddEModeCategoryTx:()=>At,buildStellarProposeApproveBlendPoolTx:()=>Nt,buildStellarProposeApproveTokenTx:()=>Lt,buildStellarProposeConfigureMarketOracleTx:()=>Ft,buildStellarProposeCreateLiquidityPoolTx:()=>Gt,buildStellarProposeDeployPoolTx:()=>Mt,buildStellarProposeDisableTokenOracleTx:()=>Dt,buildStellarProposeEditAssetConfigTx:()=>Rt,buildStellarProposeEditAssetInEModeTx:()=>Bt,buildStellarProposeEditOracleToleranceTx:()=>Ht,buildStellarProposeGovernanceUpgradeTx:()=>jt,buildStellarProposeGrantGovernanceRoleTx:()=>Kt,buildStellarProposeMigrateControllerTx:()=>Wt,buildStellarProposeRemoveAssetFromEModeTx:()=>Ct,buildStellarProposeRemoveEModeCategoryTx:()=>Pt,buildStellarProposeRevokeBlendPoolTx:()=>Ut,buildStellarProposeRevokeGovernanceRoleTx:()=>Zt,buildStellarProposeRevokeTokenTx:()=>$t,buildStellarProposeSetAccumulatorTx:()=>xt,buildStellarProposeSetAggregatorTx:()=>Tt,buildStellarProposeSetMinBorrowCollatTx:()=>kt,buildStellarProposeSetPoolTemplateTx:()=>vt,buildStellarProposeSetPositionLimitsTx:()=>Et,buildStellarProposeTransferCtrlOwnershipTx:()=>Xt,buildStellarProposeTransferGovOwnTx:()=>Yt,buildStellarProposeUpdateDelayTx:()=>Qt,buildStellarProposeUpdatePoolCapsTx:()=>Ot,buildStellarProposeUpgradeControllerTx:()=>zt,buildStellarProposeUpgradePoolParamsTx:()=>qt,buildStellarProposeUpgradePoolTx:()=>Vt,buildStellarRemoveAssetFromEModeTx:()=>He,buildStellarRemoveEModeCategoryTx:()=>De,buildStellarRenewAccountTx:()=>et,buildStellarRepayBatchTx:()=>V,buildStellarRepayDebtWithCollateralTx:()=>Q,buildStellarRepayTx:()=>D,buildStellarRevokeRoleTx:()=>Ce,buildStellarRevokeTokenTx:()=>Qe,buildStellarSetAccumulatorTx:()=>Ue,buildStellarSetAggregatorTx:()=>Ne,buildStellarSetLiquidityPoolTemplateTx:()=>Ge,buildStellarSetPositionLimitsTx:()=>Me,buildStellarSupplyBatchTx:()=>$,buildStellarSupplyTx:()=>N,buildStellarSwapCollateralTx:()=>j,buildStellarSwapDebtTx:()=>H,buildStellarTransferOwnershipTx:()=>Le,buildStellarUnpauseTx:()=>Be,buildStellarUpdateAccountThresholdTx:()=>st,buildStellarUpdateIndexesTx:()=>Je,buildStellarUpdatePoolCapsTx:()=>Fe,buildStellarUpgradeControllerTx:()=>Ae,buildStellarUpgradeLiquidityPoolParamsTx:()=>rt,buildStellarUpgradeLiquidityPoolTx:()=>ot,buildStellarWithdrawBatchTx:()=>q,buildStellarWithdrawTx:()=>M,buildTx:()=>L,decodeStellarLendingEvent:()=>kr,encodeAssetConfigRaw:()=>Te,encodeInterestRateModel:()=>he,encodeMarketOracleConfigInput:()=>ke,encodeMarketParamsRaw:()=>we,encodeOracleSourceConfigInput:()=>Ee,encodePositionLimits:()=>xe,encodeStrategyPayloadToRouteXdr:()=>qr,extractEventOrder:()=>Br,getStellarAccountPositions:()=>pe,getStellarAggregatorQuote:()=>Nr,getStellarAggregatorRouter:()=>u,getStellarAsset:()=>ne,getStellarAssetGraph:()=>me,getStellarAssetMarkets:()=>le,getStellarAssetPage:()=>se,getStellarAssets:()=>J,getStellarGovernance:()=>c,getStellarGovernanceProposals:()=>_e,getStellarHub:()=>ie,getStellarHubGraph:()=>fe,getStellarHubs:()=>ee,getStellarLendingController:()=>i,getStellarQuoteTokens:()=>Ur,getStellarReserve:()=>oe,getStellarReserveGraph:()=>Se,getStellarReserveHolders:()=>ae,getStellarReserves:()=>re,getStellarSpoke:()=>ue,getStellarSpokeGraph:()=>be,getStellarSpokes:()=>te,getStellarUserActivity:()=>de,getStellarUserPositions:()=>ce,mapQuoteResponseToAggregatorSwap:()=>Wr,mapQuoteResponseToStrategyPayload:()=>Dr,mapQuoteResponseToStrategySwap:()=>zr,mapStellarPositionActivityType:()=>Cr,prepareStellarBuiltTx:()=>jr,prepareStellarTxXdr:()=>Hr,stellarLendingDispatchKey:()=>lr,stellarLendingRead:()=>ge,syntheticEventOrder:()=>Or,tagStellarInvokedContractError:()=>Fr,toBase64Xdr:()=>nr,toStellarPositionMode:()=>Qr});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"},l={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function i(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"],_=e=>new d.Address(e).toScVal(),m=e=>new d.ScInt(e).toI128(),f=e=>d.xdr.ScVal.scvU32(e),b=e=>new d.ScInt("string"==typeof e?e:e.toString()).toU64(),S=e=>d.xdr.ScVal.scvBool(e),g=e=>d.xdr.ScVal.scvString(e),y=e=>d.xdr.ScVal.scvSymbol(e),h=()=>d.xdr.ScVal.scvVoid(),w=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)},x=(e,t)=>null==e?h():t(e),v=e=>d.xdr.ScVal.scvVec(e.map((e=>{return t=e.token,r=e.amount,d.xdr.ScVal.scvVec([_(t),m(r)]);var t,r}))),R=(e,t)=>A({asset:_(t),hub_id:f(e)}),E=(e,t,r)=>d.xdr.ScVal.scvVec([R(e,t),m(r)]),k=e=>d.xdr.ScVal.scvVec(e.map((e=>E(e.hubId,e.asset,e.amount)))),A=e=>{const t=Object.keys(e).sort().map((t=>new d.xdr.ScMapEntry({key:y(t),val:e[t]})));return d.xdr.ScVal.scvMap(t)},P=e=>{const t=e.paths.map((e=>{const t=e.hops.map((e=>{return A({amount_out:m(e.amountOut),pool:_(e.pool),token_in:_(e.tokenIn),token_out:_(e.tokenOut),venue:(t=e.venue,d.xdr.ScVal.scvVec([y(t)]))});var t}));return A({hops:d.xdr.ScVal.scvVec(t),split_ppm:f(e.splitPpm)})}));return A({paths:d.xdr.ScVal.scvVec(t),referral_id:b(e.referralId??0),token_in:_(e.tokenIn),token_out:_(e.tokenOut),total_min_out:m(e.totalMinOut)})},I=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)},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},O=e=>{if("string"==typeof e)return I(B(e));if(e instanceof Uint8Array)return I(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?I(B(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?I(B(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?I(B(e.bytes)):I(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(P(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},C=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 L(e,t,r){const o=e.controllerAddress??i(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:l[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function $(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return L(e,"supply",[_(e.caller),b(r),f(o),k([...t.assets])])}function N(e,t){return $(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function U(e,t){return L(e,"borrow",[_(e.caller),b(t.accountNonce),k([...t.borrows]),x(t.to,_)])}function G(e,t){return U(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function q(e,t){return L(e,"withdraw",[_(e.caller),b(t.accountNonce),k([...t.withdrawals]),x(t.to,_)])}function M(e,t){return q(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function V(e,t){return L(e,"repay",[_(e.caller),b(t.accountNonce),k([...t.payments])])}function D(e,t){return V(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function z(e,t){return L(e,"liquidate",[_(e.caller),b(t.accountNonce),k([...t.debtPayments])])}function W(e,t){return L(e,"flash_loan",[_(e.caller),R(t.hubId,t.asset),m(t.amount),_(t.receiver),C(t.data)])}function X(e,t){return L(e,"migrate_from_blend",[_(e.caller),b(t.accountId),f(t.spokeId),f(t.hubId),_(t.blendPool),w(t.collateralTokens.map(_)),w(t.supplyTokens.map(_)),v(t.debtCaps.map((e=>({token:e.token,amount:e.cap}))))])}function F(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return L(e,"multiply",[_(e.caller),b(r),f(o),R(t.collateral.hubId,t.collateral.asset),m(t.debtToFlashLoan),R(t.debt.hubId,t.debt.asset),f(t.mode),O(t.steps),x(t.initialPayment,(e=>E(e.hubId,e.asset,e.amount))),x(t.convertSwap,O)])}function H(e,t){return L(e,"swap_debt",[_(e.caller),b(t.accountNonce),R(t.existingDebt.hubId,t.existingDebt.asset),m(t.newDebtAmount),R(t.newDebt.hubId,t.newDebt.asset),O(t.steps)])}function j(e,t){return L(e,"swap_collateral",[_(e.caller),b(t.accountNonce),R(t.current.hubId,t.current.asset),m(t.fromAmount),R(t.newCollateral.hubId,t.newCollateral.asset),O(t.steps)])}function Q(e,t){return L(e,"repay_debt_with_collateral",[_(e.caller),b(t.accountNonce),R(t.collateral.hubId,t.collateral.asset),m(t.collateralAmount),R(t.debt.hubId,t.debt.asset),O(t.steps),S(t.closePosition)])}const K="/stellar-lending",Z=25,Y=encodeURIComponent,J=(e,t)=>e.fetchWithTimeout(`${K}/assets`,t),ee=(e,t)=>e.fetchWithTimeout(`${K}/hubs`,t),te=(e,t)=>e.fetchWithTimeout(`${K}/spokes`,t),re=(e,t={},r)=>{const{hubId:o,spokeId:a,asset:n}=t;return e.fetchWithTimeout(`${K}/reserves`,{...r,params:{...void 0!==o?{hubId:o}:{},...void 0!==a?{spokeId:a}:{},...n?{asset:n}:{}}})},oe=(e,t,r,o,a)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}`,a),ae=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}/holders`,{...n,params:{side:a}}),ne=(e,t,r)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}`,r),se=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/page`,{...o,params:{...r}}),le=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/markets`,{...o,params:{side:r}}),ie=(e,t,r)=>e.fetchWithTimeout(`${K}/hubs/${t}`,r),ue=(e,t,r)=>e.fetchWithTimeout(`${K}/spokes/${t}`,r),ce=(e,t,r)=>e.fetchWithTimeout(`${K}/users/${Y(t)}/positions`,r),de=(e,t,r={},o)=>{const{skip:a,top:n}=r;return e.fetchWithTimeout(`${K}/users/${Y(t)}/activity`,{...o,params:{...void 0!==a?{skip:a}:{},...void 0!==n?{top:n}:{}}})},pe=(e,t,r)=>e.fetchWithTimeout(`${K}/accounts/${Y(t)}/positions`,r),_e=(e,t={},r)=>{const{top:o=Z,continuationToken:a}=t;return e.fetchWithTimeout(`${K}/governance/proposals`,{...r,params:{top:o,...a?{continuationToken:a}:{}}})},me=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/graph`,{...o,params:{...r}}),fe=(e,t,r,o)=>e.fetchWithTimeout(`${K}/hubs/${t}/graph`,{...o,params:{...r}}),be=(e,t,r,o)=>e.fetchWithTimeout(`${K}/spokes/${t}/graph`,{...o,params:{...r}}),Se=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}/graph`,{...n,params:{...a}}),ge=e=>({assets:t=>J(e,t),hubs:t=>ee(e,t),spokes:t=>te(e,t),reserves:(t,r)=>re(e,t,r),reserve:(t,r,o,a)=>oe(e,t,r,o,a),reserveHolders:(t,r,o,a,n)=>ae(e,t,r,o,a,n),asset:(t,r)=>ne(e,t,r),assetMarkets:(t,r,o)=>le(e,t,r,o),hub:(t,r)=>ie(e,t,r),spoke:(t,r)=>ue(e,t,r),userPositions:(t,r)=>ce(e,t,r),userActivity:(t,r,o)=>de(e,t,r,o),accountPositions:(t,r)=>pe(e,t,r),governanceProposals:(t,r)=>_e(e,t,r),assetGraph:(t,r,o)=>me(e,t,r,o),hubGraph:(t,r,o)=>fe(e,t,r,o),spokeGraph:(t,r,o)=>be(e,t,r,o),reserveGraph:(t,r,o,a,n)=>Se(e,t,r,o,a,n)}),ye={Single:0,PrimaryWithAnchor:1},he=e=>A({base_borrow_rate_ray:m(e.baseBorrowRateRay),max_borrow_rate_ray:m(e.maxBorrowRateRay),max_utilization_ray:m(e.maxUtilizationRay),mid_utilization_ray:m(e.midUtilizationRay),optimal_utilization_ray:m(e.optimalUtilizationRay),reserve_factor_bps:f(e.reserveFactorBps),slope1_ray:m(e.slope1Ray),slope2_ray:m(e.slope2Ray),slope3_ray:m(e.slope3Ray)}),we=e=>A({asset_decimals:f(e.assetDecimals),asset_id:_(e.assetId),base_borrow_rate_ray:m(e.baseBorrowRateRay),borrow_cap:m(e.borrowCap),max_borrow_rate_ray:m(e.maxBorrowRateRay),max_utilization_ray:m(e.maxUtilizationRay),mid_utilization_ray:m(e.midUtilizationRay),optimal_utilization_ray:m(e.optimalUtilizationRay),reserve_factor_bps:f(e.reserveFactorBps),slope1_ray:m(e.slope1Ray),slope2_ray:m(e.slope2Ray),slope3_ray:m(e.slope3Ray),supply_cap:m(e.supplyCap)}),Te=e=>A({asset_decimals:f(0),e_mode_categories:w(e.eModeCategories.map((e=>f(e)))),flashloan_fee_bps:f(e.flashloanFeeBps),is_borrowable:S(e.isBorrowable),is_collateralizable:S(e.isCollateralizable),is_flashloanable:S(e.isFlashloanable),liquidation_bonus_bps:f(e.liquidationBonusBps),liquidation_fees_bps:f(e.liquidationFeesBps),liquidation_threshold_bps:f(e.liquidationThresholdBps),loan_to_value_bps:f(e.loanToValueBps)}),xe=e=>A({max_borrow_positions:f(e.maxBorrowPositions),max_supply_positions:f(e.maxSupplyPositions)}),ve=e=>{const t=e.kind;switch(t){case"Stellar":return w([y("Stellar"),_(e.value)]);case"Symbol":return w([y("Symbol"),y(e.value)]);case"String":return w([y("String"),g(e.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${t}"`)}},Re=(e,t)=>{if("Twap"===e){if("number"!=typeof t)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return w([y("Twap"),f(t)])}return w([y("Spot")])},Ee=e=>{const t=e.provider;if("ReflectorSep40"===t){if(!e.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return w([y("Reflector"),A({asset:ve(e.asset),contract:_(e.contract),read_mode:Re(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 w([y("RedStone"),A({contract:_(e.contract),feed_id:g(e.feedId),max_stale_seconds:b(e.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${t}"`)},ke=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,w(null==r?[y("None")]:[y("Some"),Ee(r)])),max_price_stale_seconds:b(e.maxPriceStaleSeconds),max_sanity_price_wad:m(e.maxSanityPriceWad),min_sanity_price_wad:m(e.minSanityPriceWad),primary:Ee(e.primary),strategy:f(t),tolerance_bps:f(e.toleranceBps)});var r};function Ae(e,t){return L(e,"upgrade",[T(t.wasmHash)])}function Pe(e,t){return L(e,"migrate",[f(t.newVersion)])}function Ie(e){return L(e,"pause",[])}function Be(e){return L(e,"unpause",[])}function Oe(e,t){return L(e,"grant_role",[_(t.account),y(t.role)])}function Ce(e,t){return L(e,"revoke_role",[_(t.account),y(t.role)])}function Le(e,t){return L(e,"transfer_ownership",[_(t.newOwner),f(t.liveUntilLedger)])}function $e(e){return L(e,"accept_ownership",[])}function Ne(e,t){return L(e,"set_aggregator",[_(t.aggregator)])}function Ue(e,t){return L(e,"set_accumulator",[_(t.accumulator)])}function Ge(e,t){return L(e,"set_liquidity_pool_template",[T(t.wasmHash)])}function qe(e,t){return L(e,"edit_asset_config",[_(t.asset),Te(t.config)])}function Me(e,t){return L(e,"set_position_limits",[xe(t)])}function Ve(e){return L(e,"add_e_mode_category",[])}function De(e,t){return L(e,"remove_e_mode_category",[f(t.id)])}const ze=e=>A({asset:_(e.asset),category_id:f(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:f(e.ltv),threshold:f(e.threshold),bonus:f(e.bonus),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)});function We(e,t){return L(e,"add_asset_to_e_mode_category",[ze(t)])}function Xe(e,t){return L(e,"edit_asset_in_e_mode_category",[ze(t)])}function Fe(e,t){return L(e,"update_pool_caps",[_(t.asset),m(t.supplyCap),m(t.borrowCap)])}function He(e,t){return L(e,"remove_asset_from_e_mode",[_(t.asset),f(t.categoryId)])}function je(e,t){return L(e,"approve_token",[_(t.token)])}function Qe(e,t){return L(e,"revoke_token",[_(t.token)])}function Ke(e,t){return L(e,"configure_market_oracle",[_(e.caller),_(t.asset),ke(t.config)])}function Ze(e,t){return L(e,"edit_oracle_tolerance",[_(e.caller),_(t.asset),f(t.tolerance)])}function Ye(e,t){return L(e,"disable_token_oracle",[_(e.caller),_(t.asset)])}function Je(e,t){return L(e,"update_indexes",[_(e.caller),w(t.assets.map((e=>_(e))))])}function et(e,t){return L(e,"renew_account",[_(e.caller),b(t.accountNonce)])}function tt(e,t){return L(e,"create_liquidity_pool",[_(t.asset),we(t.params),Te(t.config)])}function rt(e,t){return L(e,"upgrade_liquidity_pool_params",[_(t.asset),he(t.params)])}function ot(e,t){return L(e,"upgrade_liquidity_pool",[_(t.asset),T(t.wasmHash)])}function at(e,t){return L(e,"claim_revenue",[_(e.caller),w(t.assets.map((e=>_(e))))])}function nt(e,t){return L(e,"add_rewards",[_(e.caller),w(t.rewards.map((e=>w([_(e.token),m(e.amount)]))))])}function st(e,t){return L(e,"update_account_threshold",[_(e.caller),_(t.asset),S(t.hasRisks),w(t.accountNonces.map((e=>b(e))))])}const lt="00".repeat(32),it=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)},ut=(e,...t)=>w([y(e),...t]),ct=e=>A({asset:_(e.asset),category_id:f(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:f(e.ltv),threshold:f(e.threshold),bonus:f(e.bonus),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)}),dt=e=>A({asset:_(e.asset),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)}),pt=e=>A({asset:_(e.asset),category_id:f(e.categoryId)}),_t=e=>A({asset:_(e.asset),params:we(e.params),config:Te(e.config)}),mt=e=>A({asset:_(e.asset),params:he(e.params)}),ft=e=>A({new_owner:_(e.newOwner),live_until_ledger:f(e.liveUntilLedger)}),bt=e=>A({asset:_(e.asset),cfg:ke(e.config)}),St=e=>A({asset:_(e.asset),tolerance:f(e.tolerance)}),gt=e=>A({account:_(e.account),role:y(e.role)});function yt(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:l[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const ht=(e,t,r)=>yt(e,"propose",[_(e.caller),t,it(r)]),wt=(e,t,r)=>yt(e,"execute_self",[h(),t,it(r)]);function Tt(e,t,r){return ht(e,ut("SetAggregator",_(t.aggregator)),r)}function xt(e,t,r){return ht(e,ut("SetAccumulator",_(t.accumulator)),r)}function vt(e,t,r){return ht(e,ut("SetLiquidityPoolTemplate",T(t.wasmHash)),r)}function Rt(e,t,r){return ht(e,ut("EditAssetConfig",_(t.asset),Te(t.config)),r)}function Et(e,t,r){return ht(e,ut("SetPositionLimits",xe(t)),r)}function kt(e,t,r){return ht(e,ut("SetMinBorrowCollateralUsd",m(t.floorWad)),r)}function At(e,t){return ht(e,ut("AddEModeCategory"),t)}function Pt(e,t,r){return ht(e,ut("RemoveEModeCategory",f(t.id)),r)}function It(e,t,r){return ht(e,ut("AddAssetToEModeCategory",ct(t)),r)}function Bt(e,t,r){return ht(e,ut("EditAssetInEModeCategory",ct(t)),r)}function Ot(e,t,r){return ht(e,ut("UpdatePoolCaps",dt(t)),r)}function Ct(e,t,r){return ht(e,ut("RemoveAssetFromEMode",pt(t)),r)}function Lt(e,t,r){return ht(e,ut("ApproveToken",_(t.token)),r)}function $t(e,t,r){return ht(e,ut("RevokeToken",_(t.token)),r)}function Nt(e,t,r){return ht(e,ut("ApproveBlendPool",_(t.pool)),r)}function Ut(e,t,r){return ht(e,ut("RevokeBlendPool",_(t.pool)),r)}function Gt(e,t,r){return ht(e,ut("CreateLiquidityPool",_t(t)),r)}function qt(e,t,r){return ht(e,ut("UpgradeLiquidityPoolParams",mt(t)),r)}function Mt(e,t){return ht(e,ut("DeployPool"),t)}function Vt(e,t,r){return ht(e,ut("UpgradePool",T(t.wasmHash)),r)}function Dt(e,t,r){return ht(e,ut("DisableTokenOracle",_(t.asset)),r)}function zt(e,t,r){return ht(e,ut("UpgradeController",T(t.wasmHash)),r)}function Wt(e,t,r){return ht(e,ut("MigrateController",f(t.newVersion)),r)}function Xt(e,t,r){return ht(e,ut("TransferCtrlOwnership",ft(t)),r)}function Ft(e,t,r){return ht(e,ut("ConfigureMarketOracle",bt(t)),r)}function Ht(e,t,r){return ht(e,ut("EditOracleTolerance",St(t)),r)}function jt(e,t,r){return ht(e,ut("UpgradeGov",T(t.wasmHash)),r)}function Qt(e,t,r){return ht(e,ut("UpdateGovDelay",f(t.newDelay)),r)}function Kt(e,t,r){return ht(e,ut("GrantGovRole",gt(t)),r)}function Zt(e,t,r){return ht(e,ut("RevokeGovRole",gt(t)),r)}function Yt(e,t,r){return ht(e,ut("TransferGovOwnership",ft(t)),r)}function Jt(e,t){const r=w(t.argsXdr.map((e=>d.xdr.ScVal.fromXDR(e,"base64")))),o=it(t.predecessor??lt);return yt(e,"execute",[h(),_(t.target),y(t.functionName),r,o,it(t.salt)])}function er(e,t,r){return wt(e,ut("UpgradeGov",T(t.wasmHash)),r)}function tr(e,t,r){return wt(e,ut("UpdateGovDelay",f(t.newDelay)),r)}function rr(e,t,r){return wt(e,ut("GrantGovRole",gt(t)),r)}function or(e,t,r){return wt(e,ut("RevokeGovRole",gt(t)),r)}function ar(e,t,r){return wt(e,ut("TransferGovOwnership",ft(t)),r)}const nr=e=>e.toXDR("base64"),sr=e=>d.xdr.ScVal.fromXDR(e,"base64"),lr=e=>e.map((e=>String((0,d.scValToNative)(sr(e))))).join(":"),ir=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),ur=e=>Number(e),cr=e=>String(e),dr=e=>null==e?void 0:ir(e),pr=e=>null==e?void 0:cr(e),_r=e=>e instanceof Uint8Array?Buffer.from(e).toString("hex"):Buffer.isBuffer(e)?e.toString("hex"):String(e),mr=["None","Multiply","Long","Short"],fr=["Single","PrimaryWithAnchor"],br=["ReflectorSep40","RedStonePriceFeed"],Sr=["Spot","Twap"],gr=["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"],yr=e=>Array.isArray(e)?e:[],hr=e=>({loanToValueBps:ur(e.loan_to_value_bps),liquidationThresholdBps:ur(e.liquidation_threshold_bps),liquidationBonusBps:ur(e.liquidation_bonus_bps),liquidationFeesBps:ur(e.liquidation_fees_bps),isCollateralizable:Boolean(e.is_collateralizable),isBorrowable:Boolean(e.is_borrowable),isFlashloanable:Boolean(e.is_flashloanable),flashloanFeeBps:ur(e.flashloan_fee_bps),eModeCategories:(e.e_mode_categories??[]).map(ur)}),wr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],gr[ur(o)]??ir(o)),positionType:t,asset:cr(e[1]),scaledAmountRay:ir(e[2]),indexRay:ir(e[3]),amount:ir(e[4]),liquidationThresholdBps:r?void 0:ur(e[5]),liquidationBonusBps:r?void 0:ur(e[6]),loanToValueBps:r?void 0:ur(e[7])};var o},Tr=e=>{return{owner:cr(e[0]),eModeCategoryId:ur(e[1]),mode:(t=e[2],mr[ur(t)]??"None")};var t},xr=(e,t)=>{const r=Sr[ur(e[`${t}_read_mode`])]??"Spot",o=e[`${t}_asset`],a=e[`${t}_symbol`],n=null!=o?{kind:"Stellar",value:cr(o)}:null!=a?{kind:"Symbol",value:cr(a)}:void 0;return{provider:br[ur(e[`${t}_provider`])]??"ReflectorSep40",contractAddress:cr(e[`${t}_contract`]),asset:n,feedId:pr(e[`${t}_feed_id`]),readMode:r,twapRecords:"Twap"===r?ur(e[`${t}_twap_records`]):void 0,decimals:ur(e[`${t}_decimals`]),resolutionSeconds:ur(e[`${t}_resolution_seconds`]),maxStaleSeconds:ur(e[`${t}_max_stale_seconds`])}},vr=e=>{const t=null!==e.anchor_provider&&void 0!==e.anchor_provider;return{baseTokenId:cr(e.base_token_id),quoteTokenId:cr(e.quote_token_id),tolerance:{upperRatio:ur(e.upper_ratio_bps??e.tolerance?.upper_ratio_bps),lowerRatio:ur(e.lower_ratio_bps??e.tolerance?.lower_ratio_bps)},assetDecimals:ur(e.asset_decimals),maxPriceStaleSeconds:ur(e.max_price_stale_seconds),strategy:fr[ur(e.strategy)]??"Single",primary:xr(e,"primary"),anchor:t?xr(e,"anchor"):void 0,primaryQuoteToken:pr(e.primary_quote_token),anchorQuoteToken:pr(e.anchor_quote_token),minSanityPriceWad:dr(e.min_sanity_price_wad),maxSanityPriceWad:dr(e.max_sanity_price_wad)}},Rr={"market:create":e=>({topic:"market:create",data:{baseAsset:cr(e.base_asset),maxBorrowRate:ir(e.max_borrow_rate),baseBorrowRate:ir(e.base_borrow_rate),slope1:ir(e.slope1),slope2:ir(e.slope2),slope3:ir(e.slope3),midUtilization:ir(e.mid_utilization),optimalUtilization:ir(e.optimal_utilization),maxUtilization:dr(e.max_utilization),reserveFactor:ur(e.reserve_factor),marketAddress:cr(e.market_address),config:hr(e.config)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:cr(e.asset),maxBorrowRateRay:ir(e.max_borrow_rate_ray),baseBorrowRateRay:ir(e.base_borrow_rate_ray),slope1Ray:ir(e.slope1_ray),slope2Ray:ir(e.slope2_ray),slope3Ray:ir(e.slope3_ray),midUtilizationRay:ir(e.mid_utilization_ray),optimalUtilizationRay:ir(e.optimal_utilization_ray),maxUtilizationRay:dr(e.max_utilization_ray),reserveFactorBps:ur(e.reserve_factor_bps)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:yr(e).map((e=>{return t=yr(e),{asset:cr(t[0]),timestamp:ur(t[1]),supplyIndexRay:ir(t[2]),borrowIndexRay:ir(t[3]),reservesRay:ir(t[4]),suppliedRay:ir(t[5]),borrowedRay:ir(t[6]),revenueRay:ir(t[7]),assetPriceWad:dr(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:yr(e).map((e=>{const t=e;return{asset:cr(t.asset),params:(r=t.params,{maxBorrowRateRay:ir(r.max_borrow_rate_ray),baseBorrowRateRay:ir(r.base_borrow_rate_ray),slope1Ray:ir(r.slope1_ray),slope2Ray:ir(r.slope2_ray),slope3Ray:ir(r.slope3_ray),midUtilizationRay:ir(r.mid_utilization_ray),optimalUtilizationRay:ir(r.optimal_utilization_ray),maxUtilizationRay:dr(r.max_utilization_ray),reserveFactorBps:ur(r.reserve_factor_bps),supplyCap:ir(r.supply_cap),borrowCap:ir(r.borrow_cap),assetId:pr(r.asset_id),assetDecimals:void 0===r.asset_decimals?void 0:ur(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=yr(e);return{topic:"position:batch_update",data:{accountId:ir(t[0]),accountAttributes:Tr(yr(t[1])),updates:[...yr(t[2]).map((e=>wr(yr(e),"Deposit"))),...yr(t[3]).map((e=>wr(yr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{asset:cr(e.asset),receiver:cr(e.receiver),caller:cr(e.caller),amount:ir(e.amount),fee:ir(e.fee)}}),"config:asset":e=>({topic:"config:asset",data:{asset:cr(e.asset),config:hr(e.config)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:cr(e.asset),oracle:vr(e.oracle)}}),"config:emode_category":e=>({topic:"config:emode_category",data:{category:{categoryId:ur(e.category.category_id),isDeprecated:Boolean(e.category.is_deprecated)}}}),"config:emode_asset":e=>({topic:"config:emode_asset",data:{asset:cr(e.asset),config:{isCollateralizable:Boolean(e.config.is_collateralizable),isBorrowable:Boolean(e.config.is_borrowable),loanToValueBps:ur(e.config.loan_to_value_bps),liquidationThresholdBps:ur(e.config.liquidation_threshold_bps),liquidationBonusBps:ur(e.config.liquidation_bonus_bps),supplyCap:ir(e.config.supply_cap),borrowCap:ir(e.config.borrow_cap)},categoryId:ur(e.category_id)}}),"config:remove_emode_asset":e=>({topic:"config:remove_emode_asset",data:{asset:cr(e.asset),categoryId:ur(e.category_id)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:ir(e.account_id),totalBorrowUsdWad:ir(e.total_borrow_usd_wad),totalCollateralUsdWad:ir(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:cr(e.token),amount:ir(e.amount),usdValueWad:ir(e.usd_value_wad),accountId:ir(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{asset:cr(e.asset),amount:ir(e.amount),fee:ir(e.fee),amountSent:ir(e.amount_sent)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:_r(e.wasm_hash),approved:Boolean(e.approved)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:cr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:cr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:_r(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:ur(e.max_supply_positions),maxBorrowPositions:ur(e.max_borrow_positions)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:cr(e.asset)}})},Er=Object.freeze(Object.keys(Rr));function kr(e,t){const r=lr(e),o=Rr[r];return o?o((0,d.scValToNative)(sr(t))):null}const Ar="XLENDXLM-a7c9f3",Pr=1e4;function Ir(e){const t=BigInt(e).toString(16),r=t.length%2==0?t:`0${t}`;return`${Ar}-${r}`}function Br(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function Or(e,t=0){return e*Pr+t}function Cr(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Lr=(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()},$r=e=>e.baseUrl??s[e.network];async function Nr(e,t){if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=Lr($r(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 Ur(e){const t=Lr($r(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 Gr=(e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e,qr=e=>P(e).toXDR("base64");function Mr(e,t){const r=e.routerAddress??u(e.network),o=new d.Contract(r),a=new d.Account(e.caller,e.sourceSequence),n=O(Gr(t,e.referralId));return{xdr:new d.TransactionBuilder(a,{fee:e.fee??d.BASE_FEE,networkPassphrase:l[e.network]}).addOperation(o.call("execute_strategy",_(e.caller),m(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Vr(e,t){return Mr(e,t)}function Dr(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(Xr),splitPpm:e.splitPpm}))):[{hops:e.hops.map(Xr),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function zr(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:Dr(e,t)}const Wr=Dr,Xr=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function Fr(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function Hr(e,t,r){const o=d.TransactionBuilder.fromXDR(t,"base64");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw Fr(r.invokedContractId,e);throw e}}async function jr(e,t,r){return Hr(e,t.xdr,r)}function Qr(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 Kr(e,t){return{paths:[{hops:[{amountOut:"0",pool:e,tokenIn:e,tokenOut:e,venue:"Soroswap"}],splitPpm:1e6}],referralId:0,tokenIn:e,tokenOut:e,totalMinOut:t}}const Zr=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 Yr(e){const t=new d.Account(e.caller,e.sourceSequence),r=new d.Contract(e.forwarderAddress).call("mint_and_forward",d.xdr.ScVal.scvBytes(Zr(e.message)),d.xdr.ScVal.scvBytes(Zr(e.attestation)));return{xdr:new d.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:l[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}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:()=>it,STELLAR_LENDING_CONTROLLER:()=>r,STELLAR_LENDING_TOPICS:()=>kr,STELLAR_NETWORK_PASSPHRASE:()=>l,STELLAR_QUOTE_URL:()=>s,STELLAR_SOROBAN_RPC_URL:()=>n,SYNTHETIC_EVENT_ORDER_STRIDE:()=>Ir,XOXNO_LENDING_STELLAR_TICKER:()=>Pr,buildSameTokenRepaySwapSteps:()=>Zr,buildStellarAcceptOwnershipTx:()=>Ne,buildStellarAddAssetToEModeCategoryTx:()=>Xe,buildStellarAddEModeCategoryTx:()=>De,buildStellarAddRewardsTx:()=>st,buildStellarApproveTokenTx:()=>Qe,buildStellarBatchSwapTx:()=>Dr,buildStellarBorrowBatchTx:()=>U,buildStellarBorrowTx:()=>G,buildStellarCctpForwardTx:()=>Jr,buildStellarClaimRevenueTx:()=>nt,buildStellarConfigureMarketOracleTx:()=>Ze,buildStellarCreateLiquidityPoolTx:()=>rt,buildStellarDisableTokenOracleTx:()=>Je,buildStellarEditAssetConfigTx:()=>Me,buildStellarEditAssetInEModeCategoryTx:()=>Fe,buildStellarEditOracleToleranceTx:()=>Ye,buildStellarExecuteStrategyTx:()=>Vr,buildStellarFlashLoanTx:()=>W,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>tr,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>or,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>ar,buildStellarGovernanceExecuteTransferGovOwnTx:()=>nr,buildStellarGovernanceExecuteTx:()=>er,buildStellarGovernanceExecuteUpdateDelayTx:()=>rr,buildStellarGrantRoleTx:()=>Ce,buildStellarLendingIdentifier:()=>Br,buildStellarLiquidateTx:()=>z,buildStellarMigrateFromBlendTx:()=>X,buildStellarMigrateTx:()=>Ie,buildStellarMultiplyTx:()=>F,buildStellarPauseTx:()=>Be,buildStellarProposeAddAssetToEModeTx:()=>Bt,buildStellarProposeAddEModeCategoryTx:()=>Pt,buildStellarProposeApproveBlendPoolTx:()=>Ut,buildStellarProposeApproveTokenTx:()=>$t,buildStellarProposeConfigureMarketOracleTx:()=>Ht,buildStellarProposeCreateLiquidityPoolTx:()=>qt,buildStellarProposeDeployPoolTx:()=>Vt,buildStellarProposeDisableTokenOracleTx:()=>zt,buildStellarProposeEditAssetConfigTx:()=>Et,buildStellarProposeEditAssetInEModeTx:()=>Ot,buildStellarProposeEditOracleToleranceTx:()=>jt,buildStellarProposeGovernanceUpgradeTx:()=>Qt,buildStellarProposeGrantGovernanceRoleTx:()=>Zt,buildStellarProposeMigrateControllerTx:()=>Xt,buildStellarProposeRemoveAssetFromEModeTx:()=>Lt,buildStellarProposeRemoveEModeCategoryTx:()=>It,buildStellarProposeRevokeBlendPoolTx:()=>Gt,buildStellarProposeRevokeGovernanceRoleTx:()=>Yt,buildStellarProposeRevokeTokenTx:()=>Nt,buildStellarProposeSetAccumulatorTx:()=>vt,buildStellarProposeSetAggregatorTx:()=>xt,buildStellarProposeSetMinBorrowCollatTx:()=>At,buildStellarProposeSetPoolTemplateTx:()=>Rt,buildStellarProposeSetPositionLimitsTx:()=>kt,buildStellarProposeTransferCtrlOwnershipTx:()=>Ft,buildStellarProposeTransferGovOwnTx:()=>Jt,buildStellarProposeUpdateDelayTx:()=>Kt,buildStellarProposeUpdatePoolCapsTx:()=>Ct,buildStellarProposeUpgradeControllerTx:()=>Wt,buildStellarProposeUpgradePoolParamsTx:()=>Mt,buildStellarProposeUpgradePoolTx:()=>Dt,buildStellarRemoveAssetFromEModeTx:()=>je,buildStellarRemoveEModeCategoryTx:()=>ze,buildStellarRenewAccountTx:()=>tt,buildStellarRepayBatchTx:()=>V,buildStellarRepayDebtWithCollateralTx:()=>Q,buildStellarRepayTx:()=>D,buildStellarRevokeRoleTx:()=>Le,buildStellarRevokeTokenTx:()=>Ke,buildStellarSetAccumulatorTx:()=>Ge,buildStellarSetAggregatorTx:()=>Ue,buildStellarSetLiquidityPoolTemplateTx:()=>qe,buildStellarSetPositionLimitsTx:()=>Ve,buildStellarSupplyBatchTx:()=>$,buildStellarSupplyTx:()=>N,buildStellarSwapCollateralTx:()=>j,buildStellarSwapDebtTx:()=>H,buildStellarTransferOwnershipTx:()=>$e,buildStellarUnpauseTx:()=>Oe,buildStellarUpdateAccountThresholdTx:()=>lt,buildStellarUpdateIndexesTx:()=>et,buildStellarUpdatePoolCapsTx:()=>He,buildStellarUpgradeControllerTx:()=>Pe,buildStellarUpgradeLiquidityPoolParamsTx:()=>ot,buildStellarUpgradeLiquidityPoolTx:()=>at,buildStellarWithdrawBatchTx:()=>q,buildStellarWithdrawTx:()=>M,buildTx:()=>L,decodeStellarLendingEvent:()=>Ar,encodeAssetConfigRaw:()=>xe,encodeInterestRateModel:()=>we,encodeMarketOracleConfigInput:()=>Ae,encodeMarketParamsRaw:()=>Te,encodeOracleSourceConfigInput:()=>ke,encodePositionLimits:()=>ve,encodeStrategyPayloadToRouteXdr:()=>Mr,extractEventOrder:()=>Or,getStellarAccountPositions:()=>_e,getStellarAggregatorQuote:()=>Ur,getStellarAggregatorRouter:()=>u,getStellarAsset:()=>se,getStellarAssetGraph:()=>fe,getStellarAssetMarkets:()=>ie,getStellarAssetPage:()=>le,getStellarAssets:()=>ee,getStellarGovernance:()=>c,getStellarGovernanceProposals:()=>me,getStellarHub:()=>ue,getStellarHubGraph:()=>be,getStellarHubs:()=>te,getStellarLendingContext:()=>J,getStellarLendingController:()=>i,getStellarQuoteTokens:()=>Gr,getStellarReserve:()=>ae,getStellarReserveGraph:()=>ge,getStellarReserveHolders:()=>ne,getStellarReserves:()=>oe,getStellarSpoke:()=>ce,getStellarSpokeGraph:()=>Se,getStellarSpokes:()=>re,getStellarUserActivity:()=>pe,getStellarUserPositions:()=>de,mapQuoteResponseToAggregatorSwap:()=>Xr,mapQuoteResponseToStrategyPayload:()=>zr,mapQuoteResponseToStrategySwap:()=>Wr,mapStellarPositionActivityType:()=>Lr,prepareStellarBuiltTx:()=>Qr,prepareStellarTxXdr:()=>jr,stellarLendingDispatchKey:()=>ir,stellarLendingRead:()=>ye,syntheticEventOrder:()=>Cr,tagStellarInvokedContractError:()=>Hr,toBase64Xdr:()=>sr,toStellarPositionMode:()=>Kr});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"},l={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function i(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"],_=e=>new d.Address(e).toScVal(),m=e=>new d.ScInt(e).toI128(),f=e=>d.xdr.ScVal.scvU32(e),b=e=>new d.ScInt("string"==typeof e?e:e.toString()).toU64(),S=e=>d.xdr.ScVal.scvBool(e),g=e=>d.xdr.ScVal.scvString(e),y=e=>d.xdr.ScVal.scvSymbol(e),h=()=>d.xdr.ScVal.scvVoid(),w=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)},x=(e,t)=>null==e?h():t(e),v=e=>d.xdr.ScVal.scvVec(e.map((e=>{return t=e.token,r=e.amount,d.xdr.ScVal.scvVec([_(t),m(r)]);var t,r}))),R=(e,t)=>A({asset:_(t),hub_id:f(e)}),E=(e,t,r)=>d.xdr.ScVal.scvVec([R(e,t),m(r)]),k=e=>d.xdr.ScVal.scvVec(e.map((e=>E(e.hubId,e.asset,e.amount)))),A=e=>{const t=Object.keys(e).sort().map((t=>new d.xdr.ScMapEntry({key:y(t),val:e[t]})));return d.xdr.ScVal.scvMap(t)},P=e=>{const t=e.paths.map((e=>{const t=e.hops.map((e=>{return A({amount_out:m(e.amountOut),pool:_(e.pool),token_in:_(e.tokenIn),token_out:_(e.tokenOut),venue:(t=e.venue,d.xdr.ScVal.scvVec([y(t)]))});var t}));return A({hops:d.xdr.ScVal.scvVec(t),split_ppm:f(e.splitPpm)})}));return A({paths:d.xdr.ScVal.scvVec(t),referral_id:b(e.referralId??0),token_in:_(e.tokenIn),token_out:_(e.tokenOut),total_min_out:m(e.totalMinOut)})},I=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)},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},O=e=>{if("string"==typeof e)return I(B(e));if(e instanceof Uint8Array)return I(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?I(B(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?I(B(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?I(B(e.bytes)):I(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(P(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},C=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 L(e,t,r){const o=e.controllerAddress??i(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:l[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function $(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return L(e,"supply",[_(e.caller),b(r),f(o),k([...t.assets])])}function N(e,t){return $(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function U(e,t){return L(e,"borrow",[_(e.caller),b(t.accountNonce),k([...t.borrows]),x(t.to,_)])}function G(e,t){return U(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function q(e,t){return L(e,"withdraw",[_(e.caller),b(t.accountNonce),k([...t.withdrawals]),x(t.to,_)])}function M(e,t){return q(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function V(e,t){return L(e,"repay",[_(e.caller),b(t.accountNonce),k([...t.payments])])}function D(e,t){return V(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function z(e,t){return L(e,"liquidate",[_(e.caller),b(t.accountNonce),k([...t.debtPayments])])}function W(e,t){return L(e,"flash_loan",[_(e.caller),R(t.hubId,t.asset),m(t.amount),_(t.receiver),C(t.data)])}function X(e,t){return L(e,"migrate_from_blend",[_(e.caller),b(t.accountId),f(t.spokeId),f(t.hubId),_(t.blendPool),w(t.collateralTokens.map(_)),w(t.supplyTokens.map(_)),v(t.debtCaps.map((e=>({token:e.token,amount:e.cap}))))])}function F(e,t){const r=t.accountNonce??0,o=t.spokeId??0;return L(e,"multiply",[_(e.caller),b(r),f(o),R(t.collateral.hubId,t.collateral.asset),m(t.debtToFlashLoan),R(t.debt.hubId,t.debt.asset),f(t.mode),O(t.steps),x(t.initialPayment,(e=>E(e.hubId,e.asset,e.amount))),x(t.convertSwap,O)])}function H(e,t){return L(e,"swap_debt",[_(e.caller),b(t.accountNonce),R(t.existingDebt.hubId,t.existingDebt.asset),m(t.newDebtAmount),R(t.newDebt.hubId,t.newDebt.asset),O(t.steps)])}function j(e,t){return L(e,"swap_collateral",[_(e.caller),b(t.accountNonce),R(t.current.hubId,t.current.asset),m(t.fromAmount),R(t.newCollateral.hubId,t.newCollateral.asset),O(t.steps)])}function Q(e,t){return L(e,"repay_debt_with_collateral",[_(e.caller),b(t.accountNonce),R(t.collateral.hubId,t.collateral.asset),m(t.collateralAmount),R(t.debt.hubId,t.debt.asset),O(t.steps),S(t.closePosition)])}const K="/stellar-lending",Z=25,Y=encodeURIComponent,J=(e,t)=>e.fetchWithTimeout(`${K}/context`,t),ee=(e,t)=>e.fetchWithTimeout(`${K}/assets`,t),te=(e,t)=>e.fetchWithTimeout(`${K}/hubs`,t),re=(e,t)=>e.fetchWithTimeout(`${K}/spokes`,t),oe=(e,t={},r)=>{const{hubId:o,spokeId:a,asset:n}=t;return e.fetchWithTimeout(`${K}/reserves`,{...r,params:{...void 0!==o?{hubId:o}:{},...void 0!==a?{spokeId:a}:{},...n?{asset:n}:{}}})},ae=(e,t,r,o,a)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}`,a),ne=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}/holders`,{...n,params:{side:a}}),se=(e,t,r)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}`,r),le=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/page`,{...o,params:{...r}}),ie=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/markets`,{...o,params:{side:r}}),ue=(e,t,r)=>e.fetchWithTimeout(`${K}/hubs/${t}`,r),ce=(e,t,r)=>e.fetchWithTimeout(`${K}/spokes/${t}`,r),de=(e,t,r)=>e.fetchWithTimeout(`${K}/users/${Y(t)}/positions`,r),pe=(e,t,r={},o)=>{const{skip:a,top:n}=r;return e.fetchWithTimeout(`${K}/users/${Y(t)}/activity`,{...o,params:{...void 0!==a?{skip:a}:{},...void 0!==n?{top:n}:{}}})},_e=(e,t,r)=>e.fetchWithTimeout(`${K}/accounts/${Y(t)}/positions`,r),me=(e,t={},r)=>{const{top:o=Z,continuationToken:a}=t;return e.fetchWithTimeout(`${K}/governance/proposals`,{...r,params:{top:o,...a?{continuationToken:a}:{}}})},fe=(e,t,r,o)=>e.fetchWithTimeout(`${K}/assets/${Y(t)}/graph`,{...o,params:{...r}}),be=(e,t,r,o)=>e.fetchWithTimeout(`${K}/hubs/${t}/graph`,{...o,params:{...r}}),Se=(e,t,r,o)=>e.fetchWithTimeout(`${K}/spokes/${t}/graph`,{...o,params:{...r}}),ge=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}/graph`,{...n,params:{...a}}),ye=e=>({context:t=>J(e,t),assets:t=>ee(e,t),hubs:t=>te(e,t),spokes:t=>re(e,t),reserves:(t,r)=>{return void 0===(o=t)||"hubId"in o||"spokeId"in o||"asset"in o?oe(e,t,r):oe(e,{},t);var o},reserve:(t,r,o,a)=>ae(e,t,r,o,a),reserveHolders:(t,r,o,a,n)=>ne(e,t,r,o,a,n),asset:(t,r)=>se(e,t,r),assetMarkets:(t,r,o)=>ie(e,t,r,o),hub:(t,r)=>ue(e,t,r),spoke:(t,r)=>ce(e,t,r),userPositions:(t,r)=>de(e,t,r),userActivity:(t,r,o)=>pe(e,t,r,o),accountPositions:(t,r)=>_e(e,t,r),governanceProposals:(t,r)=>me(e,t,r),assetGraph:(t,r,o)=>fe(e,t,r,o),hubGraph:(t,r,o)=>be(e,t,r,o),spokeGraph:(t,r,o)=>Se(e,t,r,o),reserveGraph:(t,r,o,a,n)=>ge(e,t,r,o,a,n)}),he={Single:0,PrimaryWithAnchor:1},we=e=>A({base_borrow_rate_ray:m(e.baseBorrowRateRay),max_borrow_rate_ray:m(e.maxBorrowRateRay),max_utilization_ray:m(e.maxUtilizationRay),mid_utilization_ray:m(e.midUtilizationRay),optimal_utilization_ray:m(e.optimalUtilizationRay),reserve_factor_bps:f(e.reserveFactorBps),slope1_ray:m(e.slope1Ray),slope2_ray:m(e.slope2Ray),slope3_ray:m(e.slope3Ray)}),Te=e=>A({asset_decimals:f(e.assetDecimals),asset_id:_(e.assetId),base_borrow_rate_ray:m(e.baseBorrowRateRay),borrow_cap:m(e.borrowCap),max_borrow_rate_ray:m(e.maxBorrowRateRay),max_utilization_ray:m(e.maxUtilizationRay),mid_utilization_ray:m(e.midUtilizationRay),optimal_utilization_ray:m(e.optimalUtilizationRay),reserve_factor_bps:f(e.reserveFactorBps),slope1_ray:m(e.slope1Ray),slope2_ray:m(e.slope2Ray),slope3_ray:m(e.slope3Ray),supply_cap:m(e.supplyCap)}),xe=e=>A({asset_decimals:f(0),e_mode_categories:w(e.eModeCategories.map((e=>f(e)))),flashloan_fee_bps:f(e.flashloanFeeBps),is_borrowable:S(e.isBorrowable),is_collateralizable:S(e.isCollateralizable),is_flashloanable:S(e.isFlashloanable),liquidation_bonus_bps:f(e.liquidationBonusBps),liquidation_fees_bps:f(e.liquidationFeesBps),liquidation_threshold_bps:f(e.liquidationThresholdBps),loan_to_value_bps:f(e.loanToValueBps)}),ve=e=>A({max_borrow_positions:f(e.maxBorrowPositions),max_supply_positions:f(e.maxSupplyPositions)}),Re=e=>{const t=e.kind;switch(t){case"Stellar":return w([y("Stellar"),_(e.value)]);case"Symbol":return w([y("Symbol"),y(e.value)]);case"String":return w([y("String"),g(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 w([y("Twap"),f(t)])}return w([y("Spot")])},ke=e=>{const t=e.provider;if("ReflectorSep40"===t){if(!e.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return w([y("Reflector"),A({asset:Re(e.asset),contract:_(e.contract),read_mode:Ee(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 w([y("RedStone"),A({contract:_(e.contract),feed_id:g(e.feedId),max_stale_seconds:b(e.maxStaleSeconds)})])}throw new Error(`Stellar builder: unknown oracle provider "${t}"`)},Ae=e=>{const t=he[e.strategy];if(void 0===t)throw new Error(`Stellar builder: unknown oracle strategy "${e.strategy}"`);return A({anchor:(r=e.anchor,w(null==r?[y("None")]:[y("Some"),ke(r)])),max_price_stale_seconds:b(e.maxPriceStaleSeconds),max_sanity_price_wad:m(e.maxSanityPriceWad),min_sanity_price_wad:m(e.minSanityPriceWad),primary:ke(e.primary),strategy:f(t),tolerance_bps:f(e.toleranceBps)});var r};function Pe(e,t){return L(e,"upgrade",[T(t.wasmHash)])}function Ie(e,t){return L(e,"migrate",[f(t.newVersion)])}function Be(e){return L(e,"pause",[])}function Oe(e){return L(e,"unpause",[])}function Ce(e,t){return L(e,"grant_role",[_(t.account),y(t.role)])}function Le(e,t){return L(e,"revoke_role",[_(t.account),y(t.role)])}function $e(e,t){return L(e,"transfer_ownership",[_(t.newOwner),f(t.liveUntilLedger)])}function Ne(e){return L(e,"accept_ownership",[])}function Ue(e,t){return L(e,"set_aggregator",[_(t.aggregator)])}function Ge(e,t){return L(e,"set_accumulator",[_(t.accumulator)])}function qe(e,t){return L(e,"set_liquidity_pool_template",[T(t.wasmHash)])}function Me(e,t){return L(e,"edit_asset_config",[_(t.asset),xe(t.config)])}function Ve(e,t){return L(e,"set_position_limits",[ve(t)])}function De(e){return L(e,"add_e_mode_category",[])}function ze(e,t){return L(e,"remove_e_mode_category",[f(t.id)])}const We=e=>A({asset:_(e.asset),category_id:f(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:f(e.ltv),threshold:f(e.threshold),bonus:f(e.bonus),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)});function Xe(e,t){return L(e,"add_asset_to_e_mode_category",[We(t)])}function Fe(e,t){return L(e,"edit_asset_in_e_mode_category",[We(t)])}function He(e,t){return L(e,"update_pool_caps",[_(t.asset),m(t.supplyCap),m(t.borrowCap)])}function je(e,t){return L(e,"remove_asset_from_e_mode",[_(t.asset),f(t.categoryId)])}function Qe(e,t){return L(e,"approve_token",[_(t.token)])}function Ke(e,t){return L(e,"revoke_token",[_(t.token)])}function Ze(e,t){return L(e,"configure_market_oracle",[_(e.caller),_(t.asset),Ae(t.config)])}function Ye(e,t){return L(e,"edit_oracle_tolerance",[_(e.caller),_(t.asset),f(t.tolerance)])}function Je(e,t){return L(e,"disable_token_oracle",[_(e.caller),_(t.asset)])}function et(e,t){return L(e,"update_indexes",[_(e.caller),w(t.assets.map((e=>_(e))))])}function tt(e,t){return L(e,"renew_account",[_(e.caller),b(t.accountNonce)])}function rt(e,t){return L(e,"create_liquidity_pool",[_(t.asset),Te(t.params),xe(t.config)])}function ot(e,t){return L(e,"upgrade_liquidity_pool_params",[_(t.asset),we(t.params)])}function at(e,t){return L(e,"upgrade_liquidity_pool",[_(t.asset),T(t.wasmHash)])}function nt(e,t){return L(e,"claim_revenue",[_(e.caller),w(t.assets.map((e=>_(e))))])}function st(e,t){return L(e,"add_rewards",[_(e.caller),w(t.rewards.map((e=>w([_(e.token),m(e.amount)]))))])}function lt(e,t){return L(e,"update_account_threshold",[_(e.caller),_(t.asset),S(t.hasRisks),w(t.accountNonces.map((e=>b(e))))])}const it="00".repeat(32),ut=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)},ct=(e,...t)=>w([y(e),...t]),dt=e=>A({asset:_(e.asset),category_id:f(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:f(e.ltv),threshold:f(e.threshold),bonus:f(e.bonus),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)}),pt=e=>A({asset:_(e.asset),supply_cap:m(e.supplyCap),borrow_cap:m(e.borrowCap)}),_t=e=>A({asset:_(e.asset),category_id:f(e.categoryId)}),mt=e=>A({asset:_(e.asset),params:Te(e.params),config:xe(e.config)}),ft=e=>A({asset:_(e.asset),params:we(e.params)}),bt=e=>A({new_owner:_(e.newOwner),live_until_ledger:f(e.liveUntilLedger)}),St=e=>A({asset:_(e.asset),cfg:Ae(e.config)}),gt=e=>A({asset:_(e.asset),tolerance:f(e.tolerance)}),yt=e=>A({account:_(e.account),role:y(e.role)});function ht(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:l[e.network]}).addOperation(a.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const wt=(e,t,r)=>ht(e,"propose",[_(e.caller),t,ut(r)]),Tt=(e,t,r)=>ht(e,"execute_self",[h(),t,ut(r)]);function xt(e,t,r){return wt(e,ct("SetAggregator",_(t.aggregator)),r)}function vt(e,t,r){return wt(e,ct("SetAccumulator",_(t.accumulator)),r)}function Rt(e,t,r){return wt(e,ct("SetLiquidityPoolTemplate",T(t.wasmHash)),r)}function Et(e,t,r){return wt(e,ct("EditAssetConfig",_(t.asset),xe(t.config)),r)}function kt(e,t,r){return wt(e,ct("SetPositionLimits",ve(t)),r)}function At(e,t,r){return wt(e,ct("SetMinBorrowCollateralUsd",m(t.floorWad)),r)}function Pt(e,t){return wt(e,ct("AddEModeCategory"),t)}function It(e,t,r){return wt(e,ct("RemoveEModeCategory",f(t.id)),r)}function Bt(e,t,r){return wt(e,ct("AddAssetToEModeCategory",dt(t)),r)}function Ot(e,t,r){return wt(e,ct("EditAssetInEModeCategory",dt(t)),r)}function Ct(e,t,r){return wt(e,ct("UpdatePoolCaps",pt(t)),r)}function Lt(e,t,r){return wt(e,ct("RemoveAssetFromEMode",_t(t)),r)}function $t(e,t,r){return wt(e,ct("ApproveToken",_(t.token)),r)}function Nt(e,t,r){return wt(e,ct("RevokeToken",_(t.token)),r)}function Ut(e,t,r){return wt(e,ct("ApproveBlendPool",_(t.pool)),r)}function Gt(e,t,r){return wt(e,ct("RevokeBlendPool",_(t.pool)),r)}function qt(e,t,r){return wt(e,ct("CreateLiquidityPool",mt(t)),r)}function Mt(e,t,r){return wt(e,ct("UpgradeLiquidityPoolParams",ft(t)),r)}function Vt(e,t){return wt(e,ct("DeployPool"),t)}function Dt(e,t,r){return wt(e,ct("UpgradePool",T(t.wasmHash)),r)}function zt(e,t,r){return wt(e,ct("DisableTokenOracle",_(t.asset)),r)}function Wt(e,t,r){return wt(e,ct("UpgradeController",T(t.wasmHash)),r)}function Xt(e,t,r){return wt(e,ct("MigrateController",f(t.newVersion)),r)}function Ft(e,t,r){return wt(e,ct("TransferCtrlOwnership",bt(t)),r)}function Ht(e,t,r){return wt(e,ct("ConfigureMarketOracle",St(t)),r)}function jt(e,t,r){return wt(e,ct("EditOracleTolerance",gt(t)),r)}function Qt(e,t,r){return wt(e,ct("UpgradeGov",T(t.wasmHash)),r)}function Kt(e,t,r){return wt(e,ct("UpdateGovDelay",f(t.newDelay)),r)}function Zt(e,t,r){return wt(e,ct("GrantGovRole",yt(t)),r)}function Yt(e,t,r){return wt(e,ct("RevokeGovRole",yt(t)),r)}function Jt(e,t,r){return wt(e,ct("TransferGovOwnership",bt(t)),r)}function er(e,t){const r=w(t.argsXdr.map((e=>d.xdr.ScVal.fromXDR(e,"base64")))),o=ut(t.predecessor??it);return ht(e,"execute",[h(),_(t.target),y(t.functionName),r,o,ut(t.salt)])}function tr(e,t,r){return Tt(e,ct("UpgradeGov",T(t.wasmHash)),r)}function rr(e,t,r){return Tt(e,ct("UpdateGovDelay",f(t.newDelay)),r)}function or(e,t,r){return Tt(e,ct("GrantGovRole",yt(t)),r)}function ar(e,t,r){return Tt(e,ct("RevokeGovRole",yt(t)),r)}function nr(e,t,r){return Tt(e,ct("TransferGovOwnership",bt(t)),r)}const sr=e=>e.toXDR("base64"),lr=e=>d.xdr.ScVal.fromXDR(e,"base64"),ir=e=>e.map((e=>String((0,d.scValToNative)(lr(e))))).join(":"),ur=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),cr=e=>Number(e),dr=e=>String(e),pr=e=>null==e?void 0:ur(e),_r=e=>null==e?void 0:dr(e),mr=e=>e instanceof Uint8Array?Buffer.from(e).toString("hex"):Buffer.isBuffer(e)?e.toString("hex"):String(e),fr=["None","Multiply","Long","Short"],br=["Single","PrimaryWithAnchor"],Sr=["ReflectorSep40","RedStonePriceFeed"],gr=["Spot","Twap"],yr=["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"],hr=e=>Array.isArray(e)?e:[],wr=e=>({loanToValueBps:cr(e.loan_to_value_bps),liquidationThresholdBps:cr(e.liquidation_threshold_bps),liquidationBonusBps:cr(e.liquidation_bonus_bps),liquidationFeesBps:cr(e.liquidation_fees_bps),isCollateralizable:Boolean(e.is_collateralizable),isBorrowable:Boolean(e.is_borrowable),isFlashloanable:Boolean(e.is_flashloanable),flashloanFeeBps:cr(e.flashloan_fee_bps),eModeCategories:(e.e_mode_categories??[]).map(cr)}),Tr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],yr[cr(o)]??ur(o)),positionType:t,asset:dr(e[1]),scaledAmountRay:ur(e[2]),indexRay:ur(e[3]),amount:ur(e[4]),liquidationThresholdBps:r?void 0:cr(e[5]),liquidationBonusBps:r?void 0:cr(e[6]),loanToValueBps:r?void 0:cr(e[7])};var o},xr=e=>{return{owner:dr(e[0]),eModeCategoryId:cr(e[1]),mode:(t=e[2],fr[cr(t)]??"None")};var t},vr=(e,t)=>{const r=gr[cr(e[`${t}_read_mode`])]??"Spot",o=e[`${t}_asset`],a=e[`${t}_symbol`],n=null!=o?{kind:"Stellar",value:dr(o)}:null!=a?{kind:"Symbol",value:dr(a)}:void 0;return{provider:Sr[cr(e[`${t}_provider`])]??"ReflectorSep40",contractAddress:dr(e[`${t}_contract`]),asset:n,feedId:_r(e[`${t}_feed_id`]),readMode:r,twapRecords:"Twap"===r?cr(e[`${t}_twap_records`]):void 0,decimals:cr(e[`${t}_decimals`]),resolutionSeconds:cr(e[`${t}_resolution_seconds`]),maxStaleSeconds:cr(e[`${t}_max_stale_seconds`])}},Rr=e=>{const t=null!==e.anchor_provider&&void 0!==e.anchor_provider;return{baseTokenId:dr(e.base_token_id),quoteTokenId:dr(e.quote_token_id),tolerance:{upperRatio:cr(e.upper_ratio_bps??e.tolerance?.upper_ratio_bps),lowerRatio:cr(e.lower_ratio_bps??e.tolerance?.lower_ratio_bps)},assetDecimals:cr(e.asset_decimals),maxPriceStaleSeconds:cr(e.max_price_stale_seconds),strategy:br[cr(e.strategy)]??"Single",primary:vr(e,"primary"),anchor:t?vr(e,"anchor"):void 0,primaryQuoteToken:_r(e.primary_quote_token),anchorQuoteToken:_r(e.anchor_quote_token),minSanityPriceWad:pr(e.min_sanity_price_wad),maxSanityPriceWad:pr(e.max_sanity_price_wad)}},Er={"market:create":e=>({topic:"market:create",data:{baseAsset:dr(e.base_asset),maxBorrowRate:ur(e.max_borrow_rate),baseBorrowRate:ur(e.base_borrow_rate),slope1:ur(e.slope1),slope2:ur(e.slope2),slope3:ur(e.slope3),midUtilization:ur(e.mid_utilization),optimalUtilization:ur(e.optimal_utilization),maxUtilization:pr(e.max_utilization),reserveFactor:cr(e.reserve_factor),marketAddress:dr(e.market_address),config:wr(e.config)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:dr(e.asset),maxBorrowRateRay:ur(e.max_borrow_rate_ray),baseBorrowRateRay:ur(e.base_borrow_rate_ray),slope1Ray:ur(e.slope1_ray),slope2Ray:ur(e.slope2_ray),slope3Ray:ur(e.slope3_ray),midUtilizationRay:ur(e.mid_utilization_ray),optimalUtilizationRay:ur(e.optimal_utilization_ray),maxUtilizationRay:pr(e.max_utilization_ray),reserveFactorBps:cr(e.reserve_factor_bps)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:hr(e).map((e=>{return t=hr(e),{asset:dr(t[0]),timestamp:cr(t[1]),supplyIndexRay:ur(t[2]),borrowIndexRay:ur(t[3]),reservesRay:ur(t[4]),suppliedRay:ur(t[5]),borrowedRay:ur(t[6]),revenueRay:ur(t[7]),assetPriceWad:pr(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:hr(e).map((e=>{const t=e;return{asset:dr(t.asset),params:(r=t.params,{maxBorrowRateRay:ur(r.max_borrow_rate_ray),baseBorrowRateRay:ur(r.base_borrow_rate_ray),slope1Ray:ur(r.slope1_ray),slope2Ray:ur(r.slope2_ray),slope3Ray:ur(r.slope3_ray),midUtilizationRay:ur(r.mid_utilization_ray),optimalUtilizationRay:ur(r.optimal_utilization_ray),maxUtilizationRay:pr(r.max_utilization_ray),reserveFactorBps:cr(r.reserve_factor_bps),supplyCap:ur(r.supply_cap),borrowCap:ur(r.borrow_cap),assetId:_r(r.asset_id),assetDecimals:void 0===r.asset_decimals?void 0:cr(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=hr(e);return{topic:"position:batch_update",data:{accountId:ur(t[0]),accountAttributes:xr(hr(t[1])),updates:[...hr(t[2]).map((e=>Tr(hr(e),"Deposit"))),...hr(t[3]).map((e=>Tr(hr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{asset:dr(e.asset),receiver:dr(e.receiver),caller:dr(e.caller),amount:ur(e.amount),fee:ur(e.fee)}}),"config:asset":e=>({topic:"config:asset",data:{asset:dr(e.asset),config:wr(e.config)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:dr(e.asset),oracle:Rr(e.oracle)}}),"config:emode_category":e=>({topic:"config:emode_category",data:{category:{categoryId:cr(e.category.category_id),isDeprecated:Boolean(e.category.is_deprecated)}}}),"config:emode_asset":e=>({topic:"config:emode_asset",data:{asset:dr(e.asset),config:{isCollateralizable:Boolean(e.config.is_collateralizable),isBorrowable:Boolean(e.config.is_borrowable),loanToValueBps:cr(e.config.loan_to_value_bps),liquidationThresholdBps:cr(e.config.liquidation_threshold_bps),liquidationBonusBps:cr(e.config.liquidation_bonus_bps),supplyCap:ur(e.config.supply_cap),borrowCap:ur(e.config.borrow_cap)},categoryId:cr(e.category_id)}}),"config:remove_emode_asset":e=>({topic:"config:remove_emode_asset",data:{asset:dr(e.asset),categoryId:cr(e.category_id)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:ur(e.account_id),totalBorrowUsdWad:ur(e.total_borrow_usd_wad),totalCollateralUsdWad:ur(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:dr(e.token),amount:ur(e.amount),usdValueWad:ur(e.usd_value_wad),accountId:ur(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{asset:dr(e.asset),amount:ur(e.amount),fee:ur(e.fee),amountSent:ur(e.amount_sent)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:mr(e.wasm_hash),approved:Boolean(e.approved)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:dr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:dr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:mr(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:cr(e.max_supply_positions),maxBorrowPositions:cr(e.max_borrow_positions)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:dr(e.asset)}})},kr=Object.freeze(Object.keys(Er));function Ar(e,t){const r=ir(e),o=Er[r];return o?o((0,d.scValToNative)(lr(t))):null}const Pr="XLENDXLM-a7c9f3",Ir=1e4;function Br(e){const t=BigInt(e).toString(16),r=t.length%2==0?t:`0${t}`;return`${Pr}-${r}`}function Or(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function Cr(e,t=0){return e*Ir+t}function Lr(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const $r=(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()},Nr=e=>e.baseUrl??s[e.network];async function Ur(e,t){if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=$r(Nr(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 Gr(e){const t=$r(Nr(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 qr=(e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e,Mr=e=>P(e).toXDR("base64");function Vr(e,t){const r=e.routerAddress??u(e.network),o=new d.Contract(r),a=new d.Account(e.caller,e.sourceSequence),n=O(qr(t,e.referralId));return{xdr:new d.TransactionBuilder(a,{fee:e.fee??d.BASE_FEE,networkPassphrase:l[e.network]}).addOperation(o.call("execute_strategy",_(e.caller),m(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Dr(e,t){return Vr(e,t)}function zr(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(Fr),splitPpm:e.splitPpm}))):[{hops:e.hops.map(Fr),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function Wr(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:zr(e,t)}const Xr=zr,Fr=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function Hr(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function jr(e,t,r){const o=d.TransactionBuilder.fromXDR(t,"base64");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw Hr(r.invokedContractId,e);throw e}}async function Qr(e,t,r){return jr(e,t.xdr,r)}function Kr(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 Zr(e,t){return{paths:[{hops:[{amountOut:"0",pool:e,tokenIn:e,tokenOut:e,venue:"Soroswap"}],splitPpm:1e6}],referralId:0,tokenIn:e,tokenOut:e,totalMinOut:t}}const Yr=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 Jr(e){const t=new d.Account(e.caller,e.sourceSequence),r=new d.Contract(e.forwarderAddress).call("mint_and_forward",d.xdr.ScVal.scvBytes(Yr(e.message)),d.xdr.ScVal.scvBytes(Yr(e.attestation)));return{xdr:new d.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:l[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}module.exports=t})();