dex-skills v0.1.0

estimatePrice()

Get a price estimation for a potential buy or sell trade without executing it. Returns the estimated token amount, cost, fees, and price per token. This is a read-only operation that does not require a private key. Currently only supported on Four.meme.

Signature

const skill = getSkill(skills, "fourmeme");
const quote: PriceQuote = await skill.estimatePrice({
  tokenAddress: "0xTokenAddress...",
  action: "buy",
  amount: "0.1",
});

Parameters

Parameter Type Description
tokenAddress * string The address of the token to get a price quote for.
action * string The trade direction. Either "buy" or "sell".
amount * string Amount to quote. For buy: native currency amount. For sell: token amount.

Return Value

Returns a Promise<PriceQuote>. See the Types reference for the full PriceQuote definition.

Platform Support

Platform Supported
Pump.fun No
LetsBonk No
Moonshot No
Zora No
Clanker No
Four.meme Yes
SunPump No

Example

estimate-price.ts
import { createSkills, getSkill } from "dex-skills";

const skills = createSkills({
  wallets: {
    bnb: {
      privateKey: "0x-prefixed-hex-private-key",
      rpcUrl: "https://bsc-dataseed1.binance.org",
    },
  },
});

// Estimate the cost of buying tokens on Four.meme
const fourmeme = getSkill(skills, "fourmeme");
const buyQuote = await fourmeme.estimatePrice({
  tokenAddress: "0xTokenContractAddress...",
  action: "buy",
  amount: "0.1",
});

console.log("Estimated tokens:", buyQuote.estimatedAmount);
console.log("Estimated cost:", buyQuote.estimatedCost);
console.log("Fee:", buyQuote.fee);
console.log("Price per token:", buyQuote.pricePerToken);

// Estimate the return from selling tokens
const sellQuote = await fourmeme.estimatePrice({
  tokenAddress: "0xTokenContractAddress...",
  action: "sell",
  amount: "1000000",
});

console.log("Estimated return:", sellQuote.estimatedAmount);
Four.meme only
estimatePrice() is currently only supported on the Four.meme platform. Calling this method on other platforms will throw an error indicating the method is not available.
Estimates are not guaranteed
Price estimates are based on the current state of the bonding curve or liquidity pool. The actual trade result may differ due to price movement between the estimation and execution.