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