UNPKG

tensaikit

Version:

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

50 lines (49 loc) 2.54 kB
import { EvmWalletProvider } from "./walletProviders"; /** * Approves a spender to spend tokens on behalf of the owner. * * Encodes and sends an ERC-20 `approve` transaction using the provided wallet, * allowing the specified spender to spend a given amount of tokens. * * @param wallet - The EVM wallet provider used to sign and send the transaction. * @param tokenAddress - The ERC-20 token contract address. * @param spenderAddress - The address being approved to spend tokens. * @param amount - The amount of tokens to approve (in atomic units, e.g., wei). * @returns A promise that resolves to a success or error message string. */ export declare const approve: (wallet: EvmWalletProvider, tokenAddress: string, spenderAddress: string, amount: bigint) => Promise<string>; /** * Scales a gas estimate by a given multiplier. * * This function converts the gas estimate to a number, applies the multiplier, * rounds the result to the nearest integer, and returns it as a bigint. * * @param gas - The original gas estimate as a bigint. * @param multiplier - The factor by which to scale the estimate. * @returns The adjusted gas estimate as a bigint. */ export declare const applyGasMultiplier: (gas: bigint, multiplier: number) => bigint; /** * Fetches the current token allowance for a spender set by the connected wallet. * * Calls the ERC-20 `allowance` function to determine how many tokens the * `spenderAddress` is allowed to spend on behalf of the wallet's address. * * @param wallet - The EVM wallet provider used to get the owner's address and read from the contract * @param tokenAddress - The address of the ERC-20 token contract * @param spenderAddress - The address of the spender whose allowance is being queried * @returns A promise that resolves to the allowance amount as a bigint * @throws CONTRACT_ERROR if the read call fails */ export declare const allowance: (wallet: EvmWalletProvider, tokenAddress: string, spenderAddress: string) => Promise<bigint>; /** * Checks if the provided token address represents a native token (e.g., ETH, MATIC). * * Considers two common placeholders used to represent native tokens: * - `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` (commonly used in DeFi protocols) * - `0x0000000000000000000000000000000000000000` (null address) * * @param tokenAddress - The token address to check * @returns `true` if the address is a known native token placeholder, otherwise `false` */ export declare const isNativeToken: (tokenAddress: string) => boolean;