primecli 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {primecli-0.2.0 → primecli-0.2.1}/PKG-INFO +2 -2
- {primecli-0.2.0 → primecli-0.2.1}/README.md +1 -1
- {primecli-0.2.0 → primecli-0.2.1}/primecli/degenprime.py +57 -14
- {primecli-0.2.0 → primecli-0.2.1}/primecli/deltaprime.py +13 -8
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/PKG-INFO +2 -2
- {primecli-0.2.0 → primecli-0.2.1}/pyproject.toml +1 -1
- {primecli-0.2.0 → primecli-0.2.1}/LICENSE +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli/__init__.py +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/SOURCES.txt +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/dependency_links.txt +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/entry_points.txt +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/requires.txt +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/primecli.egg-info/top_level.txt +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/setup.cfg +0 -0
- {primecli-0.2.0 → primecli-0.2.1}/tests/test_redstone_encoding.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: primecli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Agent-friendly CLI tools for the DeltaPrime (Avalanche) and DegenPrime (Base) lending and leverage protocols. Preview-by-default; no Etherscan key required.
|
|
5
5
|
Author: Mnemosyne-quest contributors
|
|
6
6
|
License: MIT
|
|
@@ -138,7 +138,7 @@ Full per-command reference: [docs/deltaprime-reference.md](docs/deltaprime-refer
|
|
|
138
138
|
| Group | Commands |
|
|
139
139
|
|-------|----------|
|
|
140
140
|
| Lending core | `pool-info [--json]`, `my-positions`, `deposit`, `withdraw`, `borrow`, `repay`, `fund` |
|
|
141
|
-
| Degen Account | `create-account`, `summary`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
141
|
+
| Degen Account | `create-account`, `summary [--json]`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
142
142
|
| Swaps | `swap --from S --to S --amount N [--slippage P]` (ParaSwap v6), `swap-debt --from S --to S --amount N` |
|
|
143
143
|
| Aerodrome (read-only in v1) | `aerodrome-positions` |
|
|
144
144
|
|
|
@@ -106,7 +106,7 @@ Full per-command reference: [docs/deltaprime-reference.md](docs/deltaprime-refer
|
|
|
106
106
|
| Group | Commands |
|
|
107
107
|
|-------|----------|
|
|
108
108
|
| Lending core | `pool-info [--json]`, `my-positions`, `deposit`, `withdraw`, `borrow`, `repay`, `fund` |
|
|
109
|
-
| Degen Account | `create-account`, `summary`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
109
|
+
| Degen Account | `create-account`, `summary [--json]`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
110
110
|
| Swaps | `swap --from S --to S --amount N [--slippage P]` (ParaSwap v6), `swap-debt --from S --to S --amount N` |
|
|
111
111
|
| Aerodrome (read-only in v1) | `aerodrome-positions` |
|
|
112
112
|
|
|
@@ -694,25 +694,30 @@ def _pool_json_shape(data: dict) -> dict:
|
|
|
694
694
|
d = cfg["decimals"]
|
|
695
695
|
ts_raw, tb_raw = raw.get("totalSupply"), raw.get("totalBorrowed")
|
|
696
696
|
dr_raw, br_raw = raw.get("getDepositRate"), raw.get("getBorrowingRate")
|
|
697
|
-
ts = (ts_raw or 0) / 10**d
|
|
698
|
-
tb = (tb_raw or 0) / 10**d
|
|
699
|
-
util = (tb / ts * 100) if ts > 0 else 0.0
|
|
700
697
|
out = {
|
|
701
698
|
"symbol": cfg["symbol"],
|
|
702
699
|
"proxy": cfg["proxy"],
|
|
703
700
|
"token": cfg["token"],
|
|
704
701
|
"decimals": d,
|
|
705
|
-
"totalSupply": _compact_num(ts),
|
|
706
|
-
"totalBorrowed": _compact_num(tb),
|
|
707
|
-
"utilization": _compact_num(util),
|
|
708
702
|
}
|
|
703
|
+
# Omit any field whose multicall leg returned None (revert / decode failure).
|
|
704
|
+
# That lets a downstream consumer tell "this pool's read failed" from "this
|
|
705
|
+
# pool is at literally 0".
|
|
706
|
+
if ts_raw is not None:
|
|
707
|
+
out["totalSupply"] = _compact_num(ts_raw / 10**d)
|
|
708
|
+
if tb_raw is not None:
|
|
709
|
+
out["totalBorrowed"] = _compact_num(tb_raw / 10**d)
|
|
710
|
+
if ts_raw is not None and tb_raw is not None:
|
|
711
|
+
ts = ts_raw / 10**d
|
|
712
|
+
util = (tb_raw / 10**d / ts * 100) if ts > 0 else 0.0
|
|
713
|
+
out["utilization"] = _compact_num(util)
|
|
709
714
|
if dr_raw is not None:
|
|
710
715
|
out["depositRate"] = _compact_num(dr_raw / 1e18 * 100)
|
|
711
716
|
if br_raw is not None:
|
|
712
717
|
out["borrowingRate"] = _compact_num(br_raw / 1e18 * 100)
|
|
713
|
-
if price:
|
|
718
|
+
if price and ts_raw is not None:
|
|
714
719
|
out["tokenPrice"] = _compact_num(price, places=4)
|
|
715
|
-
out["tvl"] = _compact_num(
|
|
720
|
+
out["tvl"] = _compact_num(ts_raw / 10**d * price)
|
|
716
721
|
my_bal = raw.get("balanceOf")
|
|
717
722
|
if my_bal is not None and my_bal > 0:
|
|
718
723
|
out["myDeposit"] = _compact_num(my_bal / 10**d, places=6)
|
|
@@ -1074,7 +1079,7 @@ def _prices_usd(w3, account, symbols: list, payload: bytes) -> dict:
|
|
|
1074
1079
|
except Exception:
|
|
1075
1080
|
return {}
|
|
1076
1081
|
|
|
1077
|
-
def cmd_summary():
|
|
1082
|
+
def cmd_summary(as_json: bool = False):
|
|
1078
1083
|
"""Read-only Degen Account view: in-account collateral, debts, and live
|
|
1079
1084
|
RedStone-gated solvency (getTotalValue/getDebt/getHealthRatio/isSolvent). Falls
|
|
1080
1085
|
back to balances-only if the RedStone gateway is unreachable or a view reverts.
|
|
@@ -1082,6 +1087,12 @@ def cmd_summary():
|
|
|
1082
1087
|
feed are priced here. Symbols sourced on-chain from BaseOracle TWAP show as
|
|
1083
1088
|
balance-only (the SolvencyFacet still values them for the total/debt figures).
|
|
1084
1089
|
|
|
1090
|
+
With --json: emits a single JSON object covering wallet, account, native
|
|
1091
|
+
balance, per-asset supplied/borrowed with optional USD, total/debt/health-ratio/
|
|
1092
|
+
solvent flags. Null fields, empty lists, and empty dicts are dropped (same
|
|
1093
|
+
trim contract as `deltaprime defi --json`). Numeric 0 and boolean false are
|
|
1094
|
+
preserved.
|
|
1095
|
+
|
|
1085
1096
|
Multicall: stage A batches getAllOwnedAssets + getDebts (2 -> 1 RPC). Stage B
|
|
1086
1097
|
batches one getBalance per owned asset (N -> 1 RPC). Stage C batches the four
|
|
1087
1098
|
RedStone-gated solvency views + getPrices (4-5 -> 1 RPC), each leg carrying the
|
|
@@ -1089,14 +1100,20 @@ def cmd_summary():
|
|
|
1089
1100
|
w3 = get_w3()
|
|
1090
1101
|
acct = get_account()
|
|
1091
1102
|
pa = get_prime_account(w3, acct.address)
|
|
1092
|
-
|
|
1103
|
+
if not as_json:
|
|
1104
|
+
print(f"Wallet: {acct.address}")
|
|
1093
1105
|
if not pa:
|
|
1094
|
-
|
|
1106
|
+
if as_json:
|
|
1107
|
+
print(json.dumps({"wallet": acct.address, "account": None}, indent=2))
|
|
1108
|
+
else:
|
|
1109
|
+
print("No Degen Account yet. Create one with: degenprime create-account --execute")
|
|
1095
1110
|
return
|
|
1096
1111
|
|
|
1097
|
-
print(f"Degen Account: {pa}")
|
|
1098
1112
|
pa_eth = w3.eth.get_balance(pa) / 1e18
|
|
1099
|
-
|
|
1113
|
+
if not as_json:
|
|
1114
|
+
print(f"Degen Account: {pa}")
|
|
1115
|
+
if pa_eth >= 1e-9:
|
|
1116
|
+
print(f" Native ETH (gas): {pa_eth:.6f}")
|
|
1100
1117
|
|
|
1101
1118
|
account = w3.eth.contract(address=Web3.to_checksum_address(pa), abi=PRIME_ACCOUNT_ABI)
|
|
1102
1119
|
pa_cs = account.address
|
|
@@ -1179,6 +1196,32 @@ def cmd_summary():
|
|
|
1179
1196
|
except Exception as e:
|
|
1180
1197
|
solvency["error"] = type(e).__name__
|
|
1181
1198
|
|
|
1199
|
+
if as_json:
|
|
1200
|
+
def _asset_row(r):
|
|
1201
|
+
row = {"symbol": r["symbol"], "amount": r["raw"] / 10**r["decimals"]}
|
|
1202
|
+
usd = solvency["prices"].get(r["symbol"])
|
|
1203
|
+
if usd is not None:
|
|
1204
|
+
row["usd"] = round(row["amount"] * usd, 2)
|
|
1205
|
+
return row
|
|
1206
|
+
|
|
1207
|
+
out = {
|
|
1208
|
+
"wallet": acct.address,
|
|
1209
|
+
"account": pa,
|
|
1210
|
+
"nativeBalance": pa_eth if pa_eth >= 1e-9 else None,
|
|
1211
|
+
"supplied": [_asset_row(r) for r in supplied],
|
|
1212
|
+
"borrowed": [_asset_row(r) for r in borrowed],
|
|
1213
|
+
"totalValueUsd": solvency["total"],
|
|
1214
|
+
"debtUsd": solvency["debt"],
|
|
1215
|
+
"healthRatio": solvency["ratio"],
|
|
1216
|
+
"solvent": solvency["solvent"],
|
|
1217
|
+
"solvencyError": solvency["error"],
|
|
1218
|
+
}
|
|
1219
|
+
# Drop None / empty list / empty dict; preserve 0 and False.
|
|
1220
|
+
out = {k: v for k, v in out.items()
|
|
1221
|
+
if not (v is None or v == [] or v == {})}
|
|
1222
|
+
print(json.dumps(out, indent=2))
|
|
1223
|
+
return
|
|
1224
|
+
|
|
1182
1225
|
print(" Assets:")
|
|
1183
1226
|
if supplied:
|
|
1184
1227
|
for r in supplied:
|
|
@@ -2000,7 +2043,7 @@ def _dispatch():
|
|
|
2000
2043
|
return
|
|
2001
2044
|
cmd_create_account("--execute" in args, fund_pool, fund_amount)
|
|
2002
2045
|
elif cmd == "summary":
|
|
2003
|
-
cmd_summary()
|
|
2046
|
+
cmd_summary(as_json="--json" in args)
|
|
2004
2047
|
elif cmd == "fund":
|
|
2005
2048
|
pool, amount = None, None
|
|
2006
2049
|
execute = "--execute" in args
|
|
@@ -1118,25 +1118,30 @@ def _pool_json_shape(data: dict) -> dict:
|
|
|
1118
1118
|
d = cfg["decimals"]
|
|
1119
1119
|
ts_raw, tb_raw = raw.get("totalSupply"), raw.get("totalBorrowed")
|
|
1120
1120
|
dr_raw, br_raw = raw.get("getDepositRate"), raw.get("getBorrowingRate")
|
|
1121
|
-
ts = (ts_raw or 0) / 10**d
|
|
1122
|
-
tb = (tb_raw or 0) / 10**d
|
|
1123
|
-
util = (tb / ts * 100) if ts > 0 else 0.0
|
|
1124
1121
|
out = {
|
|
1125
1122
|
"symbol": cfg["symbol"],
|
|
1126
1123
|
"proxy": cfg["proxy"],
|
|
1127
1124
|
"token": cfg["token"],
|
|
1128
1125
|
"decimals": d,
|
|
1129
|
-
"totalSupply": _compact_num(ts),
|
|
1130
|
-
"totalBorrowed": _compact_num(tb),
|
|
1131
|
-
"utilization": _compact_num(util),
|
|
1132
1126
|
}
|
|
1127
|
+
# Omit any field whose multicall leg returned None (revert / decode failure).
|
|
1128
|
+
# Lets a downstream consumer tell "this pool's read failed" from "this pool is
|
|
1129
|
+
# at literally 0".
|
|
1130
|
+
if ts_raw is not None:
|
|
1131
|
+
out["totalSupply"] = _compact_num(ts_raw / 10**d)
|
|
1132
|
+
if tb_raw is not None:
|
|
1133
|
+
out["totalBorrowed"] = _compact_num(tb_raw / 10**d)
|
|
1134
|
+
if ts_raw is not None and tb_raw is not None:
|
|
1135
|
+
ts = ts_raw / 10**d
|
|
1136
|
+
util = (tb_raw / 10**d / ts * 100) if ts > 0 else 0.0
|
|
1137
|
+
out["utilization"] = _compact_num(util)
|
|
1133
1138
|
if dr_raw is not None:
|
|
1134
1139
|
out["depositRate"] = _compact_num(dr_raw / 1e18 * 100)
|
|
1135
1140
|
if br_raw is not None:
|
|
1136
1141
|
out["borrowingRate"] = _compact_num(br_raw / 1e18 * 100)
|
|
1137
|
-
if price:
|
|
1142
|
+
if price and ts_raw is not None:
|
|
1138
1143
|
out["tokenPrice"] = _compact_num(price, places=4)
|
|
1139
|
-
out["tvl"] = _compact_num(
|
|
1144
|
+
out["tvl"] = _compact_num(ts_raw / 10**d * price)
|
|
1140
1145
|
my_bal = raw.get("balanceOf")
|
|
1141
1146
|
if my_bal is not None and my_bal > 0:
|
|
1142
1147
|
out["myDeposit"] = _compact_num(my_bal / 10**d, places=6)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: primecli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Agent-friendly CLI tools for the DeltaPrime (Avalanche) and DegenPrime (Base) lending and leverage protocols. Preview-by-default; no Etherscan key required.
|
|
5
5
|
Author: Mnemosyne-quest contributors
|
|
6
6
|
License: MIT
|
|
@@ -138,7 +138,7 @@ Full per-command reference: [docs/deltaprime-reference.md](docs/deltaprime-refer
|
|
|
138
138
|
| Group | Commands |
|
|
139
139
|
|-------|----------|
|
|
140
140
|
| Lending core | `pool-info [--json]`, `my-positions`, `deposit`, `withdraw`, `borrow`, `repay`, `fund` |
|
|
141
|
-
| Degen Account | `create-account`, `summary`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
141
|
+
| Degen Account | `create-account`, `summary [--json]`, `withdraw-collateral`, `withdrawal-intents`, `execute-withdrawal`, `cancel-withdrawal` |
|
|
142
142
|
| Swaps | `swap --from S --to S --amount N [--slippage P]` (ParaSwap v6), `swap-debt --from S --to S --amount N` |
|
|
143
143
|
| Aerodrome (read-only in v1) | `aerodrome-positions` |
|
|
144
144
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "primecli"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Agent-friendly CLI tools for the DeltaPrime (Avalanche) and DegenPrime (Base) lending and leverage protocols. Preview-by-default; no Etherscan key required."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|