NEAR CONbine

Showcasing how adding Combined Swap on top of an existing Near DEX improves prices.

Motivation

Inspired by DEXes not on Near such as CowSwap and OneInch, I thought Near was lacking a "combined swap" mechanism on top of an aggregation of pools and order books. That would offer better prices on top of existing Near DeXes that have either Pools or Order Books, such as Ref.Finance, or Far Away Swap (of which I am the CTO).

The combined swap mechanism splits your swap in two parts: One part is done with market orders on an aggregated order book, and one part is swapped using aggregated pools AMM. As was simulated by Luaron, a fellow CS student, a few months ago, this strategy offers better prices in some scenarios, such as big transactions.

What was lacking before the hackathon on Near was a nice frontend and a few SCs that would do this combined swap mechanism and also compute a nice Pool/Order ratio (called "Pool ratio") based on the chosen aggregated pool's and order book's states.

So that's what I tried to do.

Result & self-critique

100 % working svelte+typescript frontend. Partially working SCs in rust, with only the ability to do Combined Swap on top of Far Away Swap's pools and order book because I found it hard to do so many cross-contract calls.

Integrating the client SDK in a frontend framework is super non-obvious because of compatibility flaws of the JS library with modern JS tooling (according to my own experience), but I had figured it out already on other projects.

Now I'm having a better vision on how to add Combined Swap on top of other platforms, such as Ref.Finance's pools or Spin's order book.

Quite satisfied with the progress as a solo dev on this. Had to use my own frontend libraries and SCs primitives to speed the work a lot and focus on the Combined Swap mechanism, while not compromising on the UX and design.

Built With

Share this project:

Updates

Submission history