* implemented create_mango_account which uses PDA
* wrote iter() funciton for bids and asks. Still working on size LM
* added CreatePerpMarket
* added CreatePerpMarket
* implemented the instruction for CreatePerpMarket
* Run workflows on all pushes/prs for "v*.*" branch names
* Run cargo fmt
* Fix compilation when bytemuck is used with the derive feature (#71)
With the feature enabled there's also a bytemuck::Pod derive macro,
which will conflict with mango_macro::Pod.
Using bytemuck's Pod macro instead would be a larger change because
it validates that all fields in the struct are Pod themselves. And
technically neither bool or enums are: these types do not allow any
bit pattern.
* updated cargo lock and anchor version; still need to finish one more function cancel_all_with_incentives
* implemented size incentives for cancel_all
* Allow for signer key to fund creation of new perp market accounts
* updated CreatePerpMarket so bids, asks and event queue are craeted first not as PDAs
* Optimized new size LM
* removed the ***; reverted sim_new_bid to not cause complications
* fixed bugs in size depth calculations
* updated changelog
* updated readme with bug bounty email
* fixed bug
* fixed cache_prices where the oracle doesn't have token with decimals. Defaults to 6 decimals
* updated to version 3.2.1
* trying out sort_unstable to get around clippy error
* added back AddPerpMarket to not fail unit tests
* update changelog
* since AddPerpMarket is added back, it also now sets the decimals to 6 if perp market added before spot market; But AddPerpMarket is deprecated and shouldn't be used anyway
* update Deploy time for mainnet deployment v3.2.1
Co-authored-by: dd <dafydd.durairaj@gmail.com>
Co-authored-by: Christian Kamm <ckamm@delightful-solutions.de>
Co-authored-by: Maximilian Schneider <mail@maximilianschneider.net>
Co-authored-by: Christian Kamm <mail@ckamm.de>
* implemented reduce_only and market order for PlacePerpOrder; untested
* added root bank cache valid check under MangoCache
* fixed the root bank cache function and made it compiling
* added some stuff during live stream. still not finished
* Cache validation moved to impl
* All cache validations moved to appropriate struct implementations
* Increase valid_interval for RootBankCache check
* implemented place_spot_order2; still not finished reducing size of the tx
* more progress on place_spot_order2
* finished implementing place_spot_order2
* intermediate work on advanced orders
* compiling and deployed to devnet; advanced orders still unfinished
* changed get_spot_val to use Option for open_orders; more work on advanced orders but not completed
* added testi80f48 into placespotorder2
* removed test_i80f48; removed rent_ai into invoke_place_order
* removed test_i80f48; removed rent_ai into invoke_place_order
* cleaned up compiler warnings
* use serum order v3 serialization
* add perp stop order instruction
* implement correctly register order
* connect instructions with impl
* changed name to PerpTriggerOrder. Still need to implement RemovePerpTriggerOrder and test;
* Added RemoveAdvancedOrder and rearranged some of the instruction discriminants
* remove perp trigger order instruction
* Fix pda_signer_seeds
* fixed borrow issue in AddPerpTriggerOrder
* Move transfer_lamports
* fix accounts comment
* fixed borrow checker issue in execute adv order; added signed version of transfer lamports
* added order_type into LeafNode to help with trading view order movement
* fixed issues with transfering lamports so now RemoveAdvancedOrder works
* added some TODOs for logs; added simulation of perp order to prevent exploits in ExecutePerpTriggerOrder
* added exp to liquidity mining params
* Replaced json logging of FillEvent with borsh serialized LoggableFillEvent base64 encoding
* Added accounts to logs where necessary (mango_group_pk, liqee, liqor). Fixed malformed json. Added logging to cache_perp_markets. Made 'init_health above zero' an error'.
* updated the LoggableFillEvent
* revert throwing zero on 'Account init_health above zero'
* Added accounts to logs where necessary (mango_group_pk, liqee, liqor)… (#55)
* Added accounts to logs where necessary (mango_group_pk, liqee, liqor). Fixed malformed json. Added logging to cache_perp_markets. Made 'init_health above zero' an error'.
* revert throwing zero on 'Account init_health above zero'
* fixed liquidate_perp_market log
* fixed zero open interest bug in perp bankruptcy
* fixed zero open interest bug in perp bankruptcy
* added anchor events framework in mango-logs directory. See the README on how to use it.
* added stubs for all the logs that need to be replaced
* Added mango group to FillLog and added cache prices log, CacheRootBanksLog
* added support for all logs; added OpenOrdersBalanceLog as well whereever OpenOrders changes
* Added PostOnlySlide
* fixed PostOnlySlide
* added MngoAccrual
* added MngoAccrualLog
* rearrange
* removed reduce_only restriction on AddPerpTriggerOrder
* added msg into exec perp trigger
* fixed check in ExecutePerpTriggerOrder
* Fix test build: don't require &'a [AccountInfo<'a>] lifetimes (#59)
It's sufficient to propagate the lifetimes on
checked_unpack_open_orders.
* Add log events for deposit, withdraw and redeem mngo (#58)
* updated I80F48 to u64 in new log structs
* Fix serialization of instructions (#60)
Now it matches what MangoInstruction::unpack() expects.
- Side, OrderType, AssetType, TriggerCondition are serialized into u8
- the Option fields in ChangePerpMarketParams have a fixed width
* merged in changes from main
* Update serum-dex program fixture to 0.4.0
Built from 1be91f2863d8ecede32daaae7e768034e24bbc79
* quantity == u64::max in withdraw now withdraws max possible (if allow borrow false)
* UpdateFunding now caches funding; new UpdateFundingLog
* Add perp trigger order unittests (#61)
* Fix sim_new_bid/ask when the book is empty
* Add first perp trigger order unittest
This test only runs with "cargo test-bpf" as the non-bpf runtime does
not allow creation of pda accounts.
- Test users are now owned by the system program, not by themselves
- MangoProgramTest::process_transaction no longer always returns success
(must check for error; all existing users do)
* Test: Add perp trigger order test around health
* Minor fixes to mango-logs (#63)
* Add mango-logs to Anchor.toml
* mango-logs: Disable doctests
There's nothing to test and they fail spuriously with an ambiguity error
on the mango_logs program.
* Add github actions CI workflow (#64)
* Apply rustfmt
To allow the formatting lint CI job to pass
* Add github actions CI workflow
Adapted from https://github.com/solana-labs/dapp-scaffold
Co-authored-by: dafyddd <daffy321@gmail.com>
* updated github workflows
* added max_withdrawable utility function in processor.rs
* moved max_withdrawable into MangoAccount and now also uses existing deposits
* Added market index to FillLog
* removed some debug logging in execute trigger order
* added the deploy time for v3.1
Co-authored-by: dd <dafydd.durairaj@gmail.com>
Co-authored-by: Ralfs <lagzda7@inbox.lv>
Co-authored-by: Tyler Shipe <tjshipe@gmail.com>
Co-authored-by: Maximilian Schneider <mail@maximilianschneider.net>
Co-authored-by: Riordan Panayides <riordan@panayid.es>
Co-authored-by: root <nicholasgclarke@gmail.com>
Co-authored-by: Christian Kamm <ckamm@delightful-solutions.de>
* Test spot order matching and init liq testing
* Test liquidate_token_and_token
* Rewrite into cookies
* settle_funds test fix
* Removed <Option> from mango_group_cookie
* Removed the Option wrappers where unnecessary for cookies
* Clean up compiler warnings
* Liq test rewrite, added scenarios
* Some more rewrites
* Worst case test with fractions, 10 spot orders and 15 perp orders
* Increment order_id in the test cookie
* Corrected max_coin_qty for spot_order tests
* More readability improvements
* Started rewriting HealthCache again as HealthCache2
* Wrote new more efficient HealthCache and updated place_spot_order
* Fixed liquidate_token_and_token to use new HealthCache method; compiles but is untested
* Added open orders checks everywhere in processor.rs
Co-authored-by: Ralfs <lagzda7@inbox.lv>
Co-authored-by: dd <dafydd.durairaj@gmail.com>
* maker and taker both executing async on event queue now
* Updated liquidate function to properly update open interest
* implemented socialize loss for perp market bankruptcy
* implemented socialize loss for perp market bankruptcy
* implemented settle_fees; upgraded to 1.7.3
* resolve_token_bankruptcy done
* moved interest rate function params into RootBank and added set_rate_params
* Added dao vault to init_mango_group
* added force_cancel_spot_orders
* Wire up liquidate instructions, fix compiler warning
* Added force cancenl perp orders; fixed stack error with inline(never)
* fixed withdraw function
* fixed set_rate_params
* Took out the '***' markers. Incomplete list of changes:
settle borrow is gone
borrow is gone
interest rate params are now stored on root bank
add spot market params changed
add perp market params changed
fees added to PerpMarketInfo
perp cancel order accounts changed
perp cancel order by client id accounts changed
InitMangoGroup accounts + params changed
* Helper functions
* Add new liquidation instructions to the list
* Remove todos
* Added in liquidity incentive fields into PerpMarket, FillEvent and PerpOpenOrders; plumbing unfinished
* Working but apply_incentives still not working
* Implemented apply incentives for cancel perp order functions; Still no tests
* Added liquidity incentive params to add_perp_market instruction
* init_perp_market, deposit, place_and_cancel
* Deposit implemented
* Test deposits re-implemented
* remove logs
* Testing place perp order
* merged in ralfs
* fixed consume events
* Fix tests to work with changes, create mngo and msrm mints in localnet
* Scenarios for place and cancel orders
* Add all spot markets to mango group
* added test_compute
* removed print statements to improve compute
* OO inits as Bids
* added some tx size optimization ideas
* added fast mul for unsigned I80F48
* started implementing Fast fixed point library
* Place spot order test working
* Code cleanup for previous
* Worst case scenario test
* Clock implemented
* started pushing in FI80F48
* Fix add oracle test bug
* Mint order fix
* 31 spot open orders test working
* 32 deposits, 31 spot open orders test
* cleaned up get_health and adding logging options for tests
* Perps added to test
* do an active_asset check on perp market before calculating health for it
* bunch of stuff
* Mint fixes
* uncommented perps
* clean up
* Fix duplicate borrows
* Resolve compiler warnings
* Massive cleanup of the tests
* fixed place perp order with reduce_only
* Massive cleanup of the tests part 2
* updated naming of fastmath checked ops
* updated liquidate token and token with optimizations
* optimized bankruptcy and liquidation functions
* wip to get fraction deposits
* not compiling; llvm intrinsics error
* removed llvm stuff
* Tests with fractions
* AddPerpMarket instruction changed
PerpMarket layout changed substantially
EventQueueHeader layout increased by 32 bytes to hold fee info
MangoGroup add 64 bytes padding at the end for expansions
MangoAccount add 32 byte buffer for info; add extra 64 byte padding at end for expansions
CancelPerpOrder and CancelPerpOrderByClientId now take in perp_market_ai as write
InitSpotOpenOrders instruction added and placeSpotOrder does not implicitly initialize an OpenOrders account. Look at mango-client-v3 in placeSpotOrder method to see new way to call
* AddPerpMarket instruction changed
PerpMarket layout changed substantially
EventQueueHeader layout increased by 32 bytes to hold fee info
MangoGroup add 64 bytes padding at the end for expansions
MangoAccount add 32 byte buffer for info; add extra 64 byte padding at end for expansions
CancelPerpOrder and CancelPerpOrderByClientId now take in perp_market_ai as write
InitSpotOpenOrders instruction added and placeSpotOrder does not implicitly initialize an OpenOrders account. Look at mango-client-v3 in placeSpotOrder method to see new way to call
MAX_TOKENS=16
* merged in main; test-bpf worst_case_scenario still doesn't work; ready for mergin into main
Co-authored-by: dd <dafydd.durairaj@gmail.com>
Co-authored-by: Riordan Panayides <riordan@panayid.es>
Co-authored-by: Ralfs <lagzda7@inbox.lv>
* maker and taker both executing async on event queue now
* Updated liquidate function to properly update open interest
* implemented socialize loss for perp market bankruptcy
* implemented socialize loss for perp market bankruptcy
* implemented settle_fees; upgraded to 1.7.3
* resolve_token_bankruptcy done
* moved interest rate function params into RootBank and added set_rate_params
* Added dao vault to init_mango_group
* added force_cancel_spot_orders
* Wire up liquidate instructions, fix compiler warning
* Added force cancenl perp orders; fixed stack error with inline(never)
* fixed withdraw function
* fixed set_rate_params
* Took out the '***' markers. Incomplete list of changes:
settle borrow is gone
borrow is gone
interest rate params are now stored on root bank
add spot market params changed
add perp market params changed
fees added to PerpMarketInfo
perp cancel order accounts changed
perp cancel order by client id accounts changed
InitMangoGroup accounts + params changed
* Helper functions
* Add new liquidation instructions to the list
* Remove todos
* Added in liquidity incentive fields into PerpMarket, FillEvent and PerpOpenOrders; plumbing unfinished
* Working but apply_incentives still not working
* Implemented apply incentives for cancel perp order functions; Still no tests
* Added liquidity incentive params to add_perp_market instruction
* init_perp_market, deposit, place_and_cancel
* Deposit implemented
* Test deposits re-implemented
* remove logs
* Testing place perp order
* merged in ralfs
* fixed consume events
* Fix tests to work with changes, create mngo and msrm mints in localnet
* Scenarios for place and cancel orders
* Add all spot markets to mango group
* added test_compute
* removed print statements to improve compute
Co-authored-by: dd <dafydd.durairaj@gmail.com>
Co-authored-by: Riordan Panayides <riordan@panayid.es>
Co-authored-by: Ralfs <lagzda7@inbox.lv>
* fixed health calculation in get_spot_health by simulation bids and asks; added some inline nevers; added mutual exclusivity checks in MangoAccount checked_add, checked_sub functions
* rewrote place_spot_order
* added more checks to settle_funds instruction;
Co-authored-by: dd <dafydd.durairaj@gmail.com>
* in the middle of revising health factor
* rewrote the health factor; still need to fix asset_liab calculation; tests failing
* Changed add_perp_market and add_spot_market instruction to take in init_leverage and maint_leverage
* continued work on liquidation but unfinished
* implementing liquidation still
* more progress on liq
* implemented first draft of `liquidate_perp`; untested, existing tests not succeeding
* fixed bug with merging
Co-authored-by: dd <dafydd.durairaj@gmail.com>