FXFusion
Trade artificial Forex tokens on Flow using Pyth rates, bypassing local restrictions.
Problem Statement
FXFusion is a decentralized app on Flow EVM that mints synthetic ERC20 tokens for fiat (fUSD, fEUR, fGBP, fCHF, fINR, fYEN). Users swap FLOW testnet tokens for these synthetic fiat tokens at live market-derived rates (via Pyth). Users then compose and lock baskets made of those synthetic tokens; the platform tracks real-time values and shows a PnL curve. On maturity the basket is redeemed and winners (if any) get FLOW from a FLOW pool funded by fees or contributors; jackpot winners are selected with verifiable Pyth randomness.Step-by-step data flow (what happens, in order)User chooses a token to buy (or a basket to create).Example UI: “Buy fEUR” or “Create basket with fUSD+fEUR+fINR”.Front end requests current prices from Pyth (via the off-chain service or on-chain reader).Required feeds: FLOW/USD and each fiat/USD (e.g., EUR/USD, INR/USD).Compute the FLOW → fiat conversion using those two rates.User sends FLOW to the minting contract (or calls a buy function).Front end prepares a transaction using ethers.js and the user signs it with MetaMask.Smart contract mints synthetic fiat tokens to the user.Amount minted = (FLOW_amount × FLOW/USD) ÷ (fiat/USD).Contract emits an event TokenMinted(user, token, amount, entryPriceUSD).The contract can also split a portion of received FLOW into the FLOW pool (fee → pool).User builds a basket (or directly buys tokens to add).Basket metadata recorded on-chain (NFT or struct): token addresses, token amounts, entry prices (USD per token), lock duration, owner.Example record stored: { basketId, owner, [(fUSD, 2.0, entryUSD=1.00), (fEUR,1.09,entryUSD=1.10)], lockUntil }.Off-chain Valuation Service subscribes to events and Pyth price stream.It listens to TokenMinted, BasketCreated, and Flow events.It streams prices from Pyth, computes live basket values, and stores timeseries for charting.Frontend subscribes (WebSocket/REST) to the valuation service.Users see a real-time PnL curve, token-level PnL breakdown, and live tickers for the chosen currencies.During the lock period the system continually recomputes:For each basket: currentValueUSD = Σ (amount_i × currentPriceUSD_i).initialValueUSD = Σ (amount_i × entryPriceUSD_i) (this was saved at mint).PnL% = (currentValueUSD - initialValueUSD) / initialValueUSD.These values feed the PnL chart and leaderboard.At maturity the platform finalizes the basket.Off-chain service compiles final values and qualifying lists (those meeting thresholds).It requests on-chain randomness (Pyth entropy) if jackpot selection is needed.Jackpot selection and payout (if applicable).JackpotPool contract receives the entropy callback from Pyth.Deterministic selection algorithm (seeded with that entropy) picks winners from qualified NFTs.Winners are paid FLOW from the FLOW pool; all payouts are explicit on-chain transactions.User redemption:The basket owner redeems and receives payout (common patterns):Option A (recommended for clarity): Payout in synthetic fiat tokens (e.g., fUSD) — user can later convert fUSD → FLOW if you support that.Option B: Payout converted to FLOW at the current FLOW/USD price at redemption: payoutFLOW = currentValueUSD / currentFLOW_USD. (Note: this introduces exposure to FLOW price changes.)Contract burns tokens or marks NFT redeemed; emits BasketRedeemed event.
Solution
We built FXFusion on the Flow EVM Testnet to bring forex trading on-chain. We created synthetic ERC-20 tokens like fUSD, fEUR, fINR, etc., and used Pyth price feeds to mint them at real-time FX rates.On the frontend, we used Next.js + Tailwind + ethers.js so users can swap FLOW into these tokens, build a basket of currencies, and track profits in real time with simple charts.The “hacky” part was minting our own fiat-backed tokens and pegging them to Pyth prices, which let us simulate forex positions without needing actual liquidity pools.
Hackathon
ETHGlobal New Delhi
2025
Contributors
- YashIIT0909
23 contributions
- AkshatRai07
18 contributions