Giter Club home page Giter Club logo

mango-explorer's People

Contributors

aaroncritchley avatar dafyddd avatar kronael avatar mschneider avatar nathan7432 avatar ochaloup avatar opinionatedgeek avatar riordanp avatar roelantc avatar silas-x avatar smx-stevel avatar spacemonkeyforever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mango-explorer's Issues

No perp account for basket token USDC

Using the MarketMakingQuickstart readme step-by-step (using WSL2 properly configured), returns following error after calling account balance in second step of part 9

Traceback (most recent call last):
File "/app/bin/show-account-balances", line 78, in
report: mango.AccountInstrumentValues = mango.AccountInstrumentValues.from_account_basket_base_token(
File "/app/mango/accountinstrumentvalues.py", line 114, in from_account_basket_base_token
raise Exception(f"No perp account for basket token {account_slot.base_instrument.symbol}")
Exception: No perp account for basket token USDC

usdc deposit was however subtracted from account without error

also, there seems to be an issue with displaying some characters on WSL but i'm not sure if that's on WSL side, i've tried cycling a couple different mono fonts

ubuntu2004_bJgxBoMgJQ

certain instruction data cause a StreamError in MangoInstructionReporter

The second and third mango instructions in this mango transaction seem to cause an error in mango.instructionreporter.MangoInstructionReporter

minimal Python example, with instruction data taken from Instruction 1 of this tx

from base58 import b58decode
from mango.instructionreporter import MangoInstructionReporter
from solana.transaction import TransactionInstruction

MANGO_PROGRAM_ADDRESS = "mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68"

instruction_data = "3QTfBEZUonKTiyJa4QWgbYKWvYcaAj3oxZf1TYnjs"  # appears to be a PlacePerpOrder 
raw_data = b58decode(instruction_data)

instruction = TransactionInstruction(
     keys=[], program_id=MANGO_PROGRAM_ADDRESS, data=raw_data
)

report =  MangoInstructionReporter(MANGO_PROGRAM_ADDRESS).report(instruction=instruction) # causes a StreamError

the above code causes the following error (truncated):

File ~/.pyenv/versions/3.9.10/envs/py39/lib/python3.9/site-packages/construct/core.py:91, in stream_read(stream, length, path)
     89     raise StreamError("stream.read() failed, requested %s bytes" % (length,), path=path)
     90 if len(data) != length:
---> 91     raise StreamError("stream read less than specified amount, expected %d, found %d" % (length, len(data)), path=path)
     92 return data

StreamError: Error in path (parsing) -> reduce_only
stream read less than specified amount, expected 1, found 0

It seems to happen with PlacePerpOrderinstructions that occur after a CancelAllPerpOrders instructions
Could the struct that parses perp orders be out of date? Or am I using the module incorrectly?

Place-Order error

hello, every time I try to place an order on the devnet i get the following error:
I am using the devnet wallet with enough SOL 4xrjGMTBD3SmcWaMHbhXL8nFS3dnF11JD5UfoAYyyfgk

 « TransactionException in 'Mango Explorer' [sendTransaction]: -32002:: Transaction failed with: 'Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.'
     Instructions:
         « Mango Instruction: PlacePerpOrder2: side: SELL, order_type: IOC, price: 100, max_base_quantity: 100, max_quote_quantity: 9223372036854775807, client_order_id: 1650763345486, reduce_only: False, expiry_timestamp: 1970-01-01 00:00:00+00:00, limit: 20
             Program ID: 4skJ85cdxQAFVKbcGgfun8iZPL7BadVYXG3kGEGkufqA
             Data: 4000000064000000000000006400000000000000ffffffffffffff7f4eae295980010000000000000000000001010014
             Key[ 0]: Ec2enZyoC4nGpEfu2sUNAa2nUGJHWxoUWYSEJ2hNTWTA
             Key[ 1]: 2iHDpuKEZ4XJVe4s5xNJHf6JXx6V8eJgynnxE61BM5pc
             Key[ 2]: BJ6aXBAMbeZAxDVThRzEEmp3KeiBcMiXK8y9HuHs6hr8
             Key[ 3]: 8mFQbdXsFXt3R3cu3oSNS3bDZRwJRP18vyzd9J278J9z
             Key[ 4]: 58vac8i9QXStG1hpaa4ouwE1X7ngeDjY9oY7R15hcbKJ
             Key[ 5]: 7HRgm8iXEDx2TmSETo3Lq9SXkF954HMVKNiq8t5sKvQS
             Key[ 6]: 4oNxXQv1Rx3h7aNWjhTs3PWBoXdoPZjCaikSThV4yGb8
             Key[ 7]: CZ5MCRvkN38d5pnZDDEEyMiED3drgDUVpEUjkuJq31Kf
             Key[ 8]: 2iHDpuKEZ4XJVe4s5xNJHf6JXx6V8eJgynnxE61BM5pc
             Key[ 9]: 474RTTzzH5BBw1M8ujxQPiAqKHMMpKPMRx1vRQAqPpRJ
         »
         « Mango Instruction: ConsumeEvents: limit: 5
             Program ID: 4skJ85cdxQAFVKbcGgfun8iZPL7BadVYXG3kGEGkufqA
             Data: 0f0000000500000000000000
             Key[ 0]: Ec2enZyoC4nGpEfu2sUNAa2nUGJHWxoUWYSEJ2hNTWTA
             Key[ 1]: 8mFQbdXsFXt3R3cu3oSNS3bDZRwJRP18vyzd9J278J9z
             Key[ 2]: 58vac8i9QXStG1hpaa4ouwE1X7ngeDjY9oY7R15hcbKJ
             Key[ 3]: CZ5MCRvkN38d5pnZDDEEyMiED3drgDUVpEUjkuJq31Kf
             Key[ 4]: 2iHDpuKEZ4XJVe4s5xNJHf6JXx6V8eJgynnxE61BM5pc
         »
     Accounts:
         No Accounts
     Errors:
         AccountNotFound
     Logs:
         No Logs
 »

`mango-explorer` 'Exception: Cannot find base token or perp market' on devnet

It was working last Friday, but throwing exceptions today on devnet. It still works on mainnet.

~$ mango-explorer show-account-balances --cluster-name devnet
2021-12-13 03:49:08 ⚠ root         
⚠ 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.

    🥭 Mango Markets: https://mango.markets
    📄 Documentation: https://docs.mango.markets/
    💬 Discord: https://discord.gg/67jySBhxrg
    🐦 Twitter: https://twitter.com/mangomarkets
    🚧 Github: https://github.com/blockworks-foundation
    📧 Email: mailto:[email protected]

Traceback (most recent call last):
  File "/app/bin/show-account-balances", line 30, in <module>
    group: mango.Group = mango.Group.load(context)
  File "/app/mango/group.py", line 343, in load
    return Group.parse(account_info, name, context.instrument_lookup, context.market_lookup)
  File "/app/mango/group.py", line 328, in parse
    return Group.from_layout(layout, name, account_info, Version.V3, instrument_lookup, market_lookup)
  File "/app/mango/group.py", line 295, in from_layout
    raise Exception(f"Cannot find base token or perp market for index {index}")
Exception: Cannot find base token or perp market for index 10

How to calculate Collateral Available

Dear Team,

1、I have run the ''show-account-balances" in the /bin directory.I can see the total value of the account. How to calculate collateral available ?

2、It is confused that the member of the open orders. what is the meaning of base_token_free, quote_token_free, etc?

thanks.

# # 🥭 OpenOrders class
#
class OpenOrders(AddressableAccount):
    def __init__(self, account_info: AccountInfo, version: Version, program_address: PublicKey,
                 account_flags: AccountFlags, market: PublicKey, owner: PublicKey,
                 base_token_free: Decimal, base_token_total: Decimal, quote_token_free: Decimal,
                 quote_token_total: Decimal, placed_orders: typing.Sequence[PlacedOrder],
                 referrer_rebate_accrued: Decimal) -> None:
        super().__init__(account_info)
        self.version: Version = version
        self.program_address: PublicKey = program_address
        self.account_flags: AccountFlags = account_flags
        self.market: PublicKey = market
        self.owner: PublicKey = owner
        self.base_token_free: Decimal = base_token_free
        self.base_token_total: Decimal = base_token_total
        self.quote_token_free: Decimal = quote_token_free
        self.quote_token_total: Decimal = quote_token_total
        self.placed_orders: typing.Sequence[PlacedOrder] = placed_orders
        self.referrer_rebate_accrued: Decimal = referrer_rebate_accrued

Thanks.

oracle provider error

Traceback (most recent call last):
  File "/app/bin/marketmaker", line 149, in <module>
    oracle_provider: mango.OracleProvider = mango.create_oracle_provider(context, args.oracle_provider)
  File "/app/mango/oraclefactory.py", line 45, in create_oracle_provider
    raise Exception(f"Unknown oracle provider '{proper_provider_name}'.")

Already tried with 3 different oracle, result come with same error

show-account-balances and show-account-valuation return an error

When I run show-account-balances and show-account-valuation, I get the following error.
What parameters should be specified?

Command: ./bin/show-account-valuation --address

Traceback (most recent call last):
File "/app/./bin/show-account-valuation", line 34, in
valuation: mango.Valuation = mango.Valuation.from_wallet(context, group, cache, address)
File "/app/mango/valuation.py", line 166, in from_wallet
spl_tokens = TokenValuation.all_from_wallet(context, group, cache, address)
File "/app/mango/valuation.py", line 67, in all_from_wallet
balances = group.fetch_balances(context, address)
File "/app/mango/group.py", line 306, in fetch_balances
balance = TokenValue.fetch_total_value(context, root_address, basket_token.token)
File "/app/mango/tokenvalue.py", line 64, in fetch_total_value
value = TokenValue.fetch_total_value_or_none(context, account_public_key, token)
File "/app/mango/tokenvalue.py", line 51, in fetch_total_value_or_none
token_accounts = context.client.get_token_accounts_by_owner(account_public_key, opts)
File "/app/mango/client.py", line 604, in get_token_accounts_by_owner
response = self.compatible_client.get_token_accounts_by_owner(owner, token_account_options, commitment)
File "/app/mango/client.py", line 360, in get_token_accounts_by_owner
return self._send_request("getTokenAccountsByOwner", str(owner), account_options, options)
File "/app/mango/client.py", line 451, in _send_request
raise TransactionException(transaction, exception_message, error_code, self.name, self.cluster_url,
mango.client.TransactionException: « 𝚃𝚛𝚊𝚗𝚜𝚊𝚌𝚝𝚒𝚘𝚗𝙴𝚡𝚌𝚎𝚙𝚝𝚒𝚘𝚗 in 'Mango Explorer' [getTokenAccountsByOwner]: -32602:: Transaction failed with: 'Invalid param: could not find mint'
Accounts:
No accounts
Errors:
No error text returned
Logs:
No logs

Transaction simulation failed: Error processing Instruction 0: custom program error: 0xa

hello , when i run liquidator print this log , is this have any problem ?

2022-01-09 03:54:14 ⚠ ReportingAcc Account was not liquidatable:
« 𝚃𝚛𝚊𝚗𝚜𝚊𝚌𝚝𝚒𝚘𝚗𝙴𝚡𝚌𝚎𝚙𝚝𝚒𝚘𝚗 in 'Mango Explorer' calling [sendTransaction]: -32002:: Transaction failed with: 'Transaction simulation failed: Error processing Instruction 0: custom program error: 0xa'
    Accounts:
        No Accounts
    Errors:
        {'InstructionError': [0, {'Custom': 10}]}
    Logs:
        Program 5fNfvyp5czQ*PuazuWgjhTqEH invoke [1]
        Program log: Mango: PartialLiquidate
        Program log: MangoErrorCode::NotLiquidatable; src/processor.rs:1276
        Program 5fNfvyp5czQ*PuazuWgjhTqEH consumed 42756 of 200000 compute units
        Program 5fNfvyp5czQ*PuazuWgjhTqEH failed: custom program error: 0xa
    Request Text:
        {"jsonrpc": "2.0", "id": 2658, "method": "sendTransaction", "params": ["base64encodingstring", {"skipPreflight": false, "preflightCommitment": "processed", "encoding": "base64"}]}
    Response Text:
        {"jsonrpc":"2.0","error":{"code":-32002,"message":"Transaction simulation failed: Error processing Instruction 0: custom program error: 0xa","data":{"accounts":null,"err":{"InstructionError":[0,{"Custom":10}]},"logs":["Program 5fNfvyp5czQ*PuazuWgjhTqEH invoke [1]","Program log: Mango: PartialLiquidate","Program log: MangoErrorCode::NotLiquidatable; src/processor.rs:1276","Program 5fNfvyp5czQ*PuazuWgjhTqEH consumed 42756 of 200000 compute units","Program 5fNfvyp5czQ*PuazuWgjhTqEH failed: custom program error: 0xa"]}},"id":2658}

BTC-PERT missing from devnet

Hi, I was going though the marketing making tutorial, and encountered an error at the last step (step 11):

$ mango-explorer marketmaker --name "BTC-PERP Marketmaker" --market BTC-PERP --oracle-provider pyth --confidenceinterval-position-size-ratio 0.1 --minimumcharge-ratio 0 --confidenceinterval-level 2 --confidenceinterval-level 4 --existing-order-tolerance 0.0001 --pulse-interval 30 --order-type POST_ONLY --biasquoteonposition-bias 0.00003 --log-level DEBUG --cluster-name devnet --dry-run

... ...

2022-08-29 23:21:44 🐛 Reconnecting Closing WebSocket for wss://mango.devnet.rpcpool.com
Traceback (most recent call last):
  File "/app/bin/marketmaker", line 221, in <module>
    market = mango.market(context, args.market)
  File "/app/mango/porcelain.py", line 93, in market
    raise Exception(f"Could not find market {symbol}")
Exception: Could not find market BTC-PERP

Upon further examination, I realized that the reason is that PERP-BTC doesn't existing in devnet, but exists in mainnet and testnet, see below:

$ poetry run bin/show-market --name mm --cluster-name testnet --market BTC-PERP
... ...

« PerpMarket BTC-PERP 6GTMXmpBdUDAojfjocxxn2nD7C5CiN9i4RLqcC3BWEG7 [BXhdkETgbHrr5QmVBT1xbz3JrMM28u5djbVtmTUfmFTH]
    « PerpMarketDetails Version.V1 [6GTMXmpBdUDAojfjocxxn2nD7C5CiN9i4RLqcC3BWEG7]
        
... ...

$ poetry run bin/show-market --name mm --cluster-name devnet --market BTC-PERP
... ...
Traceback (most recent call last):
  File "/home/stevel/workspace/crypto/solana/mango-explorer/bin/show-market", line 19, in <module>
    market = mango.market(context, args.market)
  File "/home/stevel/workspace/crypto/solana/mango-explorer/mango/porcelain.py", line 93, in market
    raise Exception(f"Could not find market {symbol}")
Exception: Could not find market BTC-PERP

If PERP-BTC is indeed missing in devnet, perhaps one of the following two changes should be made?

  1. Replace devnet with testnet in the tutorial, or
  2. Replace PERP-BTC with something else in the tutorial.

If you guys decide to go one way or another, am happy to submit a PR to save you guys some work...

BUG: Init Health,Maint Health,Levearge, Available Collateral cal error When SOL/USDC open orders exist

Dear Team,

When placing SOL/USDC Buy 100 size Orders,the orders are open in the market.

However, the caluation of init health, maint health, leverage, available collateral are wrong.

I have fixed the error of leverage. "QuoteLocked" is needed to added to asset value.
==> leverage, total value are correct.

However, the init health,maint health and available collateral are still wrong. I have no idea that how to fix the bug.
pls help check it.

thanks.

def unweighted_assets(
        self, frame: pandas.DataFrame
    ) -> typing.Tuple[Decimal, Decimal]:
        non_quote = frame.loc[frame["Symbol"] != self.shared_quote_token.symbol]
        quote = frame.loc[
            frame["Symbol"] == self.shared_quote_token.symbol, "SpotValue"
        ].sum()

        assets = Decimal(0)
        liabilities = Decimal(0)
        if quote > 0:
            assets = quote
        else:
            liabilities = quote

        liabilities += (
            Account.__sum_neg(non_quote, "SpotValue") + non_quote["PerpLiability"].sum()
        )

        assets += (
            Account.__sum_pos(non_quote, "SpotValue")
            + non_quote["PerpAsset"].sum()
            + Account.__sum_pos(non_quote, "QuoteUnsettled")
            + Account.__sum_pos(non_quote, "QuoteLocked")
        )

        return assets, liabilities

This lib is taking screenshots ?!

Once installed, and run :

  • I got security warnings over Ghostscript dev right
  • Once i bypassed this warnings in my own conf, and run an example script, i found... A screenshot of my shell appeared in the working directory !

I've installed it with pip3, with your source.
What's going on ?

Pip install not working

Hi I tried to install mango-explorer via pip. We got an error

ERROR: Could not find a version that satisfies the requirement mango-explorer (from versions: none)

How to get funding rate Stats and total account value?

Hi all,
I'm a python programmer. I want to do something in Mango Markets, but I cannot find some of function in the example code. Hope anyone can help!

  • history funding rate
  • immediately funding rate
  • total account balance including unrealized and realized PnL also funding and Interest PnL

thanks a lot!! Hopefully there's some example for me.

PerpAccount.base_token_value display issue

>>> sl.net_value
« InstrumentValue:        -0.00040000 BTC »
>>> sl.perp_account.base_token_value
« InstrumentValue:       400.00000000 BTC »
>>> sl.perp_account.base_position_raw
Decimal('400')

Instrument value of perp base token position is shown in raw. Should convert by decimal.

Getting an error when using place-order

Any ideas why I'm getting this error? I have a funded account on mango with about $10 in it.

./place-order --market SOL/USDC --quantity 0.01 --price 90.00 --side BUY --order-type LIMIT --account-address 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk
2022-02-01 18:51:13 ⚠ root         

2022-02-01 18:51:14 ⓘ SpotMarketOp Placing SOL/USDC order « Order BUY for 0.01000000 at 90.00000000 [ID: 0 / 0] LIMIT».
Traceback (most recent call last):
  File "/root/mango/mango-explorer/bin/./place-order", line 41, in <module>
    placed = market_operations.place_order(order)
  File "/root/mango/mango-explorer/mango/spotmarketoperations.py", line 188, in place_order
    transaction_ids = (signers + place + crank + settle).execute(self.context)
  File "/root/mango/mango-explorer/mango/combinableinstructions.py", line 242, in execute
    raise exception
  File "/root/mango/mango-explorer/mango/combinableinstructions.py", line 234, in execute
    response = context.client.send_transaction(transaction, *self.signers)
  File "/root/mango/mango-explorer/mango/client.py", line 786, in send_transaction
    response = self.compatible_client.send_transaction(transaction, *signers, opts=proper_opts)
  File "/usr/local/lib/python3.9/dist-packages/solana/rpc/api.py", line 1185, in send_transaction
    txn_resp = self.send_raw_transaction(txn.serialize(), opts=opts)
  File "/usr/local/lib/python3.9/dist-packages/solana/rpc/api.py", line 1137, in send_raw_transaction
    resp = self._provider.make_request(*args)
  File "/root/mango/mango-explorer/mango/client.py", line 574, in make_request
    result = provider.make_request(method, *params)
  File "/root/mango/mango-explorer/mango/client.py", line 416, in make_request
    return self.__make_request(method, *params)
  File "/root/mango/mango-explorer/mango/client.py", line 516, in __make_request
    raise TransactionException(transaction, exception_message, error_code, self.name,
mango.client.TransactionException: « TransactionException in 'Mango Explorer' [sendTransaction]: -32002:: Transaction failed with: 'Transaction simulation failed: Error processing Instruction 0: custom program error: 0x19'
    Instructions:
        « CreateSpotOpenOrders: None
                Key[ 0]: 98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue
                Key[ 1]: 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk
                Key[ 2]: Es9NnGZRk3Ew7Cb8csXvaVpLJc9Yn7M6YKUhtqodnjh6
                Key[ 3]: 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
                Key[ 4]: TK4VWqe3Z2eV4ykNcMPs2NDapGYqQBqFY4e5VaASSjK
                Key[ 5]: 9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT
                Key[ 6]: 9BVcYqEQxyccuwznvxXqDkSJFavvTyheiTYk231T1A8S
                Key[ 7]: 11111111111111111111111111111111
        »
        Instruction Details:
        Key[ 0]: 98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue  Read-Only       
        Key[ 1]: 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk  Writable        
        Key[ 2]: Es9NnGZRk3Ew7Cb8csXvaVpLJc9Yn7M6YKUhtqodnjh6  Writable  Signer
        Key[ 3]: 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin  Read-Only       
        Key[ 4]: TK4VWqe3Z2eV4ykNcMPs2NDapGYqQBqFY4e5VaASSjK   Writable        
        Key[ 5]: 9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT  Writable        
        Key[ 6]: 9BVcYqEQxyccuwznvxXqDkSJFavvTyheiTYk231T1A8S  Read-Only       
        Key[ 7]: 11111111111111111111111111111111              Read-Only       
        Program ID: mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68
        Data: 3c000000
        « PlaceSpotOrder2: None
                Key[ 0]: 98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue
                Key[ 1]: 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk
                Key[ 2]: Es9NnGZRk3Ew7Cb8csXvaVpLJc9Yn7M6YKUhtqodnjh6
                Key[ 3]: EBDRoayCDDUvDgCimta45ajQeXbexv7aKqJubruqpyvu
                Key[ 4]: 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
                Key[ 5]: 9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT
                Key[ 6]: 14ivtgssEBoBjuZJtSAPKYgpUK7DmnSwuPMqJoVTSgKJ
                Key[ 7]: CEQdAFKdycHugujQg9k2wbmxjcpdYZyVLfV9WerTnafJ
                Key[ 8]: AZG3tFCFtiCqEwyardENBQNpHqxgzbMw8uKeZEw2nRG5
                Key[ 9]: 5KKsLVU6TcbVDK4BS6K1DGDxnh4Q9xjYJ8XaDCG5t8ht
                Key[10]: 36c6YqAwyGKQG66XEp2dJc5JqjaBNv7sVghEtJv4c7u6
                Key[11]: 8CFo8bL8mZQK8abbFyypFMwEDd8tVJjHTTojMLgQTUSZ
                Key[12]: 7jH1uLmiB2zbHNe6juZZYjQCrvquakTwd3yMaQpeP8rR
                Key[13]: 2bqJYcA1A8gw4qJFjyE2G4akiUunpd9rP6QzfnxHqSqr
                Key[14]: AVn3JRGhifPCxjxZsU3tQuo4U4dTHizHzBDGW983tx47
                Key[15]: AMzanZxMirPCgGcBoH9kw4Jzi9LFMomyUCXbpzDeL2T8
                Key[16]: BGcwkj1WudQwUUjFk78hAjwd1uAm8trh1N4CJSa51euh
                Key[17]: 8Vw25ZackDzaJzzBBqcgcpDsCsDfRSkMGgwFQ3gbReWF
                Key[18]: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                Key[19]: 9BVcYqEQxyccuwznvxXqDkSJFavvTyheiTYk231T1A8S
                Key[20]: F8Vyqk3unwxkXukZFQeYyGmFfTG3CAX4v24iyrjEYBJV
                Key[21]: HiB9JtxgnA7G29EWVcPFhXbLCTaPitdVJKgD3BhH6TJj
                Key[22]: TK4VWqe3Z2eV4ykNcMPs2NDapGYqQBqFY4e5VaASSjK
        »
        Instruction Details:
        Key[ 0]: 98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue  Read-Only       
        Key[ 1]: 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk  Writable        
        Key[ 2]: Es9NnGZRk3Ew7Cb8csXvaVpLJc9Yn7M6YKUhtqodnjh6  Writable  Signer
        Key[ 3]: EBDRoayCDDUvDgCimta45ajQeXbexv7aKqJubruqpyvu  Read-Only       
        Key[ 4]: 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin  Read-Only       
        Key[ 5]: 9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT  Writable        
        Key[ 6]: 14ivtgssEBoBjuZJtSAPKYgpUK7DmnSwuPMqJoVTSgKJ  Writable        
        Key[ 7]: CEQdAFKdycHugujQg9k2wbmxjcpdYZyVLfV9WerTnafJ  Writable        
        Key[ 8]: AZG3tFCFtiCqEwyardENBQNpHqxgzbMw8uKeZEw2nRG5  Writable        
        Key[ 9]: 5KKsLVU6TcbVDK4BS6K1DGDxnh4Q9xjYJ8XaDCG5t8ht  Writable        
        Key[10]: 36c6YqAwyGKQG66XEp2dJc5JqjaBNv7sVghEtJv4c7u6  Writable        
        Key[11]: 8CFo8bL8mZQK8abbFyypFMwEDd8tVJjHTTojMLgQTUSZ  Writable        
        Key[12]: 7jH1uLmiB2zbHNe6juZZYjQCrvquakTwd3yMaQpeP8rR  Read-Only       
        Key[13]: 2bqJYcA1A8gw4qJFjyE2G4akiUunpd9rP6QzfnxHqSqr  Writable        
        Key[14]: AVn3JRGhifPCxjxZsU3tQuo4U4dTHizHzBDGW983tx47  Writable        
        Key[15]: AMzanZxMirPCgGcBoH9kw4Jzi9LFMomyUCXbpzDeL2T8  Read-Only       
        Key[16]: BGcwkj1WudQwUUjFk78hAjwd1uAm8trh1N4CJSa51euh  Writable        
        Key[17]: 8Vw25ZackDzaJzzBBqcgcpDsCsDfRSkMGgwFQ3gbReWF  Writable        
        Key[18]: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA   Read-Only       
        Key[19]: 9BVcYqEQxyccuwznvxXqDkSJFavvTyheiTYk231T1A8S  Read-Only       
        Key[20]: F8Vyqk3unwxkXukZFQeYyGmFfTG3CAX4v24iyrjEYBJV  Read-Only       
        Key[21]: HiB9JtxgnA7G29EWVcPFhXbLCTaPitdVJKgD3BhH6TJj  Read-Only       
        Key[22]: TK4VWqe3Z2eV4ykNcMPs2NDapGYqQBqFY4e5VaASSjK   Writable        
        Program ID: mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68
        Data: 2900000000000000905f0100000000000000000000000000000000000000000000000000000000007e6fa0b67e010000ffff
    Accounts:
        No Accounts
    Errors:
        {'InstructionError': [0, {'Custom': 25}]}
    Logs:
        Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 invoke [1]
        Program log: Mango: CreateSpotOpenOrders
        Program log: Custom program error: 0x19
        Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 consumed 9634 of 200000 compute units
        Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 failed: custom program error: 0x19
    Response:
        {"jsonrpc":"2.0","error":{"code":-32002,"message":"Transaction simulation failed: Error processing Instruction 0: custom program error: 0x19","data":{"accounts":null,"err":{"InstructionError":[0,{"Custom":25}]},"logs":["Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 invoke [1]","Program log: Mango: CreateSpotOpenOrders","Program log: Custom program error: 0x19","Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 consumed 9634 of 200000 compute units","Program mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68 failed: custom program error: 0x19"]}},"id":16}

Faiing to run notebook

I'm trying to run ShowAccount.ipynb, so I cloned the repo and did pip install requirements.txt which worked fine.

I'm now trying to run the second cell and I get the following error: ModuleNotFoundError: No module named 'solana.keypair'

Has this dependency been missed from requirements.txt or am I making incorrect use of this repo?

Account is not prepared for group exception

Great writeup on how to run a liquidator. However, when I get to the dry run for running the liquidator I got the following exception and the liquidator terminates.

Exception: Account 'Dd8sgey2VD1uo5jBJfwJAdfi2GZAvULcoSqAy87jQGBT' is not prepared for group '2oogpTYm1sp6LPZAWD3bp2wsFpnV2kXL1s52yyFhW5vp'.

Any ideas?

Bug: Perp Position Value is not correct.

Dear Team,

I have updated the latest mango-explorer version, however, my perp positions are not correct.eg: my BTC-PERP is 0.087,but the value of mango is 87,800. SOL-PERP has the same issue.

pls help check it.

The log is below after running "./bin/show-accounts"

« AccountSlot [1] BTC
            Net Value:     « InstrumentValue:         0.00000000 BTC »
                Deposited: « InstrumentValue:         0.00000000 BTC » (raw value: 0E-20)
                Borrowed:  « InstrumentValue:         0.00000000 BTC » (raw value 0E-20)
            Spot OpenOrders: None
            Perp Account:
                « PerpAccount
                    Base Position: « InstrumentValue:    87,800.00000000 BTC »
                    Quote Position: -3783574498.53515607565438472193
                    Long Settled Funding: 587094.74736902058174692343
                    Short Settled Funding: 585522.72434996363400827590
                    Bids Quantity: 0
                    Asks Quantity: 0
                    Taker Base: 0
                    Taker Quote: 0
                    MNGO Accrued: « InstrumentValue:         0.45457900 MNGO »
                    OpenOrders:
                        « PerpOpenOrders
                            Orders:
                                None
                        »
                »

health-check error:Exception: Could not find market for spot token ADA.

Hi Team, I run the ./show-health in the bin directory. It shows the errors below. Mango has no ADA/USDC spot market,however, it seems still checks the ADA spot market. pls help fix it. thanks.


2022-02-08 17:00:43 ⚠ root         
⚠ 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.

    🥭 Mango Markets: https://mango.markets
    📄 Documentation: https://docs.mango.markets/
    💬 Discord: https://discord.gg/67jySBhxrg
    🐦 Twitter: https://twitter.com/mangomarkets
    🚧 Github: https://github.com/blockworks-foundation
    📧 Email: mailto:[email protected]

Traceback (most recent call last):
  File "/Users/foonsun/works/mango-explorer/bin/./show-health", line 51, in <module>
    mango.output("Health", health_calculator.calculate(mango_account, spot_open_orders, group, cache))
  File "/opt/anaconda3/envs/driftenv/lib/python3.9/site-packages/mango/calculators/healthcalculator.py", line 157, in calculate
    raise Exception(f"Could not find market for spot token {priced_report.base_token.symbol}.")
Exception: Could not find market for spot token ADA.

My account scout log is below:

2022-02-08 16:56:37 ⓘ root         Address: 8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag
« ScoutReport [8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag]:
    Summary:
        Found 13 error(s) and 0 warning(s).

    Errors:
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'MNGO'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'BTC'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'ETH'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'SOL'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'USDT'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'SRM'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'RAY'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'COPE'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'FTT'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'MSOL'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'BNB'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'AVAX'.
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has no account for token 'LUNA'.

    Warnings:
        None

    Details:
        Account '8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag' has 1 USDC token account(s): [AztsQ8K4MfDzL3AXgjV4n5ymt6WmqGqjztcEW6ZRugbD]
        Margin account: « Account (un-named), Version.V3 [GUM8tdeVsKzKaBns828SgNbeA3i5oBQMZarutukZsVJt]
            « Metadata Version.V2 - Account: Initialized »
            Owner: 8AhMgKNmKmYtDnc6YCvK6GRmbEM8RmbAkjSSCdJz4Mag
            Delegated To: None
            Group: « Group 'mainnet.1' [98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue] »
            Advanced Orders Account: None
            MSRM: 0
            Bankrupt? False
            Upgradable? True
            Being Liquidated? False
            Shared Quote Token:
                « AccountSlot [15] USDC
                    Net Value:     « InstrumentValue:       679.80051715 USDC »
                        Deposited: « InstrumentValue:       679.80051715 USDC » (raw value: 657.72375935230919452579)
                        Borrowed:  « InstrumentValue:         0.00000000 USDC » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        None
                »
            In Basket: MNGO, BTC, ETH, SOL, USDT, SRM, RAY, COPE, FTT, ADA, MSOL, BNB, AVAX, LUNA
            Basket [14 in basket]:
                « AccountSlot [0] MNGO
                    Net Value:     « InstrumentValue:         0.00000000 MNGO »
                        Deposited: « InstrumentValue:         0.00000000 MNGO » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 MNGO » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [1] BTC
                    Net Value:     « InstrumentValue:         0.00000000 BTC »
                        Deposited: « InstrumentValue:         0.00000000 BTC » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 BTC » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [2] ETH
                    Net Value:     « InstrumentValue:         0.00000000 ETH »
                        Deposited: « InstrumentValue:         0.00000000 ETH » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 ETH » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [3] SOL
                    Net Value:     « InstrumentValue:         0.60000928 SOL »
                        Deposited: « InstrumentValue:         0.60000928 SOL » (raw value: 599.26469950687738474926)
                        Borrowed:  « InstrumentValue:         0.00000000 SOL » (raw value 0E-20)
                    Spot OpenOrders: 2gWc3qrroPFMsF1BGwnamTUb1RtMggWXWcsSytAVUoAc
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [4] USDT
                    Net Value:     « InstrumentValue:         0.00000000 USDT »
                        Deposited: « InstrumentValue:         0.00000000 USDT » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 USDT » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [5] SRM
                    Net Value:     « InstrumentValue:         0.00000000 SRM »
                        Deposited: « InstrumentValue:         0.00000000 SRM » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 SRM » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [6] RAY
                    Net Value:     « InstrumentValue:         0.00000000 RAY »
                        Deposited: « InstrumentValue:         0.00000000 RAY » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 RAY » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [7] COPE
                    Net Value:     « InstrumentValue:         0.00000000 COPE »
                        Deposited: « InstrumentValue:         0.00000000 COPE » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 COPE » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [8] FTT
                    Net Value:     « InstrumentValue:         0.00000000 FTT »
                        Deposited: « InstrumentValue:         0.00000000 FTT » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 FTT » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [9] ADA
                    Net Value:     « InstrumentValue:         0.00000000 Cardano »
                        Deposited: « InstrumentValue:         0.00000000 Cardano » (raw value: 0)
                        Borrowed:  « InstrumentValue:         0.00000000 Cardano » (raw value 0)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount
                            Base Position: « InstrumentValue:         0.00000000 Cardano »
                            Quote Position: 0E-20
                            Long Settled Funding: 0E-20
                            Short Settled Funding: 0E-20
                            Bids Quantity: 1
                            Asks Quantity: 0
                            Taker Base: 0
                            Taker Quote: 0
                            MNGO Accrued: « InstrumentValue:         0.00000000 MNGO »
                            OpenOrders:
                                « PerpOpenOrders
                                    Orders:
                                        « PlacedOrder BUY [186330561888540172549656] 1644310038812 »
                                »
                        »
                »
                « AccountSlot [10] MSOL
                    Net Value:     « InstrumentValue:         0.00000000 MSOL »
                        Deposited: « InstrumentValue:         0.00000000 MSOL » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 MSOL » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [11] BNB
                    Net Value:     « InstrumentValue:         0.00000000 BNB »
                        Deposited: « InstrumentValue:         0.00000000 BNB » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 BNB » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [12] AVAX
                    Net Value:     « InstrumentValue:         0.00000000 AVAX »
                        Deposited: « InstrumentValue:         0.00000000 AVAX » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 AVAX » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
                « AccountSlot [13] LUNA
                    Net Value:     « InstrumentValue:         0.00000000 LUNA »
                        Deposited: « InstrumentValue:         0.00000000 LUNA » (raw value: 0E-20)
                        Borrowed:  « InstrumentValue:         0.00000000 LUNA » (raw value 0E-20)
                    Spot OpenOrders: None
                    Perp Account:
                        « PerpAccount (empty) »
                »
        »
»

Issues on using pip to install package list on pypi

As the title described, before raising this ticket I also try to pip install --upgrade pip, but it still did not work for me.

pip install mango-explorer
pip install mango-explorer==3.4.6
ERROR: Could not find a version that satisfies the requirement mango-explorer==3.4.6 (from versions: none)

List Index out of range

Hi,

Anyone else noticed that they are now getting ? When I use the show account data example with my own key I get "List Index out of range" error ?

Is this related to the addition of the "GMT-PERP" ?

Thanks
A.

Error when using ./bin/place-order

~/mango/mango-explorer/bin# ./place-order --market SOL/USDC --quantity 0.01 --price 90.00 --side BUY --order-type LIMIT --account-address 2WkWHY1u7LyXuYZSjA2SEqNiZDyhr8VMrNQ8rfVtBxfk
2022-01-29 03:31:43 ⓘ SpotMarketOp Placing SOL/USDC order « Order BUY for 0.01000000 at 90.00000000 [ID: 0 / 0] LIMIT».
Traceback (most recent call last):
  File "/root/mango/mango-explorer/bin/./place-order", line 41, in <module>
    placed = market_operations.place_order(order)
  File "/root/mango/mango-explorer/mango/spotmarketoperations.py", line 177, in place_order
    place: CombinableInstructions = self.market_instruction_builder.build_place_order_instructions(
  File "/root/mango/mango-explorer/mango/spotmarketoperations.py", line 89, in build_place_order_instructions
    return build_spot_place_order_instructions(self.context, self.wallet, self.group, self.account,
  File "/root/mango/mango-explorer/mango/instructions.py", line 664, in build_spot_place_order_instructions
    open_orders_address = create_open_orders.signers[0].public_key
IndexError: list index out of range

It appears that the array of signers is empty.

need to use Genesys Go RPC servers

I often encountered "NodeIsBehindException" using default mainnet RPC servers.
I heard that Genesys Go's RPC servers are stable and it can be used on Web UI.
Would you instruct how to use it on mango-explorer market making bot?
It seems it will work well by adding solana program information to ids.json.

Error when trying to run docker container

Traceback (most recent call last):
File "/opt/conda/bin/jupyter-notebook", line 6, in
from notebook.notebookapp import main
File "/opt/conda/lib/python3.9/site-packages/notebook/notebookapp.py", line 80, in
from .services.contents.manager import ContentsManager
File "/opt/conda/lib/python3.9/site-packages/notebook/services/contents/manager.py", line 17, in
from nbformat import sign, validate as validate_nb, ValidationError
File "/opt/conda/lib/python3.9/site-packages/nbformat/init.py", line 32, in
from .validator import validate, ValidationError
File "/opt/conda/lib/python3.9/site-packages/nbformat/validator.py", line 12, in
from .json_compat import get_current_validator, ValidationError
File "/opt/conda/lib/python3.9/site-packages/nbformat/json_compat.py", line 10, in
import jsonschema
File "/opt/conda/lib/python3.9/site-packages/jsonschema/init.py", line 11, in
from jsonschema.exceptions import (
File "/opt/conda/lib/python3.9/site-packages/jsonschema/exceptions.py", line 9, in
import attr
ModuleNotFoundError: No module named 'attr'

Exception: Account data length (0) does not match expected size (4296)

I've got "Exception: Account data length (0) does not match expected size (4296)" when trying to place an order.

  • Is this variable supposed to be private, public, or keypair ?
    wallet = mango.Wallet(bytes([1, 2, 3....32])

  • Is this one supposed to be the public key ( = wallet address) OR the SPL key (Serum dedicated address for SPL tokens) ?
    account = mango.Account.load(context, PublicKey("..."), group)

Or is it completely something else ?

Thanks

"Attempt to debit an account but found no record of a prior credit"

I am trying to send a test transaction using the Python API. I'm not exactly sure where to put which key. I have my long Phantom private key that is in the format of "FrHr9FCz9B7EkxHPg6gUig2XXXXXUig2Uig2Uig2" (not my real private key ofc) and my mango account address from which is under the word "Account" in the Mango GUI. But for some reason when I try to send a simple 0.1 SOL order, it says:

mango.client.TransactionException: « TransactionException in 'Mango Explorer' [sendTransaction]: -32002:: Transaction failed with: 'Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.'

Even though I definitely have the balance for that order. I can place the exact same order through the GUI no problem.

What am I missing here? Here is my code. It is exactly like this code but using my credentials:

import base64
import decimal
import mango

from solana.publickey import PublicKey

wallet_key = b"FrHr9FCz9B7EkxHPg6gUig2XXXXXUig2Uig2Uig2"
wallet_key = base64.b64decode(wallet_key)

wallet_public = "XXXXXX-------REDACTED-----XXXXXX"
mango_account = "XXXXXX-------REDACTED-----XXXXXX"


wallet = mango.Wallet(wallet_key)

with mango.ContextBuilder.build(cluster_name="mainnet") as context:
    group = mango.Group.load(context)
    account = mango.Account.load(context, PublicKey(mango_account), group)
    market_operations = mango.operations(context, wallet, account, "SOL-PERP", dry_run=False)

    print("Orders (initial):")
    print(market_operations.load_orderbook())

    order = mango.Order.from_values(side=mango.Side.BUY,
                                    price=decimal.Decimal("86.60"),
                                    quantity=decimal.Decimal(0.1),
                                    order_type=mango.OrderType.POST_ONLY,
                                    client_id=1001)
    print("Placing order:", order)
    placed_order_signatures = market_operations.place_order(order)

    print("Waiting for place order transaction to confirm...\n", placed_order_signatures)
    mango.WebSocketTransactionMonitor.wait_for_all(
            context.client.cluster_ws_url, placed_order_signatures, commitment="processed"
        )

    print("\n\nOrders (including our new order):")
    orderbook = market_operations.load_orderbook()
    print(orderbook)

    # Order has the client ID 1001 so we can use that Order object as a parameter here.
    cancellaton_signatures = market_operations.cancel_order(order)

    print("Waiting for cancel order transaction to confirm...\n", cancellaton_signatures)
    mango.WebSocketTransactionMonitor.wait_for_all(
            context.client.cluster_ws_url, cancellaton_signatures, commitment="processed"
        )

    print("\n\nOrders (without our order):")
    print(market_operations.load_orderbook())

print("Example complete.")

Transaction simulation failed: Error processing Instruction 0: custom program error: 0xf

Hi! I often get an error, I can't find what exactly the problem is. Can you help?

Traceback (most recent call last):
  File "/home/*/*/*/*.py", line 76, in cancel_order
    return market_operations.cancel_order(order)
  File "/home/*/mango/lib/python3.9/site-packages/mango/perpmarketoperations.py", line 57, in cancel_order
    return (signers + cancel + crank + settle).execute(self.context)
  File "/home/*/mango/lib/python3.9/site-packages/mango/combinableinstructions.py", line 142, in execute
    raise exception
  File "/home/*/mango/lib/python3.9/site-packages/mango/combinableinstructions.py", line 134, in execute
    response = context.client.send_transaction(transaction, *self.signers)
  File "/home/*/mango/lib/python3.9/site-packages/mango/client.py", line 613, in send_transaction
    response = self.compatible_client.send_transaction(
  File "/home/*/mango/lib/python3.9/site-packages/mango/client.py", line 390, in send_transaction
    response = self._send_request(
  File "/home/*/mango/lib/python3.9/site-packages/mango/client.py", line 451, in _send_request    
raise TransactionException(transaction, exception_message, error_code, self.name, self.cluster_url,
mango.client.TransactionException: « 𝚃𝚛𝚊𝚗𝚜𝚊𝚌𝚝𝚒𝚘𝚗𝙴𝚡𝚌𝚎𝚙𝚝𝚒𝚘𝚗 in 'Mango Explorer' [sendTransaction]: -32002:: Transaction failed with: 'Transaction simulation failed: Error processing Instruction 0: custom program error: 0xf'
    Accounts:
        No Accounts
    Errors:
        {'InstructionError': [0, {'Custom': 15}]}
    Logs:
        Program ********************************invoke [1]
        Program log: Mango: CancelPerpOrderByClientId client_order_id=1111111111111
        Program log: MangoErrorCode::ClientIdNotFound; src/processor.rs:2039
        Program ********************************consumed 4966 of 200000 compute units
        Program ******************************** failed: custom program error: 0xf

Group-balance-wallet fails due to "Invalid Public Key Input" exception

Hey there,

Trying to run group-balance-wallet from command line, with the dry-run flag everything looks good, but when I run it without it I see the following exception:

of <solana.account.Account object at 0x7f38e3593d30>>')'.
2021-12-14 08:18:01 ⓘ RetryWithPau Will retry [Place Serum Order And Settle] call in 4 second(s).
2021-12-14 08:18:05 ⓘ RetryWithPau Retriable call failed [Place Serum Order And Settle] with error '('invalid public key input:', '<bound method Account.public_key 
of <solana.account.Account object at 0x7f38e3593d30>>')'.
2021-12-14 08:18:05 ⓘ RetryWithPau Will retry [Place Serum Order And Settle] call in 8 second(s).
2021-12-14 08:18:14 ⓘ RetryWithPau Retriable call failed [Place Serum Order And Settle] with error '('invalid public key input:', '<bound method Account.public_key 
of <solana.account.Account object at 0x7f38e3593d30>>')'.
2021-12-14 08:18:14 ⓘ RetryWithPau Will retry [Place Serum Order And Settle] call in 16 second(s).
2021-12-14 08:18:30 ⓘ RetryWithPau Retriable call failed [Place Serum Order And Settle] with error '('invalid public key input:', '<bound method Account.public_key 
of <solana.account.Account object at 0x7f38e3593d30>>')'.
2021-12-14 08:18:30 ⓘ RetryWithPau Will retry [Place Serum Order And Settle] call in 20 second(s).
2021-12-14 08:18:50 ⓘ RetryWithPau Retriable call failed [Place Serum Order And Settle] with error '('invalid public key input:', '<bound method Account.public_key 
of <solana.account.Account object at 0x7f38e3593d30>>')'.
2021-12-14 08:18:50 ⓘ RetryWithPau Will retry [Place Serum Order And Settle] call in 30 second(s).
2021-12-14 08:19:20 ⓘ RetryWithPau End of retry loop for [Place Serum Order And Settle] - propagating exception.
2021-12-14 08:19:20 🛑 root         Balancing stopped because of exception: ('invalid public key input:', '<bound method Account.public_key of <solana.account.Accou
nt object at 0x7f38e3593d30>>') - Traceback (most recent call last):
  File "/home/jovyan/.local/lib/pyston3.8/site-packages/solana/publickey.py", line 31, in __init__
    self._key = base58.b58decode(value)
  File "/home/jovyan/.local/lib/pyston3.8/site-packages/base58/__init__.py", line 124, in b58decode
    acc = b58decode_int(v, alphabet=alphabet, autofix=autofix)
  File "/home/jovyan/.local/lib/pyston3.8/site-packages/base58/__init__.py", line 104, in b58decode_int
    raise ValueError(
ValueError: Invalid character '<'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/jovyan/work/bin/group-balance-wallet", line 61, in <module>
    wallet_balancer.balance(prices)
  File "/home/jovyan/work/mango/walletbalancer.py", line 319, in balance
    self._make_changes(sorted_changes)
  File "/home/jovyan/work/mango/walletbalancer.py", line 331, in _make_changes
    self.trade_executor.buy(market_symbol, change.value.copy_abs())
  File "/home/jovyan/work/mango/tradeexecutor.py", line 191, in buy
    return self._execute(
  File "/home/jovyan/work/mango/tradeexecutor.py", line 280, in _execute
    return retrier.run(transaction, *signers)
  File "/home/jovyan/work/mango/retrier.py", line 84, in run
    raise captured_exception
  File "/home/jovyan/work/mango/retrier.py", line 55, in run

Earlier when running AccountScout all looks well and pub key was parsed successfully. What am I doing wrong?

id.json missing in docker context

Hi I am seeing this issue when running on wsl 2 via docker. I checked the docker image via vscode and don't see the id.json file in /app/id.json

#mango-explorer solana-keygen new --force --outfile /app/id.json
Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none):

Error: Unable to write /app/id.json: Is a directory (os error 21)

New User question

Hi,

Hopefully very simple for someone... How do I get a list of the last fills for a Spot symbol ?

I've seen example for the Perp's but I can't seem to find a way to get a list of the last Spot fills.

Any help would be appreciated.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.