> For the complete documentation index, see [llms.txt](https://gaslockr.gitbook.io/gaslockr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gaslockr.gitbook.io/gaslockr/core-pricing-model/afp-mechanism.md).

# AFP Mechanism

GasLockR uses a pre-trained AI model for its core pricing output. This is called the Adaptive Flat-Rate Pricing(AFP) mechanism, which reflects an intelligent threshold for gas price, guiding users with a data-driven benchmark anchored in network conditions, within an upcoming expected volatile period.&#x20;

Specifically, this innovative AI model employs two main parts as input elements for training: one part belongs to the time series prediction, which contains historical gas prices as well as trading frequency; the other part is other instantaneous elements, which contain, for example, social network sentiments, macro factors, technical indicators, on-chain data. AFP mechanism provides short-term optimal constant gas prices as a threshold in real-time.

The formulas presented below offer a simplified abstract understanding of the AI model used by AFP mechanism. They encapsulate the model's two main components:

**1.Time Series Prediction**

ARIMA is used as an autoregressive integrated model. Historical gas prices $$p(t)$$and transaction frequency $$f(t)$$:

$$
p\_{\text{predicted}}(t+1) = \beta\_1 p(t) + \beta\_2 p(t-1) + \dots + \beta\_n f(t) + \epsilon\_t
$$

where $$β\_i$$ are the model parameters, and $$\epsilon\_t$$ is the error term.

**2.Instantaneous Element Analysis**

Utilizes a multifactor regression model or a machine learning classifier. Social network sentiments $$s(t),$$ macroeconomic factors $$m(t)$$, technical indicators $$I(t)$$, and on-chain data $$d(t)$$:

$$
p\_{\text{instant}}(t) = \alpha\_1 s(t) + \alpha\_2 m(t) + \alpha\_3 I(t) + \alpha\_4 d(t) + \eta\_t
$$

where $$α\_i​$$ are the weight coefficients, and $$η\_t​$$ is the error term.

#### AFP Algorithm

AFP output is a weighted combination of the outputs from the time series prediction and the instantaneous element analysis:

$$
p\_{\text{final}}(t+1) = \gamma \cdot p\_{\text{predicted}}(t+1) + (1-\gamma) \cdot p\_{\text{instant}}(t)
$$

where $$γ$$ is a tuning parameter that balances the contribution of both parts.

This abstract representation simplifies the complex interplay of historical and real-time data processing within the AFP AI model. Also, the oracle and ZK(zero-knowledge) proofs are leveraged to make the output credible on-chain, ensuring the verifiability of execution. The entire model is still being iterated and optimized, and the combination of above parameters will be made public when it goes live on mainnet.

***

*Times of regression tests have been conducted for different time intervals using gas price data from* the past to dat&#x65;*, and selected typical test result as shown below.*

<figure><img src="/files/H8jZQlMedwJGuOEg1bnm" alt=""><figcaption><p>AFP threshold simulation for per upcoming 300 blocks</p></figcaption></figure>

*The AFP mechanism is reflected in our different GasFi beta products, and we will continue to update the latest experimental content.🌀*

&#x20;
