Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swapkit/api

Package Overview
Dependencies
Maintainers
0
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapkit/api - npm Package Compare versions

Comparing version 0.0.0-nightly-20241017130444 to 0.0.0-nightly-20241104131900

4

dist/index.js

@@ -1,3 +0,3 @@

var fe=Object.defineProperty;var U=(r,t)=>{for(var i in t)fe(r,i,{get:t[i],enumerable:!0,configurable:!0,set:(n)=>t[i]=()=>n})};var k={};U(k,{getTNSChainAddress:()=>Se,getTHORNamesByOwner:()=>Be,getTHORNamesByAddress:()=>Ce,getTHORNameDetails:()=>_,getTHORChainPools:()=>Pe,getLiquidityPositionsRaw:()=>R,getLiquidityPositions:()=>ce});import{AssetValue as S,BaseDecimal as c,RequestClient as $,SwapKitNumber as he}from"@swapkit/helpers";function _(r){return $.get(`${F}/thorname/lookup/${r}`)}function Be(r){return $.get(`${F}/thorname/owner/${r}`)}function Ce(r){return $.get(`${F}/thorname/address/${r}`)}function Pe(r){return $.get(`${F}/pools`,{searchParams:{period:r}})}function R(r){return $.get(`${F}/fullmember?address=${r.join(",")}`)}async function Se({chain:r,tns:t}){return(await _(t))?.entries?.find((n)=>n.chain.toLowerCase()===r.toLowerCase())?.address}async function ce(r){return(await R(r)).map((i)=>({assetRegisteredAddress:i.assetAddress,asset:S.from({asset:i.pool,value:i.assetAdded,fromBaseDecimal:c.THOR}),assetPending:S.from({asset:i.pool,value:i.assetPending,fromBaseDecimal:c.THOR}),assetWithdrawn:S.from({asset:i.pool,value:i.assetWithdrawn,fromBaseDecimal:c.THOR}),runeRegisteredAddress:i.runeAddress,rune:S.from({asset:"THOR.RUNE",value:i.runeAdded,fromBaseDecimal:c.THOR}),runePending:S.from({asset:"THOR.RUNE",value:i.runePending,fromBaseDecimal:c.THOR}),runeWithdrawn:S.from({asset:"THOR.RUNE",value:i.runeWithdrawn,fromBaseDecimal:c.THOR}),poolShare:new he(i.sharedUnits).div(i.poolUnits),dateLastAdded:i.dateLastAdded,dateFirstAdded:i.dateFirstAdded}))}var F="https://mu.thorswap.net";import{AssetValue as l,BaseDecimal as g,Chain as I,RequestClient as D,SwapKitNumber as E}from"@swapkit/helpers";function K(r=!1){return r?`${x}/v2/mayaname`:`${v}/v2/thorname`}function ee(r,t=!1){return D.get(`${t?x:v}/v2/borrower/${r}`)}function re(r,t=!1){return D.get(`${t?x:v}/v2/saver/${r}`)}function te(r,t){return D.get(`${t?x:v}/v2/member/${r}`)}function De(r,t=!1){return D.get(`${K(t)}/lookup/${r}`)}function Ge(r,t=!1){return D.get(`${K(t)}/rlookup/${r}`)}function Te(r,t=!1){return D.get(`${K(t)}/owner/${r}`)}async function Ve(r,t=!1){return(await ee(r,t)).pools.map((n)=>({collateral_deposited:l.from({asset:n.collateral_asset,value:n.collateral_deposited,fromBaseDecimal:g.THOR}),collateral_withdrawn:l.from({asset:n.collateral_asset,value:n.collateral_withdrawn,fromBaseDecimal:g.THOR}),debt_issued_tor:E.fromBigInt(BigInt(n.debt_issued_tor),g.THOR),debt_repaid_tor:E.fromBigInt(BigInt(n.debt_repaid_tor),g.THOR),last_open_loan_timestamp:n.last_open_loan_timestamp,last_repay_loan_timestamp:n.last_repay_loan_timestamp,target_assets:n.target_assets.map((H)=>l.from({asset:H}))}))}async function Ue(r,t=!1){return(await re(r,t)).pools.map((n)=>({assetRegisteredAddress:n.assetAddress,assetAdded:l.from({asset:n.pool,value:n.assetAdded,fromBaseDecimal:g.THOR}),assetDeposit:l.from({asset:n.pool,value:n.assetDeposit,fromBaseDecimal:g.THOR}),assetRedeem:l.from({asset:n.pool,value:n.assetRedeem,fromBaseDecimal:g.THOR}),assetWithdrawn:l.from({asset:n.pool,value:n.assetWithdrawn,fromBaseDecimal:g.THOR}),dateLastAdded:n.dateLastAdded,dateFirstAdded:n.dateFirstAdded}))}async function $e(r,t=!1){return(await te(r,t)).pools.map((n)=>({assetRegisteredAddress:n.assetAddress,asset:l.from({asset:n.pool,value:n.assetAdded,fromBaseDecimal:g.THOR}),assetPending:l.from({asset:n.pool,value:n.assetPending,fromBaseDecimal:g.THOR}),assetWithdrawn:l.from({asset:n.pool,value:n.assetWithdrawn,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}RegisteredAddress`]:n.runeAddress,[`${t?"cacao":"rune"}`]:l.from({asset:"THOR.RUNE",value:n.runeAdded,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}Pending`]:l.from({asset:"THOR.RUNE",value:n.runePending,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}Withdrawn`]:l.from({asset:"THOR.RUNE",value:n.runeWithdrawn,fromBaseDecimal:g.THOR}),poolShare:new E(n.liquidityUnits).div(n.pool),dateLastAdded:n.dateLastAdded,dateFirstAdded:n.dateFirstAdded}))}var v="https://midgard.ninerealms.com",x="https://midgard.mayachain.info",ne=(r)=>({getBorrowerDetail:(t)=>Ve(t,r===I.Maya),getBorrowerDetailRaw:(t)=>ee(t,r===I.Maya),getSaversDetail:(t)=>Ue(t,r===I.Maya),getSaverDetailRaw:(t)=>re(t,r===I.Maya),getLiquidityPosition:(t)=>$e(t,r===I.Maya),getLiquidityPositionRaw:(t)=>te(t,r===I.Maya),getNameDetails:(t)=>De(t,r===I.Maya),getNamesByAddress:(t)=>Ge(t,r===I.Maya),getNamesByOwner:(t)=>Te(t,r===I.Maya)}),se=ne(I.THORChain),oe=ne(I.Maya);var j={};U(j,{getThorchainQueue:()=>Xe,getTNSPreferredAsset:()=>Ye,getTHORNodeTNSDetails:()=>ie,getRunePoolProviderInfo:()=>We,getRunePoolInfo:()=>qe,getNodes:()=>we,getMimirInfo:()=>ve,getLastBlock:()=>ye,getInboundAddresses:()=>xe});import{AssetValue as Fe,RequestClient as h}from"@swapkit/helpers";function B({type:r="thorchain",stagenet:t=!1}={}){switch(r){case"mayachain":return t?"https://stagenet.mayanode.mayachain.info/mayachain":"https://mayanode.mayachain.info/mayachain";default:return t?"https://stagenet-thornode.ninerealms.com/thorchain":"https://thornode.thorswap.net/thorchain"}}function Me({type:r="thorchain",stagenet:t=!1}={}){const i=r==="mayachain"?"mayaname":"thorname";return`${B({type:r,stagenet:t})}/${i}`}function ye(r){return h.get(`${B(r)}/lastblock`)}function Xe(r){return h.get(`${B(r)}/queue`)}function we(r){return h.get(`${B(r)}/nodes`)}function ve(r){return h.get(`${B(r)}/mimir`)}function xe(r){return h.get(`${B(r)}/inbound_addresses`)}function ie(r){return h.get(`${Me(r)}/${r.name}`)}async function Ye(r){const t=await ie({name:r});if(!t.preferred_asset||t.preferred_asset===".")return;return Fe.from({asyncTokenLookup:!0,asset:t.preferred_asset})}function qe(r){return h.get(`${B(r)}/runepool`)}function We(r){return h.get(`${B(r)}/rune_provider/${r.thorAddress}`)}var Q={};U(Q,{getTxnDetails:()=>Re,getTokenListProviders:()=>er,getSwapQuote:()=>Qe,getRepayQuote:()=>Ze,getLoans:()=>Oe,getLendingAssets:()=>ze,getGasRates:()=>_e,getCachedPrices:()=>je,getBorrowQuote:()=>Je,APIV1RequestClient:()=>M});import{RequestClient as G}from"@swapkit/helpers";import{z as C}from"zod";var ke;((o)=>{o.SWAP_TC_TO_TC="SWAP:TC-TC";o.SWAP_ETH_TO_TC="SWAP:ERC20-TC";o.SWAP_TC_TO_ETH="SWAP:TC-ERC20";o.SWAP_ETH_TO_ETH="SWAP:ERC20-ERC20";o.SWAP_AVAX_TO_TC="SWAP:AVAX-TC";o.SWAP_TC_TO_AVAX="SWAP:TC-AVAX";o.SWAP_AVAX_TO_AVAX="SWAP:AVAX-AVAX";o.SWAP_ETH_TO_AVAX="SWAP:ETH-AVAX";o.SWAP_AVAX_TO_ETH="SWAP:AVAX-ETH";o.SWAP_TC_TO_GAIA="SWAP:TC-GAIA";o.SWAP_GAIA_TO_TC="SWAP:GAIA-TC";o.SWAP_TC_TO_BTC="SWAP:TC-BTC";o.SWAP_BTC_TO_TC="SWAP:BTC-TC";o.SWAP_TC_TO_BCH="SWAP:TC-BCH";o.SWAP_BCH_TO_TC="SWAP:BCH-TC";o.SWAP_TC_TO_LTC="SWAP:TC-LTC";o.SWAP_LTC_TO_TC="SWAP:LTC-TC";o.SWAP_TC_TO_DOGE="SWAP:TC-DOGE";o.SWAP_DOGE_TO_TC="SWAP:DOGE-TC";o.TC_STATUS="TC:STATUS";o.TC_TRANSFER="TC:TRANSFER";o.TC_DEPOSIT="TC:DEPOSIT";o.TC_SEND="TC:SEND";o.TC_SWITCH="TC:SWITCH";o.TC_LP_ADD="TC:ADDLIQUIDITY";o.TC_LP_WITHDRAW="TC:WITHDRAW";o.TC_TNS_CREATE="TC:TNS-CREATE";o.TC_TNS_EXTEND="TC:TNS-EXTEND";o.TC_TNS_UPDATE="TC:TNS-UPDATE";o.TC_SAVINGS_ADD="TC:ADDSAVINGS";o.TC_SAVINGS_WITHDRAW="TC:WITHDRAWSAVINGS";o.TC_LENDING_OPEN="TC:LENDINGOPEN";o.TC_LENDING_CLOSE="TC:LENDINGCLOSE";o.ETH_APPROVAL="ETH:APPROVAL";o.ETH_STATUS="ETH:STATUS";o.ETH_TRANSFER_TO_TC="ETH:TRANSFER:IN";o.ETH_TRANSFER_FROM_TC="ETH:TRANSFER:OUT";o.AVAX_APPROVAL="AVAX:APPROVAL";o.AVAX_STATUS="AVAX:STATUS";o.AVAX_TRANSFER_TO_TC="AVAX:TRANSFER:IN";o.AVAX_TRANSFER_FROM_TC="AVAX:TRANSFER:OUT";o.BSC_APPROVAL="BSC:APPROVAL";o.BSC_STATUS="BSC:STATUS";o.BSC_TRANSFER_TO_TC="BSC:TRANSFER:IN";o.BSC_TRANSFER_FROM_TC="BSC:TRANSFER:OUT";o.APPROVAL="APPROVAL";o.STATUS="STATUS";o.TRANSFER_TO_TC="TRANSFER:IN";o.TRANSFER_FROM_TC="TRANSFER:OUT";o.UNSUPPORTED="UNSUPPORTED";o.TC_LENDING="TC:LENDING"})(ke||={});var Ee;((A)=>{A.PENDING="pending";A.SUCCESS="success";A.CANCELLED="cancelled";A.REFUNDED="refunded";A.REPLACED="replaced";A.ERROR="error";A.UNKNOWN="unknown";A.NOT_STARTED="not_started";A.NOT_FOUND="not_found";A.RETRIES_EXCEEDED="retries_exceeded";A.STREAMING="streaming"})(Ee||={});var Ke;((n)=>{n[n.NOT_STARTED=0]="NOT_STARTED";n[n.SUCCESS=1]="SUCCESS";n[n.REFUNDED=2]="REFUNDED"})(Ke||={});var me;((s)=>{s.INVALID_INPUT_PARAMETERS="1000";s.UNKNOWN_PROVIDERS="1001";s.CANNOT_FIND_INBOUND_ADDRESS="1002";s.NO_INBOUND_ADDRESSES="1003";s.CHAIN_HALTED_OR_UNSUPPORTED="1004";s.MISSING_INPUT_PARAMETER="1005";s.INVALID_TYPE_GENERIC="1100";s.INVALID_NUMBER_STRING="1101";s.INVALID_NUMBER="1102";s.INVALID_BOOLEAN="1103";s.INVALID_OBJECT="1104";s.INVALID_ARRAY="1105";s.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER="2000";s.SELL_BUY_ASSETS_ARE_THE_SAME="2001";s.MISSING_SOURCE_ADDRESS_FOR_SYNTH="2002";s.AFF_ADDRESS_AND_BPS_OR_NEITHER="2003";s.AFF_ADDRESS_TOO_LONG="2004";s.AFF_BPS_INTEGER_MAX_500="2005";s.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN="2006";s.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN="2007";s.PREFERRED_PROVIDER_NOT_SUPPORTED="2008";s.DESTINATION_ADDRESS_SMART_CONTRACT="2009";s.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER="2010";s.SOURCE_ADDRESS_SMART_CONTRACT="2011";s.SWAP_AMOUNT_TOO_LOW="2012";s.INVALID_PROVIDER="2100";s.MISSING_CROSS_CHAIN_PROVIDER="2101";s.MISSING_AVAX_PROVIDER="2102";s.MISSING_BSC_PROVIDER="2103";s.MISSING_ETH_PROVIDER="2104";s.INVALID_PROVIDER_FOR_SWAP_OUT="2105";s.MISSING_ARB_PROVIDER="2106";s.INVALID_CHAIN="2200";s.INVALID_ASSET="2201";s.INVALID_ASSET_IDENTIFIER="2202";s.UNSUPPORTED_CHAIN="2204";s.UNSUPPORTED_ASSET="2203";s.UNSUPPORTED_ASSET_FOR_SWAPOUT="2205";s.INVALID_SOURCE_ADDRESS="2300";s.INVALID_DESTINATION_ADDRESS="2301";s.THORNODE_QUOTE_GENERIC_ERROR="3000";s.NOT_ENOUGH_SYNTH_BALANCE="3001";s.SYNTH_MINTING_CAP_REACHED="3002";s.INVALID_QUOTE_MODE="4000";s.NO_QUOTES="4001";s.SERVICE_UNAVAILABLE_GENERIC="5000";s.MISSING_GAS_DATA_GENERIC="5100";s.MISSING_TOKEN_INFO_GENERIC="5200";s.CANT_FIND_TOKEN_LIST="5201";s.NO_PRICE="5202";s.PRICE_IS_STALE="5203";s.ADDRESS_NOT_WHITELISTED="6000";s.ADDRESS_ALREADY_CLAIMED="6001";s.TEMPORARY_ERROR="9999"})(me||={});var ue;((m)=>{m.HEALTH_CONTROLLER="1000";m.LIQUIDITY_CONTROLLER="1001";m.PROVIDER_CONTROLLER="1002";m.QUOTE_CONTROLLER="1003";m.SWAP_CONTROLLER="1004";m.UTIL_CONTROLLER="1005";m.AIRDROP_CONTROLLER="1006";m.PROVIDER="2000";m.ASSET="2001";m.TOKEN_LIST="2002";m.QUOTE="2100";m.QUOTE_TXN_DETAILS="2101";m.THORCHAIN_PROVIDER="3000";m.UNISWAPV2_ETH_PROVIDER="3001";m.UNISWAPV3_ETH_PROVIDER="3002";m.SUSHISWAP_ETH_PROVIDER="3003";m.PANCAKESWAP_BSC_PROVIDER="3004";m.PANCAKESWAP_ETH_PROVIDER="3005";m.ONEINCH_ETH_PROVIDER="3006";m.ONEINCH_BSC_PROVIDER="3007";m.ONEINCH_AVAX_PROVIDER="3008";m.ZEROX_ETH_PROVIDER="3009";m.WOOFI_AVAX_PROVIDER="3010";m.PANGOLIN_AVAX_PROVIDER="3011";m.TRADERJOE_AVAX_PROVIDER="3012";m.KYBER_ETH_PROVIDER="3013";m.KYBER_AVAX_PROVIDER="3014";m.WOOFI_BSC_PROVIDER="3015";m.STARGATE_PROVIDER="3016";m.PROVIDER_UTIL="4000";m.TXN_DETAILS="5000";m.AIRDROP_UTIL="6000"})(ue||={});var de;((N)=>{N.VALIDATION_ERROR="VALIDATION_ERROR";N.REQUEST_PARAMETER_ERROR="REQUEST_PARAMETER_ERROR";N.RESPONSE_PARSING_ERROR="RESPONSE_PARSING_ERROR";N.UNSUPPORTED="UNSUPPORTED";N.NOT_IMPLEMENTED="NOT_IMPLEMENTED";N.INCOMPATIBLE_ASSETS_OPERATIONS="INCOMPATIBLE_ASSETS_OPERATIONS";N.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE";N.DOWN_FOR_MAINTENANCE="DOWN_FOR_MAINTENANCE";N.MISSING_INBOUND_INFO="MISSING_INBOUND_INFO";N.QUOTE_FETCHING_ERROR="QUOTE_FETCHING_ERROR";N.AIRDROP_ERROR="AIRDROP_ERROR";N.UNHANDLED_ERROR="UNHANDLED_ERROR"})(de||={});var Ae=C.object({status:C.number(),type:C.nativeEnum(de),code:C.nativeEnum(me),module:C.nativeEnum(ue),complete:C.string(),identifier:C.string(),message:C.string()});function je({tokens:r,...t}){const i=new URLSearchParams,n=r.filter((H,p,W)=>W.findIndex((u)=>u===H)===p);for(let H of n)i.append("tokens",JSON.stringify(H));if(t.metadata)i.append("metadata","true");if(t.lookup)i.append("lookup","true");if(t.sparkline)i.append("sparkline","true");return M.post(`${L}/tokenlist/cached-price`,{body:i.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}})}function Qe(r){return M.get(`${L}/aggregator/tokens/quote`,{searchParams:r})}function Je(r){return M.get(`${L}/aggregator/lending/borrow`,{searchParams:r})}function Ze(r){return M.get(`${L}/aggregator/lending/repay`,{searchParams:r})}function ze(){return G.get(`${L}/aggregator/lending/assets`)}function Oe(r){return G.get(`${L}/aggregator/lending/loans`,{searchParams:r})}function _e(){return G.get(`${L}/resource-worker/gasPrice/getAll`)}function Re(r){return G.get(`${L}/apiusage/v2/txn`,{searchParams:{txHash:r}})}function er(){return G.get(`${L}/tokenlist/providers`)}var L="https://api.thorswap.finance",M=G.extend({responseHandler:(r)=>{try{return Ae.parse(r)}catch(t){return r}}});var Z={};U(Z,{getTrackerDetails:()=>fr,getTokenTradingPairs:()=>Cr,getTokenListV2:()=>Le,getTokenListProvidersV2:()=>J,getSwapQuoteV2:()=>hr,getPrice:()=>Br});import{ProviderName as b,RequestClient as y,SwapKitError as q}from"@swapkit/helpers";import{Chain as rr,ChainId as tr,FeeTypeEnum as nr,ProviderName as V,WarningCodeEnum as sr}from"@swapkit/helpers";import{z as e}from"zod";var ae;((a)=>{a.native_send="native_send";a.token_transfer="token_transfer";a.native_contract_call="native_contract_call";a.token_contract_call="token_contract_call";a.approve="approve";a.deposit="deposit";a.thorname_action="thorname_action";a.lp_action="lp_action";a.swap="swap";a.streaming_swap="streaming_swap";a.stake="stake";a.claim="claim";a.lending="lending";a.unknown="unknown"})(ae||={});var ge;((p)=>{p.unknown="unknown";p.not_started="not_started";p.pending="pending";p.swappping="swapping";p.completed="completed"})(ge||={});var le;((d)=>{d.not_started="not_started";d.starting="starting";d.broadcasted="broadcasted";d.mempool="mempool";d.inbound="inbound";d.outbound="outbound";d.swapping="swapping";d.completed="completed";d.refunded="refunded";d.partially_refunded="partially_refunded";d.dropped="dropped";d.reverted="reverted";d.replaced="replaced";d.retries_exceeded="retries_exceeded";d.parsing_error="parsing_error"})(le||={});var Wr=e.object({error:e.string(),message:e.string()}),T=e.object({chain:e.nativeEnum(rr),symbol:e.string(),ticker:e.string(),decimal:e.optional(e.number()),address:e.optional(e.string()),isGasAsset:e.boolean(),isSynthetic:e.boolean(),tax:e.optional(e.object({buy:e.number(),sell:e.number()}))}),or=e.object({name:e.string(),id:e.string(),market_cap:e.number(),total_volume:e.number(),price_change_24h_usd:e.number(),price_change_percentage_24h_usd:e.number(),timestamp:e.string(),sparkline_in_7d:e.array(e.number())}),be=e.array(e.object({identifier:e.string(),provider:e.string(),cg:or.optional(),price_usd:e.number(),timestamp:e.number()}).partial()),kr=e.object({sellAsset:e.string({description:"Asset to sell"}),buyAsset:e.string({description:"Asset to buy"}),sellAmount:e.string({description:"Amount of asset to sell"}).refine((r)=>+r>0,{message:"sellAmount must be greater than 0",path:["sellAmount"]}),providers:e.optional(e.array(e.string({description:"List of providers to use"}).refine((r)=>{return V[r]!==void 0},{message:"Invalid provider",path:["providers"]}))),sourceAddress:e.optional(e.string({description:"Address to send asset from"})),destinationAddress:e.optional(e.string({description:"Address to send asset to"})),slippage:e.optional(e.number({description:"Slippage tolerance as a percentage. Default is 3%."})),affiliate:e.optional(e.string({description:"Affiliate thorname"})),affiliateFee:e.optional(e.number({description:"Affiliate fee in basis points"}).refine((r)=>{return r===Math.floor(r)&&r>=0},{message:"affiliateFee must be a positive integer",path:["affiliateFee"]})),allowSmartContractSender:e.optional(e.boolean({description:"Allow smart contract as sender"})),allowSmartContractReceiver:e.optional(e.boolean({description:"Allow smart contract as recipient"})),disableSecurityChecks:e.optional(e.boolean({description:"Disable security checks"})),includeTx:e.optional(e.boolean({description:"Set to true to include an transaction object (EVM only)"}))}).refine((r)=>r.sellAsset!==r.buyAsset,{message:"Must be different",path:["sellAsset","buyAsset"]}),Er=e.object({tokens:e.array(e.object({identifier:e.string()})),metadata:e.boolean()}),ir=e.object({evmCalldata:e.optional(e.string()),logs:e.optional(e.unknown()),memo:e.optional(e.string()),spender:e.optional(e.string())}),mr=e.object({estimatedfinalisedAt:e.number(),estimatedTimeToComplete:e.number(),updatedAt:e.number(),currentLegIndex:e.optional(e.number()),providerDetails:e.optional(e.unknown())}),ur=e.object({network:e.optional(T),affiliate:e.optional(T),liquidity:e.optional(T),protocol:e.optional(T),tax:e.optional(T)}),dr=e.object({broadcastedAt:e.optional(e.number()),wallet:e.optional(e.string()),quoteId:e.optional(e.string()),explorerUrl:e.optional(e.string()),affiliate:e.optional(e.string()),fees:e.optional(ur),provider:e.optional(e.nativeEnum(V)),images:e.optional(e.object({from:e.optional(e.string()),to:e.optional(e.string()),provider:e.optional(e.string()),chain:e.optional(e.string())}))}),Y=e.object({chainId:e.nativeEnum(tr),hash:e.string(),block:e.number(),type:e.nativeEnum(ae),status:e.nativeEnum(ge),trackingStatus:e.optional(e.nativeEnum(le)),fromAsset:e.string(),fromAmount:e.string(),fromAddress:e.string(),toAsset:e.string(),toAmount:e.string(),toAddress:e.string(),finalAsset:e.optional(T),finalAddress:e.optional(e.string()),finalisedAt:e.number(),transient:e.optional(mr),meta:e.optional(dr),payload:e.optional(ir)}),Kr=Y.extend({legs:e.array(Y)}),jr=Y.extend({legs:e.array(Y)}),Ne=e.array(e.object({type:e.nativeEnum(nr),amount:e.string(),asset:e.string(),chain:e.string(),protocol:e.nativeEnum(V)})),Ie=e.object({inbound:e.optional(e.number({description:"Time to receive inbound asset in seconds"})),swap:e.optional(e.number({description:"Time to swap assets in seconds"})),outbound:e.optional(e.number({description:"Time to receive outbound asset in seconds"})),total:e.number({description:"Total time in seconds"})}),Ar=e.object({to:e.string({description:"Address of the recipient"}),from:e.string({description:"Address of the sender"}),value:e.string({description:"Value to send"}),data:e.string({description:"Data to send"})}),ar=e.array(e.union([e.string(),e.number(),e.array(e.string()),e.object({from:e.string(),value:e.string()}).describe("Parameters to pass to the contract method")])),Qr=e.object({contractAddress:e.string({description:"Address of the contract to interact with"}),contractMethod:e.string({description:"Name of the method to call"}),contractParams:ar,contractParamNames:e.array(e.string({description:"Names of the parameters to pass to the contract method"})),approvalToken:e.optional(e.string({description:"Address of the token to approve spending of"})),approvalSpender:e.optional(e.string({description:"Address of the spender to approve"}))}),gr=e.object({sellAsset:e.string({description:"Asset to sell"}),buyAsset:e.string({description:"Asset to buy"}),provider:e.nativeEnum(V),sourceAddress:e.string({description:"Source address"}),destinationAddress:e.string({description:"Destination address"}),estimatedTime:Ie.optional(),affiliate:e.string({description:"Affiliate address"}).optional(),affiliateFee:e.number({description:"Affiliate fee"}).optional(),slipPercentage:e.number({description:"Slippage as a percentage"})}),Jr=gr.omit({sourceAddress:!0,destinationAddress:!0,slipPercentage:!0}),lr=e.object({asset:e.string({description:"Asset name"}),price:e.number({description:"Price in USD"}),image:e.string({description:"Asset image"})}),br=e.object({priceImpact:e.optional(e.number({description:"Price impact"})),assets:e.optional(e.array(lr)),approvalAddress:e.optional(e.string({description:"Approval address for swap"})),streamingInterval:e.number().optional(),maxStreamingQuantity:e.number().optional()}),Nr=e.array(e.object({code:e.nativeEnum(sr),display:e.string(),tooltip:e.string().optional()})),Ir=e.object({provider:e.nativeEnum(V),sellAsset:e.string({description:"Asset to sell"}),sellAmount:e.string({description:"Sell amount"}),buyAsset:e.string({description:"Asset to buy"}),buyAmount:e.string({description:"Buy amount"}),buyAmountMaxSlippage:e.string({description:"Buy amount max slippage"}),fees:e.optional(Ne)}),pr=e.object({providers:e.array(e.nativeEnum(V)),sellAsset:e.string({description:"Asset to sell"}),sellAmount:e.string({description:"Sell amount"}),buyAsset:e.string({description:"Asset to buy"}),expectedBuyAmount:e.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:e.string({description:"Expected Buy amount max slippage"}),sourceAddress:e.string({description:"Source address"}),destinationAddress:e.string({description:"Destination address"}),targetAddress:e.optional(e.string({description:"Target address"})),inboundAddress:e.optional(e.string({description:"Inbound address"})),expiration:e.optional(e.string({description:"Expiration"})),memo:e.optional(e.string({description:"Memo"})),fees:Ne,tx:e.optional(Ar),transaction:e.optional(e.unknown()),estimatedTime:e.optional(Ie),totalSlippageBps:e.number({description:"Total slippage in bps"}),legs:e.array(Ir),warnings:Nr,meta:br}),pe=e.object({quoteId:e.string({description:"Quote ID"}),routes:e.array(pr),error:e.optional(e.string({description:"Error message"}))});function X(r){return r?Hr:Lr}function fr(r){return y.post(`${X()}/track`,{json:r})}async function hr(r,t){const i=await y.post(`${X(t)}/quote`,{json:r});if(i.error)throw new q("api_v2_server_error",{message:i.error});try{const n=pe.safeParse(i);if(!n.success)throw new q("api_v2_invalid_response",n.error);return n.data}catch(n){return console.warn(n),i}}function J(r=!1){return y.get(`${X(r)}/providers`)}function Le(r,t=!1){return y.get(`${X(t)}/tokens?provider=${r}`)}async function Br(r,t=!1){const i=await y.post(`${X(t)}/price`,{json:r});try{const n=be.safeParse(i);if(!n.success)throw new q("api_v2_invalid_response",n.error);return n.data}catch(n){throw new q("api_v2_invalid_response",n)}}async function Cr(r,t=!1){const i=new Map;if(!r.length)return i;const n=r.map(async(u)=>{return await Le(u,t)}),H=(await Promise.all(n)).filter((u)=>!!u).map(({tokens:u,...f})=>({data:{...f||{},tokens:u.map(({address:P,...w})=>({...w,...P&&["resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].includes(P.toLowerCase())?{}:{address:P}}))},...f})),p=[b.CAVIAR_V1,b.CHAINFLIP,b.MAYACHAIN,b.MAYACHAIN_STREAMING],W=H.filter(({data:u})=>{return!p.includes(u?.provider||"")}).reduce((u,{data:f})=>f?.tokens?u.concat(f.tokens):u,[]);for(let{data:u}of H){if(!u?.tokens)return;const f=u.provider&&!p.includes(u.provider);for(let P of u.tokens){const w=i.get(P.identifier.toLowerCase())||{tokens:[],providers:[]},A=f?{tokens:W,providers:[b.THORCHAIN,b.THORCHAIN_STREAMING,b.PANCAKESWAP,b.ONEINCH,b.PANGOLIN_V1,b.SUSHISWAP_V2,b.TRADERJOE_V2,b.UNISWAP_V3,b.UNISWAP_V2]}:{tokens:u.tokens,providers:u.provider};i.set(P.identifier.toLowerCase(),{tokens:w.tokens.concat(A.tokens),providers:w.providers.concat(A.providers)})}}return i}var Lr="https://api.swapkit.dev",Hr="https://dev-api.swapkit.dev";var O={};U(O,{getTokenList:()=>Dr,getProviderLogo:()=>Vr,getLogoForAsset:()=>Gr,getChainLogoForAsset:()=>Tr});import{AssetValue as Pr,RequestClient as Sr,getChainIdentifier as cr}from"@swapkit/helpers";function Dr(r){return Sr.get(`${z}/token-list/${r}.json`)}function Gr(r){return`${z}/token-list/images/${r.toLowerCase()}.png`}function Tr(r){const{chain:t}=Pr.from({asset:r}),i=cr(t).toLowerCase();return`${z}/token-list/images/${i}.png`}async function Vr(r){return He||=await J(),He.find((t)=>t.name===r)?.url}var z="https://static.thorswap.net",He;var rt={...k,...j,...Q,...Z,...O,thorchainMidgard:se,mayachainMidgard:oe};export{ae as TxnType,ge as TxnStatus,Ee as TxStatus,ke as TransactionType,Kr as TransactionSchema,jr as TransactionDTOSchema,le as TrackingStatus,or as TokenDetailsMetadataSchema,rt as SwapKitApi,Ke as StreamingSwapProgressStatus,Nr as RouteQuoteWarningSchema,br as RouteQuoteMetadataSchema,lr as RouteQuoteMetadataAssetSchema,Jr as RouteLegWithoutAddressesSchema,gr as RouteLegSchema,pe as QuoteResponseSchema,kr as QuoteRequestSchema,be as PriceResponseSchema,Er as PriceRequestSchema,Ne as FeesSchema,Ie as EstimatedTimeSchema,Ar as EVMTransactionSchema,Qr as EVMTransactionDetailsSchema,ar as EVMTransactionDetailsParamsSchema,de as ERROR_TYPE,ue as ERROR_MODULE,me as ERROR_CODE,T as AssetValueSchema,Wr as ApiV2ErrorSchema,Ae as ApiV1ErrorSchema};
var fe=Object.defineProperty;var U=(r,t)=>{for(var i in t)fe(r,i,{get:t[i],enumerable:!0,configurable:!0,set:(n)=>t[i]=()=>n})};var k={};U(k,{getTNSChainAddress:()=>Se,getTHORNamesByOwner:()=>Be,getTHORNamesByAddress:()=>Ce,getTHORNameDetails:()=>_,getTHORChainPools:()=>Pe,getLiquidityPositionsRaw:()=>R,getLiquidityPositions:()=>ce});import{AssetValue as S,BaseDecimal as c,RequestClient as $,SwapKitNumber as he}from"@swapkit/helpers";var F="https://mu.thorswap.net";function _(r){return $.get(`${F}/thorname/lookup/${r}`)}function Be(r){return $.get(`${F}/thorname/owner/${r}`)}function Ce(r){return $.get(`${F}/thorname/address/${r}`)}function Pe(r){return $.get(`${F}/pools`,{searchParams:{period:r}})}function R(r){return $.get(`${F}/fullmember?address=${r.join(",")}`)}async function Se({chain:r,tns:t}){return(await _(t))?.entries?.find((n)=>n.chain.toLowerCase()===r.toLowerCase())?.address}async function ce(r){return(await R(r)).map((i)=>({assetRegisteredAddress:i.assetAddress,asset:S.from({asset:i.pool,value:i.assetAdded,fromBaseDecimal:c.THOR}),assetPending:S.from({asset:i.pool,value:i.assetPending,fromBaseDecimal:c.THOR}),assetWithdrawn:S.from({asset:i.pool,value:i.assetWithdrawn,fromBaseDecimal:c.THOR}),runeRegisteredAddress:i.runeAddress,rune:S.from({asset:"THOR.RUNE",value:i.runeAdded,fromBaseDecimal:c.THOR}),runePending:S.from({asset:"THOR.RUNE",value:i.runePending,fromBaseDecimal:c.THOR}),runeWithdrawn:S.from({asset:"THOR.RUNE",value:i.runeWithdrawn,fromBaseDecimal:c.THOR}),poolShare:new he(i.sharedUnits).div(i.poolUnits),dateLastAdded:i.dateLastAdded,dateFirstAdded:i.dateFirstAdded}))}import{AssetValue as l,BaseDecimal as g,Chain as I,RequestClient as D,SwapKitNumber as E}from"@swapkit/helpers";var v="https://midgard.ninerealms.com",x="https://midgard.mayachain.info";function K(r=!1){return r?`${x}/v2/mayaname`:`${v}/v2/thorname`}function ee(r,t=!1){return D.get(`${t?x:v}/v2/borrower/${r}`)}function re(r,t=!1){return D.get(`${t?x:v}/v2/saver/${r}`)}function te(r,t){return D.get(`${t?x:v}/v2/member/${r}`)}function De(r,t=!1){return D.get(`${K(t)}/lookup/${r}`)}function Ge(r,t=!1){return D.get(`${K(t)}/rlookup/${r}`)}function Te(r,t=!1){return D.get(`${K(t)}/owner/${r}`)}async function Ve(r,t=!1){return(await ee(r,t)).pools.map((n)=>({collateral_deposited:l.from({asset:n.collateral_asset,value:n.collateral_deposited,fromBaseDecimal:g.THOR}),collateral_withdrawn:l.from({asset:n.collateral_asset,value:n.collateral_withdrawn,fromBaseDecimal:g.THOR}),debt_issued_tor:E.fromBigInt(BigInt(n.debt_issued_tor),g.THOR),debt_repaid_tor:E.fromBigInt(BigInt(n.debt_repaid_tor),g.THOR),last_open_loan_timestamp:n.last_open_loan_timestamp,last_repay_loan_timestamp:n.last_repay_loan_timestamp,target_assets:n.target_assets.map((H)=>l.from({asset:H}))}))}async function Ue(r,t=!1){return(await re(r,t)).pools.map((n)=>({assetRegisteredAddress:n.assetAddress,assetAdded:l.from({asset:n.pool,value:n.assetAdded,fromBaseDecimal:g.THOR}),assetDeposit:l.from({asset:n.pool,value:n.assetDeposit,fromBaseDecimal:g.THOR}),assetRedeem:l.from({asset:n.pool,value:n.assetRedeem,fromBaseDecimal:g.THOR}),assetWithdrawn:l.from({asset:n.pool,value:n.assetWithdrawn,fromBaseDecimal:g.THOR}),dateLastAdded:n.dateLastAdded,dateFirstAdded:n.dateFirstAdded}))}async function $e(r,t=!1){return(await te(r,t)).pools.map((n)=>({assetRegisteredAddress:n.assetAddress,asset:l.from({asset:n.pool,value:n.assetAdded,fromBaseDecimal:g.THOR}),assetPending:l.from({asset:n.pool,value:n.assetPending,fromBaseDecimal:g.THOR}),assetWithdrawn:l.from({asset:n.pool,value:n.assetWithdrawn,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}RegisteredAddress`]:n.runeAddress,[`${t?"cacao":"rune"}`]:l.from({asset:"THOR.RUNE",value:n.runeAdded,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}Pending`]:l.from({asset:"THOR.RUNE",value:n.runePending,fromBaseDecimal:g.THOR}),[`${t?"cacao":"rune"}Withdrawn`]:l.from({asset:"THOR.RUNE",value:n.runeWithdrawn,fromBaseDecimal:g.THOR}),poolShare:new E(n.liquidityUnits).div(n.pool),dateLastAdded:n.dateLastAdded,dateFirstAdded:n.dateFirstAdded}))}var ne=(r)=>({getBorrowerDetail:(t)=>Ve(t,r===I.Maya),getBorrowerDetailRaw:(t)=>ee(t,r===I.Maya),getSaversDetail:(t)=>Ue(t,r===I.Maya),getSaverDetailRaw:(t)=>re(t,r===I.Maya),getLiquidityPosition:(t)=>$e(t,r===I.Maya),getLiquidityPositionRaw:(t)=>te(t,r===I.Maya),getNameDetails:(t)=>De(t,r===I.Maya),getNamesByAddress:(t)=>Ge(t,r===I.Maya),getNamesByOwner:(t)=>Te(t,r===I.Maya)}),se=ne(I.THORChain),oe=ne(I.Maya);var j={};U(j,{getThorchainQueue:()=>Xe,getTNSPreferredAsset:()=>Ye,getTHORNodeTNSDetails:()=>ie,getRunePoolProviderInfo:()=>We,getRunePoolInfo:()=>qe,getNodes:()=>we,getMimirInfo:()=>ve,getLastBlock:()=>ye,getInboundAddresses:()=>xe});import{AssetValue as Fe,RequestClient as h}from"@swapkit/helpers";function B({type:r="thorchain",stagenet:t=!1}={}){switch(r){case"mayachain":return t?"https://stagenet.mayanode.mayachain.info/mayachain":"https://mayanode.mayachain.info/mayachain";default:return t?"https://stagenet-thornode.ninerealms.com/thorchain":"https://thornode.thorswap.net/thorchain"}}function Me({type:r="thorchain",stagenet:t=!1}={}){let i=r==="mayachain"?"mayaname":"thorname";return`${B({type:r,stagenet:t})}/${i}`}function ye(r){return h.get(`${B(r)}/lastblock`)}function Xe(r){return h.get(`${B(r)}/queue`)}function we(r){return h.get(`${B(r)}/nodes`)}function ve(r){return h.get(`${B(r)}/mimir`)}function xe(r){return h.get(`${B(r)}/inbound_addresses`)}function ie(r){return h.get(`${Me(r)}/${r.name}`)}async function Ye(r){let t=await ie({name:r});if(!t.preferred_asset||t.preferred_asset===".")return;return Fe.from({asyncTokenLookup:!0,asset:t.preferred_asset})}function qe(r){return h.get(`${B(r)}/runepool`)}function We(r){return h.get(`${B(r)}/rune_provider/${r.thorAddress}`)}var Q={};U(Q,{getTxnDetails:()=>Re,getTokenListProviders:()=>er,getSwapQuote:()=>Qe,getRepayQuote:()=>Ze,getLoans:()=>Oe,getLendingAssets:()=>ze,getGasRates:()=>_e,getCachedPrices:()=>je,getBorrowQuote:()=>Je,APIV1RequestClient:()=>M});import{RequestClient as G}from"@swapkit/helpers";import{z as C}from"zod";var ke;((o)=>{o.SWAP_TC_TO_TC="SWAP:TC-TC";o.SWAP_ETH_TO_TC="SWAP:ERC20-TC";o.SWAP_TC_TO_ETH="SWAP:TC-ERC20";o.SWAP_ETH_TO_ETH="SWAP:ERC20-ERC20";o.SWAP_AVAX_TO_TC="SWAP:AVAX-TC";o.SWAP_TC_TO_AVAX="SWAP:TC-AVAX";o.SWAP_AVAX_TO_AVAX="SWAP:AVAX-AVAX";o.SWAP_ETH_TO_AVAX="SWAP:ETH-AVAX";o.SWAP_AVAX_TO_ETH="SWAP:AVAX-ETH";o.SWAP_TC_TO_GAIA="SWAP:TC-GAIA";o.SWAP_GAIA_TO_TC="SWAP:GAIA-TC";o.SWAP_TC_TO_BTC="SWAP:TC-BTC";o.SWAP_BTC_TO_TC="SWAP:BTC-TC";o.SWAP_TC_TO_BCH="SWAP:TC-BCH";o.SWAP_BCH_TO_TC="SWAP:BCH-TC";o.SWAP_TC_TO_LTC="SWAP:TC-LTC";o.SWAP_LTC_TO_TC="SWAP:LTC-TC";o.SWAP_TC_TO_DOGE="SWAP:TC-DOGE";o.SWAP_DOGE_TO_TC="SWAP:DOGE-TC";o.TC_STATUS="TC:STATUS";o.TC_TRANSFER="TC:TRANSFER";o.TC_DEPOSIT="TC:DEPOSIT";o.TC_SEND="TC:SEND";o.TC_SWITCH="TC:SWITCH";o.TC_LP_ADD="TC:ADDLIQUIDITY";o.TC_LP_WITHDRAW="TC:WITHDRAW";o.TC_TNS_CREATE="TC:TNS-CREATE";o.TC_TNS_EXTEND="TC:TNS-EXTEND";o.TC_TNS_UPDATE="TC:TNS-UPDATE";o.TC_SAVINGS_ADD="TC:ADDSAVINGS";o.TC_SAVINGS_WITHDRAW="TC:WITHDRAWSAVINGS";o.TC_LENDING_OPEN="TC:LENDINGOPEN";o.TC_LENDING_CLOSE="TC:LENDINGCLOSE";o.ETH_APPROVAL="ETH:APPROVAL";o.ETH_STATUS="ETH:STATUS";o.ETH_TRANSFER_TO_TC="ETH:TRANSFER:IN";o.ETH_TRANSFER_FROM_TC="ETH:TRANSFER:OUT";o.AVAX_APPROVAL="AVAX:APPROVAL";o.AVAX_STATUS="AVAX:STATUS";o.AVAX_TRANSFER_TO_TC="AVAX:TRANSFER:IN";o.AVAX_TRANSFER_FROM_TC="AVAX:TRANSFER:OUT";o.BSC_APPROVAL="BSC:APPROVAL";o.BSC_STATUS="BSC:STATUS";o.BSC_TRANSFER_TO_TC="BSC:TRANSFER:IN";o.BSC_TRANSFER_FROM_TC="BSC:TRANSFER:OUT";o.APPROVAL="APPROVAL";o.STATUS="STATUS";o.TRANSFER_TO_TC="TRANSFER:IN";o.TRANSFER_FROM_TC="TRANSFER:OUT";o.UNSUPPORTED="UNSUPPORTED";o.TC_LENDING="TC:LENDING"})(ke||={});var Ee;((A)=>{A.PENDING="pending";A.SUCCESS="success";A.CANCELLED="cancelled";A.REFUNDED="refunded";A.REPLACED="replaced";A.ERROR="error";A.UNKNOWN="unknown";A.NOT_STARTED="not_started";A.NOT_FOUND="not_found";A.RETRIES_EXCEEDED="retries_exceeded";A.STREAMING="streaming"})(Ee||={});var Ke;((n)=>{n[n.NOT_STARTED=0]="NOT_STARTED";n[n.SUCCESS=1]="SUCCESS";n[n.REFUNDED=2]="REFUNDED"})(Ke||={});var me;((s)=>{s.INVALID_INPUT_PARAMETERS="1000";s.UNKNOWN_PROVIDERS="1001";s.CANNOT_FIND_INBOUND_ADDRESS="1002";s.NO_INBOUND_ADDRESSES="1003";s.CHAIN_HALTED_OR_UNSUPPORTED="1004";s.MISSING_INPUT_PARAMETER="1005";s.INVALID_TYPE_GENERIC="1100";s.INVALID_NUMBER_STRING="1101";s.INVALID_NUMBER="1102";s.INVALID_BOOLEAN="1103";s.INVALID_OBJECT="1104";s.INVALID_ARRAY="1105";s.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER="2000";s.SELL_BUY_ASSETS_ARE_THE_SAME="2001";s.MISSING_SOURCE_ADDRESS_FOR_SYNTH="2002";s.AFF_ADDRESS_AND_BPS_OR_NEITHER="2003";s.AFF_ADDRESS_TOO_LONG="2004";s.AFF_BPS_INTEGER_MAX_500="2005";s.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN="2006";s.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN="2007";s.PREFERRED_PROVIDER_NOT_SUPPORTED="2008";s.DESTINATION_ADDRESS_SMART_CONTRACT="2009";s.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER="2010";s.SOURCE_ADDRESS_SMART_CONTRACT="2011";s.SWAP_AMOUNT_TOO_LOW="2012";s.INVALID_PROVIDER="2100";s.MISSING_CROSS_CHAIN_PROVIDER="2101";s.MISSING_AVAX_PROVIDER="2102";s.MISSING_BSC_PROVIDER="2103";s.MISSING_ETH_PROVIDER="2104";s.INVALID_PROVIDER_FOR_SWAP_OUT="2105";s.MISSING_ARB_PROVIDER="2106";s.INVALID_CHAIN="2200";s.INVALID_ASSET="2201";s.INVALID_ASSET_IDENTIFIER="2202";s.UNSUPPORTED_CHAIN="2204";s.UNSUPPORTED_ASSET="2203";s.UNSUPPORTED_ASSET_FOR_SWAPOUT="2205";s.INVALID_SOURCE_ADDRESS="2300";s.INVALID_DESTINATION_ADDRESS="2301";s.THORNODE_QUOTE_GENERIC_ERROR="3000";s.NOT_ENOUGH_SYNTH_BALANCE="3001";s.SYNTH_MINTING_CAP_REACHED="3002";s.INVALID_QUOTE_MODE="4000";s.NO_QUOTES="4001";s.SERVICE_UNAVAILABLE_GENERIC="5000";s.MISSING_GAS_DATA_GENERIC="5100";s.MISSING_TOKEN_INFO_GENERIC="5200";s.CANT_FIND_TOKEN_LIST="5201";s.NO_PRICE="5202";s.PRICE_IS_STALE="5203";s.ADDRESS_NOT_WHITELISTED="6000";s.ADDRESS_ALREADY_CLAIMED="6001";s.TEMPORARY_ERROR="9999"})(me||={});var ue;((m)=>{m.HEALTH_CONTROLLER="1000";m.LIQUIDITY_CONTROLLER="1001";m.PROVIDER_CONTROLLER="1002";m.QUOTE_CONTROLLER="1003";m.SWAP_CONTROLLER="1004";m.UTIL_CONTROLLER="1005";m.AIRDROP_CONTROLLER="1006";m.PROVIDER="2000";m.ASSET="2001";m.TOKEN_LIST="2002";m.QUOTE="2100";m.QUOTE_TXN_DETAILS="2101";m.THORCHAIN_PROVIDER="3000";m.UNISWAPV2_ETH_PROVIDER="3001";m.UNISWAPV3_ETH_PROVIDER="3002";m.SUSHISWAP_ETH_PROVIDER="3003";m.PANCAKESWAP_BSC_PROVIDER="3004";m.PANCAKESWAP_ETH_PROVIDER="3005";m.ONEINCH_ETH_PROVIDER="3006";m.ONEINCH_BSC_PROVIDER="3007";m.ONEINCH_AVAX_PROVIDER="3008";m.ZEROX_ETH_PROVIDER="3009";m.WOOFI_AVAX_PROVIDER="3010";m.PANGOLIN_AVAX_PROVIDER="3011";m.TRADERJOE_AVAX_PROVIDER="3012";m.KYBER_ETH_PROVIDER="3013";m.KYBER_AVAX_PROVIDER="3014";m.WOOFI_BSC_PROVIDER="3015";m.STARGATE_PROVIDER="3016";m.PROVIDER_UTIL="4000";m.TXN_DETAILS="5000";m.AIRDROP_UTIL="6000"})(ue||={});var de;((N)=>{N.VALIDATION_ERROR="VALIDATION_ERROR";N.REQUEST_PARAMETER_ERROR="REQUEST_PARAMETER_ERROR";N.RESPONSE_PARSING_ERROR="RESPONSE_PARSING_ERROR";N.UNSUPPORTED="UNSUPPORTED";N.NOT_IMPLEMENTED="NOT_IMPLEMENTED";N.INCOMPATIBLE_ASSETS_OPERATIONS="INCOMPATIBLE_ASSETS_OPERATIONS";N.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE";N.DOWN_FOR_MAINTENANCE="DOWN_FOR_MAINTENANCE";N.MISSING_INBOUND_INFO="MISSING_INBOUND_INFO";N.QUOTE_FETCHING_ERROR="QUOTE_FETCHING_ERROR";N.AIRDROP_ERROR="AIRDROP_ERROR";N.UNHANDLED_ERROR="UNHANDLED_ERROR"})(de||={});var Ae=C.object({status:C.number(),type:C.nativeEnum(de),code:C.nativeEnum(me),module:C.nativeEnum(ue),complete:C.string(),identifier:C.string(),message:C.string()});var L="https://api.thorswap.finance",M=G.extend({responseHandler:(r)=>{try{return Ae.parse(r)}catch(t){return r}}});function je({tokens:r,...t}){let i=new URLSearchParams,n=r.filter((H,p,W)=>W.findIndex((u)=>u===H)===p);for(let H of n)i.append("tokens",JSON.stringify(H));if(t.metadata)i.append("metadata","true");if(t.lookup)i.append("lookup","true");if(t.sparkline)i.append("sparkline","true");return M.post(`${L}/tokenlist/cached-price`,{body:i.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}})}function Qe(r){return M.get(`${L}/aggregator/tokens/quote`,{searchParams:r})}function Je(r){return M.get(`${L}/aggregator/lending/borrow`,{searchParams:r})}function Ze(r){return M.get(`${L}/aggregator/lending/repay`,{searchParams:r})}function ze(){return G.get(`${L}/aggregator/lending/assets`)}function Oe(r){return G.get(`${L}/aggregator/lending/loans`,{searchParams:r})}function _e(){return G.get(`${L}/resource-worker/gasPrice/getAll`)}function Re(r){return G.get(`${L}/apiusage/v2/txn`,{searchParams:{txHash:r}})}function er(){return G.get(`${L}/tokenlist/providers`)}var Z={};U(Z,{getTrackerDetails:()=>fr,getTokenTradingPairs:()=>Cr,getTokenListV2:()=>Le,getTokenListProvidersV2:()=>J,getSwapQuoteV2:()=>hr,getPrice:()=>Br});import{ProviderName as b,RequestClient as y,SwapKitError as q}from"@swapkit/helpers";import{Chain as rr,ChainId as tr,FeeTypeEnum as nr,ProviderName as V,WarningCodeEnum as sr}from"@swapkit/helpers";import{z as e}from"zod";var ae;((a)=>{a.native_send="native_send";a.token_transfer="token_transfer";a.native_contract_call="native_contract_call";a.token_contract_call="token_contract_call";a.approve="approve";a.deposit="deposit";a.thorname_action="thorname_action";a.lp_action="lp_action";a.swap="swap";a.streaming_swap="streaming_swap";a.stake="stake";a.claim="claim";a.lending="lending";a.unknown="unknown"})(ae||={});var ge;((p)=>{p.unknown="unknown";p.not_started="not_started";p.pending="pending";p.swappping="swapping";p.completed="completed"})(ge||={});var le;((d)=>{d.not_started="not_started";d.starting="starting";d.broadcasted="broadcasted";d.mempool="mempool";d.inbound="inbound";d.outbound="outbound";d.swapping="swapping";d.completed="completed";d.refunded="refunded";d.partially_refunded="partially_refunded";d.dropped="dropped";d.reverted="reverted";d.replaced="replaced";d.retries_exceeded="retries_exceeded";d.parsing_error="parsing_error"})(le||={});var Wr=e.object({error:e.string(),message:e.string()}),T=e.object({chain:e.nativeEnum(rr),symbol:e.string(),ticker:e.string(),decimal:e.optional(e.number()),address:e.optional(e.string()),isGasAsset:e.boolean(),isSynthetic:e.boolean(),tax:e.optional(e.object({buy:e.number(),sell:e.number()}))}),or=e.object({name:e.string(),id:e.string(),market_cap:e.number(),total_volume:e.number(),price_change_24h_usd:e.number(),price_change_percentage_24h_usd:e.number(),timestamp:e.string(),sparkline_in_7d:e.array(e.number())}),be=e.array(e.object({identifier:e.string(),provider:e.string(),cg:or.optional(),price_usd:e.number(),timestamp:e.number()}).partial()),kr=e.object({sellAsset:e.string({description:"Asset to sell"}),buyAsset:e.string({description:"Asset to buy"}),sellAmount:e.string({description:"Amount of asset to sell"}).refine((r)=>+r>0,{message:"sellAmount must be greater than 0",path:["sellAmount"]}),providers:e.optional(e.array(e.string({description:"List of providers to use"}).refine((r)=>{return V[r]!==void 0},{message:"Invalid provider",path:["providers"]}))),sourceAddress:e.optional(e.string({description:"Address to send asset from"})),destinationAddress:e.optional(e.string({description:"Address to send asset to"})),slippage:e.optional(e.number({description:"Slippage tolerance as a percentage. Default is 3%."})),affiliate:e.optional(e.string({description:"Affiliate thorname"})),affiliateFee:e.optional(e.number({description:"Affiliate fee in basis points"}).refine((r)=>{return r===Math.floor(r)&&r>=0},{message:"affiliateFee must be a positive integer",path:["affiliateFee"]})),allowSmartContractSender:e.optional(e.boolean({description:"Allow smart contract as sender"})),allowSmartContractReceiver:e.optional(e.boolean({description:"Allow smart contract as recipient"})),disableSecurityChecks:e.optional(e.boolean({description:"Disable security checks"})),includeTx:e.optional(e.boolean({description:"Set to true to include an transaction object (EVM only)"}))}).refine((r)=>r.sellAsset!==r.buyAsset,{message:"Must be different",path:["sellAsset","buyAsset"]}),Er=e.object({tokens:e.array(e.object({identifier:e.string()})),metadata:e.boolean()}),ir=e.object({evmCalldata:e.optional(e.string()),logs:e.optional(e.unknown()),memo:e.optional(e.string()),spender:e.optional(e.string())}),mr=e.object({estimatedfinalisedAt:e.number(),estimatedTimeToComplete:e.number(),updatedAt:e.number(),currentLegIndex:e.optional(e.number()),providerDetails:e.optional(e.unknown())}),ur=e.object({network:e.optional(T),affiliate:e.optional(T),liquidity:e.optional(T),protocol:e.optional(T),tax:e.optional(T)}),dr=e.object({broadcastedAt:e.optional(e.number()),wallet:e.optional(e.string()),quoteId:e.optional(e.string()),explorerUrl:e.optional(e.string()),affiliate:e.optional(e.string()),fees:e.optional(ur),provider:e.optional(e.nativeEnum(V)),images:e.optional(e.object({from:e.optional(e.string()),to:e.optional(e.string()),provider:e.optional(e.string()),chain:e.optional(e.string())}))}),Y=e.object({chainId:e.nativeEnum(tr),hash:e.string(),block:e.number(),type:e.nativeEnum(ae),status:e.nativeEnum(ge),trackingStatus:e.optional(e.nativeEnum(le)),fromAsset:e.string(),fromAmount:e.string(),fromAddress:e.string(),toAsset:e.string(),toAmount:e.string(),toAddress:e.string(),finalAsset:e.optional(T),finalAddress:e.optional(e.string()),finalisedAt:e.number(),transient:e.optional(mr),meta:e.optional(dr),payload:e.optional(ir)}),Kr=Y.extend({legs:e.array(Y)}),jr=Y.extend({legs:e.array(Y)}),Ne=e.array(e.object({type:e.nativeEnum(nr),amount:e.string(),asset:e.string(),chain:e.string(),protocol:e.nativeEnum(V)})),Ie=e.object({inbound:e.optional(e.number({description:"Time to receive inbound asset in seconds"})),swap:e.optional(e.number({description:"Time to swap assets in seconds"})),outbound:e.optional(e.number({description:"Time to receive outbound asset in seconds"})),total:e.number({description:"Total time in seconds"})}),Ar=e.object({to:e.string({description:"Address of the recipient"}),from:e.string({description:"Address of the sender"}),value:e.string({description:"Value to send"}),data:e.string({description:"Data to send"})}),ar=e.array(e.union([e.string(),e.number(),e.array(e.string()),e.object({from:e.string(),value:e.string()}).describe("Parameters to pass to the contract method")])),Qr=e.object({contractAddress:e.string({description:"Address of the contract to interact with"}),contractMethod:e.string({description:"Name of the method to call"}),contractParams:ar,contractParamNames:e.array(e.string({description:"Names of the parameters to pass to the contract method"})),approvalToken:e.optional(e.string({description:"Address of the token to approve spending of"})),approvalSpender:e.optional(e.string({description:"Address of the spender to approve"}))}),gr=e.object({sellAsset:e.string({description:"Asset to sell"}),buyAsset:e.string({description:"Asset to buy"}),provider:e.nativeEnum(V),sourceAddress:e.string({description:"Source address"}),destinationAddress:e.string({description:"Destination address"}),estimatedTime:Ie.optional(),affiliate:e.string({description:"Affiliate address"}).optional(),affiliateFee:e.number({description:"Affiliate fee"}).optional(),slipPercentage:e.number({description:"Slippage as a percentage"})}),Jr=gr.omit({sourceAddress:!0,destinationAddress:!0,slipPercentage:!0}),lr=e.object({asset:e.string({description:"Asset name"}),price:e.number({description:"Price in USD"}),image:e.string({description:"Asset image"})}),br=e.object({priceImpact:e.optional(e.number({description:"Price impact"})),assets:e.optional(e.array(lr)),approvalAddress:e.optional(e.string({description:"Approval address for swap"})),streamingInterval:e.number().optional(),maxStreamingQuantity:e.number().optional()}),Nr=e.array(e.object({code:e.nativeEnum(sr),display:e.string(),tooltip:e.string().optional()})),Ir=e.object({provider:e.nativeEnum(V),sellAsset:e.string({description:"Asset to sell"}),sellAmount:e.string({description:"Sell amount"}),buyAsset:e.string({description:"Asset to buy"}),buyAmount:e.string({description:"Buy amount"}),buyAmountMaxSlippage:e.string({description:"Buy amount max slippage"}),fees:e.optional(Ne)}),pr=e.object({providers:e.array(e.nativeEnum(V)),sellAsset:e.string({description:"Asset to sell"}),sellAmount:e.string({description:"Sell amount"}),buyAsset:e.string({description:"Asset to buy"}),expectedBuyAmount:e.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:e.string({description:"Expected Buy amount max slippage"}),sourceAddress:e.string({description:"Source address"}),destinationAddress:e.string({description:"Destination address"}),targetAddress:e.optional(e.string({description:"Target address"})),inboundAddress:e.optional(e.string({description:"Inbound address"})),expiration:e.optional(e.string({description:"Expiration"})),memo:e.optional(e.string({description:"Memo"})),fees:Ne,tx:e.optional(Ar),transaction:e.optional(e.unknown()),estimatedTime:e.optional(Ie),totalSlippageBps:e.number({description:"Total slippage in bps"}),legs:e.array(Ir),warnings:Nr,meta:br}),pe=e.object({quoteId:e.string({description:"Quote ID"}),routes:e.array(pr),error:e.optional(e.string({description:"Error message"}))});var Lr="https://api.swapkit.dev",Hr="https://dev-api.swapkit.dev";function X(r){return r?Hr:Lr}function fr(r){return y.post(`${X()}/track`,{json:r})}async function hr(r,t){let i=await y.post(`${X(t)}/quote`,{json:r});if(i.error)throw new q("api_v2_server_error",{message:i.error});try{let n=pe.safeParse(i);if(!n.success)throw new q("api_v2_invalid_response",n.error);return n.data}catch(n){return console.warn(n),i}}function J(r=!1){return y.get(`${X(r)}/providers`)}function Le(r,t=!1){return y.get(`${X(t)}/tokens?provider=${r}`)}async function Br(r,t=!1){let i=await y.post(`${X(t)}/price`,{json:r});try{let n=be.safeParse(i);if(!n.success)throw new q("api_v2_invalid_response",n.error);return n.data}catch(n){throw new q("api_v2_invalid_response",n)}}async function Cr(r,t=!1){let i=new Map;if(!r.length)return i;let n=r.map(async(u)=>{return await Le(u,t)}),H=(await Promise.all(n)).filter((u)=>!!u).map(({tokens:u,...f})=>({data:{...f||{},tokens:u.map(({address:P,...w})=>({...w,...P&&["resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].includes(P.toLowerCase())?{}:{address:P}}))},...f})),p=[b.CAVIAR_V1,b.CHAINFLIP,b.MAYACHAIN,b.MAYACHAIN_STREAMING],W=H.filter(({data:u})=>{return!p.includes(u?.provider||"")}).reduce((u,{data:f})=>f?.tokens?u.concat(f.tokens):u,[]);for(let{data:u}of H){if(!u?.tokens)return;let f=u.provider&&!p.includes(u.provider);for(let P of u.tokens){let w=i.get(P.identifier.toLowerCase())||{tokens:[],providers:[]},A=f?{tokens:W,providers:[b.THORCHAIN,b.THORCHAIN_STREAMING,b.PANCAKESWAP,b.ONEINCH,b.PANGOLIN_V1,b.SUSHISWAP_V2,b.TRADERJOE_V2,b.UNISWAP_V3,b.UNISWAP_V2]}:{tokens:u.tokens,providers:u.provider};i.set(P.identifier.toLowerCase(),{tokens:w.tokens.concat(A.tokens),providers:w.providers.concat(A.providers)})}}return i}var O={};U(O,{getTokenList:()=>Dr,getProviderLogo:()=>Vr,getLogoForAsset:()=>Gr,getChainLogoForAsset:()=>Tr});import{AssetValue as Pr,RequestClient as Sr,getChainIdentifier as cr}from"@swapkit/helpers";var z="https://static.thorswap.net";function Dr(r){return Sr.get(`${z}/token-list/${r}.json`)}function Gr(r){return`${z}/token-list/images/${r.toLowerCase()}.png`}function Tr(r){let{chain:t}=Pr.from({asset:r}),i=cr(t).toLowerCase();return`${z}/token-list/images/${i}.png`}var He;async function Vr(r){return He||=await J(),He.find((t)=>t.name===r)?.url}var rt={...k,...j,...Q,...Z,...O,thorchainMidgard:se,mayachainMidgard:oe};export{ae as TxnType,ge as TxnStatus,Ee as TxStatus,ke as TransactionType,Kr as TransactionSchema,jr as TransactionDTOSchema,le as TrackingStatus,or as TokenDetailsMetadataSchema,rt as SwapKitApi,Ke as StreamingSwapProgressStatus,Nr as RouteQuoteWarningSchema,br as RouteQuoteMetadataSchema,lr as RouteQuoteMetadataAssetSchema,Jr as RouteLegWithoutAddressesSchema,gr as RouteLegSchema,pe as QuoteResponseSchema,kr as QuoteRequestSchema,be as PriceResponseSchema,Er as PriceRequestSchema,Ne as FeesSchema,Ie as EstimatedTimeSchema,Ar as EVMTransactionSchema,Qr as EVMTransactionDetailsSchema,ar as EVMTransactionDetailsParamsSchema,de as ERROR_TYPE,ue as ERROR_MODULE,me as ERROR_CODE,T as AssetValueSchema,Wr as ApiV2ErrorSchema,Ae as ApiV1ErrorSchema};
//# debugId=995E722858C1C9DB64756E2164756E21
//# debugId=0829AB1E5708FD2C64756E2164756E21
{
"author": "swapkit-oss",
"dependencies": {
"@swapkit/helpers": "0.0.0-nightly-20241017130444",
"@swapkit/helpers": "0.0.0-nightly-20241104131900",
"zod": "3.23.8"

@@ -30,3 +30,3 @@ },

"types": "./src/index.ts",
"version": "0.0.0-nightly-20241017130444"
"version": "0.0.0-nightly-20241104131900"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc