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