-
Notifications
You must be signed in to change notification settings - Fork 20
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
Clean incentives state when users unstake #436
Conversation
// - LP in incentives = 300 (user_a 100, user_b 200) | ||
// - Rewards available for user_1 = 0 | ||
// - Rewards available for user_2 = 0 | ||
assert_eq!( |
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.
The bug should be isolated to separate test case to show exactly where is the problem.
Right now is composed between full LP lifecycle and here we check what is expected (I checked first commit on the branch) vs raising existing problem with invalid rewards amount in the contract.
I would recommend to use example from this branch https://github.com/mars-protocol/contracts-internal/pull/117
This way we can see real funds transfer and actual error not like this on first commit on this branch:
assertion `left == right` failed
left: Some(Uint128(0))
right: None
let prefix = USER_ASTRO_INCENTIVE_STATES.prefix((account_id, lp_coin.denom.as_str())); | ||
|
||
// Iterate over all reward_denom keys | ||
let keys_to_remove: Vec<String> = |
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.
Better to raise error for a key (not filter out)...
I would use:
let keys_to_remove: StdResult<Vec<String>> = prefix.keys(store, None, None, Order::Ascending).collect();
or
let keys_to_remove = prefix.keys(store, None, None, Order::Ascending).collect::<StdResult<Vec<String>>>()?;
|
||
// Get all incentive states for the lp_key | ||
let prefix = ASTRO_INCENTIVE_STATES.prefix(lp_key); | ||
let keys_to_remove: Vec<_> = |
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. See comment for line 265
@markonmars remember about this one (if rewards already claimed in the same block): And ideally we could improve logging just in case for future. Maybe you found something worth to include: |
* fix spelling types_diff_v1_0_0__mars_v2.txt * fix spelling issue test_incentives.rs * add auxiliary verb health_computer.rs
* Init devnet config for neutron. * Update params. * Update config to match mainnet data. * Include dAtom asset params. * Update HLS setup. * Comment out price checking. * Disabled dAtom/Atom lp whitelisting. * Redemption rate for dAtom price source.
* Bump minor cw version. * Update optimizer and rust version. * Mars ver to 2.1.0, cleanup migrations, fix clippy.
…protocol/contracts into MP-2662-fix-incentives-bug
closing, replaced with #437 |
When users unstake from Astroport via Mars incentives contract, we should clean up the state if the user has no more position.
We should also do the same if the denom has no positions (i.e TOTAL_STAKED_LP = 0)