AshSwap Docs
Comment on page

How does AshPerp Work

  • Trades are collateralized with USDC. The leverage is synthetic and backed by the Perpectual Vault.
  • The Perpectual Vault acts as the counterparty, handling PnL distributions and receiving a portion of trading fees. Specifically, USDC is taken from the Perpectual Vault to pay the traders PnL (if positive) or receives USDC from trades if their PnL was negative.

AshPerp Oracle System

Oracles are data sources that provide real-world information to smart contracts. In AshPerp, they verify asset prices for accurate trading execution.They ensure that trading decisions are based on accurate asset prices, preventing manipulation and errors.AshPerp implements 3 on-demand oracle nodes in the following workflow:
  • Whenever an open order request is sent to the trading contract, the contract asks for the asset's spot price from an aggregator contract.
  • The aggregator consults oracle nodes to get the median price from Centralized Exchanges APIs (xxx, yyy, zzz), currently we have Binance, Bitfinex,, Gemini, hitBTC, Huobi, Kraken, Okx, Crypto-compare, Gate, and MEXC in the API list.
  • Prices are cross-verified with Hatom Price Feed to reject outliers. If there is more than a 1.5% difference from the Hatom Price Feed, it rejects the node answer and waits for the next answer.
  • After the price fulfills all conditions, the aggregator contract will again calculate the median price and send the final price to the trading contract to execute the order.

Trading Flow

  • Supported order types are Market, Limit, and Stop.
  • Market orders execute immediately, while other orders may involve Matching Bots.
  • Orders closed by these actions: Take Profit, Stop Loss, and Liquidation are automated executed by matching bots.
  • Liquidation prices are calculated based on collateral, borrowing fees, and leverage.

Fee Structure

  • Dynamic spreads, borrowing fees, and rollover fees are part of the fee structure.
    • Dynamic Spreads: Fees that vary based on market conditions and asset pair volatility.
    • Borrowing Fees: Charges associated with borrowing funds for leveraged trading.
  • Fees vary based on asset pairs, leverage, collateral, and order type.

Current Limitations on AshPerp Devnet

  • Three open trades per pair per wallet.
  • Maximum Stop Loss at 80%, and Maximum Profit at 900%.
  • Maximum Leverage:
    • For crypto: x100
    • For forex: tbu
Last modified 13d ago