Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(perp): MsgWithdrawFromPerpFund sudo call as part of #1642 #1734
feat(perp): MsgWithdrawFromPerpFund sudo call as part of #1642 #1734
Changes from 12 commits
240dffe
596a840
5121341
0090d2f
e43672a
d3f0ce3
1316f18
cc89084
40aec00
b7fc955
1e2e226
bf89c80
a9938d4
11cb148
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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) it might be safer to just withdraw to whoever sends the message, i.e. the message
sender
.I can foresee possible human error in the future where somebody sends the message but accidentally sets the
to_addr
different from the message signer/sender.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 think so too. The problem we might encounter here is when the claim goes to a smart contract that doesn't expose a function to withdraw its balance, or if there's routing happening between multiple contracts like the ones used in Mars Protocol or in future Nibiru-developed contracts.
sudo_contract_calls_msg -> withdraw_to_contract_addr -> No fn to withdraw -> funds are lost
I'm trying to avoid this ^ deadlock.
Adding an explicit
to_addr
makes it less error prone in a different way, by making the caller pass in the location they want the funds to end up.Another option is to make that field nullable, so that empty means,
to_addr := sender
. Would you prefer that?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.
Wow, I didn't even consider that scenario. In that case, then I think it's better to be explicit.
Thinking about it more, in the general case, we'll likely be sending these
WithdrawFromPerpFund
messages from the CW3 multisig. Having the ability to target a recipient with the message would be more efficient, instead of withdrawing to the CW3 multisig and then doing a bank transfer.A more sophisticated design could be to only execute the message if the
to_addr
is in thesudo
sudoers list. It would prevent the funds from going to a CosmWasm smart contract that doesn't have the withdraw functionality, because we would be the ones whitelisting the possible recipients. But that could be addressed in a separate PR. What's implemented looks good to me.