tensaikit
Version:
An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.
58 lines (57 loc) • 2.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sushiSwapActionProvider = exports.SushiSwapActionProvider = void 0;
const actionProvider_1 = require("../actionProvider");
const actions_1 = require("./actions");
const utlis_1 = require("./utlis");
/**
* SushiSwapActionProvider is a modular integration layer for interacting with SushiSwap on EVM-compatible chains.
*
* This provider bundles multiple functional action groups:
* - Token pricing (USD prices and metadata)
* - Token discovery via subgraph
* - Swap quote generation
*
* Responsibilities:
* - Register individual SushiSwap action modules into a unified provider
* - Enforce required configuration (e.g., subgraph API key)
* - Determine whether the current network is supported (EVM only)
*
*
* Usage:
* ```ts
* const provider = new SushiSwapActionProvider({ subGraphApiKey: "<API_KEY>" });
* ```
*/
class SushiSwapActionProvider extends actionProvider_1.ActionProvider {
/**
* Constructs the SushiSwapActionProvider and registers its action groups.
*/
constructor(config = {}) {
config.subGraphApiKey || (config.subGraphApiKey = process.env.SUBGRAPH_API_KEY || "");
if (!config.subGraphApiKey) {
throw new Error("SUBGRAPH_API_KEY is not configured.");
}
super("sushi_swap", [
new actions_1.SushiSwapPriceActions(),
new actions_1.SushiSwapLiquidityActions(),
new actions_1.SushiSwapTokenActions(config.subGraphApiKey),
new actions_1.SushiSwapQuoteActions(),
]);
/**
* Checks if the SushiSwap action provider supports the given network.
*
* @param network - The network to validate.
* @returns `true` if the network uses the EVM protocol family, else `false`.
*/
this.supportsNetwork = (network) => network.protocolFamily === "evm" &&
utlis_1.SUSHISWAP_SUPPORTED_NETWORK.includes(network.networkId);
}
}
exports.SushiSwapActionProvider = SushiSwapActionProvider;
/**
* Creates a new instance of SushiSwapActionProvider.
* @returns A new instance of SushiSwapActionProvider
*/
const sushiSwapActionProvider = () => new SushiSwapActionProvider();
exports.sushiSwapActionProvider = sushiSwapActionProvider;