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