Inspiration

Commonly used grid trading systems can only be specified within a certain range. When the price of a trading pair exceeds this range, the grid trading system will fail. In addition, the capital utilization rate of the grid trading system is very small. In order to solve these problems of the grid trading system, we designed this double moving average trading system based on the moving average strategy. This system allows users to follow orders without having to pay attention anymore, and the contract will automatically carry out high-sell, low-buy transactions with all funds.

What it does

  1. Earns profits by selling high and buying low.
  2. Trade based on the trend of the double MAs.
  3. The capital utilization rate is 100%, and the compound interest effect is huge.
  4. Decentralization, the contract is deployed on L2, which can reduce transaction fees.
  5. After the user places an order, the contract automatically helps complete the contract operation without any intervention.

How we built it

The dual moving average trading system involves two core contracts:

  1. *Historical price acquisition system: * We obtain historical data based on Chainlink Historical Data, and use Chainlink Automation for off-chain analysis and calculation. When transaction conditions are met, on-chain transactions are performed.
  2. *Trading system: * Carry out the following transactions based on the two moving averages obtained from historical prices: 2.1 When the two MAs cross and the short MA is greater than the long MA, the price rises and the contract performs a buy order operation. 2.2 When the two MAs cross and the short MA is smaller than the long MA, the price falls and the contract performs a sell order operation

Challenges we ran into

  1. Historical Historical Data consists of different phaseIds and aggregatorRoundIds. When the required data is large, multiple phaseIds may be involved. The contract needs to specifically deal with this issue.
  2. When the price fluctuates, multiple invalid operations may be triggered, which will consume gas and principal. Therefore, the choice of moving average and the time interval of trading are very important.

Accomplishments that we're proud of

  1. Chainlink Historical Data and Chainlink Automation seamlessly integrate with our project.
  2. Our demo runs smoothly and comprehensively.

What we learned

  1. New Chainlink technology stacks usage.
  2. Good spirit of teamwork.
  3. Other skills like using AI dubbing and video editing.

What's next for SmartMA

  1. Unlock more pairs

Built With

Share this project:

Updates