@xoxno/sdk-js 1.0.162 → 1.0.169

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