-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add flashloan fee #273
base: main
Are you sure you want to change the base?
Add flashloan fee #273
Conversation
@@ -23,11 +23,14 @@ pub struct FeeState { | |||
/// Flat fee assessed when a new bank is initialized, in lamports. | |||
/// * In SOL, in native decimals. | |||
pub bank_init_flat_sol_fee: u32, | |||
/// Flat fee assessed at flashloan end, in lamports. |
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 struct is live on mainnet now, so new fields need to go at the end (just before padding) to avoid breaking existing serialization.
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.
done, let me know if it's preferred that I move the flashloan_flat_sol_fee
to be the last arg in all the methods as well. I had put it next to the other "flat_sol" fee arbitrarily.
@@ -144,4 +156,29 @@ pub struct LendingAccountEndFlashloan<'info> { | |||
pub marginfi_account: AccountLoader<'info, MarginfiAccount>, | |||
#[account(address = marginfi_account.load()?.authority)] | |||
pub signer: Signer<'info>, | |||
// Note: there is just one FeeState per program, so no further check is required. | |||
#[account( | |||
seeds = [FEE_STATE_SEED.as_bytes()], |
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.
Nit: we don't need the seed check, this account is unique per-program deployment.
Almost LGTM, just needs updates to the tests in tests/user_actions/flash_loan.rs (there are currently no flashloan TS tests but that would be a nice-to-have as well). |
The TS side tests also need to be updated for initGlobalFeeState and editGlobalFeeState in group-instructions.ts. current CI pipeline failure is from roothooks.ts:164 not having the extra argument) |
@jgur-psyops all that's left is the tests but been having a tough time getting the rust tests to work. The closest I've gotten is e.g. running
Best guess atm is I still haven't built something or set some flag correctly. I built and have .so for brick, liquidity_incentive_program, marginfi, mocks, test_transfer_hook. When I run EDIT: nvm got it. reinstalled everything following CI. its a new day. |
Thanks for the feedback @jgur-psyops. Ready for another review if you'd like to get this in ASAP--gonna see if I can come back to the TS nice to have. |
Attempt to close #270. All feedback welcome. No worries if this is too far from the right way to go about it.
I'm also wondering if this could perhaps do with a test similar to this one
marginfi-v2/tests/03_addBank.spec.ts
Line 74 in bd7efda
If so, afaict there aren't ts tests for flashloans so would have to add a new file perhaps?