Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
onikonychev committed Sep 25, 2023
1 parent 70d20f4 commit c006389
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 408 deletions.
241 changes: 14 additions & 227 deletions examples/1- Connect to nibiru py and query.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -13,18 +13,9 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "'0.21.9'"
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nibiru.__version__"
]
Expand All @@ -47,7 +38,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -65,77 +56,8 @@
},
{
"cell_type": "code",
"execution_count": 15,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"ammMarkets\": [\n",
" {\n",
" \"market\": {\n",
" \"pair\": \"ubtc:unusd\",\n",
" \"enabled\": true,\n",
" \"maintenanceMarginRatio\": 0.05,\n",
" \"maxLeverage\": 10.0,\n",
" \"latestCumulativePremiumFraction\": -2025.8005470607002,\n",
" \"exchangeFeeRatio\": 0.001,\n",
" \"ecosystemFundFeeRatio\": 0.001,\n",
" \"liquidationFeeRatio\": 0.05,\n",
" \"partialLiquidationRatio\": 0.5,\n",
" \"fundingRateEpochId\": \"30 min\",\n",
" \"twapLookbackWindow\": \"1800s\",\n",
" \"prepaidBadDebt\": {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"0\"\n",
" },\n",
" \"maxFundingRate\": \"10000000000000000\"\n",
" },\n",
" \"amm\": {\n",
" \"pair\": \"ubtc:unusd\",\n",
" \"baseReserve\": 39651725762543.484,\n",
" \"quoteReserve\": 40351333245409.98,\n",
" \"sqrtDepth\": 40000000000000.0,\n",
" \"priceMultiplier\": 25662.0,\n",
" \"totalLong\": 17225707431054.695,\n",
" \"totalShort\": 16877433193598.176\n",
" }\n",
" },\n",
" {\n",
" \"market\": {\n",
" \"pair\": \"ueth:unusd\",\n",
" \"enabled\": true,\n",
" \"maintenanceMarginRatio\": 0.05,\n",
" \"maxLeverage\": 15.0,\n",
" \"latestCumulativePremiumFraction\": 5.803715725724983,\n",
" \"exchangeFeeRatio\": 0.001,\n",
" \"ecosystemFundFeeRatio\": 0.001,\n",
" \"liquidationFeeRatio\": 0.05,\n",
" \"partialLiquidationRatio\": 0.5,\n",
" \"fundingRateEpochId\": \"30 min\",\n",
" \"twapLookbackWindow\": \"1800s\",\n",
" \"prepaidBadDebt\": {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"1005838\"\n",
" },\n",
" \"maxFundingRate\": \"10000000000000000\"\n",
" },\n",
" \"amm\": {\n",
" \"pair\": \"ueth:unusd\",\n",
" \"baseReserve\": 40668533522817.69,\n",
" \"quoteReserve\": 39342456228530.99,\n",
" \"sqrtDepth\": 40000000000000.0,\n",
" \"priceMultiplier\": 1628.58,\n",
" \"totalLong\": 15576416547771.994,\n",
" \"totalShort\": 16244950070589.68\n",
" }\n",
" }\n",
" ]\n",
"}\n"
]
}
],
"execution_count": null,
"outputs": [],
"source": [
"print(json.dumps(client.query.perp.markets(), indent=4))"
],
Expand All @@ -145,31 +67,8 @@
},
{
"cell_type": "code",
"execution_count": 16,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"ueth:unusd\": {\n",
" \"position\": {\n",
" \"trader_address\": \"nibi1jle8khj3aennq24zx6g93aam9rt0fqhgyp4h52\",\n",
" \"pair\": \"ueth:unusd\",\n",
" \"size\": 75525.89948709492,\n",
" \"margin\": 123000000.0,\n",
" \"open_notional\": 123000000.0,\n",
" \"latest_cumulative_premium_fraction\": 29.18318944237999,\n",
" \"last_updated_block_number\": 322701\n",
" },\n",
" \"position_notional\": 118989313.93739063,\n",
" \"unrealized_pnl\": -4010686.0626093773,\n",
" \"margin_ratio\": 1.0148396164626545\n",
" }\n",
"}\n"
]
}
],
"execution_count": null,
"outputs": [],
"source": [
"print(json.dumps(client.query.perp.all_positions(trader=\"nibi1jle8khj3aennq24zx6g93aam9rt0fqhgyp4h52\"), indent=4))"
],
Expand All @@ -188,139 +87,27 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"id\": \"1\",\n",
" \"address\": \"nibi1w00c7pqkr5z7ptewg5z87j2ncvxd88w43ug679\",\n",
" \"poolParams\": {\n",
" \"swapFee\": \"10000000000000000\",\n",
" \"exitFee\": \"10000000000000000\",\n",
" \"A\": \"0\"\n",
" },\n",
" \"poolAssets\": [\n",
" {\n",
" \"token\": {\n",
" \"denom\": \"unibi\",\n",
" \"amount\": \"671035023\"\n",
" },\n",
" \"weight\": \"1073741824\"\n",
" },\n",
" {\n",
" \"token\": {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"6778727934\"\n",
" },\n",
" \"weight\": \"1073741824\"\n",
" }\n",
" ],\n",
" \"totalWeight\": \"2147483648\",\n",
" \"totalShares\": {\n",
" \"denom\": \"nibiru/pool/1\",\n",
" \"amount\": \"196537289863623618511\"\n",
" }\n",
" },\n",
" {\n",
" \"id\": \"2\",\n",
" \"address\": \"nibi1vm70ju9n2laspspsh6fs2hu50z3qzf4m2emr0p\",\n",
" \"poolParams\": {\n",
" \"swapFee\": \"10000000000000000\",\n",
" \"exitFee\": \"10000000000000000\",\n",
" \"A\": \"10\",\n",
" \"poolType\": \"STABLESWAP\"\n",
" },\n",
" \"poolAssets\": [\n",
" {\n",
" \"token\": {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"12205111472\"\n",
" },\n",
" \"weight\": \"1073741824\"\n",
" },\n",
" {\n",
" \"token\": {\n",
" \"denom\": \"uusdt\",\n",
" \"amount\": \"402339760703\"\n",
" },\n",
" \"weight\": \"1073741824\"\n",
" }\n",
" ],\n",
" \"totalWeight\": \"2147483648\",\n",
" \"totalShares\": {\n",
" \"denom\": \"nibiru/pool/2\",\n",
" \"amount\": \"17287165063133703219071\"\n",
" }\n",
" }\n",
"]\n"
]
}
],
"outputs": [],
"source": [
"print(json.dumps(client.query.spot.pools(), indent=4))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"liquidity\": [\n",
" {\n",
" \"denom\": \"unibi\",\n",
" \"amount\": \"671035023\"\n",
" },\n",
" {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"6778727934\"\n",
" }\n",
" ]\n",
"}\n"
]
}
],
"outputs": [],
"source": [
"print(json.dumps(client.query.spot.total_pool_liquidity(1), indent=4))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"liquidity\": [\n",
" {\n",
" \"denom\": \"unibi\",\n",
" \"amount\": \"671035023\"\n",
" },\n",
" {\n",
" \"denom\": \"unusd\",\n",
" \"amount\": \"18983839406\"\n",
" },\n",
" {\n",
" \"denom\": \"uusdt\",\n",
" \"amount\": \"402339760703\"\n",
" }\n",
" ]\n",
"}\n"
]
}
],
"outputs": [],
"source": [
"print(json.dumps(client.query.spot.total_liquidity(), indent=4))"
]
Expand Down
Loading

0 comments on commit c006389

Please sign in to comment.