Mathematical Models and Loops Used by GliderGPT AI Agents

  1. Liquidity Pool Price Impact (Constant Product AMM):

    Plain text: P_new = P_old * (1 - Q_trade / Q_pool)

    Explanation:

    • Q_trade: Trade quantity

    • Q_pool: Total liquidity in the pool

  2. Slippage Calculation:

    Plain text: S = ΔP / P_original

    Explanation:

    • ΔP: Change in price

    • P_original: Initial price before the trade

  3. Transaction Fee Estimation:

    Plain text: F = V * r

    Explanation:

    • V: Trade volume

    • r: Fee rate (e.g., 0.3% for most DEXs)

  4. Net Proceeds from Liquidation:

    Plain text: N = P_sell * Q_sell - F - G

    Explanation:

    • P_sell: Selling price

    • Q_sell: Quantity sold

    • F: Fees

    • G: Gas costs


Loops for Computation

  1. Optimization Loop for Best DEX:

    pythonCopyEditfor dex in available_dexes:
        simulate_trade(dex, asset, trade_amount)
    select_dex_with_highest_proceeds()
  2. Trade Size Adjustment to Minimize Slippage:

    pythonCopyEditwhile slippage > threshold:
        reduce_trade_size()
    execute_trade_if_conditions_met()
  3. Dynamic ROI Calculations:

    pythonCopyEditfor price_data in real_time_market_data:
        calculate_roi(price_data, fees, gas_costs)

Last updated

Was this helpful?