> For the complete documentation index, see [llms.txt](https://docs.rh.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rh.fun/for-developers/trading-coins/factory-trade-helper.md).

# Factory Trade Helper (ETH In / ETH Out)

This guide covers the **RH Factory Trade Helper** contract.

The helper provides ETH-in / ETH-out integrations for both curve-stage and DEX-stage flows.

## Quote Methods

```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);

function quoteDexExactInput(address tokenIn, address tokenOut, uint256 amountIn)
    external
    view
    returns (uint256 amountOutReceivedExpected);
```

## Bonding Curve Stage Methods

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

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

* `funds` must match `msg.value` in `buyWithEth`.
* Caller must approve helper before `sellForEth`.

## DEX Stage Methods

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

function dexSellForEth(address token, uint256 tokenAmountIn, uint256 minEthOut)
    external
    returns (uint256 ethOut);
```

These methods are for post-migration DEX trading paths.

## Events

* `BuyWithEth`
* `SellForEth`
