FiatExDocs

Build & operate

Contract integration

Entry points, amounts, and events for clients integrating with the FiatEx contracts.

Contract responsibilities

ContractResponsibility
FiatExPoolFactoryCreates tokens and permanently held v4 positions; stores launch terms.
FiatExPoolHookEnforces pool fees and liquidity rules; tracks bonding and executes buybacks.
FiatExZapRouterRoutes native-USDC buys and sells, simulates quotes, and exposes pool snapshots.
FiatExStartingPriceOracleVerifies the price updates used for currency creation.
FiatExTokenERC-20 with immutable metadata URI, initial mint, and holder-initiated burn.

Use the ABI matching the deployment. The creator-buyback revision adds a field to the launch tuple and changes hook event signatures. An older ABI is not compatible merely because the function name looks familiar.

Native and pool units differ

Native USDC uses 18 decimals. The pool-facing USDC ERC-20 and EURC use 6, cirBTC uses 8, and MARCO uses 18. FiatEx tokens and fx currencies use 18. Read the quote currency’s decimals before displaying or calculating an amount. One whole USDC is therefore 10¹⁸ native units or 10⁶ pool units.

native raw USDC = pool raw USDC × 10^12
1 basis point = 0.01%
creatorFeeBps: 0..1500
buybackShareBps: 0..10000

Native buy amounts must be representable at the pool’s six-decimal precision. Do not pass a token’s 18-decimal amount where a raw USDC reserve is expected. Prices named X18 are scaled by 10¹⁸; check which quote asset they describe.

Primary entry points

Factory

launchToken(TokenLaunch) takes name, symbol, metadataURI, quoteAsset, creatorFeeBps, buybackShareBps, and salt. It computes the price; it does not accept a creator-selected starting price.

createCurrency(...) takes the currency code, metadata URI, salt, verified price updates, minimum and maximum starting price, and deadline. Send exactly the currency deposit plus the quoted oracle update fee.

Router

buyWithNativeUsdc(token, minimumTokensOut, recipient, deadline) receives the purchase amount as native value. sellForNativeUsdc(token, tokensIn, minimumNativeUsdcOut, recipient, deadline) transfers the seller’s approved tokens and pays native USDC.

Use quoteNativeBuy(token, nativeUsdcIn) through an eth_call simulation with the same native value and a funded caller. It is payable, not a view function. quoteNativeSell(token, tokensIn) simulates the sell. Quote simulations revert their internal swap effects and are not transactions a client needs to broadcast.

Hook

checkpointBonding(token) records an eligible milestone after settlement. buybackExecutionLimits(token) returns the eligible budget and price limit or reverts when conditions fail. executeBuybackAndBurn(token) spends only that token’s queued quote and burns its output.

claimableTradingFees(beneficiary, quoteAsset) returns unpaid fees for that beneficiary. Only that address may call claimTradingFees(quoteAsset, recipient). The claim settles existing fees; it cannot remove LP or spend the buyback queue.

External v4 settlement

Use the registered pool key, including its hook. The pool has zero v4 LP fee; the hook accounts for creator tax and platform fees through swap deltas. Consumers must handle these hook deltas and the real quote transfer.

The hook attempts fee payment during the swap. If payment fails, it mints backed ERC-6909 fee claims and records the beneficiary’s credit. Deferred-settlement routers still have to settle every swap delta before unlocking ends. Verify the actual router action sequence on Arc.

User swaps require full fills. Use an explicit deadline and meaningful minimum output. Local compatibility tests use the installed v4 router implementation, not proof that every deployed router or Permit2 path is supported.

Events used by the indexer

  • AssetCreated and PoolLiquidityLocked identify launches and their positions.
  • TradeExecuted records FiatEx router trades. PoolTradeExecuted covers compatible external routes; do not count both for the same FiatEx swap.
  • TradingFeesPaid separates the net creator-wallet payment, platform fee, and queued buyback portion.
  • TradingFeesDeferred increases the beneficiary’s unpaid balance. TradingFeesClaimed reduces it and identifies the receiving wallet. These events do not change the buyback queue.
  • BuybackExecuted records actual quote spent and tokens burned.
  • ERC-20 Transfer to the zero address reduces current supply. Do not reduce it again when handling BuybackExecuted.
  • BondingCompleted records the one-time milestone.
Check addresses before integrating