# Factory Trade Helper (ETH In / ETH Out)

This guide covers Bonding Curve stage trading through the **Basememe Factory Trade Helper** contract.

Coins on Base.meme can be created with different collateral pairs (ETH / USDC / SOL). For coins that use an ERC20 collateral token (e.g. USDC / SOL), interacting with the Factory directly requires the caller to hold and approve that collateral token.

The Trade Helper provides a simplified interface that lets callers trade using **ETH only**:

* **Buy:** pay in ETH, receive the coin
* **Sell:** pay in the coin, receive ETH

Internally, the helper swaps between ETH and the coin’s configured collateral token, then calls the Factory.

## Quote Methods

These methods return the coin’s configured collateral token and an estimated conversion amount between ETH and that collateral token.

```solidity
function quoteEthToCollateralForToken(address token, uint256 ethIn)
    external
    returns (address collateralToken, uint256 collateralOut);

function quoteCollateralToEthForToken(address token, uint256 collateralIn)
    external
    returns (address collateralToken, uint256 ethOut);
```

## Trading Methods

### Buy with ETH

```solidity
function buyWithEth(address token, uint256 funds, uint256 minTokenOut, address tradeReferrer)
    external
    payable
    returns (uint256 tokenOut, uint256 refundOut);
```

* `funds` must match `msg.value`.
* `refundOut` is any leftover ETH refunded back to the caller (e.g. due to fee/price movement or swap output variance).

### Sell for ETH

```solidity
function sellForEth(address token, uint256 tokenAmountIn, uint256 minEthOut, address tradeReferrer)
    external
    returns (uint256 ethOut);
```

The caller must approve the helper to transfer `tokenAmountIn` of the coin before selling.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.base.meme/for-developers/trading-coins/factory-trade-helper.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
