mrgnlabs / marginfi-v2

Apache License 2.0
147 stars 61 forks source link

cli: add seed to add bank command #160

Closed exdx closed 6 months ago

exdx commented 6 months ago

Updates the mfi group add bank command to have an optional seed boolean argument. If seed is set then the command generates a PDA and uses it to sign the ix on behalf of the bank.

Based off the work in https://github.com/mrgnlabs/marginfi-v2/issues/154.

Generates a PDA from seeds and a random string iteratively. Uses the PDA to then sign on behalf of the bank in the group_add_bank command.

Continuation of #158

jkbpvsc commented 6 months ago

Seeing lint and tests failing

exdx commented 6 months ago

CI is green @jkbpvsc -- I accidentally feature-gated imports in utils.rs which broke a lot of things lol.

Ready for another look. I think conceptually this PR is ready I just want to make sure the business logic is correct.

I do think using generics could slim this down further but I will look into that as a follow-up. Would be nice to abstract the different between AddBank and AddBankWithSeed further via a trait and only have one fn here instead of two. They are very similar conceptually.