Ramstack implements math modules and algorithms on-chain to simulate token pair price and predict option price.
For more detailed information on product features, you can refer to our project description on TaiKai.
Our project employs the main idea of developing an on-chain algorithm using Monte Carlo simulation and implementing distributed computation using smart contracts to simulate the token price.
-
We use Aptos_std and Aptos_framework as the foundation to develop Ramstack. The most important modules are fixed_point64 and math_fixed64.
-
To generate random numbers following probability distributions, we utilize the Aptos randomness API to generate uniform distribution numbers initially. Subsequently, math formulas such as Box-Muller and inverse CDF are applied to transform these numbers.
-
For frontend development, we employ Aptos-labs/ts-sdk, Next.js, Redux Toolkit, Rechart, and Ant Design.
-
PI: Approximate the value of π using the Bailey-Borwein-Plouffe and Leibniz formulas.
-
Cosine and Sine: Approximate Cos(x) and Sin(x) using the Maclaurin series formula, where x is in radians.
-
Fixed Point64 with Sign: Enhance the original fixed_point64 module in the aptos_std package to support both positive and negative numbers.
-
Math Fixed64 with Sign: Enhance the original math_fixed64 module in the aptos_std package to allow operations such as multiplication, division, natural logarithm, mean, standard variation, minimum, maximum, and square root using fixed_point64_with_sign. This enables operations on both negative and positive numbers.
-
Box-Muller: Transform random numbers of uniform distribution (generated from Randomness) to normal distribution using the Box-Muller method.
-
Chi-square Transform: Transform random numbers of uniform distribution to Chi-square distribution. (uniform -> normal -> Chi-square)
-
Laplacian Transform: Transform random numbers of uniform distribution to Laplacian distribution using the inverse CDF.
-
Exponential Transform: Transform random numbers of uniform distribution to Exponential distribution using the inverse CDF.
-
Prob_distribution: Include view functions to generate random numbers based on inputs and specific distributions.
-
Price_simulation: Include view functions to generate price paths based on inputs and the Monte Carlo algorithm.
To build & test smart contract:
- Go to smart contract folder, e.g.
cd contracts/ramstack
- To compile:
aptos move compile
- To test:
aptos move test
- To deploy:
aptos move publish --expiration-secs 6000000
To run Ramstack frontend application:
cd frontend
npm i
npm run dev
for the dev modenpm run build
&npm run start
for the production mode.