Go to file
Geoff Taylor cd7cdab540 Added commands to wrap and unwrap SOL. 2021-06-02 20:03:46 +01:00
bin Added commands to wrap and unwrap SOL. 2021-06-02 20:03:46 +01:00
meta Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
scripts Added CsvFileNotificationTarget. 2021-05-21 20:02:54 +01:00
.dockerignore Added wallet balancing. Big changes throughout to support this. 2021-05-06 14:21:40 +01:00
.envrc Moved development commands to 'scripts', so 'bin' is for actual commands. 2021-04-29 10:53:01 +01:00
.gitignore Refactored PollingLiquidator into ReportingAccountLiquidator and LiquidationProcessor 2021-05-21 14:28:42 +01:00
.mypy.ini Refactored PollingLiquidator into ReportingAccountLiquidator and LiquidationProcessor 2021-05-21 14:28:42 +01:00
AccountLiquidator.ipynb Fixed reference to group name in LiquidationEvent. 2021-05-21 20:40:40 +01:00
AccountScout.ipynb Moved AccountInfo into BaseModel, moved 'fetch' methods to appropriate objects. 2021-05-14 15:51:29 +01:00
BaseModel.ipynb Added commands to wrap and unwrap SOL. 2021-06-02 20:03:46 +01:00
Constants.ipynb Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00
Context.ipynb Some tweaks to improve 5-token group handling. 2021-06-02 09:54:48 +01:00
Decoder.ipynb Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
Dockerfile Split BasketTokenMetadata up. Improved linting. 2021-05-11 19:24:02 +01:00
Instructions.ipynb Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00
LICENSE
Layouts.ipynb Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
Liquidation.ipynb Added TransactionScout to show Mango transaction details. 2021-05-13 20:32:23 +01:00
LiquidationProcessor.ipynb Better retry functionality with backoff pauses. 2021-05-28 17:16:53 +01:00
Notification.ipynb Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00
Observables.ipynb Added warnings to FunctionObserver instead of propagating exceptions. 2021-06-01 12:08:24 +01:00
Pandas.ipynb Added a common base class for addressable account objects. 2021-05-17 12:04:17 +01:00
Quickstart.md Renamed commands to better reflect purpose. Updated Quickstart. 2021-05-24 10:40:33 +01:00
README.md Refactored PollingLiquidator into ReportingAccountLiquidator and LiquidationProcessor 2021-05-21 14:28:42 +01:00
Retrier.ipynb Retry pauses now uses kangda's 4,8,16,20,30 seconds pauses. 2021-05-28 17:20:07 +01:00
ShowAccount.ipynb Some tweaks to improve 5-token group handling. 2021-06-02 09:54:48 +01:00
ShowAllMarginAccounts.ipynb Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
ShowGroup.ipynb Fixed context for ShowGroup. 2021-06-01 12:34:53 +01:00
ShowMarginAccount.ipynb Removed unused import. 2021-06-02 09:57:50 +01:00
ShowRipeMarginAccounts.ipynb Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
TradeExecutor.ipynb Extended use of Lookups - serum buys and sells no longer need a Group. 2021-06-01 19:16:59 +01:00
TransactionScout.ipynb Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00
Wallet.ipynb Moved AccountInfo into BaseModel, moved 'fetch' methods to appropriate objects. 2021-05-14 15:51:29 +01:00
WalletBalancer.ipynb Fixed tests to use new Token constructor. 2021-06-01 19:26:33 +01:00
ids.json Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
requirements.txt Refactored PollingLiquidator into ReportingAccountLiquidator and LiquidationProcessor 2021-05-21 14:28:42 +01:00
solana.tokenlist.json Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00

README.md

🥭 Mango Explorer

⚠ Warning

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Run these notebooks on Binder: Binder

Introduction

I am not yet confident in the figures and calculations. Please don't rely on this code yet!

This is the start of a project to explore and provide useful code for Mango Markets.

There are some notebook pages to explore Mango account structures for your own accounts.

There is also a functional liquidator.

The goal is not to be easy to use (although that would be nice!). The goal is to show you how the system works and allow you to use some simeple code to interact with it.

Running the liquidator

Check out the Quickstart documentation - it's a walkthrough of setting up and running the liquidator, from creating the account, 'balancing' the wallet across the different tokens, and running the liquidator itself.

It can take around 30 minutes to run through.

Requirements:

  • A server with docker installed
  • Some SOL to pay for transactions
  • Some USDT to fund the liquidation wallet

Running the notebooks

Most notebooks are currently 'runnable' - if you open them in your browser and press the 'fast-forward' button () on the toolbar

Verify a user's account is properly set up for Mango Markets liquidators

Mango Markets should set up your account automatically for trading, but the requirements for running a liquidator can be a bit more extensive. For instance, for trading you need token accounts for both tokens in the trade but to run a liquidator you need token accounts for all tokens in the Group.

The AccountScout notebook can verify any user's root account to make sure it meets the requirements of the liquidator.

Show your Mango margin accounts

To try this out, go to the Show Account page and enter your public key. (Note: I know you're running untrusted code, but it can't do much if you only give it your public key.)

Show all Mango margin accounts

To try this out, go to the Show All Accounts page and run the code.

Load all margin accounts into a Pandas DataFrame

To try this out, go to the Pandas page and run the code.

Pandas is a data analysis and manipulation tool and it's useful for sorting and slicing large data sets.

The Pandas page can currently show you:

  • The total assets and liabilities currently in Mango Markets margin accounts.
  • The top ten margin accounts with the most assets.
  • The top ten margin accounts with the most liabilities.
  • The top ten margin accounts with the lowest collateralisation.

Structure of this project

The code is (nearly) all Python in Jupyter Notebooks.

Some notebooks are more code files than useful notebooks themselves (although being able to easily run the code is still a boon):

  • The Layouts notebook contains the low-level Python data structures for interpreting raw Solana program data.
  • The BaseModel notebook contains higher-level classes for loading and working with that data.

Other notebooks are more user-oriented:

  • Show Account to show data pertaining to a single Mango Markets margin account.
  • Show All Accounts to show data for all Mango Markets margin accounts.
  • Pandas to load data into a Pandas DataFrame to allow for further manipulation and analysis.

References

TODO

Still to come:

Don't hold your breath waiting for these!

Support

You can contact me @OpinionatedGeek on Twitter.