uniswap-tx-builder-mcp

v0.4.3
io.github.Yummybait-fin/uniswap-tx-builder-mcp Checked 1 day ago Published 4 months ago

Builds and simulates unsigned Uniswap v3 liquidity-position transactions — keyless, never signs.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

build_collect Build a collect-fees transaction

Build an UNSIGNED tx that collects all uncollected fees from a Uniswap v3 position to `recipient`. Returns tx={to,data,value,chainId} plus rlp (the unsigned EIP-1559 serialization for signing services). When simulated, simulationResult={amount0,amount1} — the actual amounts eth_call reports would be collected. Set simulate=false to skip the eth_call dry-run (on by default).

ParameterTypeDescription
chainId *integer
positionId *string
recipient *string
simulateboolean

build_close Build a close-position transaction

Build an UNSIGNED tx that removes all liquidity and collects everything from a Uniswap v3 position (multicalls when needed). Returns the tx (+ unsigned rlp) plus the read position. When simulated, simulationResult={decreaseLiquidity?: {amount0,amount1}, collect: {amount0,amount1}} decoded from the eth_call return data. Set burn=true to also burn the now-empty NFT in the same multicall. Set simulate=false to skip the eth_call dry-run (on by default).

ParameterTypeDescription
chainId *integer
positionId *string
recipient *string
burnboolean
simulateboolean

build_mint Build a mint-position transaction

Build an UNSIGNED tx that mints a new Uniswap v3 position. Amounts are decimal strings (wei) — compute them with get_pool_state (live ratio) right before minting, or stale prices revert the mint. Returns the tx plus unsigned rlp. When simulated, simulationResult={tokenId,liquidity,amount0,amount1} decoded from the eth_call return data. Simulation is OFF by default here (minting needs token approvals and balances, so eth_call usually reverts); pass simulate=true to attempt it.

ParameterTypeDescription
amount0Desired *string
amount1Desired *string
chainId *integer
fee *integer
recipient *string
tickLower *integer
tickUpper *integer
token0 *string
token1 *string
simulateboolean
slippageBpsinteger

build_increase Build an increase-liquidity transaction

Build an UNSIGNED tx that adds liquidity to an EXISTING Uniswap v3 position. Amounts are decimal strings (wei); mins are derived from slippageBps (default 0.5%). Returns the tx plus unsigned rlp. When simulated, simulationResult={liquidity,amount0,amount1} decoded from the eth_call return data. Simulation is OFF by default (needs token approvals + balances); pass simulate=true to attempt it.

ParameterTypeDescription
amount0Desired *string
amount1Desired *string
chainId *integer
positionId *string
recipient *string
simulateboolean
slippageBpsinteger

build_approve Build an ERC-20 approve transaction

Build an UNSIGNED tx that approves `spender` to move up to `amount` of `token` on behalf of the wallet that signs it — e.g. the NonfungiblePositionManager before build_mint/build_increase, or Permit2 before a Permit2-paid build_swap. Pass amount="max" for an unlimited (uint256 max) allowance. Returns the tx plus unsigned rlp; when simulated, simulationResult={approved} decoded from the eth_call return data. Pass `sender` (the signing wallet) to eth_call-simulate before signing.

ParameterTypeDescription
amount *
chainId *integer
spender *string
token *string
senderstring
simulateboolean

plan_position Plan a position from a human price range

READ-ONLY helper (builds no tx). Given a human price range (token1 per token0) and optional human token amounts, reads each token's decimals over RPC and returns the aligned tickLower/tickUpper (for the fee's tick spacing) plus wei amount0Desired/amount1Desired — ready to feed into build_mint. token0 must be < token1 by address. Does NOT compute the optimal amount ratio for the range.

ParameterTypeDescription
chainId *integer
fee *integer
priceLower *number
priceUpper *number
token0 *string
token1 *string
amount0string
amount1string

get_pool_state Read live pool state; plan a range and mint amounts from it

READ-ONLY (builds no tx). Returns the pool's LIVE state: pool address, tick, sqrtPriceX96, price (token1 per token0, human units), tickSpacing. With rangePct: suggested tickLower/tickUpper within ±pct of spot, rounded INWARD to tick spacing. With balance0+balance1 (raw wei) + tickLower/tickUpper: amount0Desired/amount1Desired for build_mint computed from the live sqrtPrice ratio, plus which side limits. Errors if spot is outside the range. ALWAYS recompute amounts with this right before build_mint — stale ratios revert with 'Price slippage check'.

ParameterTypeDescription
chainId *integer
fee *integer
token0 *string
token1 *string
balance0string
balance1string
rangePctnumber
tickLowerinteger
tickUpperinteger

get_positions List a wallet's Uniswap v3 positions

READ-ONLY (builds no tx). Lists every Uniswap v3 position NFT `owner` holds on `chainId` via the NonfungiblePositionManager, with each position's full state (token0/token1, fee, tickLower/tickUpper, liquidity, tokensOwed0/1) — feed a positionId straight into build_collect/build_close/build_increase.

ParameterTypeDescription
chainId *integer
owner *string

build_wrap Build a wrap-native-ETH transaction (Universal Router)

Build an UNSIGNED payable tx that wraps `amountWei` native ETH into WETH via the Universal Router WRAP_ETH command (works under UR-allowlisting wallet policies where a direct WETH.deposit() doesn't). `recipient` defaults to the tx sender — omit it unless the WETH should go elsewhere. Returns the tx plus unsigned rlp. Pass `sender` (the signing wallet) to eth_call-simulate before signing.

ParameterTypeDescription
amountWei *string
chainId *integer
deadlineinteger
recipientstring
senderstring
simulateboolean

build_swap Build a token→token swap transaction (Universal Router)

Build an UNSIGNED tx that swaps `amountInWei` of `tokenIn` for `tokenOut` (exact-in, single hop through the `fee` pool) via the Universal Router. By default `tokenIn` pays via Permit2. When `sender` is given and Permit2 has no sufficient standing allowance for the Universal Router, this returns {permit2Required: true, typedData, permit} instead of a tx — sign `typedData` with `sender`'s wallet (e.g. sign_typed_data), then call build_swap again with the same args plus permit2=<the returned "permit"> and permit2Signature=<the signature> to get the tx, with a PERMIT2_PERMIT command embedded ahe…

ParameterTypeDescription
amountInWei *string
amountOutMin *string
chainId *integer
fee *integer
tokenIn *string
tokenOut *string
deadlineinteger
permit2object
permit2Signaturestring
recipientstring
senderstring
simulateboolean
unwrapOutboolean
wrapWeistring

get_swap_quote Quote a token→token swap (Uniswap v3 QuoterV2)

READ-ONLY (builds no tx). Quotes an exact-in single-hop `tokenIn` → `tokenOut` swap (the same shape build_swap executes) via QuoterV2.quoteExactInputSingle — the live amountOut the pool would give at its CURRENT price, without sending a tx. Returns amountOut (wei), amountOutMin (amountOut after slippageBps, default 0.5% — feed this straight into build_swap), sqrtPriceX96After, initializedTicksCrossed, and gasEstimate. Call this immediately before build_swap: a quote read even a block earlier can go stale enough that the amountOutMin it produced reverts the swap.

ParameterTypeDescription
amountInWei *string
chainId *integer
fee *integer
tokenIn *string
tokenOut *string
slippageBpsinteger