Aggregator/DeFi Integration

Crystal is a fully on-chain orderbook exchange. As a result, the output of a swap is not determined by any algorithm such as x*y = k, and quotes must either be simulated onchain or locally. The L2 book can be directly queried onchain with a single rpc method, while the L3 book is also visible onchain but must be queried manually. Every order placement, cancelation, and fill emits an event with enough information to update a local copy of the L3 book.

Alternatively, the getAmountsOut and getAmountsIn function on the router can be called to easily simulate quotes, but this is not recommended for aggregators. On individual markets, the getQuote method can also be called with the option to set a slippage limit, or price point at which the quote terminates and the filled portion is returned.

To conduct a trade, it is recommended to directly call marketOrder on the desired pair. To participate in our fee sharing program, pass an address controlled by the team operating the integration as the referrer parameter. This allows for integrations to recieve a 25% fee commission (subject to change) and give its users a 25% fee discount (subject to change) in the form of a rebate. Any referral earnings and rebates can be claimed onchain anytime through the Crystal interface. It is strongly recommended to inform users of any claimable rebate after they place a trade that routes through Crystal's liquidity.

If you have any questions or would like to notify our team that you plan on integrating Crystal, please contact our team by messaging @j3remycheng on telegram.

Last updated