@coinbase/agentkit
Version:
Coinbase AgentKit core primitives
33 lines (32 loc) • 1.56 kB
TypeScript
import { EvmWalletProvider } from "./wallet-providers";
/**
* Approves a spender to spend tokens on behalf of the owner
*
* @param wallet - The wallet provider
* @param tokenAddress - The address of the token contract
* @param spenderAddress - The address of the spender
* @param amount - The amount to approve in atomic units (wei)
* @returns A success message or error message
*/
export declare function 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 (bigint).
* @param multiplier - The factor by which to scale the estimate.
* @returns The adjusted gas estimate as a bigint.
*/
export declare function applyGasMultiplier(gas: bigint, multiplier: number): bigint;
/**
* Retry function with exponential backoff
*
* @param fn - The function to retry
* @param maxRetries - Maximum number of retries (default: 3)
* @param baseDelay - Base delay in milliseconds for retries (default: 1000)
* @param initialDelay - Initial delay before the first attempt in milliseconds (default: 0)
* @returns Promise that resolves with the function result or rejects with the last error
*/
export declare function retryWithExponentialBackoff<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number, initialDelay?: number): Promise<T>;