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:
- 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.
- In JSON format, in https://www.npmjs.com/package/cvm-cw-types?activeTab=code, open
/cvm-cw-types/dist/cw-mantis-order/response_to_get_all_orders.json
.
- In JSON format, in https://www.npmjs.com/package/cvm-cw-types?activeTab=code, open
- Solvers Collect Data Needed to Solve Problems
AMM amounts/fees, tokens denominations, and routes are needed.
- AMM Neutron
- AMM Osmosis
- Routes
- Fees and rate limits are added if needed
These are collected off-chain and on-chain.
Coding is in progress to satisfy what the solver algorithm wants.
- 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.
- 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 https://www.npmjs.com/package/cvm-cw-types?activeTab=code, in the
/cvm-cw-types/dist/cw-mantis-order/response_to_get_all_solutions.json
file.
- 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.
- 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.
- 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.
- 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.