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

feat: add asset price in position query #807

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

cryptokage1996
Copy link
Contributor

@cryptokage1996 cryptokage1996 commented Sep 20, 2024

Expose price for an asset in position query
https://elys.atlassian.net/browse/DEV-1889

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 42.60%. Comparing base (aa9ced8) to head (5be2e54).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #807      +/-   ##
==========================================
- Coverage   42.63%   42.60%   -0.03%     
==========================================
  Files         672      672              
  Lines       22813    22826      +13     
==========================================
  Hits         9726     9726              
- Misses      11913    11926      +13     
  Partials     1174     1174              
Components Coverage Δ
leveragelp_transactions 92.63% <ø> (ø)
leveragelp_lifecycle 88.04% <ø> (ø)
leveragelp_keeper 86.58% <ø> (ø)
leveragelp_queries 19.28% <ø> (ø)
accountedpool_transactions 100.00% <ø> (ø)
accountedpool_lifecycle ∅ <ø> (∅)
accountedpool_queries 68.42% <ø> (ø)
amm_transactions 57.93% <ø> (ø)
amm_lifecycle 79.16% <ø> (ø)
amm_keeper 61.13% <ø> (ø)
amm_queries 29.94% <ø> (ø)
assetprofile_transactions 78.82% <ø> (ø)
assetprofile_lifecycle ∅ <ø> (∅)
assetprofile_keeper 83.33% <ø> (ø)
assetprofile_queries 47.41% <ø> (ø)
burner_transactions 0.00% <ø> (ø)
burner_lifecycle ∅ <ø> (∅)
burner_keeper 100.00% <ø> (ø)
burner_queries 63.54% <ø> (ø)
clock_transactions 30.00% <ø> (ø)
clock_lifecycle ∅ <ø> (∅)
clock_keeper 76.92% <ø> (ø)
clock_queries ∅ <ø> (∅)
commitment_transactions 48.83% <ø> (ø)
commitment_lifecycle ∅ <ø> (∅)
commitment_keeper 19.60% <ø> (ø)
commitment_queries 9.33% <ø> (ø)
epochs_transactions ∅ <ø> (∅)
epochs_lifecycle 100.00% <ø> (ø)
epochs_keeper 81.81% <ø> (ø)
epochs_queries 85.71% <ø> (ø)
estaking_transactions 48.64% <ø> (ø)
estaking_lifecycle 73.23% <ø> (ø)
estaking_keeper 63.05% <ø> (ø)
estaking_queries 55.31% <ø> (ø)
incentive_transactions 0.00% <ø> (ø)
incentive_lifecycle ∅ <ø> (∅)
incentive_keeper 0.00% <ø> (ø)
incentive_queries ∅ <ø> (∅)
masterchef_transactions 64.78% <ø> (ø)
masterchef_lifecycle 69.78% <ø> (ø)
masterchef_keeper 89.47% <ø> (ø)
masterchef_queries 45.97% <ø> (ø)
oracle_transactions 31.91% <ø> (ø)
oracle_lifecycle 0.00% <ø> (ø)
oracle_keeper 63.88% <ø> (ø)
oracle_queries 34.90% <ø> (ø)
parameter_transactions 15.11% <ø> (ø)
parameter_lifecycle ∅ <ø> (∅)
parameter_keeper 75.00% <ø> (ø)
parameter_queries 60.00% <ø> (ø)
stablestake_transactions 73.91% <ø> (ø)
stablestake_lifecycle 75.00% <ø> (ø)
stablestake_keeper 71.42% <ø> (ø)
stablestake_queries 13.04% <ø> (ø)
tier_transactions 28.57% <ø> (ø)
tier_lifecycle 100.00% <ø> (ø)
tier_keeper 90.47% <ø> (ø)
tier_queries 20.32% <ø> (ø)
tokenomics_transactions 72.32% <ø> (ø)
tokenomics_lifecycle ∅ <ø> (∅)
tokenomics_keeper 83.33% <ø> (ø)
tokenomics_queries 70.96% <ø> (ø)
transferhook_transactions ∅ <ø> (∅)
transferhook_lifecycle ∅ <ø> (∅)
transferhook_keeper 100.00% <ø> (ø)
transferhook_queries 60.00% <ø> (ø)
tradeshield_transactions 2.94% <ø> (ø)
tradeshield_lifecycle ∅ <ø> (∅)
tradeshield_keeper 75.00% <ø> (ø)
tradeshield_queries 1.80% <ø> (ø)

@cryptokage1996 cryptokage1996 marked this pull request as ready for review September 20, 2024 13:32
@cryptokage1996
Copy link
Contributor Author

