Skip to main content

Integration Guides

Integration Guide for Apps/Wallets

Wallets and Banana Gun bots will be able to plug into MANTIS using an open source UI package.

The end-to-end flow for getting data for solvers, posting the solution, and executing solutions on chain is as follows:

  1. User Posts Problem
  • The user sends their transaction to our Cosmos CosmWasm contract via RPC.
  • The order ends up in storage.
  • It is the user's responsibility to consult an oracle to set limits he wants.
  • The problem format is here.
  1. Solvers Collect Data Needed to Solve Problems
  • AMM amounts/fees, tokens denominations, and routes are needed.

  • These are collected off-chain and on-chain.

  • Coding is in progress to satisfy what the solver algorithm wants.

  1. Solvers Run Optimization Algorithm
  • Solvers solve for:
    • Maximal volume via Coincidence of Wants (CoWs), where CoWs are matched up to the limit.
    • The remaining amount of the order is proposed to be settled via constant function market maker (CFMM) routes
  • Python coding is in progress here.
  • Rust port is here.
  1. Solvers Post Solution On-Chain Into Contract
  • Python solver output is in progress.
  • The final matrix output is to be converted into a call to a standard Cosmos CosmWasm RPC.
  • The solution message to RPC format is in, in the /cvm-cw-types/dist/cw-mantis-order/response_to_get_all_solutions.json file.
  1. Contract Choses the Solution Clearing the Largest Volume
  • Currently, any solution of several is picked each block for testing.
  • The final configuration will be 2 blocks of solutions.
  • The contract checks that the solution respects the user's limits.
  1. Contract Executes CoW in the Same Transaction
  • CoWs happen on the same chain.
  • These are coded as simple CosmWasm transfers back and forth between accounts.
  1. Contract Sends a Message to Convert Route to CVM
  • Each solution has a simplified version of routes which is mapped 1:1 to a more detailed lower level CVM program.
    • Coding is in progress. The solution route tree is here. An equivalent root of the tree in the CVM is here.
  1. The CVM is Executed
  • This mostly involves converting CVM instructions to IBC packets.

Problems can be submitted from a wallet or application via RPC to MANTIS. Here is an example typescript problem for submission to MANTIS.