UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

371 lines 19 kB
import { WalletClient as ViemWalletClient, PublicClient as ViemPublicClient, Address } from "viem"; import { TradeActionBNStr, PayableOverrides, StrategyUpdate, EncodedStrategyBNStr, Strategy } from '@bancor/carbon-sdk'; import { ContractsConfig } from '@bancor/carbon-sdk/contracts-api'; import { MarginalPriceOptions } from '@bancor/carbon-sdk/strategy-management'; import { TwitterPostTweetSchema, TwitterAccountMentionsSchema, TwitterPostTweetReplySchema } from '../tools'; import { type RedeemTakaraParams } from '../tools/takara'; import { StrategyType } from "../tools/carbon"; import { z } from 'zod'; export declare class SeiAgentKit { publicClient: ViemPublicClient; walletClient: ViemWalletClient; wallet_address: Address; token: string | undefined; /** * Creates a new SeiAgentKit instance * @param private_key The private key for the wallet * @param provider The model provider to use */ constructor(private_key: string, provider: any); /** * Gets the ERC20 token balance * @param contract_address Optional ERC-20 token contract address. If not provided, gets native SEI balance * @returns Promise with formatted balance as string */ getERC20Balance(contract_address?: Address): Promise<string>; /** * Transfers SEI tokens or ERC-20 tokens * @param amount Amount to transfer as a string (e.g., "1.5" for 1.5 tokens) * @param recipient Recipient address * @param ticker Optional token ticker (if not provided, transfers native SEI) * @returns Promise with transaction result */ ERC20Transfer(amount: string, recipient: Address, ticker?: string): Promise<string>; /** * Gets the ERC721 token balance * @param tokenAddress The ERC-721 token contract address * @returns Promise with balance as string */ getERC721Balance(tokenAddress: Address): Promise<string>; /** * Transfers an ERC721 token * @param amount Deprecated parameter (kept for compatibility) * @param recipient The recipient address * @param tokenAddress The ERC-721 token contract address * @param tokenId The token ID to transfer * @returns Promise with transaction details or error message */ ERC721Transfer(amount: string, recipient: Address, tokenAddress: Address, tokenId: string): Promise<string>; /** * Mints an ERC721 token * @param recipient The recipient address that will receive the minted token * @param tokenAddress The ERC-721 token contract address * @param tokenId The token ID to mint * @returns Promise with transaction details or error message */ ERC721Mint(recipient: Address, tokenAddress: Address, tokenId: bigint): Promise<string>; /** * Gets a token address from its ticker symbol * @param ticker The token ticker symbol (e.g., "SEI", "USDC") * @returns Promise with token address or null if not found */ getTokenAddressFromTicker(ticker: string): Promise<Address | null>; /** * Stakes SEI tokens on the network * @param amount Amount of SEI to stake as a string (e.g., "1.5" for 1.5 SEI) * @returns Promise with transaction hash or error message */ stake(amount: string): Promise<string>; /** * Unstakes SEI tokens from the network * @param amount Amount of SEI to unstake as a string (e.g., "1.5" for 1.5 SEI) * @returns Promise with transaction hash or error message */ unstake(amount: string): Promise<string>; /** * Swaps tokens using the Symphony aggregator * @param amount The amount of tokens to swap as a string (e.g., "1.5") * @param tokenIn The address of the token to swap from * @param tokenOut The address of the token to swap to * @returns Transaction details as a string */ swap(amount: string, tokenIn: Address, tokenOut: Address): Promise<string>; /** * Mints tTokens by depositing underlying tokens into the Takara Protocol * @param ticker The token ticker (e.g., "USDC") * @param mintAmount The amount to mint in human-readable format * @returns Transaction hash and expected tToken amount */ mintTakara(ticker: string, mintAmount: string): Promise<`0x${string}`>; /** * Borrows underlying tokens from the Takara Protocol using tTokens as collateral * @param ticker The token ticker (e.g., "USDC") * @param borrowAmount The amount to borrow in human-readable format * @returns Transaction hash and borrowed amount */ borrowTakara(ticker: string, borrowAmount: string): Promise<`0x${string}`>; /** * Repays borrowed tokens to the Takara Protocol * @param ticker The token ticker (e.g., "USDC") * @param repayAmount The amount to repay in human-readable format, or "MAX" to repay full balance * @returns Transaction hash and amount repaid */ repayTakara(ticker: string, repayAmount: string): Promise<{ txHash: import("viem").Hash; repaidAmount: string; }>; /** * Redeems tTokens from the Takara Protocol to get underlying tokens back * @param ticker The token ticker (e.g., "USDC") * @param redeemAmount The amount to redeem in human-readable format, or "MAX" to redeem all * @param redeemType Whether to redeem underlying tokens or tTokens * @returns Transaction details and redemption status */ redeemTakara(ticker: string, redeemAmount: string, redeemType?: RedeemTakaraParams['redeemType']): Promise<{ txHash: import("viem").Hash; redeemedAmount: string; expected: string; actual: string; success: boolean; }>; /** * Calculates the amount of underlying tokens that can be redeemed by a user * @param ticker The token ticker (e.g., "USDC") * @param userAddress Optional address of the user to check * @returns Information about redeemable amounts */ getRedeemableAmount(ticker: string, userAddress?: Address): Promise<{ tTokenBalance: string; exchangeRate: string; redeemableUnderlying: string; safeMaxRedeemable: string; underlyingDecimals: number; underlyingTokenAddress: Address; }>; /** * Retrieves the current borrow balance for a user * @param ticker The token ticker (e.g., "USDC") * @param userAddress Optional address of the user to check * @returns Information about the borrow balance */ getBorrowBalance(ticker: string, userAddress?: Address): Promise<{ borrowBalance: string; underlyingDecimals: number; underlyingTokenAddress: Address; }>; /** * Composes a trade transaction based on the source token amount using Carbon SDK. * @param config The Carbon contracts configuration. * @param sourceToken The address of the source token. * @param targetToken The address of the target token. * @param tradeActions An array of trade actions. * @param deadline The transaction deadline timestamp. * @param minReturn The minimum amount of target tokens to receive. * @param overrides Optional transaction overrides. * @returns Promise with the transaction hash or null. */ composeTradeBySourceTx(config: ContractsConfig, sourceToken: string, targetToken: string, tradeActions: TradeActionBNStr[], deadline: string, minReturn: string, overrides?: PayableOverrides): Promise<string | null>; /** * Composes a trade transaction based on the target token amount using Carbon SDK. * @param config The Carbon contracts configuration. * @param sourceToken The address of the source token. * @param targetToken The address of the target token. * @param tradeActions An array of trade actions. * @param deadline The transaction deadline timestamp. * @param maxInput The maximum amount of source tokens to spend. * @param overrides Optional transaction overrides. * @returns Promise with the transaction hash or null. */ composeTradeByTargetTx(config: ContractsConfig, sourceToken: string, targetToken: string, tradeActions: TradeActionBNStr[], deadline: string, maxInput: string, overrides?: PayableOverrides): Promise<string | null>; /** * Posts a tweet to Twitter * @param tweet The tweet to post * @returns Transaction hash and tweet details */ postTweet(tweet: z.infer<typeof TwitterPostTweetSchema>): Promise<string>; /** * Retrieves details about the authenticated user's Twitter account * @returns Account details as a string */ getAccountDetails(): Promise<string>; /** * Retrieves mentions for the authenticated user's Twitter account * @returns Mentions as a string */ getAccountMentions(args: z.infer<typeof TwitterAccountMentionsSchema>): Promise<string>; /** * Posts a reply to a tweet on Twitter * @param args The arguments for posting a reply * @returns Transaction hash and reply details */ postTweetReply(args: z.infer<typeof TwitterPostTweetReplySchema>): Promise<string>; /** * Deposits USDC tokens into the Citrex Protocol * @param amount The amount of USDC to deposit as a string (e.g., "1.5" for 1.5 USDC) * @returns Promise with transaction hash or error message */ citrexDeposit(amount: string): Promise<string>; /** * Withdraws USDC tokens from the Citrex Protocol * @param amount The amount of USDC to withdraw as a string (e.g., "1.5" for 1.5 USDC) * @returns Promise with transaction hash or error message */ citrexWithdraw(amount: string): Promise<"Withdrawal successful" | "Withdrawal failed">; /** * Retrieves all products from the Citrex Protocol * @returns Promise with products or error message */ citrexGetProducts(): Promise<import("../tools").productParsed | undefined>; /** * Retrieves the order book for a product from the Citrex Protocol * @param symbol The symbol of the product (e.g., "ethperp") * @returns Promise with order book or error message */ citrexGetOrderBook(symbol: string): Promise<import("citrex-sdk/types").OrderBookReturnType | undefined>; /** * Retrieves the account health for the Citrex Protocol * @returns Promise with account health or error message */ citrexGetAccountHealth(): Promise<import("citrex-sdk/types").AccountHealthReturnType | undefined>; /** * Retrieves the tickers for the Citrex Protocol * @returns Promise with tickers or error message */ citrexGetTickers(symbol?: `${string}perp`): Promise<import("citrex-sdk/types").TickerReturnType | undefined>; /** * Calculates the required margin for a new order on Citrex Protocol * @param isBuy Whether to buy (true) or sell (false) * @param price The price of the asset for the order * @param productId The product ID of the asset * @param quantity The quantity of the asset to order * @returns Promise with the required margin calculation result */ citrexCalculateMarginRequirement(isBuy: boolean, price: number, productId: number, quantity: number): Promise<import("citrex-sdk/types").CalculateMarginRequirementReturnType | undefined>; /** * Retrieves K-line (candlestick) chart data for a product on Citrex Protocol * @param productSymbol The product symbol (e.g., 'btcperp', 'ethperp') * @param optionalArgs Optional arguments for the query * @returns Promise with K-line data */ citrexGetKlines(productSymbol: `${string}perp`, optionalArgs?: any): Promise<import("citrex-sdk/types").KlinesReturnType | undefined>; /** * Retrieves information about a specific product on Citrex Protocol * @param identifier The product ID or symbol * @returns Promise with product information */ citrexGetProduct(identifier: number | string): Promise<import("citrex-sdk/types").ProductReturnType | undefined>; /** * Retrieves the current server time from Citrex Protocol * @returns Promise with server time information */ citrexGetServerTime(): Promise<import("citrex-sdk/types").ServerTimeReturnType | undefined>; /** * Retrieves trade history for a product on Citrex Protocol * @param productSymbol The product symbol (e.g., 'btcperp', 'ethperp') * @param quantity Optional number of trades to fetch * @returns Promise with trade history data */ citrexGetTradeHistory(productSymbol: `${string}perp`, quantity?: number): Promise<import("citrex-sdk/types").TradeHistoryReturnType | undefined>; /** * Cancels and replaces an order on Citrex Protocol * @param orderId The unique ID of the order to replace * @param orderArgs The new order arguments * @returns Promise with the new order information */ citrexCancelAndReplaceOrder(orderId: `0x${string}`, orderArgs: any): Promise<import("citrex-sdk/types").PlaceOrderReturnType | undefined>; /** * Cancels all open orders for a specific product on Citrex Protocol * @param productId The product ID for which to cancel all orders * @returns Promise with cancellation result */ citrexCancelOpenOrdersForProduct(productId: number): Promise<import("citrex-sdk/types").CancelOrdersReturnType | undefined>; /** * Cancels a specific order on Citrex Protocol * @param orderId The unique ID of the order to cancel * @param productId The product ID of the order * @returns Promise with cancellation result */ citrexCancelOrder(orderId: `0x${string}`, productId: number): Promise<import("citrex-sdk/types").CancelOrderReturnType | undefined>; /** * Cancels multiple orders on Citrex Protocol * @param ordersArgs Array of [orderId, productId] pairs * @returns Promise with cancellation results */ citrexCancelOrders(ordersArgs: [`0x${string}`, number][]): Promise<import("citrex-sdk/types").CancelOrderReturnType[] | undefined>; /** * Lists all account balances on Citrex Protocol * @returns Promise with account balances */ citrexListBalances(): Promise<import("citrex-sdk/types").BalancesReturnType | undefined>; /** * Lists all open orders on Citrex Protocol * @param productSymbol Optional product symbol to filter orders * @returns Promise with open orders */ citrexListOpenOrders(productSymbol?: `${string}perp`): Promise<import("citrex-sdk/types").OpenOrdersReturnType | undefined>; /** * Lists all positions on Citrex Protocol * @param productSymbol Optional product symbol to filter positions * @returns Promise with positions */ citrexListPositions(productSymbol?: `${string}perp`): Promise<import("citrex-sdk/types").PositionsReturnType | undefined>; /** * Places a single order on Citrex Protocol * @param orderArgs The order arguments * @returns Promise with order placement result */ citrexPlaceOrder(orderArgs: any): Promise<import("citrex-sdk/types").PlaceOrderReturnType | undefined>; /** * Places multiple orders on Citrex Protocol * @param ordersArgs Array of order arguments * @returns Promise with order placement results */ citrexPlaceOrders(ordersArgs: any[]): Promise<import("citrex-sdk/types").PlaceOrderReturnType[] | undefined>; /** * Creates a buy/sell strategy using Carbon SDK. * @param config The Carbon contracts configuration. * @param baseToken The address of the base token. * @param quoteToken The address of the quote token. * @param buyPriceLow The lower bound of the buy price range. * @param buyPriceMarginal The marginal buy price. * @param buyPriceHigh The upper bound of the buy price range. * @param buyBudget The budget allocated for buying. * @param sellPriceLow The lower bound of the sell price range. * @param sellPriceMarginal The marginal sell price. * @param sellPriceHigh The upper bound of the sell price range. * @param sellBudget The budget allocated for selling. * @param overrides Optional transaction overrides. * @returns Promise with the transaction hash or null. */ createBuySellStrategy(config: ContractsConfig, type: StrategyType, baseToken: Address, quoteToken: Address, buyRange: string | string[] | undefined, sellRange: string | string[] | undefined, buyBudget: string | undefined, sellBudget: string | undefined, overrides?: PayableOverrides): Promise<string | null>; /** * Creates an overlapping LP strategy using Carbon SDK. * @param config The Carbon contracts configuration. * @param baseToken The address of the base token. * @param quoteToken The address of the quote token. * @param sellPriceHigh The lower bound of the sell price range. * @param buyPriceLow The upper bound of the buy price range. * @param buyBudget The budget allocated for buying. * @param sellBudget The budget allocated for selling. * @param overrides Optional transaction overrides. * @returns Promise with the transaction hash or null. */ createOverlappingStrategy(config: ContractsConfig, baseToken: Address, quoteToken: Address, buyPriceLow: string | undefined, sellPriceHigh: string | undefined, buyBudget: string | undefined, sellBudget: string | undefined, fee: number, range: number, marketPriceOverride: string | undefined, overrides?: PayableOverrides): Promise<string | null>; /** * Deletes a strategy using Carbon SDK. * @param config The Carbon contracts configuration. * @param strategyId The ID of the strategy to delete. * @returns Promise with the transaction hash or null. */ deleteStrategy(config: ContractsConfig, strategyId: string): Promise<string | null>; /** * Gets the strategies for a user using Carbon SDK. * @param config The Carbon contracts configuration. * @param user Optional user address. Defaults to the agent's wallet address. * @returns Promise with the user's strategies or null. */ getUserStrategies(config: ContractsConfig, user: `0x${string}`): Promise<Strategy[] | null>; /** * Updates a strategy using Carbon SDK. * @param config The Carbon contracts configuration. * @param strategyId The ID of the strategy to update. * @param update The strategy update data. * @param encoded The encoded strategy data. * @param buyPriceMarginal Optional marginal buy price options. * @param sellPriceMarginal Optional marginal sell price options. * @param overrides Optional transaction overrides. * @returns Promise with the transaction hash or null. */ updateStrategy(config: ContractsConfig, strategyId: string, update: StrategyUpdate, encoded: EncodedStrategyBNStr, buyPriceMarginal?: MarginalPriceOptions | string, sellPriceMarginal?: MarginalPriceOptions | string, overrides?: PayableOverrides): Promise<string | null>; } //# sourceMappingURL=index.d.ts.map