Skip to content

Commit

Permalink
do not claim ANC rewards if it is 0
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
  • Loading branch information
pronvis committed Apr 21, 2022
1 parent 8a5787c commit b273a1c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Binary file modified artifacts/basset_vault_basset_vault.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1127642dd241faa3b23503159e9f3867df300e50ebc8ab9f24d8b3d5fa2bf340 basset_vault_basset_vault.wasm
d3eaf6baed48a002ab8e4257653eb3eebbe3ab0091f01155e55154286cc8a01c basset_vault_basset_vault.wasm
45293766020f103310e7e27d85b48287155cb52173c65a784ed44bd25a8842c9 basset_vault_basset_vault_strategy.wasm
cc231ca7a6e90a8fae048e865714a7dc3a14a3abd94205c59da926a4dd1f60ee basset_vault_nasset_config_holder.wasm
832394369cbd808e71690fa2a8f26d04750dec8e373c47867dcb729076d0417c basset_vault_nasset_rewards.wasm
Expand Down
2 changes: 1 addition & 1 deletion artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
59725f40d37d0d42324af258dce0e47f984a1fdb31067976f159effe78b9d912 target/wasm32-unknown-unknown/release/basset_vault_basset_vault.wasm
05103436757614be84ef82f0fe2f49f41633e821c646b4658ea842344438f993 target/wasm32-unknown-unknown/release/basset_vault_basset_vault.wasm
0a9a05b9fbde3f8196d89feb43c0c897ed9e953edd52d0c7366ed23a50ce31a4 target/wasm32-unknown-unknown/release/basset_vault_basset_vault_strategy.wasm
ca7504c44c5e1fe36707388fe3dca16c7d8fb1b6ea825593ac297e22d0f617bb target/wasm32-unknown-unknown/release/basset_vault_nasset_config_holder.wasm
63926e4ae2cb5f28f42580f3a124d39974255e6ff64dae0fb82b6b41dbe221e2 target/wasm32-unknown-unknown/release/basset_vault_nasset_rewards.wasm
Expand Down
13 changes: 12 additions & 1 deletion contracts/basset_vault/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ pub fn is_anc_rewards_claimable(
) -> StdResult<bool> {
let enough_pending_rewards =
pending_rewards >= Decimal256::from_uint256(MIN_ANC_REWARDS_TO_CLAIM);
Ok(enough_pending_rewards || is_last_anc_claim_was_24_hours_ago(deps, env)?)
let is_there_any_rewards = pending_rewards > Decimal256::zero();
Ok(is_there_any_rewards
&& (enough_pending_rewards || is_last_anc_claim_was_24_hours_ago(deps, env)?))
}

fn is_last_anc_claim_was_24_hours_ago(deps: Deps, env: &Env) -> StdResult<bool> {
Expand Down Expand Up @@ -1767,5 +1769,14 @@ mod test {
is_anc_rewards_claimable(deps.as_ref(), &env, Decimal256::from_uint256(100_000u64));
assert!(!is_claimable.unwrap());
}

// pending rewards is 0ANC tokens. So we should not claim it, even if last claim was long
// time ago
{
let last_anc_claim_seconds = 0;
store_last_anc_claim_seconds(deps.as_mut().storage, &last_anc_claim_seconds).unwrap();
let is_claimable = is_anc_rewards_claimable(deps.as_ref(), &env, Decimal256::zero());
assert!(!is_claimable.unwrap());
}
}
}

0 comments on commit b273a1c

Please sign in to comment.