Go to file
Geoff Taylor 01e121ad49 Refactored SpotMarketInfo and PerpMarketInfo. 2021-11-08 11:54:50 +00:00
.github/workflows Added documentation for building and packaging releases. 2021-10-22 12:43:35 +01:00
.vscode Fixed some settings for venv. 2021-10-13 18:42:02 +01:00
bin Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
data Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
docs Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
mango Refactored SpotMarketInfo and PerpMarketInfo. 2021-11-08 11:54:50 +00:00
scripts Switched random taker oracle to FTX. 2021-09-09 21:41:53 +01:00
tests Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
.dockerignore Debug logging now outputs the version details. 2021-09-30 11:54:43 +01:00
.envrc Moved development commands to 'scripts', so 'bin' is for actual commands. 2021-04-29 10:53:01 +01:00
.flake8 Fixed some settings for venv. 2021-10-13 18:42:02 +01:00
.gitignore Fixed data file handling to allow Nuitka compilation. 2021-10-08 17:30:20 +01:00
.mypy.ini Fixed data file handling to allow Nuitka compilation. 2021-10-08 17:30:20 +01:00
Dockerfile Added OrderBook instead of passing around bids and asks. Added it to ModelState too, and cleaned up usage. 2021-10-26 18:45:04 +01:00
LICENSE Initial import. 2021-04-14 16:51:39 +01:00
Makefile Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
README.md Made mango-explorer a pip-installable package. 2021-10-11 17:08:54 +01:00
poetry.lock Moved to having Instrument as a basis for Token, to allow for perp markets with no underlying SPL token. 2021-11-08 11:39:09 +00:00
pyproject.toml v0.1.10 2021-11-01 19:10:51 +00: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.

Introduction

mango-explorer provides Python code to interface with Mango Markets, along with a functional [marketmaker]](docs/MarketmakingQuickstart.md).

Here's a brief but complete example of how to place and cancel an order. This example is runnable in your browser!

import decimal
import mango
import os
import time

# Load the wallet from the environment variable 'KEYPAIR'. (Other mechanisms are available.)
wallet = mango.Wallet(os.environ.get("KEYPAIR"))

# Create a 'devnet' Context
context = mango.ContextBuilder.build(cluster_name="devnet")

# Load the wallet's account
group = mango.Group.load(context)
accounts = mango.Account.load_all_for_owner(context, wallet.address, group)
account = accounts[0]

# Load the market
stub = context.market_lookup.find_by_symbol("SOL-PERP")
market = mango.ensure_market_loaded(context, stub)

market_operations = mango.create_market_operations(context, wallet, account, market, dry_run=False)

print("Orders (initial):")
for order in market_operations.load_orders():
    print(order)

# Go on - try to buy 1 SOL for $10.
order = mango.Order.from_basic_info(side=mango.Side.BUY,
                                    price=decimal.Decimal(10),
                                    quantity=decimal.Decimal(1),
                                    order_type=mango.OrderType.POST_ONLY)
placed_order = market_operations.place_order(order)
print("\n\nplaced_order\n\t", placed_order)

print("\n\nSleeping for 10 seconds...")
time.sleep(10)

print("\n\nOrders (including our new order):")
for order in market_operations.load_orders():
    print(order)

cancellaton_signatures = market_operations.cancel_order(placed_order)
print("\n\ncancellaton_signatures:\n\t", cancellaton_signatures)

print("\n\nSleeping for 10 seconds...")
time.sleep(10)

print("\n\nOrders (without our order):")
for order in market_operations.load_orders():
    print(order)

Many more examples are provided in a separate Github repo and can be run in your browser (no installation required!) at Binder.

Running the marketmaker

There is a Marketmaking Quickstart - a walkthrough of setting up and running the marketmaker on devnet, from setting up the account, depositing tokens, to running the marketmaker itself.

It can take around 30 minutes to run through.

Requirements:

  • A server with docker installed

Note This walkthrough is devnet-only so no actual funds are used or at-risk.

References

Support

🥭 Mango Markets support is available at: Docs | Discord | Twitter | Github | Email