@accret/bridge-sdk
Version:
57 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getQuote = getQuote;
const swap_sdk_1 = require("@mayanfinance/swap-sdk");
/**
* @description Fetches a quote for swapping tokens on the Mayan network
* @param params - The parameters for fetching a quote
* @param params.fromChain - The chain from which to swap
* @param params.fromToken - The token to swap from
* @param params.toChain - The chain to which to swap
* @param params.toToken - The token to swap to
* @param params.amount - The amount to swap
* @param params.slippageBps - The slippage in basis points (default is 50)
* @returns A promise that resolves to the best quote for the swap
*/
async function getQuote(params) {
const { fromChain, fromToken, toChain, toToken, amount } = params;
const supportedChains = [
"solana",
"ethereum",
"base",
"polygon",
"arbitrum",
"avalanche",
"bsc",
];
const referrerAddress = {
solana: "69izdTrBfvhpuq8LgWifstGbHTZC6DKn1w5wLpdjapfF",
evm: "0xD0208Bfe9Ae201Cc2baE4e4b5a74561472A7a910",
};
if (!supportedChains.includes(fromChain) ||
!supportedChains.includes(toChain)) {
throw new Error("Chain not supported. Supported chains: solana, ethereum, base, polygon, arbitrum, avalanche, bsc");
}
const referrer = fromChain === "solana" || fromChain === "polygon"
? referrerAddress.solana
: referrerAddress.evm;
const quotes = await (0, swap_sdk_1.fetchQuote)({
amount,
fromChain,
fromToken,
toChain,
toToken,
slippageBps: 50,
referrer,
referrerBps: 50,
});
if (quotes.length === 0) {
throw new Error("No quotes found for the specified parameters");
}
const quote = quotes;
if (quote.length === 0) {
throw new Error("No quotes found for the specified parameters");
}
return quote;
}
//# sourceMappingURL=getQuote.js.map