UNPKG

tensaikit

Version:

An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.

59 lines (58 loc) 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SUSHISWAP_SUPPORTED_NETWORK = exports.SUSHI_SWAP_GRAPH_URL = exports.subGraphUrlByChainId = exports.getSpender = exports.SushiSwapModule = exports.DEFAULT_MAX_SLIPPAGE = exports.SUSHI_LIQUIDITY_ENDPOINT = exports.SUSHI_TOKEN_ENDPOINT = exports.SUSHI_QUOTE_ENDPOINT = exports.SUSHI_ENDPOINT = void 0; // SushiSwap API endpoints exports.SUSHI_ENDPOINT = "https://api.sushi.com"; exports.SUSHI_QUOTE_ENDPOINT = exports.SUSHI_ENDPOINT + "/quote/v7"; exports.SUSHI_TOKEN_ENDPOINT = exports.SUSHI_ENDPOINT + "/token/v1"; exports.SUSHI_LIQUIDITY_ENDPOINT = exports.SUSHI_ENDPOINT + "/liquidity-providers/v7"; // Default maximum slippage (0.5%) exports.DEFAULT_MAX_SLIPPAGE = 0.005; // Default fallback spender address (SushiSwap router or smart order router) const DEFAULT_SPENDER = "0xAC4c6e212A361c968F1725b4d055b47E63F80b75"; /** * Dynamically imports Sushi SDK and exposes primary swap utilities. * Lazy-loaded to optimize bundle size. */ const SushiSwapModule = async () => { const sushiModule = await import("sushi"); return { price: sushiModule.getPrice, prices: sushiModule.getPrices, getSwap: sushiModule.getSwap, }; }; exports.SushiSwapModule = SushiSwapModule; const SUSHI_SPENDER_MAP = { 324: "0x35E98C2b3894D71D3D4D7edb8b30E4f36E2f9179", // zkSync 810181: "0x35E98C2b3894D71D3D4D7edb8b30E4f36E2f9179", // zkLink Nova }; /** * Gets the appropriate SushiSwap router/spender address for a given chain ID. * * @param chainId - The EVM chain ID * @returns A spender address to use for token approvals */ const getSpender = (chainId) => { return SUSHI_SPENDER_MAP[chainId] || DEFAULT_SPENDER; }; exports.getSpender = getSpender; /** * Returns the subgraph endpoint URL for querying Sushi protocol data * from The Graph on a supported chain. * * @param chainId - The numeric Chain ID of the network * @returns The Graph subgraph URL * @throws If the chain ID is not supported for subgraph access */ const subGraphUrlByChainId = (chainId) => { switch (chainId) { case 747474: // Katana return "https://gateway-arbitrum.network.thegraph.com/api/subgraphs/id/2YG7eSFHx1Wm9SHKdcrM8HR23JQpVe8fNNdmDHMXyVYR"; default: throw new Error(`${chainId} not supported for Sushi Subgraph.`); } }; exports.subGraphUrlByChainId = subGraphUrlByChainId; exports.SUSHI_SWAP_GRAPH_URL = "https://production.data-gcp.sushi.com/graphql"; exports.SUSHISWAP_SUPPORTED_NETWORK = ["katana-mainnet", "katana-testnet"];