Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add AirSwap #615

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Feat: Add AirSwap #615

wants to merge 1 commit into from

Conversation

dmosites
Copy link

AirSwap (https://airswap.io/) is an RFQ DEX.
Counter-party discovery and token pricing are communicated off-chain; atomic token swaps are settled on-chain. AirSwap itself is a technology provider and runs no infrastructure of its own. More info on our wiki.

Notes
AirSwap uses a smart contract (Registry) for server URL discovery.

AirSwap calls multiple third-party server URLs for pricing and orders.

  • We use Fetcher to make HTTP calls on an interval.
  • Fetcher is not instantiated for slave AirSwap instances.
  • Prices are communicated to slaves via the cache.

Limitation: Tests cannot pass reliably on third-party servers, so:

  • During tests an env var overrides URLs to point to a local server.
  • Alternatively, we could pass a isLocal flag into initializePricing
  • Alternatively, we could check process.env.NODE_ENV is test

Flow

  1. initializePricing is called by the engine
    a. Registry starts up; hydrates; listens for event updates to track active server URLs
    b. Worker starts up (if not a slave process); writes pricing from active servers URLs to cache.
  2. getPoolIdentifiers returns unique identifiers for active server URLs for a given token pair.
  3. getPricesVolume pulls identifiers for a pair and reads the cache for pricing.
  4. preProcessTransaction calls get*SideOrder on winning server.
  5. getSimpleParam encodes the function call for the SwapERC20 contract.

Tests
For the initial review, simple tests are passing.
airswap-e2e.test.ts, airswap-events.test.ts, airswap-integration.test.ts.

* initial commit

* comments and cleanup
@dmosites dmosites changed the title Integrate AirSwap V4 Feat: Add AirSwap Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant