Motivation
Solana users are used to a Solana-native trading experience, wherein they can buy and sell SPL tokens with other tokens in their wallet. However, they’re unable to interact with liquidity that exists elsewhere.Description
Concurrency & Counterparties
The liquidity that Solana users are interacting with resides offchain. In contrast to the atomic behavior of trades that interact with liquidity that is natively on Solana, clients need to handle asynchronous behavior: multiple transactions that can land over several Solana slots fill the open order transaction.
There are two parties involved in the lifecycle of a CLP trade: the liquidity provider and the taker.
The taker and the LP interact in a permissionless multi-transaction trade. In order to increase or reduce
positions, the taker writes the limit price and trade side to the CLP contract.
Increasing Positions
The LP reads the limit price and side written onchain through the first transaction and mints SPL tokens representing the position entered into at a price that is equal to or better than the limit price.
Reducing Positions
The LP reads the limit price and side written onchain through the first transaction and transfers stablecoins to the taker equivalent in value to the size of the position reduced at the limit price or better.