🧑‍🏫Technical explanation

How the bonding curve dex contract works

  1. The DEX starts with a certain amount of STX (the main cryptocurrency on the Stacks blockchain) and a certain number of tokens.

  2. When someone wants to buy tokens, they send STX to the DEX. The DEX then gives them a certain number of tokens based on a formula in the code.

  3. As more people buy tokens, the price of the tokens goes up, following a "bonding curve." This means that the more tokens that are bought, the more expensive each additional token becomes.

  4. When someone wants to sell their tokens, they send the tokens back to the DEX, and the DEX gives them STX in return, based on the same formula.

  5. Once the DEX has reached a certain amount of STX (the "STX_TARGET_AMOUNT"), the DEX will automatically "complete" the bonding curve. This means that the DEX will burn (or destroy) any remaining tokens and send the remaining STX to a special address called the "VELAR_ADDRESS."

The bonding curve dex uses the simple formula like normal AMM Dex k = x*y

What happens if the bonding curve is completed?

There is the concept called the Last Buyer who trigger tradable to be disabled on the bonding curve DEX.

The target is 10k stx, and the current balance of the DEX is 9900, if you buy above 100 stx you will be the last buyer.

If you are the last buyer, after you receive tokens here is how it works:

  • Dex will burn 20% of the remaining tokens making an inflationary boost for the token

  • Dex will send STX and token amount to a Velar dex. The Velar team will pair STX with the token to create a trading pair and add LP for the token.

  • Trading on the bonding curve is completed and the user can't swap on the bonding curve anymore

Summary

  • Each token will be paired with 1 bonding curve dex

  • After the user deploys a bonding curve token, the user has to deploy a bonding curve dex. In the token's contract, the total supply will be sent to dex's balance

  • Dex starts with 0 STX and 10B tokens

  • Dex ends at {target} STX

  • After transfer to Velar, Dex balance should be 0 STX and 0 tokens

  • Fees:

    • 2% STX per transaction

    • 2% of STX_TARGET_AMOUNT upon curve completion

    • 75% on the Initial "Buy First" amount.

      Benefits of Buy First Fee:

      • Prevents immediate dumping by deployer

      • Supports STX City development costs

Last updated