Skip to content
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

Adds origination fee and program fee related updates #934

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

jgur-psyops
Copy link
Contributor

@jgur-psyops jgur-psyops commented Oct 28, 2024

Handles changes from mrgnlabs/marginfi-v2#244 and mrgnlabs/marginfi-v2#239, adding origination fees on borrow and program-level fees (paid to the program administrator) that are collected by a global fee wallet.

Changes:

  • Banks have a new field: bank.config.interest_rate_config.protocol_origination_fee and bank.collected_program_fees_outstanding
  • Groups have new fields: group_flags and fee_state_cache.
  • A new account called FeeState exists. This account is one-of-a-kind per program.
  • A new ix init_global_fee_state will run once after this program update, and then be removed from the program buffer in a subsequent update.
  • A new FeeState admin-only ix edit_global_fee_state modifies program fees.
  • A new FeeState admin-only ix config_group_fee controls if a group pays program fees or not.
  • A new permissionless ix propagate_fee_state forces a group to adopt the current global FeeState regime.
  • add_bank now requires the FeeState account and the interest rate config now has a protocolOriginationFee field.
  • collect_bank_fees now requires the global fee state and fee ata, which is the canonical ATA of FeeState.global_fee_wallet

Launch readiness checklist:

  • UI supports the changes above
  • Program deployed to staging
  • init_fee_state runs once, signed by the program multisig
  • Groups created from this point on will automatically have program fees (flat sol to create pool, % of borrow fee revenue) enabled, no further action required.
  • Banks created from this point on will configure their borrow origination fee on setup (add_pool) or via configure_bank
  • Test fund FeeState.global_fee_wallet with some SOL to make sure it is a valid account that we own.
  • Test create a group and pool, verify the FeeState.global_fee_wallet gains the flat sol fee.
  • Test create a bank with a non-zero origination fee, verify the user owes X+fee after a borrow of X. Verify a portion of the fee goes to the group, and the rest to the program.
  • Prepare infra to run propagate_fee_state for all groups that exist after any changes to fees (edit_global_fee_state)
  • Program deployed to mainnet
  • init_fee_state runs once for mainnet, signed by the program multisig

Less important but should do eventually:

  • propagate_fee_state runs for any group that existed prior to this update.
  • config_group_fee runs for any group that existed prior to this update that should enable program fees.
  • configure_bank runs for any bank that existed prior to this update that should enable borrow origination fees.
  • Create ATA's for FeeState.global_fee_wallet any asset we will ultimately collect fees on, or modify how collect_bank_fees is called to create the ATA as needed.
  • Begin update to remove init_fee_state from the program buffer
  • config_group_fee turns off fees for any group created after this update that is whitelisted and should not pay them (e.g. arena groups already owned by mrgn)
  • UI elements to show users how much they will pay in origination fees.

Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marginfi-landing-page ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:20pm
marginfi-v2-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:20pm
marginfi-v2-trading ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:20pm
marginfi-v2-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:20pm

Copy link

🤖 No test run has been triggered as your Meticulous project has been deactivated (since you haven't viewed any test results in a while). Click here to reactivate.

Last updated for commit af3b815. This comment will update as new commits are pushed.

@k0beLeenders k0beLeenders merged commit ce9a9f7 into main Nov 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants