Redpoint Arbitrage
Astroport MEV proposal
Our team
Redpoint Arbitrage is created by a self-funded small business. Its owner, Kyle Moser, has degrees in Computer Science and Cybersecurity and over a decade software engineering experience, including building major public key infrastructure.
In addition, our team helped build Sycamore Tax app and has several grants with Osmosis, including a “Testnet arbitrage” grant to improve testnet price accuracy. Finally, we built the MEV products below, which will aid an understanding of our Astroport proposal.
MEV products
Osmosis Arbitrage Bot
8 months ago Redpoint launched an arbitrage bot on Osmosis which competes with other arbitrage bots to earn revenue. We gained a deep understanding of Tendermint and Cosmos SDK, implementing mempool spying and presigned arbitrage TXs. Our bot supports simple cycles (graph theory) of between 3 and 7 vertices. Most arbitrage can be captured by cycles of length 3 or 4.
-
For cycles of length 3 or 4, we use Johnson’s algorithm to discover the cycles.
-
For all cycles, we use a customized version of the Bellman Ford graph algorithm to discover “negative weight” (e.g., potentially profitable) arbitrage opportunities.
MEV simulator (Redpoint)
Most MEV is wasteful, spamming failed TXs on chain (only one bot can “win” the search). To solve this problem, Redpoint created a simulator API for Osmosis and Junoswap (currently live for Osmosis) which works as follows:
-
The trading website queries our API, asking “what arbitrage trade will be possible if the user makes the following trade {1000 OSMO for ATOM using pool 1}”?
-
The API answers “Trade 300 OSMO through pools 1, 3, 5 to earn 1.5 OSMO in arbitrage”.
-
The website submits a single TX with two swaps, (1) the user’s swap and (2) the arbitrage swap.
-
This technique ends “racing” and TX spamming. Since TXs are atomic, ours wins automatically.
-
On chains that support CosmWasm, the arbitrage swap is submitted through a smart contract.
-
Defiant has a working Junoswap contract for this (which we plan to adapt for Astroport).
Redpoint invented the MEV technique above (on-chain example). We released a CLI tool for Osmosis users to arb their own trades here as well as a Javascript API for partners.
Astroport proposal
Redpoint’s MEV capture solution for Astroport will complete in three stages. Our proposal is designed to begin capturing arbitrage for the protocol during stage one. Our arbitrage algorithms support all pools types used by Astroport (constant product and stableswap invariant).
Our simulator API will be used to find arbitrage routes (see above) and our smart contract will be used to submit trades. Stage one will complete and start capturing arbitrage for Astroport in roughly 6 weeks, and Redpoint will take ZERO payment until stage two is completed.
Arbitrage smart contract
This contract applies to all stages. Our arbitrage smart contract is already tested (for the criteria listed below):
-
Users never send funds or conduct swaps with our smart contract, so there is no risk to the user.
-
A smart contract failure never causes the user’s TX to fail. At a high level, it does this by using submessages.
-
Our system consists of one smart contract that distributes rewards, and one that performs swaps.
-
If there are no rewards, no arbitrage is distributed, but the TX still succeeds.
Stage One: Off chain simulator
Our estimated timeline is 6 weeks since we have already built a simulator and arbitrage smart contract (for other DEXs). Our Astroport smart contract will support splitting arbitrage profits as follows:
-
A percentage (note: this can be set from 0 to 100%) of all profits will go to an Astroport-controlled grants address, where the grants team can manage the funds to be put towards protocol development.
-
The remainder of profits will go to the user who initiated the trade.
Redpoint will take NO payments during stage one.
Stage Two: Staker/governance distribution
During stage two, we will modify the distribution mechanism as voted on by the Astral Assembly. We propose sending arbitrage profits to stakers and governance. We propose doing so via the Maker contract, by sending funds to Maker with an arbitrage collection strategy (like the fee collection strategy). Therefore, in stage two:
-
For one year, ten percent of arbitrage revenue will go to Redpoint (via the smart contract). After one year, the fee will be reduced to five percent.
-
A preconfigured percentage of all remaining profits will be distributed as decided by Astroport governance. We propose it goes to stakers and governance as defined by the Astroport Maker contract.
-
The remainder of profits will go to the user who initiated the trade.
We estimate stage two will take approximately 3 months to complete after stage one is delivered.
Stage Three: On-chain simulator
In stage three, Redpoint will build a fully on-chain solution. This means our off-chain simulator will no longer be needed. We will develop a smart contract that solves the arbitrage route problem (using the same algorithm described in this paper, see Differentiators below). Our fee schedule will remain the same (e.g., 5% of arbitrage revenue if it has been more than one year since stage two was introduced). We estimate that stage three will take 6 months to complete after stage two is delivered.
Differentiators
Our tooling is publicly available (see our Twitter and links throughout this proposal). The Astroport community can be assured that we are fully capable and can use our tools rather than taking our word for it.
-
Our arbitrage algorithm is more advanced (faster, and equally as accurate) as any of our competitors.
-
We derived an algebraic solution to the arbitrage problem (how many tokens, what routes).
-
Competitors typically approximate a solution through repeated guessing.
-
Our algorithm works in under 500 microseconds in the worst case (measured on localhost).
-
Our simulator tools are Dockerized, inexpensive, highly available, scalable, and process thousands of requests/second on a single node.
Project Deliverables
Off-chain simulator and Javascript API: Allows Astroport front-end to query the Redpoint API for arbitrage related information and submit to our smart contract.
On-chain smart contract v1 Smart contract created in stage one. Allows Astroport to submit an arbitrage trade. Open source contract and test library which proves our simulator and smart contract correctly produce trade routes & successful earn arb revenue.
On-chain smart contract v2 Smart contract created in stage two. Updated distribution to stakers/governance. Open source contract and test library as above.
On-chain smart contract v3 Smart contract created in stage three. Fully on-chain (Astroport frontend will not need to call any off chain API). Same as smart contract v2.