-
Notifications
You must be signed in to change notification settings - Fork 12
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
Remove BONDED_AMOUNT and additional query/execute functionality #202
Conversation
a8132f1
to
d9aab18
Compare
contracts/core/src/contract.rs
Outdated
let bond_provider_balances = deps | ||
.querier | ||
.query_all_balances(bond_provider_address.clone())?; | ||
let bond_provider_balances_except_untrn = bond_provider_balances | ||
.into_iter() | ||
.filter(|coin| coin.denom != *UNTRN_DENOM.to_string()) | ||
.collect::<Vec<Coin>>(); | ||
if !bond_provider_balances_except_untrn.is_empty() { | ||
return Err(ContractError::BondProviderBalanceNotEmpty {}); | ||
} |
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 we should add query interface to the bond provider and let him answer can it be removed or not. Because there is internal state in the provider and it relates not only to bank balance but on other operations as well. So the real way to remove provider on working protocol is to pause bonding, wait for all balances and internal states becomes normal and only after that we can safely remove bond provider
let all_balances = deps.querier.query_all_balances(env.contract.address)?; | ||
let all_balances_except_untrn = all_balances | ||
.into_iter() | ||
.filter(|coin| coin.denom != *LOCAL_DENOM.to_string()) | ||
.collect::<Vec<Coin>>(); |
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.
Unfortunately this is not enough, we also need to be sure there is no any PENDING_LSM_SHARES and LSM_SHARES_TO_REDEEM, and only after that we are safe to remove provider (during one block)
let all_balances = deps.querier.query_all_balances(env.contract.address)?; | ||
let all_balances_except_untrn = all_balances | ||
.into_iter() | ||
.filter(|coin| coin.denom != *LOCAL_DENOM.to_string()) | ||
.collect::<Vec<Coin>>(); |
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 here, we also need to check for empty NON_STAKED_BALANCE
PR includes some of proposed audit fixes:
Missing input deduplicationUnfinished developmentUsage of panic for handling errors is discouraged