@xoxno/sdk-js 1.0.164 → 1.0.170

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_:()=>ye,DU:()=>c,fA:()=>Eo,A$:()=>m,J9:()=>b,hS:()=>f,gR:()=>Mo,Cg:()=>Po,VZ:()=>Ko,N0:()=>Gt,Wc:()=>Kt,hu:()=>Xt,B_:()=>ce,eX:()=>te,z:()=>Go,xD:()=>W,jR:()=>j,P2:()=>Jo,W6:()=>le,KH:()=>oe,se:()=>se,ln:()=>ne,g:()=>jt,jP:()=>Zt,FM:()=>re,yr:()=>Do,sp:()=>Z,$9:()=>to,zw:()=>oo,h_:()=>ro,e_:()=>no,Tk:()=>Ye,BA:()=>eo,SX:()=>Bt,UF:()=>Ro,Y5:()=>K,mE:()=>J,xG:()=>Ut,s9:()=>Y,OL:()=>Lt,Mq:()=>Me,fc:()=>ke,kD:()=>Le,Yf:()=>Ce,c5:()=>He,qU:()=>Be,RZ:()=>De,PD:()=>ze,cJ:()=>we,vM:()=>Re,hF:()=>Xe,Qk:()=>Fe,Gw:()=>Ke,$K:()=>We,cO:()=>Ie,Qy:()=>Pe,X7:()=>$e,Ub:()=>Ze,Dx:()=>Ue,OA:()=>qe,$U:()=>Se,ob:()=>Ee,cY:()=>Te,$l:()=>Ae,VS:()=>je,HP:()=>Je,YQ:()=>Qe,mK:()=>Oe,QY:()=>Ve,os:()=>Ne,Ko:()=>Ge,kz:()=>Yt,Oy:()=>Ft,IJ:()=>ie,nw:()=>F,Pr:()=>ot,ZE:()=>Q,ev:()=>Nt,P8:()=>ee,aV:()=>Vt,p2:()=>zt,Ww:()=>Wt,Dy:()=>Ht,Ni:()=>z,v_:()=>V,qD:()=>et,qR:()=>tt,QJ:()=>Dt,bm:()=>$t,n_:()=>de,v8:()=>ue,Y_:()=>Jt,qM:()=>Ct,gH:()=>ae,un:()=>pe,O3:()=>H,Gz:()=>X,pr:()=>G,Fm:()=>ko,ns:()=>kt,MB:()=>At,Dn:()=>It,pq:()=>Et,ml:()=>Ot,Q3:()=>Pt,wf:()=>No,Um:()=>Oo,xO:()=>ht,Lw:()=>$o,KM:()=>h,mM:()=>dt,iE:()=>xt,zp:()=>yt,bN:()=>it,QV:()=>_,T_:()=>_t,XI:()=>ft,Lt:()=>vt,KK:()=>st,vc:()=>g,CH:()=>Bo,FI:()=>lt,KG:()=>qt,nW:()=>ct,jF:()=>pt,S2:()=>bt,uS:()=>St,u_:()=>at,O5:()=>gt,Av:()=>mt,LA:()=>Wo,E6:()=>zo,Ds:()=>Vo,CU:()=>Co,Vx:()=>Fo,DL:()=>Xo,ON:()=>so,Hh:()=>Tt,oV:()=>Io,g5:()=>Ho,L:()=>uo,Vu:()=>Qo});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??""},f={mainnet:"https://soroban-rpc.stellar.org",testnet:"https://soroban-testnet.stellar.org"},b={mainnet:process.env.STELLAR_QUOTE_URL_MAINNET??"https://stellar-swap.xoxno.com",testnet:process.env.STELLAR_QUOTE_URL_TESTNET??"https://testnet-stellar-swap.xoxno.com"},m={mainnet:"Public Global Stellar Network ; September 2015",testnet:"Test SDF Network ; September 2015"};function g(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),E=t=>s.ScVal.scvSymbol(t),k=()=>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?k():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:E(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([E(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??g(e.network),a=new r(s),p=new t(e.caller,e.sourceSequence);return{xdr:new u(p,{fee:e.fee??o,networkPassphrase:m[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),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)}/markets`,{...r,params:{side:o}}),ft=(t,e,o)=>t.fetchWithTimeout(`${rt}/hubs/${e}`,o),bt=(t,e,o)=>t.fetchWithTimeout(`${rt}/spokes/${e}`,o),mt=(t,e,o)=>t.fetchWithTimeout(`${rt}/users/${ut(e)}/positions`,o),gt=(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}:{}}})},ht=(t,e,o)=>t.fetchWithTimeout(`${rt}/accounts/${ut(e)}/positions`,o),_t=(t,e={},o)=>{const{top:r=nt,continuationToken:n}=e;return t.fetchWithTimeout(`${rt}/governance/proposals`,{...o,params:{top:r,...n?{continuationToken:n}:{}}})},xt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/assets/${ut(e)}/graph`,{...r,params:{...o}}),vt=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/hubs/${e}/graph`,{...r,params:{...o}}),St=(t,e,o,r)=>t.fetchWithTimeout(`${rt}/spokes/${e}/graph`,{...r,params:{...o}}),qt=(t,e,o,r,n,u)=>t.fetchWithTimeout(`${rt}/reserves/${e}/${o}/${ut(r)}/graph`,{...u,params:{...n}}),Tt=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)=>yt(t,e,o,r),hub:(e,o)=>ft(t,e,o),spoke:(e,o)=>bt(t,e,o),userPositions:(e,o)=>mt(t,e,o),userActivity:(e,o,r)=>gt(t,e,o,r),accountPositions:(e,o)=>ht(t,e,o),governanceProposals:(e,o)=>_t(t,e,o),assetGraph:(e,o,r)=>xt(t,e,o,r),hubGraph:(e,o,r)=>vt(t,e,o,r),spokeGraph:(e,o,r)=>St(t,e,o,r),reserveGraph:(e,o,r,n,u)=>qt(t,e,o,r,n,u)}),wt={Single:0,PrimaryWithAnchor:1},At=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)}),kt=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)}),Pt=t=>U({max_borrow_positions:q(t.maxBorrowPositions),max_supply_positions:q(t.maxSupplyPositions)}),Mt=t=>{const e=t.kind;switch(e){case"Stellar":return P([E("Stellar"),v(t.value)]);case"Symbol":return P([E("Symbol"),E(t.value)]);case"String":return P([E("String"),A(t.value)]);default:throw new Error(`Stellar builder: unknown oracle asset ref kind "${e}"`)}},Rt=(t,e)=>{if("Twap"===t){if("number"!=typeof e)throw new Error("Stellar builder: oracle source with Twap read mode requires `twapRecords`");return P([E("Twap"),q(e)])}return P([E("Spot")])},Ot=t=>{const e=t.provider;if("ReflectorSep40"===e){if(!t.asset)throw new Error("Stellar builder: Reflector oracle source requires `asset`");return P([E("Reflector"),U({asset:Mt(t.asset),contract:v(t.contract),read_mode:Rt(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([E("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}"`)},It=t=>{const e=wt[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?[E("None")]:[E("Some"),Ot(o)])),max_price_stale_seconds:T(t.maxPriceStaleSeconds),max_sanity_price_wad:S(t.maxSanityPriceWad),min_sanity_price_wad:S(t.minSanityPriceWad),primary:Ot(t.primary),strategy:q(e),tolerance_bps:q(t.toleranceBps)});var o};function Ct(t,e){return G(t,"upgrade",[M(e.wasmHash)])}function Ut(t,e){return G(t,"migrate",[q(e.newVersion)])}function Lt(t){return G(t,"pause",[])}function $t(t){return G(t,"unpause",[])}function Bt(t,e){return G(t,"grant_role",[v(e.account),E(e.role)])}function Nt(t,e){return G(t,"revoke_role",[v(e.account),E(e.role)])}function Dt(t,e){return G(t,"transfer_ownership",[v(e.newOwner),q(e.liveUntilLedger)])}function Gt(t){return G(t,"accept_ownership",[])}function zt(t,e){return G(t,"set_aggregator",[v(e.aggregator)])}function Vt(t,e){return G(t,"set_accumulator",[v(e.accumulator)])}function Wt(t,e){return G(t,"set_liquidity_pool_template",[M(e.wasmHash)])}function jt(t,e){return G(t,"edit_asset_config",[v(e.asset),kt(e.config)])}function Ht(t,e){return G(t,"set_position_limits",[Pt(e)])}function Xt(t){return G(t,"add_e_mode_category",[])}function Ft(t,e){return G(t,"remove_e_mode_category",[q(e.id)])}const Qt=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 Kt(t,e){return G(t,"add_asset_to_e_mode_category",[Qt(e)])}function Zt(t,e){return G(t,"edit_asset_in_e_mode_category",[Qt(e)])}function Jt(t,e){return G(t,"update_pool_caps",[v(e.asset),S(e.supplyCap),S(e.borrowCap)])}function Yt(t,e){return G(t,"remove_asset_from_e_mode",[v(e.asset),q(e.categoryId)])}function te(t,e){return G(t,"approve_token",[v(e.token)])}function ee(t,e){return G(t,"revoke_token",[v(e.token)])}function oe(t,e){return G(t,"configure_market_oracle",[v(t.caller),v(e.asset),It(e.config)])}function re(t,e){return G(t,"edit_oracle_tolerance",[v(t.caller),v(e.asset),q(e.tolerance)])}function ne(t,e){return G(t,"disable_token_oracle",[v(t.caller),v(e.asset)])}function ue(t,e){return G(t,"update_indexes",[v(t.caller),P(e.assets.map((t=>v(t))))])}function ie(t,e){return G(t,"renew_account",[v(t.caller),T(e.accountNonce)])}function se(t,e){return G(t,"create_liquidity_pool",[v(e.asset),Et(e.params),kt(e.config)])}function ae(t,e){return G(t,"upgrade_liquidity_pool_params",[v(e.asset),At(e.params)])}function pe(t,e){return G(t,"upgrade_liquidity_pool",[v(e.asset),M(e.wasmHash)])}function le(t,e){return G(t,"claim_revenue",[v(t.caller),P(e.assets.map((t=>v(t))))])}function ce(t,e){return G(t,"add_rewards",[v(t.caller),P(e.rewards.map((t=>P([v(t.token),S(t.amount)]))))])}function de(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 ye="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)},be=(t,...e)=>P([E(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)}),ge=t=>U({new_owner:v(t.newOwner),live_until_ledger:q(t.liveUntilLedger)}),he=t=>U({account:v(t.account),role:E(t.role)});function _e(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:m[e.network]}).addOperation(a.call(n,...i)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const xe=(t,e,o)=>_e(t,"propose",[v(t.caller),e,fe(o)]),ve=(t,e,o)=>_e(t,"execute_self",[k(),e,fe(o)]);function Se(t,e,o){return xe(t,be("SetAggregator",v(e.aggregator)),o)}function qe(t,e,o){return xe(t,be("SetAccumulator",v(e.accumulator)),o)}function Te(t,e,o){return xe(t,be("SetLiquidityPoolTemplate",M(e.wasmHash)),o)}function we(t,e,o){return xe(t,be("EditAssetConfig",v(e.asset),kt(e.config)),o)}function Ae(t,e,o){return xe(t,be("SetPositionLimits",Pt(e)),o)}function Ee(t,e,o){return xe(t,be("SetMinBorrowCollateralUsd",S(e.floorWad)),o)}function ke(t,e){return xe(t,be("AddEModeCategory"),e)}function Pe(t,e,o){return xe(t,be("RemoveEModeCategory",q(e.id)),o)}function Me(t,e,o){return xe(t,be("AddAssetToEModeCategory",me(e)),o)}function Re(t,e,o){return xe(t,be("EditAssetInEModeCategory",me(e)),o)}function Oe(t,e,o){return xe(t,be("UpdatePoolCaps",U({asset:v((r=e).asset),supply_cap:S(r.supplyCap),borrow_cap:S(r.borrowCap)})),o);var r}function Ie(t,e,o){return xe(t,be("RemoveAssetFromEMode",U({asset:v((r=e).asset),category_id:q(r.categoryId)})),o);var r}function Ce(t,e,o){return xe(t,be("ApproveToken",v(e.token)),o)}function Ue(t,e,o){return xe(t,be("RevokeToken",v(e.token)),o)}function Le(t,e,o){return xe(t,be("ApproveBlendPool",v(e.pool)),o)}function $e(t,e,o){return xe(t,be("RevokeBlendPool",v(e.pool)),o)}function Be(t,e,o){return xe(t,be("CreateLiquidityPool",U({asset:v((r=e).asset),params:Et(r.params),config:kt(r.config)})),o);var r}function Ne(t,e,o){return xe(t,be("UpgradeLiquidityPoolParams",U({asset:v((r=e).asset),params:At(r.params)})),o);var r}function De(t,e){return xe(t,be("DeployPool"),e)}function Ge(t,e,o){return xe(t,be("UpgradePool",M(e.wasmHash)),o)}function ze(t,e,o){return xe(t,be("DisableTokenOracle",v(e.asset)),o)}function Ve(t,e,o){return xe(t,be("UpgradeController",M(e.wasmHash)),o)}function We(t,e,o){return xe(t,be("MigrateController",q(e.newVersion)),o)}function je(t,e,o){return xe(t,be("TransferCtrlOwnership",ge(e)),o)}function He(t,e,o){return xe(t,be("ConfigureMarketOracle",U({asset:v((r=e).asset),cfg:It(r.config)})),o);var r}function Xe(t,e,o){return xe(t,be("EditOracleTolerance",U({asset:v((r=e).asset),tolerance:q(r.tolerance)})),o);var r}function Fe(t,e,o){return xe(t,be("UpgradeGov",M(e.wasmHash)),o)}function Qe(t,e,o){return xe(t,be("UpdateGovDelay",q(e.newDelay)),o)}function Ke(t,e,o){return xe(t,be("GrantGovRole",he(e)),o)}function Ze(t,e,o){return xe(t,be("RevokeGovRole",he(e)),o)}function Je(t,e,o){return xe(t,be("TransferGovOwnership",ge(e)),o)}function Ye(t,e){const o=P(e.argsXdr.map((t=>s.ScVal.fromXDR(t,"base64")))),r=fe(e.predecessor??ye);return _e(t,"execute",[k(),v(e.target),E(e.functionName),o,r,fe(e.salt)])}function to(t,e,o){return ve(t,be("UpgradeGov",M(e.wasmHash)),o)}function eo(t,e,o){return ve(t,be("UpdateGovDelay",q(e.newDelay)),o)}function oo(t,e,o){return ve(t,be("GrantGovRole",he(e)),o)}function ro(t,e,o){return ve(t,be("RevokeGovRole",he(e)),o)}function no(t,e,o){return ve(t,be("TransferGovOwnership",ge(e)),o)}const uo=t=>t.toXDR("base64"),io=t=>s.ScVal.fromXDR(t,"base64"),so=t=>t.map((t=>String(i(io(t))))).join(":"),ao=t=>"bigint"==typeof t||"number"==typeof t?t.toString():String(t),po=t=>Number(t),lo=t=>String(t),co=t=>null==t?void 0:ao(t),yo=t=>null==t?void 0:lo(t),fo=t=>t instanceof Uint8Array?Buffer.from(t).toString("hex"):Buffer.isBuffer(t)?t.toString("hex"):String(t),bo=["None","Multiply","Long","Short"],mo=["Single","PrimaryWithAnchor"],go=["ReflectorSep40","RedStonePriceFeed"],ho=["Spot","Twap"],_o=["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"],xo=t=>Array.isArray(t)?t:[],vo=t=>({loanToValueBps:po(t.loan_to_value_bps),liquidationThresholdBps:po(t.liquidation_threshold_bps),liquidationBonusBps:po(t.liquidation_bonus_bps),liquidationFeesBps:po(t.liquidation_fees_bps),isCollateralizable:Boolean(t.is_collateralizable),isBorrowable:Boolean(t.is_borrowable),isFlashloanable:Boolean(t.is_flashloanable),flashloanFeeBps:po(t.flashloan_fee_bps),eModeCategories:(t.e_mode_categories??[]).map(po)}),So=(t,e)=>{const o="Borrow"===e;return{action:(r=t[0],_o[po(r)]??ao(r)),positionType:e,asset:lo(t[1]),scaledAmountRay:ao(t[2]),indexRay:ao(t[3]),amount:ao(t[4]),liquidationThresholdBps:o?void 0:po(t[5]),liquidationBonusBps:o?void 0:po(t[6]),loanToValueBps:o?void 0:po(t[7])};var r},qo=t=>{return{owner:lo(t[0]),eModeCategoryId:po(t[1]),mode:(e=t[2],bo[po(e)]??"None")};var e},To=(t,e)=>{const o=ho[po(t[`${e}_read_mode`])]??"Spot",r=t[`${e}_asset`],n=t[`${e}_symbol`],u=null!=r?{kind:"Stellar",value:lo(r)}:null!=n?{kind:"Symbol",value:lo(n)}:void 0;return{provider:go[po(t[`${e}_provider`])]??"ReflectorSep40",contractAddress:lo(t[`${e}_contract`]),asset:u,feedId:yo(t[`${e}_feed_id`]),readMode:o,twapRecords:"Twap"===o?po(t[`${e}_twap_records`]):void 0,decimals:po(t[`${e}_decimals`]),resolutionSeconds:po(t[`${e}_resolution_seconds`]),maxStaleSeconds:po(t[`${e}_max_stale_seconds`])}},wo=t=>{const e=null!==t.anchor_provider&&void 0!==t.anchor_provider;return{baseTokenId:lo(t.base_token_id),quoteTokenId:lo(t.quote_token_id),tolerance:{upperRatio:po(t.upper_ratio_bps??t.tolerance?.upper_ratio_bps),lowerRatio:po(t.lower_ratio_bps??t.tolerance?.lower_ratio_bps)},assetDecimals:po(t.asset_decimals),maxPriceStaleSeconds:po(t.max_price_stale_seconds),strategy:mo[po(t.strategy)]??"Single",primary:To(t,"primary"),anchor:e?To(t,"anchor"):void 0,primaryQuoteToken:yo(t.primary_quote_token),anchorQuoteToken:yo(t.anchor_quote_token),minSanityPriceWad:co(t.min_sanity_price_wad),maxSanityPriceWad:co(t.max_sanity_price_wad)}},Ao={"market:create":t=>({topic:"market:create",data:{baseAsset:lo(t.base_asset),maxBorrowRate:ao(t.max_borrow_rate),baseBorrowRate:ao(t.base_borrow_rate),slope1:ao(t.slope1),slope2:ao(t.slope2),slope3:ao(t.slope3),midUtilization:ao(t.mid_utilization),optimalUtilization:ao(t.optimal_utilization),maxUtilization:co(t.max_utilization),reserveFactor:po(t.reserve_factor),marketAddress:lo(t.market_address),config:vo(t.config)}}),"market:params_update":t=>({topic:"market:params_update",data:{asset:lo(t.asset),maxBorrowRateRay:ao(t.max_borrow_rate_ray),baseBorrowRateRay:ao(t.base_borrow_rate_ray),slope1Ray:ao(t.slope1_ray),slope2Ray:ao(t.slope2_ray),slope3Ray:ao(t.slope3_ray),midUtilizationRay:ao(t.mid_utilization_ray),optimalUtilizationRay:ao(t.optimal_utilization_ray),maxUtilizationRay:co(t.max_utilization_ray),reserveFactorBps:po(t.reserve_factor_bps)}}),"market:batch_state_update":t=>({topic:"market:batch_state_update",data:{updates:xo(t).map((t=>{return e=xo(t),{asset:lo(e[0]),timestamp:po(e[1]),supplyIndexRay:ao(e[2]),borrowIndexRay:ao(e[3]),reservesRay:ao(e[4]),suppliedRay:ao(e[5]),borrowedRay:ao(e[6]),revenueRay:ao(e[7]),assetPriceWad:co(e[8])};var e}))}}),"market:batch_params_update":t=>({topic:"market:batch_params_update",data:{updates:xo(t).map((t=>{const e=t;return{asset:lo(e.asset),params:(o=e.params,{maxBorrowRateRay:ao(o.max_borrow_rate_ray),baseBorrowRateRay:ao(o.base_borrow_rate_ray),slope1Ray:ao(o.slope1_ray),slope2Ray:ao(o.slope2_ray),slope3Ray:ao(o.slope3_ray),midUtilizationRay:ao(o.mid_utilization_ray),optimalUtilizationRay:ao(o.optimal_utilization_ray),maxUtilizationRay:co(o.max_utilization_ray),reserveFactorBps:po(o.reserve_factor_bps),supplyCap:ao(o.supply_cap),borrowCap:ao(o.borrow_cap),assetId:yo(o.asset_id),assetDecimals:void 0===o.asset_decimals?void 0:po(o.asset_decimals)})};var o}))}}),"position:batch_update":t=>{const e=xo(t);return{topic:"position:batch_update",data:{accountId:ao(e[0]),accountAttributes:qo(xo(e[1])),updates:[...xo(e[2]).map((t=>So(xo(t),"Deposit"))),...xo(e[3]).map((t=>So(xo(t),"Borrow")))]}}},"position:flash_loan":t=>({topic:"position:flash_loan",data:{asset:lo(t.asset),receiver:lo(t.receiver),caller:lo(t.caller),amount:ao(t.amount),fee:ao(t.fee)}}),"config:asset":t=>({topic:"config:asset",data:{asset:lo(t.asset),config:vo(t.config)}}),"config:oracle":t=>({topic:"config:oracle",data:{asset:lo(t.asset),oracle:wo(t.oracle)}}),"config:emode_category":t=>({topic:"config:emode_category",data:{category:{categoryId:po(t.category.category_id),isDeprecated:Boolean(t.category.is_deprecated)}}}),"config:emode_asset":t=>({topic:"config:emode_asset",data:{asset:lo(t.asset),config:{isCollateralizable:Boolean(t.config.is_collateralizable),isBorrowable:Boolean(t.config.is_borrowable),loanToValueBps:po(t.config.loan_to_value_bps),liquidationThresholdBps:po(t.config.liquidation_threshold_bps),liquidationBonusBps:po(t.config.liquidation_bonus_bps),supplyCap:ao(t.config.supply_cap),borrowCap:ao(t.config.borrow_cap)},categoryId:po(t.category_id)}}),"config:remove_emode_asset":t=>({topic:"config:remove_emode_asset",data:{asset:lo(t.asset),categoryId:po(t.category_id)}}),"debt:bad_debt":t=>({topic:"debt:bad_debt",data:{accountId:ao(t.account_id),totalBorrowUsdWad:ao(t.total_borrow_usd_wad),totalCollateralUsdWad:ao(t.total_collateral_usd_wad)}}),"strategy:initial_payment":t=>({topic:"strategy:initial_payment",data:{token:lo(t.token),amount:ao(t.amount),usdValueWad:ao(t.usd_value_wad),accountId:ao(t.account_id)}}),"strategy:fee":t=>({topic:"strategy:fee",data:{asset:lo(t.asset),amount:ao(t.amount),fee:ao(t.fee),amountSent:ao(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:lo(t.aggregator)}}),"config:accumulator":t=>({topic:"config:accumulator",data:{accumulator:lo(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:po(t.max_supply_positions),maxBorrowPositions:po(t.max_borrow_positions)}}),"config:oracle_disabled":t=>({topic:"config:oracle_disabled",data:{asset:lo(t.asset)}})},Eo=Object.freeze(Object.keys(Ao));function ko(t,e){const o=so(t),r=Ao[o];return r?r(i(io(e))):null}const Po="XLENDXLM-a7c9f3",Mo=1e4;function Ro(t){const e=BigInt(t).toString(16),o=e.length%2==0?e:`0${e}`;return`${Po}-${o}`}function Oo(t){const e=t.split("-");return e.length>=2&&parseInt(e[1],10)||0}function Io(t,e=0){return t*Mo+e}function Co(t){switch(t){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Uo=(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()},Lo=t=>t.baseUrl??b[t.network];async function $o(t,e){if(null==t.amountIn==(null==t.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const o=Uo(Lo(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 Bo(t){const e=Uo(Lo(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 No=t=>L(t).toXDR("base64");function Do(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:m[e.network]}).addOperation(s.call("execute_strategy",v(e.caller),S(e.totalIn),p)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Go(t,e){return Do(t,e)}function zo(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(jo),splitPpm:t.splitPpm}))):[{hops:t.hops.map(jo),splitPpm:1e6}],referralId:e.referralId??0,tokenIn:t.from,tokenOut:t.to,totalMinOut:t.amountOutMin}}function Vo(t,e={}){const o=t;return"string"==typeof o.routeXdr&&o.routeXdr.length>0?{routeXdr:o.routeXdr}:zo(t,e)}const Wo=zo,jo=t=>({amountOut:t.amountOut,pool:t.address,tokenIn:t.from,tokenOut:t.to,venue:t.dex});function Ho(t,e){const o=e instanceof Error?e.message:String(e);return new Error(`[xoxno-invoked:${t}] ${o}`)}async function Xo(t,e,o){const r=u.fromXDR(e,"base64");try{return(await t.prepareTransaction(r)).toXDR()}catch(t){if(o?.invokedContractId)throw Ho(o.invokedContractId,t);throw t}}async function Fo(t,e,o){return Xo(t,e.xdr,o)}function Qo(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 Ko(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 Zo=t=>{const e=t.startsWith("0x")?t.slice(2):t;if(e.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return Buffer.from(e,"hex")};function Jo(e){const o=new t(e.caller,e.sourceSequence),n=new r(e.forwarderAddress).call("mint_and_forward",s.ScVal.scvBytes(Zo(e.message)),s.ScVal.scvBytes(Zo(e.attestation)));return{xdr:new u(o,{fee:e.fee??"10000000",networkPassphrase:m[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",f="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";var b;!function(t){t.MAINNET="1",t.DEVNET="D"}(b||(b={}));class m{apiUrl;chain;init;config;constructor({chain:t=b.MAINNET,apiUrl:e=c,...o}={}){this.apiUrl=e??{[b.MAINNET]:c,[b.DEVNET]:"https://devnet-api.xoxno.com"}[t],this.chain=t,this.init=o,this.config=t==b.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:d,DR_SC:y,KG_SC:f,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:f,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,f="Bearer undefined"===y?void 0:y,b={...l,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",..."PUT"===c?{}:{"Content-Type":"application/json"},...f?{Authorization:f}:{}},m=Object.entries(e??{}).flatMap((([t,e])=>Array.isArray(e)?e.map((e=>`${t}=${encodeURIComponent(e)}`)):`${t}=${encodeURIComponent(e)}`)).join("&"),g=`${this.apiUrl}${t}${m.length?`?${m}`:""}`,{revalidate:h,..._}=r??{},{revalidate:x,...v}=s??{},S="GET"!==c||f?void 0:x??h,q="GET"!==c||f||S?void 0:a??n,T={...i,...d,method:c,...Object.keys(b).length?{headers:b}:{},cache:q,next:{..._,...v,revalidate:S}};(p??u)&&console.debug("SDK fetch: ",g,T);const w=await fetch(g,T).catch((t=>{if(t instanceof Error&&!t.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${g}: ${t.message}`),{cause:t});throw t})),A=await w.text();if(!w.ok){let t;try{t=JSON.parse(A)}catch{t={message:A}}const e=[g,w.status,w.statusText,t.message].filter(Boolean).join(";;");throw new Error(e)}try{return JSON.parse(A)}catch{return A}}}const g=t=>{const e=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(t)),o=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t);return e||o},h=t=>{const e=/^0x[a-fA-F0-9]{1,64}$/.test(t),o=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(t);return e||o};class _ 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"}},"/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=>!g(t))):!g(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:f,cache:b,next:m,debug:h,continuationToken:S,...q}=l,T=d?`Bearer ${d}`:void 0,w={...f,...T?{Authorization:T}:{},...S?{"X-Continuation-Token":String(S)}:{}},A={...m,tags:[...m?.tags??[],u]};return r.fetchWithTimeout(u,{method:y,params:q,body:c,headers:w,cache:b,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 E(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{b as Chain,m as XOXNOClient,E as buildSdk,g 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 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_:()=>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 +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:()=>st,STELLAR_LENDING_CONTROLLER:()=>r,STELLAR_LENDING_TOPICS:()=>Rr,STELLAR_NETWORK_PASSPHRASE:()=>l,STELLAR_QUOTE_URL:()=>s,STELLAR_SOROBAN_RPC_URL:()=>n,SYNTHETIC_EVENT_ORDER_STRIDE:()=>Ar,XOXNO_LENDING_STELLAR_TICKER:()=>kr,buildSameTokenRepaySwapSteps:()=>Qr,buildStellarAcceptOwnershipTx:()=>Le,buildStellarAddAssetToEModeCategoryTx:()=>ze,buildStellarAddEModeCategoryTx:()=>Me,buildStellarAddRewardsTx:()=>at,buildStellarApproveTokenTx:()=>He,buildStellarBatchSwapTx:()=>Mr,buildStellarBorrowBatchTx:()=>U,buildStellarBorrowTx:()=>G,buildStellarCctpForwardTx:()=>Zr,buildStellarClaimRevenueTx:()=>ot,buildStellarConfigureMarketOracleTx:()=>Qe,buildStellarCreateLiquidityPoolTx:()=>et,buildStellarDisableTokenOracleTx:()=>Ze,buildStellarEditAssetConfigTx:()=>Ge,buildStellarEditAssetInEModeCategoryTx:()=>We,buildStellarEditOracleToleranceTx:()=>Ke,buildStellarExecuteStrategyTx:()=>qr,buildStellarFlashLoanTx:()=>W,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>Jt,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>tr,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>rr,buildStellarGovernanceExecuteTransferGovOwnTx:()=>or,buildStellarGovernanceExecuteTx:()=>Yt,buildStellarGovernanceExecuteUpdateDelayTx:()=>er,buildStellarGrantRoleTx:()=>Be,buildStellarLendingIdentifier:()=>Pr,buildStellarLiquidateTx:()=>z,buildStellarMigrateFromBlendTx:()=>X,buildStellarMigrateTx:()=>Ae,buildStellarMultiplyTx:()=>F,buildStellarPauseTx:()=>Pe,buildStellarProposeAddAssetToEModeTx:()=>Pt,buildStellarProposeAddEModeCategoryTx:()=>kt,buildStellarProposeApproveBlendPoolTx:()=>$t,buildStellarProposeApproveTokenTx:()=>Ct,buildStellarProposeConfigureMarketOracleTx:()=>Xt,buildStellarProposeCreateLiquidityPoolTx:()=>Ut,buildStellarProposeDeployPoolTx:()=>qt,buildStellarProposeDisableTokenOracleTx:()=>Vt,buildStellarProposeEditAssetConfigTx:()=>vt,buildStellarProposeEditAssetInEModeTx:()=>It,buildStellarProposeEditOracleToleranceTx:()=>Ft,buildStellarProposeGovernanceUpgradeTx:()=>Ht,buildStellarProposeGrantGovernanceRoleTx:()=>Qt,buildStellarProposeMigrateControllerTx:()=>zt,buildStellarProposeRemoveAssetFromEModeTx:()=>Ot,buildStellarProposeRemoveEModeCategoryTx:()=>At,buildStellarProposeRevokeBlendPoolTx:()=>Nt,buildStellarProposeRevokeGovernanceRoleTx:()=>Kt,buildStellarProposeRevokeTokenTx:()=>Lt,buildStellarProposeSetAccumulatorTx:()=>Tt,buildStellarProposeSetAggregatorTx:()=>wt,buildStellarProposeSetMinBorrowCollatTx:()=>Et,buildStellarProposeSetPoolTemplateTx:()=>xt,buildStellarProposeSetPositionLimitsTx:()=>Rt,buildStellarProposeTransferCtrlOwnershipTx:()=>Wt,buildStellarProposeTransferGovOwnTx:()=>Zt,buildStellarProposeUpdateDelayTx:()=>jt,buildStellarProposeUpdatePoolCapsTx:()=>Bt,buildStellarProposeUpgradeControllerTx:()=>Dt,buildStellarProposeUpgradePoolParamsTx:()=>Gt,buildStellarProposeUpgradePoolTx:()=>Mt,buildStellarRemoveAssetFromEModeTx:()=>Fe,buildStellarRemoveEModeCategoryTx:()=>Ve,buildStellarRenewAccountTx:()=>Je,buildStellarRepayBatchTx:()=>V,buildStellarRepayDebtWithCollateralTx:()=>Q,buildStellarRepayTx:()=>D,buildStellarRevokeRoleTx:()=>Oe,buildStellarRevokeTokenTx:()=>je,buildStellarSetAccumulatorTx:()=>Ne,buildStellarSetAggregatorTx:()=>$e,buildStellarSetLiquidityPoolTemplateTx:()=>Ue,buildStellarSetPositionLimitsTx:()=>qe,buildStellarSupplyBatchTx:()=>$,buildStellarSupplyTx:()=>N,buildStellarSwapCollateralTx:()=>j,buildStellarSwapDebtTx:()=>H,buildStellarTransferOwnershipTx:()=>Ce,buildStellarUnpauseTx:()=>Ie,buildStellarUpdateAccountThresholdTx:()=>nt,buildStellarUpdateIndexesTx:()=>Ye,buildStellarUpdatePoolCapsTx:()=>Xe,buildStellarUpgradeControllerTx:()=>ke,buildStellarUpgradeLiquidityPoolParamsTx:()=>tt,buildStellarUpgradeLiquidityPoolTx:()=>rt,buildStellarWithdrawBatchTx:()=>q,buildStellarWithdrawTx:()=>M,buildTx:()=>L,decodeStellarLendingEvent:()=>Er,encodeAssetConfigRaw:()=>we,encodeInterestRateModel:()=>ye,encodeMarketOracleConfigInput:()=>Ee,encodeMarketParamsRaw:()=>he,encodeOracleSourceConfigInput:()=>Re,encodePositionLimits:()=>Te,encodeStrategyPayloadToRouteXdr:()=>Gr,extractEventOrder:()=>Ir,getStellarAccountPositions:()=>de,getStellarAggregatorQuote:()=>$r,getStellarAggregatorRouter:()=>u,getStellarAsset:()=>ne,getStellarAssetGraph:()=>_e,getStellarAssetMarkets:()=>se,getStellarAssets:()=>J,getStellarGovernance:()=>c,getStellarGovernanceProposals:()=>pe,getStellarHub:()=>le,getStellarHubGraph:()=>fe,getStellarHubs:()=>ee,getStellarLendingController:()=>i,getStellarQuoteTokens:()=>Nr,getStellarReserve:()=>oe,getStellarReserveGraph:()=>be,getStellarReserveHolders:()=>ae,getStellarReserves:()=>re,getStellarSpoke:()=>ie,getStellarSpokeGraph:()=>me,getStellarSpokes:()=>te,getStellarUserActivity:()=>ce,getStellarUserPositions:()=>ue,mapQuoteResponseToAggregatorSwap:()=>zr,mapQuoteResponseToStrategyPayload:()=>Vr,mapQuoteResponseToStrategySwap:()=>Dr,mapStellarPositionActivityType:()=>Or,prepareStellarBuiltTx:()=>Hr,prepareStellarTxXdr:()=>Fr,stellarLendingDispatchKey:()=>sr,stellarLendingRead:()=>Se,syntheticEventOrder:()=>Br,tagStellarInvokedContractError:()=>Xr,toBase64Xdr:()=>ar,toStellarPositionMode:()=>jr});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(),f=e=>new d.ScInt(e).toI128(),m=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),f(r)]);var t,r}))),R=(e,t)=>A({asset:_(t),hub_id:m(e)}),E=(e,t,r)=>d.xdr.ScVal.scvVec([R(e,t),f(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:f(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:m(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:f(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),m(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),f(t.amount),_(t.receiver),C(t.data)])}function X(e,t){return L(e,"migrate_from_blend",[_(e.caller),b(t.accountId),m(t.spokeId),_(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),m(o),R(t.collateral.hubId,t.collateral.asset),f(t.debtToFlashLoan),R(t.debt.hubId,t.debt.asset),m(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),f(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),f(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),f(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)}/markets`,{...o,params:{side:r}}),le=(e,t,r)=>e.fetchWithTimeout(`${K}/hubs/${t}`,r),ie=(e,t,r)=>e.fetchWithTimeout(`${K}/spokes/${t}`,r),ue=(e,t,r)=>e.fetchWithTimeout(`${K}/users/${Y(t)}/positions`,r),ce=(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}:{}}})},de=(e,t,r)=>e.fetchWithTimeout(`${K}/accounts/${Y(t)}/positions`,r),pe=(e,t={},r)=>{const{top:o=Z,continuationToken:a}=t;return e.fetchWithTimeout(`${K}/governance/proposals`,{...r,params:{top:o,...a?{continuationToken:a}:{}}})},_e=(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}}),me=(e,t,r,o)=>e.fetchWithTimeout(`${K}/spokes/${t}/graph`,{...o,params:{...r}}),be=(e,t,r,o,a,n)=>e.fetchWithTimeout(`${K}/reserves/${t}/${r}/${Y(o)}/graph`,{...n,params:{...a}}),Se=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)=>se(e,t,r,o),hub:(t,r)=>le(e,t,r),spoke:(t,r)=>ie(e,t,r),userPositions:(t,r)=>ue(e,t,r),userActivity:(t,r,o)=>ce(e,t,r,o),accountPositions:(t,r)=>de(e,t,r),governanceProposals:(t,r)=>pe(e,t,r),assetGraph:(t,r,o)=>_e(e,t,r,o),hubGraph:(t,r,o)=>fe(e,t,r,o),spokeGraph:(t,r,o)=>me(e,t,r,o),reserveGraph:(t,r,o,a,n)=>be(e,t,r,o,a,n)}),ge={Single:0,PrimaryWithAnchor:1},ye=e=>A({base_borrow_rate_ray:f(e.baseBorrowRateRay),max_borrow_rate_ray:f(e.maxBorrowRateRay),max_utilization_ray:f(e.maxUtilizationRay),mid_utilization_ray:f(e.midUtilizationRay),optimal_utilization_ray:f(e.optimalUtilizationRay),reserve_factor_bps:m(e.reserveFactorBps),slope1_ray:f(e.slope1Ray),slope2_ray:f(e.slope2Ray),slope3_ray:f(e.slope3Ray)}),he=e=>A({asset_decimals:m(e.assetDecimals),asset_id:_(e.assetId),base_borrow_rate_ray:f(e.baseBorrowRateRay),borrow_cap:f(e.borrowCap),max_borrow_rate_ray:f(e.maxBorrowRateRay),max_utilization_ray:f(e.maxUtilizationRay),mid_utilization_ray:f(e.midUtilizationRay),optimal_utilization_ray:f(e.optimalUtilizationRay),reserve_factor_bps:m(e.reserveFactorBps),slope1_ray:f(e.slope1Ray),slope2_ray:f(e.slope2Ray),slope3_ray:f(e.slope3Ray),supply_cap:f(e.supplyCap)}),we=e=>A({asset_decimals:m(0),e_mode_categories:w(e.eModeCategories.map((e=>m(e)))),flashloan_fee_bps:m(e.flashloanFeeBps),is_borrowable:S(e.isBorrowable),is_collateralizable:S(e.isCollateralizable),is_flashloanable:S(e.isFlashloanable),liquidation_bonus_bps:m(e.liquidationBonusBps),liquidation_fees_bps:m(e.liquidationFeesBps),liquidation_threshold_bps:m(e.liquidationThresholdBps),loan_to_value_bps:m(e.loanToValueBps)}),Te=e=>A({max_borrow_positions:m(e.maxBorrowPositions),max_supply_positions:m(e.maxSupplyPositions)}),xe=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}"`)}},ve=(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"),m(t)])}return w([y("Spot")])},Re=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:xe(e.asset),contract:_(e.contract),read_mode:ve(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}"`)},Ee=e=>{const t=ge[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"),Re(r)])),max_price_stale_seconds:b(e.maxPriceStaleSeconds),max_sanity_price_wad:f(e.maxSanityPriceWad),min_sanity_price_wad:f(e.minSanityPriceWad),primary:Re(e.primary),strategy:m(t),tolerance_bps:m(e.toleranceBps)});var r};function ke(e,t){return L(e,"upgrade",[T(t.wasmHash)])}function Ae(e,t){return L(e,"migrate",[m(t.newVersion)])}function Pe(e){return L(e,"pause",[])}function Ie(e){return L(e,"unpause",[])}function Be(e,t){return L(e,"grant_role",[_(t.account),y(t.role)])}function Oe(e,t){return L(e,"revoke_role",[_(t.account),y(t.role)])}function Ce(e,t){return L(e,"transfer_ownership",[_(t.newOwner),m(t.liveUntilLedger)])}function Le(e){return L(e,"accept_ownership",[])}function $e(e,t){return L(e,"set_aggregator",[_(t.aggregator)])}function Ne(e,t){return L(e,"set_accumulator",[_(t.accumulator)])}function Ue(e,t){return L(e,"set_liquidity_pool_template",[T(t.wasmHash)])}function Ge(e,t){return L(e,"edit_asset_config",[_(t.asset),we(t.config)])}function qe(e,t){return L(e,"set_position_limits",[Te(t)])}function Me(e){return L(e,"add_e_mode_category",[])}function Ve(e,t){return L(e,"remove_e_mode_category",[m(t.id)])}const De=e=>A({asset:_(e.asset),category_id:m(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:m(e.ltv),threshold:m(e.threshold),bonus:m(e.bonus),supply_cap:f(e.supplyCap),borrow_cap:f(e.borrowCap)});function ze(e,t){return L(e,"add_asset_to_e_mode_category",[De(t)])}function We(e,t){return L(e,"edit_asset_in_e_mode_category",[De(t)])}function Xe(e,t){return L(e,"update_pool_caps",[_(t.asset),f(t.supplyCap),f(t.borrowCap)])}function Fe(e,t){return L(e,"remove_asset_from_e_mode",[_(t.asset),m(t.categoryId)])}function He(e,t){return L(e,"approve_token",[_(t.token)])}function je(e,t){return L(e,"revoke_token",[_(t.token)])}function Qe(e,t){return L(e,"configure_market_oracle",[_(e.caller),_(t.asset),Ee(t.config)])}function Ke(e,t){return L(e,"edit_oracle_tolerance",[_(e.caller),_(t.asset),m(t.tolerance)])}function Ze(e,t){return L(e,"disable_token_oracle",[_(e.caller),_(t.asset)])}function Ye(e,t){return L(e,"update_indexes",[_(e.caller),w(t.assets.map((e=>_(e))))])}function Je(e,t){return L(e,"renew_account",[_(e.caller),b(t.accountNonce)])}function et(e,t){return L(e,"create_liquidity_pool",[_(t.asset),he(t.params),we(t.config)])}function tt(e,t){return L(e,"upgrade_liquidity_pool_params",[_(t.asset),ye(t.params)])}function rt(e,t){return L(e,"upgrade_liquidity_pool",[_(t.asset),T(t.wasmHash)])}function ot(e,t){return L(e,"claim_revenue",[_(e.caller),w(t.assets.map((e=>_(e))))])}function at(e,t){return L(e,"add_rewards",[_(e.caller),w(t.rewards.map((e=>w([_(e.token),f(e.amount)]))))])}function nt(e,t){return L(e,"update_account_threshold",[_(e.caller),_(t.asset),S(t.hasRisks),w(t.accountNonces.map((e=>b(e))))])}const st="00".repeat(32),lt=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)},it=(e,...t)=>w([y(e),...t]),ut=e=>A({asset:_(e.asset),category_id:m(e.categoryId),can_collateral:S(e.canCollateral),can_borrow:S(e.canBorrow),ltv:m(e.ltv),threshold:m(e.threshold),bonus:m(e.bonus),supply_cap:f(e.supplyCap),borrow_cap:f(e.borrowCap)}),ct=e=>A({asset:_(e.asset),supply_cap:f(e.supplyCap),borrow_cap:f(e.borrowCap)}),dt=e=>A({asset:_(e.asset),category_id:m(e.categoryId)}),pt=e=>A({asset:_(e.asset),params:he(e.params),config:we(e.config)}),_t=e=>A({asset:_(e.asset),params:ye(e.params)}),ft=e=>A({new_owner:_(e.newOwner),live_until_ledger:m(e.liveUntilLedger)}),mt=e=>A({asset:_(e.asset),cfg:Ee(e.config)}),bt=e=>A({asset:_(e.asset),tolerance:m(e.tolerance)}),St=e=>A({account:_(e.account),role:y(e.role)});function gt(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 yt=(e,t,r)=>gt(e,"propose",[_(e.caller),t,lt(r)]),ht=(e,t,r)=>gt(e,"execute_self",[h(),t,lt(r)]);function wt(e,t,r){return yt(e,it("SetAggregator",_(t.aggregator)),r)}function Tt(e,t,r){return yt(e,it("SetAccumulator",_(t.accumulator)),r)}function xt(e,t,r){return yt(e,it("SetLiquidityPoolTemplate",T(t.wasmHash)),r)}function vt(e,t,r){return yt(e,it("EditAssetConfig",_(t.asset),we(t.config)),r)}function Rt(e,t,r){return yt(e,it("SetPositionLimits",Te(t)),r)}function Et(e,t,r){return yt(e,it("SetMinBorrowCollateralUsd",f(t.floorWad)),r)}function kt(e,t){return yt(e,it("AddEModeCategory"),t)}function At(e,t,r){return yt(e,it("RemoveEModeCategory",m(t.id)),r)}function Pt(e,t,r){return yt(e,it("AddAssetToEModeCategory",ut(t)),r)}function It(e,t,r){return yt(e,it("EditAssetInEModeCategory",ut(t)),r)}function Bt(e,t,r){return yt(e,it("UpdatePoolCaps",ct(t)),r)}function Ot(e,t,r){return yt(e,it("RemoveAssetFromEMode",dt(t)),r)}function Ct(e,t,r){return yt(e,it("ApproveToken",_(t.token)),r)}function Lt(e,t,r){return yt(e,it("RevokeToken",_(t.token)),r)}function $t(e,t,r){return yt(e,it("ApproveBlendPool",_(t.pool)),r)}function Nt(e,t,r){return yt(e,it("RevokeBlendPool",_(t.pool)),r)}function Ut(e,t,r){return yt(e,it("CreateLiquidityPool",pt(t)),r)}function Gt(e,t,r){return yt(e,it("UpgradeLiquidityPoolParams",_t(t)),r)}function qt(e,t){return yt(e,it("DeployPool"),t)}function Mt(e,t,r){return yt(e,it("UpgradePool",T(t.wasmHash)),r)}function Vt(e,t,r){return yt(e,it("DisableTokenOracle",_(t.asset)),r)}function Dt(e,t,r){return yt(e,it("UpgradeController",T(t.wasmHash)),r)}function zt(e,t,r){return yt(e,it("MigrateController",m(t.newVersion)),r)}function Wt(e,t,r){return yt(e,it("TransferCtrlOwnership",ft(t)),r)}function Xt(e,t,r){return yt(e,it("ConfigureMarketOracle",mt(t)),r)}function Ft(e,t,r){return yt(e,it("EditOracleTolerance",bt(t)),r)}function Ht(e,t,r){return yt(e,it("UpgradeGov",T(t.wasmHash)),r)}function jt(e,t,r){return yt(e,it("UpdateGovDelay",m(t.newDelay)),r)}function Qt(e,t,r){return yt(e,it("GrantGovRole",St(t)),r)}function Kt(e,t,r){return yt(e,it("RevokeGovRole",St(t)),r)}function Zt(e,t,r){return yt(e,it("TransferGovOwnership",ft(t)),r)}function Yt(e,t){const r=w(t.argsXdr.map((e=>d.xdr.ScVal.fromXDR(e,"base64")))),o=lt(t.predecessor??st);return gt(e,"execute",[h(),_(t.target),y(t.functionName),r,o,lt(t.salt)])}function Jt(e,t,r){return ht(e,it("UpgradeGov",T(t.wasmHash)),r)}function er(e,t,r){return ht(e,it("UpdateGovDelay",m(t.newDelay)),r)}function tr(e,t,r){return ht(e,it("GrantGovRole",St(t)),r)}function rr(e,t,r){return ht(e,it("RevokeGovRole",St(t)),r)}function or(e,t,r){return ht(e,it("TransferGovOwnership",ft(t)),r)}const ar=e=>e.toXDR("base64"),nr=e=>d.xdr.ScVal.fromXDR(e,"base64"),sr=e=>e.map((e=>String((0,d.scValToNative)(nr(e))))).join(":"),lr=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),ir=e=>Number(e),ur=e=>String(e),cr=e=>null==e?void 0:lr(e),dr=e=>null==e?void 0:ur(e),pr=e=>e instanceof Uint8Array?Buffer.from(e).toString("hex"):Buffer.isBuffer(e)?e.toString("hex"):String(e),_r=["None","Multiply","Long","Short"],fr=["Single","PrimaryWithAnchor"],mr=["ReflectorSep40","RedStonePriceFeed"],br=["Spot","Twap"],Sr=["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"],gr=e=>Array.isArray(e)?e:[],yr=e=>({loanToValueBps:ir(e.loan_to_value_bps),liquidationThresholdBps:ir(e.liquidation_threshold_bps),liquidationBonusBps:ir(e.liquidation_bonus_bps),liquidationFeesBps:ir(e.liquidation_fees_bps),isCollateralizable:Boolean(e.is_collateralizable),isBorrowable:Boolean(e.is_borrowable),isFlashloanable:Boolean(e.is_flashloanable),flashloanFeeBps:ir(e.flashloan_fee_bps),eModeCategories:(e.e_mode_categories??[]).map(ir)}),hr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],Sr[ir(o)]??lr(o)),positionType:t,asset:ur(e[1]),scaledAmountRay:lr(e[2]),indexRay:lr(e[3]),amount:lr(e[4]),liquidationThresholdBps:r?void 0:ir(e[5]),liquidationBonusBps:r?void 0:ir(e[6]),loanToValueBps:r?void 0:ir(e[7])};var o},wr=e=>{return{owner:ur(e[0]),eModeCategoryId:ir(e[1]),mode:(t=e[2],_r[ir(t)]??"None")};var t},Tr=(e,t)=>{const r=br[ir(e[`${t}_read_mode`])]??"Spot",o=e[`${t}_asset`],a=e[`${t}_symbol`],n=null!=o?{kind:"Stellar",value:ur(o)}:null!=a?{kind:"Symbol",value:ur(a)}:void 0;return{provider:mr[ir(e[`${t}_provider`])]??"ReflectorSep40",contractAddress:ur(e[`${t}_contract`]),asset:n,feedId:dr(e[`${t}_feed_id`]),readMode:r,twapRecords:"Twap"===r?ir(e[`${t}_twap_records`]):void 0,decimals:ir(e[`${t}_decimals`]),resolutionSeconds:ir(e[`${t}_resolution_seconds`]),maxStaleSeconds:ir(e[`${t}_max_stale_seconds`])}},xr=e=>{const t=null!==e.anchor_provider&&void 0!==e.anchor_provider;return{baseTokenId:ur(e.base_token_id),quoteTokenId:ur(e.quote_token_id),tolerance:{upperRatio:ir(e.upper_ratio_bps??e.tolerance?.upper_ratio_bps),lowerRatio:ir(e.lower_ratio_bps??e.tolerance?.lower_ratio_bps)},assetDecimals:ir(e.asset_decimals),maxPriceStaleSeconds:ir(e.max_price_stale_seconds),strategy:fr[ir(e.strategy)]??"Single",primary:Tr(e,"primary"),anchor:t?Tr(e,"anchor"):void 0,primaryQuoteToken:dr(e.primary_quote_token),anchorQuoteToken:dr(e.anchor_quote_token),minSanityPriceWad:cr(e.min_sanity_price_wad),maxSanityPriceWad:cr(e.max_sanity_price_wad)}},vr={"market:create":e=>({topic:"market:create",data:{baseAsset:ur(e.base_asset),maxBorrowRate:lr(e.max_borrow_rate),baseBorrowRate:lr(e.base_borrow_rate),slope1:lr(e.slope1),slope2:lr(e.slope2),slope3:lr(e.slope3),midUtilization:lr(e.mid_utilization),optimalUtilization:lr(e.optimal_utilization),maxUtilization:cr(e.max_utilization),reserveFactor:ir(e.reserve_factor),marketAddress:ur(e.market_address),config:yr(e.config)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:ur(e.asset),maxBorrowRateRay:lr(e.max_borrow_rate_ray),baseBorrowRateRay:lr(e.base_borrow_rate_ray),slope1Ray:lr(e.slope1_ray),slope2Ray:lr(e.slope2_ray),slope3Ray:lr(e.slope3_ray),midUtilizationRay:lr(e.mid_utilization_ray),optimalUtilizationRay:lr(e.optimal_utilization_ray),maxUtilizationRay:cr(e.max_utilization_ray),reserveFactorBps:ir(e.reserve_factor_bps)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:gr(e).map((e=>{return t=gr(e),{asset:ur(t[0]),timestamp:ir(t[1]),supplyIndexRay:lr(t[2]),borrowIndexRay:lr(t[3]),reservesRay:lr(t[4]),suppliedRay:lr(t[5]),borrowedRay:lr(t[6]),revenueRay:lr(t[7]),assetPriceWad:cr(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:gr(e).map((e=>{const t=e;return{asset:ur(t.asset),params:(r=t.params,{maxBorrowRateRay:lr(r.max_borrow_rate_ray),baseBorrowRateRay:lr(r.base_borrow_rate_ray),slope1Ray:lr(r.slope1_ray),slope2Ray:lr(r.slope2_ray),slope3Ray:lr(r.slope3_ray),midUtilizationRay:lr(r.mid_utilization_ray),optimalUtilizationRay:lr(r.optimal_utilization_ray),maxUtilizationRay:cr(r.max_utilization_ray),reserveFactorBps:ir(r.reserve_factor_bps),supplyCap:lr(r.supply_cap),borrowCap:lr(r.borrow_cap),assetId:dr(r.asset_id),assetDecimals:void 0===r.asset_decimals?void 0:ir(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=gr(e);return{topic:"position:batch_update",data:{accountId:lr(t[0]),accountAttributes:wr(gr(t[1])),updates:[...gr(t[2]).map((e=>hr(gr(e),"Deposit"))),...gr(t[3]).map((e=>hr(gr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{asset:ur(e.asset),receiver:ur(e.receiver),caller:ur(e.caller),amount:lr(e.amount),fee:lr(e.fee)}}),"config:asset":e=>({topic:"config:asset",data:{asset:ur(e.asset),config:yr(e.config)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:ur(e.asset),oracle:xr(e.oracle)}}),"config:emode_category":e=>({topic:"config:emode_category",data:{category:{categoryId:ir(e.category.category_id),isDeprecated:Boolean(e.category.is_deprecated)}}}),"config:emode_asset":e=>({topic:"config:emode_asset",data:{asset:ur(e.asset),config:{isCollateralizable:Boolean(e.config.is_collateralizable),isBorrowable:Boolean(e.config.is_borrowable),loanToValueBps:ir(e.config.loan_to_value_bps),liquidationThresholdBps:ir(e.config.liquidation_threshold_bps),liquidationBonusBps:ir(e.config.liquidation_bonus_bps),supplyCap:lr(e.config.supply_cap),borrowCap:lr(e.config.borrow_cap)},categoryId:ir(e.category_id)}}),"config:remove_emode_asset":e=>({topic:"config:remove_emode_asset",data:{asset:ur(e.asset),categoryId:ir(e.category_id)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:lr(e.account_id),totalBorrowUsdWad:lr(e.total_borrow_usd_wad),totalCollateralUsdWad:lr(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:ur(e.token),amount:lr(e.amount),usdValueWad:lr(e.usd_value_wad),accountId:lr(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{asset:ur(e.asset),amount:lr(e.amount),fee:lr(e.fee),amountSent:lr(e.amount_sent)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:pr(e.wasm_hash),approved:Boolean(e.approved)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:ur(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:ur(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:pr(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:ir(e.max_supply_positions),maxBorrowPositions:ir(e.max_borrow_positions)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:ur(e.asset)}})},Rr=Object.freeze(Object.keys(vr));function Er(e,t){const r=sr(e),o=vr[r];return o?o((0,d.scValToNative)(nr(t))):null}const kr="XLENDXLM-a7c9f3",Ar=1e4;function Pr(e){const t=BigInt(e).toString(16),r=t.length%2==0?t:`0${t}`;return`${kr}-${r}`}function Ir(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function Br(e,t=0){return e*Ar+t}function Or(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"param_upd":return"lendingUpdateAccountParameters";default:return"lendingUpdateAccountPosition"}}const Cr=(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()},Lr=e=>e.baseUrl??s[e.network];async function $r(e,t){if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=Cr(Lr(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 Nr(e){const t=Cr(Lr(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 Ur=(e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e,Gr=e=>P(e).toXDR("base64");function qr(e,t){const r=e.routerAddress??u(e.network),o=new d.Contract(r),a=new d.Account(e.caller,e.sourceSequence),n=O(Ur(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),f(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function Mr(e,t){return qr(e,t)}function Vr(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(Wr),splitPpm:e.splitPpm}))):[{hops:e.hops.map(Wr),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function Dr(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:Vr(e,t)}const zr=Vr,Wr=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function Xr(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function Fr(e,t,r){const o=d.TransactionBuilder.fromXDR(t,"base64");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw Xr(r.invokedContractId,e);throw e}}async function Hr(e,t,r){return Fr(e,t.xdr,r)}function jr(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 Qr(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 Kr=e=>{const t=e.startsWith("0x")?e.slice(2):e;if(t.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return Buffer.from(t,"hex")};function Zr(e){const t=new d.Account(e.caller,e.sourceSequence),r=new d.Contract(e.forwarderAddress).call("mint_and_forward",d.xdr.ScVal.scvBytes(Kr(e.message)),d.xdr.ScVal.scvBytes(Kr(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:()=>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})();