elys-network / elys

Elys Network is the first All-In-One DEFI platform to join the Atom Economic Zone, backed by Informal Systems and the Cosmos Hub. Built on Cosmos and CometBFT, leveraging the latest blockchain technologies to provide a premier user experience. Visit our official site at https://elys.network
https://elys.network
Apache License 2.0
57 stars 51 forks source link

[Perpetual]: add stop loss price #759

Closed cryptokage1996 closed 1 week ago

cryptokage1996 commented 2 weeks ago

Add message to update the stop loss of a given position.

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 47.36842% with 60 lines in your changes missing coverage. Please review.

Project coverage is 43.08%. Comparing base (3eca470) to head (b3e2e59). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #759 +/- ## ========================================== + Coverage 43.06% 43.08% +0.01% ========================================== Files 637 640 +3 Lines 20900 21005 +105 ========================================== + Hits 9001 9049 +48 - Misses 10830 10882 +52 - Partials 1069 1074 +5 ``` | [Components](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | Coverage Δ | | |---|---|---| | [leveragelp_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `93.13% <ø> (ø)` | | | [leveragelp_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `88.29% <ø> (ø)` | | | [leveragelp_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `86.58% <ø> (ø)` | | | [leveragelp_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `19.28% <ø> (ø)` | | | [accountedpool_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `100.00% <ø> (ø)` | | | [accountedpool_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [accountedpool_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `68.42% <ø> (ø)` | | | [amm_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `57.93% <ø> (ø)` | | | [amm_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `79.16% <ø> (ø)` | | | [amm_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `61.13% <ø> (ø)` | | | [amm_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `29.94% <ø> (ø)` | | | [assetprofile_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `78.82% <ø> (ø)` | | | [assetprofile_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [assetprofile_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `83.33% <ø> (ø)` | | | [assetprofile_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `47.41% <ø> (ø)` | | | [burner_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `0.00% <ø> (ø)` | | | [burner_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [burner_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `100.00% <ø> (ø)` | | | [burner_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `63.54% <ø> (ø)` | | | [clock_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `30.00% <ø> (ø)` | | | [clock_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [clock_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `76.92% <ø> (ø)` | | | [clock_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [commitment_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `48.95% <ø> (ø)` | | | [commitment_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [commitment_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `19.60% <ø> (ø)` | | | [commitment_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `9.33% <ø> (ø)` | | | [epochs_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [epochs_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `100.00% <ø> (ø)` | | | [epochs_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `81.81% <ø> (ø)` | | | [epochs_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `85.71% <ø> (ø)` | | | [estaking_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `48.64% <ø> (ø)` | | | [estaking_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `71.23% <ø> (ø)` | | | [estaking_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `63.05% <ø> (ø)` | | | [estaking_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `55.31% <ø> (ø)` | | | [incentive_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `0.00% <ø> (ø)` | | | [incentive_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [incentive_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `0.00% <ø> (ø)` | | | [incentive_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [masterchef_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `62.12% <ø> (ø)` | | | [masterchef_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `73.50% <ø> (ø)` | | | [masterchef_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `89.47% <ø> (ø)` | | | [masterchef_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `45.97% <ø> (ø)` | | | [oracle_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `31.91% <ø> (ø)` | | | [oracle_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `0.00% <ø> (ø)` | | | [oracle_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `63.88% <ø> (ø)` | | | [oracle_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `34.90% <ø> (ø)` | | | [parameter_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `15.11% <ø> (ø)` | | | [parameter_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [parameter_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `75.00% <ø> (ø)` | | | [parameter_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `60.00% <ø> (ø)` | | | [stablestake_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `73.91% <ø> (ø)` | | | [stablestake_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `75.00% <ø> (ø)` | | | [stablestake_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `71.42% <ø> (ø)` | | | [stablestake_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `13.04% <ø> (ø)` | | | [tier_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `28.57% <ø> (ø)` | | | [tier_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `100.00% <ø> (ø)` | | | [tier_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `90.47% <ø> (ø)` | | | [tier_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `19.67% <ø> (ø)` | | | [tokenomics_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `72.32% <ø> (ø)` | | | [tokenomics_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [tokenomics_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `83.33% <ø> (ø)` | | | [tokenomics_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `70.96% <ø> (ø)` | | | [transferhook_transactions](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [transferhook_lifecycle](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `∅ <ø> (∅)` | | | [transferhook_keeper](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `100.00% <ø> (ø)` | | | [transferhook_queries](https://app.codecov.io/gh/elys-network/elys/pull/759/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=elys-network) | `60.00% <ø> (ø)` | |
cosmic-vagabond commented 2 weeks ago

@cryptokage1996 can you provide test results?

amityadav0 commented 2 weeks ago

I see we are only setting stop loss value, shouldn't we add logic for stop loss trigger ? when this will trigger ?

cryptokage1996 commented 1 week ago

I see we are only setting stop loss value, shouldn't we add logic for stop loss trigger ? when this will trigger ?

  • When custody amount hits stop loss or is there any other variable ?

in the ticket it is not mentioned to close position when stop loss is hit, should i do it like we do for leveragelp @amityadav0

cosmic-vagabond commented 1 week ago

@cryptokage1996 @amityadav0 I agree without the ABCI logic for trigger the stop loss (closing of the position) it will be useful at all, is there any reason we are ommiting that part?

cryptokage1996 commented 1 week ago

@cryptokage1996 @amityadav0 I agree without the ABCI logic for trigger the stop loss (closing of the position) it will be useful at all, is there any reason we are ommiting that part?

@cosmic-vagabond there is a new ticket to implement this

cosmic-vagabond commented 1 week ago

@cryptokage1996 the software upgrade test is failing due to a module migration error see here https://github.com/elys-network/elys/actions/runs/10771967355/job/29870663829?pr=759

cryptokage1996 commented 1 week ago

@cryptokage1996 the software upgrade test is failing due to a module migration error see here https://github.com/elys-network/elys/actions/runs/10771967355/job/29870663829?pr=759

@cosmic-vagabond i dont know whats the issue here , code is fine i updated the registry and added migration from v6 to v7 it is still looking for v5 to v6 migration. i think this is issue bcoz the previous pr has migration in same module(perpetual) could be the reason , also iam not totally sure. @amityadav0 @avkr003 can your help here.is there anything iam missing? Thanks!

avkr003 commented 1 week ago

@cryptokage1996 Multiple migrations are happening here, and your code is skipping one version. err := cfg.RegisterMigration(types.ModuleName, 5, m.V6Migration) if err != nil { panic(err) } Do not remove this. And add your code next to it: err := cfg.RegisterMigration(types.ModuleName, 6, m.V7Migration) if err != nil { panic(err) }
Or, You can add code in m.V7Migration to m.V6Migration at the end and remove .V7Migration and consensus version back to 6

image