Skip to content
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

allow setting first week epoch in farm #835

Merged
merged 6 commits into from
Feb 22, 2024
Merged

Conversation

dorin-iancu
Copy link
Contributor

@dorin-iancu dorin-iancu commented Feb 12, 2024

Added the possibility of setting first_week_start_epoch when deploying the farm contracts.

Also done some misc changes:

  • reorder some conditions for early-exit
  • removed set_if_empty. No longer needed since we have a separate method
  • also removed the migration code from the init function

Copy link

github-actions bot commented Feb 12, 2024

Contract comparison - from cad0c11 to 2ed5386

Path                                                                                             size                  has-allocator                     has-format
mx-exchange-sc
- pause-all/pause-all.wasm 5548 No No
mx-exchange-sc/dex
- farm/farm.wasm 38759 ➡️ 38842 🔴 No No
- farm-with-locked-rewards/farm-with-locked-rewards.wasm 38439 ➡️ 38525 🔴 No No
- governance/governance.wasm 17355 No No
- pair
- - pair.wasm 31271 No No
- - pair-full.wasm 32650 No No
- - safe-price-view.wasm 7888 No No
- pair-mock/pair-mock.wasm 5470 No No
- price-discovery/price-discovery.wasm 16381 No No
- proxy-deployer/proxy-deployer.wasm 4502 ➡️ 4578 🔴 No No
- router/router.wasm 26718 No No
mx-exchange-sc/energy-integration
- energy-factory-mock/energy-factory-mock.wasm 4277 No No
- energy-update/energy-update.wasm 1558 No No
- fees-collector/fees-collector.wasm 18953 No No
- governance-v2/governance-v2.wasm 16680 No No
mx-exchange-sc/farm-staking
- farm-staking/farm-staking.wasm 43393 ➡️ 43517 🔴 No No
- farm-staking-proxy/farm-staking-proxy.wasm 19393 No No
- metabonding-staking/metabonding-staking.wasm 10176 No No
mx-exchange-sc/locked-asset
- distribution/distribution.wasm 14292 No No
- energy-factory/energy-factory.wasm 35029 No No
- factory/factory.wasm 30471 No No
- lkmex-transfer/lkmex-transfer.wasm 11288 No No
- locked-token-wrapper/locked-token-wrapper.wasm 14586 No No
- proxy_dex/proxy_dex.wasm 36917 No No
- simple-lock/simple-lock.wasm 24491 No No
- simple-lock-whitelist/simple-lock-whitelist.wasm 26210 No No
- token-unstake/token-unstake.wasm 14288 No No

@dorin-iancu dorin-iancu marked this pull request as ready for review February 12, 2024 09:35
CostinCarabas
CostinCarabas previously approved these changes Feb 13, 2024
fn claim_boosted_rewards(&self, opt_user: OptionalValue<ManagedAddress>) -> EsdtTokenPayment {
let current_epoch = self.blockchain().get_block_epoch();
let first_week_start_epoch = self.first_week_start_epoch().get();
require!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the extra check in place? We already have the check when computing the actual rewards. Maybe we accept that until the first_week_start_epoch is reached, we don't fail the endpoint, and just return 0. Then, after we pass that particular epoch, we avoid the 2 extra reads.

}

storage_cache.reward_reserve += &total_reward;
let split_rewards = sc.take_reward_slice(total_reward);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a check in the startProduceRewards endpoint, to not allow the rewards to start generating, if current_epoch < first_week_start_epoch. This way, we avoid getting to the point where we may call an endpoint (like enterFarm) that calls the take_reward_slice function, which then would throw a SC error.

@psorinionut psorinionut changed the base branch from main to feat/v3.1 February 22, 2024 13:36
@psorinionut psorinionut dismissed CostinCarabas’s stale review February 22, 2024 13:36

The base branch was changed.

@psorinionut psorinionut merged commit 834166d into feat/v3.1 Feb 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants