# Dust conversion

Convert small Trading balances into one Asset with quotes, idempotent conversion, and conversion reads.

`transfer.v1.DustConversionService` converts eligible Trading balances into one target Asset at current Index Prices, less a disclosed fee. USDT is the default target. Every source moves and the payout is credited within the same account atomically, or nothing moves.

## Access and account scope

Calls accept an authenticated session or a signed API key. Quoting, converting, and reading conversions need the `CONVERT_DUST` product action. Listing dust balances needs `READ_BALANCES`. `CONVERT_DUST` can be granted on both API-key policies and Subaccount policies; it is not an API-key-only account permission. See [API key policies](https://testnet.polyester.com/docs/developer-docs/account/api-key-policies).

For a Subaccount, the member role must be owner, admin, trader, or leveraged trader, and the Subaccount policy must grant `CONVERT_DUST`. Its default policy does not. An API key needs the action on its own policy and, when acting on a Subaccount, on the Subaccount policy too.

Each call accepts optional `subaccountId`. Without it, a Subaccount-scoped API key uses its bound Subaccount; other callers use their authenticated Main Account. A create must select the same account as its quote.

## Which balances qualify

- The whole available Trading balance must be too small for an order on any open market at the current Index Price and worth at most $10. Open orders and other reservations are excluded.
- The target Asset is never a source. Unsupported Assets and Assets without a current price are excluded. A missing price is unknown, never zero.
- One conversion takes at most 20 balances, highest value first, worth at most $200 together. Other balances wait for a later conversion.
- An account converts once every 6 hours. A refused conversion does not count toward this window; a conversion still processing prevents another one. Each target has a daily conversion limit.

## Quote, then convert

1. Call [`ListDustBalances`](https://testnet.polyester.com/docs/api-docs/connect/transfer.v1.DustConversionService/ListDustBalances) ([`GET /v1/trading/dust/balances`](https://testnet.polyester.com/docs/api-docs/rest/GET/v1/trading/dust/balances)). It returns every nonzero available Trading balance with its eligibility, available targets in preference order, the fee rate, an estimated payout after the fee, and `targetAvailable`. Omit `targetAssetId` or use `0` for the first target. This read reserves nothing.
2. Call [`QuoteDustConversion`](https://testnet.polyester.com/docs/api-docs/connect/transfer.v1.DustConversionService/QuoteDustConversion) ([`POST /v1/trading/dust/quotes`](https://testnet.polyester.com/docs/api-docs/rest/POST/v1/trading/dust/quotes)) with a `targetAssetId` from `targets`. The quote lasts 30 seconds and reserves nothing. Check `expiresAt`, the fee rate, and the payout. An empty `quoteId` means no balance qualifies or the payout rounds to zero; inspect the returned balances instead of creating a conversion.
3. Call [`CreateDustConversion`](https://testnet.polyester.com/docs/api-docs/connect/transfer.v1.DustConversionService/CreateDustConversion) ([`POST /v1/trading/dust/conversions`](https://testnet.polyester.com/docs/api-docs/rest/POST/v1/trading/dust/conversions)) with the `quoteId` and a stable client-supplied `idempotencyKey`. Conversion uses current prices. Every source must still be the whole available balance quoted; a payout more than 1% below the quoted payout is refused.
4. Read the result. `COMPLETED` means all sources moved and the payout was credited. `PROCESSING` means the outcome is still being resolved: poll [`GetDustConversion`](https://testnet.polyester.com/docs/api-docs/connect/transfer.v1.DustConversionService/GetDustConversion) ([`GET /v1/trading/dust/conversions/{conversionId}`](https://testnet.polyester.com/docs/api-docs/rest/GET/v1/trading/dust/conversions/conversionId)) with the returned `conversionId`. It completes or is refused without another create. `REFUSED` means nothing moved; inspect `refusalCode`.

The fee is deducted from the payout. Read the rate from `feeBps` rather than assuming a fixed percentage. A conversion also reports the actual `fee`, `payout`, and `quotedPayout` in REST. ConnectRPC uses U128 amounts at scale 18 (`feeE18`, `payoutE18`, `quotedPayoutE18`); REST amounts are decimal strings in whole Asset units. See [Scaled integers](https://testnet.polyester.com/docs/developer-docs/connectrpc/scaled-integers) for exact arithmetic and the linked API reference for request and response fields.

## Idempotency and history

A quote converts once. Keep the same `idempotencyKey`, quote, and account when retrying a create whose outcome is unknown; it returns the conversion already made under that key. Reusing a key or quote for another conversion returns `IDEMPOTENCY_CONFLICT`. After `SERVICE_UNAVAILABLE` or `ACCOUNT_SHARD_UNAVAILABLE`, retry the same request rather than starting a second conversion.

[`ListDustConversions`](https://testnet.polyester.com/docs/api-docs/connect/transfer.v1.DustConversionService/ListDustConversions) ([`GET /v1/trading/dust/conversions`](https://testnet.polyester.com/docs/api-docs/rest/GET/v1/trading/dust/conversions)) returns conversions newest first. `limit` defaults to 20 and is at most 100. Pass `nextPageToken` as `pageToken` for the next page, keeping the same account scope; an empty token ends the list.

## Dust errors

These `transfer.v1.ErrorCode` values also appear as REST problem `code` values and, for a refused conversion, as `refusalCode`:

- `DUST_QUOTE_EXPIRED`: the quote is over 30 seconds old, unknown, or belongs to another account. Obtain a new quote for the intended account.
- `DUST_PRICE_MOVED`: the payout fell more than 1% below the quote. Review a new quote.
- `DUST_NOT_ELIGIBLE`: a quoted balance no longer qualifies, or the payout rounds to zero. Read balances and quote again if anything qualifies.
- `DUST_WINDOW_ACTIVE`: the account converted within 6 hours or a conversion is still processing. Wait for the window or the pending conversion to finish.
- `DUST_DAILY_LIMIT`: the target reached its daily conversion limit. Choose another available target or try later.
- `DUST_BUSY`: too many conversions are in progress. Retry shortly.
- `DUST_TARGET_UNAVAILABLE`: the target cannot be paid now or has no current price. Choose another available target or try later.
- `DUST_BALANCE_CHANGED`: a source balance changed after quoting. Read balances and obtain a new quote.
- `DUST_CONVERSION_FAILED`: conversion failed and nothing moved. Obtain a new quote before retrying.

See [Error codes](https://testnet.polyester.com/docs/developer-docs/error-handling/error-codes) for numeric values and transport statuses, and [Error responses](https://testnet.polyester.com/docs/developer-docs/error-handling/error-responses) for retry rules.
