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

farm position functionality #760

Merged
merged 71 commits into from
Oct 2, 2023
Merged

farm position functionality #760

merged 71 commits into from
Oct 2, 2023

Conversation

psorinionut
Copy link
Contributor

  • Added total user farm position storage. It is updated on every user interaction (enter/exit farm, claim/compound rewards, merge positions)
  • It includes a new endpoint for computing the user's new total farm position
  • It includes a new claimBoostedRewards endpoint, which allows any user to claim the boosted rewards for himself or for another user

dex/farm/src/base_functions.rs Outdated Show resolved Hide resolved
dex/farm/src/base_functions.rs Outdated Show resolved Hide resolved
dex/farm/src/claim_boost_only.rs Outdated Show resolved Hide resolved
dex/farm/src/claim_boost_only.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_position/src/farm_position.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_position/src/farm_position.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_position/src/farm_position.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_position/src/farm_position.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_position/src/farm_position.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Contract comparison - from 711aede to 3cf4458

Path                                                                                             size                  has-allocator                     has-format
mx-exchange-sc
- pause-all/pause-all.wasm 5438 No No
mx-exchange-sc/dex
- farm/farm.wasm 38165 ➡️ 38690 🔴 No No
- farm-with-locked-rewards/farm-with-locked-rewards.wasm 37846 ➡️ 38299 🔴 No No
- governance/governance.wasm 17283 No No
- pair
- - pair.wasm 30515 ➡️ 30513 🟢 No No
- - pair-full.wasm 31971 ➡️ 31962 🟢 No No
- - safe-price-view.wasm 7862 No No
- pair-mock/pair-mock.wasm 5474 No No
- price-discovery/price-discovery.wasm 16254 No No
- proxy-deployer/proxy-deployer.wasm 4457 No No
- router/router.wasm 25991 No No
mx-exchange-sc/energy-integration
- energy-factory-mock/energy-factory-mock.wasm 4233 No No
- energy-update/energy-update.wasm 1510 No No
- fees-collector/fees-collector.wasm 18320 ➡️ 18531 🔴 No No
- governance-v2/governance-v2.wasm 16693 No No
mx-exchange-sc/farm-staking
- farm-staking/farm-staking.wasm 41505 ➡️ 42863 🔴 No No
- farm-staking-proxy/farm-staking-proxy.wasm 22835 ➡️ 18629 🟢 No No
- metabonding-staking/metabonding-staking.wasm 9595 ➡️ 9593 🟢 No No
mx-exchange-sc/locked-asset
- distribution/distribution.wasm 14358 No No
- energy-factory/energy-factory.wasm 34616 No No
- factory/factory.wasm 30375 No No
- lkmex-transfer/lkmex-transfer.wasm 11214 No No
- locked-token-wrapper/locked-token-wrapper.wasm 14291 No No
- proxy_dex/proxy_dex.wasm 35671 ➡️ 35363 🟢 No No
- simple-lock/simple-lock.wasm 24300 ➡️ 24112 🟢 No No
- simple-lock-whitelist/simple-lock-whitelist.wasm 25946 ➡️ 25758 🟢 No No
- token-unstake/token-unstake.wasm 13625 No No

@CostinCarabas CostinCarabas self-requested a review August 25, 2023 13:11
common/modules/farm/config/src/config.rs Outdated Show resolved Hide resolved
common/modules/farm/farm_base_impl/src/base_traits_impl.rs Outdated Show resolved Hide resolved
Comment on lines +233 to +235
let farm_token_mapper = sc.farm_token();
let token_attributes: FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api> =
farm_token_mapper.get_token_attributes(farm_position.token_nonce);
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting attributes a second time, first time on line 204. Why not give them as argument?

Copy link
Contributor

Choose a reason for hiding this comment

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

We use decrease_user_farm_position in other contexts (i.e. BaseExitFarmModule).
I think the improvement here would be less than the expense in exit_farm_base: we would have to get farm_token from storage and then get_token_attributes.

dex/farm/src/base_functions.rs Outdated Show resolved Hide resolved
farm-staking/farm-staking/src/base_impl_wrapper.rs Outdated Show resolved Hide resolved
psorinionut and others added 26 commits September 20, 2023 10:38
Moved try_set_farm_position_migration_nonce to common modules to
remove code duplication.
@psorinionut psorinionut merged commit 3491557 into main Oct 2, 2023
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.

4 participants