-
Notifications
You must be signed in to change notification settings - Fork 51
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
[Perpetual] net open interest was added #804
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #804 +/- ##
==========================================
+ Coverage 42.63% 42.69% +0.06%
==========================================
Files 672 673 +1
Lines 22813 22844 +31
==========================================
+ Hits 9726 9753 +27
- Misses 11913 11915 +2
- Partials 1174 1176 +2 |
@fenriz07 can you share a test result in comment of the updated CLI query thanks |
response: {
"pool": [
{
"amm_pool_id": "2",
"health": "0.883351042402733204",
"enabled": true,
"closed": false,
"borrow_interest_rate": "0.000000535466554908",
"pool_assets_long": [
{
"liabilities": "3931813932907",
"custody": "0",
"take_profit_liabilities": "3605857570107",
"take_profit_custody": "0",
"asset_balance": "1062716517114",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "0",
"custody": "563524739564",
"take_profit_liabilities": "0",
"take_profit_custody": "394720462935",
"asset_balance": "-563584155567",
"block_borrow_interest": "0",
"asset_denom": "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4"
}
],
"pool_assets_short": [
{
"liabilities": "0",
"custody": "25521549362",
"take_profit_liabilities": "0",
"take_profit_custody": "758800649",
"asset_balance": "-13515873900",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "3173650598",
"custody": "0",
"take_profit_liabilities": "758578518",
"take_profit_custody": "0",
"asset_balance": "0",
"block_borrow_interest": "0",
"asset_denom": "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4"
}
],
"last_height_borrow_interest_rate_computed": "9865471",
"funding_rate": "0.001000000000000000",
"net_open_interest": "3928640282309"
},
{
"amm_pool_id": "4",
"health": "1.000010318825890871",
"enabled": true,
"closed": false,
"borrow_interest_rate": "0.000000219967299502",
"pool_assets_long": [
{
"liabilities": "-200000000",
"custody": "0",
"take_profit_liabilities": "-186115695",
"take_profit_custody": "0",
"asset_balance": "6781429",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "0",
"custody": "0",
"take_profit_liabilities": "0",
"take_profit_custody": "-445632798",
"asset_balance": "0",
"block_borrow_interest": "0",
"asset_denom": "ibc/B4314D0E670CB43C88A5DCA09F76E5E812BD831CC2FEC6E434C9E5A9D1F57953"
}
],
"pool_assets_short": [
{
"liabilities": "0",
"custody": "0",
"take_profit_liabilities": "0",
"take_profit_custody": "0",
"asset_balance": "320805",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "0",
"custody": "0",
"take_profit_liabilities": "-1",
"take_profit_custody": "0",
"asset_balance": "0",
"block_borrow_interest": "0",
"asset_denom": "ibc/B4314D0E670CB43C88A5DCA09F76E5E812BD831CC2FEC6E434C9E5A9D1F57953"
}
],
"last_height_borrow_interest_rate_computed": "9865471",
"funding_rate": "0.000000000000000000",
"net_open_interest": "-200000000"
}
],
"pagination": { "next_key": null, "total": "0" }
} |
response: {
"pool": {
"amm_pool_id": "2",
"health": "0.883351042402733204",
"enabled": true,
"closed": false,
"borrow_interest_rate": "0.000000535466554908",
"pool_assets_long": [
{
"liabilities": "3931813932907",
"custody": "0",
"take_profit_liabilities": "3605857570107",
"take_profit_custody": "0",
"asset_balance": "1062716517114",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "0",
"custody": "563524739564",
"take_profit_liabilities": "0",
"take_profit_custody": "394720462935",
"asset_balance": "-563584155567",
"block_borrow_interest": "0",
"asset_denom": "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4"
}
],
"pool_assets_short": [
{
"liabilities": "0",
"custody": "25521549362",
"take_profit_liabilities": "0",
"take_profit_custody": "758800649",
"asset_balance": "-13515873900",
"block_borrow_interest": "0",
"asset_denom": "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
},
{
"liabilities": "3173650598",
"custody": "0",
"take_profit_liabilities": "758578518",
"take_profit_custody": "0",
"asset_balance": "0",
"block_borrow_interest": "0",
"asset_denom": "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4"
}
],
"last_height_borrow_interest_rate_computed": "9865494",
"funding_rate": "0.001000000000000000",
"net_open_interest": "3928640282309"
}
} |
assetLiabilitiesShort = assetLiabilitiesShort.Add(asset.Liabilities) | ||
} | ||
|
||
netOpenInterest := assetLiabilitiesLong.Sub(assetLiabilitiesShort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fenriz07 there is one thing that is not right and I realized we are doing it wrong with the existing update funding rate
function here https://github.com/elys-network/elys/blob/main/x/perpetual/keeper/update_funding_rate.go as well, we have to make sure that all liabilities amount that we are cumulating within assetLiabilitiesLong
and assetLiabilitiesShort
are using the same denom USDC
if not they must be swapped to USDC the same way we do here https://github.com/elys-network/elys/blob/main/x/perpetual/keeper/keeper.go
can you update both get net open interest
and update funding rate
functions to reflect that? thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this issue mentioned above will be handle as part of a separate PR, everything else looks good
Net open interest was added to the next queries