@xoxno/sdk-js 1.0.160 → 1.0.162

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