TRADING / SELL
Sell tokens back to ETH.
Approve deliberately. Quote freshly. Sell with a minimum output.
Selling transfers tokens to the bonding market and pays native ETH to your wallet. The market needs an ERC-20 allowance from the selling account before the sell can execute.
1. Approve the amount
TypeScript
import { prepareSellApproval } from '@floor1/sdk';
import { parseUnits } from 'viem';
const amount = parseUnits('100', 18);
const approval = prepareSellApproval(token, amount);
const approvalHash = await wallet.sendTransaction({
account, chain: wallet.chain,
to: approval.to, data: approval.data, value: approval.value,
});
const receipt = await receiptClient.waitForTransactionReceipt({
hash: approvalHash,
});
if (receipt.status !== 'success') throw new Error('Approval failed');receiptClient is your existing receipt provider. The approval helper authorizes the configured Floor1 market for exactly the amount you supply. If you already have sufficient allowance, you can skip approval. The SDK neither reads allowance nor silently grants unlimited approval.
2. Request a fresh sell
TypeScript
const { hash, quote } = await floor1.sell({
token, amount, slippageBps: 100,
});The sell method requests a fresh quote, builds sellToEth(token, amount, minimumOut), and sends it through the connected wallet. Sell transaction value is zero. The quote output and minimum output are in wei.
Prepare a sell yourself
TypeScript
import { prepareSell } from '@floor1/sdk';
const quote = await floor1.quote({ token, side: 'sell', amount });
const tx = prepareSell(quote);