-
Notifications
You must be signed in to change notification settings - Fork 8
mango msol #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mango msol #146
Conversation
* - ProgramResult -> Result<()> * Use error! * use error from anchor * Add Check for Unchecked accountsInfo * WIP trying to make it work but seems that devnet is having issues. Pausing for now
* feat: accounting suite for accounting tests * added more checks * working * changed back to test_development
* Use new anchor-comp package for mango CPI * remove old CPI helpers * Safe changes (w/o mint/redeem/rebalance) * Use place_perp_order_v2 and simplify code * Working * Update tests (most logic been offloaded to Mango) * Remove uneeded accounts + explicit ATA checks * allow 100% slippage * Improve computing for tests * Slippage tweaks - Slippage u32 -> u16 - 0 slippage accepted again (was disabled due to previous code but that's been refactored)
* Update mango 3.4.1 * fix comment * Enforce limit price through providing it from front end * Cleanup * Ken comments * idl * json idl
* Add zo-abi WIP zo Stash pop stash pop WIP Cpi almost there. More updates Currently doesn't work with yarn so kinda annoying, let's wait for them to fix this as discussed in the TG Toward cpi support.. Toward cpi support.. almost there Update reserved padding Update IDL and client version (still using yarn link) Fixes Working Init zo deposiroty + tests Init Control account in the program for simplicity Mint WIP Cargo audit fix Working register with OO account creationg Mint issue with CPI Update client * wip ZO - issue with constraint. Will add anchor latest for more info to debug * Deposit mint * Redeem and mint - Computing issue. Breakpoiint will transit to 0copy * Redeem withdraw and controller as zero_copy Require! * Update PR feedback * Use latest client (private) Use accountLoader for mango depository * Fixing test slowly... * More test updates and fixes * Update latest 01 version * Fixed tests * ZO Cleanup (Make a branc without any ZO change for clarity) * Updated idl * add the mistakenly erased bank keypair
* Use udx-protocol on NPM instead of private gh version * Misc * Fixed mint * Working integration tests * Offering to Clippy gods + fmt * New program ID + resident program for CI * Update CI * npm ci Co-authored-by: Bamboozelino <memail>
* first * instructions (#139) * instructions * comments * api * rename * math * start on tests * wip tests * require * fixes with accounts and merge * quote_redeem (#140) * quote_redeem * comments * fixed comments and mango check * a * poggers * latest * save * nothing * save * math fixes * save * Invalid Blockhash * for remote version * Feature/positive minting and more (#151) * quote_redeem * comments * fixed comments and mango check * a * poggers * latest * save * nothing * save * math fixes * save * Fix memory layout of accounts * Use the oss version of the client and ditch the private one * Invalid Blockhash * for remote version * simplified assertion (#147) * save changes * save * Chore/fix tests (#149) * Use udx-protocol on NPM instead of private gh version * Misc * Fixed mint * Working integration tests * Offering to Clippy gods + fmt * New program ID + resident program for CI * Update CI * npm ci Co-authored-by: Bamboozelino <memail> * committed * save * progress Co-authored-by: Acammm <alexcamill@gmail.com> Co-authored-by: Ken C <ctk2012ac@gmail.com> Co-authored-by: acammm <40299747+acamill@users.noreply.github.com> * Work with max * misc - added test to ensure user has UXD - formatting - account mutability for mango * Added test quote test to CI * - fix quoteMintAndRedeemSuite switch cases - fix quote mint and redeem test asserts - changed equals to close_to * testing improvements - adding accounting tests for quoteMint and quoteRedeem - incorporate accounting tests into test suite * - small test fix * Test working Co-authored-by: Max Planck <maxplanck.crypto@gmail.com> Co-authored-by: Max Planck <99688618+CryptoMaxPlanck@users.noreply.github.com> Co-authored-by: Ken C <ctk2012ac@gmail.com> Co-authored-by: Bamboozelino <memail>
|
|
||
| pub fn handler(ctx: Context<EnableMsolSwap>, enable: bool) -> Result<()> { | ||
| let msol_config = &mut ctx.accounts.msol_config.load_mut()?; | ||
| msol_config.enabled = enable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure should we have a single "edit_msol_settings" or smthg and have a object passed as parameter that can change multiple parameters, makes the code simpler.
Downside is that it's less explicit, I do like solo instruction like this one more, just takes more space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather make them explicit, there are only two fields editable right now and can't see there are anymore in the current "msol" scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yhea ok let's keep that for a global param struct refactor later on
programs/uxd/src/lib.rs
Outdated
| target_liquidity_ratio: u16, | ||
| ) -> Result<()> { | ||
| msg!("[create_depository_msol_config]"); | ||
| instructions::create_depository_msol_config::handler(ctx, target_liquidity_ratio).map_err( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been removed from a while ago can do a rebase
programs/uxd/src/lib.rs
Outdated
| )] | ||
| pub fn enable_msol_swap(ctx: Context<EnableMsolSwap>, enable: bool) -> Result<()> { | ||
| msg!("[enable_msol_swap]"); | ||
| instructions::enable_msol_swap::handler(ctx, enable).map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
programs/uxd/src/lib.rs
Outdated
| target_liquidity_ratio: u16, | ||
| ) -> Result<()> { | ||
| msg!("[set_msol_liquidity_ratio]"); | ||
| instructions::set_msol_liquidity_ratio::handler(ctx, target_liquidity_ratio).map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you want to call or review smthg specific, I think we could finalize this by the time @alg747 join so that we can start UXSol
(Also I assume latest changes are not reflected here you must have another unpushed branch)
* first commit * - added "should fail" tests for quoteMint and quoteRedeem - added unit tests
* added msol config state and ixn to create one * added msol config ixns * doc updated * added back account contraints * updated according to pr comments * fixed error code * renamed conversion to swap * rebased fixed error * used account loader create msol config * used account loader / require
* added mango_info * dissolved mango info * use local client package for testing
* wip wip swapping enabled checking wip test cpi wip added mut to accounts liquid unstake cpi test msol fixed up wip sol-msol-sol draft disable wip sol-msol-sol test clean up program removed unused ix and test code fixed error and better doc reverted debug code fixed fmt/clippy fixed ata pass to mango cpi * fixed idl * added mainnet integration test for msol / fixed program (#159) * internal mainnet testing setup * rm extra seed added for debug * set mainnet program address * added wrap/unwrap sol on chain * added sync native after wrapping * minor * revert test_development * exit ix when swapping amount is zero * added msol utils, refactor * install marinade sdk * refactor test * fixed comment
| let cpi_program = self.mango_program.to_account_info(); | ||
| CpiContext::new(cpi_program, cpi_accounts) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have the factorisation but would be nice to keep it smol in the main logic. Can do by adding two helper that keep the parameterization out of the main logic here
| } | ||
| MsolSwapRoute::LiquidUnstake => { | ||
| // 6. msol equivalent lamports need to withdraw from mango | ||
| let liquid_unstake_lamports: u64 = diff_to_target_liquidity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount of MSOL to be withdrawn and converted back to SOL
-> sol_withdraw_amount
| .ok_or_else(|| error!(UxdError::MathError))?; | ||
|
|
||
| // 7. msol amount of (6) | ||
| let msol_liquid_unstake_amount = marinade_state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount of MSOL to be unstaked from Marinade
calc_msol_from_lamports -> convert_sol_to_msol_amount
DISLAIMER: it's from Marinade not us, so cannot rename (@cnek )
| )?; | ||
|
|
||
| // 9. convert msol from msol passthrough to sol and transfer to the user | ||
| let cpi_ctx = ctx.accounts.into_liquid_unstake_cpi_ctx(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here depending of the amount of buffer left should be done delayed or instant
|
update: |
#142
#145
#156
#159
work with anchor-comp branch: mango_msol (related PR UXDProtocol/anchor-comp#5)