This note is for backend/contracts work around SO4 GM pools, test tokens, and the faucet.
Baseline reference: GMX Synthetics models a market as:
Market.Props {
marketToken,
indexToken,
longToken,
shortToken
}
MarketFactory.createMarket(indexToken, longToken, shortToken, marketType) deploys a new GM market token and stores the market fields. A GM pool consists of an index price feed plus long and short backing tokens. Fully backed markets usually use indexToken == longToken and a stable shortToken, for example ETH/USD backed by WETH-USDC.
contracts/market_factoryfollows the GMX shape: it takesindex_token,long_token,short_token, andmarket_type; deploys a deterministic market token; and stores market token, index token, long token, and short token indata_store.contracts/market_tokenrepresents the GM LP token and also acts as the pool custodian for backing tokens after deposits are executed.contracts/deposit_handlerfollows the GMX two-step flow: user creates a deposit, keeper executes it with oracle prices, backing tokens move into the market token, and GM tokens are minted to the receiver.- Pool accounting is keyed by
(market_token, token), which matches GMX's risk-isolated per-market accounting model. - Fully backed test markets should be modeled as:
TWBTC/USD:
index_token = TWBTC
long_token = TWBTC
short_token = TUSDC
TETH/USD:
index_token = TETH
long_token = TETH
short_token = TUSDC
TXLM/USD:
index_token = TXLM
long_token = TXLM
short_token = TUSDC
The deployed contract interface requires:
create_market(caller, index_token, long_token, short_token, market_type)
but scripts/bootstrap.sh currently calls create_market without market_type.
Fix: compute/pass a BytesN<32> market type, such as sha256("DEFAULT"), and pass it in every market creation command. Without this, the scripted pool bootstrap is not consistent with the current contract ABI or GMX's market factory model.
GMX markets require many per-market risk/config keys: max pool amounts, max open interest, reserve factors, swap/position impact factors, fee factors, borrowing factors, funding factors, and PnL caps.
Current bootstrap.sh mostly prints or attempts one config path and even calls a pool_amount_key helper on MARKET_FACTORY, which does not appear to exist in the factory contract. This means markets may be created but not safely configured like GMX markets.
Fix: add real key-generation helpers or a config contract/script that writes the actual gmx_keys keys into data_store for each market.
Older docs describe test assets as Stellar classic assets wrapped by SACs. The new contracts/test_token is a custom mintable SEP-41-like Soroban token, and contracts/test_faucet mints through token owner authority.
This is acceptable for testnet UX, but it is not the same as the prior SAC-based plan.
Backend should make this explicit:
- If using
test_token, updateTEST_ASSETS.md, Make targets, and frontend env assumptions to stop saying these are SAC-backed classic assets. - If production-like Stellar asset behavior is desired, keep SAC tokens as the canonical path and use faucet/distributor flows around trustlines.
test_faucet expects each test_token to be initialized with the faucet contract as owner. The faucet can mint enabled tokens to any claiming user after cooldown.
That is fine for TUSDC, TWBTC, TETH, and TXLM on testnet, but production collateral must not use this owner/minter model.
Recommended testnet token list:
TUSDC - stable short token / common collateral
TWBTC - BTC/USD long and index token
TETH - ETH/USD long and index token
TXLM - XLM/USD long and index token
Frontend currently uses symbolic market/token IDs such as BTC-BTC-USDC, BTC, and USDC. Contracts require real Soroban Address values:
market = market_token contract ID
initial_long_token = test token contract ID
initial_short_token = test token contract ID
After pools are created, write the generated market token IDs and test token IDs into the frontend env/config. Do not call protocol contracts with symbolic strings.
Every market token initializes with name GMX Market Token and symbol GM. This matches the broad GM concept but is weaker than production GMX UI/indexer expectations, where markets are identified by their market token address and displayed with pair labels.
Recommendation: keep GM as the token symbol if desired, but ensure frontend/indexer displays markets from stored index_token, long_token, and short_token, not only the GM metadata.
market_utils::get_pool_value includes long USD, short USD, impact pool, and net PnL. It currently sets total_borrowing_fees: 0 and does not appear to apply the fuller GMX PnL cap / max PnL factor model for deposits, withdrawals, and trader operations.
This is an important difference from GMX pool pricing. It may be acceptable for an MVP, but it should be documented as simplified economics.
GMX supports single-token pools where longToken == shortToken, with different assumptions around swaps and price impact. The current model may technically allow equal long/short token addresses, but the config layer does not appear to enforce the GMX-specific single-token behavior.
Recommendation: do not advertise single-token GM pools until config and execution paths are reviewed for that case.
GM pools are the current consistent piece. GLV pools in GMX aggregate liquidity across supported GM markets and shift liquidity across them based on allocation/utilization rules.
Current frontend has GLV concepts, but deployed contract env still lacks GLV router/vault contracts. Treat GLV as disabled/mock until real GLV contracts exist and are wired to real GM market token IDs.
- Decide canonical test token path:
- custom
test_token+test_faucet, or - Stellar classic assets + SAC.
- custom
- Deploy/configure test tokens:
TUSDC,TWBTC,TETH,TXLM.
- Patch
bootstrap.shto passmarket_type. - Add robust market config writes for all required GMX-style keys.
- Create one market first:
TWBTC/TUSDC, withindex == long == TWBTC.
- Submit oracle prices for both
TWBTCandTUSDC. - Seed liquidity through
deposit_handler. - Export the generated token and market token contract IDs for frontend consumption.
- Repeat for
TETH/TUSDCandTXLM/TUSDC.
The market core is directionally GMX-consistent. The main issues are around scripts/config, test-token architecture drift, symbolic frontend IDs, simplified pool economics, and missing GLV support.