mtp:
    address: elys1u8c28343vvhwgwhf29w6hlcz73hvq7lwxmrl46
    amm_pool_id: "2"
    borrow_interest_paid_collateral: "48"
    borrow_interest_paid_custody: "47"
    borrow_interest_unpaid_collateral: "19551"
    collateral: "100000000"
    collateral_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    consolidate_leverage: "0.000000000000000000"
    custody: "499999953"
    custody_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    funding_fee_paid_collateral: "0"
    funding_fee_paid_custody: "0"
    funding_fee_received_collateral: "0"
    funding_fee_received_custody: "0"
    id: "50"
    last_funding_calc_block: "9840596"
    last_funding_calc_time: "1726109566"
    last_interest_calc_block: "9840596"
    last_interest_calc_time: "1726109566"
    leverage: "5.000000000000000000"
    liabilities: "91054740"
    liabilities_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
    mtp_health: "1.310597119453523308"
    open_price: "4.390490573026091650"
    position: SHORT
    stop_loss_price: "0.000000000000000000"
    sum_collateral: "100000000"
    take_profit_borrow_rate: "1.000000000000000000"
    take_profit_custody: "27600073"
    take_profit_liabilities: "27599639"
    take_profit_price: "3.299076000000000000"
    trading_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
  trading_asset_price: "0.000004187546444214"
- mtp:
    address: elys17lwha3f5jue86hwcfdd6crpxz85j8nf8m7hg5g
    amm_pool_id: "2"
    borrow_interest_paid_collateral: "362"
    borrow_interest_paid_custody: "86"
    borrow_interest_unpaid_collateral: "145002"
    collateral: "225100635"
    collateral_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    consolidate_leverage: "3.000000000000000000"
    custody: "112214323"
    custody_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
    funding_fee_paid_collateral: "467429"
    funding_fee_paid_custody: "112326"
    funding_fee_received_collateral: "0"
    funding_fee_received_custody: "0"
    id: "26"
    last_funding_calc_block: "9840596"
    last_funding_calc_time: "1726109566"
    last_interest_calc_block: "9840596"
    last_interest_calc_time: "1726109566"
    leverage: "4.000000000000000000"
    liabilities: "675301905"
    liabilities_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    mtp_health: "0.696102509504866235"
    open_price: "8.015923724659138361"
    position: LONG
    stop_loss_price: "0.000000000000000000"
    sum_collateral: "225100635"
    take_profit_borrow_rate: "1.000000000000000000"
    take_profit_custody: "76786844"
    take_profit_liabilities: "319431108"
    take_profit_price: "8.794500000000000000"
    trading_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
  trading_asset_price: "0.000004187546444214"

@@ -167,15 +167,20 @@ func (k Keeper) GetMTPs(ctx sdk.Context, pagination *query.PageRequest) ([]*type
mtp.BorrowInterestUnpaidCollateral = k.GetBorrowInterest(ctx, &mtp, ammPool).Add(mtp.BorrowInterestUnpaidCollateral)
}

mtpList = append(mtpList, &mtp)
trading_asset_price := k.oracleKeeper.GetAssetPriceFromDenom(ctx, mtp.TradingAsset)
Copy link
Contributor

Choose a reason for hiding this comment

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

This price doesn't include decimals, is that right ?

This need to be same as stop_loss price, decimals that is when user gives input and it includes decimals, then we should multiply this value with decimals too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mtp:
    address: elys17lwha3f5jue86hwcfdd6crpxz85j8nf8m7hg5g
    amm_pool_id: "2"
    borrow_interest_paid_collateral: "362"
    borrow_interest_paid_custody: "86"
    borrow_interest_unpaid_collateral: "190202"
    collateral: "225100635"
    collateral_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    consolidate_leverage: "3.000000000000000000"
    custody: "112214323"
    custody_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
    funding_fee_paid_collateral: "467429"
    funding_fee_paid_custody: "112326"
    funding_fee_received_collateral: "0"
    funding_fee_received_custody: "0"
    id: "26"
    last_funding_calc_block: "9840596"
    last_funding_calc_time: "1726109566"
    last_interest_calc_block: "9840596"
    last_interest_calc_time: "1726109566"
    leverage: "4.000000000000000000"
    liabilities: "675301905"
    liabilities_asset: ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65
    mtp_health: "0.696055930376696467"
    open_price: "8.015923724659138361"
    position: LONG
    stop_loss_price: "0.000000000000000000"
    sum_collateral: "225100635"
    take_profit_borrow_rate: "1.000000000000000000"
    take_profit_custody: "76786844"
    take_profit_liabilities: "319431108"
    take_profit_price: "8.794500000000000000"
    trading_asset: ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4
  trading_asset_price: "4.187546444213566112"
  

@amityadav0 fixed

Copy link
Contributor

@amityadav0 amityadav0 left a comment

Choose a reason for hiding this comment

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

Please resolve a conflict

@cosmic-vagabond cosmic-vagabond merged commit 0cc4fbd into main Sep 24, 2024
1 of 2 checks passed
@cosmic-vagabond cosmic-vagabond deleted the DEV-1889-expose-price-for-an-asset branch September 24, 2024 03:47
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