Skip to Content
neatdocs
Reference

CompetitiveFeeClient

The main entry point of neat3-sdk. Quote, encode and submit.

import { CompetitiveFeeClient, DEVNET, poolAbi, erc20Abi } from "neat3-sdk";

Constructor

new CompetitiveFeeClient(config: ClientConfig)
OptionTypeDefaultNotes
rpcUrlstringrequiredJSON-RPC URL of the chain the pool lives on
poolAddressrequiredDevnetCompetitivePool address
quoteMode"private" | "public""private"Private reads go through anonFetch and never through a plain fetch
anonFetchFetchFnnoneRequired for private mode. See neat3-sdk/anon
frameSubmitterFrameSubmitternoneEnables submit(). Can be set later
timeoutMsnumber120000RPC timeout. Anonymizing networks are slow

quote

client.quote({ tokenIn, amountIn, mode? }): Promise<Quote>

A read-only call to the pool's quote. It runs the same code as swap, so it matches a swap in the same block. mode overrides the client's quoteMode for one call.

Throws if mode is "private" and no anonFetch was given.

Quote

FieldTypeMeaning
tokenInAddressEcho of the input
amountInbigintEcho of the input
amountOutbigintWhat you receive, after the pool's fee
feePipsnumberPool fee in pips (1e6 = 100%, 3000 = 0.30%)
bestOutbigintBest competitor's output. 0n = no fresh quote, fallback fee used
zeroFeeOutbigintThe pool's output at zero fee
beatsBestVenuebooleanbestOut > 0n && amountOut >= bestOut
mode"private" | "public"Which path served the read

encodeSwap

client.encodeSwap(quote, { minOut?, deadline? }): Call[]

Returns [approve, swap]. quote only needs tokenIn, amountIn and amountOut.

OptionDefault
minOutThe quoted amountOut
deadlineNow + 600 seconds. Unix seconds, as a bigint

Each Call is { to, data, execution?, state? }. execution and state are gas-limit hints that frame submitters use; wallets ignore them.

submit

client.submit(quote, { minOut?, deadline? }): Promise<Hex>

Encodes the swap and hands the calls to the frame submitter. Returns the transaction hash.

Throws if no submitter is set. Pass one in the config, or call setFrameSubmitter.

setFrameSubmitter

client.setFrameSubmitter(fn: (calls: Call[]) => Promise<Hex>): this

Any function that sends the calls as one transaction works. createFrameSubmitter is the EIP-8141 one.

Exports

ExportWhat it is
DEVNET{ chainId: 1337, rpcUrl, explorerUrl } for the self-hosted EIP-8141 devnet
poolAbiquote, the 4-argument swap, and the pool's errors
erc20AbiJust approve
TypesCall, ClientConfig, FetchFn, FrameSubmitter, Quote, QuoteMode, SwapOptions

The 3-argument swap

The pool also has swap(tokenIn, amountIn, minOut), which uses block.timestamp as its deadline. The SDK's ABI and encodeSwap use only the 4-argument form.

On this page