Mathematical Models and Loops Used by GliderGPT AI Agents
Liquidity Pool Price Impact (Constant Product AMM):
Plain text:
P_new = P_old * (1 - Q_trade / Q_pool)
Explanation:
Q_trade
: Trade quantityQ_pool
: Total liquidity in the pool
Slippage Calculation:
Plain text:
S = ÎP / P_original
Explanation:
ÎP
: Change in priceP_original
: Initial price before the trade
Transaction Fee Estimation:
Plain text:
F = V * r
Explanation:
V
: Trade volumer
: Fee rate (e.g., 0.3% for most DEXs)
Net Proceeds from Liquidation:
Plain text:
N = P_sell * Q_sell - F - G
Explanation:
P_sell
: Selling priceQ_sell
: Quantity soldF
: FeesG
: Gas costs
Loops for Computation
Optimization Loop for Best DEX:
pythonCopyEditfor dex in available_dexes: simulate_trade(dex, asset, trade_amount) select_dex_with_highest_proceeds()
Trade Size Adjustment to Minimize Slippage:
pythonCopyEditwhile slippage > threshold: reduce_trade_size() execute_trade_if_conditions_met()
Dynamic ROI Calculations:
pythonCopyEditfor price_data in real_time_market_data: calculate_roi(price_data, fees, gas_costs)
Last updated
Was this helpful?