Go to file
Geoff Taylor f2d4e7c13f Added Serum trading.
* Added nasty patch around pyserum bug
* OpenOrders can now provide (on-demand) the pyserum representation OpenOrdersAccount
* New context methods -unwrap_transaction_id_or_raise_exception() and random_client_id()
* Added Retrier and retry_context() function
* Added TradeExecutor and SerumImmediateTradeExecutor classes to trade on Serum
2021-05-04 17:18:09 +01:00
bin Added Serum trading. 2021-05-04 17:18:09 +01:00
meta Added timestamp to logging. 2021-04-30 15:20:59 +01:00
scripts Fixed some script issues. 2021-04-29 14:23:05 +01:00
.dockerignore Initial import. 2021-04-14 16:51:39 +01:00
.envrc Moved development commands to 'scripts', so 'bin' is for actual commands. 2021-04-29 10:53:01 +01:00
.gitignore Added Serum trading. 2021-05-04 17:18:09 +01:00
AccountLiquidator.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
AccountScout.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
BaseModel.ipynb Added Serum trading. 2021-05-04 17:18:09 +01:00
Constants.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
Context.ipynb Added Serum trading. 2021-05-04 17:18:09 +01:00
Decoder.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
Dockerfile Added Serum trading. 2021-05-04 17:18:09 +01:00
Instructions.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
LICENSE Initial import. 2021-04-14 16:51:39 +01:00
Layouts.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
Liquidation.ipynb Fixed problem with logging messages and token dereference. 2021-05-02 14:36:16 +01:00
Pandas.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
README.md Pre-alpha: now tries to send PartialLiquidate transaction. 2021-04-23 18:15:44 +01:00
Retrier.ipynb Added Serum trading. 2021-05-04 17:18:09 +01:00
ShowAllAccounts.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
ShowMyAccounts.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
SimpleLiquidator.ipynb Fixed problem with logging messages and token dereference. 2021-05-02 14:36:16 +01:00
TradeExecutor.ipynb Added Serum trading. 2021-05-04 17:18:09 +01:00
Wallet.ipynb Fixed linting problems with RPCErrors. 2021-04-29 17:20:46 +01:00
ids.json Initial import. 2021-04-14 16:51:39 +01:00
requirements.txt Added Serum trading. 2021-05-04 17:18:09 +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.

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 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 My Accounts 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 Classes notebook contains higher-level classes for loading and working with that data.

Other notebooks are more user-oriented:

  • Show My Accounts 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:

  • More work on margin accounts and valuation
  • Performance of code that loads all margin accounts is much too slow and needs to be improved.
  • The notebooks use hard-coded data from the Mango Client - it would be good if it could do without that.

Don't hold your breath waiting for these!

Support

You can contact me @OpinionatedGeek on Twitter.